File tree 2 files changed +8
-2
lines changed
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ The available options are:
54
54
55
55
Note that the ` (…more) ` bit counts towards the max length – so a max length of 10 would truncate ` 1234567890 ` to ` 12 (…more) ` .
56
56
57
+ ## Customizations in this Fork
58
+
59
+ Removed extra ")" that is appended to more text. Included link prefix and suffix in max length calculation (before, was only including more text).
60
+
57
61
## Credits and license
58
62
59
63
By [ Henrik Nyh] ( http://henrik.nyh.se/ ) under the MIT license:
Original file line number Diff line number Diff line change 15
15
var content_length = $ . trim ( squeeze ( $ ( this ) . text ( ) ) ) . length ;
16
16
if ( content_length <= opts . max_length )
17
17
return ; // bail early if not overlong
18
+
19
+ // include more text, link prefix, and link suffix in max length
20
+ var actual_max_length = opts . max_length - opts . more . length - opts . link_prefix . length - opts . link_suffix . length ;
18
21
19
- var actual_max_length = opts . max_length - opts . more . length - 3 ; // 3 for " ()"
20
22
var truncated_node = recursivelyTruncate ( this , actual_max_length ) ;
21
23
var full_node = $ ( this ) . hide ( ) ;
22
24
23
25
truncated_node . insertAfter ( full_node ) ;
24
26
25
- findNodeForMore ( truncated_node ) . append ( opts . link_prefix + '<a href="#more" class="' + opts . css_more_class + '">' + opts . more + '</a>) ' + opts . link_suffix ) ;
27
+ findNodeForMore ( truncated_node ) . append ( opts . link_prefix + '<a href="#more" class="' + opts . css_more_class + '">' + opts . more + '</a>' + opts . link_suffix ) ;
26
28
findNodeForLess ( full_node ) . append ( opts . link_prefix + '<a href="#less" class="' + opts . css_less_class + '">' + opts . less + '</a>' + opts . link_suffix ) ;
27
29
28
30
truncated_node . find ( 'a:last' ) . click ( function ( ) {
You can’t perform that action at this time.
0 commit comments