You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1 lines
8.1 KiB

!function(a){function b(b,d,e){var f=this;return this.on("click.pjax",b,function(b){var g=a.extend({},p(d,e));g.container||(g.container=a(this).attr("data-pjax")||f),c(b,g)})}function c(b,c,d){d=p(c,d);var f=b.currentTarget;if("A"!==f.tagName.toUpperCase())throw"$.fn.pjax or $.pjax.click requires an anchor element";if(!(b.which>1||b.metaKey||b.ctrlKey||b.shiftKey||b.altKey||location.protocol!==f.protocol||location.hostname!==f.hostname||f.href.indexOf("#")>-1&&o(f)==o(location)||b.isDefaultPrevented())){var g={url:f.href,container:a(f).attr("data-pjax"),target:f},h=a.extend({},g,d),i=a.Event("pjax:click");a(f).trigger(i,[h]),i.isDefaultPrevented()||(e(h),b.preventDefault(),a(f).trigger("pjax:clicked",[h]))}}function d(b,c,d){d=p(c,d);var f=b.currentTarget,g=a(f);if("FORM"!==f.tagName.toUpperCase())throw"$.pjax.submit requires a form element";var h={type:(g.attr("method")||"GET").toUpperCase(),url:g.attr("action"),container:g.attr("data-pjax"),target:f};if("GET"!==h.type&&void 0!==window.FormData)h.data=new FormData(f),h.processData=!1,h.contentType=!1;else{if(a(f).find(":file").length)return;h.data=a(f).serializeArray()}e(a.extend({},h,d)),b.preventDefault()}function e(b){function c(b,c,e){e||(e={}),e.relatedTarget=d;var f=a.Event(b,e);return i.trigger(f,c),!f.isDefaultPrevented()}b=a.extend(!0,{},a.ajaxSettings,e.defaults,b),"function"==typeof b.url&&(b.url=b.url());var d=b.target,f=n(b.url).hash,h=q(b.container),i=b.context=h[0],o=h[1];b.data||(b.data={}),a.isArray(b.data)?b.data.push({name:"_pjax",value:o}):b.data._pjax=o;var p;b.beforeSend=function(a,d){if("GET"!==d.type&&(d.timeout=0),a.setRequestHeader("X-PJAX","true"),a.setRequestHeader("X-PJAX-Container",o),!c("pjax:beforeSend",[a,d]))return!1;d.timeout>0&&(p=setTimeout(function(){c("pjax:timeout",[a,b])&&a.abort("timeout")},d.timeout),d.timeout=0);var e=n(d.url);f&&(e.hash=f),b.requestUrl=m(e)},b.complete=function(a,d){p&&clearTimeout(p),c("pjax:complete",[a,d,b]),c("pjax:end",[a,b])},b.error=function(a,d,e){var f=t("",a,b),h=c("pjax:error",[a,d,e,b]);"GET"==b.type&&"abort"!==d&&h&&g(f.url)},b.success=function(d,h,j){function l(){var e=i.find("input[autofocus], textarea[autofocus]").last()[0];e&&document.activeElement!==e&&e.focus(),u(r.scripts);var g=b.scrollTo;if(f){var k=decodeURIComponent(f.slice(1)),l=document.getElementById(k)||document.getElementsByName(k)[0];l&&(g=a(l).offset().top)}"number"==typeof g&&a(window).scrollTop(g),c("pjax:success",[d,h,j,b])}var m=e.state,p="function"==typeof a.pjax.defaults.version?a.pjax.defaults.version():a.pjax.defaults.version,q=j.getResponseHeader("X-PJAX-Version"),r=t(d,j,b),s=n(r.url);if(f&&(s.hash=f,r.url=s.href),p&&q&&p!==q)return void g(r.url);if(!r.contents)return void g(r.url);if(e.state={id:b.id||k(),url:r.url,title:r.title,container:o,fragment:b.fragment,timeout:b.timeout},(b.push||b.replace)&&window.history.replaceState(e.state,r.title,r.url),a.contains(b.container,document.activeElement))try{document.activeElement.blur()}catch(v){}r.title&&(document.title=r.title),c("pjax:beforeReplace",[r.contents,b],{state:e.state,previousState:m}),"function"==typeof b.renderCallback?b.renderCallback(i,r.contents,l):(i.html(r.contents),l())},e.state||(e.state={id:k(),url:window.location.href,title:document.title,container:o,fragment:b.fragment,timeout:b.timeout},window.history.replaceState(e.state,document.title)),j(e.xhr),e.options=b;var r=e.xhr=a.ajax(b);return r.readyState>0&&(b.push&&!b.replace&&(v(e.state.id,l(i,o)),window.history.pushState(null,"",b.requestUrl)),c("pjax:start",[r,b]),c("pjax:send",[r,b])),e.xhr}function f(b,c){var d={url:window.location.href,push:!1,replace:!0,scrollTo:!1};return e(a.extend(d,p(b,c)))}function g(a){window.history.replaceState(null,"",e.state.url),window.location.replace(a)}function h(b){B||j(e.xhr);var c,d=e.state,f=b.state;if(f&&f.container){if(B&&C==f.url)return;if(d){if(d.id===f.id)return;c=d.id<f.id?"forward":"back"}var h=E[f.id]||[],i=h[0]||f.container,k=a(i),m=h[1];if(k.length){d&&w(c,d.id,l(k,i));var n=a.Event("pjax:popstate",{state:f,direction:c});k.trigger(n);var o={id:f.id,url:f.url,container:k,push:!1,fragment:f.fragment,timeout:f.timeout,scrollTo:!1};if(m){k.trigger("pjax:start",[null,o]),e.state=f,f.title&&(document.title=f.title);var p=a.Event("pjax:beforeReplace",{state:f,previousState:d});k.trigger(p,[m,o]),k.html(m),k.trigger("pjax:end",[null,o])}else e(o);k[0].offsetHeight}else g(location.href)}B=!1}function i(b){var c="function"==typeof b.url?b.url():b.url,d=b.type?b.type.toUpperCase():"GET",e=a("<form>",{method:"GET"===d?"GET":"POST",action:c,style:"display:none"});"GET"!==d&&"POST"!==d&&e.append(a("<input>",{type:"hidden",name:"_method",value:d.toLowerCase()}));var f=b.data;if("string"==typeof f)a.each(f.split("&"),function(b,c){var d=c.split("=");e.append(a("<input>",{type:"hidden",name:d[0],value:d[1]}))});else if(a.isArray(f))a.each(f,function(b,c){e.append(a("<input>",{type:"hidden",name:c.name,value:c.value}))});else if("object"==typeof f){var g;for(g in f)e.append(a("<input>",{type:"hidden",name:g,value:f[g]}))}a(document.body).append(e),e.submit()}function j(b){b&&b.readyState<4&&(b.onreadystatechange=a.noop,b.abort())}function k(){return(new Date).getTime()}function l(a,b){var c=a.clone();return c.find("script").each(function(){this.src||jQuery._data(this,"globalEval",!1)}),[b,c.contents()]}function m(a){return a.search=a.search.replace(/([?&])(_pjax|_)=[^&]*/g,""),a.href.replace(/\?($|#)/,"$1")}function n(a){var b=document.createElement("a");return b.href=a,b}function o(a){return a.href.replace(/#.*/,"")}function p(b,c){return b&&c?c.container=b:c=a.isPlainObject(b)?b:{container:b},c.container&&(c.container=q(c.container)),c}function q(b){var c,d;if(a.isArray(b)?(d=b[0],c=b[1]):(c=b,d=a(c)),d.length)return[d,c];throw"no pjax container for "+c}function r(a,b){return a.filter(b).add(a.find(b))}function s(b){return a.parseHTML(b,document,!0)}function t(b,c,d){var e={},f=/<html/i.test(b),g=c.getResponseHeader("X-PJAX-URL");if(e.url=g?m(n(g)):d.requestUrl,f)var h=a(s(b.match(/<head[^>]*>([\s\S.]*)<\/head>/i)[0])),i=a(s(b.match(/<body[^>]*>([\s\S.]*)<\/body>/i)[0]));else var h=i=a(s(b));if(0===i.length)return e;if(e.title=r(h,"title").last().text(),d.fragment){if("body"===d.fragment)var j=i;else var j=r(i,d.fragment).first();j.length&&(e.contents="body"===d.fragment?j:j.contents(),e.title||(e.title=j.attr("title")||j.data("title")))}else f||(e.contents=i);return e.contents&&(e.contents=e.contents.not(function(){return a(this).is("title")}),e.contents.find("title").remove(),e.scripts=r(e.contents,"script[src]").remove(),e.contents=e.contents.not(e.scripts)),e.title&&(e.title=a.trim(e.title)),e}function u(b){if(b){var c=a("script[src]");b.each(function(){var b=this.src;if(!c.filter(function(){return this.src===b}).length){var d=document.createElement("script"),e=a(this).attr("type");e&&(d.type=e),d.src=a(this).attr("src"),document.head.appendChild(d)}})}}function v(a,b){E[a]=b,G.push(a),x(F,0),x(G,e.defaults.maxCacheLength)}function w(a,b,c){var d,f;E[b]=c,"forward"===a?(d=G,f=F):(d=F,f=G),d.push(b),(b=f.pop())&&delete E[b],x(d,e.defaults.maxCacheLength)}function x(a,b){for(;a.length>b;)delete E[a.shift()]}function y(){return a("meta").filter(function(){var b=a(this).attr("http-equiv");return b&&"X-PJAX-VERSION"===b.toUpperCase()}).attr("content")}function z(){a.fn.pjax=b,a.pjax=e,a.pjax.enable=a.noop,a.pjax.disable=A,a.pjax.click=c,a.pjax.submit=d,a.pjax.reload=f,a.pjax.defaults={timeout:650,push:!0,replace:!1,type:"GET",dataType:"html",scrollTo:0,renderCallback:!1,maxCacheLength:20,version:y},a(window).on("popstate.pjax",h)}function A(){a.fn.pjax=function(){return this},a.pjax=i,a.pjax.enable=z,a.pjax.disable=a.noop,a.pjax.click=a.noop,a.pjax.submit=a.noop,a.pjax.reload=function(){window.location.reload()},a(window).off("popstate.pjax",h)}var B=!0,C=window.location.href,D=window.history.state;D&&D.container&&(e.state=D),"state"in window.history&&(B=!1);var E={},F=[],G=[];a.event.props&&a.inArray("state",a.event.props)<0?a.event.props.push("state"):"state"in a.Event.prototype||a.event.addProp("state"),a.support.pjax=window.history&&window.history.pushState&&window.history.replaceState&&!navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/),a.support.pjax?z():A()}(jQuery);