From 0e0b4d55756e438111264423cc04baadb8b067a7 Mon Sep 17 00:00:00 2001 From: kondou Date: Thu, 20 Feb 2014 21:53:59 +0100 Subject: Hide remove image, if there's no custom avatar Fix #7308 --- settings/js/personal.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'settings') diff --git a/settings/js/personal.js b/settings/js/personal.js index ef261b50bbc..77c06f26a6a 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -58,6 +58,8 @@ function updateAvatar (hidedefault) { } $displaydiv.css({'background-color': ''}); $displaydiv.avatar(OC.currentUser, 128, true); + + $('#removeavatar').show(); } function showAvatarCropper() { @@ -254,6 +256,7 @@ $(document).ready(function(){ url: OC.Router.generate('core_avatar_delete'), success: function(msg) { updateAvatar(true); + $('#removeavatar').hide(); } }); }); @@ -276,6 +279,17 @@ $(document).ready(function(){ t('core', 'Strong password') ] }); + + // does the user have a custom avatar? if he does hide #removeavatar + // needs to be this complicated because we can't check yet if an avatar has been loaded, because it's async + OC.Router.registerLoadedCallback(function() { + var url = OC.Router.generate('core_avatar_get', {user: OC.currentUser, size: 1})+'?requesttoken='+oc_requesttoken; + $.get(url, function(result) { + if (typeof(result) === 'object') { + $('#removeavatar').hide(); + } + }); + }); } ); OC.Encryption = { -- cgit v1.2.3 From 88882e3fa73cc21b96c2877a3d527bea56b6be11 Mon Sep 17 00:00:00 2001 From: kondou Date: Fri, 21 Feb 2014 12:42:07 +0100 Subject: Use addClass('hidden') and removeClass('hidden') --- settings/js/personal.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'settings') diff --git a/settings/js/personal.js b/settings/js/personal.js index 77c06f26a6a..59f112c8032 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -59,7 +59,7 @@ function updateAvatar (hidedefault) { $displaydiv.css({'background-color': ''}); $displaydiv.avatar(OC.currentUser, 128, true); - $('#removeavatar').show(); + $('#removeavatar').removeClass('hidden'); } function showAvatarCropper() { @@ -256,7 +256,7 @@ $(document).ready(function(){ url: OC.Router.generate('core_avatar_delete'), success: function(msg) { updateAvatar(true); - $('#removeavatar').hide(); + $('#removeavatar').addClass('hidden'); } }); }); @@ -286,7 +286,7 @@ $(document).ready(function(){ var url = OC.Router.generate('core_avatar_get', {user: OC.currentUser, size: 1})+'?requesttoken='+oc_requesttoken; $.get(url, function(result) { if (typeof(result) === 'object') { - $('#removeavatar').hide(); + $('#removeavatar').addClass('hidden'); } }); }); -- cgit v1.2.3 From dd97d532beda0a32121f3faa2fae92508284a326 Mon Sep 17 00:00:00 2001 From: kondou Date: Wed, 12 Mar 2014 15:31:48 +0100 Subject: Remove OC.Router usage --- settings/js/personal.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'settings') diff --git a/settings/js/personal.js b/settings/js/personal.js index 26c50f8fa5d..fe8c21aa4f1 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -284,13 +284,14 @@ $(document).ready(function(){ // does the user have a custom avatar? if he does hide #removeavatar // needs to be this complicated because we can't check yet if an avatar has been loaded, because it's async - OC.Router.registerLoadedCallback(function() { - var url = OC.Router.generate('core_avatar_get', {user: OC.currentUser, size: 1})+'?requesttoken='+oc_requesttoken; - $.get(url, function(result) { - if (typeof(result) === 'object') { - $('#removeavatar').addClass('hidden'); - } - }); + var url = OC.generateUrl( + '/avatar/{user}/{size}', + {user: OC.currentUser, size: 1} + ) + '?requesttoken=' + oc_requesttoken; + $.get(url, function(result) { + if (typeof(result) === 'object') { + $('#removeavatar').addClass('hidden'); + } }); } ); -- cgit v1.2.3 From 8fafee31efd9cb8126cc82017b6bb2d614d9b977 Mon Sep 17 00:00:00 2001 From: kondou Date: Wed, 12 Mar 2014 15:42:29 +0100 Subject: Use $.hide() instead of .hidden for now .inlineblock ranks higher than .hidden --- settings/js/personal.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'settings') diff --git a/settings/js/personal.js b/settings/js/personal.js index fe8c21aa4f1..f502037cfda 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -61,7 +61,7 @@ function updateAvatar (hidedefault) { $displaydiv.css({'background-color': ''}); $displaydiv.avatar(OC.currentUser, 128, true); - $('#removeavatar').removeClass('hidden'); + $('#removeavatar').show(); } function showAvatarCropper() { @@ -258,7 +258,7 @@ $(document).ready(function(){ url: OC.generateUrl('/avatar/'), success: function(msg) { updateAvatar(true); - $('#removeavatar').addClass('hidden'); + $('#removeavatar').hide(); } }); }); @@ -290,7 +290,7 @@ $(document).ready(function(){ ) + '?requesttoken=' + oc_requesttoken; $.get(url, function(result) { if (typeof(result) === 'object') { - $('#removeavatar').addClass('hidden'); + $('#removeavatar').hide(); } }); } ); -- cgit v1.2.3