import * as Core from "../Core";
import DomChangeListener from "../Dom/Change/Listener";
import * as Environment from "../Environment";
-import * as EventHandler from "../Event/Handler";
import * as UiAlignment from "./Alignment";
import UiCloseOverlay from "./CloseOverlay";
import * as UiDropdownReusable from "./Dropdown/Reusable";
+import { closeSearchBar, openSearchBar } from "./Page/Header/Fixed";
import { PageMenuMain } from "./Page/Menu/Main";
import { hasValidUserMenu, PageMenuUser } from "./Page/Menu/User";
import * as UiScreen from "./Screen";
-interface MainMenuMorePayload {
- identifier: string;
- handler: any; //UiPageMenuMain;
-}
-
let _dropdownMenu: HTMLUListElement | null = null;
let _dropdownMenuMessage: HTMLElement | null = null;
let _enabled = false;
function init(): void {
_enabled = true;
- initSearchBar();
+ initSearchButton();
initButtonGroupNavigation();
initMessages();
initMobileMenu();
});
}
-function initSearchBar(): void {
+function initSearchButton(): void {
const searchBar = document.getElementById("pageHeaderSearch")!;
const searchInput = document.getElementById("pageHeaderSearchInput")!;
let scrollTop: number | null = null;
- EventHandler.add("com.woltlab.wcf.MainMenuMobile", "more", (data: MainMenuMorePayload) => {
- if (data.identifier === "com.woltlab.wcf.search") {
- data.handler.close();
+ const searchButton = document.getElementById("pageHeaderSearchMobile")!;
+ searchButton.addEventListener("click", (event) => {
+ event.preventDefault();
+ event.stopPropagation();
+
+ if (searchButton.getAttribute("aria-expanded") === "true") {
+ closeSearch(searchBar, scrollTop);
+ closeSearchBar();
+ searchButton.setAttribute("aria-expanded", "false");
+ } else {
if (Environment.platform() === "ios") {
scrollTop = document.body.scrollTop;
UiScreen.scrollDisable();
}
+ openSearchBar();
+
const pageHeader = document.getElementById("pageHeader")!;
searchBar.style.setProperty("top", `${pageHeader.offsetHeight}px`, "");
searchBar.classList.add("open");
if (Environment.platform() === "ios") {
document.body.scrollTop = 0;
}
+
+ searchButton.setAttribute("aria-expanded", "true");
}
});
- document.getElementById("main")!.addEventListener("click", () => {
- if (searchBar) {
- searchBar.classList.remove("open");
- }
+ searchBar.addEventListener("click", (event) => {
+ if (event.target === searchBar) {
+ event.preventDefault();
+
+ closeSearch(searchBar, scrollTop);
+ closeSearchBar();
- if (Environment.platform() === "ios" && scrollTop) {
- UiScreen.scrollEnable();
- document.body.scrollTop = scrollTop;
- scrollTop = null;
+ searchButton.setAttribute("aria-expanded", "false");
}
});
+
+ UiCloseOverlay.add("WoltLabSuite/Core/Ui/MobileSearch", () => {
+ closeSearch(searchBar, scrollTop);
+ closeSearchBar();
+
+ searchButton.setAttribute("aria-expanded", "false");
+ });
+}
+
+function closeSearch(searchBar: HTMLElement, scrollTop: number | null): void {
+ if (searchBar) {
+ searchBar.classList.remove("open");
+ }
+
+ if (Environment.platform() === "ios" && scrollTop) {
+ UiScreen.scrollEnable();
+ document.body.scrollTop = scrollTop;
+ scrollTop = null;
+ }
}
function initButtonGroupNavigation(): void {
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLabSuite/Core/Ui/Mobile
*/
-define(["require", "exports", "tslib", "../Core", "../Dom/Change/Listener", "../Environment", "../Event/Handler", "./Alignment", "./CloseOverlay", "./Dropdown/Reusable", "./Page/Menu/Main", "./Page/Menu/User", "./Screen"], function (require, exports, tslib_1, Core, Listener_1, Environment, EventHandler, UiAlignment, CloseOverlay_1, UiDropdownReusable, Main_1, User_1, UiScreen) {
+define(["require", "exports", "tslib", "../Core", "../Dom/Change/Listener", "../Environment", "./Alignment", "./CloseOverlay", "./Dropdown/Reusable", "./Page/Header/Fixed", "./Page/Menu/Main", "./Page/Menu/User", "./Screen"], function (require, exports, tslib_1, Core, Listener_1, Environment, UiAlignment, CloseOverlay_1, UiDropdownReusable, Fixed_1, Main_1, User_1, UiScreen) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeShadow = exports.rebuildShadow = exports.disableShadow = exports.disable = exports.enableShadow = exports.enable = exports.setup = void 0;
Core = (0, tslib_1.__importStar)(Core);
Listener_1 = (0, tslib_1.__importDefault)(Listener_1);
Environment = (0, tslib_1.__importStar)(Environment);
- EventHandler = (0, tslib_1.__importStar)(EventHandler);
UiAlignment = (0, tslib_1.__importStar)(UiAlignment);
CloseOverlay_1 = (0, tslib_1.__importDefault)(CloseOverlay_1);
UiDropdownReusable = (0, tslib_1.__importStar)(UiDropdownReusable);
const _sidebars = [];
function init() {
_enabled = true;
- initSearchBar();
+ initSearchButton();
initButtonGroupNavigation();
initMessages();
initMobileMenu();
initMessages();
});
}
- function initSearchBar() {
+ function initSearchButton() {
const searchBar = document.getElementById("pageHeaderSearch");
const searchInput = document.getElementById("pageHeaderSearchInput");
let scrollTop = null;
- EventHandler.add("com.woltlab.wcf.MainMenuMobile", "more", (data) => {
- if (data.identifier === "com.woltlab.wcf.search") {
- data.handler.close();
+ const searchButton = document.getElementById("pageHeaderSearchMobile");
+ searchButton.addEventListener("click", (event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ if (searchButton.getAttribute("aria-expanded") === "true") {
+ closeSearch(searchBar, scrollTop);
+ (0, Fixed_1.closeSearchBar)();
+ searchButton.setAttribute("aria-expanded", "false");
+ }
+ else {
if (Environment.platform() === "ios") {
scrollTop = document.body.scrollTop;
UiScreen.scrollDisable();
}
+ (0, Fixed_1.openSearchBar)();
const pageHeader = document.getElementById("pageHeader");
searchBar.style.setProperty("top", `${pageHeader.offsetHeight}px`, "");
searchBar.classList.add("open");
if (Environment.platform() === "ios") {
document.body.scrollTop = 0;
}
+ searchButton.setAttribute("aria-expanded", "true");
}
});
- document.getElementById("main").addEventListener("click", () => {
- if (searchBar) {
- searchBar.classList.remove("open");
- }
- if (Environment.platform() === "ios" && scrollTop) {
- UiScreen.scrollEnable();
- document.body.scrollTop = scrollTop;
- scrollTop = null;
+ searchBar.addEventListener("click", (event) => {
+ if (event.target === searchBar) {
+ event.preventDefault();
+ closeSearch(searchBar, scrollTop);
+ (0, Fixed_1.closeSearchBar)();
+ searchButton.setAttribute("aria-expanded", "false");
}
});
+ CloseOverlay_1.default.add("WoltLabSuite/Core/Ui/MobileSearch", () => {
+ closeSearch(searchBar, scrollTop);
+ (0, Fixed_1.closeSearchBar)();
+ searchButton.setAttribute("aria-expanded", "false");
+ });
+ }
+ function closeSearch(searchBar, scrollTop) {
+ if (searchBar) {
+ searchBar.classList.remove("open");
+ }
+ if (Environment.platform() === "ios" && scrollTop) {
+ UiScreen.scrollEnable();
+ document.body.scrollTop = scrollTop;
+ scrollTop = null;
+ }
}
function initButtonGroupNavigation() {
document.querySelectorAll(".buttonGroupNavigation").forEach((navigation) => {
define(["require", "exports", "tslib", "../../../Event/Handler", "../../Alignment", "../../CloseOverlay", "../../Dropdown/Simple", "../../Screen"], function (require, exports, tslib_1, EventHandler, UiAlignment, CloseOverlay_1, Simple_1, UiScreen) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
- exports.init = void 0;
+ 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);
_searchInput.selectionStart = _searchInput.selectionEnd = _searchInput.value.length;
}, 1);
}
+ exports.openSearchBar = openSearchBar;
/**
* Closes the search bar.
*/
const scope = _pageHeaderSearch.querySelector(".pageHeaderSearchType");
Simple_1.default.close(scope.id);
}
+ exports.closeSearchBar = closeSearchBar;
/**
* Initializes the sticky page header handler.
*/