mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Live reloading of css in development (#9859)
This commit is contained in:
committed by
GitHub
parent
793085c703
commit
f9649c92b5
@@ -43,6 +43,41 @@ export function setLocalTheme(ids, themeSeq) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function refreshCSS(node, hash, newHref) {
|
||||||
|
let $orig = $(node);
|
||||||
|
|
||||||
|
if ($orig.data("reloading")) {
|
||||||
|
clearTimeout($orig.data("timeout"));
|
||||||
|
$orig.data("copy").remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$orig.data("orig")) {
|
||||||
|
$orig.data("orig", node.href);
|
||||||
|
}
|
||||||
|
|
||||||
|
$orig.data("reloading", true);
|
||||||
|
|
||||||
|
const orig = $(node).data("orig");
|
||||||
|
|
||||||
|
let reloaded = $orig.clone(true);
|
||||||
|
if (hash) {
|
||||||
|
reloaded[0].href =
|
||||||
|
orig + (orig.indexOf("?") >= 0 ? "&hash=" : "?hash=") + hash;
|
||||||
|
} else {
|
||||||
|
reloaded[0].href = newHref;
|
||||||
|
}
|
||||||
|
|
||||||
|
$orig.after(reloaded);
|
||||||
|
|
||||||
|
let timeout = setTimeout(() => {
|
||||||
|
$orig.remove();
|
||||||
|
reloaded.data("reloading", false);
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
$orig.data("timeout", timeout);
|
||||||
|
$orig.data("copy", reloaded);
|
||||||
|
}
|
||||||
|
|
||||||
export function listThemes(site) {
|
export function listThemes(site) {
|
||||||
let themes = site.get("user_themes");
|
let themes = site.get("user_themes");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user