foundation-rails 6.4.1.0 → 6.4.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Rakefile +5 -6
  4. data/lib/foundation/rails/version.rb +1 -1
  5. data/vendor/assets/js/foundation.abide.js +781 -0
  6. data/vendor/assets/js/foundation.accordion.js +511 -0
  7. data/vendor/assets/js/foundation.accordionMenu.js +527 -0
  8. data/vendor/assets/js/foundation.core.js +860 -0
  9. data/vendor/assets/js/foundation.drilldown.js +759 -0
  10. data/vendor/assets/js/foundation.dropdown.js +1131 -0
  11. data/vendor/assets/js/foundation.dropdownMenu.js +678 -0
  12. data/vendor/assets/js/foundation.equalizer.js +542 -0
  13. data/vendor/assets/js/foundation.interchange.js +399 -0
  14. data/vendor/assets/js/{foundation.js.es6 → foundation.js} +11 -12
  15. data/vendor/assets/js/foundation.magellan.js +449 -0
  16. data/vendor/assets/js/foundation.offcanvas.js +1052 -0
  17. data/vendor/assets/js/foundation.orbit.js +767 -0
  18. data/vendor/assets/js/foundation.responsiveAccordionTabs.js +440 -0
  19. data/vendor/assets/js/foundation.responsiveMenu.js +362 -0
  20. data/vendor/assets/js/foundation.responsiveToggle.js +336 -0
  21. data/vendor/assets/js/foundation.reveal.js +1066 -0
  22. data/vendor/assets/js/foundation.slider.js +1236 -0
  23. data/vendor/assets/js/foundation.smoothScroll.js +303 -0
  24. data/vendor/assets/js/foundation.sticky.js +1001 -0
  25. data/vendor/assets/js/foundation.tabs.js +678 -0
  26. data/vendor/assets/js/foundation.toggler.js +602 -0
  27. data/vendor/assets/js/foundation.tooltip.js +1195 -0
  28. data/vendor/assets/js/{foundation.util.box.js.es6 → foundation.util.box.js} +154 -41
  29. data/vendor/assets/js/foundation.util.imageLoader.js +163 -0
  30. data/vendor/assets/js/foundation.util.keyboard.js +298 -0
  31. data/vendor/assets/js/foundation.util.mediaQuery.js +353 -0
  32. data/vendor/assets/js/foundation.util.motion.js +231 -0
  33. data/vendor/assets/js/foundation.util.nest.js +181 -0
  34. data/vendor/assets/js/foundation.util.timer.js +170 -0
  35. data/vendor/assets/js/foundation.util.timerAndImageLoader.js +90 -0
  36. data/vendor/assets/js/foundation.util.touch.js +275 -0
  37. data/vendor/assets/js/foundation.util.triggers.js +399 -0
  38. data/vendor/assets/js/foundation.zf.responsiveAccordionTabs.js +262 -0
  39. metadata +37 -71
  40. data/vendor/assets/js/entries/foundation-plugins.js +0 -25
  41. data/vendor/assets/js/entries/foundation.js +0 -101
  42. data/vendor/assets/js/entries/plugins/foundation.abide.js +0 -4
  43. data/vendor/assets/js/entries/plugins/foundation.accordion.js +0 -4
  44. data/vendor/assets/js/entries/plugins/foundation.accordionMenu.js +0 -5
  45. data/vendor/assets/js/entries/plugins/foundation.core.js +0 -21
  46. data/vendor/assets/js/entries/plugins/foundation.drilldown.js +0 -4
  47. data/vendor/assets/js/entries/plugins/foundation.dropdown.js +0 -5
  48. data/vendor/assets/js/entries/plugins/foundation.dropdownMenu.js +0 -4
  49. data/vendor/assets/js/entries/plugins/foundation.equalizer.js +0 -4
  50. data/vendor/assets/js/entries/plugins/foundation.interchange.js +0 -4
  51. data/vendor/assets/js/entries/plugins/foundation.magellan.js +0 -4
  52. data/vendor/assets/js/entries/plugins/foundation.offcanvas.js +0 -4
  53. data/vendor/assets/js/entries/plugins/foundation.orbit.js +0 -5
  54. data/vendor/assets/js/entries/plugins/foundation.responsiveAccordionTabs.js +0 -5
  55. data/vendor/assets/js/entries/plugins/foundation.responsiveMenu.js +0 -5
  56. data/vendor/assets/js/entries/plugins/foundation.responsiveToggle.js +0 -5
  57. data/vendor/assets/js/entries/plugins/foundation.reveal.js +0 -4
  58. data/vendor/assets/js/entries/plugins/foundation.slider.js +0 -5
  59. data/vendor/assets/js/entries/plugins/foundation.smoothScroll.js +0 -5
  60. data/vendor/assets/js/entries/plugins/foundation.sticky.js +0 -5
  61. data/vendor/assets/js/entries/plugins/foundation.tabs.js +0 -5
  62. data/vendor/assets/js/entries/plugins/foundation.toggler.js +0 -5
  63. data/vendor/assets/js/entries/plugins/foundation.tooltip.js +0 -4
  64. data/vendor/assets/js/entries/plugins/foundation.util.box.js +0 -4
  65. data/vendor/assets/js/entries/plugins/foundation.util.imageLoader.js +0 -5
  66. data/vendor/assets/js/entries/plugins/foundation.util.keyboard.js +0 -4
  67. data/vendor/assets/js/entries/plugins/foundation.util.mediaQuery.js +0 -4
  68. data/vendor/assets/js/entries/plugins/foundation.util.motion.js +0 -5
  69. data/vendor/assets/js/entries/plugins/foundation.util.nest.js +0 -5
  70. data/vendor/assets/js/entries/plugins/foundation.util.timer.js +0 -5
  71. data/vendor/assets/js/entries/plugins/foundation.util.touch.js +0 -7
  72. data/vendor/assets/js/entries/plugins/foundation.util.triggers.js +0 -5
  73. data/vendor/assets/js/foundation.abide.js.es6 +0 -587
  74. data/vendor/assets/js/foundation.accordion.js.es6 +0 -329
  75. data/vendor/assets/js/foundation.accordionMenu.js.es6 +0 -328
  76. data/vendor/assets/js/foundation.core.js.es6 +0 -337
  77. data/vendor/assets/js/foundation.drilldown.js.es6 +0 -536
  78. data/vendor/assets/js/foundation.dropdown.js.es6 +0 -394
  79. data/vendor/assets/js/foundation.dropdownMenu.js.es6 +0 -458
  80. data/vendor/assets/js/foundation.equalizer.js.es6 +0 -318
  81. data/vendor/assets/js/foundation.interchange.js.es6 +0 -210
  82. data/vendor/assets/js/foundation.magellan.js.es6 +0 -257
  83. data/vendor/assets/js/foundation.offcanvas.js.es6 +0 -546
  84. data/vendor/assets/js/foundation.orbit.js.es6 +0 -531
  85. data/vendor/assets/js/foundation.plugin.js.es6 +0 -54
  86. data/vendor/assets/js/foundation.positionable.js.es6 +0 -206
  87. data/vendor/assets/js/foundation.responsiveAccordionTabs.js.es6 +0 -243
  88. data/vendor/assets/js/foundation.responsiveMenu.js.es6 +0 -155
  89. data/vendor/assets/js/foundation.responsiveToggle.js.es6 +0 -156
  90. data/vendor/assets/js/foundation.reveal.js.es6 +0 -585
  91. data/vendor/assets/js/foundation.slider.js.es6 +0 -712
  92. data/vendor/assets/js/foundation.smoothScroll.js.es6 +0 -135
  93. data/vendor/assets/js/foundation.sticky.js.es6 +0 -507
  94. data/vendor/assets/js/foundation.tabs.js.es6 +0 -498
  95. data/vendor/assets/js/foundation.toggler.js.es6 +0 -150
  96. data/vendor/assets/js/foundation.tooltip.js.es6 +0 -462
  97. data/vendor/assets/js/foundation.util.core.js.es6 +0 -52
  98. data/vendor/assets/js/foundation.util.imageLoader.js.es6 +0 -45
  99. data/vendor/assets/js/foundation.util.keyboard.js.es6 +0 -162
  100. data/vendor/assets/js/foundation.util.mediaQuery.js.es6 +0 -234
  101. data/vendor/assets/js/foundation.util.motion.js.es6 +0 -104
  102. data/vendor/assets/js/foundation.util.nest.js.es6 +0 -67
  103. data/vendor/assets/js/foundation.util.timer.js.es6 +0 -48
  104. data/vendor/assets/js/foundation.util.touch.js.es6 +0 -149
  105. data/vendor/assets/js/foundation.util.triggers.js.es6 +0 -268
@@ -1,394 +0,0 @@
1
- 'use strict';
2
-
3
- import $ from 'jquery';
4
- import { Keyboard } from './foundation.util.keyboard';
5
- import { GetYoDigits } from './foundation.util.core';
6
- import { Positionable } from './foundation.positionable';
7
-
8
- import { Triggers } from './foundation.util.triggers';
9
-
10
-
11
- /**
12
- * Dropdown module.
13
- * @module foundation.dropdown
14
- * @requires foundation.util.keyboard
15
- * @requires foundation.util.box
16
- * @requires foundation.util.triggers
17
- */
18
- class Dropdown extends Positionable {
19
- /**
20
- * Creates a new instance of a dropdown.
21
- * @class
22
- * @name Dropdown
23
- * @param {jQuery} element - jQuery object to make into a dropdown.
24
- * Object should be of the dropdown panel, rather than its anchor.
25
- * @param {Object} options - Overrides to the default plugin settings.
26
- */
27
- _setup(element, options) {
28
- this.$element = element;
29
- this.options = $.extend({}, Dropdown.defaults, this.$element.data(), options);
30
- this.className = 'Dropdown'; // ie9 back compat
31
-
32
- // Triggers init is idempotent, just need to make sure it is initialized
33
- Triggers.init($);
34
-
35
- this._init();
36
-
37
- Keyboard.register('Dropdown', {
38
- 'ENTER': 'open',
39
- 'SPACE': 'open',
40
- 'ESCAPE': 'close'
41
- });
42
- }
43
-
44
- /**
45
- * Initializes the plugin by setting/checking options and attributes, adding helper variables, and saving the anchor.
46
- * @function
47
- * @private
48
- */
49
- _init() {
50
- var $id = this.$element.attr('id');
51
-
52
- this.$anchor = $(`[data-toggle="${$id}"]`).length ? $(`[data-toggle="${$id}"]`) : $(`[data-open="${$id}"]`);
53
- this.$anchor.attr({
54
- 'aria-controls': $id,
55
- 'data-is-focus': false,
56
- 'data-yeti-box': $id,
57
- 'aria-haspopup': true,
58
- 'aria-expanded': false
59
-
60
- });
61
-
62
- if(this.options.parentClass){
63
- this.$parent = this.$element.parents('.' + this.options.parentClass);
64
- }else{
65
- this.$parent = null;
66
- }
67
-
68
- this.$element.attr({
69
- 'aria-hidden': 'true',
70
- 'data-yeti-box': $id,
71
- 'data-resize': $id,
72
- 'aria-labelledby': this.$anchor[0].id || GetYoDigits(6, 'dd-anchor')
73
- });
74
- super._init();
75
- this._events();
76
- }
77
-
78
- _getDefaultPosition() {
79
- // handle legacy classnames
80
- var position = this.$element[0].className.match(/(top|left|right|bottom)/g);
81
- if(position) {
82
- return position[0];
83
- } else {
84
- return 'bottom'
85
- }
86
- }
87
-
88
- _getDefaultAlignment() {
89
- // handle legacy float approach
90
- var horizontalPosition = /float-(\S+)/.exec(this.$anchor[0].className);
91
- if(horizontalPosition) {
92
- return horizontalPosition[1];
93
- }
94
-
95
- return super._getDefaultAlignment();
96
- }
97
-
98
-
99
-
100
- /**
101
- * Sets the position and orientation of the dropdown pane, checks for collisions if allow-overlap is not true.
102
- * Recursively calls itself if a collision is detected, with a new position class.
103
- * @function
104
- * @private
105
- */
106
- _setPosition() {
107
- super._setPosition(this.$anchor, this.$element, this.$parent);
108
- }
109
-
110
- /**
111
- * Adds event listeners to the element utilizing the triggers utility library.
112
- * @function
113
- * @private
114
- */
115
- _events() {
116
- var _this = this;
117
- this.$element.on({
118
- 'open.zf.trigger': this.open.bind(this),
119
- 'close.zf.trigger': this.close.bind(this),
120
- 'toggle.zf.trigger': this.toggle.bind(this),
121
- 'resizeme.zf.trigger': this._setPosition.bind(this)
122
- });
123
-
124
- if(this.options.hover){
125
- this.$anchor.off('mouseenter.zf.dropdown mouseleave.zf.dropdown')
126
- .on('mouseenter.zf.dropdown', function(){
127
- var bodyData = $('body').data();
128
- if(typeof(bodyData.whatinput) === 'undefined' || bodyData.whatinput === 'mouse') {
129
- clearTimeout(_this.timeout);
130
- _this.timeout = setTimeout(function(){
131
- _this.open();
132
- _this.$anchor.data('hover', true);
133
- }, _this.options.hoverDelay);
134
- }
135
- }).on('mouseleave.zf.dropdown', function(){
136
- clearTimeout(_this.timeout);
137
- _this.timeout = setTimeout(function(){
138
- _this.close();
139
- _this.$anchor.data('hover', false);
140
- }, _this.options.hoverDelay);
141
- });
142
- if(this.options.hoverPane){
143
- this.$element.off('mouseenter.zf.dropdown mouseleave.zf.dropdown')
144
- .on('mouseenter.zf.dropdown', function(){
145
- clearTimeout(_this.timeout);
146
- }).on('mouseleave.zf.dropdown', function(){
147
- clearTimeout(_this.timeout);
148
- _this.timeout = setTimeout(function(){
149
- _this.close();
150
- _this.$anchor.data('hover', false);
151
- }, _this.options.hoverDelay);
152
- });
153
- }
154
- }
155
- this.$anchor.add(this.$element).on('keydown.zf.dropdown', function(e) {
156
-
157
- var $target = $(this),
158
- visibleFocusableElements = Keyboard.findFocusable(_this.$element);
159
-
160
- Keyboard.handleKey(e, 'Dropdown', {
161
- open: function() {
162
- if ($target.is(_this.$anchor)) {
163
- _this.open();
164
- _this.$element.attr('tabindex', -1).focus();
165
- e.preventDefault();
166
- }
167
- },
168
- close: function() {
169
- _this.close();
170
- _this.$anchor.focus();
171
- }
172
- });
173
- });
174
- }
175
-
176
- /**
177
- * Adds an event handler to the body to close any dropdowns on a click.
178
- * @function
179
- * @private
180
- */
181
- _addBodyHandler() {
182
- var $body = $(document.body).not(this.$element),
183
- _this = this;
184
- $body.off('click.zf.dropdown')
185
- .on('click.zf.dropdown', function(e){
186
- if(_this.$anchor.is(e.target) || _this.$anchor.find(e.target).length) {
187
- return;
188
- }
189
- if(_this.$element.find(e.target).length) {
190
- return;
191
- }
192
- _this.close();
193
- $body.off('click.zf.dropdown');
194
- });
195
- }
196
-
197
- /**
198
- * Opens the dropdown pane, and fires a bubbling event to close other dropdowns.
199
- * @function
200
- * @fires Dropdown#closeme
201
- * @fires Dropdown#show
202
- */
203
- open() {
204
- // var _this = this;
205
- /**
206
- * Fires to close other open dropdowns, typically when dropdown is opening
207
- * @event Dropdown#closeme
208
- */
209
- this.$element.trigger('closeme.zf.dropdown', this.$element.attr('id'));
210
- this.$anchor.addClass('hover')
211
- .attr({'aria-expanded': true});
212
- // this.$element/*.show()*/;
213
-
214
- this.$element.addClass('is-opening');
215
- this._setPosition();
216
- this.$element.removeClass('is-opening').addClass('is-open')
217
- .attr({'aria-hidden': false});
218
-
219
- if(this.options.autoFocus){
220
- var $focusable = Keyboard.findFocusable(this.$element);
221
- if($focusable.length){
222
- $focusable.eq(0).focus();
223
- }
224
- }
225
-
226
- if(this.options.closeOnClick){ this._addBodyHandler(); }
227
-
228
- if (this.options.trapFocus) {
229
- Keyboard.trapFocus(this.$element);
230
- }
231
-
232
- /**
233
- * Fires once the dropdown is visible.
234
- * @event Dropdown#show
235
- */
236
- this.$element.trigger('show.zf.dropdown', [this.$element]);
237
- }
238
-
239
- /**
240
- * Closes the open dropdown pane.
241
- * @function
242
- * @fires Dropdown#hide
243
- */
244
- close() {
245
- if(!this.$element.hasClass('is-open')){
246
- return false;
247
- }
248
- this.$element.removeClass('is-open')
249
- .attr({'aria-hidden': true});
250
-
251
- this.$anchor.removeClass('hover')
252
- .attr('aria-expanded', false);
253
-
254
- /**
255
- * Fires once the dropdown is no longer visible.
256
- * @event Dropdown#hide
257
- */
258
- this.$element.trigger('hide.zf.dropdown', [this.$element]);
259
-
260
- if (this.options.trapFocus) {
261
- Keyboard.releaseFocus(this.$element);
262
- }
263
- }
264
-
265
- /**
266
- * Toggles the dropdown pane's visibility.
267
- * @function
268
- */
269
- toggle() {
270
- if(this.$element.hasClass('is-open')){
271
- if(this.$anchor.data('hover')) return;
272
- this.close();
273
- }else{
274
- this.open();
275
- }
276
- }
277
-
278
- /**
279
- * Destroys the dropdown.
280
- * @function
281
- */
282
- _destroy() {
283
- this.$element.off('.zf.trigger').hide();
284
- this.$anchor.off('.zf.dropdown');
285
- $(document.body).off('click.zf.dropdown');
286
-
287
- }
288
- }
289
-
290
- Dropdown.defaults = {
291
- /**
292
- * Class that designates bounding container of Dropdown (default: window)
293
- * @option
294
- * @type {?string}
295
- * @default null
296
- */
297
- parentClass: null,
298
- /**
299
- * Amount of time to delay opening a submenu on hover event.
300
- * @option
301
- * @type {number}
302
- * @default 250
303
- */
304
- hoverDelay: 250,
305
- /**
306
- * Allow submenus to open on hover events
307
- * @option
308
- * @type {boolean}
309
- * @default false
310
- */
311
- hover: false,
312
- /**
313
- * Don't close dropdown when hovering over dropdown pane
314
- * @option
315
- * @type {boolean}
316
- * @default false
317
- */
318
- hoverPane: false,
319
- /**
320
- * Number of pixels between the dropdown pane and the triggering element on open.
321
- * @option
322
- * @type {number}
323
- * @default 0
324
- */
325
- vOffset: 0,
326
- /**
327
- * Number of pixels between the dropdown pane and the triggering element on open.
328
- * @option
329
- * @type {number}
330
- * @default 0
331
- */
332
- hOffset: 0,
333
- /**
334
- * DEPRECATED: Class applied to adjust open position.
335
- * @option
336
- * @type {string}
337
- * @default ''
338
- */
339
- positionClass: '',
340
-
341
- /**
342
- * Position of dropdown. Can be left, right, bottom, top, or auto.
343
- * @option
344
- * @type {string}
345
- * @default 'auto'
346
- */
347
- position: 'auto',
348
- /**
349
- * Alignment of dropdown relative to anchor. Can be left, right, bottom, top, center, or auto.
350
- * @option
351
- * @type {string}
352
- * @default 'auto'
353
- */
354
- alignment: 'auto',
355
- /**
356
- * Allow overlap of container/window. If false, dropdown will first try to position as defined by data-position and data-alignment, but reposition if it would cause an overflow.
357
- * @option
358
- * @type {boolean}
359
- * @default false
360
- */
361
- allowOverlap: false,
362
- /**
363
- * Allow overlap of only the bottom of the container. This is the most common
364
- * behavior for dropdowns, allowing the dropdown to extend the bottom of the
365
- * screen but not otherwise influence or break out of the container.
366
- * @option
367
- * @type {boolean}
368
- * @default true
369
- */
370
- allowBottomOverlap: true,
371
- /**
372
- * Allow the plugin to trap focus to the dropdown pane if opened with keyboard commands.
373
- * @option
374
- * @type {boolean}
375
- * @default false
376
- */
377
- trapFocus: false,
378
- /**
379
- * Allow the plugin to set focus to the first focusable element within the pane, regardless of method of opening.
380
- * @option
381
- * @type {boolean}
382
- * @default false
383
- */
384
- autoFocus: false,
385
- /**
386
- * Allows a click on the body to close the dropdown.
387
- * @option
388
- * @type {boolean}
389
- * @default false
390
- */
391
- closeOnClick: false
392
- }
393
-
394
- export {Dropdown};
@@ -1,458 +0,0 @@
1
- 'use strict';
2
-
3
- import $ from 'jquery';
4
- import { Keyboard } from './foundation.util.keyboard';
5
- import { Nest } from './foundation.util.nest';
6
- import { Box } from './foundation.util.box';
7
- import { rtl as Rtl } from './foundation.util.core';
8
- import { Plugin } from './foundation.plugin';
9
-
10
-
11
- /**
12
- * DropdownMenu module.
13
- * @module foundation.dropdown-menu
14
- * @requires foundation.util.keyboard
15
- * @requires foundation.util.box
16
- * @requires foundation.util.nest
17
- */
18
-
19
- class DropdownMenu extends Plugin {
20
- /**
21
- * Creates a new instance of DropdownMenu.
22
- * @class
23
- * @name DropdownMenu
24
- * @fires DropdownMenu#init
25
- * @param {jQuery} element - jQuery object to make into a dropdown menu.
26
- * @param {Object} options - Overrides to the default plugin settings.
27
- */
28
- _setup(element, options) {
29
- this.$element = element;
30
- this.options = $.extend({}, DropdownMenu.defaults, this.$element.data(), options);
31
- this.className = 'DropdownMenu'; // ie9 back compat
32
-
33
- Nest.Feather(this.$element, 'dropdown');
34
- this._init();
35
-
36
- Keyboard.register('DropdownMenu', {
37
- 'ENTER': 'open',
38
- 'SPACE': 'open',
39
- 'ARROW_RIGHT': 'next',
40
- 'ARROW_UP': 'up',
41
- 'ARROW_DOWN': 'down',
42
- 'ARROW_LEFT': 'previous',
43
- 'ESCAPE': 'close'
44
- });
45
- }
46
-
47
- /**
48
- * Initializes the plugin, and calls _prepareMenu
49
- * @private
50
- * @function
51
- */
52
- _init() {
53
- var subs = this.$element.find('li.is-dropdown-submenu-parent');
54
- this.$element.children('.is-dropdown-submenu-parent').children('.is-dropdown-submenu').addClass('first-sub');
55
-
56
- this.$menuItems = this.$element.find('[role="menuitem"]');
57
- this.$tabs = this.$element.children('[role="menuitem"]');
58
- this.$tabs.find('ul.is-dropdown-submenu').addClass(this.options.verticalClass);
59
-
60
- if (this.options.alignment === 'auto') {
61
- if (this.$element.hasClass(this.options.rightClass) || Rtl() || this.$element.parents('.top-bar-right').is('*')) {
62
- this.options.alignment = 'right';
63
- subs.addClass('opens-left');
64
- } else {
65
- this.options.alignment = 'left';
66
- subs.addClass('opens-right');
67
- }
68
- } else {
69
- if (this.options.alignment === 'right') {
70
- subs.addClass('opens-left');
71
- } else {
72
- subs.addClass('opens-right');
73
- }
74
- }
75
- this.changed = false;
76
- this._events();
77
- };
78
-
79
- _isVertical() {
80
- return this.$tabs.css('display') === 'block' || this.$element.css('flex-direction') === 'column';
81
- }
82
-
83
- _isRtl() {
84
- return this.$element.hasClass('align-right') || (Rtl() && !this.$element.hasClass('align-left'));
85
- }
86
-
87
- /**
88
- * Adds event listeners to elements within the menu
89
- * @private
90
- * @function
91
- */
92
- _events() {
93
- var _this = this,
94
- hasTouch = 'ontouchstart' in window || (typeof window.ontouchstart !== 'undefined'),
95
- parClass = 'is-dropdown-submenu-parent';
96
-
97
- // used for onClick and in the keyboard handlers
98
- var handleClickFn = function(e) {
99
- var $elem = $(e.target).parentsUntil('ul', `.${parClass}`),
100
- hasSub = $elem.hasClass(parClass),
101
- hasClicked = $elem.attr('data-is-click') === 'true',
102
- $sub = $elem.children('.is-dropdown-submenu');
103
-
104
- if (hasSub) {
105
- if (hasClicked) {
106
- if (!_this.options.closeOnClick || (!_this.options.clickOpen && !hasTouch) || (_this.options.forceFollow && hasTouch)) { return; }
107
- else {
108
- e.stopImmediatePropagation();
109
- e.preventDefault();
110
- _this._hide($elem);
111
- }
112
- } else {
113
- e.preventDefault();
114
- e.stopImmediatePropagation();
115
- _this._show($sub);
116
- $elem.add($elem.parentsUntil(_this.$element, `.${parClass}`)).attr('data-is-click', true);
117
- }
118
- }
119
- };
120
-
121
- if (this.options.clickOpen || hasTouch) {
122
- this.$menuItems.on('click.zf.dropdownmenu touchstart.zf.dropdownmenu', handleClickFn);
123
- }
124
-
125
- // Handle Leaf element Clicks
126
- if(_this.options.closeOnClickInside){
127
- this.$menuItems.on('click.zf.dropdownmenu', function(e) {
128
- var $elem = $(this),
129
- hasSub = $elem.hasClass(parClass);
130
- if(!hasSub){
131
- _this._hide();
132
- }
133
- });
134
- }
135
-
136
- if (!this.options.disableHover) {
137
- this.$menuItems.on('mouseenter.zf.dropdownmenu', function(e) {
138
- var $elem = $(this),
139
- hasSub = $elem.hasClass(parClass);
140
-
141
- if (hasSub) {
142
- clearTimeout($elem.data('_delay'));
143
- $elem.data('_delay', setTimeout(function() {
144
- _this._show($elem.children('.is-dropdown-submenu'));
145
- }, _this.options.hoverDelay));
146
- }
147
- }).on('mouseleave.zf.dropdownmenu', function(e) {
148
- var $elem = $(this),
149
- hasSub = $elem.hasClass(parClass);
150
- if (hasSub && _this.options.autoclose) {
151
- if ($elem.attr('data-is-click') === 'true' && _this.options.clickOpen) { return false; }
152
-
153
- clearTimeout($elem.data('_delay'));
154
- $elem.data('_delay', setTimeout(function() {
155
- _this._hide($elem);
156
- }, _this.options.closingTime));
157
- }
158
- });
159
- }
160
- this.$menuItems.on('keydown.zf.dropdownmenu', function(e) {
161
- var $element = $(e.target).parentsUntil('ul', '[role="menuitem"]'),
162
- isTab = _this.$tabs.index($element) > -1,
163
- $elements = isTab ? _this.$tabs : $element.siblings('li').add($element),
164
- $prevElement,
165
- $nextElement;
166
-
167
- $elements.each(function(i) {
168
- if ($(this).is($element)) {
169
- $prevElement = $elements.eq(i-1);
170
- $nextElement = $elements.eq(i+1);
171
- return;
172
- }
173
- });
174
-
175
- var nextSibling = function() {
176
- if (!$element.is(':last-child')) {
177
- $nextElement.children('a:first').focus();
178
- e.preventDefault();
179
- }
180
- }, prevSibling = function() {
181
- $prevElement.children('a:first').focus();
182
- e.preventDefault();
183
- }, openSub = function() {
184
- var $sub = $element.children('ul.is-dropdown-submenu');
185
- if ($sub.length) {
186
- _this._show($sub);
187
- $element.find('li > a:first').focus();
188
- e.preventDefault();
189
- } else { return; }
190
- }, closeSub = function() {
191
- //if ($element.is(':first-child')) {
192
- var close = $element.parent('ul').parent('li');
193
- close.children('a:first').focus();
194
- _this._hide(close);
195
- e.preventDefault();
196
- //}
197
- };
198
- var functions = {
199
- open: openSub,
200
- close: function() {
201
- _this._hide(_this.$element);
202
- _this.$menuItems.eq(0).children('a').focus(); // focus to first element
203
- e.preventDefault();
204
- },
205
- handled: function() {
206
- e.stopImmediatePropagation();
207
- }
208
- };
209
-
210
- if (isTab) {
211
- if (_this._isVertical()) { // vertical menu
212
- if (_this._isRtl()) { // right aligned
213
- $.extend(functions, {
214
- down: nextSibling,
215
- up: prevSibling,
216
- next: closeSub,
217
- previous: openSub
218
- });
219
- } else { // left aligned
220
- $.extend(functions, {
221
- down: nextSibling,
222
- up: prevSibling,
223
- next: openSub,
224
- previous: closeSub
225
- });
226
- }
227
- } else { // horizontal menu
228
- if (_this._isRtl()) { // right aligned
229
- $.extend(functions, {
230
- next: prevSibling,
231
- previous: nextSibling,
232
- down: openSub,
233
- up: closeSub
234
- });
235
- } else { // left aligned
236
- $.extend(functions, {
237
- next: nextSibling,
238
- previous: prevSibling,
239
- down: openSub,
240
- up: closeSub
241
- });
242
- }
243
- }
244
- } else { // not tabs -> one sub
245
- if (_this._isRtl()) { // right aligned
246
- $.extend(functions, {
247
- next: closeSub,
248
- previous: openSub,
249
- down: nextSibling,
250
- up: prevSibling
251
- });
252
- } else { // left aligned
253
- $.extend(functions, {
254
- next: openSub,
255
- previous: closeSub,
256
- down: nextSibling,
257
- up: prevSibling
258
- });
259
- }
260
- }
261
- Keyboard.handleKey(e, 'DropdownMenu', functions);
262
-
263
- });
264
- }
265
-
266
- /**
267
- * Adds an event handler to the body to close any dropdowns on a click.
268
- * @function
269
- * @private
270
- */
271
- _addBodyHandler() {
272
- var $body = $(document.body),
273
- _this = this;
274
- $body.off('mouseup.zf.dropdownmenu touchend.zf.dropdownmenu')
275
- .on('mouseup.zf.dropdownmenu touchend.zf.dropdownmenu', function(e) {
276
- var $link = _this.$element.find(e.target);
277
- if ($link.length) { return; }
278
-
279
- _this._hide();
280
- $body.off('mouseup.zf.dropdownmenu touchend.zf.dropdownmenu');
281
- });
282
- }
283
-
284
- /**
285
- * Opens a dropdown pane, and checks for collisions first.
286
- * @param {jQuery} $sub - ul element that is a submenu to show
287
- * @function
288
- * @private
289
- * @fires DropdownMenu#show
290
- */
291
- _show($sub) {
292
- var idx = this.$tabs.index(this.$tabs.filter(function(i, el) {
293
- return $(el).find($sub).length > 0;
294
- }));
295
- var $sibs = $sub.parent('li.is-dropdown-submenu-parent').siblings('li.is-dropdown-submenu-parent');
296
- this._hide($sibs, idx);
297
- $sub.css('visibility', 'hidden').addClass('js-dropdown-active')
298
- .parent('li.is-dropdown-submenu-parent').addClass('is-active');
299
- var clear = Box.ImNotTouchingYou($sub, null, true);
300
- if (!clear) {
301
- var oldClass = this.options.alignment === 'left' ? '-right' : '-left',
302
- $parentLi = $sub.parent('.is-dropdown-submenu-parent');
303
- $parentLi.removeClass(`opens${oldClass}`).addClass(`opens-${this.options.alignment}`);
304
- clear = Box.ImNotTouchingYou($sub, null, true);
305
- if (!clear) {
306
- $parentLi.removeClass(`opens-${this.options.alignment}`).addClass('opens-inner');
307
- }
308
- this.changed = true;
309
- }
310
- $sub.css('visibility', '');
311
- if (this.options.closeOnClick) { this._addBodyHandler(); }
312
- /**
313
- * Fires when the new dropdown pane is visible.
314
- * @event DropdownMenu#show
315
- */
316
- this.$element.trigger('show.zf.dropdownmenu', [$sub]);
317
- }
318
-
319
- /**
320
- * Hides a single, currently open dropdown pane, if passed a parameter, otherwise, hides everything.
321
- * @function
322
- * @param {jQuery} $elem - element with a submenu to hide
323
- * @param {Number} idx - index of the $tabs collection to hide
324
- * @private
325
- */
326
- _hide($elem, idx) {
327
- var $toClose;
328
- if ($elem && $elem.length) {
329
- $toClose = $elem;
330
- } else if (idx !== undefined) {
331
- $toClose = this.$tabs.not(function(i, el) {
332
- return i === idx;
333
- });
334
- }
335
- else {
336
- $toClose = this.$element;
337
- }
338
- var somethingToClose = $toClose.hasClass('is-active') || $toClose.find('.is-active').length > 0;
339
-
340
- if (somethingToClose) {
341
- $toClose.find('li.is-active').add($toClose).attr({
342
- 'data-is-click': false
343
- }).removeClass('is-active');
344
-
345
- $toClose.find('ul.js-dropdown-active').removeClass('js-dropdown-active');
346
-
347
- if (this.changed || $toClose.find('opens-inner').length) {
348
- var oldClass = this.options.alignment === 'left' ? 'right' : 'left';
349
- $toClose.find('li.is-dropdown-submenu-parent').add($toClose)
350
- .removeClass(`opens-inner opens-${this.options.alignment}`)
351
- .addClass(`opens-${oldClass}`);
352
- this.changed = false;
353
- }
354
- /**
355
- * Fires when the open menus are closed.
356
- * @event DropdownMenu#hide
357
- */
358
- this.$element.trigger('hide.zf.dropdownmenu', [$toClose]);
359
- }
360
- }
361
-
362
- /**
363
- * Destroys the plugin.
364
- * @function
365
- */
366
- _destroy() {
367
- this.$menuItems.off('.zf.dropdownmenu').removeAttr('data-is-click')
368
- .removeClass('is-right-arrow is-left-arrow is-down-arrow opens-right opens-left opens-inner');
369
- $(document.body).off('.zf.dropdownmenu');
370
- Nest.Burn(this.$element, 'dropdown');
371
- }
372
- }
373
-
374
- /**
375
- * Default settings for plugin
376
- */
377
- DropdownMenu.defaults = {
378
- /**
379
- * Disallows hover events from opening submenus
380
- * @option
381
- * @type {boolean}
382
- * @default false
383
- */
384
- disableHover: false,
385
- /**
386
- * Allow a submenu to automatically close on a mouseleave event, if not clicked open.
387
- * @option
388
- * @type {boolean}
389
- * @default true
390
- */
391
- autoclose: true,
392
- /**
393
- * Amount of time to delay opening a submenu on hover event.
394
- * @option
395
- * @type {number}
396
- * @default 50
397
- */
398
- hoverDelay: 50,
399
- /**
400
- * Allow a submenu to open/remain open on parent click event. Allows cursor to move away from menu.
401
- * @option
402
- * @type {boolean}
403
- * @default false
404
- */
405
- clickOpen: false,
406
- /**
407
- * Amount of time to delay closing a submenu on a mouseleave event.
408
- * @option
409
- * @type {number}
410
- * @default 500
411
- */
412
-
413
- closingTime: 500,
414
- /**
415
- * Position of the menu relative to what direction the submenus should open. Handled by JS. Can be `'auto'`, `'left'` or `'right'`.
416
- * @option
417
- * @type {string}
418
- * @default 'auto'
419
- */
420
- alignment: 'auto',
421
- /**
422
- * Allow clicks on the body to close any open submenus.
423
- * @option
424
- * @type {boolean}
425
- * @default true
426
- */
427
- closeOnClick: true,
428
- /**
429
- * Allow clicks on leaf anchor links to close any open submenus.
430
- * @option
431
- * @type {boolean}
432
- * @default true
433
- */
434
- closeOnClickInside: true,
435
- /**
436
- * Class applied to vertical oriented menus, Foundation default is `vertical`. Update this if using your own class.
437
- * @option
438
- * @type {string}
439
- * @default 'vertical'
440
- */
441
- verticalClass: 'vertical',
442
- /**
443
- * Class applied to right-side oriented menus, Foundation default is `align-right`. Update this if using your own class.
444
- * @option
445
- * @type {string}
446
- * @default 'align-right'
447
- */
448
- rightClass: 'align-right',
449
- /**
450
- * Boolean to force overide the clicking of links to perform default action, on second touch event for mobile.
451
- * @option
452
- * @type {boolean}
453
- * @default true
454
- */
455
- forceFollow: true
456
- };
457
-
458
- export {DropdownMenu};