2016-04-20 10:19:39 +00:00
|
|
|
/* global OC */
|
|
|
|
|
2011-08-22 23:40:13 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
|
2013-03-13 10:03:52 +00:00
|
|
|
* 2013, Morris Jobke <morris.jobke@gmail.com>
|
2016-04-20 10:19:39 +00:00
|
|
|
* 2016, Christoph Wurst <christoph@owncloud.com>
|
2011-08-22 23:40:13 +00:00
|
|
|
* This file is licensed under the Affero General Public License version 3 or later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2016-04-20 10:19:39 +00:00
|
|
|
OC.Settings = OC.Settings || {};
|
|
|
|
|
2014-04-07 12:04:16 +00:00
|
|
|
/**
|
|
|
|
* The callback will be fired as soon as enter is pressed by the
|
|
|
|
* user or 1 second after the last data entry
|
|
|
|
*
|
|
|
|
* @param callback
|
2015-05-05 09:58:19 +00:00
|
|
|
* @param allowEmptyValue if this is set to true the callback is also called when the value is empty
|
2014-04-07 12:04:16 +00:00
|
|
|
*/
|
2015-05-05 09:58:19 +00:00
|
|
|
jQuery.fn.keyUpDelayedOrEnter = function (callback, allowEmptyValue) {
|
2014-04-07 12:04:16 +00:00
|
|
|
var cb = callback;
|
|
|
|
var that = this;
|
2017-02-27 21:49:42 +00:00
|
|
|
|
|
|
|
this.on('input', _.debounce(function (event) {
|
2014-04-07 12:04:16 +00:00
|
|
|
// enter is already handled in keypress
|
2014-08-15 15:18:46 +00:00
|
|
|
if (event.keyCode === 13) {
|
2014-04-07 12:04:16 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-05-05 09:58:19 +00:00
|
|
|
if (allowEmptyValue || that.val() !== '') {
|
2016-04-20 10:19:39 +00:00
|
|
|
cb(event);
|
2014-04-07 12:04:16 +00:00
|
|
|
}
|
|
|
|
}, 1000));
|
|
|
|
|
2014-05-30 13:12:39 +00:00
|
|
|
this.keypress(function (event) {
|
2015-05-05 09:58:19 +00:00
|
|
|
if (event.keyCode === 13 && (allowEmptyValue || that.val() !== '')) {
|
2014-04-07 12:04:16 +00:00
|
|
|
event.preventDefault();
|
2016-04-20 10:19:39 +00:00
|
|
|
cb(event);
|
2014-04-07 12:04:16 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-10-04 00:27:53 +00:00
|
|
|
function updateAvatar (hidedefault) {
|
2014-04-07 12:04:16 +00:00
|
|
|
var $headerdiv = $('#header .avatardiv');
|
|
|
|
var $displaydiv = $('#displayavatar .avatardiv');
|
2013-09-04 11:16:21 +00:00
|
|
|
|
2016-08-29 12:55:23 +00:00
|
|
|
//Bump avatar avatarversion
|
|
|
|
oc_userconfig.avatar.version = -(Math.floor(Math.random() * 1000));
|
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
if (hidedefault) {
|
2013-10-04 00:27:53 +00:00
|
|
|
$headerdiv.hide();
|
2014-02-20 12:37:23 +00:00
|
|
|
$('#header .avatardiv').removeClass('avatardiv-shown');
|
2013-10-04 00:27:53 +00:00
|
|
|
} else {
|
|
|
|
$headerdiv.css({'background-color': ''});
|
|
|
|
$headerdiv.avatar(OC.currentUser, 32, true);
|
2014-02-20 12:37:23 +00:00
|
|
|
$('#header .avatardiv').addClass('avatardiv-shown');
|
2013-10-04 00:27:53 +00:00
|
|
|
}
|
2013-09-04 11:16:21 +00:00
|
|
|
$displaydiv.css({'background-color': ''});
|
2016-10-20 14:36:03 +00:00
|
|
|
$displaydiv.avatar(OC.currentUser, 145, true, null, function() {
|
|
|
|
$displaydiv.removeClass('loading');
|
|
|
|
$('#displayavatar img').show();
|
2016-12-06 17:01:24 +00:00
|
|
|
if($('#displayavatar img').length === 0) {
|
|
|
|
$('#removeavatar').removeClass('inlineblock').addClass('hidden');
|
|
|
|
} else {
|
2016-03-07 15:50:29 +00:00
|
|
|
$('#removeavatar').removeClass('hidden').addClass('inlineblock');
|
|
|
|
}
|
|
|
|
});
|
2013-08-23 22:35:32 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
function showAvatarCropper () {
|
2014-04-07 12:04:16 +00:00
|
|
|
var $cropper = $('#cropper');
|
2016-10-20 13:57:34 +00:00
|
|
|
var $cropperImage = $('<img/>');
|
2016-10-20 14:23:54 +00:00
|
|
|
$cropperImage.css('opacity', 0); // prevent showing the unresized image
|
|
|
|
$cropper.children('.inner-container').prepend($cropperImage);
|
2013-09-03 15:40:41 +00:00
|
|
|
|
2014-04-07 12:04:16 +00:00
|
|
|
$cropperImage.attr('src',
|
2015-02-17 14:25:38 +00:00
|
|
|
OC.generateUrl('/avatar/tmp') + '?requesttoken=' + encodeURIComponent(oc_requesttoken) + '#' + Math.floor(Math.random() * 1000));
|
2013-08-30 07:00:37 +00:00
|
|
|
|
2016-10-21 13:08:36 +00:00
|
|
|
$cropperImage.load(function () {
|
|
|
|
var img = $cropperImage.get()[0];
|
|
|
|
var selectSize = Math.min(img.width, img.height);
|
|
|
|
var offsetX = (img.width - selectSize) / 2;
|
|
|
|
var offsetY = (img.height - selectSize) / 2;
|
2013-09-03 15:40:41 +00:00
|
|
|
$cropperImage.Jcrop({
|
2013-08-23 22:35:32 +00:00
|
|
|
onChange: saveCoords,
|
|
|
|
onSelect: saveCoords,
|
2013-08-29 14:56:32 +00:00
|
|
|
aspectRatio: 1,
|
2016-10-24 11:56:21 +00:00
|
|
|
boxHeight: Math.min(500, $('#app-content').height() -100),
|
|
|
|
boxWidth: Math.min(500, $('#app-content').width()),
|
2016-10-21 13:08:36 +00:00
|
|
|
setSelect: [offsetX, offsetY, selectSize, selectSize]
|
2016-10-20 14:25:11 +00:00
|
|
|
}, function() {
|
|
|
|
$cropper.show();
|
2013-08-23 22:35:32 +00:00
|
|
|
});
|
2013-08-30 07:00:37 +00:00
|
|
|
});
|
2013-08-23 22:35:32 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
function sendCropData () {
|
2013-09-05 17:26:02 +00:00
|
|
|
cleanCropper();
|
2013-09-03 15:40:41 +00:00
|
|
|
|
2014-04-07 12:04:16 +00:00
|
|
|
var cropperData = $('#cropper').data();
|
2013-08-23 22:35:32 +00:00
|
|
|
var data = {
|
2014-04-07 12:04:16 +00:00
|
|
|
x: cropperData.x,
|
|
|
|
y: cropperData.y,
|
|
|
|
w: cropperData.w,
|
|
|
|
h: cropperData.h
|
2013-08-23 22:35:32 +00:00
|
|
|
};
|
2014-03-02 21:30:24 +00:00
|
|
|
$.post(OC.generateUrl('/avatar/cropped'), {crop: data}, avatarResponseHandler);
|
2013-08-23 22:35:32 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
function saveCoords (c) {
|
2013-08-23 22:35:32 +00:00
|
|
|
$('#cropper').data(c);
|
|
|
|
}
|
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
function cleanCropper () {
|
2014-04-07 12:04:16 +00:00
|
|
|
var $cropper = $('#cropper');
|
2013-09-05 17:26:02 +00:00
|
|
|
$('#displayavatar').show();
|
|
|
|
$cropper.hide();
|
|
|
|
$('.jcrop-holder').remove();
|
|
|
|
$('#cropper img').removeData('Jcrop').removeAttr('style').removeAttr('src');
|
|
|
|
$('#cropper img').remove();
|
|
|
|
}
|
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
function avatarResponseHandler (data) {
|
2015-08-26 15:08:25 +00:00
|
|
|
if (typeof data === 'string') {
|
2016-04-19 13:06:42 +00:00
|
|
|
data = JSON.parse(data);
|
2015-08-26 15:08:25 +00:00
|
|
|
}
|
2016-04-21 08:33:03 +00:00
|
|
|
var $warning = $('#avatarform .warning');
|
2013-08-23 22:35:32 +00:00
|
|
|
$warning.hide();
|
|
|
|
if (data.status === "success") {
|
|
|
|
updateAvatar();
|
2013-09-06 11:46:50 +00:00
|
|
|
} else if (data.data === "notsquare") {
|
2013-08-23 22:35:32 +00:00
|
|
|
showAvatarCropper();
|
|
|
|
} else {
|
|
|
|
$warning.show();
|
|
|
|
$warning.text(data.data.message);
|
|
|
|
}
|
2013-07-29 09:34:38 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
$(document).ready(function () {
|
2015-01-09 14:38:39 +00:00
|
|
|
if($('#pass2').length) {
|
|
|
|
$('#pass2').showPassword().keyup();
|
|
|
|
}
|
2016-09-01 09:43:34 +00:00
|
|
|
|
|
|
|
var removeloader = function () {
|
|
|
|
setTimeout(function(){
|
|
|
|
if ($('.password-state').length > 0) {
|
|
|
|
$('.password-state').remove();
|
|
|
|
}
|
|
|
|
}, 5000)
|
|
|
|
};
|
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
$("#passwordbutton").click(function () {
|
2015-03-31 11:41:10 +00:00
|
|
|
var isIE8or9 = $('html').hasClass('lte9');
|
2015-03-16 12:11:44 +00:00
|
|
|
// FIXME - TODO - once support for IE8 and IE9 is dropped
|
|
|
|
// for IE8 and IE9 this will check additionally if the typed in password
|
|
|
|
// is different from the placeholder, because in IE8/9 the placeholder
|
|
|
|
// is simply set as the value to look like a placeholder
|
|
|
|
if ($('#pass1').val() !== '' && $('#pass2').val() !== ''
|
|
|
|
&& !(isIE8or9 && $('#pass2').val() === $('#pass2').attr('placeholder'))) {
|
2011-08-27 21:40:41 +00:00
|
|
|
// Serialize the data
|
2014-08-15 15:18:46 +00:00
|
|
|
var post = $("#passwordform").serialize();
|
2011-08-27 21:40:41 +00:00
|
|
|
$('#passwordchanged').hide();
|
|
|
|
$('#passworderror').hide();
|
2016-09-01 08:42:09 +00:00
|
|
|
$("#passwordbutton").attr('disabled', 'disabled');
|
2016-09-01 09:43:34 +00:00
|
|
|
$("#passwordbutton").after("<span class='password-loading icon icon-loading-small-dark password-state'></span>");
|
2016-09-01 10:14:48 +00:00
|
|
|
$(".personal-show-label").hide();
|
2011-08-27 21:40:41 +00:00
|
|
|
// Ajax foo
|
2014-08-15 15:18:46 +00:00
|
|
|
$.post(OC.generateUrl('/settings/personal/changepassword'), post, function (data) {
|
|
|
|
if (data.status === "success") {
|
2016-09-01 09:04:06 +00:00
|
|
|
$("#passwordbutton").after("<span class='checkmark icon icon-checkmark password-state'></span>");
|
2016-09-01 09:43:34 +00:00
|
|
|
removeloader();
|
2016-09-01 10:14:48 +00:00
|
|
|
$(".personal-show-label").show();
|
2011-08-27 21:40:41 +00:00
|
|
|
$('#pass1').val('');
|
2015-10-07 13:58:37 +00:00
|
|
|
$('#pass2').val('').change();
|
2016-11-04 19:45:46 +00:00
|
|
|
}
|
|
|
|
if (typeof(data.data) !== "undefined") {
|
|
|
|
OC.msg.finishedSaving('#password-error-msg', data);
|
2014-08-15 15:18:46 +00:00
|
|
|
} else {
|
2016-11-04 19:45:46 +00:00
|
|
|
OC.msg.finishedSaving('#password-error-msg',
|
|
|
|
{
|
|
|
|
'status' : 'error',
|
|
|
|
'data' : {
|
|
|
|
'message' : t('core', 'Unable to change password')
|
2016-06-27 09:30:13 +00:00
|
|
|
}
|
2016-11-04 19:45:46 +00:00
|
|
|
}
|
|
|
|
);
|
2011-08-27 21:40:41 +00:00
|
|
|
}
|
2016-09-01 16:54:19 +00:00
|
|
|
$(".password-loading").remove();
|
2016-09-01 08:42:09 +00:00
|
|
|
$("#passwordbutton").removeAttr('disabled');
|
2011-08-27 21:40:41 +00:00
|
|
|
});
|
|
|
|
return false;
|
|
|
|
} else {
|
2016-06-27 09:30:13 +00:00
|
|
|
OC.msg.finishedSaving('#password-error-msg',
|
|
|
|
{
|
|
|
|
'status' : 'error',
|
|
|
|
'data' : {
|
|
|
|
'message' : t('core', 'Unable to change password')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2011-08-27 21:40:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-04-18 13:07:14 +00:00
|
|
|
});
|
2013-02-24 23:07:35 +00:00
|
|
|
|
2017-04-26 13:56:59 +00:00
|
|
|
var showVerifyDialog = function(dialog, howToVerify, verificationCode) {
|
|
|
|
var dialogContent = dialog.children('.verification-dialog-content');
|
|
|
|
dialogContent.children(".explainVerification").text(howToVerify);
|
|
|
|
dialogContent.children(".verificationCode").text(verificationCode);
|
|
|
|
dialog.css('display', 'block');
|
2017-03-14 15:56:11 +00:00
|
|
|
};
|
|
|
|
|
2017-04-27 07:54:38 +00:00
|
|
|
$(".verify").click(function (event) {
|
2017-04-26 13:56:59 +00:00
|
|
|
|
2017-04-27 07:54:38 +00:00
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
var verify = $(this);
|
|
|
|
var indicator = $(this).children('img');
|
|
|
|
var accountId = indicator.attr('id');
|
2017-04-27 10:27:36 +00:00
|
|
|
var status = indicator.data('status');
|
|
|
|
|
|
|
|
var onlyVerificationCode = false;
|
|
|
|
if (parseInt(status) === 1) {
|
|
|
|
onlyVerificationCode = true;
|
|
|
|
}
|
2017-04-27 07:54:38 +00:00
|
|
|
|
|
|
|
if (indicator.hasClass('verify-action')) {
|
|
|
|
$.ajax(
|
|
|
|
OC.generateUrl('/settings/users/{account}/verify', {account: accountId}),
|
2017-04-27 10:27:36 +00:00
|
|
|
{
|
|
|
|
method: 'GET',
|
|
|
|
data: {onlyVerificationCode: onlyVerificationCode}
|
|
|
|
}
|
2017-04-27 07:54:38 +00:00
|
|
|
).done(function (data) {
|
|
|
|
var dialog = verify.children('.verification-dialog');
|
|
|
|
showVerifyDialog($(dialog), data.msg, data.code);
|
2017-04-27 12:03:59 +00:00
|
|
|
indicator.attr('data-origin-title', t('core', 'Verifying …'));
|
2017-04-27 07:54:38 +00:00
|
|
|
indicator.attr('src', OC.imagePath('core', 'actions/verifying.svg'));
|
2017-04-27 10:27:36 +00:00
|
|
|
indicator.data('status', '1');
|
2017-04-27 07:54:38 +00:00
|
|
|
});
|
|
|
|
}
|
2017-03-14 15:56:11 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-04-26 19:29:01 +00:00
|
|
|
// When the user clicks anywhere outside of the verification dialog we close it
|
|
|
|
$(document).click(function(event){
|
|
|
|
var element = event.target;
|
|
|
|
var isDialog = $(element).hasClass('verificationCode')
|
|
|
|
|| $(element).hasClass('explainVerification')
|
|
|
|
|| $(element).hasClass('verification-dialog-content')
|
|
|
|
|| $(element).hasClass('verification-dialog');
|
|
|
|
if (!isDialog) {
|
|
|
|
$(document).find('.verification-dialog').css('display', 'none');
|
2017-03-14 15:56:11 +00:00
|
|
|
}
|
2017-04-26 19:29:01 +00:00
|
|
|
});
|
2017-03-14 15:56:11 +00:00
|
|
|
|
|
|
|
|
2016-04-20 10:19:39 +00:00
|
|
|
var federationSettingsView = new OC.Settings.FederationSettingsView({
|
2016-04-21 08:33:03 +00:00
|
|
|
el: '#personal-settings'
|
2016-04-20 10:19:39 +00:00
|
|
|
});
|
|
|
|
federationSettingsView.render();
|
2013-12-07 16:33:27 +00:00
|
|
|
|
2017-06-21 09:22:05 +00:00
|
|
|
var updateLanguage = function () {
|
|
|
|
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
|
|
|
OC.PasswordConfirmation.requirePasswordConfirmation(updateLanguage);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var selectedLang = $("#languageinput").val(),
|
|
|
|
user = OC.getCurrentUser();
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: OC.linkToOCS('cloud/users', 2) + user['uid'],
|
|
|
|
method: 'PUT',
|
|
|
|
data: {
|
|
|
|
key: 'language',
|
|
|
|
value: selectedLang
|
|
|
|
},
|
|
|
|
success: function() {
|
|
|
|
location.reload();
|
|
|
|
},
|
|
|
|
fail: function() {
|
|
|
|
OC.Notification.showTemporary(t('settings', 'An error occured while changing your language. Please reload the page and try again.'));
|
2011-06-20 12:33:02 +00:00
|
|
|
}
|
|
|
|
});
|
2017-06-21 09:22:05 +00:00
|
|
|
};
|
|
|
|
$("#languageinput").change(updateLanguage);
|
2013-06-10 10:57:18 +00:00
|
|
|
|
2013-08-02 06:03:51 +00:00
|
|
|
var uploadparms = {
|
2016-03-22 19:28:57 +00:00
|
|
|
pasteZone: null,
|
2014-08-15 15:18:46 +00:00
|
|
|
done: function (e, data) {
|
2015-08-26 15:08:25 +00:00
|
|
|
var response = data;
|
|
|
|
if (typeof data.result === 'string') {
|
2016-04-19 13:06:42 +00:00
|
|
|
response = JSON.parse(data.result);
|
2015-08-26 15:08:25 +00:00
|
|
|
} else if (data.result && data.result.length) {
|
|
|
|
// fetch response from iframe
|
2016-04-19 13:06:42 +00:00
|
|
|
response = JSON.parse(data.result[0].body.innerText);
|
2015-08-26 15:08:25 +00:00
|
|
|
} else {
|
|
|
|
response = data.result;
|
|
|
|
}
|
|
|
|
avatarResponseHandler(response);
|
|
|
|
},
|
|
|
|
submit: function(e, data) {
|
2016-10-20 14:36:03 +00:00
|
|
|
$('#displayavatar img').hide();
|
|
|
|
$('#displayavatar .avatardiv').addClass('loading');
|
2015-08-26 15:08:25 +00:00
|
|
|
data.formData = _.extend(data.formData || {}, {
|
|
|
|
requesttoken: OC.requestToken
|
|
|
|
});
|
2015-07-22 11:13:39 +00:00
|
|
|
},
|
|
|
|
fail: function (e, data){
|
|
|
|
var msg = data.jqXHR.statusText + ' (' + data.jqXHR.status + ')';
|
|
|
|
if (!_.isUndefined(data.jqXHR.responseJSON) &&
|
|
|
|
!_.isUndefined(data.jqXHR.responseJSON.data) &&
|
|
|
|
!_.isUndefined(data.jqXHR.responseJSON.data.message)
|
|
|
|
) {
|
|
|
|
msg = data.jqXHR.responseJSON.data.message;
|
|
|
|
}
|
|
|
|
avatarResponseHandler({
|
2016-08-29 14:50:45 +00:00
|
|
|
data: {
|
|
|
|
message: msg
|
2015-07-22 11:13:39 +00:00
|
|
|
}
|
|
|
|
});
|
2013-08-02 06:03:51 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$('#uploadavatar').fileupload(uploadparms);
|
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
$('#selectavatar').click(function () {
|
2013-09-04 10:56:14 +00:00
|
|
|
OC.dialogs.filepicker(
|
|
|
|
t('settings', "Select a profile picture"),
|
2014-08-15 15:18:46 +00:00
|
|
|
function (path) {
|
2016-10-20 14:36:03 +00:00
|
|
|
$('#displayavatar img').hide();
|
|
|
|
$('#displayavatar .avatardiv').addClass('loading');
|
2015-07-22 11:13:39 +00:00
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: OC.generateUrl('/avatar/'),
|
|
|
|
data: { path: path }
|
|
|
|
}).done(avatarResponseHandler)
|
2016-08-29 14:50:45 +00:00
|
|
|
.fail(function(jqXHR) {
|
2015-07-22 11:13:39 +00:00
|
|
|
var msg = jqXHR.statusText + ' (' + jqXHR.status + ')';
|
|
|
|
if (!_.isUndefined(jqXHR.responseJSON) &&
|
|
|
|
!_.isUndefined(jqXHR.responseJSON.data) &&
|
|
|
|
!_.isUndefined(jqXHR.responseJSON.data.message)
|
|
|
|
) {
|
|
|
|
msg = jqXHR.responseJSON.data.message;
|
|
|
|
}
|
|
|
|
avatarResponseHandler({
|
|
|
|
data: {
|
2016-08-29 14:50:45 +00:00
|
|
|
message: msg
|
2015-07-22 11:13:39 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-09-04 10:56:14 +00:00
|
|
|
},
|
|
|
|
false,
|
2013-09-05 21:12:52 +00:00
|
|
|
["image/png", "image/jpeg"]
|
2013-09-04 10:56:14 +00:00
|
|
|
);
|
2013-07-29 09:34:38 +00:00
|
|
|
});
|
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
$('#removeavatar').click(function () {
|
2013-08-18 20:10:23 +00:00
|
|
|
$.ajax({
|
2014-08-15 15:18:46 +00:00
|
|
|
type: 'DELETE',
|
|
|
|
url: OC.generateUrl('/avatar/'),
|
|
|
|
success: function () {
|
2013-10-04 00:27:53 +00:00
|
|
|
updateAvatar(true);
|
2013-08-18 20:10:23 +00:00
|
|
|
}
|
|
|
|
});
|
2013-07-29 09:34:38 +00:00
|
|
|
});
|
2013-09-03 15:40:41 +00:00
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
$('#abortcropperbutton').click(function () {
|
2016-10-20 14:36:03 +00:00
|
|
|
$('#displayavatar .avatardiv').removeClass('loading');
|
|
|
|
$('#displayavatar img').show();
|
2013-09-05 17:26:02 +00:00
|
|
|
cleanCropper();
|
2013-09-03 15:40:41 +00:00
|
|
|
});
|
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
$('#sendcropperbutton').click(function () {
|
2013-09-03 15:40:41 +00:00
|
|
|
sendCropData();
|
|
|
|
});
|
2013-03-13 10:03:52 +00:00
|
|
|
|
|
|
|
$('#pass2').strengthify({
|
2016-10-21 07:11:52 +00:00
|
|
|
zxcvbn: OC.linkTo('core','vendor/zxcvbn/dist/zxcvbn.js'),
|
2013-03-13 10:03:52 +00:00
|
|
|
titles: [
|
|
|
|
t('core', 'Very weak password'),
|
|
|
|
t('core', 'Weak password'),
|
|
|
|
t('core', 'So-so password'),
|
|
|
|
t('core', 'Good password'),
|
|
|
|
t('core', 'Strong password')
|
2016-06-15 13:27:07 +00:00
|
|
|
],
|
|
|
|
drawTitles: true,
|
2013-03-13 10:03:52 +00:00
|
|
|
});
|
2014-02-20 20:53:59 +00:00
|
|
|
|
2015-12-17 12:46:25 +00:00
|
|
|
// Load the big avatar
|
2017-02-13 23:49:05 +00:00
|
|
|
$('#avatarform .avatardiv').avatar(OC.currentUser, 145, true, null, function() {
|
|
|
|
if($('#displayavatar img').length === 0) {
|
|
|
|
$('#removeavatar').removeClass('inlineblock').addClass('hidden');
|
|
|
|
} else {
|
|
|
|
$('#removeavatar').removeClass('hidden').addClass('inlineblock');
|
|
|
|
}
|
|
|
|
});
|
2017-03-14 15:56:11 +00:00
|
|
|
|
2016-05-18 10:03:22 +00:00
|
|
|
|
|
|
|
// Show token views
|
|
|
|
var collection = new OC.Settings.AuthTokenCollection();
|
|
|
|
var view = new OC.Settings.AuthTokenView({
|
|
|
|
collection: collection
|
|
|
|
});
|
|
|
|
view.reload();
|
2016-06-21 14:14:51 +00:00
|
|
|
|
|
|
|
// 'redirect' to anchor sections
|
|
|
|
// anchors are lost on redirects (e.g. while solving the 2fa challenge) otherwise
|
|
|
|
// example: /settings/person?section=devices will result in /settings/person?#devices
|
|
|
|
if (!window.location.hash) {
|
|
|
|
var query = OC.parseQueryString(location.search);
|
|
|
|
if (query && query.section) {
|
|
|
|
OC.Util.History.replaceState({});
|
|
|
|
window.location.hash = query.section;
|
|
|
|
}
|
|
|
|
}
|
2014-08-15 15:18:46 +00:00
|
|
|
});
|
2013-07-29 15:06:05 +00:00
|
|
|
|
2015-04-21 10:01:56 +00:00
|
|
|
if (!OC.Encryption) {
|
|
|
|
OC.Encryption = {};
|
|
|
|
}
|
2013-07-29 15:06:05 +00:00
|
|
|
|
2014-08-15 15:18:46 +00:00
|
|
|
OC.Encryption.msg = {
|
|
|
|
start: function (selector, msg) {
|
|
|
|
var spinner = '<img src="' + OC.imagePath('core', 'loading-small.gif') + '">';
|
2013-07-29 15:06:05 +00:00
|
|
|
$(selector)
|
2014-08-15 15:18:46 +00:00
|
|
|
.html(msg + ' ' + spinner)
|
2013-07-29 15:06:05 +00:00
|
|
|
.removeClass('success')
|
|
|
|
.removeClass('error')
|
|
|
|
.stop(true, true)
|
|
|
|
.show();
|
|
|
|
},
|
2014-08-15 15:18:46 +00:00
|
|
|
finished: function (selector, data) {
|
|
|
|
if (data.status === "success") {
|
|
|
|
$(selector).html(data.data.message)
|
2013-07-29 15:06:05 +00:00
|
|
|
.addClass('success')
|
|
|
|
.stop(true, true)
|
2013-11-20 11:23:10 +00:00
|
|
|
.delay(3000);
|
2014-08-15 15:18:46 +00:00
|
|
|
} else {
|
|
|
|
$(selector).html(data.data.message).addClass('error');
|
2013-07-29 15:06:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2016-04-20 10:19:39 +00:00
|
|
|
|
|
|
|
OC.Settings.updateAvatar = updateAvatar;
|