Files
zulip/static/js/settings_toggle.js
Steve Howell 5f53fb1561 refactor: Remove factory code for toggle component.
We now have components.toggle simply return an object, without
putting the object into a lookup table.  The consumers of the
objects have all been changed to just store the object in their
own module scope.

The diff is a bit hard to read here, but it's mostly de-denting
code and removing these things:

        - we don't have opts.name
        - we don't have __toggle.lookup
        - we don't have keys
        - we don't create a sibling object to the prototype object
2018-04-20 13:45:58 -07:00

50 lines
1.2 KiB
JavaScript

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({
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;
}