additional_plugins/homepage/scripts/master.js
2018-09-30 16:36:16 +02:00

2 lines
No EOL
6.8 KiB
JavaScript

!function(m,g,y){"use strict";var e=function(e,t){!!g.getComputedStyle||(g.getComputedStyle=function(n){return this.el=n,this.getPropertyValue=function(e){var t=/(\-([a-z]){1})/g;return"float"===e&&(e="styleFloat"),t.test(e)&&(e=e.replace(t,function(){return arguments[2].toUpperCase()})),n.currentStyle[e]?n.currentStyle[e]:null},this});var s,o,n,i,a,r,c=function(t,n,i,s){if("addEventListener"in t)try{t.addEventListener(n,i,s)}catch(e){if("object"!=typeof i||!i.handleEvent)throw e;t.addEventListener(n,function(e){i.handleEvent.call(i,e)},s)}else"attachEvent"in t&&("object"==typeof i&&i.handleEvent?t.attachEvent("on"+n,function(){i.handleEvent.call(i)}):t.attachEvent("on"+n,i))},l=function(t,n,i,s){if("removeEventListener"in t)try{t.removeEventListener(n,i,s)}catch(e){if("object"!=typeof i||!i.handleEvent)throw e;t.removeEventListener(n,function(e){i.handleEvent.call(i,e)},s)}else"detachEvent"in t&&("object"==typeof i&&i.handleEvent?t.detachEvent("on"+n,function(){i.handleEvent.call(i)}):t.detachEvent("on"+n,i))},h=function(e,t){for(var n in t)e.setAttribute(n,t[n])},u=function(e,t){0!==e.className.indexOf(t)&&(e.className+=" "+t,e.className=e.className.replace(/(^\s*)|(\s*$)/g,""))},p=function(e,t){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ").replace(/(^\s*)|(\s*$)/g,"")},v=m.createElement("style"),d=m.documentElement,f=function(e,t){var n;for(n in this.options={animate:!0,transition:284,label:"Menu",insert:"before",customToggle:"",closeOnNavClick:!1,openPos:"relative",navClass:"nav-collapse",navActiveClass:"js-nav-active",jsClass:"js",init:function(){},open:function(){},close:function(){}},t)this.options[n]=t[n];if(u(d,this.options.jsClass),this.wrapperEl=e.replace("#",""),m.getElementById(this.wrapperEl))this.wrapper=m.getElementById(this.wrapperEl);else{if(!m.querySelector(this.wrapperEl))throw new Error("The nav element you are trying to select doesn't exist");this.wrapper=m.querySelector(this.wrapperEl)}this.wrapper.inner=function(e){if(e.children.length<1)throw new Error("The Nav container has no containing elements");for(var t=[],n=0;n<e.children.length;n++)1===e.children[n].nodeType&&t.push(e.children[n]);return t}(this.wrapper),o=this.options,s=this.wrapper,this._init(this)};return f.prototype={destroy:function(){this._removeStyles(),p(s,"closed"),p(s,"opened"),p(s,o.navClass),p(s,o.navClass+"-"+this.index),p(d,o.navActiveClass),s.removeAttribute("style"),s.removeAttribute("aria-hidden"),l(g,"resize",this,!1),l(g,"focus",this,!1),l(m.body,"touchmove",this,!1),l(n,"touchstart",this,!1),l(n,"touchend",this,!1),l(n,"mouseup",this,!1),l(n,"keyup",this,!1),l(n,"click",this,!1),o.customToggle?n.removeAttribute("aria-hidden"):n.parentNode.removeChild(n)},toggle:function(){!0===i&&(r?this.close():this.open())},open:function(){r||(p(s,"closed"),u(s,"opened"),u(d,o.navActiveClass),u(n,"active"),s.style.position=o.openPos,h(s,{"aria-hidden":"false"}),r=!0,o.open())},close:function(){r&&(u(s,"closed"),p(s,"opened"),p(d,o.navActiveClass),p(n,"active"),h(s,{"aria-hidden":"true"}),o.animate?(i=!1,setTimeout(function(){s.style.position="absolute",i=!0},o.transition+10)):s.style.position="absolute",r=!1,o.close())},resize:function(){"none"!==g.getComputedStyle(n,null).getPropertyValue("display")?(a=!0,h(n,{"aria-hidden":"false"}),s.className.match(/(^|\s)closed(\s|$)/)&&(h(s,{"aria-hidden":"true"}),s.style.position="absolute"),this._createStyles(),this._calcHeight()):(a=!1,h(n,{"aria-hidden":"true"}),h(s,{"aria-hidden":"false"}),s.style.position=o.openPos,this._removeStyles())},handleEvent:function(e){var t=e||g.event;switch(t.type){case"touchstart":this._onTouchStart(t);break;case"touchmove":this._onTouchMove(t);break;case"touchend":case"mouseup":this._onTouchEnd(t);break;case"click":this._preventDefault(t);break;case"keyup":this._onKeyUp(t);break;case"focus":case"resize":this.resize(t)}},_init:function(){this.index=y++,u(s,o.navClass),u(s,o.navClass+"-"+this.index),u(s,"closed"),r=!(i=!0),this._closeOnNavClick(),this._createToggle(),this._transitions(),this.resize();var e=this;setTimeout(function(){e.resize()},20),c(g,"resize",this,!1),c(g,"focus",this,!1),c(m.body,"touchmove",this,!1),c(n,"touchstart",this,!1),c(n,"touchend",this,!1),c(n,"mouseup",this,!1),c(n,"keyup",this,!1),c(n,"click",this,!1),o.init()},_createStyles:function(){v.parentNode||(v.type="text/css",m.getElementsByTagName("head")[0].appendChild(v))},_removeStyles:function(){v.parentNode&&v.parentNode.removeChild(v)},_createToggle:function(){if(o.customToggle){var e=o.customToggle.replace("#","");if(m.getElementById(e))n=m.getElementById(e);else{if(!m.querySelector(e))throw new Error("The custom nav toggle you are trying to select doesn't exist");n=m.querySelector(e)}}else{var t=m.createElement("a");t.innerHTML=o.label,h(t,{href:"#",class:"nav-toggle"}),"after"===o.insert?s.parentNode.insertBefore(t,s.nextSibling):s.parentNode.insertBefore(t,s),n=t}},_closeOnNavClick:function(){if(o.closeOnNavClick){var n=s.getElementsByTagName("a"),i=this;!function(e,t,n){for(var i=0;i<e.length;i++)t.call(n,i,e[i])}(n,function(e,t){c(n[e],"click",function(){a&&i.toggle()},!1)})}},_preventDefault:function(e){if(e.preventDefault)return e.stopImmediatePropagation&&e.stopImmediatePropagation(),e.preventDefault(),e.stopPropagation(),!1;e.returnValue=!1},_onTouchStart:function(e){Event.prototype.stopImmediatePropagation||this._preventDefault(e),this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY,this.touchHasMoved=!1,l(n,"mouseup",this,!1)},_onTouchMove:function(e){(10<Math.abs(e.touches[0].clientX-this.startX)||10<Math.abs(e.touches[0].clientY-this.startY))&&(this.touchHasMoved=!0)},_onTouchEnd:function(e){if(this._preventDefault(e),a&&!this.touchHasMoved){if("touchend"===e.type)return void this.toggle();var t=e||g.event;3!==t.which&&2!==t.button&&this.toggle()}},_onKeyUp:function(e){13===(e||g.event).keyCode&&this.toggle()},_transitions:function(){if(o.animate){var e=s.style,t="max-height "+o.transition+"ms";e.WebkitTransition=e.MozTransition=e.OTransition=e.transition=t}},_calcHeight:function(){for(var e=0,t=0;t<s.inner.length;t++)e+=s.inner[t].offsetHeight;var n="."+o.jsClass+" ."+o.navClass+"-"+this.index+".opened{max-height:"+e+"px !important} ."+o.jsClass+" ."+o.navClass+"-"+this.index+".opened.dropdown-active {max-height:9999px !important}";v.styleSheet?v.styleSheet.cssText=n:v.innerHTML=n,n=""}},new f(e,t)};"undefined"!=typeof module&&module.exports?module.exports=e:g.responsiveNav=e}(document,window,0),$(function(){responsiveNav(".nav-collapse",{customToggle:"#open-nav",closeOnNavClick:!0});$("#to-top, #markdown-toc a").click(function(){if(location.pathname.replace(/^\//,"")===this.pathname.replace(/^\//,"")&&location.hostname===this.hostname){var e=$(this.hash);if((e=e.length&&e||$("[name="+this.hash.slice(1)+"]")).length){var t=e.offset().top;return $("html,body").animate({scrollTop:t},300),!1}}})});
//# sourceMappingURL=master.js.map