2015-02-13 07:22:32 +03:00
|
|
|
import Ember from 'ember';
|
2014-03-04 00:18:10 +04:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
const {Mixin, run} = Ember;
|
|
|
|
|
|
|
|
// mixin used for routes that need to set a css className on the body tag
|
|
|
|
export default Mixin.create({
|
|
|
|
activate() {
|
|
|
|
let cssClasses = this.get('classNames');
|
2014-10-25 01:09:50 +04:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
this._super(...arguments);
|
2014-03-04 00:18:10 +04:00
|
|
|
|
|
|
|
if (cssClasses) {
|
2015-10-28 14:36:45 +03:00
|
|
|
run.schedule('afterRender', null, function () {
|
|
|
|
cssClasses.forEach((curClass) => {
|
2014-03-04 00:18:10 +04:00
|
|
|
Ember.$('body').addClass(curClass);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
deactivate() {
|
|
|
|
let cssClasses = this.get('classNames');
|
2014-10-25 01:09:50 +04:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
this._super(...arguments);
|
2014-03-04 00:18:10 +04:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
run.schedule('afterRender', null, function () {
|
|
|
|
cssClasses.forEach((curClass) => {
|
2014-03-04 00:18:10 +04:00
|
|
|
Ember.$('body').removeClass(curClass);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|