This commit is contained in:
Mirco Wittrien 2021-03-12 12:17:27 +01:00
parent c3e3f896fc
commit 983936dfca
3 changed files with 20 additions and 16 deletions

View File

@ -1505,14 +1505,8 @@ module.exports = (_ => {
text = typeof text == "function" ? text() : text;
if (typeof text != "string" && !BDFDB.ReactUtils.isValidElement(text) && !BDFDB.ObjectUtils.is(config.guild)) return null;
let id = BDFDB.NumberUtils.generateId(Tooltips);
let zIndexed = typeof config.zIndex == "number";
let zIndexed = config.zIndex && typeof config.zIndex == "number";
let itemLayer = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS.itemlayer + BDFDB.disCN.itemlayerdisabledpointerevents}"><div class="${BDFDB.disCN.tooltip}" tooltip-id="${id}"><div class="${BDFDB.disCN.tooltippointer}"></div><div class="${BDFDB.disCN.tooltipcontent}"></div></div></div>`);
if (zIndexed) {
let itemLayerContainerClone = itemLayerContainer.cloneNode();
itemLayerContainerClone.style.setProperty("z-index", config.zIndex || 1002, "important");
itemLayerContainer.parentElement.insertBefore(itemLayerContainerClone, itemLayerContainer.nextElementSibling);
itemLayerContainer = itemLayerContainerClone;
}
itemLayerContainer.appendChild(itemLayer);
let tooltip = itemLayer.firstElementChild;
@ -1538,10 +1532,12 @@ module.exports = (_ => {
style = (style ? (style + " ") : "") + `background: ${backgroundColor} !important; border-color: ${backgroundColorIsGradient ? BDFDB.ColorUtils.convert(config.backgroundColor[type == "left" ? 100 : 0], "RGBA") : backgroundColor} !important;`;
}
if (style) tooltip.style = style;
const zIndexed = config.zIndex && typeof config.zIndex == "number";
if (zIndexed) {
itemLayer.style.setProperty("z-index", config.zIndex || 1002, "important");
tooltip.style.setProperty("z-index", config.zIndex || 1002, "important");
tooltipContent.style.setProperty("z-index", config.zIndex || 1002, "important");
itemLayer.style.setProperty("z-index", config.zIndex, "important");
tooltip.style.setProperty("z-index", config.zIndex, "important");
tooltipContent.style.setProperty("z-index", config.zIndex, "important");
BDFDB.DOMUtils.addClass(itemLayerContainer, BDFDB.disCN.itemlayercontainerzindexdisabled);
}
if (typeof config.width == "number" && config.width > 196) {
tooltip.style.setProperty("width", `${config.width}px`, "important");
@ -1560,7 +1556,7 @@ module.exports = (_ => {
let parent = e.target.parentElement.querySelector(":hover");
if (parent && anker != parent && !anker.contains(parent)) itemLayer.removeTooltip();
};
let mouseLeave = e => {itemLayer.removeTooltip();};
let mouseLeave = e => itemLayer.removeTooltip();
if (!config.perssist) {
document.addEventListener("mousemove", mouseMove);
document.addEventListener("mouseleave", mouseLeave);
@ -1655,7 +1651,7 @@ module.exports = (_ => {
BDFDB.DOMUtils.remove(itemLayer);
BDFDB.ArrayUtils.remove(Tooltips, id);
observer.disconnect();
if (zIndexed) BDFDB.DOMUtils.remove(itemLayerContainer);
if (zIndexed) BDFDB.DOMUtils.removeClass(itemLayerContainer, BDFDB.disCN.itemlayercontainerzindexdisabled);
if (typeof config.onHide == "function") config.onHide(itemLayer, anker);
});
(tooltip.update = itemLayer.update = newText => {

View File

@ -557,6 +557,11 @@
"inputNumberWrapper": "numberInputWrapper-j4svZS",
"inputNumberWrapperDefault": "numberInputWrapperDefault-gRxcuK numberInputWrapper-j4svZS",
"inputNumberWrapperMini": "numberInputWrapperMini-wtUU31 numberInputWrapper-j4svZS",
"layerContainerZIndexDisabled": "zIndexDisabled-Pf4Txx",
"listInput": "listInput-11g5Sr",
"listInputDelete": "delete-M_nPTt",
"listInputItem": "item-wGC8aX",
"listInputItems": "items-D9PGwH",
"listRow": "listRow-7SfZww",
"loadingIcon": "loadingIcon-cOYMPl",
"loadingIconWrapper": "loadingIconWrapper-PsVJ9m",
@ -573,10 +578,6 @@
"paginationTop": "top-v-18jZ",
"popoutWrapper": "popout-xwjvsX",
"quickSelectWrapper": "quickSelectWrapper-UCfTKz",
"listInput": "listInput-11g5Sr",
"listInputDelete": "delete-M_nPTt",
"listInputItem": "item-wGC8aX",
"listInputItems": "items-D9PGwH",
"marginLeft4": "marginLeft4-58StzA",
"marginLeft8": "marginLeft8-3RhhAa",
"menuColorCustom": "colorCustom-44asd2",
@ -2032,6 +2033,7 @@
"imagezoom": ["ImageWrapper", "imageZoom"],
"itemlayer": ["ItemLayerContainer", "layer"],
"itemlayercontainer": ["ItemLayerContainer", "layerContainer"],
"itemlayercontainerzindexdisabled": ["BDFDB", "layerContainerZIndexDisabled"],
"itemlayerdisabledpointerevents": ["ItemLayerContainer", "disabledPointerEvents"],
"input": ["Input", "input"],
"inputdefault": ["Input", "inputDefault"],

View File

@ -8,6 +8,12 @@ img:not([src]), img[src=""], img[src="null"] {
opacity: 0;
}
[REPLACE_CLASS_itemlayercontainerzindexdisabled] {
z-index: unset;
}
[REPLACE_CLASS_itemlayercontainerzindexdisabled] > * {
z-index: 1002;
}
[REPLACE_CLASS_itemlayer] ~ [REPLACE_CLASS_itemlayer] [REPLACE_CLASS_menu] {
z-index: 1001;
}