2021-02-17 05:49:20 +01:00
|
|
|
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"],
|
2021-02-17 05:49:20 +01:00
|
|
|
showTopics: true,
|
2021-02-24 08:43:35 +01:00
|
|
|
|
2021-02-17 05:49:20 +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-17 05:49:20 +01:00
|
|
|
}
|
|
|
|
},
|
2021-02-24 08:43:35 +01:00
|
|
|
|
|
|
|
@observes("topics")
|
2021-02-17 05:49:20 +01:00
|
|
|
toggleShowWhenTopicsChange() {
|
2021-02-24 08:43:35 +01:00
|
|
|
this.set("showTopics", true);
|
2021-02-17 05:49:20 +01:00
|
|
|
},
|
2021-02-24 08:43:35 +01:00
|
|
|
|
2021-02-17 05:49:20 +01:00
|
|
|
actions: {
|
|
|
|
toggleShowTopics() {
|
2021-02-24 08:43:35 +01:00
|
|
|
this.set("showTopics", true);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|