+/**
+ * Customizable popover overlays that show additional information after a short
+ * delay.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+
import DomUtil from "../Dom/Util";
import { getPageOverlayContainer } from "../Helper/PageOverlay";
import { wheneverFirstSeen } from "../Helper/Selector";
}
#showPopover(): void {
+ if (!this.#enabled) {
+ return;
+ }
+
this.#timerHide?.stop();
if (this.#timerShouldShow === undefined) {
}
#hidePopover(): void {
+ if (!this.#enabled) {
+ return;
+ }
+
this.#timerShouldShow?.stop();
if (this.#timerHide === undefined) {
#setEnabled(enabled: boolean): void {
this.#enabled = enabled;
+
+ this.#container?.setAttribute("aria-hidden", "true");
}
#getObjectId(): number {
this.#container!.remove();
}
});
+
+ this.#container.addEventListener("mouseenter", () => {
+ this.#timerHide?.stop();
+ });
+ this.#container.addEventListener("mouseleave", () => {
+ this.#hidePopover();
+ });
}
if (this.#container.parentNode === null) {
selector: string;
};
+const cacheByIdentifier = new Map<string, SharedCache>();
+
export function setupFor(configuration: Configuration): void {
const { identifier, endpoint, selector } = configuration;
const cache = new SharedCache(endpoint);
+ cacheByIdentifier.set(identifier, cache);
wheneverFirstSeen(selector, (element) => {
+ // Disregard elements nested inside a popover.
+ if (element.closest(".popoverContainer") !== null) {
+ return;
+ }
+
element.addEventListener(
"mouseenter",
() => {
);
});
}
+
+export function resetCache(identifier: string, objectId: number): void {
+ cacheByIdentifier.get(identifier)!.reset(objectId);
+}
+/**
+ * Shared cache for popover instances serving the same selector.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
type ObjectId = number;
return content;
}
+
+ reset(objectId: ObjectId): void {
+ this.#data.delete(objectId);
+ }
}
export default SharedCache;
+/**
+ * Customizable popover overlays that show additional information after a short
+ * delay.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
define(["require", "exports", "tslib", "../Dom/Util", "../Helper/PageOverlay", "../Helper/Selector", "../Timer/Repeating", "../Ui/Alignment", "./Popover/SharedCache"], function (require, exports, tslib_1, Util_1, PageOverlay_1, Selector_1, Repeating_1, UiAlignment, SharedCache_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
- exports.setupFor = void 0;
+ exports.resetCache = exports.setupFor = void 0;
Util_1 = tslib_1.__importDefault(Util_1);
Repeating_1 = tslib_1.__importDefault(Repeating_1);
UiAlignment = tslib_1.__importStar(UiAlignment);
this.#showPopover();
}
#showPopover() {
+ if (!this.#enabled) {
+ return;
+ }
this.#timerHide?.stop();
if (this.#timerShouldShow === undefined) {
this.#timerShouldShow = new Repeating_1.default((timer) => {
}
}
#hidePopover() {
+ if (!this.#enabled) {
+ return;
+ }
this.#timerShouldShow?.stop();
if (this.#timerHide === undefined) {
this.#timerHide = new Repeating_1.default((timer) => {
}
#setEnabled(enabled) {
this.#enabled = enabled;
+ this.#container?.setAttribute("aria-hidden", "true");
}
#getObjectId() {
return parseInt(this.#element.dataset.objectId);
this.#container.remove();
}
});
+ this.#container.addEventListener("mouseenter", () => {
+ this.#timerHide?.stop();
+ });
+ this.#container.addEventListener("mouseleave", () => {
+ this.#hidePopover();
+ });
}
if (this.#container.parentNode === null) {
(0, PageOverlay_1.getPageOverlayContainer)().append(this.#container);
return this.#container;
}
}
+ const cacheByIdentifier = new Map();
function setupFor(configuration) {
const { identifier, endpoint, selector } = configuration;
const cache = new SharedCache_1.default(endpoint);
+ cacheByIdentifier.set(identifier, cache);
(0, Selector_1.wheneverFirstSeen)(selector, (element) => {
+ // Disregard elements nested inside a popover.
+ if (element.closest(".popoverContainer") !== null) {
+ return;
+ }
element.addEventListener("mouseenter", () => {
new Popover(cache, element, identifier);
}, { once: true });
});
}
exports.setupFor = setupFor;
+ function resetCache(identifier, objectId) {
+ cacheByIdentifier.get(identifier).reset(objectId);
+ }
+ exports.resetCache = resetCache;
});
+/**
+ * Shared cache for popover instances serving the same selector.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend"], function (require, exports, Backend_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
this.#data.set(objectId, content);
return content;
}
+ reset(objectId) {
+ this.#data.delete(objectId);
+ }
}
exports.SharedCache = SharedCache;
exports.default = SharedCache;
border-radius: var(--wcfBorderRadius);
box-shadow: var(--wcfBoxShadow);
color: var(--wcfContentText);
+ display: none;
max-height: 300px;
max-width: 500px;
opacity: 0;
transform: translateY(0);
}
}
+
+@media (hover: hover) {
+ .popoverContainer {
+ display: block;
+ }
+}