2017-04-06 02:28:57 +02:00
|
|
|
var settings_account = (function () {
|
|
|
|
|
|
|
|
var exports = {};
|
|
|
|
|
|
|
|
exports.update_email = function (new_email) {
|
|
|
|
var email_input = $('#email_value');
|
|
|
|
|
|
|
|
if (email_input) {
|
|
|
|
email_input.text(new_email);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-02 01:24:26 +01:00
|
|
|
exports.update_full_name = function (new_full_name) {
|
|
|
|
var full_name_field = $("#change_full_name button #full_name_value");
|
|
|
|
if (full_name_field) {
|
|
|
|
full_name_field.text(new_full_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Arguably, this should work more like how the `update_email`
|
|
|
|
// flow works, where we update the name in the modal on open,
|
|
|
|
// rather than updating it here, but this works.
|
|
|
|
var full_name_input = $(".full_name_change_container input[name='full_name']");
|
|
|
|
if (full_name_input) {
|
|
|
|
full_name_input.val(new_full_name);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-03-02 21:44:14 +01:00
|
|
|
exports.update_name_change_display = function () {
|
|
|
|
if (page_params.realm_name_changes_disabled && !page_params.is_admin) {
|
2018-03-02 21:48:23 +01:00
|
|
|
$('#full_name').attr('disabled', 'disabled');
|
2018-03-02 21:44:14 +01:00
|
|
|
$(".change_name_tooltip").show();
|
|
|
|
} else {
|
2018-03-02 21:48:23 +01:00
|
|
|
$('#full_name').attr('disabled', false);
|
2018-03-02 21:44:14 +01:00
|
|
|
$(".change_name_tooltip").hide();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.update_email_change_display = function () {
|
|
|
|
if (page_params.realm_email_changes_disabled && !page_params.is_admin) {
|
2018-03-02 21:48:23 +01:00
|
|
|
$('#change_email .button').attr('disabled', 'disabled');
|
2018-03-02 21:44:14 +01:00
|
|
|
$(".change_email_tooltip").show();
|
|
|
|
} else {
|
2018-03-02 21:48:23 +01:00
|
|
|
$('#change_email .button').attr('disabled', false);
|
2018-03-02 21:44:14 +01:00
|
|
|
$(".change_email_tooltip").hide();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-04-06 02:28:57 +02:00
|
|
|
function settings_change_error(message, xhr) {
|
|
|
|
ui_report.error(message, xhr, $('#account-settings-status').expectOne());
|
|
|
|
}
|
|
|
|
|
|
|
|
function settings_change_success(message) {
|
|
|
|
ui_report.success(message, $('#account-settings-status').expectOne());
|
|
|
|
}
|
|
|
|
|
2018-05-25 20:58:14 +02:00
|
|
|
function update_user_custom_profile_fields(fields) {
|
|
|
|
var spinner = $("#custom-field-status").expectOne();
|
|
|
|
loading.make_indicator(spinner, {text: 'Saving ...'});
|
|
|
|
settings_ui.do_settings_change(channel.patch, "/json/users/me/profile_data",
|
|
|
|
{data: JSON.stringify(fields)}, spinner);
|
|
|
|
}
|
|
|
|
|
2018-04-04 16:21:05 +02:00
|
|
|
exports.add_custom_profile_fields_to_settings = function () {
|
2018-02-26 20:09:07 +01:00
|
|
|
var all_custom_fields = page_params.custom_profile_fields;
|
|
|
|
|
|
|
|
all_custom_fields.forEach(function (field) {
|
2018-05-01 19:33:33 +02:00
|
|
|
var field_type = settings_profile_fields.field_type_id_to_string(field.type);
|
2018-02-26 20:09:07 +01:00
|
|
|
var type;
|
|
|
|
var value = people.my_custom_profile_data(field.id);
|
2018-05-06 11:40:31 +02:00
|
|
|
var is_long_text = field_type === "Long text";
|
2018-05-04 16:46:46 +02:00
|
|
|
var is_choice_field = field_type === "Choice";
|
2018-05-09 13:58:29 +02:00
|
|
|
var is_user_field = field_type === "User";
|
2018-05-16 19:22:43 +02:00
|
|
|
var is_date_field = field_type === "Date";
|
2018-05-04 16:46:46 +02:00
|
|
|
var field_choices = [];
|
2018-02-26 20:09:07 +01:00
|
|
|
|
2018-05-06 11:40:31 +02:00
|
|
|
if (field_type === "Long text" || field_type === "Short text") {
|
2018-02-26 20:09:07 +01:00
|
|
|
type = "text";
|
2018-05-01 19:33:33 +02:00
|
|
|
} else if (field_type === "Choice") {
|
2018-04-08 09:50:05 +02:00
|
|
|
type = "choice";
|
2018-05-04 16:46:46 +02:00
|
|
|
var field_choice_dict = JSON.parse(field.field_data);
|
|
|
|
for (var choice in field_choice_dict) {
|
|
|
|
if (choice) {
|
|
|
|
field_choices[field_choice_dict[choice].order] = {
|
|
|
|
value: choice,
|
|
|
|
text: field_choice_dict[choice].text,
|
|
|
|
selected: choice === value,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2018-05-01 19:33:33 +02:00
|
|
|
} else if (field_type === "Date") {
|
2018-04-03 18:06:13 +02:00
|
|
|
type = "date";
|
2018-05-01 19:33:33 +02:00
|
|
|
} else if (field_type === "URL") {
|
2018-04-25 19:20:58 +02:00
|
|
|
type = "url";
|
2018-05-06 09:43:38 +02:00
|
|
|
} else if (field_type === "User") {
|
|
|
|
type = "user";
|
2018-02-26 20:09:07 +01:00
|
|
|
} else {
|
|
|
|
blueslip.error("Undefined field type.");
|
|
|
|
}
|
|
|
|
if (value === undefined) {
|
|
|
|
// If user has not set value for field.
|
|
|
|
value = "";
|
|
|
|
}
|
|
|
|
|
2018-05-06 21:43:17 +02:00
|
|
|
var html = templates.render("custom-user-profile-field", {
|
|
|
|
field: field,
|
|
|
|
field_type: type,
|
|
|
|
field_value: value,
|
|
|
|
is_long_text_field: is_long_text,
|
|
|
|
is_choice_field: is_choice_field,
|
2018-05-09 13:58:29 +02:00
|
|
|
is_user_field: is_user_field,
|
2018-05-16 19:22:43 +02:00
|
|
|
is_date_field: is_date_field,
|
2018-05-06 21:43:17 +02:00
|
|
|
field_choices: field_choices,
|
|
|
|
});
|
2018-02-26 20:09:07 +01:00
|
|
|
$("#account-settings .custom-profile-fields-form").append(html);
|
2018-05-09 13:58:29 +02:00
|
|
|
|
|
|
|
if (is_user_field) {
|
|
|
|
var pill_container = $('.custom_user_field[data-field-id="' + field.id + '"] .pill-container').expectOne();
|
|
|
|
var pills = user_pill.create_pills(pill_container);
|
|
|
|
|
|
|
|
function update_custom_user_field() {
|
|
|
|
var fields = [];
|
|
|
|
var user_id = user_pill.get_user_ids(pills);
|
|
|
|
if (user_id.length !== 1) {
|
|
|
|
ui_report.message(i18n.t("Only one user allowed"), $("#custom-field-status"), 'alert-error');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fields.push({id: field.id, value: user_id[0]});
|
|
|
|
update_user_custom_profile_fields(fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
var user = people.get_person_from_user_id(value);
|
|
|
|
user_pill.append_user(user, pills);
|
|
|
|
}
|
|
|
|
var input = pill_container.children('.input');
|
|
|
|
user_pill.set_up_typeahead_on_pills(input, pills, update_custom_user_field);
|
|
|
|
pills.onPillRemove(function () {
|
|
|
|
update_custom_user_field();
|
|
|
|
});
|
|
|
|
}
|
2018-02-26 20:09:07 +01:00
|
|
|
});
|
2018-05-16 19:22:43 +02:00
|
|
|
$(".custom_user_field .datepicker").flatpickr({
|
|
|
|
altInput: true,
|
|
|
|
altFormat: "F j, Y"});
|
2018-04-04 16:21:05 +02:00
|
|
|
};
|
2017-04-06 02:28:57 +02:00
|
|
|
|
|
|
|
exports.set_up = function () {
|
2018-02-26 20:09:07 +01:00
|
|
|
// Add custom profile fields elements to user account settings.
|
2018-04-04 16:21:05 +02:00
|
|
|
exports.add_custom_profile_fields_to_settings();
|
2017-04-06 02:28:57 +02:00
|
|
|
$("#account-settings-status").hide();
|
2017-06-13 17:57:33 +02:00
|
|
|
$("#api_key_value").text("");
|
|
|
|
$("#get_api_key_box").hide();
|
|
|
|
$("#show_api_key_box").hide();
|
|
|
|
$("#api_key_button_box").show();
|
|
|
|
|
|
|
|
$('#api_key_button').click(function () {
|
|
|
|
if (page_params.realm_password_auth_enabled !== false) {
|
|
|
|
$("#get_api_key_box").show();
|
|
|
|
} else {
|
|
|
|
// Skip the password prompt step
|
|
|
|
$("#get_api_key_box form").submit();
|
|
|
|
}
|
|
|
|
$("#api_key_button_box").hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#get_api_key_box").hide();
|
|
|
|
$("#show_api_key_box").hide();
|
2018-05-18 15:21:44 +02:00
|
|
|
|
|
|
|
$("#get_api_key_button").on("click", function (e) {
|
|
|
|
var data = {};
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
data.password = $("#get_api_key_password").val();
|
|
|
|
channel.post({
|
|
|
|
url: '/json/fetch_api_key',
|
|
|
|
dataType: 'json',
|
|
|
|
data: data,
|
|
|
|
success: function (data) {
|
|
|
|
var settings_status = $('#account-settings-status').expectOne();
|
|
|
|
|
|
|
|
$("#get_api_key_password").val("");
|
|
|
|
$("#api_key_value").text(data.api_key);
|
|
|
|
$("#show_api_key_box").show();
|
|
|
|
$("#get_api_key_box").hide();
|
|
|
|
settings_status.hide();
|
|
|
|
},
|
|
|
|
error: function (xhr) {
|
|
|
|
ui_report.error(i18n.t("Error getting API key"), xhr, $('#account-settings-status').expectOne());
|
|
|
|
$("#show_api_key_box").hide();
|
|
|
|
$("#get_api_key_box").show();
|
|
|
|
},
|
|
|
|
});
|
2017-06-13 17:57:33 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#show_api_key_box").on("click", "button.regenerate_api_key", function () {
|
|
|
|
channel.post({
|
|
|
|
url: '/json/users/me/api_key/regenerate',
|
|
|
|
idempotent: true,
|
|
|
|
success: function (data) {
|
|
|
|
$('#api_key_value').text(data.api_key);
|
|
|
|
},
|
|
|
|
error: function (xhr) {
|
|
|
|
$('#user_api_key_error').text(JSON.parse(xhr.responseText).msg).show();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#download_zuliprc").on("click", function () {
|
|
|
|
$(this).attr("href", settings_bots.generate_zuliprc_uri(
|
|
|
|
people.my_current_email(),
|
|
|
|
$("#api_key_value").text()
|
|
|
|
));
|
|
|
|
});
|
2017-04-06 02:28:57 +02:00
|
|
|
|
|
|
|
function clear_password_change() {
|
|
|
|
// Clear the password boxes so that passwords don't linger in the DOM
|
|
|
|
// for an XSS attacker to find.
|
2018-01-11 20:28:18 +01:00
|
|
|
$('#old_password, #new_password').val('');
|
2018-01-24 13:30:27 +01:00
|
|
|
common.password_quality('', $('#pw_strength .bar'), $('#new_password'));
|
2017-04-06 02:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
clear_password_change();
|
|
|
|
|
2018-01-30 08:56:15 +01:00
|
|
|
$("#change_full_name").on('click', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2018-02-02 16:54:26 +01:00
|
|
|
if (!page_params.realm_name_changes_disabled || page_params.is_admin) {
|
2018-02-02 15:40:15 +01:00
|
|
|
overlays.open_modal('change_full_name_modal');
|
|
|
|
}
|
2018-01-30 08:56:15 +01:00
|
|
|
});
|
|
|
|
|
2017-12-24 19:00:29 +01:00
|
|
|
$('#change_password').on('click', function (e) {
|
2017-04-06 02:28:57 +02:00
|
|
|
e.preventDefault();
|
2017-12-24 19:00:29 +01:00
|
|
|
e.stopPropagation();
|
|
|
|
overlays.open_modal('change_password_modal');
|
2017-04-06 02:28:57 +02:00
|
|
|
$('#pw_change_controls').show();
|
2017-04-20 08:21:31 +02:00
|
|
|
if (page_params.realm_password_auth_enabled !== false) {
|
2017-04-06 02:28:57 +02:00
|
|
|
// zxcvbn.js is pretty big, and is only needed on password
|
|
|
|
// change, so load it asynchronously.
|
|
|
|
var zxcvbn_path = '/static/min/zxcvbn.js';
|
|
|
|
if (page_params.development_environment) {
|
|
|
|
// Usually the Django templates handle this path stuff
|
|
|
|
// for us, but in this case we need to hardcode it.
|
|
|
|
zxcvbn_path = '/static/node_modules/zxcvbn/dist/zxcvbn.js';
|
|
|
|
}
|
|
|
|
$.getScript(zxcvbn_path, function () {
|
|
|
|
$('#pw_strength .bar').removeClass("fade");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-01-24 13:30:27 +01:00
|
|
|
$('#change_password_modal').find('[data-dismiss=modal]').on('click', function () {
|
|
|
|
clear_password_change();
|
|
|
|
});
|
|
|
|
|
2017-12-24 19:00:29 +01:00
|
|
|
$('#change_password_button').on('click', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
var change_password_info = $('#change_password_modal').find(".change_password_info").expectOne();
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
old_password: $('#old_password').val(),
|
|
|
|
new_password: $('#new_password').val(),
|
|
|
|
confirm_password: $('#confirm_password').val(),
|
|
|
|
};
|
|
|
|
|
|
|
|
channel.patch({
|
|
|
|
url: "/json/settings",
|
|
|
|
data: data,
|
|
|
|
beforeSubmit: function () {
|
|
|
|
if (page_params.realm_password_auth_enabled !== false) {
|
|
|
|
// FIXME: Check that the two password fields match
|
|
|
|
// FIXME: Use the same jQuery validation plugin as the signup form?
|
|
|
|
var field = $('#new_password');
|
|
|
|
var new_pw = $('#new_password').val();
|
|
|
|
if (new_pw !== '') {
|
|
|
|
var password_ok = common.password_quality(new_pw, undefined, field);
|
|
|
|
if (password_ok === undefined) {
|
|
|
|
// zxcvbn.js didn't load, for whatever reason.
|
|
|
|
settings_change_error(
|
|
|
|
'An internal error occurred; try reloading the page. ' +
|
|
|
|
'Sorry for the trouble!');
|
|
|
|
return false;
|
|
|
|
} else if (!password_ok) {
|
|
|
|
settings_change_error(i18n.t('New password is too weak'));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
success: function () {
|
|
|
|
settings_change_success(i18n.t("Updated settings!"));
|
|
|
|
overlays.close_modal('change_password_modal');
|
|
|
|
},
|
|
|
|
complete: function () {
|
|
|
|
// Whether successful or not, clear the password boxes.
|
|
|
|
// TODO: Clear these earlier, while the request is still pending.
|
|
|
|
clear_password_change();
|
|
|
|
},
|
|
|
|
error: function (xhr) {
|
|
|
|
ui_report.error(i18n.t("Failed"), xhr, change_password_info);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-04-06 02:28:57 +02:00
|
|
|
$('#new_password').on('change keyup', function () {
|
|
|
|
var field = $('#new_password');
|
2017-06-22 22:08:43 +02:00
|
|
|
common.password_quality(field.val(), $('#pw_strength .bar'), field);
|
2017-04-06 02:28:57 +02:00
|
|
|
});
|
|
|
|
|
2018-01-30 08:56:15 +01:00
|
|
|
$("#change_full_name_button").on('click', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
var change_full_name_info = $('#change_full_name_modal').find(".change_full_name_info").expectOne();
|
|
|
|
var data = {};
|
|
|
|
|
|
|
|
data.full_name = $('.full_name_change_container').find("input[name='full_name']").val();
|
|
|
|
channel.patch({
|
|
|
|
url: '/json/settings',
|
|
|
|
data: data,
|
|
|
|
success: function (data) {
|
|
|
|
if ('full_name' in data) {
|
|
|
|
settings_change_success(i18n.t("Updated settings!"));
|
|
|
|
} else {
|
|
|
|
settings_change_success(i18n.t("No changes made."));
|
|
|
|
}
|
|
|
|
overlays.close_modal('change_full_name_modal');
|
|
|
|
},
|
|
|
|
error: function (xhr) {
|
|
|
|
ui_report.error(i18n.t("Failed"), xhr, change_full_name_info);
|
|
|
|
},
|
|
|
|
});
|
2017-04-06 02:28:57 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
$('#change_email_button').on('click', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2018-01-30 09:07:38 +01:00
|
|
|
var change_email_info = $('#change_email_modal').find(".change_email_info").expectOne();
|
2017-04-06 02:28:57 +02:00
|
|
|
|
|
|
|
var data = {};
|
|
|
|
data.email = $('.email_change_container').find("input[name='email']").val();
|
|
|
|
|
|
|
|
channel.patch({
|
2017-07-31 20:44:52 +02:00
|
|
|
url: '/json/settings',
|
2017-04-06 02:28:57 +02:00
|
|
|
data: data,
|
|
|
|
success: function (data) {
|
|
|
|
if ('account_email' in data) {
|
|
|
|
settings_change_success(data.account_email);
|
2017-10-04 20:44:10 +02:00
|
|
|
if (page_params.development_environment) {
|
|
|
|
var email_msg = templates.render('dev_env_email_access');
|
|
|
|
$("#account-settings-status").append(email_msg);
|
|
|
|
}
|
2017-04-06 02:28:57 +02:00
|
|
|
} else {
|
2017-08-03 23:03:24 +02:00
|
|
|
settings_change_success(i18n.t("No changes made."));
|
2017-04-06 02:28:57 +02:00
|
|
|
}
|
2018-01-30 09:07:38 +01:00
|
|
|
overlays.close_modal('change_email_modal');
|
2017-04-06 02:28:57 +02:00
|
|
|
},
|
|
|
|
error: function (xhr) {
|
2018-01-30 09:07:38 +01:00
|
|
|
ui_report.error(i18n.t("Failed"), xhr, change_email_info);
|
2017-04-06 02:28:57 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#change_email').on('click', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2018-02-02 16:54:26 +01:00
|
|
|
if (!page_params.realm_email_changes_disabled || page_params.is_admin) {
|
2018-02-02 15:40:15 +01:00
|
|
|
overlays.open_modal('change_email_modal');
|
|
|
|
var email = $('#email_value').text().trim();
|
|
|
|
$('.email_change_container').find("input[name='email']").val(email);
|
|
|
|
}
|
2017-04-06 02:28:57 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#user_deactivate_account_button").on('click', function (e) {
|
2018-05-23 22:29:00 +02:00
|
|
|
// This click event must not get propagated to parent container otherwise the modal
|
|
|
|
// will not show up because of a call to `close_active_modal` in `settings.js`.
|
2017-04-06 02:28:57 +02:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
$("#deactivate_self_modal").modal("show");
|
|
|
|
});
|
|
|
|
|
2018-05-10 15:12:46 +02:00
|
|
|
$('#settings_page').on('change', '.custom_user_field_value', function (e) {
|
2018-02-26 20:42:37 +01:00
|
|
|
var fields = [];
|
|
|
|
var value = $(this).val();
|
2018-05-06 00:38:23 +02:00
|
|
|
fields.push({id: parseInt($(e.target).closest('.custom_user_field').attr("data-field-id"), 10),
|
|
|
|
value: value});
|
2018-05-25 20:58:14 +02:00
|
|
|
update_user_custom_profile_fields(fields);
|
2018-02-26 20:42:37 +01:00
|
|
|
});
|
|
|
|
|
2017-04-06 02:28:57 +02:00
|
|
|
$("#do_deactivate_self_button").on('click',function () {
|
2018-01-26 08:01:58 +01:00
|
|
|
$("#do_deactivate_self_button .loader").css('display', 'inline-block');
|
|
|
|
$("#do_deactivate_self_button span").hide();
|
|
|
|
$("#do_deactivate_self_button object").on("load", function () {
|
|
|
|
var doc = this.getSVGDocument();
|
|
|
|
var $svg = $(doc).find("svg");
|
|
|
|
$svg.find("rect").css("fill", "#000");
|
2017-04-06 02:28:57 +02:00
|
|
|
});
|
2018-01-26 08:01:58 +01:00
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
channel.del({
|
|
|
|
url: '/json/users/me',
|
|
|
|
success: function () {
|
|
|
|
$("#deactivate_self_modal").modal("hide");
|
|
|
|
window.location.href = "/login";
|
|
|
|
},
|
|
|
|
error: function (xhr) {
|
|
|
|
$("#deactivate_self_modal").modal("hide");
|
|
|
|
ui_report.error(i18n.t("Error deactivating account"), xhr, $('#account-settings-status').expectOne());
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}, 5000);
|
2017-04-06 02:28:57 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function upload_avatar(file_input) {
|
|
|
|
var form_data = new FormData();
|
|
|
|
|
|
|
|
form_data.append('csrfmiddlewaretoken', csrf_token);
|
|
|
|
jQuery.each(file_input[0].files, function (i, file) {
|
|
|
|
form_data.append('file-'+i, file);
|
|
|
|
});
|
|
|
|
|
2018-03-02 18:33:20 +01:00
|
|
|
$("#user-avatar-source").hide();
|
|
|
|
|
2017-04-06 02:28:57 +02:00
|
|
|
var spinner = $("#upload_avatar_spinner").expectOne();
|
|
|
|
loading.make_indicator(spinner, {text: 'Uploading avatar.'});
|
|
|
|
|
2017-07-05 19:15:15 +02:00
|
|
|
channel.post({
|
2017-04-06 02:28:57 +02:00
|
|
|
url: '/json/users/me/avatar',
|
|
|
|
data: form_data,
|
|
|
|
cache: false,
|
|
|
|
processData: false,
|
|
|
|
contentType: false,
|
|
|
|
success: function (data) {
|
|
|
|
loading.destroy_indicator($("#upload_avatar_spinner"));
|
2018-03-13 18:24:14 +01:00
|
|
|
$("#user-avatar-block").expectOne().attr("src", data.avatar_url);
|
2017-04-06 02:28:57 +02:00
|
|
|
$("#user_avatar_delete_button").show();
|
2018-03-02 18:33:20 +01:00
|
|
|
$("#user-avatar-source").hide();
|
|
|
|
},
|
|
|
|
error: function () {
|
|
|
|
if (page_params.avatar_source === 'G') {
|
|
|
|
$("#user-avatar-source").show();
|
|
|
|
}
|
2017-04-06 02:28:57 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
avatar.build_user_avatar_widget(upload_avatar);
|
|
|
|
|
2017-04-20 08:13:16 +02:00
|
|
|
if (page_params.realm_name_changes_disabled) {
|
2017-04-06 02:28:57 +02:00
|
|
|
$(".name_change_container").hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return exports;
|
|
|
|
}());
|
|
|
|
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = settings_account;
|
|
|
|
}
|