2021-02-17 05:49:20 +01:00
|
|
|
import Component from "@ember/component";
|
|
|
|
import { bind } from "@ember/runloop";
|
2024-11-22 17:11:51 +01:00
|
|
|
import $ from "jquery";
|
2021-02-17 05:49:20 +01:00
|
|
|
import { observes } from "discourse-common/utils/decorators";
|
|
|
|
|
2021-03-28 11:06:49 +02:00
|
|
|
export default Component.extend({
|
|
|
|
classNames: ["wizard-similar-topics"],
|
2021-02-17 05:49:20 +01:00
|
|
|
showTopics: true,
|
2021-03-28 11:06:49 +02:00
|
|
|
|
2021-02-17 05:49:20 +01:00
|
|
|
didInsertElement() {
|
2024-11-22 17:11:51 +01:00
|
|
|
this._super(...arguments);
|
2021-02-17 05:49:20 +01:00
|
|
|
$(document).on("click", bind(this, this.documentClick));
|
|
|
|
},
|
|
|
|
|
|
|
|
willDestroyElement() {
|
2024-11-22 17:11:51 +01:00
|
|
|
this._super(...arguments);
|
2021-02-17 05:49:20 +01:00
|
|
|
$(document).off("click", bind(this, this.documentClick));
|
|
|
|
},
|
|
|
|
|
|
|
|
documentClick(e) {
|
2021-04-12 08:26:22 +02:00
|
|
|
if (this._state === "destroying") {
|
|
|
|
return;
|
|
|
|
}
|
2021-02-17 05:49:20 +01:00
|
|
|
let $target = $(e.target);
|
|
|
|
|
2021-03-28 11:06:49 +02:00
|
|
|
if (!$target.hasClass("show-topics")) {
|
|
|
|
this.set("showTopics", false);
|
2021-02-17 05:49:20 +01:00
|
|
|
}
|
|
|
|
},
|
2021-03-28 11:06:49 +02:00
|
|
|
|
|
|
|
@observes("topics")
|
2021-02-17 05:49:20 +01:00
|
|
|
toggleShowWhenTopicsChange() {
|
2021-03-28 11:06:49 +02:00
|
|
|
this.set("showTopics", true);
|
2021-02-17 05:49:20 +01:00
|
|
|
},
|
2021-03-28 11:06:49 +02:00
|
|
|
|
2021-02-17 05:49:20 +01:00
|
|
|
actions: {
|
|
|
|
toggleShowTopics() {
|
2021-03-28 11:06:49 +02:00
|
|
|
this.set("showTopics", true);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|