1! function(a) { 2 "use strict"; 3 4 function b() { 5 var a, b = document.createElement("fakeelement"), 6 c = { 7 transition: "transitionend", 8 OTransition: "oTransitionEnd", 9 MozTransition: "transitionend", 10 WebkitTransition: "webkitTransitionEnd" 11 } 12 13 ; 14 for (a in c) 15 if (void 0 !== b.style[a]) return c[a] 16 } 17 18 function c(b) { 19 var c = 0, 20 d = 0; 21 if (!b) var b = a.event; 22 return b.pageX || b.pageY ? (c = b.pageX, d = b.pageY) : (b.clientX || b.clientY) && (c = b.clientX + document.body.scrollLeft + document.documentElement.scrollLeft, d = b.clientY + document.body.scrollTop + document.documentElement.scrollTop), { 23 x: c, 24 y: d 25 } 26 } 27 28 function d(b) { 29 var c = b.getBoundingClientRect(), 30 d = document.body, 31 e = document.documentElement, 32 f = a.pageYOffset || e.scrollTop || d.scrollTop, 33 g = a.pageXOffset || e.scrollLeft || d.scrollLeft, 34 h = e.clientTop || d.clientTop || 0, 35 i = e.clientLeft || d.clientLeft || 0, 36 j = c.top + f - h, 37 k = c.left + g - i; 38 return { 39 x: Math.round(k), 40 y: Math.round(j) 41 } 42 } 43 44 class e { 45 constructor() { 46 this.body = document.body, this.dokuwiki__site = document.querySelector("#dokuwiki__site"), this.toggle = document.querySelector("#mm-menu-toggle"), this.menu = document.querySelector("#mm-menu"), this.menuItems = this.menu.querySelectorAll("li"), this.menuItemLinks = this.menu.querySelectorAll("a"), this.menuPosition = "off", this.mask = document.createElement("div"), this.mask.className = "mm-menu-mask", document.body.appendChild(this.mask), this._init(); 47 } 48 _init() { 49 this._initToggleEvents(), this._initItemTransitions(), this._initTouchEffect(), this._initMaskEvents(); 50 } 51 _initToggleEvents() { 52 var a = this; 53 this.toggle.addEventListener("click", function() { 54 "off" == a.menuPosition ? a._toggleMenuOn() : a._toggleMenuOff(); 55 }); 56 } 57 _toggleMenuOn() { 58 var a = this; 59 this.body.classList.add("mm-menu-open"), this.dokuwiki__site.classList.add("mm-menu-open"), this.toggle.classList.add("active"), this.menu.classList.add("active"); 60 for (var b = 0; b < a.menuItems.length; b++) { 61 var c = a.menuItems[b]; 62 ! function(a) { 63 a.classList.add("in-view"); 64 }(c); 65 } 66 this.mask.classList.add("active"), this.menuPosition = "on"; 67 } 68 _toggleMenuOff() { 69 var a = this; 70 this.body.classList.remove("mm-menu-open"), this.dokuwiki__site.classList.remove("mm-menu-open"), this.toggle.classList.remove("active"), this.menu.classList.remove("active"); 71 for (var b = 0; b < a.menuItems.length; b++) { 72 var c = a.menuItems[b]; 73 ! function(a) { 74 a.classList.remove("in-view"); 75 }(c); 76 } 77 this.mask.classList.remove("active"), this.menuPosition = "off"; 78 } 79 _initItemTransitions() { 80 for (var a = this.menuItems.length, b = 0; a > b; b++) { 81 var c = b + 1, 82 d = this.menuItems[b]; 83 this._itemTransitionHandler(d, c); 84 } 85 } 86 _itemTransitionHandler(a, b) { 87 a.classList.add("item-" + b); 88 } 89 _initTouchEffect() { 90 for (var a = this.menuItemLinks.length, b = 0; a > b; b++) { 91 var c = this.menuItemLinks[b]; 92 this._touchEffectHandler(c); 93 } 94 } 95 _touchEffectHandler(a) { 96 /* var b = a.offsetWidth, 97 e = a.offsetHeight, 98 g = 2 * Math.max(b, e), 99 h = document.createElement("span"); 100 h.className = "mm-menu__link--touch-effect", h.style.width = g + "px", h.style.height = g + "px", a.insertBefore(h, a.firstChild), a.addEventListener("click", function(a) { 101 var b = c(a).x - d(this).x, 102 e = c(a).y - d(this).y; 103 h.style.top = e + "px", h.style.left = b + "px", h.style.marginTop = -(g / 2) + "px", h.style.marginLeft = -(g / 2) + "px", h.classList.add("animating"); 104 }), h.addEventListener(f, function() { 105 this.classList.remove("animating"); 106 }); */ 107 } 108 _initMaskEvents() { 109 var a = this; 110 this.mask.addEventListener("click", function(b) { 111 b.preventDefault(), "on" == a.menuPosition ? a._toggleMenuOff() : !1; 112 }); 113 } 114 } 115 var f = b(); 116 a.Menu = e 117} 118(window); 119 120 121var menu = new Menu; 122 123/*** 124 * 125 * Auto - Hide top menu 126 * 127 */ 128var prevScrollpos = window.pageYOffset; 129window.onscroll = function() { 130 var currentScrollPos = window.pageYOffset; 131 if ((prevScrollpos > currentScrollPos) || (window.pageYOffset <= 0)) { 132 document.getElementById("dokuwiki__header").style.top = "0"; 133 } else { 134 document.getElementById("dokuwiki__header").style.top = "-50px"; 135 } 136 prevScrollpos = currentScrollPos; 137} 138; 139 140/** 141 * We handle several device classes based on browser width. 142 * 143 * - desktop: > __tablet_width__ (as set in style.ini) 144 * - mobile: 145 * - tablet <= __tablet_width__ 146 * - phone <= __phone_width__ 147 */ 148 149var device_class = ''; // not yet known 150var device_classes = 'desktop mobile tablet phone'; 151 152function tpl_dokuwiki_mobile() { 153 154 // the z-index in mobile.css is (mis-)used purely for detecting the screen mode here 155 var screen_mode = jQuery('#screen__mode').css('z-index') + ''; 156 157 // determine our device pattern 158 // TODO: consider moving into dokuwiki core 159 switch (screen_mode) { 160 case '1': 161 if (device_class.match(/tablet/)) return; 162 device_class = 'mobile tablet'; 163 break; 164 case '2': 165 if (device_class.match(/phone/)) return; 166 device_class = 'mobile phone'; 167 break; 168 default: 169 if (device_class == 'desktop') return; 170 device_class = 'desktop'; 171 } 172 173 jQuery('html').removeClass(device_classes).addClass(device_class); 174 175 // handle some layout changes based on change in device 176 var $handle = jQuery('#dokuwiki__aside h3.toggle'); 177 var $toc = jQuery('#dw__toc h3'); 178 179 if (device_class == 'desktop') { 180 // reset for desktop mode 181 if ($handle.length) { 182 $handle[0].setState(1); 183 $handle.hide(); 184 } 185 if ($toc.length) { 186 $toc[0].setState(1); 187 } 188 } 189 if (device_class.match(/mobile/)) { 190 // toc and sidebar hiding 191 if ($handle.length) { 192 $handle.show(); 193 $handle[0].setState(-1); 194 } 195 if ($toc.length) { 196 $toc[0].setState(-1); 197 } 198 } 199} 200 201jQuery(function() { 202 var resizeTimer; 203 dw_page.makeToggle('#dokuwiki__aside h3.toggle', '#dokuwiki__aside div.content'); 204 205 tpl_dokuwiki_mobile(); 206 jQuery(window).on('resize', 207 function() { 208 if (resizeTimer) clearTimeout(resizeTimer); 209 resizeTimer = setTimeout(tpl_dokuwiki_mobile, 200); 210 } 211 ); 212 213 214 215 // blur when clicked 216 jQuery('#dokuwiki__pagetools div.tools>ul>li>a').on('click', function() { 217 this.blur(); 218 }); 219});