]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Ticket #2924: include mini avatars in Autocomplete plugin drop-down list
authorBrion Vibber <brion@pobox.com>
Tue, 7 Dec 2010 00:55:16 +0000 (16:55 -0800)
committerBrion Vibber <brion@pobox.com>
Tue, 7 Dec 2010 00:55:16 +0000 (16:55 -0800)
Ticket #2923: don't show "(null)" for some profiles with no full name set

plugins/Autocomplete/Autocomplete.js
plugins/Autocomplete/autocomplete.php

index f39c1a7a7233437477f290ddab7929c4cc4d4827..81d43dccde2449d9b4b9abd873c0fbb01665bfe7 100644 (file)
@@ -12,7 +12,13 @@ $(document).ready(function(){
                 minChars: 1,
                 formatItem: function(row, i, max){
                     row = eval("(" + row + ")");
-                    return fullName(row);
+                    // the display:inline is because our INSANE stylesheets
+                    // override the standard display of all img tags for no
+                    // good reason.
+                    var div = $('<div><img style="display:inline; vertical-align: middle"> <span></span></div>')
+                        .find('img').attr('src', row.avatar).end()
+                        .find('span').text(fullName(row)).end()
+                    return div.html();
                 },
                 formatMatch: function(row, i, max){
                     row = eval("(" + row + ")");
index be5b51a1999fdfbe5fb89135fc45dc4b2940344d..c4b30d264d5d3d23c0a3afade9d568cce65395fb 100644 (file)
@@ -126,10 +126,32 @@ class AutocompleteAction extends Action
         $results = array();
         foreach($this->users as $user){
             $profile = $user->getProfile();
-            $results[]=array('nickname' => $user->nickname, 'fullname'=> $profile->fullname, 'type'=>'user');
+            $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
+            // sigh.... encapsulate this upstream!
+            if ($avatar) {
+                $avatar = $avatar->displayUrl();
+            } else {
+                $avatar = Avatar::defaultImage(AVATAR_MINI_SIZE);
+            }
+            $results[] = array(
+                'nickname' => $user->nickname,
+                'fullname'=> $profile->fullname,
+                'avatar' => $avatar,
+                'type' => 'user'
+            );
         }
         foreach($this->groups as $group){
-            $results[]=array('nickname' => $group->nickname, 'fullname'=> $group->fullname, 'type'=>'group');
+            // sigh.... encapsulate this upstream!
+            if ($group->mini_logo) {
+                $avatar = $group->mini_logo;
+            } else {
+                $avatar = User_group::defaultLogo(AVATAR_MINI_SIZE);
+            }
+            $results[] = array(
+                'nickname' => $group->nickname,
+                'fullname'=> $group->fullname,
+                'avatar' => $avatar,
+                'type' => 'group');
         }
         foreach($results as $result) {
             print json_encode($result) . "\n";