-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackend.ts
73 lines (59 loc) · 2.37 KB
/
Backend.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import "DistributionPackages/Litefyr.Distribution/Resources/Private/Fusion/Backend";
import eventListener from "Packages/Carbon/Carbon.FileLoader/Resources/Private/Assets/EventListener";
import { defaultEvent } from "Packages/Carbon/Carbon.FileLoader/Resources/Private/Assets/EventDispatcher";
import setZIndex from "./Global/zIndex";
// Don't init presentation
const initEvents = "code,disturber,slider,iCal,mautic,zammad";
eventListener("alpine:init", () => {
initEvents.split(",").forEach((type) => {
defaultEvent(`${type}:init`);
});
});
neosPlaceholderOverride();
if (document.documentElement.classList.contains("content-clip--reverse")) {
setZindexOnClippedElements();
}
function neosPlaceholderOverride() {
const observerCallback = (mutationList) => {
for (const mutation of mutationList) {
if (mutation.type !== "attributes") {
return;
}
const target = mutation.target;
const placeholderTarget = target.querySelector("[data-placeholder]");
if (!placeholderTarget) {
return;
}
const override = target.getAttribute("data-neos-placeholder-override");
const original = placeholderTarget.getAttribute("data-placeholder");
if (!original || !override || original === override) {
return;
}
console.log(`Override placeholder '${original}' with '${override}'`);
placeholderTarget.setAttribute("data-placeholder", override);
}
};
const observer = new MutationObserver(observerCallback);
const config = {
childList: true,
subtree: true,
attributes: true,
attributeOldValue: true,
attributeFilter: ["data-neos-placeholder-override"],
};
observer.observe(document.body, config);
}
function setZindexOnClippedElements() {
const observerCallback = (mutationList) => {
for (const mutation of mutationList) {
const { type, addedNodes } = mutation;
if (type == "childList" && addedNodes.length) {
setZIndex();
}
}
};
const observer = new MutationObserver(observerCallback);
const config = { childList: true };
const nodes = [...document.querySelectorAll(".neos-contentcollection")];
nodes.forEach((node) => observer.observe(node, config));
}