Merge pull request #2534 from nextcloud/fix-avatar-upload-buttons

Fix avatar delete button
This commit is contained in:
Roeland Jago Douma 2016-12-08 13:44:26 +01:00 committed by GitHub
commit ce707912b4
1 changed files with 11 additions and 26 deletions

View File

@ -65,16 +65,9 @@ function updateAvatar (hidedefault) {
$displaydiv.avatar(OC.currentUser, 145, true, null, function() { $displaydiv.avatar(OC.currentUser, 145, true, null, function() {
$displaydiv.removeClass('loading'); $displaydiv.removeClass('loading');
$('#displayavatar img').show(); $('#displayavatar img').show();
}); if($('#displayavatar img').length === 0) {
$.get(OC.generateUrl( $('#removeavatar').removeClass('inlineblock').addClass('hidden');
'/avatar/{user}/{size}', } else {
{
user: OC.currentUser,
size: 1
}
), function (result) {
if (typeof(result) === 'string') {
// Show the delete button when the avatar is custom
$('#removeavatar').removeClass('hidden').addClass('inlineblock'); $('#removeavatar').removeClass('hidden').addClass('inlineblock');
} }
}); });
@ -314,7 +307,6 @@ $(document).ready(function () {
url: OC.generateUrl('/avatar/'), url: OC.generateUrl('/avatar/'),
success: function () { success: function () {
updateAvatar(true); updateAvatar(true);
$('#removeavatar').addClass('hidden').removeClass('inlineblock');
} }
}); });
}); });
@ -341,24 +333,17 @@ $(document).ready(function () {
drawTitles: true, drawTitles: true,
}); });
// does the user have a custom avatar? if he does show #removeavatar
$.get(OC.generateUrl(
'/avatar/{user}/{size}',
{
user: OC.currentUser,
size: 1
}
), function (result) {
if (typeof(result) === 'string') {
// Show the delete button when the avatar is custom
$('#removeavatar').removeClass('hidden').addClass('inlineblock');
}
});
// Load the big avatar // Load the big avatar
if (oc_config.enable_avatars) { if (oc_config.enable_avatars) {
$('#avatarform .avatardiv').avatar(OC.currentUser, 145); $('#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');
}
});
} }
// Show token views // Show token views
var collection = new OC.Settings.AuthTokenCollection(); var collection = new OC.Settings.AuthTokenCollection();