aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Resources/public/themes/material/js/jquery.tinydot.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Resources/public/themes/material/js/jquery.tinydot.js')
-rw-r--r--src/Wallabag/CoreBundle/Resources/public/themes/material/js/jquery.tinydot.js103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Resources/public/themes/material/js/jquery.tinydot.js b/src/Wallabag/CoreBundle/Resources/public/themes/material/js/jquery.tinydot.js
new file mode 100644
index 00000000..bf9eadef
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/public/themes/material/js/jquery.tinydot.js
@@ -0,0 +1,103 @@
1/*
2 * jQuery tinydot 0.2.0
3 *
4 * Copyright (c) Alexander Danilov
5 * modos189.ru
6 *
7 * Plugin website:
8 * tinydot.modos189.ru
9 *
10 * Licensed under the MIT license.
11 * http://en.wikipedia.org/wiki/MIT_License
12 */
13
14(function( $, undef )
15{
16 if ( $.fn.tinydot )
17 {
18 return;
19 }
20
21 $.fn.tinydot = function( o ) {
22
23 var $dot = this;
24 $dot.child = getChildOrDie($dot);
25 $dot.orgContent = $($dot.child).html();
26 ellipsis( $dot );
27
28 $dot.watch = function()
29 {
30 $(window).on('resize', function(){
31 if ( watchInt )
32 {
33 clearInterval( watchInt );
34 }
35 watchInt = setTimeout(
36 function()
37 {
38 reinitialize($dot);
39 }, 100
40 );
41 });
42
43 return $dot;
44 };
45
46 var opts = $.extend( true, {}, $.fn.tinydot.defaults, o ),
47 watchInt = null;
48
49 if ( opts.watch )
50 {
51 $dot.watch();
52 }
53 }
54
55 // public
56 $.fn.tinydot.defaults = {
57 'watch' : false
58 };
59
60 function getChildOrDie( $elem )
61 {
62 var childrens = $elem.children();
63 if (childrens.length == 0) {
64 // create children
65 var data = $($elem).html();
66 $elem.html('');
67 $elem.append('<span />');
68 return $elem.children('span').html(data);
69 } else {
70 return childrens[0];
71 }
72 }
73
74 function reinitialize( $elem )
75 {
76 $($elem.child).html($elem.orgContent);
77 ellipsis( $elem );
78 }
79
80 function ellipsis( $elem ) {
81 var divh=$($elem).height();
82 while ($($elem.child).outerHeight()>divh) {
83 $($elem.child).html(function (index, html) {
84 return html.replace(/\W*\s(\S)*$/, '...');
85 });
86 }
87 }
88
89})( jQuery );
90
91jQuery(document).ready(function($) {
92 //We only invoke jQuery.tinydot on elements that have dot-ellipsis class
93 $(".dot-ellipsis").each(function(){
94 //Checking if update on window resize required
95 var watch_window=$(this).hasClass("dot-resize-update");
96
97 //Invoking jQuery.tinydot
98 var x = new Object();
99 if (watch_window)
100 x.watch='window';
101 $(this).tinydot(x);
102 });
103});