zurb-foundation 4.3.1 → 4.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/Gemfile.lock +31 -2
  4. data/Gruntfile.js +54 -10
  5. data/LICENSE +2 -2
  6. data/README.md +11 -2
  7. data/Rakefile +9 -0
  8. data/docs/CHANGELOG.md +9 -0
  9. data/docs/Procfile +2 -2
  10. data/docs/components/abide.html.erb +30 -6
  11. data/docs/components/alert-boxes.html.erb +35 -10
  12. data/docs/components/block-grid.html.erb +1 -1
  13. data/docs/components/breadcrumbs.html.erb +4 -4
  14. data/docs/components/button-groups.html.erb +2 -2
  15. data/docs/components/buttons.html.erb +10 -10
  16. data/docs/components/clearing.html.erb +28 -2
  17. data/docs/components/custom-forms.html.erb +9 -1
  18. data/docs/components/dropdown-buttons.html.erb +36 -11
  19. data/docs/components/dropdown.html.erb +44 -13
  20. data/docs/components/flex-video.html.erb +3 -3
  21. data/docs/components/forms.html.erb +10 -10
  22. data/docs/components/global.html.erb +15 -20
  23. data/docs/components/grid.html.erb +24 -23
  24. data/docs/components/inline-lists.html.erb +3 -3
  25. data/docs/components/interchange.html.erb +28 -2
  26. data/docs/components/joyride.html.erb +34 -10
  27. data/docs/components/keystrokes.html.erb +3 -3
  28. data/docs/components/kitchen-sink.html.erb +1 -1
  29. data/docs/components/labels.html.erb +3 -3
  30. data/docs/components/magellan.html.erb +25 -2
  31. data/docs/components/orbit.html.erb +39 -9
  32. data/docs/components/pagination.html.erb +7 -7
  33. data/docs/components/panels.html.erb +3 -3
  34. data/docs/components/pricing-tables.html.erb +11 -11
  35. data/docs/components/progress-bars.html.erb +5 -5
  36. data/docs/components/reveal.html.erb +31 -8
  37. data/docs/components/section.html.erb +61 -37
  38. data/docs/components/side-nav.html.erb +4 -4
  39. data/docs/components/split-buttons.html.erb +37 -15
  40. data/docs/components/sub-nav.html.erb +10 -6
  41. data/docs/components/switch.html.erb +2 -2
  42. data/docs/components/tables.html.erb +7 -7
  43. data/docs/components/tooltips.html.erb +30 -6
  44. data/docs/components/top-bar.html.erb +101 -13
  45. data/docs/components/type.html.erb +16 -16
  46. data/docs/config.ru +18 -1
  47. data/docs/controller.rb +1 -1
  48. data/docs/css/_coderay.scss +2 -2
  49. data/docs/css/_footer.scss +7 -7
  50. data/docs/css/_offcanvas.scss +16 -16
  51. data/docs/css/docs.scss +1 -3
  52. data/docs/index.html.erb +29 -29
  53. data/docs/layout.html.erb +5 -5
  54. data/docs/media-queries.html.erb +3 -3
  55. data/docs/rails.html.erb +2 -1
  56. data/docs/sass.html.erb +188 -146
  57. data/docs/support.html.erb +2 -2
  58. data/foundation.gemspec +1 -0
  59. data/js/foundation/foundation.abide.js +5 -5
  60. data/js/foundation/foundation.alerts.js +9 -4
  61. data/js/foundation/foundation.clearing.js +2 -2
  62. data/js/foundation/foundation.dropdown.js +11 -5
  63. data/js/foundation/foundation.forms.js +51 -28
  64. data/js/foundation/foundation.joyride.js +7 -5
  65. data/js/foundation/foundation.js +25 -1
  66. data/js/foundation/foundation.magellan.js +3 -2
  67. data/js/foundation/foundation.orbit.js +78 -58
  68. data/js/foundation/foundation.placeholder.js +424 -177
  69. data/js/foundation/foundation.reveal.js +39 -16
  70. data/js/foundation/foundation.section.js +62 -32
  71. data/js/foundation/foundation.tooltips.js +3 -2
  72. data/js/foundation/foundation.topbar.js +139 -69
  73. data/lib/foundation/generators/templates/application.html.erb +2 -1
  74. data/lib/foundation/version.rb +1 -1
  75. data/lib/zurb-foundation.rb +12 -0
  76. data/package.json +4 -3
  77. data/scss/foundation/_variables.scss +183 -159
  78. data/scss/foundation/components/_alert-boxes.scss +8 -8
  79. data/scss/foundation/components/_block-grid.scss +1 -1
  80. data/scss/foundation/components/_breadcrumbs.scss +3 -3
  81. data/scss/foundation/components/_button-groups.scss +2 -2
  82. data/scss/foundation/components/_buttons.scss +20 -20
  83. data/scss/foundation/components/_custom-forms.scss +19 -14
  84. data/scss/foundation/components/_dropdown-buttons.scss +8 -8
  85. data/scss/foundation/components/_dropdown.scss +4 -4
  86. data/scss/foundation/components/_flex-video.scss +2 -2
  87. data/scss/foundation/components/_forms.scss +28 -18
  88. data/scss/foundation/components/_global.scss +43 -18
  89. data/scss/foundation/components/_grid-5.scss +4 -4
  90. data/scss/foundation/components/_grid.scss +6 -4
  91. data/scss/foundation/components/_inline-lists.scss +3 -3
  92. data/scss/foundation/components/_joyride.scss +10 -10
  93. data/scss/foundation/components/_keystrokes.scss +2 -2
  94. data/scss/foundation/components/_labels.scss +2 -2
  95. data/scss/foundation/components/_orbit.scss +58 -44
  96. data/scss/foundation/components/_pagination.scss +6 -6
  97. data/scss/foundation/components/_panels.scss +7 -4
  98. data/scss/foundation/components/_pricing-tables.scss +10 -10
  99. data/scss/foundation/components/_progress-bars.scss +3 -3
  100. data/scss/foundation/components/_reveal.scss +5 -5
  101. data/scss/foundation/components/_section.scss +21 -21
  102. data/scss/foundation/components/_side-nav.scss +3 -3
  103. data/scss/foundation/components/_split-buttons.scss +7 -7
  104. data/scss/foundation/components/_sub-nav.scss +26 -10
  105. data/scss/foundation/components/_switch.scss +15 -11
  106. data/scss/foundation/components/_tables.scss +6 -6
  107. data/scss/foundation/components/_thumbs.scss +2 -4
  108. data/scss/foundation/components/_tooltips.scss +4 -4
  109. data/scss/foundation/components/_top-bar.scss +77 -39
  110. data/scss/foundation/components/_type.scss +25 -23
  111. data/scss/foundation/components/_visibility.scss +28 -28
  112. data/scss/normalize.scss +22 -14
  113. data/spec/js/SectionSpec.js +39 -0
  114. data/spec/js/helpers/SectionSpecHelper.js +22 -0
  115. data/spec/js/helpers/SpecHelper.js +19 -0
  116. metadata +32 -25
  117. data/.rbenv-version +0 -1
@@ -6,7 +6,7 @@
6
6
  Foundation.libs.reveal = {
7
7
  name : 'reveal',
8
8
 
9
- version : '4.2.2',
9
+ version : '4.3.2',
10
10
 
11
11
  locked : false,
12
12
 
@@ -77,24 +77,37 @@
77
77
  }
78
78
  }
79
79
  })
80
- .on('click.fndtn.reveal', this.close_targets(), function (e) {
80
+ .on('click.fndtn.reveal touchend', this.close_targets(), function (e) {
81
81
  e.preventDefault();
82
82
  if (!self.locked) {
83
- var settings = $.extend({}, self.settings, self.data_options($('.reveal-modal.open')));
84
- if ($(e.target)[0] === $('.' + settings.bgClass)[0] && !settings.closeOnBackgroundClick) {
83
+ var settings = $.extend({}, self.settings, self.data_options($('.reveal-modal.open'))),
84
+ bgClicked = $(e.target)[0] === $('.' + settings.bgClass)[0];
85
+ if (bgClicked && !settings.closeOnBackgroundClick) {
85
86
  return;
86
87
  }
87
88
 
88
89
  self.locked = true;
89
- self.close.call(self, $(this).closest('.reveal-modal'));
90
+ self.close.call(self, bgClicked ? $('.reveal-modal.open') : $(this).closest('.reveal-modal'));
90
91
  }
91
- })
92
- .on('open.fndtn.reveal', '.reveal-modal', this.settings.open)
93
- .on('opened.fndtn.reveal', '.reveal-modal', this.settings.opened)
94
- .on('opened.fndtn.reveal', '.reveal-modal', this.open_video)
95
- .on('close.fndtn.reveal', '.reveal-modal', this.settings.close)
96
- .on('closed.fndtn.reveal', '.reveal-modal', this.settings.closed)
97
- .on('closed.fndtn.reveal', '.reveal-modal', this.close_video);
92
+ });
93
+
94
+ if($(this.scope).hasClass('reveal-modal')) {
95
+ $(this.scope)
96
+ .on('open.fndtn.reveal', this.settings.open)
97
+ .on('opened.fndtn.reveal', this.settings.opened)
98
+ .on('opened.fndtn.reveal', this.open_video)
99
+ .on('close.fndtn.reveal', this.settings.close)
100
+ .on('closed.fndtn.reveal', this.settings.closed)
101
+ .on('closed.fndtn.reveal', this.close_video);
102
+ } else {
103
+ $(this.scope)
104
+ .on('open.fndtn.reveal', '.reveal-modal', this.settings.open)
105
+ .on('opened.fndtn.reveal', '.reveal-modal', this.settings.opened)
106
+ .on('opened.fndtn.reveal', '.reveal-modal', this.open_video)
107
+ .on('close.fndtn.reveal', '.reveal-modal', this.settings.close)
108
+ .on('closed.fndtn.reveal', '.reveal-modal', this.settings.closed)
109
+ .on('closed.fndtn.reveal', '.reveal-modal', this.close_video);
110
+ }
98
111
 
99
112
  $( 'body' ).bind( 'keyup.reveal', function ( event ) {
100
113
  var open_modal = $('.reveal-modal.open'),
@@ -131,7 +144,7 @@
131
144
  modal.trigger('open');
132
145
 
133
146
  if (open_modal.length < 1) {
134
- this.toggle_bg(modal);
147
+ this.toggle_bg();
135
148
  }
136
149
 
137
150
  if (typeof ajax_settings === 'undefined' || !ajax_settings.url) {
@@ -168,7 +181,7 @@
168
181
  if (open_modals.length > 0) {
169
182
  this.locked = true;
170
183
  modal.trigger('close');
171
- this.toggle_bg(modal);
184
+ this.toggle_bg();
172
185
  this.hide(open_modals, this.settings.css.close);
173
186
  }
174
187
  },
@@ -183,8 +196,8 @@
183
196
  return base;
184
197
  },
185
198
 
186
- toggle_bg : function (modal) {
187
- if ($('.reveal-modal-bg').length === 0) {
199
+ toggle_bg : function () {
200
+ if ($('.' + this.settings.bgClass).length === 0) {
188
201
  this.settings.bg = $('<div />', {'class': this.settings.bgClass})
189
202
  .appendTo('body');
190
203
  }
@@ -199,6 +212,16 @@
199
212
  show : function (el, css) {
200
213
  // is modal
201
214
  if (css) {
215
+ if (el.parent('body').length === 0) {
216
+ var placeholder = el.wrap('<div style="display: none;" />').parent();
217
+ el.on('closed.fndtn.reveal.wrapped', function() {
218
+ el.detach().appendTo(placeholder);
219
+ el.unwrap().unbind('closed.fndtn.reveal.wrapped');
220
+ });
221
+
222
+ el.detach().appendTo('body');
223
+ }
224
+
202
225
  if (/pop/i.test(this.settings.animation)) {
203
226
  css.top = $(window).scrollTop() - el.data('offset') + 'px';
204
227
  var end_css = {
@@ -7,12 +7,13 @@
7
7
  Foundation.libs.section = {
8
8
  name : 'section',
9
9
 
10
- version : '4.3.1',
10
+ version : '4.3.2',
11
11
 
12
12
  settings: {
13
13
  deep_linking: false,
14
14
  small_breakpoint: 768,
15
15
  one_up: true,
16
+ multi_expand: false,
16
17
  section_selector: '[data-section]',
17
18
  region_selector: 'section, .section, [data-section-region]',
18
19
  title_selector: '.title, [data-section-title]',
@@ -122,12 +123,17 @@
122
123
  e.stopPropagation(); //do not catch same click again on parent
123
124
 
124
125
  if (!region.hasClass(self.settings.active_class)) {
125
- prev_active_region.removeClass(self.settings.active_class);
126
+ if (!self.is_accordion(section) || (self.is_accordion(section) && !self.settings.multi_expand)) {
127
+ prev_active_region.removeClass(self.settings.active_class);
128
+ prev_active_region.trigger('closed.fndtn.section');
129
+ }
126
130
  region.addClass(self.settings.active_class);
127
131
  //force resize for better performance (do not wait timer)
128
132
  self.resize(region.find(self.settings.section_selector).not("[" + self.settings.resized_data_attr + "]"), true);
129
- } else if (!settings.one_up && (self.small(section) || self.is_vertical_nav(section) || self.is_horizontal_nav(section) || self.is_accordion(section))) {
133
+ region.trigger('opened.fndtn.section');
134
+ } else if (region.hasClass(self.settings.active_class) && self.is_accordion(section) || !settings.one_up && (self.small(section) || self.is_vertical_nav(section) || self.is_horizontal_nav(section) || self.is_accordion(section))) {
130
135
  region.removeClass(self.settings.active_class);
136
+ region.trigger('closed.fndtn.section');
131
137
  }
132
138
  settings.callback(section);
133
139
  },
@@ -143,7 +149,8 @@
143
149
  resize: function(sections, ensure_has_active_region) {
144
150
 
145
151
  var self = Foundation.libs.section,
146
- is_small_window = self.small($(document)),
152
+ section_container = $(self.settings.section_selector),
153
+ is_small_window = self.small(section_container),
147
154
  //filter for section resize
148
155
  should_be_resized = function (section, now_is_hidden) {
149
156
  return !self.is_accordion(section) &&
@@ -322,37 +329,60 @@
322
329
  hash = window.location.hash.substring(1),
323
330
  sections = $(self.settings.section_selector);
324
331
 
332
+ var selectedSection;
333
+
325
334
  sections.each(function() {
326
- var section = $(this),
327
- settings = $.extend({}, self.settings, self.data_options(section)),
328
- regions = section.children(self.settings.region_selector),
329
- set_active_from_hash = settings.deep_linking && hash.length > 0,
330
- selected = false;
331
-
332
- regions.each(function() {
333
- var region = $(this);
334
-
335
- if (selected) {
336
- region.removeClass(self.settings.active_class);
337
- } else if (set_active_from_hash) {
338
- var data_slug = region.children(self.settings.content_selector).data('slug');
339
-
340
- if (data_slug && new RegExp(data_slug, 'i').test(hash)) {
341
- if (!region.hasClass(self.settings.active_class))
342
- region.addClass(self.settings.active_class);
343
- selected = true;
344
- } else {
345
- region.removeClass(self.settings.active_class);
346
- }
347
- } else if (region.hasClass(self.settings.active_class)) {
348
- selected = true;
335
+ var section = $(this),
336
+ regions = section.children(self.settings.region_selector);
337
+ regions.each(function() {
338
+ var region = $(this),
339
+ data_slug = region.children(self.settings.content_selector).data('slug');
340
+ if (new RegExp(data_slug, 'i').test(hash)) {
341
+ selectedSection=section;
342
+ return false;
343
+ }
344
+ });
345
+
346
+ if (selectedSection != null) {
347
+ return false;
349
348
  }
350
- });
351
-
352
- if (!selected && !settings.deep_linking && (settings.one_up || !self.is_horizontal_nav(section) &&
353
- !self.is_vertical_nav(section) && !self.is_accordion(section)))
354
- regions.filter(":visible").first().addClass(self.settings.active_class);
355
349
  });
350
+
351
+ if (selectedSection != null) {
352
+ sections.each(function() {
353
+ if (selectedSection == $(this)) {
354
+ var section = $(this),
355
+ settings = $.extend({}, self.settings, self.data_options(section)),
356
+ regions = section.children(self.settings.region_selector),
357
+ set_active_from_hash = settings.deep_linking && hash.length > 0,
358
+ selected = false;
359
+
360
+ regions.each(function() {
361
+ var region = $(this);
362
+
363
+ if (selected) {
364
+ region.removeClass(self.settings.active_class);
365
+ } else if (set_active_from_hash) {
366
+ var data_slug = region.children(self.settings.content_selector).data('slug');
367
+
368
+ if (data_slug && new RegExp(data_slug, 'i').test(hash)) {
369
+ if (!region.hasClass(self.settings.active_class))
370
+ region.addClass(self.settings.active_class);
371
+ selected = true;
372
+ } else {
373
+ region.removeClass(self.settings.active_class);
374
+ }
375
+ } else if (region.hasClass(self.settings.active_class)) {
376
+ selected = true;
377
+ }
378
+ });
379
+
380
+ if (!selected && (settings.one_up || !self.is_horizontal_nav(section) &&
381
+ !self.is_vertical_nav(section) && !self.is_accordion(section)))
382
+ regions.filter(":visible").first().addClass(self.settings.active_class);
383
+ }
384
+ });
385
+ }
356
386
  },
357
387
 
358
388
  reflow: function() {
@@ -6,12 +6,13 @@
6
6
  Foundation.libs.tooltips = {
7
7
  name : 'tooltips',
8
8
 
9
- version : '4.2.2',
9
+ version : '4.3.2',
10
10
 
11
11
  settings : {
12
12
  selector : '.has-tip',
13
13
  additionalInheritableClasses : [],
14
14
  tooltipClass : '.tooltip',
15
+ touchCloseText: 'tap to close',
15
16
  appendTo: 'body',
16
17
  'disable-for-touch': false,
17
18
  tipTemplate : function (selector, content) {
@@ -110,7 +111,7 @@
110
111
 
111
112
  $tip.addClass(classes).appendTo(this.settings.appendTo);
112
113
  if (Modernizr.touch) {
113
- $tip.append('<span class="tap-to-close">tap to close </span>');
114
+ $tip.append('<span class="tap-to-close">'+this.settings.touchCloseText+'</span>');
114
115
  }
115
116
  $target.removeAttr('title').attr('title','');
116
117
  this.show($target);
@@ -6,7 +6,7 @@
6
6
  Foundation.libs.topbar = {
7
7
  name : 'topbar',
8
8
 
9
- version: '4.3.1',
9
+ version: '4.3.2',
10
10
 
11
11
  settings : {
12
12
  index : 0,
@@ -14,13 +14,13 @@
14
14
  custom_back_text: true,
15
15
  back_text: 'Back',
16
16
  is_hover: true,
17
- mobile_show_parent_link: true,
17
+ mobile_show_parent_link: false,
18
18
  scrolltop : true, // jump to top when sticky nav menu toggle is clicked
19
19
  init : false
20
20
  },
21
21
 
22
22
  init : function (section, method, options) {
23
- Foundation.inherit(this, 'data_options');
23
+ Foundation.inherit(this, 'data_options addCustomRule');
24
24
  var self = this;
25
25
 
26
26
  if (typeof method === 'object') {
@@ -39,6 +39,14 @@
39
39
  self.settings.$titlebar = self.settings.$topbar.children('ul').first();
40
40
  self.settings.$topbar.data('index', 0);
41
41
 
42
+ var topbarContainer = self.settings.$topbar.parent();
43
+ if(topbarContainer.hasClass('fixed') || topbarContainer.hasClass(self.settings.stickyClass)) {
44
+ self.settings.$topbar.data('height', self.outerHeight(topbarContainer));
45
+ self.settings.$topbar.data('stickyoffset', topbarContainer.offset().top);
46
+ } else {
47
+ self.settings.$topbar.data('height', self.outerHeight(self.settings.$topbar));
48
+ }
49
+
42
50
  var breakpoint = $("<div class='top-bar-js-breakpoint'/>").insertAfter(self.settings.$topbar);
43
51
  self.settings.breakPoint = breakpoint.width();
44
52
  breakpoint.remove();
@@ -49,8 +57,11 @@
49
57
  self.settings.$topbar.find('.has-dropdown').addClass('not-click');
50
58
  }
51
59
 
60
+ // Pad body when sticky (scrolled) or fixed.
61
+ self.addCustomRule('.f-topbar-fixed { padding-top: ' + self.settings.$topbar.data('height') + 'px }');
62
+
52
63
  if (self.settings.$topbar.parent().hasClass('fixed')) {
53
- $('body').css('padding-top', self.outerHeight(self.settings.$topbar));
64
+ $('body').addClass('f-topbar-fixed');
54
65
  }
55
66
  });
56
67
 
@@ -65,62 +76,88 @@
65
76
  }
66
77
  },
67
78
 
68
- timer : null,
69
-
70
- events : function () {
79
+ toggle: function() {
71
80
  var self = this;
72
- var offst = this.outerHeight($('.top-bar, [data-topbar]'));
73
- $(this.scope)
74
- .off('.fndtn.topbar')
75
- .on('click.fndtn.topbar', '.top-bar .toggle-topbar, [data-topbar] .toggle-topbar', function (e) {
76
- var topbar = $(this).closest('.top-bar, [data-topbar]'),
77
- section = topbar.find('section, .section'),
78
- titlebar = topbar.children('ul').first();
81
+ var topbar = $('.top-bar, [data-topbar]'),
82
+ section = topbar.find('section, .section');
79
83
 
80
- e.preventDefault();
84
+ if (self.breakpoint()) {
85
+ if (!self.rtl) {
86
+ section.css({left: '0%'});
87
+ section.find('>.name').css({left: '100%'});
88
+ } else {
89
+ section.css({right: '0%'});
90
+ section.find('>.name').css({right: '100%'});
91
+ }
81
92
 
82
- if (self.breakpoint()) {
83
- if (!self.rtl) {
84
- section.css({left: '0%'});
85
- section.find('>.name').css({left: '100%'});
86
- } else {
87
- section.css({right: '0%'});
88
- section.find('>.name').css({right: '100%'});
89
- }
93
+ section.find('li.moved').removeClass('moved');
94
+ topbar.data('index', 0);
95
+
96
+ topbar
97
+ .toggleClass('expanded')
98
+ .css('height', '');
99
+ }
90
100
 
91
- section.find('li.moved').removeClass('moved');
92
- topbar.data('index', 0);
101
+ if(self.settings.scrolltop)
102
+ {
103
+ if (!topbar.hasClass('expanded')) {
104
+ if (topbar.hasClass('fixed')) {
105
+ topbar.parent().addClass('fixed');
106
+ topbar.removeClass('fixed');
107
+ $('body').addClass('f-topbar-fixed');
108
+ }
109
+ } else if (topbar.parent().hasClass('fixed')) {
110
+ if (self.settings.scrolltop) {
111
+ topbar.parent().removeClass('fixed');
112
+ topbar.addClass('fixed');
113
+ $('body').removeClass('f-topbar-fixed');
93
114
 
94
- topbar
95
- .toggleClass('expanded')
96
- .css('height', '');
115
+ window.scrollTo(0,0);
116
+ } else {
117
+ topbar.parent().removeClass('expanded');
97
118
  }
119
+ }
120
+ } else {
121
+ if(topbar.parent().hasClass(self.settings.stickyClass)) {
122
+ topbar.parent().addClass('fixed');
123
+ }
98
124
 
125
+ if(topbar.parent().hasClass('fixed')) {
99
126
  if (!topbar.hasClass('expanded')) {
100
- if (topbar.hasClass('fixed')) {
101
- topbar.parent().addClass('fixed');
102
- topbar.removeClass('fixed');
103
- $('body').css('padding-top',offst);
104
- }
105
- } else if (topbar.parent().hasClass('fixed')) {
106
- topbar.parent().removeClass('fixed');
127
+ topbar.removeClass('fixed');
128
+ topbar.parent().removeClass('expanded');
129
+ self.updateStickyPositioning();
130
+ } else {
107
131
  topbar.addClass('fixed');
108
- $('body').css('padding-top','0');
109
-
110
- if (self.settings.scrolltop) {
111
- window.scrollTo(0,0);
112
- }
132
+ topbar.parent().addClass('expanded');
113
133
  }
134
+ }
135
+ }
136
+ },
137
+
138
+ timer : null,
139
+
140
+ events : function () {
141
+ var self = this;
142
+ $(this.scope)
143
+ .off('.fndtn.topbar')
144
+ .on('click.fndtn.topbar', '.top-bar .toggle-topbar, [data-topbar] .toggle-topbar', function (e) {
145
+ e.preventDefault();
146
+ self.toggle();
114
147
  })
115
148
 
116
149
  .on('click.fndtn.topbar', '.top-bar li.has-dropdown', function (e) {
117
- if (self.breakpoint()) return;
118
-
119
150
  var li = $(this),
120
151
  target = $(e.target),
121
152
  topbar = li.closest('[data-topbar], .top-bar'),
122
153
  is_hover = topbar.data('topbar');
123
154
 
155
+ if(target.data('revealId')) {
156
+ self.toggle();
157
+ return;
158
+ }
159
+
160
+ if (self.breakpoint()) return;
124
161
  if (self.settings.is_hover && !Modernizr.touch) return;
125
162
 
126
163
  e.stopImmediatePropagation();
@@ -134,19 +171,22 @@
134
171
  .removeClass('hover')
135
172
  .find('li')
136
173
  .removeClass('hover');
174
+
175
+ li.parents('li.hover')
176
+ .removeClass('hover');
137
177
  } else {
138
178
  li.addClass('hover');
139
179
  }
140
180
  })
141
181
 
142
182
  .on('click.fndtn.topbar', '.top-bar .has-dropdown>a, [data-topbar] .has-dropdown>a', function (e) {
143
- if (self.breakpoint()) {
183
+ if (self.breakpoint() && $(window).width() != self.settings.breakPoint) {
184
+
144
185
  e.preventDefault();
145
186
 
146
187
  var $this = $(this),
147
188
  topbar = $this.closest('.top-bar, [data-topbar]'),
148
189
  section = topbar.find('section, .section'),
149
- titlebar = topbar.children('ul').first(),
150
190
  dropdownHeight = $this.next('.dropdown').outerHeight(),
151
191
  $selectedLi = $this.closest('li');
152
192
 
@@ -161,22 +201,49 @@
161
201
  section.find('>.name').css({right: 100 * topbar.data('index') + '%'});
162
202
  }
163
203
 
164
- topbar.css('height', self.outerHeight($this.siblings('ul'), true) + self.height(titlebar));
204
+ topbar.css('height', self.outerHeight($this.siblings('ul'), true) + self.settings.$topbar.data('height'));
165
205
  }
166
206
  });
167
207
 
168
208
  $(window).on('resize.fndtn.topbar', function () {
209
+ if (typeof self.settings.$topbar === 'undefined') { return; }
210
+ var stickyContainer = self.settings.$topbar.parent('.' + this.settings.stickyClass);
211
+ var stickyOffset;
212
+
169
213
  if (!self.breakpoint()) {
214
+ var doToggle = self.settings.$topbar.hasClass('expanded');
170
215
  $('.top-bar, [data-topbar]')
171
216
  .css('height', '')
172
217
  .removeClass('expanded')
173
218
  .find('li')
174
219
  .removeClass('hover');
220
+
221
+ if(doToggle) {
222
+ self.toggle();
223
+ }
224
+ }
225
+
226
+ if(stickyContainer.length > 0) {
227
+ if(stickyContainer.hasClass('fixed')) {
228
+ // Remove the fixed to allow for correct calculation of the offset.
229
+ stickyContainer.removeClass('fixed');
230
+
231
+ stickyOffset = stickyContainer.offset().top;
232
+ if($(document.body).hasClass('f-topbar-fixed')) {
233
+ stickyOffset -= self.settings.$topbar.data('height');
234
+ }
235
+
236
+ self.settings.$topbar.data('stickyoffset', stickyOffset);
237
+ stickyContainer.addClass('fixed');
238
+ } else {
239
+ stickyOffset = stickyContainer.offset().top;
240
+ self.settings.$topbar.data('stickyoffset', stickyOffset);
241
+ }
175
242
  }
176
243
  }.bind(this));
177
244
 
178
245
  $('body').on('click.fndtn.topbar', function (e) {
179
- var parent = $(e.target).closest('[data-topbar], .top-bar');
246
+ var parent = $(e.target).closest('li').closest('li.hover');
180
247
 
181
248
  if (parent.length > 0) {
182
249
  return;
@@ -191,7 +258,6 @@
191
258
 
192
259
  var $this = $(this),
193
260
  topbar = $this.closest('.top-bar, [data-topbar]'),
194
- titlebar = topbar.children('ul').first(),
195
261
  section = topbar.find('section, .section'),
196
262
  $movedLi = $this.closest('li.moved'),
197
263
  $previousLevelUl = $movedLi.parent();
@@ -209,7 +275,7 @@
209
275
  if (topbar.data('index') === 0) {
210
276
  topbar.css('height', '');
211
277
  } else {
212
- topbar.css('height', self.outerHeight($previousLevelUl, true) + self.height(titlebar));
278
+ topbar.css('height', self.outerHeight($previousLevelUl, true) + self.settings.$topbar.data('height'));
213
279
  }
214
280
 
215
281
  setTimeout(function () {
@@ -240,7 +306,7 @@
240
306
 
241
307
  // Copy link to subnav
242
308
  if (self.settings.custom_back_text == true) {
243
- $titleLi.find('h5>a').html('&laquo; ' + self.settings.back_text);
309
+ $titleLi.find('h5>a').html(self.settings.back_text);
244
310
  } else {
245
311
  $titleLi.find('h5>a').html('&laquo; ' + $link.html());
246
312
  }
@@ -264,29 +330,33 @@
264
330
  },
265
331
 
266
332
  sticky : function () {
333
+ var $window = $(window),
334
+ self = this;
335
+
336
+ $window.scroll(function() {
337
+ self.updateStickyPositioning();
338
+ });
339
+ },
340
+
341
+ updateStickyPositioning: function() {
267
342
  var klass = '.' + this.settings.stickyClass;
343
+ var $window = $(window);
344
+
268
345
  if ($(klass).length > 0) {
269
- var distance = $(klass).length ? $(klass).offset().top: 0,
270
- $window = $(window),
271
- offst = this.outerHeight($('.top-bar')),
272
- t_top;
273
-
274
- //Whe resize elements of the page on windows resize. Must recalculate distance
275
- $(window).resize(function() {
276
- clearTimeout(t_top);
277
- t_top = setTimeout (function() {
278
- distance = $(klass).offset().top;
279
- },105);
280
- });
281
- $window.scroll(function() {
282
- if ($window.scrollTop() > (distance)) {
283
- $(klass).addClass("fixed");
284
- $('body').css('padding-top',offst);
285
- } else if ($window.scrollTop() <= distance) {
286
- $(klass).removeClass("fixed");
287
- $('body').css('padding-top','0');
346
+ var distance = this.settings.$topbar.data('stickyoffset');
347
+ if (!$(klass).hasClass('expanded')) {
348
+ if ($window.scrollTop() > (distance)) {
349
+ if (!$(klass).hasClass('fixed')) {
350
+ $(klass).addClass('fixed');
351
+ $('body').addClass('f-topbar-fixed');
288
352
  }
289
- });
353
+ } else if ($window.scrollTop() <= distance) {
354
+ if ($(klass).hasClass('fixed')) {
355
+ $(klass).removeClass('fixed');
356
+ $('body').removeClass('f-topbar-fixed');
357
+ }
358
+ }
359
+ }
290
360
  }
291
361
  },
292
362