responsive-nav-rails 1.0.14 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca1bed6b25ccd912c7bc44e71d82e75b8a8ac115
4
- data.tar.gz: dcf31c8cdf895cbef60e7f080bc6372f419439a9
3
+ metadata.gz: 1688868dad4b56b871fb5e5de337ade12aedc389
4
+ data.tar.gz: f92eaa0d81fbeb028f9fe9c56d0d5e484e6d2115
5
5
  SHA512:
6
- metadata.gz: a3ff2e6216632989393df23af3db02f2d12587dd7f4eabe1321986520b626db24779e28e7593f4c92d5f3cbf78663c34c6783754e0a49ad90546c98bb86bfd89
7
- data.tar.gz: 3c290234eb741fdd1e594c19cc99730f95d7621604eaedc905d402b22505c5710715e9d9dbd1e523bd1835e993ceeeb444b45c08a40bebb9b20f6cbc75b9ff7d
6
+ metadata.gz: 8dcbef8356e6738766b7577c3fb4df7e9a3a8af89c3354e229cecef2720c353adad0c9dfdd70d6237f1adaac33ea4cd9187eec16ed73fce57b5ec72866b9b048
7
+ data.tar.gz: c2615a3891c6b7879f7aa3edc16cb9321df792966b309c29246d4f12060917e8c176ac0cb6e92d0d3078253afa43fa958f8836ddf0e6dd209f6759dc2c68ca19
@@ -1,3 +1,3 @@
1
1
  module ResponsiveNavRails
2
- VERSION = "1.0.14"
2
+ VERSION = "1.0.15"
3
3
  end
@@ -15,6 +15,4 @@ Gem::Specification.new do |spec|
15
15
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
-
19
- spec.add_dependency "railties", ">= 3.1"
20
18
  end
@@ -1,4 +1,4 @@
1
- /*! responsive-nav.js v1.0.14
1
+ /*! responsive-nav.js v1.0.15
2
2
  * https://github.com/viljamis/responsive-nav.js
3
3
  * http://responsive-nav.com
4
4
  *
@@ -37,8 +37,6 @@ var responsiveNav = (function (window, document) {
37
37
  var nav,
38
38
  opts,
39
39
  navToggle,
40
- docEl = document.documentElement,
41
- head = document.getElementsByTagName("head")[0],
42
40
  styleElement = document.createElement("style"),
43
41
  navOpen = false,
44
42
 
@@ -96,13 +94,19 @@ var responsiveNav = (function (window, document) {
96
94
  }
97
95
  },
98
96
 
99
- getFirstChild = function (e) {
100
- var firstChild = e.firstChild;
101
- // skip TextNodes
102
- while (firstChild !== null && firstChild.nodeType !== 1) {
103
- firstChild = firstChild.nextSibling;
97
+ getChildren = function (e) {
98
+ if (e.children.length < 1) {
99
+ throw new Error("The Nav container has no containing elements");
104
100
  }
105
- return firstChild;
101
+ // Store all children in array
102
+ var children = [];
103
+ // Loop through children and store in array if child != TextNode
104
+ for (var i = 0; i < e.children.length; i++) {
105
+ if (e.children[i].nodeType === 1) {
106
+ children.push(e.children[i]);
107
+ }
108
+ }
109
+ return children;
106
110
  },
107
111
 
108
112
  setAttributes = function (el, attrs) {
@@ -144,7 +148,7 @@ var responsiveNav = (function (window, document) {
144
148
  }
145
149
 
146
150
  // Adds "js" class for <html>
147
- addClass(docEl, this.options.jsClass);
151
+ addClass(document.documentElement, this.options.jsClass);
148
152
 
149
153
  // Wrapper
150
154
  this.wrapperEl = el.replace("#", "");
@@ -156,7 +160,7 @@ var responsiveNav = (function (window, document) {
156
160
  }
157
161
 
158
162
  // Inner wrapper
159
- this.wrapper.inner = getFirstChild(this.wrapper);
163
+ this.wrapper.inner = getChildren(this.wrapper);
160
164
 
161
165
  // For minification
162
166
  opts = this.options;
@@ -264,7 +268,7 @@ var responsiveNav = (function (window, document) {
264
268
 
265
269
  _createStyles: function () {
266
270
  if (!styleElement.parentNode) {
267
- head.appendChild(styleElement);
271
+ document.getElementsByTagName("head")[0].appendChild(styleElement);
268
272
  }
269
273
  },
270
274
 
@@ -361,8 +365,12 @@ var responsiveNav = (function (window, document) {
361
365
  },
362
366
 
363
367
  _calcHeight: function () {
364
- var savedHeight = nav.inner.offsetHeight,
365
- innerStyles = "#" + this.wrapperEl + ".opened{max-height:" + savedHeight + "px}";
368
+ var savedHeight = 0;
369
+ for (var i = 0; i < nav.inner.length; i++) {
370
+ savedHeight += nav.inner[i].offsetHeight;
371
+ }
372
+
373
+ var innerStyles = "#" + this.wrapperEl + ".opened{max-height:" + savedHeight + "px}";
366
374
 
367
375
  // Hide from old IE
368
376
  if (computed) {
@@ -1,11 +1,12 @@
1
- /*! responsive-nav.js v1.0.14 by @viljamis, http://responsive-nav.com, MIT license */
2
- var responsiveNav=function(g,h){var t=!!g.getComputedStyle;g.getComputedStyle||(g.getComputedStyle=function(a){this.el=a;this.getPropertyValue=function(d){var c=/(\-([a-z]){1})/g;"float"===d&&(d="styleFloat");c.test(d)&&(d=d.replace(c,function(a,d,c){return c.toUpperCase()}));return a.currentStyle[d]?a.currentStyle[d]:null};return this});var b,f,e,u=h.documentElement,v=h.getElementsByTagName("head")[0],m=h.createElement("style"),r=!1,j=function(a,d,c,b){if("addEventListener"in a)try{a.addEventListener(d,
3
- c,b)}catch(e){if("object"===typeof c&&c.handleEvent)a.addEventListener(d,function(a){c.handleEvent.call(c,a)},b);else throw e;}else"attachEvent"in a&&("object"===typeof c&&c.handleEvent?a.attachEvent("on"+d,function(){c.handleEvent.call(c)}):a.attachEvent("on"+d,c))},k=function(a,d,c,b){if("removeEventListener"in a)try{a.removeEventListener(d,c,b)}catch(e){if("object"===typeof c&&c.handleEvent)a.removeEventListener(d,function(a){c.handleEvent.call(c,a)},b);else throw e;}else"detachEvent"in a&&("object"===
4
- typeof c&&c.handleEvent?a.detachEvent("on"+d,function(){c.handleEvent.call(c)}):a.detachEvent("on"+d,c))},l=function(a,d){for(var b in d)a.setAttribute(b,d[b])},n=function(a,b){a.className+=" "+b;a.className=a.className.replace(/(^\s*)|(\s*$)/g,"")},p=function(a,b){a.className=a.className.replace(RegExp("(\\s|^)"+b+"(\\s|$)")," ").replace(/(^\s*)|(\s*$)/g,"")},s=function(a,d){var c;this.options={animate:!0,transition:400,label:"Menu",insert:"after",customToggle:"",openPos:"relative",jsClass:"js",
5
- init:function(){},open:function(){},close:function(){}};for(c in d)this.options[c]=d[c];n(u,this.options.jsClass);this.wrapperEl=a.replace("#","");if(h.getElementById(this.wrapperEl))this.wrapper=h.getElementById(this.wrapperEl);else throw Error("The nav element you are trying to select doesn't exist");c=this.wrapper;for(var e=this.wrapper.firstChild;null!==e&&1!==e.nodeType;)e=e.nextSibling;c.inner=e;f=this.options;b=this.wrapper;this._init(this)};s.prototype={destroy:function(){this._removeStyles();
6
- p(b,"closed");p(b,"opened");b.removeAttribute("style");b.removeAttribute("aria-hidden");q=b=null;k(g,"load",this,!1);k(g,"resize",this,!1);k(e,"mousedown",this,!1);k(e,"touchstart",this,!1);k(e,"touchend",this,!1);k(e,"keyup",this,!1);k(e,"click",this,!1);f.customToggle?e.removeAttribute("aria-hidden"):e.parentNode.removeChild(e)},toggle:function(){r?(p(b,"opened"),n(b,"closed"),l(b,{"aria-hidden":"true"}),f.animate?setTimeout(function(){b.style.position="absolute"},f.transition+10):b.style.position=
7
- "absolute",r=!1,f.close()):(p(b,"closed"),n(b,"opened"),b.style.position=f.openPos,l(b,{"aria-hidden":"false"}),r=!0,f.open())},handleEvent:function(a){a=a||g.event;switch(a.type){case "mousedown":this._onmousedown(a);break;case "touchstart":this._ontouchstart(a);break;case "touchend":this._ontouchend(a);break;case "keyup":this._onkeyup(a);break;case "click":this._onclick(a);break;case "load":this._transitions(a);this._resize(a);break;case "resize":this._resize(a)}},_init:function(){n(b,"closed");
8
- this._createToggle();j(g,"load",this,!1);j(g,"resize",this,!1);j(e,"mousedown",this,!1);j(e,"touchstart",this,!1);j(e,"touchend",this,!1);j(e,"keyup",this,!1);j(e,"click",this,!1)},_createStyles:function(){m.parentNode||v.appendChild(m)},_removeStyles:function(){m.parentNode&&m.parentNode.removeChild(m)},_createToggle:function(){if(f.customToggle){var a=f.customToggle.replace("#","");if(h.getElementById(a))e=h.getElementById(a);else throw Error("The custom nav toggle you are trying to select doesn't exist");
9
- }else a=h.createElement("a"),a.innerHTML=f.label,l(a,{href:"#",id:"nav-toggle"}),"after"===f.insert?b.parentNode.insertBefore(a,b.nextSibling):b.parentNode.insertBefore(a,b),e=h.getElementById("nav-toggle")},_preventDefault:function(a){a.preventDefault?(a.preventDefault(),a.stopPropagation()):a.returnValue=!1},_onmousedown:function(a){var b=a||g.event;3===b.which||2===b.button||(this._preventDefault(a),this.toggle(a))},_ontouchstart:function(a){e.onmousedown=null;this._preventDefault(a);this.toggle(a)},
10
- _ontouchend:function(){var a=this;b.addEventListener("click",a._preventDefault,!0);setTimeout(function(){b.removeEventListener("click",a._preventDefault,!0)},f.transition)},_onkeyup:function(a){13===(a||g.event).keyCode&&this.toggle(a)},_onclick:function(a){this._preventDefault(a)},_transitions:function(){if(f.animate){var a=b.style,d="max-height "+f.transition+"ms";a.WebkitTransition=d;a.MozTransition=d;a.OTransition=d;a.transition=d}},_calcHeight:function(){var a="#"+this.wrapperEl+".opened{max-height:"+
11
- b.inner.offsetHeight+"px}";t&&(m.innerHTML=a)},_resize:function(){"none"!==g.getComputedStyle(e,null).getPropertyValue("display")?(l(e,{"aria-hidden":"false"}),b.className.match(/(^|\s)closed(\s|$)/)&&(l(b,{"aria-hidden":"true"}),b.style.position="absolute"),this._createStyles(),this._calcHeight()):(l(e,{"aria-hidden":"true"}),l(b,{"aria-hidden":"false"}),b.style.position=f.openPos,this._removeStyles());f.init()}};var q;return function(a,b){q||(q=new s(a,b));return q}}(window,document);
1
+ /*! responsive-nav.js v1.0.15 by @viljamis, http://responsive-nav.com, MIT license */
2
+ var responsiveNav=function(g,h){var u=!!g.getComputedStyle;g.getComputedStyle||(g.getComputedStyle=function(a){this.el=a;this.getPropertyValue=function(b){var c=/(\-([a-z]){1})/g;"float"===b&&(b="styleFloat");c.test(b)&&(b=b.replace(c,function(a,b,c){return c.toUpperCase()}));return a.currentStyle[b]?a.currentStyle[b]:null};return this});var d,f,e,n=h.createElement("style"),s=!1,k=function(a,b,c,d){if("addEventListener"in a)try{a.addEventListener(b,c,d)}catch(e){if("object"===typeof c&&c.handleEvent)a.addEventListener(b,
3
+ function(a){c.handleEvent.call(c,a)},d);else throw e;}else"attachEvent"in a&&("object"===typeof c&&c.handleEvent?a.attachEvent("on"+b,function(){c.handleEvent.call(c)}):a.attachEvent("on"+b,c))},l=function(a,b,c,d){if("removeEventListener"in a)try{a.removeEventListener(b,c,d)}catch(e){if("object"===typeof c&&c.handleEvent)a.removeEventListener(b,function(a){c.handleEvent.call(c,a)},d);else throw e;}else"detachEvent"in a&&("object"===typeof c&&c.handleEvent?a.detachEvent("on"+b,function(){c.handleEvent.call(c)}):
4
+ a.detachEvent("on"+b,c))},v=function(a){if(1>a.children.length)throw Error("The Nav container has no containing elements");for(var b=[],c=0;c<a.children.length;c++)1===a.children[c].nodeType&&b.push(a.children[c]);return b},m=function(a,b){for(var c in b)a.setAttribute(c,b[c])},p=function(a,b){a.className+=" "+b;a.className=a.className.replace(/(^\s*)|(\s*$)/g,"")},q=function(a,b){a.className=a.className.replace(RegExp("(\\s|^)"+b+"(\\s|$)")," ").replace(/(^\s*)|(\s*$)/g,"")},t=function(a,b){var c;
5
+ this.options={animate:!0,transition:400,label:"Menu",insert:"after",customToggle:"",openPos:"relative",jsClass:"js",init:function(){},open:function(){},close:function(){}};for(c in b)this.options[c]=b[c];p(h.documentElement,this.options.jsClass);this.wrapperEl=a.replace("#","");if(h.getElementById(this.wrapperEl))this.wrapper=h.getElementById(this.wrapperEl);else throw Error("The nav element you are trying to select doesn't exist");this.wrapper.inner=v(this.wrapper);f=this.options;d=this.wrapper;
6
+ this._init(this)};t.prototype={destroy:function(){this._removeStyles();q(d,"closed");q(d,"opened");d.removeAttribute("style");d.removeAttribute("aria-hidden");r=d=null;l(g,"load",this,!1);l(g,"resize",this,!1);l(e,"mousedown",this,!1);l(e,"touchstart",this,!1);l(e,"touchend",this,!1);l(e,"keyup",this,!1);l(e,"click",this,!1);f.customToggle?e.removeAttribute("aria-hidden"):e.parentNode.removeChild(e)},toggle:function(){s?(q(d,"opened"),p(d,"closed"),m(d,{"aria-hidden":"true"}),f.animate?setTimeout(function(){d.style.position=
7
+ "absolute"},f.transition+10):d.style.position="absolute",s=!1,f.close()):(q(d,"closed"),p(d,"opened"),d.style.position=f.openPos,m(d,{"aria-hidden":"false"}),s=!0,f.open())},handleEvent:function(a){a=a||g.event;switch(a.type){case "mousedown":this._onmousedown(a);break;case "touchstart":this._ontouchstart(a);break;case "touchend":this._ontouchend(a);break;case "keyup":this._onkeyup(a);break;case "click":this._onclick(a);break;case "load":this._transitions(a);this._resize(a);break;case "resize":this._resize(a)}},
8
+ _init:function(){p(d,"closed");this._createToggle();k(g,"load",this,!1);k(g,"resize",this,!1);k(e,"mousedown",this,!1);k(e,"touchstart",this,!1);k(e,"touchend",this,!1);k(e,"keyup",this,!1);k(e,"click",this,!1)},_createStyles:function(){n.parentNode||h.getElementsByTagName("head")[0].appendChild(n)},_removeStyles:function(){n.parentNode&&n.parentNode.removeChild(n)},_createToggle:function(){if(f.customToggle){var a=f.customToggle.replace("#","");if(h.getElementById(a))e=h.getElementById(a);else throw Error("The custom nav toggle you are trying to select doesn't exist");
9
+ }else a=h.createElement("a"),a.innerHTML=f.label,m(a,{href:"#",id:"nav-toggle"}),"after"===f.insert?d.parentNode.insertBefore(a,d.nextSibling):d.parentNode.insertBefore(a,d),e=h.getElementById("nav-toggle")},_preventDefault:function(a){a.preventDefault?(a.preventDefault(),a.stopPropagation()):a.returnValue=!1},_onmousedown:function(a){var b=a||g.event;3!==b.which&&2!==b.button&&(this._preventDefault(a),this.toggle(a))},_ontouchstart:function(a){e.onmousedown=null;this._preventDefault(a);this.toggle(a)},
10
+ _ontouchend:function(){var a=this;d.addEventListener("click",a._preventDefault,!0);setTimeout(function(){d.removeEventListener("click",a._preventDefault,!0)},f.transition)},_onkeyup:function(a){13===(a||g.event).keyCode&&this.toggle(a)},_onclick:function(a){this._preventDefault(a)},_transitions:function(){if(f.animate){var a=d.style,b="max-height "+f.transition+"ms";a.WebkitTransition=b;a.MozTransition=b;a.OTransition=b;a.transition=b}},_calcHeight:function(){for(var a=0,b=0;b<d.inner.length;b++)a+=
11
+ d.inner[b].offsetHeight;a="#"+this.wrapperEl+".opened{max-height:"+a+"px}";u&&(n.innerHTML=a)},_resize:function(){"none"!==g.getComputedStyle(e,null).getPropertyValue("display")?(m(e,{"aria-hidden":"false"}),d.className.match(/(^|\s)closed(\s|$)/)&&(m(d,{"aria-hidden":"true"}),d.style.position="absolute"),this._createStyles(),this._calcHeight()):(m(e,{"aria-hidden":"true"}),m(d,{"aria-hidden":"false"}),d.style.position=f.openPos,this._removeStyles());f.init()}};var r;return function(a,b){r||(r=new t(a,
12
+ b));return r}}(window,document);
@@ -1,4 +1,4 @@
1
- /*! responsive-nav.js v1.0.14 by @viljamis */
1
+ /*! responsive-nav.js v1.0.15 by @viljamis */
2
2
 
3
3
  #nav ul {
4
4
  margin: 0;
@@ -29,6 +29,8 @@
29
29
  @media screen and (min-width: 40em) {
30
30
  .js #nav {
31
31
  position: relative;
32
+ }
33
+ .js #nav.closed {
32
34
  max-height: none;
33
35
  }
34
36
  #nav-toggle {
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: responsive-nav-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas McNiven
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-13 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: railties
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '3.1'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '3.1'
11
+ date: 2013-06-29 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: responsive-nav.com for the rails asset pipeline
28
14
  email:
29
15
  - trmcniven@vevix.net