0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-15 22:32:54 +01:00
discourse-custom-wizard/assets/javascripts/wizard/components/wizard-similar-topics.js.es6

37 Zeilen
799 B
Text

import Component from "@ember/component";
import { bind } from "@ember/runloop";
import { observes } from "discourse-common/utils/decorators";
2021-02-24 08:43:35 +01:00
export default Component.extend({
classNames: ["wizard-similar-topics"],
showTopics: true,
2021-02-24 08:43:35 +01:00
didInsertElement() {
$(document).on("click", bind(this, this.documentClick));
},
willDestroyElement() {
$(document).off("click", bind(this, this.documentClick));
},
documentClick(e) {
if (this._state == "destroying") return;
let $target = $(e.target);
2021-02-24 08:43:35 +01:00
if (!$target.hasClass("show-topics")) {
this.set("showTopics", false);
}
},
2021-02-24 08:43:35 +01:00
@observes("topics")
toggleShowWhenTopicsChange() {
2021-02-24 08:43:35 +01:00
this.set("showTopics", true);
},
2021-02-24 08:43:35 +01:00
actions: {
toggleShowTopics() {
2021-02-24 08:43:35 +01:00
this.set("showTopics", true);
},
},
});