additional_plugins/homepage/scripts/master.js
2017-04-14 22:31:00 +02:00

2 lines
6.8 KiB
JavaScript

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