-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Visually truncate long bodies and quotes
- Introduce collapsing bodies and quotes which expand when you click more. - This is done through the new excerpt directive which looks to see if text is overflowing its container and appends 'More...' and 'Less ^' spans. - Watch annotation controller to see if an annotation is being edited so that excerpts can be applied to newly created and updated annotation. - Add event for threadToggleCollapse in the thread directive, and revaluate excerpts after thread expansion.
- Loading branch information
1 parent
5938e48
commit 79b6a89
Showing
7 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
###* | ||
# @ngdoc directive | ||
# @name excerpt | ||
# @restrict C | ||
# @description Checks to see if text is overflowing its container. | ||
# If so, it prepends/appends expanders/collapsers. Note, to work | ||
# the element needs a max height. | ||
### | ||
module.exports = [ '$timeout', ($timeout) -> | ||
link: (scope, elem, attr, ctrl) -> | ||
# Check for excerpts if an annotation has been created / edited. | ||
scope.$watch (-> scope.vm.editing), (editing) -> | ||
if editing | ||
elem.find('.more').remove() | ||
elem.find('.less').remove() | ||
scope.excerpt() | ||
|
||
# Check for excerpts on threadCollapseToggle event. | ||
scope.$on 'threadToggleCollapse', (value) -> | ||
scope.excerpt() | ||
|
||
do scope.excerpt = -> | ||
$timeout -> | ||
if elem.find('.more').length == 0 | ||
if elem[0].scrollHeight > elem[0].clientHeight | ||
elem.prepend angular.element '<span class="more"> More...</span>' | ||
elem.append angular.element '<span class="less"> Less ^</span>' | ||
elem.find('.more').on 'click', -> | ||
$(this).hide() | ||
elem.addClass('show-full-excerpt') | ||
elem.find('.less').on 'click', -> | ||
elem.find('.more').show() | ||
elem.removeClass('show-full-excerpt') | ||
restrict: 'C' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.excerpt { | ||
position: relative; | ||
|
||
&.show-full-excerpt { | ||
max-height: 100% !important; | ||
} | ||
|
||
.more, .less { | ||
color: rgba(189, 28, 43, 0.5); | ||
background: #fff; | ||
font-style: italic; | ||
font-family: Georgia,"Bitstream Charter","Times","Times New Roman",serif; | ||
|
||
&:hover { | ||
color: #BD1C2B; | ||
} | ||
} | ||
|
||
.more { | ||
position: absolute; | ||
bottom: 0; | ||
left: 87%; | ||
|
||
&:before { | ||
opacity: .8; | ||
content: " "; | ||
margin-left: -3em; | ||
padding-right: 40px; | ||
background: -webkit-gradient(linear, left top, right top, from(rgba(255, 255, 255, 0)), to(white), color-stop(50%, white)); | ||
background: -moz-linear-gradient(to right, rgba(255, 255, 255, 0), white 50%, white); | ||
background: -o-linear-gradient(to right, rgba(255, 255, 255, 0), white 50%, white); | ||
background: -ms-linear-gradient(to right, rgba(255, 255, 255, 0), white 50%, white); | ||
background: linear-gradient(to right, rgba(255, 255, 255, 0), white 50%, white); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters