vendor/assets/javascripts/responsive-nav.js in responsive-nav-rails-1.0.13 vs vendor/assets/javascripts/responsive-nav.js in responsive-nav-rails-1.0.14
- old
+ new
@@ -1,6 +1,6 @@
-/*! responsive-nav.js v1.0.13
+/*! responsive-nav.js v1.0.14
* https://github.com/viljamis/responsive-nav.js
* http://responsive-nav.com
*
* Copyright (c) 2013 @viljamis
* Available under the MIT license
@@ -119,12 +119,10 @@
removeClass = function (el, cls) {
var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
el.className = el.className.replace(reg, " ").replace(/(^\s*)|(\s*$)/g,"");
},
- log = function () {},
-
ResponsiveNav = function (el, options) {
var i;
// Default options
this.options = {
@@ -133,39 +131,23 @@
label: "Menu", // String: Label for the navigation toggle
insert: "after", // String: Insert the toggle before or after the navigation
customToggle: "", // Selector: Specify the ID of a custom toggle
openPos: "relative", // String: Position of the opened nav, relative or static
jsClass: "js", // String: 'JS enabled' class which is added to <html> el
- debug: false, // Boolean: Log debug messages to console, true or false
init: function(){}, // Function: Init callback
open: function(){}, // Function: Open callback
close: function(){} // Function: Close callback
};
// User defined options
for (i in options) {
- if (i in this.options) {
- this.options[i] = options[i];
- } else {
- throw new Error("Responsive Nav doesn't support option: " + i);
- }
+ this.options[i] = options[i];
}
// Adds "js" class for <html>
addClass(docEl, this.options.jsClass);
- // Debug logger
- if (this.options.debug) {
- log = function (s) {
- try {
- console.log(s);
- } catch (e) {
- alert(s);
- }
- };
- }
-
// Wrapper
this.wrapperEl = el.replace("#", "");
if (document.getElementById(this.wrapperEl)) {
this.wrapper = document.getElementById(this.wrapperEl);
} else {
@@ -183,11 +165,10 @@
// Init
this._init(this);
};
ResponsiveNav.prototype = {
-
// Public methods
destroy: function () {
this._removeStyles();
removeClass(nav, "closed");
removeClass(nav, "opened");
@@ -207,12 +188,10 @@
if (!opts.customToggle) {
navToggle.parentNode.removeChild(navToggle);
} else {
navToggle.removeAttribute("aria-hidden");
}
-
- log("Destroyed!");
},
toggle: function () {
if (!navOpen) {
removeClass(nav, "closed");
@@ -220,12 +199,10 @@
nav.style.position = opts.openPos;
setAttributes(nav, {"aria-hidden": "false"});
navOpen = true;
opts.open();
- log("Opened nav");
-
} else {
removeClass(nav, "opened");
addClass(nav, "closed");
setAttributes(nav, {"aria-hidden": "true"});
@@ -237,11 +214,10 @@
nav.style.position = "absolute";
}
navOpen = false;
opts.close();
- log("Closed nav");
}
},
handleEvent: function (e) {
var evt = e || window.event;
@@ -272,11 +248,10 @@
}
},
// Private methods
_init: function () {
- log("Inited Responsive Nav");
addClass(nav, "closed");
this._createToggle();
addEvent(window, "load", this, false);
addEvent(window, "resize", this, false);
@@ -288,18 +263,16 @@
},
_createStyles: function () {
if (!styleElement.parentNode) {
head.appendChild(styleElement);
- log("Created 'styleElement' to <head>");
}
},
_removeStyles: function () {
if (styleElement.parentNode) {
styleElement.parentNode.removeChild(styleElement);
- log("Removed 'styleElement' from <head>");
}
},
_createToggle: function () {
if (!opts.customToggle) {
@@ -315,18 +288,15 @@
} else {
nav.parentNode.insertBefore(toggle, nav);
}
navToggle = document.getElementById("nav-toggle");
- log("Default nav toggle created");
-
} else {
var toggleEl = opts.customToggle.replace("#", "");
if (document.getElementById(toggleEl)) {
navToggle = document.getElementById(toggleEl);
- log("Custom nav toggle created");
} else {
throw new Error("The custom nav toggle you are trying to select doesn't exist");
}
}
},
@@ -397,11 +367,9 @@
// Hide from old IE
if (computed) {
styleElement.innerHTML = innerStyles;
innerStyles = "";
}
-
- log("Calculated max-height of " + savedHeight + "px and updated 'styleElement'");
},
_resize: function () {
if (window.getComputedStyle(navToggle, null).getPropertyValue("display") !== "none") {
setAttributes(navToggle, {"aria-hidden": "false"});
\ No newline at end of file