Skip to content

Commit b23ad56

Browse files
committed
after CR
1 parent e595ba5 commit b23ad56

File tree

5 files changed

+42
-42
lines changed

5 files changed

+42
-42
lines changed

src/bundle/Resources/public/js/scripts/admin.context.menu.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
(function (global, doc, ibexa) {
2-
const adapatItemsContainer = doc.querySelector('.ibexa-context-menu');
2+
const adaptedItemsContainer = doc.querySelector('.ibexa-context-menu');
33

4-
if (!adapatItemsContainer) {
4+
if (!adaptedItemsContainer) {
55
return;
66
}
77

88
const menuButtons = [
9-
...adapatItemsContainer.querySelectorAll(
9+
...adaptedItemsContainer.querySelectorAll(
1010
'.ibexa-context-menu__item > .ibexa-btn:not(.ibexa-btn--more), .ibexa-context-menu__item > .ibexa-split-btn',
1111
),
1212
];
13-
const popupMenuElement = adapatItemsContainer.querySelector('.ibexa-context-menu__item--more .ibexa-multilevel-popup-menu');
14-
const showPopupButton = adapatItemsContainer.querySelector('.ibexa-btn--more');
13+
const popupMenuElement = adaptedItemsContainer.querySelector('.ibexa-context-menu__item--more .ibexa-multilevel-popup-menu');
14+
const showPopupButton = adaptedItemsContainer.querySelector('.ibexa-btn--more');
1515

1616
if (!showPopupButton) {
1717
return;
1818
}
1919

2020
const adaptiveItems = new ibexa.core.AdaptiveItems({
2121
itemHiddenClass: 'ibexa-context-menu__item--hidden',
22-
container: adapatItemsContainer,
22+
container: adaptedItemsContainer,
2323
getActiveItem: () => {
24-
return adapatItemsContainer.querySelector('.ibexa-context-menu__item');
24+
return adaptedItemsContainer.querySelector('.ibexa-context-menu__item');
2525
},
2626
onAdapted: (visibleItems, hiddenItems) => {
2727
const hiddenButtonsIds = [...hiddenItems].map((item) => item.querySelector('.ibexa-btn').id);
@@ -35,11 +35,13 @@
3535
},
3636
});
3737
const clickRelatedBtn = (relatedBtnId) => {
38-
const button = doc.getElementById(relatedBtnId);
38+
const relatedBtn = doc.getElementById(relatedBtnId);
3939

40-
button.click();
40+
relatedBtn.click();
41+
};
42+
const addRelatedBtnIdToMenuItem = (itemElement, relatedBtnId) => {
43+
itemElement.dataset.relatedBtnId = relatedBtnId;
4144
};
42-
const addRelatedBtnIdToMenuItem = (itemElement, relatedBtnId) => (itemElement.dataset.relatedBtnId = relatedBtnId);
4345
const multilevelPopupMenu = new ibexa.core.MultilevelPopupMenu({
4446
container: popupMenuElement,
4547
triggerElement: showPopupButton,
@@ -127,8 +129,9 @@
127129
};
128130

129131
multilevelPopupMenu.init();
132+
130133
const topBranch = multilevelPopupMenu.generateMenu(menuTree);
131134

132135
adaptiveItems.init();
133-
adapatItemsContainer.classList.remove('ibexa-context-menu--before-adaptive-items-init');
136+
adaptedItemsContainer.classList.remove('ibexa-context-menu--before-adaptive-items-init');
134137
})(window, window.document, window.ibexa);

src/bundle/Resources/public/js/scripts/admin.multilevel.popup.menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
multilevelPopupMenusContainers.forEach((container) => {
77
const multilevelPopupMenu = new ibexa.core.MultilevelPopupMenu({
88
container,
9-
triggerElement: doc.querySelector('#asdf'),
9+
triggerElement: doc.querySelector(container.dataset.triggerElementSelector),
1010
});
1111

1212
multilevelPopupMenu.init();

src/bundle/Resources/public/js/scripts/core/multilevel.popup.menu.js

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,46 +29,43 @@
2929

3030
const itemsWithSubitems = this.container.querySelectorAll('.ibexa-popup-menu__item--has-subitems');
3131

32-
this.initBranch(
33-
this.triggerElement,
34-
topBranch,
35-
this.referenceElement,
36-
this.initialBranchPlacement,
37-
this.initialBranchFallbackPlacements,
38-
this.processBranchOnInitAfter,
39-
this.processItemOnInitAfter,
40-
);
32+
this.initBranch({
33+
triggerElement: this.triggerElement,
34+
branchElement: topBranch,
35+
referenceElement: this.referenceElement,
36+
placement: this.initialBranchPlacement,
37+
fallbackPlacements: this.initialBranchFallbackPlacements,
38+
processBranchAfter: this.processBranchOnInitAfter,
39+
processBranchItemAfter: this.processItemOnInitAfter,
40+
});
4141
this.triggerElement.branchElement = topBranch;
4242

4343
itemsWithSubitems.forEach((itemElement) => {
4444
const branchElement = itemElement.querySelector(':scope > .ibexa-multilevel-popup-menu__branch');
4545
const parentBranchElement = itemElement.closest('.ibexa-popup-menu');
4646

47-
this.initBranch(
48-
itemElement,
49-
branchElement,
50-
undefined,
51-
undefined,
52-
undefined,
53-
this.processBranchOnInitAfter,
54-
this.processItemOnInitAfter,
55-
);
47+
this.initBranch({
48+
triggerElement: itemElement,
49+
branchElement: branchElement,
50+
processBranchAfter: this.processBranchOnInitAfter,
51+
processBranchItemAfter: this.processItemOnInitAfter,
52+
});
5653

5754
itemElement.branchElement = branchElement;
5855
branchElement.itemElement = itemElement;
5956
branchElement.parentBranchElement = parentBranchElement;
6057
});
6158
}
6259

63-
initBranch(
60+
initBranch({
6461
triggerElement,
6562
branchElement,
6663
referenceElement = null,
6764
placement = 'right-start',
6865
fallbackPlacements = ['right-end', 'left-start', 'left-end'],
6966
processBranchAfter = () => {},
7067
processBranchItemAfter = () => {},
71-
) {
68+
}) {
7269
doc.body.appendChild(branchElement);
7370

7471
const isTopBranch = !triggerElement.classList.contains('ibexa-popup-menu__item');
@@ -143,7 +140,7 @@
143140
}
144141

145142
updateBranchAndParentBranchesOpenState(branchElement) {
146-
const isTopBranch = !(branchElement?.parentBranchElement ?? null);
143+
const isTopBranch = !branchElement?.parentBranchElement;
147144

148145
if (isTopBranch) {
149146
return;
@@ -265,7 +262,7 @@
265262

266263
processAfterCreated(newBranchElement, data);
267264

268-
this.initBranch(triggerElement, newBranchElement, null, placement, fallbackPlacements);
265+
this.initBranch({ triggerElement, branchElement: newBranchElement, placement, fallbackPlacements });
269266

270267
const parentBranchElement = triggerElement.closest('.ibexa-popup-menu');
271268

@@ -355,10 +352,10 @@
355352
}
356353
}
357354

358-
isOurBranch(branch) {
355+
isBranchBelongingToThisMenu(branch) {
359356
const topBranch = this.triggerElement.branchElement;
360357

361-
return !!branch && (topBranch === branch || this.isOurBranch(branch.parentBranchElement));
358+
return !!branch && (topBranch === branch || this.isBranchBelongingToThisMenu(branch.parentBranchElement));
362359
}
363360

364361
handleClickOutside(event) {
@@ -371,7 +368,7 @@
371368
const closestPopup = event.target.closest('.ibexa-popup-menu');
372369
const isPopupMenuExpanded = !topBranch.classList.contains('ibexa-popup-menu--hidden');
373370
const isClickInsideTrigger = this.triggerElement.contains(event.target);
374-
const isClickInsideOurBranch = this.isOurBranch(closestPopup);
371+
const isClickInsideOurBranch = this.isBranchBelongingToThisMenu(closestPopup);
375372

376373
if (!isPopupMenuExpanded || isClickInsideTrigger || isClickInsideOurBranch) {
377374
return;

src/bundle/Resources/public/scss/_popup-menu.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
display: none;
130130
}
131131

132-
&--no-absolute {
132+
&--initial-position {
133133
position: initial;
134134
}
135135
}

src/bundle/Resources/public/scss/_split-button.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
}
1010

1111
&__main-btn {
12-
border-top-right-radius: 0px;
13-
border-bottom-right-radius: 0px;
12+
border-top-right-radius: 0;
13+
border-bottom-right-radius: 0;
1414
}
1515

1616
&__split {
@@ -20,8 +20,8 @@
2020

2121
&__toggle-btn {
2222
margin-left: calculateRem(-1px);
23-
border-top-left-radius: 0px;
24-
border-bottom-left-radius: 0px;
23+
border-top-left-radius: 0;
24+
border-bottom-left-radius: 0;
2525

2626
.ibexa-icon {
2727
transition: all $ibexa-admin-transition-duration $ibexa-admin-transition;

0 commit comments

Comments
 (0)