jquery-dotdotdot-rails 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/lib/jquery-dotdotdot-rails.rb +1 -0
- data/lib/jquery_dotdotdot/rails.rb +8 -0
- data/lib/jquery_dotdotdot/rails/version.rb +5 -0
- data/vendor/assets/javascripts/jquery.dotdotdot.js +632 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c561f0acaf57d4e5f3dc3ab25a8a103c478d73ae
|
4
|
+
data.tar.gz: 0660a701ad139f4b21ee1f805385f13b13647c2f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bc73deaed8e4e164d9580f42b2f84700b01d30de41f110abc86e33518f0a7f56c020259d1dfe847ad4831f49df695de78781f295a0bca4b33d1fe4cb75c77f1c
|
7
|
+
data.tar.gz: 848043d9af1bcfb82eb37701f615df2b19bb0e2e89b8ff37eadf1df000ab8b97092da28efb83c91f079f2fff8af9a858046f10e852b8363f39b9b7182a6a6893
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Kinsey Durham
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
## jQuery.dotdotdot-rails
|
2
|
+
|
3
|
+
jQuery-dotdotdot-rails wraps the jQuery.dotdotdot.js library in a rails engine
|
4
|
+
for simple use with the asset pipeline provided by Rails 3.1. The gem includes
|
5
|
+
the development (non-minified) source for ease for exploration. The asset
|
6
|
+
pipeline will minify in production.
|
7
|
+
|
8
|
+
jQuery-dotdotdot.js is "an advanced cross-browser ellipsis for multiple line
|
9
|
+
content." Please see the documentation for
|
10
|
+
details(http://dotdotdot.frebsite.nl/)
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
gem 'jquery-dotdotdot-rails'
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install jquery-dotdotdot-rails
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create new Pull Request
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'jquery_dotdotdot/rails'
|
@@ -0,0 +1,632 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery dotdotdot 1.6.1
|
3
|
+
*
|
4
|
+
* Copyright (c) 2013 Fred Heusschen
|
5
|
+
* www.frebsite.nl
|
6
|
+
*
|
7
|
+
* Plugin website:
|
8
|
+
* dotdotdot.frebsite.nl
|
9
|
+
*
|
10
|
+
* Dual licensed under the MIT and GPL licenses.
|
11
|
+
* http://en.wikipedia.org/wiki/MIT_License
|
12
|
+
* http://en.wikipedia.org/wiki/GNU_General_Public_License
|
13
|
+
*/
|
14
|
+
|
15
|
+
(function( $ )
|
16
|
+
{
|
17
|
+
if ( $.fn.dotdotdot )
|
18
|
+
{
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
|
22
|
+
$.fn.dotdotdot = function( o )
|
23
|
+
{
|
24
|
+
if ( this.length == 0 )
|
25
|
+
{
|
26
|
+
if ( !o || o.debug !== false )
|
27
|
+
{
|
28
|
+
debug( true, 'No element found for "' + this.selector + '".' );
|
29
|
+
}
|
30
|
+
return this;
|
31
|
+
}
|
32
|
+
if ( this.length > 1 )
|
33
|
+
{
|
34
|
+
return this.each(
|
35
|
+
function()
|
36
|
+
{
|
37
|
+
$(this).dotdotdot( o );
|
38
|
+
}
|
39
|
+
);
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
var $dot = this;
|
44
|
+
|
45
|
+
if ( $dot.data( 'dotdotdot' ) )
|
46
|
+
{
|
47
|
+
$dot.trigger( 'destroy.dot' );
|
48
|
+
}
|
49
|
+
|
50
|
+
$dot.data( 'dotdotdot-style', $dot.attr( 'style' ) );
|
51
|
+
$dot.css( 'word-wrap', 'break-word' );
|
52
|
+
if ($dot.css( 'white-space' ) === 'nowrap')
|
53
|
+
{
|
54
|
+
$dot.css( 'white-space', 'normal' );
|
55
|
+
}
|
56
|
+
|
57
|
+
$dot.bind_events = function()
|
58
|
+
{
|
59
|
+
$dot.bind(
|
60
|
+
'update.dot',
|
61
|
+
function( e, c )
|
62
|
+
{
|
63
|
+
e.preventDefault();
|
64
|
+
e.stopPropagation();
|
65
|
+
|
66
|
+
opts.maxHeight = ( typeof opts.height == 'number' )
|
67
|
+
? opts.height
|
68
|
+
: getTrueInnerHeight( $dot );
|
69
|
+
|
70
|
+
opts.maxHeight += opts.tolerance;
|
71
|
+
|
72
|
+
if ( typeof c != 'undefined' )
|
73
|
+
{
|
74
|
+
if ( typeof c == 'string' || c instanceof HTMLElement )
|
75
|
+
{
|
76
|
+
c = $('<div />').append( c ).contents();
|
77
|
+
}
|
78
|
+
if ( c instanceof $ )
|
79
|
+
{
|
80
|
+
orgContent = c;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
$inr = $dot.wrapInner( '<div class="dotdotdot" />' ).children();
|
85
|
+
$inr.empty()
|
86
|
+
.append( orgContent.clone( true ) )
|
87
|
+
.css({
|
88
|
+
'height' : 'auto',
|
89
|
+
'width' : 'auto',
|
90
|
+
'border' : 'none',
|
91
|
+
'padding' : 0,
|
92
|
+
'margin' : 0
|
93
|
+
});
|
94
|
+
|
95
|
+
var after = false,
|
96
|
+
trunc = false;
|
97
|
+
|
98
|
+
if ( conf.afterElement )
|
99
|
+
{
|
100
|
+
after = conf.afterElement.clone( true );
|
101
|
+
conf.afterElement.remove();
|
102
|
+
}
|
103
|
+
if ( test( $inr, opts ) )
|
104
|
+
{
|
105
|
+
if ( opts.wrap == 'children' )
|
106
|
+
{
|
107
|
+
trunc = children( $inr, opts, after );
|
108
|
+
}
|
109
|
+
else
|
110
|
+
{
|
111
|
+
trunc = ellipsis( $inr, $dot, $inr, opts, after );
|
112
|
+
}
|
113
|
+
}
|
114
|
+
$inr.replaceWith( $inr.contents() );
|
115
|
+
$inr = null;
|
116
|
+
|
117
|
+
if ( $.isFunction( opts.callback ) )
|
118
|
+
{
|
119
|
+
opts.callback.call( $dot[ 0 ], trunc, orgContent );
|
120
|
+
}
|
121
|
+
|
122
|
+
conf.isTruncated = trunc;
|
123
|
+
return trunc;
|
124
|
+
}
|
125
|
+
|
126
|
+
).bind(
|
127
|
+
'isTruncated.dot',
|
128
|
+
function( e, fn )
|
129
|
+
{
|
130
|
+
e.preventDefault();
|
131
|
+
e.stopPropagation();
|
132
|
+
|
133
|
+
if ( typeof fn == 'function' )
|
134
|
+
{
|
135
|
+
fn.call( $dot[ 0 ], conf.isTruncated );
|
136
|
+
}
|
137
|
+
return conf.isTruncated;
|
138
|
+
}
|
139
|
+
|
140
|
+
).bind(
|
141
|
+
'originalContent.dot',
|
142
|
+
function( e, fn )
|
143
|
+
{
|
144
|
+
e.preventDefault();
|
145
|
+
e.stopPropagation();
|
146
|
+
|
147
|
+
if ( typeof fn == 'function' )
|
148
|
+
{
|
149
|
+
fn.call( $dot[ 0 ], orgContent );
|
150
|
+
}
|
151
|
+
return orgContent;
|
152
|
+
}
|
153
|
+
|
154
|
+
).bind(
|
155
|
+
'destroy.dot',
|
156
|
+
function( e )
|
157
|
+
{
|
158
|
+
e.preventDefault();
|
159
|
+
e.stopPropagation();
|
160
|
+
|
161
|
+
$dot.unwatch()
|
162
|
+
.unbind_events()
|
163
|
+
.empty()
|
164
|
+
.append( orgContent )
|
165
|
+
.attr( 'style', $dot.data( 'dotdotdot-style' ) )
|
166
|
+
.data( 'dotdotdot', false );
|
167
|
+
}
|
168
|
+
);
|
169
|
+
return $dot;
|
170
|
+
}; // /bind_events
|
171
|
+
|
172
|
+
$dot.unbind_events = function()
|
173
|
+
{
|
174
|
+
$dot.unbind('.dot');
|
175
|
+
return $dot;
|
176
|
+
}; // /unbind_events
|
177
|
+
|
178
|
+
$dot.watch = function()
|
179
|
+
{
|
180
|
+
$dot.unwatch();
|
181
|
+
if ( opts.watch == 'window' )
|
182
|
+
{
|
183
|
+
var $window = $(window),
|
184
|
+
_wWidth = $window.width(),
|
185
|
+
_wHeight = $window.height();
|
186
|
+
|
187
|
+
$window.bind(
|
188
|
+
'resize.dot' + conf.dotId,
|
189
|
+
function()
|
190
|
+
{
|
191
|
+
if ( _wWidth != $window.width() || _wHeight != $window.height() || !opts.windowResizeFix )
|
192
|
+
{
|
193
|
+
_wWidth = $window.width();
|
194
|
+
_wHeight = $window.height();
|
195
|
+
|
196
|
+
if ( watchInt )
|
197
|
+
{
|
198
|
+
clearInterval( watchInt );
|
199
|
+
}
|
200
|
+
watchInt = setTimeout(
|
201
|
+
function()
|
202
|
+
{
|
203
|
+
$dot.trigger( 'update.dot' );
|
204
|
+
}, 10
|
205
|
+
);
|
206
|
+
}
|
207
|
+
}
|
208
|
+
);
|
209
|
+
}
|
210
|
+
else
|
211
|
+
{
|
212
|
+
watchOrg = getSizes( $dot );
|
213
|
+
watchInt = setInterval(
|
214
|
+
function()
|
215
|
+
{
|
216
|
+
var watchNew = getSizes( $dot );
|
217
|
+
if ( watchOrg.width != watchNew.width ||
|
218
|
+
watchOrg.height != watchNew.height )
|
219
|
+
{
|
220
|
+
$dot.trigger( 'update.dot' );
|
221
|
+
watchOrg = getSizes( $dot );
|
222
|
+
}
|
223
|
+
}, 100
|
224
|
+
);
|
225
|
+
}
|
226
|
+
return $dot;
|
227
|
+
};
|
228
|
+
$dot.unwatch = function()
|
229
|
+
{
|
230
|
+
$(window).unbind( 'resize.dot' + conf.dotId );
|
231
|
+
if ( watchInt )
|
232
|
+
{
|
233
|
+
clearInterval( watchInt );
|
234
|
+
}
|
235
|
+
return $dot;
|
236
|
+
};
|
237
|
+
|
238
|
+
var orgContent = $dot.contents(),
|
239
|
+
opts = $.extend( true, {}, $.fn.dotdotdot.defaults, o ),
|
240
|
+
conf = {},
|
241
|
+
watchOrg = {},
|
242
|
+
watchInt = null,
|
243
|
+
$inr = null;
|
244
|
+
|
245
|
+
|
246
|
+
if ( !( opts.lastCharacter.remove instanceof Array ) )
|
247
|
+
{
|
248
|
+
opts.lastCharacter.remove = $.fn.dotdotdot.defaultArrays.lastCharacter.remove;
|
249
|
+
}
|
250
|
+
if ( !( opts.lastCharacter.noEllipsis instanceof Array ) )
|
251
|
+
{
|
252
|
+
opts.lastCharacter.noEllipsis = $.fn.dotdotdot.defaultArrays.lastCharacter.noEllipsis;
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
conf.afterElement = getElement( opts.after, $dot );
|
257
|
+
conf.isTruncated = false;
|
258
|
+
conf.dotId = dotId++;
|
259
|
+
|
260
|
+
|
261
|
+
$dot.data( 'dotdotdot', true )
|
262
|
+
.bind_events()
|
263
|
+
.trigger( 'update.dot' );
|
264
|
+
|
265
|
+
if ( opts.watch )
|
266
|
+
{
|
267
|
+
$dot.watch();
|
268
|
+
}
|
269
|
+
|
270
|
+
return $dot;
|
271
|
+
};
|
272
|
+
|
273
|
+
|
274
|
+
// public
|
275
|
+
$.fn.dotdotdot.defaults = {
|
276
|
+
'ellipsis' : '... ',
|
277
|
+
'wrap' : 'word',
|
278
|
+
'fallbackToLetter' : true,
|
279
|
+
'lastCharacter' : {},
|
280
|
+
'tolerance' : 0,
|
281
|
+
'callback' : null,
|
282
|
+
'after' : null,
|
283
|
+
'height' : null,
|
284
|
+
'watch' : false,
|
285
|
+
'windowResizeFix' : true,
|
286
|
+
'debug' : false
|
287
|
+
};
|
288
|
+
$.fn.dotdotdot.defaultArrays = {
|
289
|
+
'lastCharacter' : {
|
290
|
+
'remove' : [ ' ', '\u3000', ',', ';', '.', '!', '?' ],
|
291
|
+
'noEllipsis' : []
|
292
|
+
}
|
293
|
+
};
|
294
|
+
|
295
|
+
|
296
|
+
// private
|
297
|
+
var dotId = 1;
|
298
|
+
|
299
|
+
function children( $elem, o, after )
|
300
|
+
{
|
301
|
+
var $elements = $elem.children(),
|
302
|
+
isTruncated = false;
|
303
|
+
|
304
|
+
$elem.empty();
|
305
|
+
|
306
|
+
for ( var a = 0, l = $elements.length; a < l; a++ )
|
307
|
+
{
|
308
|
+
var $e = $elements.eq( a );
|
309
|
+
$elem.append( $e );
|
310
|
+
if ( after )
|
311
|
+
{
|
312
|
+
$elem.append( after );
|
313
|
+
}
|
314
|
+
if ( test( $elem, o ) )
|
315
|
+
{
|
316
|
+
$e.remove();
|
317
|
+
isTruncated = true;
|
318
|
+
break;
|
319
|
+
}
|
320
|
+
else
|
321
|
+
{
|
322
|
+
if ( after )
|
323
|
+
{
|
324
|
+
after.detach();
|
325
|
+
}
|
326
|
+
}
|
327
|
+
}
|
328
|
+
return isTruncated;
|
329
|
+
}
|
330
|
+
function ellipsis( $elem, $d, $i, o, after )
|
331
|
+
{
|
332
|
+
var $elements = $elem.contents(),
|
333
|
+
isTruncated = false;
|
334
|
+
|
335
|
+
$elem.empty();
|
336
|
+
|
337
|
+
var notx = 'table, thead, tbody, tfoot, tr, col, colgroup, object, embed, param, ol, ul, dl, blockquote, select, optgroup, option, textarea, script, style';
|
338
|
+
for ( var a = 0, l = $elements.length; a < l; a++ )
|
339
|
+
{
|
340
|
+
|
341
|
+
if ( isTruncated )
|
342
|
+
{
|
343
|
+
break;
|
344
|
+
}
|
345
|
+
|
346
|
+
var e = $elements[ a ],
|
347
|
+
$e = $(e);
|
348
|
+
|
349
|
+
if ( typeof e == 'undefined' )
|
350
|
+
{
|
351
|
+
continue;
|
352
|
+
}
|
353
|
+
|
354
|
+
$elem.append( $e );
|
355
|
+
if ( after )
|
356
|
+
{
|
357
|
+
$elem[ ( $elem.is( notx ) ) ? 'after' : 'append' ]( after );
|
358
|
+
}
|
359
|
+
if ( e.nodeType == 3 )
|
360
|
+
{
|
361
|
+
if ( test( $i, o ) )
|
362
|
+
{
|
363
|
+
isTruncated = ellipsisElement( $e, $d, $i, o, after );
|
364
|
+
}
|
365
|
+
}
|
366
|
+
else
|
367
|
+
{
|
368
|
+
isTruncated = ellipsis( $e, $d, $i, o, after );
|
369
|
+
}
|
370
|
+
|
371
|
+
if ( !isTruncated )
|
372
|
+
{
|
373
|
+
if ( after )
|
374
|
+
{
|
375
|
+
after.detach();
|
376
|
+
}
|
377
|
+
}
|
378
|
+
}
|
379
|
+
return isTruncated;
|
380
|
+
}
|
381
|
+
function ellipsisElement( $e, $d, $i, o, after )
|
382
|
+
{
|
383
|
+
var isTruncated = false,
|
384
|
+
e = $e[ 0 ];
|
385
|
+
|
386
|
+
if ( typeof e == 'undefined' )
|
387
|
+
{
|
388
|
+
return false;
|
389
|
+
}
|
390
|
+
|
391
|
+
var txt = getTextContent( e ),
|
392
|
+
space = ( txt.indexOf(' ') !== -1 ) ? ' ' : '\u3000',
|
393
|
+
separator = ( o.wrap == 'letter' ) ? '' : space,
|
394
|
+
textArr = txt.split( separator ),
|
395
|
+
position = -1,
|
396
|
+
midPos = -1,
|
397
|
+
startPos = 0,
|
398
|
+
endPos = textArr.length - 1;
|
399
|
+
|
400
|
+
while ( startPos <= endPos && !( startPos == 0 && endPos == 0 ) )
|
401
|
+
{
|
402
|
+
var m = Math.floor( ( startPos + endPos ) / 2 );
|
403
|
+
if ( m == midPos )
|
404
|
+
{
|
405
|
+
break;
|
406
|
+
}
|
407
|
+
midPos = m;
|
408
|
+
|
409
|
+
setTextContent( e, textArr.slice( 0, midPos + 1 ).join( separator ) + o.ellipsis );
|
410
|
+
|
411
|
+
if ( !test( $i, o ) )
|
412
|
+
{
|
413
|
+
position = midPos;
|
414
|
+
startPos = midPos;
|
415
|
+
}
|
416
|
+
else
|
417
|
+
{
|
418
|
+
endPos = midPos;
|
419
|
+
}
|
420
|
+
if( endPos == startPos && endPos == 0 && o.fallbackToLetter )
|
421
|
+
{
|
422
|
+
separator = '';
|
423
|
+
textArr = textArr[0].split(separator);
|
424
|
+
position = -1;
|
425
|
+
midPos = -1;
|
426
|
+
startPos = 0;
|
427
|
+
endPos = textArr.length - 1;
|
428
|
+
}
|
429
|
+
}
|
430
|
+
|
431
|
+
if ( position != -1 && !( textArr.length == 1 && textArr[ 0 ].length == 0 ) )
|
432
|
+
{
|
433
|
+
txt = addEllipsis( textArr.slice( 0, position + 1 ).join( separator ), o );
|
434
|
+
isTruncated = true;
|
435
|
+
setTextContent( e, txt );
|
436
|
+
}
|
437
|
+
else
|
438
|
+
{
|
439
|
+
var $w = $e.parent();
|
440
|
+
$e.remove();
|
441
|
+
|
442
|
+
var afterLength = ( after ) ? after.length : 0 ;
|
443
|
+
|
444
|
+
if ( $w.contents().size() > afterLength )
|
445
|
+
{
|
446
|
+
var $n = $w.contents().eq( -1 - afterLength );
|
447
|
+
isTruncated = ellipsisElement( $n, $d, $i, o, after );
|
448
|
+
}
|
449
|
+
else
|
450
|
+
{
|
451
|
+
var $p = $w.prev()
|
452
|
+
var e = $p.contents().eq( -1 )[ 0 ];
|
453
|
+
|
454
|
+
if ( typeof e != 'undefined' )
|
455
|
+
{
|
456
|
+
var txt = addEllipsis( getTextContent( e ), o );
|
457
|
+
setTextContent( e, txt );
|
458
|
+
if ( after )
|
459
|
+
{
|
460
|
+
$p.append( after );
|
461
|
+
}
|
462
|
+
$w.remove();
|
463
|
+
isTruncated = true;
|
464
|
+
}
|
465
|
+
|
466
|
+
}
|
467
|
+
}
|
468
|
+
|
469
|
+
return isTruncated;
|
470
|
+
}
|
471
|
+
function test( $i, o )
|
472
|
+
{
|
473
|
+
return $i.innerHeight() > o.maxHeight;
|
474
|
+
}
|
475
|
+
function addEllipsis( txt, o )
|
476
|
+
{
|
477
|
+
while( $.inArray( txt.slice( -1 ), o.lastCharacter.remove ) > -1 )
|
478
|
+
{
|
479
|
+
txt = txt.slice( 0, -1 );
|
480
|
+
}
|
481
|
+
if ( $.inArray( txt.slice( -1 ), o.lastCharacter.noEllipsis ) < 0 )
|
482
|
+
{
|
483
|
+
txt += o.ellipsis;
|
484
|
+
}
|
485
|
+
return txt;
|
486
|
+
}
|
487
|
+
function getSizes( $d )
|
488
|
+
{
|
489
|
+
return {
|
490
|
+
'width' : $d.innerWidth(),
|
491
|
+
'height': $d.innerHeight()
|
492
|
+
};
|
493
|
+
}
|
494
|
+
function setTextContent( e, content )
|
495
|
+
{
|
496
|
+
if ( e.innerText )
|
497
|
+
{
|
498
|
+
e.innerText = content;
|
499
|
+
}
|
500
|
+
else if ( e.nodeValue )
|
501
|
+
{
|
502
|
+
e.nodeValue = content;
|
503
|
+
}
|
504
|
+
else if (e.textContent)
|
505
|
+
{
|
506
|
+
e.textContent = content;
|
507
|
+
}
|
508
|
+
|
509
|
+
}
|
510
|
+
function getTextContent( e )
|
511
|
+
{
|
512
|
+
if ( e.innerText )
|
513
|
+
{
|
514
|
+
return e.innerText;
|
515
|
+
}
|
516
|
+
else if ( e.nodeValue )
|
517
|
+
{
|
518
|
+
return e.nodeValue;
|
519
|
+
}
|
520
|
+
else if ( e.textContent )
|
521
|
+
{
|
522
|
+
return e.textContent;
|
523
|
+
}
|
524
|
+
else
|
525
|
+
{
|
526
|
+
return "";
|
527
|
+
}
|
528
|
+
}
|
529
|
+
function getElement( e, $i )
|
530
|
+
{
|
531
|
+
if ( typeof e == 'undefined' )
|
532
|
+
{
|
533
|
+
return false;
|
534
|
+
}
|
535
|
+
if ( !e )
|
536
|
+
{
|
537
|
+
return false;
|
538
|
+
}
|
539
|
+
if ( typeof e == 'string' )
|
540
|
+
{
|
541
|
+
e = $(e, $i);
|
542
|
+
return ( e.length )
|
543
|
+
? e
|
544
|
+
: false;
|
545
|
+
}
|
546
|
+
if ( typeof e == 'object' )
|
547
|
+
{
|
548
|
+
return ( typeof e.jquery == 'undefined' )
|
549
|
+
? false
|
550
|
+
: e;
|
551
|
+
}
|
552
|
+
return false;
|
553
|
+
}
|
554
|
+
function getTrueInnerHeight( $el )
|
555
|
+
{
|
556
|
+
var h = $el.innerHeight(),
|
557
|
+
a = [ 'paddingTop', 'paddingBottom' ];
|
558
|
+
|
559
|
+
for ( var z = 0, l = a.length; z < l; z++ ) {
|
560
|
+
var m = parseInt( $el.css( a[ z ] ), 10 );
|
561
|
+
if ( isNaN( m ) )
|
562
|
+
{
|
563
|
+
m = 0;
|
564
|
+
}
|
565
|
+
h -= m;
|
566
|
+
}
|
567
|
+
return h;
|
568
|
+
}
|
569
|
+
function debug( d, m )
|
570
|
+
{
|
571
|
+
if ( !d )
|
572
|
+
{
|
573
|
+
return false;
|
574
|
+
}
|
575
|
+
if ( typeof m == 'string' )
|
576
|
+
{
|
577
|
+
m = 'dotdotdot: ' + m;
|
578
|
+
}
|
579
|
+
else
|
580
|
+
{
|
581
|
+
m = [ 'dotdotdot:', m ];
|
582
|
+
}
|
583
|
+
|
584
|
+
if ( typeof window.console != 'undefined' )
|
585
|
+
{
|
586
|
+
if ( typeof window.console.log != 'undefined' )
|
587
|
+
{
|
588
|
+
window.console.log( m );
|
589
|
+
}
|
590
|
+
}
|
591
|
+
return false;
|
592
|
+
}
|
593
|
+
|
594
|
+
|
595
|
+
// override jQuery.html
|
596
|
+
var _orgHtml = $.fn.html;
|
597
|
+
$.fn.html = function( str ) {
|
598
|
+
if ( typeof str != 'undefined' )
|
599
|
+
{
|
600
|
+
if ( this.data( 'dotdotdot' ) )
|
601
|
+
{
|
602
|
+
if ( typeof str != 'function' )
|
603
|
+
{
|
604
|
+
return this.trigger( 'update', [ str ] );
|
605
|
+
}
|
606
|
+
}
|
607
|
+
return _orgHtml.call( this, str );
|
608
|
+
}
|
609
|
+
return _orgHtml.call( this );
|
610
|
+
};
|
611
|
+
|
612
|
+
|
613
|
+
// override jQuery.text
|
614
|
+
var _orgText = $.fn.text;
|
615
|
+
$.fn.text = function( str ) {
|
616
|
+
if ( typeof str != 'undefined' )
|
617
|
+
{
|
618
|
+
if ( this.data( 'dotdotdot' ) )
|
619
|
+
{
|
620
|
+
var temp = $( '<div />' );
|
621
|
+
temp.text( str );
|
622
|
+
str = temp.html();
|
623
|
+
temp.remove();
|
624
|
+
return this.trigger( 'update', [ str ] );
|
625
|
+
}
|
626
|
+
return _orgText.call( this, str );
|
627
|
+
}
|
628
|
+
return _orgText.call( this );
|
629
|
+
};
|
630
|
+
|
631
|
+
|
632
|
+
})( jQuery );
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jquery-dotdotdot-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.6.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kinsey Durham
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Jquery Dot dot dot for the Rails asset pipeline
|
56
|
+
email:
|
57
|
+
- kinseyann505@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/jquery-dotdotdot-rails.rb
|
63
|
+
- lib/jquery_dotdotdot/rails/version.rb
|
64
|
+
- lib/jquery_dotdotdot/rails.rb
|
65
|
+
- vendor/assets/javascripts/jquery.dotdotdot.js
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
homepage: https://github.com/durhamka/jQuery-dotdotdot-rails
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.0.0
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Jquery Dot dot dot for the Rails asset pipeline
|
92
|
+
test_files: []
|