Тема и палитра CRM: обработка crm:theme (data-theme / data-pal) и запись в журнал
This commit is contained in:
@@ -232,8 +232,18 @@
|
|||||||
if (!data || typeof data !== "object") return;
|
if (!data || typeof data !== "object") return;
|
||||||
// Для теста принимаем от любого origin (решение владельца).
|
// Для теста принимаем от любого origin (решение владельца).
|
||||||
if (data.type === "crm:auth") onAuth(data, ev);
|
if (data.type === "crm:auth") onAuth(data, ev);
|
||||||
|
else if (data.type === "crm:theme") onTheme(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Тема и палитра CRM: дальше всё делают селекторы tvorymo-ui.css ([data-theme][data-pal]).
|
||||||
|
function onTheme(data) {
|
||||||
|
const theme = data.theme === "dark" ? "dark" : "light";
|
||||||
|
const pal = typeof data.palette === "string" && data.palette ? data.palette : "classic";
|
||||||
|
document.documentElement.dataset.theme = theme;
|
||||||
|
document.documentElement.dataset.pal = pal;
|
||||||
|
log("crm:theme " + theme + "/" + pal);
|
||||||
|
}
|
||||||
|
|
||||||
$("refresh").addEventListener("click", () => {
|
$("refresh").addEventListener("click", () => {
|
||||||
const target = crmSource || window.parent;
|
const target = crmSource || window.parent;
|
||||||
target.postMessage({ type: "crm:refresh" }, crmOrigin || "*");
|
target.postMessage({ type: "crm:refresh" }, crmOrigin || "*");
|
||||||
|
|||||||
Reference in New Issue
Block a user