diff --git a/app/assets/javascripts/discourse/mixins/add-category-class.js.es6 b/app/assets/javascripts/discourse/mixins/add-category-class.js.es6 new file mode 100644 index 00000000000..b0fd0544e7f --- /dev/null +++ b/app/assets/javascripts/discourse/mixins/add-category-class.js.es6 @@ -0,0 +1,23 @@ +// Mix this in to a view that has a `categoryId` property to automatically +// 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. +export default { + _observeOnce: function() { this.get('categoryId'); }.on('init'), + + _removeClasses: function() { + $('body').removeClass(function(idx, css) { + return (css.match(/\bcategory-\d+/g) || []).join(' '); + }); + }, + + _categoryChanged: function() { + var categoryId = this.get('categoryId'); + this._removeClasses(); + + if (categoryId) { + $('body').addClass('category-' + categoryId); + } + }.observes('categoryId'), + + _leaveView: function() { this._removeClasses(); }.on('willDestroyElement') +}; diff --git a/app/assets/javascripts/discourse/routes/discovery_route_builders.js b/app/assets/javascripts/discourse/routes/discovery_route_builders.js index c5fc8ebe754..8e03658debe 100644 --- a/app/assets/javascripts/discourse/routes/discovery_route_builders.js +++ b/app/assets/javascripts/discourse/routes/discovery_route_builders.js @@ -103,7 +103,6 @@ function buildCategoryRoute(filter, params) { this.replaceWith('/404'); return; } - this.controllerFor('application').set('styleCategory', model); var self = this, noSubcategories = params && !!params.no_subcategories, @@ -167,7 +166,6 @@ function buildCategoryRoute(filter, params) { deactivate: function() { this._super(); this.controllerFor('search').set('searchContext', null); - this.controllerFor('application').set('styleCategory', null); }, actions: { diff --git a/app/assets/javascripts/discourse/views/navigation-category.js.es6 b/app/assets/javascripts/discourse/views/navigation-category.js.es6 new file mode 100644 index 00000000000..76e0c1c0c34 --- /dev/null +++ b/app/assets/javascripts/discourse/views/navigation-category.js.es6 @@ -0,0 +1,5 @@ +import AddCategoryClass from 'discourse/mixins/add-category-class'; + +export default Em.View.extend(AddCategoryClass, { + categoryId: Em.computed.alias('controller.category.id'), +}); diff --git a/app/assets/stylesheets/common/base/discourse.scss b/app/assets/stylesheets/common/base/discourse.scss index 2d28c543ffb..0d256fba6c4 100644 --- a/app/assets/stylesheets/common/base/discourse.scss +++ b/app/assets/stylesheets/common/base/discourse.scss @@ -21,9 +21,14 @@ a.no-href { cursor: pointer; } +html { + height: 100%; +} + body { background-attachment: fixed; background-size: cover; + min-height: 100%; button.ok { background: $success;