foundation-rails 5.5.3.2 → 6.1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +2 -8
  4. data/Rakefile +23 -0
  5. data/app/views/foundation/rails/styleguide/show.html.erb +2 -5
  6. data/bower.json +2 -2
  7. data/lib/foundation/rails/version.rb +1 -1
  8. data/lib/generators/foundation/install_generator.rb +6 -3
  9. data/lib/generators/foundation/templates/_settings.scss +546 -0
  10. data/lib/generators/foundation/templates/application.html.erb +0 -1
  11. data/lib/generators/foundation/templates/application.html.haml +0 -2
  12. data/lib/generators/foundation/templates/application.html.slim +0 -2
  13. data/lib/generators/foundation/templates/foundation_and_overrides.scss +51 -0
  14. data/vendor/assets/js/foundation.abide.js +418 -0
  15. data/vendor/assets/js/foundation.accordion.js +229 -0
  16. data/vendor/assets/js/foundation.accordionMenu.js +262 -0
  17. data/vendor/assets/js/foundation.core.js +378 -0
  18. data/vendor/assets/js/foundation.drilldown.js +321 -0
  19. data/vendor/assets/js/foundation.dropdown.js +390 -0
  20. data/vendor/assets/js/foundation.dropdownMenu.js +391 -0
  21. data/vendor/assets/js/foundation.equalizer.js +274 -0
  22. data/vendor/assets/js/foundation.interchange.js +184 -0
  23. data/vendor/assets/js/foundation.js +28 -0
  24. data/vendor/assets/js/foundation.magellan.js +212 -0
  25. data/vendor/assets/js/foundation.offcanvas.js +371 -0
  26. data/vendor/assets/js/foundation.orbit.js +419 -0
  27. data/vendor/assets/js/foundation.responsiveMenu.js +145 -0
  28. data/vendor/assets/js/foundation.responsiveToggle.js +106 -0
  29. data/vendor/assets/js/foundation.reveal.js +478 -0
  30. data/vendor/assets/js/foundation.slider.js +484 -0
  31. data/vendor/assets/js/foundation.sticky.js +436 -0
  32. data/vendor/assets/js/foundation.tabs.js +306 -0
  33. data/vendor/assets/js/foundation.toggler.js +147 -0
  34. data/vendor/assets/js/foundation.tooltip.js +429 -0
  35. data/vendor/assets/js/foundation.util.box.js +169 -0
  36. data/vendor/assets/js/foundation.util.keyboard.js +115 -0
  37. data/vendor/assets/js/foundation.util.mediaQuery.js +210 -0
  38. data/vendor/assets/js/foundation.util.motion.js +89 -0
  39. data/vendor/assets/js/foundation.util.nest.js +64 -0
  40. data/vendor/assets/js/foundation.util.timerAndImageLoader.js +78 -0
  41. data/vendor/assets/js/foundation.util.touch.js +339 -0
  42. data/vendor/assets/js/foundation.util.triggers.js +222 -0
  43. data/vendor/assets/scss/_global.scss +626 -0
  44. data/vendor/assets/scss/components/_accordion-menu.scss +32 -0
  45. data/vendor/assets/scss/components/_accordion.scss +113 -0
  46. data/vendor/assets/scss/components/_badge.scss +55 -0
  47. data/vendor/assets/scss/components/_breadcrumbs.scss +94 -0
  48. data/vendor/assets/scss/components/_button-group.scss +130 -0
  49. data/vendor/assets/scss/components/_button.scss +265 -0
  50. data/vendor/assets/scss/components/_callout.scss +105 -0
  51. data/vendor/assets/scss/components/_close-button.scss +61 -0
  52. data/vendor/assets/scss/components/_drilldown.scss +75 -0
  53. data/vendor/assets/scss/components/_dropdown-menu.scss +148 -0
  54. data/vendor/assets/scss/components/_dropdown.scss +64 -0
  55. data/vendor/assets/scss/components/_flex-video.scss +63 -0
  56. data/vendor/assets/scss/components/_float.scss +27 -0
  57. data/vendor/assets/scss/components/_label.scss +56 -0
  58. data/vendor/assets/scss/components/_media-object.scss +74 -0
  59. data/vendor/assets/scss/components/_menu.scss +209 -0
  60. data/vendor/assets/scss/components/_off-canvas.scss +180 -0
  61. data/vendor/assets/scss/components/_orbit.scss +193 -0
  62. data/vendor/assets/scss/components/_pagination.scss +158 -0
  63. data/vendor/assets/scss/components/_progress-bar.scss +83 -0
  64. data/vendor/assets/scss/components/_reveal.scss +156 -0
  65. data/vendor/assets/scss/components/_slider.scss +158 -0
  66. data/vendor/assets/scss/components/_sticky.scss +38 -0
  67. data/vendor/assets/scss/components/_switch.scss +232 -0
  68. data/vendor/assets/scss/components/_table.scss +213 -0
  69. data/vendor/assets/scss/components/_tabs.scss +170 -0
  70. data/vendor/assets/scss/components/_thumbnail.scss +54 -0
  71. data/vendor/assets/scss/components/_title-bar.scss +68 -0
  72. data/vendor/assets/scss/components/_tooltip.scss +100 -0
  73. data/vendor/assets/scss/components/_top-bar.scss +89 -0
  74. data/vendor/assets/scss/components/_visibility.scss +131 -0
  75. data/vendor/assets/scss/forms/_checkbox.scss +36 -0
  76. data/vendor/assets/scss/forms/_error.scss +82 -0
  77. data/vendor/assets/scss/forms/_fieldset.scss +53 -0
  78. data/vendor/assets/scss/forms/_forms.scss +32 -0
  79. data/vendor/assets/scss/forms/_help-text.scss +30 -0
  80. data/vendor/assets/scss/forms/_input-group.scss +91 -0
  81. data/vendor/assets/scss/forms/_label.scss +48 -0
  82. data/vendor/assets/scss/forms/_select.scss +63 -0
  83. data/vendor/assets/scss/forms/_text.scss +154 -0
  84. data/vendor/assets/scss/foundation.scss +91 -0
  85. data/vendor/assets/scss/grid/_classes.scss +153 -0
  86. data/vendor/assets/scss/grid/_column.scss +124 -0
  87. data/vendor/assets/scss/grid/_flex-grid.scss +281 -0
  88. data/vendor/assets/scss/grid/_grid.scss +48 -0
  89. data/vendor/assets/scss/grid/_gutter.scss +34 -0
  90. data/vendor/assets/scss/grid/_layout.scss +33 -0
  91. data/vendor/assets/scss/grid/_position.scss +72 -0
  92. data/vendor/assets/scss/grid/_row.scss +97 -0
  93. data/vendor/assets/scss/grid/_size.scss +24 -0
  94. data/vendor/assets/scss/settings/_settings.scss +547 -0
  95. data/vendor/assets/scss/typography/_alignment.scss +22 -0
  96. data/vendor/assets/scss/typography/_base.scss +439 -0
  97. data/vendor/assets/scss/typography/_helpers.scss +77 -0
  98. data/vendor/assets/scss/typography/_print.scss +73 -0
  99. data/vendor/assets/scss/typography/_typography.scss +28 -0
  100. data/vendor/assets/scss/util/_breakpoint.scss +266 -0
  101. data/vendor/assets/scss/util/_color.scss +41 -0
  102. data/vendor/assets/scss/util/_mixins.scss +223 -0
  103. data/vendor/assets/scss/util/_selector.scss +40 -0
  104. data/vendor/assets/scss/util/_unit.scss +90 -0
  105. data/vendor/assets/scss/util/_util.scss +15 -0
  106. data/vendor/assets/scss/util/_value.scss +126 -0
  107. metadata +97 -64
  108. data/update-gem.sh +0 -20
  109. data/vendor/assets/javascripts/foundation.js +0 -17
  110. data/vendor/assets/javascripts/foundation/foundation.abide.js +0 -426
  111. data/vendor/assets/javascripts/foundation/foundation.accordion.js +0 -125
  112. data/vendor/assets/javascripts/foundation/foundation.alert.js +0 -43
  113. data/vendor/assets/javascripts/foundation/foundation.clearing.js +0 -586
  114. data/vendor/assets/javascripts/foundation/foundation.dropdown.js +0 -468
  115. data/vendor/assets/javascripts/foundation/foundation.equalizer.js +0 -104
  116. data/vendor/assets/javascripts/foundation/foundation.interchange.js +0 -360
  117. data/vendor/assets/javascripts/foundation/foundation.joyride.js +0 -935
  118. data/vendor/assets/javascripts/foundation/foundation.js +0 -732
  119. data/vendor/assets/javascripts/foundation/foundation.magellan.js +0 -214
  120. data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +0 -225
  121. data/vendor/assets/javascripts/foundation/foundation.orbit.js +0 -476
  122. data/vendor/assets/javascripts/foundation/foundation.reveal.js +0 -522
  123. data/vendor/assets/javascripts/foundation/foundation.slider.js +0 -296
  124. data/vendor/assets/javascripts/foundation/foundation.tab.js +0 -247
  125. data/vendor/assets/javascripts/foundation/foundation.tooltip.js +0 -348
  126. data/vendor/assets/javascripts/foundation/foundation.topbar.js +0 -458
  127. data/vendor/assets/javascripts/vendor/modernizr.js +0 -1406
  128. data/vendor/assets/stylesheets/foundation.scss +0 -42
  129. data/vendor/assets/stylesheets/foundation/_functions.scss +0 -156
  130. data/vendor/assets/stylesheets/foundation/_settings.scss +0 -1489
  131. data/vendor/assets/stylesheets/foundation/components/_accordion.scss +0 -161
  132. data/vendor/assets/stylesheets/foundation/components/_alert-boxes.scss +0 -128
  133. data/vendor/assets/stylesheets/foundation/components/_block-grid.scss +0 -133
  134. data/vendor/assets/stylesheets/foundation/components/_breadcrumbs.scss +0 -132
  135. data/vendor/assets/stylesheets/foundation/components/_button-groups.scss +0 -208
  136. data/vendor/assets/stylesheets/foundation/components/_buttons.scss +0 -261
  137. data/vendor/assets/stylesheets/foundation/components/_clearing.scss +0 -260
  138. data/vendor/assets/stylesheets/foundation/components/_dropdown-buttons.scss +0 -130
  139. data/vendor/assets/stylesheets/foundation/components/_dropdown.scss +0 -269
  140. data/vendor/assets/stylesheets/foundation/components/_flex-video.scss +0 -51
  141. data/vendor/assets/stylesheets/foundation/components/_forms.scss +0 -607
  142. data/vendor/assets/stylesheets/foundation/components/_global.scss +0 -566
  143. data/vendor/assets/stylesheets/foundation/components/_grid.scss +0 -292
  144. data/vendor/assets/stylesheets/foundation/components/_icon-bar.scss +0 -460
  145. data/vendor/assets/stylesheets/foundation/components/_inline-lists.scss +0 -58
  146. data/vendor/assets/stylesheets/foundation/components/_joyride.scss +0 -220
  147. data/vendor/assets/stylesheets/foundation/components/_keystrokes.scss +0 -60
  148. data/vendor/assets/stylesheets/foundation/components/_labels.scss +0 -106
  149. data/vendor/assets/stylesheets/foundation/components/_magellan.scss +0 -34
  150. data/vendor/assets/stylesheets/foundation/components/_offcanvas.scss +0 -606
  151. data/vendor/assets/stylesheets/foundation/components/_orbit.scss +0 -388
  152. data/vendor/assets/stylesheets/foundation/components/_pagination.scss +0 -163
  153. data/vendor/assets/stylesheets/foundation/components/_panels.scss +0 -107
  154. data/vendor/assets/stylesheets/foundation/components/_pricing-tables.scss +0 -150
  155. data/vendor/assets/stylesheets/foundation/components/_progress-bars.scss +0 -85
  156. data/vendor/assets/stylesheets/foundation/components/_range-slider.scss +0 -177
  157. data/vendor/assets/stylesheets/foundation/components/_reveal.scss +0 -212
  158. data/vendor/assets/stylesheets/foundation/components/_side-nav.scss +0 -120
  159. data/vendor/assets/stylesheets/foundation/components/_split-buttons.scss +0 -203
  160. data/vendor/assets/stylesheets/foundation/components/_sub-nav.scss +0 -125
  161. data/vendor/assets/stylesheets/foundation/components/_switches.scss +0 -241
  162. data/vendor/assets/stylesheets/foundation/components/_tables.scss +0 -135
  163. data/vendor/assets/stylesheets/foundation/components/_tabs.scss +0 -142
  164. data/vendor/assets/stylesheets/foundation/components/_thumbs.scss +0 -66
  165. data/vendor/assets/stylesheets/foundation/components/_tooltips.scss +0 -142
  166. data/vendor/assets/stylesheets/foundation/components/_top-bar.scss +0 -745
  167. data/vendor/assets/stylesheets/foundation/components/_type.scss +0 -525
  168. data/vendor/assets/stylesheets/foundation/components/_visibility.scss +0 -425
  169. data/vendor/assets/stylesheets/normalize.scss +0 -424
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Accordion module.
3
+ * @module foundation.accordion
4
+ * @requires foundation.util.keyboard
5
+ * @requires foundation.util.motion
6
+ */
7
+ !function($, Foundation) {
8
+ 'use strict';
9
+
10
+ /**
11
+ * Creates a new instance of an accordion.
12
+ * @class
13
+ * @fires Accordion#init
14
+ * @param {jQuery} element - jQuery object to make into an accordion.
15
+ */
16
+ function Accordion(element, options){
17
+ this.$element = element;
18
+ this.options = $.extend({}, Accordion.defaults, this.$element.data(), options);
19
+
20
+ this._init();
21
+
22
+ Foundation.registerPlugin(this, 'Accordion');
23
+ Foundation.Keyboard.register('Accordion', {
24
+ 'ENTER': 'toggle',
25
+ 'SPACE': 'toggle',
26
+ 'ARROW_DOWN': 'next',
27
+ 'ARROW_UP': 'previous'
28
+ });
29
+ }
30
+
31
+ Accordion.defaults = {
32
+ /**
33
+ * Amount of time to animate the opening of an accordion pane.
34
+ * @option
35
+ * @example 250
36
+ */
37
+ slideSpeed: 250,
38
+ /**
39
+ * Allow the accordion to have multiple open panes.
40
+ * @option
41
+ * @example false
42
+ */
43
+ multiExpand: false,
44
+ /**
45
+ * Allow the accordion to close all panes.
46
+ * @option
47
+ * @example false
48
+ */
49
+ allowAllClosed: false
50
+ };
51
+
52
+ /**
53
+ * Initializes the accordion by animating the preset active pane(s).
54
+ * @private
55
+ */
56
+ Accordion.prototype._init = function() {
57
+ this.$element.attr('role', 'tablist');
58
+ this.$tabs = this.$element.children('li');
59
+ if (this.$tabs.length == 0) {
60
+ this.$tabs = this.$element.children('[data-accordion-item]');
61
+ }
62
+ this.$tabs.each(function(idx, el){
63
+
64
+ var $el = $(el),
65
+ $content = $el.find('[data-tab-content]'),
66
+ id = $content[0].id || Foundation.GetYoDigits(6, 'accordion'),
67
+ linkId = el.id || id + '-label';
68
+
69
+ $el.find('a:first').attr({
70
+ 'aria-controls': id,
71
+ 'role': 'tab',
72
+ 'id': linkId,
73
+ 'aria-expanded': false,
74
+ 'aria-selected': false
75
+ });
76
+ $content.attr({'role': 'tabpanel', 'aria-labelledby': linkId, 'aria-hidden': true, 'id': id});
77
+ });
78
+ var $initActive = this.$element.find('.is-active').children('[data-tab-content]');
79
+ if($initActive.length){
80
+ this.down($initActive, true);
81
+ }
82
+ this._events();
83
+ };
84
+
85
+ /**
86
+ * Adds event handlers for items within the accordion.
87
+ * @private
88
+ */
89
+ Accordion.prototype._events = function() {
90
+ var _this = this;
91
+
92
+ this.$tabs.each(function(){
93
+ var $elem = $(this);
94
+ var $tabContent = $elem.children('[data-tab-content]');
95
+ if ($tabContent.length) {
96
+ $elem.children('a').off('click.zf.accordion keydown.zf.accordion')
97
+ .on('click.zf.accordion', function(e){
98
+ // $(this).children('a').on('click.zf.accordion', function(e) {
99
+ e.preventDefault();
100
+ if ($elem.hasClass('is-active')) {
101
+ if(_this.options.allowAllClosed || $elem.siblings().hasClass('is-active')){
102
+ _this.up($tabContent);
103
+ }
104
+ }
105
+ else {
106
+ _this.down($tabContent);
107
+ }
108
+ }).on('keydown.zf.accordion', function(e){
109
+ Foundation.Keyboard.handleKey(e, 'Accordion', {
110
+ toggle: function() {
111
+ _this.toggle($tabContent);
112
+ },
113
+ next: function() {
114
+ $elem.next().find('a').focus().trigger('click.zf.accordion');
115
+ },
116
+ previous: function() {
117
+ $elem.prev().find('a').focus().trigger('click.zf.accordion');
118
+ },
119
+ handled: function() {
120
+ e.preventDefault();
121
+ e.stopPropagation();
122
+ }
123
+ });
124
+ });
125
+ }
126
+ });
127
+ };
128
+ /**
129
+ * Toggles the selected content pane's open/close state.
130
+ * @param {jQuery} $target - jQuery object of the pane to toggle.
131
+ * @function
132
+ */
133
+ Accordion.prototype.toggle = function($target){
134
+ if($target.parent().hasClass('is-active')){
135
+ if(this.options.allowAllClosed || $target.parent().siblings().hasClass('is-active')){
136
+ this.up($target);
137
+ }else{ return; }
138
+ }else{
139
+ this.down($target);
140
+ }
141
+ };
142
+ /**
143
+ * Opens the accordion tab defined by `$target`.
144
+ * @param {jQuery} $target - Accordion pane to open.
145
+ * @param {Boolean} firstTime - flag to determine if reflow should happen.
146
+ * @fires Accordion#down
147
+ * @function
148
+ */
149
+ Accordion.prototype.down = function($target, firstTime) {
150
+ var _this = this;
151
+ if(!this.options.multiExpand && !firstTime){
152
+ var $currentActive = this.$element.find('.is-active').children('[data-tab-content]');
153
+ if($currentActive.length){
154
+ this.up($currentActive);
155
+ }
156
+ }
157
+
158
+ $target
159
+ .attr('aria-hidden', false)
160
+ .parent('[data-tab-content]')
161
+ .addBack()
162
+ .parent().addClass('is-active');
163
+
164
+ // Foundation.Move(_this.options.slideSpeed, $target, function(){
165
+ $target.slideDown(_this.options.slideSpeed);
166
+ // });
167
+
168
+ // if(!firstTime){
169
+ // Foundation._reflow(this.$element.attr('data-accordion'));
170
+ // }
171
+ $('#' + $target.attr('aria-labelledby')).attr({
172
+ 'aria-expanded': true,
173
+ 'aria-selected': true
174
+ });
175
+ /**
176
+ * Fires when the tab is done opening.
177
+ * @event Accordion#down
178
+ */
179
+ this.$element.trigger('down.zf.accordion', [$target]);
180
+ };
181
+
182
+ /**
183
+ * Closes the tab defined by `$target`.
184
+ * @param {jQuery} $target - Accordion tab to close.
185
+ * @fires Accordion#up
186
+ * @function
187
+ */
188
+ Accordion.prototype.up = function($target) {
189
+ var $aunts = $target.parent().siblings(),
190
+ _this = this;
191
+ var canClose = this.options.multiExpand ? $aunts.hasClass('is-active') : $target.parent().hasClass('is-active');
192
+
193
+ if(!this.options.allowAllClosed && !canClose){
194
+ return;
195
+ }
196
+
197
+ // Foundation.Move(this.options.slideSpeed, $target, function(){
198
+ $target.slideUp(_this.options.slideSpeed);
199
+ // });
200
+
201
+ $target.attr('aria-hidden', true)
202
+ .parent().removeClass('is-active');
203
+
204
+ $('#' + $target.attr('aria-labelledby')).attr({
205
+ 'aria-expanded': false,
206
+ 'aria-selected': false
207
+ });
208
+
209
+ /**
210
+ * Fires when the tab is done collapsing up.
211
+ * @event Accordion#up
212
+ */
213
+ this.$element.trigger('up.zf.accordion', [$target]);
214
+ };
215
+
216
+ /**
217
+ * Destroys an instance of an accordion.
218
+ * @fires Accordion#destroyed
219
+ * @function
220
+ */
221
+ Accordion.prototype.destroy = function() {
222
+ this.$element.find('[data-tab-content]').slideUp(0).css('display', '');
223
+ this.$element.find('a').off('.zf.accordion');
224
+
225
+ Foundation.unregisterPlugin(this);
226
+ };
227
+
228
+ Foundation.plugin(Accordion, 'Accordion');
229
+ }(jQuery, window.Foundation);
@@ -0,0 +1,262 @@
1
+ /**
2
+ * AccordionMenu module.
3
+ * @module foundation.accordionMenu
4
+ * @requires foundation.util.keyboard
5
+ * @requires foundation.util.motion
6
+ * @requires foundation.util.nest
7
+ */
8
+ !function($) {
9
+ 'use strict';
10
+
11
+ /**
12
+ * Creates a new instance of an accordion menu.
13
+ * @class
14
+ * @fires AccordionMenu#init
15
+ * @param {jQuery} element - jQuery object to make into an accordion menu.
16
+ * @param {Object} options - Overrides to the default plugin settings.
17
+ */
18
+ function AccordionMenu(element, options) {
19
+ this.$element = element;
20
+ this.options = $.extend({}, AccordionMenu.defaults, this.$element.data(), options);
21
+
22
+ Foundation.Nest.Feather(this.$element, 'accordion');
23
+
24
+ this._init();
25
+
26
+ Foundation.registerPlugin(this, 'AccordionMenu');
27
+ Foundation.Keyboard.register('AccordionMenu', {
28
+ 'ENTER': 'toggle',
29
+ 'SPACE': 'toggle',
30
+ 'ARROW_RIGHT': 'open',
31
+ 'ARROW_UP': 'up',
32
+ 'ARROW_DOWN': 'down',
33
+ 'ARROW_LEFT': 'close',
34
+ 'ESCAPE': 'closeAll',
35
+ 'TAB': 'down',
36
+ 'SHIFT_TAB': 'up'
37
+ });
38
+ }
39
+
40
+ AccordionMenu.defaults = {
41
+ /**
42
+ * Amount of time to animate the opening of a submenu in ms.
43
+ * @option
44
+ * @example 250
45
+ */
46
+ slideSpeed: 250,
47
+ /**
48
+ * Allow the menu to have multiple open panes.
49
+ * @option
50
+ * @example true
51
+ */
52
+ multiOpen: true
53
+ };
54
+
55
+ /**
56
+ * Initializes the accordion menu by hiding all nested menus.
57
+ * @private
58
+ */
59
+ AccordionMenu.prototype._init = function() {
60
+ this.$element.find('[data-submenu]').not('.is-active').slideUp(0);//.find('a').css('padding-left', '1rem');
61
+ this.$element.attr({
62
+ 'role': 'tablist',
63
+ 'aria-multiselectable': this.options.multiOpen
64
+ });
65
+
66
+ this.$menuLinks = this.$element.find('.has-submenu');
67
+ this.$menuLinks.each(function(){
68
+ var linkId = this.id || Foundation.GetYoDigits(6, 'acc-menu-link'),
69
+ $elem = $(this),
70
+ $sub = $elem.children('[data-submenu]'),
71
+ subId = $sub[0].id || Foundation.GetYoDigits(6, 'acc-menu'),
72
+ isActive = $sub.hasClass('is-active');
73
+ $elem.attr({
74
+ 'aria-controls': subId,
75
+ 'aria-expanded': isActive,
76
+ 'aria-selected': false,
77
+ 'role': 'tab',
78
+ 'id': linkId
79
+ });
80
+ $sub.attr({
81
+ 'aria-labelledby': linkId,
82
+ 'aria-hidden': !isActive,
83
+ 'role': 'tabpanel',
84
+ 'id': subId
85
+ });
86
+ });
87
+ var initPanes = this.$element.find('.is-active');
88
+ if(initPanes.length){
89
+ var _this = this;
90
+ initPanes.each(function(){
91
+ _this.down($(this));
92
+ });
93
+ }
94
+ this._events();
95
+ };
96
+
97
+ /**
98
+ * Adds event handlers for items within the menu.
99
+ * @private
100
+ */
101
+ AccordionMenu.prototype._events = function() {
102
+ var _this = this;
103
+
104
+ this.$element.find('li').each(function() {
105
+ var $submenu = $(this).children('[data-submenu]');
106
+
107
+ if ($submenu.length) {
108
+ $(this).children('a').off('click.zf.accordionmenu').on('click.zf.accordionmenu', function(e) {
109
+ e.preventDefault();
110
+
111
+ _this.toggle($submenu);
112
+ });
113
+ }
114
+ }).on('keydown.zf.accordionmenu', function(e){
115
+ var $element = $(this),
116
+ $elements = $element.parent('ul').children('li'),
117
+ $prevElement,
118
+ $nextElement,
119
+ $target = $element.children('[data-submenu]');
120
+
121
+ $elements.each(function(i) {
122
+ if ($(this).is($element)) {
123
+ $prevElement = $elements.eq(Math.max(0, i-1));
124
+ $nextElement = $elements.eq(Math.min(i+1, $elements.length-1));
125
+
126
+ if ($(this).children('[data-submenu]:visible').length) { // has open sub menu
127
+ $nextElement = $element.find('li:first-child');
128
+ }
129
+ if ($(this).is(':first-child')) { // is first element of sub menu
130
+ $prevElement = $element.parents('li').first();
131
+ } else if ($prevElement.children('[data-submenu]:visible').length) { // if previous element has open sub menu
132
+ $prevElement = $prevElement.find('li:last-child');
133
+ }
134
+ if ($(this).is(':last-child')) { // is last element of sub menu
135
+ $nextElement = $element.parents('li').first().next('li');
136
+ }
137
+
138
+ return;
139
+ }
140
+ });
141
+ Foundation.Keyboard.handleKey(e, 'AccordionMenu', {
142
+ open: function() {
143
+ if ($target.is(':hidden')) {
144
+ _this.down($target);
145
+ $target.find('li').first().focus();
146
+ }
147
+ },
148
+ close: function() {
149
+ if ($target.length && !$target.is(':hidden')) { // close active sub of this item
150
+ _this.up($target);
151
+ } else if ($element.parent('[data-submenu]').length) { // close currently open sub
152
+ _this.up($element.parent('[data-submenu]'));
153
+ $element.parents('li').first().focus();
154
+ }
155
+ },
156
+ up: function() {
157
+ $prevElement.focus();
158
+ },
159
+ down: function() {
160
+ $nextElement.focus();
161
+ },
162
+ toggle: function() {
163
+ if ($element.children('[data-submenu]').length) {
164
+ _this.toggle($element.children('[data-submenu]'));
165
+ }
166
+ },
167
+ closeAll: function() {
168
+ _this.hideAll();
169
+ },
170
+ handled: function() {
171
+ e.preventDefault();
172
+ e.stopImmediatePropagation();
173
+ }
174
+ });
175
+ });//.attr('tabindex', 0);
176
+ };
177
+ /**
178
+ * Closes all panes of the menu.
179
+ * @function
180
+ */
181
+ AccordionMenu.prototype.hideAll = function(){
182
+ this.$element.find('[data-submenu]').slideUp(this.options.slideSpeed);
183
+ };
184
+ /**
185
+ * Toggles the open/close state of a submenu.
186
+ * @function
187
+ * @param {jQuery} $target - the submenu to toggle
188
+ */
189
+ AccordionMenu.prototype.toggle = function($target){
190
+ if(!$target.is(':animated')) {
191
+ if (!$target.is(':hidden')) {
192
+ this.up($target);
193
+ }
194
+ else {
195
+ this.down($target);
196
+ }
197
+ }
198
+ };
199
+ /**
200
+ * Opens the sub-menu defined by `$target`.
201
+ * @param {jQuery} $target - Sub-menu to open.
202
+ * @fires AccordionMenu#down
203
+ */
204
+ AccordionMenu.prototype.down = function($target) {
205
+ var _this = this;
206
+
207
+ if(!this.options.multiOpen){
208
+ this.up(this.$element.find('.is-active').not($target.parentsUntil(this.$element).add($target)));
209
+ }
210
+
211
+ $target.addClass('is-active').attr({'aria-hidden': false})
212
+ .parent('.has-submenu').attr({'aria-expanded': true, 'aria-selected': true});
213
+
214
+ Foundation.Move(this.options.slideSpeed, $target, function(){
215
+ $target.slideDown(_this.options.slideSpeed);
216
+ });
217
+ /**
218
+ * Fires when the menu is done collapsing up.
219
+ * @event AccordionMenu#down
220
+ */
221
+ this.$element.trigger('down.zf.accordionMenu', [$target]);
222
+ };
223
+
224
+ /**
225
+ * Closes the sub-menu defined by `$target`. All sub-menus inside the target will be closed as well.
226
+ * @param {jQuery} $target - Sub-menu to close.
227
+ * @fires AccordionMenu#up
228
+ */
229
+ AccordionMenu.prototype.up = function($target) {
230
+ var _this = this;
231
+ Foundation.Move(this.options.slideSpeed, $target, function(){
232
+ $target.slideUp(_this.options.slideSpeed);
233
+ });
234
+ $target.attr('aria-hidden', true)
235
+ .find('[data-submenu]').slideUp(0).attr('aria-hidden', true).end()
236
+ .parent('.has-submenu')
237
+ .attr({'aria-expanded': false, 'aria-selected': false});
238
+ // $target.slideUp(this.options.slideSpeed, function() {
239
+ // $target.find('[data-submenu]').slideUp(0).attr('aria-hidden', true);
240
+ // }).attr('aria-hidden', true).parent('.has-submenu').attr({'aria-expanded': false, 'aria-selected': false});
241
+
242
+ /**
243
+ * Fires when the menu is done collapsing up.
244
+ * @event AccordionMenu#up
245
+ */
246
+ this.$element.trigger('up.zf.accordionMenu', [$target]);
247
+ };
248
+
249
+ /**
250
+ * Destroys an instance of accordion menu.
251
+ * @fires AccordionMenu#destroyed
252
+ */
253
+ AccordionMenu.prototype.destroy = function(){
254
+ this.$element.find('[data-submenu]').slideDown(0).css('display', '');
255
+ this.$element.find('a').off('click.zf.accordionMenu');
256
+
257
+ Foundation.Nest.Burn(this.$element, 'accordion');
258
+ Foundation.unregisterPlugin(this);
259
+ };
260
+
261
+ Foundation.plugin(AccordionMenu, 'AccordionMenu');
262
+ }(jQuery, window.Foundation);