93 lines
2.8 KiB
JavaScript
93 lines
2.8 KiB
JavaScript
var Search;
|
|
Search = (function() {
|
|
function Search() {}
|
|
Search.prototype.pics = [];
|
|
Search.prototype.showSpinner = function() {
|
|
$('.search-container input').first().attr({
|
|
disabled: 'disabled'
|
|
}).blur();
|
|
$('.search-container img').first().show();
|
|
$('.autocomplete-container').hide();
|
|
$('.artist_loading.failed').first().hide();
|
|
this.hideSuggestions();
|
|
return false;
|
|
};
|
|
Search.prototype.hideSpinner = function() {
|
|
$('.search-container input').first().removeAttr('disabled');
|
|
$('.search_field').first().focus();
|
|
$('.search-container img').first().hide();
|
|
return false;
|
|
};
|
|
Search.prototype.showSuggestions = function(values) {
|
|
var item, _i, _len;
|
|
for (_i = 0, _len = values.length; _i < _len; _i++) {
|
|
item = values[_i];
|
|
$('.suggestions ul').append('\
|
|
<li>\
|
|
<a class="data artist">' + item.name + '</a>\
|
|
' + (item.desc != null ? '<br/><span>' + item.desc + '</span>' : '') + '\
|
|
</li>');
|
|
}
|
|
$('.suggestions').show();
|
|
return false;
|
|
};
|
|
Search.prototype.hideSuggestions = function() {
|
|
$('.suggestions ul li').remove();
|
|
$('.suggestions').hide();
|
|
return false;
|
|
};
|
|
Search.prototype.showArtistPics = function(pics) {
|
|
var pic, _i, _len;
|
|
$('.artist_loading.ok, .artist_pics').show();
|
|
for (_i = 0, _len = pics.length; _i < _len; _i++) {
|
|
pic = pics[_i];
|
|
if (this.pics.indexOf(pic) === -1) {
|
|
this.pics.push(pic);
|
|
$('.artist_pics').append('\
|
|
<div class="pic">\
|
|
<img src="' + pic + '" alt=""/>\
|
|
</div>');
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
Search.prototype.showError = function() {
|
|
$('.artist_loading.ok, .artist_pics').hide();
|
|
$('.artist_loading.failed').show();
|
|
return this.pics = [];
|
|
};
|
|
return Search;
|
|
})();
|
|
$('.search').live('click', function() {
|
|
if ($('.pulldown').css('display') === 'none') {
|
|
$('.pulldown').width($('.data-container').width() - 50);
|
|
$('.pulldown').height(300);
|
|
$('.pulldown').slideDown('fast', function() {
|
|
var data;
|
|
data = '<div class="search-container">' + $('.subpages .search-container').html() + '</div>';
|
|
_pages.renderSearch(_beathaven.localizeHTML($(data)));
|
|
_beathaven.adjustSizes();
|
|
return _beathaven.redrawScrollbar();
|
|
});
|
|
} else {
|
|
$('.pulldown').slideUp('fast', function() {
|
|
$('.pulldown').height(0);
|
|
_beathaven.adjustSizes();
|
|
return _beathaven.redrawScrollbar();
|
|
});
|
|
}
|
|
return false;
|
|
});
|
|
$('.search_form').live('submit', function() {
|
|
$('.autocomplete-container').remove();
|
|
_ajax.loadArtistData($('.search_field').first().val());
|
|
return false;
|
|
});
|
|
$('.suggestions a').live('click', function() {
|
|
$('.search_field').first().val($(this).text());
|
|
return false;
|
|
});
|
|
$('.data.artist').live('click', function() {
|
|
_ajax.go('/artist/' + $(this).text().replace(' ', '+') + '/');
|
|
return false;
|
|
}); |