]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Autocomplete/Autocomplete.js
Ticket #2924: include mini avatars in Autocomplete plugin drop-down list
[quix0rs-gnu-social.git] / plugins / Autocomplete / Autocomplete.js
1 $(document).ready(function(){
2     function fullName(row) {
3         if (typeof row.fullname == "string" && row.fullname != '') {
4             return row.nickname + ' (' + row.fullname + ')';
5         } else {
6             return row.nickname;
7         }
8     }
9             $('#notice_data-text').autocomplete($('address .url')[0].href+'/plugins/Autocomplete/autocomplete.json', {
10                 multiple: true,
11                 multipleSeparator: " ",
12                 minChars: 1,
13                 formatItem: function(row, i, max){
14                     row = eval("(" + row + ")");
15                     // the display:inline is because our INSANE stylesheets
16                     // override the standard display of all img tags for no
17                     // good reason.
18                     var div = $('<div><img style="display:inline; vertical-align: middle"> <span></span></div>')
19                         .find('img').attr('src', row.avatar).end()
20                         .find('span').text(fullName(row)).end()
21                     return div.html();
22                 },
23                 formatMatch: function(row, i, max){
24                     row = eval("(" + row + ")");
25                     return row.nickname;
26                 },
27                 formatResult: function(row){
28                     row = eval("(" + row + ")");
29                     switch(row.type)
30                     {
31                         case 'user':
32                             return '@' + row.nickname;
33                         case 'group':
34                             return '!' + row.nickname;
35                     }
36                 }
37             });
38 });