From a5e60f47b6e771ceeb5ad6d65dbf2b466a9b7d0c Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Fri, 13 Oct 2023 09:49:21 +0000 Subject: [PATCH] gear_menu: Move from TS to normal JS module. Need to convert gear menu to popover. --- tools/test-js-with-node | 2 +- web/src/{gear_menu.ts => gear_menu.js} | 8 ++++---- web/src/invite.ts | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) rename web/src/{gear_menu.ts => gear_menu.js} (96%) diff --git a/tools/test-js-with-node b/tools/test-js-with-node index 0de9547569..de13922e78 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -104,7 +104,7 @@ EXEMPT_FILES = make_set( "web/src/favicon.ts", "web/src/feedback_widget.ts", "web/src/flatpickr.ts", - "web/src/gear_menu.ts", + "web/src/gear_menu.js", "web/src/giphy.js", "web/src/global.d.ts", "web/src/hash_util.ts", diff --git a/web/src/gear_menu.ts b/web/src/gear_menu.js similarity index 96% rename from web/src/gear_menu.ts rename to web/src/gear_menu.js index ca3d158daf..4c03c1661a 100644 --- a/web/src/gear_menu.ts +++ b/web/src/gear_menu.js @@ -79,7 +79,7 @@ The click handler uses "[data-overlay-trigger]" as the selector and then calls browser_history.go_to_location. */ -export function initialize(): void { +export function initialize() { const rendered_gear_menu = render_gear_menu({ realm_name: page_params.realm_name, realm_url: new URL(page_params.realm_uri).hostname, @@ -108,17 +108,17 @@ export function initialize(): void { $("#navbar-buttons").html(rendered_gear_menu); } -export function open(): void { +export function open() { $("#settings-dropdown").trigger("click"); // there are invisible li tabs, which should not be clicked. $("#gear-menu").find("li:not(.invisible) a").eq(0).trigger("focus"); } -export function is_open(): boolean { +export function is_open() { return $(".dropdown").hasClass("open"); } -export function close(): void { +export function close() { if (is_open()) { $(".dropdown").removeClass("open"); } diff --git a/web/src/invite.ts b/web/src/invite.ts index e9c1f6fe2b..ed95cbe7d3 100644 --- a/web/src/invite.ts +++ b/web/src/invite.ts @@ -13,7 +13,6 @@ import * as channel from "./channel"; import * as common from "./common"; import {csrf_token} from "./csrf"; import * as dialog_widget from "./dialog_widget"; -import * as gear_menu from "./gear_menu"; import {$t, $t_html} from "./i18n"; import {page_params} from "./page_params"; import * as scroll_util from "./scroll_util"; @@ -276,7 +275,10 @@ function open_invite_user_modal(e: JQuery.ClickEvent): void e.stopPropagation(); e.preventDefault(); - gear_menu.close(); + const $gear_menu = $("#gear-menu"); + if ($gear_menu.hasClass("open")) { + $gear_menu.removeClass("open"); + } const time_unit_choices = ["minutes", "hours", "days", "weeks"]; const html_body = render_invite_user_modal({