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
2019-01-19 10:05:51 +01:00

40 lines
886 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(...arguments);
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(...arguments);
const pageClass = this.get("pageClass");
if (pageClass) {
$("body").removeClass(`${pageClass}-page`);
}
const bodyClass = this.get("bodyClass");
if (bodyClass) {
$("body").removeClass(bodyClass);
}
}
});