responsive-nav-rails 1.0.16 → 1.0.20
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6860a540b57bcb2d03a6f76fbd5772076f2a85cc
|
4
|
+
data.tar.gz: f4a8a25f9d1deea7bb0be3ee5be96abed16abb42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 081937438ef19fb7c291d395e71bf844c8525cf43caaff76c9a2e0959321d7df3e5ead01195f01ae3e66ba85a1c815d7339de897e814e308b3f7537026f733d4
|
7
|
+
data.tar.gz: e89dbf000e93d168ca253e392dc60d2c73ca11338aafd6f7c3f423d6310909c694486171ff6f1bce8de3c694da30b86dfa005475d608b00f0723748b20046cc7
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! responsive-nav.js v1.0.
|
1
|
+
/*! responsive-nav.js v1.0.20
|
2
2
|
* https://github.com/viljamis/responsive-nav.js
|
3
3
|
* http://responsive-nav.com
|
4
4
|
*
|
@@ -38,6 +38,7 @@ var responsiveNav = (function (window, document) {
|
|
38
38
|
opts,
|
39
39
|
navToggle,
|
40
40
|
styleElement = document.createElement("style"),
|
41
|
+
hasAnimFinished,
|
41
42
|
navOpen,
|
42
43
|
|
43
44
|
// fn arg can be an object or a function, thanks to handleEvent
|
@@ -131,7 +132,7 @@ var responsiveNav = (function (window, document) {
|
|
131
132
|
// Default options
|
132
133
|
this.options = {
|
133
134
|
animate: true, // Boolean: Use CSS3 transitions, true or false
|
134
|
-
transition:
|
135
|
+
transition: 350, // Integer: Speed of the transition, in milliseconds
|
135
136
|
label: "Menu", // String: Label for the navigation toggle
|
136
137
|
insert: "after", // String: Insert the toggle before or after the navigation
|
137
138
|
customToggle: "", // Selector: Specify the ID of a custom toggle
|
@@ -181,13 +182,13 @@ var responsiveNav = (function (window, document) {
|
|
181
182
|
nav = null;
|
182
183
|
_instance = null;
|
183
184
|
|
184
|
-
removeEvent(window, "load", this, false);
|
185
185
|
removeEvent(window, "resize", this, false);
|
186
|
-
removeEvent(
|
186
|
+
removeEvent(document.body, "touchmove", this, false);
|
187
187
|
removeEvent(navToggle, "touchstart", this, false);
|
188
188
|
removeEvent(navToggle, "touchend", this, false);
|
189
189
|
removeEvent(navToggle, "keyup", this, false);
|
190
190
|
removeEvent(navToggle, "click", this, false);
|
191
|
+
removeEvent(navToggle, "mouseup", this, false);
|
191
192
|
|
192
193
|
if (!opts.customToggle) {
|
193
194
|
navToggle.parentNode.removeChild(navToggle);
|
@@ -197,29 +198,33 @@ var responsiveNav = (function (window, document) {
|
|
197
198
|
},
|
198
199
|
|
199
200
|
toggle: function () {
|
200
|
-
if (
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
201
|
+
if (hasAnimFinished === true) {
|
202
|
+
if (!navOpen) {
|
203
|
+
removeClass(nav, "closed");
|
204
|
+
addClass(nav, "opened");
|
205
|
+
nav.style.position = opts.openPos;
|
206
|
+
setAttributes(nav, {"aria-hidden": "false"});
|
207
|
+
|
208
|
+
navOpen = true;
|
209
|
+
opts.open();
|
210
|
+
} else {
|
211
|
+
removeClass(nav, "opened");
|
212
|
+
addClass(nav, "closed");
|
213
|
+
setAttributes(nav, {"aria-hidden": "true"});
|
212
214
|
|
213
|
-
|
214
|
-
|
215
|
+
if (opts.animate) {
|
216
|
+
hasAnimFinished = false;
|
217
|
+
setTimeout(function () {
|
218
|
+
nav.style.position = "absolute";
|
219
|
+
hasAnimFinished = true;
|
220
|
+
}, opts.transition + 10);
|
221
|
+
} else {
|
215
222
|
nav.style.position = "absolute";
|
216
|
-
}
|
217
|
-
} else {
|
218
|
-
nav.style.position = "absolute";
|
219
|
-
}
|
223
|
+
}
|
220
224
|
|
221
|
-
|
222
|
-
|
225
|
+
navOpen = false;
|
226
|
+
opts.close();
|
227
|
+
}
|
223
228
|
}
|
224
229
|
},
|
225
230
|
|
@@ -227,24 +232,21 @@ var responsiveNav = (function (window, document) {
|
|
227
232
|
var evt = e || window.event;
|
228
233
|
|
229
234
|
switch (evt.type) {
|
230
|
-
case "mousedown":
|
231
|
-
this._onmousedown(evt);
|
232
|
-
break;
|
233
235
|
case "touchstart":
|
234
|
-
this.
|
236
|
+
this._onTouchStart(evt);
|
235
237
|
break;
|
236
|
-
case "
|
237
|
-
this.
|
238
|
+
case "touchmove":
|
239
|
+
this._onTouchMove(evt);
|
238
240
|
break;
|
239
|
-
case "
|
240
|
-
|
241
|
+
case "touchend":
|
242
|
+
case "mouseup":
|
243
|
+
this._onTouchEnd(evt);
|
241
244
|
break;
|
242
245
|
case "click":
|
243
|
-
this.
|
246
|
+
this._preventDefault(evt);
|
244
247
|
break;
|
245
|
-
case "
|
246
|
-
this.
|
247
|
-
this._resize(evt);
|
248
|
+
case "keyup":
|
249
|
+
this._onKeyUp(evt);
|
248
250
|
break;
|
249
251
|
case "resize":
|
250
252
|
this._resize(evt);
|
@@ -255,16 +257,23 @@ var responsiveNav = (function (window, document) {
|
|
255
257
|
// Private methods
|
256
258
|
_init: function () {
|
257
259
|
addClass(nav, "closed");
|
260
|
+
hasAnimFinished = true;
|
258
261
|
navOpen = false;
|
262
|
+
|
259
263
|
this._createToggle();
|
264
|
+
this._transitions();
|
265
|
+
this._resize();
|
260
266
|
|
261
|
-
addEvent(window, "load", this, false);
|
262
267
|
addEvent(window, "resize", this, false);
|
263
|
-
addEvent(
|
268
|
+
addEvent(document.body, "touchmove", this, false);
|
264
269
|
addEvent(navToggle, "touchstart", this, false);
|
265
270
|
addEvent(navToggle, "touchend", this, false);
|
271
|
+
addEvent(navToggle, "mouseup", this, false);
|
266
272
|
addEvent(navToggle, "keyup", this, false);
|
267
273
|
addEvent(navToggle, "click", this, false);
|
274
|
+
|
275
|
+
// Init callback
|
276
|
+
opts.init();
|
268
277
|
},
|
269
278
|
|
270
279
|
_createStyles: function () {
|
@@ -315,44 +324,50 @@ var responsiveNav = (function (window, document) {
|
|
315
324
|
}
|
316
325
|
},
|
317
326
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
}
|
327
|
+
_onTouchStart: function (e) {
|
328
|
+
e.stopPropagation();
|
329
|
+
this.startX = e.touches[0].clientX;
|
330
|
+
this.startY = e.touches[0].clientY;
|
331
|
+
this.touchHasMoved = false;
|
332
|
+
removeEvent(navToggle, "mouseup", this, false);
|
325
333
|
},
|
326
334
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
this.toggle(e);
|
335
|
+
_onTouchMove: function (e) {
|
336
|
+
if (Math.abs(e.touches[0].clientX - this.startX) > 10 ||
|
337
|
+
Math.abs(e.touches[0].clientY - this.startY) > 10) {
|
338
|
+
this.touchHasMoved = true;
|
339
|
+
}
|
333
340
|
},
|
334
341
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
+
_onTouchEnd: function (e) {
|
343
|
+
this._preventDefault(e);
|
344
|
+
if (!this.touchHasMoved) {
|
345
|
+
if (e.type === "touchend") {
|
346
|
+
this.toggle(e);
|
347
|
+
// Prevent click on the underlying menu on Android 2.3
|
348
|
+
var that = this;
|
349
|
+
nav.addEventListener("click", that._preventDefault, true);
|
350
|
+
setTimeout(function () {
|
351
|
+
nav.removeEventListener("click", that._preventDefault, true);
|
352
|
+
}, opts.transition + 100);
|
353
|
+
return;
|
354
|
+
} else {
|
355
|
+
var evt = e || window.event;
|
356
|
+
// If it isn't a right click
|
357
|
+
if (!(evt.which === 3 || evt.button === 2)) {
|
358
|
+
this.toggle(e);
|
359
|
+
}
|
360
|
+
}
|
361
|
+
}
|
342
362
|
},
|
343
363
|
|
344
|
-
|
364
|
+
_onKeyUp: function (e) {
|
345
365
|
var evt = e || window.event;
|
346
366
|
if (evt.keyCode === 13) {
|
347
367
|
this.toggle(e);
|
348
368
|
}
|
349
369
|
},
|
350
370
|
|
351
|
-
_onclick: function (e) {
|
352
|
-
// For older browsers (looking at IE)
|
353
|
-
this._preventDefault(e);
|
354
|
-
},
|
355
|
-
|
356
371
|
_transitions: function () {
|
357
372
|
if (opts.animate) {
|
358
373
|
var objStyle = nav.style,
|
@@ -398,9 +413,6 @@ var responsiveNav = (function (window, document) {
|
|
398
413
|
nav.style.position = opts.openPos;
|
399
414
|
this._removeStyles();
|
400
415
|
}
|
401
|
-
|
402
|
-
// Init callback
|
403
|
-
opts.init();
|
404
416
|
}
|
405
417
|
|
406
418
|
};
|
@@ -1,12 +1,12 @@
|
|
1
|
-
/*! responsive-nav.js v1.0.
|
2
|
-
var responsiveNav=function(g
|
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))},
|
4
|
-
a.detachEvent("on"+b,c))},
|
5
|
-
this.options={animate:!0,transition:
|
6
|
-
this._init(this)};
|
7
|
-
"absolute"},f.transition+10):d.style.position="absolute",
|
8
|
-
_init:function(){
|
9
|
-
}else a=
|
10
|
-
|
11
|
-
|
12
|
-
b));return
|
1
|
+
/*! responsive-nav.js v1.0.20 by @viljamis, http://responsive-nav.com, MIT license */
|
2
|
+
var responsiveNav=function(h,g){var v=!!h.getComputedStyle;h.getComputedStyle||(h.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=g.createElement("style"),p,q,l=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))},k=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))},w=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])},r=function(a,b){a.className+=" "+b;a.className=a.className.replace(/(^\s*)|(\s*$)/g,"")},s=function(a,b){a.className=a.className.replace(RegExp("(\\s|^)"+b+"(\\s|$)")," ").replace(/(^\s*)|(\s*$)/g,"")},u=function(a,b){var c;
|
5
|
+
this.options={animate:!0,transition:350,label:"Menu",insert:"after",customToggle:"",openPos:"relative",jsClass:"js",init:function(){},open:function(){},close:function(){}};for(c in b)this.options[c]=b[c];r(g.documentElement,this.options.jsClass);this.wrapperEl=a.replace("#","");if(g.getElementById(this.wrapperEl))this.wrapper=g.getElementById(this.wrapperEl);else throw Error("The nav element you are trying to select doesn't exist");this.wrapper.inner=w(this.wrapper);f=this.options;d=this.wrapper;
|
6
|
+
this._init(this)};u.prototype={destroy:function(){this._removeStyles();s(d,"closed");s(d,"opened");d.removeAttribute("style");d.removeAttribute("aria-hidden");t=d=null;k(h,"resize",this,!1);k(g.body,"touchmove",this,!1);k(e,"touchstart",this,!1);k(e,"touchend",this,!1);k(e,"keyup",this,!1);k(e,"click",this,!1);k(e,"mouseup",this,!1);f.customToggle?e.removeAttribute("aria-hidden"):e.parentNode.removeChild(e)},toggle:function(){!0===p&&(q?(s(d,"opened"),r(d,"closed"),m(d,{"aria-hidden":"true"}),f.animate?
|
7
|
+
(p=!1,setTimeout(function(){d.style.position="absolute";p=!0},f.transition+10)):d.style.position="absolute",q=!1,f.close()):(s(d,"closed"),r(d,"opened"),d.style.position=f.openPos,m(d,{"aria-hidden":"false"}),q=!0,f.open()))},handleEvent:function(a){a=a||h.event;switch(a.type){case "touchstart":this._onTouchStart(a);break;case "touchmove":this._onTouchMove(a);break;case "touchend":case "mouseup":this._onTouchEnd(a);break;case "click":this._preventDefault(a);break;case "keyup":this._onKeyUp(a);break;
|
8
|
+
case "resize":this._resize(a)}},_init:function(){r(d,"closed");p=!0;q=!1;this._createToggle();this._transitions();this._resize();l(h,"resize",this,!1);l(g.body,"touchmove",this,!1);l(e,"touchstart",this,!1);l(e,"touchend",this,!1);l(e,"mouseup",this,!1);l(e,"keyup",this,!1);l(e,"click",this,!1);f.init()},_createStyles:function(){n.parentNode||g.getElementsByTagName("head")[0].appendChild(n)},_removeStyles:function(){n.parentNode&&n.parentNode.removeChild(n)},_createToggle:function(){if(f.customToggle){var a=
|
9
|
+
f.customToggle.replace("#","");if(g.getElementById(a))e=g.getElementById(a);else throw Error("The custom nav toggle you are trying to select doesn't exist");}else a=g.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=g.getElementById("nav-toggle")},_preventDefault:function(a){a.preventDefault?(a.preventDefault(),a.stopPropagation()):a.returnValue=!1},_onTouchStart:function(a){a.stopPropagation();
|
10
|
+
this.startX=a.touches[0].clientX;this.startY=a.touches[0].clientY;this.touchHasMoved=!1;k(e,"mouseup",this,!1)},_onTouchMove:function(a){if(10<Math.abs(a.touches[0].clientX-this.startX)||10<Math.abs(a.touches[0].clientY-this.startY))this.touchHasMoved=!0},_onTouchEnd:function(a){this._preventDefault(a);if(!this.touchHasMoved)if("touchend"===a.type){this.toggle(a);var b=this;d.addEventListener("click",b._preventDefault,!0);setTimeout(function(){d.removeEventListener("click",b._preventDefault,!0)},
|
11
|
+
f.transition+100)}else{var c=a||h.event;3!==c.which&&2!==c.button&&this.toggle(a)}},_onKeyUp:function(a){13===(a||h.event).keyCode&&this.toggle(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+=d.inner[b].offsetHeight;a="#"+this.wrapperEl+".opened{max-height:"+a+"px}";v&&(n.innerHTML=a)},_resize:function(){"none"!==h.getComputedStyle(e,
|
12
|
+
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())}};var t;return function(a,b){t||(t=new u(a,b));return t}}(window,document);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: responsive-nav-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.20
|
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-08-
|
11
|
+
date: 2013-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: responsive-nav.com for the rails asset pipeline
|
14
14
|
email:
|