82 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			82 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/* DO NOT MODIFY. This file was compiled Mon, 27 Jun 2011 17:49:39 GMT from
 | 
						|
 * /Users/chez/Sites/beathaven/app/coffeescripts/search.coffee
 | 
						|
 */
 | 
						|
 | 
						|
(function() {
 | 
						|
  var Search;
 | 
						|
  Search = (function() {
 | 
						|
    function Search() {}
 | 
						|
    Search.prototype.pics = [];
 | 
						|
    Search.prototype.showSpinner = function() {
 | 
						|
      $('.search-container input').attr({
 | 
						|
        disabled: 'disabled'
 | 
						|
      }).blur();
 | 
						|
      $('.search-container img').show();
 | 
						|
      $('.autocomplete-container').hide();
 | 
						|
      $('.artist_loading.failed').hide();
 | 
						|
      this.hideSuggestions();
 | 
						|
      return false;
 | 
						|
    };
 | 
						|
    Search.prototype.hideSpinner = function() {
 | 
						|
      $('.search-container input').removeAttr('disabled');
 | 
						|
      $('.search_field').focus();
 | 
						|
      $('.search-container img').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 ? '<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;
 | 
						|
  })();
 | 
						|
  $(function() {
 | 
						|
    $('.search').live('click', function() {
 | 
						|
      ajax.loadSearchPage();
 | 
						|
      return false;
 | 
						|
    });
 | 
						|
    $('#search_form').live('submit', function() {
 | 
						|
      $('.autocomplete-container').remove();
 | 
						|
      ajax.loadArtistData($('#search_field').val());
 | 
						|
      return false;
 | 
						|
    });
 | 
						|
    return $('.suggestions a').live('click', function() {
 | 
						|
      $('#search_field').val($(this).text());
 | 
						|
      return false;
 | 
						|
    });
 | 
						|
  });
 | 
						|
}).call(this);
 |