0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-24 02:10:29 +01:00
discourse-custom-wizard/assets/javascripts/discourse/components/custom-wizard-similar-topics.js
Angus McLeod ce55b4671e Linting
2024-11-22 17:11:51 +01:00

41 Zeilen
900 B
JavaScript

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