diff --git a/build/director.js b/build/director.js index d4149cd..2fd3e45 100644 --- a/build/director.js +++ b/build/director.js @@ -1,8 +1,8 @@ // -// Generated on Wed Jun 25 2014 00:16:13 GMT-0700 (PDT) by Nodejitsu, Inc (Using Codesurgeon). -// Version 1.2.4 +// Generated on Fri Sep 26 2014 20:19:31 GMT-0400 (EDT) by Nodejitsu, Inc (Using Codesurgeon). +// Version 1.2.5 // (function (exports) { @@ -17,19 +17,26 @@ var dloc = document.location; +function getHash() { + var hash = dloc.href.split("#")[1] || ''; + if (hash !== '') { hash = '#' + hash } + return hash; +} + function dlocHashEmpty() { // Non-IE browsers return '' when the address bar shows '#'; Director's logic // assumes both mean empty. - return dloc.hash === '' || dloc.hash === '#'; + var hash = getHash(); + return hash === '' || hash === '#'; } var listener = { mode: 'modern', - hash: dloc.hash, + hash: getHash(), history: false, check: function () { - var h = dloc.hash; + var h = getHash(); if (h != this.hash) { this.hash = h; this.onHashChanged(); @@ -150,7 +157,7 @@ var listener = { syncHash: function () { // IE support... var s = this._hash; - if (s != dloc.hash) { + if (s != getHash()) { dloc.hash = s; } return this; @@ -191,11 +198,11 @@ Router.prototype.init = function (r) { if (dlocHashEmpty() && r) { dloc.hash = r; } else if (!dlocHashEmpty()) { - self.dispatch('on', '/' + dloc.hash.replace(/^(#\/|#|\/)/, '')); + self.dispatch('on', '/' + getHash().replace(/^(#\/|#|\/)/, '')); } } else { - var routeTo = dlocHashEmpty() && r ? r : !dlocHashEmpty() ? dloc.hash.replace(/^#/, '') : null; + var routeTo = dlocHashEmpty() && r ? r : !dlocHashEmpty() ? getHash().replace(/^#/, '') : null; if (routeTo) { window.history.replaceState({}, document.title, routeTo); } @@ -211,7 +218,7 @@ Router.prototype.init = function (r) { }; Router.prototype.explode = function () { - var v = this.history === true ? this.getPath() : dloc.hash; + var v = this.history === true ? this.getPath() : getHash(); if (v.charAt(1) === '/') { v=v.slice(1) } return v.slice(1, v.length).split("/"); }; diff --git a/build/director.min.js b/build/director.min.js index 7a8ef97..f653ab5 100644 --- a/build/director.min.js +++ b/build/director.min.js @@ -1,7 +1,7 @@ // -// Generated on Wed Jun 25 2014 00:16:13 GMT-0700 (PDT) by Nodejitsu, Inc (Using Codesurgeon). -// Version 1.2.4 +// Generated on Fri Sep 26 2014 20:19:31 GMT-0400 (EDT) by Nodejitsu, Inc (Using Codesurgeon). +// Version 1.2.5 // -(function(a){function k(a,b,c,d){var e=0,f=0,g=0,c=(c||"(").toString(),d=(d||")").toString(),h;for(h=0;hi.indexOf(d,e)||~i.indexOf(c,e)&&!~i.indexOf(d,e)||!~i.indexOf(c,e)&&~i.indexOf(d,e)){f=i.indexOf(c,e),g=i.indexOf(d,e);if(~f&&!~g||!~f&&~g){var j=a.slice(0,(h||1)+1).join(b);a=[j].concat(a.slice((h||1)+1))}e=(g>f?g:f)+1,h=0}else e=0}return a}function j(a,b){var c,d=0,e="";while(c=a.substr(d).match(/[^\w\d\- %@&]*\*[^\w\d\- %@&]*/))d=c.index+c[0].length,c[0]=c[0].replace(/^\*/,"([_.()!\\ %@&a-zA-Z0-9-]+)"),e+=a.substr(0,c.index)+c[0];a=e+=a.substr(d);var f=a.match(/:([^\/]+)/ig),g,h;if(f){h=f.length;for(var j=0;j7))this.history===!0?setTimeout(function(){window.onpopstate=d},500):window.onhashchange=d,this.mode="modern";else{var f=document.createElement("iframe");f.id="state-frame",f.style.display="none",document.body.appendChild(f),this.writeFrame(""),"onpropertychange"in document&&"attachEvent"in document&&document.attachEvent("onpropertychange",function(){event.propertyName==="location"&&c.check()}),window.setInterval(function(){c.check()},50),this.onHashChanged=d,this.mode="legacy"}e.listeners.push(a);return this.mode},destroy:function(a){if(!!e&&!!e.listeners){var b=e.listeners;for(var c=b.length-1;c>=0;c--)b[c]===a&&b.splice(c,1)}},setHash:function(a){this.mode==="legacy"&&this.writeFrame(a),this.history===!0?(window.history.pushState({},document.title,a),this.fire()):b.hash=a[0]==="/"?a:"/"+a;return this},writeFrame:function(a){var b=document.getElementById("state-frame"),c=b.contentDocument||b.contentWindow.document;c.open(),c.write("