Start tweaking Autocomplete js

This commit is contained in:
Brion Vibber 2010-12-06 16:20:54 -08:00
parent 851dbf1361
commit daae13df1c

View File

@ -1,27 +1,22 @@
$(document).ready(function(){ $(document).ready(function(){
function fullName(row) {
if (typeof row.fullname == "string" && row.fullname != '') {
return row.nickname + ' (' + row.fullname + ')';
} else {
return row.nickname;
}
}
$('#notice_data-text').autocomplete($('address .url')[0].href+'/plugins/Autocomplete/autocomplete.json', { $('#notice_data-text').autocomplete($('address .url')[0].href+'/plugins/Autocomplete/autocomplete.json', {
multiple: true, multiple: true,
multipleSeparator: " ", multipleSeparator: " ",
minChars: 1, minChars: 1,
formatItem: function(row, i, max){ formatItem: function(row, i, max){
row = eval("(" + row + ")"); row = eval("(" + row + ")");
switch(row.type) return fullName(row);
{
case 'user':
return row.nickname + ' (' + row.fullname + ')';
case 'group':
return row.nickname + ' (' + row.fullname + ')';
}
}, },
formatMatch: function(row, i, max){ formatMatch: function(row, i, max){
row = eval("(" + row + ")"); row = eval("(" + row + ")");
switch(row.type) return row.nickname;
{
case 'user':
return row.nickname;
case 'group':
return row.nickname;
}
}, },
formatResult: function(row){ formatResult: function(row){
row = eval("(" + row + ")"); row = eval("(" + row + ")");