gnu-social/plugins/Autocomplete/Autocomplete.js

39 lines
1.3 KiB
JavaScript
Raw Normal View History

2009-08-07 03:39:59 +09:00
$(document).ready(function(){
2010-12-07 09:20:54 +09:00
function fullName(row) {
if (typeof row.fullname == "string" && row.fullname != '') {
return row.nickname + ' (' + row.fullname + ')';
} else {
return row.nickname;
}
}
2010-12-07 10:16:47 +09:00
$('#notice_data-text').autocomplete($('address .url')[0].href+'main/autocomplete/suggest', {
multiple: true,
multipleSeparator: " ",
minChars: 1,
formatItem: function(row, i, max){
row = eval("(" + 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 + ")");
return row.nickname;
},
formatResult: function(row){
row = eval("(" + row + ")");
switch(row.type)
{
case 'user':
return '@' + row.nickname;
case 'group':
return '!' + row.nickname;
}
}
});
2009-08-07 03:39:59 +09:00
});