FIX: Don't lose background class while navigating from `/latest` to
`/new`
This commit is contained in:
parent
9a09817767
commit
7a739eb373
|
@ -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')
|
||||||
|
};
|
|
@ -103,7 +103,6 @@ function buildCategoryRoute(filter, params) {
|
||||||
this.replaceWith('/404');
|
this.replaceWith('/404');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.controllerFor('application').set('styleCategory', model);
|
|
||||||
|
|
||||||
var self = this,
|
var self = this,
|
||||||
noSubcategories = params && !!params.no_subcategories,
|
noSubcategories = params && !!params.no_subcategories,
|
||||||
|
@ -167,7 +166,6 @@ function buildCategoryRoute(filter, params) {
|
||||||
deactivate: function() {
|
deactivate: function() {
|
||||||
this._super();
|
this._super();
|
||||||
this.controllerFor('search').set('searchContext', null);
|
this.controllerFor('search').set('searchContext', null);
|
||||||
this.controllerFor('application').set('styleCategory', null);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -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'),
|
||||||
|
});
|
|
@ -21,9 +21,14 @@ a.no-href {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background-attachment: fixed;
|
background-attachment: fixed;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
|
min-height: 100%;
|
||||||
|
|
||||||
button.ok {
|
button.ok {
|
||||||
background: $success;
|
background: $success;
|
||||||
|
|
Loading…
Reference in New Issue