vendor/assets/javascripts/responsive-nav.js in responsive-nav-rails-1.0.33 vs vendor/assets/javascripts/responsive-nav.js in responsive-nav-rails-1.0.38

- old
+ new

@@ -1,13 +1,14 @@ -/*! responsive-nav.js 1.0.32 +/*! responsive-nav.js 1.0.38 * https://github.com/viljamis/responsive-nav.js * http://responsive-nav.com * - * Copyright (c) 2014 @viljamis + * Copyright (c) 2015 @viljamis * Available under the MIT license */ +/* global Event */ (function (document, window, index) { // Index is used to keep multiple navs on the same page namespaced "use strict"; @@ -284,13 +285,10 @@ if (!navOpen) { this.open(); } else { this.close(); } - - // Enable pointer events again - this._enablePointerEvents(); } }, /** * Opens the navigation @@ -497,11 +495,11 @@ } } }, /** - * Closes the navigation when a link inside is clicked + * Closes the navigation when a link inside is clicked. */ _closeOnNavClick: function () { if (opts.closeOnNavClick) { var links = nav.getElementsByTagName("a"), self = this; @@ -514,11 +512,11 @@ }); } }, /** - * Prevents the default tap functionality + * Prevents the default functionality. * * @param {event} event */ _preventDefault: function(e) { if (e.preventDefault) { @@ -534,46 +532,43 @@ e.returnValue = false; } }, /** - * On touch start get the location of the touch - * and disable pointer events on the body. + * On touch start we get the location of the touch. * * @param {event} event */ _onTouchStart: function (e) { - this._preventDefault(e); - addClass(document.body, "disable-pointer-events"); + if (!Event.prototype.stopImmediatePropagation) { + this._preventDefault(e); + } this.startX = e.touches[0].clientX; this.startY = e.touches[0].clientY; this.touchHasMoved = false; /** - * We remove mouseup event completely here to avoid - * double triggering of events. + * Remove mouseup event completely here to avoid + * double triggering the event. */ removeEvent(navToggle, "mouseup", this, false); }, /** - * Check if the user is scrolling instead of tapping and - * re-enable pointer events if movement happed. + * Check if the user is scrolling instead of tapping. * * @param {event} event */ _onTouchMove: function (e) { if (Math.abs(e.touches[0].clientX - this.startX) > 10 || Math.abs(e.touches[0].clientY - this.startY) > 10) { - this._enablePointerEvents(); this.touchHasMoved = true; } }, /** - * On touch end toggle either the whole navigation or - * a sub-navigation depending on which one was tapped. + * On touch end toggle the navigation. * * @param {event} event */ _onTouchEnd: function (e) { this._preventDefault(e); @@ -585,15 +580,10 @@ if (!this.touchHasMoved) { // If the event type is touch if (e.type === "touchend") { this.toggle(); - if (opts.insert === "after") { - setTimeout(function () { - removeClass(document.body, "disable-pointer-events"); - }, opts.transition + 300); - } return; // Event type was click, not touch } else { var evt = e || window.event; @@ -606,12 +596,11 @@ } }, /** * For keyboard accessibility, toggle the navigation on Enter - * keypress too (also sub-navigation is keyboard accessible - * which explains the complexity here) + * keypress too. * * @param {event} event */ _onKeyUp: function (e) { var evt = e || window.event; @@ -619,27 +608,20 @@ this.toggle(); } }, /** - * Enable pointer events - */ - _enablePointerEvents: function () { - removeClass(document.body, "disable-pointer-events"); - }, - - /** * Adds the needed CSS transitions if animations are enabled */ _transitions: function () { if (opts.animate) { var objStyle = nav.style, transition = "max-height " + opts.transition + "ms"; - objStyle.WebkitTransition = transition; - objStyle.MozTransition = transition; - objStyle.OTransition = transition; + objStyle.WebkitTransition = + objStyle.MozTransition = + objStyle.OTransition = objStyle.transition = transition; } }, /** @@ -650,12 +632,10 @@ var savedHeight = 0; for (var i = 0; i < nav.inner.length; i++) { savedHeight += nav.inner[i].offsetHeight; } - // Pointer event styles are also here since they might only be confusing inside the stylesheet - var innerStyles = "." + opts.jsClass + " ." + opts.navClass + "-" + this.index + ".opened{max-height:" + savedHeight + "px !important} ." + opts.jsClass + " .disable-pointer-events{pointer-events:none !important} ." + opts.jsClass + " ." + opts.navClass + "-" + this.index + ".opened.dropdown-active {max-height:9999px !important}"; - + var innerStyles = "." + opts.jsClass + " ." + opts.navClass + "-" + this.index + ".opened{max-height:" + savedHeight + "px !important} ." + opts.jsClass + " ." + opts.navClass + "-" + this.index + ".opened.dropdown-active {max-height:9999px !important}"; if (styleElement.styleSheet) { styleElement.styleSheet.cssText = innerStyles; } else { styleElement.innerHTML = innerStyles;