diff --git a/config/routes.rb b/config/routes.rb index c9dbe82..037e429 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -57,5 +57,5 @@ Beathaven::Application.routes.draw do # match ':controller(/:action(/:id(.:format)))' match 'artist/autocomplete' => 'artist#autocomplete' - match 'artist(/:name)' => 'artist#data' + match 'artist/(:name)/' => 'artist#data', :constraints => { :name => /[^\/]*/ } end diff --git a/public/demo/index.html b/public/demo/index.html index 86da85e..14799cf 100644 --- a/public/demo/index.html +++ b/public/demo/index.html @@ -7,16 +7,17 @@ - - - - - - - - + + + + + + + + + + - diff --git a/public/demo/search.html b/public/demo/search.html index c168272..c0d3470 100644 --- a/public/demo/search.html +++ b/public/demo/search.html @@ -7,7 +7,7 @@ $('#search_field').autocomplete({ width: 415, // Ширина списка zIndex: 9999, // z-index списка deferRequestBy: 150, // Задержка запроса (мсек) - onSelect: loadArtistData + onSelect: Ajax.loadArtistData }); $('#search_field').focus(); @@ -16,4 +16,5 @@ $('#search_field').focus(); + \ No newline at end of file diff --git a/public/images/loader.gif b/public/images/loader.gif new file mode 100644 index 0000000..91dc959 Binary files /dev/null and b/public/images/loader.gif differ diff --git a/public/javascripts/ajax.js b/public/javascripts/ajax.js deleted file mode 100644 index 7117a30..0000000 --- a/public/javascripts/ajax.js +++ /dev/null @@ -1,50 +0,0 @@ -function loadArtistData(name) { - setArchor('/artist/'+ name +'/'); - $.get('/artist/'+ name +'/', function(data){ - if (typeof data.error != 'undefined') { - if (data.error == 'loading') { - loadArtistData(name); - } else if (data.error == 404) { - load404Page(); - } - return false; - } - Pages.renderArtist(data); - }) -} -function loadSearchPage() { - setArchor('/search/'); - $.get('/demo/search.html', function(data){ - $('#data-container').html(data); - }) -} -function loadWheePage() { - $.get('/demo/whee.html', function(data){ - $('#data-container').html(data); - }) -} -function load404Page() { - $.get('/demo/404.html', function(data){ - $('#data-container').html(data); - }) -} - -$(function(){ - $('a.data.artist').live('click', function(){ - loadArtistData($(this).html()); - return false; - }); - $('.search').live('click', function(){ - loadSearchPage(); - return false; - }); - $('#search_form').live('submit', function(){ - $('.autocomplete-container').remove(); - loadArtistData($('#search_field').val()); - return false; - }); -}) - -function setArchor(anchor) { - window.location = '#'+ anchor; -} diff --git a/public/javascripts/beathaven/ajax.js b/public/javascripts/beathaven/ajax.js new file mode 100644 index 0000000..7f5bccf --- /dev/null +++ b/public/javascripts/beathaven/ajax.js @@ -0,0 +1,77 @@ +var Ajax = { + loadArtistData: function(name) { + $('#search-container input').attr('disabled', 'disabled').blur(); + $('#search-container img').show(); + name = name.replace(' ', '+'); + Ajax.setArchor('/artist/'+ name +'/'); + $.get('/artist/'+ name +'/', function(data){ + if (typeof data.error != 'undefined') { + if (data.error == 'loading') { + Ajax.loadArtistData(name); + } else if (data.error == 404) { + Ajax.load404Page(); + } + return false; + } + Pages.renderArtist(data); + }) + }, + + loadSearchPage: function() { + Ajax.setArchor('/search/'); + $.get('/demo/search.html', function(data){ + $('#data-container').html(data); + }) + }, + + loadWheePage: function() { + $.get('/demo/whee.html', function(data){ + $('#data-container').html(data); + }) + }, + + load404Page: function() { + $.get('/demo/404.html', function(data){ + $('#data-container').html(data); + }) + }, + + setArchor: function(anchor) { + window.location = '#'+ anchor; + }, + + getAnchor: function() { + var tmp = window.location.href.split('#'); + if (typeof tmp[1] !== 'undefined') { + return tmp[1]; + } + return ''; + }, + + detectStartPage: function() { + if (m = this.getAnchor().match(/\/artist\/(.+)\//)) { + this.loadArtistData(m[1]); + } else if (this.getAnchor() === '' || this.getAnchor().match(/\/search\//)) { + this.loadSearchPage(); + } else { + this.load404Page(); + } + } +} + + +$(function(){ + $('a.data.artist').live('click', 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; + }); +}) \ No newline at end of file diff --git a/public/javascripts/audio.js b/public/javascripts/beathaven/audio.js similarity index 100% rename from public/javascripts/audio.js rename to public/javascripts/beathaven/audio.js diff --git a/public/javascripts/layout.js b/public/javascripts/beathaven/layout.js similarity index 95% rename from public/javascripts/layout.js rename to public/javascripts/beathaven/layout.js index 20266c6..ed8aea8 100644 --- a/public/javascripts/layout.js +++ b/public/javascripts/beathaven/layout.js @@ -7,7 +7,7 @@ var beathaven = { init: function () { this.drawInterface(); this.adjustSizes(); - loadSearchPage(); + Ajax.detectStartPage(); }, drawInterface: function() { }, diff --git a/public/javascripts/pages.js b/public/javascripts/beathaven/pages.js similarity index 71% rename from public/javascripts/pages.js rename to public/javascripts/beathaven/pages.js index ca34220..8379795 100644 --- a/public/javascripts/pages.js +++ b/public/javascripts/beathaven/pages.js @@ -53,34 +53,4 @@ var Pages = { $('#data-container').html('').append(artist_info).append(albums_info).scrollbar(); } -} - -/* - -
-
-

Get Born

-
- Get Born by Jet -
Add to playlist
-
-
-
    -
  • -
    Last Chance
    -
    1:52
    -
  • -
  • -
    Are You Gonna Be My Girl
    -
    3:34
    -
  • -
  • -
    Rollover DJ
    -
    3:17
    -
  • -
-
-
-
- -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/public/javascripts/player.js b/public/javascripts/beathaven/player.js similarity index 100% rename from public/javascripts/player.js rename to public/javascripts/beathaven/player.js diff --git a/public/javascripts/vkontakte.js b/public/javascripts/beathaven/vkontakte.js similarity index 100% rename from public/javascripts/vkontakte.js rename to public/javascripts/beathaven/vkontakte.js diff --git a/public/javascripts/jquery.autocomplete.js b/public/javascripts/jquery/jquery.autocomplete.js similarity index 100% rename from public/javascripts/jquery.autocomplete.js rename to public/javascripts/jquery/jquery.autocomplete.js diff --git a/public/javascripts/jquery/jquery.contentchange.js b/public/javascripts/jquery/jquery.contentchange.js new file mode 100644 index 0000000..95c2efe --- /dev/null +++ b/public/javascripts/jquery/jquery.contentchange.js @@ -0,0 +1,19 @@ +(function(){ + var interval; + jQuery.event.special.contentchange = { + setup: function() { + var self = this, + $this = $(this), + $originalContent = $this.text(); + interval = setInterval(function() { + if ($originalContent != $this.text()) { + $originalContent = $this.text(); + jQuery.event.handle.call(self, {type:'contentchange'}); + } + }, 100); + }, + teardown: function() { + clearInterval(interval); + } + }; +})(); \ No newline at end of file diff --git a/public/javascripts/jquery.min.js b/public/javascripts/jquery/jquery.min.js similarity index 100% rename from public/javascripts/jquery.min.js rename to public/javascripts/jquery/jquery.min.js diff --git a/public/javascripts/jquery.scroll.js b/public/javascripts/jquery/jquery.scroll.js similarity index 100% rename from public/javascripts/jquery.scroll.js rename to public/javascripts/jquery/jquery.scroll.js diff --git a/public/javascripts/application.js b/public/javascripts/rails/application.js similarity index 100% rename from public/javascripts/application.js rename to public/javascripts/rails/application.js diff --git a/public/javascripts/controls.js b/public/javascripts/rails/controls.js similarity index 100% rename from public/javascripts/controls.js rename to public/javascripts/rails/controls.js diff --git a/public/javascripts/dragdrop.js b/public/javascripts/rails/dragdrop.js similarity index 100% rename from public/javascripts/dragdrop.js rename to public/javascripts/rails/dragdrop.js diff --git a/public/javascripts/effects.js b/public/javascripts/rails/effects.js similarity index 100% rename from public/javascripts/effects.js rename to public/javascripts/rails/effects.js diff --git a/public/javascripts/prototype.js b/public/javascripts/rails/prototype.js similarity index 100% rename from public/javascripts/prototype.js rename to public/javascripts/rails/prototype.js diff --git a/public/javascripts/rails.js b/public/javascripts/rails/rails.js similarity index 100% rename from public/javascripts/rails.js rename to public/javascripts/rails/rails.js diff --git a/public/stylesheets/misc.css b/public/stylesheets/misc.css index 709624e..9fe4d51 100644 --- a/public/stylesheets/misc.css +++ b/public/stylesheets/misc.css @@ -92,6 +92,10 @@ border: #CCC 1px solid; border-radius: 3px; } + #search-container img { + margin-top: 30px; + display: none; + } .autocomplete { margin: 4px 0 0 -1px; @@ -107,12 +111,12 @@ } #error_page { - position: absolute; + position: relative; width: 600px; text-align: center; top: 100px; left: 50%; - margin-left: -600px; + margin-left: -300px; } #error_page h1 { font-size: 150px;