2018-05-04 14:51:41 +08:00
|
|
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
|
|
import showModal from "discourse/lib/show-modal";
|
2018-05-22 19:58:06 +08:00
|
|
|
import { registerTooltip } from "discourse/lib/tooltip";
|
2018-05-04 14:51:41 +08:00
|
|
|
|
|
|
|
function initializeDiscourseLocalDates(api) {
|
|
|
|
api.decorateCooked($elem => {
|
|
|
|
$(".discourse-local-date", $elem).applyLocalDates();
|
2018-05-22 19:58:06 +08:00
|
|
|
registerTooltip($(".discourse-local-date", $elem));
|
2018-05-04 14:51:41 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
|
|
return {
|
|
|
|
action: "insertDiscourseLocalDate",
|
|
|
|
icon: "globe",
|
|
|
|
label: "discourse_local_dates.title"
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2018-06-16 00:42:20 +08:00
|
|
|
api.modifyClass("controller:composer", {
|
2018-05-04 14:51:41 +08:00
|
|
|
actions: {
|
|
|
|
insertDiscourseLocalDate() {
|
|
|
|
showModal("discourse-local-dates-create-modal").setProperties({
|
|
|
|
toolbarEvent: this.get("toolbarEvent")
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "discourse-local-dates",
|
|
|
|
|
|
|
|
initialize(container) {
|
|
|
|
const siteSettings = container.lookup("site-settings:main");
|
|
|
|
if (siteSettings.discourse_local_dates_enabled) {
|
|
|
|
withPluginApi("0.8.8", initializeDiscourseLocalDates);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|