mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 10:26:28 +00:00
navbar_help_menu: Migrate module to typescript.
Signed-off-by: sayyedarib <sayyedaribhussain4321@gmail.com>
This commit is contained in:
committed by
Anders Kaseorg
parent
2cf8f1c063
commit
b430ba2bd5
52
web/src/navbar_help_menu.ts
Normal file
52
web/src/navbar_help_menu.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import $ from "jquery";
|
||||
|
||||
import render_navbar_help_menu from "../templates/navbar_help_menu.hbs";
|
||||
|
||||
import {page_params} from "./page_params";
|
||||
import * as popover_menus from "./popover_menus";
|
||||
import {parse_html} from "./ui_util";
|
||||
|
||||
export function initialize(): void {
|
||||
popover_menus.register_popover_menu("#help-menu", {
|
||||
theme: "navbar-dropdown-menu",
|
||||
placement: "bottom",
|
||||
offset: [-50, 0],
|
||||
// The strategy: "fixed"; and eventlisteners modifier option
|
||||
// ensure that the personal menu does not modify its position
|
||||
// or disappear when user zooms the page.
|
||||
popperOptions: {
|
||||
strategy: "fixed",
|
||||
modifiers: [
|
||||
{
|
||||
name: "eventListeners",
|
||||
options: {
|
||||
scroll: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
onMount(instance) {
|
||||
popover_menus.popover_instances.help_menu = instance;
|
||||
},
|
||||
onShow(instance) {
|
||||
instance.setContent(
|
||||
parse_html(
|
||||
render_navbar_help_menu({
|
||||
corporate_enabled: page_params.corporate_enabled,
|
||||
}),
|
||||
),
|
||||
);
|
||||
},
|
||||
onHidden(instance) {
|
||||
instance.destroy();
|
||||
popover_menus.popover_instances.help_menu = null;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function toggle(): void {
|
||||
// NOTE: Since to open help menu, you need to click on help navbar icon (which calls
|
||||
// tippyjs.hideAll()), or go via gear menu if using hotkeys, we don't need to
|
||||
// call tippyjs.hideAll() for it.
|
||||
$("#help-menu").trigger("click");
|
||||
}
|
||||
Reference in New Issue
Block a user