pjax-base-min.js revision 60721add39f50a2f904fa5736c6d04bb7aecdb63
YUI.add("pjax-base",function(g){var e=g.config.win,a=c(),f=g.ClassNameManager.getClassName("pjax"),b="navigate";function c(){var h=(e&&e.location.pathname.split("/"))||[];h.pop();return h.join("/");}function d(){}d.prototype={_regexUrl:/^((?:([^:]+):(?:\/\/)?|\/\/)[^\/]*)?([^?#]*)(.*)$/i,initializer:function(){this._pjaxRoot=a;this.publish(b,{defaultFn:this._defNavigateFn});this._pjaxBindUI();},destructor:function(){this._pjaxEvents&&this._pjaxEvents.detach();},load:function(h){h=this._resolveUrl(h);this.save(this.removeRoot(h));if(this.get("scrollToTop")&&g.config.win){setTimeout(function(){g.config.win.scroll(0,0);},1);}},_getRoot:c,_normalizePath:function(q){var n="..",k="/",l,m,p,j,h,o;if(!q){return q;}j=q.split(k);o=[];for(l=0,m=j.length;l<m;++l){h=j[l];if(h===n){o.pop();}else{if(h){o.push(h);}}}p=o.join(k);if(q.charAt(q.length-1)===k){p+=k;}return p;},_pjaxBindUI:function(){if(this.html5){this._pjaxEvents=g.one("body").delegate("click",this._onLinkClick,this.get("linkSelector"),this);}},_resolvePath:function(i){var h=this._pjaxRoot;if(!i){return h;}if(i.charAt(0)==="/"){return i;}return this._normalizePath(h+"/"+i);},_resolveUrl:function(i){var h=this;return i.replace(this._regexUrl,function(k,l,j,n,m){if(j&&!j.match(/https?/i)){return k;}return(l||"")+h._resolvePath(n)+(m||"");});},_defNavigateFn:function(h){this.load(h.url);},_onLinkClick:function(i){var h=this._resolveUrl(i.currentTarget.get("href"));if(i.button!==1||i.ctrlKey||i.metaKey){return;}if(!this.hasRoute(this.removeRoot(h))){return;}i.preventDefault();this.fire(b,{originEvent:i,url:h});}};d.ATTRS={linkSelector:{value:"a."+f,writeOnce:"initOnly"},scrollToTop:{value:true}};g.PjaxBase=d;},"@VERSION@",{requires:["classnamemanager","controller","node-event-delegate"]});