2013-05-03 00:29:52 +02:00
|
|
|
var settings = (function () {
|
|
|
|
|
|
|
|
var exports = {};
|
2017-08-28 01:21:16 +02:00
|
|
|
var map;
|
2013-06-14 20:03:54 +02:00
|
|
|
|
2017-03-01 01:31:33 +01:00
|
|
|
$("body").ready(function () {
|
|
|
|
var $sidebar = $(".form-sidebar");
|
|
|
|
var $targets = $sidebar.find("[data-target]");
|
|
|
|
var $title = $sidebar.find(".title h1");
|
|
|
|
var is_open = false;
|
|
|
|
|
|
|
|
var close_sidebar = function () {
|
|
|
|
$sidebar.removeClass("show");
|
2018-02-07 10:34:52 +01:00
|
|
|
$sidebar.find("#edit_bot").empty();
|
2017-03-01 01:31:33 +01:00
|
|
|
is_open = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.trigger_sidebar = function (target) {
|
|
|
|
$targets.hide();
|
|
|
|
var $target = $(".form-sidebar").find("[data-target='" + target + "']");
|
|
|
|
|
|
|
|
$title.text($target.attr("data-title"));
|
|
|
|
$target.show();
|
|
|
|
|
|
|
|
$sidebar.addClass("show");
|
|
|
|
is_open = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
$(".form-sidebar .exit").click(function (e) {
|
|
|
|
close_sidebar();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
|
|
|
|
$("body").click(function (e) {
|
|
|
|
if (is_open && !$(e.target).within(".form-sidebar")) {
|
|
|
|
close_sidebar();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("body").on("click", "[data-sidebar-form]", function (e) {
|
|
|
|
exports.trigger_sidebar($(this).attr("data-sidebar-form"));
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
|
|
|
|
$("body").on("click", "[data-sidebar-form-close]", close_sidebar);
|
2017-08-29 19:06:31 +02:00
|
|
|
|
|
|
|
$("#settings_overlay_container").click(function (e) {
|
|
|
|
if (!overlays.is_modal_open()) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-16 12:44:42 +02:00
|
|
|
if ($(e.target).closest(".modal").length > 0) {
|
|
|
|
return;
|
|
|
|
}
|
2017-08-29 19:06:31 +02:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
overlays.close_active_modal();
|
|
|
|
});
|
2017-03-01 01:31:33 +01:00
|
|
|
});
|
|
|
|
|
2018-03-24 13:44:16 +01:00
|
|
|
function setup_settings_label() {
|
|
|
|
exports.settings_label = {
|
|
|
|
// settings_notification
|
|
|
|
// stream_notification_settings
|
|
|
|
enable_stream_desktop_notifications: i18n.t("Visual desktop notifications"),
|
|
|
|
enable_stream_sounds: i18n.t("Audible desktop notifications"),
|
|
|
|
enable_stream_push_notifications: i18n.t("Mobile notifications"),
|
|
|
|
|
|
|
|
// pm_mention_notification_settings
|
|
|
|
enable_desktop_notifications: i18n.t("Visual desktop notifications"),
|
|
|
|
enable_offline_email_notifications: i18n.t("Email notifications when offline"),
|
|
|
|
enable_offline_push_notifications: i18n.t("Mobile notifications when offline"),
|
|
|
|
enable_online_push_notifications: i18n.t("Mobile notifications always (even when online)"),
|
|
|
|
enable_sounds: i18n.t("Audible desktop notifications"),
|
|
|
|
pm_content_in_desktop_notifications: i18n.t("Include content of private messages"),
|
|
|
|
|
|
|
|
// other_notification_settings
|
|
|
|
enable_digest_emails: i18n.t("Send digest emails when I'm away"),
|
2018-04-07 20:17:04 +02:00
|
|
|
message_content_in_email_notifications: i18n.t("Include message content in missed message emails"),
|
2018-03-24 13:44:16 +01:00
|
|
|
realm_name_in_notifications: i18n.t("Include organization name in subject of missed message emails"),
|
2018-04-17 21:52:25 +02:00
|
|
|
|
|
|
|
// display settings
|
|
|
|
night_mode: i18n.t("Night mode"),
|
|
|
|
high_contrast_mode: i18n.t("High contrast mode"),
|
|
|
|
left_side_userlist: i18n.t("User list on left sidebar in narrow windows"),
|
|
|
|
twenty_four_hour_time: i18n.t("24-hour time (17:00 instead of 5:00 PM)"),
|
|
|
|
translate_emoticons: i18n.t("Translate emoticons (convert <code>:)</code> to 😃 in messages)"),
|
2018-03-24 13:44:16 +01:00
|
|
|
};
|
|
|
|
}
|
2017-03-01 01:31:33 +01:00
|
|
|
|
2016-06-10 09:03:36 +02:00
|
|
|
function _setup_page() {
|
2017-06-14 10:39:10 +02:00
|
|
|
ui.set_up_scrollbar($("#settings_page .sidebar.left"));
|
|
|
|
ui.set_up_scrollbar($("#settings_content"));
|
|
|
|
|
2017-05-09 22:09:13 +02:00
|
|
|
// only run once -- if the map has not already been initialized.
|
2017-08-28 01:21:16 +02:00
|
|
|
if (map === undefined) {
|
2017-05-09 22:09:13 +02:00
|
|
|
map = {
|
|
|
|
"your-account": i18n.t("Your account"),
|
|
|
|
"display-settings": i18n.t("Display settings"),
|
|
|
|
notifications: i18n.t("Notifications"),
|
|
|
|
"your-bots": i18n.t("Your bots"),
|
|
|
|
"alert-words": i18n.t("Alert words"),
|
|
|
|
"uploaded-files": i18n.t("Uploaded files"),
|
|
|
|
"muted-topics": i18n.t("Muted topics"),
|
2017-08-18 01:23:55 +02:00
|
|
|
"organization-profile": i18n.t("Organization profile"),
|
2017-05-09 22:09:13 +02:00
|
|
|
"organization-settings": i18n.t("Organization settings"),
|
2017-05-18 14:06:57 +02:00
|
|
|
"organization-permissions": i18n.t("Organization permissions"),
|
2017-05-09 22:09:13 +02:00
|
|
|
"emoji-settings": i18n.t("Emoji settings"),
|
|
|
|
"auth-methods": i18n.t("Authorization methods"),
|
|
|
|
"user-list-admin": i18n.t("Active users"),
|
|
|
|
"deactivated-users-admin": i18n.t("Deactivated users"),
|
|
|
|
"bot-list-admin": i18n.t("Bot list"),
|
|
|
|
"default-streams-list": i18n.t("Default streams"),
|
|
|
|
"filter-settings": i18n.t("Filter settings"),
|
2017-10-21 03:15:12 +02:00
|
|
|
"invites-list-admin": i18n.t("Invitations"),
|
2017-11-13 05:20:42 +01:00
|
|
|
"user-groups-admin": i18n.t("User groups"),
|
2017-12-14 05:51:45 +01:00
|
|
|
"profile-field-settings": i18n.t("Profile field settings"),
|
2017-05-09 22:09:13 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-12-03 01:12:52 +01:00
|
|
|
var tab = (function () {
|
|
|
|
var tab = false;
|
|
|
|
var hash_sequence = window.location.hash.split(/\//);
|
|
|
|
if (/#*(settings)/.test(hash_sequence[0])) {
|
|
|
|
tab = hash_sequence[1];
|
|
|
|
return tab || "your-account";
|
|
|
|
}
|
|
|
|
return tab;
|
|
|
|
}());
|
|
|
|
|
2018-03-24 13:44:16 +01:00
|
|
|
setup_settings_label();
|
2018-01-29 16:10:54 +01:00
|
|
|
|
2018-03-22 22:10:08 +01:00
|
|
|
var rendered_settings_tab = templates.render('settings_tab', {
|
2017-01-20 23:49:20 +01:00
|
|
|
full_name: people.my_full_name(),
|
|
|
|
page_params: page_params,
|
|
|
|
zuliprc: 'zuliprc',
|
2017-05-30 16:12:02 +02:00
|
|
|
flaskbotrc: 'flaskbotrc',
|
2017-04-02 20:59:22 +02:00
|
|
|
timezones: moment.tz.names(),
|
2018-01-29 16:10:54 +01:00
|
|
|
admin_only_bot_creation: page_params.is_admin ||
|
|
|
|
page_params.realm_bot_creation_policy !==
|
|
|
|
settings_bots.bot_creation_policy_values.admins_only.code,
|
2018-03-24 13:44:16 +01:00
|
|
|
settings_label: settings.settings_label,
|
2017-01-20 23:49:20 +01:00
|
|
|
});
|
|
|
|
|
2018-03-22 22:10:08 +01:00
|
|
|
$(".settings-box").html(rendered_settings_tab);
|
2014-02-13 23:47:57 +01:00
|
|
|
|
2017-04-07 01:30:13 +02:00
|
|
|
// Since we just swapped in a whole new settings widget, we need to
|
|
|
|
// tell settings_sections nothing is loaded.
|
|
|
|
settings_sections.reset_sections();
|
2014-03-04 23:37:29 +01:00
|
|
|
|
2016-12-03 01:12:52 +01:00
|
|
|
if (tab) {
|
|
|
|
exports.launch_page(tab);
|
|
|
|
}
|
2016-06-10 09:03:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.setup_page = function () {
|
|
|
|
i18n.ensure_i18n(_setup_page);
|
2014-02-13 23:47:57 +01:00
|
|
|
};
|
2013-05-03 00:29:52 +02:00
|
|
|
|
2016-12-03 01:12:52 +01:00
|
|
|
exports.launch_page = function (tab) {
|
|
|
|
var $active_tab = $("#settings_overlay_container li[data-section='" + tab + "']");
|
|
|
|
|
|
|
|
if (!$active_tab.hasClass("admin")) {
|
2018-04-14 16:06:51 +02:00
|
|
|
settings_toggle.highlight_toggle('settings');
|
2016-12-03 01:12:52 +01:00
|
|
|
}
|
|
|
|
|
2017-05-27 15:40:54 +02:00
|
|
|
overlays.open_settings();
|
2017-05-06 01:04:45 +02:00
|
|
|
|
2016-12-03 01:12:52 +01:00
|
|
|
$active_tab.click();
|
|
|
|
};
|
|
|
|
|
2017-05-09 22:09:13 +02:00
|
|
|
exports.set_settings_header = function (key) {
|
|
|
|
if (map[key]) {
|
|
|
|
$(".settings-header h1 .section").text(" / " + map[key]);
|
|
|
|
} else {
|
|
|
|
blueslip.warn("Error: the key '" + key + "' does not exist in the settings" +
|
|
|
|
" header mapping file. Please add it.");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-04-04 19:59:04 +02:00
|
|
|
exports.handle_up_arrow = function (e) {
|
|
|
|
var prev = e.target.previousElementSibling;
|
|
|
|
|
|
|
|
if ($(prev).css("display") !== "none") {
|
|
|
|
$(prev).focus().click();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.handle_down_arrow = function (e) {
|
|
|
|
var next = e.target.nextElementSibling;
|
|
|
|
|
|
|
|
if ($(next).css("display") !== "none") {
|
|
|
|
$(next).focus().click();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-11-19 17:15:48 +01:00
|
|
|
return exports;
|
2013-06-27 23:05:36 +02:00
|
|
|
}());
|
2016-12-04 08:59:56 +01:00
|
|
|
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = settings;
|
|
|
|
}
|