vendor/assets/javascripts/responsive-nav.js in responsive-nav-rails-1.0.30 vs vendor/assets/javascripts/responsive-nav.js in responsive-nav-rails-1.0.32

- old
+ new

@@ -1,6 +1,6 @@ -/*! responsive-nav.js 1.0.30 +/*! responsive-nav.js 1.0.32 * https://github.com/viljamis/responsive-nav.js * http://responsive-nav.com * * Copyright (c) 2014 @viljamis * Available under the MIT license @@ -31,11 +31,11 @@ return el.currentStyle[prop] ? el.currentStyle[prop] : null; }; return this; }; } - /* exported addEvent, removeEvent, getChildren, setAttributes, addClass, removeClass */ + /* exported addEvent, removeEvent, getChildren, setAttributes, addClass, removeClass, forEach */ // fn arg can be an object or a function, thanks to handleEvent // read more at: http://www.thecssninja.com/javascript/handleevent var addEvent = function (el, evt, fn, bubble) { if ("addEventListener" in el) { // BBOS6 doesn't support handleEvent, catch and polyfill @@ -117,10 +117,17 @@ }, removeClass = function (el, cls) { var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)"); el.className = el.className.replace(reg, " ").replace(/(^\s*)|(\s*$)/g,""); + }, + + // forEach method that passes back the stuff we need + forEach = function (array, callback, scope) { + for (var i = 0; i < array.length; i++) { + callback.call(scope, i, array[i]); + } }; var nav, opts, navToggle, @@ -383,14 +390,14 @@ } } }, _closeOnNavClick: function () { - if (opts.closeOnNavClick && "querySelectorAll" in document && Array.prototype.forEach) { + if (opts.closeOnNavClick && "querySelectorAll" in document) { var links = nav.querySelectorAll("a"), self = this; - [].forEach.call(links, function (el, i) { + forEach(links, function (i, el) { addEvent(links[i], "click", function () { if (isMobile) { self.toggle(); } }, false); @@ -468,10 +475,10 @@ _calcHeight: function () { var savedHeight = 0; for (var i = 0; i < nav.inner.length; i++) { savedHeight += nav.inner[i].offsetHeight; } - var innerStyles = "." + opts.navClass + "-" + this.index + ".opened{max-height:" + savedHeight + "px !important}"; + var innerStyles = "." + opts.jsClass + " ." + opts.navClass + "-" + this.index + ".opened{max-height:" + savedHeight + "px !important}"; if (styleElement.styleSheet) { styleElement.styleSheet.cssText = innerStyles; } else { styleElement.innerHTML = innerStyles; \ No newline at end of file