Created
December 7, 2016 21:09
-
-
Save aaronbhansen/7cb706ff50a85c28609a24504b39c448 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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