diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 39390e6..748fa99 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -2,12 +2,16 @@ $(document).ready(function(){ fixLists(); // fix margins for displaying the lists correctly + + initNavigation(); // set positions and :active for navigation elements + handleNavigation(); // handle animations and content switch + orderNavigation(); // order if predefined category + + onImageError(); // replace broken image links with placeholders }); $(window).load(function() { initSearchDropdown(); // dropdown for the search input - initNavigation(); // set positions and :active for navigation elements - handleNavigation(); // handle animations and content switch }); @@ -49,20 +53,47 @@ function fixLists() // set positions for navigation elements function initNavigation() { - // add positions + // add positions and hash control $(".navigation").each(function(){ $i = 0; $(this).children().each(function(){ $(this).attr("position", $i); + $(this).attr("hashcontrol", $(this).text().replace(" ","+").toLowerCase()); $i++; }); }); // add actives - $('.navigation li:first-child').addClass('active'); - $("div[wheel] > div:first-child").addClass('active'); + $str = $.deparam.fragment(window.location.href); + $active = $(".navigation li[hashcontrol="+$str.category+"]"); + if($active.text() == "" || $active == null) $id = 0; + else $id = $active.parent().children().index($active); + $('.navigation li:eq('+$id+')').addClass('active'); + $('div[wheel] > div:eq('+$id+')').addClass('active').css("opacity", 1.0).show(); } + +// order if predefined category +function orderNavigation(){ + $str = $.deparam.fragment(window.location.href); + $active = $(".navigation li[hashcontrol="+$str.category+"]"); + if($active==null) return; + + $id = $active.parent().children().index($active); + $size = $(".navigation li").size(); + + for($i=0;$i<$id;$i++){ + $element = $(".navigation li:eq("+$i+")"); + $(".navigation").append("
  • "+$element.text()+"
  • "); + } + for($i=0;$i<$id;$i++){ + $(".navigation li:first-child").remove(); + } +} + + + // Overlay function overlay(id) { @@ -115,6 +146,10 @@ function handleNavigation() $settings['nav'].children().removeClass("active"); $(this).addClass("active"); + // change URL + $str = $.param.fragment(window.location.href, 'category='+$(this).text().toLowerCase()); + window.location.href = $str; + // move navigation container $settings['nav'].animate({ marginLeft: -$fadeOutWidth-5 @@ -149,4 +184,14 @@ function handleNavigation() }, $speed); }).removeClass("active"); }); +} + + +function onImageError(){ + $("img").error(function () { + if($(this).width() < 60) $src = "/images/placeholder/album.png"; + else $src = "/images/placeholder/artist.png" + + $(this).unbind("error").attr("src", $src); + }); } \ No newline at end of file diff --git a/public/javascripts/jqueryPlugins.js b/public/javascripts/jqueryPlugins.js index 1363ac9..7db420f 100644 --- a/public/javascripts/jqueryPlugins.js +++ b/public/javascripts/jqueryPlugins.js @@ -487,4 +487,25 @@ function sz(el, p) { return parseInt($.css(el,p))||0; }; -})(jQuery); \ No newline at end of file +})(jQuery); + + + +/* + * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010 + * http://benalman.com/projects/jquery-bbq-plugin/ + * + * Copyright (c) 2010 "Cowboy" Ben Alman + * Dual licensed under the MIT and GPL licenses. + * http://benalman.com/about/license/ + */ +(function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this); \ No newline at end of file diff --git a/public/stylesheets/layout.css b/public/stylesheets/layout.css index ae9ffea..05904a2 100644 --- a/public/stylesheets/layout.css +++ b/public/stylesheets/layout.css @@ -214,7 +214,7 @@ a { text-decoration: none; color: #7d8791; } float: left; margin: 0 13px 20px 0; } -.artists img { float: left; width: 147px; height: 94px; } +.artists img { float: left; } .artists p { color: White; @@ -275,7 +275,6 @@ a { text-decoration: none; color: #7d8791; } display: block; } div[wheel] > div { display: none; opacity: 0.0; position: relative; } -div[wheel] > div:first-child { opacity: 1.0; display: block; } #artist .side { float: left; width: 400px;} #artist .side .img