mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 05:01:14 +08:00
This reverts commits 0623ac684a65f95ce4f5438ff47944b1dc2119f4 408e71e437ef8abf98f93e3449898bf906766b0e a32fa3b9470dde0543fcee809f2abd1f219f7336 User tips were running into some issues.
This commit is contained in:
@ -1,16 +1,17 @@
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
import deprecated from "discourse-common/lib/deprecated";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import LocalDateBuilder from "../lib/local-date-builder";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
import { downloadCalendar } from "discourse/lib/download-calendar";
|
||||
import { renderIcon } from "discourse-common/lib/icon-library";
|
||||
import I18n from "I18n";
|
||||
import { hidePopover, showPopover } from "discourse/lib/d-popover";
|
||||
import {
|
||||
addTagDecorateCallback,
|
||||
addTextDecorateCallback,
|
||||
} from "discourse/lib/to-markdown";
|
||||
import generateDateMarkup from "discourse/plugins/discourse-local-dates/lib/local-date-markup-generator";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
// Import applyLocalDates from discourse/lib/local-dates instead
|
||||
export function applyLocalDates(dates, siteSettings) {
|
||||
@ -344,9 +345,11 @@ function _calculateDuration(element) {
|
||||
export default {
|
||||
name: "discourse-local-dates",
|
||||
|
||||
@bind
|
||||
showDatePopover(event) {
|
||||
const tooltip = this.container.lookup("service:tooltip");
|
||||
const owner = getOwner(this);
|
||||
if (owner.isDestroyed || owner.isDestroying) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event?.target?.classList?.contains("download-calendar")) {
|
||||
const dataset = event.target.dataset;
|
||||
@ -357,25 +360,50 @@ export default {
|
||||
},
|
||||
]);
|
||||
|
||||
return tooltip.close();
|
||||
// TODO: remove this when rewriting preview as a component
|
||||
const parentPopover = event.target.closest("[data-tippy-root]");
|
||||
if (parentPopover?._tippy) {
|
||||
parentPopover._tippy.hide();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event?.target?.classList?.contains("discourse-local-date")) {
|
||||
return;
|
||||
}
|
||||
|
||||
const siteSettings = this.container.lookup("service:site-settings");
|
||||
return tooltip.show(event.target, {
|
||||
content: htmlSafe(buildHtmlPreview(event.target, siteSettings)),
|
||||
const siteSettings = owner.lookup("service:site-settings");
|
||||
|
||||
showPopover(event, {
|
||||
trigger: "click",
|
||||
content: buildHtmlPreview(event.target, siteSettings),
|
||||
allowHTML: true,
|
||||
interactive: true,
|
||||
appendTo: "parent",
|
||||
onHidden: (instance) => {
|
||||
instance.destroy();
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
hideDatePopover(event) {
|
||||
hidePopover(event);
|
||||
},
|
||||
|
||||
initialize(container) {
|
||||
this.container = container;
|
||||
window.addEventListener("click", this.showDatePopover, { passive: true });
|
||||
window.addEventListener("click", this.showDatePopover);
|
||||
|
||||
const siteSettings = container.lookup("service:site-settings");
|
||||
if (siteSettings.discourse_local_dates_enabled) {
|
||||
$.fn.applyLocalDates = function () {
|
||||
deprecated(
|
||||
"`$.applyLocalDates()` is deprecated, import and use `applyLocalDates()` instead."
|
||||
);
|
||||
|
||||
return applyLocalDates(this.toArray(), siteSettings);
|
||||
};
|
||||
|
||||
withPluginApi("0.8.8", initializeDiscourseLocalDates);
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user