forked from arvgta/ajaxify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajaxify.min.js
1 lines (1 loc) · 14.4 KB
/
ajaxify.min.js
1
function getRootUrl(){var t=window.location.protocol+"//"+(window.location.hostname||window.location.host);return window.location.port&&(t+=":"+window.location.port),t+="/"}function _trigger(t,n){jQuery(window).trigger("pronto."+t,n)}function _internal(t){return t?("object"==typeof t&&(t=t.href),""===t?!0:t.substring(0,rootUrl.length)===rootUrl||!t.iO(":")):!1}function _root(t){return t.iO("?")?t.split("?")[0]:t}String.prototype.iO=function(t){return this.toString().indexOf(t)+1},function(t){t.fn.hoverIntent=function(n,e,r){var i={interval:100,sensitivity:7,timeout:0};i="object"==typeof n?t.extend(i,n):t.isFunction(e)?t.extend(i,{over:n,out:e,selector:r}):t.extend(i,{over:n,out:n,selector:e});var o,a,c,s,u=function(t){o=t.pageX,a=t.pageY},f=function(n,e){return e.hoverIntent_t=clearTimeout(e.hoverIntent_t),Math.abs(c-o)+Math.abs(s-a)<i.sensitivity?(t(e).off("mousemove.hoverIntent",u),e.hoverIntent_s=1,i.over.apply(e,[n])):(c=o,s=a,e.hoverIntent_t=setTimeout(function(){f(n,e)},i.interval),void 0)},l=function(t,n){return n.hoverIntent_t=clearTimeout(n.hoverIntent_t),n.hoverIntent_s=0,i.out.apply(n,[t])},d=function(n){var e=jQuery.extend({},n),r=this;r.hoverIntent_t&&(r.hoverIntent_t=clearTimeout(r.hoverIntent_t)),"mouseenter"==n.type?(c=e.pageX,s=e.pageY,t(r).on("mousemove.hoverIntent",u),1!=r.hoverIntent_s&&(r.hoverIntent_t=setTimeout(function(){f(e,r)},i.interval))):(t(r).off("mousemove.hoverIntent",u),1==r.hoverIntent_s&&(r.hoverIntent_t=setTimeout(function(){l(e,r)},i.timeout)))};return this.on({"mouseenter.hoverIntent":d,"mouseleave.hoverIntent":d},i.selector)}}(jQuery),function(t){t.fn.idle=function(n){var e,r,i={idle:6e4,events:"mousemove keypress mousedown touchstart",onIdle:function(){},onActive:function(){},onHide:function(){},onShow:function(){},keepTracking:!1},o=!1,a=!0,c=t.extend({},i,n);return e=function(t,n){return o&&(n.onActive.call(),o=!1),(n.keepTracking?clearInterval:clearTimeout)(t),r(n)},r=function(t){var n,e=t.keepTracking?setInterval:setTimeout;return n=e(function(){o=!0,t.onIdle.call()},t.idle)},this.each(function(){var i=r(c);return t(this).on(c.events,function(){i=e(i,c)}),(n.onShow||n.onHide)&&t(document).on("visibilitychange webkitvisibilitychange mozvisibilitychange msvisibilitychange",function(){return document.hidden||document.webkitHidden||document.mozHidden||document.msHidden?a&&(a=!1,c.onHide.call()):a||(a=!0,c.onShow.call())})})}}(jQuery);var l=0,pass=0,currentURL="",rootUrl=getRootUrl(),api=window.history&&window.history.pushState&&window.history.replaceState,docType=/<\!DOCTYPE[^>]*>/i,tagso=/<(html|head|body|title|meta|script|link)([\s\>])/gi,tagsc=/<\/(html|head|body|title|meta|script|link)\>/gi,div12='<div class="ajy-$1"$2',linki='<link rel="stylesheet" type="text/css" href="*" />',scri='<script type="text/javascript" src="*" />',linkr='link[href*="!"]',scrr='script[src*="!"]';!function(t){var n=function(n){var e=t.extend({verbosity:0},n),r=e.verbosity;this.a=function(t){r>l&&console&&console.log(t)}};t.log=function(e,r){return t.log.o||(t.log.o=new n(r)),t.log.o.a(e)}}(jQuery),function(t){var n=function(){var n=!1;this.a=function(e){return e?"string"==typeof e?("f"===e?(t.pages("f"),t.log("Cache flushed")):n=t.pages(t.memory(e)),n):"object"==typeof e?n=e:void 0:n}};t.cache=function(e){return t.cache.o||(t.cache.o=new n),t.cache.o.a(e)}}(jQuery),function(t){var n=function(n){var e=!1,r=t.extend({memoryoff:!1},n),i=r.memoryoff;this.a=function(t){return e=i,t&&e!==!0?e===!1?t:e.iO(", ")?(e=e.split(", "),e.iO(t)?!1:t):t==e?!1:t:!1}};t.memory=function(e,r){return t.memory.o||(t.memory.o=new n(r)),t.memory.o.a(e)}}(jQuery),function(t){var n=function(){var t=[];this.a=function(n){if("string"==typeof n)if("f"===n)t=[];else for(var e=0;e<t.length;e++)if(t[e][0]==n)return t[e][1];return"object"==typeof n&&t.push(n),"boolean"==typeof n?!1:void 0}};t.pages=function(e){return t.pages.o||(t.pages.o=new n),t.pages.o.a(e)}}(jQuery),function(t){var n=function(){var n=0;this.a=function(i,o,a){return i?i.iO("/")?r(i,o):"+"===i?r(o,a,!0):"-"===i?e(o):"x"===i?n:t.cache()?t.cache().find(".ajy-"+i):void 0:t.cache()};var e=function(n){return pass++,o(n),t.scripts(t.rq("s")),t.scripts("s"),t.scripts("a"),t.scripts("c")},r=function(n,e,r){return n.iO("#")&&(n=n.split("#")[0]),t.rq("is")||!t.cache(n)?a(n,e,r):void(e&&e())},i=function(n,e){e.find(".ajy-script").each(function(){t(this).replaceWith(t(this).attr("src")?scri.replace("*",t(this).attr("src")):"")}),n.html(e.html())},o=function(n){t.cache()&&n.each(function(){i(t(this),t.cache().find("#"+t(this).attr("id")))})},a=function(e,r,i){var o=t.rq("is");n=t.ajax({url:e,type:o?"POST":"GET",data:o?t.rq("d"):null,success:function(o){o&&c(n)||i||(location.href=e),t.cache(t(s(o))),t.pages([e,t.cache()]),r&&r()},error:function(n,i,o){try{t.log("Response text : "+n.responseText),t.cache(t(s(n.responseText))),t.pages([e,t.cache()]),r&&r(o)}catch(a){}}})},c=function(t){var n;return n=t.getResponseHeader("Content-Type"),n&&(n.iO("text/html")||n.iO("text/xml"))},s=function(n){return t.trim(u(n))},u=function(t){return String(t).replace(docType,"").replace(tagso,div12).replace(tagsc,"</div>")}};t.getPage=function(e,r,i){return t.getPage.o||(t.getPage.o=new n),t.getPage.o.a(e,r,i)}}(jQuery);var fn=jQuery.getPage;!function(t){var n=function(n){var e=t.extend({pluginon:!0,deltas:!0},n),r=e.pluginon,i=e.deltas;this.a=function(n,r){var a=r;return a&&"string"==typeof a?t().pronto(a):void t(function(){o(e)&&(n.pronto(0,e),i&&t.scripts("1"))})};var o=function(n){return api&&r?(t.scripts("i",n),t.cache(0,n),t.memory(0,n),!0):!1}};t.fn.ajaxify=function(e){var r=t(this);return t.fn.ajaxify.o||(t.fn.ajaxify.o=new n(e)),t.fn.ajaxify.o.a(r,e)}}(jQuery),function($){var Scripts=function(options){var $s=!1,settings=$.extend({canonical:!0,inline:!0,inlinehints:!1,inlineskip:"adsbygoogle",inlineappend:!1,style:!0},options),canonical=settings.canonical,inline=settings.inline,inlinehints=settings.inlinehints,inlineskip=settings.inlineskip,inlineappend=settings.inlineappend,style=settings.style;this.a=function(t){return"i"===t?($s||($s=$()),!0):"s"===t?_allstyle($s.y):"1"===t?($.detScripts($s),_addScripts(!1,$s,settings)):"a"===t?_alltxts($s.t):"c"===t?canonical&&$s.can?$s.can.attr("href"):!1:($.detScripts($s),void _addScripts(t,$s,settings))};var _allstyle=function(t){style&&t&&($("head").find("style").remove(),t.each(function(){var t=$(this).text();_addstyle(t)}))},_alltxts=function(t){t.each(function(){var t=$(this).text();!t.iO(").ajaxify(")&&(inline&&!_inlineskip(t)||$(this).hasClass("ajaxy")||_inlinehints(t))&&_addtext(t)})},_addtext=function(t){if(inlineappend)return _apptext(t);try{$.globalEval(t)}catch(e1){try{eval(t)}catch(e2){$.log("Error in inline script : "+t+"\nError code : "+e2)}}},_apptext=function(t){var n=document.createElement("script");n.appendChild(document.createTextNode(t)),$.cd("g").get(0).appendChild(n)},_addstyle=function(t){$("head").append('<style type="text/css">'+t+"</style>")},_inlineskip=function(t){var n=inlineskip;if(n){n=n.split(", ");for(var e=0;e<n.length;e++)if(t.iO(n[e]))return!0}},_inlinehints=function(t){var n=inlinehints;if(n){n=n.split(", ");for(var e=0;e<n.length;e++)if(t.iO(n[e]))return!0}},_addScripts=function(t,n,e){n.c.addAll(t,"href",e),n.s.addAll(t,"src",e)}};$.scripts=function(t,n){return $.scripts.o||($.scripts.o=new Scripts(n)),$.scripts.o.a(t)}}(jQuery),function(t){var n=function(){var n=0,e=0,r=0;this.a=function(o){n=pass?t.getPage("head"):t("head"),e=n.find(pass?".ajy-link":"link"),r=pass?t.getPage("script"):t("script"),o.c=i(e,"stylesheet"),o.y=n.find("style"),o.can=i(e,"canonical"),o.s=r.filter(function(){return t(this).attr("src")}),o.t=r.filter(function(){return!t(this).attr("src")})};var i=function(n,e){return t(n).filter(function(){return t(this).attr("rel").iO(e)})}};t.detScripts=function(e){return t.detScripts.o||(t.detScripts.o=new n),t.detScripts.o.a(e)}}(jQuery),function(t){var n=function(n){var e=!1,r=!1,i=[],o=[],a=[],c=[],s=t.extend({deltas:!0},n),u=s.deltas;this.a=function(t,n,s){if(t.length){if("href"==s?(e=i,r=o):(e=a,r=c),f(t,s))return!0;if(n)return void l(t,s);r=[],p(t,r,e,s),pass&&(v(e,r),y(e,s),d(r,s),e=r.slice()),"href"==s?(i=e,o=r):(a=e,c=r)}};var f=function(n,e){return u?!1:(n.each(function(){h(t(this)[0],e)}),!0)},l=function(n,e){n.each(function(){"always"==t(this).attr("data-class")&&h(t(this).attr(e),e)})},d=function(t,n){for(var e=0;e<t.length;e++)0===t[e][1]&&h(t[e][0],n)},h=function(n,e){t("head").append(("href"==e?linki:scri).replace("*",n))},p=function(n,e,r,i){var o;n.each(function(){o=[t(this).attr(i),0],e.push(o),pass||r.push(o)})},v=function(t,n){for(var e=0;e<t.length;e++)t[e][1]=2,g(t[e][0],n)&&(t[e][1]=1)},g=function(t,n){if(t)for(var e=0;e<n.length;e++)if(n[e][0]==t)return n[e][1]=1,!0},y=function(t,n){for(var e=0;e<t.length;e++)2==t[e][1]&&t[e][0]&&m(t[e][0],n)},m=function(n,e){t(("href"==e?linkr:scrr).replace("!",n)).remove()}};t.fn.addAll=function(e,r,i){var o=t(this);return t.fn.addAll.o||(t.fn.addAll.o=new n(i)),t.fn.addAll.o.a(o,e,r)}}(jQuery),function(t){var n=function(n){var e=0,r=0,i=0,o=0,a=t.extend({aniParams:!1,aniTime:0},n),c=a.aniParams,s=a.aniTime;this.a=function(n,a){if(n){if("g"===n)return e;if("i"===n){if(e=a.first(),r=s&&c,o=e.width(),!r)return;c=t.extend({opacity:1,width:"100%",height:"100%"},c),c=t.extend({marginRight:o-c.width},c),i=t.extend({},c);for(var u in i)if(i.hasOwnProperty(u)){var f=e.css(u),l=i[u];"height"===u&&l.iO("%")&&(f=1e4/+l.substr(0,l.iO("%")-1)+"%"),i[u]=f}}if(a)return r?void(("1"===n||"2"===n)&&("1"===n&&e.stop(!0,!0),e.animate("1"===n?c:i,s,a))):void a()}}};t.cd=function(e,r,i){return t.cd.o||(t.cd.o=new n(i)),t.cd.o.a(e,r)}}(jQuery),function(t){var n=function(n){var e=!1,r=0,i=0,o=t.extend({idleTime:0,slideTime:0,menu:!1,addclass:"jqhover"},n),a=o.idleTime,c=o.slideTime,s=o.menu,u=o.addclass;this.a=function(n){if(n&&"i"===n){if(!a)return;t(document).idle({onIdle:function(){_trigger("idle"),e||(e=!0,f())},onActive:function(){_trigger("active"),i&&i.removeClass(u),clearInterval(r),e=!1},idle:a})}};var f=function(){e&&(r=setInterval(l,c))},l=function(){e&&t().pronto(d())},d=function(){var n,e=!1,r=!1,o=!1,a=!1;return t(s).each(function(c,s){var f=t(this).parent();return a?!0:(n=s.href,void(_internal(n)&&(f.removeClass(u),r||(r=t(this).parent()),o||(o=n),e?(a=n,i=f,f.addClass(u)):currentURL==n&&(e=!0))))}),a||(r.addClass(u),a=o,i=r),a}};t.slides=function(e,r){return t.slides.o||(t.slides.o=new n(r)),t.slides.o.a(e)}}(jQuery),function(t){var n=function(){var t=0,n=0,e=0,r=0;this.a=function(i,o){return"c"===i?o?r===o?!0:(r=o,!1):r:"i"===i?(t=!1,n=null,void(e=!1)):"s"===i?(o&&(e=_root(o)===_root(currentURL)),e):"is"===i?(o&&(t=o),t):"d"===i?(o&&(n=o),n):void 0}};t.rq=function(e,r){return t.rq.o||(t.rq.o=new n),t.rq.o.a(e,r)}}(jQuery),function(t){var n=function(n){var e=0,r=0,i=t.extend({forms:"form:not(.no-ajaxy)"},n),o=i.forms;this.a=function(n,i){o&&n&&("d"===n&&(r=i),"a"===n&&r.find(o).filter(function(){return _internal(t(this).attr("action"))}).submit(function(n){if(e=t(n.target),!e.is("form")&&(e=e.filter("input[type=submit]").parents("form:first"),0===e.length))return!0;i=a();var r="get",o=e.attr("method");o.length>0&&"post"==o.toLowerCase()&&(r="post");var s,u=e.attr("action");return s=u&&u.length>0?u:currentURL,t.rq("i"),t.rq("s",s),"get"==r?s=c(s,i):(t.rq("is",!0),t.rq("d",i)),_trigger("submit",s),t().pronto({href:s}),!1}))};var a=function(){var n=e.serialize(),r=t("input[name][type=submit]",e);if(0===r.length)return n;var i=r.attr("name")+"="+r.val();return n.length>0?n+="&"+i:n=i,n},c=function(t,n){return t.indexOf("?")>0&&(t=t.substring(0,t.indexOf("?"))),t+"?"+n}};t.frms=function(e,r,i){return t.frms.o||(t.frms.o=new n(i)),t.frms.o.a(e,r)}}(jQuery),function(t){var n=function(n){var e=0,r=t.extend({requestDelay:0},n),i=r.requestDelay;this.a=function(t){return t?"-"===t&&e?clearTimeout(e):void("function"==typeof t&&(e=setTimeout(t,i))):void 0}};t.rqTimer=function(e,r){return t.rqTimer.o||(t.rqTimer.o=new n(r)),t.rqTimer.o.a(e)}}(jQuery),function(t){var n=function(n){function e(){w.$body=t("body"),currentURL=window.location.href,f(),t(window).on("popstate",l),_&&(t(x).hoverIntent(i,r),t(x).on("touchstart",i)),w.$body.on("click.pronto",x,a),t.frms("d",t("body")),t.frms("a"),t.frms("d",m),t.slides("i")}function r(){}function i(n){t.rq("i");var e=n.currentTarget;if(!_internal(e))return!1;if(currentURL==e.href)return!1;var r=function(){return j===!0?!1:void(o(e)||j!==!1&&t(e).closest(j).length||a(n,!0))};fn("+",e.href,r)}function o(n){var e=!1;return m.each(function(){t(n).parents("#"+t(this).attr("id")).length>0&&(e=!0)}),e}function a(n,e){var r=n.currentTarget;if(!t.rq("c",r.href)&&(t.rq("i"),!g(n)&&_internal(r))){if(y(r))return f(),!0;n.preventDefault(),n.stopPropagation(),currentURL===r.href?f():c(n,e)}}function c(n,e,r){var i="string"!=typeof n?n.currentTarget.href:n;_trigger("request",n);var o=function(i){i&&(t.log("Error : "+i),_trigger("error",i)),s(n,!r,e)};t.rq("s",i),fn(i,o)}function s(n,e,r){t.rqTimer("-"),_trigger("beforeload",n),t.rqTimer(function(){u(n,e,r)})}function u(n,e,r){t.cd("1",function(){h(n,e,r)})}function f(){history.replaceState({url:currentURL},"state-"+currentURL,currentURL)}function l(n){t.rq("i");var e=n.originalEvent.state,r=e?e.url:0;if(r&&r!==currentURL){t.rq("s",r),_trigger("request",n);var i=function(){s(n,!1,!1)};fn(r,i)}}function d(t,n){currentURL=t,n?history.pushState({url:currentURL},"state-"+currentURL,currentURL):f()}function h(n,e,r){var i,o;i="string"!=typeof n?n.currentTarget.href||n.originalEvent.state.url:n,_trigger("load",n),o=fn("-",m),t("title").html(fn("title").html()),t.cd("2",function(){p(n,i,e,r,o)})}function p(n,e,r,i,o){if(!o||o==e||e.iO("#")||e.iO("?")||(e=o),t.frms("a"),e.iO("#")&&e.iO("#")<e.length-1&&i!==!0){var a,c=t("#"+e.split("#")[1]);c.length&&(a=c.offset().top),a!==!1&&t(window).scrollTop(a)}d(e,r),v(e),_trigger("render",n),T&&T()}function v(t){t="/"+t.replace(rootUrl,""),"undefined"!=typeof window.ga&&window.ga("send","pageview",t)}function g(t){return t.which>1||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey}function y(t){return t.hash&&t.href.replace(t.hash,"")===window.location.href.replace(location.hash,"")||t.href===window.location.href+"#"}var m,w=t.extend({selector:"a:not(.no-ajaxy):not([target='_blank'])",prefetch:!0,previewoff:!0,cb:0},n),x=w.selector,_=w.prefetch,j=w.previewoff,T=w.cb;this.a=function(n,r){return r?"object"==typeof r?void c(r.href):r.iO("/")?(c(r,!0,!0),"OK"):void 0:(m=n,t.cd(0,0,w),t.frms(0,0,w),t.slides(0,w),t.rqTimer(0,w),t.cd("i",m),e(),n)}};t.fn.pronto=function(e,r){var i=t(this);return t.fn.pronto.o||(t.fn.pronto.o=new n(r)),t.fn.pronto.o.a(i,e)}}(jQuery),jQuery.log("Ajaxify loaded...",{verbosity:2});