Skip to content

Instantly share code, notes, and snippets.

@aaronbhansen
Created December 7, 2016 21:09
Show Gist options
  • Save aaronbhansen/7cb706ff50a85c28609a24504b39c448 to your computer and use it in GitHub Desktop.
Save aaronbhansen/7cb706ff50a85c28609a24504b39c448 to your computer and use it in GitHub Desktop.
import Ember from 'ember';
export default Ember.Mixin.create({
activate() {
this._super(...arguments);
var cssClass, root;
cssClass = this.toCssClass();
root = this.root();
if (cssClass !== 'application') {
root.addClass(cssClass);
}
if (this.get('routeClasses')) {
root.addClass(this.get('routeClasses'));
}
root.removeClass('loading-full');
if (this.removeRouteClasses) {
root.removeClass(this.removeRouteClasses);
}
},
deactivate() {
this._super(...arguments);
var root;
root = this.root();
root.removeClass(this.toCssClass());
if (this.get('routeClasses')) {
return root.removeClass(this.get('routeClasses'));
}
},
root: function() {
var element;
element = window.$('html');
if (!element.hasClass('root')) {
element.addClass('root');
}
return element;
},
toCssClass: function() {
return this.routeName.split('.').slice(-1)[0].dasherize().replace(/\-/g, ' ').replace('/', ' ');
},
actions: {
loading() {
let root = this.root();
root.addClass('loading-full');
return true;
},
didTransition() {
let root = this.root();
root.removeClass('loading-full');
return true;
},
error() {
let root = this.root();
root.removeClass('loading-full');
return true;
}
},
afterModel(/* model */) {
this._super(...arguments);
let root = this.root();
root.removeClass('loading-full');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment