Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Provide events to initialize backend module JS #5390

Open
wants to merge 1 commit into
base: 9.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/JavaScript/Main.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/JavaScript/Main.min.js.map

Large diffs are not rendered by default.

135 changes: 101 additions & 34 deletions Neos.Neos/Resources/Public/JavaScript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,61 +15,79 @@ import { isNil } from "./Helper";
window.jQuery = jQuery;
window.$ = jQuery;

// init API's
Helper.init();
Configuration.init();
Notification.init();
Localization.init();

cachedFetch(Configuration.get("XliffUri")).then((xliffData) => {
if (xliffData) {
Localization.initTranslations(xliffData);
}
document.addEventListener("DOMContentLoaded", (event) => {
initialize();
});

document.addEventListener("DOMContentLoaded", (event) => {
const initialize = () => {
// init API's
Helper.init();
Configuration.init();
Notification.init();
Localization.init();

const dropDownMenuElements = document.querySelectorAll(".neos-user-menu");
dropDownMenuElements.forEach((dropDownElement) => {
new DropDownMenu(dropDownElement);
cachedFetch(Configuration.get("XliffUri")).then((xliffData) => {
if (xliffData) {
Localization.initTranslations(xliffData);
}
});

initializeMenuPanel();
initializeDropDownMenus();
initializeExpandableElements();
initializeUserMenu();
initializeUserManagement();
initializeTree();
initializeModal();
}
const initializeMenuPanel = () => {
const menuPanelElements = document.querySelectorAll(".neos-menu");
menuPanelElements.forEach((panelElement) => {
new MenuPanel(panelElement);
});
}
const initializeExpandableElements = () => {
const expandableElements = document.querySelectorAll(
"[data-neos-expandable=dropdown]"
);
expandableElements.forEach((expandableElement) => {
new DropDown(expandableElement);
});

const expandableGroupElements = document.querySelectorAll(
"[data-neos-expandable=dropdown-group]"
);
expandableGroupElements.forEach((expandableElement) => {
new DropDownGroup(expandableElement);
});
}

const initializeDropDownMenus = () => {
const dropDownMenuElements = document.querySelectorAll(".neos-user-menu");
dropDownMenuElements.forEach((dropDownElement) => {
new DropDownMenu(dropDownElement);
});
}
const initializeTree = () => {
const treeElements = document.querySelectorAll(".neos-tree-container");
treeElements.forEach((treeElement) => {
new Tree(treeElement);
});

}
const initializeModal = () => {
const modalTrigger = Array.from(
document.querySelectorAll('[data-toggle="modal"]')
document.querySelectorAll('[data-toggle="modal"]')
);
modalTrigger.forEach((_modalTrigger) => {
const modalElement = document.querySelector(
_modalTrigger.getAttribute("href")
_modalTrigger.getAttribute("href")
);
if (!isNil(modalElement)) {
new Modal(modalElement);
}
});

const expandableElements = document.querySelectorAll(
"[data-neos-expandable=dropdown]"
);
expandableElements.forEach((expandableElement) => {
new DropDown(expandableElement);
});

const expandableGroupElements = document.querySelectorAll(
"[data-neos-expandable=dropdown-group]"
);
expandableGroupElements.forEach((expandableElement) => {
new DropDownGroup(expandableElement);
});

}
const initializeUserManagement = () => {
const userModuleContainer = document.querySelector('.neos-module-administration-users');
if (!isNil(userModuleContainer)) {
Array.from(userModuleContainer.querySelectorAll('.neos-table')).forEach(
Expand All @@ -80,9 +98,58 @@ document.addEventListener("DOMContentLoaded", (event) => {
}
)
}

}
const initializeUserMenu = () => {
const userMenuContainer = document.querySelector('#neos-top-bar .neos-user-menu');
if (!isNil(userMenuContainer)) {
new UserMenu(userMenuContainer);
}
});
}

window.addEventListener(
'neos:neos:initialize',
initialize,
false
)

window.addEventListener(
'neos:neos:initialize-menu-panel',
initializeMenuPanel,
false
)

window.addEventListener(
'neos:neos:initialize-expandable-elements',
initializeExpandableElements,
false
)

window.addEventListener(
'neos:neos:initialize-drop-down-menus',
initializeDropDownMenus,
false
)

window.addEventListener(
'neos:neos:initialize-tree',
initializeTree,
false
)

window.addEventListener(
'neos:neos:initialize-modal',
initializeModal,
false
)

window.addEventListener(
'neos:neos:initialize-user-management',
initializeUserManagement,
false
)

window.addEventListener(
'neos:neos:initialize-user-menu',
initializeUserMenu,
false
)
2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/Error.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/Lite.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/Login.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/Main.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/Minimal.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/RawContentMode.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/Shortcut.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading