3-js edit

wm-helper-min-js  edit

Copy
Edit
<!-- components/3-js/wm-helper-min-js.php -->
Copy
Copy
Edit
/* scss/3-js/_wm-helper-min-js.scss */
Copy
Edit
/* js/wm-helper-min-js.js */ (function(a) { window.MBP = window.MBP || {}; MBP.viewportmeta = a.querySelector && a.querySelector('meta[name="viewport"]'); MBP.ua = navigator.userAgent; MBP.scaleFix = function() { if ( MBP.viewportmeta && /iPhone|iPad|iPod/.test(MBP.ua) && !/Opera Mini/.test(MBP.ua) ) { MBP.viewportmeta.content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0"; a.addEventListener("gesturestart", MBP.gestureStart, false); } }; MBP.gestureStart = function() { MBP.viewportmeta.content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6"; }; MBP.BODY_SCROLL_TOP = false; MBP.getScrollTop = function() { var e = window; var d = a; return ( e.pageYOffset || (d.compatMode === "CSS1Compat" && d.documentElement.scrollTop) || d.body.scrollTop || 0 ); }; MBP.hideUrlBar = function() { var d = window; if (!location.hash && MBP.BODY_SCROLL_TOP !== false) { d.scrollTo(0, MBP.BODY_SCROLL_TOP === 1 ? 0 : 1); } }; MBP.hideUrlBarOnLoad = function() { var f = window; var e = f.document; var d; if (!location.hash && f.addEventListener) { window.scrollTo(0, 1); MBP.BODY_SCROLL_TOP = 1; d = setInterval(function() { if (e.body) { clearInterval(d); MBP.BODY_SCROLL_TOP = MBP.getScrollTop(); MBP.hideUrlBar(); } }, 15); f.addEventListener("load", function() { setTimeout(function() { if (MBP.getScrollTop() < 20) { MBP.hideUrlBar(); } }, 0); }); } }; MBP.fastButton = function(e, f, d) { this.handler = f; this.pressedClass = typeof d === "undefined" ? "pressed" : d; if (e.length && e.length > 1) { for (var g in e) { this.addClickEvent(e[g]); } } else { this.addClickEvent(e); } }; MBP.fastButton.prototype.handleEvent = function(d) { d = d || window.event; switch (d.type) { case "touchstart": this.onTouchStart(d); break; case "touchmove": this.onTouchMove(d); break; case "touchend": this.onClick(d); break; case "click": this.onClick(d); break; } }; MBP.fastButton.prototype.onTouchStart = function(e) { var d = e.target || e.srcElement; e.stopPropagation(); d.addEventListener("touchend", this, false); a.body.addEventListener("touchmove", this, false); this.startX = e.touches[0].clientX; this.startY = e.touches[0].clientY; d.className += " " + this.pressedClass; }; MBP.fastButton.prototype.onTouchMove = function(d) { if ( Math.abs(d.touches[0].clientX - this.startX) > 10 || Math.abs(d.touches[0].clientY - this.startY) > 10 ) { this.reset(d); } }; MBP.fastButton.prototype.onClick = function(e) { e = e || window.event; var d = e.target || e.srcElement; if (e.stopPropagation) { e.stopPropagation(); } this.reset(e); this.handler.apply(e.currentTarget, [e]); if (e.type == "touchend") { MBP.preventGhostClick(this.startX, this.startY); } var f = new RegExp(" ?" + this.pressedClass, "gi"); d.className = d.className.replace(f, ""); }; MBP.fastButton.prototype.reset = function(e) { var d = e.target || e.srcElement; b(d, "touchend", this, false); b(a.body, "touchmove", this, false); var f = new RegExp(" ?" + this.pressedClass, "gi"); d.className = d.className.replace(f, ""); }; MBP.fastButton.prototype.addClickEvent = function(d) { c(d, "touchstart", this, false); c(d, "click", this, false); }; MBP.preventGhostClick = function(d, e) { MBP.coords.push(d, e); window.setTimeout(function() { MBP.coords.splice(0, 2); }, 2500); }; MBP.ghostClickHandler = function(g) { if (!MBP.hadTouchEvent && MBP.dodgyAndroid) { g.stopPropagation(); g.preventDefault(); return; } for (var f = 0, e = MBP.coords.length; f < e; f += 2) { var d = MBP.coords[f]; var h = MBP.coords[f + 1]; if (Math.abs(g.clientX - d) < 25 && Math.abs(g.clientY - h) < 25) { g.stopPropagation(); g.preventDefault(); } } }; MBP.dodgyAndroid = "ontouchstart" in window && navigator.userAgent.indexOf("Android 2.3") != -1; if (a.addEventListener) { a.addEventListener("click", MBP.ghostClickHandler, true); } c( a.documentElement, "touchstart", function() { MBP.hadTouchEvent = true; }, false ); MBP.coords = []; function c(h, f, g, d) { if ("addEventListener" in h) { try { h.addEventListener(f, g, d); } catch (i) { if (typeof g == "object" && g.handleEvent) { h.addEventListener( f, function(j) { g.handleEvent.call(g, j); }, d ); } else { throw i; } } } else { if ("attachEvent" in h) { if (typeof g == "object" && g.handleEvent) { h.attachEvent("on" + f, function() { g.handleEvent.call(g); }); } else { h.attachEvent("on" + f, g); } } } } function b(h, f, g, d) { if ("removeEventListener" in h) { try { h.removeEventListener(f, g, d); } catch (i) { if (typeof g == "object" && g.handleEvent) { h.removeEventListener( f, function(j) { g.handleEvent.call(g, j); }, d ); } else { throw i; } } } else { if ("detachEvent" in h) { if (typeof g == "object" && g.handleEvent) { h.detachEvent("on" + f, function() { g.handleEvent.call(g); }); } else { h.detachEvent("on" + f, g); } } } } MBP.autogrow = function(f, d) { function g(j) { var i = this.scrollHeight; var k = this.clientHeight; if (i > k) { this.style.height = i + 3 * h + "px"; } } var e = d ? d : 12; var h = f.currentStyle ? f.currentStyle.lineHeight : getComputedStyle(f, null).lineHeight; h = h.indexOf("px") == -1 ? e : parseInt(h, 10); f.style.overflow = "hidden"; f.addEventListener ? f.addEventListener("input", g, false) : f.attachEvent("onpropertychange", g); }; MBP.enableActive = function() { a.addEventListener("touchstart", function() {}, false); }; MBP.preventScrolling = function() { a.addEventListener( "touchmove", function(d) { if (d.target.type === "range") { return; } d.preventDefault(); }, false ); }; MBP.preventZoom = function() { var e = a.querySelectorAll("input, select, textarea"); var f = "width=device-width,initial-scale=1,maximum-scale="; var d = 0; for (d = 0; d < e.length; d++) { e[d].onfocus = function() { MBP.viewportmeta.content = f + "1"; }; e[d].onblur = function() { MBP.viewportmeta.content = f + "10"; }; } }; MBP.startupImage = function() { var i; var g; var h; var f; var e; var d; h = window.devicePixelRatio; f = a.getElementsByTagName("head")[0]; if (navigator.platform === "iPad") { i = h === 2 ? "img/startup/startup-tablet-portrait-retina.png" : "img/startup/startup-tablet-portrait.png"; g = h === 2 ? "img/startup/startup-tablet-landscape-retina.png" : "img/startup/startup-tablet-landscape.png"; e = a.createElement("link"); e.setAttribute("rel", "apple-touch-startup-image"); e.setAttribute("media", "screen and (orientation: portrait)"); e.setAttribute("href", i); f.appendChild(e); d = a.createElement("link"); d.setAttribute("rel", "apple-touch-startup-image"); d.setAttribute("media", "screen and (orientation: landscape)"); d.setAttribute("href", g); f.appendChild(d); } else { i = h === 2 ? "img/startup/startup-retina.png" : "img/startup/startup.png"; i = screen.height === 568 ? "img/startup/startup-retina-4in.png" : i; e = a.createElement("link"); e.setAttribute("rel", "apple-touch-startup-image"); e.setAttribute("href", i); f.appendChild(e); } if ((navigator.platform === "iPhone" || "iPod") && screen.height === 568) { if (MBP.viewportmeta) { MBP.viewportmeta.content = MBP.viewportmeta.content .replace(/\bwidth\s*=\s*320\b/, "width=320.1") .replace(/\bwidth\s*=\s*device-width\b/, ""); } } }; })(document);