2022-09-25 14:19:30 +02:00
|
|
|
const registeredClasses = new Set();
|
|
|
|
|
|
|
|
function createClassForColor(color) {
|
|
|
|
if (!color?.trim()) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
const normalizedColorName = color.replace(/[^a-z0-9]/gi, "");
|
|
|
|
|
|
|
|
if (!normalizedColorName.trim()) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2022-12-21 15:19:05 +01:00
|
|
|
const className = `color-${normalizedColorName}`;
|
2022-09-25 14:19:30 +02:00
|
|
|
|
|
|
|
if (!registeredClasses.has(className)) {
|
2023-02-27 21:01:25 +01:00
|
|
|
// make the active fancytree selector more specific than the normal color setting
|
|
|
|
$("head").append(`<style>.${className}, span.fancytree-active.${className} { color: ${color} !important; }</style>`);
|
2022-09-25 14:19:30 +02:00
|
|
|
|
|
|
|
registeredClasses.add(className);
|
|
|
|
}
|
|
|
|
|
|
|
|
return className;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
createClassForColor
|
|
|
|
};
|