@@ -1,20 +1,25 @@
|
||||
var Ajax = {
|
||||
loadArtistData: function(name) {
|
||||
$('#search-container input').attr('disabled', 'disabled').blur();
|
||||
$('#search-container img').show();
|
||||
Search.showSpinner();
|
||||
name = name.split(' ').join('+');
|
||||
Ajax.setArchor('/artist/'+ name +'/');
|
||||
$.get('/artist/'+ name +'/', function(data){
|
||||
if (typeof data.error != 'undefined') {
|
||||
if (data.error == 'loading') {
|
||||
if (typeof data.status != 'undefined') {
|
||||
if (data.status == 'loaded') {
|
||||
Ajax.loadArtistData(name);
|
||||
} else if (data.error == 404) {
|
||||
} else if (data.status == 'corrected') {
|
||||
Ajax.loadArtistData(data.page);
|
||||
} else if (data.status == 'suggestions') {
|
||||
Search.hideSpinner();
|
||||
Search.showSuggestions(data.values);
|
||||
} else if (data.status == 'error') {
|
||||
Ajax.load404Page();
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
Ajax.setArchor('/artist/'+ name +'/');
|
||||
Pages.renderArtist(data);
|
||||
beathaven.redrawScrollbar();
|
||||
}
|
||||
Pages.renderArtist(data);
|
||||
beathaven.redrawScrollbar();
|
||||
})
|
||||
},
|
||||
|
||||
@@ -75,14 +80,5 @@ $(function(){
|
||||
Ajax.loadArtistData($(this).html());
|
||||
return false;
|
||||
});
|
||||
$('.search').live('click', function(){
|
||||
Ajax.loadSearchPage();
|
||||
return false;
|
||||
});
|
||||
$('#search_form').live('submit', function(){
|
||||
$('.autocomplete-container').remove();
|
||||
Ajax.loadArtistData($('#search_field').val());
|
||||
return false;
|
||||
});
|
||||
$(window).bind('hashchange', Ajax.detectPage);
|
||||
})
|
||||
@@ -0,0 +1,46 @@
|
||||
var Search = {
|
||||
|
||||
showSpinner: function() {
|
||||
$('#search-container input').attr('disabled', 'disabled').blur();
|
||||
$('#search-container img').show();
|
||||
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] +'</a>\
|
||||
</li>\
|
||||
');
|
||||
}
|
||||
$('.suggestions').show();
|
||||
},
|
||||
|
||||
hideSuggestions: function() {
|
||||
$('.suggestions ul li').remove();
|
||||
$('.suggestions').hide();
|
||||
}
|
||||
}
|
||||
|
||||
$(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;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user