mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FIX: Archetype class wasn't being applied on refresh
This commit is contained in:
parent
2d7b036b9a
commit
1ae625ec2e
1 changed files with 10 additions and 5 deletions
|
@ -1,21 +1,26 @@
|
||||||
|
import { on, observes } from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
// Mix this in to a view that has a `archetype` property to automatically
|
// Mix this in to a view that has a `archetype` property to automatically
|
||||||
// add it to the body as the view is entered / left / model is changed.
|
// add it to the body as the view is entered / left / model is changed.
|
||||||
// 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 {
|
||||||
_init: function() { this.get('archetype'); }.on('init'),
|
|
||||||
|
|
||||||
_cleanUp() {
|
_cleanUp() {
|
||||||
$('body').removeClass((_, css) => (css.match(/\barchetype-\S+/g) || []).join(' '));
|
$('body').removeClass((_, css) => (css.match(/\barchetype-\S+/g) || []).join(' '));
|
||||||
},
|
},
|
||||||
|
|
||||||
_archetypeChanged: function() {
|
@observes('archetype')
|
||||||
|
@on('init')
|
||||||
|
_archetypeChanged() {
|
||||||
const archetype = this.get('archetype');
|
const archetype = this.get('archetype');
|
||||||
this._cleanUp();
|
this._cleanUp();
|
||||||
|
|
||||||
if (archetype) {
|
if (archetype) {
|
||||||
$('body').addClass('archetype-' + archetype);
|
$('body').addClass('archetype-' + archetype);
|
||||||
}
|
}
|
||||||
}.observes('archetype'),
|
},
|
||||||
|
|
||||||
_willDestroyElement: function() { this._cleanUp(); }.on('willDestroyElement')
|
willDestroyElement() {
|
||||||
|
this._super();
|
||||||
|
this._cleanUp();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue