diff options
Diffstat (limited to 'tpl/default/js/shaarli.js')
-rw-r--r-- | tpl/default/js/shaarli.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tpl/default/js/shaarli.js b/tpl/default/js/shaarli.js index d8464aa4..d47c257f 100644 --- a/tpl/default/js/shaarli.js +++ b/tpl/default/js/shaarli.js | |||
@@ -84,7 +84,13 @@ window.onload = function () { | |||
84 | [].forEach.call(foldAllButtons, function (foldAllButton) { | 84 | [].forEach.call(foldAllButtons, function (foldAllButton) { |
85 | foldAllButton.addEventListener('click', function (event) { | 85 | foldAllButton.addEventListener('click', function (event) { |
86 | event.preventDefault(); | 86 | event.preventDefault(); |
87 | var state = foldAllButton.firstElementChild.getAttribute('class').indexOf('down') != -1 ? 'down' : 'up'; | ||
87 | [].forEach.call(foldButtons, function (foldButton) { | 88 | [].forEach.call(foldButtons, function (foldButton) { |
89 | if (foldButton.firstElementChild.classList.contains('fa-chevron-up') && state == 'down' | ||
90 | || foldButton.firstElementChild.classList.contains('fa-chevron-down') && state == 'up' | ||
91 | ) { | ||
92 | return; | ||
93 | } | ||
88 | // Retrieve description | 94 | // Retrieve description |
89 | var description = null; | 95 | var description = null; |
90 | var thumbnail = null; | 96 | var thumbnail = null; |
@@ -225,4 +231,32 @@ window.onload = function () { | |||
225 | anchor.style.paddingTop = 0; | 231 | anchor.style.paddingTop = 0; |
226 | } | 232 | } |
227 | } | 233 | } |
234 | |||
235 | /** | ||
236 | * Text area resizer | ||
237 | */ | ||
238 | var description = document.getElementById('lf_description'); | ||
239 | var observe = function (element, event, handler) { | ||
240 | element.addEventListener(event, handler, false); | ||
241 | }; | ||
242 | function init () { | ||
243 | function resize () { | ||
244 | description.style.height = 'auto'; | ||
245 | description.style.height = description.scrollHeight+10+'px'; | ||
246 | } | ||
247 | /* 0-timeout to get the already changed text */ | ||
248 | function delayedResize () { | ||
249 | window.setTimeout(resize, 0); | ||
250 | } | ||
251 | observe(description, 'change', resize); | ||
252 | observe(description, 'cut', delayedResize); | ||
253 | observe(description, 'paste', delayedResize); | ||
254 | observe(description, 'drop', delayedResize); | ||
255 | observe(description, 'keydown', delayedResize); | ||
256 | |||
257 | resize(); | ||
258 | } | ||
259 | if (description != null) { | ||
260 | init(); | ||
261 | } | ||
228 | }; | 262 | }; |