Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show all #2

Open
LordZombi opened this issue Jan 22, 2014 · 9 comments
Open

Show all #2

LordZombi opened this issue Jan 22, 2014 · 9 comments

Comments

@LordZombi
Copy link

How can I show all text on click please ? I tried to change the height of element, but I think it needs some 'restart' after then. Can you help me ? Thankx

@dibari
Copy link
Owner

dibari commented Jan 27, 2014

You want the full text to be shown when the append text is clicked? Or, you want the full text to be shown when any of the concatenated text is clicked?

@LordZombi
Copy link
Author

Just when I click on append text would be OK.

@command-tab
Copy link

I'm running into the same issue. I have angular-ellipsis working and truncating correctly, but when I add ellipsis-append and ellipsis-append-click, I'm not sure how to "turn off" the truncation effect when I click the ellipsis-append element.

For example, here I have my section set to max-height: 150px, and when you click Read more, I remove the max-height by using ng-class:

<section
    ng-bind="description"
    ellipsis
    ellipsis-append="Read more"
    ellipsis-append-click="showFullText=true"
    ng-init="showFullText=false"
    ng-class="{'unabbreviated':showFullText}">
</section>
section {
  max-height: 150px;
}
section.unabbreviated {
  max-height: none;
}

I can observe in the Web Inspector that the unabbreviated class is being applied by Angular when I click the ellipsis-append element, so that part is working correctly, but angular-ellipsis does not then re-evaluate the element's new height and show the full text that existed before the directive was applied.

@command-tab
Copy link

I just noticed something: the above is still true, but I can trigger the re-evaluation of the height by resizing my browser just a little. So, to make the above "work", I click Read more, then resize my browser window. It's so close to perfect!

@command-tab
Copy link

I seem to have fixed this by calling buildEllipsis(); right after scope.$apply gets called, but I'm unsure if it's a good fix.

@goldylucks
Copy link

Can u share your code @commandtab ?
How do you trigger that? Did you fork the project?

@command-tab
Copy link

Sorry, I don't think I have that snippet anymore, @Adam-Goldman7. The shipping code ended up with a small directive wrapping jQuery dotdotdot, and that's been working well in production for some time.

@max-l
Copy link

max-l commented Aug 27, 2015

@commandtab, would you mind sharing your dotdotdot angular integration ?

@command-tab
Copy link

@max-l It's remarkably short. Once dotdotdot is loaded (I use RequireJS, but really any JS loader ought to work), you keep track of whether you've already applied dotdotdot to the element, and if not, apply it:

angularModule.directive('dotdotdot', [function () {
  return {
    required: 'ngBindHtml',
    restrict: 'A',
    priority: 100,
    link: function ($scope, element, attrs, ctrl) {
      $scope.isTruncated = false;
      $scope.$watch(element.html(), function (value) {
        if (!$scope.isTruncated) {
          $scope.isTruncated = true;
          element.dotdotdot();
        }
      })
    }
  };
}])

Usage might be a little different depending on if your directive's content is being trusted as HTML, but that's the basic idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants