mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
REFACTOR: add-archetype-class mixin (#16546)
This commit is contained in:
parent
ab1fe24241
commit
7f55c9c502
@ -5,24 +5,26 @@ import { observes, on } from "discourse-common/utils/decorators";
|
|||||||
// This is used for keeping the `body` style in sync for the background image.
|
// This is used for keeping the `body` style in sync for the background image.
|
||||||
export default {
|
export default {
|
||||||
_cleanUp() {
|
_cleanUp() {
|
||||||
$("body").removeClass((_, css) =>
|
document.body.classList.forEach((name) => {
|
||||||
(css.match(/\barchetype-\S+/g) || []).join(" ")
|
if (/\barchetype-\S+/g.test(name)) {
|
||||||
);
|
document.body.classList.remove(name);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes("archetype")
|
@observes("archetype")
|
||||||
@on("init")
|
@on("init")
|
||||||
_archetypeChanged() {
|
_archetypeChanged() {
|
||||||
const archetype = this.archetype;
|
|
||||||
this._cleanUp();
|
this._cleanUp();
|
||||||
|
|
||||||
if (archetype) {
|
if (this.archetype) {
|
||||||
$("body").addClass("archetype-" + archetype);
|
document.body.classList.add(`archetype-${this.archetype}`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
this._cleanUp();
|
this._cleanUp();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user