Skip to content

Commit

Permalink
Rename toggleAllBtn selector
Browse files Browse the repository at this point in the history
  • Loading branch information
bozatko committed Dec 13, 2024
1 parent c43983f commit 1228b09
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/bundle/Resources/public/js/scripts/core/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,12 @@
const multiCollapsBodies = [...doc.querySelectorAll(`[${COLLAPSE_SECTION_BODY_TAG}]`)];

const toggleMultiCollapseButton = (btn, changeToCollapseAll) => {
if (changeToCollapseAll && btn.classList.contains('label-expand-all')) {
btn.innerHTML = Translator.trans(
/*@Desc("Change collapseAll button label*/ 'product_type.edit.section.attribute_collapse_all',
{},
'ibexa_product_catalog',
);
btn.classList.remove('label-expand-all');

return;
}
if (!changeToCollapseAll) {
btn.innerHTML = Translator.trans(
/*@Desc("Change collapseAll button label*/ 'product_type.edit.section.attribute_expand_all',
{},
'ibexa_product_catalog',
);
btn.classList.add('label-expand-all');
}
const displayedText = changeToCollapseAll
? /*@Desc("Collapse all*/ 'product_type.edit.section.attribute_collapse_all'
: /*@Desc("Expand all*/ 'product_type.edit.section.attribute_expand_all';

btn.innerHTML = Translator.trans(displayedText, {}, 'ibexa_product_catalog');
btn.classList.toggle('ibexa-label-expand-all');
};

doc.querySelectorAll('.ibexa-collapse').forEach((collapseNode) => {
Expand Down Expand Up @@ -95,7 +83,7 @@
window.clearTimeout(toggleAllTimeout);

toggleAllTimeout = window.setTimeout(() => {
const isExpandingAction = btn.classList.contains('label-expand-all');
const isExpandingAction = btn.classList.contains('ibexa-label-expand-all');

handleCollapseAction(multiCollapseNode, isExpandingAction);
toggleMultiCollapseButton(btn, isExpandingAction);
Expand Down

0 comments on commit 1228b09

Please sign in to comment.