{include file='headInclude'}
-<style>
-
-</style>
-
{if !$canonicalURL|empty}
<link rel="canonical" href="{$canonicalURL}">
{/if}
require(['WoltLabSuite/Core/Ui/Page/Header/Fixed'], function(UiPageHeaderFixed) {
UiPageHeaderFixed.init();
});
- require(["WoltLabSuite/Core/Ui/Page/Menu/Main"], ({ PageMenuMain }) => {
- new PageMenuMain();
- })
</script>
</header>
import * as UiAlignment from "./Alignment";
import UiCloseOverlay from "./CloseOverlay";
import * as UiDropdownReusable from "./Dropdown/Reusable";
-//import UiPageMenuMain from "./Page/Menu/Main";
+import { PageMenuMain } from "./Page/Menu/Main";
import UiPageMenuUser from "./Page/Menu/User";
import * as UiScreen from "./Screen";
interface MainMenuMorePayload {
identifier: string;
- handler: any;//UiPageMenuMain;
+ handler: any; //UiPageMenuMain;
}
let _dropdownMenu: HTMLUListElement | null = null;
let _enableMobileMenu = false;
const _knownMessages = new WeakSet<HTMLElement>();
let _mobileSidebarEnabled = false;
-//let _pageMenuMain: UiPageMenuMain;
+let _pageMenuMain: PageMenuMain;
let _pageMenuUser: UiPageMenuUser | undefined = undefined;
let _messageGroups: HTMLCollection | null = null;
const _sidebars: HTMLElement[] = [];
function initMobileMenu(): void {
if (_enableMobileMenu) {
- //_pageMenuMain = new UiPageMenuMain();
+ _pageMenuMain = new PageMenuMain();
+ _pageMenuMain.enable();
if (UiPageMenuUser.hasValidMenu()) {
_pageMenuUser = new UiPageMenuUser();
export function enable(): void {
_enabled = true;
if (_enableMobileMenu) {
- //_pageMenuMain.enable();
+ _pageMenuMain.enable();
_pageMenuUser?.enable();
}
}
export function disable(): void {
_enabled = false;
if (_enableMobileMenu) {
- //_pageMenuMain.disable();
+ _pageMenuMain.disable();
_pageMenuUser?.disable();
}
}
import { PageMenuProvider } from "./Provider";
import { createFocusTrap, FocusTrap } from "focus-trap";
import { pageOverlayClose, pageOverlayOpen, scrollDisable, scrollEnable } from "../../Screen";
+import UiCloseOverlay from "../../CloseOverlay";
+import DomUtil from "../../../Dom/Util";
export class PageMenuContainer {
private readonly container = document.createElement("div");
constructor(provider: PageMenuProvider) {
this.provider = provider;
+
+ const menuId = DomUtil.identify(this.provider.getMenuButton());
+ UiCloseOverlay.add(`WoltLabSuite/Core/Ui/PageMenu/Container-${menuId}`, () => {
+ if (!this.container.hidden) {
+ this.close();
+ }
+ });
}
open(): void {
+ UiCloseOverlay.execute();
+
this.buildElements();
this.content.innerHTML = "";
};
}
+type CallbackOpen = (event: MouseEvent) => void;
+
export class PageMenuMain implements PageMenuProvider {
+ private readonly callbackOpen: CallbackOpen;
private readonly container: PageMenuContainer;
private readonly mainMenu: HTMLElement;
this.container = new PageMenuContainer(this);
- this.mainMenu.addEventListener("click", (event) => {
+ this.callbackOpen = (event) => {
event.preventDefault();
+ event.stopPropagation();
this.container.toggle();
- });
+ };
+ }
+
+ enable(): void {
+ this.mainMenu.setAttribute("aria-expanded", "false");
+ this.mainMenu.setAttribute("role", "button");
+ this.mainMenu.tabIndex = 0;
+ this.mainMenu.addEventListener("click", this.callbackOpen);
+ }
+
+ disable(): void {
+ this.container.close();
+
+ this.mainMenu.removeAttribute("aria-expanded");
+ this.mainMenu.removeAttribute("role");
+ this.mainMenu.removeAttribute("tabindex");
+ this.mainMenu.removeEventListener("click", this.callbackOpen);
}
getContent(): DocumentFragment {
export interface PageMenuProvider {
+ disable(): void;
+
+ enable(): void;
+
getContent(): DocumentFragment;
getMenuButton(): HTMLElement;
* @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/User", "./Screen"], function (require, exports, tslib_1, Core, Listener_1, Environment, EventHandler, UiAlignment, CloseOverlay_1, UiDropdownReusable, User_1, UiScreen) {
+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) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeShadow = exports.rebuildShadow = exports.disableShadow = exports.disable = exports.enableShadow = exports.enable = exports.setup = void 0;
let _enableMobileMenu = false;
const _knownMessages = new WeakSet();
let _mobileSidebarEnabled = false;
- //let _pageMenuMain: UiPageMenuMain;
+ let _pageMenuMain;
let _pageMenuUser = undefined;
let _messageGroups = null;
const _sidebars = [];
}
function initMobileMenu() {
if (_enableMobileMenu) {
- //_pageMenuMain = new UiPageMenuMain();
+ _pageMenuMain = new Main_1.PageMenuMain();
+ _pageMenuMain.enable();
if (User_1.default.hasValidMenu()) {
_pageMenuUser = new User_1.default();
}
function enable() {
_enabled = true;
if (_enableMobileMenu) {
- //_pageMenuMain.enable();
+ _pageMenuMain.enable();
_pageMenuUser === null || _pageMenuUser === void 0 ? void 0 : _pageMenuUser.enable();
}
}
function disable() {
_enabled = false;
if (_enableMobileMenu) {
- //_pageMenuMain.disable();
+ _pageMenuMain.disable();
_pageMenuUser === null || _pageMenuUser === void 0 ? void 0 : _pageMenuUser.disable();
}
}
-define(["require", "exports", "focus-trap", "../../Screen"], function (require, exports, focus_trap_1, Screen_1) {
+define(["require", "exports", "tslib", "focus-trap", "../../Screen", "../../CloseOverlay", "../../../Dom/Util"], function (require, exports, tslib_1, focus_trap_1, Screen_1, CloseOverlay_1, Util_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PageMenuContainer = void 0;
+ CloseOverlay_1 = (0, tslib_1.__importDefault)(CloseOverlay_1);
+ Util_1 = (0, tslib_1.__importDefault)(Util_1);
class PageMenuContainer {
constructor(provider) {
this.container = document.createElement("div");
this.content = document.createElement("div");
this.focusTrap = undefined;
this.provider = provider;
+ const menuId = Util_1.default.identify(this.provider.getMenuButton());
+ CloseOverlay_1.default.add(`WoltLabSuite/Core/Ui/PageMenu/Container-${menuId}`, () => {
+ if (!this.container.hidden) {
+ this.close();
+ }
+ });
}
open() {
+ CloseOverlay_1.default.execute();
this.buildElements();
this.content.innerHTML = "";
this.content.append(this.provider.getContent());
constructor() {
this.mainMenu = document.querySelector(".mainMenu");
this.container = new Container_1.default(this);
- this.mainMenu.addEventListener("click", (event) => {
+ this.callbackOpen = (event) => {
event.preventDefault();
+ event.stopPropagation();
this.container.toggle();
- });
+ };
+ }
+ enable() {
+ this.mainMenu.setAttribute("aria-expanded", "false");
+ this.mainMenu.setAttribute("role", "button");
+ this.mainMenu.tabIndex = 0;
+ this.mainMenu.addEventListener("click", this.callbackOpen);
+ }
+ disable() {
+ this.container.close();
+ this.mainMenu.removeAttribute("aria-expanded");
+ this.mainMenu.removeAttribute("role");
+ this.mainMenu.removeAttribute("tabindex");
+ this.mainMenu.removeEventListener("click", this.callbackOpen);
}
getContent() {
const container = document.createElement("div");