Skip to content

Commit b3516b2

Browse files
committed
hard code the less and more text
1 parent 249b04f commit b3516b2

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

app/assets/javascripts/jquery.truncator.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
// by Henrik Nyh <http://henrik.nyh.se> 2008-02-28.
33
// Free to modify and redistribute with credit.
44

5-
(function($) {
5+
(function ($) {
66

77
var trailing_whitespace = true;
88

9-
$.fn.truncate = function(options) {
9+
$.fn.truncate = function (options) {
1010

1111
var opts = $.extend({}, $.fn.truncate.defaults, options);
12-
13-
$(this).each(function() {
12+
13+
$(this).each(function () {
1414

1515
var content_length = $.trim(squeeze($(this).text())).length;
1616
if (content_length <= opts.max_length)
@@ -22,13 +22,13 @@
2222

2323
truncated_node.insertAfter(full_node);
2424

25-
findNodeForMore(truncated_node).append(' (<a href="#show more content">'+opts.more+'</a>)');
26-
findNodeForLess(full_node).append(' (<a href="#show less content">'+opts.less+'</a>)');
25+
findNodeForMore(truncated_node).append(' (<a href="#show more content">' + '...more' + '</a>)');
26+
findNodeForLess(full_node).append(' (<a href="#show less content">' + ' less' + '</a>)');
2727

28-
truncated_node.find('a:last').click(function() {
28+
truncated_node.find('a:last').click(function () {
2929
truncated_node.hide(); full_node.show(); return false;
3030
});
31-
full_node.find('a:last').click(function() {
31+
full_node.find('a:last').click(function () {
3232
truncated_node.show(); full_node.hide(); return false;
3333
});
3434

@@ -51,7 +51,7 @@
5151
var node = $(node);
5252
var new_node = node.clone().empty();
5353
var truncatedChild;
54-
node.contents().each(function() {
54+
node.contents().each(function () {
5555
var remaining_length = max_length - new_node.text().length;
5656
if (remaining_length == 0) return; // breaks the loop
5757
truncatedChild = recursivelyTruncate(this, remaining_length);
@@ -76,14 +76,14 @@
7676
function squeeze(string) {
7777
return string.replace(/\s+/g, ' ');
7878
}
79-
79+
8080
// Finds the last, innermost block-level element
8181
function findNodeForMore(node) {
8282
var $node = $(node);
8383
var last_child = $node.children(":last");
8484
if (!last_child) return node;
8585
var display = last_child.css('display');
86-
if (!display || display=='inline') return $node;
86+
if (!display || display == 'inline') return $node;
8787
return findNodeForMore(last_child);
8888
};
8989

0 commit comments

Comments
 (0)