zurb-foundation 4.2.3 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. data/CONTRIBUTING.md +1 -1
  2. data/Gemfile.lock +1 -1
  3. data/README.md +8 -0
  4. data/docs/CHANGELOG.md +17 -0
  5. data/docs/README.md +3 -1
  6. data/docs/_sidebar-components.html.erb +2 -1
  7. data/docs/_sidebar.html.erb +2 -1
  8. data/docs/compile.rb +8 -1
  9. data/docs/components/abide.html.erb +371 -0
  10. data/docs/components/alert-boxes.html.erb +12 -9
  11. data/docs/components/block-grid.html.erb +1 -1
  12. data/docs/components/breadcrumbs.html.erb +7 -5
  13. data/docs/components/button-groups.html.erb +4 -2
  14. data/docs/components/buttons.html.erb +13 -9
  15. data/docs/components/clearing.html.erb +2 -0
  16. data/docs/components/dropdown-buttons.html.erb +59 -55
  17. data/docs/components/dropdown.html.erb +34 -32
  18. data/docs/components/flex-video.html.erb +4 -2
  19. data/docs/components/forms.html.erb +16 -15
  20. data/docs/components/global.html.erb +27 -4
  21. data/docs/components/grid.html.erb +21 -3
  22. data/docs/components/inline-lists.html.erb +8 -3
  23. data/docs/components/joyride.html.erb +5 -3
  24. data/docs/components/keystrokes.html.erb +4 -2
  25. data/docs/components/kitchen-sink.html.erb +15 -40
  26. data/docs/components/labels.html.erb +4 -2
  27. data/docs/components/magellan.html.erb +4 -2
  28. data/docs/components/orbit.html.erb +39 -27
  29. data/docs/components/pagination.html.erb +10 -8
  30. data/docs/components/panels.html.erb +7 -3
  31. data/docs/components/pricing-tables.html.erb +12 -10
  32. data/docs/components/progress-bars.html.erb +6 -4
  33. data/docs/components/reveal.html.erb +7 -28
  34. data/docs/components/section.html.erb +15 -13
  35. data/docs/components/side-nav.html.erb +5 -3
  36. data/docs/components/split-buttons.html.erb +45 -43
  37. data/docs/components/sub-nav.html.erb +7 -5
  38. data/docs/components/switch.html.erb +3 -1
  39. data/docs/components/tables.html.erb +8 -6
  40. data/docs/components/thumbnails.html.erb +2 -0
  41. data/docs/components/tooltips.html.erb +6 -4
  42. data/docs/components/top-bar.html.erb +9 -8
  43. data/docs/components/type.html.erb +20 -18
  44. data/docs/config.ru +2 -1
  45. data/docs/css/_footer.scss +420 -0
  46. data/docs/css/_offcanvas.scss +140 -0
  47. data/docs/css/docs.scss +10 -1
  48. data/docs/fonts/ProximaNova-Reg-webfont.eot +0 -0
  49. data/docs/fonts/ProximaNova-Reg-webfont.svg +244 -0
  50. data/docs/fonts/ProximaNova-Reg-webfont.ttf +0 -0
  51. data/docs/fonts/ProximaNova-Reg-webfont.woff +0 -0
  52. data/docs/fonts/proximanovacond-bold-webfont.eot +0 -0
  53. data/docs/fonts/proximanovacond-bold-webfont.svg +247 -0
  54. data/docs/fonts/proximanovacond-bold-webfont.ttf +0 -0
  55. data/docs/fonts/proximanovacond-bold-webfont.woff +0 -0
  56. data/docs/img/demos/orbit/demo1.jpg +0 -0
  57. data/docs/img/demos/orbit/demo2.jpg +0 -0
  58. data/docs/img/demos/orbit/demo3.jpg +0 -0
  59. data/docs/img/icons/footer-icons.png +0 -0
  60. data/docs/img/icons/footer-top-icons.png +0 -0
  61. data/docs/img/icons/social.png +0 -0
  62. data/docs/img/offcanvas/footer-icons.png +0 -0
  63. data/docs/img/offcanvas/menu-wht.png +0 -0
  64. data/docs/img/offcanvas/search.png +0 -0
  65. data/docs/img/offcanvas/zurb-logo.png +0 -0
  66. data/docs/img/offcanvas/zurb-wht.png +0 -0
  67. data/docs/js/docs.js +1 -0
  68. data/docs/js/jquery.offcanvas.js +28 -0
  69. data/docs/layout.html.erb +226 -42
  70. data/docs/media-queries.html.erb +3 -3
  71. data/docs/sass.html.erb +142 -142
  72. data/docs/support.html.erb +1 -1
  73. data/js/foundation/foundation.abide.js +194 -0
  74. data/js/foundation/foundation.dropdown.js +8 -9
  75. data/js/foundation/foundation.forms.js +11 -3
  76. data/js/foundation/foundation.interchange.js +25 -16
  77. data/js/foundation/foundation.joyride.js +9 -3
  78. data/js/foundation/foundation.js +2 -3
  79. data/js/foundation/foundation.magellan.js +3 -2
  80. data/js/foundation/foundation.orbit.js +359 -344
  81. data/js/foundation/foundation.reveal.js +1 -1
  82. data/js/foundation/foundation.section.js +290 -311
  83. data/js/foundation/foundation.tooltips.js +2 -2
  84. data/js/foundation/foundation.topbar.js +20 -23
  85. data/js/foundation/index.js +1 -0
  86. data/js/vendor/jquery.js +103 -121
  87. data/lib/foundation/generators/templates/application.html.slim +15 -8
  88. data/lib/foundation/version.rb +1 -1
  89. data/scss/foundation.scss +2 -5
  90. data/scss/foundation/_variables.scss +326 -295
  91. data/scss/foundation/components/_alert-boxes.scss +10 -10
  92. data/scss/foundation/components/_block-grid.scss +1 -1
  93. data/scss/foundation/components/_breadcrumbs.scss +8 -8
  94. data/scss/foundation/components/_button-groups.scss +2 -2
  95. data/scss/foundation/components/_buttons.scss +18 -18
  96. data/scss/foundation/components/_custom-forms.scss +20 -14
  97. data/scss/foundation/components/_dropdown-buttons.scss +9 -9
  98. data/scss/foundation/components/_dropdown.scss +4 -4
  99. data/scss/foundation/components/_flex-video.scss +3 -3
  100. data/scss/foundation/components/_forms.scss +54 -24
  101. data/scss/foundation/components/_global.scss +28 -5
  102. data/scss/foundation/components/_grid-5.scss +214 -0
  103. data/scss/foundation/components/_grid.scss +3 -3
  104. data/scss/foundation/components/_inline-lists.scss +3 -3
  105. data/scss/foundation/components/_joyride.scss +6 -6
  106. data/scss/foundation/components/_keystrokes.scss +3 -3
  107. data/scss/foundation/components/_labels.scss +3 -3
  108. data/scss/foundation/components/_orbit.scss +34 -9
  109. data/scss/foundation/components/_pagination.scss +8 -6
  110. data/scss/foundation/components/_panels.scss +3 -3
  111. data/scss/foundation/components/_pricing-tables.scss +10 -10
  112. data/scss/foundation/components/_progress-bars.scss +3 -3
  113. data/scss/foundation/components/_reveal.scss +7 -7
  114. data/scss/foundation/components/_section.scss +252 -214
  115. data/scss/foundation/components/_side-nav.scss +3 -3
  116. data/scss/foundation/components/_split-buttons.scss +7 -7
  117. data/scss/foundation/components/_sub-nav.scss +7 -7
  118. data/scss/foundation/components/_switch.scss +4 -4
  119. data/scss/foundation/components/_tables.scss +6 -6
  120. data/scss/foundation/components/_tooltips.scss +4 -4
  121. data/scss/foundation/components/_top-bar.scss +14 -10
  122. data/scss/foundation/components/_type.scss +23 -23
  123. data/templates/project/index.html +4 -4
  124. data/templates/project/scss/app.scss +8 -0
  125. metadata +29 -4
@@ -4,7 +4,7 @@
4
4
  'use strict';
5
5
 
6
6
  Foundation.libs.reveal = {
7
- name: 'reveal',
7
+ name : 'reveal',
8
8
 
9
9
  version : '4.2.2',
10
10
 
@@ -1,27 +1,33 @@
1
1
  /*jslint unparam: true, browser: true, indent: 2 */
2
2
 
3
- ;(function ($, window, document, undefined) {
3
+ ;
4
+ (function($, window, document) {
4
5
  'use strict';
5
6
 
6
7
  Foundation.libs.section = {
7
- name: 'section',
8
+ name : 'section',
8
9
 
9
- version : '4.2.3',
10
+ version : '4.3.0',
10
11
 
11
- settings : {
12
+ settings: {
12
13
  deep_linking: false,
13
14
  small_breakpoint: 768,
14
15
  one_up: true,
15
- section_selector : '[data-section]',
16
- region_selector : 'section, .section, [data-section-region]',
17
- title_selector : '.title, [data-section-title]',
18
- active_region_selector : 'section.active, .section.active, .active[data-section-region]',
19
- content_selector : '.content, [data-section-content]',
20
- nav_selector : '[data-section="vertical-nav"], [data-section="horizontal-nav"]',
21
- callback: function (){}
16
+ section_selector: '[data-section]',
17
+ region_selector: 'section, .section, [data-section-region]',
18
+ title_selector: '.title, [data-section-title]',
19
+ //marker: container is resized
20
+ resized_data_attr: 'data-section-resized',
21
+ //marker: container should apply accordion style
22
+ small_style_data_attr: 'data-section-small-style',
23
+ content_selector: '.content, [data-section-content]',
24
+ nav_selector: '[data-section="vertical-nav"], [data-section="horizontal-nav"]',
25
+ active_class: 'active',
26
+ callback: function() {
27
+ }
22
28
  },
23
29
 
24
- init : function (scope, method, options) {
30
+ init: function(scope, method, options) {
25
31
  var self = this;
26
32
  Foundation.inherit(this, 'throttle data_options position_right offset_right');
27
33
 
@@ -30,372 +36,334 @@
30
36
  }
31
37
 
32
38
  if (typeof method !== 'string') {
33
- this.set_active_from_hash();
34
39
  this.events();
35
-
36
40
  return true;
37
41
  } else {
38
42
  return this[method].call(this, options);
39
43
  }
40
44
  },
41
45
 
42
- events : function () {
46
+ events: function() {
43
47
  var self = this;
44
48
 
45
- $(this.scope)
46
- .on('click.fndtn.section', '[data-section] .title, [data-section] [data-section-title]', function (e) {
47
- var $this = $(this),
48
- section = $this.closest(self.settings.region_selector);
49
+ //combine titles selector from settings for click event binding
50
+ var click_title_selectors = [],
51
+ section_selector = self.settings.section_selector,
52
+ region_selectors = self.settings.region_selector.split(","),
53
+ title_selectors = self.settings.title_selector.split(",");
54
+
55
+ for (var i = 0, len = region_selectors.length; i < len; i++) {
56
+ var region_selector = region_selectors[i];
57
+
58
+ for (var j = 0, len1 = title_selectors.length; j < len1; j++) {
59
+ var title_selector = section_selector + ">" + region_selector + ">" + title_selectors[j];
60
+
61
+ click_title_selectors.push(title_selector + " a"); //or we can not do preventDefault for click event of <a>
62
+ click_title_selectors.push(title_selector);
63
+ }
64
+ }
49
65
 
50
- if (section.children(self.settings.content_selector).length > 0) {
51
- self.toggle_active.call(this, e, self);
52
- self.reflow();
66
+ $(self.scope)
67
+ .on('click.fndtn.section', click_title_selectors.join(","), function(e) {
68
+ var title = $(this).closest(self.settings.title_selector);
69
+
70
+ self.close_navs(title);
71
+ if (title.siblings(self.settings.content_selector).length > 0) {
72
+ self.toggle_active.call(title[0], e);
53
73
  }
54
74
  });
55
75
 
56
76
  $(window)
57
- .on('resize.fndtn.section', self.throttle(function () {
58
- self.resize.call(this);
59
- }, 30))
60
- .on('hashchange', function () {
61
- if (!self.settings.toggled){
62
- self.set_active_from_hash();
63
- $(this).trigger('resize');
64
- }
65
- }).trigger('resize');
66
-
67
- $(document)
68
- .on('click.fndtn.section', function (e) {
69
- if ($(e.target).closest(self.settings.title_selector).length < 1) {
70
- $(self.settings.nav_selector)
71
- .children(self.settings.region_selector)
72
- .removeClass('active')
73
- .attr('style', '');
74
- }
75
- });
77
+ .on('resize.fndtn.section', self.throttle(function() { self.resize(); }, 30))
78
+ .on('hashchange.fndtn.section', self.set_active_from_hash);
79
+
80
+ $(document).on('click.fndtn.section', function (e) {
81
+ if (e.isPropagationStopped && e.isPropagationStopped()) return;
82
+ if (e.target === document) return;
83
+ self.close_navs($(e.target).closest(self.settings.title_selector));
84
+ });
76
85
 
86
+ $(window).triggerHandler('resize.fndtn.section');
87
+ $(window).triggerHandler('hashchange.fndtn.section');
77
88
  },
89
+
90
+ //close nav !one_up on click elsewhere
91
+ close_navs: function(except_nav_with_title) {
92
+ var self = Foundation.libs.section,
93
+ navsToClose = $(self.settings.nav_selector)
94
+ .filter(function() { return !$.extend({},
95
+ self.settings, self.data_options($(this))).one_up; });
96
+
97
+ if (except_nav_with_title.length > 0) {
98
+ var section = except_nav_with_title.parent().parent();
78
99
 
79
- toggle_active : function (e, self) {
100
+ if (self.is_horizontal_nav(section) || self.is_vertical_nav(section)) {
101
+ //exclude current nav from list
102
+ navsToClose = navsToClose.filter(function() { return this !== section[0]; });
103
+ }
104
+ }
105
+ //close navs on click on title
106
+ navsToClose.children(self.settings.region_selector).removeClass(self.settings.active_class);
107
+ },
108
+
109
+ toggle_active: function(e) {
80
110
  var $this = $(this),
81
111
  self = Foundation.libs.section,
82
- region = $this.closest(self.settings.region_selector),
112
+ region = $this.parent(),
83
113
  content = $this.siblings(self.settings.content_selector),
84
- parent = region.parent(),
85
- settings = $.extend({}, self.settings, self.data_options(parent)),
86
- prev_active_section = parent
87
- .children(self.settings.active_region_selector);
88
-
89
- self.settings.toggled = true;
114
+ section = region.parent(),
115
+ settings = $.extend({}, self.settings, self.data_options(section)),
116
+ prev_active_region = section.children(self.settings.region_selector).filter("." + self.settings.active_class);
90
117
 
118
+ //for anchors inside [data-section-title]
91
119
  if (!settings.deep_linking && content.length > 0) {
92
120
  e.preventDefault();
93
121
  }
94
122
 
95
- if (region.hasClass('active')) {
96
- // this is causing the style flash.
97
- if (self.small(parent)
98
- || self.is_vertical_nav(parent)
99
- || self.is_horizontal_nav(parent)
100
- || self.is_accordion(parent)) {
101
- if (prev_active_section[0] !== region[0]
102
- || (prev_active_section[0] === region[0] && !settings.one_up)) {
103
- region
104
- .removeClass('active')
105
- .attr('style', '');
123
+ e.stopPropagation(); //do not catch same click again on parent
124
+
125
+ if (!region.hasClass(self.settings.active_class)) {
126
+ prev_active_region.removeClass(self.settings.active_class);
127
+ region.addClass(self.settings.active_class);
128
+ //force resize for better performance (do not wait timer)
129
+ self.resize(region.find(self.settings.section_selector).not("[" + self.settings.resized_data_attr + "]"), true);
130
+ } else if (!settings.one_up && (self.small(section) || self.is_vertical_nav(section) || self.is_horizontal_nav(section) || self.is_accordion(section))) {
131
+ region.removeClass(self.settings.active_class);
132
+ }
133
+ settings.callback();
134
+ },
135
+
136
+ check_resize_timer: null,
137
+
138
+ //main function that sets title and content positions; runs for :not(.resized) and :visible once when window width is medium up
139
+ //sections:
140
+ // selected sections to resize, are defined on resize forced by visibility changes
141
+ //ensure_has_active_region:
142
+ // is true when we force resize for no resized sections that were hidden and became visible,
143
+ // these sections can have no selected region, because all regions were hidden along with section on executing set_active_from_hash
144
+ resize: function(sections, ensure_has_active_region) {
145
+
146
+ var self = Foundation.libs.section,
147
+ is_small_window = self.small($(document)),
148
+ //filter for section resize
149
+ should_be_resized = function (section, now_is_hidden) {
150
+ return !self.is_accordion(section) &&
151
+ !section.is("[" + self.settings.resized_data_attr + "]") &&
152
+ (!is_small_window || self.is_horizontal_tabs(section)) &&
153
+ now_is_hidden === (section.css('display') === 'none' ||
154
+ !section.parent().is(':visible'));
155
+ };
156
+
157
+ sections = sections || $(self.settings.section_selector);
158
+
159
+ clearTimeout(self.check_resize_timer);
160
+
161
+ if (!is_small_window) {
162
+ sections.removeAttr(self.settings.small_style_data_attr);
163
+ }
164
+
165
+ //resize
166
+ sections.filter(function() { return should_be_resized($(this), false); })
167
+ .each(function() {
168
+ var section = $(this),
169
+ regions = section.children(self.settings.region_selector),
170
+ titles = regions.children(self.settings.title_selector),
171
+ content = regions.children(self.settings.content_selector),
172
+ titles_max_height = 0;
173
+
174
+ if (ensure_has_active_region &&
175
+ section.children(self.settings.region_selector).filter("." + self.settings.active_class).length == 0) {
176
+ var settings = $.extend({}, self.settings, self.data_options(section));
177
+
178
+ if (!settings.deep_linking && (settings.one_up || !self.is_horizontal_nav(section) &&
179
+ !self.is_vertical_nav(section) && !self.is_accordion(section))) {
180
+ regions.filter(":visible").first().addClass(self.settings.active_class);
106
181
  }
107
- }
108
- } else {
109
- var prev_active_section = parent
110
- .children(self.settings.active_region_selector),
111
- title_height = self.outerHeight(region
112
- .children(self.settings.title_selector));
113
-
114
- if (self.small(parent) || settings.one_up) {
115
-
116
- if (self.small(parent)) {
117
- prev_active_section.attr('style', '');
118
- } else {
119
- prev_active_section.attr('style',
120
- 'visibility: hidden; padding-top: '+title_height+'px;');
121
182
  }
122
- }
123
183
 
124
- if (self.small(parent)) {
125
- region.attr('style', '');
126
- } else {
127
- region.css('padding-top', title_height);
128
- }
184
+ if (self.is_horizontal_tabs(section) || self.is_auto(section)) {
185
+ // region: position relative
186
+ // title: position absolute
187
+ // content: position static
188
+ var titles_sum_width = 0;
129
189
 
130
- region.addClass('active');
190
+ titles.each(function() {
191
+ var title = $(this);
131
192
 
132
- if (prev_active_section.length > 0) {
133
- prev_active_section
134
- .removeClass('active')
135
- .attr('style', '');
136
- }
193
+ if (title.is(":visible")) {
194
+ title.css(!self.rtl ? 'left' : 'right', titles_sum_width);
195
+ var title_h_border_width = parseInt(title.css("border-" + (self.rtl ? 'left' : 'right') + "-width"), 10);
137
196
 
138
- // Toggle the content display attribute. This is done to
139
- // ensure accurate outerWidth measurements that account for
140
- // the scrollbar.
141
- if (self.is_vertical_tabs(parent)) {
142
- content.css('display', 'block');
197
+ if (title_h_border_width.toString() === 'Nan') {
198
+ title_h_border_width = 0;
199
+ }
143
200
 
144
- if (prev_active_section !== null) {
145
- prev_active_section
146
- .children(self.settings.content_selector)
147
- .css('display', 'none');
148
- }
149
- }
150
- }
201
+ titles_sum_width += self.outerWidth(title) - title_h_border_width;
202
+ titles_max_height = Math.max(titles_max_height, self.outerHeight(title));
203
+ }
204
+ });
205
+ titles.css('height', titles_max_height);
206
+ regions.each(function() {
207
+ var region = $(this),
208
+ region_content = region.children(self.settings.content_selector),
209
+ content_top_border_width = parseInt(region_content.css("border-top-width"), 10);
151
210
 
152
- setTimeout(function () {
153
- self.settings.toggled = false;
154
- }, 300);
211
+ if (content_top_border_width.toString() === 'Nan') {
212
+ content_top_border_width = 0;
213
+ }
155
214
 
156
- settings.callback();
157
- },
215
+ region.css('padding-top', titles_max_height - content_top_border_width);
216
+ });
158
217
 
159
- resize : function () {
160
- var self = Foundation.libs.section,
161
- sections = $(self.settings.section_selector);
218
+ section.css("min-height", titles_max_height);
219
+ } else if (self.is_horizontal_nav(section)) {
220
+ var first = true;
221
+ // region: positon relative, float left
222
+ // title: position static
223
+ // content: position absolute
224
+ titles.each(function() {
225
+ titles_max_height = Math.max(titles_max_height, self.outerHeight($(this)));
226
+ });
162
227
 
163
- sections.each(function() {
164
- var $this = $(this),
165
- active_section = $this
166
- .children(self.settings.active_region_selector),
167
- settings = $.extend({}, self.settings, self.data_options($this));
168
-
169
- if (active_section.length > 1) {
170
- active_section
171
- .not(':first')
172
- .removeClass('active')
173
- .attr('style', '');
174
- } else if (active_section.length < 1
175
- && !self.is_vertical_nav($this)
176
- && !self.is_horizontal_nav($this)
177
- && !self.is_accordion($this)) {
178
-
179
- var first = $this.children(self.settings.region_selector).first();
180
-
181
- if (settings.one_up || !self.small($this)) {
182
- first.addClass('active');
183
- }
228
+ regions.each(function() {
229
+ var region = $(this);
230
+
231
+ region.css("margin-left", "-" + (first ? section : region.children(self.settings.title_selector)).css("border-left-width"));
232
+ first = false;
233
+ });
234
+
235
+ regions.css("margin-top", "-" + section.css("border-top-width"));
236
+ titles.css('height', titles_max_height);
237
+ content.css('top', titles_max_height);
238
+ section.css("min-height", titles_max_height);
239
+ } else if (self.is_vertical_tabs(section)) {
240
+ var titles_sum_height = 0;
241
+ // region: position relative, for .active: fixed padding==title.width
242
+ // title: fixed width, position absolute
243
+ // content: position static
244
+ titles.each(function() {
245
+ var title = $(this);
246
+
247
+ if (title.is(":visible")) {
248
+ title.css('top', titles_sum_height);
249
+ var title_top_border_width = parseInt(title.css("border-top-width"), 10);
250
+
251
+ if (title_top_border_width.toString() === 'Nan') {
252
+ title_top_border_width = 0;
253
+ }
254
+
255
+ titles_sum_height += self.outerHeight(title) - title_top_border_width;
256
+ }
257
+ });
184
258
 
185
- if (self.small($this)) {
186
- first.attr('style', '');
187
- } else {
188
- first.css('padding-top', self.outerHeight(first
189
- .children(self.settings.title_selector)));
259
+ content.css('min-height', titles_sum_height + 1);
260
+ } else if (self.is_vertical_nav(section)) {
261
+ var titles_max_width = 0,
262
+ first1 = true;
263
+ // region: positon relative
264
+ // title: position static
265
+ // content: position absolute
266
+ titles.each(function() {
267
+ titles_max_width = Math.max(titles_max_width, self.outerWidth($(this)));
268
+ });
269
+
270
+ regions.each(function () {
271
+ var region = $(this);
272
+
273
+ region.css("margin-top", "-" + (first1 ? section : region.children(self.settings.title_selector)).css("border-top-width"));
274
+ first1 = false;
275
+ });
276
+
277
+ titles.css('width', titles_max_width);
278
+ content.css(!self.rtl ? 'left' : 'right', titles_max_width);
279
+ section.css('width', titles_max_width);
190
280
  }
191
- }
192
281
 
193
- if (self.small($this)) {
194
- active_section.attr('style', '');
195
- } else {
196
- active_section.css('padding-top', self.outerHeight(active_section
197
- .children(self.settings.title_selector)));
198
- }
282
+ section.attr(self.settings.resized_data_attr, true);
283
+ });
199
284
 
200
- self.position_titles($this);
285
+ //wait elements to become visible then resize
286
+ if ($(self.settings.section_selector).filter(function() { return should_be_resized($(this), true); }).length > 0)
287
+ self.check_resize_timer = setTimeout(function() {
288
+ self.resize(sections.filter(function() { return should_be_resized($(this), false); }), true);
289
+ }, 700);
201
290
 
202
- if ( (self.is_horizontal_nav($this) && !self.small($this))
203
- || self.is_vertical_tabs($this) && !self.small($this)) {
204
- self.position_content($this);
205
- } else {
206
- self.position_content($this, false);
207
- }
208
- });
291
+ if (is_small_window) {
292
+ sections.attr(self.settings.small_style_data_attr, true);
293
+ }
209
294
  },
210
295
 
211
- is_vertical_nav : function (el) {
296
+ is_vertical_nav: function(el) {
212
297
  return /vertical-nav/i.test(el.data('section'));
213
298
  },
214
299
 
215
- is_horizontal_nav : function (el) {
300
+ is_horizontal_nav: function(el) {
216
301
  return /horizontal-nav/i.test(el.data('section'));
217
302
  },
218
303
 
219
- is_accordion : function (el) {
304
+ is_accordion: function(el) {
220
305
  return /accordion/i.test(el.data('section'));
221
306
  },
222
307
 
223
- is_horizontal_tabs : function (el) {
308
+ is_horizontal_tabs: function(el) {
224
309
  return /^tabs$/i.test(el.data('section'));
225
310
  },
226
311
 
227
- is_vertical_tabs : function (el) {
312
+ is_vertical_tabs: function(el) {
228
313
  return /vertical-tabs/i.test(el.data('section'));
229
314
  },
230
-
231
- set_active_from_hash : function () {
232
- var hash = window.location.hash.substring(1),
233
- sections = $('[data-section]'),
234
- self = this;
235
- sections.each(function () {
236
- var section = $(this),
237
- settings = $.extend({}, self.settings, self.data_options(section));
238
-
239
- if (hash.length > 0 && settings.deep_linking) {
240
- var regions = section
241
- .children(self.settings.region_selector)
242
- .attr('style', '')
243
- .removeClass('active');
244
-
245
- var hash_regions = regions.map(function () {
246
- var content = $(self.settings.content_selector, this),
247
- content_slug = content.data('slug');
248
-
249
- if (new RegExp(content_slug, 'i').test(hash))
250
- return content;
251
- });
252
-
253
-
254
- var count = hash_regions.length;
255
-
256
- for (var i = count - 1; i >= 0; i--) {
257
- $(hash_regions[i]).parent().addClass('active');
258
- }
259
- }
260
- });
315
+
316
+ is_auto: function (el) {
317
+ var data_section = el.data('section');
318
+ return data_section === '' || /auto/i.test(data_section);
261
319
  },
262
320
 
263
- position_titles : function (section, off) {
264
- var self = this,
265
- titles = section
266
- .children(this.settings.region_selector)
267
- .map(function () {
268
- return $(this).children(self.settings.title_selector);
269
- }),
270
- previous_width = 0,
271
- previous_height = 0,
272
- self = this;
273
-
274
- if (typeof off === 'boolean') {
275
- titles.attr('style', '');
321
+ set_active_from_hash: function() {
322
+ var self = Foundation.libs.section,
323
+ hash = window.location.hash.substring(1),
324
+ sections = $(self.settings.section_selector);
276
325
 
277
- } else {
278
- titles.each(function () {
279
- if (self.is_vertical_tabs(section)) {
280
- $(this).css('top', previous_height);
281
- previous_height += self.outerHeight($(this));
282
- } else {
283
- if (!self.rtl) {
284
- $(this).css('left', previous_width);
326
+ sections.each(function() {
327
+ var section = $(this),
328
+ settings = $.extend({}, self.settings, self.data_options(section)),
329
+ regions = section.children(self.settings.region_selector),
330
+ set_active_from_hash = settings.deep_linking && hash.length > 0,
331
+ selected = false;
332
+
333
+ regions.each(function() {
334
+ var region = $(this);
335
+
336
+ if (selected) {
337
+ region.removeClass(self.settings.active_class);
338
+ } else if (set_active_from_hash) {
339
+ var data_slug = region.children(self.settings.content_selector).data('slug');
340
+
341
+ if (data_slug && new RegExp(data_slug, 'i').test(hash)) {
342
+ if (!region.hasClass(self.settings.active_class))
343
+ region.addClass(self.settings.active_class);
344
+ selected = true;
285
345
  } else {
286
- $(this).css('right', previous_width);
346
+ region.removeClass(self.settings.active_class);
287
347
  }
288
- previous_width += self.outerWidth($(this));
348
+ } else if (region.hasClass(self.settings.active_class)) {
349
+ selected = true;
289
350
  }
290
351
  });
291
- }
292
- },
293
-
294
- position_content : function (section, off) {
295
- var self = this,
296
- regions = section.children(self.settings.region_selector),
297
- titles = regions
298
- .map(function () {
299
- return $(this).children(self.settings.title_selector);
300
- }),
301
- content = regions
302
- .map(function () {
303
- return $(this).children(self.settings.content_selector);
304
- });
305
352
 
306
- if (typeof off === 'boolean') {
307
- content.attr('style', '');
308
- section.attr('style', '');
309
-
310
- // Reset the minHeight and maxWidth values (only applicable to
311
- // vertical tabs)
312
- content.css('minHeight', '');
313
- content.css('maxWidth', '');
314
- } else {
315
- if (self.is_vertical_tabs(section)
316
- && !self.small(section)) {
317
- var content_min_height = 0,
318
- content_min_width = Number.MAX_VALUE,
319
- title_width = null;
320
-
321
- regions.each(function () {
322
- var region = $(this),
323
- title = region.children(self.settings.title_selector),
324
- content = region.children(self.settings.content_selector),
325
- content_width = 0;
326
-
327
- title_width = self.outerWidth(title);
328
- content_width = self.outerWidth(section) - title_width;
329
-
330
- if (content_width < content_min_width) {
331
- content_min_width = content_width;
332
- }
333
-
334
- // Increment the minimum height of the content region
335
- // to align with the height of the titles.
336
- content_min_height += self.outerHeight(title);
337
-
338
- // Set all of the inactive tabs to 'display: none'
339
- // The CSS sets all of the tabs as 'display: block'
340
- // in order to account for scrollbars when measuring the width
341
- // of the content regions.
342
- if (!$(this).hasClass('active')) {
343
- content.css('display', 'none');
344
- }
345
- });
346
-
347
- regions.each(function () {
348
- var content = $(this).children(self.settings.content_selector);
349
- content.css('minHeight', content_min_height);
350
-
351
- // Remove 2 pixels to account for the right-shift in the CSS
352
- content.css('maxWidth', content_min_width - 2);
353
- });
354
-
355
- } else {
356
- regions.each(function () {
357
- var region = $(this),
358
- title = region.children(self.settings.title_selector),
359
- content = region.children(self.settings.content_selector);
360
- if (!self.rtl) {
361
- content
362
- .css({left: title.position().left - 1,
363
- top: self.outerHeight(title) - 2});
364
- } else {
365
- content
366
- .css({right: self.position_right(title) + 1,
367
- top: self.outerHeight(title) - 2});
368
- }
369
- });
370
-
371
- // temporary work around for Zepto outerheight calculation issues.
372
- if (typeof Zepto === 'function') {
373
- section.height(this.outerHeight($(titles[0])));
374
- } else {
375
- section.height(this.outerHeight($(titles[0])) - 2);
376
- }
377
- }
378
- }
353
+ if (!selected && !settings.deep_linking && (settings.one_up || !self.is_horizontal_nav(section) &&
354
+ !self.is_vertical_nav(section) && !self.is_accordion(section)))
355
+ regions.filter(":visible").first().addClass(self.settings.active_class);
356
+ });
379
357
  },
380
358
 
381
- position_right : function (el) {
382
- var self = this,
383
- section = el.closest(this.settings.section_selector),
384
- regions = section.children(this.settings.region_selector),
385
- section_width = el.closest(this.settings.section_selector).width(),
386
- offset = regions
387
- .map(function () {
388
- return $(this).children(self.settings.title_selector);
389
- }).length;
390
- return (section_width - el.position().left - el.width() * (el.index() + 1) - offset);
391
- },
359
+ reflow: function() {
360
+ var self = Foundation.libs.section;
392
361
 
393
- reflow : function (scope) {
394
- var scope = scope || document;
395
- $(this.settings.section_selector, scope).trigger('resize');
362
+ $(self.settings.section_selector).removeAttr(self.settings.resized_data_attr);
363
+ self.throttle(function() { self.resize(); }, 30)();
396
364
  },
397
365
 
398
- small : function (el) {
366
+ small: function(el) {
399
367
  var settings = $.extend({}, this.settings, this.data_options(el));
400
368
 
401
369
  if (this.is_horizontal_tabs(el)) {
@@ -413,10 +381,21 @@
413
381
  return $(this.scope).width() < settings.small_breakpoint;
414
382
  },
415
383
 
416
- off : function () {
384
+ off: function() {
417
385
  $(this.scope).off('.fndtn.section');
418
386
  $(window).off('.fndtn.section');
419
- $(document).off('.fndtn.section')
387
+ $(document).off('.fndtn.section');
420
388
  }
421
389
  };
422
- }(Foundation.zj, this, this.document));
390
+
391
+ //resize selected sections
392
+ $.fn.reflow_section = function(ensure_has_active_region) {
393
+ var section = this,
394
+ self = Foundation.libs.section;
395
+
396
+ section.removeAttr(self.settings.resized_data_attr);
397
+ self.throttle(function() { self.resize(section, ensure_has_active_region); }, 30)();
398
+ return this;
399
+ };
400
+
401
+ }(Foundation.zj, window, document));