mirror of https://github.com/zulip/zulip.git
refactor: Extract settings_panel_menu.js.
This commit is contained in:
parent
db514002ec
commit
8ce8e93645
|
@ -49,6 +49,7 @@
|
|||
"user_groups": false,
|
||||
"navigate": false,
|
||||
"toMarkdown": false,
|
||||
"settings_panel_menu": false,
|
||||
"settings_toggle": false,
|
||||
"settings_account": false,
|
||||
"settings_display": false,
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
var settings_panel_menu = (function () {
|
||||
|
||||
var exports = {};
|
||||
|
||||
exports.make_menu = function (opts) {
|
||||
var main_elem = opts.main_elem;
|
||||
|
||||
var self = {};
|
||||
|
||||
self.goto_top = function () {
|
||||
main_elem.children('li').eq(0).click();
|
||||
};
|
||||
|
||||
self.show = function () {
|
||||
main_elem.show();
|
||||
};
|
||||
|
||||
self.hide = function () {
|
||||
main_elem.hide();
|
||||
};
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
exports.initialize = function () {
|
||||
exports.normal_settings = exports.make_menu({
|
||||
main_elem: $('.normal-settings-list'),
|
||||
});
|
||||
exports.org_settings = exports.make_menu({
|
||||
main_elem: $('.org-settings-list'),
|
||||
});
|
||||
};
|
||||
|
||||
exports.show_normal_settings = function () {
|
||||
exports.org_settings.hide();
|
||||
exports.normal_settings.show();
|
||||
};
|
||||
|
||||
exports.show_org_settings = function () {
|
||||
exports.normal_settings.hide();
|
||||
exports.org_settings.show();
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
||||
}());
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = settings_panel_menu;
|
||||
}
|
|
@ -17,20 +17,15 @@ exports.initialize = function () {
|
|||
{ label: i18n.t("Organization"), key: "organization" },
|
||||
],
|
||||
callback: function (name, key, payload) {
|
||||
var normal_list = $('.normal-settings-list');
|
||||
var org_list = $('.org-settings-list');
|
||||
|
||||
if (key === "organization") {
|
||||
normal_list.hide();
|
||||
org_list.show();
|
||||
settings_panel_menu.show_org_settings();
|
||||
if (!payload.dont_switch_tab) {
|
||||
$("li[data-section='organization-profile']").click();
|
||||
settings_panel_menu.org_settings.goto_top();
|
||||
}
|
||||
} else {
|
||||
org_list.hide();
|
||||
normal_list.show();
|
||||
settings_panel_menu.show_normal_settings();
|
||||
if (!payload.dont_switch_tab) {
|
||||
$("li[data-section='your-account']").click();
|
||||
settings_panel_menu.normal_settings.goto_top();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -307,6 +307,7 @@ $(function () {
|
|||
tutorial.initialize();
|
||||
notifications.initialize();
|
||||
gear_menu.initialize();
|
||||
settings_panel_menu.initialize();
|
||||
settings_sections.initialize();
|
||||
settings_toggle.initialize();
|
||||
hashchange.initialize();
|
||||
|
|
|
@ -993,6 +993,7 @@ JS_SPECS = {
|
|||
'js/ui_util.js',
|
||||
'js/pointer.js',
|
||||
'js/click_handlers.js',
|
||||
'js/settings_panel_menu.js',
|
||||
'js/settings_toggle.js',
|
||||
'js/scroll_bar.js',
|
||||
'js/gear_menu.js',
|
||||
|
|
Loading…
Reference in New Issue