2016-06-30 13:21:47 +03:00
|
|
|
import $ from 'jquery';
|
|
|
|
import Mixin from 'ember-metal/mixin';
|
|
|
|
import run from 'ember-runloop';
|
2015-10-28 14:36:45 +03:00
|
|
|
|
|
|
|
// 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) => {
|
2016-06-11 19:52:36 +03:00
|
|
|
$('body').addClass(curClass);
|
2014-03-04 00:18:10 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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) => {
|
2016-06-11 19:52:36 +03:00
|
|
|
$('body').removeClass(curClass);
|
2014-03-04 00:18:10 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|