Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

gear_menu: Move from TS to normal JS module.

Aman Agrawala5e60f47b6e7
diff --git a/tools/test-js-with-node b/tools/test-js-with-node
index 0de9547569f..de13922e789 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 ca3d158dafe..4c03c1661ad 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 e9c1f6fe2bf..ed95cbe7d32 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<Document, undefined>): 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({