mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
refactor: Extract settings_toggle.js.
This mostly moves code, and we also abandon the lookup mechanism for finding our toggler.
This commit is contained in:
50
static/js/settings_toggle.js
Normal file
50
static/js/settings_toggle.js
Normal file
@@ -0,0 +1,50 @@
|
||||
var settings_toggle = (function () {
|
||||
|
||||
var exports = {};
|
||||
|
||||
var toggler;
|
||||
|
||||
exports.highlight_toggle = function (tab_name) {
|
||||
if (toggler) {
|
||||
toggler.goto(tab_name, { dont_switch_tab: true });
|
||||
}
|
||||
};
|
||||
|
||||
exports.create_toggler = function () {
|
||||
toggler = components.toggle({
|
||||
name: "settings-toggle",
|
||||
values: [
|
||||
{ label: i18n.t("Settings"), key: "settings" },
|
||||
{ label: i18n.t("Organization"), key: "organization" },
|
||||
],
|
||||
callback: function (name, key, payload) {
|
||||
$(".sidebar li").hide();
|
||||
|
||||
if (key === "organization") {
|
||||
$("li.admin").show();
|
||||
if (!payload.dont_switch_tab) {
|
||||
$("li[data-section='organization-profile']").click();
|
||||
}
|
||||
} else {
|
||||
$(".settings-list li:not(.admin)").show();
|
||||
if (!payload.dont_switch_tab) {
|
||||
$("li[data-section='your-account']").click();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
$("#settings_overlay_container .tab-container").append(toggler.get());
|
||||
};
|
||||
|
||||
exports.initialize = function () {
|
||||
i18n.ensure_i18n(exports.create_toggler);
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
||||
}());
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = settings_toggle;
|
||||
}
|
||||
Reference in New Issue
Block a user