This commit is contained in:
Jan Faracik committed 2024-02-10 13:23:16 +00:00
1 parent 7270712249
commit 069fefbe36
2 files changed
+12 -13

No files matched your search

@@ -11,12 +11,13 @@ function init() {
1000,
(element) => {
Utils.generateDropdown(element, (instance) => {
const elements = element.nextElementSibling.content.children[0].children;
const elements =
element.nextElementSibling.content.children[0].children;
const mappedItems = Utils.convertHtmlToItems(elements);
instance.setContent(Utils.generateDropdownItems(mappedItems));
});
}
},
);
}
+9 -11
View File
@@ -142,7 +142,7 @@ function generateDropdownItems(items, compact) {
function convertHtmlToItems(children) {
const items = [];
Array.from(children).forEach(child => {
Array.from(children).forEach((child) => {
const attributes = child.dataset;
const type = child.dataset.dropdownType;
@@ -152,7 +152,7 @@ function convertHtmlToItems(children) {
label: attributes.dropdownText,
id: attributes.dropdownId,
icon: attributes.dropdownIcon,
iconXml: attributes.dropdownIcon
iconXml: attributes.dropdownIcon,
};
if (attributes.dropdownHref) {
@@ -165,15 +165,13 @@ function convertHtmlToItems(children) {
items.push(item);
break;
case "SUBMENU":
items.push(
{
type: "ITEM",
label: attributes.dropdownText,
icon: attributes.dropdownIcon,
iconXml: attributes.dropdownIcon,
subMenu: () => convertHtmlToItems(child.content.children)
}
);
items.push({
type: "ITEM",
label: attributes.dropdownText,
icon: attributes.dropdownIcon,
iconXml: attributes.dropdownIcon,
subMenu: () => convertHtmlToItems(child.content.children),
});
break;
case "SEPARATOR":
items.push({ type: type });