Extract settings_lab.js.

This commit is contained in:
Steve Howell 2017-04-06 08:47:36 -07:00 committed by Tim Abbott
parent 89128a2272
commit f37ce1eeb1
5 changed files with 49 additions and 30 deletions

View File

@ -36,6 +36,7 @@
"settings_display": false,
"settings_notifications": false,
"settings_muting": false,
"settings_lab": false,
"settings": false,
"resize": false,
"loading": false,

View File

@ -238,7 +238,6 @@ function _setup_page() {
});
$(".settings-box").html(settings_tab);
$("#ui-settings-status").hide();
alert_words_ui.set_up_alert_words();
attachments_ui.set_up_attachments();
@ -246,6 +245,7 @@ function _setup_page() {
settings_display.set_up();
settings_notifications.set_up();
settings_muting.set_up();
settings_lab.set_up();
$("#api_key_value").text("");
$("#get_api_key_box").hide();
@ -546,35 +546,6 @@ function _setup_page() {
$("#inactive_bots_list").show();
});
$("#ui-settings").on("click", "input[name='change_settings']", 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());
},
});
});
}
exports.setup_page = function () {

44
static/js/settings_lab.js Normal file
View File

@ -0,0 +1,44 @@
var settings_lab = (function () {
var exports = {};
exports.set_up = function () {
$("#ui-settings-status").hide();
$("#ui-settings").on("click", "input[name='change_settings']", 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;
}

View File

@ -92,6 +92,8 @@ def find_edges_to_remove(graph, methods):
('compose', 'echo'),
('compose', 'resize'),
('settings', 'resize'),
('settings', 'settings_lab'),
('settings_lab', 'resize'),
('compose', 'unread_ops'),
('compose', 'drafts'),
('echo', 'message_edit'),

View File

@ -909,6 +909,7 @@ JS_SPECS = {
'js/settings_display.js',
'js/settings_notifications.js',
'js/settings_muting.js',
'js/settings_lab.js',
'js/settings.js',
'js/admin.js',
'js/tab_bar.js',