From 63cf403eaf39a8d33d635b72dab885eedfab6112 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sun, 23 Feb 2025 10:44:50 +0100 Subject: [PATCH] Initialize filters and export sidenav with common ones --- assets/index.js | 9 +++++---- assets/js/tools.js | 16 ---------------- templates/Entry/entries.html.twig | 4 ++-- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/assets/index.js b/assets/index.js index 7a4a27120..a8cfc4877 100755 --- a/assets/index.js +++ b/assets/index.js @@ -27,7 +27,7 @@ import './js/highlight'; /* Tools */ import { - savePercent, retrievePercent, initExport, initFilters, initPreviewText, + savePercent, retrievePercent, initPreviewText, } from './js/tools'; /* Import shortcuts */ @@ -273,7 +273,10 @@ const articleScroll = () => { $(document).ready(() => { // sidenav - $('.sidenav').sidenav(); + document.querySelectorAll('.sidenav').forEach((element) => { + $(element).sidenav({ edge: element.getAttribute('data-edge') ?? 'left' }); + }); + $('select').formSelect(); $('.collapsible[data-collapsible="accordion"]').collapsible(); $('.collapsible[data-collapsible="expandable"]').collapsible({ @@ -291,8 +294,6 @@ $(document).ready(() => { $('.tooltipped').tooltip(); $('.fixed-action-btn').floatingActionButton(); - initFilters(); - initExport(); stickyNav(); articleScroll(); initPreviewText(); diff --git a/assets/js/tools.js b/assets/js/tools.js index e8fe9d414..18528548d 100644 --- a/assets/js/tools.js +++ b/assets/js/tools.js @@ -31,20 +31,6 @@ function retrievePercent(id, resized) { return true; } -function initFilters() { - // no display if filters not available - if ($('div').is('#filters')) { - $('#filters.sidenav').sidenav({ edge: 'right' }); - } -} - -function initExport() { - // no display if export not available - if ($('div').is('#export')) { - $('#export.sidenav').sidenav({ edge: 'right' }); - } -} - function initPreviewText() { // no display if preview_text not available if ($('div').is('#preview-article')) { @@ -64,7 +50,5 @@ function initPreviewText() { export { savePercent, retrievePercent, - initExport, - initFilters, initPreviewText, }; diff --git a/templates/Entry/entries.html.twig b/templates/Entry/entries.html.twig index ea0225284..047db12ac 100644 --- a/templates/Entry/entries.html.twig +++ b/templates/Entry/entries.html.twig @@ -114,7 +114,7 @@ {% if has_exports and is_granted('EXPORT_ENTRIES') %} -
+
{% set current_tag = null %} {% if tag is defined %} {% set current_tag = tag.slug %} @@ -140,7 +140,7 @@ {% if has_filters %} -
+

{{ 'entry.filters.title'|trans }}