responsive-nav-rails 1.0.32 → 1.0.33
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 +4 -4
- data/.gitignore +0 -0
- data/Gemfile +0 -0
- data/LICENSE.md +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/lib/responsive-nav-rails.rb +0 -0
- data/lib/responsive-nav-rails/engine.rb +0 -0
- data/lib/responsive-nav-rails/version.rb +2 -2
- data/responsive-nav-rails.gemspec +1 -1
- data/vendor/assets/javascripts/responsive-nav.js +205 -25
- data/vendor/assets/javascripts/responsive-nav.min.js +1 -1
- data/vendor/assets/stylesheets/responsive-nav.css +1 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40318cd59caab00f767188862c9a500b8719f5cb
|
4
|
+
data.tar.gz: 561645af35471d4ab569205ee08386f7404e2cdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ab065b1002b16a677e3ea4bff6807e8645387e2e84aa3b20c06fb7abe12025ac5ce8a3a41bfe6e9cba6a9af4ff78df3b22218b50a2cffe0a08c93ec6de100e5
|
7
|
+
data.tar.gz: e28632e0a53dcc4103d1ea95e09d71b4acb9a43c6ee4176e1cd3e3c3d5dd124e7a57a429637f292969c3ea52ac0ca5bee3e48beb02ae93d39184ae134f5e7d75
|
data/.gitignore
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.md
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/lib/responsive-nav-rails.rb
CHANGED
File without changes
|
File without changes
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module ResponsiveNavRails
|
2
|
-
VERSION = "1.0.
|
3
|
-
end
|
2
|
+
VERSION = "1.0.33"
|
3
|
+
end
|
@@ -5,7 +5,7 @@ Gem::Specification.new do |spec|
|
|
5
5
|
spec.name = "responsive-nav-rails"
|
6
6
|
spec.version = ResponsiveNavRails::VERSION
|
7
7
|
spec.authors = ["Thomas McNiven"]
|
8
|
-
spec.email = ["
|
8
|
+
spec.email = ["hello@vevix.net"]
|
9
9
|
spec.description = "responsive-nav.com for the rails asset pipeline"
|
10
10
|
spec.summary = "an asset gemification of the responsive-nav plugin"
|
11
11
|
spec.homepage = "https://github.com/vevix/responsive-nav-rails"
|
@@ -7,14 +7,17 @@
|
|
7
7
|
*/
|
8
8
|
|
9
9
|
(function (document, window, index) {
|
10
|
+
// Index is used to keep multiple navs on the same page namespaced
|
10
11
|
|
11
12
|
"use strict";
|
12
13
|
|
13
14
|
var responsiveNav = function (el, options) {
|
14
15
|
|
15
16
|
var computed = !!window.getComputedStyle;
|
16
|
-
|
17
|
-
|
17
|
+
|
18
|
+
/**
|
19
|
+
* getComputedStyle polyfill for old browsers
|
20
|
+
*/
|
18
21
|
if (!computed) {
|
19
22
|
window.getComputedStyle = function(el) {
|
20
23
|
this.el = el;
|
@@ -34,8 +37,17 @@
|
|
34
37
|
};
|
35
38
|
}
|
36
39
|
/* exported addEvent, removeEvent, getChildren, setAttributes, addClass, removeClass, forEach */
|
37
|
-
|
38
|
-
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Add Event
|
43
|
+
* fn arg can be an object or a function, thanks to handleEvent
|
44
|
+
* read more at: http://www.thecssninja.com/javascript/handleevent
|
45
|
+
*
|
46
|
+
* @param {element} element
|
47
|
+
* @param {event} event
|
48
|
+
* @param {Function} fn
|
49
|
+
* @param {boolean} bubbling
|
50
|
+
*/
|
39
51
|
var addEvent = function (el, evt, fn, bubble) {
|
40
52
|
if ("addEventListener" in el) {
|
41
53
|
// BBOS6 doesn't support handleEvent, catch and polyfill
|
@@ -63,7 +75,15 @@
|
|
63
75
|
}
|
64
76
|
}
|
65
77
|
},
|
66
|
-
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Remove Event
|
81
|
+
*
|
82
|
+
* @param {element} element
|
83
|
+
* @param {event} event
|
84
|
+
* @param {Function} fn
|
85
|
+
* @param {boolean} bubbling
|
86
|
+
*/
|
67
87
|
removeEvent = function (el, evt, fn, bubble) {
|
68
88
|
if ("removeEventListener" in el) {
|
69
89
|
try {
|
@@ -87,7 +107,13 @@
|
|
87
107
|
}
|
88
108
|
}
|
89
109
|
},
|
90
|
-
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Get the children of any element
|
113
|
+
*
|
114
|
+
* @param {element}
|
115
|
+
* @return {array} Returns matching elements in an array
|
116
|
+
*/
|
91
117
|
getChildren = function (e) {
|
92
118
|
if (e.children.length < 1) {
|
93
119
|
throw new Error("The Nav container has no containing elements");
|
@@ -102,26 +128,50 @@
|
|
102
128
|
}
|
103
129
|
return children;
|
104
130
|
},
|
105
|
-
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Sets multiple attributes at once
|
134
|
+
*
|
135
|
+
* @param {element} element
|
136
|
+
* @param {attrs} attrs
|
137
|
+
*/
|
106
138
|
setAttributes = function (el, attrs) {
|
107
139
|
for (var key in attrs) {
|
108
140
|
el.setAttribute(key, attrs[key]);
|
109
141
|
}
|
110
142
|
},
|
111
|
-
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Adds a class to any element
|
146
|
+
*
|
147
|
+
* @param {element} element
|
148
|
+
* @param {string} class
|
149
|
+
*/
|
112
150
|
addClass = function (el, cls) {
|
113
151
|
if (el.className.indexOf(cls) !== 0) {
|
114
152
|
el.className += " " + cls;
|
115
153
|
el.className = el.className.replace(/(^\s*)|(\s*$)/g,"");
|
116
154
|
}
|
117
155
|
},
|
118
|
-
|
156
|
+
|
157
|
+
/**
|
158
|
+
* Remove a class from any element
|
159
|
+
*
|
160
|
+
* @param {element} element
|
161
|
+
* @param {string} class
|
162
|
+
*/
|
119
163
|
removeClass = function (el, cls) {
|
120
164
|
var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
|
121
165
|
el.className = el.className.replace(reg, " ").replace(/(^\s*)|(\s*$)/g,"");
|
122
166
|
},
|
123
|
-
|
124
|
-
|
167
|
+
|
168
|
+
/**
|
169
|
+
* forEach method that passes back the stuff we need
|
170
|
+
*
|
171
|
+
* @param {array} array
|
172
|
+
* @param {Function} callback
|
173
|
+
* @param {scope} scope
|
174
|
+
*/
|
125
175
|
forEach = function (array, callback, scope) {
|
126
176
|
for (var i = 0; i < array.length; i++) {
|
127
177
|
callback.call(scope, i, array[i]);
|
@@ -140,7 +190,10 @@
|
|
140
190
|
var ResponsiveNav = function (el, options) {
|
141
191
|
var i;
|
142
192
|
|
143
|
-
|
193
|
+
/**
|
194
|
+
* Default options
|
195
|
+
* @type {Object}
|
196
|
+
*/
|
144
197
|
this.options = {
|
145
198
|
animate: true, // Boolean: Use CSS3 transitions, true or false
|
146
199
|
transition: 284, // Integer: Speed of the transition, in milliseconds
|
@@ -194,7 +247,9 @@
|
|
194
247
|
|
195
248
|
ResponsiveNav.prototype = {
|
196
249
|
|
197
|
-
|
250
|
+
/**
|
251
|
+
* Unattaches events and removes any classes that were added
|
252
|
+
*/
|
198
253
|
destroy: function () {
|
199
254
|
this._removeStyles();
|
200
255
|
removeClass(nav, "closed");
|
@@ -206,6 +261,7 @@
|
|
206
261
|
nav.removeAttribute("aria-hidden");
|
207
262
|
|
208
263
|
removeEvent(window, "resize", this, false);
|
264
|
+
removeEvent(window, "focus", this, false);
|
209
265
|
removeEvent(document.body, "touchmove", this, false);
|
210
266
|
removeEvent(navToggle, "touchstart", this, false);
|
211
267
|
removeEvent(navToggle, "touchend", this, false);
|
@@ -220,6 +276,9 @@
|
|
220
276
|
}
|
221
277
|
},
|
222
278
|
|
279
|
+
/**
|
280
|
+
* Toggles the navigation open/close
|
281
|
+
*/
|
223
282
|
toggle: function () {
|
224
283
|
if (hasAnimFinished === true) {
|
225
284
|
if (!navOpen) {
|
@@ -227,9 +286,15 @@
|
|
227
286
|
} else {
|
228
287
|
this.close();
|
229
288
|
}
|
289
|
+
|
290
|
+
// Enable pointer events again
|
291
|
+
this._enablePointerEvents();
|
230
292
|
}
|
231
293
|
},
|
232
294
|
|
295
|
+
/**
|
296
|
+
* Opens the navigation
|
297
|
+
*/
|
233
298
|
open: function () {
|
234
299
|
if (!navOpen) {
|
235
300
|
removeClass(nav, "closed");
|
@@ -243,6 +308,9 @@
|
|
243
308
|
}
|
244
309
|
},
|
245
310
|
|
311
|
+
/**
|
312
|
+
* Closes the navigation
|
313
|
+
*/
|
246
314
|
close: function () {
|
247
315
|
if (navOpen) {
|
248
316
|
addClass(nav, "closed");
|
@@ -251,12 +319,15 @@
|
|
251
319
|
removeClass(navToggle, "active");
|
252
320
|
setAttributes(nav, {"aria-hidden": "true"});
|
253
321
|
|
322
|
+
// If animations are enabled, wait until they finish
|
254
323
|
if (opts.animate) {
|
255
324
|
hasAnimFinished = false;
|
256
325
|
setTimeout(function () {
|
257
326
|
nav.style.position = "absolute";
|
258
327
|
hasAnimFinished = true;
|
259
328
|
}, opts.transition + 10);
|
329
|
+
|
330
|
+
// Animations aren't enabled, we can do these immediately
|
260
331
|
} else {
|
261
332
|
nav.style.position = "absolute";
|
262
333
|
}
|
@@ -266,7 +337,13 @@
|
|
266
337
|
}
|
267
338
|
},
|
268
339
|
|
340
|
+
/**
|
341
|
+
* Resize is called on window resize and orientation change.
|
342
|
+
* It initializes the CSS styles and height calculations.
|
343
|
+
*/
|
269
344
|
resize: function () {
|
345
|
+
|
346
|
+
// Resize watches navigation toggle's display state
|
270
347
|
if (window.getComputedStyle(navToggle, null).getPropertyValue("display") !== "none") {
|
271
348
|
|
272
349
|
isMobile = true;
|
@@ -290,6 +367,12 @@
|
|
290
367
|
}
|
291
368
|
},
|
292
369
|
|
370
|
+
/**
|
371
|
+
* Takes care of all even handling
|
372
|
+
*
|
373
|
+
* @param {event} event
|
374
|
+
* @return {type} returns the type of event that should be used
|
375
|
+
*/
|
293
376
|
handleEvent: function (e) {
|
294
377
|
var evt = e || window.event;
|
295
378
|
|
@@ -310,13 +393,16 @@
|
|
310
393
|
case "keyup":
|
311
394
|
this._onKeyUp(evt);
|
312
395
|
break;
|
396
|
+
case "focus":
|
313
397
|
case "resize":
|
314
398
|
this.resize(evt);
|
315
399
|
break;
|
316
400
|
}
|
317
401
|
},
|
318
402
|
|
319
|
-
|
403
|
+
/**
|
404
|
+
* Initializes the widget
|
405
|
+
*/
|
320
406
|
_init: function () {
|
321
407
|
this.index = index++;
|
322
408
|
|
@@ -331,13 +417,18 @@
|
|
331
417
|
this._transitions();
|
332
418
|
this.resize();
|
333
419
|
|
334
|
-
|
420
|
+
/**
|
421
|
+
* On IE8 the resize event triggers too early for some reason
|
422
|
+
* so it's called here again on init to make sure all the
|
423
|
+
* calculated styles are correct.
|
424
|
+
*/
|
335
425
|
var self = this;
|
336
426
|
setTimeout(function () {
|
337
427
|
self.resize();
|
338
428
|
}, 20);
|
339
429
|
|
340
430
|
addEvent(window, "resize", this, false);
|
431
|
+
addEvent(window, "focus", this, false);
|
341
432
|
addEvent(document.body, "touchmove", this, false);
|
342
433
|
addEvent(navToggle, "touchstart", this, false);
|
343
434
|
addEvent(navToggle, "touchend", this, false);
|
@@ -345,10 +436,15 @@
|
|
345
436
|
addEvent(navToggle, "keyup", this, false);
|
346
437
|
addEvent(navToggle, "click", this, false);
|
347
438
|
|
348
|
-
|
439
|
+
/**
|
440
|
+
* Init callback here
|
441
|
+
*/
|
349
442
|
opts.init();
|
350
443
|
},
|
351
444
|
|
445
|
+
/**
|
446
|
+
* Creates Styles to the <head>
|
447
|
+
*/
|
352
448
|
_createStyles: function () {
|
353
449
|
if (!styleElement.parentNode) {
|
354
450
|
styleElement.type = "text/css";
|
@@ -356,13 +452,21 @@
|
|
356
452
|
}
|
357
453
|
},
|
358
454
|
|
455
|
+
/**
|
456
|
+
* Removes styles from the <head>
|
457
|
+
*/
|
359
458
|
_removeStyles: function () {
|
360
459
|
if (styleElement.parentNode) {
|
361
460
|
styleElement.parentNode.removeChild(styleElement);
|
362
461
|
}
|
363
462
|
},
|
364
463
|
|
464
|
+
/**
|
465
|
+
* Creates Navigation Toggle
|
466
|
+
*/
|
365
467
|
_createToggle: function () {
|
468
|
+
|
469
|
+
// If there's no toggle, let's create one
|
366
470
|
if (!opts.customToggle) {
|
367
471
|
var toggle = document.createElement("a");
|
368
472
|
toggle.innerHTML = opts.label;
|
@@ -371,6 +475,7 @@
|
|
371
475
|
"class": "nav-toggle"
|
372
476
|
});
|
373
477
|
|
478
|
+
// Determine where to insert the toggle
|
374
479
|
if (opts.insert === "after") {
|
375
480
|
nav.parentNode.insertBefore(toggle, nav.nextSibling);
|
376
481
|
} else {
|
@@ -378,6 +483,8 @@
|
|
378
483
|
}
|
379
484
|
|
380
485
|
navToggle = toggle;
|
486
|
+
|
487
|
+
// There is a toggle already, let's use that one
|
381
488
|
} else {
|
382
489
|
var toggleEl = opts.customToggle.replace("#", "");
|
383
490
|
|
@@ -391,9 +498,12 @@
|
|
391
498
|
}
|
392
499
|
},
|
393
500
|
|
501
|
+
/**
|
502
|
+
* Closes the navigation when a link inside is clicked
|
503
|
+
*/
|
394
504
|
_closeOnNavClick: function () {
|
395
|
-
if (opts.closeOnNavClick
|
396
|
-
var links = nav.
|
505
|
+
if (opts.closeOnNavClick) {
|
506
|
+
var links = nav.getElementsByTagName("a"),
|
397
507
|
self = this;
|
398
508
|
forEach(links, function (i, el) {
|
399
509
|
addEvent(links[i], "click", function () {
|
@@ -405,36 +515,76 @@
|
|
405
515
|
}
|
406
516
|
},
|
407
517
|
|
518
|
+
/**
|
519
|
+
* Prevents the default tap functionality
|
520
|
+
*
|
521
|
+
* @param {event} event
|
522
|
+
*/
|
408
523
|
_preventDefault: function(e) {
|
409
524
|
if (e.preventDefault) {
|
525
|
+
if (e.stopImmediatePropagation) {
|
526
|
+
e.stopImmediatePropagation();
|
527
|
+
}
|
410
528
|
e.preventDefault();
|
411
529
|
e.stopPropagation();
|
530
|
+
return false;
|
531
|
+
|
532
|
+
// This is strictly for old IE
|
412
533
|
} else {
|
413
534
|
e.returnValue = false;
|
414
535
|
}
|
415
536
|
},
|
416
537
|
|
538
|
+
/**
|
539
|
+
* On touch start get the location of the touch
|
540
|
+
* and disable pointer events on the body.
|
541
|
+
*
|
542
|
+
* @param {event} event
|
543
|
+
*/
|
417
544
|
_onTouchStart: function (e) {
|
418
|
-
|
419
|
-
|
420
|
-
addClass(document.body, "disable-pointer-events");
|
421
|
-
}
|
545
|
+
this._preventDefault(e);
|
546
|
+
addClass(document.body, "disable-pointer-events");
|
422
547
|
this.startX = e.touches[0].clientX;
|
423
548
|
this.startY = e.touches[0].clientY;
|
424
549
|
this.touchHasMoved = false;
|
550
|
+
|
551
|
+
/**
|
552
|
+
* We remove mouseup event completely here to avoid
|
553
|
+
* double triggering of events.
|
554
|
+
*/
|
425
555
|
removeEvent(navToggle, "mouseup", this, false);
|
426
556
|
},
|
427
557
|
|
558
|
+
/**
|
559
|
+
* Check if the user is scrolling instead of tapping and
|
560
|
+
* re-enable pointer events if movement happed.
|
561
|
+
*
|
562
|
+
* @param {event} event
|
563
|
+
*/
|
428
564
|
_onTouchMove: function (e) {
|
429
565
|
if (Math.abs(e.touches[0].clientX - this.startX) > 10 ||
|
430
566
|
Math.abs(e.touches[0].clientY - this.startY) > 10) {
|
567
|
+
this._enablePointerEvents();
|
431
568
|
this.touchHasMoved = true;
|
432
569
|
}
|
433
570
|
},
|
434
571
|
|
572
|
+
/**
|
573
|
+
* On touch end toggle either the whole navigation or
|
574
|
+
* a sub-navigation depending on which one was tapped.
|
575
|
+
*
|
576
|
+
* @param {event} event
|
577
|
+
*/
|
435
578
|
_onTouchEnd: function (e) {
|
436
579
|
this._preventDefault(e);
|
580
|
+
if (!isMobile) {
|
581
|
+
return;
|
582
|
+
}
|
583
|
+
|
584
|
+
// If the user isn't scrolling
|
437
585
|
if (!this.touchHasMoved) {
|
586
|
+
|
587
|
+
// If the event type is touch
|
438
588
|
if (e.type === "touchend") {
|
439
589
|
this.toggle();
|
440
590
|
if (opts.insert === "after") {
|
@@ -443,9 +593,12 @@
|
|
443
593
|
}, opts.transition + 300);
|
444
594
|
}
|
445
595
|
return;
|
596
|
+
|
597
|
+
// Event type was click, not touch
|
446
598
|
} else {
|
447
599
|
var evt = e || window.event;
|
448
|
-
|
600
|
+
|
601
|
+
// If it isn't a right click, do toggling
|
449
602
|
if (!(evt.which === 3 || evt.button === 2)) {
|
450
603
|
this.toggle();
|
451
604
|
}
|
@@ -453,6 +606,13 @@
|
|
453
606
|
}
|
454
607
|
},
|
455
608
|
|
609
|
+
/**
|
610
|
+
* For keyboard accessibility, toggle the navigation on Enter
|
611
|
+
* keypress too (also sub-navigation is keyboard accessible
|
612
|
+
* which explains the complexity here)
|
613
|
+
*
|
614
|
+
* @param {event} event
|
615
|
+
*/
|
456
616
|
_onKeyUp: function (e) {
|
457
617
|
var evt = e || window.event;
|
458
618
|
if (evt.keyCode === 13) {
|
@@ -460,6 +620,16 @@
|
|
460
620
|
}
|
461
621
|
},
|
462
622
|
|
623
|
+
/**
|
624
|
+
* Enable pointer events
|
625
|
+
*/
|
626
|
+
_enablePointerEvents: function () {
|
627
|
+
removeClass(document.body, "disable-pointer-events");
|
628
|
+
},
|
629
|
+
|
630
|
+
/**
|
631
|
+
* Adds the needed CSS transitions if animations are enabled
|
632
|
+
*/
|
463
633
|
_transitions: function () {
|
464
634
|
if (opts.animate) {
|
465
635
|
var objStyle = nav.style,
|
@@ -472,12 +642,19 @@
|
|
472
642
|
}
|
473
643
|
},
|
474
644
|
|
645
|
+
/**
|
646
|
+
* Calculates the height of the navigation and then creates
|
647
|
+
* styles which are later added to the page <head>
|
648
|
+
*/
|
475
649
|
_calcHeight: function () {
|
476
650
|
var savedHeight = 0;
|
477
651
|
for (var i = 0; i < nav.inner.length; i++) {
|
478
652
|
savedHeight += nav.inner[i].offsetHeight;
|
479
653
|
}
|
480
|
-
|
654
|
+
|
655
|
+
// Pointer event styles are also here since they might only be confusing inside the stylesheet
|
656
|
+
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}";
|
657
|
+
|
481
658
|
|
482
659
|
if (styleElement.styleSheet) {
|
483
660
|
styleElement.styleSheet.cssText = innerStyles;
|
@@ -490,10 +667,13 @@
|
|
490
667
|
|
491
668
|
};
|
492
669
|
|
670
|
+
/**
|
671
|
+
* Return new Responsive Nav
|
672
|
+
*/
|
493
673
|
return new ResponsiveNav(el, options);
|
494
674
|
|
495
675
|
};
|
496
676
|
|
497
677
|
window.responsiveNav = responsiveNav;
|
498
678
|
|
499
|
-
}(document, window, 0));
|
679
|
+
}(document, window, 0));
|
@@ -1 +1 @@
|
|
1
|
-
!function(a,b,c){"use strict";var d=function(d,e){var f=!!b.getComputedStyle;f||(b.getComputedStyle=function(a){return this.el=a,this.getPropertyValue=function(b){var c=/(\-([a-z]){1})/g;return"float"===b&&(b="styleFloat"),c.test(b)&&(b=b.replace(c,function(){return arguments[2].toUpperCase()})),a.currentStyle[b]?a.currentStyle[b]:null},this});var g,h,i,j,k,l,m=function(a,b,c,d){if("addEventListener"in a)try{a.addEventListener(b,c,d)}catch(e){if("object"!=typeof c||!c.handleEvent)throw e;a.addEventListener(b,function(a){c.handleEvent.call(c,a)},d)}else"attachEvent"in a&&("object"==typeof c&&c.handleEvent?a.attachEvent("on"+b,function(){c.handleEvent.call(c)}):a.attachEvent("on"+b,c))},n=function(a,b,c,d){if("removeEventListener"in a)try{a.removeEventListener(b,c,d)}catch(e){if("object"!=typeof c||!c.handleEvent)throw e;a.removeEventListener(b,function(a){c.handleEvent.call(c,a)},d)}else"detachEvent"in a&&("object"==typeof c&&c.handleEvent?a.detachEvent("on"+b,function(){c.handleEvent.call(c)}):a.detachEvent("on"+b,c))},o=function(a){if(a.children.length<1)throw new 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},p=function(a,b){for(var c in b)a.setAttribute(c,b[c])},q=function(a,b){0!==a.className.indexOf(b)&&(a.className+=" "+b,a.className=a.className.replace(/(^\s*)|(\s*$)/g,""))},r=function(a,b){var c=new RegExp("(\\s|^)"+b+"(\\s|$)");a.className=a.className.replace(c," ").replace(/(^\s*)|(\s*$)/g,"")},s=function(a,b,c){for(var d=0;d<a.length;d++)b.call(c,d,a[d])},t=a.createElement("style"),u=a.documentElement,v=function(b,c){var d;this.options={animate:!0,transition:284,label:"Menu",insert:"before",customToggle:"",closeOnNavClick:!1,openPos:"relative",navClass:"nav-collapse",navActiveClass:"js-nav-active",jsClass:"js",init:function(){},open:function(){},close:function(){}};for(d in c)this.options[d]=c[d];if(q(u,this.options.jsClass),this.wrapperEl=b.replace("#",""),a.getElementById(this.wrapperEl))this.wrapper=a.getElementById(this.wrapperEl);else{if(!a.querySelector(this.wrapperEl))throw new Error("The nav element you are trying to select doesn't exist");this.wrapper=a.querySelector(this.wrapperEl)}this.wrapper.inner=o(this.wrapper),h=this.options,g=this.wrapper,this._init(this)};return v.prototype={destroy:function(){this._removeStyles(),r(g,"closed"),r(g,"opened"),r(g,h.navClass),r(g,h.navClass+"-"+this.index),r(u,h.navActiveClass),g.removeAttribute("style"),g.removeAttribute("aria-hidden"),n(b,"resize",this,!1),n(a.body,"touchmove",this,!1),n(i,"touchstart",this,!1),n(i,"touchend",this,!1),n(i,"mouseup",this,!1),n(i,"keyup",this,!1),n(i,"click",this,!1),h.customToggle?i.removeAttribute("aria-hidden"):i.parentNode.removeChild(i)},toggle:function(){j===!0&&(l?this.close():this.open())},open:function(){l||(r(g,"closed"),q(g,"opened"),q(u,h.navActiveClass),q(i,"active"),g.style.position=h.openPos,p(g,{"aria-hidden":"false"}),l=!0,h.open())},close:function(){l&&(q(g,"closed"),r(g,"opened"),r(u,h.navActiveClass),r(i,"active"),p(g,{"aria-hidden":"true"}),h.animate?(j=!1,setTimeout(function(){g.style.position="absolute",j=!0},h.transition+10)):g.style.position="absolute",l=!1,h.close())},resize:function(){"none"!==b.getComputedStyle(i,null).getPropertyValue("display")?(k=!0,p(i,{"aria-hidden":"false"}),g.className.match(/(^|\s)closed(\s|$)/)&&(p(g,{"aria-hidden":"true"}),g.style.position="absolute"),this._createStyles(),this._calcHeight()):(k=!1,p(i,{"aria-hidden":"true"}),p(g,{"aria-hidden":"false"}),g.style.position=h.openPos,this._removeStyles())},handleEvent:function(a){var c=a||b.event;switch(c.type){case"touchstart":this._onTouchStart(c);break;case"touchmove":this._onTouchMove(c);break;case"touchend":case"mouseup":this._onTouchEnd(c);break;case"click":this._preventDefault(c);break;case"keyup":this._onKeyUp(c);break;case"resize":this.resize(c)}},_init:function(){this.index=c++,q(g,h.navClass),q(g,h.navClass+"-"+this.index),q(g,"closed"),j=!0,l=!1,this._closeOnNavClick(),this._createToggle(),this._transitions(),this.resize();var d=this;setTimeout(function(){d.resize()},20),m(b,"resize",this,!1),m(a.body,"touchmove",this,!1),m(i,"touchstart",this,!1),m(i,"touchend",this,!1),m(i,"mouseup",this,!1),m(i,"keyup",this,!1),m(i,"click",this,!1),h.init()},_createStyles:function(){t.parentNode||(t.type="text/css",a.getElementsByTagName("head")[0].appendChild(t))},_removeStyles:function(){t.parentNode&&t.parentNode.removeChild(t)},_createToggle:function(){if(h.customToggle){var b=h.customToggle.replace("#","");if(a.getElementById(b))i=a.getElementById(b);else{if(!a.querySelector(b))throw new Error("The custom nav toggle you are trying to select doesn't exist");i=a.querySelector(b)}}else{var c=a.createElement("a");c.innerHTML=h.label,p(c,{href:"#","class":"nav-toggle"}),"after"===h.insert?g.parentNode.insertBefore(c,g.nextSibling):g.parentNode.insertBefore(c,g),i=c}},_closeOnNavClick:function(){if(h.closeOnNavClick
|
1
|
+
!function(a,b,c){"use strict";var d=function(d,e){var f=!!b.getComputedStyle;f||(b.getComputedStyle=function(a){return this.el=a,this.getPropertyValue=function(b){var c=/(\-([a-z]){1})/g;return"float"===b&&(b="styleFloat"),c.test(b)&&(b=b.replace(c,function(){return arguments[2].toUpperCase()})),a.currentStyle[b]?a.currentStyle[b]:null},this});var g,h,i,j,k,l,m=function(a,b,c,d){if("addEventListener"in a)try{a.addEventListener(b,c,d)}catch(e){if("object"!=typeof c||!c.handleEvent)throw e;a.addEventListener(b,function(a){c.handleEvent.call(c,a)},d)}else"attachEvent"in a&&("object"==typeof c&&c.handleEvent?a.attachEvent("on"+b,function(){c.handleEvent.call(c)}):a.attachEvent("on"+b,c))},n=function(a,b,c,d){if("removeEventListener"in a)try{a.removeEventListener(b,c,d)}catch(e){if("object"!=typeof c||!c.handleEvent)throw e;a.removeEventListener(b,function(a){c.handleEvent.call(c,a)},d)}else"detachEvent"in a&&("object"==typeof c&&c.handleEvent?a.detachEvent("on"+b,function(){c.handleEvent.call(c)}):a.detachEvent("on"+b,c))},o=function(a){if(a.children.length<1)throw new 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},p=function(a,b){for(var c in b)a.setAttribute(c,b[c])},q=function(a,b){0!==a.className.indexOf(b)&&(a.className+=" "+b,a.className=a.className.replace(/(^\s*)|(\s*$)/g,""))},r=function(a,b){var c=new RegExp("(\\s|^)"+b+"(\\s|$)");a.className=a.className.replace(c," ").replace(/(^\s*)|(\s*$)/g,"")},s=function(a,b,c){for(var d=0;d<a.length;d++)b.call(c,d,a[d])},t=a.createElement("style"),u=a.documentElement,v=function(b,c){var d;this.options={animate:!0,transition:284,label:"Menu",insert:"before",customToggle:"",closeOnNavClick:!1,openPos:"relative",navClass:"nav-collapse",navActiveClass:"js-nav-active",jsClass:"js",init:function(){},open:function(){},close:function(){}};for(d in c)this.options[d]=c[d];if(q(u,this.options.jsClass),this.wrapperEl=b.replace("#",""),a.getElementById(this.wrapperEl))this.wrapper=a.getElementById(this.wrapperEl);else{if(!a.querySelector(this.wrapperEl))throw new Error("The nav element you are trying to select doesn't exist");this.wrapper=a.querySelector(this.wrapperEl)}this.wrapper.inner=o(this.wrapper),h=this.options,g=this.wrapper,this._init(this)};return v.prototype={destroy:function(){this._removeStyles(),r(g,"closed"),r(g,"opened"),r(g,h.navClass),r(g,h.navClass+"-"+this.index),r(u,h.navActiveClass),g.removeAttribute("style"),g.removeAttribute("aria-hidden"),n(b,"resize",this,!1),n(b,"focus",this,!1),n(a.body,"touchmove",this,!1),n(i,"touchstart",this,!1),n(i,"touchend",this,!1),n(i,"mouseup",this,!1),n(i,"keyup",this,!1),n(i,"click",this,!1),h.customToggle?i.removeAttribute("aria-hidden"):i.parentNode.removeChild(i)},toggle:function(){j===!0&&(l?this.close():this.open(),this._enablePointerEvents())},open:function(){l||(r(g,"closed"),q(g,"opened"),q(u,h.navActiveClass),q(i,"active"),g.style.position=h.openPos,p(g,{"aria-hidden":"false"}),l=!0,h.open())},close:function(){l&&(q(g,"closed"),r(g,"opened"),r(u,h.navActiveClass),r(i,"active"),p(g,{"aria-hidden":"true"}),h.animate?(j=!1,setTimeout(function(){g.style.position="absolute",j=!0},h.transition+10)):g.style.position="absolute",l=!1,h.close())},resize:function(){"none"!==b.getComputedStyle(i,null).getPropertyValue("display")?(k=!0,p(i,{"aria-hidden":"false"}),g.className.match(/(^|\s)closed(\s|$)/)&&(p(g,{"aria-hidden":"true"}),g.style.position="absolute"),this._createStyles(),this._calcHeight()):(k=!1,p(i,{"aria-hidden":"true"}),p(g,{"aria-hidden":"false"}),g.style.position=h.openPos,this._removeStyles())},handleEvent:function(a){var c=a||b.event;switch(c.type){case"touchstart":this._onTouchStart(c);break;case"touchmove":this._onTouchMove(c);break;case"touchend":case"mouseup":this._onTouchEnd(c);break;case"click":this._preventDefault(c);break;case"keyup":this._onKeyUp(c);break;case"focus":case"resize":this.resize(c)}},_init:function(){this.index=c++,q(g,h.navClass),q(g,h.navClass+"-"+this.index),q(g,"closed"),j=!0,l=!1,this._closeOnNavClick(),this._createToggle(),this._transitions(),this.resize();var d=this;setTimeout(function(){d.resize()},20),m(b,"resize",this,!1),m(b,"focus",this,!1),m(a.body,"touchmove",this,!1),m(i,"touchstart",this,!1),m(i,"touchend",this,!1),m(i,"mouseup",this,!1),m(i,"keyup",this,!1),m(i,"click",this,!1),h.init()},_createStyles:function(){t.parentNode||(t.type="text/css",a.getElementsByTagName("head")[0].appendChild(t))},_removeStyles:function(){t.parentNode&&t.parentNode.removeChild(t)},_createToggle:function(){if(h.customToggle){var b=h.customToggle.replace("#","");if(a.getElementById(b))i=a.getElementById(b);else{if(!a.querySelector(b))throw new Error("The custom nav toggle you are trying to select doesn't exist");i=a.querySelector(b)}}else{var c=a.createElement("a");c.innerHTML=h.label,p(c,{href:"#","class":"nav-toggle"}),"after"===h.insert?g.parentNode.insertBefore(c,g.nextSibling):g.parentNode.insertBefore(c,g),i=c}},_closeOnNavClick:function(){if(h.closeOnNavClick){var a=g.getElementsByTagName("a"),b=this;s(a,function(c){m(a[c],"click",function(){k&&b.toggle()},!1)})}},_preventDefault:function(a){return a.preventDefault?(a.stopImmediatePropagation&&a.stopImmediatePropagation(),a.preventDefault(),a.stopPropagation(),!1):void(a.returnValue=!1)},_onTouchStart:function(b){this._preventDefault(b),q(a.body,"disable-pointer-events"),this.startX=b.touches[0].clientX,this.startY=b.touches[0].clientY,this.touchHasMoved=!1,n(i,"mouseup",this,!1)},_onTouchMove:function(a){(Math.abs(a.touches[0].clientX-this.startX)>10||Math.abs(a.touches[0].clientY-this.startY)>10)&&(this._enablePointerEvents(),this.touchHasMoved=!0)},_onTouchEnd:function(c){if(this._preventDefault(c),k&&!this.touchHasMoved){if("touchend"===c.type)return this.toggle(),void("after"===h.insert&&setTimeout(function(){r(a.body,"disable-pointer-events")},h.transition+300));var d=c||b.event;3!==d.which&&2!==d.button&&this.toggle()}},_onKeyUp:function(a){var c=a||b.event;13===c.keyCode&&this.toggle()},_enablePointerEvents:function(){r(a.body,"disable-pointer-events")},_transitions:function(){if(h.animate){var a=g.style,b="max-height "+h.transition+"ms";a.WebkitTransition=b,a.MozTransition=b,a.OTransition=b,a.transition=b}},_calcHeight:function(){for(var a=0,b=0;b<g.inner.length;b++)a+=g.inner[b].offsetHeight;var c="."+h.jsClass+" ."+h.navClass+"-"+this.index+".opened{max-height:"+a+"px !important} ."+h.jsClass+" .disable-pointer-events{pointer-events:none !important} ."+h.jsClass+" ."+h.navClass+"-"+this.index+".opened.dropdown-active {max-height:9999px !important}";t.styleSheet?t.styleSheet.cssText=c:t.innerHTML=c,c=""}},new v(d,e)};b.responsiveNav=d}(document,window,0);
|
@@ -26,10 +26,6 @@
|
|
26
26
|
max-height: 9999px;
|
27
27
|
}
|
28
28
|
|
29
|
-
.disable-pointer-events {
|
30
|
-
pointer-events: none !important;
|
31
|
-
}
|
32
|
-
|
33
29
|
.nav-toggle {
|
34
30
|
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
35
31
|
-webkit-touch-callout: none;
|
@@ -50,4 +46,4 @@
|
|
50
46
|
.nav-toggle {
|
51
47
|
display: none;
|
52
48
|
}
|
53
|
-
}
|
49
|
+
}
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
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.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas McNiven
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: responsive-nav.com for the rails asset pipeline
|
14
14
|
email:
|
15
|
-
-
|
15
|
+
- hello@vevix.net
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|