]> source.dussan.org Git - nextcloud-server.git/commitdiff
Hide defaultavatar in #header and don't darken proper avatars in #header
authorkondou <kondou@ts.unde.re>
Fri, 4 Oct 2013 00:27:53 +0000 (02:27 +0200)
committerkondou <kondou@ts.unde.re>
Fri, 4 Oct 2013 00:27:53 +0000 (02:27 +0200)
core/css/styles.css
core/js/avatar.js
core/js/jquery.avatar.js
settings/js/personal.js

index 06b61f0fa689d792a3e61b46e1c867c1baf6a30b..49a2bdaadb24ae8c1ef66e311bec6eb90a6e6ee8 100644 (file)
@@ -43,6 +43,10 @@ body { background:#fefefe; font:normal .8em/1.6em "Helvetica Neue",Helvetica,Ari
        display: inline-block;
 }
 
+#header .avatardiv img {
+       opacity: 1;
+}
+
 /* INPUTS */
 input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="email"], input[type="url"],
 textarea, select,
index 57e6daa0930251fba4fa314bf36864e5209da8f2..c54c40687689259fb0ee4e04d4e48094ebac2856 100644 (file)
@@ -1,6 +1,6 @@
 $(document).ready(function(){
        if (OC.currentUser) {
-               $('#header .avatardiv').avatar(OC.currentUser, 32);
+               $('#header .avatardiv').avatar(OC.currentUser, 32, undefined, true);
                // Personal settings
                $('#avatar .avatardiv').avatar(OC.currentUser, 128);
        }
index 88a4c25d1eecfc401f7a684d6228a086eb8df44a..0006810172668fb4bf9d34bce83707dc64155d37 100644 (file)
@@ -15,7 +15,7 @@
  * You may use this on any <div></div>
  * Here I'm using <div class="avatardiv"></div> as an example.
  *
- * There are 4 ways to call this:
+ * There are 5 ways to call this:
  *
  * 1. $('.avatardiv').avatar('jdoe', 128);
  * This will make the div to jdoe's fitting avatar, with a size of 128px.
  * 4. $('.avatardiv').avatar('jdoe', 128, true);
  * This will behave like the first example, except it will also append random
  * hashes to the custom avatar images, to force image reloading in IE8.
+ *
+ * 5. $('.avatardiv').avatar('jdoe', 128, undefined, true);
+ * This will behave like the first example, but it will hide the avatardiv, if
+ * it will display the default placeholder. undefined is the ie8fix from
+ * example 4 and can be either true, or false/undefined, to be ignored.
  */
 
 (function ($) {
-       $.fn.avatar = function(user, size, ie8fix) {
+       $.fn.avatar = function(user, size, ie8fix, hidedefault) {
                if (typeof(size) === 'undefined') {
                        if (this.height() > 0) {
                                size = this.height();
                        var url = OC.Router.generate('core_avatar_get', {user: user, size: size})+'?requesttoken='+oc_requesttoken;
                        $.get(url, function(result) {
                                if (typeof(result) === 'object') {
-                                       if (result.data && result.data.displayname) {
-                                               $div.placeholder(user, result.data.displayname);
+                                       if (!hidedefault) {
+                                               if (result.data && result.data.displayname) {
+                                                       $div.placeholder(user, result.data.displayname);
+                                               } else {
+                                                       $div.placeholder(user);
+                                               }
                                        } else {
-                                               $div.placeholder(user);
+                                               $div.hide();
                                        }
                                } else {
+                                       $div.show();
                                        if (ie8fix === true) {
                                                $div.html('<img src="'+url+'#'+Math.floor(Math.random()*1000)+'">');
                                        } else {
index a923b47573145e16d2c8dca45b1cef76734afc5a..3fdc2907c4604ed48bc4b965fd53176ed1544116 100644 (file)
@@ -45,12 +45,16 @@ function changeDisplayName(){
     }
 }
 
-function updateAvatar () {
+function updateAvatar (hidedefault) {
        $headerdiv = $('#header .avatardiv');
        $displaydiv = $('#displayavatar .avatardiv');
 
-       $headerdiv.css({'background-color': ''});
-       $headerdiv.avatar(OC.currentUser, 32, true);
+       if(hidedefault) {
+               $headerdiv.hide();
+       } else {
+               $headerdiv.css({'background-color': ''});
+               $headerdiv.avatar(OC.currentUser, 32, true);
+       }
        $displaydiv.css({'background-color': ''});
        $displaydiv.avatar(OC.currentUser, 128, true);
 }
@@ -232,7 +236,7 @@ $(document).ready(function(){
                        type:   'DELETE',
                        url:    OC.Router.generate('core_avatar_delete'),
                        success: function(msg) {
-                               updateAvatar();
+                               updateAvatar(true);
                        }
                });
        });