From 5f33a81b1c0f3827298bd54260c92610c2b658f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Thu, 12 Nov 2015 19:03:43 +0100 Subject: [PATCH] FEATURE: add 'navigation-categories' class on 'body' when visiting /categories --- .../discourse/views/discovery-categories.js.es6 | 17 +++++++++++------ .../views/navigation-categories.js.es6 | 15 +++++++++++++++ .../discourse/views/navigation-category.js.es6 | 4 ++-- 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 app/assets/javascripts/discourse/views/navigation-categories.js.es6 diff --git a/app/assets/javascripts/discourse/views/discovery-categories.js.es6 b/app/assets/javascripts/discourse/views/discovery-categories.js.es6 index 59721af08..ee4b13d7d 100644 --- a/app/assets/javascripts/discourse/views/discovery-categories.js.es6 +++ b/app/assets/javascripts/discourse/views/discovery-categories.js.es6 @@ -1,11 +1,16 @@ 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, { - _addBodyClass: function() { - $('body').addClass('categories-list'); - }.on('didInsertElement'), + @on("didInsertElement") + addBodyClass() { + $('body').addClass(CATEGORIES_LIST_BODY_CLASS); + }, - _removeBodyClass: function() { - $('body').removeClass('categories-list'); - }.on('willDestroyElement') + @on("willDestroyElement") + removeBodyClass() { + $('body').removeClass(CATEGORIES_LIST_BODY_CLASS); + }, }); diff --git a/app/assets/javascripts/discourse/views/navigation-categories.js.es6 b/app/assets/javascripts/discourse/views/navigation-categories.js.es6 new file mode 100644 index 000000000..dcd408de5 --- /dev/null +++ b/app/assets/javascripts/discourse/views/navigation-categories.js.es6 @@ -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); + }, +}); diff --git a/app/assets/javascripts/discourse/views/navigation-category.js.es6 b/app/assets/javascripts/discourse/views/navigation-category.js.es6 index f5e5c3d97..6a871ecae 100644 --- a/app/assets/javascripts/discourse/views/navigation-category.js.es6 +++ b/app/assets/javascripts/discourse/views/navigation-category.js.es6 @@ -1,5 +1,5 @@ import AddCategoryClass from 'discourse/mixins/add-category-class'; -export default Em.View.extend(AddCategoryClass, { - categoryFullSlug: Em.computed.alias('controller.category.fullSlug') +export default Ember.View.extend(AddCategoryClass, { + categoryFullSlug: Ember.computed.alias('controller.category.fullSlug') });