forked from zulip/zulip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings_lab.js
43 lines (35 loc) · 1.47 KB
/
settings_lab.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var settings_lab = (function () {
var exports = {};
exports.set_up = function () {
$("#ui-settings-status").hide();
$("#ui-settings .change-setting").change(function (e) {
e.preventDefault();
var labs_updates = {};
_.each(["autoscroll_forever", "default_desktop_notifications"],
function (setting) {
labs_updates[setting] = $("#" + setting).is(":checked");
});
channel.patch({
url: '/json/settings/ui',
data: labs_updates,
success: function (resp, statusText, xhr) {
var message = i18n.t("Updated settings! You will need to reload for these changes to take effect.", page_params);
var result = JSON.parse(xhr.responseText);
var ui_settings_status = $('#ui-settings-status').expectOne();
if (result.autoscroll_forever !== undefined) {
page_params.autoscroll_forever = result.autoscroll_forever;
resize.resize_page_components();
}
ui_report.success(message, ui_settings_status);
},
error: function (xhr) {
ui_report.error(i18n.t("Error changing settings"), xhr, $('#ui-settings-status').expectOne());
},
});
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = settings_lab;
}