mirror of
https://ghfast.top/https://github.com/paviliondev/discourse-journal.git
synced 2026-07-18 12:00:07 +08:00
39 lines
893 B
JavaScript
39 lines
893 B
JavaScript
import { cook } from "discourse/lib/text";
|
|
import Component from "@ember/component";
|
|
import { bind } from "@ember/runloop";
|
|
|
|
export default Component.extend({
|
|
classNames: ["journal-topic-tip"],
|
|
|
|
didInsertElement() {
|
|
this._super(...arguments);
|
|
|
|
$(document).on("click", bind(this, this.documentClick));
|
|
|
|
const rawDetails = I18n.t(this.details);
|
|
if (rawDetails) {
|
|
cook(rawDetails).then(cooked => {
|
|
this.set("cookedDetails", cooked);
|
|
});
|
|
}
|
|
},
|
|
|
|
willDestroyElement() {
|
|
$(document).off("click", bind(this, this.documentClick));
|
|
},
|
|
|
|
documentClick(e) {
|
|
const $element = $(this.element);
|
|
const $target = $(e.target);
|
|
|
|
if ($target.closest($element).length < 1 && this._state !== "destroying") {
|
|
this.set("showDetails", false);
|
|
}
|
|
},
|
|
|
|
actions: {
|
|
toggleDetails() {
|
|
this.toggleProperty("showDetails");
|
|
}
|
|
}
|
|
});
|