FIX: category class on body was busted (:fired:)

This commit is contained in:
Régis Hanol 2015-03-27 23:07:05 +01:00
parent acc12ffed1
commit 260b94e7e1
2 changed files with 7 additions and 11 deletions

View File

@ -2,22 +2,20 @@
// 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 {
_enterView: function() { this.get('archetype'); }.on('init'), _init: function() { this.get('archetype'); }.on('init'),
_removeClasses() { _cleanUp() {
$('body').removeClass(function(idx, css) { $('body').removeClass((_, css) => (css.match(/\barchetype-\S+/g) || []).join(' '));
return (css.match(/\barchetype-\S+/g) || []).join(' ');
});
}, },
_categoryChanged: function() { _archetypeChanged: function() {
const archetype = this.get('archetype'); const archetype = this.get('archetype');
this._removeClasses(); this._cleanUp();
if (archetype) { if (archetype) {
$('body').addClass('archetype-' + archetype); $('body').addClass('archetype-' + archetype);
} }
}.observes('archetype'), }.observes('archetype'),
_leaveView: function() { this._removeClasses(); }.on('willDestroyElement') _willDestroyElement: function() { this._cleanUp(); }.on('willDestroyElement')
}; };

View File

@ -5,9 +5,7 @@ export default {
_enterView: function() { this.get('categoryFullSlug'); }.on('init'), _enterView: function() { this.get('categoryFullSlug'); }.on('init'),
_removeClasses() { _removeClasses() {
$('body').removeClass(function(idx, css) { $('body').removeClass((_, css) => (css.match(/\bcategory-\S+/g) || []).join(' '));
return (css.match(/\bcategory-\S+/g) || []).join(' ');
});
}, },
_categoryChanged: function() { _categoryChanged: function() {