Skip to content

Commit

Permalink
refactor: merge areabrick-overview-accordion.js into areabrick-overvi…
Browse files Browse the repository at this point in the history
…ew.js
  • Loading branch information
jdreesen committed Oct 25, 2024
1 parent 34ab123 commit 154bf1b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
13 changes: 0 additions & 13 deletions public/js/areabrick-overview-unpublished-toggle.js

This file was deleted.

22 changes: 17 additions & 5 deletions public/js/areabrick-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
},

});
1 change: 0 additions & 1 deletion src/EventListener/PimcoreAdminListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
}
}

0 comments on commit 154bf1b

Please sign in to comment.