2018-06-03 17:29:11 +02:00
|
|
|
var settings_panel_menu = (function () {
|
|
|
|
|
|
|
|
var exports = {};
|
|
|
|
|
|
|
|
exports.make_menu = function (opts) {
|
|
|
|
var main_elem = opts.main_elem;
|
2018-06-03 17:59:33 +02:00
|
|
|
var hash_prefix = opts.hash_prefix;
|
|
|
|
var load_section = opts.load_section;
|
2018-06-03 19:12:11 +02:00
|
|
|
var curr_li = main_elem.children('li').eq(0);
|
2018-06-03 17:29:11 +02:00
|
|
|
|
|
|
|
var self = {};
|
|
|
|
|
|
|
|
self.show = function () {
|
|
|
|
main_elem.show();
|
2018-06-03 19:12:11 +02:00
|
|
|
self.activate_section({
|
|
|
|
li_elem: curr_li,
|
|
|
|
});
|
2018-06-03 17:29:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
self.hide = function () {
|
|
|
|
main_elem.hide();
|
|
|
|
};
|
|
|
|
|
2018-06-03 19:12:11 +02:00
|
|
|
self.current_tab = function () {
|
|
|
|
return curr_li.data('section');
|
|
|
|
};
|
|
|
|
|
2018-06-03 17:59:33 +02:00
|
|
|
self.activate_section = function (opts) {
|
|
|
|
var li_elem = opts.li_elem;
|
|
|
|
var section = li_elem.data('section');
|
|
|
|
|
2018-06-03 19:12:11 +02:00
|
|
|
curr_li = li_elem;
|
|
|
|
|
2018-06-03 17:59:33 +02:00
|
|
|
main_elem.children("li").removeClass("active no-border");
|
|
|
|
li_elem.addClass("active");
|
|
|
|
li_elem.prev().addClass("no-border");
|
|
|
|
window.location.hash = hash_prefix + section;
|
|
|
|
|
|
|
|
$(".settings-section, .settings-wrapper").removeClass("show");
|
|
|
|
|
|
|
|
ui.update_scrollbar($("#settings_content"));
|
|
|
|
|
|
|
|
load_section(section);
|
|
|
|
|
|
|
|
var sel = "[data-name='" + section + "']";
|
|
|
|
$(".settings-section" + sel + ", .settings-wrapper" + sel).addClass("show");
|
|
|
|
};
|
|
|
|
|
|
|
|
main_elem.on("click", "li[data-section]", function (e) {
|
|
|
|
self.activate_section({
|
|
|
|
li_elem: $(this),
|
|
|
|
});
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
|
2018-06-03 17:29:11 +02:00
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.initialize = function () {
|
|
|
|
exports.normal_settings = exports.make_menu({
|
|
|
|
main_elem: $('.normal-settings-list'),
|
2018-06-03 17:59:33 +02:00
|
|
|
hash_prefix: "settings/",
|
|
|
|
load_section: function (section) {
|
|
|
|
settings_sections.load_settings_section(section);
|
|
|
|
},
|
2018-06-03 17:29:11 +02:00
|
|
|
});
|
|
|
|
exports.org_settings = exports.make_menu({
|
|
|
|
main_elem: $('.org-settings-list'),
|
2018-06-03 17:59:33 +02:00
|
|
|
hash_prefix: "organization/",
|
|
|
|
load_section: function (section) {
|
|
|
|
admin_sections.load_admin_section(section);
|
|
|
|
},
|
2018-06-03 17:29:11 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|