diff --git a/public/js/areabrick-overview-unpublished-toggle.js b/public/js/areabrick-overview-unpublished-toggle.js deleted file mode 100644 index b045d94..0000000 --- a/public/js/areabrick-overview-unpublished-toggle.js +++ /dev/null @@ -1,13 +0,0 @@ -document.addEventListener('DOMContentLoaded', function () { - document.addEventListener('click', event => { - if (event.target.tagName !== 'BUTTON') { - return; - } - - const el = event.target.closest('#neusta_areabrick_config .accordion'); - - if (el) { - el.querySelectorAll('button, ul').forEach(el => el.classList.toggle('active')); - } - }); -}, { once: true }); diff --git a/public/js/areabrick-overview.js b/public/js/areabrick-overview.js index d32207e..7647bf2 100644 --- a/public/js/areabrick-overview.js +++ b/public/js/areabrick-overview.js @@ -41,16 +41,28 @@ neusta.areabrick_config.areabrick_overview = Class.create({ }.bind(this), }); - document.getElementById(this.tabId).addEventListener('click', event => { - const el = event.target.closest('#neusta_areabrick_config a[data-page-id]'); + this.handleClick('#neusta_areabrick_config a[data-page-id]', el => { + pimcore.helpers.openDocument(el.dataset.pageId, el.dataset.pageType); + }) - if (el) { - pimcore.helpers.openDocument(el.dataset.pageId, el.dataset.pageType); + this.handleClick('#neusta_areabrick_config .accordion', (el, event) => { + if (event.target.tagName === 'BUTTON') { + el.querySelectorAll('button, ul').forEach(el => el.classList.toggle('active')); } - }); + }) } return this.panel; }, + handleClick: function (selector, handler) { + document.getElementById(this.tabId).addEventListener('click', event => { + const el = event.target.closest(selector); + + if (el) { + handler(el, event); + } + }); + }, + }); diff --git a/src/EventListener/PimcoreAdminListener.php b/src/EventListener/PimcoreAdminListener.php index debc779..42e45da 100755 --- a/src/EventListener/PimcoreAdminListener.php +++ b/src/EventListener/PimcoreAdminListener.php @@ -18,7 +18,6 @@ public function addJSFiles(PathsEvent $event): void $event->addPaths([ '/bundles/neustapimcoreareabrickconfig/js/startup.js', '/bundles/neustapimcoreareabrickconfig/js/areabrick-overview.js', - '/bundles/neustapimcoreareabrickconfig/js/areabrick-overview-unpublished-toggle.js', ]); } }