64 lines
1.5 KiB
JavaScript
64 lines
1.5 KiB
JavaScript
var Search = {
|
|
|
|
pics: [],
|
|
|
|
showSpinner: function() {
|
|
$('#search-container input').attr('disabled', 'disabled').blur();
|
|
$('#search-container img').show();
|
|
$('.autocomplete-container').hide();
|
|
Search.hideSuggestions();
|
|
},
|
|
|
|
hideSpinner: function() {
|
|
$('#search-container input').removeAttr('disabled');
|
|
$('#search_field').focus();
|
|
$('#search-container img').hide();
|
|
},
|
|
|
|
showSuggestions: function(values) {
|
|
for (var i = 0; i < values.length; i++) {
|
|
$('.suggestions ul').append('\
|
|
<li>\
|
|
<a class="data artist">'+ values[i].name +'</a>\
|
|
'+ (values[i].desc ? '<span>('+ values[i].desc +')</span>' : '') +'\
|
|
</li>\
|
|
');
|
|
}
|
|
$('.suggestions').css('margin-left', $('#search_field').offset().left +'px').show();
|
|
},
|
|
|
|
hideSuggestions: function() {
|
|
$('.suggestions ul li').remove();
|
|
$('.suggestions').hide();
|
|
},
|
|
|
|
showArtistPics: function(pics) {
|
|
$('.artist_loading, .artist_pics').show();
|
|
for (var i = 0; i < pics.length; i++) {
|
|
if (Search.pics.indexOf(pics[i]) === -1) {
|
|
Search.pics.push(pics[i]);
|
|
$('.artist_pics').append('\
|
|
<div class="pic">\
|
|
<img src="'+ pics[i] +'" alt=""/>\
|
|
</div>\
|
|
');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$(function(){
|
|
$('.search').live('click', function(){
|
|
Ajax.loadSearchPage();
|
|
return false;
|
|
});
|
|
$('#search_form').live('submit', function(){
|
|
$('.autocomplete-container').remove();
|
|
Ajax.loadArtistData($('#search_field').val());
|
|
return false;
|
|
});
|
|
$('.suggestions a').live('click', function(){
|
|
$('#search_field').val($(this).text());
|
|
return false;
|
|
});
|
|
}); |