diff options
Diffstat (limited to 'src/Wallabag')
3 files changed, 81 insertions, 17 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 index d2bf7fb6..bf9eadef 100644 --- a/src/Wallabag/CoreBundle/Resources/public/themes/material/js/jquery.tinydot.js +++ b/src/Wallabag/CoreBundle/Resources/public/themes/material/js/jquery.tinydot.js | |||
@@ -1,14 +1,14 @@ | |||
1 | /* | 1 | /* |
2 | * jQuery tinydot 0.1 | 2 | * jQuery tinydot 0.2.0 |
3 | * | 3 | * |
4 | * Copyright (c) Alexander Danilov | 4 | * Copyright (c) Alexander Danilov |
5 | * www.modos189.ru | 5 | * modos189.ru |
6 | * | 6 | * |
7 | * Plugin repository: | 7 | * Plugin website: |
8 | * https://gitlab.com/modos189/tinydot | 8 | * tinydot.modos189.ru |
9 | * | 9 | * |
10 | * Licensed under the MIT license. | 10 | * Licensed under the MIT license. |
11 | * http://en.wikipedia.org/wiki/MIT_License | 11 | * http://en.wikipedia.org/wiki/MIT_License |
12 | */ | 12 | */ |
13 | 13 | ||
14 | (function( $, undef ) | 14 | (function( $, undef ) |
@@ -19,21 +19,85 @@ | |||
19 | } | 19 | } |
20 | 20 | ||
21 | $.fn.tinydot = function( o ) { | 21 | $.fn.tinydot = function( o ) { |
22 | var p=$(this).children('a'); | 22 | |
23 | var divh=$(this).height(); | 23 | var $dot = this; |
24 | while ($(p).outerHeight()>divh) { | 24 | $dot.child = getChildOrDie($dot); |
25 | $(p).text(function (index, text) { | 25 | $dot.orgContent = $($dot.child).html(); |
26 | return text.replace(/\W*\s(\S)*$/, '...'); | 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 | ); | ||
27 | }); | 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(); | ||
28 | } | 52 | } |
29 | } | 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 | |||
30 | })( jQuery ); | 89 | })( jQuery ); |
31 | 90 | ||
32 | jQuery(document).ready(function($) { | 91 | jQuery(document).ready(function($) { |
33 | //We only invoke jQuery.tinydot on elements that have dot-ellipsis class | 92 | //We only invoke jQuery.tinydot on elements that have dot-ellipsis class |
34 | $(".dot-ellipsis").each(function(){ | 93 | $(".dot-ellipsis").each(function(){ |
35 | var x = new Object(); | 94 | //Checking if update on window resize required |
36 | $(this).tinydot(x); | 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); | ||
37 | }); | 102 | }); |
38 | |||
39 | }); | 103 | }); |
diff --git a/src/Wallabag/CoreBundle/Resources/public/themes/material/js/jquery.tinydot.min.js b/src/Wallabag/CoreBundle/Resources/public/themes/material/js/jquery.tinydot.min.js index 32c5799f..74754629 100644 --- a/src/Wallabag/CoreBundle/Resources/public/themes/material/js/jquery.tinydot.min.js +++ b/src/Wallabag/CoreBundle/Resources/public/themes/material/js/jquery.tinydot.min.js | |||
@@ -1 +1 @@ | |||
!function(t,n){t.fn.tinydot||(t.fn.tinydot=function(n){for(var e=t(this).children("a"),i=t(this).height();t(e).outerHeight()>i;)t(e).text(function(t,n){return n.replace(/\W*\s(\S)*$/,"...")})})}(jQuery),jQuery(document).ready(function(t){t(".dot-ellipsis").each(function(){var n=new Object;t(this).tinydot(n)})}); | !function(a,b){function c(b){var c=b.children();if(0==c.length){var d=a(b).html();return b.html(""),b.append("<span />"),b.children("span").html(d)}return c[0]}function d(b){a(b.child).html(b.orgContent),e(b)}function e(b){for(var c=a(b).height();a(b.child).outerHeight()>c;)a(b.child).html(function(a,b){return b.replace(/\W*\s(\S)*$/,"...")})}a.fn.tinydot||(a.fn.tinydot=function(b){var f=this;f.child=c(f),f.orgContent=a(f.child).html(),e(f),f.watch=function(){return a(window).on("resize",function(){h&&clearInterval(h),h=setTimeout(function(){d(f)},100)}),f};var g=a.extend(!0,{},a.fn.tinydot.defaults,b),h=null;g.watch&&f.watch()},a.fn.tinydot.defaults={watch:!1})}(jQuery),jQuery(document).ready(function(a){a(".dot-ellipsis").each(function(){var b=a(this).hasClass("dot-resize-update"),c=new Object;b&&(c.watch="window"),a(this).tinydot(c)})}); | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig index 2110b889..f6941ca5 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig | |||
@@ -35,7 +35,7 @@ | |||
35 | <i class="card-title grey-text text-darken-4 activator mdi-navigation-more-horiz right"></i> | 35 | <i class="card-title grey-text text-darken-4 activator mdi-navigation-more-horiz right"></i> |
36 | {% endif %} | 36 | {% endif %} |
37 | 37 | ||
38 | <span class="card-title dot-ellipsis"><a href="{{ path('view', { 'id': entry.id }) }}" title="{{ entry.title|raw }}">{{ entry.title|striptags|raw }}</a></span> | 38 | <span class="card-title dot-ellipsis dot-resize-update"><a href="{{ path('view', { 'id': entry.id }) }}" title="{{ entry.title|raw }}">{{ entry.title|striptags|raw }}</a></span> |
39 | 39 | ||
40 | <div class="estimatedTime grey-text"> | 40 | <div class="estimatedTime grey-text"> |
41 | <span class="tool reading-time"> | 41 | <span class="tool reading-time"> |