FIX: Don't lose background class while navigating from /latest to

`/new`
This commit is contained in:
Robin Ward 2014-07-01 15:24:04 -04:00
parent 9a09817767
commit 7a739eb373
4 changed files with 33 additions and 2 deletions

View File

@ -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')
};

View File

@ -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: {

View File

@ -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'),
});

View File

@ -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;