vendor: 20,831 bytes, lines 1-703
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 /* 161 https://github.com/paulirish/matchMedia.js 162 */ 163 164 window.matchMedia = window.matchMedia || (function ( doc ) { 165 166 'use strict'; 167 168 var bool, 169 docElem = doc.documentElement, 170 refNode = docElem.firstElementChild || docElem.firstChild, 171 // fakeBody required for <FF4 when executed in <head> 172 fakeBody = doc.createElement( 'body' ), 173 div = doc.createElement( 'div' ); 174 175 div.id = 'mq-test-1'; 176 div.style.cssText = 'position:absolute;top:-100em'; 177 fakeBody.style.background = 'none'; 178 fakeBody.appendChild(div); 179 180 return function (q) { 181 182 div.innerHTML = '­<style media="' + q + '"> #mq-test-1 { width: 42px; }</style>'; 183 184 docElem.insertBefore( fakeBody, refNode ); 185 bool = div.offsetWidth === 42; 186 docElem.removeChild( fakeBody ); 187 188 return { 189 matches : bool, 190 media : q 191 }; 192 193 }; 194 195 }( document )); 196 197 /* 198 * jquery.requestAnimationFrame 199 * https://github.com/gnarf37/jquery-requestAnimationFrame 200 * Requires jQuery 1.8+ 201 * 202 * Copyright (c) 2012 Corey Frang 203 * Licensed under the MIT license. 204 */ 205 206 (function(jQuery) { 207 208 209 // requestAnimationFrame polyfill adapted from Erik Möller 210 // fixes from Paul Irish and Tino Zijdel 211 // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ 212 // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating 213 214 var animating, 215 lastTime = 0, 216 vendors = ['webkit', 'moz'], 217 requestAnimationFrame = window.requestAnimationFrame, 218 cancelAnimationFrame = window.cancelAnimationFrame, 219 jqueryFxAvailable = 'undefined' !== typeof jQuery.fx; 220 221 for (; lastTime < vendors.length && !requestAnimationFrame; lastTime++) { 222 requestAnimationFrame = window[ vendors[lastTime] + 'RequestAnimationFrame' ]; 223 cancelAnimationFrame = cancelAnimationFrame || 224 window[ vendors[lastTime] + 'CancelAnimationFrame' ] || 225 window[ vendors[lastTime] + 'CancelRequestAnimationFrame' ]; 226 } 227 228 function raf() { 229 if (animating) { 230 requestAnimationFrame(raf); 231 232 if (jqueryFxAvailable) { 233 jQuery.fx.tick(); 234 } 235 } 236 } 237 238 if (requestAnimationFrame) { 239 // use rAF 240 window.requestAnimationFrame = requestAnimationFrame; 241 window.cancelAnimationFrame = cancelAnimationFrame; 242 243 if (jqueryFxAvailable) { 244 jQuery.fx.timer = function (timer) { 245 if (timer() && jQuery.timers.push(timer) && !animating) { 246 animating = true; 247 raf(); 248 } 249 }; 250 251 jQuery.fx.stop = function () { 252 animating = false; 253 }; 254 } 255 } else { 256 // polyfill 257 window.requestAnimationFrame = function (callback) { 258 var currTime = new Date().getTime(), 259 timeToCall = Math.max(0, 16 - (currTime - lastTime)), 260 id = window.setTimeout(function () { 261 callback(currTime + timeToCall); 262 }, timeToCall); 263 lastTime = currTime + timeToCall; 264 return id; 265 }; 266 267 window.cancelAnimationFrame = function (id) { 268 clearTimeout(id); 269 }; 270 271 } 272 273 }( $ )); 274 275 function removeQuotes (string) { 276 if (typeof string === 'string' || string instanceof String) { 277 string = string.replace(/^['\\/"]+|(;\s?})+|['\\/"]+$/g, ''); 278 } 279 280 return string; 281 } 282 283 window.Foundation = { 284 name : 'Foundation', 285 286 version : '5.5.1', 287 288 media_queries : { 289 'small' : S('.foundation-mq-small').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''), 290 'small-only' : S('.foundation-mq-small-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''), 291 'medium' : S('.foundation-mq-medium').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''), 292 'medium-only' : S('.foundation-mq-medium-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''), 293 'large' : S('.foundation-mq-large').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''), 294 'large-only' : S('.foundation-mq-large-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''), 295 'xlarge' : S('.foundation-mq-xlarge').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''), 296 'xlarge-only' : S('.foundation-mq-xlarge-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''), 297 'xxlarge' : S('.foundation-mq-xxlarge').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, '') 298 }, 299 300 stylesheet : $('<style></style>').appendTo('head')[0].sheet, 301 302 global : { 303 namespace : undefined 304 }, 305 306 init : function (scope, libraries, method, options, response) { 307 var args = [scope, method, options, response], 308 responses = []; 309 310 // check RTL 311 this.rtl = /rtl/i.test(S('html').attr('dir')); 312 313 // set foundation global scope 314 this.scope = scope || this.scope; 315 316 this.set_namespace(); 317 318 if (libraries && typeof libraries === 'string' && !/reflow/i.test(libraries)) { 319 if (this.libs.hasOwnProperty(libraries)) { 320 responses.push(this.init_lib(libraries, args)); 321 } 322 } else { 323 for (var lib in this.libs) { 324 responses.push(this.init_lib(lib, libraries)); 325 } 326 } 327 328 S(window).load(function () { 329 S(window) 330 .trigger('resize.fndtn.clearing') 331 .trigger('resize.fndtn.dropdown') 332 .trigger('resize.fndtn.equalizer') 333 .trigger('resize.fndtn.interchange') 334 .trigger('resize.fndtn.joyride') 335 .trigger('resize.fndtn.magellan') 336 .trigger('resize.fndtn.topbar') 337 .trigger('resize.fndtn.slider'); 338 }); 339 340 return scope; 341 }, 342 343 init_lib : function (lib, args) { 344 if (this.libs.hasOwnProperty(lib)) { 345 this.patch(this.libs[lib]); 346 347 if (args && args.hasOwnProperty(lib)) { 348 if (typeof this.libs[lib].settings !== 'undefined') { 349 $.extend(true, this.libs[lib].settings, args[lib]); 350 } else if (typeof this.libs[lib].defaults !== 'undefined') { 351 $.extend(true, this.libs[lib].defaults, args[lib]); 352 } 353 return this.libs[lib].init.apply(this.libs[lib], [this.scope, args[lib]]); 354 } 355 356 args = args instanceof Array ? args : new Array(args); 357 return this.libs[lib].init.apply(this.libs[lib], args); 358 } 359 360 return function () {}; 361 }, 362 363 patch : function (lib) { 364 lib.scope = this.scope; 365 lib.namespace = this.global.namespace; 366 lib.rtl = this.rtl; 367 lib['data_options'] = this.utils.data_options; 368 lib['attr_name'] = attr_name; 369 lib['add_namespace'] = add_namespace; 370 lib['bindings'] = bindings; 371 lib['S'] = this.utils.S; 372 }, 373 374 inherit : function (scope, methods) { 375 var methods_arr = methods.split(' '), 376 i = methods_arr.length; 377 378 while (i--) { 379 if (this.utils.hasOwnProperty(methods_arr[i])) { 380 scope[methods_arr[i]] = this.utils[methods_arr[i]]; 381 } 382 } 383 }, 384 385 set_namespace : function () { 386 387 // Description: 388 // Don't bother reading the namespace out of the meta tag 389 // if the namespace has been set globally in javascript 390 // 391 // Example: 392 // Foundation.global.namespace = 'my-namespace'; 393 // or make it an empty string: 394 // Foundation.global.namespace = ''; 395 // 396 // 397 398 // If the namespace has not been set (is undefined), try to read it out of the meta element. 399 // Otherwise use the globally defined namespace, even if it's empty ('') 400 var namespace = ( this.global.namespace === undefined ) ? $('.foundation-data-attribute-namespace').css('font-family') : this.global.namespace; 401 402 // Finally, if the namsepace is either undefined or false, set it to an empty string. 403 // Otherwise use the namespace value. 404 this.global.namespace = ( namespace === undefined || /false/i.test(namespace) ) ? '' : namespace; 405 }, 406 407 libs : {}, 408 409 // methods that can be inherited in libraries 410 utils : { 411 412 // Description: 413 // Fast Selector wrapper returns jQuery object. Only use where getElementById 414 // is not available. 415 // 416 // Arguments: 417 // Selector (String): CSS selector describing the element(s) to be 418 // returned as a jQuery object. 419 // 420 // Scope (String): CSS selector describing the area to be searched. Default 421 // is document. 422 // 423 // Returns: 424 // Element (jQuery Object): jQuery object containing elements matching the 425 // selector within the scope. 426 S : S, 427 428 // Description: 429 // Executes a function a max of once every n milliseconds 430 // 431 // Arguments: 432 // Func (Function): Function to be throttled. 433 // 434 // Delay (Integer): Function execution threshold in milliseconds. 435 // 436 // Returns: 437 // Lazy_function (Function): Function with throttling applied. 438 throttle : function (func, delay) { 439 var timer = null; 440 441 return function () { 442 var context = this, args = arguments; 443 444 if (timer == null) { 445 timer = setTimeout(function () { 446 func.apply(context, args); 447 timer = null; 448 }, delay); 449 } 450 }; 451 }, 452 453 // Description: 454 // Executes a function when it stops being invoked for n seconds 455 // Modified version of _.debounce() http://underscorejs.org 456 // 457 // Arguments: 458 // Func (Function): Function to be debounced. 459 // 460 // Delay (Integer): Function execution threshold in milliseconds. 461 // 462 // Immediate (Bool): Whether the function should be called at the beginning 463 // of the delay instead of the end. Default is false. 464 // 465 // Returns: 466 // Lazy_function (Function): Function with debouncing applied. 467 debounce : function (func, delay, immediate) { 468 var timeout, result; 469 return function () { 470 var context = this, args = arguments; 471 var later = function () { 472 timeout = null; 473 if (!immediate) { 474 result = func.apply(context, args); 475 } 476 }; 477 var callNow = immediate && !timeout; 478 clearTimeout(timeout); 479 timeout = setTimeout(later, delay); 480 if (callNow) { 481 result = func.apply(context, args); 482 } 483 return result; 484 }; 485 }, 486 487 // Description: 488 // Parses data-options attribute 489 // 490 // Arguments: 491 // El (jQuery Object): Element to be parsed. 492 // 493 // Returns: 494 // Options (Javascript Object): Contents of the element's data-options 495 // attribute. 496 data_options : function (el, data_attr_name) { 497 data_attr_name = data_attr_name || 'options'; 498 var opts = {}, ii, p, opts_arr, 499 data_options = function (el) { 500 var namespace = Foundation.global.namespace; 501 502 if (namespace.length > 0) { 503 return el.data(namespace + '-' + data_attr_name); 504 } 505 506 return el.data(data_attr_name); 507 }; 508 509 var cached_options = data_options(el); 510 511 if (typeof cached_options === 'object') { 512 return cached_options; 513 } 514 515 opts_arr = (cached_options || ':').split(';'); 516 ii = opts_arr.length; 517 518 function isNumber (o) { 519 return !isNaN (o - 0) && o !== null && o !== '' && o !== false && o !== true; 520 } 521 522 function trim (str) { 523 if (typeof str === 'string') { 524 return $.trim(str); 525 } 526 return str; 527 } 528 529 while (ii--) { 530 p = opts_arr[ii].split(':'); 531 p = [p[0], p.slice(1).join(':')]; 532 533 if (/true/i.test(p[1])) { 534 p[1] = true; 535 } 536 if (/false/i.test(p[1])) { 537 p[1] = false; 538 } 539 if (isNumber(p[1])) { 540 if (p[1].indexOf('.') === -1) { 541 p[1] = parseInt(p[1], 10); 542 } else { 543 p[1] = parseFloat(p[1]); 544 } 545 } 546 547 if (p.length === 2 && p[0].length > 0) { 548 opts[trim(p[0])] = trim(p[1]); 549 } 550 } 551 552 return opts; 553 }, 554 555 // Description: 556 // Adds JS-recognizable media queries 557 // 558 // Arguments: 559 // Media (String): Key string for the media query to be stored as in 560 // Foundation.media_queries 561 // 562 // Class (String): Class name for the generated <meta> tag 563 register_media : function (media, media_class) { 564 if (Foundation.media_queries[media] === undefined) { 565 $('head').append('<meta class="' + media_class + '"/>'); 566 Foundation.media_queries[media] = removeQuotes($('.' + media_class).css('font-family')); 567 } 568 }, 569 570 // Description: 571 // Add custom CSS within a JS-defined media query 572 // 573 // Arguments: 574 // Rule (String): CSS rule to be appended to the document. 575 // 576 // Media (String): Optional media query string for the CSS rule to be 577 // nested under. 578 add_custom_rule : function (rule, media) { 579 if (media === undefined && Foundation.stylesheet) { 580 Foundation.stylesheet.insertRule(rule, Foundation.stylesheet.cssRules.length); 581 } else { 582 var query = Foundation.media_queries[media]; 583 584 if (query !== undefined) { 585 Foundation.stylesheet.insertRule('@media ' + 586 Foundation.media_queries[media] + '{ ' + rule + ' }'); 587 } 588 } 589 }, 590 591 // Description: 592 // Performs a callback function when an image is fully loaded 593 // 594 // Arguments: 595 // Image (jQuery Object): Image(s) to check if loaded. 596 // 597 // Callback (Function): Function to execute when image is fully loaded. 598 image_loaded : function (images, callback) { 599 var self = this, 600 unloaded = images.length; 601 602 if (unloaded === 0) { 603 callback(images); 604 } 605 606 images.each(function () { 607 single_image_loaded(self.S(this), function () { 608 unloaded -= 1; 609 if (unloaded === 0) { 610 callback(images); 611 } 612 }); 613 }); 614 }, 615 616 // Description: 617 // Returns a random, alphanumeric string 618 // 619 // Arguments: 620 // Length (Integer): Length of string to be generated. Defaults to random 621 // integer. 622 // 623 // Returns: 624 // Rand (String): Pseudo-random, alphanumeric string. 625 random_str : function () { 626 if (!this.fidx) { 627 this.fidx = 0; 628 } 629 this.prefix = this.prefix || [(this.name || 'F'), (+new Date).toString(36)].join('-'); 630 631 return this.prefix + (this.fidx++).toString(36); 632 }, 633 634 // Description: 635 // Helper for window.matchMedia 636 // 637 // Arguments: 638 // mq (String): Media query 639 // 640 // Returns: 641 // (Boolean): Whether the media query passes or not 642 match : function (mq) { 643 return window.matchMedia(mq).matches; 644 }, 645 646 // Description: 647 // Helpers for checking Foundation default media queries with JS 648 // 649 // Returns: 650 // (Boolean): Whether the media query passes or not 651 652 is_small_up : function () { 653 return this.match(Foundation.media_queries.small); 654 }, 655 656 is_medium_up : function () { 657 return this.match(Foundation.media_queries.medium); 658 }, 659 660 is_large_up : function () { 661 return this.match(Foundation.media_queries.large); 662 }, 663 664 is_xlarge_up : function () { 665 return this.match(Foundation.media_queries.xlarge); 666 }, 667 668 is_xxlarge_up : function () { 669 return this.match(Foundation.media_queries.xxlarge); 670 }, 671 672 is_small_only : function () { 673 return !this.is_medium_up() && !this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up(); 674 }, 675 676 is_medium_only : function () { 677 return this.is_medium_up() && !this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up(); 678 }, 679 680 is_large_only : function () { 681 return this.is_medium_up() && this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up(); 682 }, 683 684 is_xlarge_only : function () { 685 return this.is_medium_up() && this.is_large_up() && this.is_xlarge_up() && !this.is_xxlarge_up(); 686 }, 687 688 is_xxlarge_only : function () { 689 return this.is_medium_up() && this.is_large_up() && this.is_xlarge_up() && this.is_xxlarge_up(); 690 } 691 } 692 }; 693 694 $.fn.foundation = function () { 695 var args = Array.prototype.slice.call(arguments, 0); 696 697 return this.each(function () { 698 Foundation.init.apply(Foundation, [this].concat(args)); 699 return this; 700 }); 701 }; 702 703}(jQuery, window, window.document));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.