2020-02-21 14:26:11 +01:00
|
|
|
const settings_config = require("./settings_config");
|
2019-11-02 00:06:25 +01:00
|
|
|
const render_settings_tab = require('../templates/settings_tab.hbs');
|
2019-07-09 21:24:00 +02:00
|
|
|
|
2017-03-01 01:31:33 +01:00
|
|
|
$("body").ready(function () {
|
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();
|
2018-05-23 22:29:00 +02:00
|
|
|
// Whenever opening a modal(over settings overlay) in an event handler
|
|
|
|
// attached to a click event, make sure to stop the propagation of the
|
|
|
|
// event to the parent container otherwise the modal will not open. This
|
|
|
|
// is so because this event handler will get fired on any click in settings
|
|
|
|
// overlay and subsequently close any open modal.
|
2017-08-29 19:06:31 +02:00
|
|
|
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
|
2019-04-17 01:31:44 +02:00
|
|
|
enable_online_push_notifications: i18n.t("Send mobile notifications even if I'm online (useful for testing)"),
|
2019-04-20 00:42:32 +02:00
|
|
|
pm_content_in_desktop_notifications: i18n.t("Include content of private messages in desktop notifications"),
|
2019-07-23 04:44:10 +02:00
|
|
|
desktop_icon_count_display: i18n.t("Unread count summary (appears in desktop sidebar and browser tab)"),
|
2018-03-24 13:44:16 +01:00
|
|
|
enable_digest_emails: i18n.t("Send digest emails when I'm away"),
|
2018-08-24 07:28:51 +02:00
|
|
|
enable_login_emails: i18n.t("Send email notifications for new logins to my account"),
|
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"),
|
2020-05-01 20:39:26 +02:00
|
|
|
presence_enabled: i18n.t("Display my availability to other users when online"),
|
2018-04-17 21:52:25 +02:00
|
|
|
|
|
|
|
// display settings
|
2018-05-24 20:53:26 +02:00
|
|
|
dense_mode: i18n.t("Dense mode"),
|
2019-06-13 15:21:20 +02:00
|
|
|
fluid_layout_width: i18n.t("Use full width on wide screens"),
|
2018-04-17 21:52:25 +02:00
|
|
|
high_contrast_mode: i18n.t("High contrast mode"),
|
2020-03-20 22:11:17 +01:00
|
|
|
left_side_userlist: i18n.t("Show user list on left sidebar in narrow windows"),
|
2018-08-17 08:48:12 +02:00
|
|
|
starred_message_counts: i18n.t("Show counts for starred messages"),
|
2019-07-28 11:47:45 +02:00
|
|
|
twenty_four_hour_time: i18n.t("Time format"),
|
2018-08-16 00:05:25 +02:00
|
|
|
translate_emoticons: i18n.t("Convert emoticons before sending (<code>:)</code> becomes 😃)"),
|
2018-03-24 13:44:16 +01:00
|
|
|
};
|
|
|
|
}
|
2017-03-01 01:31:33 +01:00
|
|
|
|
2018-12-06 01:59:07 +01:00
|
|
|
exports.build_page = function () {
|
2018-03-24 13:44:16 +01:00
|
|
|
setup_settings_label();
|
2018-01-29 16:10:54 +01:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const rendered_settings_tab = render_settings_tab({
|
2017-01-20 23:49:20 +01:00
|
|
|
full_name: people.my_full_name(),
|
|
|
|
page_params: page_params,
|
2019-06-11 08:47:49 +02:00
|
|
|
enable_sound_select: page_params.enable_sounds ||
|
|
|
|
page_params.enable_stream_audible_notifications,
|
2017-01-20 23:49:20 +01:00
|
|
|
zuliprc: 'zuliprc',
|
2018-05-29 10:18:06 +02:00
|
|
|
botserverrc: 'botserverrc',
|
2017-04-02 20:59:22 +02:00
|
|
|
timezones: moment.tz.names(),
|
2018-06-13 16:59:15 +02:00
|
|
|
can_create_new_bots: settings_bots.can_create_new_bots(),
|
2019-10-25 09:45:13 +02:00
|
|
|
settings_label: exports.settings_label,
|
2020-02-21 14:26:11 +01:00
|
|
|
demote_inactive_streams_values: settings_config.demote_inactive_streams_values,
|
2020-05-16 13:13:59 +02:00
|
|
|
color_scheme_values: settings_config.color_scheme_values,
|
2020-02-21 14:26:11 +01:00
|
|
|
twenty_four_hour_time_values: settings_config.twenty_four_hour_time_values,
|
2020-03-28 18:03:43 +01:00
|
|
|
general_settings: settings_config.all_notifications().general_settings,
|
|
|
|
notification_settings: settings_config.all_notifications().settings,
|
2019-06-29 22:00:44 +02:00
|
|
|
desktop_icon_count_display_values: settings_notifications.desktop_icon_count_display_values,
|
2020-03-22 18:03:25 +01:00
|
|
|
show_push_notifications_tooltip:
|
2020-03-28 18:03:43 +01:00
|
|
|
settings_config.all_notifications().show_push_notifications_tooltip,
|
2020-02-21 14:26:11 +01:00
|
|
|
display_settings: settings_config.get_all_display_settings(),
|
2019-07-15 23:12:31 +02:00
|
|
|
user_can_change_name: settings_account.user_can_change_name(),
|
2019-08-11 16:34:42 +02:00
|
|
|
user_can_change_avatar: settings_account.user_can_change_avatar(),
|
2017-01-20 23:49:20 +01:00
|
|
|
});
|
|
|
|
|
2018-03-22 22:10:08 +01:00
|
|
|
$(".settings-box").html(rendered_settings_tab);
|
2018-12-06 01:59:07 +01:00
|
|
|
};
|
|
|
|
|
2018-12-06 20:18:56 +01:00
|
|
|
exports.launch = function (section) {
|
2018-12-06 01:59:07 +01:00
|
|
|
exports.build_page();
|
2018-12-06 20:18:56 +01:00
|
|
|
admin.build_page();
|
2018-12-08 19:28:26 +01:00
|
|
|
settings_sections.reset_sections();
|
2018-12-06 01:59:07 +01:00
|
|
|
|
2017-05-27 15:40:54 +02:00
|
|
|
overlays.open_settings();
|
2020-06-25 00:51:20 +02:00
|
|
|
settings_panel_menu.normal_settings.activate_section_or_default(section);
|
2018-12-06 20:18:56 +01:00
|
|
|
settings_toggle.highlight_toggle('settings');
|
2016-12-03 01:12:52 +01:00
|
|
|
};
|
|
|
|
|
2017-05-09 22:09:13 +02:00
|
|
|
exports.set_settings_header = function (key) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const header_text = $(`#settings_page .sidebar-list [data-section='${key}'] .text`).text();
|
2019-08-22 13:08:24 +02:00
|
|
|
if (header_text) {
|
|
|
|
$(".settings-header h1 .section").text(" / " + header_text);
|
2017-05-09 22:09:13 +02:00
|
|
|
} else {
|
|
|
|
blueslip.warn("Error: the key '" + key + "' does not exist in the settings" +
|
2019-08-22 13:08:24 +02:00
|
|
|
" sidebar list. Please add it.");
|
2017-05-09 22:09:13 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-10-25 09:45:13 +02:00
|
|
|
window.settings = exports;
|