65 lines
1.4 KiB
CoffeeScript
65 lines
1.4 KiB
CoffeeScript
|
class Search
|
||
|
|
||
|
pics: []
|
||
|
|
||
|
showSpinner: ->
|
||
|
$('.search-container input').attr(disabled: 'disabled').blur()
|
||
|
$('.search-container img').show()
|
||
|
$('.autocomplete-container').hide()
|
||
|
$('.artist_loading.failed').hide()
|
||
|
this.hideSuggestions()
|
||
|
false
|
||
|
|
||
|
hideSpinner: ->
|
||
|
$('.search-container input').removeAttr 'disabled'
|
||
|
$('.search_field').focus()
|
||
|
$('.search-container img').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 = []
|
||
|
|
||
|
|
||
|
$ ->
|
||
|
window.search = new Search()
|
||
|
false
|
||
|
|
||
|
$('.search').live 'click', ->
|
||
|
ajax.loadSearchPage()
|
||
|
false
|
||
|
$('#search_form').live 'submit', ->
|
||
|
$('.autocomplete-container').remove()
|
||
|
ajax.loadArtistData $('#search_field').val()
|
||
|
false
|
||
|
$('.suggestions a').live 'click', ->
|
||
|
$('#search_field').val $(this).text()
|
||
|
false
|