<form method="post" action="{@$__searchLink}">
<div id="pageHeaderSearchInputContainer" class="pageHeaderSearchInputContainer">
<div class="pageHeaderSearchType dropdown">
- <a href="#" class="button dropdownToggle"><span class="pageHeaderSearchTypeLabel">{@$__searchTypeLabel}</span></a>
+ <a href="#" class="button dropdownToggle" id="pageHeaderSearchTypeSelect"><span class="pageHeaderSearchTypeLabel">{@$__searchTypeLabel}</span></a>
<ul class="dropdownMenu">
<li><a href="#" data-extended-link="{link controller='Search'}{/link}" data-object-type="everywhere">{lang}wcf.search.type.everywhere{/lang}</a></li>
<li class="dropdownDivider"></li>
const _callbackList = new CallbackList();
-const UiCloseOverlay = {
- /**
- * @see CallbackList.add
- */
- add: _callbackList.add.bind(_callbackList),
-
- /**
- * @see CallbackList.remove
- */
- remove: _callbackList.remove.bind(_callbackList),
-
- /**
- * Invokes all registered callbacks.
- */
- execute(): void {
- _callbackList.forEach(null, (callback) => callback());
- },
-};
+export enum Origin {
+ Document = "document",
+ DropDown = "dropdown",
+}
+
+type Callback = (origin?: string | Origin, identifier?: string) => void;
+
+let hasGlobalListener = false;
+export function add(identifier: string, callback: Callback): void {
+ _callbackList.add(identifier, callback);
+
+ if (!hasGlobalListener) {
+ document.body.addEventListener("click", () => {
+ execute(Origin.Document);
+ });
-document.body.addEventListener("click", () => UiCloseOverlay.execute());
+ hasGlobalListener = true;
+ }
+}
-export = UiCloseOverlay;
+export function remove(identifier: string): void {
+ _callbackList.remove(identifier);
+}
+
+export function execute(): void;
+export function execute(origin: string | Origin): void;
+export function execute(origin: string | Origin, identifier: string): void;
+export function execute(origin?: string | Origin, identifier?: string): void {
+ _callbackList.forEach(null, (callback) => callback(origin, identifier));
+}
+
+// This is required for the backwards compatibility with WSC <= 5.4.
+const UiCloseOverlay = {
+ add,
+ remove,
+ execute,
+};
+export default UiCloseOverlay;
import * as DomTraverse from "../../Dom/Traverse";
import DomUtil from "../../Dom/Util";
import * as UiAlignment from "../Alignment";
-import UiCloseOverlay from "../CloseOverlay";
+import UiCloseOverlay, { Origin } from "../CloseOverlay";
import { AllowFlip } from "../Alignment";
import { NotificationAction, NotificationCallback } from "./Data";
alternateElement?: HTMLElement,
disableAutoFocus?: boolean,
): boolean {
- _blockCloseAll = true;
- try {
- UiCloseOverlay.execute();
- } finally {
- _blockCloseAll = false;
- }
-
let isKeyboardClick = false;
if (event !== null) {
event.preventDefault();
}
}
+ _blockCloseAll = true;
+ try {
+ UiCloseOverlay.execute(Origin.DropDown, targetId!);
+ } finally {
+ _blockCloseAll = false;
+ }
+
let dropdown = _dropdowns.get(targetId!) as HTMLElement;
let preventToggle = false;
if (dropdown !== undefined) {
import DomChangeListener from "../Dom/Change/Listener";
import * as Environment from "../Environment";
import * as UiAlignment from "./Alignment";
-import UiCloseOverlay from "./CloseOverlay";
+import UiCloseOverlay, { Origin } from "./CloseOverlay";
import * as UiDropdownReusable from "./Dropdown/Reusable";
import { closeSearchBar, openSearchBar } from "./Page/Header/Fixed";
import { PageMenuMain } from "./Page/Menu/Main";
});
searchBar.addEventListener("click", (event) => {
+ event.stopPropagation();
+
if (event.target === searchBar) {
event.preventDefault();
}
});
- UiCloseOverlay.add("WoltLabSuite/Core/Ui/MobileSearch", () => {
+ UiCloseOverlay.add("WoltLabSuite/Core/Ui/MobileSearch", (origin, identifier) => {
+ if (origin === Origin.DropDown) {
+ const button = document.getElementById("pageHeaderSearchTypeSelect")!;
+ if (button.dataset.target === identifier) {
+ return;
+ }
+ }
+
closeSearch(searchBar, scrollTop);
closeSearchBar();
import * as EventHandler from "../../../Event/Handler";
import * as UiAlignment from "../../Alignment";
-import UiCloseOverlay from "../../CloseOverlay";
+import UiCloseOverlay, { Origin } from "../../CloseOverlay";
import UiDropdownSimple from "../../Dropdown/Simple";
import * as UiScreen from "../../Screen";
}
});
- UiCloseOverlay.add("WoltLabSuite/Core/Ui/Page/Header/Fixed", () => {
+ UiCloseOverlay.add("WoltLabSuite/Core/Ui/Page/Header/Fixed", (origin, identifier) => {
+ if (origin === Origin.DropDown) {
+ const button = document.getElementById("pageHeaderSearchTypeSelect")!;
+ if (button.dataset.target === identifier) {
+ return;
+ }
+ }
+
if (_pageHeader.classList.contains("searchBarForceOpen")) {
return;
}
function click(event: MouseEvent): void {
event.preventDefault();
+ event.stopPropagation();
+
+ const searchType = document.querySelector(".pageHeaderSearchType") as HTMLElement;
+ UiDropdownSimple.close(DomUtil.identify(searchType))!;
const pageHeader = document.getElementById("pageHeader") as HTMLElement;
pageHeader.classList.add("searchBarForceOpen");
*/
define(["require", "exports", "tslib", "../CallbackList"], function (require, exports, tslib_1, CallbackList_1) {
"use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.execute = exports.remove = exports.add = exports.Origin = void 0;
CallbackList_1 = (0, tslib_1.__importDefault)(CallbackList_1);
const _callbackList = new CallbackList_1.default();
+ var Origin;
+ (function (Origin) {
+ Origin["Document"] = "document";
+ Origin["DropDown"] = "dropdown";
+ })(Origin = exports.Origin || (exports.Origin = {}));
+ let hasGlobalListener = false;
+ function add(identifier, callback) {
+ _callbackList.add(identifier, callback);
+ if (!hasGlobalListener) {
+ document.body.addEventListener("click", () => {
+ execute(Origin.Document);
+ });
+ hasGlobalListener = true;
+ }
+ }
+ exports.add = add;
+ function remove(identifier) {
+ _callbackList.remove(identifier);
+ }
+ exports.remove = remove;
+ function execute(origin, identifier) {
+ _callbackList.forEach(null, (callback) => callback(origin, identifier));
+ }
+ exports.execute = execute;
+ // This is required for the backwards compatibility with WSC <= 5.4.
const UiCloseOverlay = {
- /**
- * @see CallbackList.add
- */
- add: _callbackList.add.bind(_callbackList),
- /**
- * @see CallbackList.remove
- */
- remove: _callbackList.remove.bind(_callbackList),
- /**
- * Invokes all registered callbacks.
- */
- execute() {
- _callbackList.forEach(null, (callback) => callback());
- },
+ add,
+ remove,
+ execute,
};
- document.body.addEventListener("click", () => UiCloseOverlay.execute());
- return UiCloseOverlay;
+ exports.default = UiCloseOverlay;
});
DomTraverse = (0, tslib_1.__importStar)(DomTraverse);
Util_1 = (0, tslib_1.__importDefault)(Util_1);
UiAlignment = (0, tslib_1.__importStar)(UiAlignment);
- CloseOverlay_1 = (0, tslib_1.__importDefault)(CloseOverlay_1);
+ CloseOverlay_1 = (0, tslib_1.__importStar)(CloseOverlay_1);
let _availableDropdowns;
const _callbacks = new CallbackList_1.default();
let _didInit = false;
* Toggles the drop-down's state between open and close.
*/
function toggle(event, targetId, alternateElement, disableAutoFocus) {
- _blockCloseAll = true;
- try {
- CloseOverlay_1.default.execute();
- }
- finally {
- _blockCloseAll = false;
- }
let isKeyboardClick = false;
if (event !== null) {
event.preventDefault();
}
}
}
+ _blockCloseAll = true;
+ try {
+ CloseOverlay_1.default.execute(CloseOverlay_1.Origin.DropDown, targetId);
+ }
+ finally {
+ _blockCloseAll = false;
+ }
let dropdown = _dropdowns.get(targetId);
let preventToggle = false;
if (dropdown !== undefined) {
Listener_1 = (0, tslib_1.__importDefault)(Listener_1);
Environment = (0, tslib_1.__importStar)(Environment);
UiAlignment = (0, tslib_1.__importStar)(UiAlignment);
- CloseOverlay_1 = (0, tslib_1.__importDefault)(CloseOverlay_1);
+ CloseOverlay_1 = (0, tslib_1.__importStar)(CloseOverlay_1);
UiDropdownReusable = (0, tslib_1.__importStar)(UiDropdownReusable);
UiScreen = (0, tslib_1.__importStar)(UiScreen);
let _dropdownMenu = null;
}
});
searchBar.addEventListener("click", (event) => {
+ event.stopPropagation();
if (event.target === searchBar) {
event.preventDefault();
closeSearch(searchBar, scrollTop);
searchButton.setAttribute("aria-expanded", "false");
}
});
- CloseOverlay_1.default.add("WoltLabSuite/Core/Ui/MobileSearch", () => {
+ CloseOverlay_1.default.add("WoltLabSuite/Core/Ui/MobileSearch", (origin, identifier) => {
+ if (origin === CloseOverlay_1.Origin.DropDown) {
+ const button = document.getElementById("pageHeaderSearchTypeSelect");
+ if (button.dataset.target === identifier) {
+ return;
+ }
+ }
closeSearch(searchBar, scrollTop);
(0, Fixed_1.closeSearchBar)();
searchButton.setAttribute("aria-expanded", "false");
exports.init = exports.closeSearchBar = exports.openSearchBar = void 0;
EventHandler = (0, tslib_1.__importStar)(EventHandler);
UiAlignment = (0, tslib_1.__importStar)(UiAlignment);
- CloseOverlay_1 = (0, tslib_1.__importDefault)(CloseOverlay_1);
+ CloseOverlay_1 = (0, tslib_1.__importStar)(CloseOverlay_1);
Simple_1 = (0, tslib_1.__importDefault)(Simple_1);
UiScreen = (0, tslib_1.__importStar)(UiScreen);
let _isMobile = false;
openSearchBar();
}
});
- CloseOverlay_1.default.add("WoltLabSuite/Core/Ui/Page/Header/Fixed", () => {
+ CloseOverlay_1.default.add("WoltLabSuite/Core/Ui/Page/Header/Fixed", (origin, identifier) => {
+ if (origin === CloseOverlay_1.Origin.DropDown) {
+ const button = document.getElementById("pageHeaderSearchTypeSelect");
+ if (button.dataset.target === identifier) {
+ return;
+ }
+ }
if (_pageHeader.classList.contains("searchBarForceOpen")) {
return;
}
Input_1 = (0, tslib_1.__importDefault)(Input_1);
function click(event) {
event.preventDefault();
+ event.stopPropagation();
+ const searchType = document.querySelector(".pageHeaderSearchType");
+ Simple_1.default.close(Util_1.default.identify(searchType));
const pageHeader = document.getElementById("pageHeader");
pageHeader.classList.add("searchBarForceOpen");
window.setTimeout(() => {