FEATURE: add 'navigation-categories' class on 'body' when visiting /categories

This commit is contained in:
Régis Hanol 2015-11-12 19:03:43 +01:00
parent 3c2486e2ba
commit 5f33a81b1c
3 changed files with 28 additions and 8 deletions

View file

@ -1,11 +1,16 @@
import UrlRefresh from 'discourse/mixins/url-refresh'; import UrlRefresh from 'discourse/mixins/url-refresh';
import { on } from 'ember-addons/ember-computed-decorators';
const CATEGORIES_LIST_BODY_CLASS = "categories-list";
export default Ember.View.extend(UrlRefresh, { export default Ember.View.extend(UrlRefresh, {
_addBodyClass: function() { @on("didInsertElement")
$('body').addClass('categories-list'); addBodyClass() {
}.on('didInsertElement'), $('body').addClass(CATEGORIES_LIST_BODY_CLASS);
},
_removeBodyClass: function() { @on("willDestroyElement")
$('body').removeClass('categories-list'); removeBodyClass() {
}.on('willDestroyElement') $('body').removeClass(CATEGORIES_LIST_BODY_CLASS);
},
}); });

View file

@ -0,0 +1,15 @@
import { on } from 'ember-addons/ember-computed-decorators';
const CATEGORIES_BODY_CLASS = "navigation-categories";
export default Ember.View.extend({
@on("didInsertElement")
addBodyClass() {
$('body').addClass(CATEGORIES_BODY_CLASS);
},
@on("willDestroyElement")
removeBodyClass() {
$('body').removeClass(CATEGORIES_BODY_CLASS);
},
});

View file

@ -1,5 +1,5 @@
import AddCategoryClass from 'discourse/mixins/add-category-class'; import AddCategoryClass from 'discourse/mixins/add-category-class';
export default Em.View.extend(AddCategoryClass, { export default Ember.View.extend(AddCategoryClass, {
categoryFullSlug: Em.computed.alias('controller.category.fullSlug') categoryFullSlug: Ember.computed.alias('controller.category.fullSlug')
}); });