From 4fae3834fdad47dc37ba8b29c29ae72b2de0e313 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 7 Jan 2017 18:12:24 +0100 Subject: [PATCH] tmp --- tpl/default/js/shaarli.js | 103 ++++++++++++++++++++----------- 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) { /** * Fold/Expand shaares description and thumbnail. */ -var foldButtons = document.querySelectorAll('.fold-button'); -[].forEach.call(foldButtons, function(foldButton) { - // Retrieve description - var description = null; - var thumbnail = null; - var linklistItem = getParentByClass(foldButton, 'linklist-item'); - if (linklistItem != null) { - description = linklistItem.querySelector('.linklist-item-description'); - thumbnail = linklistItem.querySelector('.linklist-item-thumbnail'); - if (description != null || thumbnail != null) { - foldButton.style.display = 'inline'; +(function (window, document) { + var foldAllButtons = document.getElementsByClassName('fold-all'); + var foldButtons = document.getElementsByClassName('fold-button'); + + [].forEach.call(foldButtons, function (foldButton) { + // Retrieve description + var description = null; + var thumbnail = null; + var linklistItem = getParentByClass(foldButton, 'linklist-item'); + if (linklistItem != null) { + description = linklistItem.querySelector('.linklist-item-description'); + thumbnail = linklistItem.querySelector('.linklist-item-thumbnail'); + if (description != null || thumbnail != null) { + foldButton.style.display = 'inline'; + } } - } - foldButton.addEventListener('click', function(event) { - event.preventDefault(); + foldButton.addEventListener('click', function (event) { + event.preventDefault(); + toggleFold(event.target, description, thumbnail); + }); + }); - // Switch fold/expand - up = fold - if (event.target.classList.contains('fa-chevron-up')) { - event.target.title = 'Expand'; - if (description != null) { - description.style.display = 'none'; - } - if (thumbnail != null) { - thumbnail.style.display = 'none'; - } + if (foldAllButtons != null) { + [].forEach.call(foldAllButtons, function (foldAllButton) { + foldAllButton.addEventListener('click', function (event) { + event.preventDefault(); + [].forEach.call(foldButtons, function (foldButton) { + // Retrieve description + var description = null; + var thumbnail = null; + var linklistItem = getParentByClass(foldButton, 'linklist-item'); + if (linklistItem != null) { + description = linklistItem.querySelector('.linklist-item-description'); + thumbnail = linklistItem.querySelector('.linklist-item-thumbnail'); + if (description != null || thumbnail != null) { + foldButton.style.display = 'inline'; + } + } + + toggleFold(foldButton.firstElementChild, description, thumbnail); + }); + foldAllButton.firstElementChild.classList.toggle('fa-chevron-down'); + foldAllButton.firstElementChild.classList.toggle('fa-chevron-up'); + }); + }); + } +})(this, this.document); + +function toggleFold(button, description, thumb) +{ + // Switch fold/expand - up = fold + if (button.classList.contains('fa-chevron-up')) { + button.title = 'Expand'; + if (description != null) { + description.style.display = 'none'; } - else { - event.target.title = 'Fold'; - if (description != null) { - description.style.display = 'block'; - } - if (thumbnail != null) { - thumbnail.style.display = 'block'; - } + if (thumb != null) { + thumb.style.display = 'none'; } - event.target.classList.toggle('fa-chevron-down'); - event.target.classList.toggle('fa-chevron-up'); - }); -}); + } + else { + button.title = 'Fold'; + if (description != null) { + description.style.display = 'block'; + } + if (thumb != null) { + thumb.style.display = 'block'; + } + } + button.classList.toggle('fa-chevron-down'); + button.classList.toggle('fa-chevron-up'); +} /** * 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 @@ class={if="$privateonly"}"filter-on"{else}"filter-off"{/if} > {/if} + + + {loop="$action_plugin"} {$value.attr.class=isset($value.attr.class) ? $value.attr.class : ''} {$value.attr.class=!empty($value.on) ? $value.attr.class .' filter-on' : $value.attr.class .' filter-off'} -- 2.41.0