responsive-nav-rails 1.0.25 → 1.0.30
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 +25 -1
- 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 +1 -1
- data/responsive-nav-rails.gemspec +0 -0
- data/vendor/assets/javascripts/responsive-nav.js +143 -92
- data/vendor/assets/javascripts/responsive-nav.min.js +1 -1
- data/vendor/assets/stylesheets/responsive-nav.css +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98452f63cb7d5a82f236409a28c077e7a2bde28a
|
4
|
+
data.tar.gz: 7dc334eb6868575309ef2ce6b2601aab34183ecc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b48b39f047ea11f1835e93b7ebf3ba9a365bdac78948914419aa8a9677f58af18ae87b51c60abddbfbfbbce61ba70ae4b83403d9b5cd00e16ff73248cd464bf6
|
7
|
+
data.tar.gz: b109e402f2bc34c4e55b34a13e2e9247e2e05af1d3fadc0b99c16f7bb8d7a49bbe888c32f158b926d566eb2a2bfc91b538ac26bd847cacd25ecf171d790256b6
|
data/.gitignore
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.md
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# responsive-nav-rails
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/responsive-nav-rails)
|
4
|
+
|
3
5
|
[responsive-nav](http://responsive-nav.com) for the Rails asset pipeline
|
4
6
|
|
5
7
|
## Installation
|
@@ -24,4 +26,26 @@ or for the minified version
|
|
24
26
|
|
25
27
|
## License
|
26
28
|
|
27
|
-
|
29
|
+
Copyright (c) 2013 Thomas McNiven
|
30
|
+
|
31
|
+
MIT License
|
32
|
+
|
33
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
34
|
+
a copy of this software and associated documentation files (the
|
35
|
+
"Software"), to deal in the Software without restriction, including
|
36
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
37
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
38
|
+
permit persons to whom the Software is furnished to do so, subject to
|
39
|
+
the following conditions:
|
40
|
+
|
41
|
+
The above copyright notice and this permission notice shall be
|
42
|
+
included in all copies or substantial portions of the Software.
|
43
|
+
|
44
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
45
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
46
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
47
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
48
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
49
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
50
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
51
|
+
|
data/Rakefile
CHANGED
File without changes
|
data/lib/responsive-nav-rails.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
@@ -1,18 +1,17 @@
|
|
1
|
-
/*! responsive-nav.js 1.0.
|
1
|
+
/*! responsive-nav.js 1.0.30
|
2
2
|
* https://github.com/viljamis/responsive-nav.js
|
3
3
|
* http://responsive-nav.com
|
4
4
|
*
|
5
|
-
* Copyright (c)
|
5
|
+
* Copyright (c) 2014 @viljamis
|
6
6
|
* Available under the MIT license
|
7
7
|
*/
|
8
8
|
|
9
|
-
(function () {
|
9
|
+
(function (document, window, index) {
|
10
10
|
|
11
11
|
"use strict";
|
12
12
|
|
13
|
-
/* exported responsiveNav */
|
14
13
|
var responsiveNav = function (el, options) {
|
15
|
-
|
14
|
+
|
16
15
|
var computed = !!window.getComputedStyle;
|
17
16
|
|
18
17
|
// getComputedStyle polyfill
|
@@ -121,73 +120,84 @@
|
|
121
120
|
var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
|
122
121
|
el.className = el.className.replace(reg, " ").replace(/(^\s*)|(\s*$)/g,"");
|
123
122
|
};
|
124
|
-
|
123
|
+
|
125
124
|
var nav,
|
126
125
|
opts,
|
127
126
|
navToggle,
|
128
127
|
styleElement = document.createElement("style"),
|
128
|
+
htmlEl = document.documentElement,
|
129
129
|
hasAnimFinished,
|
130
|
+
isMobile,
|
130
131
|
navOpen;
|
131
|
-
|
132
|
+
|
132
133
|
var ResponsiveNav = function (el, options) {
|
133
134
|
var i;
|
134
|
-
|
135
|
+
|
135
136
|
// Default options
|
136
137
|
this.options = {
|
137
|
-
animate: true,
|
138
|
-
transition:
|
139
|
-
label: "Menu",
|
140
|
-
insert: "
|
141
|
-
customToggle: "",
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
138
|
+
animate: true, // Boolean: Use CSS3 transitions, true or false
|
139
|
+
transition: 284, // Integer: Speed of the transition, in milliseconds
|
140
|
+
label: "Menu", // String: Label for the navigation toggle
|
141
|
+
insert: "before", // String: Insert the toggle before or after the navigation
|
142
|
+
customToggle: "", // Selector: Specify the ID of a custom toggle
|
143
|
+
closeOnNavClick: false, // Boolean: Close the navigation when one of the links are clicked
|
144
|
+
openPos: "relative", // String: Position of the opened nav, relative or static
|
145
|
+
navClass: "nav-collapse", // String: Default CSS class. If changed, you need to edit the CSS too!
|
146
|
+
navActiveClass: "js-nav-active", // String: Class that is added to <html> element when nav is active
|
147
|
+
jsClass: "js", // String: 'JS enabled' class which is added to <html> element
|
148
|
+
init: function(){}, // Function: Init callback
|
149
|
+
open: function(){}, // Function: Open callback
|
150
|
+
close: function(){} // Function: Close callback
|
148
151
|
};
|
149
|
-
|
152
|
+
|
150
153
|
// User defined options
|
151
154
|
for (i in options) {
|
152
155
|
this.options[i] = options[i];
|
153
156
|
}
|
154
|
-
|
157
|
+
|
155
158
|
// Adds "js" class for <html>
|
156
|
-
addClass(
|
157
|
-
|
159
|
+
addClass(htmlEl, this.options.jsClass);
|
160
|
+
|
158
161
|
// Wrapper
|
159
162
|
this.wrapperEl = el.replace("#", "");
|
163
|
+
|
164
|
+
// Try selecting ID first
|
160
165
|
if (document.getElementById(this.wrapperEl)) {
|
161
166
|
this.wrapper = document.getElementById(this.wrapperEl);
|
167
|
+
|
168
|
+
// If element with an ID doesn't exist, use querySelector
|
162
169
|
} else if (document.querySelector(this.wrapperEl)) {
|
163
170
|
this.wrapper = document.querySelector(this.wrapperEl);
|
171
|
+
|
172
|
+
// If element doesn't exists, stop here.
|
164
173
|
} else {
|
165
|
-
// If el doesn't exists, stop here.
|
166
174
|
throw new Error("The nav element you are trying to select doesn't exist");
|
167
175
|
}
|
168
|
-
|
176
|
+
|
169
177
|
// Inner wrapper
|
170
178
|
this.wrapper.inner = getChildren(this.wrapper);
|
171
|
-
|
179
|
+
|
172
180
|
// For minification
|
173
181
|
opts = this.options;
|
174
182
|
nav = this.wrapper;
|
175
|
-
|
183
|
+
|
176
184
|
// Init
|
177
185
|
this._init(this);
|
178
186
|
};
|
179
|
-
|
187
|
+
|
180
188
|
ResponsiveNav.prototype = {
|
181
|
-
|
189
|
+
|
182
190
|
// Public methods
|
183
191
|
destroy: function () {
|
184
192
|
this._removeStyles();
|
185
193
|
removeClass(nav, "closed");
|
186
194
|
removeClass(nav, "opened");
|
187
195
|
removeClass(nav, opts.navClass);
|
196
|
+
removeClass(nav, opts.navClass + "-" + this.index);
|
197
|
+
removeClass(htmlEl, opts.navActiveClass);
|
188
198
|
nav.removeAttribute("style");
|
189
199
|
nav.removeAttribute("aria-hidden");
|
190
|
-
|
200
|
+
|
191
201
|
removeEvent(window, "resize", this, false);
|
192
202
|
removeEvent(document.body, "touchmove", this, false);
|
193
203
|
removeEvent(navToggle, "touchstart", this, false);
|
@@ -195,68 +205,87 @@
|
|
195
205
|
removeEvent(navToggle, "mouseup", this, false);
|
196
206
|
removeEvent(navToggle, "keyup", this, false);
|
197
207
|
removeEvent(navToggle, "click", this, false);
|
198
|
-
|
208
|
+
|
199
209
|
if (!opts.customToggle) {
|
200
210
|
navToggle.parentNode.removeChild(navToggle);
|
201
211
|
} else {
|
202
212
|
navToggle.removeAttribute("aria-hidden");
|
203
213
|
}
|
204
214
|
},
|
205
|
-
|
215
|
+
|
206
216
|
toggle: function () {
|
207
217
|
if (hasAnimFinished === true) {
|
208
218
|
if (!navOpen) {
|
209
|
-
|
210
|
-
addClass(nav, "opened");
|
211
|
-
nav.style.position = opts.openPos;
|
212
|
-
setAttributes(nav, {"aria-hidden": "false"});
|
213
|
-
|
214
|
-
navOpen = true;
|
215
|
-
opts.open();
|
219
|
+
this.open();
|
216
220
|
} else {
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
221
|
+
this.close();
|
222
|
+
}
|
223
|
+
}
|
224
|
+
},
|
225
|
+
|
226
|
+
open: function () {
|
227
|
+
if (!navOpen) {
|
228
|
+
removeClass(nav, "closed");
|
229
|
+
addClass(nav, "opened");
|
230
|
+
addClass(htmlEl, opts.navActiveClass);
|
231
|
+
addClass(navToggle, "active");
|
232
|
+
nav.style.position = opts.openPos;
|
233
|
+
setAttributes(nav, {"aria-hidden": "false"});
|
234
|
+
navOpen = true;
|
235
|
+
opts.open();
|
236
|
+
}
|
237
|
+
},
|
238
|
+
|
239
|
+
close: function () {
|
240
|
+
if (navOpen) {
|
241
|
+
addClass(nav, "closed");
|
242
|
+
removeClass(nav, "opened");
|
243
|
+
removeClass(htmlEl, opts.navActiveClass);
|
244
|
+
removeClass(navToggle, "active");
|
245
|
+
setAttributes(nav, {"aria-hidden": "true"});
|
246
|
+
|
247
|
+
if (opts.animate) {
|
248
|
+
hasAnimFinished = false;
|
249
|
+
setTimeout(function () {
|
228
250
|
nav.style.position = "absolute";
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
251
|
+
hasAnimFinished = true;
|
252
|
+
}, opts.transition + 10);
|
253
|
+
} else {
|
254
|
+
nav.style.position = "absolute";
|
233
255
|
}
|
256
|
+
|
257
|
+
navOpen = false;
|
258
|
+
opts.close();
|
234
259
|
}
|
235
260
|
},
|
236
|
-
|
261
|
+
|
237
262
|
resize: function () {
|
238
263
|
if (window.getComputedStyle(navToggle, null).getPropertyValue("display") !== "none") {
|
264
|
+
|
265
|
+
isMobile = true;
|
239
266
|
setAttributes(navToggle, {"aria-hidden": "false"});
|
240
|
-
|
267
|
+
|
241
268
|
// If the navigation is hidden
|
242
269
|
if (nav.className.match(/(^|\s)closed(\s|$)/)) {
|
243
270
|
setAttributes(nav, {"aria-hidden": "true"});
|
244
271
|
nav.style.position = "absolute";
|
245
272
|
}
|
246
|
-
|
273
|
+
|
247
274
|
this._createStyles();
|
248
275
|
this._calcHeight();
|
249
276
|
} else {
|
277
|
+
|
278
|
+
isMobile = false;
|
250
279
|
setAttributes(navToggle, {"aria-hidden": "true"});
|
251
280
|
setAttributes(nav, {"aria-hidden": "false"});
|
252
281
|
nav.style.position = opts.openPos;
|
253
282
|
this._removeStyles();
|
254
283
|
}
|
255
284
|
},
|
256
|
-
|
285
|
+
|
257
286
|
handleEvent: function (e) {
|
258
287
|
var evt = e || window.event;
|
259
|
-
|
288
|
+
|
260
289
|
switch (evt.type) {
|
261
290
|
case "touchstart":
|
262
291
|
this._onTouchStart(evt);
|
@@ -279,24 +308,28 @@
|
|
279
308
|
break;
|
280
309
|
}
|
281
310
|
},
|
282
|
-
|
311
|
+
|
283
312
|
// Private methods
|
284
313
|
_init: function () {
|
314
|
+
this.index = index++;
|
315
|
+
|
285
316
|
addClass(nav, opts.navClass);
|
317
|
+
addClass(nav, opts.navClass + "-" + this.index);
|
286
318
|
addClass(nav, "closed");
|
287
319
|
hasAnimFinished = true;
|
288
320
|
navOpen = false;
|
289
|
-
|
321
|
+
|
322
|
+
this._closeOnNavClick();
|
290
323
|
this._createToggle();
|
291
324
|
this._transitions();
|
292
325
|
this.resize();
|
293
|
-
|
326
|
+
|
294
327
|
// IE8 hack
|
295
328
|
var self = this;
|
296
329
|
setTimeout(function () {
|
297
330
|
self.resize();
|
298
331
|
}, 20);
|
299
|
-
|
332
|
+
|
300
333
|
addEvent(window, "resize", this, false);
|
301
334
|
addEvent(document.body, "touchmove", this, false);
|
302
335
|
addEvent(navToggle, "touchstart", this, false);
|
@@ -304,24 +337,24 @@
|
|
304
337
|
addEvent(navToggle, "mouseup", this, false);
|
305
338
|
addEvent(navToggle, "keyup", this, false);
|
306
339
|
addEvent(navToggle, "click", this, false);
|
307
|
-
|
340
|
+
|
308
341
|
// Init callback
|
309
342
|
opts.init();
|
310
343
|
},
|
311
|
-
|
344
|
+
|
312
345
|
_createStyles: function () {
|
313
346
|
if (!styleElement.parentNode) {
|
314
347
|
styleElement.type = "text/css";
|
315
348
|
document.getElementsByTagName("head")[0].appendChild(styleElement);
|
316
349
|
}
|
317
350
|
},
|
318
|
-
|
351
|
+
|
319
352
|
_removeStyles: function () {
|
320
353
|
if (styleElement.parentNode) {
|
321
354
|
styleElement.parentNode.removeChild(styleElement);
|
322
355
|
}
|
323
356
|
},
|
324
|
-
|
357
|
+
|
325
358
|
_createToggle: function () {
|
326
359
|
if (!opts.customToggle) {
|
327
360
|
var toggle = document.createElement("a");
|
@@ -330,17 +363,17 @@
|
|
330
363
|
"href": "#",
|
331
364
|
"class": "nav-toggle"
|
332
365
|
});
|
333
|
-
|
366
|
+
|
334
367
|
if (opts.insert === "after") {
|
335
368
|
nav.parentNode.insertBefore(toggle, nav.nextSibling);
|
336
369
|
} else {
|
337
370
|
nav.parentNode.insertBefore(toggle, nav);
|
338
371
|
}
|
339
|
-
|
372
|
+
|
340
373
|
navToggle = toggle;
|
341
374
|
} else {
|
342
375
|
var toggleEl = opts.customToggle.replace("#", "");
|
343
|
-
|
376
|
+
|
344
377
|
if (document.getElementById(toggleEl)) {
|
345
378
|
navToggle = document.getElementById(toggleEl);
|
346
379
|
} else if (document.querySelector(toggleEl)) {
|
@@ -350,7 +383,21 @@
|
|
350
383
|
}
|
351
384
|
}
|
352
385
|
},
|
353
|
-
|
386
|
+
|
387
|
+
_closeOnNavClick: function () {
|
388
|
+
if (opts.closeOnNavClick && "querySelectorAll" in document && Array.prototype.forEach) {
|
389
|
+
var links = nav.querySelectorAll("a"),
|
390
|
+
self = this;
|
391
|
+
[].forEach.call(links, function (el, i) {
|
392
|
+
addEvent(links[i], "click", function () {
|
393
|
+
if (isMobile) {
|
394
|
+
self.toggle();
|
395
|
+
}
|
396
|
+
}, false);
|
397
|
+
});
|
398
|
+
}
|
399
|
+
},
|
400
|
+
|
354
401
|
_preventDefault: function(e) {
|
355
402
|
if (e.preventDefault) {
|
356
403
|
e.preventDefault();
|
@@ -359,83 +406,87 @@
|
|
359
406
|
e.returnValue = false;
|
360
407
|
}
|
361
408
|
},
|
362
|
-
|
409
|
+
|
363
410
|
_onTouchStart: function (e) {
|
364
411
|
e.stopPropagation();
|
365
|
-
|
412
|
+
if (opts.insert === "after") {
|
413
|
+
addClass(document.body, "disable-pointer-events");
|
414
|
+
}
|
366
415
|
this.startX = e.touches[0].clientX;
|
367
416
|
this.startY = e.touches[0].clientY;
|
368
417
|
this.touchHasMoved = false;
|
369
418
|
removeEvent(navToggle, "mouseup", this, false);
|
370
419
|
},
|
371
|
-
|
420
|
+
|
372
421
|
_onTouchMove: function (e) {
|
373
422
|
if (Math.abs(e.touches[0].clientX - this.startX) > 10 ||
|
374
423
|
Math.abs(e.touches[0].clientY - this.startY) > 10) {
|
375
424
|
this.touchHasMoved = true;
|
376
425
|
}
|
377
426
|
},
|
378
|
-
|
427
|
+
|
379
428
|
_onTouchEnd: function (e) {
|
380
429
|
this._preventDefault(e);
|
381
430
|
if (!this.touchHasMoved) {
|
382
431
|
if (e.type === "touchend") {
|
383
|
-
this.toggle(
|
384
|
-
|
385
|
-
|
386
|
-
|
432
|
+
this.toggle();
|
433
|
+
if (opts.insert === "after") {
|
434
|
+
setTimeout(function () {
|
435
|
+
removeClass(document.body, "disable-pointer-events");
|
436
|
+
}, opts.transition + 300);
|
437
|
+
}
|
387
438
|
return;
|
388
439
|
} else {
|
389
440
|
var evt = e || window.event;
|
390
441
|
// If it isn't a right click
|
391
442
|
if (!(evt.which === 3 || evt.button === 2)) {
|
392
|
-
this.toggle(
|
443
|
+
this.toggle();
|
393
444
|
}
|
394
445
|
}
|
395
446
|
}
|
396
447
|
},
|
397
|
-
|
448
|
+
|
398
449
|
_onKeyUp: function (e) {
|
399
450
|
var evt = e || window.event;
|
400
451
|
if (evt.keyCode === 13) {
|
401
|
-
this.toggle(
|
452
|
+
this.toggle();
|
402
453
|
}
|
403
454
|
},
|
404
|
-
|
455
|
+
|
405
456
|
_transitions: function () {
|
406
457
|
if (opts.animate) {
|
407
458
|
var objStyle = nav.style,
|
408
459
|
transition = "max-height " + opts.transition + "ms";
|
409
|
-
|
460
|
+
|
410
461
|
objStyle.WebkitTransition = transition;
|
411
462
|
objStyle.MozTransition = transition;
|
412
463
|
objStyle.OTransition = transition;
|
413
464
|
objStyle.transition = transition;
|
414
465
|
}
|
415
466
|
},
|
416
|
-
|
467
|
+
|
417
468
|
_calcHeight: function () {
|
418
469
|
var savedHeight = 0;
|
419
470
|
for (var i = 0; i < nav.inner.length; i++) {
|
420
471
|
savedHeight += nav.inner[i].offsetHeight;
|
421
472
|
}
|
422
|
-
var innerStyles = "." + opts.navClass + ".opened{max-height:" + savedHeight + "px !important}";
|
423
|
-
|
473
|
+
var innerStyles = "." + opts.navClass + "-" + this.index + ".opened{max-height:" + savedHeight + "px !important}";
|
474
|
+
|
424
475
|
if (styleElement.styleSheet) {
|
425
476
|
styleElement.styleSheet.cssText = innerStyles;
|
426
477
|
} else {
|
427
478
|
styleElement.innerHTML = innerStyles;
|
428
479
|
}
|
429
|
-
|
480
|
+
|
430
481
|
innerStyles = "";
|
431
482
|
}
|
432
|
-
|
483
|
+
|
433
484
|
};
|
434
|
-
|
485
|
+
|
435
486
|
return new ResponsiveNav(el, options);
|
436
|
-
|
487
|
+
|
437
488
|
};
|
438
489
|
|
439
490
|
window.responsiveNav = responsiveNav;
|
440
491
|
|
441
|
-
}());
|
492
|
+
}(document, window, 0));
|
@@ -1 +1 @@
|
|
1
|
-
!function(){"use strict";var
|
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=a.createElement("style"),t=a.documentElement,u=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(t,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 u.prototype={destroy:function(){this._removeStyles(),r(g,"closed"),r(g,"opened"),r(g,h.navClass),r(g,h.navClass+"-"+this.index),r(t,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(t,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(t,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(){s.parentNode||(s.type="text/css",a.getElementsByTagName("head")[0].appendChild(s))},_removeStyles:function(){s.parentNode&&s.parentNode.removeChild(s)},_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&&"querySelectorAll"in a&&Array.prototype.forEach){var b=g.querySelectorAll("a"),c=this;[].forEach.call(b,function(a,d){m(b[d],"click",function(){k&&c.toggle()},!1)})}},_preventDefault:function(a){a.preventDefault?(a.preventDefault(),a.stopPropagation()):a.returnValue=!1},_onTouchStart:function(b){b.stopPropagation(),"after"===h.insert&&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.touchHasMoved=!0)},_onTouchEnd:function(c){if(this._preventDefault(c),!this.touchHasMoved){if("touchend"===c.type)return this.toggle(),"after"===h.insert&&setTimeout(function(){r(a.body,"disable-pointer-events")},h.transition+300),void 0;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()},_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.navClass+"-"+this.index+".opened{max-height:"+a+"px !important}";s.styleSheet?s.styleSheet.cssText=c:s.innerHTML=c,c=""}},new u(d,e)};b.responsiveNav=d}(document,window,0);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! responsive-nav.js 1.0.
|
1
|
+
/*! responsive-nav.js 1.0.30 by @viljamis */
|
2
2
|
|
3
3
|
.nav-collapse ul {
|
4
4
|
margin: 0;
|
@@ -26,7 +26,7 @@
|
|
26
26
|
max-height: 9999px;
|
27
27
|
}
|
28
28
|
|
29
|
-
.
|
29
|
+
.disable-pointer-events {
|
30
30
|
pointer-events: none !important;
|
31
31
|
}
|
32
32
|
|
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.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas McNiven
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: responsive-nav.com for the rails asset pipeline
|
14
14
|
email:
|
@@ -17,7 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- .gitignore
|
20
|
+
- ".gitignore"
|
21
21
|
- Gemfile
|
22
22
|
- LICENSE.md
|
23
23
|
- README.md
|
@@ -39,17 +39,17 @@ require_paths:
|
|
39
39
|
- lib
|
40
40
|
required_ruby_version: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '0'
|
45
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '0'
|
50
50
|
requirements: []
|
51
51
|
rubyforge_project:
|
52
|
-
rubygems_version: 2.
|
52
|
+
rubygems_version: 2.2.2
|
53
53
|
signing_key:
|
54
54
|
specification_version: 4
|
55
55
|
summary: an asset gemification of the responsive-nav plugin
|