diff options
Diffstat (limited to 'tpl/default')
-rw-r--r-- | tpl/default/js/shaarli.js | 103 | ||||
-rw-r--r-- | tpl/default/linklist.paging.html | 3 |
2 files changed, 71 insertions, 35 deletions
diff --git a/tpl/default/js/shaarli.js b/tpl/default/js/shaarli.js index a382a7eb..ebe0b521 100644 --- a/tpl/default/js/shaarli.js +++ b/tpl/default/js/shaarli.js | |||
@@ -56,46 +56,79 @@ function getParentByClass(el, className) { | |||
56 | /** | 56 | /** |
57 | * Fold/Expand shaares description and thumbnail. | 57 | * Fold/Expand shaares description and thumbnail. |
58 | */ | 58 | */ |
59 | var foldButtons = document.querySelectorAll('.fold-button'); | 59 | (function (window, document) { |
60 | [].forEach.call(foldButtons, function(foldButton) { | 60 | var foldAllButtons = document.getElementsByClassName('fold-all'); |
61 | // Retrieve description | 61 | var foldButtons = document.getElementsByClassName('fold-button'); |
62 | var description = null; | 62 | |
63 | var thumbnail = null; | 63 | [].forEach.call(foldButtons, function (foldButton) { |
64 | var linklistItem = getParentByClass(foldButton, 'linklist-item'); | 64 | // Retrieve description |
65 | if (linklistItem != null) { | 65 | var description = null; |
66 | description = linklistItem.querySelector('.linklist-item-description'); | 66 | var thumbnail = null; |
67 | thumbnail = linklistItem.querySelector('.linklist-item-thumbnail'); | 67 | var linklistItem = getParentByClass(foldButton, 'linklist-item'); |
68 | if (description != null || thumbnail != null) { | 68 | if (linklistItem != null) { |
69 | foldButton.style.display = 'inline'; | 69 | description = linklistItem.querySelector('.linklist-item-description'); |
70 | thumbnail = linklistItem.querySelector('.linklist-item-thumbnail'); | ||
71 | if (description != null || thumbnail != null) { | ||
72 | foldButton.style.display = 'inline'; | ||
73 | } | ||
70 | } | 74 | } |
71 | } | ||
72 | 75 | ||
73 | foldButton.addEventListener('click', function(event) { | 76 | foldButton.addEventListener('click', function (event) { |
74 | event.preventDefault(); | 77 | event.preventDefault(); |
78 | toggleFold(event.target, description, thumbnail); | ||
79 | }); | ||
80 | }); | ||
75 | 81 | ||
76 | // Switch fold/expand - up = fold | 82 | if (foldAllButtons != null) { |
77 | if (event.target.classList.contains('fa-chevron-up')) { | 83 | [].forEach.call(foldAllButtons, function (foldAllButton) { |
78 | event.target.title = 'Expand'; | 84 | foldAllButton.addEventListener('click', function (event) { |
79 | if (description != null) { | 85 | event.preventDefault(); |
80 | description.style.display = 'none'; | 86 | [].forEach.call(foldButtons, function (foldButton) { |
81 | } | 87 | // Retrieve description |
82 | if (thumbnail != null) { | 88 | var description = null; |
83 | thumbnail.style.display = 'none'; | 89 | var thumbnail = null; |
84 | } | 90 | var linklistItem = getParentByClass(foldButton, 'linklist-item'); |
91 | if (linklistItem != null) { | ||
92 | description = linklistItem.querySelector('.linklist-item-description'); | ||
93 | thumbnail = linklistItem.querySelector('.linklist-item-thumbnail'); | ||
94 | if (description != null || thumbnail != null) { | ||
95 | foldButton.style.display = 'inline'; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | toggleFold(foldButton.firstElementChild, description, thumbnail); | ||
100 | }); | ||
101 | foldAllButton.firstElementChild.classList.toggle('fa-chevron-down'); | ||
102 | foldAllButton.firstElementChild.classList.toggle('fa-chevron-up'); | ||
103 | }); | ||
104 | }); | ||
105 | } | ||
106 | })(this, this.document); | ||
107 | |||
108 | function toggleFold(button, description, thumb) | ||
109 | { | ||
110 | // Switch fold/expand - up = fold | ||
111 | if (button.classList.contains('fa-chevron-up')) { | ||
112 | button.title = 'Expand'; | ||
113 | if (description != null) { | ||
114 | description.style.display = 'none'; | ||
85 | } | 115 | } |
86 | else { | 116 | if (thumb != null) { |
87 | event.target.title = 'Fold'; | 117 | thumb.style.display = 'none'; |
88 | if (description != null) { | ||
89 | description.style.display = 'block'; | ||
90 | } | ||
91 | if (thumbnail != null) { | ||
92 | thumbnail.style.display = 'block'; | ||
93 | } | ||
94 | } | 118 | } |
95 | event.target.classList.toggle('fa-chevron-down'); | 119 | } |
96 | event.target.classList.toggle('fa-chevron-up'); | 120 | else { |
97 | }); | 121 | button.title = 'Fold'; |
98 | }); | 122 | if (description != null) { |
123 | description.style.display = 'block'; | ||
124 | } | ||
125 | if (thumb != null) { | ||
126 | thumb.style.display = 'block'; | ||
127 | } | ||
128 | } | ||
129 | button.classList.toggle('fa-chevron-down'); | ||
130 | button.classList.toggle('fa-chevron-up'); | ||
131 | } | ||
99 | 132 | ||
100 | /** | 133 | /** |
101 | * Confirmation message before deletion. | 134 | * Confirmation message before deletion. |
diff --git a/tpl/default/linklist.paging.html b/tpl/default/linklist.paging.html index 0b71c9d2..a48f4c18 100644 --- a/tpl/default/linklist.paging.html +++ b/tpl/default/linklist.paging.html | |||
@@ -13,6 +13,9 @@ | |||
13 | class={if="$privateonly"}"filter-on"{else}"filter-off"{/if} | 13 | class={if="$privateonly"}"filter-on"{else}"filter-off"{/if} |
14 | ><i class="fa fa-key"></i></a> | 14 | ><i class="fa fa-key"></i></a> |
15 | {/if} | 15 | {/if} |
16 | <a href="#" class="filter-off fold-all" title="Fold all"> | ||
17 | <i class="fa fa-chevron-up"></i> | ||
18 | </a> | ||
16 | {loop="$action_plugin"} | 19 | {loop="$action_plugin"} |
17 | {$value.attr.class=isset($value.attr.class) ? $value.attr.class : ''} | 20 | {$value.attr.class=isset($value.attr.class) ? $value.attr.class : ''} |
18 | {$value.attr.class=!empty($value.on) ? $value.attr.class .' filter-on' : $value.attr.class .' filter-off'} | 21 | {$value.attr.class=!empty($value.on) ? $value.attr.class .' filter-on' : $value.attr.class .' filter-off'} |