71 lines
2.0 KiB
CoffeeScript
71 lines
2.0 KiB
CoffeeScript
class window.Search
|
|
|
|
showSpinner: ->
|
|
$('#search').val("").attr(disabled: 'disabled').blur()
|
|
$('#autocomplete-container').hide()
|
|
this.hideSuggestions()
|
|
false
|
|
|
|
hideSpinner: ->
|
|
$('#search').removeAttr 'disabled'
|
|
$('.search_field').first().focus()
|
|
$('.search-container img').first().hide()
|
|
false
|
|
|
|
showSuggestions: (values) ->
|
|
for item in values
|
|
$('.suggestions ul').append '
|
|
<li>
|
|
<a class="data artist">' +item.name+ '</a>
|
|
' +(if item.desc? then '<br/><span>'+item.desc+'</span>' else '')+ '
|
|
</li>'
|
|
$('.suggestions').show()
|
|
false
|
|
|
|
hideSuggestions: ->
|
|
$('.suggestions ul li').remove()
|
|
$('.suggestions').hide()
|
|
false
|
|
|
|
showArtistPics: (pics) ->
|
|
$('.artist_loading.ok, .artist_pics').show()
|
|
for pic in pics
|
|
if @pics.indexOf(pic) == -1
|
|
@pics.push(pic);
|
|
$('.artist_pics').append '
|
|
<div class="pic">
|
|
<img src="' +pic+ '" alt=""/>
|
|
</div>'
|
|
false
|
|
|
|
showError: ->
|
|
$('.artist_loading.ok, .artist_pics').hide()
|
|
$('.artist_loading.failed').show()
|
|
@pics = []
|
|
|
|
|
|
$('.search').live 'click', ->
|
|
if $('.pulldown').css('display') is 'none'
|
|
$('.pulldown').width $('.data-container').width() - 50
|
|
$('.pulldown').height 300#38
|
|
$('.pulldown').slideDown 'fast', ->
|
|
data = '<div class="search-container">'+$('.subpages .search-container').html()+'</div>'
|
|
_pages.renderSearch _beathaven.localizeHTML $(data)
|
|
_beathaven.adjustSizes()
|
|
_beathaven.redrawScrollbar()
|
|
else
|
|
$('.pulldown').slideUp 'fast', ->
|
|
$('.pulldown').height 0
|
|
_beathaven.adjustSizes()
|
|
_beathaven.redrawScrollbar()
|
|
false
|
|
$('.search_form').live 'submit', ->
|
|
$('.autocomplete-container').remove()
|
|
_ajax.loadArtistData $('.search_field').first().val()
|
|
false
|
|
$('.suggestions a').live 'click', ->
|
|
$('.search_field').first().val $(this).text()
|
|
false
|
|
$('.data.artist').live 'click', ->
|
|
_ajax.go('/artist/'+$(this).text().replace(' ', '+')+'/');
|
|
false; |