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