This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/d-section.js.es6
2016-11-10 15:25:04 -05:00

40 lines
862 B
JavaScript

import { scrollTop } from 'discourse/mixins/scroll-top';
// Can add a body class from within a component, also will scroll to the top automatically.
export default Ember.Component.extend({
tagName: 'section',
didInsertElement() {
this._super();
const pageClass = this.get('pageClass');
if (pageClass) {
$('body').addClass(`${pageClass}-page`);
}
const bodyClass = this.get('bodyClass');
if (bodyClass) {
$('body').addClass(bodyClass);
}
if (this.get('scrollTop') === "false") {
return;
}
scrollTop();
},
willDestroyElement() {
this._super();
const pageClass = this.get('pageClass');
if (pageClass) {
$('body').removeClass(`${pageClass}-page`);
}
const bodyClass = this.get('bodyClass');
if (bodyClass) {
$('body').removeClass(bodyClass);
}
}
});