foundation_front_end 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +64 -0
  6. data/Rakefile +1 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +7 -0
  9. data/foundation_front_end.gemspec +32 -0
  10. data/lib/foundation_front_end.rb +21 -0
  11. data/lib/foundation_front_end/version.rb +3 -0
  12. data/vendor/assets/javascripts/foundation.min.js +6376 -0
  13. data/vendor/assets/javascripts/foundation/foundation.abide.js +408 -0
  14. data/vendor/assets/javascripts/foundation/foundation.accordion.js +88 -0
  15. data/vendor/assets/javascripts/foundation/foundation.alert.js +43 -0
  16. data/vendor/assets/javascripts/foundation/foundation.clearing.js +586 -0
  17. data/vendor/assets/javascripts/foundation/foundation.dropdown.js +463 -0
  18. data/vendor/assets/javascripts/foundation/foundation.equalizer.js +104 -0
  19. data/vendor/assets/javascripts/foundation/foundation.interchange.js +359 -0
  20. data/vendor/assets/javascripts/foundation/foundation.joyride.js +932 -0
  21. data/vendor/assets/javascripts/foundation/foundation.js +725 -0
  22. data/vendor/assets/javascripts/foundation/foundation.magellan.js +215 -0
  23. data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +152 -0
  24. data/vendor/assets/javascripts/foundation/foundation.orbit.js +476 -0
  25. data/vendor/assets/javascripts/foundation/foundation.reveal.js +498 -0
  26. data/vendor/assets/javascripts/foundation/foundation.slider.js +281 -0
  27. data/vendor/assets/javascripts/foundation/foundation.tab.js +249 -0
  28. data/vendor/assets/javascripts/foundation/foundation.tooltip.js +339 -0
  29. data/vendor/assets/javascripts/foundation/foundation.topbar.js +458 -0
  30. data/vendor/assets/javascripts/vendor/fastclick.js +8 -0
  31. data/vendor/assets/javascripts/vendor/jquery.cookie.js +8 -0
  32. data/vendor/assets/javascripts/vendor/jquery.js +27 -0
  33. data/vendor/assets/javascripts/vendor/modernizr.js +8 -0
  34. data/vendor/assets/javascripts/vendor/placeholder.js +2 -0
  35. data/vendor/assets/stylesheets/foundation.css +6324 -0
  36. data/vendor/assets/stylesheets/foundation.min.css +1 -0
  37. data/vendor/assets/stylesheets/normalize.css +424 -0
  38. metadata +110 -0
@@ -0,0 +1,339 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs.tooltip = {
5
+ name : 'tooltip',
6
+
7
+ version : '5.5.2',
8
+
9
+ settings : {
10
+ additional_inheritable_classes : [],
11
+ tooltip_class : '.tooltip',
12
+ append_to : 'body',
13
+ touch_close_text : 'Tap To Close',
14
+ disable_for_touch : false,
15
+ hover_delay : 200,
16
+ show_on : 'all',
17
+ tip_template : function (selector, content) {
18
+ return '<span data-selector="' + selector + '" id="' + selector + '" class="'
19
+ + Foundation.libs.tooltip.settings.tooltip_class.substring(1)
20
+ + '" role="tooltip">' + content + '<span class="nub"></span></span>';
21
+ }
22
+ },
23
+
24
+ cache : {},
25
+
26
+ init : function (scope, method, options) {
27
+ Foundation.inherit(this, 'random_str');
28
+ this.bindings(method, options);
29
+ },
30
+
31
+ should_show : function (target, tip) {
32
+ var settings = $.extend({}, this.settings, this.data_options(target));
33
+
34
+ if (settings.show_on === 'all') {
35
+ return true;
36
+ } else if (this.small() && settings.show_on === 'small') {
37
+ return true;
38
+ } else if (this.medium() && settings.show_on === 'medium') {
39
+ return true;
40
+ } else if (this.large() && settings.show_on === 'large') {
41
+ return true;
42
+ }
43
+ return false;
44
+ },
45
+
46
+ medium : function () {
47
+ return matchMedia(Foundation.media_queries['medium']).matches;
48
+ },
49
+
50
+ large : function () {
51
+ return matchMedia(Foundation.media_queries['large']).matches;
52
+ },
53
+
54
+ events : function (instance) {
55
+ var self = this,
56
+ S = self.S;
57
+
58
+ self.create(this.S(instance));
59
+
60
+ function _startShow(elt, $this, immediate) {
61
+ if (elt.timer) {
62
+ return;
63
+ }
64
+
65
+ if (immediate) {
66
+ elt.timer = null;
67
+ self.showTip($this);
68
+ } else {
69
+ elt.timer = setTimeout(function () {
70
+ elt.timer = null;
71
+ self.showTip($this);
72
+ }.bind(elt), self.settings.hover_delay);
73
+ }
74
+ }
75
+
76
+ function _startHide(elt, $this) {
77
+ if (elt.timer) {
78
+ clearTimeout(elt.timer);
79
+ elt.timer = null;
80
+ }
81
+
82
+ self.hide($this);
83
+ }
84
+
85
+ $(this.scope)
86
+ .off('.tooltip')
87
+ .on('mouseenter.fndtn.tooltip mouseleave.fndtn.tooltip touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip',
88
+ '[' + this.attr_name() + ']', function (e) {
89
+ var $this = S(this),
90
+ settings = $.extend({}, self.settings, self.data_options($this)),
91
+ is_touch = false;
92
+
93
+ if (Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type) && S(e.target).is('a')) {
94
+ return false;
95
+ }
96
+
97
+ if (/mouse/i.test(e.type) && self.ie_touch(e)) {
98
+ return false;
99
+ }
100
+
101
+ if ($this.hasClass('open')) {
102
+ if (Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) {
103
+ e.preventDefault();
104
+ }
105
+ self.hide($this);
106
+ } else {
107
+ if (settings.disable_for_touch && Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) {
108
+ return;
109
+ } else if (!settings.disable_for_touch && Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) {
110
+ e.preventDefault();
111
+ S(settings.tooltip_class + '.open').hide();
112
+ is_touch = true;
113
+ // close other open tooltips on touch
114
+ if ($('.open[' + self.attr_name() + ']').length > 0) {
115
+ var prevOpen = S($('.open[' + self.attr_name() + ']')[0]);
116
+ self.hide(prevOpen);
117
+ }
118
+ }
119
+
120
+ if (/enter|over/i.test(e.type)) {
121
+ _startShow(this, $this);
122
+
123
+ } else if (e.type === 'mouseout' || e.type === 'mouseleave') {
124
+ _startHide(this, $this);
125
+ } else {
126
+ _startShow(this, $this, true);
127
+ }
128
+ }
129
+ })
130
+ .on('mouseleave.fndtn.tooltip touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip', '[' + this.attr_name() + '].open', function (e) {
131
+ if (/mouse/i.test(e.type) && self.ie_touch(e)) {
132
+ return false;
133
+ }
134
+
135
+ if ($(this).data('tooltip-open-event-type') == 'touch' && e.type == 'mouseleave') {
136
+ return;
137
+ } else if ($(this).data('tooltip-open-event-type') == 'mouse' && /MSPointerDown|touchstart/i.test(e.type)) {
138
+ self.convert_to_touch($(this));
139
+ } else {
140
+ _startHide(this, $(this));
141
+ }
142
+ })
143
+ .on('DOMNodeRemoved DOMAttrModified', '[' + this.attr_name() + ']:not(a)', function (e) {
144
+ _startHide(this, S(this));
145
+ });
146
+ },
147
+
148
+ ie_touch : function (e) {
149
+ // How do I distinguish between IE11 and Windows Phone 8?????
150
+ return false;
151
+ },
152
+
153
+ showTip : function ($target) {
154
+ var $tip = this.getTip($target);
155
+ if (this.should_show($target, $tip)) {
156
+ return this.show($target);
157
+ }
158
+ return;
159
+ },
160
+
161
+ getTip : function ($target) {
162
+ var selector = this.selector($target),
163
+ settings = $.extend({}, this.settings, this.data_options($target)),
164
+ tip = null;
165
+
166
+ if (selector) {
167
+ tip = this.S('span[data-selector="' + selector + '"]' + settings.tooltip_class);
168
+ }
169
+
170
+ return (typeof tip === 'object') ? tip : false;
171
+ },
172
+
173
+ selector : function ($target) {
174
+ var dataSelector = $target.attr(this.attr_name()) || $target.attr('data-selector');
175
+
176
+ if (typeof dataSelector != 'string') {
177
+ dataSelector = this.random_str(6);
178
+ $target
179
+ .attr('data-selector', dataSelector)
180
+ .attr('aria-describedby', dataSelector);
181
+ }
182
+
183
+ return dataSelector;
184
+ },
185
+
186
+ create : function ($target) {
187
+ var self = this,
188
+ settings = $.extend({}, this.settings, this.data_options($target)),
189
+ tip_template = this.settings.tip_template;
190
+
191
+ if (typeof settings.tip_template === 'string' && window.hasOwnProperty(settings.tip_template)) {
192
+ tip_template = window[settings.tip_template];
193
+ }
194
+
195
+ var $tip = $(tip_template(this.selector($target), $('<div></div>').html($target.attr('title')).html())),
196
+ classes = this.inheritable_classes($target);
197
+
198
+ $tip.addClass(classes).appendTo(settings.append_to);
199
+
200
+ if (Modernizr.touch) {
201
+ $tip.append('<span class="tap-to-close">' + settings.touch_close_text + '</span>');
202
+ $tip.on('touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip', function (e) {
203
+ self.hide($target);
204
+ });
205
+ }
206
+
207
+ $target.removeAttr('title').attr('title', '');
208
+ },
209
+
210
+ reposition : function (target, tip, classes) {
211
+ var width, nub, nubHeight, nubWidth, column, objPos;
212
+
213
+ tip.css('visibility', 'hidden').show();
214
+
215
+ width = target.data('width');
216
+ nub = tip.children('.nub');
217
+ nubHeight = nub.outerHeight();
218
+ nubWidth = nub.outerHeight();
219
+
220
+ if (this.small()) {
221
+ tip.css({'width' : '100%'});
222
+ } else {
223
+ tip.css({'width' : (width) ? width : 'auto'});
224
+ }
225
+
226
+ objPos = function (obj, top, right, bottom, left, width) {
227
+ return obj.css({
228
+ 'top' : (top) ? top : 'auto',
229
+ 'bottom' : (bottom) ? bottom : 'auto',
230
+ 'left' : (left) ? left : 'auto',
231
+ 'right' : (right) ? right : 'auto'
232
+ }).end();
233
+ };
234
+
235
+ objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', target.offset().left);
236
+
237
+ if (this.small()) {
238
+ objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', 12.5, $(this.scope).width());
239
+ tip.addClass('tip-override');
240
+ objPos(nub, -nubHeight, 'auto', 'auto', target.offset().left);
241
+ } else {
242
+ var left = target.offset().left;
243
+ if (Foundation.rtl) {
244
+ nub.addClass('rtl');
245
+ left = target.offset().left + target.outerWidth() - tip.outerWidth();
246
+ }
247
+
248
+ objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', left);
249
+ // reset nub from small styles, if they've been applied
250
+ if (nub.attr('style')) {
251
+ nub.removeAttr('style');
252
+ }
253
+
254
+ tip.removeClass('tip-override');
255
+ if (classes && classes.indexOf('tip-top') > -1) {
256
+ if (Foundation.rtl) {
257
+ nub.addClass('rtl');
258
+ }
259
+ objPos(tip, (target.offset().top - tip.outerHeight()), 'auto', 'auto', left)
260
+ .removeClass('tip-override');
261
+ } else if (classes && classes.indexOf('tip-left') > -1) {
262
+ objPos(tip, (target.offset().top + (target.outerHeight() / 2) - (tip.outerHeight() / 2)), 'auto', 'auto', (target.offset().left - tip.outerWidth() - nubHeight))
263
+ .removeClass('tip-override');
264
+ nub.removeClass('rtl');
265
+ } else if (classes && classes.indexOf('tip-right') > -1) {
266
+ objPos(tip, (target.offset().top + (target.outerHeight() / 2) - (tip.outerHeight() / 2)), 'auto', 'auto', (target.offset().left + target.outerWidth() + nubHeight))
267
+ .removeClass('tip-override');
268
+ nub.removeClass('rtl');
269
+ }
270
+ }
271
+
272
+ tip.css('visibility', 'visible').hide();
273
+ },
274
+
275
+ small : function () {
276
+ return matchMedia(Foundation.media_queries.small).matches &&
277
+ !matchMedia(Foundation.media_queries.medium).matches;
278
+ },
279
+
280
+ inheritable_classes : function ($target) {
281
+ var settings = $.extend({}, this.settings, this.data_options($target)),
282
+ inheritables = ['tip-top', 'tip-left', 'tip-bottom', 'tip-right', 'radius', 'round'].concat(settings.additional_inheritable_classes),
283
+ classes = $target.attr('class'),
284
+ filtered = classes ? $.map(classes.split(' '), function (el, i) {
285
+ if ($.inArray(el, inheritables) !== -1) {
286
+ return el;
287
+ }
288
+ }).join(' ') : '';
289
+
290
+ return $.trim(filtered);
291
+ },
292
+
293
+ convert_to_touch : function ($target) {
294
+ var self = this,
295
+ $tip = self.getTip($target),
296
+ settings = $.extend({}, self.settings, self.data_options($target));
297
+
298
+ if ($tip.find('.tap-to-close').length === 0) {
299
+ $tip.append('<span class="tap-to-close">' + settings.touch_close_text + '</span>');
300
+ $tip.on('click.fndtn.tooltip.tapclose touchstart.fndtn.tooltip.tapclose MSPointerDown.fndtn.tooltip.tapclose', function (e) {
301
+ self.hide($target);
302
+ });
303
+ }
304
+
305
+ $target.data('tooltip-open-event-type', 'touch');
306
+ },
307
+
308
+ show : function ($target) {
309
+ var $tip = this.getTip($target);
310
+
311
+ if ($target.data('tooltip-open-event-type') == 'touch') {
312
+ this.convert_to_touch($target);
313
+ }
314
+
315
+ this.reposition($target, $tip, $target.attr('class'));
316
+ $target.addClass('open');
317
+ $tip.fadeIn(150);
318
+ },
319
+
320
+ hide : function ($target) {
321
+ var $tip = this.getTip($target);
322
+ $tip.fadeOut(150, function () {
323
+ $tip.find('.tap-to-close').remove();
324
+ $tip.off('click.fndtn.tooltip.tapclose MSPointerDown.fndtn.tapclose');
325
+ $target.removeClass('open');
326
+ });
327
+ },
328
+
329
+ off : function () {
330
+ var self = this;
331
+ this.S(this.scope).off('.fndtn.tooltip');
332
+ this.S(this.settings.tooltip_class).each(function (i) {
333
+ $('[' + self.attr_name() + ']').eq(i).attr('title', $(this).text());
334
+ }).remove();
335
+ },
336
+
337
+ reflow : function () {}
338
+ };
339
+ }(jQuery, window, window.document));
@@ -0,0 +1,458 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs.topbar = {
5
+ name : 'topbar',
6
+
7
+ version : '5.5.2',
8
+
9
+ settings : {
10
+ index : 0,
11
+ start_offset : 0,
12
+ sticky_class : 'sticky',
13
+ custom_back_text : true,
14
+ back_text : 'Back',
15
+ mobile_show_parent_link : true,
16
+ is_hover : true,
17
+ scrolltop : true, // jump to top when sticky nav menu toggle is clicked
18
+ sticky_on : 'all',
19
+ dropdown_autoclose: true
20
+ },
21
+
22
+ init : function (section, method, options) {
23
+ Foundation.inherit(this, 'add_custom_rule register_media throttle');
24
+ var self = this;
25
+
26
+ self.register_media('topbar', 'foundation-mq-topbar');
27
+
28
+ this.bindings(method, options);
29
+
30
+ self.S('[' + this.attr_name() + ']', this.scope).each(function () {
31
+ var topbar = $(this),
32
+ settings = topbar.data(self.attr_name(true) + '-init'),
33
+ section = self.S('section, .top-bar-section', this);
34
+ topbar.data('index', 0);
35
+ var topbarContainer = topbar.parent();
36
+ if (topbarContainer.hasClass('fixed') || self.is_sticky(topbar, topbarContainer, settings) ) {
37
+ self.settings.sticky_class = settings.sticky_class;
38
+ self.settings.sticky_topbar = topbar;
39
+ topbar.data('height', topbarContainer.outerHeight());
40
+ topbar.data('stickyoffset', topbarContainer.offset().top);
41
+ } else {
42
+ topbar.data('height', topbar.outerHeight());
43
+ }
44
+
45
+ if (!settings.assembled) {
46
+ self.assemble(topbar);
47
+ }
48
+
49
+ if (settings.is_hover) {
50
+ self.S('.has-dropdown', topbar).addClass('not-click');
51
+ } else {
52
+ self.S('.has-dropdown', topbar).removeClass('not-click');
53
+ }
54
+
55
+ // Pad body when sticky (scrolled) or fixed.
56
+ self.add_custom_rule('.f-topbar-fixed { padding-top: ' + topbar.data('height') + 'px }');
57
+
58
+ if (topbarContainer.hasClass('fixed')) {
59
+ self.S('body').addClass('f-topbar-fixed');
60
+ }
61
+ });
62
+
63
+ },
64
+
65
+ is_sticky : function (topbar, topbarContainer, settings) {
66
+ var sticky = topbarContainer.hasClass(settings.sticky_class);
67
+ var smallMatch = matchMedia(Foundation.media_queries.small).matches;
68
+ var medMatch = matchMedia(Foundation.media_queries.medium).matches;
69
+ var lrgMatch = matchMedia(Foundation.media_queries.large).matches;
70
+
71
+ if (sticky && settings.sticky_on === 'all') {
72
+ return true;
73
+ }
74
+ if (sticky && this.small() && settings.sticky_on.indexOf('small') !== -1) {
75
+ if (smallMatch && !medMatch && !lrgMatch) { return true; }
76
+ }
77
+ if (sticky && this.medium() && settings.sticky_on.indexOf('medium') !== -1) {
78
+ if (smallMatch && medMatch && !lrgMatch) { return true; }
79
+ }
80
+ if (sticky && this.large() && settings.sticky_on.indexOf('large') !== -1) {
81
+ if (smallMatch && medMatch && lrgMatch) { return true; }
82
+ }
83
+
84
+ return false;
85
+ },
86
+
87
+ toggle : function (toggleEl) {
88
+ var self = this,
89
+ topbar;
90
+
91
+ if (toggleEl) {
92
+ topbar = self.S(toggleEl).closest('[' + this.attr_name() + ']');
93
+ } else {
94
+ topbar = self.S('[' + this.attr_name() + ']');
95
+ }
96
+
97
+ var settings = topbar.data(this.attr_name(true) + '-init');
98
+
99
+ var section = self.S('section, .top-bar-section', topbar);
100
+
101
+ if (self.breakpoint()) {
102
+ if (!self.rtl) {
103
+ section.css({left : '0%'});
104
+ $('>.name', section).css({left : '100%'});
105
+ } else {
106
+ section.css({right : '0%'});
107
+ $('>.name', section).css({right : '100%'});
108
+ }
109
+
110
+ self.S('li.moved', section).removeClass('moved');
111
+ topbar.data('index', 0);
112
+
113
+ topbar
114
+ .toggleClass('expanded')
115
+ .css('height', '');
116
+ }
117
+
118
+ if (settings.scrolltop) {
119
+ if (!topbar.hasClass('expanded')) {
120
+ if (topbar.hasClass('fixed')) {
121
+ topbar.parent().addClass('fixed');
122
+ topbar.removeClass('fixed');
123
+ self.S('body').addClass('f-topbar-fixed');
124
+ }
125
+ } else if (topbar.parent().hasClass('fixed')) {
126
+ if (settings.scrolltop) {
127
+ topbar.parent().removeClass('fixed');
128
+ topbar.addClass('fixed');
129
+ self.S('body').removeClass('f-topbar-fixed');
130
+
131
+ window.scrollTo(0, 0);
132
+ } else {
133
+ topbar.parent().removeClass('expanded');
134
+ }
135
+ }
136
+ } else {
137
+ if (self.is_sticky(topbar, topbar.parent(), settings)) {
138
+ topbar.parent().addClass('fixed');
139
+ }
140
+
141
+ if (topbar.parent().hasClass('fixed')) {
142
+ if (!topbar.hasClass('expanded')) {
143
+ topbar.removeClass('fixed');
144
+ topbar.parent().removeClass('expanded');
145
+ self.update_sticky_positioning();
146
+ } else {
147
+ topbar.addClass('fixed');
148
+ topbar.parent().addClass('expanded');
149
+ self.S('body').addClass('f-topbar-fixed');
150
+ }
151
+ }
152
+ }
153
+ },
154
+
155
+ timer : null,
156
+
157
+ events : function (bar) {
158
+ var self = this,
159
+ S = this.S;
160
+
161
+ S(this.scope)
162
+ .off('.topbar')
163
+ .on('click.fndtn.topbar', '[' + this.attr_name() + '] .toggle-topbar', function (e) {
164
+ e.preventDefault();
165
+ self.toggle(this);
166
+ })
167
+ .on('click.fndtn.topbar contextmenu.fndtn.topbar', '.top-bar .top-bar-section li a[href^="#"],[' + this.attr_name() + '] .top-bar-section li a[href^="#"]', function (e) {
168
+ var li = $(this).closest('li'),
169
+ topbar = li.closest('[' + self.attr_name() + ']'),
170
+ settings = topbar.data(self.attr_name(true) + '-init');
171
+
172
+ if (settings.dropdown_autoclose && settings.is_hover) {
173
+ var hoverLi = $(this).closest('.hover');
174
+ hoverLi.removeClass('hover');
175
+ }
176
+ if (self.breakpoint() && !li.hasClass('back') && !li.hasClass('has-dropdown')) {
177
+ self.toggle();
178
+ }
179
+
180
+ })
181
+ .on('click.fndtn.topbar', '[' + this.attr_name() + '] li.has-dropdown', function (e) {
182
+ var li = S(this),
183
+ target = S(e.target),
184
+ topbar = li.closest('[' + self.attr_name() + ']'),
185
+ settings = topbar.data(self.attr_name(true) + '-init');
186
+
187
+ if (target.data('revealId')) {
188
+ self.toggle();
189
+ return;
190
+ }
191
+
192
+ if (self.breakpoint()) {
193
+ return;
194
+ }
195
+
196
+ if (settings.is_hover && !Modernizr.touch) {
197
+ return;
198
+ }
199
+
200
+ e.stopImmediatePropagation();
201
+
202
+ if (li.hasClass('hover')) {
203
+ li
204
+ .removeClass('hover')
205
+ .find('li')
206
+ .removeClass('hover');
207
+
208
+ li.parents('li.hover')
209
+ .removeClass('hover');
210
+ } else {
211
+ li.addClass('hover');
212
+
213
+ $(li).siblings().removeClass('hover');
214
+
215
+ if (target[0].nodeName === 'A' && target.parent().hasClass('has-dropdown')) {
216
+ e.preventDefault();
217
+ }
218
+ }
219
+ })
220
+ .on('click.fndtn.topbar', '[' + this.attr_name() + '] .has-dropdown>a', function (e) {
221
+ if (self.breakpoint()) {
222
+
223
+ e.preventDefault();
224
+
225
+ var $this = S(this),
226
+ topbar = $this.closest('[' + self.attr_name() + ']'),
227
+ section = topbar.find('section, .top-bar-section'),
228
+ dropdownHeight = $this.next('.dropdown').outerHeight(),
229
+ $selectedLi = $this.closest('li');
230
+
231
+ topbar.data('index', topbar.data('index') + 1);
232
+ $selectedLi.addClass('moved');
233
+
234
+ if (!self.rtl) {
235
+ section.css({left : -(100 * topbar.data('index')) + '%'});
236
+ section.find('>.name').css({left : 100 * topbar.data('index') + '%'});
237
+ } else {
238
+ section.css({right : -(100 * topbar.data('index')) + '%'});
239
+ section.find('>.name').css({right : 100 * topbar.data('index') + '%'});
240
+ }
241
+
242
+ topbar.css('height', $this.siblings('ul').outerHeight(true) + topbar.data('height'));
243
+ }
244
+ });
245
+
246
+ S(window).off('.topbar').on('resize.fndtn.topbar', self.throttle(function () {
247
+ self.resize.call(self);
248
+ }, 50)).trigger('resize.fndtn.topbar').load(function () {
249
+ // Ensure that the offset is calculated after all of the pages resources have loaded
250
+ S(this).trigger('resize.fndtn.topbar');
251
+ });
252
+
253
+ S('body').off('.topbar').on('click.fndtn.topbar', function (e) {
254
+ var parent = S(e.target).closest('li').closest('li.hover');
255
+
256
+ if (parent.length > 0) {
257
+ return;
258
+ }
259
+
260
+ S('[' + self.attr_name() + '] li.hover').removeClass('hover');
261
+ });
262
+
263
+ // Go up a level on Click
264
+ S(this.scope).on('click.fndtn.topbar', '[' + this.attr_name() + '] .has-dropdown .back', function (e) {
265
+ e.preventDefault();
266
+
267
+ var $this = S(this),
268
+ topbar = $this.closest('[' + self.attr_name() + ']'),
269
+ section = topbar.find('section, .top-bar-section'),
270
+ settings = topbar.data(self.attr_name(true) + '-init'),
271
+ $movedLi = $this.closest('li.moved'),
272
+ $previousLevelUl = $movedLi.parent();
273
+
274
+ topbar.data('index', topbar.data('index') - 1);
275
+
276
+ if (!self.rtl) {
277
+ section.css({left : -(100 * topbar.data('index')) + '%'});
278
+ section.find('>.name').css({left : 100 * topbar.data('index') + '%'});
279
+ } else {
280
+ section.css({right : -(100 * topbar.data('index')) + '%'});
281
+ section.find('>.name').css({right : 100 * topbar.data('index') + '%'});
282
+ }
283
+
284
+ if (topbar.data('index') === 0) {
285
+ topbar.css('height', '');
286
+ } else {
287
+ topbar.css('height', $previousLevelUl.outerHeight(true) + topbar.data('height'));
288
+ }
289
+
290
+ setTimeout(function () {
291
+ $movedLi.removeClass('moved');
292
+ }, 300);
293
+ });
294
+
295
+ // Show dropdown menus when their items are focused
296
+ S(this.scope).find('.dropdown a')
297
+ .focus(function () {
298
+ $(this).parents('.has-dropdown').addClass('hover');
299
+ })
300
+ .blur(function () {
301
+ $(this).parents('.has-dropdown').removeClass('hover');
302
+ });
303
+ },
304
+
305
+ resize : function () {
306
+ var self = this;
307
+ self.S('[' + this.attr_name() + ']').each(function () {
308
+ var topbar = self.S(this),
309
+ settings = topbar.data(self.attr_name(true) + '-init');
310
+
311
+ var stickyContainer = topbar.parent('.' + self.settings.sticky_class);
312
+ var stickyOffset;
313
+
314
+ if (!self.breakpoint()) {
315
+ var doToggle = topbar.hasClass('expanded');
316
+ topbar
317
+ .css('height', '')
318
+ .removeClass('expanded')
319
+ .find('li')
320
+ .removeClass('hover');
321
+
322
+ if (doToggle) {
323
+ self.toggle(topbar);
324
+ }
325
+ }
326
+
327
+ if (self.is_sticky(topbar, stickyContainer, settings)) {
328
+ if (stickyContainer.hasClass('fixed')) {
329
+ // Remove the fixed to allow for correct calculation of the offset.
330
+ stickyContainer.removeClass('fixed');
331
+
332
+ stickyOffset = stickyContainer.offset().top;
333
+ if (self.S(document.body).hasClass('f-topbar-fixed')) {
334
+ stickyOffset -= topbar.data('height');
335
+ }
336
+
337
+ topbar.data('stickyoffset', stickyOffset);
338
+ stickyContainer.addClass('fixed');
339
+ } else {
340
+ stickyOffset = stickyContainer.offset().top;
341
+ topbar.data('stickyoffset', stickyOffset);
342
+ }
343
+ }
344
+
345
+ });
346
+ },
347
+
348
+ breakpoint : function () {
349
+ return !matchMedia(Foundation.media_queries['topbar']).matches;
350
+ },
351
+
352
+ small : function () {
353
+ return matchMedia(Foundation.media_queries['small']).matches;
354
+ },
355
+
356
+ medium : function () {
357
+ return matchMedia(Foundation.media_queries['medium']).matches;
358
+ },
359
+
360
+ large : function () {
361
+ return matchMedia(Foundation.media_queries['large']).matches;
362
+ },
363
+
364
+ assemble : function (topbar) {
365
+ var self = this,
366
+ settings = topbar.data(this.attr_name(true) + '-init'),
367
+ section = self.S('section, .top-bar-section', topbar);
368
+
369
+ // Pull element out of the DOM for manipulation
370
+ section.detach();
371
+
372
+ self.S('.has-dropdown>a', section).each(function () {
373
+ var $link = self.S(this),
374
+ $dropdown = $link.siblings('.dropdown'),
375
+ url = $link.attr('href'),
376
+ $titleLi;
377
+
378
+ if (!$dropdown.find('.title.back').length) {
379
+
380
+ if (settings.mobile_show_parent_link == true && url) {
381
+ $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li><li class="parent-link hide-for-medium-up"><a class="parent-link js-generated" href="' + url + '">' + $link.html() +'</a></li>');
382
+ } else {
383
+ $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5>');
384
+ }
385
+
386
+ // Copy link to subnav
387
+ if (settings.custom_back_text == true) {
388
+ $('h5>a', $titleLi).html(settings.back_text);
389
+ } else {
390
+ $('h5>a', $titleLi).html('&laquo; ' + $link.html());
391
+ }
392
+ $dropdown.prepend($titleLi);
393
+ }
394
+ });
395
+
396
+ // Put element back in the DOM
397
+ section.appendTo(topbar);
398
+
399
+ // check for sticky
400
+ this.sticky();
401
+
402
+ this.assembled(topbar);
403
+ },
404
+
405
+ assembled : function (topbar) {
406
+ topbar.data(this.attr_name(true), $.extend({}, topbar.data(this.attr_name(true)), {assembled : true}));
407
+ },
408
+
409
+ height : function (ul) {
410
+ var total = 0,
411
+ self = this;
412
+
413
+ $('> li', ul).each(function () {
414
+ total += self.S(this).outerHeight(true);
415
+ });
416
+
417
+ return total;
418
+ },
419
+
420
+ sticky : function () {
421
+ var self = this;
422
+
423
+ this.S(window).on('scroll', function () {
424
+ self.update_sticky_positioning();
425
+ });
426
+ },
427
+
428
+ update_sticky_positioning : function () {
429
+ var klass = '.' + this.settings.sticky_class,
430
+ $window = this.S(window),
431
+ self = this;
432
+
433
+ if (self.settings.sticky_topbar && self.is_sticky(this.settings.sticky_topbar,this.settings.sticky_topbar.parent(), this.settings)) {
434
+ var distance = this.settings.sticky_topbar.data('stickyoffset') + this.settings.start_offset;
435
+ if (!self.S(klass).hasClass('expanded')) {
436
+ if ($window.scrollTop() > (distance)) {
437
+ if (!self.S(klass).hasClass('fixed')) {
438
+ self.S(klass).addClass('fixed');
439
+ self.S('body').addClass('f-topbar-fixed');
440
+ }
441
+ } else if ($window.scrollTop() <= distance) {
442
+ if (self.S(klass).hasClass('fixed')) {
443
+ self.S(klass).removeClass('fixed');
444
+ self.S('body').removeClass('f-topbar-fixed');
445
+ }
446
+ }
447
+ }
448
+ }
449
+ },
450
+
451
+ off : function () {
452
+ this.S(this.scope).off('.fndtn.topbar');
453
+ this.S(window).off('.fndtn.topbar');
454
+ },
455
+
456
+ reflow : function () {}
457
+ };
458
+ }(jQuery, window, window.document));