Provide detailed instructions on how to submit PRs for Github mirrored repos
[web.git] / js / foundation.min.js
1 /*
2 * Foundation Responsive Library
3 * http://foundation.zurb.com
4 * Copyright 2014, ZURB
5 * Free to use under the MIT license.
6 * http://www.opensource.org/licenses/mit-license.php
7 */
8
9 (function ($, window, document, undefined) {
10 'use strict';
11
12 var header_helpers = function (class_array) {
13 var i = class_array.length;
14 var head = $('head');
15
16 while (i--) {
17 if (head.has('.' + class_array[i]).length === 0) {
18 head.append('<meta class="' + class_array[i] + '" />');
19 }
20 }
21 };
22
23 header_helpers([
24 'foundation-mq-small',
25 'foundation-mq-small-only',
26 'foundation-mq-medium',
27 'foundation-mq-medium-only',
28 'foundation-mq-large',
29 'foundation-mq-large-only',
30 'foundation-mq-xlarge',
31 'foundation-mq-xlarge-only',
32 'foundation-mq-xxlarge',
33 'foundation-data-attribute-namespace']);
34
35 // Enable FastClick if present
36
37 $(function () {
38 if (typeof FastClick !== 'undefined') {
39 // Don't attach to body if undefined
40 if (typeof document.body !== 'undefined') {
41 FastClick.attach(document.body);
42 }
43 }
44 });
45
46 // private Fast Selector wrapper,
47 // returns jQuery object. Only use where
48 // getElementById is not available.
49 var S = function (selector, context) {
50 if (typeof selector === 'string') {
51 if (context) {
52 var cont;
53 if (context.jquery) {
54 cont = context[0];
55 if (!cont) return context;
56 } else {
57 cont = context;
58 }
59 return $(cont.querySelectorAll(selector));
60 }
61
62 return $(document.querySelectorAll(selector));
63 }
64
65 return $(selector, context);
66 };
67
68 // Namespace functions.
69
70 var attr_name = function (init) {
71 var arr = [];
72 if (!init) arr.push('data');
73 if (this.namespace.length > 0) arr.push(this.namespace);
74 arr.push(this.name);
75
76 return arr.join('-');
77 };
78
79 var add_namespace = function (str) {
80 var parts = str.split('-'),
81 i = parts.length,
82 arr = [];
83
84 while (i--) {
85 if (i !== 0) {
86 arr.push(parts[i]);
87 } else {
88 if (this.namespace.length > 0) {
89 arr.push(this.namespace, parts[i]);
90 } else {
91 arr.push(parts[i]);
92 }
93 }
94 }
95
96 return arr.reverse().join('-');
97 };
98
99 // Event binding and data-options updating.
100
101 var bindings = function (method, options) {
102 var self = this,
103 should_bind_events = !S(this).data(this.attr_name(true));
104
105 if (S(this.scope).is('[' + this.attr_name() + ']')) {
106 S(this.scope).data(this.attr_name(true) + '-init', $.extend({}, this.settings, (options || method), this.data_options(S(this.scope))));
107
108 if (should_bind_events) {
109 this.events(this.scope);
110 }
111
112 } else {
113 S('[' + this.attr_name() + ']', this.scope).each(function () {
114 var should_bind_events = !S(this).data(self.attr_name(true) + '-init');
115 S(this).data(self.attr_name(true) + '-init', $.extend({}, self.settings, (options || method), self.data_options(S(this))));
116
117 if (should_bind_events) {
118 self.events(this);
119 }
120 });
121 }
122 // # Patch to fix #5043 to move this *after* the if/else clause in order for Backbone and similar frameworks to have improved control over event binding and data-options updating.
123 if (typeof method === 'string') {
124 return this[method].call(this, options);
125 }
126
127 };
128
129 var single_image_loaded = function (image, callback) {
130 function loaded() {
131 callback(image[0]);
132 }
133
134 function bindLoad() {
135 this.one('load', loaded);
136
137 if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
138 var src = this.attr('src'),
139 param = src.match(/\?/) ? '&' : '?';
140
141 param += 'random=' + (new Date()).getTime();
142 this.attr('src', src + param);
143 }
144 }
145
146 if (!image.attr('src')) {
147 loaded();
148 return;
149 }
150
151 if (image[0].complete || image[0].readyState === 4) {
152 loaded();
153 } else {
154 bindLoad.call(image);
155 }
156 };
157
158 /*
159 https://github.com/paulirish/matchMedia.js
160 */
161
162 window.matchMedia = window.matchMedia || (function (doc) {
163
164 'use strict';
165
166 var bool,
167 docElem = doc.documentElement,
168 refNode = docElem.firstElementChild || docElem.firstChild,
169 // fakeBody required for <FF4 when executed in <head>
170 fakeBody = doc.createElement('body'),
171 div = doc.createElement('div');
172
173 div.id = 'mq-test-1';
174 div.style.cssText = 'position:absolute;top:-100em';
175 fakeBody.style.background = 'none';
176 fakeBody.appendChild(div);
177
178 return function (q) {
179
180 div.innerHTML = '&shy;<style media="' + q + '"> #mq-test-1 { width: 42px; }</style>';
181
182 docElem.insertBefore(fakeBody, refNode);
183 bool = div.offsetWidth === 42;
184 docElem.removeChild(fakeBody);
185
186 return {
187 matches: bool,
188 media: q
189 };
190
191 };
192
193 }(document));
194
195 /*
196 * jquery.requestAnimationFrame
197 * https://github.com/gnarf37/jquery-requestAnimationFrame
198 * Requires jQuery 1.8+
199 *
200 * Copyright (c) 2012 Corey Frang
201 * Licensed under the MIT license.
202 */
203
204 (function ($) {
205
206 // requestAnimationFrame polyfill adapted from Erik Möller
207 // fixes from Paul Irish and Tino Zijdel
208 // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
209 // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
210
211 var animating,
212 lastTime = 0,
213 vendors = ['webkit', 'moz'],
214 requestAnimationFrame = window.requestAnimationFrame,
215 cancelAnimationFrame = window.cancelAnimationFrame,
216 jqueryFxAvailable = 'undefined' !== typeof jQuery.fx;
217
218 for (; lastTime < vendors.length && !requestAnimationFrame; lastTime++) {
219 requestAnimationFrame = window[vendors[lastTime] + 'RequestAnimationFrame'];
220 cancelAnimationFrame = cancelAnimationFrame ||
221 window[vendors[lastTime] + 'CancelAnimationFrame'] ||
222 window[vendors[lastTime] + 'CancelRequestAnimationFrame'];
223 }
224
225 function raf() {
226 if (animating) {
227 requestAnimationFrame(raf);
228
229 if (jqueryFxAvailable) {
230 jQuery.fx.tick();
231 }
232 }
233 }
234
235 if (requestAnimationFrame) {
236 // use rAF
237 window.requestAnimationFrame = requestAnimationFrame;
238 window.cancelAnimationFrame = cancelAnimationFrame;
239
240 if (jqueryFxAvailable) {
241 jQuery.fx.timer = function (timer) {
242 if (timer() && jQuery.timers.push(timer) && !animating) {
243 animating = true;
244 raf();
245 }
246 };
247
248 jQuery.fx.stop = function () {
249 animating = false;
250 };
251 }
252 } else {
253 // polyfill
254 window.requestAnimationFrame = function (callback) {
255 var currTime = new Date().getTime(),
256 timeToCall = Math.max(0, 16 - (currTime - lastTime)),
257 id = window.setTimeout(function () {
258 callback(currTime + timeToCall);
259 }, timeToCall);
260 lastTime = currTime + timeToCall;
261 return id;
262 };
263
264 window.cancelAnimationFrame = function (id) {
265 clearTimeout(id);
266 };
267
268 }
269
270 }(jQuery));
271
272
273 function removeQuotes(string) {
274 if (typeof string === 'string' || string instanceof String) {
275 string = string.replace(/^['\\/"]+|(;\s?})+|['\\/"]+$/g, '');
276 }
277
278 return string;
279 }
280
281 window.Foundation = {
282 name: 'Foundation',
283
284 version: '5.5.0',
285
286 media_queries: {
287 'small': S('.foundation-mq-small').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
288 'small-only': S('.foundation-mq-small-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
289 'medium': S('.foundation-mq-medium').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
290 'medium-only': S('.foundation-mq-medium-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
291 'large': S('.foundation-mq-large').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
292 'large-only': S('.foundation-mq-large-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
293 'xlarge': S('.foundation-mq-xlarge').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
294 'xlarge-only': S('.foundation-mq-xlarge-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
295 'xxlarge': S('.foundation-mq-xxlarge').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, '')
296 },
297
298 stylesheet: $('<style></style>').appendTo('head')[0].sheet,
299
300 global: {
301 namespace: undefined
302 },
303
304 init: function (scope, libraries, method, options, response) {
305 var args = [scope, method, options, response],
306 responses = [];
307
308 // check RTL
309 this.rtl = /rtl/i.test(S('html').attr('dir'));
310
311 // set foundation global scope
312 this.scope = scope || this.scope;
313
314 this.set_namespace();
315
316 if (libraries && typeof libraries === 'string' && !/reflow/i.test(libraries)) {
317 if (this.libs.hasOwnProperty(libraries)) {
318 responses.push(this.init_lib(libraries, args));
319 }
320 } else {
321 for (var lib in this.libs) {
322 responses.push(this.init_lib(lib, libraries));
323 }
324 }
325
326 S(window).load(function () {
327 S(window)
328 .trigger('resize.fndtn.clearing')
329 .trigger('resize.fndtn.dropdown')
330 .trigger('resize.fndtn.equalizer')
331 .trigger('resize.fndtn.interchange')
332 .trigger('resize.fndtn.joyride')
333 .trigger('resize.fndtn.magellan')
334 .trigger('resize.fndtn.topbar')
335 .trigger('resize.fndtn.slider');
336 });
337
338 return scope;
339 },
340
341 init_lib: function (lib, args) {
342 if (this.libs.hasOwnProperty(lib)) {
343 this.patch(this.libs[lib]);
344
345 if (args && args.hasOwnProperty(lib)) {
346 if (typeof this.libs[lib].settings !== 'undefined') {
347 $.extend(true, this.libs[lib].settings, args[lib]);
348 }
349 else if (typeof this.libs[lib].defaults !== 'undefined') {
350 $.extend(true, this.libs[lib].defaults, args[lib]);
351 }
352 return this.libs[lib].init.apply(this.libs[lib], [this.scope, args[lib]]);
353 }
354
355 args = args instanceof Array ? args : new Array(args);
356 return this.libs[lib].init.apply(this.libs[lib], args);
357 }
358
359 return function () {
360 };
361 },
362
363 patch: function (lib) {
364 lib.scope = this.scope;
365 lib.namespace = this.global.namespace;
366 lib.rtl = this.rtl;
367 lib['data_options'] = this.utils.data_options;
368 lib['attr_name'] = attr_name;
369 lib['add_namespace'] = add_namespace;
370 lib['bindings'] = bindings;
371 lib['S'] = this.utils.S;
372 },
373
374 inherit: function (scope, methods) {
375 var methods_arr = methods.split(' '),
376 i = methods_arr.length;
377
378 while (i--) {
379 if (this.utils.hasOwnProperty(methods_arr[i])) {
380 scope[methods_arr[i]] = this.utils[methods_arr[i]];
381 }
382 }
383 },
384
385 set_namespace: function () {
386
387 // Description:
388 // Don't bother reading the namespace out of the meta tag
389 // if the namespace has been set globally in javascript
390 //
391 // Example:
392 // Foundation.global.namespace = 'my-namespace';
393 // or make it an empty string:
394 // Foundation.global.namespace = '';
395 //
396 //
397
398 // If the namespace has not been set (is undefined), try to read it out of the meta element.
399 // Otherwise use the globally defined namespace, even if it's empty ('')
400 var namespace = ( this.global.namespace === undefined ) ? $('.foundation-data-attribute-namespace').css('font-family') : this.global.namespace;
401
402 // Finally, if the namsepace is either undefined or false, set it to an empty string.
403 // Otherwise use the namespace value.
404 this.global.namespace = ( namespace === undefined || /false/i.test(namespace) ) ? '' : namespace;
405 },
406
407 libs: {},
408
409 // methods that can be inherited in libraries
410 utils: {
411
412 // Description:
413 // Fast Selector wrapper returns jQuery object. Only use where getElementById
414 // is not available.
415 //
416 // Arguments:
417 // Selector (String): CSS selector describing the element(s) to be
418 // returned as a jQuery object.
419 //
420 // Scope (String): CSS selector describing the area to be searched. Default
421 // is document.
422 //
423 // Returns:
424 // Element (jQuery Object): jQuery object containing elements matching the
425 // selector within the scope.
426 S: S,
427
428 // Description:
429 // Executes a function a max of once every n milliseconds
430 //
431 // Arguments:
432 // Func (Function): Function to be throttled.
433 //
434 // Delay (Integer): Function execution threshold in milliseconds.
435 //
436 // Returns:
437 // Lazy_function (Function): Function with throttling applied.
438 throttle: function (func, delay) {
439 var timer = null;
440
441 return function () {
442 var context = this, args = arguments;
443
444 if (timer == null) {
445 timer = setTimeout(function () {
446 func.apply(context, args);
447 timer = null;
448 }, delay);
449 }
450 };
451 },
452
453 // Description:
454 // Executes a function when it stops being invoked for n seconds
455 // Modified version of _.debounce() http://underscorejs.org
456 //
457 // Arguments:
458 // Func (Function): Function to be debounced.
459 //
460 // Delay (Integer): Function execution threshold in milliseconds.
461 //
462 // Immediate (Bool): Whether the function should be called at the beginning
463 // of the delay instead of the end. Default is false.
464 //
465 // Returns:
466 // Lazy_function (Function): Function with debouncing applied.
467 debounce: function (func, delay, immediate) {
468 var timeout, result;
469 return function () {
470 var context = this, args = arguments;
471 var later = function () {
472 timeout = null;
473 if (!immediate) result = func.apply(context, args);
474 };
475 var callNow = immediate && !timeout;
476 clearTimeout(timeout);
477 timeout = setTimeout(later, delay);
478 if (callNow) result = func.apply(context, args);
479 return result;
480 };
481 },
482
483 // Description:
484 // Parses data-options attribute
485 //
486 // Arguments:
487 // El (jQuery Object): Element to be parsed.
488 //
489 // Returns:
490 // Options (Javascript Object): Contents of the element's data-options
491 // attribute.
492 data_options: function (el, data_attr_name) {
493 data_attr_name = data_attr_name || 'options';
494 var opts = {}, ii, p, opts_arr,
495 data_options = function (el) {
496 var namespace = Foundation.global.namespace;
497
498 if (namespace.length > 0) {
499 return el.data(namespace + '-' + data_attr_name);
500 }
501
502 return el.data(data_attr_name);
503 };
504
505 var cached_options = data_options(el);
506
507 if (typeof cached_options === 'object') {
508 return cached_options;
509 }
510
511 opts_arr = (cached_options || ':').split(';');
512 ii = opts_arr.length;
513
514 function isNumber(o) {
515 return !isNaN(o - 0) && o !== null && o !== '' && o !== false && o !== true;
516 }
517
518 function trim(str) {
519 if (typeof str === 'string') return $.trim(str);
520 return str;
521 }
522
523 while (ii--) {
524 p = opts_arr[ii].split(':');
525 p = [p[0], p.slice(1).join(':')];
526
527 if (/true/i.test(p[1])) p[1] = true;
528 if (/false/i.test(p[1])) p[1] = false;
529 if (isNumber(p[1])) {
530 if (p[1].indexOf('.') === -1) {
531 p[1] = parseInt(p[1], 10);
532 } else {
533 p[1] = parseFloat(p[1]);
534 }
535 }
536
537 if (p.length === 2 && p[0].length > 0) {
538 opts[trim(p[0])] = trim(p[1]);
539 }
540 }
541
542 return opts;
543 },
544
545 // Description:
546 // Adds JS-recognizable media queries
547 //
548 // Arguments:
549 // Media (String): Key string for the media query to be stored as in
550 // Foundation.media_queries
551 //
552 // Class (String): Class name for the generated <meta> tag
553 register_media: function (media, media_class) {
554 if (Foundation.media_queries[media] === undefined) {
555 $('head').append('<meta class="' + media_class + '"/>');
556 Foundation.media_queries[media] = removeQuotes($('.' + media_class).css('font-family'));
557 }
558 },
559
560 // Description:
561 // Add custom CSS within a JS-defined media query
562 //
563 // Arguments:
564 // Rule (String): CSS rule to be appended to the document.
565 //
566 // Media (String): Optional media query string for the CSS rule to be
567 // nested under.
568 add_custom_rule: function (rule, media) {
569 if (media === undefined && Foundation.stylesheet) {
570 Foundation.stylesheet.insertRule(rule, Foundation.stylesheet.cssRules.length);
571 } else {
572 var query = Foundation.media_queries[media];
573
574 if (query !== undefined) {
575 Foundation.stylesheet.insertRule('@media ' +
576 Foundation.media_queries[media] + '{ ' + rule + ' }');
577 }
578 }
579 },
580
581 // Description:
582 // Performs a callback function when an image is fully loaded
583 //
584 // Arguments:
585 // Image (jQuery Object): Image(s) to check if loaded.
586 //
587 // Callback (Function): Function to execute when image is fully loaded.
588 image_loaded: function (images, callback) {
589 var self = this,
590 unloaded = images.length;
591
592 if (unloaded === 0) {
593 callback(images);
594 }
595
596 images.each(function () {
597 single_image_loaded(self.S(this), function () {
598 unloaded -= 1;
599 if (unloaded === 0) {
600 callback(images);
601 }
602 });
603 });
604 },
605
606 // Description:
607 // Returns a random, alphanumeric string
608 //
609 // Arguments:
610 // Length (Integer): Length of string to be generated. Defaults to random
611 // integer.
612 //
613 // Returns:
614 // Rand (String): Pseudo-random, alphanumeric string.
615 random_str: function () {
616 if (!this.fidx) this.fidx = 0;
617 this.prefix = this.prefix || [(this.name || 'F'), (+new Date).toString(36)].join('-');
618
619 return this.prefix + (this.fidx++).toString(36);
620 },
621
622 // Description:
623 // Helper for window.matchMedia
624 //
625 // Arguments:
626 // mq (String): Media query
627 //
628 // Returns:
629 // (Boolean): Whether the media query passes or not
630 match: function (mq) {
631 return window.matchMedia(mq).matches;
632 },
633
634 // Description:
635 // Helpers for checking Foundation default media queries with JS
636 //
637 // Returns:
638 // (Boolean): Whether the media query passes or not
639
640 is_small_up: function () {
641 return this.match(Foundation.media_queries.small);
642 },
643
644 is_medium_up: function () {
645 return this.match(Foundation.media_queries.medium);
646 },
647
648 is_large_up: function () {
649 return this.match(Foundation.media_queries.large);
650 },
651
652 is_xlarge_up: function () {
653 return this.match(Foundation.media_queries.xlarge);
654 },
655
656 is_xxlarge_up: function () {
657 return this.match(Foundation.media_queries.xxlarge);
658 },
659
660 is_small_only: function () {
661 return !this.is_medium_up() && !this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up();
662 },
663
664 is_medium_only: function () {
665 return this.is_medium_up() && !this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up();
666 },
667
668 is_large_only: function () {
669 return this.is_medium_up() && this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up();
670 },
671
672 is_xlarge_only: function () {
673 return this.is_medium_up() && this.is_large_up() && this.is_xlarge_up() && !this.is_xxlarge_up();
674 },
675
676 is_xxlarge_only: function () {
677 return this.is_medium_up() && this.is_large_up() && this.is_xlarge_up() && this.is_xxlarge_up();
678 }
679 }
680 };
681
682 $.fn.foundation = function () {
683 var args = Array.prototype.slice.call(arguments, 0);
684
685 return this.each(function () {
686 Foundation.init.apply(Foundation, [this].concat(args));
687 return this;
688 });
689 };
690
691 }(jQuery, window, window.document));
692 ;
693 (function ($, window, document, undefined) {
694 'use strict';
695
696 Foundation.libs.slider = {
697 name: 'slider',
698
699 version: '5.5.0',
700
701 settings: {
702 start: 0,
703 end: 100,
704 step: 1,
705 precision: null,
706 initial: null,
707 display_selector: '',
708 vertical: false,
709 trigger_input_change: false,
710 on_change: function () {
711 }
712 },
713
714 cache: {},
715
716 init: function (scope, method, options) {
717 Foundation.inherit(this, 'throttle');
718 this.bindings(method, options);
719 this.reflow();
720 },
721
722 events: function () {
723 var self = this;
724
725 $(this.scope)
726 .off('.slider')
727 .on('mousedown.fndtn.slider touchstart.fndtn.slider pointerdown.fndtn.slider',
728 '[' + self.attr_name() + ']:not(.disabled, [disabled]) .range-slider-handle', function (e) {
729 if (!self.cache.active) {
730 e.preventDefault();
731 self.set_active_slider($(e.target));
732 }
733 })
734 .on('mousemove.fndtn.slider touchmove.fndtn.slider pointermove.fndtn.slider', function (e) {
735 if (!!self.cache.active) {
736 e.preventDefault();
737 if ($.data(self.cache.active[0], 'settings').vertical) {
738 var scroll_offset = 0;
739 if (!e.pageY) {
740 scroll_offset = window.scrollY;
741 }
742 self.calculate_position(self.cache.active, self.get_cursor_position(e, 'y') + scroll_offset);
743 } else {
744 self.calculate_position(self.cache.active, self.get_cursor_position(e, 'x'));
745 }
746 }
747 })
748 .on('mouseup.fndtn.slider touchend.fndtn.slider pointerup.fndtn.slider', function (e) {
749 self.remove_active_slider();
750 })
751 .on('change.fndtn.slider', function (e) {
752 self.settings.on_change();
753 });
754
755 self.S(window)
756 .on('resize.fndtn.slider', self.throttle(function (e) {
757 self.reflow();
758 }, 300));
759 },
760
761 get_cursor_position: function (e, xy) {
762 var pageXY = 'page' + xy.toUpperCase(),
763 clientXY = 'client' + xy.toUpperCase(),
764 position;
765
766 if (typeof e[pageXY] !== 'undefined') {
767 position = e[pageXY];
768 }
769 else if (typeof e.originalEvent[clientXY] !== 'undefined') {
770 position = e.originalEvent[clientXY];
771 }
772 else if (e.originalEvent.touches && e.originalEvent.touches[0] && typeof e.originalEvent.touches[0][clientXY] !== 'undefined') {
773 position = e.originalEvent.touches[0][clientXY];
774 }
775 else if (e.currentPoint && typeof e.currentPoint[xy] !== 'undefined') {
776 position = e.currentPoint[xy];
777 }
778 return position;
779 },
780
781 set_active_slider: function ($handle) {
782 this.cache.active = $handle;
783 },
784
785 remove_active_slider: function () {
786 this.cache.active = null;
787 },
788
789 calculate_position: function ($handle, cursor_x) {
790 var self = this,
791 settings = $.data($handle[0], 'settings'),
792 handle_l = $.data($handle[0], 'handle_l'),
793 handle_o = $.data($handle[0], 'handle_o'),
794 bar_l = $.data($handle[0], 'bar_l'),
795 bar_o = $.data($handle[0], 'bar_o');
796
797 requestAnimationFrame(function () {
798 var pct;
799
800 if (Foundation.rtl && !settings.vertical) {
801 pct = self.limit_to(((bar_o + bar_l - cursor_x) / bar_l), 0, 1);
802 } else {
803 pct = self.limit_to(((cursor_x - bar_o) / bar_l), 0, 1);
804 }
805
806 pct = settings.vertical ? 1 - pct : pct;
807
808 var norm = self.normalized_value(pct, settings.start, settings.end, settings.step, settings.precision);
809
810 self.set_ui($handle, norm);
811 });
812 },
813
814 set_ui: function ($handle, value) {
815 var settings = $.data($handle[0], 'settings'),
816 handle_l = $.data($handle[0], 'handle_l'),
817 bar_l = $.data($handle[0], 'bar_l'),
818 norm_pct = this.normalized_percentage(value, settings.start, settings.end),
819 handle_offset = norm_pct * (bar_l - handle_l) - 1,
820 progress_bar_length = norm_pct * 100,
821 $handle_parent = $handle.parent(),
822 $hidden_inputs = $handle.parent().children('input[type=hidden]');
823
824 if (Foundation.rtl && !settings.vertical) {
825 handle_offset = -handle_offset;
826 }
827
828 handle_offset = settings.vertical ? -handle_offset + bar_l - handle_l + 1 : handle_offset;
829 this.set_translate($handle, handle_offset, settings.vertical);
830
831 if (settings.vertical) {
832 $handle.siblings('.range-slider-active-segment').css('height', progress_bar_length + '%');
833 } else {
834 $handle.siblings('.range-slider-active-segment').css('width', progress_bar_length + '%');
835 }
836
837 $handle_parent.attr(this.attr_name(), value).trigger('change').trigger('change.fndtn.slider');
838
839 $hidden_inputs.val(value);
840 if (settings.trigger_input_change) {
841 $hidden_inputs.trigger('change');
842 }
843
844 if (!$handle[0].hasAttribute('aria-valuemin')) {
845 $handle.attr({
846 'aria-valuemin': settings.start,
847 'aria-valuemax': settings.end
848 });
849 }
850 $handle.attr('aria-valuenow', value);
851
852 if (settings.display_selector != '') {
853 $(settings.display_selector).each(function () {
854 if (this.hasOwnProperty('value')) {
855 $(this).val(value);
856 } else {
857 $(this).text(value);
858 }
859 });
860 }
861
862 },
863
864 normalized_percentage: function (val, start, end) {
865 return Math.min(1, (val - start) / (end - start));
866 },
867
868 normalized_value: function (val, start, end, step, precision) {
869 var range = end - start,
870 point = val * range,
871 mod = (point - (point % step)) / step,
872 rem = point % step,
873 round = ( rem >= step * 0.5 ? step : 0);
874 return ((mod * step + round) + start).toFixed(precision);
875 },
876
877 set_translate: function (ele, offset, vertical) {
878 if (vertical) {
879 $(ele)
880 .css('-webkit-transform', 'translateY(' + offset + 'px)')
881 .css('-moz-transform', 'translateY(' + offset + 'px)')
882 .css('-ms-transform', 'translateY(' + offset + 'px)')
883 .css('-o-transform', 'translateY(' + offset + 'px)')
884 .css('transform', 'translateY(' + offset + 'px)');
885 } else {
886 $(ele)
887 .css('-webkit-transform', 'translateX(' + offset + 'px)')
888 .css('-moz-transform', 'translateX(' + offset + 'px)')
889 .css('-ms-transform', 'translateX(' + offset + 'px)')
890 .css('-o-transform', 'translateX(' + offset + 'px)')
891 .css('transform', 'translateX(' + offset + 'px)');
892 }
893 },
894
895 limit_to: function (val, min, max) {
896 return Math.min(Math.max(val, min), max);
897 },
898
899
900 initialize_settings: function (handle) {
901 var settings = $.extend({}, this.settings, this.data_options($(handle).parent())),
902 decimal_places_match_result;
903
904 if (settings.precision === null) {
905 decimal_places_match_result = ('' + settings.step).match(/\.([\d]*)/);
906 settings.precision = decimal_places_match_result && decimal_places_match_result[1] ? decimal_places_match_result[1].length : 0;
907 }
908
909 if (settings.vertical) {
910 $.data(handle, 'bar_o', $(handle).parent().offset().top);
911 $.data(handle, 'bar_l', $(handle).parent().outerHeight());
912 $.data(handle, 'handle_o', $(handle).offset().top);
913 $.data(handle, 'handle_l', $(handle).outerHeight());
914 } else {
915 $.data(handle, 'bar_o', $(handle).parent().offset().left);
916 $.data(handle, 'bar_l', $(handle).parent().outerWidth());
917 $.data(handle, 'handle_o', $(handle).offset().left);
918 $.data(handle, 'handle_l', $(handle).outerWidth());
919 }
920
921 $.data(handle, 'bar', $(handle).parent());
922 $.data(handle, 'settings', settings);
923 },
924
925 set_initial_position: function ($ele) {
926 var settings = $.data($ele.children('.range-slider-handle')[0], 'settings'),
927 initial = ((typeof settings.initial == 'number' && !isNaN(settings.initial)) ? settings.initial : Math.floor((settings.end - settings.start) * 0.5 / settings.step) * settings.step + settings.start),
928 $handle = $ele.children('.range-slider-handle');
929 this.set_ui($handle, initial);
930 },
931
932 set_value: function (value) {
933 var self = this;
934 $('[' + self.attr_name() + ']', this.scope).each(function () {
935 $(this).attr(self.attr_name(), value);
936 });
937 if (!!$(this.scope).attr(self.attr_name())) {
938 $(this.scope).attr(self.attr_name(), value);
939 }
940 self.reflow();
941 },
942
943 reflow: function () {
944 var self = this;
945 self.S('[' + this.attr_name() + ']').each(function () {
946 var handle = $(this).children('.range-slider-handle')[0],
947 val = $(this).attr(self.attr_name());
948 self.initialize_settings(handle);
949
950 if (val) {
951 self.set_ui($(handle), parseFloat(val));
952 } else {
953 self.set_initial_position($(this));
954 }
955 });
956 }
957 };
958
959 }(jQuery, window, window.document));
960 ;
961 (function ($, window, document, undefined) {
962 'use strict';
963
964 var Modernizr = Modernizr || false;
965
966 Foundation.libs.joyride = {
967 name: 'joyride',
968
969 version: '5.5.0',
970
971 defaults: {
972 expose: false, // turn on or off the expose feature
973 modal: true, // Whether to cover page with modal during the tour
974 keyboard: true, // enable left, right and esc keystrokes
975 tip_location: 'bottom', // 'top' or 'bottom' in relation to parent
976 nub_position: 'auto', // override on a per tooltip bases
977 scroll_speed: 1500, // Page scrolling speed in milliseconds, 0 = no scroll animation
978 scroll_animation: 'linear', // supports 'swing' and 'linear', extend with jQuery UI.
979 timer: 0, // 0 = no timer , all other numbers = timer in milliseconds
980 start_timer_on_click: true, // true or false - true requires clicking the first button start the timer
981 start_offset: 0, // the index of the tooltip you want to start on (index of the li)
982 next_button: true, // true or false to control whether a next button is used
983 prev_button: true, // true or false to control whether a prev button is used
984 tip_animation: 'fade', // 'pop' or 'fade' in each tip
985 pause_after: [], // array of indexes where to pause the tour after
986 exposed: [], // array of expose elements
987 tip_animation_fade_speed: 300, // when tipAnimation = 'fade' this is speed in milliseconds for the transition
988 cookie_monster: false, // true or false to control whether cookies are used
989 cookie_name: 'joyride', // Name the cookie you'll use
990 cookie_domain: false, // Will this cookie be attached to a domain, ie. '.notableapp.com'
991 cookie_expires: 365, // set when you would like the cookie to expire.
992 tip_container: 'body', // Where will the tip be attached
993 abort_on_close: true, // When true, the close event will not fire any callback
994 tip_location_patterns: {
995 top: ['bottom'],
996 bottom: [], // bottom should not need to be repositioned
997 left: ['right', 'top', 'bottom'],
998 right: ['left', 'top', 'bottom']
999 },
1000 post_ride_callback: function () {
1001 }, // A method to call once the tour closes (canceled or complete)
1002 post_step_callback: function () {
1003 }, // A method to call after each step
1004 pre_step_callback: function () {
1005 }, // A method to call before each step
1006 pre_ride_callback: function () {
1007 }, // A method to call before the tour starts (passed index, tip, and cloned exposed element)
1008 post_expose_callback: function () {
1009 }, // A method to call after an element has been exposed
1010 template: { // HTML segments for tip layout
1011 link: '<a href="#close" class="joyride-close-tip">&times;</a>',
1012 timer: '<div class="joyride-timer-indicator-wrap"><span class="joyride-timer-indicator"></span></div>',
1013 tip: '<div class="joyride-tip-guide"><span class="joyride-nub"></span></div>',
1014 wrapper: '<div class="joyride-content-wrapper"></div>',
1015 button: '<a href="#" class="small button joyride-next-tip"></a>',
1016 prev_button: '<a href="#" class="small button joyride-prev-tip"></a>',
1017 modal: '<div class="joyride-modal-bg"></div>',
1018 expose: '<div class="joyride-expose-wrapper"></div>',
1019 expose_cover: '<div class="joyride-expose-cover"></div>'
1020 },
1021 expose_add_class: '' // One or more space-separated class names to be added to exposed element
1022 },
1023
1024 init: function (scope, method, options) {
1025 Foundation.inherit(this, 'throttle random_str');
1026
1027 this.settings = this.settings || $.extend({}, this.defaults, (options || method));
1028
1029 this.bindings(method, options)
1030 },
1031
1032 go_next: function () {
1033 if (this.settings.$li.next().length < 1) {
1034 this.end();
1035 } else if (this.settings.timer > 0) {
1036 clearTimeout(this.settings.automate);
1037 this.hide();
1038 this.show();
1039 this.startTimer();
1040 } else {
1041 this.hide();
1042 this.show();
1043 }
1044 },
1045
1046 go_prev: function () {
1047 if (this.settings.$li.prev().length < 1) {
1048 // Do nothing if there are no prev element
1049 } else if (this.settings.timer > 0) {
1050 clearTimeout(this.settings.automate);
1051 this.hide();
1052 this.show(null, true);
1053 this.startTimer();
1054 } else {
1055 this.hide();
1056 this.show(null, true);
1057 }
1058 },
1059
1060 events: function () {
1061 var self = this;
1062
1063 $(this.scope)
1064 .off('.joyride')
1065 .on('click.fndtn.joyride', '.joyride-next-tip, .joyride-modal-bg', function (e) {
1066 e.preventDefault();
1067 this.go_next()
1068 }.bind(this))
1069 .on('click.fndtn.joyride', '.joyride-prev-tip', function (e) {
1070 e.preventDefault();
1071 this.go_prev();
1072 }.bind(this))
1073
1074 .on('click.fndtn.joyride', '.joyride-close-tip', function (e) {
1075 e.preventDefault();
1076 this.end(this.settings.abort_on_close);
1077 }.bind(this))
1078
1079 .on('keyup.fndtn.joyride', function (e) {
1080 // Don't do anything if keystrokes are disabled
1081 // or if the joyride is not being shown
1082 if (!this.settings.keyboard || !this.settings.riding) return;
1083
1084 switch (e.which) {
1085 case 39: // right arrow
1086 e.preventDefault();
1087 this.go_next();
1088 break;
1089 case 37: // left arrow
1090 e.preventDefault();
1091 this.go_prev();
1092 break;
1093 case 27: // escape
1094 e.preventDefault();
1095 this.end(this.settings.abort_on_close);
1096 }
1097 }.bind(this));
1098
1099 $(window)
1100 .off('.joyride')
1101 .on('resize.fndtn.joyride', self.throttle(function () {
1102 if ($('[' + self.attr_name() + ']').length > 0 && self.settings.$next_tip && self.settings.riding) {
1103 if (self.settings.exposed.length > 0) {
1104 var $els = $(self.settings.exposed);
1105
1106 $els.each(function () {
1107 var $this = $(this);
1108 self.un_expose($this);
1109 self.expose($this);
1110 });
1111 }
1112
1113 if (self.is_phone()) {
1114 self.pos_phone();
1115 } else {
1116 self.pos_default(false);
1117 }
1118 }
1119 }, 100));
1120 },
1121
1122 start: function () {
1123 var self = this,
1124 $this = $('[' + this.attr_name() + ']', this.scope),
1125 integer_settings = ['timer', 'scrollSpeed', 'startOffset', 'tipAnimationFadeSpeed', 'cookieExpires'],
1126 int_settings_count = integer_settings.length;
1127
1128 if (!$this.length > 0) return;
1129
1130 if (!this.settings.init) this.events();
1131
1132 this.settings = $this.data(this.attr_name(true) + '-init');
1133
1134 // non configureable settings
1135 this.settings.$content_el = $this;
1136 this.settings.$body = $(this.settings.tip_container);
1137 this.settings.body_offset = $(this.settings.tip_container).position();
1138 this.settings.$tip_content = this.settings.$content_el.find('> li');
1139 this.settings.paused = false;
1140 this.settings.attempts = 0;
1141 this.settings.riding = true;
1142
1143 // can we create cookies?
1144 if (typeof $.cookie !== 'function') {
1145 this.settings.cookie_monster = false;
1146 }
1147
1148 // generate the tips and insert into dom.
1149 if (!this.settings.cookie_monster || this.settings.cookie_monster && !$.cookie(this.settings.cookie_name)) {
1150 this.settings.$tip_content.each(function (index) {
1151 var $this = $(this);
1152 this.settings = $.extend({}, self.defaults, self.data_options($this));
1153
1154 // Make sure that settings parsed from data_options are integers where necessary
1155 var i = int_settings_count;
1156 while (i--) {
1157 self.settings[integer_settings[i]] = parseInt(self.settings[integer_settings[i]], 10);
1158 }
1159 self.create({$li: $this, index: index});
1160 });
1161
1162 // show first tip
1163 if (!this.settings.start_timer_on_click && this.settings.timer > 0) {
1164 this.show('init');
1165 this.startTimer();
1166 } else {
1167 this.show('init');
1168 }
1169
1170 }
1171 },
1172
1173 resume: function () {
1174 this.set_li();
1175 this.show();
1176 },
1177
1178 tip_template: function (opts) {
1179 var $blank, content;
1180
1181 opts.tip_class = opts.tip_class || '';
1182
1183 $blank = $(this.settings.template.tip).addClass(opts.tip_class);
1184 content = $.trim($(opts.li).html()) +
1185 this.prev_button_text(opts.prev_button_text, opts.index) +
1186 this.button_text(opts.button_text) +
1187 this.settings.template.link +
1188 this.timer_instance(opts.index);
1189
1190 $blank.append($(this.settings.template.wrapper));
1191 $blank.first().attr(this.add_namespace('data-index'), opts.index);
1192 $('.joyride-content-wrapper', $blank).append(content);
1193
1194 return $blank[0];
1195 },
1196
1197 timer_instance: function (index) {
1198 var txt;
1199
1200 if ((index === 0 && this.settings.start_timer_on_click && this.settings.timer > 0) || this.settings.timer === 0) {
1201 txt = '';
1202 } else {
1203 txt = $(this.settings.template.timer)[0].outerHTML;
1204 }
1205 return txt;
1206 },
1207
1208 button_text: function (txt) {
1209 if (this.settings.tip_settings.next_button) {
1210 txt = $.trim(txt) || 'Next';
1211 txt = $(this.settings.template.button).append(txt)[0].outerHTML;
1212 } else {
1213 txt = '';
1214 }
1215 return txt;
1216 },
1217
1218 prev_button_text: function (txt, idx) {
1219 if (this.settings.tip_settings.prev_button) {
1220 txt = $.trim(txt) || 'Previous';
1221
1222 // Add the disabled class to the button if it's the first element
1223 if (idx == 0)
1224 txt = $(this.settings.template.prev_button).append(txt).addClass('disabled')[0].outerHTML;
1225 else
1226 txt = $(this.settings.template.prev_button).append(txt)[0].outerHTML;
1227 } else {
1228 txt = '';
1229 }
1230 return txt;
1231 },
1232
1233 create: function (opts) {
1234 this.settings.tip_settings = $.extend({}, this.settings, this.data_options(opts.$li));
1235 var buttonText = opts.$li.attr(this.add_namespace('data-button'))
1236 || opts.$li.attr(this.add_namespace('data-text')),
1237 prevButtonText = opts.$li.attr(this.add_namespace('data-button-prev'))
1238 || opts.$li.attr(this.add_namespace('data-prev-text')),
1239 tipClass = opts.$li.attr('class'),
1240 $tip_content = $(this.tip_template({
1241 tip_class: tipClass,
1242 index: opts.index,
1243 button_text: buttonText,
1244 prev_button_text: prevButtonText,
1245 li: opts.$li
1246 }));
1247
1248 $(this.settings.tip_container).append($tip_content);
1249 },
1250
1251 show: function (init, is_prev) {
1252 var $timer = null;
1253
1254 // are we paused?
1255 if (this.settings.$li === undefined
1256 || ($.inArray(this.settings.$li.index(), this.settings.pause_after) === -1)) {
1257
1258 // don't go to the next li if the tour was paused
1259 if (this.settings.paused) {
1260 this.settings.paused = false;
1261 } else {
1262 this.set_li(init, is_prev);
1263 }
1264
1265 this.settings.attempts = 0;
1266
1267 if (this.settings.$li.length && this.settings.$target.length > 0) {
1268 if (init) { //run when we first start
1269 this.settings.pre_ride_callback(this.settings.$li.index(), this.settings.$next_tip);
1270 if (this.settings.modal) {
1271 this.show_modal();
1272 }
1273 }
1274
1275 this.settings.pre_step_callback(this.settings.$li.index(), this.settings.$next_tip);
1276
1277 if (this.settings.modal && this.settings.expose) {
1278 this.expose();
1279 }
1280
1281 this.settings.tip_settings = $.extend({}, this.settings, this.data_options(this.settings.$li));
1282
1283 this.settings.timer = parseInt(this.settings.timer, 10);
1284
1285 this.settings.tip_settings.tip_location_pattern = this.settings.tip_location_patterns[this.settings.tip_settings.tip_location];
1286
1287 // scroll and hide bg if not modal
1288 if (!/body/i.test(this.settings.$target.selector)) {
1289 var joyridemodalbg = $('.joyride-modal-bg');
1290 if (/pop/i.test(this.settings.tipAnimation)) {
1291 joyridemodalbg.hide();
1292 } else {
1293 joyridemodalbg.fadeOut(this.settings.tipAnimationFadeSpeed);
1294 }
1295 this.scroll_to();
1296 }
1297
1298 if (this.is_phone()) {
1299 this.pos_phone(true);
1300 } else {
1301 this.pos_default(true);
1302 }
1303
1304 $timer = this.settings.$next_tip.find('.joyride-timer-indicator');
1305
1306 if (/pop/i.test(this.settings.tip_animation)) {
1307
1308 $timer.width(0);
1309
1310 if (this.settings.timer > 0) {
1311
1312 this.settings.$next_tip.show();
1313
1314 setTimeout(function () {
1315 $timer.animate({
1316 width: $timer.parent().width()
1317 }, this.settings.timer, 'linear');
1318 }.bind(this), this.settings.tip_animation_fade_speed);
1319
1320 } else {
1321 this.settings.$next_tip.show();
1322
1323 }
1324
1325
1326 } else if (/fade/i.test(this.settings.tip_animation)) {
1327
1328 $timer.width(0);
1329
1330 if (this.settings.timer > 0) {
1331
1332 this.settings.$next_tip
1333 .fadeIn(this.settings.tip_animation_fade_speed)
1334 .show();
1335
1336 setTimeout(function () {
1337 $timer.animate({
1338 width: $timer.parent().width()
1339 }, this.settings.timer, 'linear');
1340 }.bind(this), this.settings.tip_animation_fade_speed);
1341
1342 } else {
1343 this.settings.$next_tip.fadeIn(this.settings.tip_animation_fade_speed);
1344 }
1345 }
1346
1347 this.settings.$current_tip = this.settings.$next_tip;
1348
1349 // skip non-existant targets
1350 } else if (this.settings.$li && this.settings.$target.length < 1) {
1351
1352 this.show(init, is_prev);
1353
1354 } else {
1355
1356 this.end();
1357
1358 }
1359 } else {
1360
1361 this.settings.paused = true;
1362
1363 }
1364
1365 },
1366
1367 is_phone: function () {
1368 return matchMedia(Foundation.media_queries.small).matches && !matchMedia(Foundation.media_queries.medium).matches;
1369 },
1370
1371 hide: function () {
1372 if (this.settings.modal && this.settings.expose) {
1373 this.un_expose();
1374 }
1375
1376 if (!this.settings.modal) {
1377 $('.joyride-modal-bg').hide();
1378 }
1379
1380 // Prevent scroll bouncing...wait to remove from layout
1381 this.settings.$current_tip.css('visibility', 'hidden');
1382 setTimeout($.proxy(function () {
1383 this.hide();
1384 this.css('visibility', 'visible');
1385 }, this.settings.$current_tip), 0);
1386 this.settings.post_step_callback(this.settings.$li.index(),
1387 this.settings.$current_tip);
1388 },
1389
1390 set_li: function (init, is_prev) {
1391 if (init) {
1392 this.settings.$li = this.settings.$tip_content.eq(this.settings.start_offset);
1393 this.set_next_tip();
1394 this.settings.$current_tip = this.settings.$next_tip;
1395 } else {
1396 if (is_prev)
1397 this.settings.$li = this.settings.$li.prev();
1398 else
1399 this.settings.$li = this.settings.$li.next();
1400 this.set_next_tip();
1401 }
1402
1403 this.set_target();
1404 },
1405
1406 set_next_tip: function () {
1407 this.settings.$next_tip = $('.joyride-tip-guide').eq(this.settings.$li.index());
1408 this.settings.$next_tip.data('closed', '');
1409 },
1410
1411 set_target: function () {
1412 var cl = this.settings.$li.attr(this.add_namespace('data-class')),
1413 id = this.settings.$li.attr(this.add_namespace('data-id')),
1414 $sel = function () {
1415 if (id) {
1416 return $(document.getElementById(id));
1417 } else if (cl) {
1418 return $('.' + cl).first();
1419 } else {
1420 return $('body');
1421 }
1422 };
1423
1424 this.settings.$target = $sel();
1425 },
1426
1427 scroll_to: function () {
1428 var window_half, tipOffset;
1429
1430 window_half = $(window).height() / 2;
1431 tipOffset = Math.ceil(this.settings.$target.offset().top - window_half + this.settings.$next_tip.outerHeight());
1432
1433 if (tipOffset != 0) {
1434 $('html, body').stop().animate({
1435 scrollTop: tipOffset
1436 }, this.settings.scroll_speed, 'swing');
1437 }
1438 },
1439
1440 paused: function () {
1441 return ($.inArray((this.settings.$li.index() + 1), this.settings.pause_after) === -1);
1442 },
1443
1444 restart: function () {
1445 this.hide();
1446 this.settings.$li = undefined;
1447 this.show('init');
1448 },
1449
1450 pos_default: function (init) {
1451 var $nub = this.settings.$next_tip.find('.joyride-nub'),
1452 nub_width = Math.ceil($nub.outerWidth() / 2),
1453 nub_height = Math.ceil($nub.outerHeight() / 2),
1454 toggle = init || false;
1455
1456 // tip must not be "display: none" to calculate position
1457 if (toggle) {
1458 this.settings.$next_tip.css('visibility', 'hidden');
1459 this.settings.$next_tip.show();
1460 }
1461
1462 if (!/body/i.test(this.settings.$target.selector)) {
1463 var topAdjustment = this.settings.tip_settings.tipAdjustmentY ? parseInt(this.settings.tip_settings.tipAdjustmentY) : 0,
1464 leftAdjustment = this.settings.tip_settings.tipAdjustmentX ? parseInt(this.settings.tip_settings.tipAdjustmentX) : 0;
1465
1466 if (this.bottom()) {
1467 if (this.rtl) {
1468 this.settings.$next_tip.css({
1469 top: (this.settings.$target.offset().top + nub_height + this.settings.$target.outerHeight() + topAdjustment),
1470 left: this.settings.$target.offset().left + this.settings.$target.outerWidth() - this.settings.$next_tip.outerWidth() + leftAdjustment
1471 });
1472 } else {
1473 this.settings.$next_tip.css({
1474 top: (this.settings.$target.offset().top + nub_height + this.settings.$target.outerHeight() + topAdjustment),
1475 left: this.settings.$target.offset().left + leftAdjustment
1476 });
1477 }
1478
1479 this.nub_position($nub, this.settings.tip_settings.nub_position, 'top');
1480
1481 } else if (this.top()) {
1482 if (this.rtl) {
1483 this.settings.$next_tip.css({
1484 top: (this.settings.$target.offset().top - this.settings.$next_tip.outerHeight() - nub_height + topAdjustment),
1485 left: this.settings.$target.offset().left + this.settings.$target.outerWidth() - this.settings.$next_tip.outerWidth()
1486 });
1487 } else {
1488 this.settings.$next_tip.css({
1489 top: (this.settings.$target.offset().top - this.settings.$next_tip.outerHeight() - nub_height + topAdjustment),
1490 left: this.settings.$target.offset().left + leftAdjustment
1491 });
1492 }
1493
1494 this.nub_position($nub, this.settings.tip_settings.nub_position, 'bottom');
1495
1496 } else if (this.right()) {
1497
1498 this.settings.$next_tip.css({
1499 top: this.settings.$target.offset().top + topAdjustment,
1500 left: (this.settings.$target.outerWidth() + this.settings.$target.offset().left + nub_width + leftAdjustment)
1501 });
1502
1503 this.nub_position($nub, this.settings.tip_settings.nub_position, 'left');
1504
1505 } else if (this.left()) {
1506
1507 this.settings.$next_tip.css({
1508 top: this.settings.$target.offset().top + topAdjustment,
1509 left: (this.settings.$target.offset().left - this.settings.$next_tip.outerWidth() - nub_width + leftAdjustment)
1510 });
1511
1512 this.nub_position($nub, this.settings.tip_settings.nub_position, 'right');
1513
1514 }
1515
1516 if (!this.visible(this.corners(this.settings.$next_tip)) && this.settings.attempts < this.settings.tip_settings.tip_location_pattern.length) {
1517
1518 $nub.removeClass('bottom')
1519 .removeClass('top')
1520 .removeClass('right')
1521 .removeClass('left');
1522
1523 this.settings.tip_settings.tip_location = this.settings.tip_settings.tip_location_pattern[this.settings.attempts];
1524
1525 this.settings.attempts++;
1526
1527 this.pos_default();
1528
1529 }
1530
1531 } else if (this.settings.$li.length) {
1532
1533 this.pos_modal($nub);
1534
1535 }
1536
1537 if (toggle) {
1538 this.settings.$next_tip.hide();
1539 this.settings.$next_tip.css('visibility', 'visible');
1540 }
1541
1542 },
1543
1544 pos_phone: function (init) {
1545 var tip_height = this.settings.$next_tip.outerHeight(),
1546 tip_offset = this.settings.$next_tip.offset(),
1547 target_height = this.settings.$target.outerHeight(),
1548 $nub = $('.joyride-nub', this.settings.$next_tip),
1549 nub_height = Math.ceil($nub.outerHeight() / 2),
1550 toggle = init || false;
1551
1552 $nub.removeClass('bottom')
1553 .removeClass('top')
1554 .removeClass('right')
1555 .removeClass('left');
1556
1557 if (toggle) {
1558 this.settings.$next_tip.css('visibility', 'hidden');
1559 this.settings.$next_tip.show();
1560 }
1561
1562 if (!/body/i.test(this.settings.$target.selector)) {
1563
1564 if (this.top()) {
1565
1566 this.settings.$next_tip.offset({top: this.settings.$target.offset().top - tip_height - nub_height});
1567 $nub.addClass('bottom');
1568
1569 } else {
1570
1571 this.settings.$next_tip.offset({top: this.settings.$target.offset().top + target_height + nub_height});
1572 $nub.addClass('top');
1573
1574 }
1575
1576 } else if (this.settings.$li.length) {
1577 this.pos_modal($nub);
1578 }
1579
1580 if (toggle) {
1581 this.settings.$next_tip.hide();
1582 this.settings.$next_tip.css('visibility', 'visible');
1583 }
1584 },
1585
1586 pos_modal: function ($nub) {
1587 this.center();
1588 $nub.hide();
1589
1590 this.show_modal();
1591 },
1592
1593 show_modal: function () {
1594 if (!this.settings.$next_tip.data('closed')) {
1595 var joyridemodalbg = $('.joyride-modal-bg');
1596 if (joyridemodalbg.length < 1) {
1597 var joyridemodalbg = $(this.settings.template.modal);
1598 joyridemodalbg.appendTo('body');
1599 }
1600
1601 if (/pop/i.test(this.settings.tip_animation)) {
1602 joyridemodalbg.show();
1603 } else {
1604 joyridemodalbg.fadeIn(this.settings.tip_animation_fade_speed);
1605 }
1606 }
1607 },
1608
1609 expose: function () {
1610 var expose,
1611 exposeCover,
1612 el,
1613 origCSS,
1614 origClasses,
1615 randId = 'expose-' + this.random_str(6);
1616
1617 if (arguments.length > 0 && arguments[0] instanceof $) {
1618 el = arguments[0];
1619 } else if (this.settings.$target && !/body/i.test(this.settings.$target.selector)) {
1620 el = this.settings.$target;
1621 } else {
1622 return false;
1623 }
1624
1625 if (el.length < 1) {
1626 if (window.console) {
1627 console.error('element not valid', el);
1628 }
1629 return false;
1630 }
1631
1632 expose = $(this.settings.template.expose);
1633 this.settings.$body.append(expose);
1634 expose.css({
1635 top: el.offset().top,
1636 left: el.offset().left,
1637 width: el.outerWidth(true),
1638 height: el.outerHeight(true)
1639 });
1640
1641 exposeCover = $(this.settings.template.expose_cover);
1642
1643 origCSS = {
1644 zIndex: el.css('z-index'),
1645 position: el.css('position')
1646 };
1647
1648 origClasses = el.attr('class') == null ? '' : el.attr('class');
1649
1650 el.css('z-index', parseInt(expose.css('z-index')) + 1);
1651
1652 if (origCSS.position == 'static') {
1653 el.css('position', 'relative');
1654 }
1655
1656 el.data('expose-css', origCSS);
1657 el.data('orig-class', origClasses);
1658 el.attr('class', origClasses + ' ' + this.settings.expose_add_class);
1659
1660 exposeCover.css({
1661 top: el.offset().top,
1662 left: el.offset().left,
1663 width: el.outerWidth(true),
1664 height: el.outerHeight(true)
1665 });
1666
1667 if (this.settings.modal) this.show_modal();
1668
1669 this.settings.$body.append(exposeCover);
1670 expose.addClass(randId);
1671 exposeCover.addClass(randId);
1672 el.data('expose', randId);
1673 this.settings.post_expose_callback(this.settings.$li.index(), this.settings.$next_tip, el);
1674 this.add_exposed(el);
1675 },
1676
1677 un_expose: function () {
1678 var exposeId,
1679 el,
1680 expose,
1681 origCSS,
1682 origClasses,
1683 clearAll = false;
1684
1685 if (arguments.length > 0 && arguments[0] instanceof $) {
1686 el = arguments[0];
1687 } else if (this.settings.$target && !/body/i.test(this.settings.$target.selector)) {
1688 el = this.settings.$target;
1689 } else {
1690 return false;
1691 }
1692
1693 if (el.length < 1) {
1694 if (window.console) {
1695 console.error('element not valid', el);
1696 }
1697 return false;
1698 }
1699
1700 exposeId = el.data('expose');
1701 expose = $('.' + exposeId);
1702
1703 if (arguments.length > 1) {
1704 clearAll = arguments[1];
1705 }
1706
1707 if (clearAll === true) {
1708 $('.joyride-expose-wrapper,.joyride-expose-cover').remove();
1709 } else {
1710 expose.remove();
1711 }
1712
1713 origCSS = el.data('expose-css');
1714
1715 if (origCSS.zIndex == 'auto') {
1716 el.css('z-index', '');
1717 } else {
1718 el.css('z-index', origCSS.zIndex);
1719 }
1720
1721 if (origCSS.position != el.css('position')) {
1722 if (origCSS.position == 'static') {// this is default, no need to set it.
1723 el.css('position', '');
1724 } else {
1725 el.css('position', origCSS.position);
1726 }
1727 }
1728
1729 origClasses = el.data('orig-class');
1730 el.attr('class', origClasses);
1731 el.removeData('orig-classes');
1732
1733 el.removeData('expose');
1734 el.removeData('expose-z-index');
1735 this.remove_exposed(el);
1736 },
1737
1738 add_exposed: function (el) {
1739 this.settings.exposed = this.settings.exposed || [];
1740 if (el instanceof $ || typeof el === 'object') {
1741 this.settings.exposed.push(el[0]);
1742 } else if (typeof el == 'string') {
1743 this.settings.exposed.push(el);
1744 }
1745 },
1746
1747 remove_exposed: function (el) {
1748 var search, i;
1749 if (el instanceof $) {
1750 search = el[0]
1751 } else if (typeof el == 'string') {
1752 search = el;
1753 }
1754
1755 this.settings.exposed = this.settings.exposed || [];
1756 i = this.settings.exposed.length;
1757
1758 while (i--) {
1759 if (this.settings.exposed[i] == search) {
1760 this.settings.exposed.splice(i, 1);
1761 return;
1762 }
1763 }
1764 },
1765
1766 center: function () {
1767 var $w = $(window);
1768
1769 this.settings.$next_tip.css({
1770 top: ((($w.height() - this.settings.$next_tip.outerHeight()) / 2) + $w.scrollTop()),
1771 left: ((($w.width() - this.settings.$next_tip.outerWidth()) / 2) + $w.scrollLeft())
1772 });
1773
1774 return true;
1775 },
1776
1777 bottom: function () {
1778 return /bottom/i.test(this.settings.tip_settings.tip_location);
1779 },
1780
1781 top: function () {
1782 return /top/i.test(this.settings.tip_settings.tip_location);
1783 },
1784
1785 right: function () {
1786 return /right/i.test(this.settings.tip_settings.tip_location);
1787 },
1788
1789 left: function () {
1790 return /left/i.test(this.settings.tip_settings.tip_location);
1791 },
1792
1793 corners: function (el) {
1794 var w = $(window),
1795 window_half = w.height() / 2,
1796 //using this to calculate since scroll may not have finished yet.
1797 tipOffset = Math.ceil(this.settings.$target.offset().top - window_half + this.settings.$next_tip.outerHeight()),
1798 right = w.width() + w.scrollLeft(),
1799 offsetBottom = w.height() + tipOffset,
1800 bottom = w.height() + w.scrollTop(),
1801 top = w.scrollTop();
1802
1803 if (tipOffset < top) {
1804 if (tipOffset < 0) {
1805 top = 0;
1806 } else {
1807 top = tipOffset;
1808 }
1809 }
1810
1811 if (offsetBottom > bottom) {
1812 bottom = offsetBottom;
1813 }
1814
1815 return [
1816 el.offset().top < top,
1817 right < el.offset().left + el.outerWidth(),
1818 bottom < el.offset().top + el.outerHeight(),
1819 w.scrollLeft() > el.offset().left
1820 ];
1821 },
1822
1823 visible: function (hidden_corners) {
1824 var i = hidden_corners.length;
1825
1826 while (i--) {
1827 if (hidden_corners[i]) return false;
1828 }
1829
1830 return true;
1831 },
1832
1833 nub_position: function (nub, pos, def) {
1834 if (pos === 'auto') {
1835 nub.addClass(def);
1836 } else {
1837 nub.addClass(pos);
1838 }
1839 },
1840
1841 startTimer: function () {
1842 if (this.settings.$li.length) {
1843 this.settings.automate = setTimeout(function () {
1844 this.hide();
1845 this.show();
1846 this.startTimer();
1847 }.bind(this), this.settings.timer);
1848 } else {
1849 clearTimeout(this.settings.automate);
1850 }
1851 },
1852
1853 end: function (abort) {
1854 if (this.settings.cookie_monster) {
1855 $.cookie(this.settings.cookie_name, 'ridden', {
1856 expires: this.settings.cookie_expires,
1857 domain: this.settings.cookie_domain
1858 });
1859 }
1860
1861 if (this.settings.timer > 0) {
1862 clearTimeout(this.settings.automate);
1863 }
1864
1865 if (this.settings.modal && this.settings.expose) {
1866 this.un_expose();
1867 }
1868
1869 // Unplug keystrokes listener
1870 $(this.scope).off('keyup.joyride')
1871
1872 this.settings.$next_tip.data('closed', true);
1873 this.settings.riding = false;
1874
1875 $('.joyride-modal-bg').hide();
1876 this.settings.$current_tip.hide();
1877
1878 if (typeof abort === 'undefined' || abort === false) {
1879 this.settings.post_step_callback(this.settings.$li.index(), this.settings.$current_tip);
1880 this.settings.post_ride_callback(this.settings.$li.index(), this.settings.$current_tip);
1881 }
1882
1883 $('.joyride-tip-guide').remove();
1884 },
1885
1886 off: function () {
1887 $(this.scope).off('.joyride');
1888 $(window).off('.joyride');
1889 $('.joyride-close-tip, .joyride-next-tip, .joyride-modal-bg').off('.joyride');
1890 $('.joyride-tip-guide, .joyride-modal-bg').remove();
1891 clearTimeout(this.settings.automate);
1892 this.settings = {};
1893 },
1894
1895 reflow: function () {
1896 }
1897 };
1898 }(jQuery, window, window.document));
1899 ;
1900 (function ($, window, document, undefined) {
1901 'use strict';
1902
1903 Foundation.libs.equalizer = {
1904 name: 'equalizer',
1905
1906 version: '5.5.0',
1907
1908 settings: {
1909 use_tallest: true,
1910 before_height_change: $.noop,
1911 after_height_change: $.noop,
1912 equalize_on_stack: false
1913 },
1914
1915 init: function (scope, method, options) {
1916 Foundation.inherit(this, 'image_loaded');
1917 this.bindings(method, options);
1918 this.reflow();
1919 },
1920
1921 events: function () {
1922 this.S(window).off('.equalizer').on('resize.fndtn.equalizer', function (e) {
1923 this.reflow();
1924 }.bind(this));
1925 },
1926
1927 equalize: function (equalizer) {
1928 var isStacked = false,
1929 vals = equalizer.find('[' + this.attr_name() + '-watch]:visible'),
1930 settings = equalizer.data(this.attr_name(true) + '-init');
1931
1932 if (vals.length === 0) return;
1933 var firstTopOffset = vals.first().offset().top;
1934 settings.before_height_change();
1935 equalizer.trigger('before-height-change').trigger('before-height-change.fndth.equalizer');
1936 vals.height('inherit');
1937 vals.each(function () {
1938 var el = $(this);
1939 if (el.offset().top !== firstTopOffset) {
1940 isStacked = true;
1941 }
1942 });
1943
1944 if (settings.equalize_on_stack === false) {
1945 if (isStacked) return;
1946 }
1947 ;
1948
1949 var heights = vals.map(function () {
1950 return $(this).outerHeight(false)
1951 }).get();
1952
1953 if (settings.use_tallest) {
1954 var max = Math.max.apply(null, heights);
1955 vals.css('height', max);
1956 } else {
1957 var min = Math.min.apply(null, heights);
1958 vals.css('height', min);
1959 }
1960 settings.after_height_change();
1961 equalizer.trigger('after-height-change').trigger('after-height-change.fndtn.equalizer');
1962 },
1963
1964 reflow: function () {
1965 var self = this;
1966
1967 this.S('[' + this.attr_name() + ']', this.scope).each(function () {
1968 var $eq_target = $(this);
1969 self.image_loaded(self.S('img', this), function () {
1970 self.equalize($eq_target)
1971 });
1972 });
1973 }
1974 };
1975 })(jQuery, window, window.document);
1976 ;
1977 (function ($, window, document, undefined) {
1978 'use strict';
1979
1980 Foundation.libs.dropdown = {
1981 name: 'dropdown',
1982
1983 version: '5.5.0',
1984
1985 settings: {
1986 active_class: 'open',
1987 disabled_class: 'disabled',
1988 mega_class: 'mega',
1989 align: 'bottom',
1990 is_hover: false,
1991 hover_timeout: 150,
1992 opened: function () {
1993 },
1994 closed: function () {
1995 }
1996 },
1997
1998 init: function (scope, method, options) {
1999 Foundation.inherit(this, 'throttle');
2000
2001 $.extend(true, this.settings, method, options);
2002 this.bindings(method, options);
2003 },
2004
2005 events: function (scope) {
2006 var self = this,
2007 S = self.S;
2008
2009 S(this.scope)
2010 .off('.dropdown')
2011 .on('click.fndtn.dropdown', '[' + this.attr_name() + ']', function (e) {
2012 var settings = S(this).data(self.attr_name(true) + '-init') || self.settings;
2013 if (!settings.is_hover || Modernizr.touch) {
2014 e.preventDefault();
2015 if (S(this).parent('[data-reveal-id]')) {
2016 e.stopPropagation();
2017 }
2018 self.toggle($(this));
2019 }
2020 })
2021 .on('mouseenter.fndtn.dropdown', '[' + this.attr_name() + '], [' + this.attr_name() + '-content]', function (e) {
2022 var $this = S(this),
2023 dropdown,
2024 target;
2025
2026 clearTimeout(self.timeout);
2027
2028 if ($this.data(self.data_attr())) {
2029 dropdown = S('#' + $this.data(self.data_attr()));
2030 target = $this;
2031 } else {
2032 dropdown = $this;
2033 target = S('[' + self.attr_name() + '="' + dropdown.attr('id') + '"]');
2034 }
2035
2036 var settings = target.data(self.attr_name(true) + '-init') || self.settings;
2037
2038 if (S(e.currentTarget).data(self.data_attr()) && settings.is_hover) {
2039 self.closeall.call(self);
2040 }
2041
2042 if (settings.is_hover) self.open.apply(self, [dropdown, target]);
2043 })
2044 .on('mouseleave.fndtn.dropdown', '[' + this.attr_name() + '], [' + this.attr_name() + '-content]', function (e) {
2045 var $this = S(this);
2046 var settings;
2047
2048 if ($this.data(self.data_attr())) {
2049 settings = $this.data(self.data_attr(true) + '-init') || self.settings;
2050 }
2051 else {
2052 var target = S('[' + self.attr_name() + '="' + S(this).attr('id') + '"]'),
2053 settings = target.data(self.attr_name(true) + '-init') || self.settings;
2054 }
2055
2056 self.timeout = setTimeout(function () {
2057 if ($this.data(self.data_attr())) {
2058 if (settings.is_hover) self.close.call(self, S('#' + $this.data(self.data_attr())));
2059 } else {
2060 if (settings.is_hover) self.close.call(self, $this);
2061 }
2062 }.bind(this), settings.hover_timeout);
2063 })
2064 .on('click.fndtn.dropdown', function (e) {
2065 var parent = S(e.target).closest('[' + self.attr_name() + '-content]');
2066 var links = parent.find('a');
2067
2068 if (links.length > 0 && parent.attr('aria-autoclose') !== "false") {
2069 self.close.call(self, S('[' + self.attr_name() + '-content]'));
2070 }
2071
2072 if (S(e.target).closest('[' + self.attr_name() + ']').length > 0) {
2073 return;
2074 }
2075
2076 if (!(S(e.target).data('revealId')) &&
2077 (parent.length > 0 && (S(e.target).is('[' + self.attr_name() + '-content]') ||
2078 $.contains(parent.first()[0], e.target)))) {
2079 e.stopPropagation();
2080 return;
2081 }
2082
2083 self.close.call(self, S('[' + self.attr_name() + '-content]'));
2084 })
2085 .on('opened.fndtn.dropdown', '[' + self.attr_name() + '-content]', function () {
2086 self.settings.opened.call(this);
2087 })
2088 .on('closed.fndtn.dropdown', '[' + self.attr_name() + '-content]', function () {
2089 self.settings.closed.call(this);
2090 });
2091
2092 S(window)
2093 .off('.dropdown')
2094 .on('resize.fndtn.dropdown', self.throttle(function () {
2095 self.resize.call(self);
2096 }, 50));
2097
2098 this.resize();
2099 },
2100
2101 close: function (dropdown) {
2102 var self = this;
2103 dropdown.each(function () {
2104 var original_target = $('[' + self.attr_name() + '=' + dropdown[0].id + ']') || $('aria-controls=' + dropdown[0].id + ']');
2105 original_target.attr('aria-expanded', 'false');
2106 if (self.S(this).hasClass(self.settings.active_class)) {
2107 self.S(this)
2108 .css(Foundation.rtl ? 'right' : 'left', '-99999px')
2109 .attr('aria-hidden', 'true')
2110 .removeClass(self.settings.active_class)
2111 .prev('[' + self.attr_name() + ']')
2112 .removeClass(self.settings.active_class)
2113 .removeData('target');
2114
2115 self.S(this).trigger('closed').trigger('closed.fndtn.dropdown', [dropdown]);
2116 }
2117 });
2118 dropdown.removeClass('f-open-' + this.attr_name(true));
2119 },
2120
2121 closeall: function () {
2122 var self = this;
2123 $.each(self.S('.f-open-' + this.attr_name(true)), function () {
2124 self.close.call(self, self.S(this));
2125 });
2126 },
2127
2128 open: function (dropdown, target) {
2129 this
2130 .css(dropdown
2131 .addClass(this.settings.active_class), target);
2132 dropdown.prev('[' + this.attr_name() + ']').addClass(this.settings.active_class);
2133 dropdown.data('target', target.get(0)).trigger('opened').trigger('opened.fndtn.dropdown', [dropdown, target]);
2134 dropdown.attr('aria-hidden', 'false');
2135 target.attr('aria-expanded', 'true');
2136 dropdown.focus();
2137 dropdown.addClass('f-open-' + this.attr_name(true));
2138 },
2139
2140 data_attr: function () {
2141 if (this.namespace.length > 0) {
2142 return this.namespace + '-' + this.name;
2143 }
2144
2145 return this.name;
2146 },
2147
2148 toggle: function (target) {
2149 if (target.hasClass(this.settings.disabled_class)) {
2150 return;
2151 }
2152 var dropdown = this.S('#' + target.data(this.data_attr()));
2153 if (dropdown.length === 0) {
2154 // No dropdown found, not continuing
2155 return;
2156 }
2157
2158 this.close.call(this, this.S('[' + this.attr_name() + '-content]').not(dropdown));
2159
2160 if (dropdown.hasClass(this.settings.active_class)) {
2161 this.close.call(this, dropdown);
2162 if (dropdown.data('target') !== target.get(0))
2163 this.open.call(this, dropdown, target);
2164 } else {
2165 this.open.call(this, dropdown, target);
2166 }
2167 },
2168
2169 resize: function () {
2170 var dropdown = this.S('[' + this.attr_name() + '-content].open'),
2171 target = this.S('[' + this.attr_name() + '="' + dropdown.attr('id') + '"]');
2172
2173 if (dropdown.length && target.length) {
2174 this.css(dropdown, target);
2175 }
2176 },
2177
2178 css: function (dropdown, target) {
2179 var left_offset = Math.max((target.width() - dropdown.width()) / 2, 8),
2180 settings = target.data(this.attr_name(true) + '-init') || this.settings;
2181
2182 this.clear_idx();
2183
2184 if (this.small()) {
2185 var p = this.dirs.bottom.call(dropdown, target, settings);
2186
2187 dropdown.attr('style', '').removeClass('drop-left drop-right drop-top').css({
2188 position: 'absolute',
2189 width: '95%',
2190 'max-width': 'none',
2191 top: p.top
2192 });
2193
2194 dropdown.css(Foundation.rtl ? 'right' : 'left', left_offset);
2195 } else {
2196
2197 this.style(dropdown, target, settings);
2198 }
2199
2200 return dropdown;
2201 },
2202
2203 style: function (dropdown, target, settings) {
2204 var css = $.extend({position: 'absolute'},
2205 this.dirs[settings.align].call(dropdown, target, settings));
2206
2207 dropdown.attr('style', '').css(css);
2208 },
2209
2210 // return CSS property object
2211 // `this` is the dropdown
2212 dirs: {
2213 // Calculate target offset
2214 _base: function (t) {
2215 var o_p = this.offsetParent(),
2216 o = o_p.offset(),
2217 p = t.offset();
2218
2219 p.top -= o.top;
2220 p.left -= o.left;
2221
2222 //set some flags on the p object to pass along
2223 p.missRight = false;
2224 p.missTop = false;
2225 p.missLeft = false;
2226 p.leftRightFlag = false;
2227
2228 //lets see if the panel will be off the screen
2229 //get the actual width of the page and store it
2230 var actualBodyWidth;
2231 if (document.getElementsByClassName('row')[0]) {
2232 actualBodyWidth = document.getElementsByClassName('row')[0].clientWidth;
2233 } else {
2234 actualBodyWidth = window.outerWidth;
2235 }
2236
2237 var actualMarginWidth = (window.outerWidth - actualBodyWidth) / 2;
2238 var actualBoundary = actualBodyWidth;
2239
2240 if (!this.hasClass('mega')) {
2241 //miss top
2242 if (t.offset().top <= this.outerHeight()) {
2243 p.missTop = true;
2244 actualBoundary = window.outerWidth - actualMarginWidth;
2245 p.leftRightFlag = true;
2246 }
2247
2248 //miss right
2249 if (t.offset().left + this.outerWidth() > t.offset().left + actualMarginWidth && t.offset().left - actualMarginWidth > this.outerWidth()) {
2250 p.missRight = true;
2251 p.missLeft = false;
2252 }
2253
2254 //miss left
2255 if (t.offset().left - this.outerWidth() <= 0) {
2256 p.missLeft = true;
2257 p.missRight = false;
2258 }
2259 }
2260
2261 return p;
2262 },
2263
2264 top: function (t, s) {
2265 var self = Foundation.libs.dropdown,
2266 p = self.dirs._base.call(this, t);
2267
2268 this.addClass('drop-top');
2269
2270 if (p.missTop == true) {
2271 p.top = p.top + t.outerHeight() + this.outerHeight();
2272 this.removeClass('drop-top');
2273 }
2274
2275 if (p.missRight == true) {
2276 p.left = p.left - this.outerWidth() + t.outerWidth();
2277 }
2278
2279 if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
2280 self.adjust_pip(this, t, s, p);
2281 }
2282
2283 if (Foundation.rtl) {
2284 return {
2285 left: p.left - this.outerWidth() + t.outerWidth(),
2286 top: p.top - this.outerHeight()
2287 };
2288 }
2289
2290 return {left: p.left, top: p.top - this.outerHeight()};
2291 },
2292
2293 bottom: function (t, s) {
2294 var self = Foundation.libs.dropdown,
2295 p = self.dirs._base.call(this, t);
2296
2297 if (p.missRight == true) {
2298 p.left = p.left - this.outerWidth() + t.outerWidth();
2299 }
2300
2301 if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
2302 self.adjust_pip(this, t, s, p);
2303 }
2304
2305 if (self.rtl) {
2306 return {left: p.left - this.outerWidth() + t.outerWidth(), top: p.top + t.outerHeight()};
2307 }
2308
2309 return {left: p.left, top: p.top + t.outerHeight()};
2310 },
2311
2312 left: function (t, s) {
2313 var p = Foundation.libs.dropdown.dirs._base.call(this, t);
2314
2315 this.addClass('drop-left');
2316
2317 if (p.missLeft == true) {
2318 p.left = p.left + this.outerWidth();
2319 p.top = p.top + t.outerHeight();
2320 this.removeClass('drop-left');
2321 }
2322
2323 return {left: p.left - this.outerWidth(), top: p.top};
2324 },
2325
2326 right: function (t, s) {
2327 var p = Foundation.libs.dropdown.dirs._base.call(this, t);
2328
2329 this.addClass('drop-right');
2330
2331 if (p.missRight == true) {
2332 p.left = p.left - this.outerWidth();
2333 p.top = p.top + t.outerHeight();
2334 this.removeClass('drop-right');
2335 } else {
2336 p.triggeredRight = true;
2337 }
2338
2339 var self = Foundation.libs.dropdown;
2340
2341 if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
2342 self.adjust_pip(this, t, s, p);
2343 }
2344
2345 return {left: p.left + t.outerWidth(), top: p.top};
2346 }
2347 },
2348
2349 // Insert rule to style psuedo elements
2350 adjust_pip: function (dropdown, target, settings, position) {
2351 var sheet = Foundation.stylesheet,
2352 pip_offset_base = 8;
2353
2354 if (dropdown.hasClass(settings.mega_class)) {
2355 pip_offset_base = position.left + (target.outerWidth() / 2) - 8;
2356 }
2357 else if (this.small()) {
2358 pip_offset_base += position.left - 8;
2359 }
2360
2361 this.rule_idx = sheet.cssRules.length;
2362
2363 //default
2364 var sel_before = '.f-dropdown.open:before',
2365 sel_after = '.f-dropdown.open:after',
2366 css_before = 'left: ' + pip_offset_base + 'px;',
2367 css_after = 'left: ' + (pip_offset_base - 1) + 'px;';
2368
2369 if (position.missRight == true) {
2370 pip_offset_base = dropdown.outerWidth() - 23;
2371 sel_before = '.f-dropdown.open:before',
2372 sel_after = '.f-dropdown.open:after',
2373 css_before = 'left: ' + pip_offset_base + 'px;',
2374 css_after = 'left: ' + (pip_offset_base - 1) + 'px;';
2375 }
2376
2377 //just a case where right is fired, but its not missing right
2378 if (position.triggeredRight == true) {
2379 sel_before = '.f-dropdown.open:before',
2380 sel_after = '.f-dropdown.open:after',
2381 css_before = 'left:-12px;',
2382 css_after = 'left:-14px;';
2383 }
2384
2385 if (sheet.insertRule) {
2386 sheet.insertRule([sel_before, '{', css_before, '}'].join(' '), this.rule_idx);
2387 sheet.insertRule([sel_after, '{', css_after, '}'].join(' '), this.rule_idx + 1);
2388 } else {
2389 sheet.addRule(sel_before, css_before, this.rule_idx);
2390 sheet.addRule(sel_after, css_after, this.rule_idx + 1);
2391 }
2392 },
2393
2394 // Remove old dropdown rule index
2395 clear_idx: function () {
2396 var sheet = Foundation.stylesheet;
2397
2398 if (typeof this.rule_idx !== 'undefined') {
2399 sheet.deleteRule(this.rule_idx);
2400 sheet.deleteRule(this.rule_idx);
2401 delete this.rule_idx;
2402 }
2403 },
2404
2405 small: function () {
2406 return matchMedia(Foundation.media_queries.small).matches && !matchMedia(Foundation.media_queries.medium).matches;
2407 },
2408
2409 off: function () {
2410 this.S(this.scope).off('.fndtn.dropdown');
2411 this.S('html, body').off('.fndtn.dropdown');
2412 this.S(window).off('.fndtn.dropdown');
2413 this.S('[data-dropdown-content]').off('.fndtn.dropdown');
2414 },
2415
2416 reflow: function () {
2417 }
2418 };
2419 }(jQuery, window, window.document));
2420 ;
2421 (function ($, window, document, undefined) {
2422 'use strict';
2423
2424 Foundation.libs.clearing = {
2425 name: 'clearing',
2426
2427 version: '5.5.0',
2428
2429 settings: {
2430 templates: {
2431 viewing: '<a href="#" class="clearing-close">&times;</a>' +
2432 '<div class="visible-img" style="display: none"><div class="clearing-touch-label"></div><img src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D" alt="" />' +
2433 '<p class="clearing-caption"></p><a href="#" class="clearing-main-prev"><span></span></a>' +
2434 '<a href="#" class="clearing-main-next"><span></span></a></div>'
2435 },
2436
2437 // comma delimited list of selectors that, on click, will close clearing,
2438 // add 'div.clearing-blackout, div.visible-img' to close on background click
2439 close_selectors: '.clearing-close, div.clearing-blackout',
2440
2441 // Default to the entire li element.
2442 open_selectors: '',
2443
2444 // Image will be skipped in carousel.
2445 skip_selector: '',
2446
2447 touch_label: '',
2448
2449 // event initializers and locks
2450 init: false,
2451 locked: false
2452 },
2453
2454 init: function (scope, method, options) {
2455 var self = this;
2456 Foundation.inherit(this, 'throttle image_loaded');
2457
2458 this.bindings(method, options);
2459
2460 if (self.S(this.scope).is('[' + this.attr_name() + ']')) {
2461 this.assemble(self.S('li', this.scope));
2462 } else {
2463 self.S('[' + this.attr_name() + ']', this.scope).each(function () {
2464 self.assemble(self.S('li', this));
2465 });
2466 }
2467 },
2468
2469 events: function (scope) {
2470 var self = this,
2471 S = self.S,
2472 $scroll_container = $('.scroll-container');
2473
2474 if ($scroll_container.length > 0) {
2475 this.scope = $scroll_container;
2476 }
2477
2478 S(this.scope)
2479 .off('.clearing')
2480 .on('click.fndtn.clearing', 'ul[' + this.attr_name() + '] li ' + this.settings.open_selectors,
2481 function (e, current, target) {
2482 var current = current || S(this),
2483 target = target || current,
2484 next = current.next('li'),
2485 settings = current.closest('[' + self.attr_name() + ']').data(self.attr_name(true) + '-init'),
2486 image = S(e.target);
2487
2488 e.preventDefault();
2489
2490 if (!settings) {
2491 self.init();
2492 settings = current.closest('[' + self.attr_name() + ']').data(self.attr_name(true) + '-init');
2493 }
2494
2495 // if clearing is open and the current image is
2496 // clicked, go to the next image in sequence
2497 if (target.hasClass('visible') &&
2498 current[0] === target[0] &&
2499 next.length > 0 && self.is_open(current)) {
2500 target = next;
2501 image = S('img', target);
2502 }
2503
2504 // set current and target to the clicked li if not otherwise defined.
2505 self.open(image, current, target);
2506 self.update_paddles(target);
2507 })
2508
2509 .on('click.fndtn.clearing', '.clearing-main-next',
2510 function (e) {
2511 self.nav(e, 'next')
2512 })
2513 .on('click.fndtn.clearing', '.clearing-main-prev',
2514 function (e) {
2515 self.nav(e, 'prev')
2516 })
2517 .on('click.fndtn.clearing', this.settings.close_selectors,
2518 function (e) {
2519 Foundation.libs.clearing.close(e, this)
2520 });
2521
2522 $(document).on('keydown.fndtn.clearing',
2523 function (e) {
2524 self.keydown(e)
2525 });
2526
2527 S(window).off('.clearing').on('resize.fndtn.clearing',
2528 function () {
2529 self.resize()
2530 });
2531
2532 this.swipe_events(scope);
2533 },
2534
2535 swipe_events: function (scope) {
2536 var self = this,
2537 S = self.S;
2538
2539 S(this.scope)
2540 .on('touchstart.fndtn.clearing', '.visible-img', function (e) {
2541 if (!e.touches) {
2542 e = e.originalEvent;
2543 }
2544 var data = {
2545 start_page_x: e.touches[0].pageX,
2546 start_page_y: e.touches[0].pageY,
2547 start_time: (new Date()).getTime(),
2548 delta_x: 0,
2549 is_scrolling: undefined
2550 };
2551
2552 S(this).data('swipe-transition', data);
2553 e.stopPropagation();
2554 })
2555 .on('touchmove.fndtn.clearing', '.visible-img', function (e) {
2556 if (!e.touches) {
2557 e = e.originalEvent;
2558 }
2559 // Ignore pinch/zoom events
2560 if (e.touches.length > 1 || e.scale && e.scale !== 1) return;
2561
2562 var data = S(this).data('swipe-transition');
2563
2564 if (typeof data === 'undefined') {
2565 data = {};
2566 }
2567
2568 data.delta_x = e.touches[0].pageX - data.start_page_x;
2569
2570 if (Foundation.rtl) {
2571 data.delta_x = -data.delta_x;
2572 }
2573
2574 if (typeof data.is_scrolling === 'undefined') {
2575 data.is_scrolling = !!( data.is_scrolling || Math.abs(data.delta_x) < Math.abs(e.touches[0].pageY - data.start_page_y) );
2576 }
2577
2578 if (!data.is_scrolling && !data.active) {
2579 e.preventDefault();
2580 var direction = (data.delta_x < 0) ? 'next' : 'prev';
2581 data.active = true;
2582 self.nav(e, direction);
2583 }
2584 })
2585 .on('touchend.fndtn.clearing', '.visible-img', function (e) {
2586 S(this).data('swipe-transition', {});
2587 e.stopPropagation();
2588 });
2589 },
2590
2591 assemble: function ($li) {
2592 var $el = $li.parent();
2593
2594 if ($el.parent().hasClass('carousel')) {
2595 return;
2596 }
2597
2598 $el.after('<div id="foundationClearingHolder"></div>');
2599
2600 var grid = $el.detach(),
2601 grid_outerHTML = '';
2602
2603 if (grid[0] == null) {
2604 return;
2605 } else {
2606 grid_outerHTML = grid[0].outerHTML;
2607 }
2608
2609 var holder = this.S('#foundationClearingHolder'),
2610 settings = $el.data(this.attr_name(true) + '-init'),
2611 data = {
2612 grid: '<div class="carousel">' + grid_outerHTML + '</div>',
2613 viewing: settings.templates.viewing
2614 },
2615 wrapper = '<div class="clearing-assembled"><div>' + data.viewing +
2616 data.grid + '</div></div>',
2617 touch_label = this.settings.touch_label;
2618
2619 if (Modernizr.touch) {
2620 wrapper = $(wrapper).find('.clearing-touch-label').html(touch_label).end();
2621 }
2622
2623 holder.after(wrapper).remove();
2624 },
2625
2626 open: function ($image, current, target) {
2627 var self = this,
2628 body = $(document.body),
2629 root = target.closest('.clearing-assembled'),
2630 container = self.S('div', root).first(),
2631 visible_image = self.S('.visible-img', container),
2632 image = self.S('img', visible_image).not($image),
2633 label = self.S('.clearing-touch-label', container),
2634 error = false;
2635
2636 // Event to disable scrolling on touch devices when Clearing is activated
2637 $('body').on('touchmove', function (e) {
2638 e.preventDefault();
2639 });
2640
2641 image.error(function () {
2642 error = true;
2643 });
2644
2645 function startLoad() {
2646 setTimeout(function () {
2647 this.image_loaded(image, function () {
2648 if (image.outerWidth() === 1 && !error) {
2649 startLoad.call(this);
2650 } else {
2651 cb.call(this, image);
2652 }
2653 }.bind(this));
2654 }.bind(this), 100);
2655 }
2656
2657 function cb(image) {
2658 var $image = $(image);
2659 $image.css('visibility', 'visible');
2660 // toggle the gallery
2661 body.css('overflow', 'hidden');
2662 root.addClass('clearing-blackout');
2663 container.addClass('clearing-container');
2664 visible_image.show();
2665 this.fix_height(target)
2666 .caption(self.S('.clearing-caption', visible_image), self.S('img', target))
2667 .center_and_label(image, label)
2668 .shift(current, target, function () {
2669 target.closest('li').siblings().removeClass('visible');
2670 target.closest('li').addClass('visible');
2671 });
2672 visible_image.trigger('opened.fndtn.clearing')
2673 }
2674
2675 if (!this.locked()) {
2676 visible_image.trigger('open.fndtn.clearing');
2677 // set the image to the selected thumbnail
2678 image
2679 .attr('src', this.load($image))
2680 .css('visibility', 'hidden');
2681
2682 startLoad.call(this);
2683 }
2684 },
2685
2686 close: function (e, el) {
2687 e.preventDefault();
2688
2689 var root = (function (target) {
2690 if (/blackout/.test(target.selector)) {
2691 return target;
2692 } else {
2693 return target.closest('.clearing-blackout');
2694 }
2695 }($(el))),
2696 body = $(document.body), container, visible_image;
2697
2698 if (el === e.target && root) {
2699 body.css('overflow', '');
2700 container = $('div', root).first();
2701 visible_image = $('.visible-img', container);
2702 visible_image.trigger('close.fndtn.clearing');
2703 this.settings.prev_index = 0;
2704 $('ul[' + this.attr_name() + ']', root)
2705 .attr('style', '').closest('.clearing-blackout')
2706 .removeClass('clearing-blackout');
2707 container.removeClass('clearing-container');
2708 visible_image.hide();
2709 visible_image.trigger('closed.fndtn.clearing');
2710 }
2711
2712 // Event to re-enable scrolling on touch devices
2713 $('body').off('touchmove');
2714
2715 return false;
2716 },
2717
2718 is_open: function (current) {
2719 return current.parent().prop('style').length > 0;
2720 },
2721
2722 keydown: function (e) {
2723 var clearing = $('.clearing-blackout ul[' + this.attr_name() + ']'),
2724 NEXT_KEY = this.rtl ? 37 : 39,
2725 PREV_KEY = this.rtl ? 39 : 37,
2726 ESC_KEY = 27;
2727
2728 if (e.which === NEXT_KEY) this.go(clearing, 'next');
2729 if (e.which === PREV_KEY) this.go(clearing, 'prev');
2730 if (e.which === ESC_KEY) this.S('a.clearing-close').trigger('click').trigger('click.fndtn.clearing');
2731 },
2732
2733 nav: function (e, direction) {
2734 var clearing = $('ul[' + this.attr_name() + ']', '.clearing-blackout');
2735
2736 e.preventDefault();
2737 this.go(clearing, direction);
2738 },
2739
2740 resize: function () {
2741 var image = $('img', '.clearing-blackout .visible-img'),
2742 label = $('.clearing-touch-label', '.clearing-blackout');
2743
2744 if (image.length) {
2745 this.center_and_label(image, label);
2746 image.trigger('resized.fndtn.clearing')
2747 }
2748 },
2749
2750 // visual adjustments
2751 fix_height: function (target) {
2752 var lis = target.parent().children(),
2753 self = this;
2754
2755 lis.each(function () {
2756 var li = self.S(this),
2757 image = li.find('img');
2758
2759 if (li.height() > image.outerHeight()) {
2760 li.addClass('fix-height');
2761 }
2762 })
2763 .closest('ul')
2764 .width(lis.length * 100 + '%');
2765
2766 return this;
2767 },
2768
2769 update_paddles: function (target) {
2770 target = target.closest('li');
2771 var visible_image = target
2772 .closest('.carousel')
2773 .siblings('.visible-img');
2774
2775 if (target.next().length > 0) {
2776 this.S('.clearing-main-next', visible_image).removeClass('disabled');
2777 } else {
2778 this.S('.clearing-main-next', visible_image).addClass('disabled');
2779 }
2780
2781 if (target.prev().length > 0) {
2782 this.S('.clearing-main-prev', visible_image).removeClass('disabled');
2783 } else {
2784 this.S('.clearing-main-prev', visible_image).addClass('disabled');
2785 }
2786 },
2787
2788 center_and_label: function (target, label) {
2789 if (!this.rtl) {
2790 target.css({
2791 marginLeft: -(target.outerWidth() / 2),
2792 marginTop: -(target.outerHeight() / 2)
2793 });
2794
2795 if (label.length > 0) {
2796 label.css({
2797 marginLeft: -(label.outerWidth() / 2),
2798 marginTop: -(target.outerHeight() / 2) - label.outerHeight() - 10
2799 });
2800 }
2801 } else {
2802 target.css({
2803 marginRight: -(target.outerWidth() / 2),
2804 marginTop: -(target.outerHeight() / 2),
2805 left: 'auto',
2806 right: '50%'
2807 });
2808
2809 if (label.length > 0) {
2810 label.css({
2811 marginRight: -(label.outerWidth() / 2),
2812 marginTop: -(target.outerHeight() / 2) - label.outerHeight() - 10,
2813 left: 'auto',
2814 right: '50%'
2815 });
2816 }
2817 }
2818 return this;
2819 },
2820
2821 // image loading and preloading
2822
2823 load: function ($image) {
2824 var href;
2825
2826 if ($image[0].nodeName === 'A') {
2827 href = $image.attr('href');
2828 } else {
2829 href = $image.closest('a').attr('href');
2830 }
2831
2832 this.preload($image);
2833
2834 if (href) return href;
2835 return $image.attr('src');
2836 },
2837
2838 preload: function ($image) {
2839 this
2840 .img($image.closest('li').next())
2841 .img($image.closest('li').prev());
2842 },
2843
2844 img: function (img) {
2845 if (img.length) {
2846 var new_img = new Image(),
2847 new_a = this.S('a', img);
2848
2849 if (new_a.length) {
2850 new_img.src = new_a.attr('href');
2851 } else {
2852 new_img.src = this.S('img', img).attr('src');
2853 }
2854 }
2855 return this;
2856 },
2857
2858 // image caption
2859
2860 caption: function (container, $image) {
2861 var caption = $image.attr('data-caption');
2862
2863 if (caption) {
2864 container
2865 .html(caption)
2866 .show();
2867 } else {
2868 container
2869 .text('')
2870 .hide();
2871 }
2872 return this;
2873 },
2874
2875 // directional methods
2876
2877 go: function ($ul, direction) {
2878 var current = this.S('.visible', $ul),
2879 target = current[direction]();
2880
2881 // Check for skip selector.
2882 if (this.settings.skip_selector && target.find(this.settings.skip_selector).length != 0) {
2883 target = target[direction]();
2884 }
2885
2886 if (target.length) {
2887 this.S('img', target)
2888 .trigger('click', [current, target]).trigger('click.fndtn.clearing', [current, target])
2889 .trigger('change.fndtn.clearing');
2890 }
2891 },
2892
2893 shift: function (current, target, callback) {
2894 var clearing = target.parent(),
2895 old_index = this.settings.prev_index || target.index(),
2896 direction = this.direction(clearing, current, target),
2897 dir = this.rtl ? 'right' : 'left',
2898 left = parseInt(clearing.css('left'), 10),
2899 width = target.outerWidth(),
2900 skip_shift;
2901
2902 var dir_obj = {};
2903
2904 // we use jQuery animate instead of CSS transitions because we
2905 // need a callback to unlock the next animation
2906 // needs support for RTL **
2907 if (target.index() !== old_index && !/skip/.test(direction)) {
2908 if (/left/.test(direction)) {
2909 this.lock();
2910 dir_obj[dir] = left + width;
2911 clearing.animate(dir_obj, 300, this.unlock());
2912 } else if (/right/.test(direction)) {
2913 this.lock();
2914 dir_obj[dir] = left - width;
2915 clearing.animate(dir_obj, 300, this.unlock());
2916 }
2917 } else if (/skip/.test(direction)) {
2918 // the target image is not adjacent to the current image, so
2919 // do we scroll right or not
2920 skip_shift = target.index() - this.settings.up_count;
2921 this.lock();
2922
2923 if (skip_shift > 0) {
2924 dir_obj[dir] = -(skip_shift * width);
2925 clearing.animate(dir_obj, 300, this.unlock());
2926 } else {
2927 dir_obj[dir] = 0;
2928 clearing.animate(dir_obj, 300, this.unlock());
2929 }
2930 }
2931
2932 callback();
2933 },
2934
2935 direction: function ($el, current, target) {
2936 var lis = this.S('li', $el),
2937 li_width = lis.outerWidth() + (lis.outerWidth() / 4),
2938 up_count = Math.floor(this.S('.clearing-container').outerWidth() / li_width) - 1,
2939 target_index = lis.index(target),
2940 response;
2941
2942 this.settings.up_count = up_count;
2943
2944 if (this.adjacent(this.settings.prev_index, target_index)) {
2945 if ((target_index > up_count) && target_index > this.settings.prev_index) {
2946 response = 'right';
2947 } else if ((target_index > up_count - 1) && target_index <= this.settings.prev_index) {
2948 response = 'left';
2949 } else {
2950 response = false;
2951 }
2952 } else {
2953 response = 'skip';
2954 }
2955
2956 this.settings.prev_index = target_index;
2957
2958 return response;
2959 },
2960
2961 adjacent: function (current_index, target_index) {
2962 for (var i = target_index + 1; i >= target_index - 1; i--) {
2963 if (i === current_index) return true;
2964 }
2965 return false;
2966 },
2967
2968 // lock management
2969
2970 lock: function () {
2971 this.settings.locked = true;
2972 },
2973
2974 unlock: function () {
2975 this.settings.locked = false;
2976 },
2977
2978 locked: function () {
2979 return this.settings.locked;
2980 },
2981
2982 off: function () {
2983 this.S(this.scope).off('.fndtn.clearing');
2984 this.S(window).off('.fndtn.clearing');
2985 },
2986
2987 reflow: function () {
2988 this.init();
2989 }
2990 };
2991
2992 }(jQuery, window, window.document));
2993 ;
2994 (function ($, window, document, undefined) {
2995 'use strict';
2996
2997 var noop = function () {
2998 };
2999
3000 var Orbit = function (el, settings) {
3001 // Don't reinitialize plugin
3002 if (el.hasClass(settings.slides_container_class)) {
3003 return this;
3004 }
3005
3006 var self = this,
3007 container,
3008 slides_container = el,
3009 number_container,
3010 bullets_container,
3011 timer_container,
3012 idx = 0,
3013 animate,
3014 timer,
3015 locked = false,
3016 adjust_height_after = false;
3017
3018
3019 self.slides = function () {
3020 return slides_container.children(settings.slide_selector);
3021 };
3022
3023 self.slides().first().addClass(settings.active_slide_class);
3024
3025 self.update_slide_number = function (index) {
3026 if (settings.slide_number) {
3027 number_container.find('span:first').text(parseInt(index) + 1);
3028 number_container.find('span:last').text(self.slides().length);
3029 }
3030 if (settings.bullets) {
3031 bullets_container.children().removeClass(settings.bullets_active_class);
3032 $(bullets_container.children().get(index)).addClass(settings.bullets_active_class);
3033 }
3034 };
3035
3036 self.update_active_link = function (index) {
3037 var link = $('[data-orbit-link="' + self.slides().eq(index).attr('data-orbit-slide') + '"]');
3038 link.siblings().removeClass(settings.bullets_active_class);
3039 link.addClass(settings.bullets_active_class);
3040 };
3041
3042 self.build_markup = function () {
3043 slides_container.wrap('<div class="' + settings.container_class + '"></div>');
3044 container = slides_container.parent();
3045 slides_container.addClass(settings.slides_container_class);
3046
3047 if (settings.stack_on_small) {
3048 container.addClass(settings.stack_on_small_class);
3049 }
3050
3051 if (settings.navigation_arrows) {
3052 container.append($('<a href="#"><span></span></a>').addClass(settings.prev_class));
3053 container.append($('<a href="#"><span></span></a>').addClass(settings.next_class));
3054 }
3055
3056 if (settings.timer) {
3057 timer_container = $('<div>').addClass(settings.timer_container_class);
3058 timer_container.append('<span>');
3059 timer_container.append($('<div>').addClass(settings.timer_progress_class));
3060 timer_container.addClass(settings.timer_paused_class);
3061 container.append(timer_container);
3062 }
3063
3064 if (settings.slide_number) {
3065 number_container = $('<div>').addClass(settings.slide_number_class);
3066 number_container.append('<span></span> ' + settings.slide_number_text + ' <span></span>');
3067 container.append(number_container);
3068 }
3069
3070 if (settings.bullets) {
3071 bullets_container = $('<ol>').addClass(settings.bullets_container_class);
3072 container.append(bullets_container);
3073 bullets_container.wrap('<div class="orbit-bullets-container"></div>');
3074 self.slides().each(function (idx, el) {
3075 var bullet = $('<li>').attr('data-orbit-slide', idx).on('click', self.link_bullet);
3076 ;
3077 bullets_container.append(bullet);
3078 });
3079 }
3080
3081 };
3082
3083 self._goto = function (next_idx, start_timer) {
3084 // if (locked) {return false;}
3085 if (next_idx === idx) {
3086 return false;
3087 }
3088 if (typeof timer === 'object') {
3089 timer.restart();
3090 }
3091 var slides = self.slides();
3092
3093 var dir = 'next';
3094 locked = true;
3095 if (next_idx < idx) {
3096 dir = 'prev';
3097 }
3098 if (next_idx >= slides.length) {
3099 if (!settings.circular) return false;
3100 next_idx = 0;
3101 } else if (next_idx < 0) {
3102 if (!settings.circular) return false;
3103 next_idx = slides.length - 1;
3104 }
3105
3106 var current = $(slides.get(idx));
3107 var next = $(slides.get(next_idx));
3108
3109 current.css('zIndex', 2);
3110 current.removeClass(settings.active_slide_class);
3111 next.css('zIndex', 4).addClass(settings.active_slide_class);
3112
3113 slides_container.trigger('before-slide-change.fndtn.orbit');
3114 settings.before_slide_change();
3115 self.update_active_link(next_idx);
3116
3117 var callback = function () {
3118 var unlock = function () {
3119 idx = next_idx;
3120 locked = false;
3121 if (start_timer === true) {
3122 timer = self.create_timer();
3123 timer.start();
3124 }
3125 self.update_slide_number(idx);
3126 slides_container.trigger('after-slide-change.fndtn.orbit', [{
3127 slide_number: idx,
3128 total_slides: slides.length
3129 }]);
3130 settings.after_slide_change(idx, slides.length);
3131 };
3132 if (slides_container.height() != next.height() && settings.variable_height) {
3133 slides_container.animate({'height': next.height()}, 250, 'linear', unlock);
3134 } else {
3135 unlock();
3136 }
3137 };
3138
3139 if (slides.length === 1) {
3140 callback();
3141 return false;
3142 }
3143
3144 var start_animation = function () {
3145 if (dir === 'next') {
3146 animate.next(current, next, callback);
3147 }
3148 if (dir === 'prev') {
3149 animate.prev(current, next, callback);
3150 }
3151 };
3152
3153 if (next.height() > slides_container.height() && settings.variable_height) {
3154 slides_container.animate({'height': next.height()}, 250, 'linear', start_animation);
3155 } else {
3156 start_animation();
3157 }
3158 };
3159
3160 self.next = function (e) {
3161 e.stopImmediatePropagation();
3162 e.preventDefault();
3163 self._goto(idx + 1);
3164 };
3165
3166 self.prev = function (e) {
3167 e.stopImmediatePropagation();
3168 e.preventDefault();
3169 self._goto(idx - 1);
3170 };
3171
3172 self.link_custom = function (e) {
3173 e.preventDefault();
3174 var link = $(this).attr('data-orbit-link');
3175 if ((typeof link === 'string') && (link = $.trim(link)) != '') {
3176 var slide = container.find('[data-orbit-slide=' + link + ']');
3177 if (slide.index() != -1) {
3178 self._goto(slide.index());
3179 }
3180 }
3181 };
3182
3183 self.link_bullet = function (e) {
3184 var index = $(this).attr('data-orbit-slide');
3185 if ((typeof index === 'string') && (index = $.trim(index)) != '') {
3186 if (isNaN(parseInt(index))) {
3187 var slide = container.find('[data-orbit-slide=' + index + ']');
3188 if (slide.index() != -1) {
3189 self._goto(slide.index() + 1);
3190 }
3191 }
3192 else {
3193 self._goto(parseInt(index));
3194 }
3195 }
3196
3197 }
3198
3199 self.timer_callback = function () {
3200 self._goto(idx + 1, true);
3201 }
3202
3203 self.compute_dimensions = function () {
3204 var current = $(self.slides().get(idx));
3205 var h = current.height();
3206 if (!settings.variable_height) {
3207 self.slides().each(function () {
3208 if ($(this).height() > h) {
3209 h = $(this).height();
3210 }
3211 });
3212 }
3213 slides_container.height(h);
3214 };
3215
3216 self.create_timer = function () {
3217 var t = new Timer(
3218 container.find('.' + settings.timer_container_class),
3219 settings,
3220 self.timer_callback
3221 );
3222 return t;
3223 };
3224
3225 self.stop_timer = function () {
3226 if (typeof timer === 'object') timer.stop();
3227 };
3228
3229 self.toggle_timer = function () {
3230 var t = container.find('.' + settings.timer_container_class);
3231 if (t.hasClass(settings.timer_paused_class)) {
3232 if (typeof timer === 'undefined') {
3233 timer = self.create_timer();
3234 }
3235 timer.start();
3236 }
3237 else {
3238 if (typeof timer === 'object') {
3239 timer.stop();
3240 }
3241 }
3242 };
3243
3244 self.init = function () {
3245 self.build_markup();
3246 if (settings.timer) {
3247 timer = self.create_timer();
3248 Foundation.utils.image_loaded(this.slides().children('img'), timer.start);
3249 }
3250 animate = new FadeAnimation(settings, slides_container);
3251 if (settings.animation === 'slide')
3252 animate = new SlideAnimation(settings, slides_container);
3253
3254 container.on('click', '.' + settings.next_class, self.next);
3255 container.on('click', '.' + settings.prev_class, self.prev);
3256
3257 if (settings.next_on_click) {
3258 container.on('click', '.' + settings.slides_container_class + ' [data-orbit-slide]', self.link_bullet);
3259 }
3260
3261 container.on('click', self.toggle_timer);
3262 if (settings.swipe) {
3263 container.on('touchstart.fndtn.orbit', function (e) {
3264 if (!e.touches) {
3265 e = e.originalEvent;
3266 }
3267 var data = {
3268 start_page_x: e.touches[0].pageX,
3269 start_page_y: e.touches[0].pageY,
3270 start_time: (new Date()).getTime(),
3271 delta_x: 0,
3272 is_scrolling: undefined
3273 };
3274 container.data('swipe-transition', data);
3275 e.stopPropagation();
3276 })
3277 .on('touchmove.fndtn.orbit', function (e) {
3278 if (!e.touches) {
3279 e = e.originalEvent;
3280 }
3281 // Ignore pinch/zoom events
3282 if (e.touches.length > 1 || e.scale && e.scale !== 1) return;
3283
3284 var data = container.data('swipe-transition');
3285 if (typeof data === 'undefined') {
3286 data = {};
3287 }
3288
3289 data.delta_x = e.touches[0].pageX - data.start_page_x;
3290
3291 if (typeof data.is_scrolling === 'undefined') {
3292 data.is_scrolling = !!( data.is_scrolling || Math.abs(data.delta_x) < Math.abs(e.touches[0].pageY - data.start_page_y) );
3293 }
3294
3295 if (!data.is_scrolling && !data.active) {
3296 e.preventDefault();
3297 var direction = (data.delta_x < 0) ? (idx + 1) : (idx - 1);
3298 data.active = true;
3299 self._goto(direction);
3300 }
3301 })
3302 .on('touchend.fndtn.orbit', function (e) {
3303 container.data('swipe-transition', {});
3304 e.stopPropagation();
3305 })
3306 }
3307 container.on('mouseenter.fndtn.orbit', function (e) {
3308 if (settings.timer && settings.pause_on_hover) {
3309 self.stop_timer();
3310 }
3311 })
3312 .on('mouseleave.fndtn.orbit', function (e) {
3313 if (settings.timer && settings.resume_on_mouseout) {
3314 timer.start();
3315 }
3316 });
3317
3318 $(document).on('click', '[data-orbit-link]', self.link_custom);
3319 $(window).on('load resize', self.compute_dimensions);
3320 Foundation.utils.image_loaded(this.slides().children('img'), self.compute_dimensions);
3321 Foundation.utils.image_loaded(this.slides().children('img'), function () {
3322 container.prev('.' + settings.preloader_class).css('display', 'none');
3323 self.update_slide_number(0);
3324 self.update_active_link(0);
3325 slides_container.trigger('ready.fndtn.orbit');
3326 });
3327 };
3328
3329 self.init();
3330 };
3331
3332 var Timer = function (el, settings, callback) {
3333 var self = this,
3334 duration = settings.timer_speed,
3335 progress = el.find('.' + settings.timer_progress_class),
3336 start,
3337 timeout,
3338 left = -1;
3339
3340 this.update_progress = function (w) {
3341 var new_progress = progress.clone();
3342 new_progress.attr('style', '');
3343 new_progress.css('width', w + '%');
3344 progress.replaceWith(new_progress);
3345 progress = new_progress;
3346 };
3347
3348 this.restart = function () {
3349 clearTimeout(timeout);
3350 el.addClass(settings.timer_paused_class);
3351 left = -1;
3352 self.update_progress(0);
3353 };
3354
3355 this.start = function () {
3356 if (!el.hasClass(settings.timer_paused_class)) {
3357 return true;
3358 }
3359 left = (left === -1) ? duration : left;
3360 el.removeClass(settings.timer_paused_class);
3361 start = new Date().getTime();
3362 progress.animate({'width': '100%'}, left, 'linear');
3363 timeout = setTimeout(function () {
3364 self.restart();
3365 callback();
3366 }, left);
3367 el.trigger('timer-started.fndtn.orbit')
3368 };
3369
3370 this.stop = function () {
3371 if (el.hasClass(settings.timer_paused_class)) {
3372 return true;
3373 }
3374 clearTimeout(timeout);
3375 el.addClass(settings.timer_paused_class);
3376 var end = new Date().getTime();
3377 left = left - (end - start);
3378 var w = 100 - ((left / duration) * 100);
3379 self.update_progress(w);
3380 el.trigger('timer-stopped.fndtn.orbit');
3381 };
3382 };
3383
3384 var SlideAnimation = function (settings, container) {
3385 var duration = settings.animation_speed;
3386 var is_rtl = ($('html[dir=rtl]').length === 1);
3387 var margin = is_rtl ? 'marginRight' : 'marginLeft';
3388 var animMargin = {};
3389 animMargin[margin] = '0%';
3390
3391 this.next = function (current, next, callback) {
3392 current.animate({marginLeft: '-100%'}, duration);
3393 next.animate(animMargin, duration, function () {
3394 current.css(margin, '100%');
3395 callback();
3396 });
3397 };
3398
3399 this.prev = function (current, prev, callback) {
3400 current.animate({marginLeft: '100%'}, duration);
3401 prev.css(margin, '-100%');
3402 prev.animate(animMargin, duration, function () {
3403 current.css(margin, '100%');
3404 callback();
3405 });
3406 };
3407 };
3408
3409 var FadeAnimation = function (settings, container) {
3410 var duration = settings.animation_speed;
3411 var is_rtl = ($('html[dir=rtl]').length === 1);
3412 var margin = is_rtl ? 'marginRight' : 'marginLeft';
3413
3414 this.next = function (current, next, callback) {
3415 next.css({'margin': '0%', 'opacity': '0.01'});
3416 next.animate({'opacity': '1'}, duration, 'linear', function () {
3417 current.css('margin', '100%');
3418 callback();
3419 });
3420 };
3421
3422 this.prev = function (current, prev, callback) {
3423 prev.css({'margin': '0%', 'opacity': '0.01'});
3424 prev.animate({'opacity': '1'}, duration, 'linear', function () {
3425 current.css('margin', '100%');
3426 callback();
3427 });
3428 };
3429 };
3430
3431
3432 Foundation.libs = Foundation.libs || {};
3433
3434 Foundation.libs.orbit = {
3435 name: 'orbit',
3436
3437 version: '5.5.0',
3438
3439 settings: {
3440 animation: 'slide',
3441 timer_speed: 10000,
3442 pause_on_hover: true,
3443 resume_on_mouseout: false,
3444 next_on_click: true,
3445 animation_speed: 500,
3446 stack_on_small: false,
3447 navigation_arrows: true,
3448 slide_number: true,
3449 slide_number_text: 'of',
3450 container_class: 'orbit-container',
3451 stack_on_small_class: 'orbit-stack-on-small',
3452 next_class: 'orbit-next',
3453 prev_class: 'orbit-prev',
3454 timer_container_class: 'orbit-timer',
3455 timer_paused_class: 'paused',
3456 timer_progress_class: 'orbit-progress',
3457 slides_container_class: 'orbit-slides-container',
3458 preloader_class: 'preloader',
3459 slide_selector: '*',
3460 bullets_container_class: 'orbit-bullets',
3461 bullets_active_class: 'active',
3462 slide_number_class: 'orbit-slide-number',
3463 caption_class: 'orbit-caption',
3464 active_slide_class: 'active',
3465 orbit_transition_class: 'orbit-transitioning',
3466 bullets: true,
3467 circular: true,
3468 timer: true,
3469 variable_height: false,
3470 swipe: true,
3471 before_slide_change: noop,
3472 after_slide_change: noop
3473 },
3474
3475 init: function (scope, method, options) {
3476 var self = this;
3477 this.bindings(method, options);
3478 },
3479
3480 events: function (instance) {
3481 var orbit_instance = new Orbit(this.S(instance), this.S(instance).data('orbit-init'));
3482 this.S(instance).data(this.name + '-instance', orbit_instance);
3483 },
3484
3485 reflow: function () {
3486 var self = this;
3487
3488 if (self.S(self.scope).is('[data-orbit]')) {
3489 var $el = self.S(self.scope);
3490 var instance = $el.data(self.name + '-instance');
3491 instance.compute_dimensions();
3492 } else {
3493 self.S('[data-orbit]', self.scope).each(function (idx, el) {
3494 var $el = self.S(el);
3495 var opts = self.data_options($el);
3496 var instance = $el.data(self.name + '-instance');
3497 instance.compute_dimensions();
3498 });
3499 }
3500 }
3501 };
3502
3503
3504 }(jQuery, window, window.document));
3505 ;
3506 (function ($, window, document, undefined) {
3507 'use strict';
3508
3509 Foundation.libs.offcanvas = {
3510 name: 'offcanvas',
3511
3512 version: '5.5.0',
3513
3514 settings: {
3515 open_method: 'move',
3516 close_on_click: false
3517 },
3518
3519 init: function (scope, method, options) {
3520 this.bindings(method, options);
3521 },
3522
3523 events: function () {
3524 var self = this,
3525 S = self.S,
3526 move_class = '',
3527 right_postfix = '',
3528 left_postfix = '';
3529
3530 if (this.settings.open_method === 'move') {
3531 move_class = 'move-';
3532 right_postfix = 'right';
3533 left_postfix = 'left';
3534 } else if (this.settings.open_method === 'overlap_single') {
3535 move_class = 'offcanvas-overlap-';
3536 right_postfix = 'right';
3537 left_postfix = 'left';
3538 } else if (this.settings.open_method === 'overlap') {
3539 move_class = 'offcanvas-overlap';
3540 }
3541
3542 S(this.scope).off('.offcanvas')
3543 .on('click.fndtn.offcanvas', '.left-off-canvas-toggle', function (e) {
3544 self.click_toggle_class(e, move_class + right_postfix);
3545 if (self.settings.open_method !== 'overlap') {
3546 S('.left-submenu').removeClass(move_class + right_postfix);
3547 }
3548 $('.left-off-canvas-toggle').attr('aria-expanded', 'true');
3549 })
3550 .on('click.fndtn.offcanvas', '.left-off-canvas-menu a', function (e) {
3551 var settings = self.get_settings(e);
3552 var parent = S(this).parent();
3553
3554 if (settings.close_on_click && !parent.hasClass('has-submenu') && !parent.hasClass('back')) {
3555 self.hide.call(self, move_class + right_postfix, self.get_wrapper(e));
3556 parent.parent().removeClass(move_class + right_postfix);
3557 } else if (S(this).parent().hasClass('has-submenu')) {
3558 e.preventDefault();
3559 S(this).siblings('.left-submenu').toggleClass(move_class + right_postfix);
3560 } else if (parent.hasClass('back')) {
3561 e.preventDefault();
3562 parent.parent().removeClass(move_class + right_postfix);
3563 }
3564 $('.left-off-canvas-toggle').attr('aria-expanded', 'true');
3565 })
3566 .on('click.fndtn.offcanvas', '.right-off-canvas-toggle', function (e) {
3567 self.click_toggle_class(e, move_class + left_postfix);
3568 if (self.settings.open_method !== 'overlap') {
3569 S('.right-submenu').removeClass(move_class + left_postfix);
3570 }
3571 $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
3572 })
3573 .on('click.fndtn.offcanvas', '.right-off-canvas-menu a', function (e) {
3574 var settings = self.get_settings(e);
3575 var parent = S(this).parent();
3576
3577 if (settings.close_on_click && !parent.hasClass('has-submenu') && !parent.hasClass('back')) {
3578 self.hide.call(self, move_class + left_postfix, self.get_wrapper(e));
3579 parent.parent().removeClass(move_class + left_postfix);
3580 } else if (S(this).parent().hasClass('has-submenu')) {
3581 e.preventDefault();
3582 S(this).siblings('.right-submenu').toggleClass(move_class + left_postfix);
3583 } else if (parent.hasClass('back')) {
3584 e.preventDefault();
3585 parent.parent().removeClass(move_class + left_postfix);
3586 }
3587 $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
3588 })
3589 .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
3590 self.click_remove_class(e, move_class + left_postfix);
3591 S('.right-submenu').removeClass(move_class + left_postfix);
3592 if (right_postfix) {
3593 self.click_remove_class(e, move_class + right_postfix);
3594 S('.left-submenu').removeClass(move_class + left_postfix);
3595 }
3596 $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
3597 })
3598 .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
3599 self.click_remove_class(e, move_class + left_postfix);
3600 $('.left-off-canvas-toggle').attr('aria-expanded', 'false');
3601 if (right_postfix) {
3602 self.click_remove_class(e, move_class + right_postfix);
3603 $('.right-off-canvas-toggle').attr('aria-expanded', 'false');
3604 }
3605 });
3606 },
3607
3608 toggle: function (class_name, $off_canvas) {
3609 $off_canvas = $off_canvas || this.get_wrapper();
3610 if ($off_canvas.is('.' + class_name)) {
3611 this.hide(class_name, $off_canvas);
3612 } else {
3613 this.show(class_name, $off_canvas);
3614 }
3615 },
3616
3617 show: function (class_name, $off_canvas) {
3618 $off_canvas = $off_canvas || this.get_wrapper();
3619 $off_canvas.trigger('open').trigger('open.fndtn.offcanvas');
3620 $off_canvas.addClass(class_name);
3621 },
3622
3623 hide: function (class_name, $off_canvas) {
3624 $off_canvas = $off_canvas || this.get_wrapper();
3625 $off_canvas.trigger('close').trigger('close.fndtn.offcanvas');
3626 $off_canvas.removeClass(class_name);
3627 },
3628
3629 click_toggle_class: function (e, class_name) {
3630 e.preventDefault();
3631 var $off_canvas = this.get_wrapper(e);
3632 this.toggle(class_name, $off_canvas);
3633 },
3634
3635 click_remove_class: function (e, class_name) {
3636 e.preventDefault();
3637 var $off_canvas = this.get_wrapper(e);
3638 this.hide(class_name, $off_canvas);
3639 },
3640
3641 get_settings: function (e) {
3642 var offcanvas = this.S(e.target).closest('[' + this.attr_name() + ']');
3643 return offcanvas.data(this.attr_name(true) + '-init') || this.settings;
3644 },
3645
3646 get_wrapper: function (e) {
3647 var $off_canvas = this.S(e ? e.target : this.scope).closest('.off-canvas-wrap');
3648
3649 if ($off_canvas.length === 0) {
3650 $off_canvas = this.S('.off-canvas-wrap');
3651 }
3652 return $off_canvas;
3653 },
3654
3655 reflow: function () {
3656 }
3657 };
3658 }(jQuery, window, window.document));
3659 ;
3660 (function ($, window, document, undefined) {
3661 'use strict';
3662
3663 Foundation.libs.alert = {
3664 name: 'alert',
3665
3666 version: '5.5.0',
3667
3668 settings: {
3669 callback: function () {
3670 }
3671 },
3672
3673 init: function (scope, method, options) {
3674 this.bindings(method, options);
3675 },
3676
3677 events: function () {
3678 var self = this,
3679 S = this.S;
3680
3681 $(this.scope).off('.alert').on('click.fndtn.alert', '[' + this.attr_name() + '] .close', function (e) {
3682 var alertBox = S(this).closest('[' + self.attr_name() + ']'),
3683 settings = alertBox.data(self.attr_name(true) + '-init') || self.settings;
3684
3685 e.preventDefault();
3686 if (Modernizr.csstransitions) {
3687 alertBox.addClass('alert-close');
3688 alertBox.on('transitionend webkitTransitionEnd oTransitionEnd', function (e) {
3689 S(this).trigger('close').trigger('close.fndtn.alert').remove();
3690 settings.callback();
3691 });
3692 } else {
3693 alertBox.fadeOut(300, function () {
3694 S(this).trigger('close').trigger('close.fndtn.alert').remove();
3695 settings.callback();
3696 });
3697 }
3698 });
3699 },
3700
3701 reflow: function () {
3702 }
3703 };
3704 }(jQuery, window, window.document));
3705 ;
3706 (function ($, window, document, undefined) {
3707 'use strict';
3708
3709 Foundation.libs.reveal = {
3710 name: 'reveal',
3711
3712 version: '5.5.0',
3713
3714 locked: false,
3715
3716 settings: {
3717 animation: 'fadeAndPop',
3718 animation_speed: 250,
3719 close_on_background_click: true,
3720 close_on_esc: true,
3721 dismiss_modal_class: 'close-reveal-modal',
3722 bg_class: 'reveal-modal-bg',
3723 bg_root_element: 'body',
3724 root_element: 'body',
3725 open: function () {
3726 },
3727 opened: function () {
3728 },
3729 close: function () {
3730 },
3731 closed: function () {
3732 },
3733 bg: $('.reveal-modal-bg'),
3734 css: {
3735 open: {
3736 'opacity': 0,
3737 'visibility': 'visible',
3738 'display': 'block'
3739 },
3740 close: {
3741 'opacity': 1,
3742 'visibility': 'hidden',
3743 'display': 'none'
3744 }
3745 }
3746 },
3747
3748 init: function (scope, method, options) {
3749 $.extend(true, this.settings, method, options);
3750 this.bindings(method, options);
3751 },
3752
3753 events: function (scope) {
3754 var self = this,
3755 S = self.S;
3756
3757 S(this.scope)
3758 .off('.reveal')
3759 .on('click.fndtn.reveal', '[' + this.add_namespace('data-reveal-id') + ']:not([disabled])', function (e) {
3760 e.preventDefault();
3761
3762 if (!self.locked) {
3763 var element = S(this),
3764 ajax = element.data(self.data_attr('reveal-ajax'));
3765
3766 self.locked = true;
3767
3768 if (typeof ajax === 'undefined') {
3769 self.open.call(self, element);
3770 } else {
3771 var url = ajax === true ? element.attr('href') : ajax;
3772
3773 self.open.call(self, element, {url: url});
3774 }
3775 }
3776 });
3777
3778 S(document)
3779 .on('click.fndtn.reveal', this.close_targets(), function (e) {
3780
3781 e.preventDefault();
3782
3783 if (!self.locked) {
3784 var settings = S('[' + self.attr_name() + '].open').data(self.attr_name(true) + '-init') || self.settings,
3785 bg_clicked = S(e.target)[0] === S('.' + settings.bg_class)[0];
3786
3787 if (bg_clicked) {
3788 if (settings.close_on_background_click) {
3789 e.stopPropagation();
3790 } else {
3791 return;
3792 }
3793 }
3794
3795 self.locked = true;
3796 self.close.call(self, bg_clicked ? S('[' + self.attr_name() + '].open') : S(this).closest('[' + self.attr_name() + ']'));
3797 }
3798 });
3799
3800 if (S('[' + self.attr_name() + ']', this.scope).length > 0) {
3801 S(this.scope)
3802 // .off('.reveal')
3803 .on('open.fndtn.reveal', this.settings.open)
3804 .on('opened.fndtn.reveal', this.settings.opened)
3805 .on('opened.fndtn.reveal', this.open_video)
3806 .on('close.fndtn.reveal', this.settings.close)
3807 .on('closed.fndtn.reveal', this.settings.closed)
3808 .on('closed.fndtn.reveal', this.close_video);
3809 } else {
3810 S(this.scope)
3811 // .off('.reveal')
3812 .on('open.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.open)
3813 .on('opened.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.opened)
3814 .on('opened.fndtn.reveal', '[' + self.attr_name() + ']', this.open_video)
3815 .on('close.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.close)
3816 .on('closed.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.closed)
3817 .on('closed.fndtn.reveal', '[' + self.attr_name() + ']', this.close_video);
3818 }
3819
3820 return true;
3821 },
3822
3823 // PATCH #3: turning on key up capture only when a reveal window is open
3824 key_up_on: function (scope) {
3825 var self = this;
3826
3827 // PATCH #1: fixing multiple keyup event trigger from single key press
3828 self.S('body').off('keyup.fndtn.reveal').on('keyup.fndtn.reveal', function (event) {
3829 var open_modal = self.S('[' + self.attr_name() + '].open'),
3830 settings = open_modal.data(self.attr_name(true) + '-init') || self.settings;
3831 // PATCH #2: making sure that the close event can be called only while unlocked,
3832 // so that multiple keyup.fndtn.reveal events don't prevent clean closing of the reveal window.
3833 if (settings && event.which === 27 && settings.close_on_esc && !self.locked) { // 27 is the keycode for the Escape key
3834 self.close.call(self, open_modal);
3835 }
3836 });
3837
3838 return true;
3839 },
3840
3841 // PATCH #3: turning on key up capture only when a reveal window is open
3842 key_up_off: function (scope) {
3843 this.S('body').off('keyup.fndtn.reveal');
3844 return true;
3845 },
3846
3847
3848 open: function (target, ajax_settings) {
3849 var self = this,
3850 modal;
3851
3852 if (target) {
3853 if (typeof target.selector !== 'undefined') {
3854 // Find the named node; only use the first one found, since the rest of the code assumes there's only one node
3855 modal = self.S('#' + target.data(self.data_attr('reveal-id'))).first();
3856 } else {
3857 modal = self.S(this.scope);
3858
3859 ajax_settings = target;
3860 }
3861 } else {
3862 modal = self.S(this.scope);
3863 }
3864
3865 var settings = modal.data(self.attr_name(true) + '-init');
3866 settings = settings || this.settings;
3867
3868
3869 if (modal.hasClass('open') && target.attr('data-reveal-id') == modal.attr('id')) {
3870 return self.close(modal);
3871 }
3872
3873 if (!modal.hasClass('open')) {
3874 var open_modal = self.S('[' + self.attr_name() + '].open');
3875
3876 if (typeof modal.data('css-top') === 'undefined') {
3877 modal.data('css-top', parseInt(modal.css('top'), 10))
3878 .data('offset', this.cache_offset(modal));
3879 }
3880
3881 this.key_up_on(modal); // PATCH #3: turning on key up capture only when a reveal window is open
3882 modal.trigger('open').trigger('open.fndtn.reveal');
3883
3884 if (open_modal.length < 1) {
3885 this.toggle_bg(modal, true);
3886 }
3887
3888 if (typeof ajax_settings === 'string') {
3889 ajax_settings = {
3890 url: ajax_settings
3891 };
3892 }
3893
3894 if (typeof ajax_settings === 'undefined' || !ajax_settings.url) {
3895 if (open_modal.length > 0) {
3896 this.hide(open_modal, settings.css.close);
3897 }
3898
3899 this.show(modal, settings.css.open);
3900 } else {
3901 var old_success = typeof ajax_settings.success !== 'undefined' ? ajax_settings.success : null;
3902
3903 $.extend(ajax_settings, {
3904 success: function (data, textStatus, jqXHR) {
3905 if ($.isFunction(old_success)) {
3906 var result = old_success(data, textStatus, jqXHR);
3907 if (typeof result == 'string') data = result;
3908 }
3909
3910 modal.html(data);
3911 self.S(modal).foundation('section', 'reflow');
3912 self.S(modal).children().foundation();
3913
3914 if (open_modal.length > 0) {
3915 self.hide(open_modal, settings.css.close);
3916 }
3917 self.show(modal, settings.css.open);
3918 }
3919 });
3920
3921 $.ajax(ajax_settings);
3922 }
3923 }
3924 self.S(window).trigger('resize');
3925 },
3926
3927 close: function (modal) {
3928 var modal = modal && modal.length ? modal : this.S(this.scope),
3929 open_modals = this.S('[' + this.attr_name() + '].open'),
3930 settings = modal.data(this.attr_name(true) + '-init') || this.settings;
3931
3932 if (open_modals.length > 0) {
3933 this.locked = true;
3934 this.key_up_off(modal); // PATCH #3: turning on key up capture only when a reveal window is open
3935 modal.trigger('close').trigger('close.fndtn.reveal');
3936 this.toggle_bg(modal, false);
3937 this.hide(open_modals, settings.css.close, settings);
3938 }
3939 },
3940
3941 close_targets: function () {
3942 var base = '.' + this.settings.dismiss_modal_class;
3943
3944 if (this.settings.close_on_background_click) {
3945 return base + ', .' + this.settings.bg_class;
3946 }
3947
3948 return base;
3949 },
3950
3951 toggle_bg: function (el, modal, state) {
3952 var settings = el.data(this.attr_name(true) + '-init') || this.settings,
3953 bg_root_element = settings.bg_root_element; // Adding option to specify the background root element fixes scrolling issue
3954
3955 if (this.S('.' + this.settings.bg_class).length === 0) {
3956 this.settings.bg = $('<div />', {'class': this.settings.bg_class})
3957 .appendTo(bg_root_element).hide();
3958 }
3959
3960 var visible = this.settings.bg.filter(':visible').length > 0;
3961 if (state != visible) {
3962 if (state == undefined ? visible : !state) {
3963 this.hide(this.settings.bg);
3964 } else {
3965 this.show(this.settings.bg);
3966 }
3967 }
3968 },
3969
3970 show: function (el, css) {
3971 // is modal
3972 if (css) {
3973 var settings = el.data(this.attr_name(true) + '-init') || this.settings,
3974 root_element = settings.root_element;
3975
3976 if (el.parent(root_element).length === 0) {
3977 var placeholder = el.wrap('<div style="display: none;" />').parent();
3978
3979 el.on('closed.fndtn.reveal.wrapped', function () {
3980 el.detach().appendTo(placeholder);
3981 el.unwrap().unbind('closed.fndtn.reveal.wrapped');
3982 });
3983
3984 el.detach().appendTo(root_element);
3985 }
3986
3987 var animData = getAnimationData(settings.animation);
3988 if (!animData.animate) {
3989 this.locked = false;
3990 }
3991 if (animData.pop) {
3992 css.top = $(root_element).scrollTop() - el.data('offset') + 'px'; //adding root_element instead of window for scrolling offset if modal trigger is below the fold
3993 var end_css = {
3994 top: $(root_element).scrollTop() + el.data('css-top') + 'px', //adding root_element instead of window for scrolling offset if modal trigger is below the fold
3995 opacity: 1
3996 };
3997
3998 return setTimeout(function () {
3999 return el
4000 .css(css)
4001 .animate(end_css, settings.animation_speed, 'linear', function () {
4002 this.locked = false;
4003 el.trigger('opened').trigger('opened.fndtn.reveal');
4004 }.bind(this))
4005 .addClass('open');
4006 }.bind(this), settings.animation_speed / 2);
4007 }
4008
4009 if (animData.fade) {
4010 css.top = $(root_element).scrollTop() + el.data('css-top') + 'px'; //adding root_element instead of window for scrolling offset if modal trigger is below the fold
4011 var end_css = {opacity: 1};
4012
4013 return setTimeout(function () {
4014 return el
4015 .css(css)
4016 .animate(end_css, settings.animation_speed, 'linear', function () {
4017 this.locked = false;
4018 el.trigger('opened').trigger('opened.fndtn.reveal');
4019 }.bind(this))
4020 .addClass('open');
4021 }.bind(this), settings.animation_speed / 2);
4022 }
4023
4024 return el.css(css).show().css({opacity: 1}).addClass('open').trigger('opened').trigger('opened.fndtn.reveal');
4025 }
4026
4027 var settings = this.settings;
4028
4029 // should we animate the background?
4030 if (getAnimationData(settings.animation).fade) {
4031 return el.fadeIn(settings.animation_speed / 2);
4032 }
4033
4034 this.locked = false;
4035
4036 return el.show();
4037 },
4038
4039 hide: function (el, css) {
4040 // is modal
4041 if (css) {
4042 var settings = el.data(this.attr_name(true) + '-init') || this.settings,
4043 root_element = settings.root_element;
4044
4045 var animData = getAnimationData(settings.animation);
4046 if (!animData.animate) {
4047 this.locked = false;
4048 }
4049 if (animData.pop) {
4050 var end_css = {
4051 top: -$(root_element).scrollTop() - el.data('offset') + 'px', //adding root_element instead of window for scrolling offset if modal trigger is below the fold
4052 opacity: 0
4053 };
4054
4055 return setTimeout(function () {
4056 return el
4057 .animate(end_css, settings.animation_speed, 'linear', function () {
4058 this.locked = false;
4059 el.css(css).trigger('closed').trigger('closed.fndtn.reveal');
4060 }.bind(this))
4061 .removeClass('open');
4062 }.bind(this), settings.animation_speed / 2);
4063 }
4064
4065 if (animData.fade) {
4066 var end_css = {opacity: 0};
4067
4068 return setTimeout(function () {
4069 return el
4070 .animate(end_css, settings.animation_speed, 'linear', function () {
4071 this.locked = false;
4072 el.css(css).trigger('closed').trigger('closed.fndtn.reveal');
4073 }.bind(this))
4074 .removeClass('open');
4075 }.bind(this), settings.animation_speed / 2);
4076 }
4077
4078 return el.hide().css(css).removeClass('open').trigger('closed').trigger('closed.fndtn.reveal');
4079 }
4080
4081 var settings = this.settings;
4082
4083 // should we animate the background?
4084 if (getAnimationData(settings.animation).fade) {
4085 return el.fadeOut(settings.animation_speed / 2);
4086 }
4087
4088 return el.hide();
4089 },
4090
4091 close_video: function (e) {
4092 var video = $('.flex-video', e.target),
4093 iframe = $('iframe', video);
4094
4095 if (iframe.length > 0) {
4096 iframe.attr('data-src', iframe[0].src);
4097 iframe.attr('src', iframe.attr('src'));
4098 video.hide();
4099 }
4100 },
4101
4102 open_video: function (e) {
4103 var video = $('.flex-video', e.target),
4104 iframe = video.find('iframe');
4105
4106 if (iframe.length > 0) {
4107 var data_src = iframe.attr('data-src');
4108 if (typeof data_src === 'string') {
4109 iframe[0].src = iframe.attr('data-src');
4110 } else {
4111 var src = iframe[0].src;
4112 iframe[0].src = undefined;
4113 iframe[0].src = src;
4114 }
4115 video.show();
4116 }
4117 },
4118
4119 data_attr: function (str) {
4120 if (this.namespace.length > 0) {
4121 return this.namespace + '-' + str;
4122 }
4123
4124 return str;
4125 },
4126
4127 cache_offset: function (modal) {
4128 var offset = modal.show().height() + parseInt(modal.css('top'), 10);
4129
4130 modal.hide();
4131
4132 return offset;
4133 },
4134
4135 off: function () {
4136 $(this.scope).off('.fndtn.reveal');
4137 },
4138
4139 reflow: function () {
4140 }
4141 };
4142
4143 /*
4144 * getAnimationData('popAndFade') // {animate: true, pop: true, fade: true}
4145 * getAnimationData('fade') // {animate: true, pop: false, fade: true}
4146 * getAnimationData('pop') // {animate: true, pop: true, fade: false}
4147 * getAnimationData('foo') // {animate: false, pop: false, fade: false}
4148 * getAnimationData(null) // {animate: false, pop: false, fade: false}
4149 */
4150 function getAnimationData(str) {
4151 var fade = /fade/i.test(str);
4152 var pop = /pop/i.test(str);
4153 return {
4154 animate: fade || pop,
4155 pop: pop,
4156 fade: fade
4157 };
4158 }
4159 }(jQuery, window, window.document));
4160 ;
4161 (function ($, window, document, undefined) {
4162 'use strict';
4163
4164 Foundation.libs.interchange = {
4165 name: 'interchange',
4166
4167 version: '5.5.0',
4168
4169 cache: {},
4170
4171 images_loaded: false,
4172 nodes_loaded: false,
4173
4174 settings: {
4175 load_attr: 'interchange',
4176
4177 named_queries: {
4178 'default': 'only screen',
4179 'small': Foundation.media_queries['small'],
4180 'small-only': Foundation.media_queries['small-only'],
4181 'medium': Foundation.media_queries['medium'],
4182 'medium-only': Foundation.media_queries['medium-only'],
4183 'large': Foundation.media_queries['large'],
4184 'large-only': Foundation.media_queries['large-only'],
4185 'xlarge': Foundation.media_queries['xlarge'],
4186 'xlarge-only': Foundation.media_queries['xlarge-only'],
4187 'xxlarge': Foundation.media_queries['xxlarge'],
4188 'landscape': 'only screen and (orientation: landscape)',
4189 'portrait': 'only screen and (orientation: portrait)',
4190 'retina': 'only screen and (-webkit-min-device-pixel-ratio: 2),' +
4191 'only screen and (min--moz-device-pixel-ratio: 2),' +
4192 'only screen and (-o-min-device-pixel-ratio: 2/1),' +
4193 'only screen and (min-device-pixel-ratio: 2),' +
4194 'only screen and (min-resolution: 192dpi),' +
4195 'only screen and (min-resolution: 2dppx)'
4196 },
4197
4198 directives: {
4199 replace: function (el, path, trigger) {
4200 // The trigger argument, if called within the directive, fires
4201 // an event named after the directive on the element, passing
4202 // any parameters along to the event that you pass to trigger.
4203 //
4204 // ex. trigger(), trigger([a, b, c]), or trigger(a, b, c)
4205 //
4206 // This allows you to bind a callback like so:
4207 // $('#interchangeContainer').on('replace', function (e, a, b, c) {
4208 // console.log($(this).html(), a, b, c);
4209 // });
4210
4211 if (/IMG/.test(el[0].nodeName)) {
4212 var orig_path = el[0].src;
4213
4214 if (new RegExp(path, 'i').test(orig_path)) return;
4215
4216 el[0].src = path;
4217
4218 return trigger(el[0].src);
4219 }
4220 var last_path = el.data(this.data_attr + '-last-path'),
4221 self = this;
4222
4223 if (last_path == path) return;
4224
4225 if (/\.(gif|jpg|jpeg|tiff|png)([?#].*)?/i.test(path)) {
4226 $(el).css('background-image', 'url(' + path + ')');
4227 el.data('interchange-last-path', path);
4228 return trigger(path);
4229 }
4230
4231 return $.get(path, function (response) {
4232 el.html(response);
4233 el.data(self.data_attr + '-last-path', path);
4234 trigger();
4235 });
4236
4237 }
4238 }
4239 },
4240
4241 init: function (scope, method, options) {
4242 Foundation.inherit(this, 'throttle random_str');
4243
4244 this.data_attr = this.set_data_attr();
4245 $.extend(true, this.settings, method, options);
4246 this.bindings(method, options);
4247 this.load('images');
4248 this.load('nodes');
4249 },
4250
4251 get_media_hash: function () {
4252 var mediaHash = '';
4253 for (var queryName in this.settings.named_queries) {
4254 mediaHash += matchMedia(this.settings.named_queries[queryName]).matches.toString();
4255 }
4256 return mediaHash;
4257 },
4258
4259 events: function () {
4260 var self = this, prevMediaHash;
4261
4262 $(window)
4263 .off('.interchange')
4264 .on('resize.fndtn.interchange', self.throttle(function () {
4265 var currMediaHash = self.get_media_hash();
4266 if (currMediaHash !== prevMediaHash) {
4267 self.resize();
4268 }
4269 prevMediaHash = currMediaHash;
4270 }, 50));
4271
4272 return this;
4273 },
4274
4275 resize: function () {
4276 var cache = this.cache;
4277
4278 if (!this.images_loaded || !this.nodes_loaded) {
4279 setTimeout($.proxy(this.resize, this), 50);
4280 return;
4281 }
4282
4283 for (var uuid in cache) {
4284 if (cache.hasOwnProperty(uuid)) {
4285 var passed = this.results(uuid, cache[uuid]);
4286
4287 if (passed) {
4288 this.settings.directives[passed
4289 .scenario[1]].call(this, passed.el, passed.scenario[0], function () {
4290 if (arguments[0] instanceof Array) {
4291 var args = arguments[0];
4292 } else {
4293 var args = Array.prototype.slice.call(arguments, 0);
4294 }
4295
4296 passed.el.trigger(passed.scenario[1], args);
4297 });
4298 }
4299 }
4300 }
4301
4302 },
4303
4304 results: function (uuid, scenarios) {
4305 var count = scenarios.length;
4306
4307 if (count > 0) {
4308 var el = this.S('[' + this.add_namespace('data-uuid') + '="' + uuid + '"]');
4309
4310 while (count--) {
4311 var mq, rule = scenarios[count][2];
4312 if (this.settings.named_queries.hasOwnProperty(rule)) {
4313 mq = matchMedia(this.settings.named_queries[rule]);
4314 } else {
4315 mq = matchMedia(rule);
4316 }
4317 if (mq.matches) {
4318 return {el: el, scenario: scenarios[count]};
4319 }
4320 }
4321 }
4322
4323 return false;
4324 },
4325
4326 load: function (type, force_update) {
4327 if (typeof this['cached_' + type] === 'undefined' || force_update) {
4328 this['update_' + type]();
4329 }
4330
4331 return this['cached_' + type];
4332 },
4333
4334 update_images: function () {
4335 var images = this.S('img[' + this.data_attr + ']'),
4336 count = images.length,
4337 i = count,
4338 loaded_count = 0,
4339 data_attr = this.data_attr;
4340
4341 this.cache = {};
4342 this.cached_images = [];
4343 this.images_loaded = (count === 0);
4344
4345 while (i--) {
4346 loaded_count++;
4347 if (images[i]) {
4348 var str = images[i].getAttribute(data_attr) || '';
4349
4350 if (str.length > 0) {
4351 this.cached_images.push(images[i]);
4352 }
4353 }
4354
4355 if (loaded_count === count) {
4356 this.images_loaded = true;
4357 this.enhance('images');
4358 }
4359 }
4360
4361 return this;
4362 },
4363
4364 update_nodes: function () {
4365 var nodes = this.S('[' + this.data_attr + ']').not('img'),
4366 count = nodes.length,
4367 i = count,
4368 loaded_count = 0,
4369 data_attr = this.data_attr;
4370
4371 this.cached_nodes = [];
4372 this.nodes_loaded = (count === 0);
4373
4374
4375 while (i--) {
4376 loaded_count++;
4377 var str = nodes[i].getAttribute(data_attr) || '';
4378
4379 if (str.length > 0) {
4380 this.cached_nodes.push(nodes[i]);
4381 }
4382
4383 if (loaded_count === count) {
4384 this.nodes_loaded = true;
4385 this.enhance('nodes');
4386 }
4387 }
4388
4389 return this;
4390 },
4391
4392 enhance: function (type) {
4393 var i = this['cached_' + type].length;
4394
4395 while (i--) {
4396 this.object($(this['cached_' + type][i]));
4397 }
4398
4399 return $(window).trigger('resize').trigger('resize.fndtn.interchange');
4400 },
4401
4402 convert_directive: function (directive) {
4403
4404 var trimmed = this.trim(directive);
4405
4406 if (trimmed.length > 0) {
4407 return trimmed;
4408 }
4409
4410 return 'replace';
4411 },
4412
4413 parse_scenario: function (scenario) {
4414 // This logic had to be made more complex since some users were using commas in the url path
4415 // So we cannot simply just split on a comma
4416 var directive_match = scenario[0].match(/(.+),\s*(\w+)\s*$/),
4417 media_query = scenario[1];
4418
4419 if (directive_match) {
4420 var path = directive_match[1],
4421 directive = directive_match[2];
4422 }
4423 else {
4424 var cached_split = scenario[0].split(/,\s*$/),
4425 path = cached_split[0],
4426 directive = '';
4427 }
4428
4429 return [this.trim(path), this.convert_directive(directive), this.trim(media_query)];
4430 },
4431
4432 object: function (el) {
4433 var raw_arr = this.parse_data_attr(el),
4434 scenarios = [],
4435 i = raw_arr.length;
4436
4437 if (i > 0) {
4438 while (i--) {
4439 var split = raw_arr[i].split(/\((.*?)(\))$/);
4440
4441 if (split.length > 1) {
4442 var params = this.parse_scenario(split);
4443 scenarios.push(params);
4444 }
4445 }
4446 }
4447
4448 return this.store(el, scenarios);
4449 },
4450
4451 store: function (el, scenarios) {
4452 var uuid = this.random_str(),
4453 current_uuid = el.data(this.add_namespace('uuid', true));
4454
4455 if (this.cache[current_uuid]) return this.cache[current_uuid];
4456
4457 el.attr(this.add_namespace('data-uuid'), uuid);
4458
4459 return this.cache[uuid] = scenarios;
4460 },
4461
4462 trim: function (str) {
4463
4464 if (typeof str === 'string') {
4465 return $.trim(str);
4466 }
4467
4468 return str;
4469 },
4470
4471 set_data_attr: function (init) {
4472 if (init) {
4473 if (this.namespace.length > 0) {
4474 return this.namespace + '-' + this.settings.load_attr;
4475 }
4476
4477 return this.settings.load_attr;
4478 }
4479
4480 if (this.namespace.length > 0) {
4481 return 'data-' + this.namespace + '-' + this.settings.load_attr;
4482 }
4483
4484 return 'data-' + this.settings.load_attr;
4485 },
4486
4487 parse_data_attr: function (el) {
4488 var raw = el.attr(this.attr_name()).split(/\[(.*?)\]/),
4489 i = raw.length,
4490 output = [];
4491
4492 while (i--) {
4493 if (raw[i].replace(/[\W\d]+/, '').length > 4) {
4494 output.push(raw[i]);
4495 }
4496 }
4497
4498 return output;
4499 },
4500
4501 reflow: function () {
4502 this.load('images', true);
4503 this.load('nodes', true);
4504 }
4505
4506 };
4507
4508 }(jQuery, window, window.document));
4509 ;
4510 (function ($, window, document, undefined) {
4511 'use strict';
4512
4513 Foundation.libs['magellan-expedition'] = {
4514 name: 'magellan-expedition',
4515
4516 version: '5.5.0',
4517
4518 settings: {
4519 active_class: 'active',
4520 threshold: 0, // pixels from the top of the expedition for it to become fixes
4521 destination_threshold: 20, // pixels from the top of destination for it to be considered active
4522 throttle_delay: 30, // calculation throttling to increase framerate
4523 fixed_top: 0, // top distance in pixels assigend to the fixed element on scroll
4524 offset_by_height: true, // whether to offset the destination by the expedition height. Usually you want this to be true, unless your expedition is on the side.
4525 duration: 700, // animation duration time
4526 easing: 'swing' // animation easing
4527 },
4528
4529 init: function (scope, method, options) {
4530 Foundation.inherit(this, 'throttle');
4531 this.bindings(method, options);
4532 },
4533
4534 events: function () {
4535 var self = this,
4536 S = self.S,
4537 settings = self.settings;
4538
4539 // initialize expedition offset
4540 self.set_expedition_position();
4541
4542 S(self.scope)
4543 .off('.magellan')
4544 .on('click.fndtn.magellan', '[' + self.add_namespace('data-magellan-arrival') + '] a[href^="#"]', function (e) {
4545 e.preventDefault();
4546 var expedition = $(this).closest('[' + self.attr_name() + ']'),
4547 settings = expedition.data('magellan-expedition-init'),
4548 hash = this.hash.split('#').join(''),
4549 target = $('a[name="' + hash + '"]');
4550
4551 if (target.length === 0) {
4552 target = $('#' + hash);
4553
4554 }
4555
4556
4557 // Account for expedition height if fixed position
4558 var scroll_top = target.offset().top - settings.destination_threshold + 1;
4559 if (settings.offset_by_height) {
4560 scroll_top = scroll_top - expedition.outerHeight();
4561 }
4562
4563 $('html, body').stop().animate({
4564 'scrollTop': scroll_top
4565 }, settings.duration, settings.easing, function () {
4566 if (history.pushState) {
4567 history.pushState(null, null, '#' + hash);
4568 }
4569 else {
4570 location.hash = '#' + hash;
4571 }
4572 });
4573 })
4574 .on('scroll.fndtn.magellan', self.throttle(this.check_for_arrivals.bind(this), settings.throttle_delay));
4575
4576 $(window)
4577 .on('resize.fndtn.magellan', self.throttle(this.set_expedition_position.bind(this), settings.throttle_delay));
4578 },
4579
4580 check_for_arrivals: function () {
4581 var self = this;
4582 self.update_arrivals();
4583 self.update_expedition_positions();
4584 },
4585
4586 set_expedition_position: function () {
4587 var self = this;
4588 $('[' + this.attr_name() + '=fixed]', self.scope).each(function (idx, el) {
4589 var expedition = $(this),
4590 settings = expedition.data('magellan-expedition-init'),
4591 styles = expedition.attr('styles'), // save styles
4592 top_offset, fixed_top;
4593
4594 expedition.attr('style', '');
4595 top_offset = expedition.offset().top + settings.threshold;
4596
4597 //set fixed-top by attribute
4598 fixed_top = parseInt(expedition.data('magellan-fixed-top'));
4599 if (!isNaN(fixed_top))
4600 self.settings.fixed_top = fixed_top;
4601
4602 expedition.data(self.data_attr('magellan-top-offset'), top_offset);
4603 expedition.attr('style', styles);
4604 });
4605 },
4606
4607 update_expedition_positions: function () {
4608 var self = this,
4609 window_top_offset = $(window).scrollTop();
4610
4611 $('[' + this.attr_name() + '=fixed]', self.scope).each(function () {
4612 var expedition = $(this),
4613 settings = expedition.data('magellan-expedition-init'),
4614 styles = expedition.attr('style'), // save styles
4615 top_offset = expedition.data('magellan-top-offset');
4616
4617 //scroll to the top distance
4618 if (window_top_offset + self.settings.fixed_top >= top_offset) {
4619 // Placeholder allows height calculations to be consistent even when
4620 // appearing to switch between fixed/non-fixed placement
4621 var placeholder = expedition.prev('[' + self.add_namespace('data-magellan-expedition-clone') + ']');
4622 if (placeholder.length === 0) {
4623 placeholder = expedition.clone();
4624 placeholder.removeAttr(self.attr_name());
4625 placeholder.attr(self.add_namespace('data-magellan-expedition-clone'), '');
4626 expedition.before(placeholder);
4627 }
4628 expedition.css({position: 'fixed', top: settings.fixed_top}).addClass('fixed');
4629 } else {
4630 expedition.prev('[' + self.add_namespace('data-magellan-expedition-clone') + ']').remove();
4631 expedition.attr('style', styles).css('position', '').css('top', '').removeClass('fixed');
4632 }
4633 });
4634 },
4635
4636 update_arrivals: function () {
4637 var self = this,
4638 window_top_offset = $(window).scrollTop();
4639
4640 $('[' + this.attr_name() + ']', self.scope).each(function () {
4641 var expedition = $(this),
4642 settings = expedition.data(self.attr_name(true) + '-init'),
4643 offsets = self.offsets(expedition, window_top_offset),
4644 arrivals = expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']'),
4645 active_item = false;
4646 offsets.each(function (idx, item) {
4647 if (item.viewport_offset >= item.top_offset) {
4648 var arrivals = expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']');
4649 arrivals.not(item.arrival).removeClass(settings.active_class);
4650 item.arrival.addClass(settings.active_class);
4651 active_item = true;
4652 return true;
4653 }
4654 });
4655
4656 if (!active_item) arrivals.removeClass(settings.active_class);
4657 });
4658 },
4659
4660 offsets: function (expedition, window_offset) {
4661 var self = this,
4662 settings = expedition.data(self.attr_name(true) + '-init'),
4663 viewport_offset = window_offset;
4664
4665 return expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']').map(function (idx, el) {
4666 var name = $(this).data(self.data_attr('magellan-arrival')),
4667 dest = $('[' + self.add_namespace('data-magellan-destination') + '=' + name + ']');
4668 if (dest.length > 0) {
4669 var top_offset = dest.offset().top - settings.destination_threshold;
4670 if (settings.offset_by_height) {
4671 top_offset = top_offset - expedition.outerHeight();
4672 }
4673 top_offset = Math.floor(top_offset);
4674 return {
4675 destination: dest,
4676 arrival: $(this),
4677 top_offset: top_offset,
4678 viewport_offset: viewport_offset
4679 }
4680 }
4681 }).sort(function (a, b) {
4682 if (a.top_offset < b.top_offset) return -1;
4683 if (a.top_offset > b.top_offset) return 1;
4684 return 0;
4685 });
4686 },
4687
4688 data_attr: function (str) {
4689 if (this.namespace.length > 0) {
4690 return this.namespace + '-' + str;
4691 }
4692
4693 return str;
4694 },
4695
4696 off: function () {
4697 this.S(this.scope).off('.magellan');
4698 this.S(window).off('.magellan');
4699 },
4700
4701 reflow: function () {
4702 var self = this;
4703 // remove placeholder expeditions used for height calculation purposes
4704 $('[' + self.add_namespace('data-magellan-expedition-clone') + ']', self.scope).remove();
4705 }
4706 };
4707 }(jQuery, window, window.document));
4708 ;
4709 (function ($, window, document, undefined) {
4710 'use strict';
4711
4712 Foundation.libs.accordion = {
4713 name: 'accordion',
4714
4715 version: '5.5.0',
4716
4717 settings: {
4718 content_class: 'content',
4719 active_class: 'active',
4720 multi_expand: false,
4721 toggleable: true,
4722 callback: function () {
4723 }
4724 },
4725
4726 init: function (scope, method, options) {
4727 this.bindings(method, options);
4728 },
4729
4730 events: function () {
4731 var self = this;
4732 var S = this.S;
4733 S(this.scope)
4734 .off('.fndtn.accordion')
4735 .on('click.fndtn.accordion', '[' + this.attr_name() + '] > .accordion-navigation > a', function (e) {
4736 var accordion = S(this).closest('[' + self.attr_name() + ']'),
4737 groupSelector = self.attr_name() + '=' + accordion.attr(self.attr_name()),
4738 settings = accordion.data(self.attr_name(true) + '-init') || self.settings,
4739 target = S('#' + this.href.split('#')[1]),
4740 aunts = $('> .accordion-navigation', accordion),
4741 siblings = aunts.children('.' + settings.content_class),
4742 active_content = siblings.filter('.' + settings.active_class);
4743
4744 e.preventDefault();
4745
4746 if (accordion.attr(self.attr_name())) {
4747 siblings = siblings.add('[' + groupSelector + '] dd > ' + '.' + settings.content_class);
4748 aunts = aunts.add('[' + groupSelector + '] .accordion-navigation');
4749 }
4750
4751 if (settings.toggleable && target.is(active_content)) {
4752 target.parent('.accordion-navigation').toggleClass(settings.active_class, false);
4753 target.toggleClass(settings.active_class, false);
4754 settings.callback(target);
4755 target.triggerHandler('toggled', [accordion]);
4756 accordion.triggerHandler('toggled', [target]);
4757 return;
4758 }
4759
4760 if (!settings.multi_expand) {
4761 siblings.removeClass(settings.active_class);
4762 aunts.removeClass(settings.active_class);
4763 }
4764
4765 target.addClass(settings.active_class).parent().addClass(settings.active_class);
4766 settings.callback(target);
4767 target.triggerHandler('toggled', [accordion]);
4768 accordion.triggerHandler('toggled', [target]);
4769 });
4770 },
4771
4772 off: function () {
4773 },
4774
4775 reflow: function () {
4776 }
4777 };
4778 }(jQuery, window, window.document));
4779 ;
4780 (function ($, window, document, undefined) {
4781 'use strict';
4782
4783 Foundation.libs.topbar = {
4784 name: 'topbar',
4785
4786 version: '5.5.0',
4787
4788 settings: {
4789 index: 0,
4790 sticky_class: 'sticky',
4791 custom_back_text: true,
4792 back_text: 'Back',
4793 mobile_show_parent_link: true,
4794 is_hover: true,
4795 scrolltop: true, // jump to top when sticky nav menu toggle is clicked
4796 sticky_on: 'all'
4797 },
4798
4799 init: function (section, method, options) {
4800 Foundation.inherit(this, 'add_custom_rule register_media throttle');
4801 var self = this;
4802
4803 self.register_media('topbar', 'foundation-mq-topbar');
4804
4805 this.bindings(method, options);
4806
4807 self.S('[' + this.attr_name() + ']', this.scope).each(function () {
4808 var topbar = $(this),
4809 settings = topbar.data(self.attr_name(true) + '-init'),
4810 section = self.S('section, .top-bar-section', this);
4811 topbar.data('index', 0);
4812 var topbarContainer = topbar.parent();
4813 if (topbarContainer.hasClass('fixed') || self.is_sticky(topbar, topbarContainer, settings)) {
4814 self.settings.sticky_class = settings.sticky_class;
4815 self.settings.sticky_topbar = topbar;
4816 topbar.data('height', topbarContainer.outerHeight());
4817 topbar.data('stickyoffset', topbarContainer.offset().top);
4818 } else {
4819 topbar.data('height', topbar.outerHeight());
4820 }
4821
4822 if (!settings.assembled) {
4823 self.assemble(topbar);
4824 }
4825
4826 if (settings.is_hover) {
4827 self.S('.has-dropdown', topbar).addClass('not-click');
4828 } else {
4829 self.S('.has-dropdown', topbar).removeClass('not-click');
4830 }
4831
4832 // Pad body when sticky (scrolled) or fixed.
4833 self.add_custom_rule('.f-topbar-fixed { padding-top: ' + topbar.data('height') + 'px }');
4834
4835 if (topbarContainer.hasClass('fixed')) {
4836 self.S('body').addClass('f-topbar-fixed');
4837 }
4838 });
4839
4840 },
4841
4842 is_sticky: function (topbar, topbarContainer, settings) {
4843 var sticky = topbarContainer.hasClass(settings.sticky_class);
4844
4845 if (sticky && settings.sticky_on === 'all') {
4846 return true;
4847 } else if (sticky && this.small() && settings.sticky_on === 'small') {
4848 return (matchMedia(Foundation.media_queries.small).matches && !matchMedia(Foundation.media_queries.medium).matches && !matchMedia(Foundation.media_queries.large).matches);
4849 //return true;
4850 } else if (sticky && this.medium() && settings.sticky_on === 'medium') {
4851 return (matchMedia(Foundation.media_queries.small).matches && matchMedia(Foundation.media_queries.medium).matches && !matchMedia(Foundation.media_queries.large).matches);
4852 //return true;
4853 } else if (sticky && this.large() && settings.sticky_on === 'large') {
4854 return (matchMedia(Foundation.media_queries.small).matches && matchMedia(Foundation.media_queries.medium).matches &&
4855 matchMedia(Foundation.media_queries.large).matches);
4856 //return true;
4857 }
4858
4859 return false;
4860 },
4861
4862 toggle: function (toggleEl) {
4863 var self = this,
4864 topbar;
4865
4866 if (toggleEl) {
4867 topbar = self.S(toggleEl).closest('[' + this.attr_name() + ']');
4868 } else {
4869 topbar = self.S('[' + this.attr_name() + ']');
4870 }
4871
4872 var settings = topbar.data(this.attr_name(true) + '-init');
4873
4874 var section = self.S('section, .top-bar-section', topbar);
4875
4876 if (self.breakpoint()) {
4877 if (!self.rtl) {
4878 section.css({left: '0%'});
4879 $('>.name', section).css({left: '100%'});
4880 } else {
4881 section.css({right: '0%'});
4882 $('>.name', section).css({right: '100%'});
4883 }
4884
4885 self.S('li.moved', section).removeClass('moved');
4886 topbar.data('index', 0);
4887
4888 topbar
4889 .toggleClass('expanded')
4890 .css('height', '');
4891 }
4892
4893 if (settings.scrolltop) {
4894 if (!topbar.hasClass('expanded')) {
4895 if (topbar.hasClass('fixed')) {
4896 topbar.parent().addClass('fixed');
4897 topbar.removeClass('fixed');
4898 self.S('body').addClass('f-topbar-fixed');
4899 }
4900 } else if (topbar.parent().hasClass('fixed')) {
4901 if (settings.scrolltop) {
4902 topbar.parent().removeClass('fixed');
4903 topbar.addClass('fixed');
4904 self.S('body').removeClass('f-topbar-fixed');
4905
4906 window.scrollTo(0, 0);
4907 } else {
4908 topbar.parent().removeClass('expanded');
4909 }
4910 }
4911 } else {
4912 if (self.is_sticky(topbar, topbar.parent(), settings)) {
4913 topbar.parent().addClass('fixed');
4914 }
4915
4916 if (topbar.parent().hasClass('fixed')) {
4917 if (!topbar.hasClass('expanded')) {
4918 topbar.removeClass('fixed');
4919 topbar.parent().removeClass('expanded');
4920 self.update_sticky_positioning();
4921 } else {
4922 topbar.addClass('fixed');
4923 topbar.parent().addClass('expanded');
4924 self.S('body').addClass('f-topbar-fixed');
4925 }
4926 }
4927 }
4928 },
4929
4930 timer: null,
4931
4932 events: function (bar) {
4933 var self = this,
4934 S = this.S;
4935
4936 S(this.scope)
4937 .off('.topbar')
4938 .on('click.fndtn.topbar', '[' + this.attr_name() + '] .toggle-topbar', function (e) {
4939 e.preventDefault();
4940 self.toggle(this);
4941 })
4942 .on('click.fndtn.topbar', '.top-bar .top-bar-section li a[href^="#"],[' + this.attr_name() + '] .top-bar-section li a[href^="#"]', function (e) {
4943 var li = $(this).closest('li');
4944 if (self.breakpoint() && !li.hasClass('back') && !li.hasClass('has-dropdown')) {
4945 self.toggle();
4946 }
4947 })
4948 .on('click.fndtn.topbar', '[' + this.attr_name() + '] li.has-dropdown', function (e) {
4949 var li = S(this),
4950 target = S(e.target),
4951 topbar = li.closest('[' + self.attr_name() + ']'),
4952 settings = topbar.data(self.attr_name(true) + '-init');
4953
4954 if (target.data('revealId')) {
4955 self.toggle();
4956 return;
4957 }
4958
4959 if (self.breakpoint()) return;
4960 if (settings.is_hover && !Modernizr.touch) return;
4961
4962 e.stopImmediatePropagation();
4963
4964 if (li.hasClass('hover')) {
4965 li
4966 .removeClass('hover')
4967 .find('li')
4968 .removeClass('hover');
4969
4970 li.parents('li.hover')
4971 .removeClass('hover');
4972 } else {
4973 li.addClass('hover');
4974
4975 $(li).siblings().removeClass('hover');
4976
4977 if (target[0].nodeName === 'A' && target.parent().hasClass('has-dropdown')) {
4978 e.preventDefault();
4979 }
4980 }
4981 })
4982 .on('click.fndtn.topbar', '[' + this.attr_name() + '] .has-dropdown>a', function (e) {
4983 if (self.breakpoint()) {
4984
4985 e.preventDefault();
4986
4987 var $this = S(this),
4988 topbar = $this.closest('[' + self.attr_name() + ']'),
4989 section = topbar.find('section, .top-bar-section'),
4990 dropdownHeight = $this.next('.dropdown').outerHeight(),
4991 $selectedLi = $this.closest('li');
4992
4993 topbar.data('index', topbar.data('index') + 1);
4994 $selectedLi.addClass('moved');
4995
4996 if (!self.rtl) {
4997 section.css({left: -(100 * topbar.data('index')) + '%'});
4998 section.find('>.name').css({left: 100 * topbar.data('index') + '%'});
4999 } else {
5000 section.css({right: -(100 * topbar.data('index')) + '%'});
5001 section.find('>.name').css({right: 100 * topbar.data('index') + '%'});
5002 }
5003
5004 topbar.css('height', $this.siblings('ul').outerHeight(true) + topbar.data('height'));
5005 }
5006 });
5007
5008 S(window).off('.topbar').on('resize.fndtn.topbar', self.throttle(function () {
5009 self.resize.call(self);
5010 }, 50)).trigger('resize').trigger('resize.fndtn.topbar').load(function () {
5011 // Ensure that the offset is calculated after all of the pages resources have loaded
5012 S(this).trigger('resize.fndtn.topbar');
5013 });
5014
5015 S('body').off('.topbar').on('click.fndtn.topbar', function (e) {
5016 var parent = S(e.target).closest('li').closest('li.hover');
5017
5018 if (parent.length > 0) {
5019 return;
5020 }
5021
5022 S('[' + self.attr_name() + '] li.hover').removeClass('hover');
5023 });
5024
5025 // Go up a level on Click
5026 S(this.scope).on('click.fndtn.topbar', '[' + this.attr_name() + '] .has-dropdown .back', function (e) {
5027 e.preventDefault();
5028
5029 var $this = S(this),
5030 topbar = $this.closest('[' + self.attr_name() + ']'),
5031 section = topbar.find('section, .top-bar-section'),
5032 settings = topbar.data(self.attr_name(true) + '-init'),
5033 $movedLi = $this.closest('li.moved'),
5034 $previousLevelUl = $movedLi.parent();
5035
5036 topbar.data('index', topbar.data('index') - 1);
5037
5038 if (!self.rtl) {
5039 section.css({left: -(100 * topbar.data('index')) + '%'});
5040 section.find('>.name').css({left: 100 * topbar.data('index') + '%'});
5041 } else {
5042 section.css({right: -(100 * topbar.data('index')) + '%'});
5043 section.find('>.name').css({right: 100 * topbar.data('index') + '%'});
5044 }
5045
5046 if (topbar.data('index') === 0) {
5047 topbar.css('height', '');
5048 } else {
5049 topbar.css('height', $previousLevelUl.outerHeight(true) + topbar.data('height'));
5050 }
5051
5052 setTimeout(function () {
5053 $movedLi.removeClass('moved');
5054 }, 300);
5055 });
5056
5057 // Show dropdown menus when their items are focused
5058 S(this.scope).find('.dropdown a')
5059 .focus(function () {
5060 $(this).parents('.has-dropdown').addClass('hover');
5061 })
5062 .blur(function () {
5063 $(this).parents('.has-dropdown').removeClass('hover');
5064 });
5065 },
5066
5067 resize: function () {
5068 var self = this;
5069 self.S('[' + this.attr_name() + ']').each(function () {
5070 var topbar = self.S(this),
5071 settings = topbar.data(self.attr_name(true) + '-init');
5072
5073 var stickyContainer = topbar.parent('.' + self.settings.sticky_class);
5074 var stickyOffset;
5075
5076 if (!self.breakpoint()) {
5077 var doToggle = topbar.hasClass('expanded');
5078 topbar
5079 .css('height', '')
5080 .removeClass('expanded')
5081 .find('li')
5082 .removeClass('hover');
5083
5084 if (doToggle) {
5085 self.toggle(topbar);
5086 }
5087 }
5088
5089 if (self.is_sticky(topbar, stickyContainer, settings)) {
5090 if (stickyContainer.hasClass('fixed')) {
5091 // Remove the fixed to allow for correct calculation of the offset.
5092 stickyContainer.removeClass('fixed');
5093
5094 stickyOffset = stickyContainer.offset().top;
5095 if (self.S(document.body).hasClass('f-topbar-fixed')) {
5096 stickyOffset -= topbar.data('height');
5097 }
5098
5099 topbar.data('stickyoffset', stickyOffset);
5100 stickyContainer.addClass('fixed');
5101 } else {
5102 stickyOffset = stickyContainer.offset().top;
5103 topbar.data('stickyoffset', stickyOffset);
5104 }
5105 }
5106
5107 });
5108 },
5109
5110 breakpoint: function () {
5111 return !matchMedia(Foundation.media_queries['topbar']).matches;
5112 },
5113
5114 small: function () {
5115 return matchMedia(Foundation.media_queries['small']).matches;
5116 },
5117
5118 medium: function () {
5119 return matchMedia(Foundation.media_queries['medium']).matches;
5120 },
5121
5122 large: function () {
5123 return matchMedia(Foundation.media_queries['large']).matches;
5124 },
5125
5126 assemble: function (topbar) {
5127 var self = this,
5128 settings = topbar.data(this.attr_name(true) + '-init'),
5129 section = self.S('section, .top-bar-section', topbar);
5130
5131 // Pull element out of the DOM for manipulation
5132 section.detach();
5133
5134 self.S('.has-dropdown>a', section).each(function () {
5135 var $link = self.S(this),
5136 $dropdown = $link.siblings('.dropdown'),
5137 url = $link.attr('href'),
5138 $titleLi;
5139
5140
5141 if (!$dropdown.find('.title.back').length) {
5142
5143 if (settings.mobile_show_parent_link == true && url) {
5144 $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li><li class="parent-link show-for-small-only"><a class="parent-link js-generated" href="' + url + '">' + $link.html() + '</a></li>');
5145 } else {
5146 $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5>');
5147 }
5148
5149 // Copy link to subnav
5150 if (settings.custom_back_text == true) {
5151 $('h5>a', $titleLi).html(settings.back_text);
5152 } else {
5153 $('h5>a', $titleLi).html('&laquo; ' + $link.html());
5154 }
5155 $dropdown.prepend($titleLi);
5156 }
5157 });
5158
5159 // Put element back in the DOM
5160 section.appendTo(topbar);
5161
5162 // check for sticky
5163 this.sticky();
5164
5165 this.assembled(topbar);
5166 },
5167
5168 assembled: function (topbar) {
5169 topbar.data(this.attr_name(true), $.extend({}, topbar.data(this.attr_name(true)), {assembled: true}));
5170 },
5171
5172 height: function (ul) {
5173 var total = 0,
5174 self = this;
5175
5176 $('> li', ul).each(function () {
5177 total += self.S(this).outerHeight(true);
5178 });
5179
5180 return total;
5181 },
5182
5183 sticky: function () {
5184 var self = this;
5185
5186 this.S(window).on('scroll', function () {
5187 self.update_sticky_positioning();
5188 });
5189 },
5190
5191 update_sticky_positioning: function () {
5192 var klass = '.' + this.settings.sticky_class,
5193 $window = this.S(window),
5194 self = this;
5195
5196 if (self.settings.sticky_topbar && self.is_sticky(this.settings.sticky_topbar, this.settings.sticky_topbar.parent(), this.settings)) {
5197 var distance = this.settings.sticky_topbar.data('stickyoffset');
5198 if (!self.S(klass).hasClass('expanded')) {
5199 if ($window.scrollTop() > (distance)) {
5200 if (!self.S(klass).hasClass('fixed')) {
5201 self.S(klass).addClass('fixed');
5202 self.S('body').addClass('f-topbar-fixed');
5203 }
5204 } else if ($window.scrollTop() <= distance) {
5205 if (self.S(klass).hasClass('fixed')) {
5206 self.S(klass).removeClass('fixed');
5207 self.S('body').removeClass('f-topbar-fixed');
5208 }
5209 }
5210 }
5211 }
5212 },
5213
5214 off: function () {
5215 this.S(this.scope).off('.fndtn.topbar');
5216 this.S(window).off('.fndtn.topbar');
5217 },
5218
5219 reflow: function () {
5220 }
5221 };
5222 }(jQuery, window, window.document));
5223 ;
5224 (function ($, window, document, undefined) {
5225 'use strict';
5226
5227 Foundation.libs.tab = {
5228 name: 'tab',
5229
5230 version: '5.5.0',
5231
5232 settings: {
5233 active_class: 'active',
5234 callback: function () {
5235 },
5236 deep_linking: false,
5237 scroll_to_content: true,
5238 is_hover: false
5239 },
5240
5241 default_tab_hashes: [],
5242
5243 init: function (scope, method, options) {
5244 var self = this,
5245 S = this.S;
5246
5247 this.bindings(method, options);
5248 this.handle_location_hash_change();
5249
5250 // Store the default active tabs which will be referenced when the
5251 // location hash is absent, as in the case of navigating the tabs and
5252 // returning to the first viewing via the browser Back button.
5253 S('[' + this.attr_name() + '] > .active > a', this.scope).each(function () {
5254 self.default_tab_hashes.push(this.hash);
5255 });
5256 },
5257
5258 events: function () {
5259 var self = this,
5260 S = this.S;
5261
5262 var usual_tab_behavior = function (e) {
5263 var settings = S(this).closest('[' + self.attr_name() + ']').data(self.attr_name(true) + '-init');
5264 if (!settings.is_hover || Modernizr.touch) {
5265 e.preventDefault();
5266 e.stopPropagation();
5267 self.toggle_active_tab(S(this).parent());
5268 }
5269 };
5270
5271 S(this.scope)
5272 .off('.tab')
5273 // Click event: tab title
5274 .on('focus.fndtn.tab', '[' + this.attr_name() + '] > * > a', usual_tab_behavior)
5275 .on('click.fndtn.tab', '[' + this.attr_name() + '] > * > a', usual_tab_behavior)
5276 // Hover event: tab title
5277 .on('mouseenter.fndtn.tab', '[' + this.attr_name() + '] > * > a', function (e) {
5278 var settings = S(this).closest('[' + self.attr_name() + ']').data(self.attr_name(true) + '-init');
5279 if (settings.is_hover) self.toggle_active_tab(S(this).parent());
5280 });
5281
5282 // Location hash change event
5283 S(window).on('hashchange.fndtn.tab', function (e) {
5284 e.preventDefault();
5285 self.handle_location_hash_change();
5286 });
5287 },
5288
5289 handle_location_hash_change: function () {
5290
5291 var self = this,
5292 S = this.S;
5293
5294 S('[' + this.attr_name() + ']', this.scope).each(function () {
5295 var settings = S(this).data(self.attr_name(true) + '-init');
5296 if (settings.deep_linking) {
5297 // Match the location hash to a label
5298 var hash;
5299 if (settings.scroll_to_content) {
5300 hash = self.scope.location.hash;
5301 } else {
5302 // prefix the hash to prevent anchor scrolling
5303 hash = self.scope.location.hash.replace('fndtn-', '');
5304 }
5305 if (hash != '') {
5306 // Check whether the location hash references a tab content div or
5307 // another element on the page (inside or outside the tab content div)
5308 var hash_element = S(hash);
5309 if (hash_element.hasClass('content') && hash_element.parent().hasClass('tabs-content')) {
5310 // Tab content div
5311 self.toggle_active_tab($('[' + self.attr_name() + '] > * > a[href=' + hash + ']').parent());
5312 } else {
5313 // Not the tab content div. If inside the tab content, find the
5314 // containing tab and toggle it as active.
5315 var hash_tab_container_id = hash_element.closest('.content').attr('id');
5316 if (hash_tab_container_id != undefined) {
5317 self.toggle_active_tab($('[' + self.attr_name() + '] > * > a[href=#' + hash_tab_container_id + ']').parent(), hash);
5318 }
5319 }
5320 } else {
5321 // Reference the default tab hashes which were initialized in the init function
5322 for (var ind = 0; ind < self.default_tab_hashes.length; ind++) {
5323 self.toggle_active_tab($('[' + self.attr_name() + '] > * > a[href=' + self.default_tab_hashes[ind] + ']').parent());
5324 }
5325 }
5326 }
5327 });
5328 },
5329
5330 toggle_active_tab: function (tab, location_hash) {
5331 var S = this.S,
5332 tabs = tab.closest('[' + this.attr_name() + ']'),
5333 tab_link = tab.find('a'),
5334 anchor = tab.children('a').first(),
5335 target_hash = '#' + anchor.attr('href').split('#')[1],
5336 target = S(target_hash),
5337 siblings = tab.siblings(),
5338 settings = tabs.data(this.attr_name(true) + '-init'),
5339 interpret_keyup_action = function (e) {
5340 // Light modification of Heydon Pickering's Practical ARIA Examples: http://heydonworks.com/practical_aria_examples/js/a11y.js
5341
5342 // define current, previous and next (possible) tabs
5343
5344 var $original = $(this);
5345 var $prev = $(this).parents('li').prev().children('[role="tab"]');
5346 var $next = $(this).parents('li').next().children('[role="tab"]');
5347 var $target;
5348
5349 // find the direction (prev or next)
5350
5351 switch (e.keyCode) {
5352 case 37:
5353 $target = $prev;
5354 break;
5355 case 39:
5356 $target = $next;
5357 break;
5358 default:
5359 $target = false
5360 break;
5361 }
5362
5363 if ($target.length) {
5364 $original.attr({
5365 'tabindex': '-1',
5366 'aria-selected': null
5367 });
5368 $target.attr({
5369 'tabindex': '0',
5370 'aria-selected': true
5371 }).focus();
5372 }
5373
5374 // Hide panels
5375
5376 $('[role="tabpanel"]')
5377 .attr('aria-hidden', 'true');
5378
5379 // Show panel which corresponds to target
5380
5381 $('#' + $(document.activeElement).attr('href').substring(1))
5382 .attr('aria-hidden', null);
5383
5384 };
5385
5386 // allow usage of data-tab-content attribute instead of href
5387 if (S(this).data(this.data_attr('tab-content'))) {
5388 target_hash = '#' + S(this).data(this.data_attr('tab-content')).split('#')[1];
5389 target = S(target_hash);
5390 }
5391
5392 if (settings.deep_linking) {
5393
5394 if (settings.scroll_to_content) {
5395 // retain current hash to scroll to content
5396 window.location.hash = location_hash || target_hash;
5397 if (location_hash == undefined || location_hash == target_hash) {
5398 tab.parent()[0].scrollIntoView();
5399 } else {
5400 S(target_hash)[0].scrollIntoView();
5401 }
5402 } else {
5403 // prefix the hashes so that the browser doesn't scroll down
5404 if (location_hash != undefined) {
5405 window.location.hash = 'fndtn-' + location_hash.replace('#', '');
5406 } else {
5407 window.location.hash = 'fndtn-' + target_hash.replace('#', '');
5408 }
5409 }
5410 }
5411
5412 // WARNING: The activation and deactivation of the tab content must
5413 // occur after the deep linking in order to properly refresh the browser
5414 // window (notably in Chrome).
5415 // Clean up multiple attr instances to done once
5416 tab.addClass(settings.active_class).triggerHandler('opened');
5417 tab_link.attr({'aria-selected': 'true', tabindex: 0});
5418 siblings.removeClass(settings.active_class)
5419 siblings.find('a').attr({'aria-selected': 'false', tabindex: -1});
5420 target.siblings().removeClass(settings.active_class).attr({'aria-hidden': 'true', tabindex: -1});
5421 target.addClass(settings.active_class).attr('aria-hidden', 'false').removeAttr('tabindex');
5422 settings.callback(tab);
5423 target.triggerHandler('toggled', [tab]);
5424 tabs.triggerHandler('toggled', [target]);
5425
5426 tab_link.off('keydown').on('keydown', interpret_keyup_action);
5427 },
5428
5429 data_attr: function (str) {
5430 if (this.namespace.length > 0) {
5431 return this.namespace + '-' + str;
5432 }
5433
5434 return str;
5435 },
5436
5437 off: function () {
5438 },
5439
5440 reflow: function () {
5441 }
5442 };
5443 }(jQuery, window, window.document));
5444 ;
5445 (function ($, window, document, undefined) {
5446 'use strict';
5447
5448 Foundation.libs.abide = {
5449 name: 'abide',
5450
5451 version: '5.5.0',
5452
5453 settings: {
5454 live_validate: true,
5455 validate_on_blur: true,
5456 focus_on_invalid: true,
5457 error_labels: true, // labels with a for="inputId" will recieve an `error` class
5458 error_class: 'error',
5459 timeout: 1000,
5460 patterns: {
5461 alpha: /^[a-zA-Z]+$/,
5462 alpha_numeric: /^[a-zA-Z0-9]+$/,
5463 integer: /^[-+]?\d+$/,
5464 number: /^[-+]?\d*(?:[\.\,]\d+)?$/,
5465
5466 // amex, visa, diners
5467 card: /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/,
5468 cvv: /^([0-9]){3,4}$/,
5469
5470 // http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
5471 email: /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/,
5472
5473 url: /^(https?|ftp|file|ssh):\/\/(((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/,
5474 // abc.de
5475 domain: /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,8}$/,
5476
5477 datetime: /^([0-2][0-9]{3})\-([0-1][0-9])\-([0-3][0-9])T([0-5][0-9])\:([0-5][0-9])\:([0-5][0-9])(Z|([\-\+]([0-1][0-9])\:00))$/,
5478 // YYYY-MM-DD
5479 date: /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))$/,
5480 // HH:MM:SS
5481 time: /^(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}$/,
5482 dateISO: /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/,
5483 // MM/DD/YYYY
5484 month_day_year: /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.]\d{4}$/,
5485 // DD/MM/YYYY
5486 day_month_year: /^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.]\d{4}$/,
5487
5488 // #FFF or #FFFFFF
5489 color: /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/
5490 },
5491 validators: {
5492 equalTo: function (el, required, parent) {
5493 var from = document.getElementById(el.getAttribute(this.add_namespace('data-equalto'))).value,
5494 to = el.value,
5495 valid = (from === to);
5496
5497 return valid;
5498 }
5499 }
5500 },
5501
5502 timer: null,
5503
5504 init: function (scope, method, options) {
5505 this.bindings(method, options);
5506 },
5507
5508 events: function (scope) {
5509 var self = this,
5510 form = self.S(scope).attr('novalidate', 'novalidate'),
5511 settings = form.data(this.attr_name(true) + '-init') || {};
5512
5513 this.invalid_attr = this.add_namespace('data-invalid');
5514
5515 form
5516 .off('.abide')
5517 .on('submit.fndtn.abide validate.fndtn.abide', function (e) {
5518 var is_ajax = /ajax/i.test(self.S(this).attr(self.attr_name()));
5519 return self.validate(self.S(this).find('input, textarea, select').get(), e, is_ajax);
5520 })
5521 .on('reset', function () {
5522 return self.reset($(this));
5523 })
5524 .find('input, textarea, select')
5525 .off('.abide')
5526 .on('blur.fndtn.abide change.fndtn.abide', function (e) {
5527 if (settings.validate_on_blur === true) {
5528 self.validate([this], e);
5529 }
5530 })
5531 .on('keydown.fndtn.abide', function (e) {
5532 if (settings.live_validate === true && e.which != 9) {
5533 clearTimeout(self.timer);
5534 self.timer = setTimeout(function () {
5535 self.validate([this], e);
5536 }.bind(this), settings.timeout);
5537 }
5538 });
5539 },
5540
5541 reset: function (form) {
5542 form.removeAttr(this.invalid_attr);
5543 $(this.invalid_attr, form).removeAttr(this.invalid_attr);
5544 $('.' + this.settings.error_class, form).not('small').removeClass(this.settings.error_class);
5545 },
5546
5547 validate: function (els, e, is_ajax) {
5548 var validations = this.parse_patterns(els),
5549 validation_count = validations.length,
5550 form = this.S(els[0]).closest('form'),
5551 submit_event = /submit/.test(e.type);
5552
5553 // Has to count up to make sure the focus gets applied to the top error
5554 for (var i = 0; i < validation_count; i++) {
5555 if (!validations[i] && (submit_event || is_ajax)) {
5556 if (this.settings.focus_on_invalid) els[i].focus();
5557 form.trigger('invalid').trigger('invalid.fndtn.abide');
5558 this.S(els[i]).closest('form').attr(this.invalid_attr, '');
5559 return false;
5560 }
5561 }
5562
5563 if (submit_event || is_ajax) {
5564 form.trigger('valid').trigger('valid.fndtn.abide');
5565 }
5566
5567 form.removeAttr(this.invalid_attr);
5568
5569 if (is_ajax) return false;
5570
5571 return true;
5572 },
5573
5574 parse_patterns: function (els) {
5575 var i = els.length,
5576 el_patterns = [];
5577
5578 while (i--) {
5579 el_patterns.push(this.pattern(els[i]));
5580 }
5581
5582 return this.check_validation_and_apply_styles(el_patterns);
5583 },
5584
5585 pattern: function (el) {
5586 var type = el.getAttribute('type'),
5587 required = typeof el.getAttribute('required') === 'string';
5588
5589 var pattern = el.getAttribute('pattern') || '';
5590
5591 if (this.settings.patterns.hasOwnProperty(pattern) && pattern.length > 0) {
5592 return [el, this.settings.patterns[pattern], required];
5593 } else if (pattern.length > 0) {
5594 return [el, new RegExp(pattern), required];
5595 }
5596
5597 if (this.settings.patterns.hasOwnProperty(type)) {
5598 return [el, this.settings.patterns[type], required];
5599 }
5600
5601 pattern = /.*/;
5602
5603 return [el, pattern, required];
5604 },
5605
5606 // TODO: Break this up into smaller methods, getting hard to read.
5607 check_validation_and_apply_styles: function (el_patterns) {
5608 var i = el_patterns.length,
5609 validations = [],
5610 form = this.S(el_patterns[0][0]).closest('[data-' + this.attr_name(true) + ']'),
5611 settings = form.data(this.attr_name(true) + '-init') || {};
5612 while (i--) {
5613 var el = el_patterns[i][0],
5614 required = el_patterns[i][2],
5615 value = el.value.trim(),
5616 direct_parent = this.S(el).parent(),
5617 validator = el.getAttribute(this.add_namespace('data-abide-validator')),
5618 is_radio = el.type === "radio",
5619 is_checkbox = el.type === "checkbox",
5620 label = this.S('label[for="' + el.getAttribute('id') + '"]'),
5621 valid_length = (required) ? (el.value.length > 0) : true,
5622 el_validations = [];
5623
5624 var parent, valid;
5625
5626 // support old way to do equalTo validations
5627 if (el.getAttribute(this.add_namespace('data-equalto'))) {
5628 validator = "equalTo"
5629 }
5630
5631 if (!direct_parent.is('label')) {
5632 parent = direct_parent;
5633 } else {
5634 parent = direct_parent.parent();
5635 }
5636
5637 if (validator) {
5638 valid = this.settings.validators[validator].apply(this, [el, required, parent]);
5639 el_validations.push(valid);
5640 }
5641
5642 if (is_radio && required) {
5643 el_validations.push(this.valid_radio(el, required));
5644 } else if (is_checkbox && required) {
5645 el_validations.push(this.valid_checkbox(el, required));
5646 } else {
5647
5648 if (el_patterns[i][1].test(value) && valid_length ||
5649 !required && el.value.length < 1 || $(el).attr('disabled')) {
5650 el_validations.push(true);
5651 } else {
5652 el_validations.push(false);
5653 }
5654
5655 el_validations = [el_validations.every(function (valid) {
5656 return valid;
5657 })];
5658
5659 if (el_validations[0]) {
5660 this.S(el).removeAttr(this.invalid_attr);
5661 el.setAttribute('aria-invalid', 'false');
5662 el.removeAttribute('aria-describedby');
5663 parent.removeClass(this.settings.error_class);
5664 if (label.length > 0 && this.settings.error_labels) {
5665 label.removeClass(this.settings.error_class).removeAttr('role');
5666 }
5667 $(el).triggerHandler('valid');
5668 } else {
5669 this.S(el).attr(this.invalid_attr, '');
5670 el.setAttribute('aria-invalid', 'true');
5671
5672 // Try to find the error associated with the input
5673 var errorElem = parent.find('small.' + this.settings.error_class, 'span.' + this.settings.error_class);
5674 var errorID = errorElem.length > 0 ? errorElem[0].id : "";
5675 if (errorID.length > 0) el.setAttribute('aria-describedby', errorID);
5676
5677 // el.setAttribute('aria-describedby', $(el).find('.error')[0].id);
5678 parent.addClass(this.settings.error_class);
5679 if (label.length > 0 && this.settings.error_labels) {
5680 label.addClass(this.settings.error_class).attr('role', 'alert');
5681 }
5682 $(el).triggerHandler('invalid');
5683 }
5684 }
5685 validations.push(el_validations[0]);
5686 }
5687 validations = [validations.every(function (valid) {
5688 return valid;
5689 })];
5690 return validations;
5691 },
5692
5693 valid_checkbox: function (el, required) {
5694 var el = this.S(el),
5695 valid = (el.is(':checked') || !required);
5696
5697 if (valid) {
5698 el.removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
5699 } else {
5700 el.attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
5701 }
5702
5703 return valid;
5704 },
5705
5706 valid_radio: function (el, required) {
5707 var name = el.getAttribute('name'),
5708 group = this.S(el).closest('[data-' + this.attr_name(true) + ']').find("[name='" + name + "']"),
5709 count = group.length,
5710 valid = false;
5711
5712 // Has to count up to make sure the focus gets applied to the top error
5713 for (var i = 0; i < count; i++) {
5714 if (group[i].checked) valid = true;
5715 }
5716
5717 // Has to count up to make sure the focus gets applied to the top error
5718 for (var i = 0; i < count; i++) {
5719 if (valid) {
5720 this.S(group[i]).removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
5721 } else {
5722 this.S(group[i]).attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
5723 }
5724 }
5725
5726 return valid;
5727 },
5728
5729 valid_equal: function (el, required, parent) {
5730 var from = document.getElementById(el.getAttribute(this.add_namespace('data-equalto'))).value,
5731 to = el.value,
5732 valid = (from === to);
5733
5734 if (valid) {
5735 this.S(el).removeAttr(this.invalid_attr);
5736 parent.removeClass(this.settings.error_class);
5737 if (label.length > 0 && settings.error_labels) label.removeClass(this.settings.error_class);
5738 } else {
5739 this.S(el).attr(this.invalid_attr, '');
5740 parent.addClass(this.settings.error_class);
5741 if (label.length > 0 && settings.error_labels) label.addClass(this.settings.error_class);
5742 }
5743
5744 return valid;
5745 },
5746
5747 valid_oneof: function (el, required, parent, doNotValidateOthers) {
5748 var el = this.S(el),
5749 others = this.S('[' + this.add_namespace('data-oneof') + ']'),
5750 valid = others.filter(':checked').length > 0;
5751
5752 if (valid) {
5753 el.removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
5754 } else {
5755 el.attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
5756 }
5757
5758 if (!doNotValidateOthers) {
5759 var _this = this;
5760 others.each(function () {
5761 _this.valid_oneof.call(_this, this, null, null, true);
5762 });
5763 }
5764
5765 return valid;
5766 }
5767 };
5768 }(jQuery, window, window.document));
5769 ;
5770 (function ($, window, document, undefined) {
5771 'use strict';
5772
5773 Foundation.libs.tooltip = {
5774 name: 'tooltip',
5775
5776 version: '5.5.0',
5777
5778 settings: {
5779 additional_inheritable_classes: [],
5780 tooltip_class: '.tooltip',
5781 append_to: 'body',
5782 touch_close_text: 'Tap To Close',
5783 disable_for_touch: false,
5784 hover_delay: 200,
5785 show_on: 'all',
5786 tip_template: function (selector, content) {
5787 return '<span data-selector="' + selector + '" id="' + selector + '" class="'
5788 + Foundation.libs.tooltip.settings.tooltip_class.substring(1)
5789 + '" role="tooltip">' + content + '<span class="nub"></span></span>';
5790 }
5791 },
5792
5793 cache: {},
5794
5795 init: function (scope, method, options) {
5796 Foundation.inherit(this, 'random_str');
5797 this.bindings(method, options);
5798 },
5799
5800 should_show: function (target, tip) {
5801 var settings = $.extend({}, this.settings, this.data_options(target));
5802
5803 if (settings.show_on === 'all') {
5804 return true;
5805 } else if (this.small() && settings.show_on === 'small') {
5806 return true;
5807 } else if (this.medium() && settings.show_on === 'medium') {
5808 return true;
5809 } else if (this.large() && settings.show_on === 'large') {
5810 return true;
5811 }
5812 return false;
5813 },
5814
5815 medium: function () {
5816 return matchMedia(Foundation.media_queries['medium']).matches;
5817 },
5818
5819 large: function () {
5820 return matchMedia(Foundation.media_queries['large']).matches;
5821 },
5822
5823 events: function (instance) {
5824 var self = this,
5825 S = self.S;
5826
5827 self.create(this.S(instance));
5828
5829 $(this.scope)
5830 .off('.tooltip')
5831 .on('mouseenter.fndtn.tooltip mouseleave.fndtn.tooltip touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip',
5832 '[' + this.attr_name() + ']', function (e) {
5833 var $this = S(this),
5834 settings = $.extend({}, self.settings, self.data_options($this)),
5835 is_touch = false;
5836
5837 if (Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type) && S(e.target).is('a')) {
5838 return false;
5839 }
5840
5841 if (/mouse/i.test(e.type) && self.ie_touch(e)) return false;
5842
5843 if ($this.hasClass('open')) {
5844 if (Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) e.preventDefault();
5845 self.hide($this);
5846 } else {
5847 if (settings.disable_for_touch && Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) {
5848 return;
5849 } else if (!settings.disable_for_touch && Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) {
5850 e.preventDefault();
5851 S(settings.tooltip_class + '.open').hide();
5852 is_touch = true;
5853 }
5854
5855 if (/enter|over/i.test(e.type)) {
5856 this.timer = setTimeout(function () {
5857 var tip = self.showTip($this);
5858 }.bind(this), self.settings.hover_delay);
5859 } else if (e.type === 'mouseout' || e.type === 'mouseleave') {
5860 clearTimeout(this.timer);
5861 self.hide($this);
5862 } else {
5863 self.showTip($this);
5864 }
5865 }
5866 })
5867 .on('mouseleave.fndtn.tooltip touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip', '[' + this.attr_name() + '].open', function (e) {
5868 if (/mouse/i.test(e.type) && self.ie_touch(e)) return false;
5869
5870 if ($(this).data('tooltip-open-event-type') == 'touch' && e.type == 'mouseleave') {
5871 return;
5872 }
5873 else if ($(this).data('tooltip-open-event-type') == 'mouse' && /MSPointerDown|touchstart/i.test(e.type)) {
5874 self.convert_to_touch($(this));
5875 } else {
5876 self.hide($(this));
5877 }
5878 })
5879 .on('DOMNodeRemoved DOMAttrModified', '[' + this.attr_name() + ']:not(a)', function (e) {
5880 self.hide(S(this));
5881 });
5882 },
5883
5884 ie_touch: function (e) {
5885 // How do I distinguish between IE11 and Windows Phone 8?????
5886 return false;
5887 },
5888
5889 showTip: function ($target) {
5890 var $tip = this.getTip($target);
5891 if (this.should_show($target, $tip)) {
5892 return this.show($target);
5893 }
5894 return;
5895 },
5896
5897 getTip: function ($target) {
5898 var selector = this.selector($target),
5899 settings = $.extend({}, this.settings, this.data_options($target)),
5900 tip = null;
5901
5902 if (selector) {
5903 tip = this.S('span[data-selector="' + selector + '"]' + settings.tooltip_class);
5904 }
5905
5906 return (typeof tip === 'object') ? tip : false;
5907 },
5908
5909 selector: function ($target) {
5910 var id = $target.attr('id'),
5911 dataSelector = $target.attr(this.attr_name()) || $target.attr('data-selector');
5912
5913 if ((id && id.length < 1 || !id) && typeof dataSelector != 'string') {
5914 dataSelector = this.random_str(6);
5915 $target
5916 .attr('data-selector', dataSelector)
5917 .attr('aria-describedby', dataSelector);
5918 }
5919
5920 return (id && id.length > 0) ? id : dataSelector;
5921 },
5922
5923 create: function ($target) {
5924 var self = this,
5925 settings = $.extend({}, this.settings, this.data_options($target)),
5926 tip_template = this.settings.tip_template;
5927
5928 if (typeof settings.tip_template === 'string' && window.hasOwnProperty(settings.tip_template)) {
5929 tip_template = window[settings.tip_template];
5930 }
5931
5932 var $tip = $(tip_template(this.selector($target), $('<div></div>').html($target.attr('title')).html())),
5933 classes = this.inheritable_classes($target);
5934
5935 $tip.addClass(classes).appendTo(settings.append_to);
5936
5937 if (Modernizr.touch) {
5938 $tip.append('<span class="tap-to-close">' + settings.touch_close_text + '</span>');
5939 $tip.on('touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip', function (e) {
5940 self.hide($target);
5941 });
5942 }
5943
5944 $target.removeAttr('title').attr('title', '');
5945 },
5946
5947 reposition: function (target, tip, classes) {
5948 var width, nub, nubHeight, nubWidth, column, objPos;
5949
5950 tip.css('visibility', 'hidden').show();
5951
5952 width = target.data('width');
5953 nub = tip.children('.nub');
5954 nubHeight = nub.outerHeight();
5955 nubWidth = nub.outerHeight();
5956
5957 if (this.small()) {
5958 tip.css({'width': '100%'});
5959 } else {
5960 tip.css({'width': (width) ? width : 'auto'});
5961 }
5962
5963 objPos = function (obj, top, right, bottom, left, width) {
5964 return obj.css({
5965 'top': (top) ? top : 'auto',
5966 'bottom': (bottom) ? bottom : 'auto',
5967 'left': (left) ? left : 'auto',
5968 'right': (right) ? right : 'auto'
5969 }).end();
5970 };
5971
5972 objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', target.offset().left);
5973
5974 if (this.small()) {
5975 objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', 12.5, $(this.scope).width());
5976 tip.addClass('tip-override');
5977 objPos(nub, -nubHeight, 'auto', 'auto', target.offset().left);
5978 } else {
5979 var left = target.offset().left;
5980 if (Foundation.rtl) {
5981 nub.addClass('rtl');
5982 left = target.offset().left + target.outerWidth() - tip.outerWidth();
5983 }
5984 objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', left);
5985 tip.removeClass('tip-override');
5986 if (classes && classes.indexOf('tip-top') > -1) {
5987 if (Foundation.rtl) nub.addClass('rtl');
5988 objPos(tip, (target.offset().top - tip.outerHeight()), 'auto', 'auto', left)
5989 .removeClass('tip-override');
5990 } else if (classes && classes.indexOf('tip-left') > -1) {
5991 objPos(tip, (target.offset().top + (target.outerHeight() / 2) - (tip.outerHeight() / 2)), 'auto', 'auto', (target.offset().left - tip.outerWidth() - nubHeight))
5992 .removeClass('tip-override');
5993 nub.removeClass('rtl');
5994 } else if (classes && classes.indexOf('tip-right') > -1) {
5995 objPos(tip, (target.offset().top + (target.outerHeight() / 2) - (tip.outerHeight() / 2)), 'auto', 'auto', (target.offset().left + target.outerWidth() + nubHeight))
5996 .removeClass('tip-override');
5997 nub.removeClass('rtl');
5998 }
5999 }
6000
6001 tip.css('visibility', 'visible').hide();
6002 },
6003
6004 small: function () {
6005 return matchMedia(Foundation.media_queries.small).matches && !matchMedia(Foundation.media_queries.medium).matches;
6006 },
6007
6008 inheritable_classes: function ($target) {
6009 var settings = $.extend({}, this.settings, this.data_options($target)),
6010 inheritables = ['tip-top', 'tip-left', 'tip-bottom', 'tip-right', 'radius', 'round'].concat(settings.additional_inheritable_classes),
6011 classes = $target.attr('class'),
6012 filtered = classes ? $.map(classes.split(' '), function (el, i) {
6013 if ($.inArray(el, inheritables) !== -1) {
6014 return el;
6015 }
6016 }).join(' ') : '';
6017
6018 return $.trim(filtered);
6019 },
6020
6021 convert_to_touch: function ($target) {
6022 var self = this,
6023 $tip = self.getTip($target),
6024 settings = $.extend({}, self.settings, self.data_options($target));
6025
6026 if ($tip.find('.tap-to-close').length === 0) {
6027 $tip.append('<span class="tap-to-close">' + settings.touch_close_text + '</span>');
6028 $tip.on('click.fndtn.tooltip.tapclose touchstart.fndtn.tooltip.tapclose MSPointerDown.fndtn.tooltip.tapclose', function (e) {
6029 self.hide($target);
6030 });
6031 }
6032
6033 $target.data('tooltip-open-event-type', 'touch');
6034 },
6035
6036 show: function ($target) {
6037 var $tip = this.getTip($target);
6038
6039 if ($target.data('tooltip-open-event-type') == 'touch') {
6040 this.convert_to_touch($target);
6041 }
6042
6043 this.reposition($target, $tip, $target.attr('class'));
6044 $target.addClass('open');
6045 $tip.fadeIn(150);
6046 },
6047
6048 hide: function ($target) {
6049 var $tip = this.getTip($target);
6050
6051 $tip.fadeOut(150, function () {
6052 $tip.find('.tap-to-close').remove();
6053 $tip.off('click.fndtn.tooltip.tapclose MSPointerDown.fndtn.tapclose');
6054 $target.removeClass('open');
6055 });
6056 },
6057
6058 off: function () {
6059 var self = this;
6060 this.S(this.scope).off('.fndtn.tooltip');
6061 this.S(this.settings.tooltip_class).each(function (i) {
6062 $('[' + self.attr_name() + ']').eq(i).attr('title', $(this).text());
6063 }).remove();
6064 },
6065
6066 reflow: function () {
6067 }
6068 };
6069 }(jQuery, window, window.document));