From 03eb4752d14fbd8f759713a64fd8a54e6fb4a68a Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 21 Jan 2015 14:34:01 -0500 Subject: [PATCH] Add `categories-list` css class to body for customization purposes --- .../discourse/views/discovery-categories.js.es6 | 10 +++++++++- .../integration/topic-discovery-test.js.es6 | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/views/discovery-categories.js.es6 b/app/assets/javascripts/discourse/views/discovery-categories.js.es6 index 8571185e2..460a15423 100644 --- a/app/assets/javascripts/discourse/views/discovery-categories.js.es6 +++ b/app/assets/javascripts/discourse/views/discovery-categories.js.es6 @@ -1,3 +1,11 @@ import UrlRefresh from 'discourse/mixins/url-refresh'; -export default Discourse.View.extend(UrlRefresh, Discourse.ScrollTop); +export default Discourse.View.extend(UrlRefresh, Discourse.ScrollTop, { + _addBodyClass: function() { + $('body').addClass('categories-list'); + }.on('didInsertElement'), + + _removeBodyClass: function() { + $('body').removeClass('categories-list'); + }.on('willDestroyElement') +}); diff --git a/test/javascripts/integration/topic-discovery-test.js.es6 b/test/javascripts/integration/topic-discovery-test.js.es6 index c5931f633..fcd4a090d 100644 --- a/test/javascripts/integration/topic-discovery-test.js.es6 +++ b/test/javascripts/integration/topic-discovery-test.js.es6 @@ -11,15 +11,20 @@ test("Visit Discovery Pages", function() { andThen(function() { ok(exists(".topic-list"), "The list of topics was rendered"); ok(exists('.topic-list .topic-list-item'), "has topics"); + ok($('body.category-1').length, "has a custom css class for the category id on the body"); }); visit("/categories"); andThen(function() { + ok($('body.category-1').length === 0, "removes the custom category class"); + ok(exists('.category'), "has a list of categories"); + ok($('body.categories-list').length, "has a custom class to indicate categories"); }); visit("/top"); andThen(function() { + ok($('body.categories-list').length === 0, "removes the `categories-list` class"); ok(exists('.topic-list .topic-list-item'), "has topics"); }); });