Hide the delete button, until we know its a custom avatar

This commit is contained in:
Joas Schilling 2016-01-26 12:59:58 +01:00
parent 3da78c8f1c
commit 751e99512a
2 changed files with 9 additions and 10 deletions

View File

@ -100,7 +100,7 @@ function updateAvatar (hidedefault) {
$displaydiv.css({'background-color': ''}); $displaydiv.css({'background-color': ''});
$displaydiv.avatar(OC.currentUser, 145, true); $displaydiv.avatar(OC.currentUser, 145, true);
$('#removeavatar').show(); $('#removeavatar').removeClass('hidden').addClass('inlineblock');
} }
function showAvatarCropper () { function showAvatarCropper () {
@ -303,7 +303,7 @@ $(document).ready(function () {
url: OC.generateUrl('/avatar/'), url: OC.generateUrl('/avatar/'),
success: function () { success: function () {
updateAvatar(true); updateAvatar(true);
$('#removeavatar').hide(); $('#removeavatar').addClass('hidden').removeClass('inlineblock');
} }
}); });
}); });
@ -327,15 +327,14 @@ $(document).ready(function () {
] ]
}); });
// does the user have a custom avatar? if he does hide #removeavatar // does the user have a custom avatar? if he does show #removeavatar
// needs to be this complicated because we can't check yet if an avatar has been loaded, because it's async $.get(OC.generateUrl(
var url = OC.generateUrl(
'/avatar/{user}/{size}', '/avatar/{user}/{size}',
{user: OC.currentUser, size: 1} {user: OC.currentUser, size: 1}
); ), function (result) {
$.get(url, function (result) { if (typeof(result) === 'string') {
if (typeof(result) === 'object') { // Show the delete button when the avatar is custom
$('#removeavatar').hide(); $('#removeavatar').removeClass('hidden').addClass('inlineblock');
} }
}); });

View File

@ -41,7 +41,7 @@
<?php if ($_['avatarChangeSupported']): ?> <?php if ($_['avatarChangeSupported']): ?>
<label for="uploadavatar" class="inlineblock button icon-upload svg" id="uploadavatarbutton" title="<?php p($l->t('Upload new')); ?>"></label> <label for="uploadavatar" class="inlineblock button icon-upload svg" id="uploadavatarbutton" title="<?php p($l->t('Upload new')); ?>"></label>
<div class="inlineblock button icon-folder svg" id="selectavatar" title="<?php p($l->t('Select from Files')); ?>"></div> <div class="inlineblock button icon-folder svg" id="selectavatar" title="<?php p($l->t('Select from Files')); ?>"></div>
<div class="inlineblock button icon-delete svg" id="removeavatar" title="<?php p($l->t('Remove image')); ?>"></div> <div class="hidden button icon-delete svg" id="removeavatar" title="<?php p($l->t('Remove image')); ?>"></div>
<input type="file" name="files[]" id="uploadavatar" class="hiddenuploadfield"> <input type="file" name="files[]" id="uploadavatar" class="hiddenuploadfield">
<p><em><?php p($l->t('png or jpg, max. 20 MB')); ?></em></p> <p><em><?php p($l->t('png or jpg, max. 20 MB')); ?></em></p>
<?php else: ?> <?php else: ?>