2018-04-14 16:06:51 +02:00
|
|
|
var settings_toggle = (function () {
|
|
|
|
|
|
|
|
var exports = {};
|
|
|
|
|
|
|
|
var toggler;
|
|
|
|
|
|
|
|
exports.highlight_toggle = function (tab_name) {
|
|
|
|
if (toggler) {
|
2018-06-03 19:12:11 +02:00
|
|
|
toggler.goto(tab_name);
|
2018-04-14 16:06:51 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-05-30 18:02:29 +02:00
|
|
|
exports.initialize = function () {
|
2018-04-14 16:06:51 +02:00
|
|
|
toggler = components.toggle({
|
2018-06-03 12:42:43 +02:00
|
|
|
child_wants_focus: true,
|
2018-04-14 16:06:51 +02:00
|
|
|
values: [
|
|
|
|
{ label: i18n.t("Settings"), key: "settings" },
|
|
|
|
{ label: i18n.t("Organization"), key: "organization" },
|
|
|
|
],
|
2018-06-03 19:12:11 +02:00
|
|
|
callback: function (name, key) {
|
2018-04-14 16:06:51 +02:00
|
|
|
if (key === "organization") {
|
2018-06-03 17:29:11 +02:00
|
|
|
settings_panel_menu.show_org_settings();
|
2018-04-14 16:06:51 +02:00
|
|
|
} else {
|
2018-06-03 17:29:11 +02:00
|
|
|
settings_panel_menu.show_normal_settings();
|
2018-04-14 16:06:51 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2018-06-03 12:42:43 +02:00
|
|
|
settings_panel_menu.set_key_handlers(toggler);
|
|
|
|
|
2018-04-14 16:06:51 +02:00
|
|
|
$("#settings_overlay_container .tab-container").append(toggler.get());
|
|
|
|
};
|
|
|
|
|
2019-05-13 00:43:21 +02:00
|
|
|
// Handles the collapse/reveal of some tabs in the org settings for non-admins.
|
|
|
|
exports.toggle_org_setting_collapse = function () {
|
|
|
|
var is_collapsed = $(".collapse-org-settings").hasClass("hide-org-settings");
|
|
|
|
var show_fewer_settings_text = i18n.t("Show fewer");
|
|
|
|
var show_more_settings_text = i18n.t("Show more");
|
|
|
|
|
|
|
|
if (is_collapsed) {
|
|
|
|
_.each($(".collapse-org-settings"), function (elem) {
|
|
|
|
$(elem).removeClass("hide-org-settings");
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#toggle_collapse_chevron").removeClass("fa-angle-double-down");
|
|
|
|
$("#toggle_collapse_chevron").addClass("fa-angle-double-up");
|
|
|
|
|
|
|
|
$("#toggle_collapse").text(show_fewer_settings_text);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
_.each($(".collapse-org-settings"), function (elem) {
|
|
|
|
$(elem).addClass("hide-org-settings");
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#toggle_collapse_chevron").removeClass("fa-angle-double-up");
|
|
|
|
$("#toggle_collapse_chevron").addClass("fa-angle-double-down");
|
|
|
|
|
|
|
|
$("#toggle_collapse").text(show_more_settings_text);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If current tab is about to be collapsed, go to default tab.
|
|
|
|
var current_tab = $(".org-settings-list .active");
|
|
|
|
if (current_tab.hasClass("hide-org-settings")) {
|
|
|
|
$(location).attr("href", "/#organization/organization-profile");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-04-14 16:06:51 +02:00
|
|
|
return exports;
|
|
|
|
|
|
|
|
}());
|
|
|
|
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = settings_toggle;
|
|
|
|
}
|
2018-05-28 08:04:36 +02:00
|
|
|
window.settings_toggle = settings_toggle;
|