2023-04-27 19:56:56 +02:00
|
|
|
;(function() {
|
2022-12-01 10:40:36 +01:00
|
|
|
"use strict"
|
|
|
|
|
2023-04-27 19:56:56 +02:00
|
|
|
var styleSheet = document.createElement("style")
|
2022-12-01 10:40:36 +01:00
|
|
|
styleSheet.textContent = `
|
|
|
|
.modifier-card-tiny.modifier-toggle-inactive {
|
|
|
|
background: transparent;
|
|
|
|
border: 2px dashed red;
|
|
|
|
opacity:0.2;
|
|
|
|
}
|
2023-04-27 19:56:56 +02:00
|
|
|
`
|
|
|
|
document.head.appendChild(styleSheet)
|
2022-12-01 10:40:36 +01:00
|
|
|
|
|
|
|
// observe for changes in tag list
|
2023-04-27 19:56:56 +02:00
|
|
|
var observer = new MutationObserver(function(mutations) {
|
|
|
|
// mutations.forEach(function (mutation) {
|
|
|
|
if (editorModifierTagsList.childNodes.length > 0) {
|
|
|
|
ModifierToggle()
|
|
|
|
}
|
|
|
|
// })
|
2022-12-01 10:40:36 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
observer.observe(editorModifierTagsList, {
|
2023-04-28 12:20:44 +02:00
|
|
|
childList: true,
|
2022-12-01 10:40:36 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
function ModifierToggle() {
|
2023-04-27 19:56:56 +02:00
|
|
|
let overlays = document.querySelector("#editor-inputs-tags-list").querySelectorAll(".modifier-card-overlay")
|
|
|
|
overlays.forEach((i) => {
|
2022-12-01 10:40:36 +01:00
|
|
|
i.oncontextmenu = (e) => {
|
|
|
|
e.preventDefault()
|
|
|
|
|
2023-04-27 19:56:56 +02:00
|
|
|
if (i.parentElement.classList.contains("modifier-toggle-inactive")) {
|
|
|
|
i.parentElement.classList.remove("modifier-toggle-inactive")
|
|
|
|
} else {
|
|
|
|
i.parentElement.classList.add("modifier-toggle-inactive")
|
2022-12-01 10:40:36 +01:00
|
|
|
}
|
|
|
|
// refresh activeTags
|
2023-04-27 19:56:56 +02:00
|
|
|
let modifierName = i.parentElement
|
|
|
|
.getElementsByClassName("modifier-card-label")[0]
|
|
|
|
.getElementsByTagName("p")[0].dataset.fullName
|
|
|
|
activeTags = activeTags.map((obj) => {
|
2023-02-20 00:59:20 +01:00
|
|
|
if (trimModifiers(obj.name) === trimModifiers(modifierName)) {
|
2023-04-27 19:56:56 +02:00
|
|
|
return { ...obj, inactive: obj.element.classList.contains("modifier-toggle-inactive") }
|
2022-12-01 10:40:36 +01:00
|
|
|
}
|
2023-04-27 19:56:56 +02:00
|
|
|
|
|
|
|
return obj
|
|
|
|
})
|
|
|
|
document.dispatchEvent(new Event("refreshImageModifiers"))
|
2022-12-01 10:40:36 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})()
|