mirror of
https://github.com/zulip/zulip.git
synced 2025-11-20 06:28:23 +00:00
js: Convert static/js/gear_menu.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
fb93be0d94
commit
b408565111
@@ -144,7 +144,6 @@
|
|||||||
"emoji_picker": false,
|
"emoji_picker": false,
|
||||||
"favicon": false,
|
"favicon": false,
|
||||||
"flatpickr": false,
|
"flatpickr": false,
|
||||||
"gear_menu": false,
|
|
||||||
"hash_util": false,
|
"hash_util": false,
|
||||||
"hashchange": false,
|
"hashchange": false,
|
||||||
"helpers": false,
|
"helpers": false,
|
||||||
|
|||||||
@@ -35,9 +35,12 @@ const emoji_picker = set_global("emoji_picker", {
|
|||||||
set_global("hotspots", {
|
set_global("hotspots", {
|
||||||
is_open: () => false,
|
is_open: () => false,
|
||||||
});
|
});
|
||||||
const gear_menu = set_global("gear_menu", {
|
const gear_menu = {
|
||||||
|
__esModule: true,
|
||||||
is_open: () => false,
|
is_open: () => false,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
rewiremock("../../static/js/gear_menu").with(gear_menu);
|
||||||
|
|
||||||
// Important note on these tests:
|
// Important note on these tests:
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ rewiremock("../../static/js/click_handlers").with({initialize() {}});
|
|||||||
rewiremock("../../static/js/compose_pm_pill").with({initialize() {}});
|
rewiremock("../../static/js/compose_pm_pill").with({initialize() {}});
|
||||||
rewiremock("../../static/js/drafts").with({initialize() {}});
|
rewiremock("../../static/js/drafts").with({initialize() {}});
|
||||||
set_global("emoji_picker", {initialize() {}});
|
set_global("emoji_picker", {initialize() {}});
|
||||||
set_global("gear_menu", {initialize() {}});
|
rewiremock("../../static/js/gear_menu").with({initialize() {}});
|
||||||
set_global("hashchange", {initialize() {}});
|
set_global("hashchange", {initialize() {}});
|
||||||
set_global("hotspots", {initialize() {}});
|
set_global("hotspots", {initialize() {}});
|
||||||
// Accesses home_msg_list, which is a lot of complexity to set up
|
// Accesses home_msg_list, which is a lot of complexity to set up
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ set_global("settings_users", {
|
|||||||
update_user_data() {},
|
update_user_data() {},
|
||||||
});
|
});
|
||||||
|
|
||||||
set_global("gear_menu", {
|
rewiremock("../../static/js/gear_menu").with({
|
||||||
update_org_settings_menu_item() {},
|
update_org_settings_menu_item() {},
|
||||||
});
|
});
|
||||||
const page_params = set_global("page_params", {
|
const page_params = set_global("page_params", {
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import "../reload";
|
|||||||
import "../compose_actions";
|
import "../compose_actions";
|
||||||
import "../subs";
|
import "../subs";
|
||||||
import "../ui";
|
import "../ui";
|
||||||
import "../gear_menu";
|
|
||||||
import "../stream_popover";
|
import "../stream_popover";
|
||||||
import "../popovers";
|
import "../popovers";
|
||||||
import "../overlays";
|
import "../overlays";
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
"use strict";
|
import * as message_viewport from "./message_viewport";
|
||||||
|
|
||||||
const message_viewport = require("./message_viewport");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
For various historical reasons there isn't one
|
For various historical reasons there isn't one
|
||||||
@@ -78,17 +76,17 @@ the selector and then calls hash_change.go_to_location.
|
|||||||
// when we switch back.)
|
// when we switch back.)
|
||||||
const scroll_positions = new Map();
|
const scroll_positions = new Map();
|
||||||
|
|
||||||
exports.update_org_settings_menu_item = function () {
|
export function update_org_settings_menu_item() {
|
||||||
const item = $(".admin-menu-item").expectOne();
|
const item = $(".admin-menu-item").expectOne();
|
||||||
if (page_params.is_admin) {
|
if (page_params.is_admin) {
|
||||||
item.find("span").text(i18n.t("Manage organization"));
|
item.find("span").text(i18n.t("Manage organization"));
|
||||||
} else {
|
} else {
|
||||||
item.find("span").text(i18n.t("Organization settings"));
|
item.find("span").text(i18n.t("Organization settings"));
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.initialize = function () {
|
export function initialize() {
|
||||||
exports.update_org_settings_menu_item();
|
update_org_settings_menu_item();
|
||||||
|
|
||||||
$('#gear-menu a[data-toggle="tab"]').on("show", (e) => {
|
$('#gear-menu a[data-toggle="tab"]').on("show", (e) => {
|
||||||
// Save the position of our old tab away, before we switch
|
// Save the position of our old tab away, before we switch
|
||||||
@@ -121,22 +119,20 @@ exports.initialize = function () {
|
|||||||
|
|
||||||
// The admin and settings pages are generated client-side through
|
// The admin and settings pages are generated client-side through
|
||||||
// templates.
|
// templates.
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.open = function () {
|
export function open() {
|
||||||
$("#settings-dropdown").trigger("click");
|
$("#settings-dropdown").trigger("click");
|
||||||
// there are invisible li tabs, which should not be clicked.
|
// there are invisible li tabs, which should not be clicked.
|
||||||
$("#gear-menu").find("li:not(.invisible) a").eq(0).trigger("focus");
|
$("#gear-menu").find("li:not(.invisible) a").eq(0).trigger("focus");
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.is_open = function () {
|
export function is_open() {
|
||||||
return $(".dropdown").hasClass("open");
|
return $(".dropdown").hasClass("open");
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.close = function () {
|
export function close() {
|
||||||
if (exports.is_open()) {
|
if (is_open()) {
|
||||||
$(".dropdown").removeClass("open");
|
$(".dropdown").removeClass("open");
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
window.gear_menu = exports;
|
|
||||||
|
|||||||
1
static/js/global.d.ts
vendored
1
static/js/global.d.ts
vendored
@@ -21,7 +21,6 @@ declare let current_msg_list: any;
|
|||||||
declare let emoji: any;
|
declare let emoji: any;
|
||||||
declare let emoji_picker: any;
|
declare let emoji_picker: any;
|
||||||
declare let favicon: any;
|
declare let favicon: any;
|
||||||
declare let gear_menu: any;
|
|
||||||
declare let hashchange: any;
|
declare let hashchange: any;
|
||||||
declare let hash_util: any;
|
declare let hash_util: any;
|
||||||
declare let helpers: any;
|
declare let helpers: any;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const condense = require("./condense");
|
|||||||
const copy_and_paste = require("./copy_and_paste");
|
const copy_and_paste = require("./copy_and_paste");
|
||||||
const drafts = require("./drafts");
|
const drafts = require("./drafts");
|
||||||
const feedback_widget = require("./feedback_widget");
|
const feedback_widget = require("./feedback_widget");
|
||||||
|
const gear_menu = require("./gear_menu");
|
||||||
const lightbox = require("./lightbox");
|
const lightbox = require("./lightbox");
|
||||||
const message_edit = require("./message_edit");
|
const message_edit = require("./message_edit");
|
||||||
const muting_ui = require("./muting_ui");
|
const muting_ui = require("./muting_ui");
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const copy_and_paste = require("./copy_and_paste");
|
|||||||
const drafts = require("./drafts");
|
const drafts = require("./drafts");
|
||||||
const echo = require("./echo");
|
const echo = require("./echo");
|
||||||
const emojisets = require("./emojisets");
|
const emojisets = require("./emojisets");
|
||||||
|
const gear_menu = require("./gear_menu");
|
||||||
const invite = require("./invite");
|
const invite = require("./invite");
|
||||||
const lightbox = require("./lightbox");
|
const lightbox = require("./lightbox");
|
||||||
const markdown = require("./markdown");
|
const markdown = require("./markdown");
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
// dependencies that existed when this code was in people.js.
|
// dependencies that existed when this code was in people.js.
|
||||||
// (We should do bot updates here too.)
|
// (We should do bot updates here too.)
|
||||||
const compose = require("./compose");
|
const compose = require("./compose");
|
||||||
|
const gear_menu = require("./gear_menu");
|
||||||
const message_live_update = require("./message_live_update");
|
const message_live_update = require("./message_live_update");
|
||||||
const narrow_state = require("./narrow_state");
|
const narrow_state = require("./narrow_state");
|
||||||
const people = require("./people");
|
const people = require("./people");
|
||||||
|
|||||||
Reference in New Issue
Block a user