website_template/js/main.min.js
2014-07-29 02:50:38 +02:00

1 line
7.9 KiB
JavaScript

function externalLinks(){if(document.getElementsByTagName)for(var e=document.getElementsByTagName("a"),t=0;t<e.length;t++){var n=e[t];n.getAttribute("href")&&"external"===n.getAttribute("class")&&(n.target="_blank")}}window.onload=externalLinks;var InstantClick=function(e,t){function n(e){var t=e.indexOf("#");return 0>t?e:e.substr(0,t)}function r(e){for(;"A"!=e.nodeName;)e=e.parentNode;return e}function a(e){do{if(!e.hasAttribute)break;if(e.hasAttribute("data-instant"))return!1;if(e.hasAttribute("data-no-instant"))return!0}while(e=e.parentNode);return!1}function i(e){do{if(!e.hasAttribute)break;if(e.hasAttribute("data-no-instant"))return!1;if(e.hasAttribute("data-instant"))return!0}while(e=e.parentNode);return!1}function o(e,t){for(var n=0;n<z[e].length;n++)z[e][n](t)}function s(t,r,a,i){if(e.title=t,e.documentElement.replaceChild(r,e.body),a){history.pushState(null,null,a);var s=a.indexOf("#"),c=s>-1&&e.getElementById(a.substr(s+1)),l=0;if(c)for(;c.offsetParent;)l+=c.offsetTop,c=c.offsetParent;scrollTo(0,l),E=n(a)}else scrollTo(0,i);v(),W.done(),o("change",!1)}function c(){Y=!1,O=!1}function l(e){g(r(e.target).href)}function d(e){var t=r(e.target);t.addEventListener("mouseout",h),C?(T=t.href,w=setTimeout(g,C)):g(t.href)}function f(e){var t=r(e.target);x?t.removeEventListener("mousedown",l):t.removeEventListener("mouseover",d),g(t.href)}function u(e){e.which>1||e.metaKey||e.ctrlKey||(e.preventDefault(),p(r(e.target).href))}function h(){return w?(clearTimeout(w),void(w=!1)):void(Y&&!O&&(L.abort(),c()))}function m(){if(!(L.readyState<4)&&0!=L.status){if(F.ready=+new Date-F.start,o("receive"),L.getResponseHeader("Content-Type").match(/\/(x|ht|xht)ml/)){var t=e.implementation.createHTMLDocument("");t.documentElement.innerHTML=L.responseText,D=t.title,B=t.body;var r=n(S);N[r]={body:B,title:D,scrollY:r in N?N[r].scrollY:0};for(var a,i,s=t.head.children,c=0,l=s.length-1;l>=0;l--)if(a=s[l],a.hasAttribute("data-instant-track")){i=a.getAttribute("href")||a.getAttribute("src")||a.innerHTML;for(var d=I.length-1;d>=0;d--)I[d]==i&&c++}c!=I.length&&(H=!0)}else H=!0;O&&(O=!1,p(S))}}function v(r){for(var o,s=e.getElementsByTagName("a"),c=t.protocol+"//"+t.host,h=s.length-1;h>=0;h--)o=s[h],o.target||o.hasAttribute("download")||0!=o.href.indexOf(c+"/")||o.href.indexOf("#")>-1&&n(o.href)==E||(k?!i(o):a(o))||(o.addEventListener("touchstart",f),x?o.addEventListener("mousedown",l):o.addEventListener("mouseover",d),o.addEventListener("click",u));if(!r){var m,v,g,p,y=e.body.getElementsByTagName("script");for(h=0,j=y.length;j>h;h++)m=y[h],m.hasAttribute("data-no-instant")||(v=e.createElement("script"),m.src&&(v.src=m.src),m.innerHTML&&(v.innerHTML=m.innerHTML),g=m.parentNode,p=m.nextSibling,g.removeChild(m),g.insertBefore(v,p))}}function g(e){!x&&"display"in F&&+new Date-(F.start+F.display)<100||(w&&(clearTimeout(w),w=!1),e||(e=T),(!Y||e!=S&&!O)&&(Y=!0,O=!1,S=e,B=!1,H=!1,F={start:+new Date},o("fetch"),L.open("GET",e),L.send()))}function p(e){return"display"in F||(F.display=+new Date-F.start),w?S&&S!=e?void(t.href=e):(g(e),W.start(0,!0),o("wait"),void(O=!0)):!Y||O?void(t.href=e):H?void(t.href=S):B?(N[E].scrollY=pageYOffset,c(),void s(D,B,S)):(W.start(0,!0),o("wait"),void(O=!0))}function y(){if(!E){if(!q)return void o("change",!0);for(var r=arguments.length-1;r>=0;r--){var a=arguments[r];a===!0?k=!0:"mousedown"==a?x=!0:"number"==typeof a&&(C=a)}E=n(t.href),N[E]={body:e.body,title:e.title,scrollY:pageYOffset};for(var i,c,l=e.head.children,r=l.length-1;r>=0;r--)i=l[r],i.hasAttribute("data-instant-track")&&(c=i.getAttribute("href")||i.getAttribute("src")||i.innerHTML,I.push(c));L=new XMLHttpRequest,L.addEventListener("readystatechange",m),v(!0),W.init(),o("change",!0),addEventListener("popstate",function(){var e=n(t.href);if(e!=E){if(!(e in N))return void(t.href=t.href);N[E].scrollY=pageYOffset,E=e,s(N[e].title,N[e].body,!1,N[e].scrollY)}})}}function b(e,t){z[e].push(t)}var E,T,w,L,k,x,C,A=navigator.userAgent,M="createTouch"in e,N={},S=!1,D=!1,H=!1,B=!1,F={},Y=!1,O=!1,I=[],z={fetch:[],receive:[],wait:[],change:[]},W=function(){function t(){c=e.createElement("div"),c.id="instantclick",l=e.createElement("div"),l.id="instantclick-bar",l.className="instantclick-bar",c.appendChild(l);var t=["Webkit","Moz","O"];if(d="transform",!(d in l.style))for(var n=0;3>n;n++)t[n]+"Transform"in l.style&&(d=t[n]+"Transform");var r="transition";if(!(r in l.style))for(var n=0;3>n;n++)t[n]+"Transition"in l.style&&(r="-"+t[n].toLowerCase()+"-"+r);var a=e.createElement("style");a.innerHTML="#instantclick{position:"+(M?"absolute":"fixed")+";top:0;left:0;width:100%;pointer-events:none;z-index:2147483647;"+r+":opacity .25s .1s}.instantclick-bar{background:#29d;width:100%;margin-left:-100%;height:2px;"+r+":all .25s}",e.head.appendChild(a),M&&(s(),addEventListener("resize",s),addEventListener("scroll",s))}function n(t,n){f=t,e.getElementById(c.id)&&e.body.removeChild(c),c.style.opacity="1",e.getElementById(c.id)&&e.body.removeChild(c),i(),n&&setTimeout(r,0),clearTimeout(u),u=setTimeout(a,500)}function r(){f=10,i()}function a(){f+=1+2*Math.random(),f>=98?f=98:u=setTimeout(a,500),i()}function i(){l.style[d]="translate("+f+"%)",e.getElementById(c.id)||e.body.appendChild(c)}function o(){return e.getElementById(c.id)?(clearTimeout(u),f=100,i(),void(c.style.opacity="0")):(n(100==f?0:f),void setTimeout(o,0))}function s(){c.style.left=pageXOffset+"px",c.style.width=innerWidth+"px",c.style.top=pageYOffset+"px";var e="orientation"in window&&90==Math.abs(orientation),t=innerWidth/screen[e?"height":"width"]*2;c.style[d]="scaleY("+t+")"}var c,l,d,f,u;return{init:t,start:n,done:o}}(),q="pushState"in history&&(!A.match("Android")||A.match("Chrome/"))&&"file:"!=t.protocol;return{supported:q,init:y,on:b}}(document,location);!function(e,t){function n(){var e=v.elements;return"string"==typeof e?e.split(" "):e}function r(e){var t=m[e[u]];return t||(t={},h++,e[u]=h,m[h]=t),t}function a(e,n,a){return n||(n=t),c?n.createElement(e):(a||(a=r(n)),n=a.cache[e]?a.cache[e].cloneNode():f.test(e)?(a.cache[e]=a.createElem(e)).cloneNode():a.createElem(e),n.canHaveChildren&&!d.test(e)?a.frag.appendChild(n):n)}function i(e,t){t.cache||(t.cache={},t.createElem=e.createElement,t.createFrag=e.createDocumentFragment,t.frag=t.createFrag()),e.createElement=function(n){return v.shivMethods?a(n,e,t):t.createElem(n)},e.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+n().join().replace(/[\w\-]+/g,function(e){return t.createElem(e),t.frag.createElement(e),'c("'+e+'")'})+");return n}")(v,t.frag)}function o(e){e||(e=t);var n=r(e);if(v.shivCSS&&!s&&!n.hasCSS){var a,o=e;a=o.createElement("p"),o=o.getElementsByTagName("head")[0]||o.documentElement,a.innerHTML="x<style>article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}</style>",a=o.insertBefore(a.lastChild,o.firstChild),n.hasCSS=!!a}return c||i(e,n),e}var s,c,l=e.html5||{},d=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,f=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,u="_html5shiv",h=0,m={};!function(){try{var e=t.createElement("a");e.innerHTML="<xyz></xyz>",s="hidden"in e;var n;if(!(n=1==e.childNodes.length)){t.createElement("a");var r=t.createDocumentFragment();n="undefined"==typeof r.cloneNode||"undefined"==typeof r.createDocumentFragment||"undefined"==typeof r.createElement}c=n}catch(a){c=s=!0}}();var v={elements:l.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:"3.7.0",shivCSS:!1!==l.shivCSS,supportsUnknownElements:c,shivMethods:!1!==l.shivMethods,type:"default",shivDocument:o,createElement:a,createDocumentFragment:function(e,a){if(e||(e=t),c)return e.createDocumentFragment();for(var a=a||r(e),i=a.frag.cloneNode(),o=0,s=n(),l=s.length;l>o;o++)i.createElement(s[o]);return i}};e.html5=v,o(t)}(this,document);