additional_plugins/homepage/scripts/master.js
2019-04-27 16:55:49 +02:00

9 lines
7 KiB
JavaScript

/*! responsive-nav.js 1.0.39
* https://github.com/viljamis/responsive-nav.js
* http://responsive-nav.com
*
* Copyright (c) 2015 @viljamis
* Available under the MIT license
*/
!function(m,g,y){"use strict";function e(e,t){function s(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))}function n(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))}function i(e,t){for(var n in t)e.setAttribute(n,t[n])}function o(e,t){0!==e.className.indexOf(t)&&(e.className+=" "+t,e.className=e.className.replace(/(^\s*)|(\s*$)/g,""))}function a(e,t){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ").replace(/(^\s*)|(\s*$)/g,"")}function r(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(o(f,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),l=this.options,c=this.wrapper,this._init(this)}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 c,l,h,u,p,v,d=m.createElement("style"),f=m.documentElement;return r.prototype={destroy:function(){this._removeStyles(),a(c,"closed"),a(c,"opened"),a(c,l.navClass),a(c,l.navClass+"-"+this.index),a(f,l.navActiveClass),c.removeAttribute("style"),c.removeAttribute("aria-hidden"),n(g,"resize",this,!1),n(g,"focus",this,!1),n(m.body,"touchmove",this,!1),n(h,"touchstart",this,!1),n(h,"touchend",this,!1),n(h,"mouseup",this,!1),n(h,"keyup",this,!1),n(h,"click",this,!1),l.customToggle?h.removeAttribute("aria-hidden"):h.parentNode.removeChild(h)},toggle:function(){!0===u&&(v?this.close():this.open())},open:function(){v||(a(c,"closed"),o(c,"opened"),o(f,l.navActiveClass),o(h,"active"),c.style.position=l.openPos,i(c,{"aria-hidden":"false"}),v=!0,l.open())},close:function(){v&&(o(c,"closed"),a(c,"opened"),a(f,l.navActiveClass),a(h,"active"),i(c,{"aria-hidden":"true"}),l.animate?(u=!1,setTimeout(function(){c.style.position="absolute",u=!0},l.transition+10)):c.style.position="absolute",v=!1,l.close())},resize:function(){"none"!==g.getComputedStyle(h,null).getPropertyValue("display")?(p=!0,i(h,{"aria-hidden":"false"}),c.className.match(/(^|\s)closed(\s|$)/)&&(i(c,{"aria-hidden":"true"}),c.style.position="absolute"),this._createStyles(),this._calcHeight()):(p=!1,i(h,{"aria-hidden":"true"}),i(c,{"aria-hidden":"false"}),c.style.position=l.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++,o(c,l.navClass),o(c,l.navClass+"-"+this.index),o(c,"closed"),v=!(u=!0),this._closeOnNavClick(),this._createToggle(),this._transitions(),this.resize();var e=this;setTimeout(function(){e.resize()},20),s(g,"resize",this,!1),s(g,"focus",this,!1),s(m.body,"touchmove",this,!1),s(h,"touchstart",this,!1),s(h,"touchend",this,!1),s(h,"mouseup",this,!1),s(h,"keyup",this,!1),s(h,"click",this,!1),l.init()},_createStyles:function(){d.parentNode||(d.type="text/css",m.getElementsByTagName("head")[0].appendChild(d))},_removeStyles:function(){d.parentNode&&d.parentNode.removeChild(d)},_createToggle:function(){if(l.customToggle){var e=l.customToggle.replace("#","");if(m.getElementById(e))h=m.getElementById(e);else{if(!m.querySelector(e))throw new Error("The custom nav toggle you are trying to select doesn't exist");h=m.querySelector(e)}}else{var t=m.createElement("a");t.innerHTML=l.label,i(t,{href:"#",class:"nav-toggle"}),"after"===l.insert?c.parentNode.insertBefore(t,c.nextSibling):c.parentNode.insertBefore(t,c),h=t}},_closeOnNavClick:function(){if(l.closeOnNavClick){var n=c.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){s(n[e],"click",function(){p&&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,n(h,"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),p&&!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(l.animate){var e=c.style,t="max-height "+l.transition+"ms";e.WebkitTransition=e.MozTransition=e.OTransition=e.transition=t}},_calcHeight:function(){for(var e=0,t=0;t<c.inner.length;t++)e+=c.inner[t].offsetHeight;var n="."+l.jsClass+" ."+l.navClass+"-"+this.index+".opened{max-height:"+e+"px !important} ."+l.jsClass+" ."+l.navClass+"-"+this.index+".opened.dropdown-active {max-height:9999px !important}";d.styleSheet?d.styleSheet.cssText=n:d.innerHTML=n,n=""}},new r(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