pjax-base-min.js revision 5605db94212fed5f46b43401aedb898c9316f46c
YUI.add("pjax-base",function(g){var e=g.config.win,a=e.location,c=g.Lang,f=g.ClassNameManager.getClassName("pjax"),b="navigate";function d(){}d.prototype={_regexURL:/^((?:[^\/#?:]+:\/\/|\/\/)[^\/]*)?([^?#]*)(.*)$/,initializer:function(){this.publish(b,{defaultFn:this._defNavigateFn});if(this.get("html5")){this._pjaxBindUI();}},destructor:function(){this._pjaxEvents&&this._pjaxEvents.detach();},navigate:function(i,h){i=this._resolveURL(i);if(this._navigate(i,h)){return true;}if(!this._hasSameOrigin(i)){g.error("Security error: The new URL must be of the same origin as the current URL.");}return false;},_getRoot:function(){var i="/",j=a.pathname,h;if(j.charAt(j.length-1)===i){return j;}h=j.split(i);h.pop();return h.join(i)+i;},_navigate:function(i,h){if(!this.hasRoute(i)){return false;}h||(h={});h.url=i;c.isValue(h.replace)||(h.replace=i===this._getURL());if(this.get("html5")||h.force){this.fire(b,h);}else{if(h.replace){a.replace(i);}else{e.location=i;}}return true;},_normalizePath:function(q){var n="..",h="/",j,m,p,k,l,o;if(!q){return h;}k=q.split(h);o=[];for(j=0,m=k.length;j<m;++j){l=k[j];if(l===n){o.pop();}else{if(l){o.push(l);}}}p=h+o.join(h);if(p!==h&&q.charAt(q.length-1)===h){p+=h;}return p;},_pjaxBindUI:function(){if(!this._pjaxEvents){this._pjaxEvents=g.one("body").delegate("click",this._onLinkClick,this.get("linkSelector"),this);}},_resolvePath:function(h){if(!h){return this._getPath();}if(h.charAt(0)==="/"){return h;}return this._normalizePath(this._getRoot()+h);},_resolveURL:function(i){var l=i&&i.match(this._regexURL),h,k,j;if(!l){return this._getURL();}h=l[1];k=l[2];j=l[3];if(h){if(h.indexOf("//")===0){h=a.protocol+h;}return h+(k||"/")+(j+"");}return this._getOrigin()+this._resolvePath(k)+(j||"");},_defNavigateFn:function(h){this[h.replace?"replace":"save"](h.url);if(e&&this.get("scrollToTop")){setTimeout(function(){e.scroll(0,0);},1);}},_onLinkClick:function(i){var h;if(i.button!==1||i.ctrlKey||i.metaKey){return;}h=i.currentTarget.get("href");h&&this._navigate(h,{originEvent:i})&&i.preventDefault();}};d.ATTRS={linkSelector:{value:"a."+f,writeOnce:"initOnly"},scrollToTop:{value:true}};g.PjaxBase=d;},"@VERSION@",{requires:["classnamemanager","node-event-delegate","router"]});