foundation-rails 6.1.2.0 → 6.2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -6
  3. data/README.md +1 -1
  4. data/Rakefile +5 -1
  5. data/bower.json +3 -3
  6. data/foundation-rails.gemspec +1 -0
  7. data/lib/foundation-rails.rb +1 -0
  8. data/lib/foundation/rails/version.rb +1 -1
  9. data/lib/generators/foundation/templates/foundation_and_overrides.scss +2 -2
  10. data/vendor/assets/js/foundation.abide.js.es6 +462 -0
  11. data/vendor/assets/js/{foundation.accordion.js → foundation.accordion.js.es6} +55 -47
  12. data/vendor/assets/js/{foundation.accordionMenu.js → foundation.accordionMenu.js.es6} +46 -35
  13. data/vendor/assets/js/{foundation.core.js → foundation.core.js.es6} +10 -8
  14. data/vendor/assets/js/{foundation.drilldown.js → foundation.drilldown.js.es6} +75 -49
  15. data/vendor/assets/js/{foundation.dropdown.js → foundation.dropdown.js.es6} +100 -88
  16. data/vendor/assets/js/{foundation.dropdownMenu.js → foundation.dropdownMenu.js.es6} +134 -128
  17. data/vendor/assets/js/{foundation.equalizer.js → foundation.equalizer.js.es6} +72 -61
  18. data/vendor/assets/js/{foundation.interchange.js → foundation.interchange.js.es6} +44 -45
  19. data/vendor/assets/js/{foundation.js → foundation.js.es6} +0 -0
  20. data/vendor/assets/js/{foundation.magellan.js → foundation.magellan.js.es6} +80 -83
  21. data/vendor/assets/js/foundation.offcanvas.js.es6 +395 -0
  22. data/vendor/assets/js/foundation.orbit.js.es6 +445 -0
  23. data/vendor/assets/js/{foundation.responsiveMenu.js → foundation.responsiveMenu.js.es6} +37 -31
  24. data/vendor/assets/js/foundation.responsiveToggle.js.es6 +112 -0
  25. data/vendor/assets/js/foundation.reveal.js.es6 +544 -0
  26. data/vendor/assets/js/{foundation.slider.js → foundation.slider.js.es6} +235 -184
  27. data/vendor/assets/js/{foundation.sticky.js → foundation.sticky.js.es6} +177 -166
  28. data/vendor/assets/js/{foundation.tabs.js → foundation.tabs.js.es6} +138 -118
  29. data/vendor/assets/js/{foundation.toggler.js → foundation.toggler.js.es6} +34 -37
  30. data/vendor/assets/js/{foundation.tooltip.js → foundation.tooltip.js.es6} +162 -153
  31. data/vendor/assets/js/foundation.util.box.js.es6 +183 -0
  32. data/vendor/assets/js/{foundation.util.keyboard.js → foundation.util.keyboard.js.es6} +54 -54
  33. data/vendor/assets/js/{foundation.util.mediaQuery.js → foundation.util.mediaQuery.js.es6} +46 -46
  34. data/vendor/assets/js/{foundation.util.motion.js → foundation.util.motion.js.es6} +58 -48
  35. data/vendor/assets/js/foundation.util.nest.js.es6 +76 -0
  36. data/vendor/assets/js/foundation.util.timerAndImageLoader.js.es6 +86 -0
  37. data/vendor/assets/js/{foundation.util.touch.js → foundation.util.touch.js.es6} +2 -2
  38. data/vendor/assets/js/foundation.util.triggers.js.es6 +239 -0
  39. data/vendor/assets/scss/_global.scss +28 -27
  40. data/vendor/assets/scss/components/_badge.scss +1 -1
  41. data/vendor/assets/scss/components/_button-group.scss +77 -26
  42. data/vendor/assets/scss/components/_button.scss +8 -8
  43. data/vendor/assets/scss/components/_callout.scss +2 -2
  44. data/vendor/assets/scss/components/_drilldown.scss +4 -0
  45. data/vendor/assets/scss/components/_dropdown-menu.scss +104 -54
  46. data/vendor/assets/scss/components/_flex.scss +28 -0
  47. data/vendor/assets/scss/components/_label.scss +1 -1
  48. data/vendor/assets/scss/components/_media-object.scss +37 -7
  49. data/vendor/assets/scss/components/_menu-icon.scss +9 -0
  50. data/vendor/assets/scss/components/_menu.scss +127 -29
  51. data/vendor/assets/scss/components/_off-canvas.scss +1 -0
  52. data/vendor/assets/scss/components/_pagination.scss +3 -3
  53. data/vendor/assets/scss/components/_progress-bar.scss +1 -25
  54. data/vendor/assets/scss/components/_reveal.scss +12 -6
  55. data/vendor/assets/scss/components/_slider.scss +3 -35
  56. data/vendor/assets/scss/components/_table.scss +8 -0
  57. data/vendor/assets/scss/components/_tabs.scss +5 -10
  58. data/vendor/assets/scss/components/_title-bar.scss +27 -10
  59. data/vendor/assets/scss/components/_tooltip.scss +0 -4
  60. data/vendor/assets/scss/components/_top-bar.scss +93 -21
  61. data/vendor/assets/scss/components/_visibility.scss +1 -1
  62. data/vendor/assets/scss/forms/_checkbox.scss +1 -1
  63. data/vendor/assets/scss/forms/_error.scss +7 -5
  64. data/vendor/assets/scss/forms/_forms.scss +3 -0
  65. data/vendor/assets/scss/forms/_help-text.scss +1 -1
  66. data/vendor/assets/scss/forms/_input-group.scss +44 -9
  67. data/vendor/assets/scss/forms/_meter.scss +109 -0
  68. data/vendor/assets/scss/forms/_progress.scss +85 -0
  69. data/vendor/assets/scss/forms/_range.scss +144 -0
  70. data/vendor/assets/scss/forms/_select.scss +1 -1
  71. data/vendor/assets/scss/forms/_text.scss +10 -1
  72. data/vendor/assets/scss/foundation.scss +16 -5
  73. data/vendor/assets/scss/grid/_classes.scss +5 -18
  74. data/vendor/assets/scss/grid/_column.scss +13 -11
  75. data/vendor/assets/scss/grid/_flex-grid.scss +54 -80
  76. data/vendor/assets/scss/grid/_grid.scss +22 -10
  77. data/vendor/assets/scss/grid/_layout.scss +18 -0
  78. data/vendor/assets/scss/grid/_row.scss +11 -15
  79. data/vendor/assets/scss/motion-ui/_classes.scss +10 -3
  80. data/vendor/assets/scss/motion-ui/effects/_fade.scss +4 -1
  81. data/vendor/assets/scss/motion-ui/effects/_zoom.scss +1 -1
  82. data/vendor/assets/scss/motion-ui/transitions/_slide.scss +1 -1
  83. data/vendor/assets/scss/motion-ui/util/_transition.scss +1 -1
  84. data/vendor/assets/scss/settings/_settings.scss +64 -47
  85. data/vendor/assets/scss/typography/_base.scss +4 -0
  86. data/vendor/assets/scss/typography/_print.scss +9 -5
  87. data/vendor/assets/scss/util/_breakpoint.scss +31 -25
  88. data/vendor/assets/scss/util/_color.scss +19 -0
  89. data/vendor/assets/scss/util/_flex.scss +68 -0
  90. data/vendor/assets/scss/util/_mixins.scss +13 -7
  91. data/vendor/assets/scss/util/_util.scss +1 -5
  92. data/vendor/assets/scss/util/_value.scss +9 -28
  93. metadata +51 -31
  94. data/vendor/assets/js/foundation.abide.js +0 -418
  95. data/vendor/assets/js/foundation.offcanvas.js +0 -376
  96. data/vendor/assets/js/foundation.orbit.js +0 -421
  97. data/vendor/assets/js/foundation.responsiveToggle.js +0 -106
  98. data/vendor/assets/js/foundation.reveal.js +0 -514
  99. data/vendor/assets/js/foundation.util.box.js +0 -169
  100. data/vendor/assets/js/foundation.util.nest.js +0 -63
  101. data/vendor/assets/js/foundation.util.timerAndImageLoader.js +0 -82
  102. data/vendor/assets/js/foundation.util.triggers.js +0 -224
@@ -1,3 +1,7 @@
1
+ 'use strict';
2
+
3
+ !function($) {
4
+
1
5
  /**
2
6
  * Drilldown module.
3
7
  * @module foundation.drilldown
@@ -5,16 +9,15 @@
5
9
  * @requires foundation.util.motion
6
10
  * @requires foundation.util.nest
7
11
  */
8
- !function($, Foundation){
9
- 'use strict';
10
12
 
13
+ class Drilldown {
11
14
  /**
12
15
  * Creates a new instance of a drilldown menu.
13
16
  * @class
14
17
  * @param {jQuery} element - jQuery object to make into an accordion menu.
15
18
  * @param {Object} options - Overrides to the default plugin settings.
16
19
  */
17
- function Drilldown(element, options){
20
+ constructor(element, options) {
18
21
  this.$element = element;
19
22
  this.options = $.extend({}, Drilldown.defaults, this.$element.data(), options);
20
23
 
@@ -35,32 +38,12 @@
35
38
  'SHIFT_TAB': 'up'
36
39
  });
37
40
  }
38
- Drilldown.defaults = {
39
- /**
40
- * Markup used for JS generated back button. Prepended to submenu lists and deleted on `destroy` method, 'js-drilldown-back' class required. Remove the backslash (`\`) if copy and pasting.
41
- * @option
42
- * @example '<\li><\a>Back<\/a><\/li>'
43
- */
44
- backButton: '<li class="js-drilldown-back"><a>Back</a></li>',
45
- /**
46
- * Markup used to wrap drilldown menu. Use a class name for independent styling; the JS applied class: `is-drilldown` is required. Remove the backslash (`\`) if copy and pasting.
47
- * @option
48
- * @example '<\div class="is-drilldown"><\/div>'
49
- */
50
- wrapper: '<div></div>',
51
- /**
52
- * Allow the menu to return to root list on body click.
53
- * @option
54
- * @example false
55
- */
56
- closeOnClick: false
57
- // holdOpen: false
58
- };
41
+
59
42
  /**
60
43
  * Initializes the drilldown by creating jQuery collections of elements
61
44
  * @private
62
45
  */
63
- Drilldown.prototype._init = function(){
46
+ _init() {
64
47
  this.$submenuAnchors = this.$element.find('li.is-drilldown-submenu-parent');
65
48
  this.$submenus = this.$submenuAnchors.children('[data-submenu]');
66
49
  this.$menuItems = this.$element.find('li').not('.js-drilldown-back').attr('role', 'menuitem');
@@ -68,7 +51,8 @@
68
51
  this._prepareMenu();
69
52
 
70
53
  this._keyboardEvents();
71
- };
54
+ }
55
+
72
56
  /**
73
57
  * prepares drilldown menu by setting attributes to links and elements
74
58
  * sets a min height to prevent content jumping
@@ -76,7 +60,7 @@
76
60
  * @private
77
61
  * @function
78
62
  */
79
- Drilldown.prototype._prepareMenu = function(){
63
+ _prepareMenu() {
80
64
  var _this = this;
81
65
  // if(!this.options.holdOpen){
82
66
  // this._menuLinkEvents();
@@ -84,6 +68,9 @@
84
68
  this.$submenuAnchors.each(function(){
85
69
  var $sub = $(this);
86
70
  var $link = $sub.find('a:first');
71
+ if(_this.options.parentLink){
72
+ $link.clone().prependTo($sub.children('[data-submenu]')).wrap('<li class="is-submenu-parent-item is-submenu-item is-drilldown-submenu-item" role="menu-item"></li>');
73
+ }
87
74
  $link.data('savedHref', $link.attr('href')).removeAttr('href');
88
75
  $sub.children('[data-submenu]')
89
76
  .attr({
@@ -105,15 +92,15 @@
105
92
  this.$wrapper = $(this.options.wrapper).addClass('is-drilldown').css(this._getMaxDims());
106
93
  this.$element.wrap(this.$wrapper);
107
94
  }
95
+ }
108
96
 
109
- };
110
97
  /**
111
98
  * Adds event handlers to elements in the menu.
112
99
  * @function
113
100
  * @private
114
101
  * @param {jQuery} $elem - the current menu item to add handlers to.
115
102
  */
116
- Drilldown.prototype._events = function($elem){
103
+ _events($elem) {
117
104
  var _this = this;
118
105
 
119
106
  $elem.off('click.zf.drilldown')
@@ -137,12 +124,13 @@
137
124
  });
138
125
  }
139
126
  });
140
- };
127
+ }
128
+
141
129
  /**
142
130
  * Adds keydown event listener to `li`'s in the menu.
143
131
  * @private
144
132
  */
145
- Drilldown.prototype._keyboardEvents = function() {
133
+ _keyboardEvents() {
146
134
  var _this = this;
147
135
  this.$menuItems.add(this.$element.find('.js-drilldown-back')).on('keydown.zf.drilldown', function(e){
148
136
  var $element = $(this),
@@ -199,14 +187,14 @@
199
187
  }
200
188
  });
201
189
  }); // end keyboardAccess
202
- };
190
+ }
203
191
 
204
192
  /**
205
193
  * Closes all open elements, and returns to root menu.
206
194
  * @function
207
195
  * @fires Drilldown#closed
208
196
  */
209
- Drilldown.prototype._hideAll = function(){
197
+ _hideAll() {
210
198
  var $elem = this.$element.find('.is-drilldown-submenu.is-active').addClass('is-closing');
211
199
  $elem.one(Foundation.transitionend($elem), function(e){
212
200
  $elem.removeClass('is-active is-closing');
@@ -216,14 +204,15 @@
216
204
  * @event Drilldown#closed
217
205
  */
218
206
  this.$element.trigger('closed.zf.drilldown');
219
- };
207
+ }
208
+
220
209
  /**
221
210
  * Adds event listener for each `back` button, and closes open menus.
222
211
  * @function
223
212
  * @fires Drilldown#back
224
213
  * @param {jQuery} $elem - the current sub-menu to add `back` event.
225
214
  */
226
- Drilldown.prototype._back = function($elem){
215
+ _back($elem) {
227
216
  var _this = this;
228
217
  $elem.off('click.zf.drilldown');
229
218
  $elem.children('.js-drilldown-back')
@@ -232,13 +221,14 @@
232
221
  // console.log('mouseup on back');
233
222
  _this._hide($elem);
234
223
  });
235
- };
224
+ }
225
+
236
226
  /**
237
227
  * Adds event listener to menu items w/o submenus to close open menus on click.
238
228
  * @function
239
229
  * @private
240
230
  */
241
- Drilldown.prototype._menuLinkEvents = function(){
231
+ _menuLinkEvents() {
242
232
  var _this = this;
243
233
  this.$menuItems.not('.is-drilldown-submenu-parent')
244
234
  .off('click.zf.drilldown')
@@ -248,64 +238,68 @@
248
238
  _this._hideAll();
249
239
  }, 0);
250
240
  });
251
- };
241
+ }
242
+
252
243
  /**
253
244
  * Opens a submenu.
254
245
  * @function
255
246
  * @fires Drilldown#open
256
247
  * @param {jQuery} $elem - the current element with a submenu to open.
257
248
  */
258
- Drilldown.prototype._show = function($elem){
249
+ _show($elem) {
259
250
  $elem.children('[data-submenu]').addClass('is-active');
260
251
 
261
252
  this.$element.trigger('open.zf.drilldown', [$elem]);
262
253
  };
254
+
263
255
  /**
264
256
  * Hides a submenu
265
257
  * @function
266
258
  * @fires Drilldown#hide
267
259
  * @param {jQuery} $elem - the current sub-menu to hide.
268
260
  */
269
- Drilldown.prototype._hide = function($elem){
261
+ _hide($elem) {
270
262
  var _this = this;
271
263
  $elem.addClass('is-closing')
272
264
  .one(Foundation.transitionend($elem), function(){
273
265
  $elem.removeClass('is-active is-closing');
266
+ $elem.blur();
274
267
  });
275
268
  /**
276
269
  * Fires when the submenu is has closed.
277
270
  * @event Drilldown#hide
278
271
  */
279
272
  $elem.trigger('hide.zf.drilldown', [$elem]);
273
+ }
280
274
 
281
- };
282
275
  /**
283
276
  * Iterates through the nested menus to calculate the min-height, and max-width for the menu.
284
277
  * Prevents content jumping.
285
278
  * @function
286
279
  * @private
287
280
  */
288
- Drilldown.prototype._getMaxDims = function(){
281
+ _getMaxDims() {
289
282
  var max = 0, result = {};
290
283
  this.$submenus.add(this.$element).each(function(){
291
284
  var numOfElems = $(this).children('li').length;
292
285
  max = numOfElems > max ? numOfElems : max;
293
286
  });
294
287
 
295
- result.height = max * this.$menuItems[0].getBoundingClientRect().height + 'px';
296
- result.width = this.$element[0].getBoundingClientRect().width + 'px';
288
+ result['min-height'] = `${max * this.$menuItems[0].getBoundingClientRect().height}px`;
289
+ result['max-width'] = `${this.$element[0].getBoundingClientRect().width}px`;
297
290
 
298
291
  return result;
299
- };
292
+ }
293
+
300
294
  /**
301
295
  * Destroys the Drilldown Menu
302
296
  * @function
303
297
  */
304
- Drilldown.prototype.destroy = function(){
298
+ destroy() {
305
299
  this._hideAll();
306
300
  Foundation.Nest.Burn(this.$element, 'drilldown');
307
301
  this.$element.unwrap()
308
- .find('.js-drilldown-back').remove()
302
+ .find('.js-drilldown-back, .is-submenu-parent-item').remove()
309
303
  .end().find('.is-active, .is-closing, .is-drilldown-submenu').removeClass('is-active is-closing is-drilldown-submenu')
310
304
  .end().find('[data-submenu]').removeAttr('aria-hidden tabindex role')
311
305
  .off('.zf.drilldown').end().off('zf.drilldown');
@@ -317,5 +311,37 @@
317
311
  });
318
312
  Foundation.unregisterPlugin(this);
319
313
  };
320
- Foundation.plugin(Drilldown, 'Drilldown');
321
- }(jQuery, window.Foundation);
314
+ }
315
+
316
+ Drilldown.defaults = {
317
+ /**
318
+ * Markup used for JS generated back button. Prepended to submenu lists and deleted on `destroy` method, 'js-drilldown-back' class required. Remove the backslash (`\`) if copy and pasting.
319
+ * @option
320
+ * @example '<\li><\a>Back<\/a><\/li>'
321
+ */
322
+ backButton: '<li class="js-drilldown-back"><a>Back</a></li>',
323
+ /**
324
+ * Markup used to wrap drilldown menu. Use a class name for independent styling; the JS applied class: `is-drilldown` is required. Remove the backslash (`\`) if copy and pasting.
325
+ * @option
326
+ * @example '<\div class="is-drilldown"><\/div>'
327
+ */
328
+ wrapper: '<div></div>',
329
+ /**
330
+ * Adds the parent link to the submenu.
331
+ * @option
332
+ * @example false
333
+ */
334
+ parentLink: false,
335
+ /**
336
+ * Allow the menu to return to root list on body click.
337
+ * @option
338
+ * @example false
339
+ */
340
+ closeOnClick: false
341
+ // holdOpen: false
342
+ };
343
+
344
+ // Window exports
345
+ Foundation.plugin(Drilldown, 'Drilldown');
346
+
347
+ }(jQuery);
@@ -1,3 +1,7 @@
1
+ 'use strict';
2
+
3
+ !function($) {
4
+
1
5
  /**
2
6
  * Dropdown module.
3
7
  * @module foundation.dropdown
@@ -5,8 +9,8 @@
5
9
  * @requires foundation.util.box
6
10
  * @requires foundation.util.triggers
7
11
  */
8
- !function($, Foundation){
9
- 'use strict';
12
+
13
+ class Dropdown {
10
14
  /**
11
15
  * Creates a new instance of a dropdown.
12
16
  * @class
@@ -14,7 +18,7 @@
14
18
  * Object should be of the dropdown panel, rather than its anchor.
15
19
  * @param {Object} options - Overrides to the default plugin settings.
16
20
  */
17
- function Dropdown(element, options){
21
+ constructor(element, options) {
18
22
  this.$element = element;
19
23
  this.options = $.extend({}, Dropdown.defaults, this.$element.data(), options);
20
24
  this._init();
@@ -29,78 +33,22 @@
29
33
  });
30
34
  }
31
35
 
32
- Dropdown.defaults = {
33
- /**
34
- * Amount of time to delay opening a submenu on hover event.
35
- * @option
36
- * @example 250
37
- */
38
- hoverDelay: 250,
39
- /**
40
- * Allow submenus to open on hover events
41
- * @option
42
- * @example false
43
- */
44
- hover: false,
45
- /**
46
- * Don't close dropdown when hovering over dropdown pane
47
- * @option
48
- * @example true
49
- */
50
- hoverPane: false,
51
- /**
52
- * Number of pixels between the dropdown pane and the triggering element on open.
53
- * @option
54
- * @example 1
55
- */
56
- vOffset: 1,
57
- /**
58
- * Number of pixels between the dropdown pane and the triggering element on open.
59
- * @option
60
- * @example 1
61
- */
62
- hOffset: 1,
63
- /**
64
- * Class applied to adjust open position. JS will test and fill this in.
65
- * @option
66
- * @example 'top'
67
- */
68
- positionClass: '',
69
- /**
70
- * Allow the plugin to trap focus to the dropdown pane if opened with keyboard commands.
71
- * @option
72
- * @example false
73
- */
74
- trapFocus: false,
75
- /**
76
- * Allow the plugin to set focus to the first focusable element within the pane, regardless of method of opening.
77
- * @option
78
- * @example true
79
- */
80
- autoFocus: false,
81
- /**
82
- * Allows a click on the body to close the dropdown.
83
- * @option
84
- * @example false
85
- */
86
- closeOnClick: false
87
- };
88
36
  /**
89
37
  * Initializes the plugin by setting/checking options and attributes, adding helper variables, and saving the anchor.
90
38
  * @function
91
39
  * @private
92
40
  */
93
- Dropdown.prototype._init = function(){
41
+ _init() {
94
42
  var $id = this.$element.attr('id');
95
43
 
96
- this.$anchor = $('[data-toggle="' + $id + '"]') || $('[data-open="' + $id + '"]');
44
+ this.$anchor = $(`[data-toggle="${$id}"]`) || $(`[data-open="${$id}"]`);
97
45
  this.$anchor.attr({
98
46
  'aria-controls': $id,
99
47
  'data-is-focus': false,
100
48
  'data-yeti-box': $id,
101
49
  'aria-haspopup': true,
102
50
  'aria-expanded': false
103
- // 'data-resize': $id
51
+
104
52
  });
105
53
 
106
54
  this.options.positionClass = this.getPositionClass();
@@ -113,24 +61,26 @@
113
61
  'aria-labelledby': this.$anchor[0].id || Foundation.GetYoDigits(6, 'dd-anchor')
114
62
  });
115
63
  this._events();
116
- };
64
+ }
65
+
117
66
  /**
118
67
  * Helper function to determine current orientation of dropdown pane.
119
68
  * @function
120
69
  * @returns {String} position - string value of a position class.
121
70
  */
122
- Dropdown.prototype.getPositionClass = function(){
71
+ getPositionClass() {
123
72
  var position = this.$element[0].className.match(/\b(top|left|right)\b/g);
124
73
  position = position ? position[0] : '';
125
74
  return position;
126
- };
75
+ }
76
+
127
77
  /**
128
78
  * Adjusts the dropdown panes orientation by adding/removing positioning classes.
129
79
  * @function
130
80
  * @private
131
81
  * @param {String} position - position class to remove.
132
82
  */
133
- Dropdown.prototype._reposition = function(position){
83
+ _reposition(position) {
134
84
  this.usedPositions.push(position ? position : 'bottom');
135
85
  //default, try switching to opposite side
136
86
  if(!position && (this.usedPositions.indexOf('top') < 0)){
@@ -162,14 +112,15 @@
162
112
  }
163
113
  this.classChanged = true;
164
114
  this.counter--;
165
- };
115
+ }
116
+
166
117
  /**
167
118
  * Sets the position and orientation of the dropdown pane, checks for collisions.
168
119
  * Recursively calls itself if a collision is detected, with a new position class.
169
120
  * @function
170
121
  * @private
171
122
  */
172
- Dropdown.prototype._setPosition = function(){
123
+ _setPosition() {
173
124
  if(this.$anchor.attr('aria-expanded') === 'false'){ return false; }
174
125
  var position = this.getPositionClass(),
175
126
  $eleDims = Foundation.Box.GetDimensions(this.$element),
@@ -194,13 +145,14 @@
194
145
  this._reposition(position);
195
146
  this._setPosition();
196
147
  }
197
- };
148
+ }
149
+
198
150
  /**
199
151
  * Adds event listeners to the element utilizing the triggers utility library.
200
152
  * @function
201
153
  * @private
202
154
  */
203
- Dropdown.prototype._events = function(){
155
+ _events() {
204
156
  var _this = this;
205
157
  this.$element.on({
206
158
  'open.zf.trigger': this.open.bind(this),
@@ -276,13 +228,14 @@
276
228
  }
277
229
  });
278
230
  });
279
- };
231
+ }
232
+
280
233
  /**
281
234
  * Adds an event handler to the body to close any dropdowns on a click.
282
235
  * @function
283
236
  * @private
284
237
  */
285
- Dropdown.prototype._addBodyHandler = function(){
238
+ _addBodyHandler() {
286
239
  var $body = $(document.body).not(this.$element),
287
240
  _this = this;
288
241
  $body.off('click.zf.dropdown')
@@ -296,14 +249,15 @@
296
249
  _this.close();
297
250
  $body.off('click.zf.dropdown');
298
251
  });
299
- };
252
+ }
253
+
300
254
  /**
301
255
  * Opens the dropdown pane, and fires a bubbling event to close other dropdowns.
302
256
  * @function
303
257
  * @fires Dropdown#closeme
304
258
  * @fires Dropdown#show
305
259
  */
306
- Dropdown.prototype.open = function(){
260
+ open() {
307
261
  // var _this = this;
308
262
  /**
309
263
  * Fires to close other open dropdowns
@@ -330,18 +284,15 @@
330
284
  * Fires once the dropdown is visible.
331
285
  * @event Dropdown#show
332
286
  */
333
- this.$element.trigger('show.zf.dropdown', [this.$element]);
334
- //why does this not work correctly for this plugin?
335
- // Foundation.reflow(this.$element, 'dropdown');
336
- // Foundation._reflow(this.$element.attr('data-dropdown'));
337
- };
287
+ this.$element.trigger('show.zf.dropdown', [this.$element]);
288
+ }
338
289
 
339
290
  /**
340
291
  * Closes the open dropdown pane.
341
292
  * @function
342
293
  * @fires Dropdown#hide
343
294
  */
344
- Dropdown.prototype.close = function(){
295
+ close() {
345
296
  if(!this.$element.hasClass('is-open')){
346
297
  return false;
347
298
  }
@@ -363,30 +314,91 @@
363
314
  this.usedPositions.length = 0;
364
315
  }
365
316
  this.$element.trigger('hide.zf.dropdown', [this.$element]);
366
- // Foundation.reflow(this.$element, 'dropdown');
367
- };
317
+ }
318
+
368
319
  /**
369
320
  * Toggles the dropdown pane's visibility.
370
321
  * @function
371
322
  */
372
- Dropdown.prototype.toggle = function(){
323
+ toggle() {
373
324
  if(this.$element.hasClass('is-open')){
374
325
  if(this.$anchor.data('hover')) return;
375
326
  this.close();
376
327
  }else{
377
328
  this.open();
378
329
  }
379
- };
330
+ }
331
+
380
332
  /**
381
333
  * Destroys the dropdown.
382
334
  * @function
383
335
  */
384
- Dropdown.prototype.destroy = function(){
336
+ destroy() {
385
337
  this.$element.off('.zf.trigger').hide();
386
338
  this.$anchor.off('.zf.dropdown');
387
339
 
388
340
  Foundation.unregisterPlugin(this);
389
- };
341
+ }
342
+ }
343
+
344
+ Dropdown.defaults = {
345
+ /**
346
+ * Amount of time to delay opening a submenu on hover event.
347
+ * @option
348
+ * @example 250
349
+ */
350
+ hoverDelay: 250,
351
+ /**
352
+ * Allow submenus to open on hover events
353
+ * @option
354
+ * @example false
355
+ */
356
+ hover: false,
357
+ /**
358
+ * Don't close dropdown when hovering over dropdown pane
359
+ * @option
360
+ * @example true
361
+ */
362
+ hoverPane: false,
363
+ /**
364
+ * Number of pixels between the dropdown pane and the triggering element on open.
365
+ * @option
366
+ * @example 1
367
+ */
368
+ vOffset: 1,
369
+ /**
370
+ * Number of pixels between the dropdown pane and the triggering element on open.
371
+ * @option
372
+ * @example 1
373
+ */
374
+ hOffset: 1,
375
+ /**
376
+ * Class applied to adjust open position. JS will test and fill this in.
377
+ * @option
378
+ * @example 'top'
379
+ */
380
+ positionClass: '',
381
+ /**
382
+ * Allow the plugin to trap focus to the dropdown pane if opened with keyboard commands.
383
+ * @option
384
+ * @example false
385
+ */
386
+ trapFocus: false,
387
+ /**
388
+ * Allow the plugin to set focus to the first focusable element within the pane, regardless of method of opening.
389
+ * @option
390
+ * @example true
391
+ */
392
+ autoFocus: false,
393
+ /**
394
+ * Allows a click on the body to close the dropdown.
395
+ * @option
396
+ * @example false
397
+ */
398
+ closeOnClick: false
399
+ }
400
+
401
+ // Window exports
402
+ Foundation.plugin(Dropdown, 'Dropdown');
390
403
 
391
- Foundation.plugin(Dropdown, 'Dropdown');
392
- }(jQuery, window.Foundation);
404
+ }(jQuery);