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/edit-category-tab.js.es6
2018-06-15 17:03:24 +02:00

42 lines
977 B
JavaScript

import { propertyEqual } from "discourse/lib/computed";
export default Em.Component.extend({
tagName: "li",
classNameBindings: ["active", "tabClassName"],
tabClassName: function() {
return "edit-category-" + this.get("tab");
}.property("tab"),
active: propertyEqual("selectedTab", "tab"),
title: function() {
return I18n.t("category." + this.get("tab").replace("-", "_"));
}.property("tab"),
didInsertElement() {
this._super();
Ember.run.scheduleOnce("afterRender", this, this._addToCollection);
},
_addToCollection: function() {
this.get("panels").addObject(this.get("tabClassName"));
},
_resetModalScrollState() {
const $modalBody = this.$()
.parents("#discourse-modal")
.find(".modal-body");
if ($modalBody.length === 1) {
$modalBody.scrollTop(0);
}
},
actions: {
select: function() {
this.set("selectedTab", this.get("tab"));
this._resetModalScrollState();
}
}
});