vendor: 42,881 bytes, lines 1-1589
1/*! 2 * jQuery JavaScript Library v3.3.1 3 * https://jquery.com/ 4 * 5 * Includes Sizzle.js 6 * https://sizzlejs.com/ 7 * 8 * Copyright JS Foundation and other contributors 9 * Released under the MIT license 10 * https://jquery.org/license 11 * 12 * Date: 2018-01-20T17:24Z 13 */ 14( function( global, factory ) { 15 16 "use strict"; 17 18 if ( typeof module === "object" && typeof module.exports === "object" ) { 19 20 // For CommonJS and CommonJS-like environments where a proper `window` 21 // is present, execute the factory and get jQuery. 22 // For environments that do not have a `window` with a `document` 23 // (such as Node.js), expose a factory as module.exports. 24 // This accentuates the need for the creation of a real `window`. 25 // e.g. var jQuery = require("jquery")(window); 26 // See ticket #14549 for more info. 27 module.exports = global.document ? 28 factory( global, true ) : 29 function( w ) { 30 if ( !w.document ) { 31 throw new Error( "jQuery requires a window with a document" ); 32 } 33 return factory( w ); 34 }; 35 } else { 36 factory( global ); 37 } 38 39// Pass this if window is not defined yet 40} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { 41 42// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1 43// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode 44// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common 45// enough that all such attempts are guarded in a try block. 46"use strict"; 47 48var arr = []; 49 50var document = window.document; 51 52var getProto = Object.getPrototypeOf; 53 54var slice = arr.slice; 55 56var concat = arr.concat; 57 58var push = arr.push; 59 60var indexOf = arr.indexOf; 61 62var class2type = {}; 63 64var toString = class2type.toString; 65 66var hasOwn = class2type.hasOwnProperty; 67 68var fnToString = hasOwn.toString; 69 70var ObjectFunctionString = fnToString.call( Object ); 71 72var support = {}; 73 74var isFunction = function isFunction( obj ) { 75 76 // Support: Chrome <=57, Firefox <=52 77 // In some browsers, typeof returns "function" for HTML <object> elements 78 // (i.e., `typeof document.createElement( "object" ) === "function"`). 79 // We don't want to classify *any* DOM node as a function. 80 return typeof obj === "function" && typeof obj.nodeType !== "number"; 81 }; 82 83 84var isWindow = function isWindow( obj ) { 85 return obj != null && obj === obj.window; 86 }; 87 88 89 90 91 var preservedScriptAttributes = { 92 type: true, 93 src: true, 94 noModule: true 95 }; 96 97 function DOMEval( code, doc, node ) { 98 doc = doc || document; 99 100 var i, 101 script = doc.createElement( "script" ); 102 103 script.text = code; 104 if ( node ) { 105 for ( i in preservedScriptAttributes ) { 106 if ( node[ i ] ) { 107 script[ i ] = node[ i ]; 108 } 109 } 110 } 111 doc.head.appendChild( script ).parentNode.removeChild( script ); 112 } 113 114 115function toType( obj ) { 116 if ( obj == null ) { 117 return obj + ""; 118 } 119 120 // Support: Android <=2.3 only (functionish RegExp) 121 return typeof obj === "object" || typeof obj === "function" ? 122 class2type[ toString.call( obj ) ] || "object" : 123 typeof obj; 124} 125/* global Symbol */ 126// Defining this global in .eslintrc.json would create a danger of using the global 127// unguarded in another place, it seems safer to define global only for this module 128 129 130 131var 132 version = "3.3.1", 133 134 // Define a local copy of jQuery 135 jQuery = function( selector, context ) { 136 137 // The jQuery object is actually just the init constructor 'enhanced' 138 // Need init if jQuery is called (just allow error to be thrown if not included) 139 return new jQuery.fn.init( selector, context ); 140 }, 141 142 // Support: Android <=4.0 only 143 // Make sure we trim BOM and NBSP 144 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; 145 146jQuery.fn = jQuery.prototype = { 147 148 // The current version of jQuery being used 149 jquery: version, 150 151 constructor: jQuery, 152 153 // The default length of a jQuery object is 0 154 length: 0, 155 156 toArray: function() { 157 return slice.call( this ); 158 }, 159 160 // Get the Nth element in the matched element set OR 161 // Get the whole matched element set as a clean array 162 get: function( num ) { 163 164 // Return all the elements in a clean array 165 if ( num == null ) { 166 return slice.call( this ); 167 } 168 169 // Return just the one element from the set 170 return num < 0 ? this[ num + this.length ] : this[ num ]; 171 }, 172 173 // Take an array of elements and push it onto the stack 174 // (returning the new matched element set) 175 pushStack: function( elems ) { 176 177 // Build a new jQuery matched element set 178 var ret = jQuery.merge( this.constructor(), elems ); 179 180 // Add the old object onto the stack (as a reference) 181 ret.prevObject = this; 182 183 // Return the newly-formed element set 184 return ret; 185 }, 186 187 // Execute a callback for every element in the matched set. 188 each: function( callback ) { 189 return jQuery.each( this, callback ); 190 }, 191 192 map: function( callback ) { 193 return this.pushStack( jQuery.map( this, function( elem, i ) { 194 return callback.call( elem, i, elem ); 195 } ) ); 196 }, 197 198 slice: function() { 199 return this.pushStack( slice.apply( this, arguments ) ); 200 }, 201 202 first: function() { 203 return this.eq( 0 ); 204 }, 205 206 last: function() { 207 return this.eq( -1 ); 208 }, 209 210 eq: function( i ) { 211 var len = this.length, 212 j = +i + ( i < 0 ? len : 0 ); 213 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); 214 }, 215 216 end: function() { 217 return this.prevObject || this.constructor(); 218 }, 219 220 // For internal use only. 221 // Behaves like an Array's method, not like a jQuery method. 222 push: push, 223 sort: arr.sort, 224 splice: arr.splice 225}; 226 227jQuery.extend = jQuery.fn.extend = function() { 228 var options, name, src, copy, copyIsArray, clone, 229 target = arguments[ 0 ] || {}, 230 i = 1, 231 length = arguments.length, 232 deep = false; 233 234 // Handle a deep copy situation 235 if ( typeof target === "boolean" ) { 236 deep = target; 237 238 // Skip the boolean and the target 239 target = arguments[ i ] || {}; 240 i++; 241 } 242 243 // Handle case when target is a string or something (possible in deep copy) 244 if ( typeof target !== "object" && !isFunction( target ) ) { 245 target = {}; 246 } 247 248 // Extend jQuery itself if only one argument is passed 249 if ( i === length ) { 250 target = this; 251 i--; 252 } 253 254 for ( ; i < length; i++ ) { 255 256 // Only deal with non-null/undefined values 257 if ( ( options = arguments[ i ] ) != null ) { 258 259 // Extend the base object 260 for ( name in options ) { 261 src = target[ name ]; 262 copy = options[ name ]; 263 264 // Prevent never-ending loop 265 if ( target === copy ) { 266 continue; 267 } 268 269 // Recurse if we're merging plain objects or arrays 270 if ( deep && copy && ( jQuery.isPlainObject( copy ) || 271 ( copyIsArray = Array.isArray( copy ) ) ) ) { 272 273 if ( copyIsArray ) { 274 copyIsArray = false; 275 clone = src && Array.isArray( src ) ? src : []; 276 277 } else { 278 clone = src && jQuery.isPlainObject( src ) ? src : {}; 279 } 280 281 // Never move original objects, clone them 282 target[ name ] = jQuery.extend( deep, clone, copy ); 283 284 // Don't bring in undefined values 285 } else if ( copy !== undefined ) { 286 target[ name ] = copy; 287 } 288 } 289 } 290 } 291 292 // Return the modified object 293 return target; 294}; 295 296jQuery.extend( { 297 298 // Unique for each copy of jQuery on the page 299 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), 300 301 // Assume jQuery is ready without the ready module 302 isReady: true, 303 304 error: function( msg ) { 305 throw new Error( msg ); 306 }, 307 308 noop: function() {}, 309 310 isPlainObject: function( obj ) { 311 var proto, Ctor; 312 313 // Detect obvious negatives 314 // Use toString instead of jQuery.type to catch host objects 315 if ( !obj || toString.call( obj ) !== "[object Object]" ) { 316 return false; 317 } 318 319 proto = getProto( obj ); 320 321 // Objects with no prototype (e.g., `Object.create( null )`) are plain 322 if ( !proto ) { 323 return true; 324 } 325 326 // Objects with prototype are plain iff they were constructed by a global Object function 327 Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; 328 return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; 329 }, 330 331 isEmptyObject: function( obj ) { 332 333 /* eslint-disable no-unused-vars */ 334 // See https://github.com/eslint/eslint/issues/6125 335 var name; 336 337 for ( name in obj ) { 338 return false; 339 } 340 return true; 341 }, 342 343 // Evaluates a script in a global context 344 globalEval: function( code ) { 345 DOMEval( code ); 346 }, 347 348 each: function( obj, callback ) { 349 var length, i = 0; 350 351 if ( isArrayLike( obj ) ) { 352 length = obj.length; 353 for ( ; i < length; i++ ) { 354 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 355 break; 356 } 357 } 358 } else { 359 for ( i in obj ) { 360 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 361 break; 362 } 363 } 364 } 365 366 return obj; 367 }, 368 369 // Support: Android <=4.0 only 370 trim: function( text ) { 371 return text == null ? 372 "" : 373 ( text + "" ).replace( rtrim, "" ); 374 }, 375 376 // results is for internal usage only 377 makeArray: function( arr, results ) { 378 var ret = results || []; 379 380 if ( arr != null ) { 381 if ( isArrayLike( Object( arr ) ) ) { 382 jQuery.merge( ret, 383 typeof arr === "string" ? 384 [ arr ] : arr 385 ); 386 } else { 387 push.call( ret, arr ); 388 } 389 } 390 391 return ret; 392 }, 393 394 inArray: function( elem, arr, i ) { 395 return arr == null ? -1 : indexOf.call( arr, elem, i ); 396 }, 397 398 // Support: Android <=4.0 only, PhantomJS 1 only 399 // push.apply(_, arraylike) throws on ancient WebKit 400 merge: function( first, second ) { 401 var len = +second.length, 402 j = 0, 403 i = first.length; 404 405 for ( ; j < len; j++ ) { 406 first[ i++ ] = second[ j ]; 407 } 408 409 first.length = i; 410 411 return first; 412 }, 413 414 grep: function( elems, callback, invert ) { 415 var callbackInverse, 416 matches = [], 417 i = 0, 418 length = elems.length, 419 callbackExpect = !invert; 420 421 // Go through the array, only saving the items 422 // that pass the validator function 423 for ( ; i < length; i++ ) { 424 callbackInverse = !callback( elems[ i ], i ); 425 if ( callbackInverse !== callbackExpect ) { 426 matches.push( elems[ i ] ); 427 } 428 } 429 430 return matches; 431 }, 432 433 // arg is for internal usage only 434 map: function( elems, callback, arg ) { 435 var length, value, 436 i = 0, 437 ret = []; 438 439 // Go through the array, translating each of the items to their new values 440 if ( isArrayLike( elems ) ) { 441 length = elems.length; 442 for ( ; i < length; i++ ) { 443 value = callback( elems[ i ], i, arg ); 444 445 if ( value != null ) { 446 ret.push( value ); 447 } 448 } 449 450 // Go through every key on the object, 451 } else { 452 for ( i in elems ) { 453 value = callback( elems[ i ], i, arg ); 454 455 if ( value != null ) { 456 ret.push( value ); 457 } 458 } 459 } 460 461 // Flatten any nested arrays 462 return concat.apply( [], ret ); 463 }, 464 465 // A global GUID counter for objects 466 guid: 1, 467 468 // jQuery.support is not used in Core but other projects attach their 469 // properties to it so it needs to exist. 470 support: support 471} ); 472 473if ( typeof Symbol === "function" ) { 474 jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; 475} 476 477// Populate the class2type map 478jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), 479function( i, name ) { 480 class2type[ "[object " + name + "]" ] = name.toLowerCase(); 481} ); 482 483function isArrayLike( obj ) { 484 485 // Support: real iOS 8.2 only (not reproducible in simulator) 486 // `in` check used to prevent JIT error (gh-2145) 487 // hasOwn isn't used here due to false negatives 488 // regarding Nodelist length in IE 489 var length = !!obj && "length" in obj && obj.length, 490 type = toType( obj ); 491 492 if ( isFunction( obj ) || isWindow( obj ) ) { 493 return false; 494 } 495 496 return type === "array" || length === 0 || 497 typeof length === "number" && length > 0 && ( length - 1 ) in obj; 498} 499var Sizzle = 500/*! 501 * Sizzle CSS Selector Engine v2.3.3 502 * https://sizzlejs.com/ 503 * 504 * Copyright jQuery Foundation and other contributors 505 * Released under the MIT license 506 * http://jquery.org/license 507 * 508 * Date: 2016-08-08 509 */ 510(function( window ) { 511 512var i, 513 support, 514 Expr, 515 getText, 516 isXML, 517 tokenize, 518 compile, 519 select, 520 outermostContext, 521 sortInput, 522 hasDuplicate, 523 524 // Local document vars 525 setDocument, 526 document, 527 docElem, 528 documentIsHTML, 529 rbuggyQSA, 530 rbuggyMatches, 531 matches, 532 contains, 533 534 // Instance-specific data 535 expando = "sizzle" + 1 * new Date(), 536 preferredDoc = window.document, 537 dirruns = 0, 538 done = 0, 539 classCache = createCache(), 540 tokenCache = createCache(), 541 compilerCache = createCache(), 542 sortOrder = function( a, b ) { 543 if ( a === b ) { 544 hasDuplicate = true; 545 } 546 return 0; 547 }, 548 549 // Instance methods 550 hasOwn = ({}).hasOwnProperty, 551 arr = [], 552 pop = arr.pop, 553 push_native = arr.push, 554 push = arr.push, 555 slice = arr.slice, 556 // Use a stripped-down indexOf as it's faster than native 557 // https://jsperf.com/thor-indexof-vs-for/5 558 indexOf = function( list, elem ) { 559 var i = 0, 560 len = list.length; 561 for ( ; i < len; i++ ) { 562 if ( list[i] === elem ) { 563 return i; 564 } 565 } 566 return -1; 567 }, 568 569 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", 570 571 // Regular expressions 572 573 // http://www.w3.org/TR/css3-selectors/#whitespace 574 whitespace = "[\\x20\\t\\r\\n\\f]", 575 576 // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier 577 identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+", 578 579 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors 580 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + 581 // Operator (capture 2) 582 "*([*^$|!~]?=)" + whitespace + 583 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" 584 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + 585 "*\\]", 586 587 pseudos = ":(" + identifier + ")(?:\\((" + 588 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: 589 // 1. quoted (capture 3; capture 4 or capture 5) 590 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + 591 // 2. simple (capture 6) 592 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + 593 // 3. anything else (capture 2) 594 ".*" + 595 ")\\)|)", 596 597 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter 598 rwhitespace = new RegExp( whitespace + "+", "g" ), 599 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), 600 601 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), 602 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), 603 604 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), 605 606 rpseudo = new RegExp( pseudos ), 607 ridentifier = new RegExp( "^" + identifier + "$" ), 608 609 matchExpr = { 610 "ID": new RegExp( "^#(" + identifier + ")" ), 611 "CLASS": new RegExp( "^\\.(" + identifier + ")" ), 612 "TAG": new RegExp( "^(" + identifier + "|[*])" ), 613 "ATTR": new RegExp( "^" + attributes ), 614 "PSEUDO": new RegExp( "^" + pseudos ), 615 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + 616 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + 617 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), 618 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), 619 // For use in libraries implementing .is() 620 // We use this for POS matching in `select` 621 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + 622 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) 623 }, 624 625 rinputs = /^(?:input|select|textarea|button)$/i, 626 rheader = /^h\d$/i, 627 628 rnative = /^[^{]+\{\s*\[native \w/, 629 630 // Easily-parseable/retrievable ID or TAG or CLASS selectors 631 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, 632 633 rsibling = /[+~]/, 634 635 // CSS escapes 636 // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters 637 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), 638 funescape = function( _, escaped, escapedWhitespace ) { 639 var high = "0x" + escaped - 0x10000; 640 // NaN means non-codepoint 641 // Support: Firefox<24 642 // Workaround erroneous numeric interpretation of +"0x" 643 return high !== high || escapedWhitespace ? 644 escaped : 645 high < 0 ? 646 // BMP codepoint 647 String.fromCharCode( high + 0x10000 ) : 648 // Supplemental Plane codepoint (surrogate pair) 649 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); 650 }, 651 652 // CSS string/identifier serialization 653 // https://drafts.csswg.org/cssom/#common-serializing-idioms 654 rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g, 655 fcssescape = function( ch, asCodePoint ) { 656 if ( asCodePoint ) { 657 658 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER 659 if ( ch === "\0" ) { 660 return "\uFFFD"; 661 } 662 663 // Control characters and (dependent upon position) numbers get escaped as code points 664 return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; 665 } 666 667 // Other potentially-special ASCII characters get backslash-escaped 668 return "\\" + ch; 669 }, 670 671 // Used for iframes 672 // See setDocument() 673 // Removing the function wrapper causes a "Permission Denied" 674 // error in IE 675 unloadHandler = function() { 676 setDocument(); 677 }, 678 679 disabledAncestor = addCombinator( 680 function( elem ) { 681 return elem.disabled === true && ("form" in elem || "label" in elem); 682 }, 683 { dir: "parentNode", next: "legend" } 684 ); 685 686// Optimize for push.apply( _, NodeList ) 687try { 688 push.apply( 689 (arr = slice.call( preferredDoc.childNodes )), 690 preferredDoc.childNodes 691 ); 692 // Support: Android<4.0 693 // Detect silently failing push.apply 694 arr[ preferredDoc.childNodes.length ].nodeType; 695} catch ( e ) { 696 push = { apply: arr.length ? 697 698 // Leverage slice if possible 699 function( target, els ) { 700 push_native.apply( target, slice.call(els) ); 701 } : 702 703 // Support: IE<9 704 // Otherwise append directly 705 function( target, els ) { 706 var j = target.length, 707 i = 0; 708 // Can't trust NodeList.length 709 while ( (target[j++] = els[i++]) ) {} 710 target.length = j - 1; 711 } 712 }; 713} 714 715function Sizzle( selector, context, results, seed ) { 716 var m, i, elem, nid, match, groups, newSelector, 717 newContext = context && context.ownerDocument, 718 719 // nodeType defaults to 9, since context defaults to document 720 nodeType = context ? context.nodeType : 9; 721 722 results = results || []; 723 724 // Return early from calls with invalid selector or context 725 if ( typeof selector !== "string" || !selector || 726 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { 727 728 return results; 729 } 730 731 // Try to shortcut find operations (as opposed to filters) in HTML documents 732 if ( !seed ) { 733 734 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { 735 setDocument( context ); 736 } 737 context = context || document; 738 739 if ( documentIsHTML ) { 740 741 // If the selector is sufficiently simple, try using a "get*By*" DOM method 742 // (excepting DocumentFragment context, where the methods don't exist) 743 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { 744 745 // ID selector 746 if ( (m = match[1]) ) { 747 748 // Document context 749 if ( nodeType === 9 ) { 750 if ( (elem = context.getElementById( m )) ) { 751 752 // Support: IE, Opera, Webkit 753 // TODO: identify versions 754 // getElementById can match elements by name instead of ID 755 if ( elem.id === m ) { 756 results.push( elem ); 757 return results; 758 } 759 } else { 760 return results; 761 } 762 763 // Element context 764 } else { 765 766 // Support: IE, Opera, Webkit 767 // TODO: identify versions 768 // getElementById can match elements by name instead of ID 769 if ( newContext && (elem = newContext.getElementById( m )) && 770 contains( context, elem ) && 771 elem.id === m ) { 772 773 results.push( elem ); 774 return results; 775 } 776 } 777 778 // Type selector 779 } else if ( match[2] ) { 780 push.apply( results, context.getElementsByTagName( selector ) ); 781 return results; 782 783 // Class selector 784 } else if ( (m = match[3]) && support.getElementsByClassName && 785 context.getElementsByClassName ) { 786 787 push.apply( results, context.getElementsByClassName( m ) ); 788 return results; 789 } 790 } 791 792 // Take advantage of querySelectorAll 793 if ( support.qsa && 794 !compilerCache[ selector + " " ] && 795 (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { 796 797 if ( nodeType !== 1 ) { 798 newContext = context; 799 newSelector = selector; 800 801 // qSA looks outside Element context, which is not what we want 802 // Thanks to Andrew Dupont for this workaround technique 803 // Support: IE <=8 804 // Exclude object elements 805 } else if ( context.nodeName.toLowerCase() !== "object" ) { 806 807 // Capture the context ID, setting it first if necessary 808 if ( (nid = context.getAttribute( "id" )) ) { 809 nid = nid.replace( rcssescape, fcssescape ); 810 } else { 811 context.setAttribute( "id", (nid = expando) ); 812 } 813 814 // Prefix every selector in the list 815 groups = tokenize( selector ); 816 i = groups.length; 817 while ( i-- ) { 818 groups[i] = "#" + nid + " " + toSelector( groups[i] ); 819 } 820 newSelector = groups.join( "," ); 821 822 // Expand context for sibling selectors 823 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || 824 context; 825 } 826 827 if ( newSelector ) { 828 try { 829 push.apply( results, 830 newContext.querySelectorAll( newSelector ) 831 ); 832 return results; 833 } catch ( qsaError ) { 834 } finally { 835 if ( nid === expando ) { 836 context.removeAttribute( "id" ); 837 } 838 } 839 } 840 } 841 } 842 } 843 844 // All others 845 return select( selector.replace( rtrim, "$1" ), context, results, seed ); 846} 847 848/** 849 * Create key-value caches of limited size 850 * @returns {function(string, object)} Returns the Object data after storing it on itself with 851 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) 852 * deleting the oldest entry 853 */ 854function createCache() { 855 var keys = []; 856 857 function cache( key, value ) { 858 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) 859 if ( keys.push( key + " " ) > Expr.cacheLength ) { 860 // Only keep the most recent entries 861 delete cache[ keys.shift() ]; 862 } 863 return (cache[ key + " " ] = value); 864 } 865 return cache; 866} 867 868/** 869 * Mark a function for special use by Sizzle 870 * @param {Function} fn The function to mark 871 */ 872function markFunction( fn ) { 873 fn[ expando ] = true; 874 return fn; 875} 876 877/** 878 * Support testing using an element 879 * @param {Function} fn Passed the created element and returns a boolean result 880 */ 881function assert( fn ) { 882 var el = document.createElement("fieldset"); 883 884 try { 885 return !!fn( el ); 886 } catch (e) { 887 return false; 888 } finally { 889 // Remove from its parent by default 890 if ( el.parentNode ) { 891 el.parentNode.removeChild( el ); 892 } 893 // release memory in IE 894 el = null; 895 } 896} 897 898/** 899 * Adds the same handler for all of the specified attrs 900 * @param {String} attrs Pipe-separated list of attributes 901 * @param {Function} handler The method that will be applied 902 */ 903function addHandle( attrs, handler ) { 904 var arr = attrs.split("|"), 905 i = arr.length; 906 907 while ( i-- ) { 908 Expr.attrHandle[ arr[i] ] = handler; 909 } 910} 911 912/** 913 * Checks document order of two siblings 914 * @param {Element} a 915 * @param {Element} b 916 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b 917 */ 918function siblingCheck( a, b ) { 919 var cur = b && a, 920 diff = cur && a.nodeType === 1 && b.nodeType === 1 && 921 a.sourceIndex - b.sourceIndex; 922 923 // Use IE sourceIndex if available on both nodes 924 if ( diff ) { 925 return diff; 926 } 927 928 // Check if b follows a 929 if ( cur ) { 930 while ( (cur = cur.nextSibling) ) { 931 if ( cur === b ) { 932 return -1; 933 } 934 } 935 } 936 937 return a ? 1 : -1; 938} 939 940/** 941 * Returns a function to use in pseudos for input types 942 * @param {String} type 943 */ 944function createInputPseudo( type ) { 945 return function( elem ) { 946 var name = elem.nodeName.toLowerCase(); 947 return name === "input" && elem.type === type; 948 }; 949} 950 951/** 952 * Returns a function to use in pseudos for buttons 953 * @param {String} type 954 */ 955function createButtonPseudo( type ) { 956 return function( elem ) { 957 var name = elem.nodeName.toLowerCase(); 958 return (name === "input" || name === "button") && elem.type === type; 959 }; 960} 961 962/** 963 * Returns a function to use in pseudos for :enabled/:disabled 964 * @param {Boolean} disabled true for :disabled; false for :enabled 965 */ 966function createDisabledPseudo( disabled ) { 967 968 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable 969 return function( elem ) { 970 971 // Only certain elements can match :enabled or :disabled 972 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled 973 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled 974 if ( "form" in elem ) { 975 976 // Check for inherited disabledness on relevant non-disabled elements: 977 // * listed form-associated elements in a disabled fieldset 978 // https://html.spec.whatwg.org/multipage/forms.html#category-listed 979 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled 980 // * option elements in a disabled optgroup 981 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled 982 // All such elements have a "form" property. 983 if ( elem.parentNode && elem.disabled === false ) { 984 985 // Option elements defer to a parent optgroup if present 986 if ( "label" in elem ) { 987 if ( "label" in elem.parentNode ) { 988 return elem.parentNode.disabled === disabled; 989 } else { 990 return elem.disabled === disabled; 991 } 992 } 993 994 // Support: IE 6 - 11 995 // Use the isDisabled shortcut property to check for disabled fieldset ancestors 996 return elem.isDisabled === disabled || 997 998 // Where there is no isDisabled, check manually 999 /* jshint -W018 */ 1000 elem.isDisabled !== !disabled && 1001 disabledAncestor( elem ) === disabled; 1002 } 1003 1004 return elem.disabled === disabled; 1005 1006 // Try to winnow out elements that can't be disabled before trusting the disabled property. 1007 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't 1008 // even exist on them, let alone have a boolean value. 1009 } else if ( "label" in elem ) { 1010 return elem.disabled === disabled; 1011 } 1012 1013 // Remaining elements are neither :enabled nor :disabled 1014 return false; 1015 }; 1016} 1017 1018/** 1019 * Returns a function to use in pseudos for positionals 1020 * @param {Function} fn 1021 */ 1022function createPositionalPseudo( fn ) { 1023 return markFunction(function( argument ) { 1024 argument = +argument; 1025 return markFunction(function( seed, matches ) { 1026 var j, 1027 matchIndexes = fn( [], seed.length, argument ), 1028 i = matchIndexes.length; 1029 1030 // Match elements found at the specified indexes 1031 while ( i-- ) { 1032 if ( seed[ (j = matchIndexes[i]) ] ) { 1033 seed[j] = !(matches[j] = seed[j]); 1034 } 1035 } 1036 }); 1037 }); 1038} 1039 1040/** 1041 * Checks a node for validity as a Sizzle context 1042 * @param {Element|Object=} context 1043 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value 1044 */ 1045function testContext( context ) { 1046 return context && typeof context.getElementsByTagName !== "undefined" && context; 1047} 1048 1049// Expose support vars for convenience 1050support = Sizzle.support = {}; 1051 1052/** 1053 * Detects XML nodes 1054 * @param {Element|Object} elem An element or a document 1055 * @returns {Boolean} True iff elem is a non-HTML XML node 1056 */ 1057isXML = Sizzle.isXML = function( elem ) { 1058 // documentElement is verified for cases where it doesn't yet exist 1059 // (such as loading iframes in IE - #4833) 1060 var documentElement = elem && (elem.ownerDocument || elem).documentElement; 1061 return documentElement ? documentElement.nodeName !== "HTML" : false; 1062}; 1063 1064/** 1065 * Sets document-related variables once based on the current document 1066 * @param {Element|Object} [doc] An element or document object to use to set the document 1067 * @returns {Object} Returns the current document 1068 */ 1069setDocument = Sizzle.setDocument = function( node ) { 1070 var hasCompare, subWindow, 1071 doc = node ? node.ownerDocument || node : preferredDoc; 1072 1073 // Return early if doc is invalid or already selected 1074 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { 1075 return document; 1076 } 1077 1078 // Update global variables 1079 document = doc; 1080 docElem = document.documentElement; 1081 documentIsHTML = !isXML( document ); 1082 1083 // Support: IE 9-11, Edge 1084 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) 1085 if ( preferredDoc !== document && 1086 (subWindow = document.defaultView) && subWindow.top !== subWindow ) { 1087 1088 // Support: IE 11, Edge 1089 if ( subWindow.addEventListener ) { 1090 subWindow.addEventListener( "unload", unloadHandler, false ); 1091 1092 // Support: IE 9 - 10 only 1093 } else if ( subWindow.attachEvent ) { 1094 subWindow.attachEvent( "onunload", unloadHandler ); 1095 } 1096 } 1097 1098 /* Attributes 1099 ---------------------------------------------------------------------- */ 1100 1101 // Support: IE<8 1102 // Verify that getAttribute really returns attributes and not properties 1103 // (excepting IE8 booleans) 1104 support.attributes = assert(function( el ) { 1105 el.className = "i"; 1106 return !el.getAttribute("className"); 1107 }); 1108 1109 /* getElement(s)By* 1110 ---------------------------------------------------------------------- */ 1111 1112 // Check if getElementsByTagName("*") returns only elements 1113 support.getElementsByTagName = assert(function( el ) { 1114 el.appendChild( document.createComment("") ); 1115 return !el.getElementsByTagName("*").length; 1116 }); 1117 1118 // Support: IE<9 1119 support.getElementsByClassName = rnative.test( document.getElementsByClassName ); 1120 1121 // Support: IE<10 1122 // Check if getElementById returns elements by name 1123 // The broken getElementById methods don't pick up programmatically-set names, 1124 // so use a roundabout getElementsByName test 1125 support.getById = assert(function( el ) { 1126 docElem.appendChild( el ).id = expando; 1127 return !document.getElementsByName || !document.getElementsByName( expando ).length; 1128 }); 1129 1130 // ID filter and find 1131 if ( support.getById ) { 1132 Expr.filter["ID"] = function( id ) { 1133 var attrId = id.replace( runescape, funescape ); 1134 return function( elem ) { 1135 return elem.getAttribute("id") === attrId; 1136 }; 1137 }; 1138 Expr.find["ID"] = function( id, context ) { 1139 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 1140 var elem = context.getElementById( id ); 1141 return elem ? [ elem ] : []; 1142 } 1143 }; 1144 } else { 1145 Expr.filter["ID"] = function( id ) { 1146 var attrId = id.replace( runescape, funescape ); 1147 return function( elem ) { 1148 var node = typeof elem.getAttributeNode !== "undefined" && 1149 elem.getAttributeNode("id"); 1150 return node && node.value === attrId; 1151 }; 1152 }; 1153 1154 // Support: IE 6 - 7 only 1155 // getElementById is not reliable as a find shortcut 1156 Expr.find["ID"] = function( id, context ) { 1157 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 1158 var node, i, elems, 1159 elem = context.getElementById( id ); 1160 1161 if ( elem ) { 1162 1163 // Verify the id attribute 1164 node = elem.getAttributeNode("id"); 1165 if ( node && node.value === id ) { 1166 return [ elem ]; 1167 } 1168 1169 // Fall back on getElementsByName 1170 elems = context.getElementsByName( id ); 1171 i = 0; 1172 while ( (elem = elems[i++]) ) { 1173 node = elem.getAttributeNode("id"); 1174 if ( node && node.value === id ) { 1175 return [ elem ]; 1176 } 1177 } 1178 } 1179 1180 return []; 1181 } 1182 }; 1183 } 1184 1185 // Tag 1186 Expr.find["TAG"] = support.getElementsByTagName ? 1187 function( tag, context ) { 1188 if ( typeof context.getElementsByTagName !== "undefined" ) { 1189 return context.getElementsByTagName( tag ); 1190 1191 // DocumentFragment nodes don't have gEBTN 1192 } else if ( support.qsa ) { 1193 return context.querySelectorAll( tag ); 1194 } 1195 } : 1196 1197 function( tag, context ) { 1198 var elem, 1199 tmp = [], 1200 i = 0, 1201 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too 1202 results = context.getElementsByTagName( tag ); 1203 1204 // Filter out possible comments 1205 if ( tag === "*" ) { 1206 while ( (elem = results[i++]) ) { 1207 if ( elem.nodeType === 1 ) { 1208 tmp.push( elem ); 1209 } 1210 } 1211 1212 return tmp; 1213 } 1214 return results; 1215 }; 1216 1217 // Class 1218 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { 1219 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { 1220 return context.getElementsByClassName( className ); 1221 } 1222 }; 1223 1224 /* QSA/matchesSelector 1225 ---------------------------------------------------------------------- */ 1226 1227 // QSA and matchesSelector support 1228 1229 // matchesSelector(:active) reports false when true (IE9/Opera 11.5) 1230 rbuggyMatches = []; 1231 1232 // qSa(:focus) reports false when true (Chrome 21) 1233 // We allow this because of a bug in IE8/9 that throws an error 1234 // whenever `document.activeElement` is accessed on an iframe 1235 // So, we allow :focus to pass through QSA all the time to avoid the IE error 1236 // See https://bugs.jquery.com/ticket/13378 1237 rbuggyQSA = []; 1238 1239 if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { 1240 // Build QSA regex 1241 // Regex strategy adopted from Diego Perini 1242 assert(function( el ) { 1243 // Select is set to empty string on purpose 1244 // This is to test IE's treatment of not explicitly 1245 // setting a boolean content attribute, 1246 // since its presence should be enough 1247 // https://bugs.jquery.com/ticket/12359 1248 docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" + 1249 "<select id='" + expando + "-\r\\' msallowcapture=''>" + 1250 "<option selected=''></option></select>"; 1251 1252 // Support: IE8, Opera 11-12.16 1253 // Nothing should be selected when empty strings follow ^= or $= or *= 1254 // The test attribute must be unknown in Opera but "safe" for WinRT 1255 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section 1256 if ( el.querySelectorAll("[msallowcapture^='']").length ) { 1257 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); 1258 } 1259 1260 // Support: IE8 1261 // Boolean attributes and "value" are not treated correctly 1262 if ( !el.querySelectorAll("[selected]").length ) { 1263 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); 1264 } 1265 1266 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ 1267 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { 1268 rbuggyQSA.push("~="); 1269 } 1270 1271 // Webkit/Opera - :checked should return selected option elements 1272 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 1273 // IE8 throws error here and will not see later tests 1274 if ( !el.querySelectorAll(":checked").length ) { 1275 rbuggyQSA.push(":checked"); 1276 } 1277 1278 // Support: Safari 8+, iOS 8+ 1279 // https://bugs.webkit.org/show_bug.cgi?id=136851 1280 // In-page `selector#id sibling-combinator selector` fails 1281 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { 1282 rbuggyQSA.push(".#.+[+~]"); 1283 } 1284 }); 1285 1286 assert(function( el ) { 1287 el.innerHTML = "<a href='' disabled='disabled'></a>" + 1288 "<select disabled='disabled'><option/></select>"; 1289 1290 // Support: Windows 8 Native Apps 1291 // The type and name attributes are restricted during .innerHTML assignment 1292 var input = document.createElement("input"); 1293 input.setAttribute( "type", "hidden" ); 1294 el.appendChild( input ).setAttribute( "name", "D" ); 1295 1296 // Support: IE8 1297 // Enforce case-sensitivity of name attribute 1298 if ( el.querySelectorAll("[name=d]").length ) { 1299 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); 1300 } 1301 1302 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) 1303 // IE8 throws error here and will not see later tests 1304 if ( el.querySelectorAll(":enabled").length !== 2 ) { 1305 rbuggyQSA.push( ":enabled", ":disabled" ); 1306 } 1307 1308 // Support: IE9-11+ 1309 // IE's :disabled selector does not pick up the children of disabled fieldsets 1310 docElem.appendChild( el ).disabled = true; 1311 if ( el.querySelectorAll(":disabled").length !== 2 ) { 1312 rbuggyQSA.push( ":enabled", ":disabled" ); 1313 } 1314 1315 // Opera 10-11 does not throw on post-comma invalid pseudos 1316 el.querySelectorAll("*,:x"); 1317 rbuggyQSA.push(",.*:"); 1318 }); 1319 } 1320 1321 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || 1322 docElem.webkitMatchesSelector || 1323 docElem.mozMatchesSelector || 1324 docElem.oMatchesSelector || 1325 docElem.msMatchesSelector) )) ) { 1326 1327 assert(function( el ) { 1328 // Check to see if it's possible to do matchesSelector 1329 // on a disconnected node (IE 9) 1330 support.disconnectedMatch = matches.call( el, "*" ); 1331 1332 // This should fail with an exception 1333 // Gecko does not error, returns false instead 1334 matches.call( el, "[s!='']:x" ); 1335 rbuggyMatches.push( "!=", pseudos ); 1336 }); 1337 } 1338 1339 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); 1340 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); 1341 1342 /* Contains 1343 ---------------------------------------------------------------------- */ 1344 hasCompare = rnative.test( docElem.compareDocumentPosition ); 1345 1346 // Element contains another 1347 // Purposefully self-exclusive 1348 // As in, an element does not contain itself 1349 contains = hasCompare || rnative.test( docElem.contains ) ? 1350 function( a, b ) { 1351 var adown = a.nodeType === 9 ? a.documentElement : a, 1352 bup = b && b.parentNode; 1353 return a === bup || !!( bup && bup.nodeType === 1 && ( 1354 adown.contains ? 1355 adown.contains( bup ) : 1356 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 1357 )); 1358 } : 1359 function( a, b ) { 1360 if ( b ) { 1361 while ( (b = b.parentNode) ) { 1362 if ( b === a ) { 1363 return true; 1364 } 1365 } 1366 } 1367 return false; 1368 }; 1369 1370 /* Sorting 1371 ---------------------------------------------------------------------- */ 1372 1373 // Document order sorting 1374 sortOrder = hasCompare ? 1375 function( a, b ) { 1376 1377 // Flag for duplicate removal 1378 if ( a === b ) { 1379 hasDuplicate = true; 1380 return 0; 1381 } 1382 1383 // Sort on method existence if only one input has compareDocumentPosition 1384 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; 1385 if ( compare ) { 1386 return compare; 1387 } 1388 1389 // Calculate position if both inputs belong to the same document 1390 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? 1391 a.compareDocumentPosition( b ) : 1392 1393 // Otherwise we know they are disconnected 1394 1; 1395 1396 // Disconnected nodes 1397 if ( compare & 1 || 1398 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { 1399 1400 // Choose the first element that is related to our preferred document 1401 if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { 1402 return -1; 1403 } 1404 if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { 1405 return 1; 1406 } 1407 1408 // Maintain original order 1409 return sortInput ? 1410 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 1411 0; 1412 } 1413 1414 return compare & 4 ? -1 : 1; 1415 } : 1416 function( a, b ) { 1417 // Exit early if the nodes are identical 1418 if ( a === b ) { 1419 hasDuplicate = true; 1420 return 0; 1421 } 1422 1423 var cur, 1424 i = 0, 1425 aup = a.parentNode, 1426 bup = b.parentNode, 1427 ap = [ a ], 1428 bp = [ b ]; 1429 1430 // Parentless nodes are either documents or disconnected 1431 if ( !aup || !bup ) { 1432 return a === document ? -1 : 1433 b === document ? 1 : 1434 aup ? -1 : 1435 bup ? 1 : 1436 sortInput ? 1437 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 1438 0; 1439 1440 // If the nodes are siblings, we can do a quick check 1441 } else if ( aup === bup ) { 1442 return siblingCheck( a, b ); 1443 } 1444 1445 // Otherwise we need full lists of their ancestors for comparison 1446 cur = a; 1447 while ( (cur = cur.parentNode) ) { 1448 ap.unshift( cur ); 1449 } 1450 cur = b; 1451 while ( (cur = cur.parentNode) ) { 1452 bp.unshift( cur ); 1453 } 1454 1455 // Walk down the tree looking for a discrepancy 1456 while ( ap[i] === bp[i] ) { 1457 i++; 1458 } 1459 1460 return i ? 1461 // Do a sibling check if the nodes have a common ancestor 1462 siblingCheck( ap[i], bp[i] ) : 1463 1464 // Otherwise nodes in our document sort first 1465 ap[i] === preferredDoc ? -1 : 1466 bp[i] === preferredDoc ? 1 : 1467 0; 1468 }; 1469 1470 return document; 1471}; 1472 1473Sizzle.matches = function( expr, elements ) { 1474 return Sizzle( expr, null, null, elements ); 1475}; 1476 1477Sizzle.matchesSelector = function( elem, expr ) { 1478 // Set document vars if needed 1479 if ( ( elem.ownerDocument || elem ) !== document ) { 1480 setDocument( elem ); 1481 } 1482 1483 // Make sure that attribute selectors are quoted 1484 expr = expr.replace( rattributeQuotes, "='$1']" ); 1485 1486 if ( support.matchesSelector && documentIsHTML && 1487 !compilerCache[ expr + " " ] && 1488 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && 1489 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { 1490 1491 try { 1492 var ret = matches.call( elem, expr ); 1493 1494 // IE 9's matchesSelector returns false on disconnected nodes 1495 if ( ret || support.disconnectedMatch || 1496 // As well, disconnected nodes are said to be in a document 1497 // fragment in IE 9 1498 elem.document && elem.document.nodeType !== 11 ) { 1499 return ret; 1500 } 1501 } catch (e) {} 1502 } 1503 1504 return Sizzle( expr, document, null, [ elem ] ).length > 0; 1505}; 1506 1507Sizzle.contains = function( context, elem ) { 1508 // Set document vars if needed 1509 if ( ( context.ownerDocument || context ) !== document ) { 1510 setDocument( context ); 1511 } 1512 return contains( context, elem ); 1513}; 1514 1515Sizzle.attr = function( elem, name ) { 1516 // Set document vars if needed 1517 if ( ( elem.ownerDocument || elem ) !== document ) { 1518 setDocument( elem ); 1519 } 1520 1521 var fn = Expr.attrHandle[ name.toLowerCase() ], 1522 // Don't get fooled by Object.prototype properties (jQuery #13807) 1523 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? 1524 fn( elem, name, !documentIsHTML ) : 1525 undefined; 1526 1527 return val !== undefined ? 1528 val : 1529 support.attributes || !documentIsHTML ? 1530 elem.getAttribute( name ) : 1531 (val = elem.getAttributeNode(name)) && val.specified ? 1532 val.value : 1533 null; 1534}; 1535 1536Sizzle.escape = function( sel ) { 1537 return (sel + "").replace( rcssescape, fcssescape ); 1538}; 1539 1540Sizzle.error = function( msg ) { 1541 throw new Error( "Syntax error, unrecognized expression: " + msg ); 1542}; 1543 1544/** 1545 * Document sorting and removing duplicates 1546 * @param {ArrayLike} results 1547 */ 1548Sizzle.uniqueSort = function( results ) { 1549 var elem, 1550 duplicates = [], 1551 j = 0, 1552 i = 0; 1553 1554 // Unless we *know* we can detect duplicates, assume their presence 1555 hasDuplicate = !support.detectDuplicates; 1556 sortInput = !support.sortStable && results.slice( 0 ); 1557 results.sort( sortOrder ); 1558 1559 if ( hasDuplicate ) { 1560 while ( (elem = results[i++]) ) { 1561 if ( elem === results[ i ] ) { 1562 j = duplicates.push( i ); 1563 } 1564 } 1565 while ( j-- ) { 1566 results.splice( duplicates[ j ], 1 ); 1567 } 1568 } 1569 1570 // Clear input after sorting to release objects 1571 // See https://github.com/jquery/sizzle/pull/225 1572 sortInput = null; 1573 1574 return results; 1575}; 1576 1577/** 1578 * Utility function for retrieving the text value of an array of DOM nodes 1579 * @param {Array|Element} elem 1580 */ 1581getText = Sizzle.getText = function( elem ) { 1582 var node, 1583 ret = "", 1584 i = 0, 1585 nodeType = elem.nodeType; 1586 1587 if ( !nodeType ) { 1588 // If no nodeType, this is expected to be an array 1589 while ( (node = elem[i++]) ) {
vendor: 11,976 bytes, lines 1590-1988
1590 // Do not traverse comment nodes 1591 ret += getText( node ); 1592 } 1593 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { 1594 // Use textContent for elements 1595 // innerText usage removed for consistency of new lines (jQuery #11153) 1596 if ( typeof elem.textContent === "string" ) { 1597 return elem.textContent; 1598 } else { 1599 // Traverse its children 1600 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 1601 ret += getText( elem ); 1602 } 1603 } 1604 } else if ( nodeType === 3 || nodeType === 4 ) { 1605 return elem.nodeValue; 1606 } 1607 // Do not include comment or processing instruction nodes 1608 1609 return ret; 1610}; 1611 1612Expr = Sizzle.selectors = { 1613 1614 // Can be adjusted by the user 1615 cacheLength: 50, 1616 1617 createPseudo: markFunction, 1618 1619 match: matchExpr, 1620 1621 attrHandle: {}, 1622 1623 find: {}, 1624 1625 relative: { 1626 ">": { dir: "parentNode", first: true }, 1627 " ": { dir: "parentNode" }, 1628 "+": { dir: "previousSibling", first: true }, 1629 "~": { dir: "previousSibling" } 1630 }, 1631 1632 preFilter: { 1633 "ATTR": function( match ) { 1634 match[1] = match[1].replace( runescape, funescape ); 1635 1636 // Move the given value to match[3] whether quoted or unquoted 1637 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); 1638 1639 if ( match[2] === "~=" ) { 1640 match[3] = " " + match[3] + " "; 1641 } 1642 1643 return match.slice( 0, 4 ); 1644 }, 1645 1646 "CHILD": function( match ) { 1647 /* matches from matchExpr["CHILD"] 1648 1 type (only|nth|...) 1649 2 what (child|of-type) 1650 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) 1651 4 xn-component of xn+y argument ([+-]?\d*n|) 1652 5 sign of xn-component 1653 6 x of xn-component 1654 7 sign of y-component 1655 8 y of y-component 1656 */ 1657 match[1] = match[1].toLowerCase(); 1658 1659 if ( match[1].slice( 0, 3 ) === "nth" ) { 1660 // nth-* requires argument 1661 if ( !match[3] ) { 1662 Sizzle.error( match[0] ); 1663 } 1664 1665 // numeric x and y parameters for Expr.filter.CHILD 1666 // remember that false/true cast respectively to 0/1 1667 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); 1668 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); 1669 1670 // other types prohibit arguments 1671 } else if ( match[3] ) { 1672 Sizzle.error( match[0] ); 1673 } 1674 1675 return match; 1676 }, 1677 1678 "PSEUDO": function( match ) { 1679 var excess, 1680 unquoted = !match[6] && match[2]; 1681 1682 if ( matchExpr["CHILD"].test( match[0] ) ) { 1683 return null; 1684 } 1685 1686 // Accept quoted arguments as-is 1687 if ( match[3] ) { 1688 match[2] = match[4] || match[5] || ""; 1689 1690 // Strip excess characters from unquoted arguments 1691 } else if ( unquoted && rpseudo.test( unquoted ) && 1692 // Get excess from tokenize (recursively) 1693 (excess = tokenize( unquoted, true )) && 1694 // advance to the next closing parenthesis 1695 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { 1696 1697 // excess is a negative index 1698 match[0] = match[0].slice( 0, excess ); 1699 match[2] = unquoted.slice( 0, excess ); 1700 } 1701 1702 // Return only captures needed by the pseudo filter method (type and argument) 1703 return match.slice( 0, 3 ); 1704 } 1705 }, 1706 1707 filter: { 1708 1709 "TAG": function( nodeNameSelector ) { 1710 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); 1711 return nodeNameSelector === "*" ? 1712 function() { return true; } : 1713 function( elem ) { 1714 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; 1715 }; 1716 }, 1717 1718 "CLASS": function( className ) { 1719 var pattern = classCache[ className + " " ]; 1720 1721 return pattern || 1722 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && 1723 classCache( className, function( elem ) { 1724 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); 1725 }); 1726 }, 1727 1728 "ATTR": function( name, operator, check ) { 1729 return function( elem ) { 1730 var result = Sizzle.attr( elem, name ); 1731 1732 if ( result == null ) { 1733 return operator === "!="; 1734 } 1735 if ( !operator ) { 1736 return true; 1737 } 1738 1739 result += ""; 1740 1741 return operator === "=" ? result === check : 1742 operator === "!=" ? result !== check : 1743 operator === "^=" ? check && result.indexOf( check ) === 0 : 1744 operator === "*=" ? check && result.indexOf( check ) > -1 : 1745 operator === "$=" ? check && result.slice( -check.length ) === check : 1746 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : 1747 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : 1748 false; 1749 }; 1750 }, 1751 1752 "CHILD": function( type, what, argument, first, last ) { 1753 var simple = type.slice( 0, 3 ) !== "nth", 1754 forward = type.slice( -4 ) !== "last", 1755 ofType = what === "of-type"; 1756 1757 return first === 1 && last === 0 ? 1758 1759 // Shortcut for :nth-*(n) 1760 function( elem ) { 1761 return !!elem.parentNode; 1762 } : 1763 1764 function( elem, context, xml ) { 1765 var cache, uniqueCache, outerCache, node, nodeIndex, start, 1766 dir = simple !== forward ? "nextSibling" : "previousSibling", 1767 parent = elem.parentNode, 1768 name = ofType && elem.nodeName.toLowerCase(), 1769 useCache = !xml && !ofType, 1770 diff = false; 1771 1772 if ( parent ) { 1773 1774 // :(first|last|only)-(child|of-type) 1775 if ( simple ) { 1776 while ( dir ) { 1777 node = elem; 1778 while ( (node = node[ dir ]) ) { 1779 if ( ofType ? 1780 node.nodeName.toLowerCase() === name : 1781 node.nodeType === 1 ) { 1782 1783 return false; 1784 } 1785 } 1786 // Reverse direction for :only-* (if we haven't yet done so) 1787 start = dir = type === "only" && !start && "nextSibling"; 1788 } 1789 return true; 1790 } 1791 1792 start = [ forward ? parent.firstChild : parent.lastChild ]; 1793 1794 // non-xml :nth-child(...) stores cache data on `parent` 1795 if ( forward && useCache ) { 1796 1797 // Seek `elem` from a previously-cached index 1798 1799 // ...in a gzip-friendly way 1800 node = parent; 1801 outerCache = node[ expando ] || (node[ expando ] = {}); 1802 1803 // Support: IE <9 only 1804 // Defend against cloned attroperties (jQuery gh-1709) 1805 uniqueCache = outerCache[ node.uniqueID ] || 1806 (outerCache[ node.uniqueID ] = {}); 1807 1808 cache = uniqueCache[ type ] || []; 1809 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 1810 diff = nodeIndex && cache[ 2 ]; 1811 node = nodeIndex && parent.childNodes[ nodeIndex ]; 1812 1813 while ( (node = ++nodeIndex && node && node[ dir ] || 1814 1815 // Fallback to seeking `elem` from the start 1816 (diff = nodeIndex = 0) || start.pop()) ) { 1817 1818 // When found, cache indexes on `parent` and break 1819 if ( node.nodeType === 1 && ++diff && node === elem ) { 1820 uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; 1821 break; 1822 } 1823 } 1824 1825 } else { 1826 // Use previously-cached element index if available 1827 if ( useCache ) { 1828 // ...in a gzip-friendly way 1829 node = elem; 1830 outerCache = node[ expando ] || (node[ expando ] = {}); 1831 1832 // Support: IE <9 only 1833 // Defend against cloned attroperties (jQuery gh-1709) 1834 uniqueCache = outerCache[ node.uniqueID ] || 1835 (outerCache[ node.uniqueID ] = {}); 1836 1837 cache = uniqueCache[ type ] || []; 1838 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 1839 diff = nodeIndex; 1840 } 1841 1842 // xml :nth-child(...) 1843 // or :nth-last-child(...) or :nth(-last)?-of-type(...) 1844 if ( diff === false ) { 1845 // Use the same loop as above to seek `elem` from the start 1846 while ( (node = ++nodeIndex && node && node[ dir ] || 1847 (diff = nodeIndex = 0) || start.pop()) ) { 1848 1849 if ( ( ofType ? 1850 node.nodeName.toLowerCase() === name : 1851 node.nodeType === 1 ) && 1852 ++diff ) { 1853 1854 // Cache the index of each encountered element 1855 if ( useCache ) { 1856 outerCache = node[ expando ] || (node[ expando ] = {}); 1857 1858 // Support: IE <9 only 1859 // Defend against cloned attroperties (jQuery gh-1709) 1860 uniqueCache = outerCache[ node.uniqueID ] || 1861 (outerCache[ node.uniqueID ] = {}); 1862 1863 uniqueCache[ type ] = [ dirruns, diff ]; 1864 } 1865 1866 if ( node === elem ) { 1867 break; 1868 } 1869 } 1870 } 1871 } 1872 } 1873 1874 // Incorporate the offset, then check against cycle size 1875 diff -= last; 1876 return diff === first || ( diff % first === 0 && diff / first >= 0 ); 1877 } 1878 }; 1879 }, 1880 1881 "PSEUDO": function( pseudo, argument ) { 1882 // pseudo-class names are case-insensitive 1883 // http://www.w3.org/TR/selectors/#pseudo-classes 1884 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters 1885 // Remember that setFilters inherits from pseudos 1886 var args, 1887 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || 1888 Sizzle.error( "unsupported pseudo: " + pseudo ); 1889 1890 // The user may use createPseudo to indicate that 1891 // arguments are needed to create the filter function 1892 // just as Sizzle does 1893 if ( fn[ expando ] ) { 1894 return fn( argument ); 1895 } 1896 1897 // But maintain support for old signatures 1898 if ( fn.length > 1 ) { 1899 args = [ pseudo, pseudo, "", argument ]; 1900 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? 1901 markFunction(function( seed, matches ) { 1902 var idx, 1903 matched = fn( seed, argument ), 1904 i = matched.length; 1905 while ( i-- ) { 1906 idx = indexOf( seed, matched[i] ); 1907 seed[ idx ] = !( matches[ idx ] = matched[i] ); 1908 } 1909 }) : 1910 function( elem ) { 1911 return fn( elem, 0, args ); 1912 }; 1913 } 1914 1915 return fn; 1916 } 1917 }, 1918 1919 pseudos: { 1920 // Potentially complex pseudos 1921 "not": markFunction(function( selector ) { 1922 // Trim the selector passed to compile 1923 // to avoid treating leading and trailing 1924 // spaces as combinators 1925 var input = [], 1926 results = [], 1927 matcher = compile( selector.replace( rtrim, "$1" ) ); 1928 1929 return matcher[ expando ] ? 1930 markFunction(function( seed, matches, context, xml ) { 1931 var elem, 1932 unmatched = matcher( seed, null, xml, [] ), 1933 i = seed.length; 1934 1935 // Match elements unmatched by `matcher` 1936 while ( i-- ) { 1937 if ( (elem = unmatched[i]) ) { 1938 seed[i] = !(matches[i] = elem); 1939 } 1940 } 1941 }) : 1942 function( elem, context, xml ) { 1943 input[0] = elem; 1944 matcher( input, null, xml, results ); 1945 // Don't keep the element (issue #299) 1946 input[0] = null; 1947 return !results.pop(); 1948 }; 1949 }), 1950 1951 "has": markFunction(function( selector ) { 1952 return function( elem ) { 1953 return Sizzle( selector, elem ).length > 0; 1954 }; 1955 }), 1956 1957 "contains": markFunction(function( text ) { 1958 text = text.replace( runescape, funescape ); 1959 return function( elem ) { 1960 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; 1961 }; 1962 }), 1963 1964 // "Whether an element is represented by a :lang() selector 1965 // is based solely on the element's language value 1966 // being equal to the identifier C, 1967 // or beginning with the identifier C immediately followed by "-". 1968 // The matching of C against the element's language value is performed case-insensitively. 1969 // The identifier C does not have to be a valid language name." 1970 // http://www.w3.org/TR/selectors/#lang-pseudo 1971 "lang": markFunction( function( lang ) { 1972 // lang value must be a valid identifier 1973 if ( !ridentifier.test(lang || "") ) { 1974 Sizzle.error( "unsupported lang: " + lang ); 1975 } 1976 lang = lang.replace( runescape, funescape ).toLowerCase(); 1977 return function( elem ) { 1978 var elemLang; 1979 do { 1980 if ( (elemLang = documentIsHTML ? 1981 elem.lang : 1982 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { 1983 1984 elemLang = elemLang.toLowerCase(); 1985 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; 1986 } 1987 } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); 1988 return false;
vendor: 23,967 bytes, lines 1989-2860
1989 }; 1990 }), 1991 1992 // Miscellaneous 1993 "target": function( elem ) { 1994 var hash = window.location && window.location.hash; 1995 return hash && hash.slice( 1 ) === elem.id; 1996 }, 1997 1998 "root": function( elem ) { 1999 return elem === docElem; 2000 }, 2001 2002 "focus": function( elem ) { 2003 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); 2004 }, 2005 2006 // Boolean properties 2007 "enabled": createDisabledPseudo( false ), 2008 "disabled": createDisabledPseudo( true ), 2009 2010 "checked": function( elem ) { 2011 // In CSS3, :checked should return both checked and selected elements 2012 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 2013 var nodeName = elem.nodeName.toLowerCase(); 2014 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); 2015 }, 2016 2017 "selected": function( elem ) { 2018 // Accessing this property makes selected-by-default 2019 // options in Safari work properly 2020 if ( elem.parentNode ) { 2021 elem.parentNode.selectedIndex; 2022 } 2023 2024 return elem.selected === true; 2025 }, 2026 2027 // Contents 2028 "empty": function( elem ) { 2029 // http://www.w3.org/TR/selectors/#empty-pseudo 2030 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), 2031 // but not by others (comment: 8; processing instruction: 7; etc.) 2032 // nodeType < 6 works because attributes (2) do not appear as children 2033 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 2034 if ( elem.nodeType < 6 ) { 2035 return false; 2036 } 2037 } 2038 return true; 2039 }, 2040 2041 "parent": function( elem ) { 2042 return !Expr.pseudos["empty"]( elem ); 2043 }, 2044 2045 // Element/input types 2046 "header": function( elem ) { 2047 return rheader.test( elem.nodeName ); 2048 }, 2049 2050 "input": function( elem ) { 2051 return rinputs.test( elem.nodeName ); 2052 }, 2053 2054 "button": function( elem ) { 2055 var name = elem.nodeName.toLowerCase(); 2056 return name === "input" && elem.type === "button" || name === "button"; 2057 }, 2058 2059 "text": function( elem ) { 2060 var attr; 2061 return elem.nodeName.toLowerCase() === "input" && 2062 elem.type === "text" && 2063 2064 // Support: IE<8 2065 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" 2066 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); 2067 }, 2068 2069 // Position-in-collection 2070 "first": createPositionalPseudo(function() { 2071 return [ 0 ]; 2072 }), 2073 2074 "last": createPositionalPseudo(function( matchIndexes, length ) { 2075 return [ length - 1 ]; 2076 }), 2077 2078 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { 2079 return [ argument < 0 ? argument + length : argument ]; 2080 }), 2081 2082 "even": createPositionalPseudo(function( matchIndexes, length ) { 2083 var i = 0; 2084 for ( ; i < length; i += 2 ) { 2085 matchIndexes.push( i ); 2086 } 2087 return matchIndexes; 2088 }), 2089 2090 "odd": createPositionalPseudo(function( matchIndexes, length ) { 2091 var i = 1; 2092 for ( ; i < length; i += 2 ) { 2093 matchIndexes.push( i ); 2094 } 2095 return matchIndexes; 2096 }), 2097 2098 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { 2099 var i = argument < 0 ? argument + length : argument; 2100 for ( ; --i >= 0; ) { 2101 matchIndexes.push( i ); 2102 } 2103 return matchIndexes; 2104 }), 2105 2106 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { 2107 var i = argument < 0 ? argument + length : argument; 2108 for ( ; ++i < length; ) { 2109 matchIndexes.push( i ); 2110 } 2111 return matchIndexes; 2112 }) 2113 } 2114}; 2115 2116Expr.pseudos["nth"] = Expr.pseudos["eq"]; 2117 2118// Add button/input type pseudos 2119for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { 2120 Expr.pseudos[ i ] = createInputPseudo( i ); 2121} 2122for ( i in { submit: true, reset: true } ) { 2123 Expr.pseudos[ i ] = createButtonPseudo( i ); 2124} 2125 2126// Easy API for creating new setFilters 2127function setFilters() {} 2128setFilters.prototype = Expr.filters = Expr.pseudos; 2129Expr.setFilters = new setFilters(); 2130 2131tokenize = Sizzle.tokenize = function( selector, parseOnly ) { 2132 var matched, match, tokens, type, 2133 soFar, groups, preFilters, 2134 cached = tokenCache[ selector + " " ]; 2135 2136 if ( cached ) { 2137 return parseOnly ? 0 : cached.slice( 0 ); 2138 } 2139 2140 soFar = selector; 2141 groups = []; 2142 preFilters = Expr.preFilter; 2143 2144 while ( soFar ) { 2145 2146 // Comma and first run 2147 if ( !matched || (match = rcomma.exec( soFar )) ) { 2148 if ( match ) { 2149 // Don't consume trailing commas as valid 2150 soFar = soFar.slice( match[0].length ) || soFar; 2151 } 2152 groups.push( (tokens = []) ); 2153 } 2154 2155 matched = false; 2156 2157 // Combinators 2158 if ( (match = rcombinators.exec( soFar )) ) { 2159 matched = match.shift(); 2160 tokens.push({ 2161 value: matched, 2162 // Cast descendant combinators to space 2163 type: match[0].replace( rtrim, " " ) 2164 }); 2165 soFar = soFar.slice( matched.length ); 2166 } 2167 2168 // Filters 2169 for ( type in Expr.filter ) { 2170 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || 2171 (match = preFilters[ type ]( match ))) ) { 2172 matched = match.shift(); 2173 tokens.push({ 2174 value: matched, 2175 type: type, 2176 matches: match 2177 }); 2178 soFar = soFar.slice( matched.length ); 2179 } 2180 } 2181 2182 if ( !matched ) { 2183 break; 2184 } 2185 } 2186 2187 // Return the length of the invalid excess 2188 // if we're just parsing 2189 // Otherwise, throw an error or return tokens 2190 return parseOnly ? 2191 soFar.length : 2192 soFar ? 2193 Sizzle.error( selector ) : 2194 // Cache the tokens 2195 tokenCache( selector, groups ).slice( 0 ); 2196}; 2197 2198function toSelector( tokens ) { 2199 var i = 0, 2200 len = tokens.length, 2201 selector = ""; 2202 for ( ; i < len; i++ ) { 2203 selector += tokens[i].value; 2204 } 2205 return selector; 2206} 2207 2208function addCombinator( matcher, combinator, base ) { 2209 var dir = combinator.dir, 2210 skip = combinator.next, 2211 key = skip || dir, 2212 checkNonElements = base && key === "parentNode", 2213 doneName = done++; 2214 2215 return combinator.first ? 2216 // Check against closest ancestor/preceding element 2217 function( elem, context, xml ) { 2218 while ( (elem = elem[ dir ]) ) { 2219 if ( elem.nodeType === 1 || checkNonElements ) { 2220 return matcher( elem, context, xml ); 2221 } 2222 } 2223 return false; 2224 } : 2225 2226 // Check against all ancestor/preceding elements 2227 function( elem, context, xml ) { 2228 var oldCache, uniqueCache, outerCache, 2229 newCache = [ dirruns, doneName ]; 2230 2231 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching 2232 if ( xml ) { 2233 while ( (elem = elem[ dir ]) ) { 2234 if ( elem.nodeType === 1 || checkNonElements ) { 2235 if ( matcher( elem, context, xml ) ) { 2236 return true; 2237 } 2238 } 2239 } 2240 } else { 2241 while ( (elem = elem[ dir ]) ) { 2242 if ( elem.nodeType === 1 || checkNonElements ) { 2243 outerCache = elem[ expando ] || (elem[ expando ] = {}); 2244 2245 // Support: IE <9 only 2246 // Defend against cloned attroperties (jQuery gh-1709) 2247 uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); 2248 2249 if ( skip && skip === elem.nodeName.toLowerCase() ) { 2250 elem = elem[ dir ] || elem; 2251 } else if ( (oldCache = uniqueCache[ key ]) && 2252 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { 2253 2254 // Assign to newCache so results back-propagate to previous elements 2255 return (newCache[ 2 ] = oldCache[ 2 ]); 2256 } else { 2257 // Reuse newcache so results back-propagate to previous elements 2258 uniqueCache[ key ] = newCache; 2259 2260 // A match means we're done; a fail means we have to keep checking 2261 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { 2262 return true; 2263 } 2264 } 2265 } 2266 } 2267 } 2268 return false; 2269 }; 2270} 2271 2272function elementMatcher( matchers ) { 2273 return matchers.length > 1 ? 2274 function( elem, context, xml ) { 2275 var i = matchers.length; 2276 while ( i-- ) { 2277 if ( !matchers[i]( elem, context, xml ) ) { 2278 return false; 2279 } 2280 } 2281 return true; 2282 } : 2283 matchers[0]; 2284} 2285 2286function multipleContexts( selector, contexts, results ) { 2287 var i = 0, 2288 len = contexts.length; 2289 for ( ; i < len; i++ ) { 2290 Sizzle( selector, contexts[i], results ); 2291 } 2292 return results; 2293} 2294 2295function condense( unmatched, map, filter, context, xml ) { 2296 var elem, 2297 newUnmatched = [], 2298 i = 0, 2299 len = unmatched.length, 2300 mapped = map != null; 2301 2302 for ( ; i < len; i++ ) { 2303 if ( (elem = unmatched[i]) ) { 2304 if ( !filter || filter( elem, context, xml ) ) { 2305 newUnmatched.push( elem ); 2306 if ( mapped ) { 2307 map.push( i ); 2308 } 2309 } 2310 } 2311 } 2312 2313 return newUnmatched; 2314} 2315 2316function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { 2317 if ( postFilter && !postFilter[ expando ] ) { 2318 postFilter = setMatcher( postFilter ); 2319 } 2320 if ( postFinder && !postFinder[ expando ] ) { 2321 postFinder = setMatcher( postFinder, postSelector ); 2322 } 2323 return markFunction(function( seed, results, context, xml ) { 2324 var temp, i, elem, 2325 preMap = [], 2326 postMap = [], 2327 preexisting = results.length, 2328 2329 // Get initial elements from seed or context 2330 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), 2331 2332 // Prefilter to get matcher input, preserving a map for seed-results synchronization 2333 matcherIn = preFilter && ( seed || !selector ) ? 2334 condense( elems, preMap, preFilter, context, xml ) : 2335 elems, 2336 2337 matcherOut = matcher ? 2338 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, 2339 postFinder || ( seed ? preFilter : preexisting || postFilter ) ? 2340 2341 // ...intermediate processing is necessary 2342 [] : 2343 2344 // ...otherwise use results directly 2345 results : 2346 matcherIn; 2347 2348 // Find primary matches 2349 if ( matcher ) { 2350 matcher( matcherIn, matcherOut, context, xml ); 2351 } 2352 2353 // Apply postFilter 2354 if ( postFilter ) { 2355 temp = condense( matcherOut, postMap ); 2356 postFilter( temp, [], context, xml ); 2357 2358 // Un-match failing elements by moving them back to matcherIn 2359 i = temp.length; 2360 while ( i-- ) { 2361 if ( (elem = temp[i]) ) { 2362 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); 2363 } 2364 } 2365 } 2366 2367 if ( seed ) { 2368 if ( postFinder || preFilter ) { 2369 if ( postFinder ) { 2370 // Get the final matcherOut by condensing this intermediate into postFinder contexts 2371 temp = []; 2372 i = matcherOut.length; 2373 while ( i-- ) { 2374 if ( (elem = matcherOut[i]) ) { 2375 // Restore matcherIn since elem is not yet a final match 2376 temp.push( (matcherIn[i] = elem) ); 2377 } 2378 } 2379 postFinder( null, (matcherOut = []), temp, xml ); 2380 } 2381 2382 // Move matched elements from seed to results to keep them synchronized 2383 i = matcherOut.length; 2384 while ( i-- ) { 2385 if ( (elem = matcherOut[i]) && 2386 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { 2387 2388 seed[temp] = !(results[temp] = elem); 2389 } 2390 } 2391 } 2392 2393 // Add elements to results, through postFinder if defined 2394 } else { 2395 matcherOut = condense( 2396 matcherOut === results ? 2397 matcherOut.splice( preexisting, matcherOut.length ) : 2398 matcherOut 2399 ); 2400 if ( postFinder ) { 2401 postFinder( null, results, matcherOut, xml ); 2402 } else { 2403 push.apply( results, matcherOut ); 2404 } 2405 } 2406 }); 2407} 2408 2409function matcherFromTokens( tokens ) { 2410 var checkContext, matcher, j, 2411 len = tokens.length, 2412 leadingRelative = Expr.relative[ tokens[0].type ], 2413 implicitRelative = leadingRelative || Expr.relative[" "], 2414 i = leadingRelative ? 1 : 0, 2415 2416 // The foundational matcher ensures that elements are reachable from top-level context(s) 2417 matchContext = addCombinator( function( elem ) { 2418 return elem === checkContext; 2419 }, implicitRelative, true ), 2420 matchAnyContext = addCombinator( function( elem ) { 2421 return indexOf( checkContext, elem ) > -1; 2422 }, implicitRelative, true ), 2423 matchers = [ function( elem, context, xml ) { 2424 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( 2425 (checkContext = context).nodeType ? 2426 matchContext( elem, context, xml ) : 2427 matchAnyContext( elem, context, xml ) ); 2428 // Avoid hanging onto element (issue #299) 2429 checkContext = null; 2430 return ret; 2431 } ]; 2432 2433 for ( ; i < len; i++ ) { 2434 if ( (matcher = Expr.relative[ tokens[i].type ]) ) { 2435 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; 2436 } else { 2437 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); 2438 2439 // Return special upon seeing a positional matcher 2440 if ( matcher[ expando ] ) { 2441 // Find the next relative operator (if any) for proper handling 2442 j = ++i; 2443 for ( ; j < len; j++ ) { 2444 if ( Expr.relative[ tokens[j].type ] ) { 2445 break; 2446 } 2447 } 2448 return setMatcher( 2449 i > 1 && elementMatcher( matchers ), 2450 i > 1 && toSelector( 2451 // If the preceding token was a descendant combinator, insert an implicit any-element `*` 2452 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) 2453 ).replace( rtrim, "$1" ), 2454 matcher, 2455 i < j && matcherFromTokens( tokens.slice( i, j ) ), 2456 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), 2457 j < len && toSelector( tokens ) 2458 ); 2459 } 2460 matchers.push( matcher ); 2461 } 2462 } 2463 2464 return elementMatcher( matchers ); 2465} 2466 2467function matcherFromGroupMatchers( elementMatchers, setMatchers ) { 2468 var bySet = setMatchers.length > 0, 2469 byElement = elementMatchers.length > 0, 2470 superMatcher = function( seed, context, xml, results, outermost ) { 2471 var elem, j, matcher, 2472 matchedCount = 0, 2473 i = "0", 2474 unmatched = seed && [], 2475 setMatched = [], 2476 contextBackup = outermostContext, 2477 // We must always have either seed elements or outermost context 2478 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), 2479 // Use integer dirruns iff this is the outermost matcher 2480 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), 2481 len = elems.length; 2482 2483 if ( outermost ) { 2484 outermostContext = context === document || context || outermost; 2485 } 2486 2487 // Add elements passing elementMatchers directly to results 2488 // Support: IE<9, Safari 2489 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id 2490 for ( ; i !== len && (elem = elems[i]) != null; i++ ) { 2491 if ( byElement && elem ) { 2492 j = 0; 2493 if ( !context && elem.ownerDocument !== document ) { 2494 setDocument( elem ); 2495 xml = !documentIsHTML; 2496 } 2497 while ( (matcher = elementMatchers[j++]) ) { 2498 if ( matcher( elem, context || document, xml) ) { 2499 results.push( elem ); 2500 break; 2501 } 2502 } 2503 if ( outermost ) { 2504 dirruns = dirrunsUnique; 2505 } 2506 } 2507 2508 // Track unmatched elements for set filters 2509 if ( bySet ) { 2510 // They will have gone through all possible matchers 2511 if ( (elem = !matcher && elem) ) { 2512 matchedCount--; 2513 } 2514 2515 // Lengthen the array for every element, matched or not 2516 if ( seed ) { 2517 unmatched.push( elem ); 2518 } 2519 } 2520 } 2521 2522 // `i` is now the count of elements visited above, and adding it to `matchedCount` 2523 // makes the latter nonnegative. 2524 matchedCount += i; 2525 2526 // Apply set filters to unmatched elements 2527 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` 2528 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have 2529 // no element matchers and no seed. 2530 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that 2531 // case, which will result in a "00" `matchedCount` that differs from `i` but is also 2532 // numerically zero. 2533 if ( bySet && i !== matchedCount ) { 2534 j = 0; 2535 while ( (matcher = setMatchers[j++]) ) { 2536 matcher( unmatched, setMatched, context, xml ); 2537 } 2538 2539 if ( seed ) { 2540 // Reintegrate element matches to eliminate the need for sorting 2541 if ( matchedCount > 0 ) { 2542 while ( i-- ) { 2543 if ( !(unmatched[i] || setMatched[i]) ) { 2544 setMatched[i] = pop.call( results ); 2545 } 2546 } 2547 } 2548 2549 // Discard index placeholder values to get only actual matches 2550 setMatched = condense( setMatched ); 2551 } 2552 2553 // Add matches to results 2554 push.apply( results, setMatched ); 2555 2556 // Seedless set matches succeeding multiple successful matchers stipulate sorting 2557 if ( outermost && !seed && setMatched.length > 0 && 2558 ( matchedCount + setMatchers.length ) > 1 ) { 2559 2560 Sizzle.uniqueSort( results ); 2561 } 2562 } 2563 2564 // Override manipulation of globals by nested matchers 2565 if ( outermost ) { 2566 dirruns = dirrunsUnique; 2567 outermostContext = contextBackup; 2568 } 2569 2570 return unmatched; 2571 }; 2572 2573 return bySet ? 2574 markFunction( superMatcher ) : 2575 superMatcher; 2576} 2577 2578compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { 2579 var i, 2580 setMatchers = [], 2581 elementMatchers = [], 2582 cached = compilerCache[ selector + " " ]; 2583 2584 if ( !cached ) { 2585 // Generate a function of recursive functions that can be used to check each element 2586 if ( !match ) { 2587 match = tokenize( selector ); 2588 } 2589 i = match.length; 2590 while ( i-- ) { 2591 cached = matcherFromTokens( match[i] ); 2592 if ( cached[ expando ] ) { 2593 setMatchers.push( cached ); 2594 } else { 2595 elementMatchers.push( cached ); 2596 } 2597 } 2598 2599 // Cache the compiled function 2600 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); 2601 2602 // Save selector and tokenization 2603 cached.selector = selector; 2604 } 2605 return cached; 2606}; 2607 2608/** 2609 * A low-level selection function that works with Sizzle's compiled 2610 * selector functions 2611 * @param {String|Function} selector A selector or a pre-compiled 2612 * selector function built with Sizzle.compile 2613 * @param {Element} context 2614 * @param {Array} [results] 2615 * @param {Array} [seed] A set of elements to match against 2616 */ 2617select = Sizzle.select = function( selector, context, results, seed ) { 2618 var i, tokens, token, type, find, 2619 compiled = typeof selector === "function" && selector, 2620 match = !seed && tokenize( (selector = compiled.selector || selector) ); 2621 2622 results = results || []; 2623 2624 // Try to minimize operations if there is only one selector in the list and no seed 2625 // (the latter of which guarantees us context) 2626 if ( match.length === 1 ) { 2627 2628 // Reduce context if the leading compound selector is an ID 2629 tokens = match[0] = match[0].slice( 0 ); 2630 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && 2631 context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) { 2632 2633 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; 2634 if ( !context ) { 2635 return results; 2636 2637 // Precompiled matchers will still verify ancestry, so step up a level 2638 } else if ( compiled ) { 2639 context = context.parentNode; 2640 } 2641 2642 selector = selector.slice( tokens.shift().value.length ); 2643 } 2644 2645 // Fetch a seed set for right-to-left matching 2646 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; 2647 while ( i-- ) { 2648 token = tokens[i]; 2649 2650 // Abort if we hit a combinator 2651 if ( Expr.relative[ (type = token.type) ] ) { 2652 break; 2653 } 2654 if ( (find = Expr.find[ type ]) ) { 2655 // Search, expanding context for leading sibling combinators 2656 if ( (seed = find( 2657 token.matches[0].replace( runescape, funescape ), 2658 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context 2659 )) ) { 2660 2661 // If seed is empty or no tokens remain, we can return early 2662 tokens.splice( i, 1 ); 2663 selector = seed.length && toSelector( tokens ); 2664 if ( !selector ) { 2665 push.apply( results, seed ); 2666 return results; 2667 } 2668 2669 break; 2670 } 2671 } 2672 } 2673 } 2674 2675 // Compile and execute a filtering function if one is not provided 2676 // Provide `match` to avoid retokenization if we modified the selector above 2677 ( compiled || compile( selector, match ) )( 2678 seed, 2679 context, 2680 !documentIsHTML, 2681 results, 2682 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context 2683 ); 2684 return results; 2685}; 2686 2687// One-time assignments 2688 2689// Sort stability 2690support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; 2691 2692// Support: Chrome 14-35+ 2693// Always assume duplicates if they aren't passed to the comparison function 2694support.detectDuplicates = !!hasDuplicate; 2695 2696// Initialize against the default document 2697setDocument(); 2698 2699// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) 2700// Detached nodes confoundingly follow *each other* 2701support.sortDetached = assert(function( el ) { 2702 // Should return 1, but returns 4 (following) 2703 return el.compareDocumentPosition( document.createElement("fieldset") ) & 1; 2704}); 2705 2706// Support: IE<8 2707// Prevent attribute/property "interpolation" 2708// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx 2709if ( !assert(function( el ) { 2710 el.innerHTML = "<a href='#'></a>"; 2711 return el.firstChild.getAttribute("href") === "#" ; 2712}) ) { 2713 addHandle( "type|href|height|width", function( elem, name, isXML ) { 2714 if ( !isXML ) { 2715 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); 2716 } 2717 }); 2718} 2719 2720// Support: IE<9 2721// Use defaultValue in place of getAttribute("value") 2722if ( !support.attributes || !assert(function( el ) { 2723 el.innerHTML = "<input/>"; 2724 el.firstChild.setAttribute( "value", "" ); 2725 return el.firstChild.getAttribute( "value" ) === ""; 2726}) ) { 2727 addHandle( "value", function( elem, name, isXML ) { 2728 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { 2729 return elem.defaultValue; 2730 } 2731 }); 2732} 2733 2734// Support: IE<9 2735// Use getAttributeNode to fetch booleans when getAttribute lies 2736if ( !assert(function( el ) { 2737 return el.getAttribute("disabled") == null; 2738}) ) { 2739 addHandle( booleans, function( elem, name, isXML ) { 2740 var val; 2741 if ( !isXML ) { 2742 return elem[ name ] === true ? name.toLowerCase() : 2743 (val = elem.getAttributeNode( name )) && val.specified ? 2744 val.value : 2745 null; 2746 } 2747 }); 2748} 2749 2750return Sizzle; 2751 2752})( window ); 2753 2754 2755 2756jQuery.find = Sizzle; 2757jQuery.expr = Sizzle.selectors; 2758 2759// Deprecated 2760jQuery.expr[ ":" ] = jQuery.expr.pseudos; 2761jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; 2762jQuery.text = Sizzle.getText; 2763jQuery.isXMLDoc = Sizzle.isXML; 2764jQuery.contains = Sizzle.contains; 2765jQuery.escapeSelector = Sizzle.escape; 2766 2767 2768 2769 2770var dir = function( elem, dir, until ) { 2771 var matched = [], 2772 truncate = until !== undefined; 2773 2774 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { 2775 if ( elem.nodeType === 1 ) { 2776 if ( truncate && jQuery( elem ).is( until ) ) { 2777 break; 2778 } 2779 matched.push( elem ); 2780 } 2781 } 2782 return matched; 2783}; 2784 2785 2786var siblings = function( n, elem ) { 2787 var matched = []; 2788 2789 for ( ; n; n = n.nextSibling ) { 2790 if ( n.nodeType === 1 && n !== elem ) { 2791 matched.push( n ); 2792 } 2793 } 2794 2795 return matched; 2796}; 2797 2798 2799var rneedsContext = jQuery.expr.match.needsContext; 2800 2801 2802 2803function nodeName( elem, name ) { 2804 2805 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); 2806 2807}; 2808var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); 2809 2810 2811 2812// Implement the identical functionality for filter and not 2813function winnow( elements, qualifier, not ) { 2814 if ( isFunction( qualifier ) ) { 2815 return jQuery.grep( elements, function( elem, i ) { 2816 return !!qualifier.call( elem, i, elem ) !== not; 2817 } ); 2818 } 2819 2820 // Single element 2821 if ( qualifier.nodeType ) { 2822 return jQuery.grep( elements, function( elem ) { 2823 return ( elem === qualifier ) !== not; 2824 } ); 2825 } 2826 2827 // Arraylike of elements (jQuery, arguments, Array) 2828 if ( typeof qualifier !== "string" ) { 2829 return jQuery.grep( elements, function( elem ) { 2830 return ( indexOf.call( qualifier, elem ) > -1 ) !== not; 2831 } ); 2832 } 2833 2834 // Filtered directly for both simple and complex selectors 2835 return jQuery.filter( qualifier, elements, not ); 2836} 2837 2838jQuery.filter = function( expr, elems, not ) { 2839 var elem = elems[ 0 ]; 2840 2841 if ( not ) { 2842 expr = ":not(" + expr + ")"; 2843 } 2844 2845 if ( elems.length === 1 && elem.nodeType === 1 ) { 2846 return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; 2847 } 2848 2849 return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { 2850 return elem.nodeType === 1; 2851 } ) ); 2852}; 2853 2854jQuery.fn.extend( { 2855 find: function( selector ) { 2856 var i, ret, 2857 len = this.length, 2858 self = this; 2859 2860 if ( typeof selector !== "string" ) {
vendor: 4,662 bytes, lines 2861-3046
2861 return this.pushStack( jQuery( selector ).filter( function() { 2862 for ( i = 0; i < len; i++ ) { 2863 if ( jQuery.contains( self[ i ], this ) ) { 2864 return true; 2865 } 2866 } 2867 } ) ); 2868 } 2869 2870 ret = this.pushStack( [] ); 2871 2872 for ( i = 0; i < len; i++ ) { 2873 jQuery.find( selector, self[ i ], ret ); 2874 } 2875 2876 return len > 1 ? jQuery.uniqueSort( ret ) : ret; 2877 }, 2878 filter: function( selector ) { 2879 return this.pushStack( winnow( this, selector || [], false ) ); 2880 }, 2881 not: function( selector ) { 2882 return this.pushStack( winnow( this, selector || [], true ) ); 2883 }, 2884 is: function( selector ) { 2885 return !!winnow( 2886 this, 2887 2888 // If this is a positional/relative selector, check membership in the returned set 2889 // so $("p:first").is("p:last") won't return true for a doc with two "p". 2890 typeof selector === "string" && rneedsContext.test( selector ) ? 2891 jQuery( selector ) : 2892 selector || [], 2893 false 2894 ).length; 2895 } 2896} ); 2897 2898 2899// Initialize a jQuery object 2900 2901 2902// A central reference to the root jQuery(document) 2903var rootjQuery, 2904 2905 // A simple way to check for HTML strings 2906 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) 2907 // Strict HTML recognition (#11290: must start with <) 2908 // Shortcut simple #id case for speed 2909 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, 2910 2911 init = jQuery.fn.init = function( selector, context, root ) { 2912 var match, elem; 2913 2914 // HANDLE: $(""), $(null), $(undefined), $(false) 2915 if ( !selector ) { 2916 return this; 2917 } 2918 2919 // Method init() accepts an alternate rootjQuery 2920 // so migrate can support jQuery.sub (gh-2101) 2921 root = root || rootjQuery; 2922 2923 // Handle HTML strings 2924 if ( typeof selector === "string" ) { 2925 if ( selector[ 0 ] === "<" && 2926 selector[ selector.length - 1 ] === ">" && 2927 selector.length >= 3 ) { 2928 2929 // Assume that strings that start and end with <> are HTML and skip the regex check 2930 match = [ null, selector, null ]; 2931 2932 } else { 2933 match = rquickExpr.exec( selector ); 2934 } 2935 2936 // Match html or make sure no context is specified for #id 2937 if ( match && ( match[ 1 ] || !context ) ) { 2938 2939 // HANDLE: $(html) -> $(array) 2940 if ( match[ 1 ] ) { 2941 context = context instanceof jQuery ? context[ 0 ] : context; 2942 2943 // Option to run scripts is true for back-compat 2944 // Intentionally let the error be thrown if parseHTML is not present 2945 jQuery.merge( this, jQuery.parseHTML( 2946 match[ 1 ], 2947 context && context.nodeType ? context.ownerDocument || context : document, 2948 true 2949 ) ); 2950 2951 // HANDLE: $(html, props) 2952 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { 2953 for ( match in context ) { 2954 2955 // Properties of context are called as methods if possible 2956 if ( isFunction( this[ match ] ) ) { 2957 this[ match ]( context[ match ] ); 2958 2959 // ...and otherwise set as attributes 2960 } else { 2961 this.attr( match, context[ match ] ); 2962 } 2963 } 2964 } 2965 2966 return this; 2967 2968 // HANDLE: $(#id) 2969 } else { 2970 elem = document.getElementById( match[ 2 ] ); 2971 2972 if ( elem ) { 2973 2974 // Inject the element directly into the jQuery object 2975 this[ 0 ] = elem; 2976 this.length = 1; 2977 } 2978 return this; 2979 } 2980 2981 // HANDLE: $(expr, $(...)) 2982 } else if ( !context || context.jquery ) { 2983 return ( context || root ).find( selector ); 2984 2985 // HANDLE: $(expr, context) 2986 // (which is just equivalent to: $(context).find(expr) 2987 } else { 2988 return this.constructor( context ).find( selector ); 2989 } 2990 2991 // HANDLE: $(DOMElement) 2992 } else if ( selector.nodeType ) { 2993 this[ 0 ] = selector; 2994 this.length = 1; 2995 return this; 2996 2997 // HANDLE: $(function) 2998 // Shortcut for document ready 2999 } else if ( isFunction( selector ) ) { 3000 return root.ready !== undefined ? 3001 root.ready( selector ) : 3002 3003 // Execute immediately if ready is not present 3004 selector( jQuery ); 3005 } 3006 3007 return jQuery.makeArray( selector, this ); 3008 }; 3009 3010// Give the init function the jQuery prototype for later instantiation 3011init.prototype = jQuery.fn; 3012 3013// Initialize central reference 3014rootjQuery = jQuery( document ); 3015 3016 3017var rparentsprev = /^(?:parents|prev(?:Until|All))/, 3018 3019 // Methods guaranteed to produce a unique set when starting from a unique set 3020 guaranteedUnique = { 3021 children: true, 3022 contents: true, 3023 next: true, 3024 prev: true 3025 }; 3026 3027jQuery.fn.extend( { 3028 has: function( target ) { 3029 var targets = jQuery( target, this ), 3030 l = targets.length; 3031 3032 return this.filter( function() { 3033 var i = 0; 3034 for ( ; i < l; i++ ) { 3035 if ( jQuery.contains( this, targets[ i ] ) ) { 3036 return true; 3037 } 3038 } 3039 } ); 3040 }, 3041 3042 closest: function( selectors, context ) { 3043 var cur, 3044 i = 0, 3045 l = this.length, 3046 matched = [],
vendor: 6,003 bytes, lines 3047-3273
3047 targets = typeof selectors !== "string" && jQuery( selectors ); 3048 3049 // Positional selectors never match, since there's no _selection_ context 3050 if ( !rneedsContext.test( selectors ) ) { 3051 for ( ; i < l; i++ ) { 3052 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { 3053 3054 // Always skip document fragments 3055 if ( cur.nodeType < 11 && ( targets ? 3056 targets.index( cur ) > -1 : 3057 3058 // Don't pass non-elements to Sizzle 3059 cur.nodeType === 1 && 3060 jQuery.find.matchesSelector( cur, selectors ) ) ) { 3061 3062 matched.push( cur ); 3063 break; 3064 } 3065 } 3066 } 3067 } 3068 3069 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); 3070 }, 3071 3072 // Determine the position of an element within the set 3073 index: function( elem ) { 3074 3075 // No argument, return index in parent 3076 if ( !elem ) { 3077 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; 3078 } 3079 3080 // Index in selector 3081 if ( typeof elem === "string" ) { 3082 return indexOf.call( jQuery( elem ), this[ 0 ] ); 3083 } 3084 3085 // Locate the position of the desired element 3086 return indexOf.call( this, 3087 3088 // If it receives a jQuery object, the first element is used 3089 elem.jquery ? elem[ 0 ] : elem 3090 ); 3091 }, 3092 3093 add: function( selector, context ) { 3094 return this.pushStack( 3095 jQuery.uniqueSort( 3096 jQuery.merge( this.get(), jQuery( selector, context ) ) 3097 ) 3098 ); 3099 }, 3100 3101 addBack: function( selector ) { 3102 return this.add( selector == null ? 3103 this.prevObject : this.prevObject.filter( selector ) 3104 ); 3105 } 3106} ); 3107 3108function sibling( cur, dir ) { 3109 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} 3110 return cur; 3111} 3112 3113jQuery.each( { 3114 parent: function( elem ) { 3115 var parent = elem.parentNode; 3116 return parent && parent.nodeType !== 11 ? parent : null; 3117 }, 3118 parents: function( elem ) { 3119 return dir( elem, "parentNode" ); 3120 }, 3121 parentsUntil: function( elem, i, until ) { 3122 return dir( elem, "parentNode", until ); 3123 }, 3124 next: function( elem ) { 3125 return sibling( elem, "nextSibling" ); 3126 }, 3127 prev: function( elem ) { 3128 return sibling( elem, "previousSibling" ); 3129 }, 3130 nextAll: function( elem ) { 3131 return dir( elem, "nextSibling" ); 3132 }, 3133 prevAll: function( elem ) { 3134 return dir( elem, "previousSibling" ); 3135 }, 3136 nextUntil: function( elem, i, until ) { 3137 return dir( elem, "nextSibling", until ); 3138 }, 3139 prevUntil: function( elem, i, until ) { 3140 return dir( elem, "previousSibling", until ); 3141 }, 3142 siblings: function( elem ) { 3143 return siblings( ( elem.parentNode || {} ).firstChild, elem ); 3144 }, 3145 children: function( elem ) { 3146 return siblings( elem.firstChild ); 3147 }, 3148 contents: function( elem ) { 3149 if ( nodeName( elem, "iframe" ) ) { 3150 return elem.contentDocument; 3151 } 3152 3153 // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only 3154 // Treat the template element as a regular one in browsers that 3155 // don't support it. 3156 if ( nodeName( elem, "template" ) ) { 3157 elem = elem.content || elem; 3158 } 3159 3160 return jQuery.merge( [], elem.childNodes ); 3161 } 3162}, function( name, fn ) { 3163 jQuery.fn[ name ] = function( until, selector ) { 3164 var matched = jQuery.map( this, fn, until ); 3165 3166 if ( name.slice( -5 ) !== "Until" ) { 3167 selector = until; 3168 } 3169 3170 if ( selector && typeof selector === "string" ) { 3171 matched = jQuery.filter( selector, matched ); 3172 } 3173 3174 if ( this.length > 1 ) { 3175 3176 // Remove duplicates 3177 if ( !guaranteedUnique[ name ] ) { 3178 jQuery.uniqueSort( matched ); 3179 } 3180 3181 // Reverse order for parents* and prev-derivatives 3182 if ( rparentsprev.test( name ) ) { 3183 matched.reverse(); 3184 } 3185 } 3186 3187 return this.pushStack( matched ); 3188 }; 3189} ); 3190var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g ); 3191 3192 3193 3194// Convert String-formatted options into Object-formatted ones 3195function createOptions( options ) { 3196 var object = {}; 3197 jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) { 3198 object[ flag ] = true; 3199 } ); 3200 return object; 3201} 3202 3203/* 3204 * Create a callback list using the following parameters: 3205 * 3206 * options: an optional list of space-separated options that will change how 3207 * the callback list behaves or a more traditional option object 3208 * 3209 * By default a callback list will act like an event callback list and can be 3210 * "fired" multiple times. 3211 * 3212 * Possible options: 3213 * 3214 * once: will ensure the callback list can only be fired once (like a Deferred) 3215 * 3216 * memory: will keep track of previous values and will call any callback added 3217 * after the list has been fired right away with the latest "memorized" 3218 * values (like a Deferred) 3219 * 3220 * unique: will ensure a callback can only be added once (no duplicate in the list) 3221 * 3222 * stopOnFalse: interrupt callings when a callback returns false 3223 * 3224 */ 3225jQuery.Callbacks = function( options ) { 3226 3227 // Convert options from String-formatted to Object-formatted if needed 3228 // (we check in cache first) 3229 options = typeof options === "string" ? 3230 createOptions( options ) : 3231 jQuery.extend( {}, options ); 3232 3233 var // Flag to know if list is currently firing 3234 firing, 3235 3236 // Last fire value for non-forgettable lists 3237 memory, 3238 3239 // Flag to know if list was already fired 3240 fired, 3241 3242 // Flag to prevent firing 3243 locked, 3244 3245 // Actual callback list 3246 list = [], 3247 3248 // Queue of execution data for repeatable lists 3249 queue = [], 3250 3251 // Index of currently firing callback (modified by add/remove as needed) 3252 firingIndex = -1, 3253 3254 // Fire callbacks 3255 fire = function() { 3256 3257 // Enforce single-firing 3258 locked = locked || options.once; 3259 3260 // Execute callbacks for all pending executions, 3261 // respecting firingIndex overrides and runtime changes 3262 fired = firing = true; 3263 for ( ; queue.length; firingIndex = -1 ) { 3264 memory = queue.shift(); 3265 while ( ++firingIndex < list.length ) { 3266 3267 // Run callback and check for early termination 3268 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && 3269 options.stopOnFalse ) { 3270 3271 // Jump to end and forget the data so .add doesn't re-fire 3272 firingIndex = list.length; 3273 memory = false;
vendor: 4,918 bytes, lines 3274-3483
3274 } 3275 } 3276 } 3277 3278 // Forget the data if we're done with it 3279 if ( !options.memory ) { 3280 memory = false; 3281 } 3282 3283 firing = false; 3284 3285 // Clean up if we're done firing for good 3286 if ( locked ) { 3287 3288 // Keep an empty list if we have data for future add calls 3289 if ( memory ) { 3290 list = []; 3291 3292 // Otherwise, this object is spent 3293 } else { 3294 list = ""; 3295 } 3296 } 3297 }, 3298 3299 // Actual Callbacks object 3300 self = { 3301 3302 // Add a callback or a collection of callbacks to the list 3303 add: function() { 3304 if ( list ) { 3305 3306 // If we have memory from a past run, we should fire after adding 3307 if ( memory && !firing ) { 3308 firingIndex = list.length - 1; 3309 queue.push( memory ); 3310 } 3311 3312 ( function add( args ) { 3313 jQuery.each( args, function( _, arg ) { 3314 if ( isFunction( arg ) ) { 3315 if ( !options.unique || !self.has( arg ) ) { 3316 list.push( arg ); 3317 } 3318 } else if ( arg && arg.length && toType( arg ) !== "string" ) { 3319 3320 // Inspect recursively 3321 add( arg ); 3322 } 3323 } ); 3324 } )( arguments ); 3325 3326 if ( memory && !firing ) { 3327 fire(); 3328 } 3329 } 3330 return this; 3331 }, 3332 3333 // Remove a callback from the list 3334 remove: function() { 3335 jQuery.each( arguments, function( _, arg ) { 3336 var index; 3337 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { 3338 list.splice( index, 1 ); 3339 3340 // Handle firing indexes 3341 if ( index <= firingIndex ) { 3342 firingIndex--; 3343 } 3344 } 3345 } ); 3346 return this; 3347 }, 3348 3349 // Check if a given callback is in the list. 3350 // If no argument is given, return whether or not list has callbacks attached. 3351 has: function( fn ) { 3352 return fn ? 3353 jQuery.inArray( fn, list ) > -1 : 3354 list.length > 0; 3355 }, 3356 3357 // Remove all callbacks from the list 3358 empty: function() { 3359 if ( list ) { 3360 list = []; 3361 } 3362 return this; 3363 }, 3364 3365 // Disable .fire and .add 3366 // Abort any current/pending executions 3367 // Clear all callbacks and values 3368 disable: function() { 3369 locked = queue = []; 3370 list = memory = ""; 3371 return this; 3372 }, 3373 disabled: function() { 3374 return !list; 3375 }, 3376 3377 // Disable .fire 3378 // Also disable .add unless we have memory (since it would have no effect) 3379 // Abort any pending executions 3380 lock: function() { 3381 locked = queue = []; 3382 if ( !memory && !firing ) { 3383 list = memory = ""; 3384 } 3385 return this; 3386 }, 3387 locked: function() { 3388 return !!locked; 3389 }, 3390 3391 // Call all callbacks with the given context and arguments 3392 fireWith: function( context, args ) { 3393 if ( !locked ) { 3394 args = args || []; 3395 args = [ context, args.slice ? args.slice() : args ]; 3396 queue.push( args ); 3397 if ( !firing ) { 3398 fire(); 3399 } 3400 } 3401 return this; 3402 }, 3403 3404 // Call all the callbacks with the given arguments 3405 fire: function() { 3406 self.fireWith( this, arguments ); 3407 return this; 3408 }, 3409 3410 // To know if the callbacks have already been called at least once 3411 fired: function() { 3412 return !!fired; 3413 } 3414 }; 3415 3416 return self; 3417}; 3418 3419 3420function Identity( v ) { 3421 return v; 3422} 3423function Thrower( ex ) { 3424 throw ex; 3425} 3426 3427function adoptValue( value, resolve, reject, noValue ) { 3428 var method; 3429 3430 try { 3431 3432 // Check for promise aspect first to privilege synchronous behavior 3433 if ( value && isFunction( ( method = value.promise ) ) ) { 3434 method.call( value ).done( resolve ).fail( reject ); 3435 3436 // Other thenables 3437 } else if ( value && isFunction( ( method = value.then ) ) ) { 3438 method.call( value, resolve, reject ); 3439 3440 // Other non-thenables 3441 } else { 3442 3443 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: 3444 // * false: [ value ].slice( 0 ) => resolve( value ) 3445 // * true: [ value ].slice( 1 ) => resolve() 3446 resolve.apply( undefined, [ value ].slice( noValue ) ); 3447 } 3448 3449 // For Promises/A+, convert exceptions into rejections 3450 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in 3451 // Deferred#then to conditionally suppress rejection. 3452 } catch ( value ) { 3453 3454 // Support: Android 4.0 only 3455 // Strict mode functions invoked without .call/.apply get global-object context 3456 reject.apply( undefined, [ value ] ); 3457 } 3458} 3459 3460jQuery.extend( { 3461 3462 Deferred: function( func ) { 3463 var tuples = [ 3464 3465 // action, add listener, callbacks, 3466 // ... .then handlers, argument index, [final state] 3467 [ "notify", "progress", jQuery.Callbacks( "memory" ), 3468 jQuery.Callbacks( "memory" ), 2 ], 3469 [ "resolve", "done", jQuery.Callbacks( "once memory" ), 3470 jQuery.Callbacks( "once memory" ), 0, "resolved" ], 3471 [ "reject", "fail", jQuery.Callbacks( "once memory" ), 3472 jQuery.Callbacks( "once memory" ), 1, "rejected" ] 3473 ], 3474 state = "pending", 3475 promise = { 3476 state: function() { 3477 return state; 3478 }, 3479 always: function() { 3480 deferred.done( arguments ).fail( arguments ); 3481 return this; 3482 }, 3483 "catch": function( fn ) {
vendor: 15,167 bytes, lines 3484-4075
3484 return promise.then( null, fn ); 3485 }, 3486 3487 // Keep pipe for back-compat 3488 pipe: function( /* fnDone, fnFail, fnProgress */ ) { 3489 var fns = arguments; 3490 3491 return jQuery.Deferred( function( newDefer ) { 3492 jQuery.each( tuples, function( i, tuple ) { 3493 3494 // Map tuples (progress, done, fail) to arguments (done, fail, progress) 3495 var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; 3496 3497 // deferred.progress(function() { bind to newDefer or newDefer.notify }) 3498 // deferred.done(function() { bind to newDefer or newDefer.resolve }) 3499 // deferred.fail(function() { bind to newDefer or newDefer.reject }) 3500 deferred[ tuple[ 1 ] ]( function() { 3501 var returned = fn && fn.apply( this, arguments ); 3502 if ( returned && isFunction( returned.promise ) ) { 3503 returned.promise() 3504 .progress( newDefer.notify ) 3505 .done( newDefer.resolve ) 3506 .fail( newDefer.reject ); 3507 } else { 3508 newDefer[ tuple[ 0 ] + "With" ]( 3509 this, 3510 fn ? [ returned ] : arguments 3511 ); 3512 } 3513 } ); 3514 } ); 3515 fns = null; 3516 } ).promise(); 3517 }, 3518 then: function( onFulfilled, onRejected, onProgress ) { 3519 var maxDepth = 0; 3520 function resolve( depth, deferred, handler, special ) { 3521 return function() { 3522 var that = this, 3523 args = arguments, 3524 mightThrow = function() { 3525 var returned, then; 3526 3527 // Support: Promises/A+ section 2.3.3.3.3 3528 // https://promisesaplus.com/#point-59 3529 // Ignore double-resolution attempts 3530 if ( depth < maxDepth ) { 3531 return; 3532 } 3533 3534 returned = handler.apply( that, args ); 3535 3536 // Support: Promises/A+ section 2.3.1 3537 // https://promisesaplus.com/#point-48 3538 if ( returned === deferred.promise() ) { 3539 throw new TypeError( "Thenable self-resolution" ); 3540 } 3541 3542 // Support: Promises/A+ sections 2.3.3.1, 3.5 3543 // https://promisesaplus.com/#point-54 3544 // https://promisesaplus.com/#point-75 3545 // Retrieve `then` only once 3546 then = returned && 3547 3548 // Support: Promises/A+ section 2.3.4 3549 // https://promisesaplus.com/#point-64 3550 // Only check objects and functions for thenability 3551 ( typeof returned === "object" || 3552 typeof returned === "function" ) && 3553 returned.then; 3554 3555 // Handle a returned thenable 3556 if ( isFunction( then ) ) { 3557 3558 // Special processors (notify) just wait for resolution 3559 if ( special ) { 3560 then.call( 3561 returned, 3562 resolve( maxDepth, deferred, Identity, special ), 3563 resolve( maxDepth, deferred, Thrower, special ) 3564 ); 3565 3566 // Normal processors (resolve) also hook into progress 3567 } else { 3568 3569 // ...and disregard older resolution values 3570 maxDepth++; 3571 3572 then.call( 3573 returned, 3574 resolve( maxDepth, deferred, Identity, special ), 3575 resolve( maxDepth, deferred, Thrower, special ), 3576 resolve( maxDepth, deferred, Identity, 3577 deferred.notifyWith ) 3578 ); 3579 } 3580 3581 // Handle all other returned values 3582 } else { 3583 3584 // Only substitute handlers pass on context 3585 // and multiple values (non-spec behavior) 3586 if ( handler !== Identity ) { 3587 that = undefined; 3588 args = [ returned ]; 3589 } 3590 3591 // Process the value(s) 3592 // Default process is resolve 3593 ( special || deferred.resolveWith )( that, args ); 3594 } 3595 }, 3596 3597 // Only normal processors (resolve) catch and reject exceptions 3598 process = special ? 3599 mightThrow : 3600 function() { 3601 try { 3602 mightThrow(); 3603 } catch ( e ) { 3604 3605 if ( jQuery.Deferred.exceptionHook ) { 3606 jQuery.Deferred.exceptionHook( e, 3607 process.stackTrace ); 3608 } 3609 3610 // Support: Promises/A+ section 2.3.3.3.4.1 3611 // https://promisesaplus.com/#point-61 3612 // Ignore post-resolution exceptions 3613 if ( depth + 1 >= maxDepth ) { 3614 3615 // Only substitute handlers pass on context 3616 // and multiple values (non-spec behavior) 3617 if ( handler !== Thrower ) { 3618 that = undefined; 3619 args = [ e ]; 3620 } 3621 3622 deferred.rejectWith( that, args ); 3623 } 3624 } 3625 }; 3626 3627 // Support: Promises/A+ section 2.3.3.3.1 3628 // https://promisesaplus.com/#point-57 3629 // Re-resolve promises immediately to dodge false rejection from 3630 // subsequent errors 3631 if ( depth ) { 3632 process(); 3633 } else { 3634 3635 // Call an optional hook to record the stack, in case of exception 3636 // since it's otherwise lost when execution goes async 3637 if ( jQuery.Deferred.getStackHook ) { 3638 process.stackTrace = jQuery.Deferred.getStackHook(); 3639 } 3640 window.setTimeout( process ); 3641 } 3642 }; 3643 } 3644 3645 return jQuery.Deferred( function( newDefer ) { 3646 3647 // progress_handlers.add( ... ) 3648 tuples[ 0 ][ 3 ].add( 3649 resolve( 3650 0, 3651 newDefer, 3652 isFunction( onProgress ) ? 3653 onProgress : 3654 Identity, 3655 newDefer.notifyWith 3656 ) 3657 ); 3658 3659 // fulfilled_handlers.add( ... ) 3660 tuples[ 1 ][ 3 ].add( 3661 resolve( 3662 0, 3663 newDefer, 3664 isFunction( onFulfilled ) ? 3665 onFulfilled : 3666 Identity 3667 ) 3668 ); 3669 3670 // rejected_handlers.add( ... ) 3671 tuples[ 2 ][ 3 ].add( 3672 resolve( 3673 0, 3674 newDefer, 3675 isFunction( onRejected ) ? 3676 onRejected : 3677 Thrower 3678 ) 3679 ); 3680 } ).promise(); 3681 }, 3682 3683 // Get a promise for this deferred 3684 // If obj is provided, the promise aspect is added to the object 3685 promise: function( obj ) { 3686 return obj != null ? jQuery.extend( obj, promise ) : promise; 3687 } 3688 }, 3689 deferred = {}; 3690 3691 // Add list-specific methods 3692 jQuery.each( tuples, function( i, tuple ) { 3693 var list = tuple[ 2 ], 3694 stateString = tuple[ 5 ]; 3695 3696 // promise.progress = list.add 3697 // promise.done = list.add 3698 // promise.fail = list.add 3699 promise[ tuple[ 1 ] ] = list.add; 3700 3701 // Handle state 3702 if ( stateString ) { 3703 list.add( 3704 function() { 3705 3706 // state = "resolved" (i.e., fulfilled) 3707 // state = "rejected" 3708 state = stateString; 3709 }, 3710 3711 // rejected_callbacks.disable 3712 // fulfilled_callbacks.disable 3713 tuples[ 3 - i ][ 2 ].disable, 3714 3715 // rejected_handlers.disable 3716 // fulfilled_handlers.disable 3717 tuples[ 3 - i ][ 3 ].disable, 3718 3719 // progress_callbacks.lock 3720 tuples[ 0 ][ 2 ].lock, 3721 3722 // progress_handlers.lock 3723 tuples[ 0 ][ 3 ].lock 3724 ); 3725 } 3726 3727 // progress_handlers.fire 3728 // fulfilled_handlers.fire 3729 // rejected_handlers.fire 3730 list.add( tuple[ 3 ].fire ); 3731 3732 // deferred.notify = function() { deferred.notifyWith(...) } 3733 // deferred.resolve = function() { deferred.resolveWith(...) } 3734 // deferred.reject = function() { deferred.rejectWith(...) } 3735 deferred[ tuple[ 0 ] ] = function() { 3736 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); 3737 return this; 3738 }; 3739 3740 // deferred.notifyWith = list.fireWith 3741 // deferred.resolveWith = list.fireWith 3742 // deferred.rejectWith = list.fireWith 3743 deferred[ tuple[ 0 ] + "With" ] = list.fireWith; 3744 } ); 3745 3746 // Make the deferred a promise 3747 promise.promise( deferred ); 3748 3749 // Call given func if any 3750 if ( func ) { 3751 func.call( deferred, deferred ); 3752 } 3753 3754 // All done! 3755 return deferred; 3756 }, 3757 3758 // Deferred helper 3759 when: function( singleValue ) { 3760 var 3761 3762 // count of uncompleted subordinates 3763 remaining = arguments.length, 3764 3765 // count of unprocessed arguments 3766 i = remaining, 3767 3768 // subordinate fulfillment data 3769 resolveContexts = Array( i ), 3770 resolveValues = slice.call( arguments ), 3771 3772 // the master Deferred 3773 master = jQuery.Deferred(), 3774 3775 // subordinate callback factory 3776 updateFunc = function( i ) { 3777 return function( value ) { 3778 resolveContexts[ i ] = this; 3779 resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; 3780 if ( !( --remaining ) ) { 3781 master.resolveWith( resolveContexts, resolveValues ); 3782 } 3783 }; 3784 }; 3785 3786 // Single- and empty arguments are adopted like Promise.resolve 3787 if ( remaining <= 1 ) { 3788 adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject, 3789 !remaining ); 3790 3791 // Use .then() to unwrap secondary thenables (cf. gh-3000) 3792 if ( master.state() === "pending" || 3793 isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { 3794 3795 return master.then(); 3796 } 3797 } 3798 3799 // Multiple arguments are aggregated like Promise.all array elements 3800 while ( i-- ) { 3801 adoptValue( resolveValues[ i ], updateFunc( i ), master.reject ); 3802 } 3803 3804 return master.promise(); 3805 } 3806} ); 3807 3808 3809// These usually indicate a programmer mistake during development, 3810// warn about them ASAP rather than swallowing them by default. 3811var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; 3812 3813jQuery.Deferred.exceptionHook = function( error, stack ) { 3814 3815 // Support: IE 8 - 9 only 3816 // Console exists when dev tools are open, which can happen at any time 3817 if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { 3818 window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack ); 3819 } 3820}; 3821 3822 3823 3824 3825jQuery.readyException = function( error ) { 3826 window.setTimeout( function() { 3827 throw error; 3828 } ); 3829}; 3830 3831 3832 3833 3834// The deferred used on DOM ready 3835var readyList = jQuery.Deferred(); 3836 3837jQuery.fn.ready = function( fn ) { 3838 3839 readyList 3840 .then( fn ) 3841 3842 // Wrap jQuery.readyException in a function so that the lookup 3843 // happens at the time of error handling instead of callback 3844 // registration. 3845 .catch( function( error ) { 3846 jQuery.readyException( error ); 3847 } ); 3848 3849 return this; 3850}; 3851 3852jQuery.extend( { 3853 3854 // Is the DOM ready to be used? Set to true once it occurs. 3855 isReady: false, 3856 3857 // A counter to track how many items to wait for before 3858 // the ready event fires. See #6781 3859 readyWait: 1, 3860 3861 // Handle when the DOM is ready 3862 ready: function( wait ) { 3863 3864 // Abort if there are pending holds or we're already ready 3865 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { 3866 return; 3867 } 3868 3869 // Remember that the DOM is ready 3870 jQuery.isReady = true; 3871 3872 // If a normal DOM Ready event fired, decrement, and wait if need be 3873 if ( wait !== true && --jQuery.readyWait > 0 ) { 3874 return; 3875 } 3876 3877 // If there are functions bound, to execute 3878 readyList.resolveWith( document, [ jQuery ] ); 3879 } 3880} ); 3881 3882jQuery.ready.then = readyList.then; 3883 3884// The ready event handler and self cleanup method 3885function completed() { 3886 document.removeEventListener( "DOMContentLoaded", completed ); 3887 window.removeEventListener( "load", completed ); 3888 jQuery.ready(); 3889} 3890 3891// Catch cases where $(document).ready() is called 3892// after the browser event has already occurred. 3893// Support: IE <=9 - 10 only 3894// Older IE sometimes signals "interactive" too soon 3895if ( document.readyState === "complete" || 3896 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { 3897 3898 // Handle it asynchronously to allow scripts the opportunity to delay ready 3899 window.setTimeout( jQuery.ready ); 3900 3901} else { 3902 3903 // Use the handy event callback 3904 document.addEventListener( "DOMContentLoaded", completed ); 3905 3906 // A fallback to window.onload, that will always work 3907 window.addEventListener( "load", completed ); 3908} 3909 3910 3911 3912 3913// Multifunctional method to get and set values of a collection 3914// The value/s can optionally be executed if it's a function 3915var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { 3916 var i = 0, 3917 len = elems.length, 3918 bulk = key == null; 3919 3920 // Sets many values 3921 if ( toType( key ) === "object" ) { 3922 chainable = true; 3923 for ( i in key ) { 3924 access( elems, fn, i, key[ i ], true, emptyGet, raw ); 3925 } 3926 3927 // Sets one value 3928 } else if ( value !== undefined ) { 3929 chainable = true; 3930 3931 if ( !isFunction( value ) ) { 3932 raw = true; 3933 } 3934 3935 if ( bulk ) { 3936 3937 // Bulk operations run against the entire set 3938 if ( raw ) { 3939 fn.call( elems, value ); 3940 fn = null; 3941 3942 // ...except when executing function values 3943 } else { 3944 bulk = fn; 3945 fn = function( elem, key, value ) { 3946 return bulk.call( jQuery( elem ), value ); 3947 }; 3948 } 3949 } 3950 3951 if ( fn ) { 3952 for ( ; i < len; i++ ) { 3953 fn( 3954 elems[ i ], key, raw ? 3955 value : 3956 value.call( elems[ i ], i, fn( elems[ i ], key ) ) 3957 ); 3958 } 3959 } 3960 } 3961 3962 if ( chainable ) { 3963 return elems; 3964 } 3965 3966 // Gets 3967 if ( bulk ) { 3968 return fn.call( elems ); 3969 } 3970 3971 return len ? fn( elems[ 0 ], key ) : emptyGet; 3972}; 3973 3974 3975// Matches dashed string for camelizing 3976var rmsPrefix = /^-ms-/, 3977 rdashAlpha = /-([a-z])/g; 3978 3979// Used by camelCase as callback to replace() 3980function fcamelCase( all, letter ) { 3981 return letter.toUpperCase(); 3982} 3983 3984// Convert dashed to camelCase; used by the css and data modules 3985// Support: IE <=9 - 11, Edge 12 - 15 3986// Microsoft forgot to hump their vendor prefix (#9572) 3987function camelCase( string ) { 3988 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); 3989} 3990var acceptData = function( owner ) { 3991 3992 // Accepts only: 3993 // - Node 3994 // - Node.ELEMENT_NODE 3995 // - Node.DOCUMENT_NODE 3996 // - Object 3997 // - Any 3998 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); 3999}; 4000 4001 4002 4003 4004function Data() { 4005 this.expando = jQuery.expando + Data.uid++; 4006} 4007 4008Data.uid = 1; 4009 4010Data.prototype = { 4011 4012 cache: function( owner ) { 4013 4014 // Check if the owner object already has a cache 4015 var value = owner[ this.expando ]; 4016 4017 // If not, create one 4018 if ( !value ) { 4019 value = {}; 4020 4021 // We can accept data for non-element nodes in modern browsers, 4022 // but we should not, see #8335. 4023 // Always return an empty object. 4024 if ( acceptData( owner ) ) { 4025 4026 // If it is a node unlikely to be stringify-ed or looped over 4027 // use plain assignment 4028 if ( owner.nodeType ) { 4029 owner[ this.expando ] = value; 4030 4031 // Otherwise secure it in a non-enumerable property 4032 // configurable must be true to allow the property to be 4033 // deleted when data is removed 4034 } else { 4035 Object.defineProperty( owner, this.expando, { 4036 value: value, 4037 configurable: true 4038 } ); 4039 } 4040 } 4041 } 4042 4043 return value; 4044 }, 4045 set: function( owner, data, value ) { 4046 var prop, 4047 cache = this.cache( owner ); 4048 4049 // Handle: [ owner, key, value ] args 4050 // Always use camelCase key (gh-2257) 4051 if ( typeof data === "string" ) { 4052 cache[ camelCase( data ) ] = value; 4053 4054 // Handle: [ owner, { properties } ] args 4055 } else { 4056 4057 // Copy the properties one-by-one to the cache object 4058 for ( prop in data ) { 4059 cache[ camelCase( prop ) ] = data[ prop ]; 4060 } 4061 } 4062 return cache; 4063 }, 4064 get: function( owner, key ) { 4065 return key === undefined ? 4066 this.cache( owner ) : 4067 4068 // Always use camelCase key (gh-2257) 4069 owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; 4070 }, 4071 access: function( owner, key, value ) { 4072 4073 // In cases where either: 4074 // 4075 // 1. No key was specified
vendor: 8,694 bytes, lines 4076-4434
4076 // 2. A string key was specified, but no value provided 4077 // 4078 // Take the "read" path and allow the get method to determine 4079 // which value to return, respectively either: 4080 // 4081 // 1. The entire cache object 4082 // 2. The data stored at the key 4083 // 4084 if ( key === undefined || 4085 ( ( key && typeof key === "string" ) && value === undefined ) ) { 4086 4087 return this.get( owner, key ); 4088 } 4089 4090 // When the key is not a string, or both a key and value 4091 // are specified, set or extend (existing objects) with either: 4092 // 4093 // 1. An object of properties 4094 // 2. A key and value 4095 // 4096 this.set( owner, key, value ); 4097 4098 // Since the "set" path can have two possible entry points 4099 // return the expected data based on which path was taken[*] 4100 return value !== undefined ? value : key; 4101 }, 4102 remove: function( owner, key ) { 4103 var i, 4104 cache = owner[ this.expando ]; 4105 4106 if ( cache === undefined ) { 4107 return; 4108 } 4109 4110 if ( key !== undefined ) { 4111 4112 // Support array or space separated string of keys 4113 if ( Array.isArray( key ) ) { 4114 4115 // If key is an array of keys... 4116 // We always set camelCase keys, so remove that. 4117 key = key.map( camelCase ); 4118 } else { 4119 key = camelCase( key ); 4120 4121 // If a key with the spaces exists, use it. 4122 // Otherwise, create an array by matching non-whitespace 4123 key = key in cache ? 4124 [ key ] : 4125 ( key.match( rnothtmlwhite ) || [] ); 4126 } 4127 4128 i = key.length; 4129 4130 while ( i-- ) { 4131 delete cache[ key[ i ] ]; 4132 } 4133 } 4134 4135 // Remove the expando if there's no more data 4136 if ( key === undefined || jQuery.isEmptyObject( cache ) ) { 4137 4138 // Support: Chrome <=35 - 45 4139 // Webkit & Blink performance suffers when deleting properties 4140 // from DOM nodes, so set to undefined instead 4141 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) 4142 if ( owner.nodeType ) { 4143 owner[ this.expando ] = undefined; 4144 } else { 4145 delete owner[ this.expando ]; 4146 } 4147 } 4148 }, 4149 hasData: function( owner ) { 4150 var cache = owner[ this.expando ]; 4151 return cache !== undefined && !jQuery.isEmptyObject( cache ); 4152 } 4153}; 4154var dataPriv = new Data(); 4155 4156var dataUser = new Data(); 4157 4158 4159 4160// Implementation Summary 4161// 4162// 1. Enforce API surface and semantic compatibility with 1.9.x branch 4163// 2. Improve the module's maintainability by reducing the storage 4164// paths to a single mechanism. 4165// 3. Use the same single mechanism to support "private" and "user" data. 4166// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) 4167// 5. Avoid exposing implementation details on user objects (eg. expando properties) 4168// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 4169 4170var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, 4171 rmultiDash = /[A-Z]/g; 4172 4173function getData( data ) { 4174 if ( data === "true" ) { 4175 return true; 4176 } 4177 4178 if ( data === "false" ) { 4179 return false; 4180 } 4181 4182 if ( data === "null" ) { 4183 return null; 4184 } 4185 4186 // Only convert to a number if it doesn't change the string 4187 if ( data === +data + "" ) { 4188 return +data; 4189 } 4190 4191 if ( rbrace.test( data ) ) { 4192 return JSON.parse( data ); 4193 } 4194 4195 return data; 4196} 4197 4198function dataAttr( elem, key, data ) { 4199 var name; 4200 4201 // If nothing was found internally, try to fetch any 4202 // data from the HTML5 data-* attribute 4203 if ( data === undefined && elem.nodeType === 1 ) { 4204 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); 4205 data = elem.getAttribute( name ); 4206 4207 if ( typeof data === "string" ) { 4208 try { 4209 data = getData( data ); 4210 } catch ( e ) {} 4211 4212 // Make sure we set the data so it isn't changed later 4213 dataUser.set( elem, key, data ); 4214 } else { 4215 data = undefined; 4216 } 4217 } 4218 return data; 4219} 4220 4221jQuery.extend( { 4222 hasData: function( elem ) { 4223 return dataUser.hasData( elem ) || dataPriv.hasData( elem ); 4224 }, 4225 4226 data: function( elem, name, data ) { 4227 return dataUser.access( elem, name, data ); 4228 }, 4229 4230 removeData: function( elem, name ) { 4231 dataUser.remove( elem, name ); 4232 }, 4233 4234 // TODO: Now that all calls to _data and _removeData have been replaced 4235 // with direct calls to dataPriv methods, these can be deprecated. 4236 _data: function( elem, name, data ) { 4237 return dataPriv.access( elem, name, data ); 4238 }, 4239 4240 _removeData: function( elem, name ) { 4241 dataPriv.remove( elem, name ); 4242 } 4243} ); 4244 4245jQuery.fn.extend( { 4246 data: function( key, value ) { 4247 var i, name, data, 4248 elem = this[ 0 ], 4249 attrs = elem && elem.attributes; 4250 4251 // Gets all values 4252 if ( key === undefined ) { 4253 if ( this.length ) { 4254 data = dataUser.get( elem ); 4255 4256 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { 4257 i = attrs.length; 4258 while ( i-- ) { 4259 4260 // Support: IE 11 only 4261 // The attrs elements can be null (#14894) 4262 if ( attrs[ i ] ) { 4263 name = attrs[ i ].name; 4264 if ( name.indexOf( "data-" ) === 0 ) { 4265 name = camelCase( name.slice( 5 ) ); 4266 dataAttr( elem, name, data[ name ] ); 4267 } 4268 } 4269 } 4270 dataPriv.set( elem, "hasDataAttrs", true ); 4271 } 4272 } 4273 4274 return data; 4275 } 4276 4277 // Sets multiple values 4278 if ( typeof key === "object" ) { 4279 return this.each( function() { 4280 dataUser.set( this, key ); 4281 } ); 4282 } 4283 4284 return access( this, function( value ) { 4285 var data; 4286 4287 // The calling jQuery object (element matches) is not empty 4288 // (and therefore has an element appears at this[ 0 ]) and the 4289 // `value` parameter was not undefined. An empty jQuery object 4290 // will result in `undefined` for elem = this[ 0 ] which will 4291 // throw an exception if an attempt to read a data cache is made. 4292 if ( elem && value === undefined ) { 4293 4294 // Attempt to get data from the cache 4295 // The key will always be camelCased in Data 4296 data = dataUser.get( elem, key ); 4297 if ( data !== undefined ) { 4298 return data; 4299 } 4300 4301 // Attempt to "discover" the data in 4302 // HTML5 custom data-* attrs 4303 data = dataAttr( elem, key ); 4304 if ( data !== undefined ) { 4305 return data; 4306 } 4307 4308 // We tried really hard, but the data doesn't exist. 4309 return; 4310 } 4311 4312 // Set the data... 4313 this.each( function() { 4314 4315 // We always store the camelCased key 4316 dataUser.set( this, key, value ); 4317 } ); 4318 }, null, value, arguments.length > 1, null, true ); 4319 }, 4320 4321 removeData: function( key ) { 4322 return this.each( function() { 4323 dataUser.remove( this, key ); 4324 } ); 4325 } 4326} ); 4327 4328 4329jQuery.extend( { 4330 queue: function( elem, type, data ) { 4331 var queue; 4332 4333 if ( elem ) { 4334 type = ( type || "fx" ) + "queue"; 4335 queue = dataPriv.get( elem, type ); 4336 4337 // Speed up dequeue by getting out quickly if this is just a lookup 4338 if ( data ) { 4339 if ( !queue || Array.isArray( data ) ) { 4340 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); 4341 } else { 4342 queue.push( data ); 4343 } 4344 } 4345 return queue || []; 4346 } 4347 }, 4348 4349 dequeue: function( elem, type ) { 4350 type = type || "fx"; 4351 4352 var queue = jQuery.queue( elem, type ), 4353 startLength = queue.length, 4354 fn = queue.shift(), 4355 hooks = jQuery._queueHooks( elem, type ), 4356 next = function() { 4357 jQuery.dequeue( elem, type ); 4358 }; 4359 4360 // If the fx queue is dequeued, always remove the progress sentinel 4361 if ( fn === "inprogress" ) { 4362 fn = queue.shift(); 4363 startLength--; 4364 } 4365 4366 if ( fn ) { 4367 4368 // Add a progress sentinel to prevent the fx queue from being 4369 // automatically dequeued 4370 if ( type === "fx" ) { 4371 queue.unshift( "inprogress" ); 4372 } 4373 4374 // Clear up the last queue stop function 4375 delete hooks.stop; 4376 fn.call( elem, next, hooks ); 4377 } 4378 4379 if ( !startLength && hooks ) { 4380 hooks.empty.fire(); 4381 } 4382 }, 4383 4384 // Not public - generate a queueHooks object, or return the current one 4385 _queueHooks: function( elem, type ) { 4386 var key = type + "queueHooks"; 4387 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { 4388 empty: jQuery.Callbacks( "once memory" ).add( function() { 4389 dataPriv.remove( elem, [ type + "queue", key ] ); 4390 } ) 4391 } ); 4392 } 4393} ); 4394 4395jQuery.fn.extend( { 4396 queue: function( type, data ) { 4397 var setter = 2; 4398 4399 if ( typeof type !== "string" ) { 4400 data = type; 4401 type = "fx"; 4402 setter--; 4403 } 4404 4405 if ( arguments.length < setter ) { 4406 return jQuery.queue( this[ 0 ], type ); 4407 } 4408 4409 return data === undefined ? 4410 this : 4411 this.each( function() { 4412 var queue = jQuery.queue( this, type, data ); 4413 4414 // Ensure a hooks for this queue 4415 jQuery._queueHooks( this, type ); 4416 4417 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { 4418 jQuery.dequeue( this, type ); 4419 } 4420 } ); 4421 }, 4422 dequeue: function( type ) { 4423 return this.each( function() { 4424 jQuery.dequeue( this, type ); 4425 } ); 4426 }, 4427 clearQueue: function( type ) { 4428 return this.queue( type || "fx", [] ); 4429 }, 4430 4431 // Get a promise resolved when queues of a certain type 4432 // are emptied (fx is the type by default) 4433 promise: function( type, obj ) { 4434 var tmp,
vendor: 37,137 bytes, lines 4435-5860
4435 count = 1, 4436 defer = jQuery.Deferred(), 4437 elements = this, 4438 i = this.length, 4439 resolve = function() { 4440 if ( !( --count ) ) { 4441 defer.resolveWith( elements, [ elements ] ); 4442 } 4443 }; 4444 4445 if ( typeof type !== "string" ) { 4446 obj = type; 4447 type = undefined; 4448 } 4449 type = type || "fx"; 4450 4451 while ( i-- ) { 4452 tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); 4453 if ( tmp && tmp.empty ) { 4454 count++; 4455 tmp.empty.add( resolve ); 4456 } 4457 } 4458 resolve(); 4459 return defer.promise( obj ); 4460 } 4461} ); 4462var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; 4463 4464var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); 4465 4466 4467var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; 4468 4469var isHiddenWithinTree = function( elem, el ) { 4470 4471 // isHiddenWithinTree might be called from jQuery#filter function; 4472 // in that case, element will be second argument 4473 elem = el || elem; 4474 4475 // Inline style trumps all 4476 return elem.style.display === "none" || 4477 elem.style.display === "" && 4478 4479 // Otherwise, check computed style 4480 // Support: Firefox <=43 - 45 4481 // Disconnected elements can have computed display: none, so first confirm that elem is 4482 // in the document. 4483 jQuery.contains( elem.ownerDocument, elem ) && 4484 4485 jQuery.css( elem, "display" ) === "none"; 4486 }; 4487 4488var swap = function( elem, options, callback, args ) { 4489 var ret, name, 4490 old = {}; 4491 4492 // Remember the old values, and insert the new ones 4493 for ( name in options ) { 4494 old[ name ] = elem.style[ name ]; 4495 elem.style[ name ] = options[ name ]; 4496 } 4497 4498 ret = callback.apply( elem, args || [] ); 4499 4500 // Revert the old values 4501 for ( name in options ) { 4502 elem.style[ name ] = old[ name ]; 4503 } 4504 4505 return ret; 4506}; 4507 4508 4509 4510 4511function adjustCSS( elem, prop, valueParts, tween ) { 4512 var adjusted, scale, 4513 maxIterations = 20, 4514 currentValue = tween ? 4515 function() { 4516 return tween.cur(); 4517 } : 4518 function() { 4519 return jQuery.css( elem, prop, "" ); 4520 }, 4521 initial = currentValue(), 4522 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), 4523 4524 // Starting value computation is required for potential unit mismatches 4525 initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && 4526 rcssNum.exec( jQuery.css( elem, prop ) ); 4527 4528 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { 4529 4530 // Support: Firefox <=54 4531 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) 4532 initial = initial / 2; 4533 4534 // Trust units reported by jQuery.css 4535 unit = unit || initialInUnit[ 3 ]; 4536 4537 // Iteratively approximate from a nonzero starting point 4538 initialInUnit = +initial || 1; 4539 4540 while ( maxIterations-- ) { 4541 4542 // Evaluate and update our best guess (doubling guesses that zero out). 4543 // Finish if the scale equals or crosses 1 (making the old*new product non-positive). 4544 jQuery.style( elem, prop, initialInUnit + unit ); 4545 if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { 4546 maxIterations = 0; 4547 } 4548 initialInUnit = initialInUnit / scale; 4549 4550 } 4551 4552 initialInUnit = initialInUnit * 2; 4553 jQuery.style( elem, prop, initialInUnit + unit ); 4554 4555 // Make sure we update the tween properties later on 4556 valueParts = valueParts || []; 4557 } 4558 4559 if ( valueParts ) { 4560 initialInUnit = +initialInUnit || +initial || 0; 4561 4562 // Apply relative offset (+=/-=) if specified 4563 adjusted = valueParts[ 1 ] ? 4564 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : 4565 +valueParts[ 2 ]; 4566 if ( tween ) { 4567 tween.unit = unit; 4568 tween.start = initialInUnit; 4569 tween.end = adjusted; 4570 } 4571 } 4572 return adjusted; 4573} 4574 4575 4576var defaultDisplayMap = {}; 4577 4578function getDefaultDisplay( elem ) { 4579 var temp, 4580 doc = elem.ownerDocument, 4581 nodeName = elem.nodeName, 4582 display = defaultDisplayMap[ nodeName ]; 4583 4584 if ( display ) { 4585 return display; 4586 } 4587 4588 temp = doc.body.appendChild( doc.createElement( nodeName ) ); 4589 display = jQuery.css( temp, "display" ); 4590 4591 temp.parentNode.removeChild( temp ); 4592 4593 if ( display === "none" ) { 4594 display = "block"; 4595 } 4596 defaultDisplayMap[ nodeName ] = display; 4597 4598 return display; 4599} 4600 4601function showHide( elements, show ) { 4602 var display, elem, 4603 values = [], 4604 index = 0, 4605 length = elements.length; 4606 4607 // Determine new display value for elements that need to change 4608 for ( ; index < length; index++ ) { 4609 elem = elements[ index ]; 4610 if ( !elem.style ) { 4611 continue; 4612 } 4613 4614 display = elem.style.display; 4615 if ( show ) { 4616 4617 // Since we force visibility upon cascade-hidden elements, an immediate (and slow) 4618 // check is required in this first loop unless we have a nonempty display value (either 4619 // inline or about-to-be-restored) 4620 if ( display === "none" ) { 4621 values[ index ] = dataPriv.get( elem, "display" ) || null; 4622 if ( !values[ index ] ) { 4623 elem.style.display = ""; 4624 } 4625 } 4626 if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { 4627 values[ index ] = getDefaultDisplay( elem ); 4628 } 4629 } else { 4630 if ( display !== "none" ) { 4631 values[ index ] = "none"; 4632 4633 // Remember what we're overwriting 4634 dataPriv.set( elem, "display", display ); 4635 } 4636 } 4637 } 4638 4639 // Set the display of the elements in a second loop to avoid constant reflow 4640 for ( index = 0; index < length; index++ ) { 4641 if ( values[ index ] != null ) { 4642 elements[ index ].style.display = values[ index ]; 4643 } 4644 } 4645 4646 return elements; 4647} 4648 4649jQuery.fn.extend( { 4650 show: function() { 4651 return showHide( this, true ); 4652 }, 4653 hide: function() { 4654 return showHide( this ); 4655 }, 4656 toggle: function( state ) { 4657 if ( typeof state === "boolean" ) { 4658 return state ? this.show() : this.hide(); 4659 } 4660 4661 return this.each( function() { 4662 if ( isHiddenWithinTree( this ) ) { 4663 jQuery( this ).show(); 4664 } else { 4665 jQuery( this ).hide(); 4666 } 4667 } ); 4668 } 4669} ); 4670var rcheckableType = ( /^(?:checkbox|radio)$/i ); 4671 4672var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i ); 4673 4674var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); 4675 4676 4677 4678// We have to close these tags to support XHTML (#13200) 4679var wrapMap = { 4680 4681 // Support: IE <=9 only 4682 option: [ 1, "<select multiple='multiple'>", "</select>" ], 4683 4684 // XHTML parsers do not magically insert elements in the 4685 // same way that tag soup parsers do. So we cannot shorten 4686 // this by omitting <tbody> or other required elements. 4687 thead: [ 1, "<table>", "</table>" ], 4688 col: [ 2, "<table><colgroup>", "</colgroup></table>" ], 4689 tr: [ 2, "<table><tbody>", "</tbody></table>" ], 4690 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], 4691 4692 _default: [ 0, "", "" ] 4693}; 4694 4695// Support: IE <=9 only 4696wrapMap.optgroup = wrapMap.option; 4697 4698wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; 4699wrapMap.th = wrapMap.td; 4700 4701 4702function getAll( context, tag ) { 4703 4704 // Support: IE <=9 - 11 only 4705 // Use typeof to avoid zero-argument method invocation on host objects (#15151) 4706 var ret; 4707 4708 if ( typeof context.getElementsByTagName !== "undefined" ) { 4709 ret = context.getElementsByTagName( tag || "*" ); 4710 4711 } else if ( typeof context.querySelectorAll !== "undefined" ) { 4712 ret = context.querySelectorAll( tag || "*" ); 4713 4714 } else { 4715 ret = []; 4716 } 4717 4718 if ( tag === undefined || tag && nodeName( context, tag ) ) { 4719 return jQuery.merge( [ context ], ret ); 4720 } 4721 4722 return ret; 4723} 4724 4725 4726// Mark scripts as having already been evaluated 4727function setGlobalEval( elems, refElements ) { 4728 var i = 0, 4729 l = elems.length; 4730 4731 for ( ; i < l; i++ ) { 4732 dataPriv.set( 4733 elems[ i ], 4734 "globalEval", 4735 !refElements || dataPriv.get( refElements[ i ], "globalEval" ) 4736 ); 4737 } 4738} 4739 4740 4741var rhtml = /<|&#?\w+;/; 4742 4743function buildFragment( elems, context, scripts, selection, ignored ) { 4744 var elem, tmp, tag, wrap, contains, j, 4745 fragment = context.createDocumentFragment(), 4746 nodes = [], 4747 i = 0, 4748 l = elems.length; 4749 4750 for ( ; i < l; i++ ) { 4751 elem = elems[ i ]; 4752 4753 if ( elem || elem === 0 ) { 4754 4755 // Add nodes directly 4756 if ( toType( elem ) === "object" ) { 4757 4758 // Support: Android <=4.0 only, PhantomJS 1 only 4759 // push.apply(_, arraylike) throws on ancient WebKit 4760 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); 4761 4762 // Convert non-html into a text node 4763 } else if ( !rhtml.test( elem ) ) { 4764 nodes.push( context.createTextNode( elem ) ); 4765 4766 // Convert html into DOM nodes 4767 } else { 4768 tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); 4769 4770 // Deserialize a standard representation 4771 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); 4772 wrap = wrapMap[ tag ] || wrapMap._default; 4773 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; 4774 4775 // Descend through wrappers to the right content 4776 j = wrap[ 0 ]; 4777 while ( j-- ) { 4778 tmp = tmp.lastChild; 4779 } 4780 4781 // Support: Android <=4.0 only, PhantomJS 1 only 4782 // push.apply(_, arraylike) throws on ancient WebKit 4783 jQuery.merge( nodes, tmp.childNodes ); 4784 4785 // Remember the top-level container 4786 tmp = fragment.firstChild; 4787 4788 // Ensure the created nodes are orphaned (#12392) 4789 tmp.textContent = ""; 4790 } 4791 } 4792 } 4793 4794 // Remove wrapper from fragment 4795 fragment.textContent = ""; 4796 4797 i = 0; 4798 while ( ( elem = nodes[ i++ ] ) ) { 4799 4800 // Skip elements already in the context collection (trac-4087) 4801 if ( selection && jQuery.inArray( elem, selection ) > -1 ) { 4802 if ( ignored ) { 4803 ignored.push( elem ); 4804 } 4805 continue; 4806 } 4807 4808 contains = jQuery.contains( elem.ownerDocument, elem ); 4809 4810 // Append to fragment 4811 tmp = getAll( fragment.appendChild( elem ), "script" ); 4812 4813 // Preserve script evaluation history 4814 if ( contains ) { 4815 setGlobalEval( tmp ); 4816 } 4817 4818 // Capture executables 4819 if ( scripts ) { 4820 j = 0; 4821 while ( ( elem = tmp[ j++ ] ) ) { 4822 if ( rscriptType.test( elem.type || "" ) ) { 4823 scripts.push( elem ); 4824 } 4825 } 4826 } 4827 } 4828 4829 return fragment; 4830} 4831 4832 4833( function() { 4834 var fragment = document.createDocumentFragment(), 4835 div = fragment.appendChild( document.createElement( "div" ) ), 4836 input = document.createElement( "input" ); 4837 4838 // Support: Android 4.0 - 4.3 only 4839 // Check state lost if the name is set (#11217) 4840 // Support: Windows Web Apps (WWA) 4841 // `name` and `type` must use .setAttribute for WWA (#14901) 4842 input.setAttribute( "type", "radio" ); 4843 input.setAttribute( "checked", "checked" ); 4844 input.setAttribute( "name", "t" ); 4845 4846 div.appendChild( input ); 4847 4848 // Support: Android <=4.1 only 4849 // Older WebKit doesn't clone checked state correctly in fragments 4850 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; 4851 4852 // Support: IE <=11 only 4853 // Make sure textarea (and checkbox) defaultValue is properly cloned 4854 div.innerHTML = "<textarea>x</textarea>"; 4855 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; 4856} )(); 4857var documentElement = document.documentElement; 4858 4859 4860 4861var 4862 rkeyEvent = /^key/, 4863 rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, 4864 rtypenamespace = /^([^.]*)(?:\.(.+)|)/; 4865 4866function returnTrue() { 4867 return true; 4868} 4869 4870function returnFalse() { 4871 return false; 4872} 4873 4874// Support: IE <=9 only 4875// See #13393 for more info 4876function safeActiveElement() { 4877 try { 4878 return document.activeElement; 4879 } catch ( err ) { } 4880} 4881 4882function on( elem, types, selector, data, fn, one ) { 4883 var origFn, type; 4884 4885 // Types can be a map of types/handlers 4886 if ( typeof types === "object" ) { 4887 4888 // ( types-Object, selector, data ) 4889 if ( typeof selector !== "string" ) { 4890 4891 // ( types-Object, data ) 4892 data = data || selector; 4893 selector = undefined; 4894 } 4895 for ( type in types ) { 4896 on( elem, type, selector, data, types[ type ], one ); 4897 } 4898 return elem; 4899 } 4900 4901 if ( data == null && fn == null ) { 4902 4903 // ( types, fn ) 4904 fn = selector; 4905 data = selector = undefined; 4906 } else if ( fn == null ) { 4907 if ( typeof selector === "string" ) { 4908 4909 // ( types, selector, fn ) 4910 fn = data; 4911 data = undefined; 4912 } else { 4913 4914 // ( types, data, fn ) 4915 fn = data; 4916 data = selector; 4917 selector = undefined; 4918 } 4919 } 4920 if ( fn === false ) { 4921 fn = returnFalse; 4922 } else if ( !fn ) { 4923 return elem; 4924 } 4925 4926 if ( one === 1 ) { 4927 origFn = fn; 4928 fn = function( event ) { 4929 4930 // Can use an empty set, since event contains the info 4931 jQuery().off( event ); 4932 return origFn.apply( this, arguments ); 4933 }; 4934 4935 // Use same guid so caller can remove using origFn 4936 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); 4937 } 4938 return elem.each( function() { 4939 jQuery.event.add( this, types, fn, data, selector ); 4940 } ); 4941} 4942 4943/* 4944 * Helper functions for managing events -- not part of the public interface. 4945 * Props to Dean Edwards' addEvent library for many of the ideas. 4946 */ 4947jQuery.event = { 4948 4949 global: {}, 4950 4951 add: function( elem, types, handler, data, selector ) { 4952 4953 var handleObjIn, eventHandle, tmp, 4954 events, t, handleObj, 4955 special, handlers, type, namespaces, origType, 4956 elemData = dataPriv.get( elem ); 4957 4958 // Don't attach events to noData or text/comment nodes (but allow plain objects) 4959 if ( !elemData ) { 4960 return; 4961 } 4962 4963 // Caller can pass in an object of custom data in lieu of the handler 4964 if ( handler.handler ) { 4965 handleObjIn = handler; 4966 handler = handleObjIn.handler; 4967 selector = handleObjIn.selector; 4968 } 4969 4970 // Ensure that invalid selectors throw exceptions at attach time 4971 // Evaluate against documentElement in case elem is a non-element node (e.g., document) 4972 if ( selector ) { 4973 jQuery.find.matchesSelector( documentElement, selector ); 4974 } 4975 4976 // Make sure that the handler has a unique ID, used to find/remove it later 4977 if ( !handler.guid ) { 4978 handler.guid = jQuery.guid++; 4979 } 4980 4981 // Init the element's event structure and main handler, if this is the first 4982 if ( !( events = elemData.events ) ) { 4983 events = elemData.events = {}; 4984 } 4985 if ( !( eventHandle = elemData.handle ) ) { 4986 eventHandle = elemData.handle = function( e ) { 4987 4988 // Discard the second event of a jQuery.event.trigger() and 4989 // when an event is called after a page has unloaded 4990 return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? 4991 jQuery.event.dispatch.apply( elem, arguments ) : undefined; 4992 }; 4993 } 4994 4995 // Handle multiple events separated by a space 4996 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; 4997 t = types.length; 4998 while ( t-- ) { 4999 tmp = rtypenamespace.exec( types[ t ] ) || []; 5000 type = origType = tmp[ 1 ]; 5001 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 5002 5003 // There *must* be a type, no attaching namespace-only handlers 5004 if ( !type ) { 5005 continue; 5006 } 5007 5008 // If event changes its type, use the special event handlers for the changed type 5009 special = jQuery.event.special[ type ] || {}; 5010 5011 // If selector defined, determine special event api type, otherwise given type 5012 type = ( selector ? special.delegateType : special.bindType ) || type; 5013 5014 // Update special based on newly reset type 5015 special = jQuery.event.special[ type ] || {}; 5016 5017 // handleObj is passed to all event handlers 5018 handleObj = jQuery.extend( { 5019 type: type, 5020 origType: origType, 5021 data: data, 5022 handler: handler, 5023 guid: handler.guid, 5024 selector: selector, 5025 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), 5026 namespace: namespaces.join( "." ) 5027 }, handleObjIn ); 5028 5029 // Init the event handler queue if we're the first 5030 if ( !( handlers = events[ type ] ) ) { 5031 handlers = events[ type ] = []; 5032 handlers.delegateCount = 0; 5033 5034 // Only use addEventListener if the special events handler returns false 5035 if ( !special.setup || 5036 special.setup.call( elem, data, namespaces, eventHandle ) === false ) { 5037 5038 if ( elem.addEventListener ) { 5039 elem.addEventListener( type, eventHandle ); 5040 } 5041 } 5042 } 5043 5044 if ( special.add ) { 5045 special.add.call( elem, handleObj ); 5046 5047 if ( !handleObj.handler.guid ) { 5048 handleObj.handler.guid = handler.guid; 5049 } 5050 } 5051 5052 // Add to the element's handler list, delegates in front 5053 if ( selector ) { 5054 handlers.splice( handlers.delegateCount++, 0, handleObj ); 5055 } else { 5056 handlers.push( handleObj ); 5057 } 5058 5059 // Keep track of which events have ever been used, for event optimization 5060 jQuery.event.global[ type ] = true; 5061 } 5062 5063 }, 5064 5065 // Detach an event or set of events from an element 5066 remove: function( elem, types, handler, selector, mappedTypes ) { 5067 5068 var j, origCount, tmp, 5069 events, t, handleObj, 5070 special, handlers, type, namespaces, origType, 5071 elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); 5072 5073 if ( !elemData || !( events = elemData.events ) ) { 5074 return; 5075 } 5076 5077 // Once for each type.namespace in types; type may be omitted 5078 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; 5079 t = types.length; 5080 while ( t-- ) { 5081 tmp = rtypenamespace.exec( types[ t ] ) || []; 5082 type = origType = tmp[ 1 ]; 5083 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 5084 5085 // Unbind all events (on this namespace, if provided) for the element 5086 if ( !type ) { 5087 for ( type in events ) { 5088 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); 5089 } 5090 continue; 5091 } 5092 5093 special = jQuery.event.special[ type ] || {}; 5094 type = ( selector ? special.delegateType : special.bindType ) || type; 5095 handlers = events[ type ] || []; 5096 tmp = tmp[ 2 ] && 5097 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); 5098 5099 // Remove matching events 5100 origCount = j = handlers.length; 5101 while ( j-- ) { 5102 handleObj = handlers[ j ]; 5103 5104 if ( ( mappedTypes || origType === handleObj.origType ) && 5105 ( !handler || handler.guid === handleObj.guid ) && 5106 ( !tmp || tmp.test( handleObj.namespace ) ) && 5107 ( !selector || selector === handleObj.selector || 5108 selector === "**" && handleObj.selector ) ) { 5109 handlers.splice( j, 1 ); 5110 5111 if ( handleObj.selector ) { 5112 handlers.delegateCount--; 5113 } 5114 if ( special.remove ) { 5115 special.remove.call( elem, handleObj ); 5116 } 5117 } 5118 } 5119 5120 // Remove generic event handler if we removed something and no more handlers exist 5121 // (avoids potential for endless recursion during removal of special event handlers) 5122 if ( origCount && !handlers.length ) { 5123 if ( !special.teardown || 5124 special.teardown.call( elem, namespaces, elemData.handle ) === false ) { 5125 5126 jQuery.removeEvent( elem, type, elemData.handle ); 5127 } 5128 5129 delete events[ type ]; 5130 } 5131 } 5132 5133 // Remove data and the expando if it's no longer used 5134 if ( jQuery.isEmptyObject( events ) ) { 5135 dataPriv.remove( elem, "handle events" ); 5136 } 5137 }, 5138 5139 dispatch: function( nativeEvent ) { 5140 5141 // Make a writable jQuery.Event from the native event object 5142 var event = jQuery.event.fix( nativeEvent ); 5143 5144 var i, j, ret, matched, handleObj, handlerQueue, 5145 args = new Array( arguments.length ), 5146 handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [], 5147 special = jQuery.event.special[ event.type ] || {}; 5148 5149 // Use the fix-ed jQuery.Event rather than the (read-only) native event 5150 args[ 0 ] = event; 5151 5152 for ( i = 1; i < arguments.length; i++ ) { 5153 args[ i ] = arguments[ i ]; 5154 } 5155 5156 event.delegateTarget = this; 5157 5158 // Call the preDispatch hook for the mapped type, and let it bail if desired 5159 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { 5160 return; 5161 } 5162 5163 // Determine handlers 5164 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); 5165 5166 // Run delegates first; they may want to stop propagation beneath us 5167 i = 0; 5168 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { 5169 event.currentTarget = matched.elem; 5170 5171 j = 0; 5172 while ( ( handleObj = matched.handlers[ j++ ] ) && 5173 !event.isImmediatePropagationStopped() ) { 5174 5175 // Triggered event must either 1) have no namespace, or 2) have namespace(s) 5176 // a subset or equal to those in the bound event (both can have no namespace). 5177 if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) { 5178 5179 event.handleObj = handleObj; 5180 event.data = handleObj.data; 5181 5182 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || 5183 handleObj.handler ).apply( matched.elem, args ); 5184 5185 if ( ret !== undefined ) { 5186 if ( ( event.result = ret ) === false ) { 5187 event.preventDefault(); 5188 event.stopPropagation(); 5189 } 5190 } 5191 } 5192 } 5193 } 5194 5195 // Call the postDispatch hook for the mapped type 5196 if ( special.postDispatch ) { 5197 special.postDispatch.call( this, event ); 5198 } 5199 5200 return event.result; 5201 }, 5202 5203 handlers: function( event, handlers ) { 5204 var i, handleObj, sel, matchedHandlers, matchedSelectors, 5205 handlerQueue = [], 5206 delegateCount = handlers.delegateCount, 5207 cur = event.target; 5208 5209 // Find delegate handlers 5210 if ( delegateCount && 5211 5212 // Support: IE <=9 5213 // Black-hole SVG <use> instance trees (trac-13180) 5214 cur.nodeType && 5215 5216 // Support: Firefox <=42 5217 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861) 5218 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click 5219 // Support: IE 11 only 5220 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343) 5221 !( event.type === "click" && event.button >= 1 ) ) { 5222 5223 for ( ; cur !== this; cur = cur.parentNode || this ) { 5224 5225 // Don't check non-elements (#13208) 5226 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) 5227 if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) { 5228 matchedHandlers = []; 5229 matchedSelectors = {}; 5230 for ( i = 0; i < delegateCount; i++ ) { 5231 handleObj = handlers[ i ]; 5232 5233 // Don't conflict with Object.prototype properties (#13203) 5234 sel = handleObj.selector + " "; 5235 5236 if ( matchedSelectors[ sel ] === undefined ) { 5237 matchedSelectors[ sel ] = handleObj.needsContext ? 5238 jQuery( sel, this ).index( cur ) > -1 : 5239 jQuery.find( sel, this, null, [ cur ] ).length; 5240 } 5241 if ( matchedSelectors[ sel ] ) { 5242 matchedHandlers.push( handleObj ); 5243 } 5244 } 5245 if ( matchedHandlers.length ) { 5246 handlerQueue.push( { elem: cur, handlers: matchedHandlers } ); 5247 } 5248 } 5249 } 5250 } 5251 5252 // Add the remaining (directly-bound) handlers 5253 cur = this; 5254 if ( delegateCount < handlers.length ) { 5255 handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } ); 5256 } 5257 5258 return handlerQueue; 5259 }, 5260 5261 addProp: function( name, hook ) { 5262 Object.defineProperty( jQuery.Event.prototype, name, { 5263 enumerable: true, 5264 configurable: true, 5265 5266 get: isFunction( hook ) ? 5267 function() { 5268 if ( this.originalEvent ) { 5269 return hook( this.originalEvent ); 5270 } 5271 } : 5272 function() { 5273 if ( this.originalEvent ) { 5274 return this.originalEvent[ name ]; 5275 } 5276 }, 5277 5278 set: function( value ) { 5279 Object.defineProperty( this, name, { 5280 enumerable: true, 5281 configurable: true, 5282 writable: true, 5283 value: value 5284 } ); 5285 } 5286 } ); 5287 }, 5288 5289 fix: function( originalEvent ) { 5290 return originalEvent[ jQuery.expando ] ? 5291 originalEvent : 5292 new jQuery.Event( originalEvent ); 5293 }, 5294 5295 special: { 5296 load: { 5297 5298 // Prevent triggered image.load events from bubbling to window.load 5299 noBubble: true 5300 }, 5301 focus: { 5302 5303 // Fire native event if possible so blur/focus sequence is correct 5304 trigger: function() { 5305 if ( this !== safeActiveElement() && this.focus ) { 5306 this.focus(); 5307 return false; 5308 } 5309 }, 5310 delegateType: "focusin" 5311 }, 5312 blur: { 5313 trigger: function() { 5314 if ( this === safeActiveElement() && this.blur ) { 5315 this.blur(); 5316 return false; 5317 } 5318 }, 5319 delegateType: "focusout" 5320 }, 5321 click: { 5322 5323 // For checkbox, fire native event so checked state will be right 5324 trigger: function() { 5325 if ( this.type === "checkbox" && this.click && nodeName( this, "input" ) ) { 5326 this.click(); 5327 return false; 5328 } 5329 }, 5330 5331 // For cross-browser consistency, don't fire native .click() on links 5332 _default: function( event ) { 5333 return nodeName( event.target, "a" ); 5334 } 5335 }, 5336 5337 beforeunload: { 5338 postDispatch: function( event ) { 5339 5340 // Support: Firefox 20+ 5341 // Firefox doesn't alert if the returnValue field is not set. 5342 if ( event.result !== undefined && event.originalEvent ) { 5343 event.originalEvent.returnValue = event.result; 5344 } 5345 } 5346 } 5347 } 5348}; 5349 5350jQuery.removeEvent = function( elem, type, handle ) { 5351 5352 // This "if" is needed for plain objects 5353 if ( elem.removeEventListener ) { 5354 elem.removeEventListener( type, handle ); 5355 } 5356}; 5357 5358jQuery.Event = function( src, props ) { 5359 5360 // Allow instantiation without the 'new' keyword 5361 if ( !( this instanceof jQuery.Event ) ) { 5362 return new jQuery.Event( src, props ); 5363 } 5364 5365 // Event object 5366 if ( src && src.type ) { 5367 this.originalEvent = src; 5368 this.type = src.type; 5369 5370 // Events bubbling up the document may have been marked as prevented 5371 // by a handler lower down the tree; reflect the correct value. 5372 this.isDefaultPrevented = src.defaultPrevented || 5373 src.defaultPrevented === undefined && 5374 5375 // Support: Android <=2.3 only 5376 src.returnValue === false ? 5377 returnTrue : 5378 returnFalse; 5379 5380 // Create target properties 5381 // Support: Safari <=6 - 7 only 5382 // Target should not be a text node (#504, #13143) 5383 this.target = ( src.target && src.target.nodeType === 3 ) ? 5384 src.target.parentNode : 5385 src.target; 5386 5387 this.currentTarget = src.currentTarget; 5388 this.relatedTarget = src.relatedTarget; 5389 5390 // Event type 5391 } else { 5392 this.type = src; 5393 } 5394 5395 // Put explicitly provided properties onto the event object 5396 if ( props ) { 5397 jQuery.extend( this, props ); 5398 } 5399 5400 // Create a timestamp if incoming event doesn't have one 5401 this.timeStamp = src && src.timeStamp || Date.now(); 5402 5403 // Mark it as fixed 5404 this[ jQuery.expando ] = true; 5405}; 5406 5407// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding 5408// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html 5409jQuery.Event.prototype = { 5410 constructor: jQuery.Event, 5411 isDefaultPrevented: returnFalse, 5412 isPropagationStopped: returnFalse, 5413 isImmediatePropagationStopped: returnFalse, 5414 isSimulated: false, 5415 5416 preventDefault: function() { 5417 var e = this.originalEvent; 5418 5419 this.isDefaultPrevented = returnTrue; 5420 5421 if ( e && !this.isSimulated ) { 5422 e.preventDefault(); 5423 } 5424 }, 5425 stopPropagation: function() { 5426 var e = this.originalEvent; 5427 5428 this.isPropagationStopped = returnTrue; 5429 5430 if ( e && !this.isSimulated ) { 5431 e.stopPropagation(); 5432 } 5433 }, 5434 stopImmediatePropagation: function() { 5435 var e = this.originalEvent; 5436 5437 this.isImmediatePropagationStopped = returnTrue; 5438 5439 if ( e && !this.isSimulated ) { 5440 e.stopImmediatePropagation(); 5441 } 5442 5443 this.stopPropagation(); 5444 } 5445}; 5446 5447// Includes all common event props including KeyEvent and MouseEvent specific props 5448jQuery.each( { 5449 altKey: true, 5450 bubbles: true, 5451 cancelable: true, 5452 changedTouches: true, 5453 ctrlKey: true, 5454 detail: true, 5455 eventPhase: true, 5456 metaKey: true, 5457 pageX: true, 5458 pageY: true, 5459 shiftKey: true, 5460 view: true, 5461 "char": true, 5462 charCode: true, 5463 key: true, 5464 keyCode: true, 5465 button: true, 5466 buttons: true, 5467 clientX: true, 5468 clientY: true, 5469 offsetX: true, 5470 offsetY: true, 5471 pointerId: true, 5472 pointerType: true, 5473 screenX: true, 5474 screenY: true, 5475 targetTouches: true, 5476 toElement: true, 5477 touches: true, 5478 5479 which: function( event ) { 5480 var button = event.button; 5481 5482 // Add which for key events 5483 if ( event.which == null && rkeyEvent.test( event.type ) ) { 5484 return event.charCode != null ? event.charCode : event.keyCode; 5485 } 5486 5487 // Add which for click: 1 === left; 2 === middle; 3 === right 5488 if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) { 5489 if ( button & 1 ) { 5490 return 1; 5491 } 5492 5493 if ( button & 2 ) { 5494 return 3; 5495 } 5496 5497 if ( button & 4 ) { 5498 return 2; 5499 } 5500 5501 return 0; 5502 } 5503 5504 return event.which; 5505 } 5506}, jQuery.event.addProp ); 5507 5508// Create mouseenter/leave events using mouseover/out and event-time checks 5509// so that event delegation works in jQuery. 5510// Do the same for pointerenter/pointerleave and pointerover/pointerout 5511// 5512// Support: Safari 7 only 5513// Safari sends mouseenter too often; see: 5514// https://bugs.chromium.org/p/chromium/issues/detail?id=470258 5515// for the description of the bug (it existed in older Chrome versions as well). 5516jQuery.each( { 5517 mouseenter: "mouseover", 5518 mouseleave: "mouseout", 5519 pointerenter: "pointerover", 5520 pointerleave: "pointerout" 5521}, function( orig, fix ) { 5522 jQuery.event.special[ orig ] = { 5523 delegateType: fix, 5524 bindType: fix, 5525 5526 handle: function( event ) { 5527 var ret, 5528 target = this, 5529 related = event.relatedTarget, 5530 handleObj = event.handleObj; 5531 5532 // For mouseenter/leave call the handler if related is outside the target. 5533 // NB: No relatedTarget if the mouse left/entered the browser window 5534 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { 5535 event.type = handleObj.origType; 5536 ret = handleObj.handler.apply( this, arguments ); 5537 event.type = fix; 5538 } 5539 return ret; 5540 } 5541 }; 5542} ); 5543 5544jQuery.fn.extend( { 5545 5546 on: function( types, selector, data, fn ) { 5547 return on( this, types, selector, data, fn ); 5548 }, 5549 one: function( types, selector, data, fn ) { 5550 return on( this, types, selector, data, fn, 1 ); 5551 }, 5552 off: function( types, selector, fn ) { 5553 var handleObj, type; 5554 if ( types && types.preventDefault && types.handleObj ) { 5555 5556 // ( event ) dispatched jQuery.Event 5557 handleObj = types.handleObj; 5558 jQuery( types.delegateTarget ).off( 5559 handleObj.namespace ? 5560 handleObj.origType + "." + handleObj.namespace : 5561 handleObj.origType, 5562 handleObj.selector, 5563 handleObj.handler 5564 ); 5565 return this; 5566 } 5567 if ( typeof types === "object" ) { 5568 5569 // ( types-object [, selector] ) 5570 for ( type in types ) { 5571 this.off( type, selector, types[ type ] ); 5572 } 5573 return this; 5574 } 5575 if ( selector === false || typeof selector === "function" ) { 5576 5577 // ( types [, fn] ) 5578 fn = selector; 5579 selector = undefined; 5580 } 5581 if ( fn === false ) { 5582 fn = returnFalse; 5583 } 5584 return this.each( function() { 5585 jQuery.event.remove( this, types, fn, selector ); 5586 } ); 5587 } 5588} ); 5589 5590 5591var 5592 5593 /* eslint-disable max-len */ 5594 5595 // See https://github.com/eslint/eslint/issues/3229 5596 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi, 5597 5598 /* eslint-enable */ 5599 5600 // Support: IE <=10 - 11, Edge 12 - 13 only 5601 // In IE/Edge using regex groups here causes severe slowdowns. 5602 // See https://connect.microsoft.com/IE/feedback/details/1736512/ 5603 rnoInnerhtml = /<script|<style|<link/i, 5604 5605 // checked="checked" or checked 5606 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, 5607 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; 5608 5609// Prefer a tbody over its parent table for containing new rows 5610function manipulationTarget( elem, content ) { 5611 if ( nodeName( elem, "table" ) && 5612 nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { 5613 5614 return jQuery( elem ).children( "tbody" )[ 0 ] || elem; 5615 } 5616 5617 return elem; 5618} 5619 5620// Replace/restore the type attribute of script elements for safe DOM manipulation 5621function disableScript( elem ) { 5622 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; 5623 return elem; 5624} 5625function restoreScript( elem ) { 5626 if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) { 5627 elem.type = elem.type.slice( 5 ); 5628 } else { 5629 elem.removeAttribute( "type" ); 5630 } 5631 5632 return elem; 5633} 5634 5635function cloneCopyEvent( src, dest ) { 5636 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; 5637 5638 if ( dest.nodeType !== 1 ) { 5639 return; 5640 } 5641 5642 // 1. Copy private data: events, handlers, etc. 5643 if ( dataPriv.hasData( src ) ) { 5644 pdataOld = dataPriv.access( src ); 5645 pdataCur = dataPriv.set( dest, pdataOld ); 5646 events = pdataOld.events; 5647 5648 if ( events ) { 5649 delete pdataCur.handle; 5650 pdataCur.events = {}; 5651 5652 for ( type in events ) { 5653 for ( i = 0, l = events[ type ].length; i < l; i++ ) { 5654 jQuery.event.add( dest, type, events[ type ][ i ] ); 5655 } 5656 } 5657 } 5658 } 5659 5660 // 2. Copy user data 5661 if ( dataUser.hasData( src ) ) { 5662 udataOld = dataUser.access( src ); 5663 udataCur = jQuery.extend( {}, udataOld ); 5664 5665 dataUser.set( dest, udataCur ); 5666 } 5667} 5668 5669// Fix IE bugs, see support tests 5670function fixInput( src, dest ) { 5671 var nodeName = dest.nodeName.toLowerCase(); 5672 5673 // Fails to persist the checked state of a cloned checkbox or radio button. 5674 if ( nodeName === "input" && rcheckableType.test( src.type ) ) { 5675 dest.checked = src.checked; 5676 5677 // Fails to return the selected option to the default selected state when cloning options 5678 } else if ( nodeName === "input" || nodeName === "textarea" ) { 5679 dest.defaultValue = src.defaultValue; 5680 } 5681} 5682 5683function domManip( collection, args, callback, ignored ) { 5684 5685 // Flatten any nested arrays 5686 args = concat.apply( [], args ); 5687 5688 var fragment, first, scripts, hasScripts, node, doc, 5689 i = 0, 5690 l = collection.length, 5691 iNoClone = l - 1, 5692 value = args[ 0 ], 5693 valueIsFunction = isFunction( value ); 5694 5695 // We can't cloneNode fragments that contain checked, in WebKit 5696 if ( valueIsFunction || 5697 ( l > 1 && typeof value === "string" && 5698 !support.checkClone && rchecked.test( value ) ) ) { 5699 return collection.each( function( index ) { 5700 var self = collection.eq( index ); 5701 if ( valueIsFunction ) { 5702 args[ 0 ] = value.call( this, index, self.html() ); 5703 } 5704 domManip( self, args, callback, ignored ); 5705 } ); 5706 } 5707 5708 if ( l ) { 5709 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); 5710 first = fragment.firstChild; 5711 5712 if ( fragment.childNodes.length === 1 ) { 5713 fragment = first; 5714 } 5715 5716 // Require either new content or an interest in ignored elements to invoke the callback 5717 if ( first || ignored ) { 5718 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); 5719 hasScripts = scripts.length; 5720 5721 // Use the original fragment for the last item 5722 // instead of the first because it can end up 5723 // being emptied incorrectly in certain situations (#8070). 5724 for ( ; i < l; i++ ) { 5725 node = fragment; 5726 5727 if ( i !== iNoClone ) { 5728 node = jQuery.clone( node, true, true ); 5729 5730 // Keep references to cloned scripts for later restoration 5731 if ( hasScripts ) { 5732 5733 // Support: Android <=4.0 only, PhantomJS 1 only 5734 // push.apply(_, arraylike) throws on ancient WebKit 5735 jQuery.merge( scripts, getAll( node, "script" ) ); 5736 } 5737 } 5738 5739 callback.call( collection[ i ], node, i ); 5740 } 5741 5742 if ( hasScripts ) { 5743 doc = scripts[ scripts.length - 1 ].ownerDocument; 5744 5745 // Reenable scripts 5746 jQuery.map( scripts, restoreScript ); 5747 5748 // Evaluate executable scripts on first document insertion 5749 for ( i = 0; i < hasScripts; i++ ) { 5750 node = scripts[ i ]; 5751 if ( rscriptType.test( node.type || "" ) && 5752 !dataPriv.access( node, "globalEval" ) && 5753 jQuery.contains( doc, node ) ) { 5754 5755 if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) { 5756 5757 // Optional AJAX dependency, but won't run scripts if not present 5758 if ( jQuery._evalUrl ) { 5759 jQuery._evalUrl( node.src ); 5760 } 5761 } else { 5762 DOMEval( node.textContent.replace( rcleanScript, "" ), doc, node ); 5763 } 5764 } 5765 } 5766 } 5767 } 5768 } 5769 5770 return collection; 5771} 5772 5773function remove( elem, selector, keepData ) { 5774 var node, 5775 nodes = selector ? jQuery.filter( selector, elem ) : elem, 5776 i = 0; 5777 5778 for ( ; ( node = nodes[ i ] ) != null; i++ ) { 5779 if ( !keepData && node.nodeType === 1 ) { 5780 jQuery.cleanData( getAll( node ) ); 5781 } 5782 5783 if ( node.parentNode ) { 5784 if ( keepData && jQuery.contains( node.ownerDocument, node ) ) { 5785 setGlobalEval( getAll( node, "script" ) ); 5786 } 5787 node.parentNode.removeChild( node ); 5788 } 5789 } 5790 5791 return elem; 5792} 5793 5794jQuery.extend( { 5795 htmlPrefilter: function( html ) { 5796 return html.replace( rxhtmlTag, "<$1></$2>" ); 5797 }, 5798 5799 clone: function( elem, dataAndEvents, deepDataAndEvents ) { 5800 var i, l, srcElements, destElements, 5801 clone = elem.cloneNode( true ), 5802 inPage = jQuery.contains( elem.ownerDocument, elem ); 5803 5804 // Fix IE cloning issues 5805 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && 5806 !jQuery.isXMLDoc( elem ) ) { 5807 5808 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 5809 destElements = getAll( clone ); 5810 srcElements = getAll( elem ); 5811 5812 for ( i = 0, l = srcElements.length; i < l; i++ ) { 5813 fixInput( srcElements[ i ], destElements[ i ] ); 5814 } 5815 } 5816 5817 // Copy the events from the original to the clone 5818 if ( dataAndEvents ) { 5819 if ( deepDataAndEvents ) { 5820 srcElements = srcElements || getAll( elem ); 5821 destElements = destElements || getAll( clone ); 5822 5823 for ( i = 0, l = srcElements.length; i < l; i++ ) { 5824 cloneCopyEvent( srcElements[ i ], destElements[ i ] ); 5825 } 5826 } else { 5827 cloneCopyEvent( elem, clone ); 5828 } 5829 } 5830 5831 // Preserve script evaluation history 5832 destElements = getAll( clone, "script" ); 5833 if ( destElements.length > 0 ) { 5834 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); 5835 } 5836 5837 // Return the cloned set 5838 return clone; 5839 }, 5840 5841 cleanData: function( elems ) { 5842 var data, elem, type, 5843 special = jQuery.event.special, 5844 i = 0; 5845 5846 for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { 5847 if ( acceptData( elem ) ) { 5848 if ( ( data = elem[ dataPriv.expando ] ) ) { 5849 if ( data.events ) { 5850 for ( type in data.events ) { 5851 if ( special[ type ] ) { 5852 jQuery.event.remove( elem, type ); 5853 5854 // This is a shortcut to avoid jQuery.event.remove's overhead 5855 } else { 5856 jQuery.removeEvent( elem, type, data.handle ); 5857 } 5858 } 5859 } 5860
vendor: 1,119 bytes, lines 5861-5905
5861 // Support: Chrome <=35 - 45+ 5862 // Assign undefined instead of using delete, see Data#remove 5863 elem[ dataPriv.expando ] = undefined; 5864 } 5865 if ( elem[ dataUser.expando ] ) { 5866 5867 // Support: Chrome <=35 - 45+ 5868 // Assign undefined instead of using delete, see Data#remove 5869 elem[ dataUser.expando ] = undefined; 5870 } 5871 } 5872 } 5873 } 5874} ); 5875 5876jQuery.fn.extend( { 5877 detach: function( selector ) { 5878 return remove( this, selector, true ); 5879 }, 5880 5881 remove: function( selector ) { 5882 return remove( this, selector ); 5883 }, 5884 5885 text: function( value ) { 5886 return access( this, function( value ) { 5887 return value === undefined ? 5888 jQuery.text( this ) : 5889 this.empty().each( function() { 5890 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 5891 this.textContent = value; 5892 } 5893 } ); 5894 }, null, value, arguments.length ); 5895 }, 5896 5897 append: function() { 5898 return domManip( this, arguments, function( elem ) { 5899 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 5900 var target = manipulationTarget( this, elem ); 5901 target.appendChild( elem ); 5902 } 5903 } ); 5904 }, 5905
vendor: 52,786 bytes, lines 5906-7960
5906 prepend: function() { 5907 return domManip( this, arguments, function( elem ) { 5908 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 5909 var target = manipulationTarget( this, elem ); 5910 target.insertBefore( elem, target.firstChild ); 5911 } 5912 } ); 5913 }, 5914 5915 before: function() { 5916 return domManip( this, arguments, function( elem ) { 5917 if ( this.parentNode ) { 5918 this.parentNode.insertBefore( elem, this ); 5919 } 5920 } ); 5921 }, 5922 5923 after: function() { 5924 return domManip( this, arguments, function( elem ) { 5925 if ( this.parentNode ) { 5926 this.parentNode.insertBefore( elem, this.nextSibling ); 5927 } 5928 } ); 5929 }, 5930 5931 empty: function() { 5932 var elem, 5933 i = 0; 5934 5935 for ( ; ( elem = this[ i ] ) != null; i++ ) { 5936 if ( elem.nodeType === 1 ) { 5937 5938 // Prevent memory leaks 5939 jQuery.cleanData( getAll( elem, false ) ); 5940 5941 // Remove any remaining nodes 5942 elem.textContent = ""; 5943 } 5944 } 5945 5946 return this; 5947 }, 5948 5949 clone: function( dataAndEvents, deepDataAndEvents ) { 5950 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; 5951 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; 5952 5953 return this.map( function() { 5954 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); 5955 } ); 5956 }, 5957 5958 html: function( value ) { 5959 return access( this, function( value ) { 5960 var elem = this[ 0 ] || {}, 5961 i = 0, 5962 l = this.length; 5963 5964 if ( value === undefined && elem.nodeType === 1 ) { 5965 return elem.innerHTML; 5966 } 5967 5968 // See if we can take a shortcut and just use innerHTML 5969 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && 5970 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { 5971 5972 value = jQuery.htmlPrefilter( value ); 5973 5974 try { 5975 for ( ; i < l; i++ ) { 5976 elem = this[ i ] || {}; 5977 5978 // Remove element nodes and prevent memory leaks 5979 if ( elem.nodeType === 1 ) { 5980 jQuery.cleanData( getAll( elem, false ) ); 5981 elem.innerHTML = value; 5982 } 5983 } 5984 5985 elem = 0; 5986 5987 // If using innerHTML throws an exception, use the fallback method 5988 } catch ( e ) {} 5989 } 5990 5991 if ( elem ) { 5992 this.empty().append( value ); 5993 } 5994 }, null, value, arguments.length ); 5995 }, 5996 5997 replaceWith: function() { 5998 var ignored = []; 5999 6000 // Make the changes, replacing each non-ignored context element with the new content 6001 return domManip( this, arguments, function( elem ) { 6002 var parent = this.parentNode; 6003 6004 if ( jQuery.inArray( this, ignored ) < 0 ) { 6005 jQuery.cleanData( getAll( this ) ); 6006 if ( parent ) { 6007 parent.replaceChild( elem, this ); 6008 } 6009 } 6010 6011 // Force callback invocation 6012 }, ignored ); 6013 } 6014} ); 6015 6016jQuery.each( { 6017 appendTo: "append", 6018 prependTo: "prepend", 6019 insertBefore: "before", 6020 insertAfter: "after", 6021 replaceAll: "replaceWith" 6022}, function( name, original ) { 6023 jQuery.fn[ name ] = function( selector ) { 6024 var elems, 6025 ret = [], 6026 insert = jQuery( selector ), 6027 last = insert.length - 1, 6028 i = 0; 6029 6030 for ( ; i <= last; i++ ) { 6031 elems = i === last ? this : this.clone( true ); 6032 jQuery( insert[ i ] )[ original ]( elems ); 6033 6034 // Support: Android <=4.0 only, PhantomJS 1 only 6035 // .get() because push.apply(_, arraylike) throws on ancient WebKit 6036 push.apply( ret, elems.get() ); 6037 } 6038 6039 return this.pushStack( ret ); 6040 }; 6041} ); 6042var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); 6043 6044var getStyles = function( elem ) { 6045 6046 // Support: IE <=11 only, Firefox <=30 (#15098, #14150) 6047 // IE throws on elements created in popups 6048 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" 6049 var view = elem.ownerDocument.defaultView; 6050 6051 if ( !view || !view.opener ) { 6052 view = window; 6053 } 6054 6055 return view.getComputedStyle( elem ); 6056 }; 6057 6058var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); 6059 6060 6061 6062( function() { 6063 6064 // Executing both pixelPosition & boxSizingReliable tests require only one layout 6065 // so they're executed at the same time to save the second computation. 6066 function computeStyleTests() { 6067 6068 // This is a singleton, we need to execute it only once 6069 if ( !div ) { 6070 return; 6071 } 6072 6073 container.style.cssText = "position:absolute;left:-11111px;width:60px;" + 6074 "margin-top:1px;padding:0;border:0"; 6075 div.style.cssText = 6076 "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + 6077 "margin:auto;border:1px;padding:1px;" + 6078 "width:60%;top:1%"; 6079 documentElement.appendChild( container ).appendChild( div ); 6080 6081 var divStyle = window.getComputedStyle( div ); 6082 pixelPositionVal = divStyle.top !== "1%"; 6083 6084 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 6085 reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; 6086 6087 // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 6088 // Some styles come back with percentage values, even though they shouldn't 6089 div.style.right = "60%"; 6090 pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; 6091 6092 // Support: IE 9 - 11 only 6093 // Detect misreporting of content dimensions for box-sizing:border-box elements 6094 boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; 6095 6096 // Support: IE 9 only 6097 // Detect overflow:scroll screwiness (gh-3699) 6098 div.style.position = "absolute"; 6099 scrollboxSizeVal = div.offsetWidth === 36 || "absolute"; 6100 6101 documentElement.removeChild( container ); 6102 6103 // Nullify the div so it wouldn't be stored in the memory and 6104 // it will also be a sign that checks already performed 6105 div = null; 6106 } 6107 6108 function roundPixelMeasures( measure ) { 6109 return Math.round( parseFloat( measure ) ); 6110 } 6111 6112 var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, 6113 reliableMarginLeftVal, 6114 container = document.createElement( "div" ), 6115 div = document.createElement( "div" ); 6116 6117 // Finish early in limited (non-browser) environments 6118 if ( !div.style ) { 6119 return; 6120 } 6121 6122 // Support: IE <=9 - 11 only 6123 // Style of cloned element affects source element cloned (#8908) 6124 div.style.backgroundClip = "content-box"; 6125 div.cloneNode( true ).style.backgroundClip = ""; 6126 support.clearCloneStyle = div.style.backgroundClip === "content-box"; 6127 6128 jQuery.extend( support, { 6129 boxSizingReliable: function() { 6130 computeStyleTests(); 6131 return boxSizingReliableVal; 6132 }, 6133 pixelBoxStyles: function() { 6134 computeStyleTests(); 6135 return pixelBoxStylesVal; 6136 }, 6137 pixelPosition: function() { 6138 computeStyleTests(); 6139 return pixelPositionVal; 6140 }, 6141 reliableMarginLeft: function() { 6142 computeStyleTests(); 6143 return reliableMarginLeftVal; 6144 }, 6145 scrollboxSize: function() { 6146 computeStyleTests(); 6147 return scrollboxSizeVal; 6148 } 6149 } ); 6150} )(); 6151 6152 6153function curCSS( elem, name, computed ) { 6154 var width, minWidth, maxWidth, ret, 6155 6156 // Support: Firefox 51+ 6157 // Retrieving style before computed somehow 6158 // fixes an issue with getting wrong values 6159 // on detached elements 6160 style = elem.style; 6161 6162 computed = computed || getStyles( elem ); 6163 6164 // getPropertyValue is needed for: 6165 // .css('filter') (IE 9 only, #12537) 6166 // .css('--customProperty) (#3144) 6167 if ( computed ) { 6168 ret = computed.getPropertyValue( name ) || computed[ name ]; 6169 6170 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { 6171 ret = jQuery.style( elem, name ); 6172 } 6173 6174 // A tribute to the "awesome hack by Dean Edwards" 6175 // Android Browser returns percentage for some values, 6176 // but width seems to be reliably pixels. 6177 // This is against the CSSOM draft spec: 6178 // https://drafts.csswg.org/cssom/#resolved-values 6179 if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) { 6180 6181 // Remember the original values 6182 width = style.width; 6183 minWidth = style.minWidth; 6184 maxWidth = style.maxWidth; 6185 6186 // Put in the new values to get a computed value out 6187 style.minWidth = style.maxWidth = style.width = ret; 6188 ret = computed.width; 6189 6190 // Revert the changed values 6191 style.width = width; 6192 style.minWidth = minWidth; 6193 style.maxWidth = maxWidth; 6194 } 6195 } 6196 6197 return ret !== undefined ? 6198 6199 // Support: IE <=9 - 11 only 6200 // IE returns zIndex value as an integer. 6201 ret + "" : 6202 ret; 6203} 6204 6205 6206function addGetHookIf( conditionFn, hookFn ) { 6207 6208 // Define the hook, we'll check on the first run if it's really needed. 6209 return { 6210 get: function() { 6211 if ( conditionFn() ) { 6212 6213 // Hook not needed (or it's not possible to use it due 6214 // to missing dependency), remove it. 6215 delete this.get; 6216 return; 6217 } 6218 6219 // Hook needed; redefine it so that the support test is not executed again. 6220 return ( this.get = hookFn ).apply( this, arguments ); 6221 } 6222 }; 6223} 6224 6225 6226var 6227 6228 // Swappable if display is none or starts with table 6229 // except "table", "table-cell", or "table-caption" 6230 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display 6231 rdisplayswap = /^(none|table(?!-c[ea]).+)/, 6232 rcustomProp = /^--/, 6233 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, 6234 cssNormalTransform = { 6235 letterSpacing: "0", 6236 fontWeight: "400" 6237 }, 6238 6239 cssPrefixes = [ "Webkit", "Moz", "ms" ], 6240 emptyStyle = document.createElement( "div" ).style; 6241 6242// Return a css property mapped to a potentially vendor prefixed property 6243function vendorPropName( name ) { 6244 6245 // Shortcut for names that are not vendor prefixed 6246 if ( name in emptyStyle ) { 6247 return name; 6248 } 6249 6250 // Check for vendor prefixed names 6251 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), 6252 i = cssPrefixes.length; 6253 6254 while ( i-- ) { 6255 name = cssPrefixes[ i ] + capName; 6256 if ( name in emptyStyle ) { 6257 return name; 6258 } 6259 } 6260} 6261 6262// Return a property mapped along what jQuery.cssProps suggests or to 6263// a vendor prefixed property. 6264function finalPropName( name ) { 6265 var ret = jQuery.cssProps[ name ]; 6266 if ( !ret ) { 6267 ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name; 6268 } 6269 return ret; 6270} 6271 6272function setPositiveNumber( elem, value, subtract ) { 6273 6274 // Any relative (+/-) values have already been 6275 // normalized at this point 6276 var matches = rcssNum.exec( value ); 6277 return matches ? 6278 6279 // Guard against undefined "subtract", e.g., when used as in cssHooks 6280 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : 6281 value; 6282} 6283 6284function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { 6285 var i = dimension === "width" ? 1 : 0, 6286 extra = 0, 6287 delta = 0; 6288 6289 // Adjustment may not be necessary 6290 if ( box === ( isBorderBox ? "border" : "content" ) ) { 6291 return 0; 6292 } 6293 6294 for ( ; i < 4; i += 2 ) { 6295 6296 // Both box models exclude margin 6297 if ( box === "margin" ) { 6298 delta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); 6299 } 6300 6301 // If we get here with a content-box, we're seeking "padding" or "border" or "margin" 6302 if ( !isBorderBox ) { 6303 6304 // Add padding 6305 delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 6306 6307 // For "border" or "margin", add border 6308 if ( box !== "padding" ) { 6309 delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 6310 6311 // But still keep track of it otherwise 6312 } else { 6313 extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 6314 } 6315 6316 // If we get here with a border-box (content + padding + border), we're seeking "content" or 6317 // "padding" or "margin" 6318 } else { 6319 6320 // For "content", subtract padding 6321 if ( box === "content" ) { 6322 delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 6323 } 6324 6325 // For "content" or "padding", subtract border 6326 if ( box !== "margin" ) { 6327 delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 6328 } 6329 } 6330 } 6331 6332 // Account for positive content-box scroll gutter when requested by providing computedVal 6333 if ( !isBorderBox && computedVal >= 0 ) { 6334 6335 // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border 6336 // Assuming integer scroll gutter, subtract the rest and round down 6337 delta += Math.max( 0, Math.ceil( 6338 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - 6339 computedVal - 6340 delta - 6341 extra - 6342 0.5 6343 ) ); 6344 } 6345 6346 return delta; 6347} 6348 6349function getWidthOrHeight( elem, dimension, extra ) { 6350 6351 // Start with computed style 6352 var styles = getStyles( elem ), 6353 val = curCSS( elem, dimension, styles ), 6354 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 6355 valueIsBorderBox = isBorderBox; 6356 6357 // Support: Firefox <=54 6358 // Return a confounding non-pixel value or feign ignorance, as appropriate. 6359 if ( rnumnonpx.test( val ) ) { 6360 if ( !extra ) { 6361 return val; 6362 } 6363 val = "auto"; 6364 } 6365 6366 // Check for style in case a browser which returns unreliable values 6367 // for getComputedStyle silently falls back to the reliable elem.style 6368 valueIsBorderBox = valueIsBorderBox && 6369 ( support.boxSizingReliable() || val === elem.style[ dimension ] ); 6370 6371 // Fall back to offsetWidth/offsetHeight when value is "auto" 6372 // This happens for inline elements with no explicit setting (gh-3571) 6373 // Support: Android <=4.1 - 4.3 only 6374 // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) 6375 if ( val === "auto" || 6376 !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) { 6377 6378 val = elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ]; 6379 6380 // offsetWidth/offsetHeight provide border-box values 6381 valueIsBorderBox = true; 6382 } 6383 6384 // Normalize "" and auto 6385 val = parseFloat( val ) || 0; 6386 6387 // Adjust for the element's box model 6388 return ( val + 6389 boxModelAdjustment( 6390 elem, 6391 dimension, 6392 extra || ( isBorderBox ? "border" : "content" ), 6393 valueIsBorderBox, 6394 styles, 6395 6396 // Provide the current computed size to request scroll gutter calculation (gh-3589) 6397 val 6398 ) 6399 ) + "px"; 6400} 6401 6402jQuery.extend( { 6403 6404 // Add in style property hooks for overriding the default 6405 // behavior of getting and setting a style property 6406 cssHooks: { 6407 opacity: { 6408 get: function( elem, computed ) { 6409 if ( computed ) { 6410 6411 // We should always get a number back from opacity 6412 var ret = curCSS( elem, "opacity" ); 6413 return ret === "" ? "1" : ret; 6414 } 6415 } 6416 } 6417 }, 6418 6419 // Don't automatically add "px" to these possibly-unitless properties 6420 cssNumber: { 6421 "animationIterationCount": true, 6422 "columnCount": true, 6423 "fillOpacity": true, 6424 "flexGrow": true, 6425 "flexShrink": true, 6426 "fontWeight": true, 6427 "lineHeight": true, 6428 "opacity": true, 6429 "order": true, 6430 "orphans": true, 6431 "widows": true, 6432 "zIndex": true, 6433 "zoom": true 6434 }, 6435 6436 // Add in properties whose names you wish to fix before 6437 // setting or getting the value 6438 cssProps: {}, 6439 6440 // Get and set the style property on a DOM Node 6441 style: function( elem, name, value, extra ) { 6442 6443 // Don't set styles on text and comment nodes 6444 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { 6445 return; 6446 } 6447 6448 // Make sure that we're working with the right name 6449 var ret, type, hooks, 6450 origName = camelCase( name ), 6451 isCustomProp = rcustomProp.test( name ), 6452 style = elem.style; 6453 6454 // Make sure that we're working with the right name. We don't 6455 // want to query the value if it is a CSS custom property 6456 // since they are user-defined. 6457 if ( !isCustomProp ) { 6458 name = finalPropName( origName ); 6459 } 6460 6461 // Gets hook for the prefixed version, then unprefixed version 6462 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 6463 6464 // Check if we're setting a value 6465 if ( value !== undefined ) { 6466 type = typeof value; 6467 6468 // Convert "+=" or "-=" to relative numbers (#7345) 6469 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { 6470 value = adjustCSS( elem, name, ret ); 6471 6472 // Fixes bug #9237 6473 type = "number"; 6474 } 6475 6476 // Make sure that null and NaN values aren't set (#7116) 6477 if ( value == null || value !== value ) { 6478 return; 6479 } 6480 6481 // If a number was passed in, add the unit (except for certain CSS properties) 6482 if ( type === "number" ) { 6483 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); 6484 } 6485 6486 // background-* props affect original clone's values 6487 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { 6488 style[ name ] = "inherit"; 6489 } 6490 6491 // If a hook was provided, use that value, otherwise just set the specified value 6492 if ( !hooks || !( "set" in hooks ) || 6493 ( value = hooks.set( elem, value, extra ) ) !== undefined ) { 6494 6495 if ( isCustomProp ) { 6496 style.setProperty( name, value ); 6497 } else { 6498 style[ name ] = value; 6499 } 6500 } 6501 6502 } else { 6503 6504 // If a hook was provided get the non-computed value from there 6505 if ( hooks && "get" in hooks && 6506 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { 6507 6508 return ret; 6509 } 6510 6511 // Otherwise just get the value from the style object 6512 return style[ name ]; 6513 } 6514 }, 6515 6516 css: function( elem, name, extra, styles ) { 6517 var val, num, hooks, 6518 origName = camelCase( name ), 6519 isCustomProp = rcustomProp.test( name ); 6520 6521 // Make sure that we're working with the right name. We don't 6522 // want to modify the value if it is a CSS custom property 6523 // since they are user-defined. 6524 if ( !isCustomProp ) { 6525 name = finalPropName( origName ); 6526 } 6527 6528 // Try prefixed name followed by the unprefixed name 6529 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 6530 6531 // If a hook was provided get the computed value from there 6532 if ( hooks && "get" in hooks ) { 6533 val = hooks.get( elem, true, extra ); 6534 } 6535 6536 // Otherwise, if a way to get the computed value exists, use that 6537 if ( val === undefined ) { 6538 val = curCSS( elem, name, styles ); 6539 } 6540 6541 // Convert "normal" to computed value 6542 if ( val === "normal" && name in cssNormalTransform ) { 6543 val = cssNormalTransform[ name ]; 6544 } 6545 6546 // Make numeric if forced or a qualifier was provided and val looks numeric 6547 if ( extra === "" || extra ) { 6548 num = parseFloat( val ); 6549 return extra === true || isFinite( num ) ? num || 0 : val; 6550 } 6551 6552 return val; 6553 } 6554} ); 6555 6556jQuery.each( [ "height", "width" ], function( i, dimension ) { 6557 jQuery.cssHooks[ dimension ] = { 6558 get: function( elem, computed, extra ) { 6559 if ( computed ) { 6560 6561 // Certain elements can have dimension info if we invisibly show them 6562 // but it must have a current display style that would benefit 6563 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && 6564 6565 // Support: Safari 8+ 6566 // Table columns in Safari have non-zero offsetWidth & zero 6567 // getBoundingClientRect().width unless display is changed. 6568 // Support: IE <=11 only 6569 // Running getBoundingClientRect on a disconnected node 6570 // in IE throws an error. 6571 ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? 6572 swap( elem, cssShow, function() { 6573 return getWidthOrHeight( elem, dimension, extra ); 6574 } ) : 6575 getWidthOrHeight( elem, dimension, extra ); 6576 } 6577 }, 6578 6579 set: function( elem, value, extra ) { 6580 var matches, 6581 styles = getStyles( elem ), 6582 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 6583 subtract = extra && boxModelAdjustment( 6584 elem, 6585 dimension, 6586 extra, 6587 isBorderBox, 6588 styles 6589 ); 6590 6591 // Account for unreliable border-box dimensions by comparing offset* to computed and 6592 // faking a content-box to get border and padding (gh-3699) 6593 if ( isBorderBox && support.scrollboxSize() === styles.position ) { 6594 subtract -= Math.ceil( 6595 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - 6596 parseFloat( styles[ dimension ] ) - 6597 boxModelAdjustment( elem, dimension, "border", false, styles ) - 6598 0.5 6599 ); 6600 } 6601 6602 // Convert to pixels if value adjustment is needed 6603 if ( subtract && ( matches = rcssNum.exec( value ) ) && 6604 ( matches[ 3 ] || "px" ) !== "px" ) { 6605 6606 elem.style[ dimension ] = value; 6607 value = jQuery.css( elem, dimension ); 6608 } 6609 6610 return setPositiveNumber( elem, value, subtract ); 6611 } 6612 }; 6613} ); 6614 6615jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, 6616 function( elem, computed ) { 6617 if ( computed ) { 6618 return ( parseFloat( curCSS( elem, "marginLeft" ) ) || 6619 elem.getBoundingClientRect().left - 6620 swap( elem, { marginLeft: 0 }, function() { 6621 return elem.getBoundingClientRect().left; 6622 } ) 6623 ) + "px"; 6624 } 6625 } 6626); 6627 6628// These hooks are used by animate to expand properties 6629jQuery.each( { 6630 margin: "", 6631 padding: "", 6632 border: "Width" 6633}, function( prefix, suffix ) { 6634 jQuery.cssHooks[ prefix + suffix ] = { 6635 expand: function( value ) { 6636 var i = 0, 6637 expanded = {}, 6638 6639 // Assumes a single number if not a string 6640 parts = typeof value === "string" ? value.split( " " ) : [ value ]; 6641 6642 for ( ; i < 4; i++ ) { 6643 expanded[ prefix + cssExpand[ i ] + suffix ] = 6644 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; 6645 } 6646 6647 return expanded; 6648 } 6649 }; 6650 6651 if ( prefix !== "margin" ) { 6652 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; 6653 } 6654} ); 6655 6656jQuery.fn.extend( { 6657 css: function( name, value ) { 6658 return access( this, function( elem, name, value ) { 6659 var styles, len, 6660 map = {}, 6661 i = 0; 6662 6663 if ( Array.isArray( name ) ) { 6664 styles = getStyles( elem ); 6665 len = name.length; 6666 6667 for ( ; i < len; i++ ) { 6668 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); 6669 } 6670 6671 return map; 6672 } 6673 6674 return value !== undefined ? 6675 jQuery.style( elem, name, value ) : 6676 jQuery.css( elem, name ); 6677 }, name, value, arguments.length > 1 ); 6678 } 6679} ); 6680 6681 6682function Tween( elem, options, prop, end, easing ) { 6683 return new Tween.prototype.init( elem, options, prop, end, easing ); 6684} 6685jQuery.Tween = Tween; 6686 6687Tween.prototype = { 6688 constructor: Tween, 6689 init: function( elem, options, prop, end, easing, unit ) { 6690 this.elem = elem; 6691 this.prop = prop; 6692 this.easing = easing || jQuery.easing._default; 6693 this.options = options; 6694 this.start = this.now = this.cur(); 6695 this.end = end; 6696 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); 6697 }, 6698 cur: function() { 6699 var hooks = Tween.propHooks[ this.prop ]; 6700 6701 return hooks && hooks.get ? 6702 hooks.get( this ) : 6703 Tween.propHooks._default.get( this ); 6704 }, 6705 run: function( percent ) { 6706 var eased, 6707 hooks = Tween.propHooks[ this.prop ]; 6708 6709 if ( this.options.duration ) { 6710 this.pos = eased = jQuery.easing[ this.easing ]( 6711 percent, this.options.duration * percent, 0, 1, this.options.duration 6712 ); 6713 } else { 6714 this.pos = eased = percent; 6715 } 6716 this.now = ( this.end - this.start ) * eased + this.start; 6717 6718 if ( this.options.step ) { 6719 this.options.step.call( this.elem, this.now, this ); 6720 } 6721 6722 if ( hooks && hooks.set ) { 6723 hooks.set( this ); 6724 } else { 6725 Tween.propHooks._default.set( this ); 6726 } 6727 return this; 6728 } 6729}; 6730 6731Tween.prototype.init.prototype = Tween.prototype; 6732 6733Tween.propHooks = { 6734 _default: { 6735 get: function( tween ) { 6736 var result; 6737 6738 // Use a property on the element directly when it is not a DOM element, 6739 // or when there is no matching style property that exists. 6740 if ( tween.elem.nodeType !== 1 || 6741 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { 6742 return tween.elem[ tween.prop ]; 6743 } 6744 6745 // Passing an empty string as a 3rd parameter to .css will automatically 6746 // attempt a parseFloat and fallback to a string if the parse fails. 6747 // Simple values such as "10px" are parsed to Float; 6748 // complex values such as "rotate(1rad)" are returned as-is. 6749 result = jQuery.css( tween.elem, tween.prop, "" ); 6750 6751 // Empty strings, null, undefined and "auto" are converted to 0. 6752 return !result || result === "auto" ? 0 : result; 6753 }, 6754 set: function( tween ) { 6755 6756 // Use step hook for back compat. 6757 // Use cssHook if its there. 6758 // Use .style if available and use plain properties where available. 6759 if ( jQuery.fx.step[ tween.prop ] ) { 6760 jQuery.fx.step[ tween.prop ]( tween ); 6761 } else if ( tween.elem.nodeType === 1 && 6762 ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || 6763 jQuery.cssHooks[ tween.prop ] ) ) { 6764 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); 6765 } else { 6766 tween.elem[ tween.prop ] = tween.now; 6767 } 6768 } 6769 } 6770}; 6771 6772// Support: IE <=9 only 6773// Panic based approach to setting things on disconnected nodes 6774Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { 6775 set: function( tween ) { 6776 if ( tween.elem.nodeType && tween.elem.parentNode ) { 6777 tween.elem[ tween.prop ] = tween.now; 6778 } 6779 } 6780}; 6781 6782jQuery.easing = { 6783 linear: function( p ) { 6784 return p; 6785 }, 6786 swing: function( p ) { 6787 return 0.5 - Math.cos( p * Math.PI ) / 2; 6788 }, 6789 _default: "swing" 6790}; 6791 6792jQuery.fx = Tween.prototype.init; 6793 6794// Back compat <1.8 extension point 6795jQuery.fx.step = {}; 6796 6797 6798 6799 6800var 6801 fxNow, inProgress, 6802 rfxtypes = /^(?:toggle|show|hide)$/, 6803 rrun = /queueHooks$/; 6804 6805function schedule() { 6806 if ( inProgress ) { 6807 if ( document.hidden === false && window.requestAnimationFrame ) { 6808 window.requestAnimationFrame( schedule ); 6809 } else { 6810 window.setTimeout( schedule, jQuery.fx.interval ); 6811 } 6812 6813 jQuery.fx.tick(); 6814 } 6815} 6816 6817// Animations created synchronously will run synchronously 6818function createFxNow() { 6819 window.setTimeout( function() { 6820 fxNow = undefined; 6821 } ); 6822 return ( fxNow = Date.now() ); 6823} 6824 6825// Generate parameters to create a standard animation 6826function genFx( type, includeWidth ) { 6827 var which, 6828 i = 0, 6829 attrs = { height: type }; 6830 6831 // If we include width, step value is 1 to do all cssExpand values, 6832 // otherwise step value is 2 to skip over Left and Right 6833 includeWidth = includeWidth ? 1 : 0; 6834 for ( ; i < 4; i += 2 - includeWidth ) { 6835 which = cssExpand[ i ]; 6836 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; 6837 } 6838 6839 if ( includeWidth ) { 6840 attrs.opacity = attrs.width = type; 6841 } 6842 6843 return attrs; 6844} 6845 6846function createTween( value, prop, animation ) { 6847 var tween, 6848 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), 6849 index = 0, 6850 length = collection.length; 6851 for ( ; index < length; index++ ) { 6852 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { 6853 6854 // We're done with this property 6855 return tween; 6856 } 6857 } 6858} 6859 6860function defaultPrefilter( elem, props, opts ) { 6861 var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, 6862 isBox = "width" in props || "height" in props, 6863 anim = this, 6864 orig = {}, 6865 style = elem.style, 6866 hidden = elem.nodeType && isHiddenWithinTree( elem ), 6867 dataShow = dataPriv.get( elem, "fxshow" ); 6868 6869 // Queue-skipping animations hijack the fx hooks 6870 if ( !opts.queue ) { 6871 hooks = jQuery._queueHooks( elem, "fx" ); 6872 if ( hooks.unqueued == null ) { 6873 hooks.unqueued = 0; 6874 oldfire = hooks.empty.fire; 6875 hooks.empty.fire = function() { 6876 if ( !hooks.unqueued ) { 6877 oldfire(); 6878 } 6879 }; 6880 } 6881 hooks.unqueued++; 6882 6883 anim.always( function() { 6884 6885 // Ensure the complete handler is called before this completes 6886 anim.always( function() { 6887 hooks.unqueued--; 6888 if ( !jQuery.queue( elem, "fx" ).length ) { 6889 hooks.empty.fire(); 6890 } 6891 } ); 6892 } ); 6893 } 6894 6895 // Detect show/hide animations 6896 for ( prop in props ) { 6897 value = props[ prop ]; 6898 if ( rfxtypes.test( value ) ) { 6899 delete props[ prop ]; 6900 toggle = toggle || value === "toggle"; 6901 if ( value === ( hidden ? "hide" : "show" ) ) { 6902 6903 // Pretend to be hidden if this is a "show" and 6904 // there is still data from a stopped show/hide 6905 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { 6906 hidden = true; 6907 6908 // Ignore all other no-op show/hide data 6909 } else { 6910 continue; 6911 } 6912 } 6913 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); 6914 } 6915 } 6916 6917 // Bail out if this is a no-op like .hide().hide() 6918 propTween = !jQuery.isEmptyObject( props ); 6919 if ( !propTween && jQuery.isEmptyObject( orig ) ) { 6920 return; 6921 } 6922 6923 // Restrict "overflow" and "display" styles during box animations 6924 if ( isBox && elem.nodeType === 1 ) { 6925 6926 // Support: IE <=9 - 11, Edge 12 - 15 6927 // Record all 3 overflow attributes because IE does not infer the shorthand 6928 // from identically-valued overflowX and overflowY and Edge just mirrors 6929 // the overflowX value there. 6930 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; 6931 6932 // Identify a display type, preferring old show/hide data over the CSS cascade 6933 restoreDisplay = dataShow && dataShow.display; 6934 if ( restoreDisplay == null ) { 6935 restoreDisplay = dataPriv.get( elem, "display" ); 6936 } 6937 display = jQuery.css( elem, "display" ); 6938 if ( display === "none" ) { 6939 if ( restoreDisplay ) { 6940 display = restoreDisplay; 6941 } else { 6942 6943 // Get nonempty value(s) by temporarily forcing visibility 6944 showHide( [ elem ], true ); 6945 restoreDisplay = elem.style.display || restoreDisplay; 6946 display = jQuery.css( elem, "display" ); 6947 showHide( [ elem ] ); 6948 } 6949 } 6950 6951 // Animate inline elements as inline-block 6952 if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { 6953 if ( jQuery.css( elem, "float" ) === "none" ) { 6954 6955 // Restore the original display value at the end of pure show/hide animations 6956 if ( !propTween ) { 6957 anim.done( function() { 6958 style.display = restoreDisplay; 6959 } ); 6960 if ( restoreDisplay == null ) { 6961 display = style.display; 6962 restoreDisplay = display === "none" ? "" : display; 6963 } 6964 } 6965 style.display = "inline-block"; 6966 } 6967 } 6968 } 6969 6970 if ( opts.overflow ) { 6971 style.overflow = "hidden"; 6972 anim.always( function() { 6973 style.overflow = opts.overflow[ 0 ]; 6974 style.overflowX = opts.overflow[ 1 ]; 6975 style.overflowY = opts.overflow[ 2 ]; 6976 } ); 6977 } 6978 6979 // Implement show/hide animations 6980 propTween = false; 6981 for ( prop in orig ) { 6982 6983 // General show/hide setup for this element animation 6984 if ( !propTween ) { 6985 if ( dataShow ) { 6986 if ( "hidden" in dataShow ) { 6987 hidden = dataShow.hidden; 6988 } 6989 } else { 6990 dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); 6991 } 6992 6993 // Store hidden/visible for toggle so `.stop().toggle()` "reverses" 6994 if ( toggle ) { 6995 dataShow.hidden = !hidden; 6996 } 6997 6998 // Show elements before animating them 6999 if ( hidden ) { 7000 showHide( [ elem ], true ); 7001 } 7002 7003 /* eslint-disable no-loop-func */ 7004 7005 anim.done( function() { 7006 7007 /* eslint-enable no-loop-func */ 7008 7009 // The final step of a "hide" animation is actually hiding the element 7010 if ( !hidden ) { 7011 showHide( [ elem ] ); 7012 } 7013 dataPriv.remove( elem, "fxshow" ); 7014 for ( prop in orig ) { 7015 jQuery.style( elem, prop, orig[ prop ] ); 7016 } 7017 } ); 7018 } 7019 7020 // Per-property setup 7021 propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); 7022 if ( !( prop in dataShow ) ) { 7023 dataShow[ prop ] = propTween.start; 7024 if ( hidden ) { 7025 propTween.end = propTween.start; 7026 propTween.start = 0; 7027 } 7028 } 7029 } 7030} 7031 7032function propFilter( props, specialEasing ) { 7033 var index, name, easing, value, hooks; 7034 7035 // camelCase, specialEasing and expand cssHook pass 7036 for ( index in props ) { 7037 name = camelCase( index ); 7038 easing = specialEasing[ name ]; 7039 value = props[ index ]; 7040 if ( Array.isArray( value ) ) { 7041 easing = value[ 1 ]; 7042 value = props[ index ] = value[ 0 ]; 7043 } 7044 7045 if ( index !== name ) { 7046 props[ name ] = value; 7047 delete props[ index ]; 7048 } 7049 7050 hooks = jQuery.cssHooks[ name ]; 7051 if ( hooks && "expand" in hooks ) { 7052 value = hooks.expand( value ); 7053 delete props[ name ]; 7054 7055 // Not quite $.extend, this won't overwrite existing keys. 7056 // Reusing 'index' because we have the correct "name" 7057 for ( index in value ) { 7058 if ( !( index in props ) ) { 7059 props[ index ] = value[ index ]; 7060 specialEasing[ index ] = easing; 7061 } 7062 } 7063 } else { 7064 specialEasing[ name ] = easing; 7065 } 7066 } 7067} 7068 7069function Animation( elem, properties, options ) { 7070 var result, 7071 stopped, 7072 index = 0, 7073 length = Animation.prefilters.length, 7074 deferred = jQuery.Deferred().always( function() { 7075 7076 // Don't match elem in the :animated selector 7077 delete tick.elem; 7078 } ), 7079 tick = function() { 7080 if ( stopped ) { 7081 return false; 7082 } 7083 var currentTime = fxNow || createFxNow(), 7084 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), 7085 7086 // Support: Android 2.3 only 7087 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) 7088 temp = remaining / animation.duration || 0, 7089 percent = 1 - temp, 7090 index = 0, 7091 length = animation.tweens.length; 7092 7093 for ( ; index < length; index++ ) { 7094 animation.tweens[ index ].run( percent ); 7095 } 7096 7097 deferred.notifyWith( elem, [ animation, percent, remaining ] ); 7098 7099 // If there's more to do, yield 7100 if ( percent < 1 && length ) { 7101 return remaining; 7102 } 7103 7104 // If this was an empty animation, synthesize a final progress notification 7105 if ( !length ) { 7106 deferred.notifyWith( elem, [ animation, 1, 0 ] ); 7107 } 7108 7109 // Resolve the animation and report its conclusion 7110 deferred.resolveWith( elem, [ animation ] ); 7111 return false; 7112 }, 7113 animation = deferred.promise( { 7114 elem: elem, 7115 props: jQuery.extend( {}, properties ), 7116 opts: jQuery.extend( true, { 7117 specialEasing: {}, 7118 easing: jQuery.easing._default 7119 }, options ), 7120 originalProperties: properties, 7121 originalOptions: options, 7122 startTime: fxNow || createFxNow(), 7123 duration: options.duration, 7124 tweens: [], 7125 createTween: function( prop, end ) { 7126 var tween = jQuery.Tween( elem, animation.opts, prop, end, 7127 animation.opts.specialEasing[ prop ] || animation.opts.easing ); 7128 animation.tweens.push( tween ); 7129 return tween; 7130 }, 7131 stop: function( gotoEnd ) { 7132 var index = 0, 7133 7134 // If we are going to the end, we want to run all the tweens 7135 // otherwise we skip this part 7136 length = gotoEnd ? animation.tweens.length : 0; 7137 if ( stopped ) { 7138 return this; 7139 } 7140 stopped = true; 7141 for ( ; index < length; index++ ) { 7142 animation.tweens[ index ].run( 1 ); 7143 } 7144 7145 // Resolve when we played the last frame; otherwise, reject 7146 if ( gotoEnd ) { 7147 deferred.notifyWith( elem, [ animation, 1, 0 ] ); 7148 deferred.resolveWith( elem, [ animation, gotoEnd ] ); 7149 } else { 7150 deferred.rejectWith( elem, [ animation, gotoEnd ] ); 7151 } 7152 return this; 7153 } 7154 } ), 7155 props = animation.props; 7156 7157 propFilter( props, animation.opts.specialEasing ); 7158 7159 for ( ; index < length; index++ ) { 7160 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); 7161 if ( result ) { 7162 if ( isFunction( result.stop ) ) { 7163 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = 7164 result.stop.bind( result ); 7165 } 7166 return result; 7167 } 7168 } 7169 7170 jQuery.map( props, createTween, animation ); 7171 7172 if ( isFunction( animation.opts.start ) ) { 7173 animation.opts.start.call( elem, animation ); 7174 } 7175 7176 // Attach callbacks from options 7177 animation 7178 .progress( animation.opts.progress ) 7179 .done( animation.opts.done, animation.opts.complete ) 7180 .fail( animation.opts.fail ) 7181 .always( animation.opts.always ); 7182 7183 jQuery.fx.timer( 7184 jQuery.extend( tick, { 7185 elem: elem, 7186 anim: animation, 7187 queue: animation.opts.queue 7188 } ) 7189 ); 7190 7191 return animation; 7192} 7193 7194jQuery.Animation = jQuery.extend( Animation, { 7195 7196 tweeners: { 7197 "*": [ function( prop, value ) { 7198 var tween = this.createTween( prop, value ); 7199 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); 7200 return tween; 7201 } ] 7202 }, 7203 7204 tweener: function( props, callback ) { 7205 if ( isFunction( props ) ) { 7206 callback = props; 7207 props = [ "*" ]; 7208 } else { 7209 props = props.match( rnothtmlwhite ); 7210 } 7211 7212 var prop, 7213 index = 0, 7214 length = props.length; 7215 7216 for ( ; index < length; index++ ) { 7217 prop = props[ index ]; 7218 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; 7219 Animation.tweeners[ prop ].unshift( callback ); 7220 } 7221 }, 7222 7223 prefilters: [ defaultPrefilter ], 7224 7225 prefilter: function( callback, prepend ) { 7226 if ( prepend ) { 7227 Animation.prefilters.unshift( callback ); 7228 } else { 7229 Animation.prefilters.push( callback ); 7230 } 7231 } 7232} ); 7233 7234jQuery.speed = function( speed, easing, fn ) { 7235 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { 7236 complete: fn || !fn && easing || 7237 isFunction( speed ) && speed, 7238 duration: speed, 7239 easing: fn && easing || easing && !isFunction( easing ) && easing 7240 }; 7241 7242 // Go to the end state if fx are off 7243 if ( jQuery.fx.off ) { 7244 opt.duration = 0; 7245 7246 } else { 7247 if ( typeof opt.duration !== "number" ) { 7248 if ( opt.duration in jQuery.fx.speeds ) { 7249 opt.duration = jQuery.fx.speeds[ opt.duration ]; 7250 7251 } else { 7252 opt.duration = jQuery.fx.speeds._default; 7253 } 7254 } 7255 } 7256 7257 // Normalize opt.queue - true/undefined/null -> "fx" 7258 if ( opt.queue == null || opt.queue === true ) { 7259 opt.queue = "fx"; 7260 } 7261 7262 // Queueing 7263 opt.old = opt.complete; 7264 7265 opt.complete = function() { 7266 if ( isFunction( opt.old ) ) { 7267 opt.old.call( this ); 7268 } 7269 7270 if ( opt.queue ) { 7271 jQuery.dequeue( this, opt.queue ); 7272 } 7273 }; 7274 7275 return opt; 7276}; 7277 7278jQuery.fn.extend( { 7279 fadeTo: function( speed, to, easing, callback ) { 7280 7281 // Show any hidden elements after setting opacity to 0 7282 return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show() 7283 7284 // Animate to the value specified 7285 .end().animate( { opacity: to }, speed, easing, callback ); 7286 }, 7287 animate: function( prop, speed, easing, callback ) { 7288 var empty = jQuery.isEmptyObject( prop ), 7289 optall = jQuery.speed( speed, easing, callback ), 7290 doAnimation = function() { 7291 7292 // Operate on a copy of prop so per-property easing won't be lost 7293 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); 7294 7295 // Empty animations, or finishing resolves immediately 7296 if ( empty || dataPriv.get( this, "finish" ) ) { 7297 anim.stop( true ); 7298 } 7299 }; 7300 doAnimation.finish = doAnimation; 7301 7302 return empty || optall.queue === false ? 7303 this.each( doAnimation ) : 7304 this.queue( optall.queue, doAnimation ); 7305 }, 7306 stop: function( type, clearQueue, gotoEnd ) { 7307 var stopQueue = function( hooks ) { 7308 var stop = hooks.stop; 7309 delete hooks.stop; 7310 stop( gotoEnd ); 7311 }; 7312 7313 if ( typeof type !== "string" ) { 7314 gotoEnd = clearQueue; 7315 clearQueue = type; 7316 type = undefined; 7317 } 7318 if ( clearQueue && type !== false ) { 7319 this.queue( type || "fx", [] ); 7320 } 7321 7322 return this.each( function() { 7323 var dequeue = true, 7324 index = type != null && type + "queueHooks", 7325 timers = jQuery.timers, 7326 data = dataPriv.get( this ); 7327 7328 if ( index ) { 7329 if ( data[ index ] && data[ index ].stop ) { 7330 stopQueue( data[ index ] ); 7331 } 7332 } else { 7333 for ( index in data ) { 7334 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { 7335 stopQueue( data[ index ] ); 7336 } 7337 } 7338 } 7339 7340 for ( index = timers.length; index--; ) { 7341 if ( timers[ index ].elem === this && 7342 ( type == null || timers[ index ].queue === type ) ) { 7343 7344 timers[ index ].anim.stop( gotoEnd ); 7345 dequeue = false; 7346 timers.splice( index, 1 ); 7347 } 7348 } 7349 7350 // Start the next in the queue if the last step wasn't forced. 7351 // Timers currently will call their complete callbacks, which 7352 // will dequeue but only if they were gotoEnd. 7353 if ( dequeue || !gotoEnd ) { 7354 jQuery.dequeue( this, type ); 7355 } 7356 } ); 7357 }, 7358 finish: function( type ) { 7359 if ( type !== false ) { 7360 type = type || "fx"; 7361 } 7362 return this.each( function() { 7363 var index, 7364 data = dataPriv.get( this ), 7365 queue = data[ type + "queue" ], 7366 hooks = data[ type + "queueHooks" ], 7367 timers = jQuery.timers, 7368 length = queue ? queue.length : 0; 7369 7370 // Enable finishing flag on private data 7371 data.finish = true; 7372 7373 // Empty the queue first 7374 jQuery.queue( this, type, [] ); 7375 7376 if ( hooks && hooks.stop ) { 7377 hooks.stop.call( this, true ); 7378 } 7379 7380 // Look for any active animations, and finish them 7381 for ( index = timers.length; index--; ) { 7382 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { 7383 timers[ index ].anim.stop( true ); 7384 timers.splice( index, 1 ); 7385 } 7386 } 7387 7388 // Look for any animations in the old queue and finish them 7389 for ( index = 0; index < length; index++ ) { 7390 if ( queue[ index ] && queue[ index ].finish ) { 7391 queue[ index ].finish.call( this ); 7392 } 7393 } 7394 7395 // Turn off finishing flag 7396 delete data.finish; 7397 } ); 7398 } 7399} ); 7400 7401jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) { 7402 var cssFn = jQuery.fn[ name ]; 7403 jQuery.fn[ name ] = function( speed, easing, callback ) { 7404 return speed == null || typeof speed === "boolean" ? 7405 cssFn.apply( this, arguments ) : 7406 this.animate( genFx( name, true ), speed, easing, callback ); 7407 }; 7408} ); 7409 7410// Generate shortcuts for custom animations 7411jQuery.each( { 7412 slideDown: genFx( "show" ), 7413 slideUp: genFx( "hide" ), 7414 slideToggle: genFx( "toggle" ), 7415 fadeIn: { opacity: "show" }, 7416 fadeOut: { opacity: "hide" }, 7417 fadeToggle: { opacity: "toggle" } 7418}, function( name, props ) { 7419 jQuery.fn[ name ] = function( speed, easing, callback ) { 7420 return this.animate( props, speed, easing, callback ); 7421 }; 7422} ); 7423 7424jQuery.timers = []; 7425jQuery.fx.tick = function() { 7426 var timer, 7427 i = 0, 7428 timers = jQuery.timers; 7429 7430 fxNow = Date.now(); 7431 7432 for ( ; i < timers.length; i++ ) { 7433 timer = timers[ i ]; 7434 7435 // Run the timer and safely remove it when done (allowing for external removal) 7436 if ( !timer() && timers[ i ] === timer ) { 7437 timers.splice( i--, 1 ); 7438 } 7439 } 7440 7441 if ( !timers.length ) { 7442 jQuery.fx.stop(); 7443 } 7444 fxNow = undefined; 7445}; 7446 7447jQuery.fx.timer = function( timer ) { 7448 jQuery.timers.push( timer ); 7449 jQuery.fx.start(); 7450}; 7451 7452jQuery.fx.interval = 13; 7453jQuery.fx.start = function() { 7454 if ( inProgress ) { 7455 return; 7456 } 7457 7458 inProgress = true; 7459 schedule(); 7460}; 7461 7462jQuery.fx.stop = function() { 7463 inProgress = null; 7464}; 7465 7466jQuery.fx.speeds = { 7467 slow: 600, 7468 fast: 200, 7469 7470 // Default speed 7471 _default: 400 7472}; 7473 7474 7475// Based off of the plugin by Clint Helfers, with permission. 7476// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ 7477jQuery.fn.delay = function( time, type ) { 7478 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; 7479 type = type || "fx"; 7480 7481 return this.queue( type, function( next, hooks ) { 7482 var timeout = window.setTimeout( next, time ); 7483 hooks.stop = function() { 7484 window.clearTimeout( timeout ); 7485 }; 7486 } ); 7487}; 7488 7489 7490( function() { 7491 var input = document.createElement( "input" ), 7492 select = document.createElement( "select" ), 7493 opt = select.appendChild( document.createElement( "option" ) ); 7494 7495 input.type = "checkbox"; 7496 7497 // Support: Android <=4.3 only 7498 // Default value for a checkbox should be "on" 7499 support.checkOn = input.value !== ""; 7500 7501 // Support: IE <=11 only 7502 // Must access selectedIndex to make default options select 7503 support.optSelected = opt.selected; 7504 7505 // Support: IE <=11 only 7506 // An input loses its value after becoming a radio 7507 input = document.createElement( "input" ); 7508 input.value = "t"; 7509 input.type = "radio"; 7510 support.radioValue = input.value === "t"; 7511} )(); 7512 7513 7514var boolHook, 7515 attrHandle = jQuery.expr.attrHandle; 7516 7517jQuery.fn.extend( { 7518 attr: function( name, value ) { 7519 return access( this, jQuery.attr, name, value, arguments.length > 1 ); 7520 }, 7521 7522 removeAttr: function( name ) { 7523 return this.each( function() { 7524 jQuery.removeAttr( this, name ); 7525 } ); 7526 } 7527} ); 7528 7529jQuery.extend( { 7530 attr: function( elem, name, value ) { 7531 var ret, hooks, 7532 nType = elem.nodeType; 7533 7534 // Don't get/set attributes on text, comment and attribute nodes 7535 if ( nType === 3 || nType === 8 || nType === 2 ) { 7536 return; 7537 } 7538 7539 // Fallback to prop when attributes are not supported 7540 if ( typeof elem.getAttribute === "undefined" ) { 7541 return jQuery.prop( elem, name, value ); 7542 } 7543 7544 // Attribute hooks are determined by the lowercase version 7545 // Grab necessary hook if one is defined 7546 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 7547 hooks = jQuery.attrHooks[ name.toLowerCase() ] || 7548 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); 7549 } 7550 7551 if ( value !== undefined ) { 7552 if ( value === null ) { 7553 jQuery.removeAttr( elem, name ); 7554 return; 7555 } 7556 7557 if ( hooks && "set" in hooks && 7558 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 7559 return ret; 7560 } 7561 7562 elem.setAttribute( name, value + "" ); 7563 return value; 7564 } 7565 7566 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 7567 return ret; 7568 } 7569 7570 ret = jQuery.find.attr( elem, name ); 7571 7572 // Non-existent attributes return null, we normalize to undefined 7573 return ret == null ? undefined : ret; 7574 }, 7575 7576 attrHooks: { 7577 type: { 7578 set: function( elem, value ) { 7579 if ( !support.radioValue && value === "radio" && 7580 nodeName( elem, "input" ) ) { 7581 var val = elem.value; 7582 elem.setAttribute( "type", value ); 7583 if ( val ) { 7584 elem.value = val; 7585 } 7586 return value; 7587 } 7588 } 7589 } 7590 }, 7591 7592 removeAttr: function( elem, value ) { 7593 var name, 7594 i = 0, 7595 7596 // Attribute names can contain non-HTML whitespace characters 7597 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 7598 attrNames = value && value.match( rnothtmlwhite ); 7599 7600 if ( attrNames && elem.nodeType === 1 ) { 7601 while ( ( name = attrNames[ i++ ] ) ) { 7602 elem.removeAttribute( name ); 7603 } 7604 } 7605 } 7606} ); 7607 7608// Hooks for boolean attributes 7609boolHook = { 7610 set: function( elem, value, name ) { 7611 if ( value === false ) { 7612 7613 // Remove boolean attributes when set to false 7614 jQuery.removeAttr( elem, name ); 7615 } else { 7616 elem.setAttribute( name, name ); 7617 } 7618 return name; 7619 } 7620}; 7621 7622jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { 7623 var getter = attrHandle[ name ] || jQuery.find.attr; 7624 7625 attrHandle[ name ] = function( elem, name, isXML ) { 7626 var ret, handle, 7627 lowercaseName = name.toLowerCase(); 7628 7629 if ( !isXML ) { 7630 7631 // Avoid an infinite loop by temporarily removing this function from the getter 7632 handle = attrHandle[ lowercaseName ]; 7633 attrHandle[ lowercaseName ] = ret; 7634 ret = getter( elem, name, isXML ) != null ? 7635 lowercaseName : 7636 null; 7637 attrHandle[ lowercaseName ] = handle; 7638 } 7639 return ret; 7640 }; 7641} ); 7642 7643 7644 7645 7646var rfocusable = /^(?:input|select|textarea|button)$/i, 7647 rclickable = /^(?:a|area)$/i; 7648 7649jQuery.fn.extend( { 7650 prop: function( name, value ) { 7651 return access( this, jQuery.prop, name, value, arguments.length > 1 ); 7652 }, 7653 7654 removeProp: function( name ) { 7655 return this.each( function() { 7656 delete this[ jQuery.propFix[ name ] || name ]; 7657 } ); 7658 } 7659} ); 7660 7661jQuery.extend( { 7662 prop: function( elem, name, value ) { 7663 var ret, hooks, 7664 nType = elem.nodeType; 7665 7666 // Don't get/set properties on text, comment and attribute nodes 7667 if ( nType === 3 || nType === 8 || nType === 2 ) { 7668 return; 7669 } 7670 7671 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 7672 7673 // Fix name and attach hooks 7674 name = jQuery.propFix[ name ] || name; 7675 hooks = jQuery.propHooks[ name ]; 7676 } 7677 7678 if ( value !== undefined ) { 7679 if ( hooks && "set" in hooks && 7680 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 7681 return ret; 7682 } 7683 7684 return ( elem[ name ] = value ); 7685 } 7686 7687 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 7688 return ret; 7689 } 7690 7691 return elem[ name ]; 7692 }, 7693 7694 propHooks: { 7695 tabIndex: { 7696 get: function( elem ) { 7697 7698 // Support: IE <=9 - 11 only 7699 // elem.tabIndex doesn't always return the 7700 // correct value when it hasn't been explicitly set 7701 // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ 7702 // Use proper attribute retrieval(#12072) 7703 var tabindex = jQuery.find.attr( elem, "tabindex" ); 7704 7705 if ( tabindex ) { 7706 return parseInt( tabindex, 10 ); 7707 } 7708 7709 if ( 7710 rfocusable.test( elem.nodeName ) || 7711 rclickable.test( elem.nodeName ) && 7712 elem.href 7713 ) { 7714 return 0; 7715 } 7716 7717 return -1; 7718 } 7719 } 7720 }, 7721 7722 propFix: { 7723 "for": "htmlFor", 7724 "class": "className" 7725 } 7726} ); 7727 7728// Support: IE <=11 only 7729// Accessing the selectedIndex property 7730// forces the browser to respect setting selected 7731// on the option 7732// The getter ensures a default option is selected 7733// when in an optgroup 7734// eslint rule "no-unused-expressions" is disabled for this code 7735// since it considers such accessions noop 7736if ( !support.optSelected ) { 7737 jQuery.propHooks.selected = { 7738 get: function( elem ) { 7739 7740 /* eslint no-unused-expressions: "off" */ 7741 7742 var parent = elem.parentNode; 7743 if ( parent && parent.parentNode ) { 7744 parent.parentNode.selectedIndex; 7745 } 7746 return null; 7747 }, 7748 set: function( elem ) { 7749 7750 /* eslint no-unused-expressions: "off" */ 7751 7752 var parent = elem.parentNode; 7753 if ( parent ) { 7754 parent.selectedIndex; 7755 7756 if ( parent.parentNode ) { 7757 parent.parentNode.selectedIndex; 7758 } 7759 } 7760 } 7761 }; 7762} 7763 7764jQuery.each( [ 7765 "tabIndex", 7766 "readOnly", 7767 "maxLength", 7768 "cellSpacing", 7769 "cellPadding", 7770 "rowSpan", 7771 "colSpan", 7772 "useMap", 7773 "frameBorder", 7774 "contentEditable" 7775], function() { 7776 jQuery.propFix[ this.toLowerCase() ] = this; 7777} ); 7778 7779 7780 7781 7782 // Strip and collapse whitespace according to HTML spec 7783 // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace 7784 function stripAndCollapse( value ) { 7785 var tokens = value.match( rnothtmlwhite ) || []; 7786 return tokens.join( " " ); 7787 } 7788 7789 7790function getClass( elem ) { 7791 return elem.getAttribute && elem.getAttribute( "class" ) || ""; 7792} 7793 7794function classesToArray( value ) { 7795 if ( Array.isArray( value ) ) { 7796 return value; 7797 } 7798 if ( typeof value === "string" ) { 7799 return value.match( rnothtmlwhite ) || []; 7800 } 7801 return []; 7802} 7803 7804jQuery.fn.extend( { 7805 addClass: function( value ) { 7806 var classes, elem, cur, curValue, clazz, j, finalValue, 7807 i = 0; 7808 7809 if ( isFunction( value ) ) { 7810 return this.each( function( j ) { 7811 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); 7812 } ); 7813 } 7814 7815 classes = classesToArray( value ); 7816 7817 if ( classes.length ) { 7818 while ( ( elem = this[ i++ ] ) ) { 7819 curValue = getClass( elem ); 7820 cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); 7821 7822 if ( cur ) { 7823 j = 0; 7824 while ( ( clazz = classes[ j++ ] ) ) { 7825 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { 7826 cur += clazz + " "; 7827 } 7828 } 7829 7830 // Only assign if different to avoid unneeded rendering. 7831 finalValue = stripAndCollapse( cur ); 7832 if ( curValue !== finalValue ) { 7833 elem.setAttribute( "class", finalValue ); 7834 } 7835 } 7836 } 7837 } 7838 7839 return this; 7840 }, 7841 7842 removeClass: function( value ) { 7843 var classes, elem, cur, curValue, clazz, j, finalValue, 7844 i = 0; 7845 7846 if ( isFunction( value ) ) { 7847 return this.each( function( j ) { 7848 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); 7849 } ); 7850 } 7851 7852 if ( !arguments.length ) { 7853 return this.attr( "class", "" ); 7854 } 7855 7856 classes = classesToArray( value ); 7857 7858 if ( classes.length ) { 7859 while ( ( elem = this[ i++ ] ) ) { 7860 curValue = getClass( elem ); 7861 7862 // This expression is here for better compressibility (see addClass) 7863 cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); 7864 7865 if ( cur ) { 7866 j = 0; 7867 while ( ( clazz = classes[ j++ ] ) ) { 7868 7869 // Remove *all* instances 7870 while ( cur.indexOf( " " + clazz + " " ) > -1 ) { 7871 cur = cur.replace( " " + clazz + " ", " " ); 7872 } 7873 } 7874 7875 // Only assign if different to avoid unneeded rendering. 7876 finalValue = stripAndCollapse( cur ); 7877 if ( curValue !== finalValue ) { 7878 elem.setAttribute( "class", finalValue ); 7879 } 7880 } 7881 } 7882 } 7883 7884 return this; 7885 }, 7886 7887 toggleClass: function( value, stateVal ) { 7888 var type = typeof value, 7889 isValidValue = type === "string" || Array.isArray( value ); 7890 7891 if ( typeof stateVal === "boolean" && isValidValue ) { 7892 return stateVal ? this.addClass( value ) : this.removeClass( value ); 7893 } 7894 7895 if ( isFunction( value ) ) { 7896 return this.each( function( i ) { 7897 jQuery( this ).toggleClass( 7898 value.call( this, i, getClass( this ), stateVal ), 7899 stateVal 7900 ); 7901 } ); 7902 } 7903 7904 return this.each( function() { 7905 var className, i, self, classNames; 7906 7907 if ( isValidValue ) { 7908 7909 // Toggle individual class names 7910 i = 0; 7911 self = jQuery( this ); 7912 classNames = classesToArray( value ); 7913 7914 while ( ( className = classNames[ i++ ] ) ) { 7915 7916 // Check each className given, space separated list 7917 if ( self.hasClass( className ) ) { 7918 self.removeClass( className ); 7919 } else { 7920 self.addClass( className ); 7921 } 7922 } 7923 7924 // Toggle whole class name 7925 } else if ( value === undefined || type === "boolean" ) { 7926 className = getClass( this ); 7927 if ( className ) { 7928 7929 // Store className if set 7930 dataPriv.set( this, "__className__", className ); 7931 } 7932 7933 // If the element has a class name or if we're passed `false`, 7934 // then remove the whole classname (if there was one, the above saved it). 7935 // Otherwise bring back whatever was previously saved (if anything), 7936 // falling back to the empty string if nothing was stored. 7937 if ( this.setAttribute ) { 7938 this.setAttribute( "class", 7939 className || value === false ? 7940 "" : 7941 dataPriv.get( this, "__className__" ) || "" 7942 ); 7943 } 7944 } 7945 } ); 7946 }, 7947 7948 hasClass: function( selector ) { 7949 var className, elem, 7950 i = 0; 7951 7952 className = " " + selector + " "; 7953 while ( ( elem = this[ i++ ] ) ) { 7954 if ( elem.nodeType === 1 && 7955 ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { 7956 return true; 7957 } 7958 } 7959 7960 return false;
vendor: 5,544 bytes, lines 7961-8196
7961 } 7962} ); 7963 7964 7965 7966 7967var rreturn = /\r/g; 7968 7969jQuery.fn.extend( { 7970 val: function( value ) { 7971 var hooks, ret, valueIsFunction, 7972 elem = this[ 0 ]; 7973 7974 if ( !arguments.length ) { 7975 if ( elem ) { 7976 hooks = jQuery.valHooks[ elem.type ] || 7977 jQuery.valHooks[ elem.nodeName.toLowerCase() ]; 7978 7979 if ( hooks && 7980 "get" in hooks && 7981 ( ret = hooks.get( elem, "value" ) ) !== undefined 7982 ) { 7983 return ret; 7984 } 7985 7986 ret = elem.value; 7987 7988 // Handle most common string cases 7989 if ( typeof ret === "string" ) { 7990 return ret.replace( rreturn, "" ); 7991 } 7992 7993 // Handle cases where value is null/undef or number 7994 return ret == null ? "" : ret; 7995 } 7996 7997 return; 7998 } 7999 8000 valueIsFunction = isFunction( value ); 8001 8002 return this.each( function( i ) { 8003 var val; 8004 8005 if ( this.nodeType !== 1 ) { 8006 return; 8007 } 8008 8009 if ( valueIsFunction ) { 8010 val = value.call( this, i, jQuery( this ).val() ); 8011 } else { 8012 val = value; 8013 } 8014 8015 // Treat null/undefined as ""; convert numbers to string 8016 if ( val == null ) { 8017 val = ""; 8018 8019 } else if ( typeof val === "number" ) { 8020 val += ""; 8021 8022 } else if ( Array.isArray( val ) ) { 8023 val = jQuery.map( val, function( value ) { 8024 return value == null ? "" : value + ""; 8025 } ); 8026 } 8027 8028 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; 8029 8030 // If set returns undefined, fall back to normal setting 8031 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { 8032 this.value = val; 8033 } 8034 } ); 8035 } 8036} ); 8037 8038jQuery.extend( { 8039 valHooks: { 8040 option: { 8041 get: function( elem ) { 8042 8043 var val = jQuery.find.attr( elem, "value" ); 8044 return val != null ? 8045 val : 8046 8047 // Support: IE <=10 - 11 only 8048 // option.text throws exceptions (#14686, #14858) 8049 // Strip and collapse whitespace 8050 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace 8051 stripAndCollapse( jQuery.text( elem ) ); 8052 } 8053 }, 8054 select: { 8055 get: function( elem ) { 8056 var value, option, i, 8057 options = elem.options, 8058 index = elem.selectedIndex, 8059 one = elem.type === "select-one", 8060 values = one ? null : [], 8061 max = one ? index + 1 : options.length; 8062 8063 if ( index < 0 ) { 8064 i = max; 8065 8066 } else { 8067 i = one ? index : 0; 8068 } 8069 8070 // Loop through all the selected options 8071 for ( ; i < max; i++ ) { 8072 option = options[ i ]; 8073 8074 // Support: IE <=9 only 8075 // IE8-9 doesn't update selected after form reset (#2551) 8076 if ( ( option.selected || i === index ) && 8077 8078 // Don't return options that are disabled or in a disabled optgroup 8079 !option.disabled && 8080 ( !option.parentNode.disabled || 8081 !nodeName( option.parentNode, "optgroup" ) ) ) { 8082 8083 // Get the specific value for the option 8084 value = jQuery( option ).val(); 8085 8086 // We don't need an array for one selects 8087 if ( one ) { 8088 return value; 8089 } 8090 8091 // Multi-Selects return an array 8092 values.push( value ); 8093 } 8094 } 8095 8096 return values; 8097 }, 8098 8099 set: function( elem, value ) { 8100 var optionSet, option, 8101 options = elem.options, 8102 values = jQuery.makeArray( value ), 8103 i = options.length; 8104 8105 while ( i-- ) { 8106 option = options[ i ]; 8107 8108 /* eslint-disable no-cond-assign */ 8109 8110 if ( option.selected = 8111 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 8112 ) { 8113 optionSet = true; 8114 } 8115 8116 /* eslint-enable no-cond-assign */ 8117 } 8118 8119 // Force browsers to behave consistently when non-matching value is set 8120 if ( !optionSet ) { 8121 elem.selectedIndex = -1; 8122 } 8123 return values; 8124 } 8125 } 8126 } 8127} ); 8128 8129// Radios and checkboxes getter/setter 8130jQuery.each( [ "radio", "checkbox" ], function() { 8131 jQuery.valHooks[ this ] = { 8132 set: function( elem, value ) { 8133 if ( Array.isArray( value ) ) { 8134 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); 8135 } 8136 } 8137 }; 8138 if ( !support.checkOn ) { 8139 jQuery.valHooks[ this ].get = function( elem ) { 8140 return elem.getAttribute( "value" ) === null ? "on" : elem.value; 8141 }; 8142 } 8143} ); 8144 8145 8146 8147 8148// Return jQuery for attributes-only inclusion 8149 8150 8151support.focusin = "onfocusin" in window; 8152 8153 8154var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, 8155 stopPropagationCallback = function( e ) { 8156 e.stopPropagation(); 8157 }; 8158 8159jQuery.extend( jQuery.event, { 8160 8161 trigger: function( event, data, elem, onlyHandlers ) { 8162 8163 var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, 8164 eventPath = [ elem || document ], 8165 type = hasOwn.call( event, "type" ) ? event.type : event, 8166 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; 8167 8168 cur = lastElement = tmp = elem = elem || document; 8169 8170 // Don't do events on text and comment nodes 8171 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { 8172 return; 8173 } 8174 8175 // focus/blur morphs to focusin/out; ensure we're not firing them right now 8176 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { 8177 return; 8178 } 8179 8180 if ( type.indexOf( "." ) > -1 ) { 8181 8182 // Namespaced trigger; create a regexp to match event type in handle() 8183 namespaces = type.split( "." ); 8184 type = namespaces.shift(); 8185 namespaces.sort(); 8186 } 8187 ontype = type.indexOf( ":" ) < 0 && "on" + type; 8188 8189 // Caller can pass in a jQuery.Event object, Object, or just an event type string 8190 event = event[ jQuery.expando ] ? 8191 event : 8192 new jQuery.Event( type, typeof event === "object" && event ); 8193 8194 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) 8195 event.isTrigger = onlyHandlers ? 2 : 3; 8196 event.namespace = namespaces.join( "." );
vendor: 32,532 bytes, lines 8197-9468
8197 event.rnamespace = event.namespace ? 8198 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : 8199 null; 8200 8201 // Clean up the event in case it is being reused 8202 event.result = undefined; 8203 if ( !event.target ) { 8204 event.target = elem; 8205 } 8206 8207 // Clone any incoming data and prepend the event, creating the handler arg list 8208 data = data == null ? 8209 [ event ] : 8210 jQuery.makeArray( data, [ event ] ); 8211 8212 // Allow special events to draw outside the lines 8213 special = jQuery.event.special[ type ] || {}; 8214 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { 8215 return; 8216 } 8217 8218 // Determine event propagation path in advance, per W3C events spec (#9951) 8219 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) 8220 if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { 8221 8222 bubbleType = special.delegateType || type; 8223 if ( !rfocusMorph.test( bubbleType + type ) ) { 8224 cur = cur.parentNode; 8225 } 8226 for ( ; cur; cur = cur.parentNode ) { 8227 eventPath.push( cur ); 8228 tmp = cur; 8229 } 8230 8231 // Only add window if we got to document (e.g., not plain obj or detached DOM) 8232 if ( tmp === ( elem.ownerDocument || document ) ) { 8233 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); 8234 } 8235 } 8236 8237 // Fire handlers on the event path 8238 i = 0; 8239 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { 8240 lastElement = cur; 8241 event.type = i > 1 ? 8242 bubbleType : 8243 special.bindType || type; 8244 8245 // jQuery handler 8246 handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] && 8247 dataPriv.get( cur, "handle" ); 8248 if ( handle ) { 8249 handle.apply( cur, data ); 8250 } 8251 8252 // Native handler 8253 handle = ontype && cur[ ontype ]; 8254 if ( handle && handle.apply && acceptData( cur ) ) { 8255 event.result = handle.apply( cur, data ); 8256 if ( event.result === false ) { 8257 event.preventDefault(); 8258 } 8259 } 8260 } 8261 event.type = type; 8262 8263 // If nobody prevented the default action, do it now 8264 if ( !onlyHandlers && !event.isDefaultPrevented() ) { 8265 8266 if ( ( !special._default || 8267 special._default.apply( eventPath.pop(), data ) === false ) && 8268 acceptData( elem ) ) { 8269 8270 // Call a native DOM method on the target with the same name as the event. 8271 // Don't do default actions on window, that's where global variables be (#6170) 8272 if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { 8273 8274 // Don't re-trigger an onFOO event when we call its FOO() method 8275 tmp = elem[ ontype ]; 8276 8277 if ( tmp ) { 8278 elem[ ontype ] = null; 8279 } 8280 8281 // Prevent re-triggering of the same event, since we already bubbled it above 8282 jQuery.event.triggered = type; 8283 8284 if ( event.isPropagationStopped() ) { 8285 lastElement.addEventListener( type, stopPropagationCallback ); 8286 } 8287 8288 elem[ type ](); 8289 8290 if ( event.isPropagationStopped() ) { 8291 lastElement.removeEventListener( type, stopPropagationCallback ); 8292 } 8293 8294 jQuery.event.triggered = undefined; 8295 8296 if ( tmp ) { 8297 elem[ ontype ] = tmp; 8298 } 8299 } 8300 } 8301 } 8302 8303 return event.result; 8304 }, 8305 8306 // Piggyback on a donor event to simulate a different one 8307 // Used only for `focus(in | out)` events 8308 simulate: function( type, elem, event ) { 8309 var e = jQuery.extend( 8310 new jQuery.Event(), 8311 event, 8312 { 8313 type: type, 8314 isSimulated: true 8315 } 8316 ); 8317 8318 jQuery.event.trigger( e, null, elem ); 8319 } 8320 8321} ); 8322 8323jQuery.fn.extend( { 8324 8325 trigger: function( type, data ) { 8326 return this.each( function() { 8327 jQuery.event.trigger( type, data, this ); 8328 } ); 8329 }, 8330 triggerHandler: function( type, data ) { 8331 var elem = this[ 0 ]; 8332 if ( elem ) { 8333 return jQuery.event.trigger( type, data, elem, true ); 8334 } 8335 } 8336} ); 8337 8338 8339// Support: Firefox <=44 8340// Firefox doesn't have focus(in | out) events 8341// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 8342// 8343// Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 8344// focus(in | out) events fire after focus & blur events, 8345// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order 8346// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 8347if ( !support.focusin ) { 8348 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { 8349 8350 // Attach a single capturing handler on the document while someone wants focusin/focusout 8351 var handler = function( event ) { 8352 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); 8353 }; 8354 8355 jQuery.event.special[ fix ] = { 8356 setup: function() { 8357 var doc = this.ownerDocument || this, 8358 attaches = dataPriv.access( doc, fix ); 8359 8360 if ( !attaches ) { 8361 doc.addEventListener( orig, handler, true ); 8362 } 8363 dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); 8364 }, 8365 teardown: function() { 8366 var doc = this.ownerDocument || this, 8367 attaches = dataPriv.access( doc, fix ) - 1; 8368 8369 if ( !attaches ) { 8370 doc.removeEventListener( orig, handler, true ); 8371 dataPriv.remove( doc, fix ); 8372 8373 } else { 8374 dataPriv.access( doc, fix, attaches ); 8375 } 8376 } 8377 }; 8378 } ); 8379} 8380var location = window.location; 8381 8382var nonce = Date.now(); 8383 8384var rquery = ( /\?/ ); 8385 8386 8387 8388// Cross-browser xml parsing 8389jQuery.parseXML = function( data ) { 8390 var xml; 8391 if ( !data || typeof data !== "string" ) { 8392 return null; 8393 } 8394 8395 // Support: IE 9 - 11 only 8396 // IE throws on parseFromString with invalid input. 8397 try { 8398 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); 8399 } catch ( e ) { 8400 xml = undefined; 8401 } 8402 8403 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { 8404 jQuery.error( "Invalid XML: " + data ); 8405 } 8406 return xml; 8407}; 8408 8409 8410var 8411 rbracket = /\[\]$/, 8412 rCRLF = /\r?\n/g, 8413 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, 8414 rsubmittable = /^(?:input|select|textarea|keygen)/i; 8415 8416function buildParams( prefix, obj, traditional, add ) { 8417 var name; 8418 8419 if ( Array.isArray( obj ) ) { 8420 8421 // Serialize array item. 8422 jQuery.each( obj, function( i, v ) { 8423 if ( traditional || rbracket.test( prefix ) ) { 8424 8425 // Treat each array item as a scalar. 8426 add( prefix, v ); 8427 8428 } else { 8429 8430 // Item is non-scalar (array or object), encode its numeric index. 8431 buildParams( 8432 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", 8433 v, 8434 traditional, 8435 add 8436 ); 8437 } 8438 } ); 8439 8440 } else if ( !traditional && toType( obj ) === "object" ) { 8441 8442 // Serialize object item. 8443 for ( name in obj ) { 8444 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); 8445 } 8446 8447 } else { 8448 8449 // Serialize scalar item. 8450 add( prefix, obj ); 8451 } 8452} 8453 8454// Serialize an array of form elements or a set of 8455// key/values into a query string 8456jQuery.param = function( a, traditional ) { 8457 var prefix, 8458 s = [], 8459 add = function( key, valueOrFunction ) { 8460 8461 // If value is a function, invoke it and use its return value 8462 var value = isFunction( valueOrFunction ) ? 8463 valueOrFunction() : 8464 valueOrFunction; 8465 8466 s[ s.length ] = encodeURIComponent( key ) + "=" + 8467 encodeURIComponent( value == null ? "" : value ); 8468 }; 8469 8470 // If an array was passed in, assume that it is an array of form elements. 8471 if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { 8472 8473 // Serialize the form elements 8474 jQuery.each( a, function() { 8475 add( this.name, this.value ); 8476 } ); 8477 8478 } else { 8479 8480 // If traditional, encode the "old" way (the way 1.3.2 or older 8481 // did it), otherwise encode params recursively. 8482 for ( prefix in a ) { 8483 buildParams( prefix, a[ prefix ], traditional, add ); 8484 } 8485 } 8486 8487 // Return the resulting serialization 8488 return s.join( "&" ); 8489}; 8490 8491jQuery.fn.extend( { 8492 serialize: function() { 8493 return jQuery.param( this.serializeArray() ); 8494 }, 8495 serializeArray: function() { 8496 return this.map( function() { 8497 8498 // Can add propHook for "elements" to filter or add form elements 8499 var elements = jQuery.prop( this, "elements" ); 8500 return elements ? jQuery.makeArray( elements ) : this; 8501 } ) 8502 .filter( function() { 8503 var type = this.type; 8504 8505 // Use .is( ":disabled" ) so that fieldset[disabled] works 8506 return this.name && !jQuery( this ).is( ":disabled" ) && 8507 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && 8508 ( this.checked || !rcheckableType.test( type ) ); 8509 } ) 8510 .map( function( i, elem ) { 8511 var val = jQuery( this ).val(); 8512 8513 if ( val == null ) { 8514 return null; 8515 } 8516 8517 if ( Array.isArray( val ) ) { 8518 return jQuery.map( val, function( val ) { 8519 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 8520 } ); 8521 } 8522 8523 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 8524 } ).get(); 8525 } 8526} ); 8527 8528 8529var 8530 r20 = /%20/g, 8531 rhash = /#.*$/, 8532 rantiCache = /([?&])_=[^&]*/, 8533 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, 8534 8535 // #7653, #8125, #8152: local protocol detection 8536 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, 8537 rnoContent = /^(?:GET|HEAD)$/, 8538 rprotocol = /^\/\//, 8539 8540 /* Prefilters 8541 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) 8542 * 2) These are called: 8543 * - BEFORE asking for a transport 8544 * - AFTER param serialization (s.data is a string if s.processData is true) 8545 * 3) key is the dataType 8546 * 4) the catchall symbol "*" can be used 8547 * 5) execution will start with transport dataType and THEN continue down to "*" if needed 8548 */ 8549 prefilters = {}, 8550 8551 /* Transports bindings 8552 * 1) key is the dataType 8553 * 2) the catchall symbol "*" can be used 8554 * 3) selection will start with transport dataType and THEN go to "*" if needed 8555 */ 8556 transports = {}, 8557 8558 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression 8559 allTypes = "*/".concat( "*" ), 8560 8561 // Anchor tag for parsing the document origin 8562 originAnchor = document.createElement( "a" ); 8563 originAnchor.href = location.href; 8564 8565// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport 8566function addToPrefiltersOrTransports( structure ) { 8567 8568 // dataTypeExpression is optional and defaults to "*" 8569 return function( dataTypeExpression, func ) { 8570 8571 if ( typeof dataTypeExpression !== "string" ) { 8572 func = dataTypeExpression; 8573 dataTypeExpression = "*"; 8574 } 8575 8576 var dataType, 8577 i = 0, 8578 dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || []; 8579 8580 if ( isFunction( func ) ) { 8581 8582 // For each dataType in the dataTypeExpression 8583 while ( ( dataType = dataTypes[ i++ ] ) ) { 8584 8585 // Prepend if requested 8586 if ( dataType[ 0 ] === "+" ) { 8587 dataType = dataType.slice( 1 ) || "*"; 8588 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); 8589 8590 // Otherwise append 8591 } else { 8592 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); 8593 } 8594 } 8595 } 8596 }; 8597} 8598 8599// Base inspection function for prefilters and transports 8600function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { 8601 8602 var inspected = {}, 8603 seekingTransport = ( structure === transports ); 8604 8605 function inspect( dataType ) { 8606 var selected; 8607 inspected[ dataType ] = true; 8608 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { 8609 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); 8610 if ( typeof dataTypeOrTransport === "string" && 8611 !seekingTransport && !inspected[ dataTypeOrTransport ] ) { 8612 8613 options.dataTypes.unshift( dataTypeOrTransport ); 8614 inspect( dataTypeOrTransport ); 8615 return false; 8616 } else if ( seekingTransport ) { 8617 return !( selected = dataTypeOrTransport ); 8618 } 8619 } ); 8620 return selected; 8621 } 8622 8623 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); 8624} 8625 8626// A special extend for ajax options 8627// that takes "flat" options (not to be deep extended) 8628// Fixes #9887 8629function ajaxExtend( target, src ) { 8630 var key, deep, 8631 flatOptions = jQuery.ajaxSettings.flatOptions || {}; 8632 8633 for ( key in src ) { 8634 if ( src[ key ] !== undefined ) { 8635 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; 8636 } 8637 } 8638 if ( deep ) { 8639 jQuery.extend( true, target, deep ); 8640 } 8641 8642 return target; 8643} 8644 8645/* Handles responses to an ajax request: 8646 * - finds the right dataType (mediates between content-type and expected dataType) 8647 * - returns the corresponding response 8648 */ 8649function ajaxHandleResponses( s, jqXHR, responses ) { 8650 8651 var ct, type, finalDataType, firstDataType, 8652 contents = s.contents, 8653 dataTypes = s.dataTypes; 8654 8655 // Remove auto dataType and get content-type in the process 8656 while ( dataTypes[ 0 ] === "*" ) { 8657 dataTypes.shift(); 8658 if ( ct === undefined ) { 8659 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); 8660 } 8661 } 8662 8663 // Check if we're dealing with a known content-type 8664 if ( ct ) { 8665 for ( type in contents ) { 8666 if ( contents[ type ] && contents[ type ].test( ct ) ) { 8667 dataTypes.unshift( type ); 8668 break; 8669 } 8670 } 8671 } 8672 8673 // Check to see if we have a response for the expected dataType 8674 if ( dataTypes[ 0 ] in responses ) { 8675 finalDataType = dataTypes[ 0 ]; 8676 } else { 8677 8678 // Try convertible dataTypes 8679 for ( type in responses ) { 8680 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { 8681 finalDataType = type; 8682 break; 8683 } 8684 if ( !firstDataType ) { 8685 firstDataType = type; 8686 } 8687 } 8688 8689 // Or just use first one 8690 finalDataType = finalDataType || firstDataType; 8691 } 8692 8693 // If we found a dataType 8694 // We add the dataType to the list if needed 8695 // and return the corresponding response 8696 if ( finalDataType ) { 8697 if ( finalDataType !== dataTypes[ 0 ] ) { 8698 dataTypes.unshift( finalDataType ); 8699 } 8700 return responses[ finalDataType ]; 8701 } 8702} 8703 8704/* Chain conversions given the request and the original response 8705 * Also sets the responseXXX fields on the jqXHR instance 8706 */ 8707function ajaxConvert( s, response, jqXHR, isSuccess ) { 8708 var conv2, current, conv, tmp, prev, 8709 converters = {}, 8710 8711 // Work with a copy of dataTypes in case we need to modify it for conversion 8712 dataTypes = s.dataTypes.slice(); 8713 8714 // Create converters map with lowercased keys 8715 if ( dataTypes[ 1 ] ) { 8716 for ( conv in s.converters ) { 8717 converters[ conv.toLowerCase() ] = s.converters[ conv ]; 8718 } 8719 } 8720 8721 current = dataTypes.shift(); 8722 8723 // Convert to each sequential dataType 8724 while ( current ) { 8725 8726 if ( s.responseFields[ current ] ) { 8727 jqXHR[ s.responseFields[ current ] ] = response; 8728 } 8729 8730 // Apply the dataFilter if provided 8731 if ( !prev && isSuccess && s.dataFilter ) { 8732 response = s.dataFilter( response, s.dataType ); 8733 } 8734 8735 prev = current; 8736 current = dataTypes.shift(); 8737 8738 if ( current ) { 8739 8740 // There's only work to do if current dataType is non-auto 8741 if ( current === "*" ) { 8742 8743 current = prev; 8744 8745 // Convert response if prev dataType is non-auto and differs from current 8746 } else if ( prev !== "*" && prev !== current ) { 8747 8748 // Seek a direct converter 8749 conv = converters[ prev + " " + current ] || converters[ "* " + current ]; 8750 8751 // If none found, seek a pair 8752 if ( !conv ) { 8753 for ( conv2 in converters ) { 8754 8755 // If conv2 outputs current 8756 tmp = conv2.split( " " ); 8757 if ( tmp[ 1 ] === current ) { 8758 8759 // If prev can be converted to accepted input 8760 conv = converters[ prev + " " + tmp[ 0 ] ] || 8761 converters[ "* " + tmp[ 0 ] ]; 8762 if ( conv ) { 8763 8764 // Condense equivalence converters 8765 if ( conv === true ) { 8766 conv = converters[ conv2 ]; 8767 8768 // Otherwise, insert the intermediate dataType 8769 } else if ( converters[ conv2 ] !== true ) { 8770 current = tmp[ 0 ]; 8771 dataTypes.unshift( tmp[ 1 ] ); 8772 } 8773 break; 8774 } 8775 } 8776 } 8777 } 8778 8779 // Apply converter (if not an equivalence) 8780 if ( conv !== true ) { 8781 8782 // Unless errors are allowed to bubble, catch and return them 8783 if ( conv && s.throws ) { 8784 response = conv( response ); 8785 } else { 8786 try { 8787 response = conv( response ); 8788 } catch ( e ) { 8789 return { 8790 state: "parsererror", 8791 error: conv ? e : "No conversion from " + prev + " to " + current 8792 }; 8793 } 8794 } 8795 } 8796 } 8797 } 8798 } 8799 8800 return { state: "success", data: response }; 8801} 8802 8803jQuery.extend( { 8804 8805 // Counter for holding the number of active queries 8806 active: 0, 8807 8808 // Last-Modified header cache for next request 8809 lastModified: {}, 8810 etag: {}, 8811 8812 ajaxSettings: { 8813 url: location.href, 8814 type: "GET", 8815 isLocal: rlocalProtocol.test( location.protocol ), 8816 global: true, 8817 processData: true, 8818 async: true, 8819 contentType: "application/x-www-form-urlencoded; charset=UTF-8", 8820 8821 /* 8822 timeout: 0, 8823 data: null, 8824 dataType: null, 8825 username: null, 8826 password: null, 8827 cache: null, 8828 throws: false, 8829 traditional: false, 8830 headers: {}, 8831 */ 8832 8833 accepts: { 8834 "*": allTypes, 8835 text: "text/plain", 8836 html: "text/html", 8837 xml: "application/xml, text/xml", 8838 json: "application/json, text/javascript" 8839 }, 8840 8841 contents: { 8842 xml: /\bxml\b/, 8843 html: /\bhtml/, 8844 json: /\bjson\b/ 8845 }, 8846 8847 responseFields: { 8848 xml: "responseXML", 8849 text: "responseText", 8850 json: "responseJSON" 8851 }, 8852 8853 // Data converters 8854 // Keys separate source (or catchall "*") and destination types with a single space 8855 converters: { 8856 8857 // Convert anything to text 8858 "* text": String, 8859 8860 // Text to html (true = no transformation) 8861 "text html": true, 8862 8863 // Evaluate text as a json expression 8864 "text json": JSON.parse, 8865 8866 // Parse text as xml 8867 "text xml": jQuery.parseXML 8868 }, 8869 8870 // For options that shouldn't be deep extended: 8871 // you can add your own custom options here if 8872 // and when you create one that shouldn't be 8873 // deep extended (see ajaxExtend) 8874 flatOptions: { 8875 url: true, 8876 context: true 8877 } 8878 }, 8879 8880 // Creates a full fledged settings object into target 8881 // with both ajaxSettings and settings fields. 8882 // If target is omitted, writes into ajaxSettings. 8883 ajaxSetup: function( target, settings ) { 8884 return settings ? 8885 8886 // Building a settings object 8887 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : 8888 8889 // Extending ajaxSettings 8890 ajaxExtend( jQuery.ajaxSettings, target ); 8891 }, 8892 8893 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), 8894 ajaxTransport: addToPrefiltersOrTransports( transports ), 8895 8896 // Main method 8897 ajax: function( url, options ) { 8898 8899 // If url is an object, simulate pre-1.5 signature 8900 if ( typeof url === "object" ) { 8901 options = url; 8902 url = undefined; 8903 } 8904 8905 // Force options to be an object 8906 options = options || {}; 8907 8908 var transport, 8909 8910 // URL without anti-cache param 8911 cacheURL, 8912 8913 // Response headers 8914 responseHeadersString, 8915 responseHeaders, 8916 8917 // timeout handle 8918 timeoutTimer, 8919 8920 // Url cleanup var 8921 urlAnchor, 8922 8923 // Request state (becomes false upon send and true upon completion) 8924 completed, 8925 8926 // To know if global events are to be dispatched 8927 fireGlobals, 8928 8929 // Loop variable 8930 i, 8931 8932 // uncached part of the url 8933 uncached, 8934 8935 // Create the final options object 8936 s = jQuery.ajaxSetup( {}, options ), 8937 8938 // Callbacks context 8939 callbackContext = s.context || s, 8940 8941 // Context for global events is callbackContext if it is a DOM node or jQuery collection 8942 globalEventContext = s.context && 8943 ( callbackContext.nodeType || callbackContext.jquery ) ? 8944 jQuery( callbackContext ) : 8945 jQuery.event, 8946 8947 // Deferreds 8948 deferred = jQuery.Deferred(), 8949 completeDeferred = jQuery.Callbacks( "once memory" ), 8950 8951 // Status-dependent callbacks 8952 statusCode = s.statusCode || {}, 8953 8954 // Headers (they are sent all at once) 8955 requestHeaders = {}, 8956 requestHeadersNames = {}, 8957 8958 // Default abort message 8959 strAbort = "canceled", 8960 8961 // Fake xhr 8962 jqXHR = { 8963 readyState: 0, 8964 8965 // Builds headers hashtable if needed 8966 getResponseHeader: function( key ) { 8967 var match; 8968 if ( completed ) { 8969 if ( !responseHeaders ) { 8970 responseHeaders = {}; 8971 while ( ( match = rheaders.exec( responseHeadersString ) ) ) { 8972 responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ]; 8973 } 8974 } 8975 match = responseHeaders[ key.toLowerCase() ]; 8976 } 8977 return match == null ? null : match; 8978 }, 8979 8980 // Raw string 8981 getAllResponseHeaders: function() { 8982 return completed ? responseHeadersString : null; 8983 }, 8984 8985 // Caches the header 8986 setRequestHeader: function( name, value ) { 8987 if ( completed == null ) { 8988 name = requestHeadersNames[ name.toLowerCase() ] = 8989 requestHeadersNames[ name.toLowerCase() ] || name; 8990 requestHeaders[ name ] = value; 8991 } 8992 return this; 8993 }, 8994 8995 // Overrides response content-type header 8996 overrideMimeType: function( type ) { 8997 if ( completed == null ) { 8998 s.mimeType = type; 8999 } 9000 return this; 9001 }, 9002 9003 // Status-dependent callbacks 9004 statusCode: function( map ) { 9005 var code; 9006 if ( map ) { 9007 if ( completed ) { 9008 9009 // Execute the appropriate callbacks 9010 jqXHR.always( map[ jqXHR.status ] ); 9011 } else { 9012 9013 // Lazy-add the new callbacks in a way that preserves old ones 9014 for ( code in map ) { 9015 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; 9016 } 9017 } 9018 } 9019 return this; 9020 }, 9021 9022 // Cancel the request 9023 abort: function( statusText ) { 9024 var finalText = statusText || strAbort; 9025 if ( transport ) { 9026 transport.abort( finalText ); 9027 } 9028 done( 0, finalText ); 9029 return this; 9030 } 9031 }; 9032 9033 // Attach deferreds 9034 deferred.promise( jqXHR ); 9035 9036 // Add protocol if not provided (prefilters might expect it) 9037 // Handle falsy url in the settings object (#10093: consistency with old signature) 9038 // We also use the url parameter if available 9039 s.url = ( ( url || s.url || location.href ) + "" ) 9040 .replace( rprotocol, location.protocol + "//" ); 9041 9042 // Alias method option to type as per ticket #12004 9043 s.type = options.method || options.type || s.method || s.type; 9044 9045 // Extract dataTypes list 9046 s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ]; 9047 9048 // A cross-domain request is in order when the origin doesn't match the current origin. 9049 if ( s.crossDomain == null ) { 9050 urlAnchor = document.createElement( "a" ); 9051 9052 // Support: IE <=8 - 11, Edge 12 - 15 9053 // IE throws exception on accessing the href property if url is malformed, 9054 // e.g. http://example.com:80x/ 9055 try { 9056 urlAnchor.href = s.url; 9057 9058 // Support: IE <=8 - 11 only 9059 // Anchor's host property isn't correctly set when s.url is relative 9060 urlAnchor.href = urlAnchor.href; 9061 s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== 9062 urlAnchor.protocol + "//" + urlAnchor.host; 9063 } catch ( e ) { 9064 9065 // If there is an error parsing the URL, assume it is crossDomain, 9066 // it can be rejected by the transport if it is invalid 9067 s.crossDomain = true; 9068 } 9069 } 9070 9071 // Convert data if not already a string 9072 if ( s.data && s.processData && typeof s.data !== "string" ) { 9073 s.data = jQuery.param( s.data, s.traditional ); 9074 } 9075 9076 // Apply prefilters 9077 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); 9078 9079 // If request was aborted inside a prefilter, stop there 9080 if ( completed ) { 9081 return jqXHR; 9082 } 9083 9084 // We can fire global events as of now if asked to 9085 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) 9086 fireGlobals = jQuery.event && s.global; 9087 9088 // Watch for a new set of requests 9089 if ( fireGlobals && jQuery.active++ === 0 ) { 9090 jQuery.event.trigger( "ajaxStart" ); 9091 } 9092 9093 // Uppercase the type 9094 s.type = s.type.toUpperCase(); 9095 9096 // Determine if request has content 9097 s.hasContent = !rnoContent.test( s.type ); 9098 9099 // Save the URL in case we're toying with the If-Modified-Since 9100 // and/or If-None-Match header later on 9101 // Remove hash to simplify url manipulation 9102 cacheURL = s.url.replace( rhash, "" ); 9103 9104 // More options handling for requests with no content 9105 if ( !s.hasContent ) { 9106 9107 // Remember the hash so we can put it back 9108 uncached = s.url.slice( cacheURL.length ); 9109 9110 // If data is available and should be processed, append data to url 9111 if ( s.data && ( s.processData || typeof s.data === "string" ) ) { 9112 cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; 9113 9114 // #9682: remove data so that it's not used in an eventual retry 9115 delete s.data; 9116 } 9117 9118 // Add or update anti-cache param if needed 9119 if ( s.cache === false ) { 9120 cacheURL = cacheURL.replace( rantiCache, "$1" ); 9121 uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached; 9122 } 9123 9124 // Put hash and anti-cache on the URL that will be requested (gh-1732) 9125 s.url = cacheURL + uncached; 9126 9127 // Change '%20' to '+' if this is encoded form body content (gh-2658) 9128 } else if ( s.data && s.processData && 9129 ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) { 9130 s.data = s.data.replace( r20, "+" ); 9131 } 9132 9133 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 9134 if ( s.ifModified ) { 9135 if ( jQuery.lastModified[ cacheURL ] ) { 9136 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); 9137 } 9138 if ( jQuery.etag[ cacheURL ] ) { 9139 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); 9140 } 9141 } 9142 9143 // Set the correct header, if data is being sent 9144 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { 9145 jqXHR.setRequestHeader( "Content-Type", s.contentType ); 9146 } 9147 9148 // Set the Accepts header for the server, depending on the dataType 9149 jqXHR.setRequestHeader( 9150 "Accept", 9151 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? 9152 s.accepts[ s.dataTypes[ 0 ] ] + 9153 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : 9154 s.accepts[ "*" ] 9155 ); 9156 9157 // Check for headers option 9158 for ( i in s.headers ) { 9159 jqXHR.setRequestHeader( i, s.headers[ i ] ); 9160 } 9161 9162 // Allow custom headers/mimetypes and early abort 9163 if ( s.beforeSend && 9164 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) { 9165 9166 // Abort if not done already and return 9167 return jqXHR.abort(); 9168 } 9169 9170 // Aborting is no longer a cancellation 9171 strAbort = "abort"; 9172 9173 // Install callbacks on deferreds 9174 completeDeferred.add( s.complete ); 9175 jqXHR.done( s.success ); 9176 jqXHR.fail( s.error ); 9177 9178 // Get transport 9179 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); 9180 9181 // If no transport, we auto-abort 9182 if ( !transport ) { 9183 done( -1, "No Transport" ); 9184 } else { 9185 jqXHR.readyState = 1; 9186 9187 // Send global event 9188 if ( fireGlobals ) { 9189 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); 9190 } 9191 9192 // If request was aborted inside ajaxSend, stop there 9193 if ( completed ) { 9194 return jqXHR; 9195 } 9196 9197 // Timeout 9198 if ( s.async && s.timeout > 0 ) { 9199 timeoutTimer = window.setTimeout( function() { 9200 jqXHR.abort( "timeout" ); 9201 }, s.timeout ); 9202 } 9203 9204 try { 9205 completed = false; 9206 transport.send( requestHeaders, done ); 9207 } catch ( e ) { 9208 9209 // Rethrow post-completion exceptions 9210 if ( completed ) { 9211 throw e; 9212 } 9213 9214 // Propagate others as results 9215 done( -1, e ); 9216 } 9217 } 9218 9219 // Callback for when everything is done 9220 function done( status, nativeStatusText, responses, headers ) { 9221 var isSuccess, success, error, response, modified, 9222 statusText = nativeStatusText; 9223 9224 // Ignore repeat invocations 9225 if ( completed ) { 9226 return; 9227 } 9228 9229 completed = true; 9230 9231 // Clear timeout if it exists 9232 if ( timeoutTimer ) { 9233 window.clearTimeout( timeoutTimer ); 9234 } 9235 9236 // Dereference transport for early garbage collection 9237 // (no matter how long the jqXHR object will be used) 9238 transport = undefined; 9239 9240 // Cache response headers 9241 responseHeadersString = headers || ""; 9242 9243 // Set readyState 9244 jqXHR.readyState = status > 0 ? 4 : 0; 9245 9246 // Determine if successful 9247 isSuccess = status >= 200 && status < 300 || status === 304; 9248 9249 // Get response data 9250 if ( responses ) { 9251 response = ajaxHandleResponses( s, jqXHR, responses ); 9252 } 9253 9254 // Convert no matter what (that way responseXXX fields are always set) 9255 response = ajaxConvert( s, response, jqXHR, isSuccess ); 9256 9257 // If successful, handle type chaining 9258 if ( isSuccess ) { 9259 9260 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 9261 if ( s.ifModified ) { 9262 modified = jqXHR.getResponseHeader( "Last-Modified" ); 9263 if ( modified ) { 9264 jQuery.lastModified[ cacheURL ] = modified; 9265 } 9266 modified = jqXHR.getResponseHeader( "etag" ); 9267 if ( modified ) { 9268 jQuery.etag[ cacheURL ] = modified; 9269 } 9270 } 9271 9272 // if no content 9273 if ( status === 204 || s.type === "HEAD" ) { 9274 statusText = "nocontent"; 9275 9276 // if not modified 9277 } else if ( status === 304 ) { 9278 statusText = "notmodified"; 9279 9280 // If we have data, let's convert it 9281 } else { 9282 statusText = response.state; 9283 success = response.data; 9284 error = response.error; 9285 isSuccess = !error; 9286 } 9287 } else { 9288 9289 // Extract error from statusText and normalize for non-aborts 9290 error = statusText; 9291 if ( status || !statusText ) { 9292 statusText = "error"; 9293 if ( status < 0 ) { 9294 status = 0; 9295 } 9296 } 9297 } 9298 9299 // Set data for the fake xhr object 9300 jqXHR.status = status; 9301 jqXHR.statusText = ( nativeStatusText || statusText ) + ""; 9302 9303 // Success/Error 9304 if ( isSuccess ) { 9305 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); 9306 } else { 9307 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); 9308 } 9309 9310 // Status-dependent callbacks 9311 jqXHR.statusCode( statusCode ); 9312 statusCode = undefined; 9313 9314 if ( fireGlobals ) { 9315 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", 9316 [ jqXHR, s, isSuccess ? success : error ] ); 9317 } 9318 9319 // Complete 9320 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); 9321 9322 if ( fireGlobals ) { 9323 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); 9324 9325 // Handle the global AJAX counter 9326 if ( !( --jQuery.active ) ) { 9327 jQuery.event.trigger( "ajaxStop" ); 9328 } 9329 } 9330 } 9331 9332 return jqXHR; 9333 }, 9334 9335 getJSON: function( url, data, callback ) { 9336 return jQuery.get( url, data, callback, "json" ); 9337 }, 9338 9339 getScript: function( url, callback ) { 9340 return jQuery.get( url, undefined, callback, "script" ); 9341 } 9342} ); 9343 9344jQuery.each( [ "get", "post" ], function( i, method ) { 9345 jQuery[ method ] = function( url, data, callback, type ) { 9346 9347 // Shift arguments if data argument was omitted 9348 if ( isFunction( data ) ) { 9349 type = type || callback; 9350 callback = data; 9351 data = undefined; 9352 } 9353 9354 // The url can be an options object (which then must have .url) 9355 return jQuery.ajax( jQuery.extend( { 9356 url: url, 9357 type: method, 9358 dataType: type, 9359 data: data, 9360 success: callback 9361 }, jQuery.isPlainObject( url ) && url ) ); 9362 }; 9363} ); 9364 9365 9366jQuery._evalUrl = function( url ) { 9367 return jQuery.ajax( { 9368 url: url, 9369 9370 // Make this explicit, since user can override this through ajaxSetup (#11264) 9371 type: "GET", 9372 dataType: "script", 9373 cache: true, 9374 async: false, 9375 global: false, 9376 "throws": true 9377 } ); 9378}; 9379 9380 9381jQuery.fn.extend( { 9382 wrapAll: function( html ) { 9383 var wrap; 9384 9385 if ( this[ 0 ] ) { 9386 if ( isFunction( html ) ) { 9387 html = html.call( this[ 0 ] ); 9388 } 9389 9390 // The elements to wrap the target around 9391 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); 9392 9393 if ( this[ 0 ].parentNode ) { 9394 wrap.insertBefore( this[ 0 ] ); 9395 } 9396 9397 wrap.map( function() { 9398 var elem = this; 9399 9400 while ( elem.firstElementChild ) { 9401 elem = elem.firstElementChild; 9402 } 9403 9404 return elem; 9405 } ).append( this ); 9406 } 9407 9408 return this; 9409 }, 9410 9411 wrapInner: function( html ) { 9412 if ( isFunction( html ) ) { 9413 return this.each( function( i ) { 9414 jQuery( this ).wrapInner( html.call( this, i ) ); 9415 } ); 9416 } 9417 9418 return this.each( function() { 9419 var self = jQuery( this ), 9420 contents = self.contents(); 9421 9422 if ( contents.length ) { 9423 contents.wrapAll( html ); 9424 9425 } else { 9426 self.append( html ); 9427 } 9428 } ); 9429 }, 9430 9431 wrap: function( html ) { 9432 var htmlIsFunction = isFunction( html ); 9433 9434 return this.each( function( i ) { 9435 jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html ); 9436 } ); 9437 }, 9438 9439 unwrap: function( selector ) { 9440 this.parent( selector ).not( "body" ).each( function() { 9441 jQuery( this ).replaceWith( this.childNodes ); 9442 } ); 9443 return this; 9444 } 9445} ); 9446 9447 9448jQuery.expr.pseudos.hidden = function( elem ) { 9449 return !jQuery.expr.pseudos.visible( elem ); 9450}; 9451jQuery.expr.pseudos.visible = function( elem ) { 9452 return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); 9453}; 9454 9455 9456 9457 9458jQuery.ajaxSettings.xhr = function() { 9459 try { 9460 return new window.XMLHttpRequest(); 9461 } catch ( e ) {} 9462}; 9463 9464var xhrSuccessStatus = { 9465 9466 // File protocol always yields status code 0, assume 200 9467 0: 200, 9468
vendor: 1,240 bytes, lines 9469-9511
9469 // Support: IE <=9 only 9470 // #1450: sometimes IE returns 1223 when it should be 204 9471 1223: 204 9472 }, 9473 xhrSupported = jQuery.ajaxSettings.xhr(); 9474 9475support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); 9476support.ajax = xhrSupported = !!xhrSupported; 9477 9478jQuery.ajaxTransport( function( options ) { 9479 var callback, errorCallback; 9480 9481 // Cross domain only allowed if supported through XMLHttpRequest 9482 if ( support.cors || xhrSupported && !options.crossDomain ) { 9483 return { 9484 send: function( headers, complete ) { 9485 var i, 9486 xhr = options.xhr(); 9487 9488 xhr.open( 9489 options.type, 9490 options.url, 9491 options.async, 9492 options.username, 9493 options.password 9494 ); 9495 9496 // Apply custom fields if provided 9497 if ( options.xhrFields ) { 9498 for ( i in options.xhrFields ) { 9499 xhr[ i ] = options.xhrFields[ i ]; 9500 } 9501 } 9502 9503 // Override mime type if needed 9504 if ( options.mimeType && xhr.overrideMimeType ) { 9505 xhr.overrideMimeType( options.mimeType ); 9506 } 9507 9508 // X-Requested-With header 9509 // For cross-domain requests, seeing as conditions for a preflight are 9510 // akin to a jigsaw puzzle, we simply never set it to be sure. 9511 // (it can always be set on a per-request basis or even using ajaxSetup)
vendor: 5,627 bytes, lines 9512-9733
9512 // For same-domain requests, won't change header if already provided. 9513 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { 9514 headers[ "X-Requested-With" ] = "XMLHttpRequest"; 9515 } 9516 9517 // Set headers 9518 for ( i in headers ) { 9519 xhr.setRequestHeader( i, headers[ i ] ); 9520 } 9521 9522 // Callback 9523 callback = function( type ) { 9524 return function() { 9525 if ( callback ) { 9526 callback = errorCallback = xhr.onload = 9527 xhr.onerror = xhr.onabort = xhr.ontimeout = 9528 xhr.onreadystatechange = null; 9529 9530 if ( type === "abort" ) { 9531 xhr.abort(); 9532 } else if ( type === "error" ) { 9533 9534 // Support: IE <=9 only 9535 // On a manual native abort, IE9 throws 9536 // errors on any property access that is not readyState 9537 if ( typeof xhr.status !== "number" ) { 9538 complete( 0, "error" ); 9539 } else { 9540 complete( 9541 9542 // File: protocol always yields status 0; see #8605, #14207 9543 xhr.status, 9544 xhr.statusText 9545 ); 9546 } 9547 } else { 9548 complete( 9549 xhrSuccessStatus[ xhr.status ] || xhr.status, 9550 xhr.statusText, 9551 9552 // Support: IE <=9 only 9553 // IE9 has no XHR2 but throws on binary (trac-11426) 9554 // For XHR2 non-text, let the caller handle it (gh-2498) 9555 ( xhr.responseType || "text" ) !== "text" || 9556 typeof xhr.responseText !== "string" ? 9557 { binary: xhr.response } : 9558 { text: xhr.responseText }, 9559 xhr.getAllResponseHeaders() 9560 ); 9561 } 9562 } 9563 }; 9564 }; 9565 9566 // Listen to events 9567 xhr.onload = callback(); 9568 errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" ); 9569 9570 // Support: IE 9 only 9571 // Use onreadystatechange to replace onabort 9572 // to handle uncaught aborts 9573 if ( xhr.onabort !== undefined ) { 9574 xhr.onabort = errorCallback; 9575 } else { 9576 xhr.onreadystatechange = function() { 9577 9578 // Check readyState before timeout as it changes 9579 if ( xhr.readyState === 4 ) { 9580 9581 // Allow onerror to be called first, 9582 // but that will not handle a native abort 9583 // Also, save errorCallback to a variable 9584 // as xhr.onerror cannot be accessed 9585 window.setTimeout( function() { 9586 if ( callback ) { 9587 errorCallback(); 9588 } 9589 } ); 9590 } 9591 }; 9592 } 9593 9594 // Create the abort callback 9595 callback = callback( "abort" ); 9596 9597 try { 9598 9599 // Do send the request (this may raise an exception) 9600 xhr.send( options.hasContent && options.data || null ); 9601 } catch ( e ) { 9602 9603 // #14683: Only rethrow if this hasn't been notified as an error yet 9604 if ( callback ) { 9605 throw e; 9606 } 9607 } 9608 }, 9609 9610 abort: function() { 9611 if ( callback ) { 9612 callback(); 9613 } 9614 } 9615 }; 9616 } 9617} ); 9618 9619 9620 9621 9622// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) 9623jQuery.ajaxPrefilter( function( s ) { 9624 if ( s.crossDomain ) { 9625 s.contents.script = false; 9626 } 9627} ); 9628 9629// Install script dataType 9630jQuery.ajaxSetup( { 9631 accepts: { 9632 script: "text/javascript, application/javascript, " + 9633 "application/ecmascript, application/x-ecmascript" 9634 }, 9635 contents: { 9636 script: /\b(?:java|ecma)script\b/ 9637 }, 9638 converters: { 9639 "text script": function( text ) { 9640 jQuery.globalEval( text ); 9641 return text; 9642 } 9643 } 9644} ); 9645 9646// Handle cache's special case and crossDomain 9647jQuery.ajaxPrefilter( "script", function( s ) { 9648 if ( s.cache === undefined ) { 9649 s.cache = false; 9650 } 9651 if ( s.crossDomain ) { 9652 s.type = "GET"; 9653 } 9654} ); 9655 9656// Bind script tag hack transport 9657jQuery.ajaxTransport( "script", function( s ) { 9658 9659 // This transport only deals with cross domain requests 9660 if ( s.crossDomain ) { 9661 var script, callback; 9662 return { 9663 send: function( _, complete ) { 9664 script = jQuery( "<script>" ).prop( { 9665 charset: s.scriptCharset, 9666 src: s.url 9667 } ).on( 9668 "load error", 9669 callback = function( evt ) { 9670 script.remove(); 9671 callback = null; 9672 if ( evt ) { 9673 complete( evt.type === "error" ? 404 : 200, evt.type ); 9674 } 9675 } 9676 ); 9677 9678 // Use native DOM manipulation to avoid our domManip AJAX trickery 9679 document.head.appendChild( script[ 0 ] ); 9680 }, 9681 abort: function() { 9682 if ( callback ) { 9683 callback(); 9684 } 9685 } 9686 }; 9687 } 9688} ); 9689 9690 9691 9692 9693var oldCallbacks = [], 9694 rjsonp = /(=)\?(?=&|$)|\?\?/; 9695 9696// Default jsonp settings 9697jQuery.ajaxSetup( { 9698 jsonp: "callback", 9699 jsonpCallback: function() { 9700 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); 9701 this[ callback ] = true; 9702 return callback; 9703 } 9704} ); 9705 9706// Detect, normalize options and install callbacks for jsonp requests 9707jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 9708 9709 var callbackName, overwritten, responseContainer, 9710 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? 9711 "url" : 9712 typeof s.data === "string" && 9713 ( s.contentType || "" ) 9714 .indexOf( "application/x-www-form-urlencoded" ) === 0 && 9715 rjsonp.test( s.data ) && "data" 9716 ); 9717 9718 // Handle iff the expected data type is "jsonp" or we have a parameter to set 9719 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { 9720 9721 // Get callback name, remembering preexisting value associated with it 9722 callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ? 9723 s.jsonpCallback() : 9724 s.jsonpCallback; 9725 9726 // Insert callback into url or form data 9727 if ( jsonProp ) { 9728 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); 9729 } else if ( s.jsonp !== false ) { 9730 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; 9731 } 9732 9733 // Use data converter to retrieve json after script execution
vendor: 2,987 bytes, lines 9734-9843
9734 s.converters[ "script json" ] = function() { 9735 if ( !responseContainer ) { 9736 jQuery.error( callbackName + " was not called" ); 9737 } 9738 return responseContainer[ 0 ]; 9739 }; 9740 9741 // Force json dataType 9742 s.dataTypes[ 0 ] = "json"; 9743 9744 // Install callback 9745 overwritten = window[ callbackName ]; 9746 window[ callbackName ] = function() { 9747 responseContainer = arguments; 9748 }; 9749 9750 // Clean-up function (fires after converters) 9751 jqXHR.always( function() { 9752 9753 // If previous value didn't exist - remove it 9754 if ( overwritten === undefined ) { 9755 jQuery( window ).removeProp( callbackName ); 9756 9757 // Otherwise restore preexisting value 9758 } else { 9759 window[ callbackName ] = overwritten; 9760 } 9761 9762 // Save back as free 9763 if ( s[ callbackName ] ) { 9764 9765 // Make sure that re-using the options doesn't screw things around 9766 s.jsonpCallback = originalSettings.jsonpCallback; 9767 9768 // Save the callback name for future use 9769 oldCallbacks.push( callbackName ); 9770 } 9771 9772 // Call if it was a function and we have a response 9773 if ( responseContainer && isFunction( overwritten ) ) { 9774 overwritten( responseContainer[ 0 ] ); 9775 } 9776 9777 responseContainer = overwritten = undefined; 9778 } ); 9779 9780 // Delegate to script 9781 return "script"; 9782 } 9783} ); 9784 9785 9786 9787 9788// Support: Safari 8 only 9789// In Safari 8 documents created via document.implementation.createHTMLDocument 9790// collapse sibling forms: the second one becomes a child of the first one. 9791// Because of that, this security measure has to be disabled in Safari 8. 9792// https://bugs.webkit.org/show_bug.cgi?id=137337 9793support.createHTMLDocument = ( function() { 9794 var body = document.implementation.createHTMLDocument( "" ).body; 9795 body.innerHTML = "<form></form><form></form>"; 9796 return body.childNodes.length === 2; 9797} )(); 9798 9799 9800// Argument "data" should be string of html 9801// context (optional): If specified, the fragment will be created in this context, 9802// defaults to document 9803// keepScripts (optional): If true, will include scripts passed in the html string 9804jQuery.parseHTML = function( data, context, keepScripts ) { 9805 if ( typeof data !== "string" ) { 9806 return []; 9807 } 9808 if ( typeof context === "boolean" ) { 9809 keepScripts = context; 9810 context = false; 9811 } 9812 9813 var base, parsed, scripts; 9814 9815 if ( !context ) { 9816 9817 // Stop scripts or inline event handlers from being executed immediately 9818 // by using document.implementation 9819 if ( support.createHTMLDocument ) { 9820 context = document.implementation.createHTMLDocument( "" ); 9821 9822 // Set the base href for the created document 9823 // so any parsed elements with URLs 9824 // are based on the document's URL (gh-2965) 9825 base = context.createElement( "base" ); 9826 base.href = document.location.href; 9827 context.head.appendChild( base ); 9828 } else { 9829 context = document; 9830 } 9831 } 9832 9833 parsed = rsingleTag.exec( data ); 9834 scripts = !keepScripts && []; 9835 9836 // Single tag 9837 if ( parsed ) { 9838 return [ context.createElement( parsed[ 1 ] ) ]; 9839 } 9840 9841 parsed = buildFragment( [ data ], context, scripts ); 9842 9843 if ( scripts && scripts.length ) {
vendor: 14,511 bytes, lines 9844-10364
9844 jQuery( scripts ).remove(); 9845 } 9846 9847 return jQuery.merge( [], parsed.childNodes ); 9848}; 9849 9850 9851/** 9852 * Load a url into a page 9853 */ 9854jQuery.fn.load = function( url, params, callback ) { 9855 var selector, type, response, 9856 self = this, 9857 off = url.indexOf( " " ); 9858 9859 if ( off > -1 ) { 9860 selector = stripAndCollapse( url.slice( off ) ); 9861 url = url.slice( 0, off ); 9862 } 9863 9864 // If it's a function 9865 if ( isFunction( params ) ) { 9866 9867 // We assume that it's the callback 9868 callback = params; 9869 params = undefined; 9870 9871 // Otherwise, build a param string 9872 } else if ( params && typeof params === "object" ) { 9873 type = "POST"; 9874 } 9875 9876 // If we have elements to modify, make the request 9877 if ( self.length > 0 ) { 9878 jQuery.ajax( { 9879 url: url, 9880 9881 // If "type" variable is undefined, then "GET" method will be used. 9882 // Make value of this field explicit since 9883 // user can override it through ajaxSetup method 9884 type: type || "GET", 9885 dataType: "html", 9886 data: params 9887 } ).done( function( responseText ) { 9888 9889 // Save response for use in complete callback 9890 response = arguments; 9891 9892 self.html( selector ? 9893 9894 // If a selector was specified, locate the right elements in a dummy div 9895 // Exclude scripts to avoid IE 'Permission Denied' errors 9896 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : 9897 9898 // Otherwise use the full result 9899 responseText ); 9900 9901 // If the request succeeds, this function gets "data", "status", "jqXHR" 9902 // but they are ignored because response was set above. 9903 // If it fails, this function gets "jqXHR", "status", "error" 9904 } ).always( callback && function( jqXHR, status ) { 9905 self.each( function() { 9906 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] ); 9907 } ); 9908 } ); 9909 } 9910 9911 return this; 9912}; 9913 9914 9915 9916 9917// Attach a bunch of functions for handling common AJAX events 9918jQuery.each( [ 9919 "ajaxStart", 9920 "ajaxStop", 9921 "ajaxComplete", 9922 "ajaxError", 9923 "ajaxSuccess", 9924 "ajaxSend" 9925], function( i, type ) { 9926 jQuery.fn[ type ] = function( fn ) { 9927 return this.on( type, fn ); 9928 }; 9929} ); 9930 9931 9932 9933 9934jQuery.expr.pseudos.animated = function( elem ) { 9935 return jQuery.grep( jQuery.timers, function( fn ) { 9936 return elem === fn.elem; 9937 } ).length; 9938}; 9939 9940 9941 9942 9943jQuery.offset = { 9944 setOffset: function( elem, options, i ) { 9945 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, 9946 position = jQuery.css( elem, "position" ), 9947 curElem = jQuery( elem ), 9948 props = {}; 9949 9950 // Set position first, in-case top/left are set even on static elem 9951 if ( position === "static" ) { 9952 elem.style.position = "relative"; 9953 } 9954 9955 curOffset = curElem.offset(); 9956 curCSSTop = jQuery.css( elem, "top" ); 9957 curCSSLeft = jQuery.css( elem, "left" ); 9958 calculatePosition = ( position === "absolute" || position === "fixed" ) && 9959 ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1; 9960 9961 // Need to be able to calculate position if either 9962 // top or left is auto and position is either absolute or fixed 9963 if ( calculatePosition ) { 9964 curPosition = curElem.position(); 9965 curTop = curPosition.top; 9966 curLeft = curPosition.left; 9967 9968 } else { 9969 curTop = parseFloat( curCSSTop ) || 0; 9970 curLeft = parseFloat( curCSSLeft ) || 0; 9971 } 9972 9973 if ( isFunction( options ) ) { 9974 9975 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) 9976 options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); 9977 } 9978 9979 if ( options.top != null ) { 9980 props.top = ( options.top - curOffset.top ) + curTop; 9981 } 9982 if ( options.left != null ) { 9983 props.left = ( options.left - curOffset.left ) + curLeft; 9984 } 9985 9986 if ( "using" in options ) { 9987 options.using.call( elem, props ); 9988 9989 } else { 9990 curElem.css( props ); 9991 } 9992 } 9993}; 9994 9995jQuery.fn.extend( { 9996 9997 // offset() relates an element's border box to the document origin 9998 offset: function( options ) { 9999 10000 // Preserve chaining for setter 10001 if ( arguments.length ) { 10002 return options === undefined ? 10003 this : 10004 this.each( function( i ) { 10005 jQuery.offset.setOffset( this, options, i ); 10006 } ); 10007 } 10008 10009 var rect, win, 10010 elem = this[ 0 ]; 10011 10012 if ( !elem ) { 10013 return; 10014 } 10015 10016 // Return zeros for disconnected and hidden (display: none) elements (gh-2310) 10017 // Support: IE <=11 only 10018 // Running getBoundingClientRect on a 10019 // disconnected node in IE throws an error 10020 if ( !elem.getClientRects().length ) { 10021 return { top: 0, left: 0 }; 10022 } 10023 10024 // Get document-relative position by adding viewport scroll to viewport-relative gBCR 10025 rect = elem.getBoundingClientRect(); 10026 win = elem.ownerDocument.defaultView; 10027 return { 10028 top: rect.top + win.pageYOffset, 10029 left: rect.left + win.pageXOffset 10030 }; 10031 }, 10032 10033 // position() relates an element's margin box to its offset parent's padding box 10034 // This corresponds to the behavior of CSS absolute positioning 10035 position: function() { 10036 if ( !this[ 0 ] ) { 10037 return; 10038 } 10039 10040 var offsetParent, offset, doc, 10041 elem = this[ 0 ], 10042 parentOffset = { top: 0, left: 0 }; 10043 10044 // position:fixed elements are offset from the viewport, which itself always has zero offset 10045 if ( jQuery.css( elem, "position" ) === "fixed" ) { 10046 10047 // Assume position:fixed implies availability of getBoundingClientRect 10048 offset = elem.getBoundingClientRect(); 10049 10050 } else { 10051 offset = this.offset(); 10052 10053 // Account for the *real* offset parent, which can be the document or its root element 10054 // when a statically positioned element is identified 10055 doc = elem.ownerDocument; 10056 offsetParent = elem.offsetParent || doc.documentElement; 10057 while ( offsetParent && 10058 ( offsetParent === doc.body || offsetParent === doc.documentElement ) && 10059 jQuery.css( offsetParent, "position" ) === "static" ) { 10060 10061 offsetParent = offsetParent.parentNode; 10062 } 10063 if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) { 10064 10065 // Incorporate borders into its offset, since they are outside its content origin 10066 parentOffset = jQuery( offsetParent ).offset(); 10067 parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true ); 10068 parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true ); 10069 } 10070 } 10071 10072 // Subtract parent offsets and element margins 10073 return { 10074 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), 10075 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) 10076 }; 10077 }, 10078 10079 // This method will return documentElement in the following cases: 10080 // 1) For the element inside the iframe without offsetParent, this method will return 10081 // documentElement of the parent window 10082 // 2) For the hidden or detached element 10083 // 3) For body or html element, i.e. in case of the html node - it will return itself 10084 // 10085 // but those exceptions were never presented as a real life use-cases 10086 // and might be considered as more preferable results. 10087 // 10088 // This logic, however, is not guaranteed and can change at any point in the future 10089 offsetParent: function() { 10090 return this.map( function() { 10091 var offsetParent = this.offsetParent; 10092 10093 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { 10094 offsetParent = offsetParent.offsetParent; 10095 } 10096 10097 return offsetParent || documentElement; 10098 } ); 10099 } 10100} ); 10101 10102// Create scrollLeft and scrollTop methods 10103jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { 10104 var top = "pageYOffset" === prop; 10105 10106 jQuery.fn[ method ] = function( val ) { 10107 return access( this, function( elem, method, val ) { 10108 10109 // Coalesce documents and windows 10110 var win; 10111 if ( isWindow( elem ) ) { 10112 win = elem; 10113 } else if ( elem.nodeType === 9 ) { 10114 win = elem.defaultView; 10115 } 10116 10117 if ( val === undefined ) { 10118 return win ? win[ prop ] : elem[ method ]; 10119 } 10120 10121 if ( win ) { 10122 win.scrollTo( 10123 !top ? val : win.pageXOffset, 10124 top ? val : win.pageYOffset 10125 ); 10126 10127 } else { 10128 elem[ method ] = val; 10129 } 10130 }, method, val, arguments.length ); 10131 }; 10132} ); 10133 10134// Support: Safari <=7 - 9.1, Chrome <=37 - 49 10135// Add the top/left cssHooks using jQuery.fn.position 10136// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 10137// Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347 10138// getComputedStyle returns percent when specified for top/left/bottom/right; 10139// rather than make the css module depend on the offset module, just check for it here 10140jQuery.each( [ "top", "left" ], function( i, prop ) { 10141 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, 10142 function( elem, computed ) { 10143 if ( computed ) { 10144 computed = curCSS( elem, prop ); 10145 10146 // If curCSS returns percentage, fallback to offset 10147 return rnumnonpx.test( computed ) ? 10148 jQuery( elem ).position()[ prop ] + "px" : 10149 computed; 10150 } 10151 } 10152 ); 10153} ); 10154 10155 10156// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods 10157jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { 10158 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, 10159 function( defaultExtra, funcName ) { 10160 10161 // Margin is only for outerHeight, outerWidth 10162 jQuery.fn[ funcName ] = function( margin, value ) { 10163 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), 10164 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); 10165 10166 return access( this, function( elem, type, value ) { 10167 var doc; 10168 10169 if ( isWindow( elem ) ) { 10170 10171 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729) 10172 return funcName.indexOf( "outer" ) === 0 ? 10173 elem[ "inner" + name ] : 10174 elem.document.documentElement[ "client" + name ]; 10175 } 10176 10177 // Get document width or height 10178 if ( elem.nodeType === 9 ) { 10179 doc = elem.documentElement; 10180 10181 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], 10182 // whichever is greatest 10183 return Math.max( 10184 elem.body[ "scroll" + name ], doc[ "scroll" + name ], 10185 elem.body[ "offset" + name ], doc[ "offset" + name ], 10186 doc[ "client" + name ] 10187 ); 10188 } 10189 10190 return value === undefined ? 10191 10192 // Get width or height on the element, requesting but not forcing parseFloat 10193 jQuery.css( elem, type, extra ) : 10194 10195 // Set width or height on the element 10196 jQuery.style( elem, type, value, extra ); 10197 }, type, chainable ? margin : undefined, chainable ); 10198 }; 10199 } ); 10200} ); 10201 10202 10203jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + 10204 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + 10205 "change select submit keydown keypress keyup contextmenu" ).split( " " ), 10206 function( i, name ) { 10207 10208 // Handle event binding 10209 jQuery.fn[ name ] = function( data, fn ) { 10210 return arguments.length > 0 ? 10211 this.on( name, null, data, fn ) : 10212 this.trigger( name ); 10213 }; 10214} ); 10215 10216jQuery.fn.extend( { 10217 hover: function( fnOver, fnOut ) { 10218 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); 10219 } 10220} ); 10221 10222 10223 10224 10225jQuery.fn.extend( { 10226 10227 bind: function( types, data, fn ) { 10228 return this.on( types, null, data, fn ); 10229 }, 10230 unbind: function( types, fn ) { 10231 return this.off( types, null, fn ); 10232 }, 10233 10234 delegate: function( selector, types, data, fn ) { 10235 return this.on( types, selector, data, fn ); 10236 }, 10237 undelegate: function( selector, types, fn ) { 10238 10239 // ( namespace ) or ( selector, types [, fn] ) 10240 return arguments.length === 1 ? 10241 this.off( selector, "**" ) : 10242 this.off( types, selector || "**", fn ); 10243 } 10244} ); 10245 10246// Bind a function to a context, optionally partially applying any 10247// arguments. 10248// jQuery.proxy is deprecated to promote standards (specifically Function#bind) 10249// However, it is not slated for removal any time soon 10250jQuery.proxy = function( fn, context ) { 10251 var tmp, args, proxy; 10252 10253 if ( typeof context === "string" ) { 10254 tmp = fn[ context ]; 10255 context = fn; 10256 fn = tmp; 10257 } 10258 10259 // Quick check to determine if target is callable, in the spec 10260 // this throws a TypeError, but we will just return undefined. 10261 if ( !isFunction( fn ) ) { 10262 return undefined; 10263 } 10264 10265 // Simulated bind 10266 args = slice.call( arguments, 2 ); 10267 proxy = function() { 10268 return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); 10269 }; 10270 10271 // Set the guid of unique handler to the same of original handler, so it can be removed 10272 proxy.guid = fn.guid = fn.guid || jQuery.guid++; 10273 10274 return proxy; 10275}; 10276 10277jQuery.holdReady = function( hold ) { 10278 if ( hold ) { 10279 jQuery.readyWait++; 10280 } else { 10281 jQuery.ready( true ); 10282 } 10283}; 10284jQuery.isArray = Array.isArray; 10285jQuery.parseJSON = JSON.parse; 10286jQuery.nodeName = nodeName; 10287jQuery.isFunction = isFunction; 10288jQuery.isWindow = isWindow; 10289jQuery.camelCase = camelCase; 10290jQuery.type = toType; 10291 10292jQuery.now = Date.now; 10293 10294jQuery.isNumeric = function( obj ) { 10295 10296 // As of jQuery 3.0, isNumeric is limited to 10297 // strings and numbers (primitives or objects) 10298 // that can be coerced to finite numbers (gh-2662) 10299 var type = jQuery.type( obj ); 10300 return ( type === "number" || type === "string" ) && 10301 10302 // parseFloat NaNs numeric-cast false positives ("") 10303 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") 10304 // subtraction forces infinities to NaN 10305 !isNaN( obj - parseFloat( obj ) ); 10306}; 10307 10308 10309 10310 10311// Register as a named AMD module, since jQuery can be concatenated with other 10312// files that may use define, but not via a proper concatenation script that 10313// understands anonymous AMD modules. A named AMD is safest and most robust 10314// way to register. Lowercase jquery is used because AMD module names are 10315// derived from file names, and jQuery is normally delivered in a lowercase 10316// file name. Do this after creating the global so that if an AMD module wants 10317// to call noConflict to hide this version of jQuery, it will work. 10318 10319// Note that for maximum portability, libraries that are not jQuery should 10320// declare themselves as anonymous modules, and avoid setting a global if an 10321// AMD loader is present. jQuery is a special case. For more information, see 10322// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon 10323 10324if ( typeof define === "function" && define.amd ) { 10325 define( "jquery", [], function() { 10326 return jQuery; 10327 } ); 10328} 10329 10330 10331 10332 10333var 10334 10335 // Map over jQuery in case of overwrite 10336 _jQuery = window.jQuery, 10337 10338 // Map over the $ in case of overwrite 10339 _$ = window.$; 10340 10341jQuery.noConflict = function( deep ) { 10342 if ( window.$ === jQuery ) { 10343 window.$ = _$; 10344 } 10345 10346 if ( deep && window.jQuery === jQuery ) { 10347 window.jQuery = _jQuery; 10348 } 10349 10350 return jQuery; 10351}; 10352 10353// Expose jQuery and $ identifiers, even in AMD 10354// (#7102#comment:10, https://github.com/jquery/jquery/pull/557) 10355// and CommonJS for browser emulators (#13566) 10356if ( !noGlobal ) { 10357 window.jQuery = window.$ = jQuery; 10358} 10359 10360 10361 10362 10363return jQuery; 10364} );
10365
vendor: 13,135 bytes, line 10366
10366!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Barba",[],e):"object"==typeof exports?exports.Barba=e():t.Barba=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="http://localhost:8080/dist",e(0)}([function(t,e,n){"function"!=typeof Promise&&(window.Promise=n(1));var r={version:"1.0.0",BaseTransition:n(4),BaseView:n(6),BaseCache:n(8),Dispatcher:n(7),HistoryManager:n(9),Pjax:n(10),Prefetch:n(13),Utils:n(5)};t.exports=r},function(t,e,n){(function(e){!function(n){function r(){}function i(t,e){return function(){t.apply(e,arguments)}}function o(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],h(t,this)}function s(t,e){for(;3===t._state;)t=t._value;return 0===t._state?void t._deferreds.push(e):(t._handled=!0,void l(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null===n)return void(1===t._state?a:c)(e.promise,t._value);var r;try{r=n(t._value)}catch(t){return void c(e.promise,t)}a(e.promise,r)}))}function a(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof o)return t._state=3,t._value=e,void u(t);if("function"==typeof n)return void h(i(n,e),t)}t._state=1,t._value=e,u(t)}catch(e){c(t,e)}}function c(t,e){t._state=2,t._value=e,u(t)}function u(t){2===t._state&&0===t._deferreds.length&&l(function(){t._handled||p(t._value)});for(var e=0,n=t._deferreds.length;e<n;e++)s(t,t._deferreds[e]);t._deferreds=null}function f(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function h(t,e){var n=!1;try{t(function(t){n||(n=!0,a(e,t))},function(t){n||(n=!0,c(e,t))})}catch(t){if(n)return;n=!0,c(e,t)}}var d=setTimeout,l="function"==typeof e&&e||function(t){d(t,0)},p=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};o.prototype.catch=function(t){return this.then(null,t)},o.prototype.then=function(t,e){var n=new this.constructor(r);return s(this,new f(t,e,n)),n},o.all=function(t){var e=Array.prototype.slice.call(t);return new o(function(t,n){function r(o,s){try{if(s&&("object"==typeof s||"function"==typeof s)){var a=s.then;if("function"==typeof a)return void a.call(s,function(t){r(o,t)},n)}e[o]=s,0===--i&&t(e)}catch(t){n(t)}}if(0===e.length)return t([]);for(var i=e.length,o=0;o<e.length;o++)r(o,e[o])})},o.resolve=function(t){return t&&"object"==typeof t&&t.constructor===o?t:new o(function(e){e(t)})},o.reject=function(t){return new o(function(e,n){n(t)})},o.race=function(t){return new o(function(e,n){for(var r=0,i=t.length;r<i;r++)t[r].then(e,n)})},o._setImmediateFn=function(t){l=t},o._setUnhandledRejectionFn=function(t){p=t},"undefined"!=typeof t&&t.exports?t.exports=o:n.Promise||(n.Promise=o)}(this)}).call(e,n(2).setImmediate)},function(t,e,n){(function(t,r){function i(t,e){this._id=t,this._clearFn=e}var o=n(3).nextTick,s=Function.prototype.apply,a=Array.prototype.slice,c={},u=0;e.setTimeout=function(){return new i(s.call(setTimeout,window,arguments),clearTimeout)},e.setInterval=function(){return new i(s.call(setInterval,window,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(window,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},e.setImmediate="function"==typeof t?t:function(t){var n=u++,r=!(arguments.length<2)&&a.call(arguments,1);return c[n]=!0,o(function(){c[n]&&(r?t.apply(null,r):t.call(null),e.clearImmediate(n))}),n},e.clearImmediate="function"==typeof r?r:function(t){delete c[t]}}).call(e,n(2).setImmediate,n(2).clearImmediate)},function(t,e){function n(){h&&u&&(h=!1,u.length?f=u.concat(f):d=-1,f.length&&r())}function r(){if(!h){var t=s(n);h=!0;for(var e=f.length;e;){for(u=f,f=[];++d<e;)u&&u[d].run();d=-1,e=f.length}u=null,h=!1,a(t)}}function i(t,e){this.fun=t,this.array=e}function o(){}var s,a,c=t.exports={};!function(){try{s=setTimeout}catch(t){s=function(){throw new Error("setTimeout is not defined")}}try{a=clearTimeout}catch(t){a=function(){throw new Error("clearTimeout is not defined")}}}();var u,f=[],h=!1,d=-1;c.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];f.push(new i(t,e)),1!==f.length||h||s(r,0)},i.prototype.run=function(){this.fun.apply(null,this.array)},c.title="browser",c.browser=!0,c.env={},c.argv=[],c.version="",c.versions={},c.on=o,c.addListener=o,c.once=o,c.off=o,c.removeListener=o,c.removeAllListeners=o,c.emit=o,c.binding=function(t){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(t){throw new Error("process.chdir is not supported")},c.umask=function(){return 0}},function(t,e,n){var r=n(5),i={oldContainer:void 0,newContainer:void 0,newContainerLoading:void 0,extend:function(t){return r.extend(this,t)},init:function(t,e){var n=this;return this.oldContainer=t,this._newContainerPromise=e,this.deferred=r.deferred(),this.newContainerReady=r.deferred(),this.newContainerLoading=this.newContainerReady.promise,this.start(),this._newContainerPromise.then(function(t){n.newContainer=t,n.newContainerReady.resolve()}),this.deferred.promise},done:function(){this.oldContainer.parentNode.removeChild(this.oldContainer),this.newContainer.style.visibility="visible",this.deferred.resolve()},start:function(){}};t.exports=i},function(t,e){var n={getCurrentUrl:function(){return window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search},cleanLink:function(t){return t.replace(/#.*/,"")},xhrTimeout:5e3,xhr:function(t){var e=this.deferred(),n=new XMLHttpRequest;return n.onreadystatechange=function(){if(4===n.readyState)return 200===n.status?e.resolve(n.responseText):e.reject(new Error("xhr: HTTP code is not 200"))},n.ontimeout=function(){return e.reject(new Error("xhr: Timeout exceeded"))},n.open("GET",t),n.timeout=this.xhrTimeout,n.setRequestHeader("x-barba","yes"),n.send(),e.promise},extend:function(t,e){var n=Object.create(t);for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);return n},deferred:function(){return new function(){this.resolve=null,this.reject=null,this.promise=new Promise(function(t,e){this.resolve=t,this.reject=e}.bind(this))}},getPort:function(t){var e="undefined"!=typeof t?t:window.location.port,n=window.location.protocol;return""!=e?parseInt(e):"http:"===n?80:"https:"===n?443:void 0}};t.exports=n},function(t,e,n){var r=n(7),i=n(5),o={namespace:null,extend:function(t){return i.extend(this,t)},init:function(){var t=this;r.on("initStateChange",function(e,n){n&&n.namespace===t.namespace&&t.onLeave()}),r.on("newPageReady",function(e,n,r){t.container=r,e.namespace===t.namespace&&t.onEnter()}),r.on("transitionCompleted",function(e,n){e.namespace===t.namespace&&t.onEnterCompleted(),n&&n.namespace===t.namespace&&t.onLeaveCompleted()})},onEnter:function(){},onEnterCompleted:function(){},onLeave:function(){},onLeaveCompleted:function(){}};t.exports=o},function(t,e){var n={events:{},on:function(t,e){this.events[t]=this.events[t]||[],this.events[t].push(e)},off:function(t,e){t in this.events!=!1&&this.events[t].splice(this.events[t].indexOf(e),1)},trigger:function(t){if(t in this.events!=!1)for(var e=0;e<this.events[t].length;e++)this.events[t][e].apply(this,Array.prototype.slice.call(arguments,1))}};t.exports=n},function(t,e,n){var r=n(5),i={data:{},extend:function(t){return r.extend(this,t)},set:function(t,e){this.data[t]=e},get:function(t){return this.data[t]},reset:function(){this.data={}}};t.exports=i},function(t,e){var n={history:[],add:function(t,e){e||(e=void 0),this.history.push({url:t,namespace:e})},currentStatus:function(){return this.history[this.history.length-1]},prevStatus:function(){var t=this.history;return t.length<2?null:t[t.length-2]}};t.exports=n},function(t,e,n){var r=n(5),i=n(7),o=n(11),s=n(8),a=n(9),c=n(12),u={Dom:c,History:a,Cache:s,cacheEnabled:!0,transitionProgress:!1,ignoreClassLink:"no-barba",start:function(){this.init()},init:function(){var t=this.Dom.getContainer(),e=this.Dom.getWrapper();e.setAttribute("aria-live","polite"),this.History.add(this.getCurrentUrl(),this.Dom.getNamespace(t)),i.trigger("initStateChange",this.History.currentStatus()),i.trigger("newPageReady",this.History.currentStatus(),{},t,this.Dom.currentHTML),i.trigger("transitionCompleted",this.History.currentStatus()),this.bindEvents()},bindEvents:function(){document.addEventListener("click",this.onLinkClick.bind(this)),window.addEventListener("popstate",this.onStateChange.bind(this))},getCurrentUrl:function(){return r.cleanLink(r.getCurrentUrl())},goTo:function(t){window.history.pushState(null,null,t),this.onStateChange()},forceGoTo:function(t){window.location=t},load:function(t){var e,n=r.deferred(),i=this;return e=this.Cache.get(t),e||(e=r.xhr(t),this.Cache.set(t,e)),e.then(function(t){var e=i.Dom.parseResponse(t);i.Dom.putContainer(e),i.cacheEnabled||i.Cache.reset(),n.resolve(e)},function(){i.forceGoTo(t),n.reject()}),n.promise},getHref:function(t){if(t)return t.getAttribute&&"string"==typeof t.getAttribute("xlink:href")?t.getAttribute("xlink:href"):"string"==typeof t.href?t.href:void 0},onLinkClick:function(t){for(var e=t.target;e&&!this.getHref(e);)e=e.parentNode;if(this.preventCheck(t,e)){t.stopPropagation(),t.preventDefault(),i.trigger("linkClicked",e,t);var n=this.getHref(e);this.goTo(n)}},preventCheck:function(t,e){if(!window.history.pushState)return!1;var n=this.getHref(e);return!(!e||!n)&&(!(t.which>1||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)&&((!e.target||"_blank"!==e.target)&&(window.location.protocol===e.protocol&&window.location.hostname===e.hostname&&(r.getPort()===r.getPort(e.port)&&(!(n.indexOf("#")>-1)&&((!e.getAttribute||"string"!=typeof e.getAttribute("download"))&&(r.cleanLink(n)!=r.cleanLink(location.href)&&!e.classList.contains(this.ignoreClassLink))))))))},getTransition:function(){return o},onStateChange:function(){var t=this.getCurrentUrl();if(this.transitionProgress&&this.forceGoTo(t),this.History.currentStatus().url===t)return!1;this.History.add(t);var e=this.load(t),n=Object.create(this.getTransition());this.transitionProgress=!0,i.trigger("initStateChange",this.History.currentStatus(),this.History.prevStatus());var r=n.init(this.Dom.getContainer(),e);e.then(this.onNewContainerLoaded.bind(this)),r.then(this.onTransitionEnd.bind(this))},onNewContainerLoaded:function(t){var e=this.History.currentStatus();e.namespace=this.Dom.getNamespace(t),i.trigger("newPageReady",this.History.currentStatus(),this.History.prevStatus(),t,this.Dom.currentHTML)},onTransitionEnd:function(){this.transitionProgress=!1,i.trigger("transitionCompleted",this.History.currentStatus(),this.History.prevStatus())}};t.exports=u},function(t,e,n){var r=n(4),i=r.extend({start:function(){this.newContainerLoading.then(this.finish.bind(this))},finish:function(){document.body.scrollTop=0,this.done()}});t.exports=i},function(t,e){var n={dataNamespace:"namespace",wrapperId:"barba-wrapper",containerClass:"barba-container",currentHTML:document.documentElement.innerHTML,parseResponse:function(t){this.currentHTML=t;var e=document.createElement("div");e.innerHTML=t;var n=e.querySelector("title");return n&&(document.title=n.textContent),this.getContainer(e)},getWrapper:function(){var t=document.getElementById(this.wrapperId);if(!t)throw new Error("Barba.js: wrapper not found!");return t},getContainer:function(t){if(t||(t=document.body),!t)throw new Error("Barba.js: DOM not ready!");var e=this.parseContainer(t);if(e&&e.jquery&&(e=e[0]),!e)throw new Error("Barba.js: no container found");return e},getNamespace:function(t){return t&&t.dataset?t.dataset[this.dataNamespace]:t?t.getAttribute("data-"+this.dataNamespace):null},putContainer:function(t){t.style.visibility="hidden";var e=this.getWrapper();e.appendChild(t)},parseContainer:function(t){return t.querySelector("."+this.containerClass)}};t.exports=n},function(t,e,n){var r=n(5),i=n(10),o={ignoreClassLink:"no-barba-prefetch",init:function(){return!!window.history.pushState&&(document.body.addEventListener("mouseover",this.onLinkEnter.bind(this)),void document.body.addEventListener("touchstart",this.onLinkEnter.bind(this)))},onLinkEnter:function(t){for(var e=t.target;e&&!i.getHref(e);)e=e.parentNode;if(e&&!e.classList.contains(this.ignoreClassLink)){var n=i.getHref(e);if(i.preventCheck(t,e)&&!i.Cache.get(n)){var o=r.xhr(n);i.Cache.set(n,o)}}}};t.exports=o}])});
vendor: 2,752 bytes, lines 10366-10469
10366 10367/** 10368 * Swiper 4.4.2 10369 * Most modern mobile touch slider and framework with hardware accelerated transitions 10370 * http://www.idangero.us/swiper/ 10371 * 10372 * Copyright 2014-2018 Vladimir Kharlampidi 10373 * 10374 * Released under the MIT License 10375 * 10376 * Released on: November 1, 2018 10377 */ 10378 10379(function (global, factory) { 10380 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 10381 typeof define === 'function' && define.amd ? define(factory) : 10382 (global.Swiper = factory()); 10383}(this, (function () { 'use strict'; 10384 10385 /** 10386 * SSR Window 1.0.1 10387 * Better handling for window object in SSR environment 10388 * https://github.com/nolimits4web/ssr-window 10389 * 10390 * Copyright 2018, Vladimir Kharlampidi 10391 * 10392 * Licensed under MIT 10393 * 10394 * Released on: July 18, 2018 10395 */ 10396 var doc = (typeof document === 'undefined') ? { 10397 body: {}, 10398 addEventListener: function addEventListener() {}, 10399 removeEventListener: function removeEventListener() {}, 10400 activeElement: { 10401 blur: function blur() {}, 10402 nodeName: '', 10403 }, 10404 querySelector: function querySelector() { 10405 return null; 10406 }, 10407 querySelectorAll: function querySelectorAll() { 10408 return []; 10409 }, 10410 getElementById: function getElementById() { 10411 return null; 10412 }, 10413 createEvent: function createEvent() { 10414 return { 10415 initEvent: function initEvent() {}, 10416 }; 10417 }, 10418 createElement: function createElement() { 10419 return { 10420 children: [], 10421 childNodes: [], 10422 style: {}, 10423 setAttribute: function setAttribute() {}, 10424 getElementsByTagName: function getElementsByTagName() { 10425 return []; 10426 }, 10427 }; 10428 }, 10429 location: { hash: '' }, 10430 } : document; // eslint-disable-line 10431 10432 var win = (typeof window === 'undefined') ? { 10433 document: doc, 10434 navigator: { 10435 userAgent: '', 10436 }, 10437 location: {}, 10438 history: {}, 10439 CustomEvent: function CustomEvent() { 10440 return this; 10441 }, 10442 addEventListener: function addEventListener() {}, 10443 removeEventListener: function removeEventListener() {}, 10444 getComputedStyle: function getComputedStyle() { 10445 return { 10446 getPropertyValue: function getPropertyValue() { 10447 return ''; 10448 }, 10449 }; 10450 }, 10451 Image: function Image() {}, 10452 Date: function Date() {}, 10453 screen: {}, 10454 setTimeout: function setTimeout() {}, 10455 clearTimeout: function clearTimeout() {}, 10456 } : window; // eslint-disable-line 10457 10458 /** 10459 * Dom7 2.1.2 10460 * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API 10461 * http://framework7.io/docs/dom.html 10462 * 10463 * Copyright 2018, Vladimir Kharlampidi 10464 * The iDangero.us 10465 * http://www.idangero.us/ 10466 * 10467 * Licensed under MIT 10468 * 10469 * Released on: September 13, 2018
vendor: 22,128 bytes, lines 10469-11212
10469 10470 */ 10471 10472 var Dom7 = function Dom7(arr) { 10473 var self = this; 10474 // Create array-like object 10475 for (var i = 0; i < arr.length; i += 1) { 10476 self[i] = arr[i]; 10477 } 10478 self.length = arr.length; 10479 // Return collection with methods 10480 return this; 10481 }; 10482 10483 function $(selector, context) { 10484 var arr = []; 10485 var i = 0; 10486 if (selector && !context) { 10487 if (selector instanceof Dom7) { 10488 return selector; 10489 } 10490 } 10491 if (selector) { 10492 // String 10493 if (typeof selector === 'string') { 10494 var els; 10495 var tempParent; 10496 var html = selector.trim(); 10497 if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) { 10498 var toCreate = 'div'; 10499 if (html.indexOf('<li') === 0) { toCreate = 'ul'; } 10500 if (html.indexOf('<tr') === 0) { toCreate = 'tbody'; } 10501 if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) { toCreate = 'tr'; } 10502 if (html.indexOf('<tbody') === 0) { toCreate = 'table'; } 10503 if (html.indexOf('<option') === 0) { toCreate = 'select'; } 10504 tempParent = doc.createElement(toCreate); 10505 tempParent.innerHTML = html; 10506 for (i = 0; i < tempParent.childNodes.length; i += 1) { 10507 arr.push(tempParent.childNodes[i]); 10508 } 10509 } else { 10510 if (!context && selector[0] === '#' && !selector.match(/[ .<>:~]/)) { 10511 // Pure ID selector 10512 els = [doc.getElementById(selector.trim().split('#')[1])]; 10513 } else { 10514 // Other selectors 10515 els = (context || doc).querySelectorAll(selector.trim()); 10516 } 10517 for (i = 0; i < els.length; i += 1) { 10518 if (els[i]) { arr.push(els[i]); } 10519 } 10520 } 10521 } else if (selector.nodeType || selector === win || selector === doc) { 10522 // Node/element 10523 arr.push(selector); 10524 } else if (selector.length > 0 && selector[0].nodeType) { 10525 // Array of elements or instance of Dom 10526 for (i = 0; i < selector.length; i += 1) { 10527 arr.push(selector[i]); 10528 } 10529 } 10530 } 10531 return new Dom7(arr); 10532 } 10533 10534 $.fn = Dom7.prototype; 10535 $.Class = Dom7; 10536 $.Dom7 = Dom7; 10537 10538 function unique(arr) { 10539 var uniqueArray = []; 10540 for (var i = 0; i < arr.length; i += 1) { 10541 if (uniqueArray.indexOf(arr[i]) === -1) { uniqueArray.push(arr[i]); } 10542 } 10543 return uniqueArray; 10544 } 10545 10546 // Classes and attributes 10547 function addClass(className) { 10548 if (typeof className === 'undefined') { 10549 return this; 10550 } 10551 var classes = className.split(' '); 10552 for (var i = 0; i < classes.length; i += 1) { 10553 for (var j = 0; j < this.length; j += 1) { 10554 if (typeof this[j] !== 'undefined' && typeof this[j].classList !== 'undefined') { this[j].classList.add(classes[i]); } 10555 } 10556 } 10557 return this; 10558 } 10559 function removeClass(className) { 10560 var classes = className.split(' '); 10561 for (var i = 0; i < classes.length; i += 1) { 10562 for (var j = 0; j < this.length; j += 1) { 10563 if (typeof this[j] !== 'undefined' && typeof this[j].classList !== 'undefined') { this[j].classList.remove(classes[i]); } 10564 } 10565 } 10566 return this; 10567 } 10568 function hasClass(className) { 10569 if (!this[0]) { return false; } 10570 return this[0].classList.contains(className); 10571 } 10572 function toggleClass(className) { 10573 var classes = className.split(' '); 10574 for (var i = 0; i < classes.length; i += 1) { 10575 for (var j = 0; j < this.length; j += 1) { 10576 if (typeof this[j] !== 'undefined' && typeof this[j].classList !== 'undefined') { this[j].classList.toggle(classes[i]); } 10577 } 10578 } 10579 return this; 10580 } 10581 function attr(attrs, value) { 10582 var arguments$1 = arguments; 10583 10584 if (arguments.length === 1 && typeof attrs === 'string') { 10585 // Get attr 10586 if (this[0]) { return this[0].getAttribute(attrs); } 10587 return undefined; 10588 } 10589 10590 // Set attrs 10591 for (var i = 0; i < this.length; i += 1) { 10592 if (arguments$1.length === 2) { 10593 // String 10594 this[i].setAttribute(attrs, value); 10595 } else { 10596 // Object 10597 // eslint-disable-next-line 10598 for (var attrName in attrs) { 10599 this[i][attrName] = attrs[attrName]; 10600 this[i].setAttribute(attrName, attrs[attrName]); 10601 } 10602 } 10603 } 10604 return this; 10605 } 10606 // eslint-disable-next-line 10607 function removeAttr(attr) { 10608 for (var i = 0; i < this.length; i += 1) { 10609 this[i].removeAttribute(attr); 10610 } 10611 return this; 10612 } 10613 function data(key, value) { 10614 var el; 10615 if (typeof value === 'undefined') { 10616 el = this[0]; 10617 // Get value 10618 if (el) { 10619 if (el.dom7ElementDataStorage && (key in el.dom7ElementDataStorage)) { 10620 return el.dom7ElementDataStorage[key]; 10621 } 10622 10623 var dataKey = el.getAttribute(("data-" + key)); 10624 if (dataKey) { 10625 return dataKey; 10626 } 10627 return undefined; 10628 } 10629 return undefined; 10630 } 10631 10632 // Set value 10633 for (var i = 0; i < this.length; i += 1) { 10634 el = this[i]; 10635 if (!el.dom7ElementDataStorage) { el.dom7ElementDataStorage = {}; } 10636 el.dom7ElementDataStorage[key] = value; 10637 } 10638 return this; 10639 } 10640 // Transforms 10641 // eslint-disable-next-line 10642 function transform(transform) { 10643 for (var i = 0; i < this.length; i += 1) { 10644 var elStyle = this[i].style; 10645 elStyle.webkitTransform = transform; 10646 elStyle.transform = transform; 10647 } 10648 return this; 10649 } 10650 function transition(duration) { 10651 if (typeof duration !== 'string') { 10652 duration = duration + "ms"; // eslint-disable-line 10653 } 10654 for (var i = 0; i < this.length; i += 1) { 10655 var elStyle = this[i].style; 10656 elStyle.webkitTransitionDuration = duration; 10657 elStyle.transitionDuration = duration; 10658 } 10659 return this; 10660 } 10661 // Events 10662 function on() { 10663 var assign; 10664 10665 var args = [], len = arguments.length; 10666 while ( len-- ) args[ len ] = arguments[ len ]; 10667 var eventType = args[0]; 10668 var targetSelector = args[1]; 10669 var listener = args[2]; 10670 var capture = args[3]; 10671 if (typeof args[1] === 'function') { 10672 (assign = args, eventType = assign[0], listener = assign[1], capture = assign[2]); 10673 targetSelector = undefined; 10674 } 10675 if (!capture) { capture = false; } 10676 10677 function handleLiveEvent(e) { 10678 var target = e.target; 10679 if (!target) { return; } 10680 var eventData = e.target.dom7EventData || []; 10681 if (eventData.indexOf(e) < 0) { 10682 eventData.unshift(e); 10683 } 10684 if ($(target).is(targetSelector)) { listener.apply(target, eventData); } 10685 else { 10686 var parents = $(target).parents(); // eslint-disable-line 10687 for (var k = 0; k < parents.length; k += 1) { 10688 if ($(parents[k]).is(targetSelector)) { listener.apply(parents[k], eventData); } 10689 } 10690 } 10691 } 10692 function handleEvent(e) { 10693 var eventData = e && e.target ? e.target.dom7EventData || [] : []; 10694 if (eventData.indexOf(e) < 0) { 10695 eventData.unshift(e); 10696 } 10697 listener.apply(this, eventData); 10698 } 10699 var events = eventType.split(' '); 10700 var j; 10701 for (var i = 0; i < this.length; i += 1) { 10702 var el = this[i]; 10703 if (!targetSelector) { 10704 for (j = 0; j < events.length; j += 1) { 10705 var event = events[j]; 10706 if (!el.dom7Listeners) { el.dom7Listeners = {}; } 10707 if (!el.dom7Listeners[event]) { el.dom7Listeners[event] = []; } 10708 el.dom7Listeners[event].push({ 10709 listener: listener, 10710 proxyListener: handleEvent, 10711 }); 10712 el.addEventListener(event, handleEvent, capture); 10713 } 10714 } else { 10715 // Live events 10716 for (j = 0; j < events.length; j += 1) { 10717 var event$1 = events[j]; 10718 if (!el.dom7LiveListeners) { el.dom7LiveListeners = {}; } 10719 if (!el.dom7LiveListeners[event$1]) { el.dom7LiveListeners[event$1] = []; } 10720 el.dom7LiveListeners[event$1].push({ 10721 listener: listener, 10722 proxyListener: handleLiveEvent, 10723 }); 10724 el.addEventListener(event$1, handleLiveEvent, capture); 10725 } 10726 } 10727 } 10728 return this; 10729 } 10730 function off() { 10731 var assign; 10732 10733 var args = [], len = arguments.length; 10734 while ( len-- ) args[ len ] = arguments[ len ]; 10735 var eventType = args[0]; 10736 var targetSelector = args[1]; 10737 var listener = args[2]; 10738 var capture = args[3]; 10739 if (typeof args[1] === 'function') { 10740 (assign = args, eventType = assign[0], listener = assign[1], capture = assign[2]); 10741 targetSelector = undefined; 10742 } 10743 if (!capture) { capture = false; } 10744 10745 var events = eventType.split(' '); 10746 for (var i = 0; i < events.length; i += 1) { 10747 var event = events[i]; 10748 for (var j = 0; j < this.length; j += 1) { 10749 var el = this[j]; 10750 var handlers = (void 0); 10751 if (!targetSelector && el.dom7Listeners) { 10752 handlers = el.dom7Listeners[event]; 10753 } else if (targetSelector && el.dom7LiveListeners) { 10754 handlers = el.dom7LiveListeners[event]; 10755 } 10756 if (handlers && handlers.length) { 10757 for (var k = handlers.length - 1; k >= 0; k -= 1) { 10758 var handler = handlers[k]; 10759 if (listener && handler.listener === listener) { 10760 el.removeEventListener(event, handler.proxyListener, capture); 10761 handlers.splice(k, 1); 10762 } else if (!listener) { 10763 el.removeEventListener(event, handler.proxyListener, capture); 10764 handlers.splice(k, 1); 10765 } 10766 } 10767 } 10768 } 10769 } 10770 return this; 10771 } 10772 function trigger() { 10773 var args = [], len = arguments.length; 10774 while ( len-- ) args[ len ] = arguments[ len ]; 10775 10776 var events = args[0].split(' '); 10777 var eventData = args[1]; 10778 for (var i = 0; i < events.length; i += 1) { 10779 var event = events[i]; 10780 for (var j = 0; j < this.length; j += 1) { 10781 var el = this[j]; 10782 var evt = (void 0); 10783 try { 10784 evt = new win.CustomEvent(event, { 10785 detail: eventData, 10786 bubbles: true, 10787 cancelable: true, 10788 }); 10789 } catch (e) { 10790 evt = doc.createEvent('Event'); 10791 evt.initEvent(event, true, true); 10792 evt.detail = eventData; 10793 } 10794 // eslint-disable-next-line 10795 el.dom7EventData = args.filter(function (data, dataIndex) { return dataIndex > 0; }); 10796 el.dispatchEvent(evt); 10797 el.dom7EventData = []; 10798 delete el.dom7EventData; 10799 } 10800 } 10801 return this; 10802 } 10803 function transitionEnd(callback) { 10804 var events = ['webkitTransitionEnd', 'transitionend']; 10805 var dom = this; 10806 var i; 10807 function fireCallBack(e) { 10808 /* jshint validthis:true */ 10809 if (e.target !== this) { return; } 10810 callback.call(this, e); 10811 for (i = 0; i < events.length; i += 1) { 10812 dom.off(events[i], fireCallBack); 10813 } 10814 } 10815 if (callback) { 10816 for (i = 0; i < events.length; i += 1) { 10817 dom.on(events[i], fireCallBack); 10818 } 10819 } 10820 return this; 10821 } 10822 function outerWidth(includeMargins) { 10823 if (this.length > 0) { 10824 if (includeMargins) { 10825 // eslint-disable-next-line 10826 var styles = this.styles(); 10827 return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left')); 10828 } 10829 return this[0].offsetWidth; 10830 } 10831 return null; 10832 } 10833 function outerHeight(includeMargins) { 10834 if (this.length > 0) { 10835 if (includeMargins) { 10836 // eslint-disable-next-line 10837 var styles = this.styles(); 10838 return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom')); 10839 } 10840 return this[0].offsetHeight; 10841 } 10842 return null; 10843 } 10844 function offset() { 10845 if (this.length > 0) { 10846 var el = this[0]; 10847 var box = el.getBoundingClientRect(); 10848 var body = doc.body; 10849 var clientTop = el.clientTop || body.clientTop || 0; 10850 var clientLeft = el.clientLeft || body.clientLeft || 0; 10851 var scrollTop = el === win ? win.scrollY : el.scrollTop; 10852 var scrollLeft = el === win ? win.scrollX : el.scrollLeft; 10853 return { 10854 top: (box.top + scrollTop) - clientTop, 10855 left: (box.left + scrollLeft) - clientLeft, 10856 }; 10857 } 10858 10859 return null; 10860 } 10861 function styles() { 10862 if (this[0]) { return win.getComputedStyle(this[0], null); } 10863 return {}; 10864 } 10865 function css(props, value) { 10866 var i; 10867 if (arguments.length === 1) { 10868 if (typeof props === 'string') { 10869 if (this[0]) { return win.getComputedStyle(this[0], null).getPropertyValue(props); } 10870 } else { 10871 for (i = 0; i < this.length; i += 1) { 10872 // eslint-disable-next-line 10873 for (var prop in props) { 10874 this[i].style[prop] = props[prop]; 10875 } 10876 } 10877 return this; 10878 } 10879 } 10880 if (arguments.length === 2 && typeof props === 'string') { 10881 for (i = 0; i < this.length; i += 1) { 10882 this[i].style[props] = value; 10883 } 10884 return this; 10885 } 10886 return this; 10887 } 10888 // Iterate over the collection passing elements to `callback` 10889 function each(callback) { 10890 // Don't bother continuing without a callback 10891 if (!callback) { return this; } 10892 // Iterate over the current collection 10893 for (var i = 0; i < this.length; i += 1) { 10894 // If the callback returns false 10895 if (callback.call(this[i], i, this[i]) === false) { 10896 // End the loop early 10897 return this; 10898 } 10899 } 10900 // Return `this` to allow chained DOM operations 10901 return this; 10902 } 10903 // eslint-disable-next-line 10904 function html(html) { 10905 if (typeof html === 'undefined') { 10906 return this[0] ? this[0].innerHTML : undefined; 10907 } 10908 10909 for (var i = 0; i < this.length; i += 1) { 10910 this[i].innerHTML = html; 10911 } 10912 return this; 10913 } 10914 // eslint-disable-next-line 10915 function text(text) { 10916 if (typeof text === 'undefined') { 10917 if (this[0]) { 10918 return this[0].textContent.trim(); 10919 } 10920 return null; 10921 } 10922 10923 for (var i = 0; i < this.length; i += 1) { 10924 this[i].textContent = text; 10925 } 10926 return this; 10927 } 10928 function is(selector) { 10929 var el = this[0]; 10930 var compareWith; 10931 var i; 10932 if (!el || typeof selector === 'undefined') { return false; } 10933 if (typeof selector === 'string') { 10934 if (el.matches) { return el.matches(selector); } 10935 else if (el.webkitMatchesSelector) { return el.webkitMatchesSelector(selector); } 10936 else if (el.msMatchesSelector) { return el.msMatchesSelector(selector); } 10937 10938 compareWith = $(selector); 10939 for (i = 0; i < compareWith.length; i += 1) { 10940 if (compareWith[i] === el) { return true; } 10941 } 10942 return false; 10943 } else if (selector === doc) { return el === doc; } 10944 else if (selector === win) { return el === win; } 10945 10946 if (selector.nodeType || selector instanceof Dom7) { 10947 compareWith = selector.nodeType ? [selector] : selector; 10948 for (i = 0; i < compareWith.length; i += 1) { 10949 if (compareWith[i] === el) { return true; } 10950 } 10951 return false; 10952 } 10953 return false; 10954 } 10955 function index() { 10956 var child = this[0]; 10957 var i; 10958 if (child) { 10959 i = 0; 10960 // eslint-disable-next-line 10961 while ((child = child.previousSibling) !== null) { 10962 if (child.nodeType === 1) { i += 1; } 10963 } 10964 return i; 10965 } 10966 return undefined; 10967 } 10968 // eslint-disable-next-line 10969 function eq(index) { 10970 if (typeof index === 'undefined') { return this; } 10971 var length = this.length; 10972 var returnIndex; 10973 if (index > length - 1) { 10974 return new Dom7([]); 10975 } 10976 if (index < 0) { 10977 returnIndex = length + index; 10978 if (returnIndex < 0) { return new Dom7([]); } 10979 return new Dom7([this[returnIndex]]); 10980 } 10981 return new Dom7([this[index]]); 10982 } 10983 function append() { 10984 var args = [], len = arguments.length; 10985 while ( len-- ) args[ len ] = arguments[ len ]; 10986 10987 var newChild; 10988 10989 for (var k = 0; k < args.length; k += 1) { 10990 newChild = args[k]; 10991 for (var i = 0; i < this.length; i += 1) { 10992 if (typeof newChild === 'string') { 10993 var tempDiv = doc.createElement('div'); 10994 tempDiv.innerHTML = newChild; 10995 while (tempDiv.firstChild) { 10996 this[i].appendChild(tempDiv.firstChild); 10997 } 10998 } else if (newChild instanceof Dom7) { 10999 for (var j = 0; j < newChild.length; j += 1) { 11000 this[i].appendChild(newChild[j]); 11001 } 11002 } else { 11003 this[i].appendChild(newChild); 11004 } 11005 } 11006 } 11007 11008 return this; 11009 } 11010 function prepend(newChild) { 11011 var i; 11012 var j; 11013 for (i = 0; i < this.length; i += 1) { 11014 if (typeof newChild === 'string') { 11015 var tempDiv = doc.createElement('div'); 11016 tempDiv.innerHTML = newChild; 11017 for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) { 11018 this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]); 11019 } 11020 } else if (newChild instanceof Dom7) { 11021 for (j = 0; j < newChild.length; j += 1) { 11022 this[i].insertBefore(newChild[j], this[i].childNodes[0]); 11023 } 11024 } else { 11025 this[i].insertBefore(newChild, this[i].childNodes[0]); 11026 } 11027 } 11028 return this; 11029 } 11030 function next(selector) { 11031 if (this.length > 0) { 11032 if (selector) { 11033 if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) { 11034 return new Dom7([this[0].nextElementSibling]); 11035 } 11036 return new Dom7([]); 11037 } 11038 11039 if (this[0].nextElementSibling) { return new Dom7([this[0].nextElementSibling]); } 11040 return new Dom7([]); 11041 } 11042 return new Dom7([]); 11043 } 11044 function nextAll(selector) { 11045 var nextEls = []; 11046 var el = this[0]; 11047 if (!el) { return new Dom7([]); } 11048 while (el.nextElementSibling) { 11049 var next = el.nextElementSibling; // eslint-disable-line 11050 if (selector) { 11051 if ($(next).is(selector)) { nextEls.push(next); } 11052 } else { nextEls.push(next); } 11053 el = next; 11054 } 11055 return new Dom7(nextEls); 11056 } 11057 function prev(selector) { 11058 if (this.length > 0) { 11059 var el = this[0]; 11060 if (selector) { 11061 if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) { 11062 return new Dom7([el.previousElementSibling]); 11063 } 11064 return new Dom7([]); 11065 } 11066 11067 if (el.previousElementSibling) { return new Dom7([el.previousElementSibling]); } 11068 return new Dom7([]); 11069 } 11070 return new Dom7([]); 11071 } 11072 function prevAll(selector) { 11073 var prevEls = []; 11074 var el = this[0]; 11075 if (!el) { return new Dom7([]); } 11076 while (el.previousElementSibling) { 11077 var prev = el.previousElementSibling; // eslint-disable-line 11078 if (selector) { 11079 if ($(prev).is(selector)) { prevEls.push(prev); } 11080 } else { prevEls.push(prev); } 11081 el = prev; 11082 } 11083 return new Dom7(prevEls); 11084 } 11085 function parent(selector) { 11086 var parents = []; // eslint-disable-line 11087 for (var i = 0; i < this.length; i += 1) { 11088 if (this[i].parentNode !== null) { 11089 if (selector) { 11090 if ($(this[i].parentNode).is(selector)) { parents.push(this[i].parentNode); } 11091 } else { 11092 parents.push(this[i].parentNode); 11093 } 11094 } 11095 } 11096 return $(unique(parents)); 11097 } 11098 function parents(selector) { 11099 var parents = []; // eslint-disable-line 11100 for (var i = 0; i < this.length; i += 1) { 11101 var parent = this[i].parentNode; // eslint-disable-line 11102 while (parent) { 11103 if (selector) { 11104 if ($(parent).is(selector)) { parents.push(parent); } 11105 } else { 11106 parents.push(parent); 11107 } 11108 parent = parent.parentNode; 11109 } 11110 } 11111 return $(unique(parents)); 11112 } 11113 function closest(selector) { 11114 var closest = this; // eslint-disable-line 11115 if (typeof selector === 'undefined') { 11116 return new Dom7([]); 11117 } 11118 if (!closest.is(selector)) { 11119 closest = closest.parents(selector).eq(0); 11120 } 11121 return closest; 11122 } 11123 function find(selector) { 11124 var foundElements = []; 11125 for (var i = 0; i < this.length; i += 1) { 11126 var found = this[i].querySelectorAll(selector); 11127 for (var j = 0; j < found.length; j += 1) { 11128 foundElements.push(found[j]); 11129 } 11130 } 11131 return new Dom7(foundElements); 11132 } 11133 function children(selector) { 11134 var children = []; // eslint-disable-line 11135 for (var i = 0; i < this.length; i += 1) { 11136 var childNodes = this[i].childNodes; 11137 11138 for (var j = 0; j < childNodes.length; j += 1) { 11139 if (!selector) { 11140 if (childNodes[j].nodeType === 1) { children.push(childNodes[j]); } 11141 } else if (childNodes[j].nodeType === 1 && $(childNodes[j]).is(selector)) { 11142 children.push(childNodes[j]); 11143 } 11144 } 11145 } 11146 return new Dom7(unique(children)); 11147 } 11148 function remove() { 11149 for (var i = 0; i < this.length; i += 1) { 11150 if (this[i].parentNode) { this[i].parentNode.removeChild(this[i]); } 11151 } 11152 return this; 11153 } 11154 function add() { 11155 var args = [], len = arguments.length; 11156 while ( len-- ) args[ len ] = arguments[ len ]; 11157 11158 var dom = this; 11159 var i; 11160 var j; 11161 for (i = 0; i < args.length; i += 1) { 11162 var toAdd = $(args[i]); 11163 for (j = 0; j < toAdd.length; j += 1) { 11164 dom[dom.length] = toAdd[j]; 11165 dom.length += 1; 11166 } 11167 } 11168 return dom; 11169 } 11170 11171 var Methods = { 11172 addClass: addClass, 11173 removeClass: removeClass, 11174 hasClass: hasClass, 11175 toggleClass: toggleClass, 11176 attr: attr, 11177 removeAttr: removeAttr, 11178 data: data, 11179 transform: transform, 11180 transition: transition, 11181 on: on, 11182 off: off, 11183 trigger: trigger, 11184 transitionEnd: transitionEnd, 11185 outerWidth: outerWidth, 11186 outerHeight: outerHeight, 11187 offset: offset, 11188 css: css, 11189 each: each, 11190 html: html, 11191 text: text, 11192 is: is, 11193 index: index, 11194 eq: eq, 11195 append: append, 11196 prepend: prepend, 11197 next: next, 11198 nextAll: nextAll, 11199 prev: prev, 11200 prevAll: prevAll, 11201 parent: parent, 11202 parents: parents, 11203 closest: closest, 11204 find: find, 11205 children: children, 11206 remove: remove, 11207 add: add, 11208 styles: styles, 11209 }; 11210 11211 Object.keys(Methods).forEach(function (methodName) { 11212 $.fn[methodName] =
vendor: 27,052 bytes, lines 11212-11954
11212Methods[methodName]; 11213 }); 11214 11215 var Utils = { 11216 deleteProps: function deleteProps(obj) { 11217 var object = obj; 11218 Object.keys(object).forEach(function (key) { 11219 try { 11220 object[key] = null; 11221 } catch (e) { 11222 // no getter for object 11223 } 11224 try { 11225 delete object[key]; 11226 } catch (e) { 11227 // something got wrong 11228 } 11229 }); 11230 }, 11231 nextTick: function nextTick(callback, delay) { 11232 if ( delay === void 0 ) delay = 0; 11233 11234 return setTimeout(callback, delay); 11235 }, 11236 now: function now() { 11237 return Date.now(); 11238 }, 11239 getTranslate: function getTranslate(el, axis) { 11240 if ( axis === void 0 ) axis = 'x'; 11241 11242 var matrix; 11243 var curTransform; 11244 var transformMatrix; 11245 11246 var curStyle = win.getComputedStyle(el, null); 11247 11248 if (win.WebKitCSSMatrix) { 11249 curTransform = curStyle.transform || curStyle.webkitTransform; 11250 if (curTransform.split(',').length > 6) { 11251 curTransform = curTransform.split(', ').map(function (a) { return a.replace(',', '.'); }).join(', '); 11252 } 11253 // Some old versions of Webkit choke when 'none' is passed; pass 11254 // empty string instead in this case 11255 transformMatrix = new win.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform); 11256 } else { 11257 transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,'); 11258 matrix = transformMatrix.toString().split(','); 11259 } 11260 11261 if (axis === 'x') { 11262 // Latest Chrome and webkits Fix 11263 if (win.WebKitCSSMatrix) { curTransform = transformMatrix.m41; } 11264 // Crazy IE10 Matrix 11265 else if (matrix.length === 16) { curTransform = parseFloat(matrix[12]); } 11266 // Normal Browsers 11267 else { curTransform = parseFloat(matrix[4]); } 11268 } 11269 if (axis === 'y') { 11270 // Latest Chrome and webkits Fix 11271 if (win.WebKitCSSMatrix) { curTransform = transformMatrix.m42; } 11272 // Crazy IE10 Matrix 11273 else if (matrix.length === 16) { curTransform = parseFloat(matrix[13]); } 11274 // Normal Browsers 11275 else { curTransform = parseFloat(matrix[5]); } 11276 } 11277 return curTransform || 0; 11278 }, 11279 parseUrlQuery: function parseUrlQuery(url) { 11280 var query = {}; 11281 var urlToParse = url || win.location.href; 11282 var i; 11283 var params; 11284 var param; 11285 var length; 11286 if (typeof urlToParse === 'string' && urlToParse.length) { 11287 urlToParse = urlToParse.indexOf('?') > -1 ? urlToParse.replace(/\S*\?/, '') : ''; 11288 params = urlToParse.split('&').filter(function (paramsPart) { return paramsPart !== ''; }); 11289 length = params.length; 11290 11291 for (i = 0; i < length; i += 1) { 11292 param = params[i].replace(/#\S+/g, '').split('='); 11293 query[decodeURIComponent(param[0])] = typeof param[1] === 'undefined' ? undefined : decodeURIComponent(param[1]) || ''; 11294 } 11295 } 11296 return query; 11297 }, 11298 isObject: function isObject(o) { 11299 return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; 11300 }, 11301 extend: function extend() { 11302 var args = [], len$1 = arguments.length; 11303 while ( len$1-- ) args[ len$1 ] = arguments[ len$1 ]; 11304 11305 var to = Object(args[0]); 11306 for (var i = 1; i < args.length; i += 1) { 11307 var nextSource = args[i]; 11308 if (nextSource !== undefined && nextSource !== null) { 11309 var keysArray = Object.keys(Object(nextSource)); 11310 for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { 11311 var nextKey = keysArray[nextIndex]; 11312 var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); 11313 if (desc !== undefined && desc.enumerable) { 11314 if (Utils.isObject(to[nextKey]) && Utils.isObject(nextSource[nextKey])) { 11315 Utils.extend(to[nextKey], nextSource[nextKey]); 11316 } else if (!Utils.isObject(to[nextKey]) && Utils.isObject(nextSource[nextKey])) { 11317 to[nextKey] = {}; 11318 Utils.extend(to[nextKey], nextSource[nextKey]); 11319 } else { 11320 to[nextKey] = nextSource[nextKey]; 11321 } 11322 } 11323 } 11324 } 11325 } 11326 return to; 11327 }, 11328 }; 11329 11330 var Support = (function Support() { 11331 var testDiv = doc.createElement('div'); 11332 return { 11333 touch: (win.Modernizr && win.Modernizr.touch === true) || (function checkTouch() { 11334 return !!(('ontouchstart' in win) || (win.DocumentTouch && doc instanceof win.DocumentTouch)); 11335 }()), 11336 11337 pointerEvents: !!(win.navigator.pointerEnabled || win.PointerEvent || ('maxTouchPoints' in win.navigator)), 11338 prefixedPointerEvents: !!win.navigator.msPointerEnabled, 11339 11340 transition: (function checkTransition() { 11341 var style = testDiv.style; 11342 return ('transition' in style || 'webkitTransition' in style || 'MozTransition' in style); 11343 }()), 11344 transforms3d: (win.Modernizr && win.Modernizr.csstransforms3d === true) || (function checkTransforms3d() { 11345 var style = testDiv.style; 11346 return ('webkitPerspective' in style || 'MozPerspective' in style || 'OPerspective' in style || 'MsPerspective' in style || 'perspective' in style); 11347 }()), 11348 11349 flexbox: (function checkFlexbox() { 11350 var style = testDiv.style; 11351 var styles = ('alignItems webkitAlignItems webkitBoxAlign msFlexAlign mozBoxAlign webkitFlexDirection msFlexDirection mozBoxDirection mozBoxOrient webkitBoxDirection webkitBoxOrient').split(' '); 11352 for (var i = 0; i < styles.length; i += 1) { 11353 if (styles[i] in style) { return true; } 11354 } 11355 return false; 11356 }()), 11357 11358 observer: (function checkObserver() { 11359 return ('MutationObserver' in win || 'WebkitMutationObserver' in win); 11360 }()), 11361 11362 passiveListener: (function checkPassiveListener() { 11363 var supportsPassive = false; 11364 try { 11365 var opts = Object.defineProperty({}, 'passive', { 11366 // eslint-disable-next-line 11367 get: function get() { 11368 supportsPassive = true; 11369 }, 11370 }); 11371 win.addEventListener('testPassiveListener', null, opts); 11372 } catch (e) { 11373 // No support 11374 } 11375 return supportsPassive; 11376 }()), 11377 11378 gestures: (function checkGestures() { 11379 return 'ongesturestart' in win; 11380 }()), 11381 }; 11382 }()); 11383 11384 var SwiperClass = function SwiperClass(params) { 11385 if ( params === void 0 ) params = {}; 11386 11387 var self = this; 11388 self.params = params; 11389 11390 // Events 11391 self.eventsListeners = {}; 11392 11393 if (self.params && self.params.on) { 11394 Object.keys(self.params.on).forEach(function (eventName) { 11395 self.on(eventName, self.params.on[eventName]); 11396 }); 11397 } 11398 }; 11399 11400 var staticAccessors = { components: { configurable: true } }; 11401 11402 SwiperClass.prototype.on = function on (events, handler, priority) { 11403 var self = this; 11404 if (typeof handler !== 'function') { return self; } 11405 var method = priority ? 'unshift' : 'push'; 11406 events.split(' ').forEach(function (event) { 11407 if (!self.eventsListeners[event]) { self.eventsListeners[event] = []; } 11408 self.eventsListeners[event][method](handler); 11409 }); 11410 return self; 11411 }; 11412 11413 SwiperClass.prototype.once = function once (events, handler, priority) { 11414 var self = this; 11415 if (typeof handler !== 'function') { return self; } 11416 function onceHandler() { 11417 var args = [], len = arguments.length; 11418 while ( len-- ) args[ len ] = arguments[ len ]; 11419 11420 handler.apply(self, args); 11421 self.off(events, onceHandler); 11422 } 11423 return self.on(events, onceHandler, priority); 11424 }; 11425 11426 SwiperClass.prototype.off = function off (events, handler) { 11427 var self = this; 11428 if (!self.eventsListeners) { return self; } 11429 events.split(' ').forEach(function (event) { 11430 if (typeof handler === 'undefined') { 11431 self.eventsListeners[event] = []; 11432 } else if (self.eventsListeners[event] && self.eventsListeners[event].length) { 11433 self.eventsListeners[event].forEach(function (eventHandler, index) { 11434 if (eventHandler === handler) { 11435 self.eventsListeners[event].splice(index, 1); 11436 } 11437 }); 11438 } 11439 }); 11440 return self; 11441 }; 11442 11443 SwiperClass.prototype.emit = function emit () { 11444 var args = [], len = arguments.length; 11445 while ( len-- ) args[ len ] = arguments[ len ]; 11446 11447 var self = this; 11448 if (!self.eventsListeners) { return self; } 11449 var events; 11450 var data; 11451 var context; 11452 if (typeof args[0] === 'string' || Array.isArray(args[0])) { 11453 events = args[0]; 11454 data = args.slice(1, args.length); 11455 context = self; 11456 } else { 11457 events = args[0].events; 11458 data = args[0].data; 11459 context = args[0].context || self; 11460 } 11461 var eventsArray = Array.isArray(events) ? events : events.split(' '); 11462 eventsArray.forEach(function (event) { 11463 if (self.eventsListeners && self.eventsListeners[event]) { 11464 var handlers = []; 11465 self.eventsListeners[event].forEach(function (eventHandler) { 11466 handlers.push(eventHandler); 11467 }); 11468 handlers.forEach(function (eventHandler) { 11469 eventHandler.apply(context, data); 11470 }); 11471 } 11472 }); 11473 return self; 11474 }; 11475 11476 SwiperClass.prototype.useModulesParams = function useModulesParams (instanceParams) { 11477 var instance = this; 11478 if (!instance.modules) { return; } 11479 Object.keys(instance.modules).forEach(function (moduleName) { 11480 var module = instance.modules[moduleName]; 11481 // Extend params 11482 if (module.params) { 11483 Utils.extend(instanceParams, module.params); 11484 } 11485 }); 11486 }; 11487 11488 SwiperClass.prototype.useModules = function useModules (modulesParams) { 11489 if ( modulesParams === void 0 ) modulesParams = {}; 11490 11491 var instance = this; 11492 if (!instance.modules) { return; } 11493 Object.keys(instance.modules).forEach(function (moduleName) { 11494 var module = instance.modules[moduleName]; 11495 var moduleParams = modulesParams[moduleName] || {}; 11496 // Extend instance methods and props 11497 if (module.instance) { 11498 Object.keys(module.instance).forEach(function (modulePropName) { 11499 var moduleProp = module.instance[modulePropName]; 11500 if (typeof moduleProp === 'function') { 11501 instance[modulePropName] = moduleProp.bind(instance); 11502 } else { 11503 instance[modulePropName] = moduleProp; 11504 } 11505 }); 11506 } 11507 // Add event listeners 11508 if (module.on && instance.on) { 11509 Object.keys(module.on).forEach(function (moduleEventName) { 11510 instance.on(moduleEventName, module.on[moduleEventName]); 11511 }); 11512 } 11513 11514 // Module create callback 11515 if (module.create) { 11516 module.create.bind(instance)(moduleParams); 11517 } 11518 }); 11519 }; 11520 11521 staticAccessors.components.set = function (components) { 11522 var Class = this; 11523 if (!Class.use) { return; } 11524 Class.use(components); 11525 }; 11526 11527 SwiperClass.installModule = function installModule (module) { 11528 var params = [], len = arguments.length - 1; 11529 while ( len-- > 0 ) params[ len ] = arguments[ len + 1 ]; 11530 11531 var Class = this; 11532 if (!Class.prototype.modules) { Class.prototype.modules = {}; } 11533 var name = module.name || (((Object.keys(Class.prototype.modules).length) + "_" + (Utils.now()))); 11534 Class.prototype.modules[name] = module; 11535 // Prototype 11536 if (module.proto) { 11537 Object.keys(module.proto).forEach(function (key) { 11538 Class.prototype[key] = module.proto[key]; 11539 }); 11540 } 11541 // Class 11542 if (module.static) { 11543 Object.keys(module.static).forEach(function (key) { 11544 Class[key] = module.static[key]; 11545 }); 11546 } 11547 // Callback 11548 if (module.install) { 11549 module.install.apply(Class, params); 11550 } 11551 return Class; 11552 }; 11553 11554 SwiperClass.use = function use (module) { 11555 var params = [], len = arguments.length - 1; 11556 while ( len-- > 0 ) params[ len ] = arguments[ len + 1 ]; 11557 11558 var Class = this; 11559 if (Array.isArray(module)) { 11560 module.forEach(function (m) { return Class.installModule(m); }); 11561 return Class; 11562 } 11563 return Class.installModule.apply(Class, [ module ].concat( params )); 11564 }; 11565 11566 Object.defineProperties( SwiperClass, staticAccessors ); 11567 11568 function updateSize () { 11569 var swiper = this; 11570 var width; 11571 var height; 11572 var $el = swiper.$el; 11573 if (typeof swiper.params.width !== 'undefined') { 11574 width = swiper.params.width; 11575 } else { 11576 width = $el[0].clientWidth; 11577 } 11578 if (typeof swiper.params.height !== 'undefined') { 11579 height = swiper.params.height; 11580 } else { 11581 height = $el[0].clientHeight; 11582 } 11583 if ((width === 0 && swiper.isHorizontal()) || (height === 0 && swiper.isVertical())) { 11584 return; 11585 } 11586 11587 // Subtract paddings 11588 width = width - parseInt($el.css('padding-left'), 10) - parseInt($el.css('padding-right'), 10); 11589 height = height - parseInt($el.css('padding-top'), 10) - parseInt($el.css('padding-bottom'), 10); 11590 11591 Utils.extend(swiper, { 11592 width: width, 11593 height: height, 11594 size: swiper.isHorizontal() ? width : height, 11595 }); 11596 } 11597 11598 function updateSlides () { 11599 var swiper = this; 11600 var params = swiper.params; 11601 11602 var $wrapperEl = swiper.$wrapperEl; 11603 var swiperSize = swiper.size; 11604 var rtl = swiper.rtlTranslate; 11605 var wrongRTL = swiper.wrongRTL; 11606 var isVirtual = swiper.virtual && params.virtual.enabled; 11607 var previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length; 11608 var slides = $wrapperEl.children(("." + (swiper.params.slideClass))); 11609 var slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length; 11610 var snapGrid = []; 11611 var slidesGrid = []; 11612 var slidesSizesGrid = []; 11613 11614 var offsetBefore = params.slidesOffsetBefore; 11615 if (typeof offsetBefore === 'function') { 11616 offsetBefore = params.slidesOffsetBefore.call(swiper); 11617 } 11618 11619 var offsetAfter = params.slidesOffsetAfter; 11620 if (typeof offsetAfter === 'function') { 11621 offsetAfter = params.slidesOffsetAfter.call(swiper); 11622 } 11623 11624 var previousSnapGridLength = swiper.snapGrid.length; 11625 var previousSlidesGridLength = swiper.snapGrid.length; 11626 11627 var spaceBetween = params.spaceBetween; 11628 var slidePosition = -offsetBefore; 11629 var prevSlideSize = 0; 11630 var index = 0; 11631 if (typeof swiperSize === 'undefined') { 11632 return; 11633 } 11634 if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) { 11635 spaceBetween = (parseFloat(spaceBetween.replace('%', '')) / 100) * swiperSize; 11636 } 11637 11638 swiper.virtualSize = -spaceBetween; 11639 11640 // reset margins 11641 if (rtl) { slides.css({ marginLeft: '', marginTop: '' }); } 11642 else { slides.css({ marginRight: '', marginBottom: '' }); } 11643 11644 var slidesNumberEvenToRows; 11645 if (params.slidesPerColumn > 1) { 11646 if (Math.floor(slidesLength / params.slidesPerColumn) === slidesLength / swiper.params.slidesPerColumn) { 11647 slidesNumberEvenToRows = slidesLength; 11648 } else { 11649 slidesNumberEvenToRows = Math.ceil(slidesLength / params.slidesPerColumn) * params.slidesPerColumn; 11650 } 11651 if (params.slidesPerView !== 'auto' && params.slidesPerColumnFill === 'row') { 11652 slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, params.slidesPerView * params.slidesPerColumn); 11653 } 11654 } 11655 11656 // Calc slides 11657 var slideSize; 11658 var slidesPerColumn = params.slidesPerColumn; 11659 var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn; 11660 var numFullColumns = slidesPerRow - ((params.slidesPerColumn * slidesPerRow) - slidesLength); 11661 for (var i = 0; i < slidesLength; i += 1) { 11662 slideSize = 0; 11663 var slide = slides.eq(i); 11664 if (params.slidesPerColumn > 1) { 11665 // Set slides order 11666 var newSlideOrderIndex = (void 0); 11667 var column = (void 0); 11668 var row = (void 0); 11669 if (params.slidesPerColumnFill === 'column') { 11670 column = Math.floor(i / slidesPerColumn); 11671 row = i - (column * slidesPerColumn); 11672 if (column > numFullColumns || (column === numFullColumns && row === slidesPerColumn - 1)) { 11673 row += 1; 11674 if (row >= slidesPerColumn) { 11675 row = 0; 11676 column += 1; 11677 } 11678 } 11679 newSlideOrderIndex = column + ((row * slidesNumberEvenToRows) / slidesPerColumn); 11680 slide 11681 .css({ 11682 '-webkit-box-ordinal-group': newSlideOrderIndex, 11683 '-moz-box-ordinal-group': newSlideOrderIndex, 11684 '-ms-flex-order': newSlideOrderIndex, 11685 '-webkit-order': newSlideOrderIndex, 11686 order: newSlideOrderIndex, 11687 }); 11688 } else { 11689 row = Math.floor(i / slidesPerRow); 11690 column = i - (row * slidesPerRow); 11691 } 11692 slide 11693 .css( 11694 ("margin-" + (swiper.isHorizontal() ? 'top' : 'left')), 11695 (row !== 0 && params.spaceBetween) && (((params.spaceBetween) + "px")) 11696 ) 11697 .attr('data-swiper-column', column) 11698 .attr('data-swiper-row', row); 11699 } 11700 if (slide.css('display') === 'none') { continue; } // eslint-disable-line 11701 11702 if (params.slidesPerView === 'auto') { 11703 var slideStyles = win.getComputedStyle(slide[0], null); 11704 var currentTransform = slide[0].style.transform; 11705 var currentWebKitTransform = slide[0].style.webkitTransform; 11706 if (currentTransform) { 11707 slide[0].style.transform = 'none'; 11708 } 11709 if (currentWebKitTransform) { 11710 slide[0].style.webkitTransform = 'none'; 11711 } 11712 if (params.roundLengths) { 11713 slideSize = swiper.isHorizontal() 11714 ? slide.outerWidth(true) 11715 : slide.outerHeight(true); 11716 } else { 11717 // eslint-disable-next-line 11718 if (swiper.isHorizontal()) { 11719 slideSize = parseFloat(slideStyles.getPropertyValue('width')) 11720 + parseFloat(slideStyles.getPropertyValue('margin-left')) 11721 + parseFloat(slideStyles.getPropertyValue('margin-right')); 11722 } else { 11723 slideSize = parseFloat(slideStyles.getPropertyValue('height')) 11724 + parseFloat(slideStyles.getPropertyValue('margin-top')) 11725 + parseFloat(slideStyles.getPropertyValue('margin-bottom')); 11726 } 11727 } 11728 if (currentTransform) { 11729 slide[0].style.transform = currentTransform; 11730 } 11731 if (currentWebKitTransform) { 11732 slide[0].style.webkitTransform = currentWebKitTransform; 11733 } 11734 if (params.roundLengths) { slideSize = Math.floor(slideSize); } 11735 } else { 11736 slideSize = (swiperSize - ((params.slidesPerView - 1) * spaceBetween)) / params.slidesPerView; 11737 if (params.roundLengths) { slideSize = Math.floor(slideSize); } 11738 11739 if (slides[i]) { 11740 if (swiper.isHorizontal()) { 11741 slides[i].style.width = slideSize + "px"; 11742 } else { 11743 slides[i].style.height = slideSize + "px"; 11744 } 11745 } 11746 } 11747 if (slides[i]) { 11748 slides[i].swiperSlideSize = slideSize; 11749 } 11750 slidesSizesGrid.push(slideSize); 11751 11752 11753 if (params.centeredSlides) { 11754 slidePosition = slidePosition + (slideSize / 2) + (prevSlideSize / 2) + spaceBetween; 11755 if (prevSlideSize === 0 && i !== 0) { slidePosition = slidePosition - (swiperSize / 2) - spaceBetween; } 11756 if (i === 0) { slidePosition = slidePosition - (swiperSize / 2) - spaceBetween; } 11757 if (Math.abs(slidePosition) < 1 / 1000) { slidePosition = 0; } 11758 if (params.roundLengths) { slidePosition = Math.floor(slidePosition); } 11759 if ((index) % params.slidesPerGroup === 0) { snapGrid.push(slidePosition); } 11760 slidesGrid.push(slidePosition); 11761 } else { 11762 if (params.roundLengths) { slidePosition = Math.floor(slidePosition); } 11763 if ((index) % params.slidesPerGroup === 0) { snapGrid.push(slidePosition); } 11764 slidesGrid.push(slidePosition); 11765 slidePosition = slidePosition + slideSize + spaceBetween; 11766 } 11767 11768 swiper.virtualSize += slideSize + spaceBetween; 11769 11770 prevSlideSize = slideSize; 11771 11772 index += 1; 11773 } 11774 swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter; 11775 var newSlidesGrid; 11776 11777 if ( 11778 rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) { 11779 $wrapperEl.css({ width: ((swiper.virtualSize + params.spaceBetween) + "px") }); 11780 } 11781 if (!Support.flexbox || params.setWrapperSize) { 11782 if (swiper.isHorizontal()) { $wrapperEl.css({ width: ((swiper.virtualSize + params.spaceBetween) + "px") }); } 11783 else { $wrapperEl.css({ height: ((swiper.virtualSize + params.spaceBetween) + "px") }); } 11784 } 11785 11786 if (params.slidesPerColumn > 1) { 11787 swiper.virtualSize = (slideSize + params.spaceBetween) * slidesNumberEvenToRows; 11788 swiper.virtualSize = Math.ceil(swiper.virtualSize / params.slidesPerColumn) - params.spaceBetween; 11789 if (swiper.isHorizontal()) { $wrapperEl.css({ width: ((swiper.virtualSize + params.spaceBetween) + "px") }); } 11790 else { $wrapperEl.css({ height: ((swiper.virtualSize + params.spaceBetween) + "px") }); } 11791 if (params.centeredSlides) { 11792 newSlidesGrid = []; 11793 for (var i$1 = 0; i$1 < snapGrid.length; i$1 += 1) { 11794 var slidesGridItem = snapGrid[i$1]; 11795 if (params.roundLengths) { slidesGridItem = Math.floor(slidesGridItem); } 11796 if (snapGrid[i$1] < swiper.virtualSize + snapGrid[0]) { newSlidesGrid.push(slidesGridItem); } 11797 } 11798 snapGrid = newSlidesGrid; 11799 } 11800 } 11801 11802 // Remove last grid elements depending on width 11803 if (!params.centeredSlides) { 11804 newSlidesGrid = []; 11805 for (var i$2 = 0; i$2 < snapGrid.length; i$2 += 1) { 11806 var slidesGridItem$1 = snapGrid[i$2]; 11807 if (params.roundLengths) { slidesGridItem$1 = Math.floor(slidesGridItem$1); } 11808 if (snapGrid[i$2] <= swiper.virtualSize - swiperSize) { 11809 newSlidesGrid.push(slidesGridItem$1); 11810 } 11811 } 11812 snapGrid = newSlidesGrid; 11813 if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) { 11814 snapGrid.push(swiper.virtualSize - swiperSize); 11815 } 11816 } 11817 if (snapGrid.length === 0) { snapGrid = [0]; } 11818 11819 if (params.spaceBetween !== 0) { 11820 if (swiper.isHorizontal()) { 11821 if (rtl) { slides.css({ marginLeft: (spaceBetween + "px") }); } 11822 else { slides.css({ marginRight: (spaceBetween + "px") }); } 11823 } else { slides.css({ marginBottom: (spaceBetween + "px") }); } 11824 } 11825 11826 if (params.centerInsufficientSlides) { 11827 var allSlidesSize = 0; 11828 slidesSizesGrid.forEach(function (slideSizeValue) { 11829 allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0); 11830 }); 11831 allSlidesSize -= params.spaceBetween; 11832 if (allSlidesSize < swiperSize) { 11833 var allSlidesOffset = (swiperSize - allSlidesSize) / 2; 11834 snapGrid.forEach(function (snap, snapIndex) { 11835 snapGrid[snapIndex] = snap - allSlidesOffset; 11836 }); 11837 slidesGrid.forEach(function (snap, snapIndex) { 11838 slidesGrid[snapIndex] = snap + allSlidesOffset; 11839 }); 11840 } 11841 } 11842 11843 Utils.extend(swiper, { 11844 slides: slides, 11845 snapGrid: snapGrid, 11846 slidesGrid: slidesGrid, 11847 slidesSizesGrid: slidesSizesGrid, 11848 }); 11849 11850 if (slidesLength !== previousSlidesLength) { 11851 swiper.emit('slidesLengthChange'); 11852 } 11853 if (snapGrid.length !== previousSnapGridLength) { 11854 if (swiper.params.watchOverflow) { swiper.checkOverflow(); } 11855 swiper.emit('snapGridLengthChange'); 11856 } 11857 if (slidesGrid.length !== previousSlidesGridLength) { 11858 swiper.emit('slidesGridLengthChange'); 11859 } 11860 11861 if (params.watchSlidesProgress || params.watchSlidesVisibility) { 11862 swiper.updateSlidesOffset(); 11863 } 11864 } 11865 11866 function updateAutoHeight (speed) { 11867 var swiper = this; 11868 var activeSlides = []; 11869 var newHeight = 0; 11870 var i; 11871 if (typeof speed === 'number') { 11872 swiper.setTransition(speed); 11873 } else if (speed === true) { 11874 swiper.setTransition(swiper.params.speed); 11875 } 11876 // Find slides currently in view 11877 if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) { 11878 for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) { 11879 var index = swiper.activeIndex + i; 11880 if (index > swiper.slides.length) { break; } 11881 activeSlides.push(swiper.slides.eq(index)[0]); 11882 } 11883 } else { 11884 activeSlides.push(swiper.slides.eq(swiper.activeIndex)[0]); 11885 } 11886 11887 // Find new height from highest slide in view 11888 for (i = 0; i < activeSlides.length; i += 1) { 11889 if (typeof activeSlides[i] !== 'undefined') { 11890 var height = activeSlides[i].offsetHeight; 11891 newHeight = height > newHeight ? height : newHeight; 11892 } 11893 } 11894 11895 // Update Height 11896 if (newHeight) { swiper.$wrapperEl.css('height', (newHeight + "px")); } 11897 } 11898 11899 function updateSlidesOffset () { 11900 var swiper = this; 11901 var slides = swiper.slides; 11902 for (var i = 0; i < slides.length; i += 1) { 11903 slides[i].swiperSlideOffset = swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop; 11904 } 11905 } 11906 11907 function updateSlidesProgress (translate) { 11908 if ( translate === void 0 ) translate = (this && this.translate) || 0; 11909 11910 var swiper = this; 11911 var params = swiper.params; 11912 11913 var slides = swiper.slides; 11914 var rtl = swiper.rtlTranslate; 11915 11916 if (slides.length === 0) { return; } 11917 if (typeof slides[0].swiperSlideOffset === 'undefined') { swiper.updateSlidesOffset(); } 11918 11919 var offsetCenter = -translate; 11920 if (rtl) { offsetCenter = translate; } 11921 11922 // Visible Slides 11923 slides.removeClass(params.slideVisibleClass); 11924 11925 swiper.visibleSlidesIndexes = []; 11926 swiper.visibleSlides = []; 11927 11928 for (var i = 0; i < slides.length; i += 1) { 11929 var slide = slides[i]; 11930 var slideProgress = ( 11931 (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0)) - slide.swiperSlideOffset 11932 ) / (slide.swiperSlideSize + params.spaceBetween); 11933 if (params.watchSlidesVisibility) { 11934 var slideBefore = -(offsetCenter - slide.swiperSlideOffset); 11935 var slideAfter = slideBefore + swiper.slidesSizesGrid[i]; 11936 var isVisible = (slideBefore >= 0 && slideBefore < swiper.size) 11937 || (slideAfter > 0 && slideAfter <= swiper.size) 11938 || (slideBefore <= 0 && slideAfter >= swiper.size); 11939 if (isVisible) { 11940 swiper.visibleSlides.push(slide); 11941 swiper.visibleSlidesIndexes.push(i); 11942 slides.eq(i).addClass(params.slideVisibleClass); 11943 } 11944 } 11945 slide.progress = rtl ? -slideProgress : slideProgress; 11946 } 11947 swiper.visibleSlides = $(swiper.visibleSlides); 11948 } 11949 11950 function updateProgress (translate) { 11951 if ( translate === void 0 ) translate = (this && this.translate) || 0; 11952 11953 var swiper = this; 11954 var params = swiper.params;
vendor: 6,283 bytes, lines 11954-12117
11954 11955 11956 var translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); 11957 var progress = swiper.progress; 11958 var isBeginning = swiper.isBeginning; 11959 var isEnd = swiper.isEnd; 11960 var wasBeginning = isBeginning; 11961 var wasEnd = isEnd; 11962 if (translatesDiff === 0) { 11963 progress = 0; 11964 isBeginning = true; 11965 isEnd = true; 11966 } else { 11967 progress = (translate - swiper.minTranslate()) / (translatesDiff); 11968 isBeginning = progress <= 0; 11969 isEnd = progress >= 1; 11970 } 11971 Utils.extend(swiper, { 11972 progress: progress, 11973 isBeginning: isBeginning, 11974 isEnd: isEnd, 11975 }); 11976 11977 if (params.watchSlidesProgress || params.watchSlidesVisibility) { swiper.updateSlidesProgress(translate); } 11978 11979 if (isBeginning && !wasBeginning) { 11980 swiper.emit('reachBeginning toEdge'); 11981 } 11982 if (isEnd && !wasEnd) { 11983 swiper.emit('reachEnd toEdge'); 11984 } 11985 if ((wasBeginning && !isBeginning) || (wasEnd && !isEnd)) { 11986 swiper.emit('fromEdge'); 11987 } 11988 11989 swiper.emit('progress', progress); 11990 } 11991 11992 function updateSlidesClasses () { 11993 var swiper = this; 11994 11995 var slides = swiper.slides; 11996 var params = swiper.params; 11997 var $wrapperEl = swiper.$wrapperEl; 11998 var activeIndex = swiper.activeIndex; 11999 var realIndex = swiper.realIndex; 12000 var isVirtual = swiper.virtual && params.virtual.enabled; 12001 12002 slides.removeClass(((params.slideActiveClass) + " " + (params.slideNextClass) + " " + (params.slidePrevClass) + " " + (params.slideDuplicateActiveClass) + " " + (params.slideDuplicateNextClass) + " " + (params.slideDuplicatePrevClass))); 12003 12004 var activeSlide; 12005 if (isVirtual) { 12006 activeSlide = swiper.$wrapperEl.find(("." + (params.slideClass) + "[data-swiper-slide-index=\"" + activeIndex + "\"]")); 12007 } else { 12008 activeSlide = slides.eq(activeIndex); 12009 } 12010 12011 // Active classes 12012 activeSlide.addClass(params.slideActiveClass); 12013 12014 if (params.loop) { 12015 // Duplicate to all looped slides 12016 if (activeSlide.hasClass(params.slideDuplicateClass)) { 12017 $wrapperEl 12018 .children(("." + (params.slideClass) + ":not(." + (params.slideDuplicateClass) + ")[data-swiper-slide-index=\"" + realIndex + "\"]")) 12019 .addClass(params.slideDuplicateActiveClass); 12020 } else { 12021 $wrapperEl 12022 .children(("." + (params.slideClass) + "." + (params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + realIndex + "\"]")) 12023 .addClass(params.slideDuplicateActiveClass); 12024 } 12025 } 12026 // Next Slide 12027 var nextSlide = activeSlide.nextAll(("." + (params.slideClass))).eq(0).addClass(params.slideNextClass); 12028 if (params.loop && nextSlide.length === 0) { 12029 nextSlide = slides.eq(0); 12030 nextSlide.addClass(params.slideNextClass); 12031 } 12032 // Prev Slide 12033 var prevSlide = activeSlide.prevAll(("." + (params.slideClass))).eq(0).addClass(params.slidePrevClass); 12034 if (params.loop && prevSlide.length === 0) { 12035 prevSlide = slides.eq(-1); 12036 prevSlide.addClass(params.slidePrevClass); 12037 } 12038 if (params.loop) { 12039 // Duplicate to all looped slides 12040 if (nextSlide.hasClass(params.slideDuplicateClass)) { 12041 $wrapperEl 12042 .children(("." + (params.slideClass) + ":not(." + (params.slideDuplicateClass) + ")[data-swiper-slide-index=\"" + (nextSlide.attr('data-swiper-slide-index')) + "\"]")) 12043 .addClass(params.slideDuplicateNextClass); 12044 } else { 12045 $wrapperEl 12046 .children(("." + (params.slideClass) + "." + (params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + (nextSlide.attr('data-swiper-slide-index')) + "\"]")) 12047 .addClass(params.slideDuplicateNextClass); 12048 } 12049 if (prevSlide.hasClass(params.slideDuplicateClass)) { 12050 $wrapperEl 12051 .children(("." + (params.slideClass) + ":not(." + (params.slideDuplicateClass) + ")[data-swiper-slide-index=\"" + (prevSlide.attr('data-swiper-slide-index')) + "\"]")) 12052 .addClass(params.slideDuplicatePrevClass); 12053 } else { 12054 $wrapperEl 12055 .children(("." + (params.slideClass) + "." + (params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + (prevSlide.attr('data-swiper-slide-index')) + "\"]")) 12056 .addClass(params.slideDuplicatePrevClass); 12057 } 12058 } 12059 } 12060 12061 function updateActiveIndex (newActiveIndex) { 12062 var swiper = this; 12063 var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate; 12064 var slidesGrid = swiper.slidesGrid; 12065 var snapGrid = swiper.snapGrid; 12066 var params = swiper.params; 12067 var previousIndex = swiper.activeIndex; 12068 var previousRealIndex = swiper.realIndex; 12069 var previousSnapIndex = swiper.snapIndex; 12070 var activeIndex = newActiveIndex; 12071 var snapIndex; 12072 if (typeof activeIndex === 'undefined') { 12073 for (var i = 0; i < slidesGrid.length; i += 1) { 12074 if (typeof slidesGrid[i + 1] !== 'undefined') { 12075 if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - ((slidesGrid[i + 1] - slidesGrid[i]) / 2)) { 12076 activeIndex = i; 12077 } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) { 12078 activeIndex = i + 1; 12079 } 12080 } else if (translate >= slidesGrid[i]) { 12081 activeIndex = i; 12082 } 12083 } 12084 // Normalize slideIndex 12085 if (params.normalizeSlideIndex) { 12086 if (activeIndex < 0 || typeof activeIndex === 'undefined') { activeIndex = 0; } 12087 } 12088 } 12089 if (snapGrid.indexOf(translate) >= 0) { 12090 snapIndex = snapGrid.indexOf(translate); 12091 } else { 12092 snapIndex = Math.floor(activeIndex / params.slidesPerGroup); 12093 } 12094 if (snapIndex >= snapGrid.length) { snapIndex = snapGrid.length - 1; } 12095 if (activeIndex === previousIndex) { 12096 if (snapIndex !== previousSnapIndex) { 12097 swiper.snapIndex = snapIndex; 12098 swiper.emit('snapIndexChange'); 12099 } 12100 return; 12101 } 12102 12103 // Get real index 12104 var realIndex = parseInt(swiper.slides.eq(activeIndex).attr('data-swiper-slide-index') || activeIndex, 10); 12105 12106 Utils.extend(swiper, { 12107 snapIndex: snapIndex, 12108 realIndex: realIndex, 12109 previousIndex: previousIndex, 12110 activeIndex: activeIndex, 12111 }); 12112 swiper.emit('activeIndexChange'); 12113 swiper.emit('snapIndexChange'); 12114 if (previousRealIndex !== realIndex) { 12115 swiper.emit('realIndexChange'); 12116 } 12117
12117swiper.emit('slideChange');
vendor: 29,818 bytes, lines 12117-13039
12117 12118 } 12119 12120 function updateClickedSlide (e) { 12121 var swiper = this; 12122 var params = swiper.params; 12123 var slide = $(e.target).closest(("." + (params.slideClass)))[0]; 12124 var slideFound = false; 12125 if (slide) { 12126 for (var i = 0; i < swiper.slides.length; i += 1) { 12127 if (swiper.slides[i] === slide) { slideFound = true; } 12128 } 12129 } 12130 12131 if (slide && slideFound) { 12132 swiper.clickedSlide = slide; 12133 if (swiper.virtual && swiper.params.virtual.enabled) { 12134 swiper.clickedIndex = parseInt($(slide).attr('data-swiper-slide-index'), 10); 12135 } else { 12136 swiper.clickedIndex = $(slide).index(); 12137 } 12138 } else { 12139 swiper.clickedSlide = undefined; 12140 swiper.clickedIndex = undefined; 12141 return; 12142 } 12143 if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) { 12144 swiper.slideToClickedSlide(); 12145 } 12146 } 12147 12148 var update = { 12149 updateSize: updateSize, 12150 updateSlides: updateSlides, 12151 updateAutoHeight: updateAutoHeight, 12152 updateSlidesOffset: updateSlidesOffset, 12153 updateSlidesProgress: updateSlidesProgress, 12154 updateProgress: updateProgress, 12155 updateSlidesClasses: updateSlidesClasses, 12156 updateActiveIndex: updateActiveIndex, 12157 updateClickedSlide: updateClickedSlide, 12158 }; 12159 12160 function getTranslate (axis) { 12161 if ( axis === void 0 ) axis = this.isHorizontal() ? 'x' : 'y'; 12162 12163 var swiper = this; 12164 12165 var params = swiper.params; 12166 var rtl = swiper.rtlTranslate; 12167 var translate = swiper.translate; 12168 var $wrapperEl = swiper.$wrapperEl; 12169 12170 if (params.virtualTranslate) { 12171 return rtl ? -translate : translate; 12172 } 12173 12174 var currentTranslate = Utils.getTranslate($wrapperEl[0], axis); 12175 if (rtl) { currentTranslate = -currentTranslate; } 12176 12177 return currentTranslate || 0; 12178 } 12179 12180 function setTranslate (translate, byController) { 12181 var swiper = this; 12182 var rtl = swiper.rtlTranslate; 12183 var params = swiper.params; 12184 var $wrapperEl = swiper.$wrapperEl; 12185 var progress = swiper.progress; 12186 var x = 0; 12187 var y = 0; 12188 var z = 0; 12189 12190 if (swiper.isHorizontal()) { 12191 x = rtl ? -translate : translate; 12192 } else { 12193 y = translate; 12194 } 12195 12196 if (params.roundLengths) { 12197 x = Math.floor(x); 12198 y = Math.floor(y); 12199 } 12200 12201 if (!params.virtualTranslate) { 12202 if (Support.transforms3d) { $wrapperEl.transform(("translate3d(" + x + "px, " + y + "px, " + z + "px)")); } 12203 else { $wrapperEl.transform(("translate(" + x + "px, " + y + "px)")); } 12204 } 12205 swiper.previousTranslate = swiper.translate; 12206 swiper.translate = swiper.isHorizontal() ? x : y; 12207 12208 // Check if we need to update progress 12209 var newProgress; 12210 var translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); 12211 if (translatesDiff === 0) { 12212 newProgress = 0; 12213 } else { 12214 newProgress = (translate - swiper.minTranslate()) / (translatesDiff); 12215 } 12216 if (newProgress !== progress) { 12217 swiper.updateProgress(translate); 12218 } 12219 12220 swiper.emit('setTranslate', swiper.translate, byController); 12221 } 12222 12223 function minTranslate () { 12224 return (-this.snapGrid[0]); 12225 } 12226 12227 function maxTranslate () { 12228 return (-this.snapGrid[this.snapGrid.length - 1]); 12229 } 12230 12231 var translate = { 12232 getTranslate: getTranslate, 12233 setTranslate: setTranslate, 12234 minTranslate: minTranslate, 12235 maxTranslate: maxTranslate, 12236 }; 12237 12238 function setTransition (duration, byController) { 12239 var swiper = this; 12240 12241 swiper.$wrapperEl.transition(duration); 12242 12243 swiper.emit('setTransition', duration, byController); 12244 } 12245 12246 function transitionStart (runCallbacks, direction) { 12247 if ( runCallbacks === void 0 ) runCallbacks = true; 12248 12249 var swiper = this; 12250 var activeIndex = swiper.activeIndex; 12251 var params = swiper.params; 12252 var previousIndex = swiper.previousIndex; 12253 if (params.autoHeight) { 12254 swiper.updateAutoHeight(); 12255 } 12256 12257 var dir = direction; 12258 if (!dir) { 12259 if (activeIndex > previousIndex) { dir = 'next'; } 12260 else if (activeIndex < previousIndex) { dir = 'prev'; } 12261 else { dir = 'reset'; } 12262 } 12263 12264 swiper.emit('transitionStart'); 12265 12266 if (runCallbacks && activeIndex !== previousIndex) { 12267 if (dir === 'reset') { 12268 swiper.emit('slideResetTransitionStart'); 12269 return; 12270 } 12271 swiper.emit('slideChangeTransitionStart'); 12272 if (dir === 'next') { 12273 swiper.emit('slideNextTransitionStart'); 12274 } else { 12275 swiper.emit('slidePrevTransitionStart'); 12276 } 12277 } 12278 } 12279 12280 function transitionEnd$1 (runCallbacks, direction) { 12281 if ( runCallbacks === void 0 ) runCallbacks = true; 12282 12283 var swiper = this; 12284 var activeIndex = swiper.activeIndex; 12285 var previousIndex = swiper.previousIndex; 12286 swiper.animating = false; 12287 swiper.setTransition(0); 12288 12289 var dir = direction; 12290 if (!dir) { 12291 if (activeIndex > previousIndex) { dir = 'next'; } 12292 else if (activeIndex < previousIndex) { dir = 'prev'; } 12293 else { dir = 'reset'; } 12294 } 12295 12296 swiper.emit('transitionEnd'); 12297 12298 if (runCallbacks && activeIndex !== previousIndex) { 12299 if (dir === 'reset') { 12300 swiper.emit('slideResetTransitionEnd'); 12301 return; 12302 } 12303 swiper.emit('slideChangeTransitionEnd'); 12304 if (dir === 'next') { 12305 swiper.emit('slideNextTransitionEnd'); 12306 } else { 12307 swiper.emit('slidePrevTransitionEnd'); 12308 } 12309 } 12310 } 12311 12312 var transition$1 = { 12313 setTransition: setTransition, 12314 transitionStart: transitionStart, 12315 transitionEnd: transitionEnd$1, 12316 }; 12317 12318 function slideTo (index, speed, runCallbacks, internal) { 12319 if ( index === void 0 ) index = 0; 12320 if ( speed === void 0 ) speed = this.params.speed; 12321 if ( runCallbacks === void 0 ) runCallbacks = true; 12322 12323 var swiper = this; 12324 var slideIndex = index; 12325 if (slideIndex < 0) { slideIndex = 0; } 12326 12327 var params = swiper.params; 12328 var snapGrid = swiper.snapGrid; 12329 var slidesGrid = swiper.slidesGrid; 12330 var previousIndex = swiper.previousIndex; 12331 var activeIndex = swiper.activeIndex; 12332 var rtl = swiper.rtlTranslate; 12333 if (swiper.animating && params.preventInteractionOnTransition) { 12334 return false; 12335 } 12336 12337 var snapIndex = Math.floor(slideIndex / params.slidesPerGroup); 12338 if (snapIndex >= snapGrid.length) { snapIndex = snapGrid.length - 1; } 12339 12340 if ((activeIndex || params.initialSlide || 0) === (previousIndex || 0) && runCallbacks) { 12341 swiper.emit('beforeSlideChangeStart'); 12342 } 12343 12344 var translate = -snapGrid[snapIndex]; 12345 12346 // Update progress 12347 swiper.updateProgress(translate); 12348 12349 // Normalize slideIndex 12350 if (params.normalizeSlideIndex) { 12351 for (var i = 0; i < slidesGrid.length; i += 1) { 12352 if (-Math.floor(translate * 100) >= Math.floor(slidesGrid[i] * 100)) { 12353 slideIndex = i; 12354 } 12355 } 12356 } 12357 // Directions locks 12358 if (swiper.initialized && slideIndex !== activeIndex) { 12359 if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) { 12360 return false; 12361 } 12362 if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) { 12363 if ((activeIndex || 0) !== slideIndex) { return false; } 12364 } 12365 } 12366 12367 var direction; 12368 if (slideIndex > activeIndex) { direction = 'next'; } 12369 else if (slideIndex < activeIndex) { direction = 'prev'; } 12370 else { direction = 'reset'; } 12371 12372 12373 // Update Index 12374 if ((rtl && -translate === swiper.translate) || (!rtl && translate === swiper.translate)) { 12375 swiper.updateActiveIndex(slideIndex); 12376 // Update Height 12377 if (params.autoHeight) { 12378 swiper.updateAutoHeight(); 12379 } 12380 swiper.updateSlidesClasses(); 12381 if (params.effect !== 'slide') { 12382 swiper.setTranslate(translate); 12383 } 12384 if (direction !== 'reset') { 12385 swiper.transitionStart(runCallbacks, direction); 12386 swiper.transitionEnd(runCallbacks, direction); 12387 } 12388 return false; 12389 } 12390 12391 if (speed === 0 || !Support.transition) { 12392 swiper.setTransition(0); 12393 swiper.setTranslate(translate); 12394 swiper.updateActiveIndex(slideIndex); 12395 swiper.updateSlidesClasses(); 12396 swiper.emit('beforeTransitionStart', speed, internal); 12397 swiper.transitionStart(runCallbacks, direction); 12398 swiper.transitionEnd(runCallbacks, direction); 12399 } else { 12400 swiper.setTransition(speed); 12401 swiper.setTranslate(translate); 12402 swiper.updateActiveIndex(slideIndex); 12403 swiper.updateSlidesClasses(); 12404 swiper.emit('beforeTransitionStart', speed, internal); 12405 swiper.transitionStart(runCallbacks, direction); 12406 if (!swiper.animating) { 12407 swiper.animating = true; 12408 if (!swiper.onSlideToWrapperTransitionEnd) { 12409 swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) { 12410 if (!swiper || swiper.destroyed) { return; } 12411 if (e.target !== this) { return; } 12412 swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd); 12413 swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd); 12414 swiper.onSlideToWrapperTransitionEnd = null; 12415 delete swiper.onSlideToWrapperTransitionEnd; 12416 swiper.transitionEnd(runCallbacks, direction); 12417 }; 12418 } 12419 swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd); 12420 swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd); 12421 } 12422 } 12423 12424 return true; 12425 } 12426 12427 function slideToLoop (index, speed, runCallbacks, internal) { 12428 if ( index === void 0 ) index = 0; 12429 if ( speed === void 0 ) speed = this.params.speed; 12430 if ( runCallbacks === void 0 ) runCallbacks = true; 12431 12432 var swiper = this; 12433 var newIndex = index; 12434 if (swiper.params.loop) { 12435 newIndex += swiper.loopedSlides; 12436 } 12437 12438 return swiper.slideTo(newIndex, speed, runCallbacks, internal); 12439 } 12440 12441 /* eslint no-unused-vars: "off" */ 12442 function slideNext (speed, runCallbacks, internal) { 12443 if ( speed === void 0 ) speed = this.params.speed; 12444 if ( runCallbacks === void 0 ) runCallbacks = true; 12445 12446 var swiper = this; 12447 var params = swiper.params; 12448 var animating = swiper.animating; 12449 if (params.loop) { 12450 if (animating) { return false; } 12451 swiper.loopFix(); 12452 // eslint-disable-next-line 12453 swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; 12454 return swiper.slideTo(swiper.activeIndex + params.slidesPerGroup, speed, runCallbacks, internal); 12455 } 12456 return swiper.slideTo(swiper.activeIndex + params.slidesPerGroup, speed, runCallbacks, internal); 12457 } 12458 12459 /* eslint no-unused-vars: "off" */ 12460 function slidePrev (speed, runCallbacks, internal) { 12461 if ( speed === void 0 ) speed = this.params.speed; 12462 if ( runCallbacks === void 0 ) runCallbacks = true; 12463 12464 var swiper = this; 12465 var params = swiper.params; 12466 var animating = swiper.animating; 12467 var snapGrid = swiper.snapGrid; 12468 var slidesGrid = swiper.slidesGrid; 12469 var rtlTranslate = swiper.rtlTranslate; 12470 12471 if (params.loop) { 12472 if (animating) { return false; } 12473 swiper.loopFix(); 12474 // eslint-disable-next-line 12475 swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; 12476 } 12477 var translate = rtlTranslate ? swiper.translate : -swiper.translate; 12478 function normalize(val) { 12479 if (val < 0) { return -Math.floor(Math.abs(val)); } 12480 return Math.floor(val); 12481 } 12482 var normalizedTranslate = normalize(translate); 12483 var normalizedSnapGrid = snapGrid.map(function (val) { return normalize(val); }); 12484 var normalizedSlidesGrid = slidesGrid.map(function (val) { return normalize(val); }); 12485 12486 var currentSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate)]; 12487 var prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1]; 12488 var prevIndex; 12489 if (typeof prevSnap !== 'undefined') { 12490 prevIndex = slidesGrid.indexOf(prevSnap); 12491 if (prevIndex < 0) { prevIndex = swiper.activeIndex - 1; } 12492 } 12493 return swiper.slideTo(prevIndex, speed, runCallbacks, internal); 12494 } 12495 12496 /* eslint no-unused-vars: "off" */ 12497 function slideReset (speed, runCallbacks, internal) { 12498 if ( speed === void 0 ) speed = this.params.speed; 12499 if ( runCallbacks === void 0 ) runCallbacks = true; 12500 12501 var swiper = this; 12502 return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal); 12503 } 12504 12505 /* eslint no-unused-vars: "off" */ 12506 function slideToClosest (speed, runCallbacks, internal) { 12507 if ( speed === void 0 ) speed = this.params.speed; 12508 if ( runCallbacks === void 0 ) runCallbacks = true; 12509 12510 var swiper = this; 12511 var index = swiper.activeIndex; 12512 var snapIndex = Math.floor(index / swiper.params.slidesPerGroup); 12513 12514 if (snapIndex < swiper.snapGrid.length - 1) { 12515 var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate; 12516 12517 var currentSnap = swiper.snapGrid[snapIndex]; 12518 var nextSnap = swiper.snapGrid[snapIndex + 1]; 12519 12520 if ((translate - currentSnap) > (nextSnap - currentSnap) / 2) { 12521 index = swiper.params.slidesPerGroup; 12522 } 12523 } 12524 12525 return swiper.slideTo(index, speed, runCallbacks, internal); 12526 } 12527 12528 function slideToClickedSlide () { 12529 var swiper = this; 12530 var params = swiper.params; 12531 var $wrapperEl = swiper.$wrapperEl; 12532 12533 var slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView; 12534 var slideToIndex = swiper.clickedIndex; 12535 var realIndex; 12536 if (params.loop) { 12537 if (swiper.animating) { return; } 12538 realIndex = parseInt($(swiper.clickedSlide).attr('data-swiper-slide-index'), 10); 12539 if (params.centeredSlides) { 12540 if ( 12541 (slideToIndex < swiper.loopedSlides - (slidesPerView / 2)) 12542 || (slideToIndex > (swiper.slides.length - swiper.loopedSlides) + (slidesPerView / 2)) 12543 ) { 12544 swiper.loopFix(); 12545 slideToIndex = $wrapperEl 12546 .children(("." + (params.slideClass) + "[data-swiper-slide-index=\"" + realIndex + "\"]:not(." + (params.slideDuplicateClass) + ")")) 12547 .eq(0) 12548 .index(); 12549 12550 Utils.nextTick(function () { 12551 swiper.slideTo(slideToIndex); 12552 }); 12553 } else { 12554 swiper.slideTo(slideToIndex); 12555 } 12556 } else if (slideToIndex > swiper.slides.length - slidesPerView) { 12557 swiper.loopFix(); 12558 slideToIndex = $wrapperEl 12559 .children(("." + (params.slideClass) + "[data-swiper-slide-index=\"" + realIndex + "\"]:not(." + (params.slideDuplicateClass) + ")")) 12560 .eq(0) 12561 .index(); 12562 12563 Utils.nextTick(function () { 12564 swiper.slideTo(slideToIndex); 12565 }); 12566 } else { 12567 swiper.slideTo(slideToIndex); 12568 } 12569 } else { 12570 swiper.slideTo(slideToIndex); 12571 } 12572 } 12573 12574 var slide = { 12575 slideTo: slideTo, 12576 slideToLoop: slideToLoop, 12577 slideNext: slideNext, 12578 slidePrev: slidePrev, 12579 slideReset: slideReset, 12580 slideToClosest: slideToClosest, 12581 slideToClickedSlide: slideToClickedSlide, 12582 }; 12583 12584 function loopCreate () { 12585 var swiper = this; 12586 var params = swiper.params; 12587 var $wrapperEl = swiper.$wrapperEl; 12588 // Remove duplicated slides 12589 $wrapperEl.children(("." + (params.slideClass) + "." + (params.slideDuplicateClass))).remove(); 12590 12591 var slides = $wrapperEl.children(("." + (params.slideClass))); 12592 12593 if (params.loopFillGroupWithBlank) { 12594 var blankSlidesNum = params.slidesPerGroup - (slides.length % params.slidesPerGroup); 12595 if (blankSlidesNum !== params.slidesPerGroup) { 12596 for (var i = 0; i < blankSlidesNum; i += 1) { 12597 var blankNode = $(doc.createElement('div')).addClass(((params.slideClass) + " " + (params.slideBlankClass))); 12598 $wrapperEl.append(blankNode); 12599 } 12600 slides = $wrapperEl.children(("." + (params.slideClass))); 12601 } 12602 } 12603 12604 if (params.slidesPerView === 'auto' && !params.loopedSlides) { params.loopedSlides = slides.length; } 12605 12606 swiper.loopedSlides = parseInt(params.loopedSlides || params.slidesPerView, 10); 12607 swiper.loopedSlides += params.loopAdditionalSlides; 12608 if (swiper.loopedSlides > slides.length) { 12609 swiper.loopedSlides = slides.length; 12610 } 12611 12612 var prependSlides = []; 12613 var appendSlides = []; 12614 slides.each(function (index, el) { 12615 var slide = $(el); 12616 if (index < swiper.loopedSlides) { appendSlides.push(el); } 12617 if (index < slides.length && index >= slides.length - swiper.loopedSlides) { prependSlides.push(el); } 12618 slide.attr('data-swiper-slide-index', index); 12619 }); 12620 for (var i$1 = 0; i$1 < appendSlides.length; i$1 += 1) { 12621 $wrapperEl.append($(appendSlides[i$1].cloneNode(true)).addClass(params.slideDuplicateClass)); 12622 } 12623 for (var i$2 = prependSlides.length - 1; i$2 >= 0; i$2 -= 1) { 12624 $wrapperEl.prepend($(prependSlides[i$2].cloneNode(true)).addClass(params.slideDuplicateClass)); 12625 } 12626 } 12627 12628 function loopFix () { 12629 var swiper = this; 12630 var params = swiper.params; 12631 var activeIndex = swiper.activeIndex; 12632 var slides = swiper.slides; 12633 var loopedSlides = swiper.loopedSlides; 12634 var allowSlidePrev = swiper.allowSlidePrev; 12635 var allowSlideNext = swiper.allowSlideNext; 12636 var snapGrid = swiper.snapGrid; 12637 var rtl = swiper.rtlTranslate; 12638 var newIndex; 12639 swiper.allowSlidePrev = true; 12640 swiper.allowSlideNext = true; 12641 12642 var snapTranslate = -snapGrid[activeIndex]; 12643 var diff = snapTranslate - swiper.getTranslate(); 12644 12645 12646 // Fix For Negative Oversliding 12647 if (activeIndex < loopedSlides) { 12648 newIndex = (slides.length - (loopedSlides * 3)) + activeIndex; 12649 newIndex += loopedSlides; 12650 var slideChanged = swiper.slideTo(newIndex, 0, false, true); 12651 if (slideChanged && diff !== 0) { 12652 swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff); 12653 } 12654 } else if ((params.slidesPerView === 'auto' && activeIndex >= loopedSlides * 2) || (activeIndex >= slides.length - loopedSlides)) { 12655 // Fix For Positive Oversliding 12656 newIndex = -slides.length + activeIndex + loopedSlides; 12657 newIndex += loopedSlides; 12658 var slideChanged$1 = swiper.slideTo(newIndex, 0, false, true); 12659 if (slideChanged$1 && diff !== 0) { 12660 swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff); 12661 } 12662 } 12663 swiper.allowSlidePrev = allowSlidePrev; 12664 swiper.allowSlideNext = allowSlideNext; 12665 } 12666 12667 function loopDestroy () { 12668 var swiper = this; 12669 var $wrapperEl = swiper.$wrapperEl; 12670 var params = swiper.params; 12671 var slides = swiper.slides; 12672 $wrapperEl.children(("." + (params.slideClass) + "." + (params.slideDuplicateClass))).remove(); 12673 slides.removeAttr('data-swiper-slide-index'); 12674 } 12675 12676 var loop = { 12677 loopCreate: loopCreate, 12678 loopFix: loopFix, 12679 loopDestroy: loopDestroy, 12680 }; 12681 12682 function setGrabCursor (moving) { 12683 var swiper = this; 12684 if (Support.touch || !swiper.params.simulateTouch || (swiper.params.watchOverflow && swiper.isLocked)) { return; } 12685 var el = swiper.el; 12686 el.style.cursor = 'move'; 12687 el.style.cursor = moving ? '-webkit-grabbing' : '-webkit-grab'; 12688 el.style.cursor = moving ? '-moz-grabbin' : '-moz-grab'; 12689 el.style.cursor = moving ? 'grabbing' : 'grab'; 12690 } 12691 12692 function unsetGrabCursor () { 12693 var swiper = this; 12694 if (Support.touch || (swiper.params.watchOverflow && swiper.isLocked)) { return; } 12695 swiper.el.style.cursor = ''; 12696 } 12697 12698 var grabCursor = { 12699 setGrabCursor: setGrabCursor, 12700 unsetGrabCursor: unsetGrabCursor, 12701 }; 12702 12703 function appendSlide (slides) { 12704 var swiper = this; 12705 var $wrapperEl = swiper.$wrapperEl; 12706 var params = swiper.params; 12707 if (params.loop) { 12708 swiper.loopDestroy(); 12709 } 12710 if (typeof slides === 'object' && 'length' in slides) { 12711 for (var i = 0; i < slides.length; i += 1) { 12712 if (slides[i]) { $wrapperEl.append(slides[i]); } 12713 } 12714 } else { 12715 $wrapperEl.append(slides); 12716 } 12717 if (params.loop) { 12718 swiper.loopCreate(); 12719 } 12720 if (!(params.observer && Support.observer)) { 12721 swiper.update(); 12722 } 12723 } 12724 12725 function prependSlide (slides) { 12726 var swiper = this; 12727 var params = swiper.params; 12728 var $wrapperEl = swiper.$wrapperEl; 12729 var activeIndex = swiper.activeIndex; 12730 12731 if (params.loop) { 12732 swiper.loopDestroy(); 12733 } 12734 var newActiveIndex = activeIndex + 1; 12735 if (typeof slides === 'object' && 'length' in slides) { 12736 for (var i = 0; i < slides.length; i += 1) { 12737 if (slides[i]) { $wrapperEl.prepend(slides[i]); } 12738 } 12739 newActiveIndex = activeIndex + slides.length; 12740 } else { 12741 $wrapperEl.prepend(slides); 12742 } 12743 if (params.loop) { 12744 swiper.loopCreate(); 12745 } 12746 if (!(params.observer && Support.observer)) { 12747 swiper.update(); 12748 } 12749 swiper.slideTo(newActiveIndex, 0, false); 12750 } 12751 12752 function addSlide (index, slides) { 12753 var swiper = this; 12754 var $wrapperEl = swiper.$wrapperEl; 12755 var params = swiper.params; 12756 var activeIndex = swiper.activeIndex; 12757 var activeIndexBuffer = activeIndex; 12758 if (params.loop) { 12759 activeIndexBuffer -= swiper.loopedSlides; 12760 swiper.loopDestroy(); 12761 swiper.slides = $wrapperEl.children(("." + (params.slideClass))); 12762 } 12763 var baseLength = swiper.slides.length; 12764 if (index <= 0) { 12765 swiper.prependSlide(slides); 12766 return; 12767 } 12768 if (index >= baseLength) { 12769 swiper.appendSlide(slides); 12770 return; 12771 } 12772 var newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer; 12773 12774 var slidesBuffer = []; 12775 for (var i = baseLength - 1; i >= index; i -= 1) { 12776 var currentSlide = swiper.slides.eq(i); 12777 currentSlide.remove(); 12778 slidesBuffer.unshift(currentSlide); 12779 } 12780 12781 if (typeof slides === 'object' && 'length' in slides) { 12782 for (var i$1 = 0; i$1 < slides.length; i$1 += 1) { 12783 if (slides[i$1]) { $wrapperEl.append(slides[i$1]); } 12784 } 12785 newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer; 12786 } else { 12787 $wrapperEl.append(slides); 12788 } 12789 12790 for (var i$2 = 0; i$2 < slidesBuffer.length; i$2 += 1) { 12791 $wrapperEl.append(slidesBuffer[i$2]); 12792 } 12793 12794 if (params.loop) { 12795 swiper.loopCreate(); 12796 } 12797 if (!(params.observer && Support.observer)) { 12798 swiper.update(); 12799 } 12800 if (params.loop) { 12801 swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); 12802 } else { 12803 swiper.slideTo(newActiveIndex, 0, false); 12804 } 12805 } 12806 12807 function removeSlide (slidesIndexes) { 12808 var swiper = this; 12809 var params = swiper.params; 12810 var $wrapperEl = swiper.$wrapperEl; 12811 var activeIndex = swiper.activeIndex; 12812 12813 var activeIndexBuffer = activeIndex; 12814 if (params.loop) { 12815 activeIndexBuffer -= swiper.loopedSlides; 12816 swiper.loopDestroy(); 12817 swiper.slides = $wrapperEl.children(("." + (params.slideClass))); 12818 } 12819 var newActiveIndex = activeIndexBuffer; 12820 var indexToRemove; 12821 12822 if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) { 12823 for (var i = 0; i < slidesIndexes.length; i += 1) { 12824 indexToRemove = slidesIndexes[i]; 12825 if (swiper.slides[indexToRemove]) { swiper.slides.eq(indexToRemove).remove(); } 12826 if (indexToRemove < newActiveIndex) { newActiveIndex -= 1; } 12827 } 12828 newActiveIndex = Math.max(newActiveIndex, 0); 12829 } else { 12830 indexToRemove = slidesIndexes; 12831 if (swiper.slides[indexToRemove]) { swiper.slides.eq(indexToRemove).remove(); } 12832 if (indexToRemove < newActiveIndex) { newActiveIndex -= 1; } 12833 newActiveIndex = Math.max(newActiveIndex, 0); 12834 } 12835 12836 if (params.loop) { 12837 swiper.loopCreate(); 12838 } 12839 12840 if (!(params.observer && Support.observer)) { 12841 swiper.update(); 12842 } 12843 if (params.loop) { 12844 swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); 12845 } else { 12846 swiper.slideTo(newActiveIndex, 0, false); 12847 } 12848 } 12849 12850 function removeAllSlides () { 12851 var swiper = this; 12852 12853 var slidesIndexes = []; 12854 for (var i = 0; i < swiper.slides.length; i += 1) { 12855 slidesIndexes.push(i); 12856 } 12857 swiper.removeSlide(slidesIndexes); 12858 } 12859 12860 var manipulation = { 12861 appendSlide: appendSlide, 12862 prependSlide: prependSlide, 12863 addSlide: addSlide, 12864 removeSlide: removeSlide, 12865 removeAllSlides: removeAllSlides, 12866 }; 12867 12868 var Device = (function Device() { 12869 var ua = win.navigator.userAgent; 12870 12871 var device = { 12872 ios: false, 12873 android: false, 12874 androidChrome: false, 12875 desktop: false, 12876 windows: false, 12877 iphone: false, 12878 ipod: false, 12879 ipad: false, 12880 cordova: win.cordova || win.phonegap, 12881 phonegap: win.cordova || win.phonegap, 12882 }; 12883 12884 var windows = ua.match(/(Windows Phone);?[\s\/]+([\d.]+)?/); // eslint-disable-line 12885 var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line 12886 var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); 12887 var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); 12888 var iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/); 12889 12890 12891 // Windows 12892 if (windows) { 12893 device.os = 'windows'; 12894 device.osVersion = windows[2]; 12895 device.windows = true; 12896 } 12897 // Android 12898 if (android && !windows) { 12899 device.os = 'android'; 12900 device.osVersion = android[2]; 12901 device.android = true; 12902 device.androidChrome = ua.toLowerCase().indexOf('chrome') >= 0; 12903 } 12904 if (ipad || iphone || ipod) { 12905 device.os = 'ios'; 12906 device.ios = true; 12907 } 12908 // iOS 12909 if (iphone && !ipod) { 12910 device.osVersion = iphone[2].replace(/_/g, '.'); 12911 device.iphone = true; 12912 } 12913 if (ipad) { 12914 device.osVersion = ipad[2].replace(/_/g, '.'); 12915 device.ipad = true; 12916 } 12917 if (ipod) { 12918 device.osVersion = ipod[3] ? ipod[3].replace(/_/g, '.') : null; 12919 device.iphone = true; 12920 } 12921 // iOS 8+ changed UA 12922 if (device.ios && device.osVersion && ua.indexOf('Version/') >= 0) { 12923 if (device.osVersion.split('.')[0] === '10') { 12924 device.osVersion = ua.toLowerCase().split('version/')[1].split(' ')[0]; 12925 } 12926 } 12927 12928 // Desktop 12929 device.desktop = !(device.os || device.android || device.webView); 12930 12931 // Webview 12932 device.webView = (iphone || ipad || ipod) && ua.match(/.*AppleWebKit(?!.*Safari)/i); 12933 12934 // Minimal UI 12935 if (device.os && device.os === 'ios') { 12936 var osVersionArr = device.osVersion.split('.'); 12937 var metaViewport = doc.querySelector('meta[name="viewport"]'); 12938 device.minimalUi = !device.webView 12939 && (ipod || iphone) 12940 && (osVersionArr[0] * 1 === 7 ? osVersionArr[1] * 1 >= 1 : osVersionArr[0] * 1 > 7) 12941 && metaViewport && metaViewport.getAttribute('content').indexOf('minimal-ui') >= 0; 12942 } 12943 12944 // Pixel Ratio 12945 device.pixelRatio = win.devicePixelRatio || 1; 12946 12947 // Export object 12948 return device; 12949 }()); 12950 12951 function onTouchStart (event) { 12952 var swiper = this; 12953 var data = swiper.touchEventsData; 12954 var params = swiper.params; 12955 var touches = swiper.touches; 12956 if (swiper.animating && params.preventInteractionOnTransition) { 12957 return; 12958 } 12959 var e = event; 12960 if (e.originalEvent) { e = e.originalEvent; } 12961 data.isTouchEvent = e.type === 'touchstart'; 12962 if (!data.isTouchEvent && 'which' in e && e.which === 3) { return; } 12963 if (!data.isTouchEvent && 'button' in e && e.button > 0) { return; } 12964 if (data.isTouched && data.isMoved) { return; } 12965 if (params.noSwiping && $(e.target).closest(params.noSwipingSelector ? params.noSwipingSelector : ("." + (params.noSwipingClass)))[0]) { 12966 swiper.allowClick = true; 12967 return; 12968 } 12969 if (params.swipeHandler) { 12970 if (!$(e).closest(params.swipeHandler)[0]) { return; } 12971 } 12972 12973 touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; 12974 touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; 12975 var startX = touches.currentX; 12976 var startY = touches.currentY; 12977 12978 // Do NOT start if iOS edge swipe is detected. Otherwise iOS app (UIWebView) cannot swipe-to-go-back anymore 12979 12980 var edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection; 12981 var edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold; 12982 if ( 12983 edgeSwipeDetection 12984 && ((startX <= edgeSwipeThreshold) 12985 || (startX >= win.screen.width - edgeSwipeThreshold)) 12986 ) { 12987 return; 12988 } 12989 12990 Utils.extend(data, { 12991 isTouched: true, 12992 isMoved: false, 12993 allowTouchCallbacks: true, 12994 isScrolling: undefined, 12995 startMoving: undefined, 12996 }); 12997 12998 touches.startX = startX; 12999 touches.startY = startY; 13000 data.touchStartTime = Utils.now(); 13001 swiper.allowClick = true; 13002 swiper.updateSize(); 13003 swiper.swipeDirection = undefined; 13004 if (params.threshold > 0) { data.allowThresholdMove = false; } 13005 if (e.type !== 'touchstart') { 13006 var preventDefault = true; 13007 if ($(e.target).is(data.formElements)) { preventDefault = false; } 13008 if ( 13009 doc.activeElement 13010 && $(doc.activeElement).is(data.formElements) 13011 && doc.activeElement !== e.target 13012 ) { 13013 doc.activeElement.blur(); 13014 } 13015 13016 var shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault; 13017 if (params.touchStartForcePreventDefault || shouldPreventDefault) { 13018 e.preventDefault(); 13019 } 13020 } 13021 swiper.emit('touchStart', e); 13022 } 13023 13024 function onTouchMove (event) { 13025 var swiper = this; 13026 var data = swiper.touchEventsData; 13027 var params = swiper.params; 13028 var touches = swiper.touches; 13029 var rtl = swiper.rtlTranslate; 13030 var e = event; 13031 if (e.originalEvent) { e = e.originalEvent; } 13032 if (!data.isTouched) { 13033 if (data.startMoving && data.isScrolling) { 13034 swiper.emit('touchMoveOpposite', e); 13035 } 13036 return; 13037 } 13038 if (data.isTouchEvent && e.type === 'mousemove') { return; } 13039 var
vendor: 2,929 bytes, lines 13039-13125
13039pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; 13040 var pageY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; 13041 if (e.preventedByNestedSwiper) { 13042 touches.startX = pageX; 13043 touches.startY = pageY; 13044 return; 13045 } 13046 if (!swiper.allowTouchMove) { 13047 // isMoved = true; 13048 swiper.allowClick = false; 13049 if (data.isTouched) { 13050 Utils.extend(touches, { 13051 startX: pageX, 13052 startY: pageY, 13053 currentX: pageX, 13054 currentY: pageY, 13055 }); 13056 data.touchStartTime = Utils.now(); 13057 } 13058 return; 13059 } 13060 if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) { 13061 if (swiper.isVertical()) { 13062 // Vertical 13063 if ( 13064 (pageY < touches.startY && swiper.translate <= swiper.maxTranslate()) 13065 || (pageY > touches.startY && swiper.translate >= swiper.minTranslate()) 13066 ) { 13067 data.isTouched = false; 13068 data.isMoved = false; 13069 return; 13070 } 13071 } else if ( 13072 (pageX < touches.startX && swiper.translate <= swiper.maxTranslate()) 13073 || (pageX > touches.startX && swiper.translate >= swiper.minTranslate()) 13074 ) { 13075 return; 13076 } 13077 } 13078 if (data.isTouchEvent && doc.activeElement) { 13079 if (e.target === doc.activeElement && $(e.target).is(data.formElements)) { 13080 data.isMoved = true; 13081 swiper.allowClick = false; 13082 return; 13083 } 13084 } 13085 if (data.allowTouchCallbacks) { 13086 swiper.emit('touchMove', e); 13087 } 13088 if (e.targetTouches && e.targetTouches.length > 1) { return; } 13089 13090 touches.currentX = pageX; 13091 touches.currentY = pageY; 13092 13093 var diffX = touches.currentX - touches.startX; 13094 var diffY = touches.currentY - touches.startY; 13095 if (swiper.params.threshold && Math.sqrt((Math.pow( diffX, 2 )) + (Math.pow( diffY, 2 ))) < swiper.params.threshold) { return; } 13096 13097 if (typeof data.isScrolling === 'undefined') { 13098 var touchAngle; 13099 if ((swiper.isHorizontal() && touches.currentY === touches.startY) || (swiper.isVertical() && touches.currentX === touches.startX)) { 13100 data.isScrolling = false; 13101 } else { 13102 // eslint-disable-next-line 13103 if ((diffX * diffX) + (diffY * diffY) >= 25) { 13104 touchAngle = (Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180) / Math.PI; 13105 data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : (90 - touchAngle > params.touchAngle); 13106 } 13107 } 13108 } 13109 if (data.isScrolling) { 13110 swiper.emit('touchMoveOpposite', e); 13111 } 13112 if (typeof data.startMoving === 'undefined') { 13113 if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) { 13114 data.startMoving = true; 13115 } 13116 } 13117 if (data.isScrolling) { 13118 data.isTouched = false; 13119 return; 13120 } 13121 if (!data.startMoving) { 13122 return; 13123 } 13124 swiper.allowClick = false; 13125 e.preventDefault();
vendor: 14,334 bytes, lines 13125-13540
13125 13126 if (params.touchMoveStopPropagation && !params.nested) { 13127 e.stopPropagation(); 13128 } 13129 13130 if (!data.isMoved) { 13131 if (params.loop) { 13132 swiper.loopFix(); 13133 } 13134 data.startTranslate = swiper.getTranslate(); 13135 swiper.setTransition(0); 13136 if (swiper.animating) { 13137 swiper.$wrapperEl.trigger('webkitTransitionEnd transitionend'); 13138 } 13139 data.allowMomentumBounce = false; 13140 // Grab Cursor 13141 if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { 13142 swiper.setGrabCursor(true); 13143 } 13144 swiper.emit('sliderFirstMove', e); 13145 } 13146 swiper.emit('sliderMove', e); 13147 data.isMoved = true; 13148 13149 var diff = swiper.isHorizontal() ? diffX : diffY; 13150 touches.diff = diff; 13151 13152 diff *= params.touchRatio; 13153 if (rtl) { diff = -diff; } 13154 13155 swiper.swipeDirection = diff > 0 ? 'prev' : 'next'; 13156 data.currentTranslate = diff + data.startTranslate; 13157 13158 var disableParentSwiper = true; 13159 var resistanceRatio = params.resistanceRatio; 13160 if (params.touchReleaseOnEdges) { 13161 resistanceRatio = 0; 13162 } 13163 if ((diff > 0 && data.currentTranslate > swiper.minTranslate())) { 13164 disableParentSwiper = false; 13165 if (params.resistance) { data.currentTranslate = (swiper.minTranslate() - 1) + (Math.pow( (-swiper.minTranslate() + data.startTranslate + diff), resistanceRatio )); } 13166 } else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) { 13167 disableParentSwiper = false; 13168 if (params.resistance) { data.currentTranslate = (swiper.maxTranslate() + 1) - (Math.pow( (swiper.maxTranslate() - data.startTranslate - diff), resistanceRatio )); } 13169 } 13170 13171 if (disableParentSwiper) { 13172 e.preventedByNestedSwiper = true; 13173 } 13174 13175 // Directions locks 13176 if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) { 13177 data.currentTranslate = data.startTranslate; 13178 } 13179 if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) { 13180 data.currentTranslate = data.startTranslate; 13181 } 13182 13183 13184 // Threshold 13185 if (params.threshold > 0) { 13186 if (Math.abs(diff) > params.threshold || data.allowThresholdMove) { 13187 if (!data.allowThresholdMove) { 13188 data.allowThresholdMove = true; 13189 touches.startX = touches.currentX; 13190 touches.startY = touches.currentY; 13191 data.currentTranslate = data.startTranslate; 13192 touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY; 13193 return; 13194 } 13195 } else { 13196 data.currentTranslate = data.startTranslate; 13197 return; 13198 } 13199 } 13200 13201 if (!params.followFinger) { return; } 13202 13203 // Update active index in free mode 13204 if (params.freeMode || params.watchSlidesProgress || params.watchSlidesVisibility) { 13205 swiper.updateActiveIndex(); 13206 swiper.updateSlidesClasses(); 13207 } 13208 if (params.freeMode) { 13209 // Velocity 13210 if (data.velocities.length === 0) { 13211 data.velocities.push({ 13212 position: touches[swiper.isHorizontal() ? 'startX' : 'startY'], 13213 time: data.touchStartTime, 13214 }); 13215 } 13216 data.velocities.push({ 13217 position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'], 13218 time: Utils.now(), 13219 }); 13220 } 13221 // Update progress 13222 swiper.updateProgress(data.currentTranslate); 13223 // Update translate 13224 swiper.setTranslate(data.currentTranslate); 13225 } 13226 13227 function onTouchEnd (event) { 13228 var swiper = this; 13229 var data = swiper.touchEventsData; 13230 13231 var params = swiper.params; 13232 var touches = swiper.touches; 13233 var rtl = swiper.rtlTranslate; 13234 var $wrapperEl = swiper.$wrapperEl; 13235 var slidesGrid = swiper.slidesGrid; 13236 var snapGrid = swiper.snapGrid; 13237 var e = event; 13238 if (e.originalEvent) { e = e.originalEvent; } 13239 if (data.allowTouchCallbacks) { 13240 swiper.emit('touchEnd', e); 13241 } 13242 data.allowTouchCallbacks = false; 13243 if (!data.isTouched) { 13244 if (data.isMoved && params.grabCursor) { 13245 swiper.setGrabCursor(false); 13246 } 13247 data.isMoved = false; 13248 data.startMoving = false; 13249 return; 13250 } 13251 // Return Grab Cursor 13252 if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { 13253 swiper.setGrabCursor(false); 13254 } 13255 13256 // Time diff 13257 var touchEndTime = Utils.now(); 13258 var timeDiff = touchEndTime - data.touchStartTime; 13259 13260 // Tap, doubleTap, Click 13261 if (swiper.allowClick) { 13262 swiper.updateClickedSlide(e); 13263 swiper.emit('tap', e); 13264 if (timeDiff < 300 && (touchEndTime - data.lastClickTime) > 300) { 13265 if (data.clickTimeout) { clearTimeout(data.clickTimeout); } 13266 data.clickTimeout = Utils.nextTick(function () { 13267 if (!swiper || swiper.destroyed) { return; } 13268 swiper.emit('click', e); 13269 }, 300); 13270 } 13271 if (timeDiff < 300 && (touchEndTime - data.lastClickTime) < 300) { 13272 if (data.clickTimeout) { clearTimeout(data.clickTimeout); } 13273 swiper.emit('doubleTap', e); 13274 } 13275 } 13276 13277 data.lastClickTime = Utils.now(); 13278 Utils.nextTick(function () { 13279 if (!swiper.destroyed) { swiper.allowClick = true; } 13280 }); 13281 13282 if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) { 13283 data.isTouched = false; 13284 data.isMoved = false; 13285 data.startMoving = false; 13286 return; 13287 } 13288 data.isTouched = false; 13289 data.isMoved = false; 13290 data.startMoving = false; 13291 13292 var currentPos; 13293 if (params.followFinger) { 13294 currentPos = rtl ? swiper.translate : -swiper.translate; 13295 } else { 13296 currentPos = -data.currentTranslate; 13297 } 13298 13299 if (params.freeMode) { 13300 if (currentPos < -swiper.minTranslate()) { 13301 swiper.slideTo(swiper.activeIndex); 13302 return; 13303 } 13304 if (currentPos > -swiper.maxTranslate()) { 13305 if (swiper.slides.length < snapGrid.length) { 13306 swiper.slideTo(snapGrid.length - 1); 13307 } else { 13308 swiper.slideTo(swiper.slides.length - 1); 13309 } 13310 return; 13311 } 13312 13313 if (params.freeModeMomentum) { 13314 if (data.velocities.length > 1) { 13315 var lastMoveEvent = data.velocities.pop(); 13316 var velocityEvent = data.velocities.pop(); 13317 13318 var distance = lastMoveEvent.position - velocityEvent.position; 13319 var time = lastMoveEvent.time - velocityEvent.time; 13320 swiper.velocity = distance / time; 13321 swiper.velocity /= 2; 13322 if (Math.abs(swiper.velocity) < params.freeModeMinimumVelocity) { 13323 swiper.velocity = 0; 13324 } 13325 // this implies that the user stopped moving a finger then released. 13326 // There would be no events with distance zero, so the last event is stale. 13327 if (time > 150 || (Utils.now() - lastMoveEvent.time) > 300) { 13328 swiper.velocity = 0; 13329 } 13330 } else { 13331 swiper.velocity = 0; 13332 } 13333 swiper.velocity *= params.freeModeMomentumVelocityRatio; 13334 13335 data.velocities.length = 0; 13336 var momentumDuration = 1000 * params.freeModeMomentumRatio; 13337 var momentumDistance = swiper.velocity * momentumDuration; 13338 13339 var newPosition = swiper.translate + momentumDistance; 13340 if (rtl) { newPosition = -newPosition; } 13341 13342 var doBounce = false; 13343 var afterBouncePosition; 13344 var bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeModeMomentumBounceRatio; 13345 var needsLoopFix; 13346 if (newPosition < swiper.maxTranslate()) { 13347 if (params.freeModeMomentumBounce) { 13348 if (newPosition + swiper.maxTranslate() < -bounceAmount) { 13349 newPosition = swiper.maxTranslate() - bounceAmount; 13350 } 13351 afterBouncePosition = swiper.maxTranslate(); 13352 doBounce = true; 13353 data.allowMomentumBounce = true; 13354 } else { 13355 newPosition = swiper.maxTranslate(); 13356 } 13357 if (params.loop && params.centeredSlides) { needsLoopFix = true; } 13358 } else if (newPosition > swiper.minTranslate()) { 13359 if (params.freeModeMomentumBounce) { 13360 if (newPosition - swiper.minTranslate() > bounceAmount) { 13361 newPosition = swiper.minTranslate() + bounceAmount; 13362 } 13363 afterBouncePosition = swiper.minTranslate(); 13364 doBounce = true; 13365 data.allowMomentumBounce = true; 13366 } else { 13367 newPosition = swiper.minTranslate(); 13368 } 13369 if (params.loop && params.centeredSlides) { needsLoopFix = true; } 13370 } else if (params.freeModeSticky) { 13371 var nextSlide; 13372 for (var j = 0; j < snapGrid.length; j += 1) { 13373 if (snapGrid[j] > -newPosition) { 13374 nextSlide = j; 13375 break; 13376 } 13377 } 13378 13379 if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') { 13380 newPosition = snapGrid[nextSlide]; 13381 } else { 13382 newPosition = snapGrid[nextSlide - 1]; 13383 } 13384 newPosition = -newPosition; 13385 } 13386 if (needsLoopFix) { 13387 swiper.once('transitionEnd', function () { 13388 swiper.loopFix(); 13389 }); 13390 } 13391 // Fix duration 13392 if (swiper.velocity !== 0) { 13393 if (rtl) { 13394 momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity); 13395 } else { 13396 momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity); 13397 } 13398 } else if (params.freeModeSticky) { 13399 swiper.slideToClosest(); 13400 return; 13401 } 13402 13403 if (params.freeModeMomentumBounce && doBounce) { 13404 swiper.updateProgress(afterBouncePosition); 13405 swiper.setTransition(momentumDuration); 13406 swiper.setTranslate(newPosition); 13407 swiper.transitionStart(true, swiper.swipeDirection); 13408 swiper.animating = true; 13409 $wrapperEl.transitionEnd(function () { 13410 if (!swiper || swiper.destroyed || !data.allowMomentumBounce) { return; } 13411 swiper.emit('momentumBounce'); 13412 13413 swiper.setTransition(params.speed); 13414 swiper.setTranslate(afterBouncePosition); 13415 $wrapperEl.transitionEnd(function () { 13416 if (!swiper || swiper.destroyed) { return; } 13417 swiper.transitionEnd(); 13418 }); 13419 }); 13420 } else if (swiper.velocity) { 13421 swiper.updateProgress(newPosition); 13422 swiper.setTransition(momentumDuration); 13423 swiper.setTranslate(newPosition); 13424 swiper.transitionStart(true, swiper.swipeDirection); 13425 if (!swiper.animating) { 13426 swiper.animating = true; 13427 $wrapperEl.transitionEnd(function () { 13428 if (!swiper || swiper.destroyed) { return; } 13429 swiper.transitionEnd(); 13430 }); 13431 } 13432 } else { 13433 swiper.updateProgress(newPosition); 13434 } 13435 13436 swiper.updateActiveIndex(); 13437 swiper.updateSlidesClasses(); 13438 } else if (params.freeModeSticky) { 13439 swiper.slideToClosest(); 13440 return; 13441 } 13442 13443 if (!params.freeModeMomentum || timeDiff >= params.longSwipesMs) { 13444 swiper.updateProgress(); 13445 swiper.updateActiveIndex(); 13446 swiper.updateSlidesClasses(); 13447 } 13448 return; 13449 } 13450 13451 // Find current slide 13452 var stopIndex = 0; 13453 var groupSize = swiper.slidesSizesGrid[0]; 13454 for (var i = 0; i < slidesGrid.length; i += params.slidesPerGroup) { 13455 if (typeof slidesGrid[i + params.slidesPerGroup] !== 'undefined') { 13456 if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + params.slidesPerGroup]) { 13457 stopIndex = i; 13458 groupSize = slidesGrid[i + params.slidesPerGroup] - slidesGrid[i]; 13459 } 13460 } else if (currentPos >= slidesGrid[i]) { 13461 stopIndex = i; 13462 groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2]; 13463 } 13464 } 13465 13466 // Find current slide size 13467 var ratio = (currentPos - slidesGrid[stopIndex]) / groupSize; 13468 13469 if (timeDiff > params.longSwipesMs) { 13470 // Long touches 13471 if (!params.longSwipes) { 13472 swiper.slideTo(swiper.activeIndex); 13473 return; 13474 } 13475 if (swiper.swipeDirection === 'next') { 13476 if (ratio >= params.longSwipesRatio) { swiper.slideTo(stopIndex + params.slidesPerGroup); } 13477 else { swiper.slideTo(stopIndex); } 13478 } 13479 if (swiper.swipeDirection === 'prev') { 13480 if (ratio > (1 - params.longSwipesRatio)) { swiper.slideTo(stopIndex + params.slidesPerGroup); } 13481 else { swiper.slideTo(stopIndex); } 13482 } 13483 } else { 13484 // Short swipes 13485 if (!params.shortSwipes) { 13486 swiper.slideTo(swiper.activeIndex); 13487 return; 13488 } 13489 if (swiper.swipeDirection === 'next') { 13490 swiper.slideTo(stopIndex + params.slidesPerGroup); 13491 } 13492 if (swiper.swipeDirection === 'prev') { 13493 swiper.slideTo(stopIndex); 13494 } 13495 } 13496 } 13497 13498 function onResize () { 13499 var swiper = this; 13500 13501 var params = swiper.params; 13502 var el = swiper.el; 13503 13504 if (el && el.offsetWidth === 0) { return; } 13505 13506 // Breakpoints 13507 if (params.breakpoints) { 13508 swiper.setBreakpoint(); 13509 } 13510 13511 // Save locks 13512 var allowSlideNext = swiper.allowSlideNext; 13513 var allowSlidePrev = swiper.allowSlidePrev; 13514 var snapGrid = swiper.snapGrid; 13515 13516 // Disable locks on resize 13517 swiper.allowSlideNext = true; 13518 swiper.allowSlidePrev = true; 13519 13520 swiper.updateSize(); 13521 swiper.updateSlides(); 13522 13523 if (params.freeMode) { 13524 var newTranslate = Math.min(Math.max(swiper.translate, swiper.maxTranslate()), swiper.minTranslate()); 13525 swiper.setTranslate(newTranslate); 13526 swiper.updateActiveIndex(); 13527 swiper.updateSlidesClasses(); 13528 13529 if (params.autoHeight) { 13530 swiper.updateAutoHeight(); 13531 } 13532 } else { 13533 swiper.updateSlidesClasses(); 13534 if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) { 13535 swiper.slideTo(swiper.slides.length - 1, 0, false, true); 13536 } else { 13537 swiper.slideTo(swiper.activeIndex, 0, false, true); 13538 } 13539 } 13540
vendor: 41,114 bytes, lines 13540-14855
13540// Return locks after resize 13541 swiper.allowSlidePrev = allowSlidePrev; 13542 swiper.allowSlideNext = allowSlideNext; 13543 13544 if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) { 13545 swiper.checkOverflow(); 13546 } 13547 } 13548 13549 function onClick (e) { 13550 var swiper = this; 13551 if (!swiper.allowClick) { 13552 if (swiper.params.preventClicks) { e.preventDefault(); } 13553 if (swiper.params.preventClicksPropagation && swiper.animating) { 13554 e.stopPropagation(); 13555 e.stopImmediatePropagation(); 13556 } 13557 } 13558 } 13559 13560 function attachEvents() { 13561 var swiper = this; 13562 var params = swiper.params; 13563 var touchEvents = swiper.touchEvents; 13564 var el = swiper.el; 13565 var wrapperEl = swiper.wrapperEl; 13566 13567 { 13568 swiper.onTouchStart = onTouchStart.bind(swiper); 13569 swiper.onTouchMove = onTouchMove.bind(swiper); 13570 swiper.onTouchEnd = onTouchEnd.bind(swiper); 13571 } 13572 13573 swiper.onClick = onClick.bind(swiper); 13574 13575 var target = params.touchEventsTarget === 'container' ? el : wrapperEl; 13576 var capture = !!params.nested; 13577 13578 // Touch Events 13579 { 13580 if (!Support.touch && (Support.pointerEvents || Support.prefixedPointerEvents)) { 13581 target.addEventListener(touchEvents.start, swiper.onTouchStart, false); 13582 doc.addEventListener(touchEvents.move, swiper.onTouchMove, capture); 13583 doc.addEventListener(touchEvents.end, swiper.onTouchEnd, false); 13584 } else { 13585 if (Support.touch) { 13586 var passiveListener = touchEvents.start === 'touchstart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false; 13587 target.addEventListener(touchEvents.start, swiper.onTouchStart, passiveListener); 13588 target.addEventListener(touchEvents.move, swiper.onTouchMove, Support.passiveListener ? { passive: false, capture: capture } : capture); 13589 target.addEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener); 13590 } 13591 if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) { 13592 target.addEventListener('mousedown', swiper.onTouchStart, false); 13593 doc.addEventListener('mousemove', swiper.onTouchMove, capture); 13594 doc.addEventListener('mouseup', swiper.onTouchEnd, false); 13595 } 13596 } 13597 // Prevent Links Clicks 13598 if (params.preventClicks || params.preventClicksPropagation) { 13599 target.addEventListener('click', swiper.onClick, true); 13600 } 13601 } 13602 13603 // Resize handler 13604 swiper.on((Device.ios || Device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate'), onResize, true); 13605 } 13606 13607 function detachEvents() { 13608 var swiper = this; 13609 13610 var params = swiper.params; 13611 var touchEvents = swiper.touchEvents; 13612 var el = swiper.el; 13613 var wrapperEl = swiper.wrapperEl; 13614 13615 var target = params.touchEventsTarget === 'container' ? el : wrapperEl; 13616 var capture = !!params.nested; 13617 13618 // Touch Events 13619 { 13620 if (!Support.touch && (Support.pointerEvents || Support.prefixedPointerEvents)) { 13621 target.removeEventListener(touchEvents.start, swiper.onTouchStart, false); 13622 doc.removeEventListener(touchEvents.move, swiper.onTouchMove, capture); 13623 doc.removeEventListener(touchEvents.end, swiper.onTouchEnd, false); 13624 } else { 13625 if (Support.touch) { 13626 var passiveListener = touchEvents.start === 'onTouchStart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false; 13627 target.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener); 13628 target.removeEventListener(touchEvents.move, swiper.onTouchMove, capture); 13629 target.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener); 13630 } 13631 if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) { 13632 target.removeEventListener('mousedown', swiper.onTouchStart, false); 13633 doc.removeEventListener('mousemove', swiper.onTouchMove, capture); 13634 doc.removeEventListener('mouseup', swiper.onTouchEnd, false); 13635 } 13636 } 13637 // Prevent Links Clicks 13638 if (params.preventClicks || params.preventClicksPropagation) { 13639 target.removeEventListener('click', swiper.onClick, true); 13640 } 13641 } 13642 13643 // Resize handler 13644 swiper.off((Device.ios || Device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate'), onResize); 13645 } 13646 13647 var events = { 13648 attachEvents: attachEvents, 13649 detachEvents: detachEvents, 13650 }; 13651 13652 function setBreakpoint () { 13653 var swiper = this; 13654 var activeIndex = swiper.activeIndex; 13655 var initialized = swiper.initialized; 13656 var loopedSlides = swiper.loopedSlides; if ( loopedSlides === void 0 ) loopedSlides = 0; 13657 var params = swiper.params; 13658 var breakpoints = params.breakpoints; 13659 if (!breakpoints || (breakpoints && Object.keys(breakpoints).length === 0)) { return; } 13660 13661 // Set breakpoint for window width and update parameters 13662 var breakpoint = swiper.getBreakpoint(breakpoints); 13663 13664 if (breakpoint && swiper.currentBreakpoint !== breakpoint) { 13665 var breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined; 13666 if (breakpointOnlyParams) { 13667 ['slidesPerView', 'spaceBetween', 'slidesPerGroup'].forEach(function (param) { 13668 var paramValue = breakpointOnlyParams[param]; 13669 if (typeof paramValue === 'undefined') { return; } 13670 if (param === 'slidesPerView' && (paramValue === 'AUTO' || paramValue === 'auto')) { 13671 breakpointOnlyParams[param] = 'auto'; 13672 } else if (param === 'slidesPerView') { 13673 breakpointOnlyParams[param] = parseFloat(paramValue); 13674 } else { 13675 breakpointOnlyParams[param] = parseInt(paramValue, 10); 13676 } 13677 }); 13678 } 13679 13680 var breakpointParams = breakpointOnlyParams || swiper.originalParams; 13681 var needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView); 13682 13683 Utils.extend(swiper.params, breakpointParams); 13684 13685 Utils.extend(swiper, { 13686 allowTouchMove: swiper.params.allowTouchMove, 13687 allowSlideNext: swiper.params.allowSlideNext, 13688 allowSlidePrev: swiper.params.allowSlidePrev, 13689 }); 13690 13691 swiper.currentBreakpoint = breakpoint; 13692 13693 if (needsReLoop && initialized) { 13694 swiper.loopDestroy(); 13695 swiper.loopCreate(); 13696 swiper.updateSlides(); 13697 swiper.slideTo((activeIndex - loopedSlides) + swiper.loopedSlides, 0, false); 13698 } 13699 swiper.emit('breakpoint', breakpointParams); 13700 } 13701 } 13702 13703 function getBreakpoint (breakpoints) { 13704 var swiper = this; 13705 // Get breakpoint for window width 13706 if (!breakpoints) { return undefined; } 13707 var breakpoint = false; 13708 var points = []; 13709 Object.keys(breakpoints).forEach(function (point) { 13710 points.push(point); 13711 }); 13712 points.sort(function (a, b) { return parseInt(a, 10) - parseInt(b, 10); }); 13713 for (var i = 0; i < points.length; i += 1) { 13714 var point = points[i]; 13715 if (swiper.params.breakpointsInverse) { 13716 if (point <= win.innerWidth) { 13717 breakpoint = point; 13718 } 13719 } else if (point >= win.innerWidth && !breakpoint) { 13720 breakpoint = point; 13721 } 13722 } 13723 return breakpoint || 'max'; 13724 } 13725 13726 var breakpoints = { setBreakpoint: setBreakpoint, getBreakpoint: getBreakpoint }; 13727 13728 var Browser = (function Browser() { 13729 function isSafari() { 13730 var ua = win.navigator.userAgent.toLowerCase(); 13731 return (ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0); 13732 } 13733 return { 13734 isIE: !!win.navigator.userAgent.match(/Trident/g) || !!win.navigator.userAgent.match(/MSIE/g), 13735 isEdge: !!win.navigator.userAgent.match(/Edge/g), 13736 isSafari: isSafari(), 13737 isUiWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(win.navigator.userAgent), 13738 }; 13739 }()); 13740 13741 function addClasses () { 13742 var swiper = this; 13743 var classNames = swiper.classNames; 13744 var params = swiper.params; 13745 var rtl = swiper.rtl; 13746 var $el = swiper.$el; 13747 var suffixes = []; 13748 13749 suffixes.push(params.direction); 13750 13751 if (params.freeMode) { 13752 suffixes.push('free-mode'); 13753 } 13754 if (!Support.flexbox) { 13755 suffixes.push('no-flexbox'); 13756 } 13757 if (params.autoHeight) { 13758 suffixes.push('autoheight'); 13759 } 13760 if (rtl) { 13761 suffixes.push('rtl'); 13762 } 13763 if (params.slidesPerColumn > 1) { 13764 suffixes.push('multirow'); 13765 } 13766 if (Device.android) { 13767 suffixes.push('android'); 13768 } 13769 if (Device.ios) { 13770 suffixes.push('ios'); 13771 } 13772 // WP8 Touch Events Fix 13773 if ((Browser.isIE || Browser.isEdge) && (Support.pointerEvents || Support.prefixedPointerEvents)) { 13774 suffixes.push(("wp8-" + (params.direction))); 13775 } 13776 13777 suffixes.forEach(function (suffix) { 13778 classNames.push(params.containerModifierClass + suffix); 13779 }); 13780 13781 $el.addClass(classNames.join(' ')); 13782 } 13783 13784 function removeClasses () { 13785 var swiper = this; 13786 var $el = swiper.$el; 13787 var classNames = swiper.classNames; 13788 13789 $el.removeClass(classNames.join(' ')); 13790 } 13791 13792 var classes = { addClasses: addClasses, removeClasses: removeClasses }; 13793 13794 function loadImage (imageEl, src, srcset, sizes, checkForComplete, callback) { 13795 var image; 13796 function onReady() { 13797 if (callback) { callback(); } 13798 } 13799 if (!imageEl.complete || !checkForComplete) { 13800 if (src) { 13801 image = new win.Image(); 13802 image.onload = onReady; 13803 image.onerror = onReady; 13804 if (sizes) { 13805 image.sizes = sizes; 13806 } 13807 if (srcset) { 13808 image.srcset = srcset; 13809 } 13810 if (src) { 13811 image.src = src; 13812 } 13813 } else { 13814 onReady(); 13815 } 13816 } else { 13817 // image already loaded... 13818 onReady(); 13819 } 13820 } 13821 13822 function preloadImages () { 13823 var swiper = this; 13824 swiper.imagesToLoad = swiper.$el.find('img'); 13825 function onReady() { 13826 if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) { return; } 13827 if (swiper.imagesLoaded !== undefined) { swiper.imagesLoaded += 1; } 13828 if (swiper.imagesLoaded === swiper.imagesToLoad.length) { 13829 if (swiper.params.updateOnImagesReady) { swiper.update(); } 13830 swiper.emit('imagesReady'); 13831 } 13832 } 13833 for (var i = 0; i < swiper.imagesToLoad.length; i += 1) { 13834 var imageEl = swiper.imagesToLoad[i]; 13835 swiper.loadImage( 13836 imageEl, 13837 imageEl.currentSrc || imageEl.getAttribute('src'), 13838 imageEl.srcset || imageEl.getAttribute('srcset'), 13839 imageEl.sizes || imageEl.getAttribute('sizes'), 13840 true, 13841 onReady 13842 ); 13843 } 13844 } 13845 13846 var images = { 13847 loadImage: loadImage, 13848 preloadImages: preloadImages, 13849 }; 13850 13851 function checkOverflow() { 13852 var swiper = this; 13853 var wasLocked = swiper.isLocked; 13854 13855 swiper.isLocked = swiper.snapGrid.length === 1; 13856 swiper.allowSlideNext = !swiper.isLocked; 13857 swiper.allowSlidePrev = !swiper.isLocked; 13858 13859 // events 13860 if (wasLocked !== swiper.isLocked) { swiper.emit(swiper.isLocked ? 'lock' : 'unlock'); } 13861 13862 if (wasLocked && wasLocked !== swiper.isLocked) { 13863 swiper.isEnd = false; 13864 swiper.navigation.update(); 13865 } 13866 } 13867 13868 var checkOverflow$1 = { checkOverflow: checkOverflow }; 13869 13870 var defaults = { 13871 init: true, 13872 direction: 'horizontal', 13873 touchEventsTarget: 'container', 13874 initialSlide: 0, 13875 speed: 300, 13876 // 13877 preventInteractionOnTransition: false, 13878 13879 // To support iOS's swipe-to-go-back gesture (when being used in-app, with UIWebView). 13880 edgeSwipeDetection: false, 13881 edgeSwipeThreshold: 20, 13882 13883 // Free mode 13884 freeMode: false, 13885 freeModeMomentum: true, 13886 freeModeMomentumRatio: 1, 13887 freeModeMomentumBounce: true, 13888 freeModeMomentumBounceRatio: 1, 13889 freeModeMomentumVelocityRatio: 1, 13890 freeModeSticky: false, 13891 freeModeMinimumVelocity: 0.02, 13892 13893 // Autoheight 13894 autoHeight: false, 13895 13896 // Set wrapper width 13897 setWrapperSize: false, 13898 13899 // Virtual Translate 13900 virtualTranslate: false, 13901 13902 // Effects 13903 effect: 'slide', // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip' 13904 13905 // Breakpoints 13906 breakpoints: undefined, 13907 breakpointsInverse: false, 13908 13909 // Slides grid 13910 spaceBetween: 0, 13911 slidesPerView: 1, 13912 slidesPerColumn: 1, 13913 slidesPerColumnFill: 'column', 13914 slidesPerGroup: 1, 13915 centeredSlides: false, 13916 slidesOffsetBefore: 0, // in px 13917 slidesOffsetAfter: 0, // in px 13918 normalizeSlideIndex: true, 13919 centerInsufficientSlides: false, 13920 13921 // Disable swiper and hide navigation when container not overflow 13922 watchOverflow: false, 13923 13924 // Round length 13925 roundLengths: false, 13926 13927 // Touches 13928 touchRatio: 1, 13929 touchAngle: 45, 13930 simulateTouch: true, 13931 shortSwipes: true, 13932 longSwipes: true, 13933 longSwipesRatio: 0.5, 13934 longSwipesMs: 300, 13935 followFinger: true, 13936 allowTouchMove: true, 13937 threshold: 0, 13938 touchMoveStopPropagation: true, 13939 touchStartPreventDefault: true, 13940 touchStartForcePreventDefault: false, 13941 touchReleaseOnEdges: false, 13942 13943 // Unique Navigation Elements 13944 uniqueNavElements: true, 13945 13946 // Resistance 13947 resistance: true, 13948 resistanceRatio: 0.85, 13949 13950 // Progress 13951 watchSlidesProgress: false, 13952 watchSlidesVisibility: false, 13953 13954 // Cursor 13955 grabCursor: false, 13956 13957 // Clicks 13958 preventClicks: true, 13959 preventClicksPropagation: true, 13960 slideToClickedSlide: false, 13961 13962 // Images 13963 preloadImages: true, 13964 updateOnImagesReady: true, 13965 13966 // loop 13967 loop: false, 13968 loopAdditionalSlides: 0, 13969 loopedSlides: null, 13970 loopFillGroupWithBlank: false, 13971 13972 // Swiping/no swiping 13973 allowSlidePrev: true, 13974 allowSlideNext: true, 13975 swipeHandler: null, // '.swipe-handler', 13976 noSwiping: true, 13977 noSwipingClass: 'swiper-no-swiping', 13978 noSwipingSelector: null, 13979 13980 // Passive Listeners 13981 passiveListeners: true, 13982 13983 // NS 13984 containerModifierClass: 'swiper-container-', // NEW 13985 slideClass: 'swiper-slide', 13986 slideBlankClass: 'swiper-slide-invisible-blank', 13987 slideActiveClass: 'swiper-slide-active', 13988 slideDuplicateActiveClass: 'swiper-slide-duplicate-active', 13989 slideVisibleClass: 'swiper-slide-visible', 13990 slideDuplicateClass: 'swiper-slide-duplicate', 13991 slideNextClass: 'swiper-slide-next', 13992 slideDuplicateNextClass: 'swiper-slide-duplicate-next', 13993 slidePrevClass: 'swiper-slide-prev', 13994 slideDuplicatePrevClass: 'swiper-slide-duplicate-prev', 13995 wrapperClass: 'swiper-wrapper', 13996 13997 // Callbacks 13998 runCallbacksOnInit: true, 13999 }; 14000 14001 var prototypes = { 14002 update: update, 14003 translate: translate, 14004 transition: transition$1, 14005 slide: slide, 14006 loop: loop, 14007 grabCursor: grabCursor, 14008 manipulation: manipulation, 14009 events: events, 14010 breakpoints: breakpoints, 14011 checkOverflow: checkOverflow$1, 14012 classes: classes, 14013 images: images, 14014 }; 14015 14016 var extendedDefaults = {}; 14017 14018 var Swiper = /*@__PURE__*/(function (SwiperClass$$1) { 14019 function Swiper() { 14020 var assign; 14021 14022 var args = [], len = arguments.length; 14023 while ( len-- ) args[ len ] = arguments[ len ]; 14024 var el; 14025 var params; 14026 if (args.length === 1 && args[0].constructor && args[0].constructor === Object) { 14027 params = args[0]; 14028 } else { 14029 (assign = args, el = assign[0], params = assign[1]); 14030 } 14031 if (!params) { params = {}; } 14032 14033 params = Utils.extend({}, params); 14034 if (el && !params.el) { params.el = el; } 14035 14036 SwiperClass$$1.call(this, params); 14037 14038 Object.keys(prototypes).forEach(function (prototypeGroup) { 14039 Object.keys(prototypes[prototypeGroup]).forEach(function (protoMethod) { 14040 if (!Swiper.prototype[protoMethod]) { 14041 Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod]; 14042 } 14043 }); 14044 }); 14045 14046 // Swiper Instance 14047 var swiper = this; 14048 if (typeof swiper.modules === 'undefined') { 14049 swiper.modules = {}; 14050 } 14051 Object.keys(swiper.modules).forEach(function (moduleName) { 14052 var module = swiper.modules[moduleName]; 14053 if (module.params) { 14054 var moduleParamName = Object.keys(module.params)[0]; 14055 var moduleParams = module.params[moduleParamName]; 14056 if (typeof moduleParams !== 'object' || moduleParams === null) { return; } 14057 if (!(moduleParamName in params && 'enabled' in moduleParams)) { return; } 14058 if (params[moduleParamName] === true) { 14059 params[moduleParamName] = { enabled: true }; 14060 } 14061 if ( 14062 typeof params[moduleParamName] === 'object' 14063 && !('enabled' in params[moduleParamName]) 14064 ) { 14065 params[moduleParamName].enabled = true; 14066 } 14067 if (!params[moduleParamName]) { params[moduleParamName] = { enabled: false }; } 14068 } 14069 }); 14070 14071 // Extend defaults with modules params 14072 var swiperParams = Utils.extend({}, defaults); 14073 swiper.useModulesParams(swiperParams); 14074 14075 // Extend defaults with passed params 14076 swiper.params = Utils.extend({}, swiperParams, extendedDefaults, params); 14077 swiper.originalParams = Utils.extend({}, swiper.params); 14078 swiper.passedParams = Utils.extend({}, params); 14079 14080 // Save Dom lib 14081 swiper.$ = $; 14082 14083 // Find el 14084 var $el = $(swiper.params.el); 14085 el = $el[0]; 14086 14087 if (!el) { 14088 return undefined; 14089 } 14090 14091 if ($el.length > 1) { 14092 var swipers = []; 14093 $el.each(function (index, containerEl) { 14094 var newParams = Utils.extend({}, params, { el: containerEl }); 14095 swipers.push(new Swiper(newParams)); 14096 }); 14097 return swipers; 14098 } 14099 14100 el.swiper = swiper; 14101 $el.data('swiper', swiper); 14102 14103 // Find Wrapper 14104 var $wrapperEl = $el.children(("." + (swiper.params.wrapperClass))); 14105 14106 // Extend Swiper 14107 Utils.extend(swiper, { 14108 $el: $el, 14109 el: el, 14110 $wrapperEl: $wrapperEl, 14111 wrapperEl: $wrapperEl[0], 14112 14113 // Classes 14114 classNames: [], 14115 14116 // Slides 14117 slides: $(), 14118 slidesGrid: [], 14119 snapGrid: [], 14120 slidesSizesGrid: [], 14121 14122 // isDirection 14123 isHorizontal: function isHorizontal() { 14124 return swiper.params.direction === 'horizontal'; 14125 }, 14126 isVertical: function isVertical() { 14127 return swiper.params.direction === 'vertical'; 14128 }, 14129 // RTL 14130 rtl: (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'), 14131 rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'), 14132 wrongRTL: $wrapperEl.css('display') === '-webkit-box', 14133 14134 // Indexes 14135 activeIndex: 0, 14136 realIndex: 0, 14137 14138 // 14139 isBeginning: true, 14140 isEnd: false, 14141 14142 // Props 14143 translate: 0, 14144 previousTranslate: 0, 14145 progress: 0, 14146 velocity: 0, 14147 animating: false, 14148 14149 // Locks 14150 allowSlideNext: swiper.params.allowSlideNext, 14151 allowSlidePrev: swiper.params.allowSlidePrev, 14152 14153 // Touch Events 14154 touchEvents: (function touchEvents() { 14155 var touch = ['touchstart', 'touchmove', 'touchend']; 14156 var desktop = ['mousedown', 'mousemove', 'mouseup']; 14157 if (Support.pointerEvents) { 14158 desktop = ['pointerdown', 'pointermove', 'pointerup']; 14159 } else if (Support.prefixedPointerEvents) { 14160 desktop = ['MSPointerDown', 'MSPointerMove', 'MSPointerUp']; 14161 } 14162 swiper.touchEventsTouch = { 14163 start: touch[0], 14164 move: touch[1], 14165 end: touch[2], 14166 }; 14167 swiper.touchEventsDesktop = { 14168 start: desktop[0], 14169 move: desktop[1], 14170 end: desktop[2], 14171 }; 14172 return Support.touch || !swiper.params.simulateTouch ? swiper.touchEventsTouch : swiper.touchEventsDesktop; 14173 }()), 14174 touchEventsData: { 14175 isTouched: undefined, 14176 isMoved: undefined, 14177 allowTouchCallbacks: undefined, 14178 touchStartTime: undefined, 14179 isScrolling: undefined, 14180 currentTranslate: undefined, 14181 startTranslate: undefined, 14182 allowThresholdMove: undefined, 14183 // Form elements to match 14184 formElements: 'input, select, option, textarea, button, video', 14185 // Last click time 14186 lastClickTime: Utils.now(), 14187 clickTimeout: undefined, 14188 // Velocities 14189 velocities: [], 14190 allowMomentumBounce: undefined, 14191 isTouchEvent: undefined, 14192 startMoving: undefined, 14193 }, 14194 14195 // Clicks 14196 allowClick: true, 14197 14198 // Touches 14199 allowTouchMove: swiper.params.allowTouchMove, 14200 14201 touches: { 14202 startX: 0, 14203 startY: 0, 14204 currentX: 0, 14205 currentY: 0, 14206 diff: 0, 14207 }, 14208 14209 // Images 14210 imagesToLoad: [], 14211 imagesLoaded: 0, 14212 14213 }); 14214 14215 // Install Modules 14216 swiper.useModules(); 14217 14218 // Init 14219 if (swiper.params.init) { 14220 swiper.init(); 14221 } 14222 14223 // Return app instance 14224 return swiper; 14225 } 14226 14227 if ( SwiperClass$$1 ) Swiper.__proto__ = SwiperClass$$1; 14228 Swiper.prototype = Object.create( SwiperClass$$1 && SwiperClass$$1.prototype ); 14229 Swiper.prototype.constructor = Swiper; 14230 14231 var staticAccessors = { extendedDefaults: { configurable: true },defaults: { configurable: true },Class: { configurable: true },$: { configurable: true } }; 14232 14233 Swiper.prototype.slidesPerViewDynamic = function slidesPerViewDynamic () { 14234 var swiper = this; 14235 var params = swiper.params; 14236 var slides = swiper.slides; 14237 var slidesGrid = swiper.slidesGrid; 14238 var swiperSize = swiper.size; 14239 var activeIndex = swiper.activeIndex; 14240 var spv = 1; 14241 if (params.centeredSlides) { 14242 var slideSize = slides[activeIndex].swiperSlideSize; 14243 var breakLoop; 14244 for (var i = activeIndex + 1; i < slides.length; i += 1) { 14245 if (slides[i] && !breakLoop) { 14246 slideSize += slides[i].swiperSlideSize; 14247 spv += 1; 14248 if (slideSize > swiperSize) { breakLoop = true; } 14249 } 14250 } 14251 for (var i$1 = activeIndex - 1; i$1 >= 0; i$1 -= 1) { 14252 if (slides[i$1] && !breakLoop) { 14253 slideSize += slides[i$1].swiperSlideSize; 14254 spv += 1; 14255 if (slideSize > swiperSize) { breakLoop = true; } 14256 } 14257 } 14258 } else { 14259 for (var i$2 = activeIndex + 1; i$2 < slides.length; i$2 += 1) { 14260 if (slidesGrid[i$2] - slidesGrid[activeIndex] < swiperSize) { 14261 spv += 1; 14262 } 14263 } 14264 } 14265 return spv; 14266 }; 14267 14268 Swiper.prototype.update = function update$$1 () { 14269 var swiper = this; 14270 if (!swiper || swiper.destroyed) { return; } 14271 var snapGrid = swiper.snapGrid; 14272 var params = swiper.params; 14273 // Breakpoints 14274 if (params.breakpoints) { 14275 swiper.setBreakpoint(); 14276 } 14277 swiper.updateSize(); 14278 swiper.updateSlides(); 14279 swiper.updateProgress(); 14280 swiper.updateSlidesClasses(); 14281 14282 function setTranslate() { 14283 var translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate; 14284 var newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate()); 14285 swiper.setTranslate(newTranslate); 14286 swiper.updateActiveIndex(); 14287 swiper.updateSlidesClasses(); 14288 } 14289 var translated; 14290 if (swiper.params.freeMode) { 14291 setTranslate(); 14292 if (swiper.params.autoHeight) { 14293 swiper.updateAutoHeight(); 14294 } 14295 } else { 14296 if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) { 14297 translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true); 14298 } else { 14299 translated = swiper.slideTo(swiper.activeIndex, 0, false, true); 14300 } 14301 if (!translated) { 14302 setTranslate(); 14303 } 14304 } 14305 if (params.watchOverflow && snapGrid !== swiper.snapGrid) { 14306 swiper.checkOverflow(); 14307 } 14308 swiper.emit('update'); 14309 }; 14310 14311 Swiper.prototype.init = function init () { 14312 var swiper = this; 14313 if (swiper.initialized) { return; } 14314 14315 swiper.emit('beforeInit'); 14316 14317 // Set breakpoint 14318 if (swiper.params.breakpoints) { 14319 swiper.setBreakpoint(); 14320 } 14321 14322 // Add Classes 14323 swiper.addClasses(); 14324 14325 // Create loop 14326 if (swiper.params.loop) { 14327 swiper.loopCreate(); 14328 } 14329 14330 // Update size 14331 swiper.updateSize(); 14332 14333 // Update slides 14334 swiper.updateSlides(); 14335 14336 if (swiper.params.watchOverflow) { 14337 swiper.checkOverflow(); 14338 } 14339 14340 // Set Grab Cursor 14341 if (swiper.params.grabCursor) { 14342 swiper.setGrabCursor(); 14343 } 14344 14345 if (swiper.params.preloadImages) { 14346 swiper.preloadImages(); 14347 } 14348 14349 // Slide To Initial Slide 14350 if (swiper.params.loop) { 14351 swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params.runCallbacksOnInit); 14352 } else { 14353 swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit); 14354 } 14355 14356 // Attach events 14357 swiper.attachEvents(); 14358 14359 // Init Flag 14360 swiper.initialized = true; 14361 14362 // Emit 14363 swiper.emit('init'); 14364 }; 14365 14366 Swiper.prototype.destroy = function destroy (deleteInstance, cleanStyles) { 14367 if ( deleteInstance === void 0 ) deleteInstance = true; 14368 if ( cleanStyles === void 0 ) cleanStyles = true; 14369 14370 var swiper = this; 14371 var params = swiper.params; 14372 var $el = swiper.$el; 14373 var $wrapperEl = swiper.$wrapperEl; 14374 var slides = swiper.slides; 14375 14376 if (typeof swiper.params === 'undefined' || swiper.destroyed) { 14377 return null; 14378 } 14379 14380 swiper.emit('beforeDestroy'); 14381 14382 // Init Flag 14383 swiper.initialized = false; 14384 14385 // Detach events 14386 swiper.detachEvents(); 14387 14388 // Destroy loop 14389 if (params.loop) { 14390 swiper.loopDestroy(); 14391 } 14392 14393 // Cleanup styles 14394 if (cleanStyles) { 14395 swiper.removeClasses(); 14396 $el.removeAttr('style'); 14397 $wrapperEl.removeAttr('style'); 14398 if (slides && slides.length) { 14399 slides 14400 .removeClass([ 14401 params.slideVisibleClass, 14402 params.slideActiveClass, 14403 params.slideNextClass, 14404 params.slidePrevClass ].join(' ')) 14405 .removeAttr('style') 14406 .removeAttr('data-swiper-slide-index') 14407 .removeAttr('data-swiper-column') 14408 .removeAttr('data-swiper-row'); 14409 } 14410 } 14411 14412 swiper.emit('destroy'); 14413 14414 // Detach emitter events 14415 Object.keys(swiper.eventsListeners).forEach(function (eventName) { 14416 swiper.off(eventName); 14417 }); 14418 14419 if (deleteInstance !== false) { 14420 swiper.$el[0].swiper = null; 14421 swiper.$el.data('swiper', null); 14422 Utils.deleteProps(swiper); 14423 } 14424 swiper.destroyed = true; 14425 14426 return null; 14427 }; 14428 14429 Swiper.extendDefaults = function extendDefaults (newDefaults) { 14430 Utils.extend(extendedDefaults, newDefaults); 14431 }; 14432 14433 staticAccessors.extendedDefaults.get = function () { 14434 return extendedDefaults; 14435 }; 14436 14437 staticAccessors.defaults.get = function () { 14438 return defaults; 14439 }; 14440 14441 staticAccessors.Class.get = function () { 14442 return SwiperClass$$1; 14443 }; 14444 14445 staticAccessors.$.get = function () { 14446 return $; 14447 }; 14448 14449 Object.defineProperties( Swiper, staticAccessors ); 14450 14451 return Swiper; 14452 }(SwiperClass)); 14453 14454 var Device$1 = { 14455 name: 'device', 14456 proto: { 14457 device: Device, 14458 }, 14459 static: { 14460 device: Device, 14461 }, 14462 }; 14463 14464 var Support$1 = { 14465 name: 'support', 14466 proto: { 14467 support: Support, 14468 }, 14469 static: { 14470 support: Support, 14471 }, 14472 }; 14473 14474 var Browser$1 = { 14475 name: 'browser', 14476 proto: { 14477 browser: Browser, 14478 }, 14479 static: { 14480 browser: Browser, 14481 }, 14482 }; 14483 14484 var Resize = { 14485 name: 'resize', 14486 create: function create() { 14487 var swiper = this; 14488 Utils.extend(swiper, { 14489 resize: { 14490 resizeHandler: function resizeHandler() { 14491 if (!swiper || swiper.destroyed || !swiper.initialized) { return; } 14492 swiper.emit('beforeResize'); 14493 swiper.emit('resize'); 14494 }, 14495 orientationChangeHandler: function orientationChangeHandler() { 14496 if (!swiper || swiper.destroyed || !swiper.initialized) { return; } 14497 swiper.emit('orientationchange'); 14498 }, 14499 }, 14500 }); 14501 }, 14502 on: { 14503 init: function init() { 14504 var swiper = this; 14505 // Emit resize 14506 win.addEventListener('resize', swiper.resize.resizeHandler); 14507 14508 // Emit orientationchange 14509 win.addEventListener('orientationchange', swiper.resize.orientationChangeHandler); 14510 }, 14511 destroy: function destroy() { 14512 var swiper = this; 14513 win.removeEventListener('resize', swiper.resize.resizeHandler); 14514 win.removeEventListener('orientationchange', swiper.resize.orientationChangeHandler); 14515 }, 14516 }, 14517 }; 14518 14519 var Observer = { 14520 func: win.MutationObserver || win.WebkitMutationObserver, 14521 attach: function attach(target, options) { 14522 if ( options === void 0 ) options = {}; 14523 14524 var swiper = this; 14525 14526 var ObserverFunc = Observer.func; 14527 var observer = new ObserverFunc(function (mutations) { 14528 // The observerUpdate event should only be triggered 14529 // once despite the number of mutations. Additional 14530 // triggers are redundant and are very costly 14531 if (mutations.length === 1) { 14532 swiper.emit('observerUpdate', mutations[0]); 14533 return; 14534 } 14535 var observerUpdate = function observerUpdate() { 14536 swiper.emit('observerUpdate', mutations[0]); 14537 }; 14538 14539 if (win.requestAnimationFrame) { 14540 win.requestAnimationFrame(observerUpdate); 14541 } else { 14542 win.setTimeout(observerUpdate, 0); 14543 } 14544 }); 14545 14546 observer.observe(target, { 14547 attributes: typeof options.attributes === 'undefined' ? true : options.attributes, 14548 childList: typeof options.childList === 'undefined' ? true : options.childList, 14549 characterData: typeof options.characterData === 'undefined' ? true : options.characterData, 14550 }); 14551 14552 swiper.observer.observers.push(observer); 14553 }, 14554 init: function init() { 14555 var swiper = this; 14556 if (!Support.observer || !swiper.params.observer) { return; } 14557 if (swiper.params.observeParents) { 14558 var containerParents = swiper.$el.parents(); 14559 for (var i = 0; i < containerParents.length; i += 1) { 14560 swiper.observer.attach(containerParents[i]); 14561 } 14562 } 14563 // Observe container 14564 swiper.observer.attach(swiper.$el[0], { childList: false }); 14565 14566 // Observe wrapper 14567 swiper.observer.attach(swiper.$wrapperEl[0], { attributes: false }); 14568 }, 14569 destroy: function destroy() { 14570 var swiper = this; 14571 swiper.observer.observers.forEach(function (observer) { 14572 observer.disconnect(); 14573 }); 14574 swiper.observer.observers = []; 14575 }, 14576 }; 14577 14578 var Observer$1 = { 14579 name: 'observer', 14580 params: { 14581 observer: false, 14582 observeParents: false, 14583 }, 14584 create: function create() { 14585 var swiper = this; 14586 Utils.extend(swiper, { 14587 observer: { 14588 init: Observer.init.bind(swiper), 14589 attach: Observer.attach.bind(swiper), 14590 destroy: Observer.destroy.bind(swiper), 14591 observers: [], 14592 }, 14593 }); 14594 }, 14595 on: { 14596 init: function init() { 14597 var swiper = this; 14598 swiper.observer.init(); 14599 }, 14600 destroy: function destroy() { 14601 var swiper = this; 14602 swiper.observer.destroy(); 14603 }, 14604 }, 14605 }; 14606 14607 var Virtual = { 14608 update: function update(force) { 14609 var swiper = this; 14610 var ref = swiper.params; 14611 var slidesPerView = ref.slidesPerView; 14612 var slidesPerGroup = ref.slidesPerGroup; 14613 var centeredSlides = ref.centeredSlides; 14614 var ref$1 = swiper.params.virtual; 14615 var addSlidesBefore = ref$1.addSlidesBefore; 14616 var addSlidesAfter = ref$1.addSlidesAfter; 14617 var ref$2 = swiper.virtual; 14618 var previousFrom = ref$2.from; 14619 var previousTo = ref$2.to; 14620 var slides = ref$2.slides; 14621 var previousSlidesGrid = ref$2.slidesGrid; 14622 var renderSlide = ref$2.renderSlide; 14623 var previousOffset = ref$2.offset; 14624 swiper.updateActiveIndex(); 14625 var activeIndex = swiper.activeIndex || 0; 14626 14627 var offsetProp; 14628 if (swiper.rtlTranslate) { offsetProp = 'right'; } 14629 else { offsetProp = swiper.isHorizontal() ? 'left' : 'top'; } 14630 14631 var slidesAfter; 14632 var slidesBefore; 14633 if (centeredSlides) { 14634 slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesBefore; 14635 slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesAfter; 14636 } else { 14637 slidesAfter = slidesPerView + (slidesPerGroup - 1) + addSlidesBefore; 14638 slidesBefore = slidesPerGroup + addSlidesAfter; 14639 } 14640 var from = Math.max((activeIndex || 0) - slidesBefore, 0); 14641 var to = Math.min((activeIndex || 0) + slidesAfter, slides.length - 1); 14642 var offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0); 14643 14644 Utils.extend(swiper.virtual, { 14645 from: from, 14646 to: to, 14647 offset: offset, 14648 slidesGrid: swiper.slidesGrid, 14649 }); 14650 14651 function onRendered() { 14652 swiper.updateSlides(); 14653 swiper.updateProgress(); 14654 swiper.updateSlidesClasses(); 14655 if (swiper.lazy && swiper.params.lazy.enabled) { 14656 swiper.lazy.load(); 14657 } 14658 } 14659 14660 if (previousFrom === from && previousTo === to && !force) { 14661 if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) { 14662 swiper.slides.css(offsetProp, (offset + "px")); 14663 } 14664 swiper.updateProgress(); 14665 return; 14666 } 14667 if (swiper.params.virtual.renderExternal) { 14668 swiper.params.virtual.renderExternal.call(swiper, { 14669 offset: offset, 14670 from: from, 14671 to: to, 14672 slides: (function getSlides() { 14673 var slidesToRender = []; 14674 for (var i = from; i <= to; i += 1) { 14675 slidesToRender.push(slides[i]); 14676 } 14677 return slidesToRender; 14678 }()), 14679 }); 14680 onRendered(); 14681 return; 14682 } 14683 var prependIndexes = []; 14684 var appendIndexes = []; 14685 if (force) { 14686 swiper.$wrapperEl.find(("." + (swiper.params.slideClass))).remove(); 14687 } else { 14688 for (var i = previousFrom; i <= previousTo; i += 1) { 14689 if (i < from || i > to) { 14690 swiper.$wrapperEl.find(("." + (swiper.params.slideClass) + "[data-swiper-slide-index=\"" + i + "\"]")).remove(); 14691 } 14692 } 14693 } 14694 for (var i$1 = 0; i$1 < slides.length; i$1 += 1) { 14695 if (i$1 >= from && i$1 <= to) { 14696 if (typeof previousTo === 'undefined' || force) { 14697 appendIndexes.push(i$1); 14698 } else { 14699 if (i$1 > previousTo) { appendIndexes.push(i$1); } 14700 if (i$1 < previousFrom) { prependIndexes.push(i$1); } 14701 } 14702 } 14703 } 14704 appendIndexes.forEach(function (index) { 14705 swiper.$wrapperEl.append(renderSlide(slides[index], index)); 14706 }); 14707 prependIndexes.sort(function (a, b) { return b - a; }).forEach(function (index) { 14708 swiper.$wrapperEl.prepend(renderSlide(slides[index], index)); 14709 }); 14710 swiper.$wrapperEl.children('.swiper-slide').css(offsetProp, (offset + "px")); 14711 onRendered(); 14712 }, 14713 renderSlide: function renderSlide(slide, index) { 14714 var swiper = this; 14715 var params = swiper.params.virtual; 14716 if (params.cache && swiper.virtual.cache[index]) { 14717 return swiper.virtual.cache[index]; 14718 } 14719 var $slideEl = params.renderSlide 14720 ? $(params.renderSlide.call(swiper, slide, index)) 14721 : $(("<div class=\"" + (swiper.params.slideClass) + "\" data-swiper-slide-index=\"" + index + "\">" + slide + "</div>")); 14722 if (!$slideEl.attr('data-swiper-slide-index')) { $slideEl.attr('data-swiper-slide-index', index); } 14723 if (params.cache) { swiper.virtual.cache[index] = $slideEl; } 14724 return $slideEl; 14725 }, 14726 appendSlide: function appendSlide(slide) { 14727 var swiper = this; 14728 swiper.virtual.slides.push(slide); 14729 swiper.virtual.update(true); 14730 }, 14731 prependSlide: function prependSlide(slide) { 14732 var swiper = this; 14733 swiper.virtual.slides.unshift(slide); 14734 if (swiper.params.virtual.cache) { 14735 var cache = swiper.virtual.cache; 14736 var newCache = {}; 14737 Object.keys(cache).forEach(function (cachedIndex) { 14738 newCache[cachedIndex + 1] = cache[cachedIndex]; 14739 }); 14740 swiper.virtual.cache = newCache; 14741 } 14742 swiper.virtual.update(true); 14743 swiper.slideNext(0); 14744 }, 14745 }; 14746 14747 var Virtual$1 = { 14748 name: 'virtual', 14749 params: { 14750 virtual: { 14751 enabled: false, 14752 slides: [], 14753 cache: true, 14754 renderSlide: null, 14755 renderExternal: null, 14756 addSlidesBefore: 0, 14757 addSlidesAfter: 0, 14758 }, 14759 }, 14760 create: function create() { 14761 var swiper = this; 14762 Utils.extend(swiper, { 14763 virtual: { 14764 update: Virtual.update.bind(swiper), 14765 appendSlide: Virtual.appendSlide.bind(swiper), 14766 prependSlide: Virtual.prependSlide.bind(swiper), 14767 renderSlide: Virtual.renderSlide.bind(swiper), 14768 slides: swiper.params.virtual.slides, 14769 cache: {}, 14770 }, 14771 }); 14772 }, 14773 on: { 14774 beforeInit: function beforeInit() { 14775 var swiper = this; 14776 if (!swiper.params.virtual.enabled) { return; } 14777 swiper.classNames.push(((swiper.params.containerModifierClass) + "virtual")); 14778 var overwriteParams = { 14779 watchSlidesProgress: true, 14780 }; 14781 Utils.extend(swiper.params, overwriteParams); 14782 Utils.extend(swiper.originalParams, overwriteParams); 14783 14784 if (!swiper.params.initialSlide) { 14785 swiper.virtual.update(); 14786 } 14787 }, 14788 setTranslate: function setTranslate() { 14789 var swiper = this; 14790 if (!swiper.params.virtual.enabled) { return; } 14791 swiper.virtual.update(); 14792 }, 14793 }, 14794 }; 14795 14796 var Keyboard = { 14797 handle: function handle(event) { 14798 var swiper = this; 14799 var rtl = swiper.rtlTranslate; 14800 var e = event; 14801 if (e.originalEvent) { e = e.originalEvent; } // jquery fix 14802 var kc = e.keyCode || e.charCode; 14803 // Directions locks 14804 if (!swiper.allowSlideNext && ((swiper.isHorizontal() && kc === 39) || (swiper.isVertical() && kc === 40))) { 14805 return false; 14806 } 14807 if (!swiper.allowSlidePrev && ((swiper.isHorizontal() && kc === 37) || (swiper.isVertical() && kc === 38))) { 14808 return false; 14809 } 14810 if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) { 14811 return undefined; 14812 } 14813 if (doc.activeElement && doc.activeElement.nodeName && (doc.activeElement.nodeName.toLowerCase() === 'input' || doc.activeElement.nodeName.toLowerCase() === 'textarea')) { 14814 return undefined; 14815 } 14816 if (swiper.params.keyboard.onlyInViewport && (kc === 37 || kc === 39 || kc === 38 || kc === 40)) { 14817 var inView = false; 14818 // Check that swiper should be inside of visible area of window 14819 if (swiper.$el.parents(("." + (swiper.params.slideClass))).length > 0 && swiper.$el.parents(("." + (swiper.params.slideActiveClass))).length === 0) { 14820 return undefined; 14821 } 14822 var windowWidth = win.innerWidth; 14823 var windowHeight = win.innerHeight; 14824 var swiperOffset = swiper.$el.offset(); 14825 if (rtl) { swiperOffset.left -= swiper.$el[0].scrollLeft; } 14826 var swiperCoord = [ 14827 [swiperOffset.left, swiperOffset.top], 14828 [swiperOffset.left + swiper.width, swiperOffset.top], 14829 [swiperOffset.left, swiperOffset.top + swiper.height], 14830 [swiperOffset.left + swiper.width, swiperOffset.top + swiper.height] ]; 14831 for (var i = 0; i < swiperCoord.length; i += 1) { 14832 var point = swiperCoord[i]; 14833 if ( 14834 point[0] >= 0 && point[0] <= windowWidth 14835 && point[1] >= 0 && point[1] <= windowHeight 14836 ) { 14837 inView = true; 14838 } 14839 } 14840 if (!inView) { return undefined; } 14841 } 14842 if (swiper.isHorizontal()) { 14843 if (kc === 37 || kc === 39) { 14844 if (e.preventDefault) { e.preventDefault(); } 14845 else { e.returnValue = false; } 14846 } 14847 if ((kc === 39 && !rtl) || (kc === 37 && rtl)) { swiper.slideNext(); } 14848 if ((kc === 37 && !rtl) || (kc === 39 && rtl)) { swiper.slidePrev(); } 14849 } else { 14850 if (kc === 38 || kc === 40) { 14851 if (e.preventDefault) { e.preventDefault(); } 14852 else { e.returnValue = false; } 14853 } 14854 if (kc === 40) { swiper.slideNext(); } 14855 if (
vendor: 13,799 bytes, lines 14855-15312
14855kc === 38) { swiper.slidePrev(); } 14856 } 14857 swiper.emit('keyPress', kc); 14858 return undefined; 14859 }, 14860 enable: function enable() { 14861 var swiper = this; 14862 if (swiper.keyboard.enabled) { return; } 14863 $(doc).on('keydown', swiper.keyboard.handle); 14864 swiper.keyboard.enabled = true; 14865 }, 14866 disable: function disable() { 14867 var swiper = this; 14868 if (!swiper.keyboard.enabled) { return; } 14869 $(doc).off('keydown', swiper.keyboard.handle); 14870 swiper.keyboard.enabled = false; 14871 }, 14872 }; 14873 14874 var Keyboard$1 = { 14875 name: 'keyboard', 14876 params: { 14877 keyboard: { 14878 enabled: false, 14879 onlyInViewport: true, 14880 }, 14881 }, 14882 create: function create() { 14883 var swiper = this; 14884 Utils.extend(swiper, { 14885 keyboard: { 14886 enabled: false, 14887 enable: Keyboard.enable.bind(swiper), 14888 disable: Keyboard.disable.bind(swiper), 14889 handle: Keyboard.handle.bind(swiper), 14890 }, 14891 }); 14892 }, 14893 on: { 14894 init: function init() { 14895 var swiper = this; 14896 if (swiper.params.keyboard.enabled) { 14897 swiper.keyboard.enable(); 14898 } 14899 }, 14900 destroy: function destroy() { 14901 var swiper = this; 14902 if (swiper.keyboard.enabled) { 14903 swiper.keyboard.disable(); 14904 } 14905 }, 14906 }, 14907 }; 14908 14909 function isEventSupported() { 14910 var eventName = 'onwheel'; 14911 var isSupported = eventName in doc; 14912 14913 if (!isSupported) { 14914 var element = doc.createElement('div'); 14915 element.setAttribute(eventName, 'return;'); 14916 isSupported = typeof element[eventName] === 'function'; 14917 } 14918 14919 if (!isSupported 14920 && doc.implementation 14921 && doc.implementation.hasFeature 14922 // always returns true in newer browsers as per the standard. 14923 // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature 14924 && doc.implementation.hasFeature('', '') !== true 14925 ) { 14926 // This is the only way to test support for the `wheel` event in IE9+. 14927 isSupported = doc.implementation.hasFeature('Events.wheel', '3.0'); 14928 } 14929 14930 return isSupported; 14931 } 14932 var Mousewheel = { 14933 lastScrollTime: Utils.now(), 14934 event: (function getEvent() { 14935 if (win.navigator.userAgent.indexOf('firefox') > -1) { return 'DOMMouseScroll'; } 14936 return isEventSupported() ? 'wheel' : 'mousewheel'; 14937 }()), 14938 normalize: function normalize(e) { 14939 // Reasonable defaults 14940 var PIXEL_STEP = 10; 14941 var LINE_HEIGHT = 40; 14942 var PAGE_HEIGHT = 800; 14943 14944 var sX = 0; 14945 var sY = 0; // spinX, spinY 14946 var pX = 0; 14947 var pY = 0; // pixelX, pixelY 14948 14949 // Legacy 14950 if ('detail' in e) { 14951 sY = e.detail; 14952 } 14953 if ('wheelDelta' in e) { 14954 sY = -e.wheelDelta / 120; 14955 } 14956 if ('wheelDeltaY' in e) { 14957 sY = -e.wheelDeltaY / 120; 14958 } 14959 if ('wheelDeltaX' in e) { 14960 sX = -e.wheelDeltaX / 120; 14961 } 14962 14963 // side scrolling on FF with DOMMouseScroll 14964 if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) { 14965 sX = sY; 14966 sY = 0; 14967 } 14968 14969 pX = sX * PIXEL_STEP; 14970 pY = sY * PIXEL_STEP; 14971 14972 if ('deltaY' in e) { 14973 pY = e.deltaY; 14974 } 14975 if ('deltaX' in e) { 14976 pX = e.deltaX; 14977 } 14978 14979 if ((pX || pY) && e.deltaMode) { 14980 if (e.deltaMode === 1) { // delta in LINE units 14981 pX *= LINE_HEIGHT; 14982 pY *= LINE_HEIGHT; 14983 } else { // delta in PAGE units 14984 pX *= PAGE_HEIGHT; 14985 pY *= PAGE_HEIGHT; 14986 } 14987 } 14988 14989 // Fall-back if spin cannot be determined 14990 if (pX && !sX) { 14991 sX = (pX < 1) ? -1 : 1; 14992 } 14993 if (pY && !sY) { 14994 sY = (pY < 1) ? -1 : 1; 14995 } 14996 14997 return { 14998 spinX: sX, 14999 spinY: sY, 15000 pixelX: pX, 15001 pixelY: pY, 15002 }; 15003 }, 15004 handleMouseEnter: function handleMouseEnter() { 15005 var swiper = this; 15006 swiper.mouseEntered = true; 15007 }, 15008 handleMouseLeave: function handleMouseLeave() { 15009 var swiper = this; 15010 swiper.mouseEntered = false; 15011 }, 15012 handle: function handle(event) { 15013 var e = event; 15014 var swiper = this; 15015 var params = swiper.params.mousewheel; 15016 15017 if (!swiper.mouseEntered && !params.releaseOnEdges) { return true; } 15018 15019 if (e.originalEvent) { e = e.originalEvent; } // jquery fix 15020 var delta = 0; 15021 var rtlFactor = swiper.rtlTranslate ? -1 : 1; 15022 15023 var data = Mousewheel.normalize(e); 15024 15025 if (params.forceToAxis) { 15026 if (swiper.isHorizontal()) { 15027 if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) { delta = data.pixelX * rtlFactor; } 15028 else { return true; } 15029 } else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) { delta = data.pixelY; } 15030 else { return true; } 15031 } else { 15032 delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY; 15033 } 15034 15035 if (delta === 0) { return true; } 15036 15037 if (params.invert) { delta = -delta; } 15038 15039 if (!swiper.params.freeMode) { 15040 if (Utils.now() - swiper.mousewheel.lastScrollTime > 60) { 15041 if (delta < 0) { 15042 if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) { 15043 swiper.slideNext(); 15044 swiper.emit('scroll', e); 15045 } else if (params.releaseOnEdges) { return true; } 15046 } else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) { 15047 swiper.slidePrev(); 15048 swiper.emit('scroll', e); 15049 } else if (params.releaseOnEdges) { return true; } 15050 } 15051 swiper.mousewheel.lastScrollTime = (new win.Date()).getTime(); 15052 } else { 15053 // Freemode or scrollContainer: 15054 if (swiper.params.loop) { 15055 swiper.loopFix(); 15056 } 15057 var position = swiper.getTranslate() + (delta * params.sensitivity); 15058 var wasBeginning = swiper.isBeginning; 15059 var wasEnd = swiper.isEnd; 15060 15061 if (position >= swiper.minTranslate()) { position = swiper.minTranslate(); } 15062 if (position <= swiper.maxTranslate()) { position = swiper.maxTranslate(); } 15063 15064 swiper.setTransition(0); 15065 swiper.setTranslate(position); 15066 swiper.updateProgress(); 15067 swiper.updateActiveIndex(); 15068 swiper.updateSlidesClasses(); 15069 15070 if ((!wasBeginning && swiper.isBeginning) || (!wasEnd && swiper.isEnd)) { 15071 swiper.updateSlidesClasses(); 15072 } 15073 15074 if (swiper.params.freeModeSticky) { 15075 clearTimeout(swiper.mousewheel.timeout); 15076 swiper.mousewheel.timeout = Utils.nextTick(function () { 15077 swiper.slideToClosest(); 15078 }, 300); 15079 } 15080 // Emit event 15081 swiper.emit('scroll', e); 15082 15083 // Stop autoplay 15084 if (swiper.params.autoplay && swiper.params.autoplayDisableOnInteraction) { swiper.autoplay.stop(); } 15085 // Return page scroll on edge positions 15086 if (position === swiper.minTranslate() || position === swiper.maxTranslate()) { return true; } 15087 } 15088 15089 if (e.preventDefault) { e.preventDefault(); } 15090 else { e.returnValue = false; } 15091 return false; 15092 }, 15093 enable: function enable() { 15094 var swiper = this; 15095 if (!Mousewheel.event) { return false; } 15096 if (swiper.mousewheel.enabled) { return false; } 15097 var target = swiper.$el; 15098 if (swiper.params.mousewheel.eventsTarged !== 'container') { 15099 target = $(swiper.params.mousewheel.eventsTarged); 15100 } 15101 target.on('mouseenter', swiper.mousewheel.handleMouseEnter); 15102 target.on('mouseleave', swiper.mousewheel.handleMouseLeave); 15103 target.on(Mousewheel.event, swiper.mousewheel.handle); 15104 swiper.mousewheel.enabled = true; 15105 return true; 15106 }, 15107 disable: function disable() { 15108 var swiper = this; 15109 if (!Mousewheel.event) { return false; } 15110 if (!swiper.mousewheel.enabled) { return false; } 15111 var target = swiper.$el; 15112 if (swiper.params.mousewheel.eventsTarged !== 'container') { 15113 target = $(swiper.params.mousewheel.eventsTarged); 15114 } 15115 target.off(Mousewheel.event, swiper.mousewheel.handle); 15116 swiper.mousewheel.enabled = false; 15117 return true; 15118 }, 15119 }; 15120 15121 var Mousewheel$1 = { 15122 name: 'mousewheel', 15123 params: { 15124 mousewheel: { 15125 enabled: false, 15126 releaseOnEdges: false, 15127 invert: false, 15128 forceToAxis: false, 15129 sensitivity: 1, 15130 eventsTarged: 'container', 15131 }, 15132 }, 15133 create: function create() { 15134 var swiper = this; 15135 Utils.extend(swiper, { 15136 mousewheel: { 15137 enabled: false, 15138 enable: Mousewheel.enable.bind(swiper), 15139 disable: Mousewheel.disable.bind(swiper), 15140 handle: Mousewheel.handle.bind(swiper), 15141 handleMouseEnter: Mousewheel.handleMouseEnter.bind(swiper), 15142 handleMouseLeave: Mousewheel.handleMouseLeave.bind(swiper), 15143 lastScrollTime: Utils.now(), 15144 }, 15145 }); 15146 }, 15147 on: { 15148 init: function init() { 15149 var swiper = this; 15150 if (swiper.params.mousewheel.enabled) { swiper.mousewheel.enable(); } 15151 }, 15152 destroy: function destroy() { 15153 var swiper = this; 15154 if (swiper.mousewheel.enabled) { swiper.mousewheel.disable(); } 15155 }, 15156 }, 15157 }; 15158 15159 var Navigation = { 15160 update: function update() { 15161 // Update Navigation Buttons 15162 var swiper = this; 15163 var params = swiper.params.navigation; 15164 15165 if (swiper.params.loop) { return; } 15166 var ref = swiper.navigation; 15167 var $nextEl = ref.$nextEl; 15168 var $prevEl = ref.$prevEl; 15169 15170 if ($prevEl && $prevEl.length > 0) { 15171 if (swiper.isBeginning) { 15172 $prevEl.addClass(params.disabledClass); 15173 } else { 15174 $prevEl.removeClass(params.disabledClass); 15175 } 15176 $prevEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); 15177 } 15178 if ($nextEl && $nextEl.length > 0) { 15179 if (swiper.isEnd) { 15180 $nextEl.addClass(params.disabledClass); 15181 } else { 15182 $nextEl.removeClass(params.disabledClass); 15183 } 15184 $nextEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); 15185 } 15186 }, 15187 onPrevClick: function onPrevClick(e) { 15188 var swiper = this; 15189 e.preventDefault(); 15190 if (swiper.isBeginning && !swiper.params.loop) { return; } 15191 swiper.slidePrev(); 15192 }, 15193 onNextClick: function onNextClick(e) { 15194 var swiper = this; 15195 e.preventDefault(); 15196 if (swiper.isEnd && !swiper.params.loop) { return; } 15197 swiper.slideNext(); 15198 }, 15199 init: function init() { 15200 var swiper = this; 15201 var params = swiper.params.navigation; 15202 if (!(params.nextEl || params.prevEl)) { return; } 15203 15204 var $nextEl; 15205 var $prevEl; 15206 if (params.nextEl) { 15207 $nextEl = $(params.nextEl); 15208 if ( 15209 swiper.params.uniqueNavElements 15210 && typeof params.nextEl === 'string' 15211 && $nextEl.length > 1 15212 && swiper.$el.find(params.nextEl).length === 1 15213 ) { 15214 $nextEl = swiper.$el.find(params.nextEl); 15215 } 15216 } 15217 if (params.prevEl) { 15218 $prevEl = $(params.prevEl); 15219 if ( 15220 swiper.params.uniqueNavElements 15221 && typeof params.prevEl === 'string' 15222 && $prevEl.length > 1 15223 && swiper.$el.find(params.prevEl).length === 1 15224 ) { 15225 $prevEl = swiper.$el.find(params.prevEl); 15226 } 15227 } 15228 15229 if ($nextEl && $nextEl.length > 0) { 15230 $nextEl.on('click', swiper.navigation.onNextClick); 15231 } 15232 if ($prevEl && $prevEl.length > 0) { 15233 $prevEl.on('click', swiper.navigation.onPrevClick); 15234 } 15235 15236 Utils.extend(swiper.navigation, { 15237 $nextEl: $nextEl, 15238 nextEl: $nextEl && $nextEl[0], 15239 $prevEl: $prevEl, 15240 prevEl: $prevEl && $prevEl[0], 15241 }); 15242 }, 15243 destroy: function destroy() { 15244 var swiper = this; 15245 var ref = swiper.navigation; 15246 var $nextEl = ref.$nextEl; 15247 var $prevEl = ref.$prevEl; 15248 if ($nextEl && $nextEl.length) { 15249 $nextEl.off('click', swiper.navigation.onNextClick); 15250 $nextEl.removeClass(swiper.params.navigation.disabledClass); 15251 } 15252 if ($prevEl && $prevEl.length) { 15253 $prevEl.off('click', swiper.navigation.onPrevClick); 15254 $prevEl.removeClass(swiper.params.navigation.disabledClass); 15255 } 15256 }, 15257 }; 15258 15259 var Navigation$1 = { 15260 name: 'navigation', 15261 params: { 15262 navigation: { 15263 nextEl: null, 15264 prevEl: null, 15265 15266 hideOnClick: false, 15267 disabledClass: 'swiper-button-disabled', 15268 hiddenClass: 'swiper-button-hidden', 15269 lockClass: 'swiper-button-lock', 15270 }, 15271 }, 15272 create: function create() { 15273 var swiper = this; 15274 Utils.extend(swiper, { 15275 navigation: { 15276 init: Navigation.init.bind(swiper), 15277 update: Navigation.update.bind(swiper), 15278 destroy: Navigation.destroy.bind(swiper), 15279 onNextClick: Navigation.onNextClick.bind(swiper), 15280 onPrevClick: Navigation.onPrevClick.bind(swiper), 15281 }, 15282 }); 15283 }, 15284 on: { 15285 init: function init() { 15286 var swiper = this; 15287 swiper.navigation.init(); 15288 swiper.navigation.update(); 15289 }, 15290 toEdge: function toEdge() { 15291 var swiper = this; 15292 swiper.navigation.update(); 15293 }, 15294 fromEdge: function fromEdge() { 15295 var swiper = this; 15296 swiper.navigation.update(); 15297 }, 15298 destroy: function destroy() { 15299 var swiper = this; 15300 swiper.navigation.destroy(); 15301 }, 15302 click: function click(e) { 15303 var swiper = this; 15304 var ref = swiper.navigation; 15305 var $nextEl = ref.$nextEl; 15306 var $prevEl = ref.$prevEl; 15307 if ( 15308 swiper.params.navigation.hideOnClick 15309 && !$(e.target).is($prevEl) 15310 && !$(e.target).is($nextEl) 15311 ) { 15312
15312if ($nextEl) { $nextEl.toggleClass(swiper.params.navigation.hiddenClass); } 15313 if ($prevEl) { $prevEl.toggleClass(swiper.params.navigation.hiddenClass);
vendor: 13,669 bytes, lines 15313-15644
15313 } 15314 } 15315 }, 15316 }, 15317 }; 15318 15319 var Pagination = { 15320 update: function update() { 15321 // Render || Update Pagination bullets/items 15322 var swiper = this; 15323 var rtl = swiper.rtl; 15324 var params = swiper.params.pagination; 15325 if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) { return; } 15326 var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; 15327 var $el = swiper.pagination.$el; 15328 // Current/Total 15329 var current; 15330 var total = swiper.params.loop ? Math.ceil((slidesLength - (swiper.loopedSlides * 2)) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; 15331 if (swiper.params.loop) { 15332 current = Math.ceil((swiper.activeIndex - swiper.loopedSlides) / swiper.params.slidesPerGroup); 15333 if (current > slidesLength - 1 - (swiper.loopedSlides * 2)) { 15334 current -= (slidesLength - (swiper.loopedSlides * 2)); 15335 } 15336 if (current > total - 1) { current -= total; } 15337 if (current < 0 && swiper.params.paginationType !== 'bullets') { current = total + current; } 15338 } else if (typeof swiper.snapIndex !== 'undefined') { 15339 current = swiper.snapIndex; 15340 } else { 15341 current = swiper.activeIndex || 0; 15342 } 15343 // Types 15344 if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) { 15345 var bullets = swiper.pagination.bullets; 15346 var firstIndex; 15347 var lastIndex; 15348 var midIndex; 15349 if (params.dynamicBullets) { 15350 swiper.pagination.bulletSize = bullets.eq(0)[swiper.isHorizontal() ? 'outerWidth' : 'outerHeight'](true); 15351 $el.css(swiper.isHorizontal() ? 'width' : 'height', ((swiper.pagination.bulletSize * (params.dynamicMainBullets + 4)) + "px")); 15352 if (params.dynamicMainBullets > 1 && swiper.previousIndex !== undefined) { 15353 swiper.pagination.dynamicBulletIndex += (current - swiper.previousIndex); 15354 if (swiper.pagination.dynamicBulletIndex > (params.dynamicMainBullets - 1)) { 15355 swiper.pagination.dynamicBulletIndex = params.dynamicMainBullets - 1; 15356 } else if (swiper.pagination.dynamicBulletIndex < 0) { 15357 swiper.pagination.dynamicBulletIndex = 0; 15358 } 15359 } 15360 firstIndex = current - swiper.pagination.dynamicBulletIndex; 15361 lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1); 15362 midIndex = (lastIndex + firstIndex) / 2; 15363 } 15364 bullets.removeClass(((params.bulletActiveClass) + " " + (params.bulletActiveClass) + "-next " + (params.bulletActiveClass) + "-next-next " + (params.bulletActiveClass) + "-prev " + (params.bulletActiveClass) + "-prev-prev " + (params.bulletActiveClass) + "-main")); 15365 if ($el.length > 1) { 15366 bullets.each(function (index, bullet) { 15367 var $bullet = $(bullet); 15368 var bulletIndex = $bullet.index(); 15369 if (bulletIndex === current) { 15370 $bullet.addClass(params.bulletActiveClass); 15371 } 15372 if (params.dynamicBullets) { 15373 if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) { 15374 $bullet.addClass(((params.bulletActiveClass) + "-main")); 15375 } 15376 if (bulletIndex === firstIndex) { 15377 $bullet 15378 .prev() 15379 .addClass(((params.bulletActiveClass) + "-prev")) 15380 .prev() 15381 .addClass(((params.bulletActiveClass) + "-prev-prev")); 15382 } 15383 if (bulletIndex === lastIndex) { 15384 $bullet 15385 .next() 15386 .addClass(((params.bulletActiveClass) + "-next")) 15387 .next() 15388 .addClass(((params.bulletActiveClass) + "-next-next")); 15389 } 15390 } 15391 }); 15392 } else { 15393 var $bullet = bullets.eq(current); 15394 $bullet.addClass(params.bulletActiveClass); 15395 if (params.dynamicBullets) { 15396 var $firstDisplayedBullet = bullets.eq(firstIndex); 15397 var $lastDisplayedBullet = bullets.eq(lastIndex); 15398 for (var i = firstIndex; i <= lastIndex; i += 1) { 15399 bullets.eq(i).addClass(((params.bulletActiveClass) + "-main")); 15400 } 15401 $firstDisplayedBullet 15402 .prev() 15403 .addClass(((params.bulletActiveClass) + "-prev")) 15404 .prev() 15405 .addClass(((params.bulletActiveClass) + "-prev-prev")); 15406 $lastDisplayedBullet 15407 .next() 15408 .addClass(((params.bulletActiveClass) + "-next")) 15409 .next() 15410 .addClass(((params.bulletActiveClass) + "-next-next")); 15411 } 15412 } 15413 if (params.dynamicBullets) { 15414 var dynamicBulletsLength = Math.min(bullets.length, params.dynamicMainBullets + 4); 15415 var bulletsOffset = (((swiper.pagination.bulletSize * dynamicBulletsLength) - (swiper.pagination.bulletSize)) / 2) - (midIndex * swiper.pagination.bulletSize); 15416 var offsetProp = rtl ? 'right' : 'left'; 15417 bullets.css(swiper.isHorizontal() ? offsetProp : 'top', (bulletsOffset + "px")); 15418 } 15419 } 15420 if (params.type === 'fraction') { 15421 $el.find(("." + (params.currentClass))).text(params.formatFractionCurrent(current + 1)); 15422 $el.find(("." + (params.totalClass))).text(params.formatFractionTotal(total)); 15423 } 15424 if (params.type === 'progressbar') { 15425 var progressbarDirection; 15426 if (params.progressbarOpposite) { 15427 progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal'; 15428 } else { 15429 progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical'; 15430 } 15431 var scale = (current + 1) / total; 15432 var scaleX = 1; 15433 var scaleY = 1; 15434 if (progressbarDirection === 'horizontal') { 15435 scaleX = scale; 15436 } else { 15437 scaleY = scale; 15438 } 15439 $el.find(("." + (params.progressbarFillClass))).transform(("translate3d(0,0,0) scaleX(" + scaleX + ") scaleY(" + scaleY + ")")).transition(swiper.params.speed); 15440 } 15441 if (params.type === 'custom' && params.renderCustom) { 15442 $el.html(params.renderCustom(swiper, current + 1, total)); 15443 swiper.emit('paginationRender', swiper, $el[0]); 15444 } else { 15445 swiper.emit('paginationUpdate', swiper, $el[0]); 15446 } 15447 $el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); 15448 }, 15449 render: function render() { 15450 // Render Container 15451 var swiper = this; 15452 var params = swiper.params.pagination; 15453 if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) { return; } 15454 var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; 15455 15456 var $el = swiper.pagination.$el; 15457 var paginationHTML = ''; 15458 if (params.type === 'bullets') { 15459 var numberOfBullets = swiper.params.loop ? Math.ceil((slidesLength - (swiper.loopedSlides * 2)) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; 15460 for (var i = 0; i < numberOfBullets; i += 1) { 15461 if (params.renderBullet) { 15462 paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass); 15463 } else { 15464 paginationHTML += "<" + (params.bulletElement) + " class=\"" + (params.bulletClass) + "\"></" + (params.bulletElement) + ">"; 15465 } 15466 } 15467 $el.html(paginationHTML); 15468 swiper.pagination.bullets = $el.find(("." + (params.bulletClass))); 15469 } 15470 if (params.type === 'fraction') { 15471 if (params.renderFraction) { 15472 paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass); 15473 } else { 15474 paginationHTML = "<span class=\"" + (params.currentClass) + "\"></span>" 15475 + ' / ' 15476 + "<span class=\"" + (params.totalClass) + "\"></span>"; 15477 } 15478 $el.html(paginationHTML); 15479 } 15480 if (params.type === 'progressbar') { 15481 if (params.renderProgressbar) { 15482 paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass); 15483 } else { 15484 paginationHTML = "<span class=\"" + (params.progressbarFillClass) + "\"></span>"; 15485 } 15486 $el.html(paginationHTML); 15487 } 15488 if (params.type !== 'custom') { 15489 swiper.emit('paginationRender', swiper.pagination.$el[0]); 15490 } 15491 }, 15492 init: function init() { 15493 var swiper = this; 15494 var params = swiper.params.pagination; 15495 if (!params.el) { return; } 15496 15497 var $el = $(params.el); 15498 if ($el.length === 0) { return; } 15499 15500 if ( 15501 swiper.params.uniqueNavElements 15502 && typeof params.el === 'string' 15503 && $el.length > 1 15504 && swiper.$el.find(params.el).length === 1 15505 ) { 15506 $el = swiper.$el.find(params.el); 15507 } 15508 15509 if (params.type === 'bullets' && params.clickable) { 15510 $el.addClass(params.clickableClass); 15511 } 15512 15513 $el.addClass(params.modifierClass + params.type); 15514 15515 if (params.type === 'bullets' && params.dynamicBullets) { 15516 $el.addClass(("" + (params.modifierClass) + (params.type) + "-dynamic")); 15517 swiper.pagination.dynamicBulletIndex = 0; 15518 if (params.dynamicMainBullets < 1) { 15519 params.dynamicMainBullets = 1; 15520 } 15521 } 15522 if (params.type === 'progressbar' && params.progressbarOpposite) { 15523 $el.addClass(params.progressbarOppositeClass); 15524 } 15525 15526 if (params.clickable) { 15527 $el.on('click', ("." + (params.bulletClass)), function onClick(e) { 15528 e.preventDefault(); 15529 var index = $(this).index() * swiper.params.slidesPerGroup; 15530 if (swiper.params.loop) { index += swiper.loopedSlides; } 15531 swiper.slideTo(index); 15532 }); 15533 } 15534 15535 Utils.extend(swiper.pagination, { 15536 $el: $el, 15537 el: $el[0], 15538 }); 15539 }, 15540 destroy: function destroy() { 15541 var swiper = this; 15542 var params = swiper.params.pagination; 15543 if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) { return; } 15544 var $el = swiper.pagination.$el; 15545 15546 $el.removeClass(params.hiddenClass); 15547 $el.removeClass(params.modifierClass + params.type); 15548 if (swiper.pagination.bullets) { swiper.pagination.bullets.removeClass(params.bulletActiveClass); } 15549 if (params.clickable) { 15550 $el.off('click', ("." + (params.bulletClass))); 15551 } 15552 }, 15553 }; 15554 15555 var Pagination$1 = { 15556 name: 'pagination', 15557 params: { 15558 pagination: { 15559 el: null, 15560 bulletElement: 'span', 15561 clickable: false, 15562 hideOnClick: false, 15563 renderBullet: null, 15564 renderProgressbar: null, 15565 renderFraction: null, 15566 renderCustom: null, 15567 progressbarOpposite: false, 15568 type: 'bullets', // 'bullets' or 'progressbar' or 'fraction' or 'custom' 15569 dynamicBullets: false, 15570 dynamicMainBullets: 1, 15571 formatFractionCurrent: function (number) { return number; }, 15572 formatFractionTotal: function (number) { return number; }, 15573 bulletClass: 'swiper-pagination-bullet', 15574 bulletActiveClass: 'swiper-pagination-bullet-active', 15575 modifierClass: 'swiper-pagination-', // NEW 15576 currentClass: 'swiper-pagination-current', 15577 totalClass: 'swiper-pagination-total', 15578 hiddenClass: 'swiper-pagination-hidden', 15579 progressbarFillClass: 'swiper-pagination-progressbar-fill', 15580 progressbarOppositeClass: 'swiper-pagination-progressbar-opposite', 15581 clickableClass: 'swiper-pagination-clickable', // NEW 15582 lockClass: 'swiper-pagination-lock', 15583 }, 15584 }, 15585 create: function create() { 15586 var swiper = this; 15587 Utils.extend(swiper, { 15588 pagination: { 15589 init: Pagination.init.bind(swiper), 15590 render: Pagination.render.bind(swiper), 15591 update: Pagination.update.bind(swiper), 15592 destroy: Pagination.destroy.bind(swiper), 15593 dynamicBulletIndex: 0, 15594 }, 15595 }); 15596 }, 15597 on: { 15598 init: function init() { 15599 var swiper = this; 15600 swiper.pagination.init(); 15601 swiper.pagination.render(); 15602 swiper.pagination.update(); 15603 }, 15604 activeIndexChange: function activeIndexChange() { 15605 var swiper = this; 15606 if (swiper.params.loop) { 15607 swiper.pagination.update(); 15608 } else if (typeof swiper.snapIndex === 'undefined') { 15609 swiper.pagination.update(); 15610 } 15611 }, 15612 snapIndexChange: function snapIndexChange() { 15613 var swiper = this; 15614 if (!swiper.params.loop) { 15615 swiper.pagination.update(); 15616 } 15617 }, 15618 slidesLengthChange: function slidesLengthChange() { 15619 var swiper = this; 15620 if (swiper.params.loop) { 15621 swiper.pagination.render(); 15622 swiper.pagination.update(); 15623 } 15624 }, 15625 snapGridLengthChange: function snapGridLengthChange() { 15626 var swiper = this; 15627 if (!swiper.params.loop) { 15628 swiper.pagination.render(); 15629 swiper.pagination.update(); 15630 } 15631 }, 15632 destroy: function destroy() { 15633 var swiper = this; 15634 swiper.pagination.destroy(); 15635 }, 15636 click: function click(e) { 15637 var swiper = this; 15638 if ( 15639 swiper.params.pagination.el 15640 && swiper.params.pagination.hideOnClick 15641 && swiper.pagination.$el.length > 0 15642 && !$(e.target).hasClass(swiper.params.pagination.bulletClass) 15643 ) { 15644
vendor: 4,999 bytes, lines 15644-15786
15644swiper.pagination.$el.toggleClass(swiper.params.pagination.hiddenClass); 15645 } 15646 }, 15647 }, 15648 }; 15649 15650 var Scrollbar = { 15651 setTranslate: function setTranslate() { 15652 var swiper = this; 15653 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) { return; } 15654 var scrollbar = swiper.scrollbar; 15655 var rtl = swiper.rtlTranslate; 15656 var progress = swiper.progress; 15657 var dragSize = scrollbar.dragSize; 15658 var trackSize = scrollbar.trackSize; 15659 var $dragEl = scrollbar.$dragEl; 15660 var $el = scrollbar.$el; 15661 var params = swiper.params.scrollbar; 15662 15663 var newSize = dragSize; 15664 var newPos = (trackSize - dragSize) * progress; 15665 if (rtl) { 15666 newPos = -newPos; 15667 if (newPos > 0) { 15668 newSize = dragSize - newPos; 15669 newPos = 0; 15670 } else if (-newPos + dragSize > trackSize) { 15671 newSize = trackSize + newPos; 15672 } 15673 } else if (newPos < 0) { 15674 newSize = dragSize + newPos; 15675 newPos = 0; 15676 } else if (newPos + dragSize > trackSize) { 15677 newSize = trackSize - newPos; 15678 } 15679 if (swiper.isHorizontal()) { 15680 if (Support.transforms3d) { 15681 $dragEl.transform(("translate3d(" + newPos + "px, 0, 0)")); 15682 } else { 15683 $dragEl.transform(("translateX(" + newPos + "px)")); 15684 } 15685 $dragEl[0].style.width = newSize + "px"; 15686 } else { 15687 if (Support.transforms3d) { 15688 $dragEl.transform(("translate3d(0px, " + newPos + "px, 0)")); 15689 } else { 15690 $dragEl.transform(("translateY(" + newPos + "px)")); 15691 } 15692 $dragEl[0].style.height = newSize + "px"; 15693 } 15694 if (params.hide) { 15695 clearTimeout(swiper.scrollbar.timeout); 15696 $el[0].style.opacity = 1; 15697 swiper.scrollbar.timeout = setTimeout(function () { 15698 $el[0].style.opacity = 0; 15699 $el.transition(400); 15700 }, 1000); 15701 } 15702 }, 15703 setTransition: function setTransition(duration) { 15704 var swiper = this; 15705 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) { return; } 15706 swiper.scrollbar.$dragEl.transition(duration); 15707 }, 15708 updateSize: function updateSize() { 15709 var swiper = this; 15710 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) { return; } 15711 15712 var scrollbar = swiper.scrollbar; 15713 var $dragEl = scrollbar.$dragEl; 15714 var $el = scrollbar.$el; 15715 15716 $dragEl[0].style.width = ''; 15717 $dragEl[0].style.height = ''; 15718 var trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight; 15719 15720 var divider = swiper.size / swiper.virtualSize; 15721 var moveDivider = divider * (trackSize / swiper.size); 15722 var dragSize; 15723 if (swiper.params.scrollbar.dragSize === 'auto') { 15724 dragSize = trackSize * divider; 15725 } else { 15726 dragSize = parseInt(swiper.params.scrollbar.dragSize, 10); 15727 } 15728 15729 if (swiper.isHorizontal()) { 15730 $dragEl[0].style.width = dragSize + "px"; 15731 } else { 15732 $dragEl[0].style.height = dragSize + "px"; 15733 } 15734 15735 if (divider >= 1) { 15736 $el[0].style.display = 'none'; 15737 } else { 15738 $el[0].style.display = ''; 15739 } 15740 if (swiper.params.scrollbarHide) { 15741 $el[0].style.opacity = 0; 15742 } 15743 Utils.extend(scrollbar, { 15744 trackSize: trackSize, 15745 divider: divider, 15746 moveDivider: moveDivider, 15747 dragSize: dragSize, 15748 }); 15749 scrollbar.$el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass); 15750 }, 15751 setDragPosition: function setDragPosition(e) { 15752 var swiper = this; 15753 var scrollbar = swiper.scrollbar; 15754 var rtl = swiper.rtlTranslate; 15755 var $el = scrollbar.$el; 15756 var dragSize = scrollbar.dragSize; 15757 var trackSize = scrollbar.trackSize; 15758 15759 var pointerPosition; 15760 if (swiper.isHorizontal()) { 15761 pointerPosition = ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageX : e.pageX || e.clientX); 15762 } else { 15763 pointerPosition = ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageY : e.pageY || e.clientY); 15764 } 15765 var positionRatio; 15766 positionRatio = ((pointerPosition) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragSize / 2)) / (trackSize - dragSize); 15767 positionRatio = Math.max(Math.min(positionRatio, 1), 0); 15768 if (rtl) { 15769 positionRatio = 1 - positionRatio; 15770 } 15771 15772 var position = swiper.minTranslate() + ((swiper.maxTranslate() - swiper.minTranslate()) * positionRatio); 15773 15774 swiper.updateProgress(position); 15775 swiper.setTranslate(position); 15776 swiper.updateActiveIndex(); 15777 swiper.updateSlidesClasses(); 15778 }, 15779 onDragStart: function onDragStart(e) { 15780 var swiper = this; 15781 var params = swiper.params.scrollbar; 15782 var scrollbar = swiper.scrollbar; 15783 var $wrapperEl = swiper.$wrapperEl; 15784 var $el = scrollbar.$el; 15785 var $dragEl = scrollbar.$dragEl; 15786 swiper.scrollbar.isTouched = true
vendor: 6,013 bytes, lines 15786-15941
15786; 15787 e.preventDefault(); 15788 e.stopPropagation(); 15789 15790 $wrapperEl.transition(100); 15791 $dragEl.transition(100); 15792 scrollbar.setDragPosition(e); 15793 15794 clearTimeout(swiper.scrollbar.dragTimeout); 15795 15796 $el.transition(0); 15797 if (params.hide) { 15798 $el.css('opacity', 1); 15799 } 15800 swiper.emit('scrollbarDragStart', e); 15801 }, 15802 onDragMove: function onDragMove(e) { 15803 var swiper = this; 15804 var scrollbar = swiper.scrollbar; 15805 var $wrapperEl = swiper.$wrapperEl; 15806 var $el = scrollbar.$el; 15807 var $dragEl = scrollbar.$dragEl; 15808 15809 if (!swiper.scrollbar.isTouched) { return; } 15810 if (e.preventDefault) { e.preventDefault(); } 15811 else { e.returnValue = false; } 15812 scrollbar.setDragPosition(e); 15813 $wrapperEl.transition(0); 15814 $el.transition(0); 15815 $dragEl.transition(0); 15816 swiper.emit('scrollbarDragMove', e); 15817 }, 15818 onDragEnd: function onDragEnd(e) { 15819 var swiper = this; 15820 15821 var params = swiper.params.scrollbar; 15822 var scrollbar = swiper.scrollbar; 15823 var $el = scrollbar.$el; 15824 15825 if (!swiper.scrollbar.isTouched) { return; } 15826 swiper.scrollbar.isTouched = false; 15827 if (params.hide) { 15828 clearTimeout(swiper.scrollbar.dragTimeout); 15829 swiper.scrollbar.dragTimeout = Utils.nextTick(function () { 15830 $el.css('opacity', 0); 15831 $el.transition(400); 15832 }, 1000); 15833 } 15834 swiper.emit('scrollbarDragEnd', e); 15835 if (params.snapOnRelease) { 15836 swiper.slideToClosest(); 15837 } 15838 }, 15839 enableDraggable: function enableDraggable() { 15840 var swiper = this; 15841 if (!swiper.params.scrollbar.el) { return; } 15842 var scrollbar = swiper.scrollbar; 15843 var touchEventsTouch = swiper.touchEventsTouch; 15844 var touchEventsDesktop = swiper.touchEventsDesktop; 15845 var params = swiper.params; 15846 var $el = scrollbar.$el; 15847 var target = $el[0]; 15848 var activeListener = Support.passiveListener && params.passiveListeners ? { passive: false, capture: false } : false; 15849 var passiveListener = Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false; 15850 if (!Support.touch) { 15851 target.addEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener); 15852 doc.addEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener); 15853 doc.addEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener); 15854 } else { 15855 target.addEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener); 15856 target.addEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener); 15857 target.addEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener); 15858 } 15859 }, 15860 disableDraggable: function disableDraggable() { 15861 var swiper = this; 15862 if (!swiper.params.scrollbar.el) { return; } 15863 var scrollbar = swiper.scrollbar; 15864 var touchEventsTouch = swiper.touchEventsTouch; 15865 var touchEventsDesktop = swiper.touchEventsDesktop; 15866 var params = swiper.params; 15867 var $el = scrollbar.$el; 15868 var target = $el[0]; 15869 var activeListener = Support.passiveListener && params.passiveListeners ? { passive: false, capture: false } : false; 15870 var passiveListener = Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false; 15871 if (!Support.touch) { 15872 target.removeEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener); 15873 doc.removeEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener); 15874 doc.removeEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener); 15875 } else { 15876 target.removeEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener); 15877 target.removeEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener); 15878 target.removeEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener); 15879 } 15880 }, 15881 init: function init() { 15882 var swiper = this; 15883 if (!swiper.params.scrollbar.el) { return; } 15884 var scrollbar = swiper.scrollbar; 15885 var $swiperEl = swiper.$el; 15886 var params = swiper.params.scrollbar; 15887 15888 var $el = $(params.el); 15889 if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) { 15890 $el = $swiperEl.find(params.el); 15891 } 15892 15893 var $dragEl = $el.find(("." + (swiper.params.scrollbar.dragClass))); 15894 if ($dragEl.length === 0) { 15895 $dragEl = $(("<div class=\"" + (swiper.params.scrollbar.dragClass) + "\"></div>")); 15896 $el.append($dragEl); 15897 } 15898 15899 Utils.extend(scrollbar, { 15900 $el: $el, 15901 el: $el[0], 15902 $dragEl: $dragEl, 15903 dragEl: $dragEl[0], 15904 }); 15905 15906 if (params.draggable) { 15907 scrollbar.enableDraggable(); 15908 } 15909 }, 15910 destroy: function destroy() { 15911 var swiper = this; 15912 swiper.scrollbar.disableDraggable(); 15913 }, 15914 }; 15915 15916 var Scrollbar$1 = { 15917 name: 'scrollbar', 15918 params: { 15919 scrollbar: { 15920 el: null, 15921 dragSize: 'auto', 15922 hide: false, 15923 draggable: false, 15924 snapOnRelease: true, 15925 lockClass: 'swiper-scrollbar-lock', 15926 dragClass: 'swiper-scrollbar-drag', 15927 }, 15928 }, 15929 create: function create() { 15930 var swiper = this; 15931 Utils.extend(swiper, { 15932 scrollbar: { 15933 init: Scrollbar.init.bind(swiper), 15934 destroy: Scrollbar.destroy.bind(swiper), 15935 updateSize: Scrollbar.updateSize.bind(swiper), 15936 setTranslate: Scrollbar.setTranslate.bind(swiper), 15937 setTransition: Scrollbar.setTransition.bind(swiper), 15938 enableDraggable: Scrollbar.enableDraggable.bind(swiper), 15939 disableDraggable: Scrollbar.disableDraggable.bind(swiper), 15940 setDragPosition: Scrollbar.setDragPosition.bind(swiper), 15941
vendor: 24,595 bytes, lines 15941-16583
15941onDragStart: Scrollbar.onDragStart.bind(swiper), 15942 onDragMove: Scrollbar.onDragMove.bind(swiper), 15943 onDragEnd: Scrollbar.onDragEnd.bind(swiper), 15944 isTouched: false, 15945 timeout: null, 15946 dragTimeout: null, 15947 }, 15948 }); 15949 }, 15950 on: { 15951 init: function init() { 15952 var swiper = this; 15953 swiper.scrollbar.init(); 15954 swiper.scrollbar.updateSize(); 15955 swiper.scrollbar.setTranslate(); 15956 }, 15957 update: function update() { 15958 var swiper = this; 15959 swiper.scrollbar.updateSize(); 15960 }, 15961 resize: function resize() { 15962 var swiper = this; 15963 swiper.scrollbar.updateSize(); 15964 }, 15965 observerUpdate: function observerUpdate() { 15966 var swiper = this; 15967 swiper.scrollbar.updateSize(); 15968 }, 15969 setTranslate: function setTranslate() { 15970 var swiper = this; 15971 swiper.scrollbar.setTranslate(); 15972 }, 15973 setTransition: function setTransition(duration) { 15974 var swiper = this; 15975 swiper.scrollbar.setTransition(duration); 15976 }, 15977 destroy: function destroy() { 15978 var swiper = this; 15979 swiper.scrollbar.destroy(); 15980 }, 15981 }, 15982 }; 15983 15984 var Parallax = { 15985 setTransform: function setTransform(el, progress) { 15986 var swiper = this; 15987 var rtl = swiper.rtl; 15988 15989 var $el = $(el); 15990 var rtlFactor = rtl ? -1 : 1; 15991 15992 var p = $el.attr('data-swiper-parallax') || '0'; 15993 var x = $el.attr('data-swiper-parallax-x'); 15994 var y = $el.attr('data-swiper-parallax-y'); 15995 var scale = $el.attr('data-swiper-parallax-scale'); 15996 var opacity = $el.attr('data-swiper-parallax-opacity'); 15997 15998 if (x || y) { 15999 x = x || '0'; 16000 y = y || '0'; 16001 } else if (swiper.isHorizontal()) { 16002 x = p; 16003 y = '0'; 16004 } else { 16005 y = p; 16006 x = '0'; 16007 } 16008 16009 if ((x).indexOf('%') >= 0) { 16010 x = (parseInt(x, 10) * progress * rtlFactor) + "%"; 16011 } else { 16012 x = (x * progress * rtlFactor) + "px"; 16013 } 16014 if ((y).indexOf('%') >= 0) { 16015 y = (parseInt(y, 10) * progress) + "%"; 16016 } else { 16017 y = (y * progress) + "px"; 16018 } 16019 16020 if (typeof opacity !== 'undefined' && opacity !== null) { 16021 var currentOpacity = opacity - ((opacity - 1) * (1 - Math.abs(progress))); 16022 $el[0].style.opacity = currentOpacity; 16023 } 16024 if (typeof scale === 'undefined' || scale === null) { 16025 $el.transform(("translate3d(" + x + ", " + y + ", 0px)")); 16026 } else { 16027 var currentScale = scale - ((scale - 1) * (1 - Math.abs(progress))); 16028 $el.transform(("translate3d(" + x + ", " + y + ", 0px) scale(" + currentScale + ")")); 16029 } 16030 }, 16031 setTranslate: function setTranslate() { 16032 var swiper = this; 16033 var $el = swiper.$el; 16034 var slides = swiper.slides; 16035 var progress = swiper.progress; 16036 var snapGrid = swiper.snapGrid; 16037 $el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]') 16038 .each(function (index, el) { 16039 swiper.parallax.setTransform(el, progress); 16040 }); 16041 slides.each(function (slideIndex, slideEl) { 16042 var slideProgress = slideEl.progress; 16043 if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') { 16044 slideProgress += Math.ceil(slideIndex / 2) - (progress * (snapGrid.length - 1)); 16045 } 16046 slideProgress = Math.min(Math.max(slideProgress, -1), 1); 16047 $(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]') 16048 .each(function (index, el) { 16049 swiper.parallax.setTransform(el, slideProgress); 16050 }); 16051 }); 16052 }, 16053 setTransition: function setTransition(duration) { 16054 if ( duration === void 0 ) duration = this.params.speed; 16055 16056 var swiper = this; 16057 var $el = swiper.$el; 16058 $el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]') 16059 .each(function (index, parallaxEl) { 16060 var $parallaxEl = $(parallaxEl); 16061 var parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration; 16062 if (duration === 0) { parallaxDuration = 0; } 16063 $parallaxEl.transition(parallaxDuration); 16064 }); 16065 }, 16066 }; 16067 16068 var Parallax$1 = { 16069 name: 'parallax', 16070 params: { 16071 parallax: { 16072 enabled: false, 16073 }, 16074 }, 16075 create: function create() { 16076 var swiper = this; 16077 Utils.extend(swiper, { 16078 parallax: { 16079 setTransform: Parallax.setTransform.bind(swiper), 16080 setTranslate: Parallax.setTranslate.bind(swiper), 16081 setTransition: Parallax.setTransition.bind(swiper), 16082 }, 16083 }); 16084 }, 16085 on: { 16086 beforeInit: function beforeInit() { 16087 var swiper = this; 16088 if (!swiper.params.parallax.enabled) { return; } 16089 swiper.params.watchSlidesProgress = true; 16090 swiper.originalParams.watchSlidesProgress = true; 16091 }, 16092 init: function init() { 16093 var swiper = this; 16094 if (!swiper.params.parallax) { return; } 16095 swiper.parallax.setTranslate(); 16096 }, 16097 setTranslate: function setTranslate() { 16098 var swiper = this; 16099 if (!swiper.params.parallax) { return; } 16100 swiper.parallax.setTranslate(); 16101 }, 16102 setTransition: function setTransition(duration) { 16103 var swiper = this; 16104 if (!swiper.params.parallax) { return; } 16105 swiper.parallax.setTransition(duration); 16106 }, 16107 }, 16108 }; 16109 16110 var Zoom = { 16111 // Calc Scale From Multi-touches 16112 getDistanceBetweenTouches: function getDistanceBetweenTouches(e) { 16113 if (e.targetTouches.length < 2) { return 1; } 16114 var x1 = e.targetTouches[0].pageX; 16115 var y1 = e.targetTouches[0].pageY; 16116 var x2 = e.targetTouches[1].pageX; 16117 var y2 = e.targetTouches[1].pageY; 16118 var distance = Math.sqrt((Math.pow( (x2 - x1), 2 )) + (Math.pow( (y2 - y1), 2 ))); 16119 return distance; 16120 }, 16121 // Events 16122 onGestureStart: function onGestureStart(e) { 16123 var swiper = this; 16124 var params = swiper.params.zoom; 16125 var zoom = swiper.zoom; 16126 var gesture = zoom.gesture; 16127 zoom.fakeGestureTouched = false; 16128 zoom.fakeGestureMoved = false; 16129 if (!Support.gestures) { 16130 if (e.type !== 'touchstart' || (e.type === 'touchstart' && e.targetTouches.length < 2)) { 16131 return; 16132 } 16133 zoom.fakeGestureTouched = true; 16134 gesture.scaleStart = Zoom.getDistanceBetweenTouches(e); 16135 } 16136 if (!gesture.$slideEl || !gesture.$slideEl.length) { 16137 gesture.$slideEl = $(e.target).closest('.swiper-slide'); 16138 if (gesture.$slideEl.length === 0) { gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); } 16139 gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas'); 16140 gesture.$imageWrapEl = gesture.$imageEl.parent(("." + (params.containerClass))); 16141 gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; 16142 if (gesture.$imageWrapEl.length === 0) { 16143 gesture.$imageEl = undefined; 16144 return; 16145 } 16146 } 16147 gesture.$imageEl.transition(0); 16148 swiper.zoom.isScaling = true; 16149 }, 16150 onGestureChange: function onGestureChange(e) { 16151 var swiper = this; 16152 var params = swiper.params.zoom; 16153 var zoom = swiper.zoom; 16154 var gesture = zoom.gesture; 16155 if (!Support.gestures) { 16156 if (e.type !== 'touchmove' || (e.type === 'touchmove' && e.targetTouches.length < 2)) { 16157 return; 16158 } 16159 zoom.fakeGestureMoved = true; 16160 gesture.scaleMove = Zoom.getDistanceBetweenTouches(e); 16161 } 16162 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 16163 if (Support.gestures) { 16164 swiper.zoom.scale = e.scale * zoom.currentScale; 16165 } else { 16166 zoom.scale = (gesture.scaleMove / gesture.scaleStart) * zoom.currentScale; 16167 } 16168 if (zoom.scale > gesture.maxRatio) { 16169 zoom.scale = (gesture.maxRatio - 1) + (Math.pow( ((zoom.scale - gesture.maxRatio) + 1), 0.5 )); 16170 } 16171 if (zoom.scale < params.minRatio) { 16172 zoom.scale = (params.minRatio + 1) - (Math.pow( ((params.minRatio - zoom.scale) + 1), 0.5 )); 16173 } 16174 gesture.$imageEl.transform(("translate3d(0,0,0) scale(" + (zoom.scale) + ")")); 16175 }, 16176 onGestureEnd: function onGestureEnd(e) { 16177 var swiper = this; 16178 var params = swiper.params.zoom; 16179 var zoom = swiper.zoom; 16180 var gesture = zoom.gesture; 16181 if (!Support.gestures) { 16182 if (!zoom.fakeGestureTouched || !zoom.fakeGestureMoved) { 16183 return; 16184 } 16185 if (e.type !== 'touchend' || (e.type === 'touchend' && e.changedTouches.length < 2 && !Device.android)) { 16186 return; 16187 } 16188 zoom.fakeGestureTouched = false; 16189 zoom.fakeGestureMoved = false; 16190 } 16191 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 16192 zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio); 16193 gesture.$imageEl.transition(swiper.params.speed).transform(("translate3d(0,0,0) scale(" + (zoom.scale) + ")")); 16194 zoom.currentScale = zoom.scale; 16195 zoom.isScaling = false; 16196 if (zoom.scale === 1) { gesture.$slideEl = undefined; } 16197 }, 16198 onTouchStart: function onTouchStart(e) { 16199 var swiper = this; 16200 var zoom = swiper.zoom; 16201 var gesture = zoom.gesture; 16202 var image = zoom.image; 16203 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 16204 if (image.isTouched) { return; } 16205 if (Device.android) { e.preventDefault(); } 16206 image.isTouched = true; 16207 image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; 16208 image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; 16209 }, 16210 onTouchMove: function onTouchMove(e) { 16211 var swiper = this; 16212 var zoom = swiper.zoom; 16213 var gesture = zoom.gesture; 16214 var image = zoom.image; 16215 var velocity = zoom.velocity; 16216 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 16217 swiper.allowClick = false; 16218 if (!image.isTouched || !gesture.$slideEl) { return; } 16219 16220 if (!image.isMoved) { 16221 image.width = gesture.$imageEl[0].offsetWidth; 16222 image.height = gesture.$imageEl[0].offsetHeight; 16223 image.startX = Utils.getTranslate(gesture.$imageWrapEl[0], 'x') || 0; 16224 image.startY = Utils.getTranslate(gesture.$imageWrapEl[0], 'y') || 0; 16225 gesture.slideWidth = gesture.$slideEl[0].offsetWidth; 16226 gesture.slideHeight = gesture.$slideEl[0].offsetHeight; 16227 gesture.$imageWrapEl.transition(0); 16228 if (swiper.rtl) { 16229 image.startX = -image.startX; 16230 image.startY = -image.startY; 16231 } 16232 } 16233 // Define if we need image drag 16234 var scaledWidth = image.width * zoom.scale; 16235 var scaledHeight = image.height * zoom.scale; 16236 16237 if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) { return; } 16238 16239 image.minX = Math.min(((gesture.slideWidth / 2) - (scaledWidth / 2)), 0); 16240 image.maxX = -image.minX; 16241 image.minY = Math.min(((gesture.slideHeight / 2) - (scaledHeight / 2)), 0); 16242 image.maxY = -image.minY; 16243 16244 image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; 16245 image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; 16246 16247 if (!image.isMoved && !zoom.isScaling) { 16248 if ( 16249 swiper.isHorizontal() 16250 && ( 16251 (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x) 16252 || (Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x) 16253 ) 16254 ) { 16255 image.isTouched = false; 16256 return; 16257 } if ( 16258 !swiper.isHorizontal() 16259 && ( 16260 (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y) 16261 || (Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y) 16262 ) 16263 ) { 16264 image.isTouched = false; 16265 return; 16266 } 16267 } 16268 e.preventDefault(); 16269 e.stopPropagation(); 16270 16271 image.isMoved = true; 16272 image.currentX = (image.touchesCurrent.x - image.touchesStart.x) + image.startX; 16273 image.currentY = (image.touchesCurrent.y - image.touchesStart.y) + image.startY; 16274 16275 if (image.currentX < image.minX) { 16276 image.currentX = (image.minX + 1) - (Math.pow( ((image.minX - image.currentX) + 1), 0.8 )); 16277 } 16278 if (image.currentX > image.maxX) { 16279 image.currentX = (image.maxX - 1) + (Math.pow( ((image.currentX - image.maxX) + 1), 0.8 )); 16280 } 16281 16282 if (image.currentY < image.minY) { 16283 image.currentY = (image.minY + 1) - (Math.pow( ((image.minY - image.currentY) + 1), 0.8 )); 16284 } 16285 if (image.currentY > image.maxY) { 16286 image.currentY = (image.maxY - 1) + (Math.pow( ((image.currentY - image.maxY) + 1), 0.8 )); 16287 } 16288 16289 // Velocity 16290 if (!velocity.prevPositionX) { velocity.prevPositionX = image.touchesCurrent.x; } 16291 if (!velocity.prevPositionY) { velocity.prevPositionY = image.touchesCurrent.y; } 16292 if (!velocity.prevTime) { velocity.prevTime = Date.now(); } 16293 velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2; 16294 velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2; 16295 if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) { velocity.x = 0; } 16296 if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) { velocity.y = 0; } 16297 velocity.prevPositionX = image.touchesCurrent.x; 16298 velocity.prevPositionY = image.touchesCurrent.y; 16299 velocity.prevTime = Date.now(); 16300 16301 gesture.$imageWrapEl.transform(("translate3d(" + (image.currentX) + "px, " + (image.currentY) + "px,0)")); 16302 }, 16303 onTouchEnd: function onTouchEnd() { 16304 var swiper = this; 16305 var zoom = swiper.zoom; 16306 var gesture = zoom.gesture; 16307 var image = zoom.image; 16308 var velocity = zoom.velocity; 16309 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 16310 if (!image.isTouched || !image.isMoved) { 16311 image.isTouched = false; 16312 image.isMoved = false; 16313 return; 16314 } 16315 image.isTouched = false; 16316 image.isMoved = false; 16317 var momentumDurationX = 300; 16318 var momentumDurationY = 300; 16319 var momentumDistanceX = velocity.x * momentumDurationX; 16320 var newPositionX = image.currentX + momentumDistanceX; 16321 var momentumDistanceY = velocity.y * momentumDurationY; 16322 var newPositionY = image.currentY + momentumDistanceY; 16323 16324 // Fix duration 16325 if (velocity.x !== 0) { momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x); } 16326 if (velocity.y !== 0) { momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y); } 16327 var momentumDuration = Math.max(momentumDurationX, momentumDurationY); 16328 16329 image.currentX = newPositionX; 16330 image.currentY = newPositionY; 16331 16332 // Define if we need image drag 16333 var scaledWidth = image.width * zoom.scale; 16334 var scaledHeight = image.height * zoom.scale; 16335 image.minX = Math.min(((gesture.slideWidth / 2) - (scaledWidth / 2)), 0); 16336 image.maxX = -image.minX; 16337 image.minY = Math.min(((gesture.slideHeight / 2) - (scaledHeight / 2)), 0); 16338 image.maxY = -image.minY; 16339 image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX); 16340 image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY); 16341 16342 gesture.$imageWrapEl.transition(momentumDuration).transform(("translate3d(" + (image.currentX) + "px, " + (image.currentY) + "px,0)")); 16343 }, 16344 onTransitionEnd: function onTransitionEnd() { 16345 var swiper = this; 16346 var zoom = swiper.zoom; 16347 var gesture = zoom.gesture; 16348 if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) { 16349 gesture.$imageEl.transform('translate3d(0,0,0) scale(1)'); 16350 gesture.$imageWrapEl.transform('translate3d(0,0,0)'); 16351 gesture.$slideEl = undefined; 16352 gesture.$imageEl = undefined; 16353 gesture.$imageWrapEl = undefined; 16354 16355 zoom.scale = 1; 16356 zoom.currentScale = 1; 16357 } 16358 }, 16359 // Toggle Zoom 16360 toggle: function toggle(e) { 16361 var swiper = this; 16362 var zoom = swiper.zoom; 16363 16364 if (zoom.scale && zoom.scale !== 1) { 16365 // Zoom Out 16366 zoom.out(); 16367 } else { 16368 // Zoom In 16369 zoom.in(e); 16370 } 16371 }, 16372 in: function in$1(e) { 16373 var swiper = this; 16374 16375 var zoom = swiper.zoom; 16376 var params = swiper.params.zoom; 16377 var gesture = zoom.gesture; 16378 var image = zoom.image; 16379 16380 if (!gesture.$slideEl) { 16381 gesture.$slideEl = swiper.clickedSlide ? $(swiper.clickedSlide) : swiper.slides.eq(swiper.activeIndex); 16382 gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas'); 16383 gesture.$imageWrapEl = gesture.$imageEl.parent(("." + (params.containerClass))); 16384 } 16385 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 16386 16387 gesture.$slideEl.addClass(("" + (params.zoomedSlideClass))); 16388 16389 var touchX; 16390 var touchY; 16391 var offsetX; 16392 var offsetY; 16393 var diffX; 16394 var diffY; 16395 var translateX; 16396 var translateY; 16397 var imageWidth; 16398 var imageHeight; 16399 var scaledWidth; 16400 var scaledHeight; 16401 var translateMinX; 16402 var translateMinY; 16403 var translateMaxX; 16404 var translateMaxY; 16405 var slideWidth; 16406 var slideHeight; 16407 16408 if (typeof image.touchesStart.x === 'undefined' && e) { 16409 touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX; 16410 touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY; 16411 } else { 16412 touchX = image.touchesStart.x; 16413 touchY = image.touchesStart.y; 16414 } 16415 16416 zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; 16417 zoom.currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; 16418 if (e) { 16419 slideWidth = gesture.$slideEl[0].offsetWidth; 16420 slideHeight = gesture.$slideEl[0].offsetHeight; 16421 offsetX = gesture.$slideEl.offset().left; 16422 offsetY = gesture.$slideEl.offset().top; 16423 diffX = (offsetX + (slideWidth / 2)) - touchX; 16424 diffY = (offsetY + (slideHeight / 2)) - touchY; 16425 16426 imageWidth = gesture.$imageEl[0].offsetWidth; 16427 imageHeight = gesture.$imageEl[0].offsetHeight; 16428 scaledWidth = imageWidth * zoom.scale; 16429 scaledHeight = imageHeight * zoom.scale; 16430 16431 translateMinX = Math.min(((slideWidth / 2) - (scaledWidth / 2)), 0); 16432 translateMinY = Math.min(((slideHeight / 2) - (scaledHeight / 2)), 0); 16433 translateMaxX = -translateMinX; 16434 translateMaxY = -translateMinY; 16435 16436 translateX = diffX * zoom.scale; 16437 translateY = diffY * zoom.scale; 16438 16439 if (translateX < translateMinX) { 16440 translateX = translateMinX; 16441 } 16442 if (translateX > translateMaxX) { 16443 translateX = translateMaxX; 16444 } 16445 16446 if (translateY < translateMinY) { 16447 translateY = translateMinY; 16448 } 16449 if (translateY > translateMaxY) { 16450 translateY = translateMaxY; 16451 } 16452 } else { 16453 translateX = 0; 16454 translateY = 0; 16455 } 16456 gesture.$imageWrapEl.transition(300).transform(("translate3d(" + translateX + "px, " + translateY + "px,0)")); 16457 gesture.$imageEl.transition(300).transform(("translate3d(0,0,0) scale(" + (zoom.scale) + ")")); 16458 }, 16459 out: function out() { 16460 var swiper = this; 16461 16462 var zoom = swiper.zoom; 16463 var params = swiper.params.zoom; 16464 var gesture = zoom.gesture; 16465 16466 if (!gesture.$slideEl) { 16467 gesture.$slideEl = swiper.clickedSlide ? $(swiper.clickedSlide) : swiper.slides.eq(swiper.activeIndex); 16468 gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas'); 16469 gesture.$imageWrapEl = gesture.$imageEl.parent(("." + (params.containerClass))); 16470 } 16471 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 16472 16473 zoom.scale = 1; 16474 zoom.currentScale = 1; 16475 gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)'); 16476 gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)'); 16477 gesture.$slideEl.removeClass(("" + (params.zoomedSlideClass))); 16478 gesture.$slideEl = undefined; 16479 }, 16480 // Attach/Detach Events 16481 enable: function enable() { 16482 var swiper = this; 16483 var zoom = swiper.zoom; 16484 if (zoom.enabled) { return; } 16485 zoom.enabled = true; 16486 16487 var passiveListener = swiper.touchEvents.start === 'touchstart' && Support.passiveListener && swiper.params.passiveListeners ? { passive: true, capture: false } : false; 16488 16489 // Scale image 16490 if (Support.gestures) { 16491 swiper.$wrapperEl.on('gesturestart', '.swiper-slide', zoom.onGestureStart, passiveListener); 16492 swiper.$wrapperEl.on('gesturechange', '.swiper-slide', zoom.onGestureChange, passiveListener); 16493 swiper.$wrapperEl.on('gestureend', '.swiper-slide', zoom.onGestureEnd, passiveListener); 16494 } else if (swiper.touchEvents.start === 'touchstart') { 16495 swiper.$wrapperEl.on(swiper.touchEvents.start, '.swiper-slide', zoom.onGestureStart, passiveListener); 16496 swiper.$wrapperEl.on(swiper.touchEvents.move, '.swiper-slide', zoom.onGestureChange, passiveListener); 16497 swiper.$wrapperEl.on(swiper.touchEvents.end, '.swiper-slide', zoom.onGestureEnd, passiveListener); 16498 } 16499 16500 // Move image 16501 swiper.$wrapperEl.on(swiper.touchEvents.move, ("." + (swiper.params.zoom.containerClass)), zoom.onTouchMove); 16502 }, 16503 disable: function disable() { 16504 var swiper = this; 16505 var zoom = swiper.zoom; 16506 if (!zoom.enabled) { return; } 16507 16508 swiper.zoom.enabled = false; 16509 16510 var passiveListener = swiper.touchEvents.start === 'touchstart' && Support.passiveListener && swiper.params.passiveListeners ? { passive: true, capture: false } : false; 16511 16512 // Scale image 16513 if (Support.gestures) { 16514 swiper.$wrapperEl.off('gesturestart', '.swiper-slide', zoom.onGestureStart, passiveListener); 16515 swiper.$wrapperEl.off('gesturechange', '.swiper-slide', zoom.onGestureChange, passiveListener); 16516 swiper.$wrapperEl.off('gestureend', '.swiper-slide', zoom.onGestureEnd, passiveListener); 16517 } else if (swiper.touchEvents.start === 'touchstart') { 16518 swiper.$wrapperEl.off(swiper.touchEvents.start, '.swiper-slide', zoom.onGestureStart, passiveListener); 16519 swiper.$wrapperEl.off(swiper.touchEvents.move, '.swiper-slide', zoom.onGestureChange, passiveListener); 16520 swiper.$wrapperEl.off(swiper.touchEvents.end, '.swiper-slide', zoom.onGestureEnd, passiveListener); 16521 } 16522 16523 // Move image 16524 swiper.$wrapperEl.off(swiper.touchEvents.move, ("." + (swiper.params.zoom.containerClass)), zoom.onTouchMove); 16525 }, 16526 }; 16527 16528 var Zoom$1 = { 16529 name: 'zoom', 16530 params: { 16531 zoom: { 16532 enabled: false, 16533 maxRatio: 3, 16534 minRatio: 1, 16535 toggle: true, 16536 containerClass: 'swiper-zoom-container', 16537 zoomedSlideClass: 'swiper-slide-zoomed', 16538 }, 16539 }, 16540 create: function create() { 16541 var swiper = this; 16542 var zoom = { 16543 enabled: false, 16544 scale: 1, 16545 currentScale: 1, 16546 isScaling: false, 16547 gesture: { 16548 $slideEl: undefined, 16549 slideWidth: undefined, 16550 slideHeight: undefined, 16551 $imageEl: undefined, 16552 $imageWrapEl: undefined, 16553 maxRatio: 3, 16554 }, 16555 image: { 16556 isTouched: undefined, 16557 isMoved: undefined, 16558 currentX: undefined, 16559 currentY: undefined, 16560 minX: undefined, 16561 minY: undefined, 16562 maxX: undefined, 16563 maxY: undefined, 16564 width: undefined, 16565 height: undefined, 16566 startX: undefined, 16567 startY: undefined, 16568 touchesStart: {}, 16569 touchesCurrent: {}, 16570 }, 16571 velocity: { 16572 x: undefined, 16573 y: undefined, 16574 prevPositionX: undefined, 16575 prevPositionY: undefined, 16576 prevTime: undefined, 16577 }, 16578 }; 16579 ('onGestureStart onGestureChange onGestureEnd onTouchStart onTouchMove onTouchEnd onTransitionEnd toggle enable disable in out').split(' ').forEach(function (methodName) { 16580 zoom[methodName] = Zoom[methodName].bind(swiper); 16581 }); 16582 Utils.extend(swiper, { 16583 zoom: zoom
vendor: 24,869 bytes, lines 16583-17273
16583, 16584 }); 16585 }, 16586 on: { 16587 init: function init() { 16588 var swiper = this; 16589 if (swiper.params.zoom.enabled) { 16590 swiper.zoom.enable(); 16591 } 16592 }, 16593 destroy: function destroy() { 16594 var swiper = this; 16595 swiper.zoom.disable(); 16596 }, 16597 touchStart: function touchStart(e) { 16598 var swiper = this; 16599 if (!swiper.zoom.enabled) { return; } 16600 swiper.zoom.onTouchStart(e); 16601 }, 16602 touchEnd: function touchEnd(e) { 16603 var swiper = this; 16604 if (!swiper.zoom.enabled) { return; } 16605 swiper.zoom.onTouchEnd(e); 16606 }, 16607 doubleTap: function doubleTap(e) { 16608 var swiper = this; 16609 if (swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) { 16610 swiper.zoom.toggle(e); 16611 } 16612 }, 16613 transitionEnd: function transitionEnd() { 16614 var swiper = this; 16615 if (swiper.zoom.enabled && swiper.params.zoom.enabled) { 16616 swiper.zoom.onTransitionEnd(); 16617 } 16618 }, 16619 }, 16620 }; 16621 16622 var Lazy = { 16623 loadInSlide: function loadInSlide(index, loadInDuplicate) { 16624 if ( loadInDuplicate === void 0 ) loadInDuplicate = true; 16625 16626 var swiper = this; 16627 var params = swiper.params.lazy; 16628 if (typeof index === 'undefined') { return; } 16629 if (swiper.slides.length === 0) { return; } 16630 var isVirtual = swiper.virtual && swiper.params.virtual.enabled; 16631 16632 var $slideEl = isVirtual 16633 ? swiper.$wrapperEl.children(("." + (swiper.params.slideClass) + "[data-swiper-slide-index=\"" + index + "\"]")) 16634 : swiper.slides.eq(index); 16635 16636 var $images = $slideEl.find(("." + (params.elementClass) + ":not(." + (params.loadedClass) + "):not(." + (params.loadingClass) + ")")); 16637 if ($slideEl.hasClass(params.elementClass) && !$slideEl.hasClass(params.loadedClass) && !$slideEl.hasClass(params.loadingClass)) { 16638 $images = $images.add($slideEl[0]); 16639 } 16640 if ($images.length === 0) { return; } 16641 16642 $images.each(function (imageIndex, imageEl) { 16643 var $imageEl = $(imageEl); 16644 $imageEl.addClass(params.loadingClass); 16645 16646 var background = $imageEl.attr('data-background'); 16647 var src = $imageEl.attr('data-src'); 16648 var srcset = $imageEl.attr('data-srcset'); 16649 var sizes = $imageEl.attr('data-sizes'); 16650 16651 swiper.loadImage($imageEl[0], (src || background), srcset, sizes, false, function () { 16652 if (typeof swiper === 'undefined' || swiper === null || !swiper || (swiper && !swiper.params) || swiper.destroyed) { return; } 16653 if (background) { 16654 $imageEl.css('background-image', ("url(\"" + background + "\")")); 16655 $imageEl.removeAttr('data-background'); 16656 } else { 16657 if (srcset) { 16658 $imageEl.attr('srcset', srcset); 16659 $imageEl.removeAttr('data-srcset'); 16660 } 16661 if (sizes) { 16662 $imageEl.attr('sizes', sizes); 16663 $imageEl.removeAttr('data-sizes'); 16664 } 16665 if (src) { 16666 $imageEl.attr('src', src); 16667 $imageEl.removeAttr('data-src'); 16668 } 16669 } 16670 16671 $imageEl.addClass(params.loadedClass).removeClass(params.loadingClass); 16672 $slideEl.find(("." + (params.preloaderClass))).remove(); 16673 if (swiper.params.loop && loadInDuplicate) { 16674 var slideOriginalIndex = $slideEl.attr('data-swiper-slide-index'); 16675 if ($slideEl.hasClass(swiper.params.slideDuplicateClass)) { 16676 var originalSlide = swiper.$wrapperEl.children(("[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]:not(." + (swiper.params.slideDuplicateClass) + ")")); 16677 swiper.lazy.loadInSlide(originalSlide.index(), false); 16678 } else { 16679 var duplicatedSlide = swiper.$wrapperEl.children(("." + (swiper.params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]")); 16680 swiper.lazy.loadInSlide(duplicatedSlide.index(), false); 16681 } 16682 } 16683 swiper.emit('lazyImageReady', $slideEl[0], $imageEl[0]); 16684 }); 16685 16686 swiper.emit('lazyImageLoad', $slideEl[0], $imageEl[0]); 16687 }); 16688 }, 16689 load: function load() { 16690 var swiper = this; 16691 var $wrapperEl = swiper.$wrapperEl; 16692 var swiperParams = swiper.params; 16693 var slides = swiper.slides; 16694 var activeIndex = swiper.activeIndex; 16695 var isVirtual = swiper.virtual && swiperParams.virtual.enabled; 16696 var params = swiperParams.lazy; 16697 16698 var slidesPerView = swiperParams.slidesPerView; 16699 if (slidesPerView === 'auto') { 16700 slidesPerView = 0; 16701 } 16702 16703 function slideExist(index) { 16704 if (isVirtual) { 16705 if ($wrapperEl.children(("." + (swiperParams.slideClass) + "[data-swiper-slide-index=\"" + index + "\"]")).length) { 16706 return true; 16707 } 16708 } else if (slides[index]) { return true; } 16709 return false; 16710 } 16711 function slideIndex(slideEl) { 16712 if (isVirtual) { 16713 return $(slideEl).attr('data-swiper-slide-index'); 16714 } 16715 return $(slideEl).index(); 16716 } 16717 16718 if (!swiper.lazy.initialImageLoaded) { swiper.lazy.initialImageLoaded = true; } 16719 if (swiper.params.watchSlidesVisibility) { 16720 $wrapperEl.children(("." + (swiperParams.slideVisibleClass))).each(function (elIndex, slideEl) { 16721 var index = isVirtual ? $(slideEl).attr('data-swiper-slide-index') : $(slideEl).index(); 16722 swiper.lazy.loadInSlide(index); 16723 }); 16724 } else if (slidesPerView > 1) { 16725 for (var i = activeIndex; i < activeIndex + slidesPerView; i += 1) { 16726 if (slideExist(i)) { swiper.lazy.loadInSlide(i); } 16727 } 16728 } else { 16729 swiper.lazy.loadInSlide(activeIndex); 16730 } 16731 if (params.loadPrevNext) { 16732 if (slidesPerView > 1 || (params.loadPrevNextAmount && params.loadPrevNextAmount > 1)) { 16733 var amount = params.loadPrevNextAmount; 16734 var spv = slidesPerView; 16735 var maxIndex = Math.min(activeIndex + spv + Math.max(amount, spv), slides.length); 16736 var minIndex = Math.max(activeIndex - Math.max(spv, amount), 0); 16737 // Next Slides 16738 for (var i$1 = activeIndex + slidesPerView; i$1 < maxIndex; i$1 += 1) { 16739 if (slideExist(i$1)) { swiper.lazy.loadInSlide(i$1); } 16740 } 16741 // Prev Slides 16742 for (var i$2 = minIndex; i$2 < activeIndex; i$2 += 1) { 16743 if (slideExist(i$2)) { swiper.lazy.loadInSlide(i$2); } 16744 } 16745 } else { 16746 var nextSlide = $wrapperEl.children(("." + (swiperParams.slideNextClass))); 16747 if (nextSlide.length > 0) { swiper.lazy.loadInSlide(slideIndex(nextSlide)); } 16748 16749 var prevSlide = $wrapperEl.children(("." + (swiperParams.slidePrevClass))); 16750 if (prevSlide.length > 0) { swiper.lazy.loadInSlide(slideIndex(prevSlide)); } 16751 } 16752 } 16753 }, 16754 }; 16755 16756 var Lazy$1 = { 16757 name: 'lazy', 16758 params: { 16759 lazy: { 16760 enabled: false, 16761 loadPrevNext: false, 16762 loadPrevNextAmount: 1, 16763 loadOnTransitionStart: false, 16764 16765 elementClass: 'swiper-lazy', 16766 loadingClass: 'swiper-lazy-loading', 16767 loadedClass: 'swiper-lazy-loaded', 16768 preloaderClass: 'swiper-lazy-preloader', 16769 }, 16770 }, 16771 create: function create() { 16772 var swiper = this; 16773 Utils.extend(swiper, { 16774 lazy: { 16775 initialImageLoaded: false, 16776 load: Lazy.load.bind(swiper), 16777 loadInSlide: Lazy.loadInSlide.bind(swiper), 16778 }, 16779 }); 16780 }, 16781 on: { 16782 beforeInit: function beforeInit() { 16783 var swiper = this; 16784 if (swiper.params.lazy.enabled && swiper.params.preloadImages) { 16785 swiper.params.preloadImages = false; 16786 } 16787 }, 16788 init: function init() { 16789 var swiper = this; 16790 if (swiper.params.lazy.enabled && !swiper.params.loop && swiper.params.initialSlide === 0) { 16791 swiper.lazy.load(); 16792 } 16793 }, 16794 scroll: function scroll() { 16795 var swiper = this; 16796 if (swiper.params.freeMode && !swiper.params.freeModeSticky) { 16797 swiper.lazy.load(); 16798 } 16799 }, 16800 resize: function resize() { 16801 var swiper = this; 16802 if (swiper.params.lazy.enabled) { 16803 swiper.lazy.load(); 16804 } 16805 }, 16806 scrollbarDragMove: function scrollbarDragMove() { 16807 var swiper = this; 16808 if (swiper.params.lazy.enabled) { 16809 swiper.lazy.load(); 16810 } 16811 }, 16812 transitionStart: function transitionStart() { 16813 var swiper = this; 16814 if (swiper.params.lazy.enabled) { 16815 if (swiper.params.lazy.loadOnTransitionStart || (!swiper.params.lazy.loadOnTransitionStart && !swiper.lazy.initialImageLoaded)) { 16816 swiper.lazy.load(); 16817 } 16818 } 16819 }, 16820 transitionEnd: function transitionEnd() { 16821 var swiper = this; 16822 if (swiper.params.lazy.enabled && !swiper.params.lazy.loadOnTransitionStart) { 16823 swiper.lazy.load(); 16824 } 16825 }, 16826 }, 16827 }; 16828 16829 /* eslint no-bitwise: ["error", { "allow": [">>"] }] */ 16830 16831 var Controller = { 16832 LinearSpline: function LinearSpline(x, y) { 16833 var binarySearch = (function search() { 16834 var maxIndex; 16835 var minIndex; 16836 var guess; 16837 return function (array, val) { 16838 minIndex = -1; 16839 maxIndex = array.length; 16840 while (maxIndex - minIndex > 1) { 16841 guess = maxIndex + minIndex >> 1; 16842 if (array[guess] <= val) { 16843 minIndex = guess; 16844 } else { 16845 maxIndex = guess; 16846 } 16847 } 16848 return maxIndex; 16849 }; 16850 }()); 16851 this.x = x; 16852 this.y = y; 16853 this.lastIndex = x.length - 1; 16854 // Given an x value (x2), return the expected y2 value: 16855 // (x1,y1) is the known point before given value, 16856 // (x3,y3) is the known point after given value. 16857 var i1; 16858 var i3; 16859 16860 this.interpolate = function interpolate(x2) { 16861 if (!x2) { return 0; } 16862 16863 // Get the indexes of x1 and x3 (the array indexes before and after given x2): 16864 i3 = binarySearch(this.x, x2); 16865 i1 = i3 - 1; 16866 16867 // We have our indexes i1 & i3, so we can calculate already: 16868 // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1 16869 return (((x2 - this.x[i1]) * (this.y[i3] - this.y[i1])) / (this.x[i3] - this.x[i1])) + this.y[i1]; 16870 }; 16871 return this; 16872 }, 16873 // xxx: for now i will just save one spline function to to 16874 getInterpolateFunction: function getInterpolateFunction(c) { 16875 var swiper = this; 16876 if (!swiper.controller.spline) { 16877 swiper.controller.spline = swiper.params.loop 16878 ? new Controller.LinearSpline(swiper.slidesGrid, c.slidesGrid) 16879 : new Controller.LinearSpline(swiper.snapGrid, c.snapGrid); 16880 } 16881 }, 16882 setTranslate: function setTranslate(setTranslate$1, byController) { 16883 var swiper = this; 16884 var controlled = swiper.controller.control; 16885 var multiplier; 16886 var controlledTranslate; 16887 function setControlledTranslate(c) { 16888 // this will create an Interpolate function based on the snapGrids 16889 // x is the Grid of the scrolled scroller and y will be the controlled scroller 16890 // it makes sense to create this only once and recall it for the interpolation 16891 // the function does a lot of value caching for performance 16892 var translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate; 16893 if (swiper.params.controller.by === 'slide') { 16894 swiper.controller.getInterpolateFunction(c); 16895 // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid 16896 // but it did not work out 16897 controlledTranslate = -swiper.controller.spline.interpolate(-translate); 16898 } 16899 16900 if (!controlledTranslate || swiper.params.controller.by === 'container') { 16901 multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate()); 16902 controlledTranslate = ((translate - swiper.minTranslate()) * multiplier) + c.minTranslate(); 16903 } 16904 16905 if (swiper.params.controller.inverse) { 16906 controlledTranslate = c.maxTranslate() - controlledTranslate; 16907 } 16908 c.updateProgress(controlledTranslate); 16909 c.setTranslate(controlledTranslate, swiper); 16910 c.updateActiveIndex(); 16911 c.updateSlidesClasses(); 16912 } 16913 if (Array.isArray(controlled)) { 16914 for (var i = 0; i < controlled.length; i += 1) { 16915 if (controlled[i] !== byController && controlled[i] instanceof Swiper) { 16916 setControlledTranslate(controlled[i]); 16917 } 16918 } 16919 } else if (controlled instanceof Swiper && byController !== controlled) { 16920 setControlledTranslate(controlled); 16921 } 16922 }, 16923 setTransition: function setTransition(duration, byController) { 16924 var swiper = this; 16925 var controlled = swiper.controller.control; 16926 var i; 16927 function setControlledTransition(c) { 16928 c.setTransition(duration, swiper); 16929 if (duration !== 0) { 16930 c.transitionStart(); 16931 if (c.params.autoHeight) { 16932 Utils.nextTick(function () { 16933 c.updateAutoHeight(); 16934 }); 16935 } 16936 c.$wrapperEl.transitionEnd(function () { 16937 if (!controlled) { return; } 16938 if (c.params.loop && swiper.params.controller.by === 'slide') { 16939 c.loopFix(); 16940 } 16941 c.transitionEnd(); 16942 }); 16943 } 16944 } 16945 if (Array.isArray(controlled)) { 16946 for (i = 0; i < controlled.length; i += 1) { 16947 if (controlled[i] !== byController && controlled[i] instanceof Swiper) { 16948 setControlledTransition(controlled[i]); 16949 } 16950 } 16951 } else if (controlled instanceof Swiper && byController !== controlled) { 16952 setControlledTransition(controlled); 16953 } 16954 }, 16955 }; 16956 var Controller$1 = { 16957 name: 'controller', 16958 params: { 16959 controller: { 16960 control: undefined, 16961 inverse: false, 16962 by: 'slide', // or 'container' 16963 }, 16964 }, 16965 create: function create() { 16966 var swiper = this; 16967 Utils.extend(swiper, { 16968 controller: { 16969 control: swiper.params.controller.control, 16970 getInterpolateFunction: Controller.getInterpolateFunction.bind(swiper), 16971 setTranslate: Controller.setTranslate.bind(swiper), 16972 setTransition: Controller.setTransition.bind(swiper), 16973 }, 16974 }); 16975 }, 16976 on: { 16977 update: function update() { 16978 var swiper = this; 16979 if (!swiper.controller.control) { return; } 16980 if (swiper.controller.spline) { 16981 swiper.controller.spline = undefined; 16982 delete swiper.controller.spline; 16983 } 16984 }, 16985 resize: function resize() { 16986 var swiper = this; 16987 if (!swiper.controller.control) { return; } 16988 if (swiper.controller.spline) { 16989 swiper.controller.spline = undefined; 16990 delete swiper.controller.spline; 16991 } 16992 }, 16993 observerUpdate: function observerUpdate() { 16994 var swiper = this; 16995 if (!swiper.controller.control) { return; } 16996 if (swiper.controller.spline) { 16997 swiper.controller.spline = undefined; 16998 delete swiper.controller.spline; 16999 } 17000 }, 17001 setTranslate: function setTranslate(translate, byController) { 17002 var swiper = this; 17003 if (!swiper.controller.control) { return; } 17004 swiper.controller.setTranslate(translate, byController); 17005 }, 17006 setTransition: function setTransition(duration, byController) { 17007 var swiper = this; 17008 if (!swiper.controller.control) { return; } 17009 swiper.controller.setTransition(duration, byController); 17010 }, 17011 }, 17012 }; 17013 17014 var a11y = { 17015 makeElFocusable: function makeElFocusable($el) { 17016 $el.attr('tabIndex', '0'); 17017 return $el; 17018 }, 17019 addElRole: function addElRole($el, role) { 17020 $el.attr('role', role); 17021 return $el; 17022 }, 17023 addElLabel: function addElLabel($el, label) { 17024 $el.attr('aria-label', label); 17025 return $el; 17026 }, 17027 disableEl: function disableEl($el) { 17028 $el.attr('aria-disabled', true); 17029 return $el; 17030 }, 17031 enableEl: function enableEl($el) { 17032 $el.attr('aria-disabled', false); 17033 return $el; 17034 }, 17035 onEnterKey: function onEnterKey(e) { 17036 var swiper = this; 17037 var params = swiper.params.a11y; 17038 if (e.keyCode !== 13) { return; } 17039 var $targetEl = $(e.target); 17040 if (swiper.navigation && swiper.navigation.$nextEl && $targetEl.is(swiper.navigation.$nextEl)) { 17041 if (!(swiper.isEnd && !swiper.params.loop)) { 17042 swiper.slideNext(); 17043 } 17044 if (swiper.isEnd) { 17045 swiper.a11y.notify(params.lastSlideMessage); 17046 } else { 17047 swiper.a11y.notify(params.nextSlideMessage); 17048 } 17049 } 17050 if (swiper.navigation && swiper.navigation.$prevEl && $targetEl.is(swiper.navigation.$prevEl)) { 17051 if (!(swiper.isBeginning && !swiper.params.loop)) { 17052 swiper.slidePrev(); 17053 } 17054 if (swiper.isBeginning) { 17055 swiper.a11y.notify(params.firstSlideMessage); 17056 } else { 17057 swiper.a11y.notify(params.prevSlideMessage); 17058 } 17059 } 17060 if (swiper.pagination && $targetEl.is(("." + (swiper.params.pagination.bulletClass)))) { 17061 $targetEl[0].click(); 17062 } 17063 }, 17064 notify: function notify(message) { 17065 var swiper = this; 17066 var notification = swiper.a11y.liveRegion; 17067 if (notification.length === 0) { return; } 17068 notification.html(''); 17069 notification.html(message); 17070 }, 17071 updateNavigation: function updateNavigation() { 17072 var swiper = this; 17073 17074 if (swiper.params.loop) { return; } 17075 var ref = swiper.navigation; 17076 var $nextEl = ref.$nextEl; 17077 var $prevEl = ref.$prevEl; 17078 17079 if ($prevEl && $prevEl.length > 0) { 17080 if (swiper.isBeginning) { 17081 swiper.a11y.disableEl($prevEl); 17082 } else { 17083 swiper.a11y.enableEl($prevEl); 17084 } 17085 } 17086 if ($nextEl && $nextEl.length > 0) { 17087 if (swiper.isEnd) { 17088 swiper.a11y.disableEl($nextEl); 17089 } else { 17090 swiper.a11y.enableEl($nextEl); 17091 } 17092 } 17093 }, 17094 updatePagination: function updatePagination() { 17095 var swiper = this; 17096 var params = swiper.params.a11y; 17097 if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { 17098 swiper.pagination.bullets.each(function (bulletIndex, bulletEl) { 17099 var $bulletEl = $(bulletEl); 17100 swiper.a11y.makeElFocusable($bulletEl); 17101 swiper.a11y.addElRole($bulletEl, 'button'); 17102 swiper.a11y.addElLabel($bulletEl, params.paginationBulletMessage.replace(/{{index}}/, $bulletEl.index() + 1)); 17103 }); 17104 } 17105 }, 17106 init: function init() { 17107 var swiper = this; 17108 17109 swiper.$el.append(swiper.a11y.liveRegion); 17110 17111 // Navigation 17112 var params = swiper.params.a11y; 17113 var $nextEl; 17114 var $prevEl; 17115 if (swiper.navigation && swiper.navigation.$nextEl) { 17116 $nextEl = swiper.navigation.$nextEl; 17117 } 17118 if (swiper.navigation && swiper.navigation.$prevEl) { 17119 $prevEl = swiper.navigation.$prevEl; 17120 } 17121 if ($nextEl) { 17122 swiper.a11y.makeElFocusable($nextEl); 17123 swiper.a11y.addElRole($nextEl, 'button'); 17124 swiper.a11y.addElLabel($nextEl, params.nextSlideMessage); 17125 $nextEl.on('keydown', swiper.a11y.onEnterKey); 17126 } 17127 if ($prevEl) { 17128 swiper.a11y.makeElFocusable($prevEl); 17129 swiper.a11y.addElRole($prevEl, 'button'); 17130 swiper.a11y.addElLabel($prevEl, params.prevSlideMessage); 17131 $prevEl.on('keydown', swiper.a11y.onEnterKey); 17132 } 17133 17134 // Pagination 17135 if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { 17136 swiper.pagination.$el.on('keydown', ("." + (swiper.params.pagination.bulletClass)), swiper.a11y.onEnterKey); 17137 } 17138 }, 17139 destroy: function destroy() { 17140 var swiper = this; 17141 if (swiper.a11y.liveRegion && swiper.a11y.liveRegion.length > 0) { swiper.a11y.liveRegion.remove(); } 17142 17143 var $nextEl; 17144 var $prevEl; 17145 if (swiper.navigation && swiper.navigation.$nextEl) { 17146 $nextEl = swiper.navigation.$nextEl; 17147 } 17148 if (swiper.navigation && swiper.navigation.$prevEl) { 17149 $prevEl = swiper.navigation.$prevEl; 17150 } 17151 if ($nextEl) { 17152 $nextEl.off('keydown', swiper.a11y.onEnterKey); 17153 } 17154 if ($prevEl) { 17155 $prevEl.off('keydown', swiper.a11y.onEnterKey); 17156 } 17157 17158 // Pagination 17159 if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { 17160 swiper.pagination.$el.off('keydown', ("." + (swiper.params.pagination.bulletClass)), swiper.a11y.onEnterKey); 17161 } 17162 }, 17163 }; 17164 var A11y = { 17165 name: 'a11y', 17166 params: { 17167 a11y: { 17168 enabled: true, 17169 notificationClass: 'swiper-notification', 17170 prevSlideMessage: 'Previous slide', 17171 nextSlideMessage: 'Next slide', 17172 firstSlideMessage: 'This is the first slide', 17173 lastSlideMessage: 'This is the last slide', 17174 paginationBulletMessage: 'Go to slide {{index}}', 17175 }, 17176 }, 17177 create: function create() { 17178 var swiper = this; 17179 Utils.extend(swiper, { 17180 a11y: { 17181 liveRegion: $(("<span class=\"" + (swiper.params.a11y.notificationClass) + "\" aria-live=\"assertive\" aria-atomic=\"true\"></span>")), 17182 }, 17183 }); 17184 Object.keys(a11y).forEach(function (methodName) { 17185 swiper.a11y[methodName] = a11y[methodName].bind(swiper); 17186 }); 17187 }, 17188 on: { 17189 init: function init() { 17190 var swiper = this; 17191 if (!swiper.params.a11y.enabled) { return; } 17192 swiper.a11y.init(); 17193 swiper.a11y.updateNavigation(); 17194 }, 17195 toEdge: function toEdge() { 17196 var swiper = this; 17197 if (!swiper.params.a11y.enabled) { return; } 17198 swiper.a11y.updateNavigation(); 17199 }, 17200 fromEdge: function fromEdge() { 17201 var swiper = this; 17202 if (!swiper.params.a11y.enabled) { return; } 17203 swiper.a11y.updateNavigation(); 17204 }, 17205 paginationUpdate: function paginationUpdate() { 17206 var swiper = this; 17207 if (!swiper.params.a11y.enabled) { return; } 17208 swiper.a11y.updatePagination(); 17209 }, 17210 destroy: function destroy() { 17211 var swiper = this; 17212 if (!swiper.params.a11y.enabled) { return; } 17213 swiper.a11y.destroy(); 17214 }, 17215 }, 17216 }; 17217 17218 var History = { 17219 init: function init() { 17220 var swiper = this; 17221 if (!swiper.params.history) { return; } 17222 if (!win.history || !win.history.pushState) { 17223 swiper.params.history.enabled = false; 17224 swiper.params.hashNavigation.enabled = true; 17225 return; 17226 } 17227 var history = swiper.history; 17228 history.initialized = true; 17229 history.paths = History.getPathValues(); 17230 if (!history.paths.key && !history.paths.value) { return; } 17231 history.scrollToSlide(0, history.paths.value, swiper.params.runCallbacksOnInit); 17232 if (!swiper.params.history.replaceState) { 17233 win.addEventListener('popstate', swiper.history.setHistoryPopState); 17234 } 17235 }, 17236 destroy: function destroy() { 17237 var swiper = this; 17238 if (!swiper.params.history.replaceState) { 17239 win.removeEventListener('popstate', swiper.history.setHistoryPopState); 17240 } 17241 }, 17242 setHistoryPopState: function setHistoryPopState() { 17243 var swiper = this; 17244 swiper.history.paths = History.getPathValues(); 17245 swiper.history.scrollToSlide(swiper.params.speed, swiper.history.paths.value, false); 17246 }, 17247 getPathValues: function getPathValues() { 17248 var pathArray = win.location.pathname.slice(1).split('/').filter(function (part) { return part !== ''; }); 17249 var total = pathArray.length; 17250 var key = pathArray[total - 2]; 17251 var value = pathArray[total - 1]; 17252 return { key: key, value: value }; 17253 }, 17254 setHistory: function setHistory(key, index) { 17255 var swiper = this; 17256 if (!swiper.history.initialized || !swiper.params.history.enabled) { return; } 17257 var slide = swiper.slides.eq(index); 17258 var value = History.slugify(slide.attr('data-history')); 17259 if (!win.location.pathname.includes(key)) { 17260 value = key + "/" + value; 17261 } 17262 var currentState = win.history.state; 17263 if (currentState && currentState.value === value) { 17264 return; 17265 } 17266 if (swiper.params.history.replaceState) { 17267 win.history.replaceState({ value: value }, null, value); 17268 } else { 17269 win.history.pushState({ value: value }, null, value); 17270 } 17271 }, 17272 slugify: function slugify(text) { 17273 return text.toString()
17273.toLowerCase
vendor: 34,669 bytes, lines 17273-18180
17273() 17274 .replace(/\s+/g, '-') 17275 .replace(/[^\w-]+/g, '') 17276 .replace(/--+/g, '-') 17277 .replace(/^-+/, '') 17278 .replace(/-+$/, ''); 17279 }, 17280 scrollToSlide: function scrollToSlide(speed, value, runCallbacks) { 17281 var swiper = this; 17282 if (value) { 17283 for (var i = 0, length = swiper.slides.length; i < length; i += 1) { 17284 var slide = swiper.slides.eq(i); 17285 var slideHistory = History.slugify(slide.attr('data-history')); 17286 if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) { 17287 var index = slide.index(); 17288 swiper.slideTo(index, speed, runCallbacks); 17289 } 17290 } 17291 } else { 17292 swiper.slideTo(0, speed, runCallbacks); 17293 } 17294 }, 17295 }; 17296 17297 var History$1 = { 17298 name: 'history', 17299 params: { 17300 history: { 17301 enabled: false, 17302 replaceState: false, 17303 key: 'slides', 17304 }, 17305 }, 17306 create: function create() { 17307 var swiper = this; 17308 Utils.extend(swiper, { 17309 history: { 17310 init: History.init.bind(swiper), 17311 setHistory: History.setHistory.bind(swiper), 17312 setHistoryPopState: History.setHistoryPopState.bind(swiper), 17313 scrollToSlide: History.scrollToSlide.bind(swiper), 17314 destroy: History.destroy.bind(swiper), 17315 }, 17316 }); 17317 }, 17318 on: { 17319 init: function init() { 17320 var swiper = this; 17321 if (swiper.params.history.enabled) { 17322 swiper.history.init(); 17323 } 17324 }, 17325 destroy: function destroy() { 17326 var swiper = this; 17327 if (swiper.params.history.enabled) { 17328 swiper.history.destroy(); 17329 } 17330 }, 17331 transitionEnd: function transitionEnd() { 17332 var swiper = this; 17333 if (swiper.history.initialized) { 17334 swiper.history.setHistory(swiper.params.history.key, swiper.activeIndex); 17335 } 17336 }, 17337 }, 17338 }; 17339 17340 var HashNavigation = { 17341 onHashCange: function onHashCange() { 17342 var swiper = this; 17343 var newHash = doc.location.hash.replace('#', ''); 17344 var activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash'); 17345 if (newHash !== activeSlideHash) { 17346 var newIndex = swiper.$wrapperEl.children(("." + (swiper.params.slideClass) + "[data-hash=\"" + newHash + "\"]")).index(); 17347 if (typeof newIndex === 'undefined') { return; } 17348 swiper.slideTo(newIndex); 17349 } 17350 }, 17351 setHash: function setHash() { 17352 var swiper = this; 17353 if (!swiper.hashNavigation.initialized || !swiper.params.hashNavigation.enabled) { return; } 17354 if (swiper.params.hashNavigation.replaceState && win.history && win.history.replaceState) { 17355 win.history.replaceState(null, null, (("#" + (swiper.slides.eq(swiper.activeIndex).attr('data-hash'))) || '')); 17356 } else { 17357 var slide = swiper.slides.eq(swiper.activeIndex); 17358 var hash = slide.attr('data-hash') || slide.attr('data-history'); 17359 doc.location.hash = hash || ''; 17360 } 17361 }, 17362 init: function init() { 17363 var swiper = this; 17364 if (!swiper.params.hashNavigation.enabled || (swiper.params.history && swiper.params.history.enabled)) { return; } 17365 swiper.hashNavigation.initialized = true; 17366 var hash = doc.location.hash.replace('#', ''); 17367 if (hash) { 17368 var speed = 0; 17369 for (var i = 0, length = swiper.slides.length; i < length; i += 1) { 17370 var slide = swiper.slides.eq(i); 17371 var slideHash = slide.attr('data-hash') || slide.attr('data-history'); 17372 if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) { 17373 var index = slide.index(); 17374 swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true); 17375 } 17376 } 17377 } 17378 if (swiper.params.hashNavigation.watchState) { 17379 $(win).on('hashchange', swiper.hashNavigation.onHashCange); 17380 } 17381 }, 17382 destroy: function destroy() { 17383 var swiper = this; 17384 if (swiper.params.hashNavigation.watchState) { 17385 $(win).off('hashchange', swiper.hashNavigation.onHashCange); 17386 } 17387 }, 17388 }; 17389 var HashNavigation$1 = { 17390 name: 'hash-navigation', 17391 params: { 17392 hashNavigation: { 17393 enabled: false, 17394 replaceState: false, 17395 watchState: false, 17396 }, 17397 }, 17398 create: function create() { 17399 var swiper = this; 17400 Utils.extend(swiper, { 17401 hashNavigation: { 17402 initialized: false, 17403 init: HashNavigation.init.bind(swiper), 17404 destroy: HashNavigation.destroy.bind(swiper), 17405 setHash: HashNavigation.setHash.bind(swiper), 17406 onHashCange: HashNavigation.onHashCange.bind(swiper), 17407 }, 17408 }); 17409 }, 17410 on: { 17411 init: function init() { 17412 var swiper = this; 17413 if (swiper.params.hashNavigation.enabled) { 17414 swiper.hashNavigation.init(); 17415 } 17416 }, 17417 destroy: function destroy() { 17418 var swiper = this; 17419 if (swiper.params.hashNavigation.enabled) { 17420 swiper.hashNavigation.destroy(); 17421 } 17422 }, 17423 transitionEnd: function transitionEnd() { 17424 var swiper = this; 17425 if (swiper.hashNavigation.initialized) { 17426 swiper.hashNavigation.setHash(); 17427 } 17428 }, 17429 }, 17430 }; 17431 17432 /* eslint no-underscore-dangle: "off" */ 17433 17434 var Autoplay = { 17435 run: function run() { 17436 var swiper = this; 17437 var $activeSlideEl = swiper.slides.eq(swiper.activeIndex); 17438 var delay = swiper.params.autoplay.delay; 17439 if ($activeSlideEl.attr('data-swiper-autoplay')) { 17440 delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay; 17441 } 17442 swiper.autoplay.timeout = Utils.nextTick(function () { 17443 if (swiper.params.autoplay.reverseDirection) { 17444 if (swiper.params.loop) { 17445 swiper.loopFix(); 17446 swiper.slidePrev(swiper.params.speed, true, true); 17447 swiper.emit('autoplay'); 17448 } else if (!swiper.isBeginning) { 17449 swiper.slidePrev(swiper.params.speed, true, true); 17450 swiper.emit('autoplay'); 17451 } else if (!swiper.params.autoplay.stopOnLastSlide) { 17452 swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true); 17453 swiper.emit('autoplay'); 17454 } else { 17455 swiper.autoplay.stop(); 17456 } 17457 } else if (swiper.params.loop) { 17458 swiper.loopFix(); 17459 swiper.slideNext(swiper.params.speed, true, true); 17460 swiper.emit('autoplay'); 17461 } else if (!swiper.isEnd) { 17462 swiper.slideNext(swiper.params.speed, true, true); 17463 swiper.emit('autoplay'); 17464 } else if (!swiper.params.autoplay.stopOnLastSlide) { 17465 swiper.slideTo(0, swiper.params.speed, true, true); 17466 swiper.emit('autoplay'); 17467 } else { 17468 swiper.autoplay.stop(); 17469 } 17470 }, delay); 17471 }, 17472 start: function start() { 17473 var swiper = this; 17474 if (typeof swiper.autoplay.timeout !== 'undefined') { return false; } 17475 if (swiper.autoplay.running) { return false; } 17476 swiper.autoplay.running = true; 17477 swiper.emit('autoplayStart'); 17478 swiper.autoplay.run(); 17479 return true; 17480 }, 17481 stop: function stop() { 17482 var swiper = this; 17483 if (!swiper.autoplay.running) { return false; } 17484 if (typeof swiper.autoplay.timeout === 'undefined') { return false; } 17485 17486 if (swiper.autoplay.timeout) { 17487 clearTimeout(swiper.autoplay.timeout); 17488 swiper.autoplay.timeout = undefined; 17489 } 17490 swiper.autoplay.running = false; 17491 swiper.emit('autoplayStop'); 17492 return true; 17493 }, 17494 pause: function pause(speed) { 17495 var swiper = this; 17496 if (!swiper.autoplay.running) { return; } 17497 if (swiper.autoplay.paused) { return; } 17498 if (swiper.autoplay.timeout) { clearTimeout(swiper.autoplay.timeout); } 17499 swiper.autoplay.paused = true; 17500 if (speed === 0 || !swiper.params.autoplay.waitForTransition) { 17501 swiper.autoplay.paused = false; 17502 swiper.autoplay.run(); 17503 } else { 17504 swiper.$wrapperEl[0].addEventListener('transitionend', swiper.autoplay.onTransitionEnd); 17505 swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd); 17506 } 17507 }, 17508 }; 17509 17510 var Autoplay$1 = { 17511 name: 'autoplay', 17512 params: { 17513 autoplay: { 17514 enabled: false, 17515 delay: 3000, 17516 waitForTransition: true, 17517 disableOnInteraction: true, 17518 stopOnLastSlide: false, 17519 reverseDirection: false, 17520 }, 17521 }, 17522 create: function create() { 17523 var swiper = this; 17524 Utils.extend(swiper, { 17525 autoplay: { 17526 running: false, 17527 paused: false, 17528 run: Autoplay.run.bind(swiper), 17529 start: Autoplay.start.bind(swiper), 17530 stop: Autoplay.stop.bind(swiper), 17531 pause: Autoplay.pause.bind(swiper), 17532 onTransitionEnd: function onTransitionEnd(e) { 17533 if (!swiper || swiper.destroyed || !swiper.$wrapperEl) { return; } 17534 if (e.target !== this) { return; } 17535 swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.autoplay.onTransitionEnd); 17536 swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd); 17537 swiper.autoplay.paused = false; 17538 if (!swiper.autoplay.running) { 17539 swiper.autoplay.stop(); 17540 } else { 17541 swiper.autoplay.run(); 17542 } 17543 }, 17544 }, 17545 }); 17546 }, 17547 on: { 17548 init: function init() { 17549 var swiper = this; 17550 if (swiper.params.autoplay.enabled) { 17551 swiper.autoplay.start(); 17552 } 17553 }, 17554 beforeTransitionStart: function beforeTransitionStart(speed, internal) { 17555 var swiper = this; 17556 if (swiper.autoplay.running) { 17557 if (internal || !swiper.params.autoplay.disableOnInteraction) { 17558 swiper.autoplay.pause(speed); 17559 } else { 17560 swiper.autoplay.stop(); 17561 } 17562 } 17563 }, 17564 sliderFirstMove: function sliderFirstMove() { 17565 var swiper = this; 17566 if (swiper.autoplay.running) { 17567 if (swiper.params.autoplay.disableOnInteraction) { 17568 swiper.autoplay.stop(); 17569 } else { 17570 swiper.autoplay.pause(); 17571 } 17572 } 17573 }, 17574 destroy: function destroy() { 17575 var swiper = this; 17576 if (swiper.autoplay.running) { 17577 swiper.autoplay.stop(); 17578 } 17579 }, 17580 }, 17581 }; 17582 17583 var Fade = { 17584 setTranslate: function setTranslate() { 17585 var swiper = this; 17586 var slides = swiper.slides; 17587 for (var i = 0; i < slides.length; i += 1) { 17588 var $slideEl = swiper.slides.eq(i); 17589 var offset = $slideEl[0].swiperSlideOffset; 17590 var tx = -offset; 17591 if (!swiper.params.virtualTranslate) { tx -= swiper.translate; } 17592 var ty = 0; 17593 if (!swiper.isHorizontal()) { 17594 ty = tx; 17595 tx = 0; 17596 } 17597 var slideOpacity = swiper.params.fadeEffect.crossFade 17598 ? Math.max(1 - Math.abs($slideEl[0].progress), 0) 17599 : 1 + Math.min(Math.max($slideEl[0].progress, -1), 0); 17600 $slideEl 17601 .css({ 17602 opacity: slideOpacity, 17603 }) 17604 .transform(("translate3d(" + tx + "px, " + ty + "px, 0px)")); 17605 } 17606 }, 17607 setTransition: function setTransition(duration) { 17608 var swiper = this; 17609 var slides = swiper.slides; 17610 var $wrapperEl = swiper.$wrapperEl; 17611 slides.transition(duration); 17612 if (swiper.params.virtualTranslate && duration !== 0) { 17613 var eventTriggered = false; 17614 slides.transitionEnd(function () { 17615 if (eventTriggered) { return; } 17616 if (!swiper || swiper.destroyed) { return; } 17617 eventTriggered = true; 17618 swiper.animating = false; 17619 var triggerEvents = ['webkitTransitionEnd', 'transitionend']; 17620 for (var i = 0; i < triggerEvents.length; i += 1) { 17621 $wrapperEl.trigger(triggerEvents[i]); 17622 } 17623 }); 17624 } 17625 }, 17626 }; 17627 17628 var EffectFade = { 17629 name: 'effect-fade', 17630 params: { 17631 fadeEffect: { 17632 crossFade: false, 17633 }, 17634 }, 17635 create: function create() { 17636 var swiper = this; 17637 Utils.extend(swiper, { 17638 fadeEffect: { 17639 setTranslate: Fade.setTranslate.bind(swiper), 17640 setTransition: Fade.setTransition.bind(swiper), 17641 }, 17642 }); 17643 }, 17644 on: { 17645 beforeInit: function beforeInit() { 17646 var swiper = this; 17647 if (swiper.params.effect !== 'fade') { return; } 17648 swiper.classNames.push(((swiper.params.containerModifierClass) + "fade")); 17649 var overwriteParams = { 17650 slidesPerView: 1, 17651 slidesPerColumn: 1, 17652 slidesPerGroup: 1, 17653 watchSlidesProgress: true, 17654 spaceBetween: 0, 17655 virtualTranslate: true, 17656 }; 17657 Utils.extend(swiper.params, overwriteParams); 17658 Utils.extend(swiper.originalParams, overwriteParams); 17659 }, 17660 setTranslate: function setTranslate() { 17661 var swiper = this; 17662 if (swiper.params.effect !== 'fade') { return; } 17663 swiper.fadeEffect.setTranslate(); 17664 }, 17665 setTransition: function setTransition(duration) { 17666 var swiper = this; 17667 if (swiper.params.effect !== 'fade') { return; } 17668 swiper.fadeEffect.setTransition(duration); 17669 }, 17670 }, 17671 }; 17672 17673 var Cube = { 17674 setTranslate: function setTranslate() { 17675 var swiper = this; 17676 var $el = swiper.$el; 17677 var $wrapperEl = swiper.$wrapperEl; 17678 var slides = swiper.slides; 17679 var swiperWidth = swiper.width; 17680 var swiperHeight = swiper.height; 17681 var rtl = swiper.rtlTranslate; 17682 var swiperSize = swiper.size; 17683 var params = swiper.params.cubeEffect; 17684 var isHorizontal = swiper.isHorizontal(); 17685 var isVirtual = swiper.virtual && swiper.params.virtual.enabled; 17686 var wrapperRotate = 0; 17687 var $cubeShadowEl; 17688 if (params.shadow) { 17689 if (isHorizontal) { 17690 $cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow'); 17691 if ($cubeShadowEl.length === 0) { 17692 $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>'); 17693 $wrapperEl.append($cubeShadowEl); 17694 } 17695 $cubeShadowEl.css({ height: (swiperWidth + "px") }); 17696 } else { 17697 $cubeShadowEl = $el.find('.swiper-cube-shadow'); 17698 if ($cubeShadowEl.length === 0) { 17699 $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>'); 17700 $el.append($cubeShadowEl); 17701 } 17702 } 17703 } 17704 for (var i = 0; i < slides.length; i += 1) { 17705 var $slideEl = slides.eq(i); 17706 var slideIndex = i; 17707 if (isVirtual) { 17708 slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10); 17709 } 17710 var slideAngle = slideIndex * 90; 17711 var round = Math.floor(slideAngle / 360); 17712 if (rtl) { 17713 slideAngle = -slideAngle; 17714 round = Math.floor(-slideAngle / 360); 17715 } 17716 var progress = Math.max(Math.min($slideEl[0].progress, 1), -1); 17717 var tx = 0; 17718 var ty = 0; 17719 var tz = 0; 17720 if (slideIndex % 4 === 0) { 17721 tx = -round * 4 * swiperSize; 17722 tz = 0; 17723 } else if ((slideIndex - 1) % 4 === 0) { 17724 tx = 0; 17725 tz = -round * 4 * swiperSize; 17726 } else if ((slideIndex - 2) % 4 === 0) { 17727 tx = swiperSize + (round * 4 * swiperSize); 17728 tz = swiperSize; 17729 } else if ((slideIndex - 3) % 4 === 0) { 17730 tx = -swiperSize; 17731 tz = (3 * swiperSize) + (swiperSize * 4 * round); 17732 } 17733 if (rtl) { 17734 tx = -tx; 17735 } 17736 17737 if (!isHorizontal) { 17738 ty = tx; 17739 tx = 0; 17740 } 17741 17742 var transform = "rotateX(" + (isHorizontal ? 0 : -slideAngle) + "deg) rotateY(" + (isHorizontal ? slideAngle : 0) + "deg) translate3d(" + tx + "px, " + ty + "px, " + tz + "px)"; 17743 if (progress <= 1 && progress > -1) { 17744 wrapperRotate = (slideIndex * 90) + (progress * 90); 17745 if (rtl) { wrapperRotate = (-slideIndex * 90) - (progress * 90); } 17746 } 17747 $slideEl.transform(transform); 17748 if (params.slideShadows) { 17749 // Set shadows 17750 var shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); 17751 var shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); 17752 if (shadowBefore.length === 0) { 17753 shadowBefore = $(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>")); 17754 $slideEl.append(shadowBefore); 17755 } 17756 if (shadowAfter.length === 0) { 17757 shadowAfter = $(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>")); 17758 $slideEl.append(shadowAfter); 17759 } 17760 if (shadowBefore.length) { shadowBefore[0].style.opacity = Math.max(-progress, 0); } 17761 if (shadowAfter.length) { shadowAfter[0].style.opacity = Math.max(progress, 0); } 17762 } 17763 } 17764 $wrapperEl.css({ 17765 '-webkit-transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"), 17766 '-moz-transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"), 17767 '-ms-transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"), 17768 'transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"), 17769 }); 17770 17771 if (params.shadow) { 17772 if (isHorizontal) { 17773 $cubeShadowEl.transform(("translate3d(0px, " + ((swiperWidth / 2) + params.shadowOffset) + "px, " + (-swiperWidth / 2) + "px) rotateX(90deg) rotateZ(0deg) scale(" + (params.shadowScale) + ")")); 17774 } else { 17775 var shadowAngle = Math.abs(wrapperRotate) - (Math.floor(Math.abs(wrapperRotate) / 90) * 90); 17776 var multiplier = 1.5 - ( 17777 (Math.sin((shadowAngle * 2 * Math.PI) / 360) / 2) 17778 + (Math.cos((shadowAngle * 2 * Math.PI) / 360) / 2) 17779 ); 17780 var scale1 = params.shadowScale; 17781 var scale2 = params.shadowScale / multiplier; 17782 var offset = params.shadowOffset; 17783 $cubeShadowEl.transform(("scale3d(" + scale1 + ", 1, " + scale2 + ") translate3d(0px, " + ((swiperHeight / 2) + offset) + "px, " + (-swiperHeight / 2 / scale2) + "px) rotateX(-90deg)")); 17784 } 17785 } 17786 var zFactor = (Browser.isSafari || Browser.isUiWebView) ? (-swiperSize / 2) : 0; 17787 $wrapperEl 17788 .transform(("translate3d(0px,0," + zFactor + "px) rotateX(" + (swiper.isHorizontal() ? 0 : wrapperRotate) + "deg) rotateY(" + (swiper.isHorizontal() ? -wrapperRotate : 0) + "deg)")); 17789 }, 17790 setTransition: function setTransition(duration) { 17791 var swiper = this; 17792 var $el = swiper.$el; 17793 var slides = swiper.slides; 17794 slides 17795 .transition(duration) 17796 .find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left') 17797 .transition(duration); 17798 if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) { 17799 $el.find('.swiper-cube-shadow').transition(duration); 17800 } 17801 }, 17802 }; 17803 17804 var EffectCube = { 17805 name: 'effect-cube', 17806 params: { 17807 cubeEffect: { 17808 slideShadows: true, 17809 shadow: true, 17810 shadowOffset: 20, 17811 shadowScale: 0.94, 17812 }, 17813 }, 17814 create: function create() { 17815 var swiper = this; 17816 Utils.extend(swiper, { 17817 cubeEffect: { 17818 setTranslate: Cube.setTranslate.bind(swiper), 17819 setTransition: Cube.setTransition.bind(swiper), 17820 }, 17821 }); 17822 }, 17823 on: { 17824 beforeInit: function beforeInit() { 17825 var swiper = this; 17826 if (swiper.params.effect !== 'cube') { return; } 17827 swiper.classNames.push(((swiper.params.containerModifierClass) + "cube")); 17828 swiper.classNames.push(((swiper.params.containerModifierClass) + "3d")); 17829 var overwriteParams = { 17830 slidesPerView: 1, 17831 slidesPerColumn: 1, 17832 slidesPerGroup: 1, 17833 watchSlidesProgress: true, 17834 resistanceRatio: 0, 17835 spaceBetween: 0, 17836 centeredSlides: false, 17837 virtualTranslate: true, 17838 }; 17839 Utils.extend(swiper.params, overwriteParams); 17840 Utils.extend(swiper.originalParams, overwriteParams); 17841 }, 17842 setTranslate: function setTranslate() { 17843 var swiper = this; 17844 if (swiper.params.effect !== 'cube') { return; } 17845 swiper.cubeEffect.setTranslate(); 17846 }, 17847 setTransition: function setTransition(duration) { 17848 var swiper = this; 17849 if (swiper.params.effect !== 'cube') { return; } 17850 swiper.cubeEffect.setTransition(duration); 17851 }, 17852 }, 17853 }; 17854 17855 var Flip = { 17856 setTranslate: function setTranslate() { 17857 var swiper = this; 17858 var slides = swiper.slides; 17859 var rtl = swiper.rtlTranslate; 17860 for (var i = 0; i < slides.length; i += 1) { 17861 var $slideEl = slides.eq(i); 17862 var progress = $slideEl[0].progress; 17863 if (swiper.params.flipEffect.limitRotation) { 17864 progress = Math.max(Math.min($slideEl[0].progress, 1), -1); 17865 } 17866 var offset = $slideEl[0].swiperSlideOffset; 17867 var rotate = -180 * progress; 17868 var rotateY = rotate; 17869 var rotateX = 0; 17870 var tx = -offset; 17871 var ty = 0; 17872 if (!swiper.isHorizontal()) { 17873 ty = tx; 17874 tx = 0; 17875 rotateX = -rotateY; 17876 rotateY = 0; 17877 } else if (rtl) { 17878 rotateY = -rotateY; 17879 } 17880 17881 $slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length; 17882 17883 if (swiper.params.flipEffect.slideShadows) { 17884 // Set shadows 17885 var shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); 17886 var shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); 17887 if (shadowBefore.length === 0) { 17888 shadowBefore = $(("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'left' : 'top') + "\"></div>")); 17889 $slideEl.append(shadowBefore); 17890 } 17891 if (shadowAfter.length === 0) { 17892 shadowAfter = $(("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'right' : 'bottom') + "\"></div>")); 17893 $slideEl.append(shadowAfter); 17894 } 17895 if (shadowBefore.length) { shadowBefore[0].style.opacity = Math.max(-progress, 0); } 17896 if (shadowAfter.length) { shadowAfter[0].style.opacity = Math.max(progress, 0); } 17897 } 17898 $slideEl 17899 .transform(("translate3d(" + tx + "px, " + ty + "px, 0px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg)")); 17900 } 17901 }, 17902 setTransition: function setTransition(duration) { 17903 var swiper = this; 17904 var slides = swiper.slides; 17905 var activeIndex = swiper.activeIndex; 17906 var $wrapperEl = swiper.$wrapperEl; 17907 slides 17908 .transition(duration) 17909 .find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left') 17910 .transition(duration); 17911 if (swiper.params.virtualTranslate && duration !== 0) { 17912 var eventTriggered = false; 17913 // eslint-disable-next-line 17914 slides.eq(activeIndex).transitionEnd(function onTransitionEnd() { 17915 if (eventTriggered) { return; } 17916 if (!swiper || swiper.destroyed) { return; } 17917 // if (!$(this).hasClass(swiper.params.slideActiveClass)) return; 17918 eventTriggered = true; 17919 swiper.animating = false; 17920 var triggerEvents = ['webkitTransitionEnd', 'transitionend']; 17921 for (var i = 0; i < triggerEvents.length; i += 1) { 17922 $wrapperEl.trigger(triggerEvents[i]); 17923 } 17924 }); 17925 } 17926 }, 17927 }; 17928 17929 var EffectFlip = { 17930 name: 'effect-flip', 17931 params: { 17932 flipEffect: { 17933 slideShadows: true, 17934 limitRotation: true, 17935 }, 17936 }, 17937 create: function create() { 17938 var swiper = this; 17939 Utils.extend(swiper, { 17940 flipEffect: { 17941 setTranslate: Flip.setTranslate.bind(swiper), 17942 setTransition: Flip.setTransition.bind(swiper), 17943 }, 17944 }); 17945 }, 17946 on: { 17947 beforeInit: function beforeInit() { 17948 var swiper = this; 17949 if (swiper.params.effect !== 'flip') { return; } 17950 swiper.classNames.push(((swiper.params.containerModifierClass) + "flip")); 17951 swiper.classNames.push(((swiper.params.containerModifierClass) + "3d")); 17952 var overwriteParams = { 17953 slidesPerView: 1, 17954 slidesPerColumn: 1, 17955 slidesPerGroup: 1, 17956 watchSlidesProgress: true, 17957 spaceBetween: 0, 17958 virtualTranslate: true, 17959 }; 17960 Utils.extend(swiper.params, overwriteParams); 17961 Utils.extend(swiper.originalParams, overwriteParams); 17962 }, 17963 setTranslate: function setTranslate() { 17964 var swiper = this; 17965 if (swiper.params.effect !== 'flip') { return; } 17966 swiper.flipEffect.setTranslate(); 17967 }, 17968 setTransition: function setTransition(duration) { 17969 var swiper = this; 17970 if (swiper.params.effect !== 'flip') { return; } 17971 swiper.flipEffect.setTransition(duration); 17972 }, 17973 }, 17974 }; 17975 17976 var Coverflow = { 17977 setTranslate: function setTranslate() { 17978 var swiper = this; 17979 var swiperWidth = swiper.width; 17980 var swiperHeight = swiper.height; 17981 var slides = swiper.slides; 17982 var $wrapperEl = swiper.$wrapperEl; 17983 var slidesSizesGrid = swiper.slidesSizesGrid; 17984 var params = swiper.params.coverflowEffect; 17985 var isHorizontal = swiper.isHorizontal(); 17986 var transform = swiper.translate; 17987 var center = isHorizontal ? -transform + (swiperWidth / 2) : -transform + (swiperHeight / 2); 17988 var rotate = isHorizontal ? params.rotate : -params.rotate; 17989 var translate = params.depth; 17990 // Each slide offset from center 17991 for (var i = 0, length = slides.length; i < length; i += 1) { 17992 var $slideEl = slides.eq(i); 17993 var slideSize = slidesSizesGrid[i]; 17994 var slideOffset = $slideEl[0].swiperSlideOffset; 17995 var offsetMultiplier = ((center - slideOffset - (slideSize / 2)) / slideSize) * params.modifier; 17996 17997 var rotateY = isHorizontal ? rotate * offsetMultiplier : 0; 17998 var rotateX = isHorizontal ? 0 : rotate * offsetMultiplier; 17999 // var rotateZ = 0 18000 var translateZ = -translate * Math.abs(offsetMultiplier); 18001 18002 var translateY = isHorizontal ? 0 : params.stretch * (offsetMultiplier); 18003 var translateX = isHorizontal ? params.stretch * (offsetMultiplier) : 0; 18004 18005 // Fix for ultra small values 18006 if (Math.abs(translateX) < 0.001) { translateX = 0; } 18007 if (Math.abs(translateY) < 0.001) { translateY = 0; } 18008 if (Math.abs(translateZ) < 0.001) { translateZ = 0; } 18009 if (Math.abs(rotateY) < 0.001) { rotateY = 0; } 18010 if (Math.abs(rotateX) < 0.001) { rotateX = 0; } 18011 18012 var slideTransform = "translate3d(" + translateX + "px," + translateY + "px," + translateZ + "px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg)"; 18013 18014 $slideEl.transform(slideTransform); 18015 $slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1; 18016 if (params.slideShadows) { 18017 // Set shadows 18018 var $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); 18019 var $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); 18020 if ($shadowBeforeEl.length === 0) { 18021 $shadowBeforeEl = $(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>")); 18022 $slideEl.append($shadowBeforeEl); 18023 } 18024 if ($shadowAfterEl.length === 0) { 18025 $shadowAfterEl = $(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>")); 18026 $slideEl.append($shadowAfterEl); 18027 } 18028 if ($shadowBeforeEl.length) { $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0; } 18029 if ($shadowAfterEl.length) { $shadowAfterEl[0].style.opacity = (-offsetMultiplier) > 0 ? -offsetMultiplier : 0; } 18030 } 18031 } 18032 18033 // Set correct perspective for IE10 18034 if (Support.pointerEvents || Support.prefixedPointerEvents) { 18035 var ws = $wrapperEl[0].style; 18036 ws.perspectiveOrigin = center + "px 50%"; 18037 } 18038 }, 18039 setTransition: function setTransition(duration) { 18040 var swiper = this; 18041 swiper.slides 18042 .transition(duration) 18043 .find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left') 18044 .transition(duration); 18045 }, 18046 }; 18047 18048 var EffectCoverflow = { 18049 name: 'effect-coverflow', 18050 params: { 18051 coverflowEffect: { 18052 rotate: 50, 18053 stretch: 0, 18054 depth: 100, 18055 modifier: 1, 18056 slideShadows: true, 18057 }, 18058 }, 18059 create: function create() { 18060 var swiper = this; 18061 Utils.extend(swiper, { 18062 coverflowEffect: { 18063 setTranslate: Coverflow.setTranslate.bind(swiper), 18064 setTransition: Coverflow.setTransition.bind(swiper), 18065 }, 18066 }); 18067 }, 18068 on: { 18069 beforeInit: function beforeInit() { 18070 var swiper = this; 18071 if (swiper.params.effect !== 'coverflow') { return; } 18072 18073 swiper.classNames.push(((swiper.params.containerModifierClass) + "coverflow")); 18074 swiper.classNames.push(((swiper.params.containerModifierClass) + "3d")); 18075 18076 swiper.params.watchSlidesProgress = true; 18077 swiper.originalParams.watchSlidesProgress = true; 18078 }, 18079 setTranslate: function setTranslate() { 18080 var swiper = this; 18081 if (swiper.params.effect !== 'coverflow') { return; } 18082 swiper.coverflowEffect.setTranslate(); 18083 }, 18084 setTransition: function setTransition(duration) { 18085 var swiper = this; 18086 if (swiper.params.effect !== 'coverflow') { return; } 18087 swiper.coverflowEffect.setTransition(duration); 18088 }, 18089 }, 18090 }; 18091 18092 var Thumbs = { 18093 init: function init() { 18094 var swiper = this; 18095 var ref = swiper.params; 18096 var thumbsParams = ref.thumbs; 18097 var SwiperClass = swiper.constructor; 18098 if (thumbsParams.swiper instanceof SwiperClass) { 18099 swiper.thumbs.swiper = thumbsParams.swiper; 18100 Utils.extend(swiper.thumbs.swiper.originalParams, { 18101 watchSlidesProgress: true, 18102 slideToClickedSlide: false, 18103 }); 18104 Utils.extend(swiper.thumbs.swiper.params, { 18105 watchSlidesProgress: true, 18106 slideToClickedSlide: false, 18107 }); 18108 } else if (Utils.isObject(thumbsParams.swiper)) { 18109 swiper.thumbs.swiper = new SwiperClass(Utils.extend({}, thumbsParams.swiper, { 18110 watchSlidesVisibility: true, 18111 watchSlidesProgress: true, 18112 slideToClickedSlide: false, 18113 })); 18114 swiper.thumbs.swiperCreated = true; 18115 } 18116 swiper.thumbs.swiper.$el.addClass(swiper.params.thumbs.thumbsContainerClass); 18117 swiper.thumbs.swiper.on('tap', swiper.thumbs.onThumbClick); 18118 }, 18119 onThumbClick: function onThumbClick() { 18120 var swiper = this; 18121 var thumbsSwiper = swiper.thumbs.swiper; 18122 if (!thumbsSwiper) { return; } 18123 var clickedIndex = thumbsSwiper.clickedIndex; 18124 var clickedSlide = thumbsSwiper.clickedSlide; 18125 if (clickedSlide && $(clickedSlide).hasClass(swiper.params.thumbs.slideThumbActiveClass)) { return; } 18126 if (typeof clickedIndex === 'undefined' || clickedIndex === null) { return; } 18127 var slideToIndex; 18128 if (thumbsSwiper.params.loop) { 18129 slideToIndex = parseInt($(thumbsSwiper.clickedSlide).attr('data-swiper-slide-index'), 10); 18130 } else { 18131 slideToIndex = clickedIndex; 18132 } 18133 if (swiper.params.loop) { 18134 var currentIndex = swiper.activeIndex; 18135 if (swiper.slides.eq(currentIndex).hasClass(swiper.params.slideDuplicateClass)) { 18136 swiper.loopFix(); 18137 // eslint-disable-next-line 18138 swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; 18139 currentIndex = swiper.activeIndex; 18140 } 18141 var prevIndex = swiper.slides.eq(currentIndex).prevAll(("[data-swiper-slide-index=\"" + slideToIndex + "\"]")).eq(0).index(); 18142 var nextIndex = swiper.slides.eq(currentIndex).nextAll(("[data-swiper-slide-index=\"" + slideToIndex + "\"]")).eq(0).index(); 18143 if (typeof prevIndex === 'undefined') { slideToIndex = nextIndex; } 18144 else if (typeof nextIndex === 'undefined') { slideToIndex = prevIndex; } 18145 else if (nextIndex - currentIndex < currentIndex - prevIndex) { slideToIndex = nextIndex; } 18146 else { slideToIndex = prevIndex; } 18147 } 18148 swiper.slideTo(slideToIndex); 18149 }, 18150 update: function update(initial) { 18151 var swiper = this; 18152 var thumbsSwiper = swiper.thumbs.swiper; 18153 if (!thumbsSwiper) { return; } 18154 18155 var slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' 18156 ? thumbsSwiper.slidesPerViewDynamic() 18157 : thumbsSwiper.params.slidesPerView; 18158 18159 if (swiper.realIndex !== thumbsSwiper.realIndex) { 18160 var currentThumbsIndex = thumbsSwiper.activeIndex; 18161 var newThumbsIndex; 18162 if (thumbsSwiper.params.loop) { 18163 if (thumbsSwiper.slides.eq(currentThumbsIndex).hasClass(thumbsSwiper.params.slideDuplicateClass)) { 18164 thumbsSwiper.loopFix(); 18165 // eslint-disable-next-line 18166 thumbsSwiper._clientLeft = thumbsSwiper.$wrapperEl[0].clientLeft; 18167 currentThumbsIndex = thumbsSwiper.activeIndex; 18168 } 18169 // Find actual thumbs index to slide to 18170 var prevThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).prevAll(("[data-swiper-slide-index=\"" + (swiper.realIndex) + "\"]")).eq(0).index(); 18171 var nextThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).nextAll(("[data-swiper-slide-index=\"" + (swiper.realIndex) + "\"]")).eq(0).index(); 18172 if (typeof prevThumbsIndex === 'undefined') { newThumbsIndex = nextThumbsIndex; } 18173 else if (typeof nextThumbsIndex === 'undefined') { newThumbsIndex = prevThumbsIndex; } 18174 else if (nextThumbsIndex - currentThumbsIndex === currentThumbsIndex - prevThumbsIndex) { newThumbsIndex = currentThumbsIndex; } 18175 else if (nextThumbsIndex - currentThumbsIndex < currentThumbsIndex - prevThumbsIndex) { newThumbsIndex = nextThumbsIndex; } 18176 else { newThumbsIndex = prevThumbsIndex; } 18177 } else { 18178 newThumbsIndex = swiper.realIndex; 18179 } 18180 if (thumbsSwiper.visibleSlidesIndexes
vendor: 1,091 bytes, lines 18180-18205
18180.indexOf(newThumbsIndex) < 0) { 18181 if (thumbsSwiper.params.centeredSlides) { 18182 if (newThumbsIndex > currentThumbsIndex) { 18183 newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1; 18184 } else { 18185 newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1; 18186 } 18187 } else if (newThumbsIndex > currentThumbsIndex) { 18188 newThumbsIndex = newThumbsIndex - slidesPerView + 1; 18189 } 18190 thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined); 18191 } 18192 } 18193 18194 // Activate thumbs 18195 var thumbsToActivate = 1; 18196 var thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass; 18197 18198 if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) { 18199 thumbsToActivate = swiper.params.slidesPerView; 18200 } 18201 18202 thumbsSwiper.slides.removeClass(thumbActiveClass); 18203 if (thumbsSwiper.params.loop) { 18204 for (var i = 0; i < thumbsToActivate; i += 1) { 18205 thumbsSwiper.$wrapperEl.children(("[data-swiper-slide-index=\"" + (swiper.realIndex + i
18205) + "\"]")).addClass(thumbActiveClass); 18206 } 18207 } else { 18208 for (var i$1 = 0; i$1 < thumbsToActivate; i$1 += 1) { 18209 thumbsSwiper.slides.eq(swiper.realIndex + i$1).addClass(thumbActiveClass); 18210 } 18211 } 18212 }, 18213 }; 18214 var Thumbs$1 = { 18215 name: 'thumbs', 18216 params: { 18217 thumbs: { 18218 swiper: null, 18219 slideThumbActiveClass: 'swiper-slide-thumb-active', 18220 thumbsContainerClass: 'swiper-container-thumbs', 18221 }, 18222 }, 18223 create: function create() { 18224 var swiper = this; 18225 Utils.extend(swiper, { 18226 thumbs: { 18227 swiper: null, 18228 init: Thumbs.init.bind(swiper), 18229 update: Thumbs.update.bind(swiper), 18230 onThumbClick: Thumbs.onThumbClick.bind(swiper), 18231 }, 18232 }); 18233 }, 18234 on: { 18235 beforeInit: function beforeInit() { 18236 var swiper = this; 18237 var ref = swiper.params; 18238 var thumbs = ref.thumbs; 18239 if (!thumbs || !thumbs.swiper) { return; } 18240 swiper.thumbs.init(); 18241 swiper.thumbs.update(true); 18242 }, 18243 slideChange: function slideChange() { 18244 var swiper = this; 18245 if (!swiper.thumbs.swiper) { return; } 18246 swiper.thumbs.update(); 18247 }, 18248 update: function update() { 18249 var swiper = this; 18250 if (!swiper.thumbs.swiper) { return; } 18251 swiper.thumbs.update(); 18252 }, 18253 resize: function resize() { 18254 var swiper = this; 18255 if (!swiper.thumbs.swiper) { return; } 18256 swiper.thumbs.update(); 18257 }, 18258 observerUpdate: function observerUpdate() { 18259 var swiper = this; 18260 if (!swiper.thumbs.swiper) { return; } 18261 swiper.thumbs.update(); 18262 }, 18263 setTransition: function setTransition(duration) { 18264 var swiper = this; 18265 var thumbsSwiper = swiper.thumbs.swiper; 18266 if (!thumbsSwiper) { return; } 18267 thumbsSwiper.setTransition(duration); 18268 }, 18269 beforeDestroy: function beforeDestroy() { 18270 var swiper = this; 18271 var thumbsSwiper = swiper.thumbs.swiper; 18272 if (!thumbsSwiper) { return; } 18273 if (swiper.thumbs.swiperCreated && thumbsSwiper) { 18274 thumbsSwiper.destroy(); 18275 } 18276 }, 18277 }, 18278 }; 18279 18280 // Swiper Class 18281 18282 var components = [ 18283 Device$1, 18284 Support$1, 18285 Browser$1, 18286 Resize, 18287 Observer$1, 18288 Virtual$1, 18289 Keyboard$1, 18290 Mousewheel$1, 18291 Navigation$1, 18292 Pagination$1, 18293 Scrollbar$1, 18294 Parallax$1, 18295 Zoom$1, 18296 Lazy$1, 18297 Controller$1, 18298 A11y, 18299 History$1, 18300 HashNavigation$1, 18301 Autoplay$1, 18302 EffectFade, 18303 EffectCube, 18304 EffectFlip, 18305 EffectCoverflow, 18306 Thumbs$1 18307 ]; 18308 18309 if (typeof Swiper.use === 'undefined') { 18310 Swiper.use = Swiper.Class.use; 18311 Swiper.installModule = Swiper.Class.installModule; 18312 } 18313 18314 Swiper.use(components); 18315 18316 return Swiper; 18317 18318}))); 18319 18320!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Scrollbar=n():t.Scrollbar=n()}(this,function(){return function(t){function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var e={};return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=56)}([function(t,n,e){var r=e(39)("wks"),o=e(16),i=e(2).Symbol,u="function"==typeof i;(t.exports=function(t){return r[t]||(r[t]=u&&i[t]||(u?i:o)("Symbol."+t))}).store=r},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)},function(t,n){var e={}.hasOwnProperty;t.exports=function(t,n){return e.call(t,n)}},function(t,n){var e=t.exports={version:"2.5.1"};"number"==typeof __e&&(__e=e)},function(t,n,e){var r=e(2),o=e(4),i=e(11),u=e(6),c=e(10),s=function(t,n,e){var a,f,l,p,h=t&s.F,d=t&s.G,v=t&s.S,y=t&s.P,m=t&s.B,g=d?r:v?r[n]||(r[n]={}):(r[n]||{}).prototype,b=d?o:o[n]||(o[n]={}),x=b.prototype||(b.prototype={});d&&(e=n);for(a in e)f=!h&&g&&void 0!==g[a],l=(f?g:e)[a],p=m&&f?c(l,r):y&&"function"==typeof l?c(Function.call,l):l,g&&u(g,a,l,t&s.U),b[a]!=l&&i(b,a,p),y&&x[a]!=l&&(x[a]=l)};r.core=o,s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,t.exports=s},function(t,n,e){var r=e(2),o=e(11),i=e(3),u=e(16)("src"),c=Function.toString,s=(""+c).split("toString");e(4).inspectSource=function(t){return c.call(t)},(t.exports=function(t,n,e,c){var a="function"==typeof e;a&&(i(e,"name")||o(e,"name",n)),t[n]!==e&&(a&&(i(e,u)||o(e,u,t[n]?""+t[n]:s.join(String(n)))),t===r?t[
vendor: 2,438 bytes, line 18320
18320n]=e:c?t[n]?t[n]=e:o(t,n,e):(delete t[n],o(t,n,e)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[u]||c.call(this)})},function(t,n,e){var r=e(8),o=e(40),i=e(42),u=Object.defineProperty;n.f=e(9)?Object.defineProperty:function(t,n,e){if(r(t),n=i(n,!0),r(e),o)try{return u(t,n,e)}catch(t){}if("get"in e||"set"in e)throw TypeError("Accessors not supported!");return"value"in e&&(t[n]=e.value),t}},function(t,n,e){var r=e(1);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},function(t,n,e){t.exports=!e(12)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n,e){var r=e(43);t.exports=function(t,n,e){if(r(t),void 0===n)return t;switch(e){case 1:return function(e){return t.call(n,e)};case 2:return function(e,r){return t.call(n,e,r)};case 3:return function(e,r,o){return t.call(n,e,r,o)}}return function(){return t.apply(n,arguments)}}},function(t,n,e){var r=e(7),o=e(17);t.exports=e(9)?function(t,n,e){return r.f(t,n,o(1,e))}:function(t,n,e){return t[n]=e,t}},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n){t.exports={}},function(t,n,e){var r=e(10),o=e(48),i=e(49),u=e(8),c=e(19),s=e(50),a={},f={},n=t.exports=function(t,n,e,l,p){var h,d,v,y,m=p?function(){return t}:s(t),g=r(e,l,n?2:1),b=0;if("function"!=typeof m)throw TypeError(t+" is not iterable!");if(i(m)){for(h=c(t.length);h>b;b++)if((y=n?g(u(d=t[b])[0],d[1]):g(t[b]))===a||y===f)return y}else for(v=m.call(t);!(d=v.next()).done;)if((y=o(v,g,d.value,n))===a||y===f)return y};n.BREAK=a,n.RETURN=f},function(t,n,e){var r=e(1);t.exports=function(t,n){if(!r(t)||t._t!==n)throw TypeError("Incompatible receiver, "+n+" required!");return t}},function(t,n){var e=0,r=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++e+r).toString(36))}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n,e){var r=e(30),o=e(27);t.exports=function(t){return r(o(t))}},function(t,n,e){var r=e(26),o=Math.min;t.exports=function(t){return t>0?o(r(t),9007199254740991):0}},function(t,n,e){var r=e(27);t.exports=function(t){return Object(r(t))}},function(t,n,e){var r=e(16)("meta"),o=e(1),i=e(3),u=e(7).f,c=0,s=Object.isExtensible||function(){return!0},a=!e(12)(function(){return s(Object.preventExtensions({}))}),f=function(t){u(t,r,{value:{i:"O"+ ++c,w:{}}
vendor: 6,750 bytes, line 18320
18320})},l=function(t,n){if(!o(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!i(t,r)){if(!s(t))return"F";if(!n)return"E";f(t)}return t[r].i},p=function(t,n){if(!i(t,r)){if(!s(t))return!0;if(!n)return!1;f(t)}return t[r].w},h=function(t){return a&&d.NEED&&s(t)&&!i(t,r)&&f(t),t},d=t.exports={KEY:r,NEED:!1,fastKey:l,getWeak:p,onFreeze:h}},function(t,n,e){"use strict";var r=e(23),o={};o[e(0)("toStringTag")]="z",o+""!="[object z]"&&e(6)(Object.prototype,"toString",function(){return"[object "+r(this)+"]"},!0)},function(t,n,e){var r=e(24),o=e(0)("toStringTag"),i="Arguments"==r(function(){return arguments}()),u=function(t,n){try{return t[n]}catch(t){}};t.exports=function(t){var n,e,c;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=u(n=Object(t),o))?e:i?r(n):"Object"==(c=r(n))&&"function"==typeof n.callee?"Arguments":c}},function(t,n){var e={}.toString;t.exports=function(t){return e.call(t).slice(8,-1)}},function(t,n,e){"use strict";var r=e(59)(!0);e(28)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,n=this._t,e=this._i;return e>=n.length?{value:void 0,done:!0}:(t=r(n,e),this._i+=t.length,{value:t,done:!1})})},function(t,n){var e=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?r:e)(t)}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,n,e){"use strict";var r=e(60),o=e(5),i=e(6),u=e(11),c=e(3),s=e(13),a=e(61),f=e(32),l=e(67),p=e(0)("iterator"),h=!([].keys&&"next"in[].keys()),d=function(){return this};t.exports=function(t,n,e,v,y,m,g){a(e,n,v);var b,x,_,w=function(t){if(!h&&t in T)return T[t];switch(t){case"keys":case"values":return function(){return new e(this,t)}}return function(){return new e(this,t)}},E=n+" Iterator",S="values"==y,O=!1,T=t.prototype,M=T[p]||T["@@iterator"]||y&&T[y],A=M||w(y),P=y?S?w("entries"):A:void 0,j="Array"==n?T.entries||M:M;if(j&&(_=l(j.call(new t)))!==Object.prototype&&_.next&&(f(_,E,!0),r||c(_,p)||u(_,p,d)),S&&M&&"values"!==M.name&&(O=!0,A=function(){return M.call(this)}),r&&!g||!h&&!O&&T[p]||u(T,p,A),s[n]=A,s[E]=d,y)if(b={values:S?A:w("values"),keys:m?A:w("keys"),entries:P},g)for(x in b)x in T||i(T,x,b[x]);else o(o.P+o.F*(h||O),n,b);return b}},function(t,n,e){var r=e(63),o=e(45);t.exports=Object.keys||function(t){return r(t,o)}},function(t,n,e){var r=e(24);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},function(t,n,e){var r=e(39)("keys"),o=e(16);t.exports=function(t){return r[t]||(r[t]=o(t))}},function(t,n,e){var r=e(7).f,o=e(3),i=e(0)("toStringTag");t.exports=function(t,n,e){t&&!o(t=e?t:t.prototype,i)&&r(t,i,{configurable:!0,value:n})}},function(t,n,e){for(var r=e(68),o=e(29),i=e(6),u=e(2),c=e(11),s=e(13),a=e(0),f=a("iterator"),l=a("toStringTag"),p=s.Array,h={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},d=o(h),v=0;v<d.length;v++){var y,m=d[v],g=h[m],b=u[m],x=b&&b.prototype;if(x&&(x[f]||c(x,f,p),x[l]||c(x,l,m),s[m]=p,g))for(y in r)x[y]||i(x,y,r[y],!0)}},function(t,n,e){var r=e(6);t.exports=function(t,n,e){for(var o in n)r(t,o,n[o],e);return t}},function(t,n){t.exports=function(t,n,e,r){if(!(t instanceof n)||void 0!==r&&r in t)throw TypeError(e+": incorrect invocation!");return t}},function(t,n,e){"use strict";var r=e(2),o=e(5),i=e(6),u=e(34),c=e(21),s=e(14),a=e(35),f=e(1),l=e(12),p=e(51),h=e(32),d=e(72);t.exports=function(t,n,e,v,y,m){var g=r[t],b=g,x=y?"set":"add",_=b&&b.prototype,w={},E=function(t){var n=_[t];i(_,t,"delete"==t?function(t){return!(m&&!f(t))&&n.call(this,0===t?0:t)}:"has"==t?function(t){return!(m&&!f(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return m&&!f(t)?void 0:n.call(this,0===t?0:t)}:"add"==t?function(t){return n.call(this,0===t?0:t),this}:function(t,e){return n.call(this,0===t?0:t,e),this})};if("function"==typeof b&&(m||_.forEach&&!l(function(){(new b).entries().next()}))){var S=new b,O=S[x](m?{}:-0,1)!=S,T=l(function(){S.has(1)}),M=p(function(t){new b(t)}),A=!m&&l(function(){for(var t=new b,n=5;n--;)t[x](n,n);return!t.has(-0)});M||(b=n(function(n,e){a(n,b,t);var r=d(new g,n,b);return void 0!=e&&s(e,y,r[x],r),r}),b.prototype=_,_.constructor=b),(T||A)&&(E("delete"),E("has"),y&&E("get")),(A||O)&&E(x),m&&_.clear&&delete _.clear}else b=v.getConstructor(n,t,y,x),u(b.prototype,e),c.NEED=!0;return h(b,t),w[t]=b,o(o.G+o.W+o.F*(b!=g),w),m||v.setStrong(b,t,y),b}},function(t,n,e){"use strict";var r=e(5);t.exports=function(t){r(r.S,t,{of:function(){for(var t=arguments.length,n=Array(t);t--;)n[t]=arguments[t];return new this(n)}})}},function(t,n,e){"use strict";var r=e(5),o=e(43),i=e(10),u=e(14);t.exports=function(t){r(r.S,t,{from:function(t){var n,e,r,c,s=arguments[1];return o(this),n=void 0!==s,n&&o(s),void 0==t?new this:(e=[],n?(r=0,c=i(s,arguments[2],2),u(t,!1,function(t){e.push(c(t,r++))})):u(t,!1,e.push,e),new this(e))}})}},function(t,n,e){var r=e(2),o=r["__core-js_shared__"]||(r["__core-js_shared__"]={});t.exports=function(t){return o[t]||(o[t]={})}},function(t,n,e){t.exports=!e(9)&&!e(12)(function(){return 7!=Object.defineProperty(e(41)("div"),"a",{get:function(){return 7}}).a})},function(t,n,e){var r=e(1),o=e(2).document,i=r(o)&&r(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,n,e){var r=e(1);t.exports=function(t,n){if(!r(t))return t;var e,o;if(n&&"function"==typeof(e=t.toString)&&!r(o=e.call(t)))return o;if("function"==typeof(e=t.valueOf)&&!r(o=e.call(t)))return o;if(!n&&"function"==typeof(e=t.toString)&&!r(o=e.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,e){var r=e(8),o=e(62),i=e(45),u=e(31)("IE_PROTO"),c=function(){},s=function(){var t,n=e(41)("iframe"),r=i.length;for(n.style.display="none",e(66).appendChild(n),n.src="javascript:",t=n.contentWindow.document,t.open(),t.write("<script>document.F=Object<\/script>"),t.close(),s=t.F;r--;)delete s.prototype[i[r]];return s()};t.exports=Object.create||function(t,n){var e;return null!==t?(c.prototype=r(t),e=new c,c.prototype=null,e[u]=t):e=s(),void 0===n?e:o(e,n)}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleStr
18320ing,toString,valueOf".split(",")},function(t,n){t.exports=function(t,n){return{value:n,done:!!t}}},function(t,n,e){"use strict";var r=e(7).f,o=e(44),i=e(34),u=e(10),c=e(35),s=e(14),a=e(28),f=e(46),l=e(71),p=e(9),h=e(21).fastKey,d=e(15),v=p?"_s":"size",y=function(t,n){var e,r=h(n);if("F"!==r)return t._i[r];for(e=t._f;e;e=e.n)if(e.k==n)return e};t.exports={getConstructor:function(t,n,e,a){var f=t(function(t,r){c(t,f,n,"_i"),t._t=n,t._i=o(null),t._f=void 0,t._l=void 0,t[v]=0,void 0!=r&&s(r,e,t[a],t)});return i(f.prototype,{clear:function(){for(var t=d(this,n),e=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete e[r.i];t._f=t._l=void 0,t[v]=0},delete:function(t){var e=d(this,n),r=y(e,t);if(r){var o=r.n,i=r.p;delete e._i[r.i],r.r=!0,i&&(i.n=o),o&&(o.p=i),e._f==r&&(e._f=o),e._l==r&&(e._l=i),e[v]--}return!!r},forEach:function(t){d(this,n);for(var e,r=u(t,arguments.length>1?arguments[1]:void 0,3);e=e?e.n:this._f;)for(r(e.v,e.k,this);e&&e.r;)e=e.p},has:function(t){return!!y(d(this,n),t)}}),p&&r(f.prototype,"size",{get:function(){return d(this,n)[v]}}),f},def:function(t,n,e){var r,o,i=y(t,n);return i?i.v=e:(t._l=i={i:o=h(n,!0),k:n,v:e,p:r=t._l,n:void 0,r:!1},t._f||(t._f=i),r&&(r.n=i),t[v]++,"F"!==o&&(t._i[o]=i)),t},getEntry:y,setStrong:function(t,n,e){a(t,n,function(t,e){this._t=d(t,n),this._k=e,this._l=void 0},function(){for(var t=this,n=t._k,e=t._l;e&&e.r;)e=e.p;return t._t&&(t._l=e=e?e.n:t._t._f)?"keys"==n?f(0,e.k):"values"==n?f(0,e.v):f(0,[e.k,e.v]):(t._t=void 0,f(1))},e?"entries":"values",!e,!0),l(n)}}},function(t,n,e){var r=e(8);t.exports=function(t,n,e,o){try{return o?n(r(e)[0],e[1]):n(e)}catch(n){var i=t.return;throw void 0!==i&&r(i.call(t)),n}}},function(t,n,e){var r=e(13),o=e(0)("iterator"),i=Array.prototype;t.exports=function(t){return void 0!==t&&(r.Array===t||i[o]===t)}},function(t,n,e){var r=e(23),o=e(0)("iterator"),i=e(13);t.exports=e(4).getIteratorMethod=function(t){if(void 0!=t)return t[o]||t["@@iterator"]||i[r(t)]}},function(t,n,e){var r=e(0)("iterator"),o=!1;try{var i=[7][r]();i.return=function(){o=!0},Array.from(i,function(){throw 2})}catch(t){}t.exports=function(t,n){if(!n&&!o)return!1;var e=!1;try{var i=[7],u=i[r]();u.next=function(){return{done:e=!0}},i[r]=function(){return u},t(i)}catch(t){}return e}},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,e){var r=e(23),o=e(76);t.exports=function(t){return function(){if(r(this)!=t)throw TypeError(t+"#toJSON isn't generic");return o(this)}}},function(t,n,e){var r=e(10),o=e(30),i=e(20),u=e(19),c=e(86);
18320t.exports=function(t,n){var e=1==t,s=2==t,a=3==t,f=4==t,l=6==t,p=5==t||l,h=n||c;return function(n,c,d){for(var v,y,m=i(n),g=o(m),b=r(c,d,3),x=u(g.length),_=0,w=e?h(n,x):s?h(n,0):void 0;x>_;_++)if((p||_ in g)&&(v=g[_],y=b(v,_,m),t))if(e)w[_]=y;else if(y)switch(t){case 3:return!0;case 5:return v;case 6:return _;case 2:w.push(v)}else if(f)return!1;return l?-1:a||f?f:w}}},function(t,n,e){"use strict";var r=e(29),o=e(89),i=e(52),u=e(20),c=e(30),s=Object.assign;t.exports=!s||e(12)(function(){var t={},n={},e=Symbol(),r="abcdefghijklmnopqrst";return t[e]=7,r.split("").forEach(function(t){n[t]=t}),7!=s({},t)[e]||Object.keys(s({},n)).join("")!=r})?function(t,n){for(var e=u(t),s=arguments.length,a=1,f=o.f,l=i.f;s>a;)for(var p,h=c(arguments[a++]),d=f?r(h).concat(f(h)):r(h),v=d.length,y=0;v>y;)l.call(h,p=d[y++])&&(e[p]=h[p]);return e}:s},function(t,n,e){t.exports=e(57)},function(t,n,e){"use strict";function r(t,n){function e(){this.constructor=t}K(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function o(t,n,e,r){var o,i=arguments.length,u=i<3?n:null===r?r=Object.getOwnPropertyDescriptor(n,e):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,n,e,r);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(u=(i<3?o(u):i>3?o(n,e,u):o(n,e))||u);return i>3&&u&&Object.defineProperty(n,e,u),u}function i(t,n,e){return t===t&&(void 0!==e&&(t=t<=e?t:e),void 0!==n&&(t=t>=n?t:n)),t}function u(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function c(t){var n=ut.call(t,st),e=t[st];try{t[st]=void 0;var r=!0}catch(t){}var o=ct.call(t);return r&&(n?t[st]=e:delete t[st]),o}function s(t){return lt.call(t)}function a(t){return null==t?void 0===t?dt:ht:vt&&vt in Object(t)?at(t):pt(t)}function f(t){return null!=t&&"object"==typeof t}function l(t){return"symbol"==typeof t||mt(t)&&yt(t)==gt}function p(t){if("number"==typeof t)return t;if(bt(t))return xt;if(Q(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=Q(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(_t,"");var e=Et.test(t);return e||St.test(t)?Ot(t.slice(2),e?2:8):wt.test(t)?xt:+t}function h(t,n,e){return void 0===e&&(e=n,n=void 0),void 0!==e&&(e=Tt(e),e=e===e?e:0),void 0!==n&&(n=Tt(n),n=n===n?n:0),J(Tt(t),n,e)}function d(t,n){return void 0===t&&(t=-1/0),void 0===n&&(n=1/0),function(e,r){var o="_"+r;Object.defineProperty(e,r,{get:function(){return this[o]},set:function(e){Object.defineProperty(this,o,{value:Mt(e,t,n),enumerable:!1,writable:!0,configurable:!0})},enumerable:!0,configurable:!0})}}function v(t,n){var e="_"+n;Object.defineProperty(t,n,{get:function(){return this[e]},set:function(t){Object.defineProperty(this,e,{value:!!t,enumerable:!1,writable:!0,configurable:!0})},enumerable:!0,configurable:!0})}function y(t,n,e){function r(n){var e=p,r=h;return p=h=void 0,g=n,v=t.apply(r,e)}function o(t){return g=t,y=setTimeout(c,n),b?r(t):v}function i(t){var e=t-m,r=t-g,o=n-e;return x?Dt(o,d-r):o}function u(t){var e=t-m,r=t-g;return void 0===m||e>=n||e<0||x&&r>=d}function c(){var t=Pt();if(u(t))return s(t);y=setTimeout(c,i(t))}function s(t){return y=void 0,_&&p?r(t):(p=h=void 0,v)}function a(){void 0!==y&&clearTimeout(y),g=0,p=m=h=y=void 0}function f(){return void 0===y?v:s(Pt())}function l(){var t=Pt(),e=u(t);if(p=arguments,h=this,m=t,e){if(void 0===y)return o(m);if(x)return y=setTimeout(c,n),r(m)}return void 0===y&&(y=setTimeout(c,n)),v}var p,h,d,v,y,m,g=0,b=!1,x=!1,_=!0;if("function"!=typeof t)throw new TypeError(jt);return n=Tt(n)||0,Q(e)&&(b=!!e.leading,x="maxWait"in e,d=x?kt(Tt(e.maxWait)||0,n):d,_="trailing"in e?!!e.trailing:_),l.cancel=a,l.flush=f,l}function m(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return function(n,e,r){var o=r.value;return{get:function(){return this.hasOwnProperty(e)||Object.defineProperty(this,e,{value:Lt.apply(void 0,[o].concat(t))}),this[e]}}}}function g(){if(void 0!==Y)return Y;var t=!1;try{var n=function(){},e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",n,e),window.removeEventListener("testPassive",n,e)}catch(t){}return Y=!!t&&{passive:!1}}function b(t){var n=zt.get(t)||[];return zt.set(t,n),function(t,e,r){function o(t){t.defaultPrevented||r(t)}e.split(/\s+/g).forEach(function(e){n.push({elem:t,eventName:e,handler:o}),t.addEventListener(e,o,g())})}}function x(t){var n=zt.get(t);n&&(n.forEach(function(t){var n=t.elem,e=t.eventName,r=t.handler;n.removeEventListener(e,r,g())}),zt.delete(t))}function _(t){return t.touches?t.touches[t.touches.length-1]:t}function w(t){var n=_(t);return{x:n.clientX,y:n.clientY}}function E(t,n){return void 0===n&&(n=[]),n.some(function(n){return t===n})}function S(t){var n={};return Object.keys(t).forEach(function(e){if(!Rt.test(e))return void(n[e]=t[e]);var r=t[e];
18320e=e.replace(/^-/,""),n[e]=r,Ct.forEach(function(t){n["-"+t+"-"+e]=r})}),n}function O(t,n){n=S(n),Object.keys(n).forEach(function(e){var r=e.replace(/^-/,"").replace(/-([a-z])/g,function(t,n){return n.toUpperCase()});t.style[r]=n[e]})}function T(t){var n=t.containerEl,e=t.contentEl;return{container:{width:n.clientWidth,height:n.clientHeight},content:{width:e.offsetWidth-e.clientWidth+e.scrollWidth,height:e.offsetHeight-e.clientHeight+e.scrollHeight}}}function M(t,n){var e=t.bounding,r=n.getBoundingClientRect(),o=Math.max(e.top,r.top),i=Math.max(e.left,r.left),u=Math.min(e.right,r.right);return o<Math.min(e.bottom,r.bottom)&&i<u}function A(t){var n=t.getSize(),e={x:Math.max(n.content.width-n.container.width,0),y:Math.max(n.content.height-n.container.height,0)},r=t.containerEl.getBoundingClientRect(),o={top:Math.max(r.top,0),right:Math.min(r.right,window.innerWidth),bottom:Math.min(r.bottom,window.innerHeight),left:Math.max(r.left,0)};t.size=n,t.limit=e,t.bounding=o,t.track.update(),t.setPosition()}function P(t,n,e){var r=t.options,o=t.offset,i=t.limit,u=t.track,c=t.contentEl;return r.renderByPixels&&(n=Math.round(n),e=Math.round(e)),n=Mt(n,0,i.x),e=Mt(e,0,i.y),n!==o.x&&u.xAxis.show(),e!==o.y&&u.yAxis.show(),r.alwaysShowTracks||u.autoHideOnIdle(),n===o.x&&e===o.y?null:(o.x=n,o.y=e,O(c,{"-transform":"translate3d("+-n+"px, "+-e+"px, 0)"}),u.update(),{offset:$({},o),limit:$({},i)})}function j(t,n,e,r,o){function i(){var n=Date.now()-g,e=r?s(Math.min(n/r,1)):1;if(t.setPosition(d+y*e,v+m*e),n>=r)"function"==typeof f&&f.call(t);else{var o=requestAnimationFrame(i);Vt.set(t,o)}}void 0===r&&(r=0);var u=void 0===o?{}:o,c=u.easing,s=void 0===c?k:c,a=u.callback,f=void 0===a?null:a,l=t.options,p=t.offset,h=t.limit;l.renderByPixels&&(n=Math.round(n),e=Math.round(e));var d=p.x,v=p.y,y=Mt(n,0,h.x)-d,m=Mt(e,0,h.y)-v,g=Date.now();cancelAnimationFrame(Vt.get(t)),i()}function k(t){return Math.pow(t-1,3)+1}function D(t,n,e){var r=void 0===e?{}:e,o=r.alignToTop,i=void 0===o||o,u=r.onlyScrollIfNeeded,c=void 0!==u&&u,s=r.offsetTop,a=void 0===s?0:s,f=r.offsetLeft,l=void 0===f?0:f,p=r.offsetBottom,h=void 0===p?0:p,d=t.containerEl,v=t.bounding,y=t.offset,m=t.limit;if(n&&d.contains(n)){var g=n.getBoundingClientRect();if(!c||!t.isVisible(n)){var b=i?g.top-v.top-a:g.bottom-v.bottom+h;t.setMomentum(g.left-v.left-l,Mt(b,-y.y,m.y-y.y))}}}function L(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t.forEach(function(t){var n=t.pluginName;if(!n)throw new TypeError("plugin name is required");Xt.order.add(n),Xt.constructors[n]=t})}function N(t,n){return Array.from(Xt.order).filter(function(t){return!1!==n[t]}).map(function(e){var r=Xt.constructors[e],o=new r(t,n[e]);return n[e]=o.options,o})}function z(t){var n=b(t),e=t.containerEl;n(e,"keydown",function(n){if(document.activeElement===e){var r=C(t,n.keyCode||n.which);if(r){var o=r[0],i=r[1];t.addTransformableMomentum(o,i,n,function(e){e?n.preventDefault():(t.containerEl.blur(),t.parent&&t.parent.containerEl.focus())})}}})}function C(t,n){var e=t.size,r=t.limit,o=t.offset;switch(n){case Wt.SPACE:return[0,200];case Wt.PAGE_UP:return[0,40-e.container.height];case Wt.PAGE_DOWN:return[0,e.container.height-40];case Wt.END:return[0,r.y-o.y];case Wt.HOME:return[0,-o.y];case Wt.LEFT:return[-40,0];case Wt.UP:return[0,-40];case Wt.RIGHT:return[40,0];case Wt.DOWN:return[0,40];default:return null}}function R(t){function n(n,e){var r=t.size;if(n===Yt.X){return e/(r.container.width+(l.thumb.realSize-l.thumb.displaySize))*r.content.width}if(n===Yt.Y){return e/(r.container.height+(p.thumb.realSize-p.thumb.displaySize))*r.content.height}return 0}function e(t){return E(t,[l.element,l.thumb.element])?Yt.X:E(t,[p.element,p.thumb.element])?Yt.Y:void 0}var r,o,i,u,c,s=b(t),a=t.containerEl,f=t.track,l=f.xAxis,p=f.yAxis;s(a,"click",function(r){if(!o&&E(r.target,[l.element,p.element])){var i=r.target,u=e(i),c=i.getBoundingClientRect(),s=w(r),a=t.offset,f=t.limit;if(u===Yt.X){var h=s.x-c.left-l.thumb.displaySize/2;t.setMomentum(Mt(n(u,h)-a.x,-a.x,f.x-a.x),0)}if(u===Yt.Y){var h=s.y-c.top-p.thumb.displaySize/2;t.setMomentum(0,Mt(n(u,h)-a.y,-a.y,f.y-a.y))}}}),s(a,"mousedown",function(n){if(E(n.target,[l.thumb.element,p.thumb.element])){r=!0;var o=n.target,s=w(n),f=o.getBoundingClientRect();u=e(o),i={x:s.x-f.left,y:s.y-f.top},c=a.getBoundingClientRect(),O(t.containerEl,{"-user-select":"none"})}}),s(window,"mousemove",function(e){if(r){o=!0;var s=t.offset,a=w(e);if(u===Yt.X){var f=a.x-i.x-c.left;t.setPosition(n(u,f),s.y)}if(u===Yt.Y){var f=a.y-i.y-c.top;t.setPosition(s.x,n(u,f))}}}),s(window,"mouseup blur",function(){r=o=!1,O(t.containerEl,{"-user-select":""})})}function F(t){b(t)(window,"resize",Lt(t.update.bind(t),300))}function I(t){function n(r){var o=r.x,i=r.y;(o||i)&&(t.setMomentum(Mt(u.x+o,0,c.x)-u.x,Mt(u.y+i,0,c.y)-u.y),e=requestAnimationFrame(function(){n({x:o,y:i})}))}var e,r=b(t),o=t.containerEl,i=t.contentEl,u=t.offset,c=t.limit,s=!1;r(window,"mousemove",function(r){if(s){cancelAnimationFrame(e);n(W(t,r))}}),r(i,"selectstart",function(t){t.stopPropagation(),cancelAnimationFrame(e),s=!0}),r(window,"mouseup blur",function(){cancelAnimationFrame(e),s=!1}),r(o,"scroll",function(t){t.preventDefault(),o.scrollTop=o.scrollLeft=0})}function W(t,n){var e=t.bounding,r=e.top,o=e.right,i=e.bottom,u=e.left,c=w(n),s=c.x,a=c.y,f={x:0,y:0};return 0===s&&0===a?f:(s>o-20?f.x=s-o+20:s<u+20&&(f.x=s-u-20),a>i-20?f.y=a-i+20:a<r+20&&(f.y=a-r-20),f.x*=2,f.y*=2,f)}function H(t){var n,e=/Android/.test(navigator.userAgent)?3:2,r=t.options.delegateTo||t.containerEl,o=new It,i=b(t),u=0;i(r,"touchstart",function(e){o.track(e),t.setMomentum(0,0),0===u&&(n=t.options.damping,t.options.damping=Math.max(n,.5)),u++}),i(r,"touchmove",function(n){if(!qt||qt===t){o.update(n);var e=o.getDelta(),r=e.x,i=e.y;t.addTransformableMomentum(r,i,n,function(e){e&&(n.preventDefault(),qt=t)})}}),i(r,"touchcancel touchend",function(r){var i=o.getVelocity(),c={x:0,y:0};
18320Object.keys(i).forEach(function(t){var r=i[t]/n;c[t]=Math.abs(r)<50?0:r*e}),t.addTransformableMomentum(c.x,c.y,r),u--,0===u&&(t.options.damping=n),o.release(r),qt=null})}function B(t){b(t)(t.options.delegateTo||t.containerEl,"onwheel"in window||document.implementation.hasFeature("Events.wheel","3.0")?"wheel":"mousewheel",function(n){var e=G(n),r=e.x,o=e.y;t.addTransformableMomentum(r,o,n,function(t){t&&n.preventDefault()})})}function G(t){if("deltaX"in t){var n=Jt(t.deltaMode);return{x:t.deltaX/Kt.STANDARD*n,y:t.deltaY/Kt.STANDARD*n}}return"wheelDeltaX"in t?{x:t.wheelDeltaX/Kt.OTHERS,y:t.wheelDeltaY/Kt.OTHERS}:{x:0,y:t.wheelDelta/Kt.OTHERS}}function V(){if(!en&&"undefined"!=typeof window){var t=document.createElement("style");t.id=nn,t.textContent=tn,document.head.appendChild(t),en=!0}}function U(){if(en&&"undefined"!=typeof window){var t=document.getElementById(nn);t&&t.parentNode&&(t.parentNode.removeChild(t),en=!1)}}Object.defineProperty(n,"__esModule",{value:!0});var X={};e.d(X,"keyboardHandler",function(){return z}),e.d(X,"mouseHandler",function(){return R}),e.d(X,"resizeHandler",function(){return F}),e.d(X,"selectHandler",function(){return I}),e.d(X,"touchHandler",function(){return H}),e.d(X,"wheelHandler",function(){return B});var Y,q,K=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])},$=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},J=(e(58),e(79),e(84),e(93),e(96),i),Q=u,Z=e(98),tt="object"==typeof self&&self&&self.Object===Object&&self,nt=Z.a||tt||Function("return this")(),et=nt,rt=et.Symbol,ot=rt,it=Object.prototype,ut=it.hasOwnProperty,ct=it.toString,st=ot?ot.toStringTag:void 0,at=c,ft=Object.prototype,lt=ft.toString,pt=s,ht="[object Null]",dt="[object Undefined]",vt=ot?ot.toStringTag:void 0,yt=a,mt=f,gt="[object Symbol]",bt=l,xt=NaN,_t=/^\s+|\s+$/g,wt=/^[-+]0x[0-9a-f]+$/i,Et=/^0b[01]+$/i,St=/^0o[0-7]+$/i,Ot=parseInt,Tt=p,Mt=h,At=function(){return et.Date.now()},Pt=At,jt="Expected a function",kt=Math.max,Dt=Math.min,Lt=y,Nt=function(){function t(t){void 0===t&&(t={});var n=this;this.damping=.1,this.thumbMinSize=20,this.renderByPixels=!0,this.alwaysShowTracks=!1,this.continuousScrolling=!0,this.delegateTo=null,this.plugins={},Object.keys(t).forEach(function(e){n[e]=t[e]})}return Object.defineProperty(t.prototype,"wheelEventTarget",{get:function(){return this.delegateTo},set:function(t){console.warn("[smooth-scrollbar]: `options.wheelEventTarget` is deprecated and will be removed in the future, use `options.delegateTo` instead."),this.delegateTo=t},enumerable:!0,configurable:!0}),o([d(0,1)],t.prototype,"damping",void 0),o([d(0,1/0)],t.prototype,"thumbMinSize",void 0),o([v],t.prototype,"renderByPixels",void 0),o([v],t.prototype,"alwaysShowTracks",void 0),o([v],t.prototype,"continuousScrolling",void 0),t}(),zt=new WeakMap,Ct=["webkit","moz","ms","o"],Rt=new RegExp("^-(?!(?:"+Ct.join("|")+")-)"),Ft=function(){function t(t){this.updateTime=Date.now(),this.delta={x:0,y:0},this.velocity={x:0,y:0},this.lastPosition={x:0,y:0},this.lastPosition=w(t)}return t.prototype.update=function(t){var n=this,e=n.velocity,r=n.updateTime,o=n.lastPosition,i=Date.now(),u=w(t),c={x:-(u.x-o.x),y:-(u.y-o.y)},s=i-r||16,a=c.x/s*16,f=c.y/s*16;e.x=.9*a+.1*e.x,e.y=.9*f+.1*e.y,this.delta=c,this.updateTime=i,this.lastPosition=u},t}(),It=function(){function t(){this._touchList={}}return Object.defineProperty(t.prototype,"_primitiveValue",{get:function(){return{x:0,y:0}},enumerable:!0,configurable:!0}),t.prototype.isActive=function(){return void 0!==this._activeTouchID},t.prototype.getDelta=function(){var t=this._getActiveTracker();return t?$({},t.delta):this._primitiveValue},t.prototype.getVelocity=function(){var t=this._getActiveTracker();return t?$({},t.velocity):this._primitiveValue},t.prototype.track=function(t){var n=this,e=t.targetTouches;return Array.from(e).forEach(function(t){n._add(t)}),this._touchList},t.prototype.update=function(t){var n=this,e=t.touches,r=t.changedTouches;return Array.from(e).forEach(function(t){n._renew(t)}),this._setActiveID(r),this._touchList},t.prototype.release=function(t){var n=this;
18320delete this._activeTouchID,Array.from(t.changedTouches).forEach(function(t){n._delete(t)})},t.prototype._add=function(t){if(!this._has(t)){var n=new Ft(t);this._touchList[t.identifier]=n}},t.prototype._renew=function(t){if(this._has(t)){this._touchList[t.identifier].update(t)}},t.prototype._delete=function(t){delete this._touchList[t.identifier]},t.prototype._has=function(t){return this._touchList.hasOwnProperty(t.identifier)},t.prototype._setActiveID=function(t){this._activeTouchID=t[t.length-1].identifier,this._lastTouch=this._touchList[this._activeTouchID]},t.prototype._getActiveTracker=function(){var t=this;return t._touchList[t._activeTouchID]},t}();!function(t){t.X="x",t.Y="y"}(q||(q={}));var Wt,Ht=function(){function t(t,n){void 0===n&&(n=0),this._direction=t,this._minSize=n,this.element=document.createElement("div"),this.displaySize=0,this.realSize=0,this.offset=0,this.element.className="scrollbar-thumb scrollbar-thumb-"+t}return t.prototype.attachTo=function(t){t.appendChild(this.element)},t.prototype.update=function(t,n,e){this.realSize=Math.min(n/e,1)*n,this.displaySize=Math.max(this.realSize,this._minSize),this.offset=t/e*(n+(this.realSize-this.displaySize)),O(this.element,this._getStyle())},t.prototype._getStyle=function(){switch(this._direction){case q.X:return{width:this.displaySize+"px","-transform":"translate3d("+this.offset+"px, 0, 0)"};case q.Y:return{height:this.displaySize+"px","-transform":"translate3d(0, "+this.offset+"px, 0)"};default:return null}},t}(),Bt=function(){function t(t,n){void 0===n&&(n=0),this.element=document.createElement("div"),this._isShown=!1,this.element.className="scrollbar-track scrollbar-track-"+t,this.thumb=new Ht(t,n),this.thumb.attachTo(this.element)}return t.prototype.attachTo=function(t){t.appendChild(this.element)},t.prototype.show=function(){this._isShown||(this._isShown=!0,this.element.classList.add("show"))},t.prototype.hide=function(){this._isShown&&(this._isShown=!1,this.element.classList.remove("show"))},t.prototype.update=function(t,n,e){O(this.element,{display:e<=n?"none":"block"}),this.thumb.update(t,n,e)},t}(),Gt=function(){function t(t){this._scrollbar=t;var n=t.options.thumbMinSize;this.xAxis=new Bt(q.X,n),this.yAxis=new Bt(q.Y,n),this.xAxis.attachTo(t.containerEl),this.yAxis.attachTo(t.containerEl),t.options.alwaysShowTracks&&(this.xAxis.show(),this.yAxis.show())}return t.prototype.update=function(){var t=this._scrollbar,n=t.size,e=t.offset;this.xAxis.update(e.x,n.container.width,n.content.width),this.yAxis.update(e.y,n.container.height,n.content.height)},t.prototype.autoHideOnIdle=function(){this._scrollbar.options.alwaysShowTracks||(this.xAxis.hide(),this.yAxis.hide())},o([m(300)],t.prototype,"autoHideOnIdle",null),t}(),Vt=new WeakMap,Ut=function(){function t(t,n){var e=this.constructor;this.scrollbar=t,this.name=e.pluginName,this.options=$({},e.defaultOptions,n)}return t.prototype.onInit=function(){},t.prototype.onDestory=function(){},t.prototype.onUpdate=function(){},t.prototype.onRender=function(t){},t.prototype.transformDelta=function(t,n){return $({},t)},t.pluginName="",t.defaultOptions={},t}(),Xt={order:new Set,constructors:{}};!function(t){t[t.SPACE=32]="SPACE",t[t.PAGE_UP=33]="PAGE_UP",t[t.PAGE_DOWN=34]="PAGE_DOWN",t[t.END=35]="END",t[t.HOME=36]="HOME",t[t.LEFT=37]="LEFT",t[t.UP=38]="UP",t[t.RIGHT=39]="RIGHT",t[t.DOWN=40]="DOWN"}(Wt||(Wt={}));var Yt;!function(t){t[t.X=0]="X",t[t.Y=1]="Y"}(Yt||(Yt={}));var qt,Kt={STANDARD:1,OTHERS:-3},$t=[1,28,500],Jt=function(t){return $t[t]||$t[0]},Qt=new Map,Zt=function(){function t(t,n){var e=this;this.offset={x:0,y:0},this.limit={x:1/0,y:1/0},this.bounding={top:0,right:0,bottom:0,left:0},this._plugins=[],this._momentum={x:0,y:0},this._listeners=new Set,this.containerEl=t;var r=this.contentEl=document.createElement("div");this.options=new Nt(n),t.setAttribute("data-scrollbar","true"),t.setAttribute("tabindex","1"),O(t,{overflow:"hidden",outline:"none"}),window.navigator.msPointerEnabled&&(t.style.msTouchAction="none"),r.className="scroll-content",Array.from(t.childNodes).forEach(function(t){r.appendChild(t)}),t.appendChild(r),this.track=new Gt(this),this.size=this.getSize(),this._plugins=N(this,this.options.plugins);var o=t.scrollLeft,i=t.scrollTop;t.scrollLeft=t.scrollTop=0,this.setPosition(o,i,{withoutCallbacks:!0});var u=window,c=u.MutationObserver||u.WebKitMutationObserver||u.MozMutationObserver;"function"==typeof c&&(this._observer=new c(function(){e.update(
18320)}),this._observer.observe(r,{subtree:!0,childList:!0})),Qt.set(t,this),requestAnimationFrame(function(){e._init()})}return Object.defineProperty(t.prototype,"parent",{get:function(){for(var t=this.containerEl.parentElement;t;){var n=Qt.get(t);if(n)return n;t=t.parentElement}return null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scrollTop",{get:function(){return this.offset.y},set:function(t){this.setPosition(this.scrollLeft,t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scrollLeft",{get:function(){return this.offset.x},set:function(t){this.setPosition(t,this.scrollTop)},enumerable:!0,configurable:!0}),t.prototype.getSize=function(){return T(this)},t.prototype.update=function(){A(this),this._plugins.forEach(function(t){t.onUpdate()})},t.prototype.isVisible=function(t){return M(this,t)},t.prototype.setPosition=function(t,n,e){var r=this;void 0===t&&(t=this.offset.x),void 0===n&&(n=this.offset.y),void 0===e&&(e={});var o=P(this,t,n);o&&!e.withoutCallbacks&&this._listeners.forEach(function(t){t.call(r,o)})},t.prototype.scrollTo=function(t,n,e,r){void 0===t&&(t=this.offset.x),void 0===n&&(n=this.offset.y),void 0===e&&(e=0),void 0===r&&(r={}),j(this,t,n,e,r)},t.prototype.scrollIntoView=function(t,n){void 0===n&&(n={}),D(this,t,n)},t.prototype.addListener=function(t){if("function"!=typeof t)throw new TypeError("[smooth-scrollbar] scrolling listener should be a function");this._listeners.add(t)},t.prototype.removeListener=function(t){this._listeners.delete(t)},t.prototype.addTransformableMomentum=function(t,n,e,r){this._updateDebounced();var o=this._plugins.reduce(function(t,n){return n.transformDelta(t,e)||t},{x:t,y:n}),i=!this._shouldPropagateMomentum(o.x,o.y);i&&this.addMomentum(o.x,o.y),r&&r.call(this,i)},t.prototype.addMomentum=function(t,n){this.setMomentum(this._momentum.x+t,this._momentum.y+n)},t.prototype.setMomentum=function(t,n){0===this.limit.x&&(t=0),0===this.limit.y&&(n=0),this.options.renderByPixels&&(t=Math.round(t),n=Math.round(n)),this._momentum.x=t,this._momentum.y=n},t.prototype.updatePluginOptions=function(t,n){this._plugins.forEach(function(e){e.name===t&&Object.assign(e.options,n)})},t.prototype.destroy=function(){var t=this,n=t.containerEl,e=t.contentEl;x(this),this._listeners.clear(),this.setMomentum(0,0),cancelAnimationFrame(this._renderID),this._observer&&this._observer.disconnect(),Qt.delete(this.containerEl);for(var r=Array.from(e.childNodes);n.firstChild;)n.removeChild(n.firstChild);r.forEach(function(t){n.appendChild(t)}),O(n,{overflow:""}),n.scrollTop=this.scrollTop,n.scrollLeft=this.scrollLeft,this._plugins.forEach(function(t){t.onDestory()}),this._plugins.length=0},t.prototype._init=function(){var t=this;this.update(),Object.keys(X).forEach(function(n){X[n](t)}),this._plugins.forEach(function(t){t.onInit()}),this._render()},t.prototype._updateDebounced=function(){this.update()},t.prototype._shouldPropagateMomentum=function(t,n){void 0===t&&(t=0),void 0===n&&(n=0);var e=this,r=e.options,o=e.offset,i=e.limit;if(!r.continuousScrolling)return!1;0===i.x&&0===i.y&&this._updateDebounced();var u=Mt(t+o.x,0,i.x),c=Mt(n+o.y,0,i.y),s=!0;return s=s&&u===o.x,s=s&&c===o.y,s=s&&(o.x===i.x||0===o.x||o.y===i.y||0===o.y)},t.prototype._render=function(){var t=this._momentum;if(t.x||t.y){var n=this._nextTick("x"),e=this._nextTick("y");t.x=n.momentum,t.y=e.momentum,this.setPosition(n.position,e.position)}var r=$({},this._momentum);this._plugins.forEach(function(t){t.onRender(r)}),this._renderID=requestAnimationFrame(this._render.bind(this))},t.prototype._nextTick=function(t){var n=this,e=n.options,r=n.offset,o=n._momentum,i=r[t],u=o[t];if(Math.abs(u)<=.1)return{momentum:0,position:i+u};var c=u*(1-e.damping);return e.renderByPixels&&(c|=0),{momentum:c,position:i+u-c}},o([m(100,{leading:!0})],t.prototype,"_updateDebounced",null),t}(),tn="\n[data-scrollbar] {\n display: block;\n position: relative;\n}\n\n.scroll-content {\n -webkit-transform: translate3d(0, 0, 0);\n transform: translate3d(0, 0, 0);\n}\n\n.scrollbar-track {\n position: absolute;\n opacity: 0;\n z-index: 1;\n background: rgba(222, 222, 222, .75);\n -webkit-user-select: none;\n -moz-user-select: none;
18320\n -ms-user-select: none;\n user-select: none;\n -webkit-transition: opacity 0.5s 0.5s ease-out;\n transition: opacity 0.5s 0.5s ease-out;\n}\n.scrollbar-track.show,\n.scrollbar-track:hover {\n opacity: 1;\n -webkit-transition-delay: 0s;\n transition-delay: 0s;\n}\n\n.scrollbar-track-x {\n bottom: 0;\n left: 0;\n width: 100%;\n height: 8px;\n}\n.scrollbar-track-y {\n top: 0;\n right: 0;\n width: 8px;\n height: 100%;\n}\n.scrollbar-thumb {\n position: absolute;\n top: 0;\n left: 0;\n width: 8px;\n height: 8px;\n background: rgba(0, 0, 0, .5);\n border-radius: 4px;\n}\n",nn="smooth-scrollbar-style",en=!1;e.d(n,"ScrollbarPlugin",function(){return Ut});var rn=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.init=function(t,n){if(!t||1!==t.nodeType)throw new TypeError("expect element to be DOM Element, but got "+t);return V(),Qt.has(t)?Qt.get(t):new Zt(t,n)},n.initAll=function(t){return Array.from(document.querySelectorAll("[data-scrollbar]"),function(e){return n.init(e,t)})},n.has=function(t){return Qt.has(t)},n.get=function(t){return Qt.get(t)},n.getAll=function(){return Array.from(Qt.values())},n.destroy=function(t){var n=Qt.get(t);n&&n.destroy()},n.destroyAll=function(){Qt.forEach(function(t){t.destroy()})},n.use=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return L.apply(void 0,t)},n.attachStyle=function(){return V()},n.detachStyle=function(){return U()},n.version="8.3.1",n.ScrollbarPlugin=Ut,n}(Zt);n.default=rn},function(t,n,e){e(22),e(25),e(33),e(70),e(75),e(77),e(78),t.exports=e(4).Map},function(t,n,e){var r=e(26),o=e(27);t.exports=function(t){return function(n,e){var i,u,c=String(o(n)),s=r(e),a=c.length;return s<0||s>=a?t?"":void 0:(i=c.charCodeAt(s),i<55296||i>56319||s+1===a||(u=c.charCodeAt(s+1))<56320||u>57343?t?c.charAt(s):i:t?c.slice(s,s+2):u-56320+(i-55296<<10)+65536)}}},function(t,n){t.exports=!1},function(t,n,e){"use strict";var r=e(44),o=e(17),i=e(32),u={};e(11)(u,e(0)("iterator"),function(){return this}),t.exports=function(t,n,e){t.prototype=r(u,{next:o(1,e)}),i(t,n+" Iterator")}},function(t,n,e){var r=e(7),o=e(8),i=e(29);t.exports=e(9)?Object.defineProperties:function(t,n){o(t);for(var e,u=i(n),c=u.length,s=0;c>s;)r.f(t,e=u[s++],n[e]);return t}},function(t,n,e){var r=e(3),o=e(18),i=e(64)(!1),u=e(31)("IE_PROTO");t.exports=function(t,n){var e,c=o(t),s=0,a=[];for(e in c)e!=u&&r(c,e)&&a.push(e);for(;n.length>s;)r(c,e=n[s++])&&(~i(a,e)||a.push(e));return a}},function(t,n,e){var r=e(18),o=e(19),i=e(65);t.exports=function(t){return function(n,e,u){var c,s=r(n),a=o(s.length),f=i(u,a);if(t&&e!=e){for(;a>f;)if((c=s[f++])!=c)return!0}else for(;a>f;f++)if((t||f in s)&&s[f]===e)return t||f||0;return!t&&-1}}},function(t,n,e){var r=e(26),o=Math.max,i=Math.min;t.exports=function(t,n){return t=r(t),t<0?o(t+n,0):i(t,n)}},function(t,n,e){var r=e(2).document;t.exports=r&&r.documentElement},function(t,n,e){var r=e(3),o=e(20),i=e(31)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=o(t),r(t,i)?t[i]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,n,e){"use strict";var r=e(69),o=e(46),i=e(13),u=e(18);t.exports=e(28)(Array,"Array",function(t,n){this._t=u(t),this._i=0,this._k=n},function(){var t=this._t,n=this._k,e=this._i++;return!t||e>=t.length?(this._t=void 0,o(1)):"keys"==n?o(0,e):"values"==n?o(0,t[e]):o(0,[e,t[e]])},"values"),i.Arguments=i.Array,r("keys"),r("values"),r("entries")},function(t,n,e){var r=e(0)("unscopables"),o=Array.prototype;void 0==o[r]&&e(11)(o,r,{}),t.exports=function(t){o[r][t]=!0}},function(t,n,e){"use strict";var r=e(47),o=e(15);t.exports=e(36)("Map",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{get:function(t){var n=r.getEntry(o(this,"Map"),t);return n&&n.v},set:function(t,n){return r.def(o(this,"Map"),0===t?0:t,n)}},r,!0)},function(t,n,e){"use strict";var r=e(2),o=e(7),i=e(9),u=e(0)("species");t.exports=function(t){var n=r[t];i&&n&&!n[u]&&o.f(n,u,{configurable:!0,get:function(){return this}})}},function(t,n,e){var r=e(1),o=e(73).set;t.exports=function(t,n,e){var i,u=n.constructor;return u!==e&&"function"==typeof u&&(i=u.prototype)!==e.prototype&&r(i)&&o&&o(t,i),t}},function(t,n,e){var r=e(1),o=e(8),i=function(t,n){if(o(t),!r(n)&&null!==n)throw TypeError(n+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,n,r){try{r=e(10)(Function.call,e(74).f(Object.prototype,"__proto__").set,2),r(t,[]),n=!(t instanceof Array)}catch(t){n=!0}return function(t,e){return i(t,e),n?t.__proto__=e:r(t,e),t}}({},!1):void 0),check:i}},function(t,n,e){var r=e(52),o=e(17),i=e(18),u=e(42),c=e(3),s=e(40),a=Object.getOwnPropertyDescriptor;n.f=e(9)?a:function(t,n){if(t=i(t),n=u(n,!0),s)try{return a(t,n)}catch(t){}if(c(t,n))return o(!r.f.call(t,n),t[n])}},function(t,n,e){var r=e(5);r(r.P+r.R,"Map",{toJSON:e(53)("Map")})},function(t,n,e){var r=e(14);t.exports=function(t,n){var e=[];return r(t,!1,e.push,e,n),e}},function(t,n,e){e(37)("Map")},function(t,n,e){e(38)("Map")},function(t,n,e){e(22),e(25),e(33),e(80),e(81),e(82),e(83),t.exp
vendor: 4,214 bytes, lines 18320-18329
18320orts=e(4).Set},function(t,n,e){"use strict";var r=e(47),o=e(15);t.exports=e(36)("Set",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{add:function(t){return r.def(o(this,"Set"),t=0===t?0:t,t)}},r)},function(t,n,e){var r=e(5);r(r.P+r.R,"Set",{toJSON:e(53)("Set")})},function(t,n,e){e(37)("Set")},function(t,n,e){e(38)("Set")},function(t,n,e){e(22),e(33),e(85),e(91),e(92),t.exports=e(4).WeakMap},function(t,n,e){"use strict";var r,o=e(54)(0),i=e(6),u=e(21),c=e(55),s=e(90),a=e(1),f=e(12),l=e(15),p=u.getWeak,h=Object.isExtensible,d=s.ufstore,v={},y=function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},m={get:function(t){if(a(t)){var n=p(t);return!0===n?d(l(this,"WeakMap")).get(t):n?n[this._i]:void 0}},set:function(t,n){return s.def(l(this,"WeakMap"),t,n)}},g=t.exports=e(36)("WeakMap",y,m,s,!0,!0);f(function(){return 7!=(new g).set((Object.freeze||Object)(v),7).get(v)})&&(r=s.getConstructor(y,"WeakMap"),c(r.prototype,m),u.NEED=!0,o(["delete","has","get","set"],function(t){var n=g.prototype,e=n[t];i(n,t,function(n,o){if(a(n)&&!h(n)){this._f||(this._f=new r);var i=this._f[t](n,o);return"set"==t?this:i}return e.call(this,n,o)})}))},function(t,n,e){var r=e(87);t.exports=function(t,n){return new(r(t))(n)}},function(t,n,e){var r=e(1),o=e(88),i=e(0)("species");t.exports=function(t){var n;return o(t)&&(n=t.constructor,"function"!=typeof n||n!==Array&&!o(n.prototype)||(n=void 0),r(n)&&null===(n=n[i])&&(n=void 0)),void 0===n?Array:n}},function(t,n,e){var r=e(24);t.exports=Array.isArray||function(t){return"Array"==r(t)}},function(t,n){n.f=Object.getOwnPropertySymbols},function(t,n,e){"use strict";var r=e(34),o=e(21).getWeak,i=e(8),u=e(1),c=e(35),s=e(14),a=e(54),f=e(3),l=e(15),p=a(5),h=a(6),d=0,v=function(t){return t._l||(t._l=new y)},y=function(){this.a=[]},m=function(t,n){return p(t.a,function(t){return t[0]===n})};y.prototype={get:function(t){var n=m(this,t);if(n)return n[1]},has:function(t){return!!m(this,t)},set:function(t,n){var e=m(this,t);e?e[1]=n:this.a.push([t,n])},delete:function(t){var n=h(this.a,function(n){return n[0]===t});return~n&&this.a.splice(n,1),!!~n}},t.exports={getConstructor:function(t,n,e,i){var a=t(function(t,r){c(t,a,n,"_i"),t._t=n,t._i=d++,t._l=void 0,void 0!=r&&s(r,e,t[i],t)});return r(a.prototype,{delete:function(t){if(!u(t))return!1;var e=o(t);return!0===e?v(l(this,n)).delete(t):e&&f(e,this._i)&&delete e[this._i]},has:function(t){if(!u(t))return!1;var e=o(t);return!0===e?v(l(this,n)).has(t):e&&f(e,this._i)}}),a},def:function(t,n,e){var r=o(i(n),!0);return!0===r?v(t).set(n,e):r[t._i]=e,t},ufstore:v}},function(t,n,e){e(37)("WeakMap")},function(t,n,e){e(38)("WeakMap")},function(t,n,e){e(25),e(94),t.exports=e(4).Array.from},function(t,n,e){"use strict";var r=e(10),o=e(5),i=e(20),u=e(48),c=e(49),s=e(19),a=e(95),f=e(50);o(o.S+o.F*!e(51)(function(t){Array.from(t)}),"Array",{from:function(t){var n,e,o,l,p=i(t),h="function"==typeof this?this:Array,d=arguments.length,v=d>1?arguments[1]:void 0,y=void 0!==v,m=0,g=f(p);if(y&&(v=r(v,d>2?arguments[2]:void 0,2)),void 0==g||h==Array&&c(g))for(n=s(p.length),e=new h(n);n>m;m++)a(e,m,y?v(p[m],m):p[m]);else for(l=g.call(p),e=new h;!(o=l.next()).done;m++)a(e,m,y?u(l,v,[o.value,m],!0):o.value);return e.length=m,e}})},function(t,n,e){"use strict";var r=e(7),o=e(17);t.exports=function(t,n,e){n in t?r.f(t,n,o(0,e)):t[n]=e}},function(t,n,e){e(97),t.exports=e(4).Object.assign},function(t,n,e){var r=e(5);r(r.S+r.F,"Object",{assign:e(55)})},function(t,n,e){"use strict";(function(t){var e="object"==typeof t&&t&&t.Object===Object&&t;n.a=e}).call(n,e(99))},function(t,n){var e;e=function(){return this}();try{e=e||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(e=window)}t.exports=e}]).default}); 18321/*! 18322 * VERSION: 2.0.2 18323 * DATE: 2018-08-27 18324 * UPDATES AND DOCS AT: http://greensock.com 18325 * 18326 * Includes all of the following: TweenLite, TweenMax, TimelineLite, TimelineMax, EasePack, CSSPlugin, RoundPropsPlugin, BezierPlugin, AttrPlugin, DirectionalRotationPlugin 18327 * 18328 * @license Copyright (c) 2008-2018, GreenSock. All rights reserved. 18329 * This work is subject to the terms at http://greensock.com/standard-license or for
18330 * Club GreenSock members, the software agreement that was issued with your membership. 18331 * 18332 * @author: Jack Doyle, [email protected] 18333 **/ 18334var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window; //helps ensure compatibility with AMD/RequireJS and CommonJS/Node 18335(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push( function() { 18336 18337 "use strict"; 18338 18339 _gsScope._gsDefine("TweenMax", ["core.Animation","core.SimpleTimeline","TweenLite"], function(Animation, SimpleTimeline, TweenLite) { 18340 18341 var _slice = function(a) { //don't use [].slice because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll() 18342 var b = [], 18343 l = a.length, 18344 i; 18345 for (i = 0; i !== l; b.push(a[i++])); 18346 return b; 18347 }, 18348 _applyCycle = function(vars, targets, i) { 18349 var alt = vars.cycle, 18350 p, val; 18351 for (p in alt) { 18352 val = alt[p]; 18353 vars[p] = (typeof(val) === "function") ? val(i, targets[i]) : val[i % val.length]; 18354 } 18355 delete vars.cycle; 18356 }, 18357 TweenMax = function(target, duration, vars) { 18358 TweenLite.call(this, target, duration, vars); 18359 this._cycle = 0; 18360 this._yoyo = (this.vars.yoyo === true || !!this.vars.yoyoEase); 18361 this._repeat = this.vars.repeat || 0; 18362 this._repeatDelay = this.vars.repeatDelay || 0; 18363 if (this._repeat) { 18364 this._uncache(true); //ensures that if there is any repeat, the totalDuration will get recalculated to accurately report it. 18365 } 18366 this.render = TweenMax.prototype.render; //speed optimization (avoid prototype lookup on this "hot" method) 18367 }, 18368 _tinyNum = 0.0000000001, 18369 TweenLiteInternals = TweenLite._internals, 18370 _isSelector = TweenLiteInternals.isSelector, 18371 _isArray = TweenLiteInternals.isArray, 18372 p = TweenMax.prototype = TweenLite.to({}, 0.1, {}), 18373 _blankArray = []; 18374 18375 TweenMax.version = "2.0.2"; 18376 p.constructor = TweenMax; 18377 p.kill()._gc = false; 18378 TweenMax.killTweensOf = TweenMax.killDelayedCallsTo = TweenLite.killTweensOf; 18379 TweenMax.getTweensOf = TweenLite.getTweensOf; 18380 TweenMax.lagSmoothing = TweenLite.lagSmoothing; 18381 TweenMax.ticker = TweenLite.ticker; 18382 TweenMax.render = TweenLite.render; 18383 18384 p.invalidate = function() { 18385 this._yoyo = (this.vars.yoyo === true || !!this.vars.yoyoEase); 18386 this._repeat = this.vars.repeat || 0; 18387 this._repeatDelay = this.vars.repeatDelay || 0; 18388 this._yoyoEase = null; 18389 this._uncache(true); 18390 return TweenLite.prototype.invalidate.call(this); 18391 }; 18392 18393 p.updateTo = function(vars, resetDuration) { 18394 var curRatio = this.ratio, 18395 immediate = this.vars.immediateRender || vars.immediateRender, 18396 p; 18397 if (resetDuration && this._startTime < this._timeline._time) { 18398 this._startTime = this._timeline._time; 18399 this._uncache(false); 18400 if (this._gc) { 18401 this._enabled(true, false); 18402 } else { 18403 this._timeline.insert(this, this._startTime - this._delay); //ensures that any necessary re-sequencing of Animations in the timeline occurs to make sure the rendering order is correct. 18404 } 18405 } 18406 for (p in vars) { 18407 this.vars[p] = vars[p]; 18408 } 18409 if (this._initted || immediate) { 18410 if (resetDuration) { 18411 this._initted = false; 18412 if (immediate) { 18413 this.render(0, true, true); 18414 } 18415 } else { 18416 if (this._gc) { 18417 this._enabled(true, false); 18418 } 18419 if (this._notifyPluginsOfEnabled && this._firstPT) { 18420 TweenLite._onPluginEvent("_onDisable", this); //in case a plugin like MotionBlur must perform some cleanup tasks 18421 } 18422 if (this._time / this._duration > 0.998) { //if the tween has finished (or come extremely close to finishing), we just need to rewind it to 0 and then render it again at the end which forces it to re-initialize (parsing the new vars). We allow tweens that are close to finishing (but haven't quite finished) to work this way too because otherwise, the values are so small when determining where to project the starting values that binary math issues creep in and can make the tween appear to render incorrectly when run backwards. 18423 var prevTime = this._totalTime; 18424 this.render(0, true, false); 18425 this._initted = false;
18426 this.render(prevTime, true, false); 18427 } else { 18428 this._initted = false; 18429 this._init(); 18430 if (this._time > 0 || immediate) { 18431 var inv = 1 / (1 - curRatio), 18432 pt = this._firstPT, endValue; 18433 while (pt) { 18434 endValue = pt.s + pt.c; 18435 pt.c *= inv; 18436 pt.s = endValue - pt.c; 18437 pt = pt._next; 18438 } 18439 } 18440 } 18441 } 18442 } 18443 return this; 18444 }; 18445 18446 p.render = function(time, suppressEvents, force) { 18447 if (!this._initted) if (this._duration === 0 && this.vars.repeat) { //zero duration tweens that render immediately have render() called from TweenLite's constructor, before TweenMax's constructor has finished setting _repeat, _repeatDelay, and _yoyo which are critical in determining totalDuration() so we need to call invalidate() which is a low-kb way to get those set properly. 18448 this.invalidate(); 18449 } 18450 var totalDur = (!this._dirty) ? this._totalDuration : this.totalDuration(), 18451 prevTime = this._time, 18452 prevTotalTime = this._totalTime, 18453 prevCycle = this._cycle, 18454 duration = this._duration, 18455 prevRawPrevTime = this._rawPrevTime, 18456 isComplete, callback, pt, cycleDuration, r, type, pow, rawPrevTime, yoyoEase; 18457 if (time >= totalDur - 0.0000001 && time >= 0) { //to work around occasional floating point math artifacts. 18458 this._totalTime = totalDur; 18459 this._cycle = this._repeat; 18460 if (this._yoyo && (this._cycle & 1) !== 0) { 18461 this._time = 0; 18462 this.ratio = this._ease._calcEnd ? this._ease.getRatio(0) : 0; 18463 } else { 18464 this._time = duration; 18465 this.ratio = this._ease._calcEnd ? this._ease.getRatio(1) : 1; 18466 } 18467 if (!this._reversed) { 18468 isComplete = true; 18469 callback = "onComplete"; 18470 force = (force || this._timeline.autoRemoveChildren); //otherwise, if the animation is unpaused/activated after it's already finished, it doesn't get removed from the parent timeline. 18471 } 18472 if (duration === 0) if (this._initted || !this.vars.lazy || force) { //zero-duration tweens are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered. 18473 if (this._startTime === this._timeline._duration) { //if a zero-duration tween is at the VERY end of a timeline and that timeline renders at its end, it will typically add a tiny bit of cushion to the render time to prevent rounding errors from getting in the way of tweens rendering their VERY end. If we then reverse() that timeline, the zero-duration tween will trigger its onReverseComplete even though technically the playhead didn't pass over it again. It's a very specific edge case we must accommodate. 18474 time = 0; 18475 } 18476 if (prevRawPrevTime < 0 || (time <= 0 && time >= -0.0000001) || (prevRawPrevTime === _tinyNum && this.data !== "isPause")) if (prevRawPrevTime !== time) { //note: when this.data is "isPause", it's a callback added by addPause() on a timeline that we should not be triggered when LEAVING its exact start time. In other words, tl.addPause(1).play(1) shouldn't pause. 18477 force = true; 18478 if (prevRawPrevTime > _tinyNum) { 18479 callback = "onReverseComplete"; 18480 } 18481 } 18482 this._rawPrevTime = rawPrevTime = (!suppressEvents || time || prevRawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient. 18483 } 18484 18485 } else if (time < 0.0000001) { //to work around occasional floating point math artifacts, round super small values to 0. 18486 this._totalTime = this._time = this._cycle = 0; 18487 this.ratio = this._ease._calcEnd ? this._ease.getRatio(0) : 0; 18488 if (prevTotalTime !== 0 || (duration === 0 && prevRawPrevTime > 0)) { 18489 callback = "onReverseComplete"; 18490 isComplete = this._reversed; 18491 } 18492 if (time < 0) { 18493 this._active = false;
18494 if (duration === 0) if (this._initted || !this.vars.lazy || force) { //zero-duration tweens are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered. 18495 if (prevRawPrevTime >= 0) { 18496 force = true; 18497 } 18498 this._rawPrevTime = rawPrevTime = (!suppressEvents || time || prevRawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient. 18499 } 18500 } 18501 if (!this._initted) { //if we render the very beginning (time == 0) of a fromTo(), we must force the render (normal tweens wouldn't need to render at a time of 0 when the prevTime was also 0). This is also mandatory to make sure overwriting kicks in immediately. 18502 force = true; 18503 } 18504 } else { 18505 this._totalTime = this._time = time; 18506 if (this._repeat !== 0) { 18507 cycleDuration = duration + this._repeatDelay; 18508 this._cycle = (this._totalTime / cycleDuration) >> 0; //originally _totalTime % cycleDuration but floating point errors caused problems, so I normalized it. (4 % 0.8 should be 0 but some browsers report it as 0.79999999!) 18509 if (this._cycle !== 0) if (this._cycle === this._totalTime / cycleDuration && prevTotalTime <= time) { 18510 this._cycle--; //otherwise when rendered exactly at the end time, it will act as though it is repeating (at the beginning) 18511 } 18512 this._time = this._totalTime - (this._cycle * cycleDuration); 18513 if (this._yoyo) if ((this._cycle & 1) !== 0) { 18514 this._time = duration - this._time; 18515 yoyoEase = this._yoyoEase || this.vars.yoyoEase; //note: we don't set this._yoyoEase in _init() like we do other properties because it's TweenMax-specific and doing it here allows us to optimize performance (most tweens don't have a yoyoEase). Note that we also must skip the this.ratio calculation further down right after we _init() in this function, because we're doing it here. 18516 if (yoyoEase) { 18517 if (!this._yoyoEase) { 18518 if (yoyoEase === true && !this._initted) { //if it's not initted and yoyoEase is true, this._ease won't have been populated yet so we must discern it here. 18519 yoyoEase = this.vars.ease; 18520 this._yoyoEase = yoyoEase = !yoyoEase ? TweenLite.defaultEase : (yoyoEase instanceof Ease) ? yoyoEase : (typeof(yoyoEase) === "function") ? new Ease(yoyoEase, this.vars.easeParams) : Ease.map[yoyoEase] || TweenLite.defaultEase; 18521 } else { 18522 this._yoyoEase = yoyoEase = (yoyoEase === true) ? this._ease : (yoyoEase instanceof Ease) ? yoyoEase : Ease.map[yoyoEase]; 18523 } 18524 } 18525 this.ratio = yoyoEase ? 1 - yoyoEase.getRatio((duration - this._time) / duration) : 0; 18526 } 18527 } 18528 if (this._time > duration) { 18529 this._time = duration; 18530 } else if (this._time < 0) { 18531 this._time = 0; 18532 } 18533 } 18534 if (this._easeType && !yoyoEase) { 18535 r = this._time / duration; 18536 type = this._easeType; 18537 pow = this._easePower; 18538 if (type === 1 || (type === 3 && r >= 0.5)) { 18539 r = 1 - r; 18540 } 18541 if (type === 3) { 18542 r *= 2; 18543 } 18544 if (pow === 1) { 18545 r *= r; 18546 } else if (pow === 2) { 18547 r *= r * r; 18548 } else if (pow === 3) { 18549 r *= r * r * r; 18550 } else if (pow === 4) { 18551 r *= r * r * r * r; 18552 } 18553 18554 if (type === 1) { 18555 this.ratio = 1 - r; 18556 } else if (type === 2) { 18557 this.ratio = r; 18558 } else if (this._time / duration < 0.5) { 18559 this.ratio = r / 2; 18560 } else { 18561 this.ratio = 1 - (r / 2); 18562 } 18563 18564 } else if (!yoyoEase) { 18565 this.ratio = this._ease.getRatio(this._time / duration); 18566 } 18567 18568 } 18569 18570 if (prevTime === this._time && !force && prevCycle === this._cycle) { 18571 if (prevTotalTime !== this._totalTime) if (this._onUpdate) if (!suppressEvents) { //so that onUp
18571date fires even during the repeatDelay - as long as the totalTime changed, we should trigger onUpdate. 18572 this._callback("onUpdate"); 18573 } 18574 return; 18575 } else if (!this._initted) { 18576 this._init(); 18577 if (!this._initted || this._gc) { //immediateRender tweens typically won't initialize until the playhead advances (_time is greater than 0) in order to ensure that overwriting occurs properly. Also, if all of the tweening properties have been overwritten (which would cause _gc to be true, as set in _init()), we shouldn't continue otherwise an onStart callback could be called for example. 18578 return; 18579 } else if (!force && this._firstPT && ((this.vars.lazy !== false && this._duration) || (this.vars.lazy && !this._duration))) { //we stick it in the queue for rendering at the very end of the tick - this is a performance optimization because browsers invalidate styles and force a recalculation if you read, write, and then read style data (so it's better to read/read/read/write/write/write than read/write/read/write/read/write). The down side, of course, is that usually you WANT things to render immediately because you may have code running right after that which depends on the change. Like imagine running TweenLite.set(...) and then immediately after that, creating a nother tween that animates the same property to another value; the starting values of that 2nd tween wouldn't be accurate if lazy is true. 18580 this._time = prevTime; 18581 this._totalTime = prevTotalTime; 18582 this._rawPrevTime = prevRawPrevTime; 18583 this._cycle = prevCycle; 18584 TweenLiteInternals.lazyTweens.push(this); 18585 this._lazy = [time, suppressEvents]; 18586 return; 18587 } 18588 //_ease is initially set to defaultEase, so now that init() has run, _ease is set properly and we need to recalculate the ratio. Overall this is faster than using conditional logic earlier in the method to avoid having to set ratio twice because we only init() once but renderTime() gets called VERY frequently. 18589 if (this._time && !isComplete && !yoyoEase) { 18590 this.ratio = this._ease.getRatio(this._time / duration); 18591 } else if (isComplete && this._ease._calcEnd && !yoyoEase) { 18592 this.ratio = this._ease.getRatio((this._time === 0) ? 0 : 1); 18593 } 18594 } 18595 if (this._lazy !== false) { 18596 this._lazy = false; 18597 } 18598 18599 if (!this._active) if (!this._paused && this._time !== prevTime && time >= 0) { 18600 this._active = true; //so that if the user renders a tween (as opposed to the timeline rendering it), the timeline is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the tween already finished but the user manually re-renders it as halfway done. 18601 } 18602 if (prevTotalTime === 0) { 18603 if (this._initted === 2 && time > 0) { 18604 //this.invalidate(); 18605 this._init(); //will just apply overwriting since _initted of (2) means it was a from() tween that had immediateRender:true 18606 } 18607 if (this._startAt) { 18608 if (time >= 0) { 18609 this._startAt.render(time, true, force); 18610 } else if (!callback) { 18611 callback = "_dummyGS"; //if no callback is defined, use a dummy value just so that the condition at the end evaluates as true because _startAt should render AFTER the normal render loop when the time is negative. We could handle this in a more intuitive way, of course, but the render loop is the MOST important thing to optimize, so this technique allows us to avoid adding extra conditional logic in a high-frequency area. 18612 } 18613 } 18614 if (this.vars.onStart) if (this._totalTime !== 0 || duration === 0) if (!suppressEvents) { 18615 this._callback("onStart"); 18616 } 18617 } 18618 18619 pt = this._firstPT; 18620 while (pt) { 18621 if (pt.f) { 18622 pt.t[pt.p](pt.c * this.ratio + pt.s); 18623 } else { 18624 pt.t[pt.p] = pt.c * this.ratio + pt.s; 18625 } 18626 pt = pt._next; 18627 } 18628 18629 if (this._onUpdate) { 18630 if (time < 0) if (this._startAt && this._startTime) { //if the tween is positioned at the VERY beginning (_startTime 0) of its parent timeline, it's illegal for the playhead to go back further, so we should not render the recorded startAt values. 18631 this._startAt.render(time, true, force); //note: for performance reasons, we tuck this conditional logic inside less traveled areas (most tweens don't have an onUpdate). We'd just have it at the end before the onComplete, but the values should be updated before any onUpdate is called, so we ALSO put it here and then if it's not called, we do so later near the onComplete. 18632 } 18633 if (!suppressEvents) if (this._totalTime !== prevTotalTime || callback) {
18634 this._callback("onUpdate"); 18635 } 18636 } 18637 if (this._cycle !== prevCycle) if (!suppressEvents) if (!this._gc) if (this.vars.onRepeat) { 18638 this._callback("onRepeat"); 18639 } 18640 if (callback) if (!this._gc || force) { //check gc because there's a chance that kill() could be called in an onUpdate 18641 if (time < 0 && this._startAt && !this._onUpdate && this._startTime) { //if the tween is positioned at the VERY beginning (_startTime 0) of its parent timeline, it's illegal for the playhead to go back further, so we should not render the recorded startAt values. 18642 this._startAt.render(time, true, force); 18643 } 18644 if (isComplete) { 18645 if (this._timeline.autoRemoveChildren) { 18646 this._enabled(false, false); 18647 } 18648 this._active = false; 18649 } 18650 if (!suppressEvents && this.vars[callback]) { 18651 this._callback(callback); 18652 } 18653 if (duration === 0 && this._rawPrevTime === _tinyNum && rawPrevTime !== _tinyNum) { //the onComplete or onReverseComplete could trigger movement of the playhead and for zero-duration tweens (which must discern direction) that land directly back on their start time, we don't want to fire again on the next render. Think of several addPause()'s in a timeline that forces the playhead to a certain spot, but what if it's already paused and another tween is tweening the "time" of the timeline? Each time it moves [forward] past that spot, it would move back, and since suppressEvents is true, it'd reset _rawPrevTime to _tinyNum so that when it begins again, the callback would fire (so ultimately it could bounce back and forth during that tween). Again, this is a very uncommon sce
18653nario, but possible nonetheless. 18654 this._rawPrevTime = 0; 18655 } 18656 } 18657 }; 18658 18659//---- STATIC FUNCTIONS ----------------------------------------------------------------------------------------------------------- 18660 18661 TweenMax.to = function(target, duration, vars) { 18662 return new TweenMax(target, duration, vars); 18663 }; 18664 18665 TweenMax.from = function(target, duration, vars) { 18666 vars.runBackwards = true; 18667 vars.immediateRender = (vars.immediateRender != false); 18668 return new TweenMax(target, duration, vars); 18669 }; 18670 18671 TweenMax.fromTo = function(target, duration, fromVars, toVars) { 18672 toVars.startAt = fromVars; 18673 toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false); 18674 return new TweenMax(target, duration, toVars); 18675 }; 18676 18677 TweenMax.staggerTo = TweenMax.allTo = function(targets, duration, vars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope) { 18678 stagger = stagger || 0; 18679 var delay = 0, 18680 a = [], 18681 finalComplete = function() { 18682 if (vars.onComplete) { 18683 vars.onComplete.apply(vars.onCompleteScope || this, arguments); 18684 } 18685 onCompleteAll.apply(onCompleteAllScope || vars.callbackScope || this, onCompleteAllParams || _blankArray); 18686 }, 18687 cycle = vars.cycle, 18688 fromCycle = (vars.startAt && vars.startAt.cycle), 18689 l, copy, i, p; 18690 if (!_isArray(targets)) { 18691 if (typeof(targets) === "string") { 18692 targets = TweenLite.selector(targets) || targets; 18693 } 18694 if (_isSelector(targets)) { 18695 targets = _slice(targets); 18696 } 18697 } 18698 targets = targets || []; 18699 if (stagger < 0) { 18700 targets = _slice(targets); 18701 targets.reverse(); 18702 stagger *= -1; 18703 } 18704 l = targets.length - 1; 18705 for (i = 0; i <= l; i++) { 18706 copy = {}; 18707 for (p in vars) { 18708 copy[p] = vars[p]; 18709 } 18710 if (cycle) { 18711 _applyCycle(copy, targets, i); 18712 if (copy.duration != null) { 18713 duration = copy.duration; 18714 delete copy.duration; 18715 } 18716 } 18717 if (fromCycle) { 18718 fromCycle = copy.startAt = {}; 18719 for (p in vars.startAt) { 18720 fromCycle[p] = vars.startAt[p]; 18721 } 18722 _applyCycle(copy.startAt, targets, i); 18723 } 18724 copy.delay = delay + (copy.delay || 0); 18725 if (i === l && onCompleteAll) { 18726 copy.onComplete = finalComplete; 18727 } 18728 a[i] = new TweenMax(targets[i], duration, copy); 18729 delay += stagger; 18730 } 18731 return a; 18732 }; 18733 18734 TweenMax.staggerFrom = TweenMax.allFrom = function(targets, duration, vars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope) { 18735 vars.runBackwards = true; 18736 vars.immediateRender = (vars.immediateRender != false); 18737 return TweenMax.staggerTo(targets, duration, vars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope); 18738 }; 18739 18740 TweenMax.staggerFromTo = TweenMax.allFromTo = function(targets, duration, fromVars, toVars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope) { 18741 toVars.startAt = fromVars; 18742 toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false); 18743 return TweenMax.staggerTo(targets, duration, toVars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope); 18744 }; 18745 18746 TweenMax.delayedCall = function(delay, callback, params, scope, useFrames) { 18747 return new TweenMax(callback, 0, {delay:delay, onComplete:callback, onCompleteParams:params, callbackScope:scope, onReverseComplete:callback, onReverseCompleteParams:params, immediateRender:false, useFrames:useFrames, overwrite:0}); 18748 }; 18749 18750 TweenMax.set = function(target, vars) { 18751 return new TweenMax(target, 0, vars); 18752 }; 18753 18754 TweenMax.isTweening = function(target) { 18755 return (TweenLite.getTweensOf(target, true).length > 0); 18756 }; 18757 18758 var _getChildrenOf = function(timeline, includeTimelines) { 18759 var a = [], 18760 cnt = 0, 18761 tween = timeline._first; 18762 while (tween) { 18763 if (tween instanceof TweenLite) { 18764 a[cnt++] = tween; 18765 } else { 18766 if (includeTimelines) { 18767 a[cnt++] = tween; 18768 } 18769 a = a.concat(_getChildrenOf(tween, includeTimelines)); 18770 cnt = a.length; 18771 } 18772 tween = tween._next; 18773 } 18774 return a; 18775 }, 18776 getAllTweens = TweenMax.getAllTweens = function(includeTimelines) { 18777 return _getChildrenOf(Animation._rootTimeline, includeTimelines).concat( _getChildrenOf(Animation._rootFramesTimeline, includeTimelines) ); 18778 }; 18779 18780 TweenMax.killAll = function(complete, tweens, delayedCalls, timelines) { 18781 if (tweens == null) { 18782 tweens = true; 18783 } 18784 if (delayedCalls == null) { 18785 delayedCalls = true; 18786 } 18787 var a = getAllTweens((timelines != false)), 18788 l = a.length, 18789 allTrue = (tweens && delayedCalls && timelines), 18790 isDC, tween, i; 18791 for (i = 0; i < l; i++) { 18792 tween = a[i]; 18793 if (allTrue || (tween instanceof SimpleTimeline) || ((isDC = (tween.target === tween.vars.onComplete)) && delayedCalls) || (tweens && !isDC)) { 18794 if (complete) { 18795 tween.totalTime(tween._reversed ? 0 : tween.totalDuration()); 18796 } else { 18797 tween._enabled(false, false); 18798 } 18799 } 18800 } 18801 }; 18802 18803 TweenMax.killChildTweensOf = function(parent, complete) { 18804 if (parent == null) { 18805 return; 18806 } 18807 var tl = TweenLiteInternals.tweenLookup, 18808 a, curParent, p, i, l; 18809 if (typeof(parent) === "string") { 18810 parent = TweenLite.selector(parent) || parent; 18811 } 18812 if (_isSelector(parent)) { 18813 parent = _slice(parent); 18814 } 18815 if (_isArray(parent)) { 18816 i = parent.length; 18817 while (--i > -1) { 18818 TweenMax.killChildTweensOf(parent[i], complete); 18819 } 18820 return; 18821 } 18822 a = []; 18823 for (p in tl) { 18824 curParent = tl[p].target.parentNode; 18825 while (curParent) { 18826 if (curParent === parent) { 18827 a = a.concat(tl[p].tweens); 18828 } 18829 curParent = curParent.parentNode; 18830 } 18831 } 18832 l = a.length; 18833 for (i = 0; i < l; i++) { 18834 if (complete) { 18835 a[i].totalTime(a[i].totalDuration()); 18836 } 18837 a[i]._enabled(false, false); 18838 } 18839 }; 18840 18841 var _changePause = function(pause, tweens, delayedCalls, timelines) { 18842 tweens = (tweens !== false); 18843 delayedCalls = (delayedCalls !== false); 18844 timelines = (timelines !== false); 18845 var a = getAllTweens(timelines), 18846 allTrue = (tweens && delayedCalls && timelines), 18847 i = a.length, 18848 isDC, tween; 18849 while (--i > -1) { 18850 tween = a[i]; 18851 if (allTrue || (tween instanceof SimpleTimeline) || ((isDC = (tween.target === tween.vars.onComplete)) && delayedCalls) || (tweens && !isDC)) { 18852 tween.paused(pause); 18853 } 18854 } 18855 }; 18856 18857 TweenMax.pauseAll = function(tweens, delayedCalls, timelines) { 18858 _changePause(true, tweens, delayedCalls, timelines); 18859 }; 18860
18861 TweenMax.resumeAll = function(tweens, delayedCalls, timelines) { 18862 _changePause(false, tweens, delayedCalls, timelines); 18863 }; 18864 18865 TweenMax.globalTimeScale = function(value) { 18866 var tl = Animation._rootTimeline, 18867 t = TweenLite.ticker.time; 18868 if (!arguments.length) { 18869 return tl._timeScale; 18870 } 18871 value = value || _tinyNum; //can't allow zero because it'll throw the math off 18872 tl._startTime = t - ((t - tl._startTime) * tl._timeScale / value); 18873 tl = Animation._rootFramesTimeline; 18874 t = TweenLite.ticker.frame; 18875 tl._startTime = t - ((t - tl._startTime) * tl._timeScale / value); 18876 tl._timeScale = Animation._rootTimeline._timeScale = value; 18877 return value; 18878 }; 18879 18880 18881//---- GETTERS / SETTERS ---------------------------------------------------------------------------------------------------------- 18882 18883 p.progress = function(value, suppressEvents) { 18884 return (!arguments.length) ? this._time / this.duration() : this.totalTime( this.duration() * ((this._yoyo && (this._cycle & 1) !== 0) ? 1 - value : value) + (this._cycle * (this._duration + this._repeatDelay)), suppressEvents); 18885 }; 18886 18887 p.totalProgress = function(value, suppressEvents) { 18888 return (!arguments.length) ? this._totalTime / this.totalDuration() : this.totalTime( this.totalDuration() * value, suppressEvents); 18889 }; 18890 18891 p.time = function(value, suppressEvents) { 18892 if (!arguments.length) { 18893 return this._time; 18894 } 18895 if (this._dirty) { 18896 this.totalDuration(); 18897 } 18898 if (value > this._duration) { 18899 value = this._duration; 18900 } 18901 if (this._yoyo && (this._cycle & 1) !== 0) { 18902 value = (this._duration - value) + (this._cycle * (this._duration + this._repeatDelay)); 18903 } else if (this._repeat !== 0) { 18904 value += this._cycle * (this._duration + this._repeatDelay); 18905 } 18906 return this.totalTime(value, suppressEvents); 18907 }; 18908 18909 p.duration = function(value) { 18910 if (!arguments.length) { 18911 return this._duration; //don't set _dirty = false because there could be repeats that haven't been factored into the _totalDuration yet. Otherwise, if you create a repeated TweenMax and then immediately check its duration(), it would cache the value and the totalDuration would not be correct, thus repeats wouldn't take effect. 18912 } 18913 return Animation.prototype.duration.call(this, value); 18914 }; 18915 18916 p.totalDuration = function(value) { 18917 if (!arguments.length) { 18918 if (this._dirty) { 18919 //instead of Infinity, we use 999999999999 so that we can accommodate reverses 18920 this._totalDuration = (this._repeat === -1) ? 999999999999 : this._duration * (this._repeat + 1) + (this._repeatDelay * this._repeat); 18921 this._dirty = false; 18922 } 18923 return this._totalDuration; 18924 } 18925 return (this._repeat === -1) ? this : this.duration( (value - (this._repeat * this._repeatDelay)) / (this._repeat + 1) ); 18926 }; 18927 18928 p.repeat = function(value) { 18929 if (!arguments.length) { 18930 return this._repeat; 18931 } 18932 this._repeat = value; 18933 return this._uncache(true); 18934 }; 18935 18936 p.repeatDelay = function(value) { 18937 if (!arguments.length) { 18938 return this._repeatDelay; 18939 } 18940 this._repeatDelay = value; 18941 return this._uncache(true); 18942 }; 18943 18944 p.yoyo = function(value) { 18945 if (!arguments.length) { 18946 return this._yoyo; 18947 } 18948 this._yoyo = value; 18949 return this; 18950 }; 18951 18952 18953 return TweenMax; 18954 18955 }, true); 18956 18957 18958 18959 18960 18961 18962 18963 18964/* 18965 * ---------------------------------------------------------------- 18966 * TimelineLite 18967 * ---------------------------------------------------------------- 18968 */ 18969 _gsScope._gsDefine("TimelineLite", ["core.Animation","core.SimpleTimeline","TweenLite"], function(Animation, SimpleTimeline, TweenLite) { 18970 18971 var TimelineLite = function(vars) { 18972 SimpleTimeline.call(this, vars); 18973 this._labels = {}; 18974 this.autoRemoveChildren = (this.vars.autoRemoveChildren === true); 18975 this.smoothChildTiming = (this.vars.smoothChildTiming === true); 18976 this._sortChildren = true; 18977 this._onUpdate = this.vars.onUpdate; 18978 var v = this.vars, 18979 val, p; 18980 for (p in v) { 18981 val = v[p]; 18982 if (_isArray(val)) if (val.join("").indexOf("{self}") !== -1) { 18983 v[p] = this._swapSelfInParams(val); 18984 } 18985 } 18986 if (_isArray(v.tweens)) { 18987 this.add(v.tweens, 0, v.align, v.stagger); 18988 } 18989 }, 18990 _tinyNum = 0.0000000001, 18991 TweenLiteInternals = TweenLite._internals, 18992 _internals = TimelineLite._internals = {}, 18993 _isSelector = TweenLiteInternals.isSelector, 18994 _isArray = TweenLiteInternals.isArray, 18995 _lazyTweens = TweenLiteInternals.lazyTweens, 18996 _lazyRender = TweenLiteInternals.lazyRender, 18997 _globals = _gsScope._gsDefine.globals, 18998 _copy = function(vars) { 18999 var copy = {}, p; 19000 for (p in vars) { 19001 copy[p] = vars[p]; 19002 } 19003 return copy; 19004 }, 19005 _applyCycle = function(vars, targets, i) { 19006 var alt = vars.cycle, 19007 p, val; 19008 for (p in alt) { 19009 val = alt[p]; 19010 vars[p] = (typeof(val) === "function") ? val(i, targets[i]) : val[i % val.length]; 19011 } 19012 delete vars.cycle; 19013 }, 19014 _pauseCallback = _internals.pauseCallback = function() {}, 19015 _slice = function(a) { //don't use [].slice because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll() 19016 var b = [], 19017 l = a.length, 19018 i; 19019 for (i = 0; i !== l; b.push(a[i++])); 19020 return b; 19021 }, 19022 p = TimelineLite.prototype = new SimpleTimeline(); 19023
19024 TimelineLite.version = "2.0.2"; 19025 p.constructor = TimelineLite; 19026 p.kill()._gc = p._forcingPlayhead = p._hasPause = false; 19027 19028 /* might use later... 19029 //translates a local time inside an animation to the corresponding time on the root/global timeline, factoring in all nesting and timeScales. 19030 function localToGlobal(time, animation) { 19031 while (animation) { 19032 time = (time / animation._timeScale) + animation._startTime; 19033 animation = animation.timeline; 19034 } 19035 return time; 19036 } 19037 19038 //translates the supplied time on the root/global timeline into the corresponding local time inside a particular animation, factoring in all nesting and timeScales 19039 function globalToLocal(time, animation) { 19040 var scale = 1; 19041 time -= localToGlobal(0, animation); 19042 while (animation) { 19043 scale *= animation._timeScale; 19044 animation = animation.timeline; 19045 } 19046 return time * scale; 19047 } 19048 */ 19049 19050 p.to = function(target, duration, vars, position) { 19051 var Engine = (vars.repeat && _globals.TweenMax) || TweenLite; 19052 return duration ? this.add( new Engine(target, duration, vars), position) : this.set(target, vars, position); 19053 }; 19054 19055 p.from = function(target, duration, vars, position) { 19056 return this.add( ((vars.repeat && _globals.TweenMax) || TweenLite).from(target, duration, vars), position); 19057 }; 19058 19059 p.fromTo = function(target, duration, fromVars, toVars, position) { 19060 var Engine = (toVars.repeat && _globals.TweenMax) || TweenLite; 19061 return duration ? this.add( Engine.fromTo(target, duration, fromVars, toVars), position) : this.set(target, toVars, position); 19062 }; 19063 19064 p.staggerTo = function(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope) { 19065 var tl = new TimelineLite({onComplete:onCompleteAll, onCompleteParams:onCompleteAllParams, callbackScope:onCompleteAllScope, smoothChildTiming:this.smoothChildTiming}), 19066 cycle = vars.cycle, 19067 copy, i; 19068 if (typeof(targets) === "string") { 19069 targets = TweenLite.selector(targets) || targets; 19070 } 19071 targets = targets || []; 19072 if (_isSelector(targets)) { //senses if the targets object is a selector. If it is, we should translate it into an array. 19073 targets = _slice(targets); 19074 } 19075 stagger = stagger || 0; 19076 if (stagger < 0) { 19077 targets = _slice(targets); 19078 targets.reverse(); 19079 stagger *= -1; 19080 } 19081 for (i = 0; i < targets.length; i++) { 19082 copy = _copy(vars); 19083 if (copy.startAt) { 19084 copy.startAt = _copy(copy.startAt); 19085 if (copy.startAt.cycle) { 19086 _applyCycle(copy.startAt, targets, i); 19087 } 19088 } 19089 if (cycle) { 19090 _applyCycle(copy, targets, i); 19091 if (copy.duration != null) { 19092 duration = copy.duration; 19093 delete copy.duration; 19094 } 19095 } 19096 tl.to(targets[i], duration, copy, i * stagger); 19097 } 19098 return this.add(tl, position); 19099 }; 19100 19101 p.staggerFrom = function(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope) { 19102 vars.immediateRender = (vars.immediateRender != false); 19103 vars.runBackwards = true; 19104 return this.staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope); 19105 }; 19106 19107 p.staggerFromTo = function(targets, duration, fromVars, toVars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope) { 19108 toVars.startAt = fromVars; 19109 toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false); 19110 return this.staggerTo(targets, duration, toVars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope); 19111 }; 19112 19113 p.call = function(callback, params, scope, position) { 19114 return this.add( TweenLite.delayedCall(0, callback, params, scope), position); 19115 }; 19116 19117 p.set = function(target, vars, position) { 19118 position = this._parseTimeOrLabel(position, 0, true); 19119 if (vars.immediateRender == null) { 19120 vars.immediateRender = (position === this._time && !this._paused); 19121 } 19122 return this.add( new TweenLite(target, 0, vars), position); 19123 }; 19124 19125 TimelineLite.exportRoot = function(vars, ignoreDelayedCalls) { 19126 vars = vars || {}; 19127 if (vars.smoothChildTiming == null) { 19128 vars.smoothChildTiming = true; 19129 } 19130 var tl = new TimelineLite(vars), 19131 root = tl._timeline, 19132 hasNegativeStart, time, tween, next; 19133 if (ignoreDelayedCalls == null) { 19134 ignoreDelayedCalls = true; 19135 } 19136 root._remove(tl, true); 19137 tl._startTime = 0; 19138 tl._rawPrevTime = tl._time = tl._totalTime = root._time; 19139 tween = root._first; 19140 while (tween) { 19141 next = tween._next; 19142 if (!ignoreDelayedCalls || !(tween instanceof TweenLite && tween.target === tween.vars.onComplete)) { 19143 time = tween._startTime - tween._delay; 19144 if (time < 0) { 19145 hasNegativeStart = 1; 19146 } 19147 tl.add(tween, time); 19148 } 19149 tween = next; 19150 } 19151 root.add(tl, 0); 19152 if (hasNegativeStart) { //calling totalDuration() will force the adjustment necessary to shift the children forward so none of them start before zero, and moves the timeline backwards the same amount, so the playhead is still aligned where it should be globally, but the timeline doesn't have illegal children that start before zero. 19153 tl.totalDuration(); 19154 } 19155 return tl; 19156 }; 19157 19158 p.add = function(value, position, align, stagger) { 19159 var curTime, l, i, child, tl, beforeRawTime; 19160 if (typeof(position) !== "number") { 19161 position = this._parseTimeOrLabel(position, 0, true, value); 19162 } 19163 if (!(value instanceof Animation)) { 19164 if ((value instanceof Array) || (value && value.push && _isArray(value))) {
19165 align = align || "normal"; 19166 stagger = stagger || 0; 19167 curTime = position; 19168 l = value.length; 19169 for (i = 0; i < l; i++) { 19170 if (_isArray(child = value[i])) { 19171 child = new TimelineLite({tweens:child}); 19172 } 19173 this.add(child, curTime); 19174 if (typeof(child) !== "string" && typeof(child) !== "function") { 19175 if (align === "sequence") { 19176 curTime = child._startTime + (child.totalDuration() / child._timeScale); 19177 } else if (align === "start") { 19178 child._startTime -= child.delay(); 19179 } 19180 } 19181 curTime += stagger; 19182 } 19183 return this._uncache(true); 19184 } else if (typeof(value) === "string") { 19185 return this.addLabel(value, position); 19186 } else if (typeof(value) === "function") { 19187 value = TweenLite.delayedCall(0, value); 19188 } else { 19189 throw("Cannot add " + value + " into the timeline; it is not a tween, timeline, function, or string."); 19190 } 19191 } 19192 19193 SimpleTimeline.prototype.add.call(this, value, position); 19194 19195 if (value._time) { //in case, for example, the _startTime is moved on a tween that has already rendered. Imagine it's at its end state, then the startTime is moved WAY later (after the end of this timeline), it should render at its beginning. 19196 curTime = Math.max(0, Math.min(value.totalDuration(), (this.rawTime() - value._startTime) * value._timeScale)); 19197 if (Math.abs(curTime - value._totalTime) > 0.00001) { //if an onComplete restarts the tween in a nested timeline, for example, there could be an endless loop without this logic (v2.0.2), like var masterTL = new TimelineMax({autoRemoveChildren: true}), tl = new TimelineMax(); tl.eventCallback("onComplete", function() { tl.restart() } );tl.fromTo('div', 1.1, { rotation: 0 }, { rotation: 360 }, 0);masterTL.add(tl); 19198 value.render(curTime, false, false); 19199 } 19200 } 19201 19202 //if the timeline has already ended but the inserted tween/timeline extends the duration, we should enable this timeline again so that it renders properly. We should also align the playhead with the parent timeline's when appropriate. 19203 if (this._gc || this._time === this._duration) if (!this._paused) if (this._duration < this.duration()) { 19204 //in case any of the ancestors had completed but should now be enabled... 19205 tl = this; 19206 beforeRawTime = (tl.rawTime() > value._startTime); //if the tween is placed on the timeline so that it starts BEFORE the current rawTime, we should align the playhead (move the timeline). This is because sometimes users will create a timeline, let it finish, and much later append a tween and expect it to run instead of jumping to its end state. While technically one could argue that it should jump to its end state, that's not what users intuitively expect. 19207 while (tl._timeline) { 19208 if (beforeRawTime && tl._timeline.smoothChildTiming) { 19209 tl.totalTime(tl._totalTime, true); //moves the timeline (shifts its startTime) if necessary, and also enables it. 19210 } else if (tl._gc) { 19211 tl._enabled(true, false); 19212 } 19213 tl = tl._timeline; 19214 } 19215 } 19216 19217 return this; 19218 }; 19219 19220 p.remove = function(value) { 19221 if (value instanceof Animation) { 19222 this._remove(value, false); 19223 var tl = value._timeline = value.vars.useFrames ? Animation._rootFramesTimeline : Animation._rootTimeline; //now that it's removed, default it to the root timeline so that if it gets played again, it doesn't jump back into this timeline. 19224 value._startTime = (value._paused ? value._pauseTime : tl._time) - ((!value._reversed ? value._totalTime : value.totalDuration() - value._totalTime) / value._timeScale); //ensure that if it gets played again, the timing is correct. 19225 return this; 19226 } else if (value instanceof Array || (value && value.push && _isArray(value))) { 19227 var i = value.length; 19228 while (--i > -1) { 19229 this.remove(value[i]); 19230 } 19231 return this; 19232 } else if (typeof(value) === "string") { 19233 return this.removeLabel(value); 19234 } 19235 return this.kill(null, value); 19236 }; 19237 19238 p._remove = function(tween, skipDisable) { 19239 SimpleTimeline.prototype._remove.call(this, tween, skipDisable); 19240 var last = this._last; 19241 if (!last) { 19242 this._time = this._totalTime = this._duration = this._totalDuration = 0; 19243 } else if (this._time > this.duration()) { 19244 this._time = this._duration; 19245 this._totalTime = this._totalDuration; 19246 } 19247 return this; 19248 }; 19249 19250 p.append = function(value, offsetOrLabel) { 19251 return this.add(value, this._parseTimeOrLabel(null, offsetOrLabel, true, value)); 19252 }; 19253 19254 p.insert = p.insertMultiple = function(value, position, align, stagger) { 19255 return this.add(value, position || 0, align, stagger); 19256 }; 19257 19258 p.appendMultiple = function(tweens, offsetOrLabel, align, stagger) { 19259 return this.add(tweens, this._parseTimeOrLabel(null, offsetOrLabel, true, tweens), align, stagger); 19260 }; 19261 19262 p.addLabel = function(label, position) { 19263 this._labels[label] = this._parseTimeOrLabel(position); 19264 return this; 19265 }; 19266 19267 p.addPause = function(position, callback, params, scope) { 19268 var t = TweenLite.delayedCall(0, _pauseCallback, params, scope || this); 19269 t.vars.onComplete = t.vars.onReverseComplete = callback;
19270 t.data = "isPause"; 19271 this._hasPause = true; 19272 return this.add(t, position); 19273 }; 19274 19275 p.removeLabel = function(label) { 19276 delete this._labels[label]; 19277 return this; 19278 }; 19279 19280 p.getLabelTime = function(label) { 19281 return (this._labels[label] != null) ? this._labels[label] : -1; 19282 }; 19283 19284 p._parseTimeOrLabel = function(timeOrLabel, offsetOrLabel, appendIfAbsent, ignore) { 19285 var clippedDuration, i; 19286 //if we're about to add a tween/timeline (or an array of them) that's already a child of this timeline, we should remove it first so that it doesn't contaminate the duration(). 19287 if (ignore instanceof Animation && ignore.timeline === this) { 19288 this.remove(ignore); 19289 } else if (ignore && ((ignore instanceof Array) || (ignore.push && _isArray(ignore)))) { 19290 i = ignore.length; 19291 while (--i > -1) { 19292 if (ignore[i] instanceof Animation && ignore[i].timeline === this) { 19293 this.remove(ignore[i]); 19294 } 19295 } 19296 } 19297 clippedDuration = (typeof(timeOrLabel) === "number" && !offsetOrLabel) ? 0 : (this.duration() > 99999999999) ? this.recent().endTime(false) : this._duration; //in case there's a child that infinitely repeats, users almost never intend for the insertion point of a new child to be based on a SUPER long value like that so we clip it and assume the most recently-added child's endTime should be used instead. 19298 if (typeof(offsetOrLabel) === "string") { 19299 return this._parseTimeOrLabel(offsetOrLabel, (appendIfAbsent && typeof(timeOrLabel) === "number" && this._labels[offsetOrLabel] == null) ? timeOrLabel - clippedDuration : 0, appendIfAbsent); 19300 } 19301 offsetOrLabel = offsetOrLabel || 0; 19302 if (typeof(timeOrLabel) === "string" && (isNaN(timeOrLabel) || this._labels[timeOrLabel] != null)) { //if the string is a number like "1", check to see if there's a label with that name, otherwise interpret it as a number (absolute value). 19303 i = timeOrLabel.indexOf("="); 19304 if (i === -1) { 19305 if (this._labels[timeOrLabel] == null) { 19306 return appendIfAbsent ? (this._labels[timeOrLabel] = clippedDuration + offsetOrLabel) : offsetOrLabel; 19307 } 19308 return this._labels[timeOrLabel] + offsetOrLabel; 19309 } 19310 offsetOrLabel = parseInt(timeOrLabel.charAt(i-1) + "1", 10) * Number(timeOrLabel.substr(i+1)); 19311 timeOrLabel = (i > 1) ? this._parseTimeOrLabel(timeOrLabel.substr(0, i-1), 0, appendIfAbsent) : clippedDuration; 19312 } else if (timeOrLabel == null) { 19313 timeOrLabel = clippedDuration; 19314 } 19315 return Number(timeOrLabel) + offsetOrLabel; 19316 }; 19317 19318 p.seek = function(position, suppressEvents) { 19319 return this.totalTime((typeof(position) === "number") ? position : this._parseTimeOrLabel(position), (suppressEvents !== false)); 19320 }; 19321 19322 p.stop = function() { 19323 return this.paused(true); 19324 }; 19325 19326 p.gotoAndPlay = function(position, suppressEvents) { 19327 return this.play(position, suppressEvents); 19328 }; 19329 19330 p.gotoAndStop = function(position, suppressEvents) { 19331 return this.pause(position, suppressEvents); 19332 }; 19333 19334 p.render = function(time, suppressEvents, force) { 19335 if (this._gc) { 19336 this._enabled(true, false); 19337 } 19338 var prevTime = this._time, 19339 totalDur = (!this._dirty) ? this._totalDuration : this.totalDuration(), 19340 prevStart = this._startTime, 19341 prevTimeScale = this._timeScale, 19342 prevPaused = this._paused, 19343 tween, isComplete, next, callback, internalForce, pauseTween, curTime; 19344 if (prevTime !== this._time) { //if totalDuration() finds a child with a negative startTime and smoothChildTiming is true, things get shifted around internally so we need to adjust the time accordingly. For example, if a tween starts at -30 we must shift EVERYTHING forward 30 seconds and move this timeline's startTime backward by 30 seconds so that things align with the playhead (no jump). 19345 time += this._time - prevTime; 19346 } 19347 if (time >= totalDur - 0.0000001 && time >= 0) { //to work around occasional floating point math artifacts. 19348 this._totalTime = this._time = totalDur; 19349 if (!this._reversed) if (!this._hasPausedChild()) { 19350 isComplete = true; 19351 callback = "onComplete"; 19352 internalForce = !!this._timeline.autoRemoveChildren; //otherwise, if the animation is unpaused/activated after it's already finished, it doesn't get removed from the parent timeline. 19353 if (this._duration === 0) if ((time <= 0 && time >= -0.0000001) || this._rawPrevTime < 0 || this._rawPrevTime === _tinyNum) if (this._rawPrevTime !== time && this._first) { 19354 internalForce = true; 19355 if (this._rawPrevTime > _tinyNum) { 19356 callback = "onReverseComplete"; 19357 } 19358 } 19359 } 19360 this._rawPrevTime = (this._duration || !suppressEvents || time || this._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient. 19361 time = totalDur + 0.0001; //to avoid occasional floating point rounding errors - sometimes child tweens/timelines were not being fully completed (their progress might be 0.999999999999998 instead of 1 because when _time - tween._startTime is performed, floating point errors would return a value that was SLIGHTLY off). Try (999999999999.7 - 999999999999) * 1 = 0.699951171875 instead of 0.7. 19362 19363 } else if (time < 0.0000001) { //to work around occasional floating point math artifacts, round super small values to 0. 19364 this._totalTime = this._time = 0; 19365 if (prevTime !== 0 || (this._duration === 0 && this._rawPrevTime !== _tinyNum && (this._rawPrevTime > 0 || (time < 0 && this._rawPrevTime >= 0)))) { 19366 callback = "onReverseComplete"; 19367 isComplete = this._reversed; 19368 } 19369 if (time < 0) { 19370 this._active = false;
19371 if (this._timeline.autoRemoveChildren && this._reversed) { //ensures proper GC if a timeline is resumed after it's finished reversing. 19372 internalForce = isComplete = true; 19373 callback = "onReverseComplete"; 19374 } else if (this._rawPrevTime >= 0 && this._first) { //when going back beyond the start, force a render so that zero-duration tweens that sit at the very beginning render their start values properly. Otherwise, if the parent timeline's playhead lands exactly at this timeline's startTime, and then moves backwards, the zero-duration tweens at the beginning would still be at their end state. 19375 internalForce = true; 19376 } 19377 this._rawPrevTime = time; 19378 } else { 19379 this._rawPrevTime = (this._duration || !suppressEvents || time || this._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient. 19380 if (time === 0 && isComplete) { //if there's a zero-duration tween at the very beginning of a timeline and the playhead lands EXACTLY at time 0, that tween will correctly render its end values, but we need to keep the timeline alive for one more render so that the beginning values render properly as the parent's playhead keeps moving beyond the begining. Imagine obj.x starts at 0 and then we do tl.set(obj, {x:100}).to(obj, 1, {x:200}) and then later we tl.reverse()...the goal is to have obj.x revert to 0. If the playhead happens to land on exactly 0, without this chunk of code, it'd complete the timeline and remove it from the rendering queue (not good). 19381 tween = this._first; 19382 while (tween && tween._startTime === 0) { 19383 if (!tween._duration) { 19384 isComplete = false; 19385 } 19386 tween = tween._next; 19387 } 19388 } 19389 time = 0; //to avoid occasional floating point rounding errors (could cause problems especially with zero-duration tweens at the very beginning of the timeline) 19390 if (!this._initted) { 19391 internalForce = true; 19392 } 19393 } 19394 19395 } else { 19396 19397 if (this._hasPause && !this._forcingPlayhead && !suppressEvents) { 19398 if (time >= prevTime) { 19399 tween = this._first; 19400 while (tween && tween._startTime <= time && !pauseTween) { 19401 if (!tween._duration) if (tween.data === "isPause" && !tween.ratio && !(tween._startTime === 0 && this._rawPrevTime === 0)) { 19402 pauseTween = tween; 19403 } 19404 tween = tween._next; 19405 } 19406 } else { 19407 tween = this._last; 19408 while (tween && tween._startTime >= time && !pauseTween) { 19409 if (!tween._duration) if (tween.data === "isPause" && tween._rawPrevTime > 0) { 19410 pauseTween = tween; 19411 } 19412 tween = tween._prev; 19413 } 19414 } 19415 if (pauseTween) { 19416 this._time = time = pauseTween._startTime; 19417 this._totalTime = time + (this._cycle * (this._totalDuration + this._repeatDelay)); 19418 } 19419 } 19420 19421 this._totalTime = this._time = this._rawPrevTime = time; 19422 } 19423 if ((this._time === prevTime || !this._first) && !force && !internalForce && !pauseTween) { 19424 return; 19425 } else if (!this._initted) { 19426 this._initted = true; 19427 } 19428 19429 if (!this._active) if (!this._paused && this._time !== prevTime && time > 0) { 19430 this._active = true; //so that if the user renders the timeline (as opposed to the parent timeline rendering it), it is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the timeline already finished but the user manually re-renders it as halfway done, for example. 19431 } 19432 19433 if (prevTime === 0) if (this.vars.onStart) if (this._time !== 0 || !this._duration) if (!suppressEvents) { 19434 this._callback("onStart"); 19435 } 19436 19437 curTime = this._time; 19438 if (curTime >= prevTime) { 19439 tween = this._first; 19440 while (tween) { 19441 next = tween._next; //record it here because the value could change after rendering... 19442 if (curTime !== this._time || (this._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete 19443 break; 19444 } else if (tween._active || (tween._startTime <= curTime && !tween._paused && !tween._gc)) { 19445 if (pauseTween === tween) { 19446 this.pause(); 19447 } 19448 if (!tween._reversed) { 19449 tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force); 19450 } else { 19451 tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force); 19452 } 19453 } 19454 tween = next; 19455 } 19456 } else { 19457 tween = this._last; 19458 while (tween) { 19459 next = tween._prev; //record it here because the value could change after rendering... 19460 if (curTime !== this._time || (this._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete 19461 break; 19462 } else if (tween._active || (tween._startTime <= prevTime && !tween._paused && !tween._gc)) { 19463 if (pauseTween === tween) { 19464 pauseTween = tween._prev; //the linked list is organized by _startTime, thus it's possible that a tween could start BEFORE the pause and end after it, in which case it would be positioned before the pause tween in the linked list, but we should render it before we pause() the timeline and cease rendering. This is only a concern when going in reverse. 19465 while (pauseTween && pauseTween.endTime() > this._time) { 19466 pauseTween.render( (pauseTween._reversed ? pauseTween.totalDuration() - ((time - pauseTween._startTime) * pauseTween._timeScale) : (time - pauseTween._startTime) * pauseTween._timeScale), suppressEvents, force); 19467 pauseTween = pauseTween._prev; 19468 } 19469 pauseTween = null; 19470 this.pause(); 19471 } 19472 if (!tween._reversed) { 19473 tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force); 19474 } else { 19475 tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force); 19476 } 19477 } 19478 tween = next; 19479 } 19480 } 19481 19482 if (this._onUpdate) if (!suppressEvents) { 19483 if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onUpdate on a timeline that reports/checks tweened values. 19484 _lazyRender(); 19485 }
19486 this._callback("onUpdate"); 19487 } 19488 19489 if (callback) if (!this._gc) if (prevStart === this._startTime || prevTimeScale !== this._timeScale) if (this._time === 0 || totalDur >= this.totalDuration()) { //if one of the tweens that was rendered altered this timeline's startTime (like if an onComplete reversed the timeline), it probably isn't complete. If it is, don't worry, because whatever call altered the startTime would complete if it was necessary at the new time. The only exception is the timeScale property. Also check _gc because there's a chance that kill() could be called in an onUpdate 19490 if (isComplete) { 19491 if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onComplete on a timeline that reports/checks tweened values. 19492 _lazyRender(); 19493 } 19494 if (this._timeline.autoRemoveChildren) { 19495 this._enabled(false, false); 19496 } 19497 this._active = false; 19498 } 19499 if (!suppressEvents && this.vars[callback]) { 19500 this._callback(callback); 19501 } 19502 } 19503 }; 19504 19505 p._hasPausedChild = function() { 19506 var tween = this._first; 19507 while (tween) { 19508 if (tween._paused || ((tween instanceof TimelineLite) && tween._hasPausedChild())) { 19509 return true; 19510 } 19511 tween = tween._next; 19512 } 19513 return false; 19514 }; 19515 19516 p.getChildren = function(nested, tweens, timelines, ignoreBeforeTime) { 19517 ignoreBeforeTime = ignoreBeforeTime || -9999999999; 19518 var a = [], 19519 tween = this._first, 19520 cnt = 0; 19521 while (tween) { 19522 if (tween._startTime < ignoreBeforeTime) { 19523 //do nothing 19524 } else if (tween instanceof TweenLite) { 19525 if (tweens !== false) { 19526 a[cnt++] = tween; 19527 } 19528 } else { 19529 if (timelines !== false) { 19530 a[cnt++] = tween; 19531 } 19532 if (nested !== false) { 19533 a = a.concat(tween.getChildren(true, tweens, timelines)); 19534 cnt = a.length; 19535 } 19536 } 19537 tween = tween._next; 19538 } 19539 return a; 19540 }; 19541 19542 p.getTweensOf = function(target, nested) { 19543 var disabled = this._gc, 19544 a = [], 19545 cnt = 0, 19546 tweens, i; 19547 if (disabled) { 19548 this._enabled(true, true); //getTweensOf() filters out disabled tweens, and we have to mark them as _gc = true when the timeline completes in order to allow clean garbage collection, so temporarily re-enable the timeline here. 19549 } 19550 tweens = TweenLite.getTweensOf(target); 19551 i = tweens.length; 19552 while (--i > -1) { 19553 if (tweens[i].timeline === this || (nested && this._contains(tweens[i]))) { 19554 a[cnt++] = tweens[i]; 19555 } 19556 } 19557 if (disabled) { 19558 this._enabled(false, true); 19559 } 19560 return a; 19561 }; 19562 19563 p.recent = function() { 19564 return this._recent; 19565 }; 19566 19567 p._contains = function(tween) { 19568 var tl = tween.timeline; 19569 while (tl) { 19570 if (tl === this) { 19571 return true; 19572 } 19573 tl = tl.timeline; 19574 } 19575 return false; 19576 }; 19577 19578 p.shiftChildren = function(amount, adjustLabels, ignoreBeforeTime) { 19579 ignoreBeforeTime = ignoreBeforeTime || 0; 19580 var tween = this._first, 19581 labels = this._labels, 19582 p; 19583 while (tween) { 19584 if (tween._startTime >= ignoreBeforeTime) { 19585 tween._startTime += amount; 19586 } 19587 tween = tween._next; 19588 }
19589 if (adjustLabels) { 19590 for (p in labels) { 19591 if (labels[p] >= ignoreBeforeTime) { 19592 labels[p] += amount; 19593 } 19594 } 19595 } 19596 return this._uncache(true); 19597 }; 19598 19599 p._kill = function(vars, target) { 19600 if (!vars && !target) { 19601 return this._enabled(false, false); 19602 } 19603 var tweens = (!target) ? this.getChildren(true, true, false) : this.getTweensOf(target), 19604 i = tweens.length, 19605 changed = false; 19606 while (--i > -1) { 19607 if (tweens[i]._kill(vars, target)) { 19608 changed = true; 19609 } 19610 } 19611 return changed; 19612 }; 19613 19614 p.clear = function(labels) { 19615 var tweens = this.getChildren(false, true, true), 19616 i = tweens.length; 19617 this._time = this._totalTime = 0; 19618 while (--i > -1) { 19619 tweens[i]._enabled(false, false); 19620 } 19621 if (labels !== false) { 19622 this._labels = {}; 19623 } 19624 return this._uncache(true); 19625 }; 19626 19627 p.invalidate = function() { 19628 var tween = this._first; 19629 while (tween) { 19630 tween.invalidate(); 19631 tween = tween._next; 19632 } 19633 return Animation.prototype.invalidate.call(this);; 19634 }; 19635 19636 p._enabled = function(enabled, ignoreTimeline) { 19637 if (enabled === this._gc) { 19638 var tween = this._first; 19639 while (tween) { 19640 tween._enabled(enabled, true); 19641 tween = tween._next; 19642 } 19643 } 19644 return SimpleTimeline.prototype._enabled.call(this, enabled, ignoreTimeline); 19645 }; 19646 19647 p.totalTime = function(time, suppressEvents, uncapped) { 19648 this._forcingPlayhead = true; 19649 var val = Animation.prototype.totalTime.apply(this, arguments); 19650 this._forcingPlayhead = false; 19651 return val; 19652 }; 19653 19654 p.duration = function(value) { 19655 if (!arguments.length) { 19656 if (this._dirty) { 19657 this.totalDuration(); //just triggers recalculation 19658 } 19659 return this._duration; 19660 } 19661 if (this.duration() !== 0 && value !== 0) { 19662 this.timeScale(this._duration / value); 19663 } 19664 return this; 19665 }; 19666 19667 p.totalDuration = function(value) { 19668 if (!arguments.length) { 19669 if (this._dirty) { 19670 var max = 0, 19671 tween = this._last, 19672 prevStart = 999999999999, 19673 prev, end; 19674 while (tween) { 19675 prev = tween._prev; //record it here in case the tween changes position in the sequence... 19676 if (tween._dirty) { 19677 tween.totalDuration(); //could change the tween._startTime, so make sure the tween's cache is clean before analyzing it. 19678 } 19679 if (tween._startTime > prevStart && this._sortChildren && !tween._paused && !this._calculatingDuration) { //in case one of the tweens shifted out of order, it needs to be re-inserted into the correct position in the sequence 19680 this._calculatingDuration = 1; //prevent endless recursive calls - there are methods that get triggered that check duration/totalDuration when we add(), like _parseTimeOrLabel(). 19681 this.add(tween, tween._startTime - tween._delay); 19682 this._calculatingDuration = 0; 19683 } else { 19684 prevStart = tween._startTime; 19685 } 19686 if (tween._startTime < 0 && !tween._paused) { //children aren't allowed to have negative startTimes unless smoothChildTiming is true, so adjust here if one is found. 19687 max -= tween._startTime; 19688 if (this._timeline.smoothChildTiming) { 19689 this._startTime += tween._startTime / this._timeScale; 19690 this._time -= tween._startTime; 19691 this._totalTime -= tween._startTime; 19692 this._rawPrevTime -= tween._startTime; 19693 } 19694 this.shiftChildren(-tween._startTime, false, -9999999999); 19695 prevStart = 0; 19696 } 19697 end = tween._startTime + (tween._totalDuration / tween._timeScale); 19698 if (end > max) { 19699 max = end; 19700 } 19701 tween = prev; 19702 } 19703 this._duration = this._totalDuration = max; 19704 this._dirty = false; 19705 } 19706 return this._totalDuration; 19707 } 19708 return (value && this.totalDuration()) ? this.timeScale(this._totalDuration / value) : this; 19709 }; 19710 19711 p.paused = function(value) { 19712 if (!value) { //if there's a pause directly at the spot from where we're unpausing, skip it. 19713 var tween = this._first, 19714 time = this._time; 19715 while (tween) { 19716 if (tween._startTime === time && tween.data === "isPause") { 19717 tween._rawPrevTime = 0; //remember, _rawPrevTime is how zero-duration tweens/callbacks sense directionality and determine whether or not to fire. If _rawPrevTime is the same as _startTime on the next render, it won't fire. 19718 } 19719 tween = tween._next; 19720 } 19721 } 19722 return Animation.prototype.paused.apply(this, arguments); 19723 }; 19724 19725 p.usesFrames = function() { 19726 var tl = this._timeline; 19727 while (tl._timeline) { 19728 tl = tl._timeline; 19729 } 19730 return (tl === Animation._rootFramesTimeline); 19731 }; 19732 19733 p.rawTime = function(wrapRepeats) { 19734 return (wrapRepeats && (this._paused || (this._repeat && this.time() > 0 && this.totalProgress() < 1))) ? this._totalTime % (this._duration + this._repeatDelay) : this._paused ? this._totalTime : (this._timeline.rawTime(wrapRepeats) - this._startTime) * this._timeScale; 19735 }; 19736 19737 return TimelineLite; 19738 19739 }, true); 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753/* 19754 * ---------------------------------------------------------------- 19755 * TimelineMax 19756 * ---------------------------------------------------------------- 19757 */ 19758 _gsScope._gsDefine("TimelineMax", ["TimelineLite","TweenLite","easing.Ease"], function(TimelineLite, TweenLite, Ease) { 19759 19760 var TimelineMax = function(vars) { 19761 TimelineLite.call(this, vars); 19762 this._repeat = this.vars.repeat || 0; 19763 this._repeatDelay = this.vars.repeatDelay || 0; 19764 this._cycle = 0; 19765 this._yoyo = (this.vars.yoyo === true); 19766 this._dirty = true; 19767 }, 19768 _tinyNum = 0.0000000001, 19769 TweenLiteInternals = TweenLite._internals, 19770 _lazyTweens = TweenLiteInternals.lazyTweens, 19771 _lazyRender = TweenLiteInternals.lazyRender, 19772 _globals = _gsScope._gsDefine.globals,
19773 _easeNone = new Ease(null, null, 1, 0), 19774 p = TimelineMax.prototype = new TimelineLite(); 19775 19776 p.constructor = TimelineMax; 19777 p.kill()._gc = false; 19778 TimelineMax.version = "2.0.2"; 19779 19780 p.invalidate = function() { 19781 this._yoyo = (this.vars.yoyo === true); 19782 this._repeat = this.vars.repeat || 0; 19783 this._repeatDelay = this.vars.repeatDelay || 0; 19784 this._uncache(true); 19785 return TimelineLite.prototype.invalidate.call(this); 19786 }; 19787 19788 p.addCallback = function(callback, position, params, scope) { 19789 return this.add( TweenLite.delayedCall(0, callback, params, scope), position); 19790 }; 19791 19792 p.removeCallback = function(callback, position) { 19793 if (callback) { 19794 if (position == null) { 19795 this._kill(null, callback); 19796 } else { 19797 var a = this.getTweensOf(callback, false), 19798 i = a.length, 19799 time = this._parseTimeOrLabel(position); 19800 while (--i > -1) { 19801 if (a[i]._startTime === time) { 19802 a[i]._enabled(false, false); 19803 } 19804 } 19805 } 19806 } 19807 return this; 19808 }; 19809 19810 p.removePause = function(position) { 19811 return this.removeCallback(TimelineLite._internals.pauseCallback, position); 19812 }; 19813 19814 p.tweenTo = function(position, vars) { 19815 vars = vars || {}; 19816 var copy = {ease:_easeNone, useFrames:this.usesFrames(), immediateRender:false, lazy:false}, 19817 Engine = (vars.repeat && _globals.TweenMax) || TweenLite, 19818 duration, p, t; 19819 for (p in vars) { 19820 copy[p] = vars[p]; 19821 } 19822 copy.time = this._parseTimeOrLabel(position); 19823 duration = (Math.abs(Number(copy.time) - this._time) / this._timeScale) || 0.001; 19824 t = new Engine(this, duration, copy); 19825 copy.onStart = function() { 19826 t.target.paused(true); 19827 if (t.vars.time !== t.target.time() && duration === t.duration() && !t.isFromTo) { //don't make the duration zero - if it's supposed to be zero, don't worry because it's already initting the tween and will complete immediately, effectively making the duration zero anyway. If we make duration zero, the tween won't run at all. 19828 t.duration( Math.abs( t.vars.time - t.target.time()) / t.target._timeScale ).render(t.time(), true, true); //render() right away to ensure that things look right, especially in the case of .tweenTo(0). 19829 } 19830 if (vars.onStart) { //in case the user had an onStart in the vars - we don't want to overwrite it. 19831 vars.onStart.apply(vars.onStartScope || vars.callbackScope || t, vars.onStartParams || []); //don't use t._callback("onStart") or it'll point to the copy.onStart and we'll get a recursion error. 19832 } 19833 }; 19834 return t; 19835 }; 19836 19837 p.tweenFromTo = function(fromPosition, toPosition, vars) { 19838 vars = vars || {}; 19839 fromPosition = this._parseTimeOrLabel(fromPosition); 19840 vars.startAt = {onComplete:this.seek, onCompleteParams:[fromPosition], callbackScope:this}; 19841 vars.immediateRender = (vars.immediateRender !== false); 19842 var t = this.tweenTo(toPosition, vars); 19843 t.isFromTo = 1; //to ensure we don't mess with the duration in the onStart (we've got the start and end values here, so lock it in) 19844 return t.duration((Math.abs( t.vars.time - fromPosition) / this._timeScale) || 0.001); 19845 }; 19846 19847 p.render = function(time, suppressEvents, force) { 19848 if (this._gc) { 19849 this._enabled(true, false); 19850 } 19851 var prevTime = this._time, 19852 totalDur = (!this._dirty) ? this._totalDuration : this.totalDuration(), 19853 dur = this._duration, 19854 prevTotalTime = this._totalTime, 19855 prevStart = this._startTime, 19856 prevTimeScale = this._timeScale, 19857 prevRawPrevTime = this._rawPrevTime, 19858 prevPaused = this._paused, 19859 prevCycle = this._cycle, 19860 tween, isComplete, next, callback, internalForce, cycleDuration, pauseTween, curTime; 19861 if (prevTime !== this._time) { //if totalDuration() finds a child with a negative startTime and smoothChildTiming is true, things get shifted around internally so we need to adjust the time accordingly. For example, if a tween starts at -30 we must shift EVERYTHING forward 30 seconds and move this timeline's startTime backward by 30 seconds so that things align with the playhead (no jump). 19862 time += this._time - prevTime; 19863 } 19864 if (time >= totalDur - 0.0000001 && time >= 0) { //to work around occasional floating point math artifacts. 19865 if (!this._locked) { 19866 this._totalTime = totalDur; 19867 this._cycle = this._repeat; 19868 } 19869 if (!this._reversed) if (!this._hasPausedChild()) { 19870 isComplete = true; 19871 callback = "onComplete"; 19872 internalForce = !!this._timeline.autoRemoveChildren; //otherwise, if the animation is unpaused/activated after it's already finished, it doesn't get removed from the parent timeline. 19873 if (this._duration === 0) if ((time <= 0 && time >= -0.0000001) || prevRawPrevTime < 0 || prevRawPrevTime === _tinyNum) if (prevRawPrevTime !== time && this._first) { 19874 internalForce = true; 19875 if (prevRawPrevTime > _tinyNum) { 19876 callback = "onReverseComplete"; 19877 } 19878 } 19879 } 19880 this._rawPrevTime = (this._duration || !suppressEvents || time || this._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient. 19881 if (this._yoyo && (this._cycle & 1) !== 0) { 19882 this._time = time = 0; 19883 } else { 19884 this._time = dur; 19885 time = dur + 0.0001; //to avoid occasional floating point rounding errors - sometimes child tweens/timelines were not being fully completed (their progress might be 0.999999999999998 instead of 1 because when _time - tween._startTime is performed, floating point errors would return a value that was SLIGHTLY off). Try (999999999999.7 - 999999999999) * 1 = 0.699951171875 instead of 0.7. We cannot do less then 0.0001 because the same issue can occur when the duration is extremely large like 999999999999 in
19885which case adding 0.00000001, for example, causes it to act like nothing was added. 19886 } 19887 19888 } else if (time < 0.0000001) { //to work around occasional floating point math artifacts, round super small values to 0. 19889 if (!this._locked) { 19890 this._totalTime = this._cycle = 0; 19891 } 19892 this._time = 0; 19893 if (prevTime !== 0 || (dur === 0 && prevRawPrevTime !== _tinyNum && (prevRawPrevTime > 0 || (time < 0 && prevRawPrevTime >= 0)) && !this._locked)) { //edge case for checking time < 0 && prevRawPrevTime >= 0: a zero-duration fromTo() tween inside a zero-duration timeline (yeah, very rare) 19894 callback = "onReverseComplete"; 19895 isComplete = this._reversed; 19896 } 19897 if (time < 0) { 19898 this._active = false; 19899 if (this._timeline.autoRemoveChildren && this._reversed) { 19900 internalForce = isComplete = true; 19901 callback = "onReverseComplete"; 19902 } else if (prevRawPrevTime >= 0 && this._first) { //when going back beyond the start, force a render so that zero-duration tweens that sit at the very beginning render their start values properly. Otherwise, if the parent timeline's playhead lands exactly at this timeline's startTime, and then moves backwards, the zero-duration tweens at the beginning would still be at their end state. 19903 internalForce = true; 19904 } 19905 this._rawPrevTime = time; 19906 } else { 19907 this._rawPrevTime = (dur || !suppressEvents || time || this._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient. 19908 if (time === 0 && isComplete) { //if there's a zero-duration tween at the very beginning of a timeline and the playhead lands EXACTLY at time 0, that tween will correctly render its end values, but we need to keep the timeline alive for one more render so that the beginning values render properly as the parent's playhead keeps moving beyond the begining. Imagine obj.x starts at 0 and then we do tl.set(obj, {x:100}).to(obj, 1, {x:200}) and then later we tl.reverse()...the goal is to have obj.x revert to 0. If the playhead happens to land on exactly 0, without this chunk of code, it'd complete the timeline and remove it from the rendering queue (not good). 19909 tween = this._first; 19910 while (tween && tween._startTime === 0) { 19911 if (!tween._duration) { 19912 isComplete = false; 19913 } 19914 tween = tween._next; 19915 } 19916 } 19917 time = 0; //to avoid occasional floating point rounding errors (could cause problems especially with zero-duration tweens at the very beginning of the timeline) 19918 if (!this._initted) { 19919 internalForce = true; 19920 } 19921 } 19922 19923 } else { 19924 if (dur === 0 && prevRawPrevTime < 0) { //without this, zero-duration repeating timelines (like with a simple callback nested at the very beginning and a repeatDelay) wouldn't render the first time through. 19925 internalForce = true; 19926 } 19927 this._time = this._rawPrevTime = time; 19928 if (!this._locked) { 19929 this._totalTime = time; 19930 if (this._repeat !== 0) { 19931 cycleDuration = dur + this._repeatDelay; 19932 this._cycle = (this._totalTime / cycleDuration) >> 0; //originally _totalTime % cycleDuration but floating point errors caused problems, so I normalized it. (4 % 0.8 should be 0 but it gets reported as 0.79999999!) 19933 if (this._cycle !== 0) if (this._cycle === this._totalTime / cycleDuration && prevTotalTime <= time) { 19934 this._cycle--; //otherwise when rendered exactly at the end time, it will act as though it is repeating (at the beginning) 19935 } 19936 this._time = this._totalTime - (this._cycle * cycleDuration); 19937 if (this._yoyo) if ((this._cycle & 1) !== 0) { 19938 this._time = dur - this._time; 19939 } 19940 if (this._time > dur) { 19941 this._time = dur; 19942 time = dur + 0.0001; //to avoid occasional floating point rounding error 19943 } else if (this._time < 0) { 19944 this._time = time = 0; 19945 } else { 19946 time = this._time; 19947 } 19948 } 19949 } 19950 19951 if (this._hasPause && !this._forcingPlayhead && !suppressEvents) { 19952 time = this._time; 19953 if (time >= prevTime || (this._repeat && prevCycle !== this._cycle)) { 19954 tween = this._first; 19955 while (tween && tween._startTime <= time && !pauseTween) { 19956 if (!tween._duration) if (tween.data === "isPause" && !tween.ratio && !(tween._startTime === 0 && this._rawPrevTime === 0)) { 19957 pauseTween = tween; 19958 } 19959 tween = tween._next; 19960 } 19961 } else { 19962 tween = this._last; 19963 while (tween && tween._startTime >= time && !pauseTween) { 19964 if (!tween._duration) if (tween.data === "isPause" && tween._rawPrevTime > 0) { 19965 pauseTween = tween; 19966 } 19967 tween = tween._prev; 19968 } 19969 } 19970 if (pauseTween && pauseTween._startTime < dur) { 19971 this._time = time = pauseTween._startTime; 19972 this._totalTime = time + (this._cycle * (this._totalDuration + this._repeatDelay)); 19973 } 19974 } 19975 19976 } 19977 19978 if (this._cycle !== prevCycle) if (!this._locked) { 19979 /* 19980 make sure children at the end/beginning of the timeline are rendered properly. If, for example, 19981 a 3-second long timeline rendered at 2.9 seconds previously, and now renders at 3.2 seconds (which
19982 would get transated to 2.8 seconds if the timeline yoyos or 0.2 seconds if it just repeats), there 19983 could be a callback or a short tween that's at 2.95 or 3 seconds in which wouldn't render. So 19984 we need to push the timeline to the end (and/or beginning depending on its yoyo value). Also we must 19985 ensure that zero-duration tweens at the very beginning or end of the TimelineMax work. 19986 */ 19987 var backwards = (this._yoyo && (prevCycle & 1) !== 0), 19988 wrap = (backwards === (this._yoyo && (this._cycle & 1) !== 0)), 19989 recTotalTime = this._totalTime, 19990 recCycle = this._cycle, 19991 recRawPrevTime = this._rawPrevTime, 19992 recTime = this._time; 19993 19994 this._totalTime = prevCycle * dur; 19995 if (this._cycle < prevCycle) { 19996 backwards = !backwards; 19997 } else { 19998 this._totalTime += dur; 19999 } 20000 this._time = prevTime; //temporarily revert _time so that render() renders the children in the correct order. Without this, tweens won't rewind correctly. We could arhictect things in a "cleaner" way by splitting out the rendering queue into a separate method but for performance reasons, we kept it all inside this method. 20001 20002 this._rawPrevTime = (dur === 0) ? prevRawPrevTime - 0.0001 : prevRawPrevTime; 20003 this._cycle = prevCycle; 20004 this._locked = true; //prevents changes to totalTime and skips repeat/yoyo behavior when we recursively call render() 20005 prevTime = (backwards) ? 0 : dur; 20006 this.render(prevTime, suppressEvents, (dur === 0)); 20007 if (!suppressEvents) if (!this._gc) { 20008 if (this.vars.onRepeat) { 20009 this._cycle = recCycle; //in case the onRepeat alters the playhead or invalidates(), we shouldn't stay locked or use the previous cycle. 20010 this._locked = false; 20011 this._callback("onRepeat"); 20012 } 20013 } 20014 if (prevTime !== this._time) { //in case there's a callback like onComplete in a nested tween/timeline that changes the playhead position, like via seek(), we should just abort. 20015 return; 20016 } 20017 if (wrap) { 20018 this._cycle = prevCycle; //if there's an onRepeat, we reverted this above, so make sure it's set properly again. We also unlocked in that scenario, so reset that too. 20019 this._locked = true; 20020 prevTime = (backwards) ? dur + 0.0001 : -0.0001; 20021 this.render(prevTime, true, false); 20022 } 20023 this._locked = false; 20024 if (this._paused && !prevPaused) { //if the render() triggered callback that paused this timeline, we should abort (very rare, but possible) 20025 return; 20026 } 20027 this._time = recTime; 20028 this._totalTime = recTotalTime; 20029 this._cycle = recCycle; 20030 this._rawPrevTime = recRawPrevTime; 20031 } 20032 20033 if ((this._time === prevTime || !this._first) && !force && !internalForce && !pauseTween) { 20034 if (prevTotalTime !== this._totalTime) if (this._onUpdate) if (!suppressEvents) { //so that onUpdate fires even during the repeatDelay - as long as the totalTime changed, we should trigger onUpdate. 20035 this._callback("onUpdate"); 20036 } 20037 return; 20038 } else if (!this._initted) { 20039 this._initted = true; 20040 } 20041 20042 if (!this._active) if (!this._paused && this._totalTime !== prevTotalTime && time > 0) { 20043 this._active = true; //so that if the user renders the timeline (as opposed to the parent timeline rendering it), it is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the timeline already finished but the user manually re-renders it as halfway done, for example. 20044 } 20045 20046 if (prevTotalTime === 0) if (this.vars.onStart) if (this._totalTime !== 0 || !this._totalDuration) if (!suppressEvents) { 20047 this._callback("onStart"); 20048 } 20049 20050 curTime = this._time; 20051 if (curTime >= prevTime) { 20052 tween = this._first; 20053 while (tween) { 20054 next = tween._next; //record it here because the value could change after rendering... 20055 if (curTime !== this._time || (this._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete 20056 break; 20057 } else if (tween._active || (tween._startTime <= this._time && !tween._paused && !tween._gc)) { 20058 if (pauseTween === tween) { 20059 this.pause(); 20060 } 20061 if (!tween._reversed) { 20062 tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force); 20063 } else { 20064 tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force); 20065 } 20066 } 20067 tween = next; 20068 } 20069 } else { 20070 tween = this._last; 20071 while (tween) { 20072 next = tween._prev; //record it here because the value could change after rendering... 20073 if (curTime !== this._time || (this._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete 20074 break; 20075 } else if (tween._active || (tween._startTime <= prevTime && !tween._paused && !tween._gc)) { 20076 if (pauseTween === tween) { 20077 pauseTween = tween._prev; //the linked list is organized by _startTime, thus it's possible that a tween could start BEFORE the pause and end after it, in which case it would be positioned before the pause tween in the linked list, but we should render it before we pause() the timeline and cease rendering. This is only a concern when going in reverse. 20078 while (pauseTween && pauseTween.endTime() > this._time) { 20079 pauseTween.render( (pauseTween._reversed ? pauseTween.totalDuration() - ((time - pauseTween._startTime) * pauseTween._timeScale) : (time - pauseTween._startTime) * pauseTween._timeScale), suppressEvents, force); 20080 pauseTween = pauseTween._prev; 20081 } 20082 pauseTween = null; 20083 this.pause(); 20084 } 20085 if (!tween._reversed) { 20086 tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force); 20087 } else { 20088 tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force); 20089 } 20090 } 20091 tween = next; 20092 } 20093 } 20094 20095 if (this._onUpdate) if (!suppressEvents) { 20096 if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onUpdate on a timeline that reports/checks tweened values. 20097 _lazyRender(); 20098 }
20099 this._callback("onUpdate"); 20100 } 20101 if (callback) if (!this._locked) if (!this._gc) if (prevStart === this._startTime || prevTimeScale !== this._timeScale) if (this._time === 0 || totalDur >= this.totalDuration()) { //if one of the tweens that was rendered altered this timeline's startTime (like if an onComplete reversed the timeline), it probably isn't complete. If it is, don't worry, because whatever call altered the startTime would complete if it was necessary at the new time. The only exception is the timeScale property. Also check _gc because there's a chance that kill() could be called in an onUpdate 20102 if (isComplete) { 20103 if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onComplete on a timeline that reports/checks tweened values. 20104 _lazyRender(); 20105 } 20106 if (this._timeline.autoRemoveChildren) { 20107 this._enabled(false, false); 20108 } 20109 this._active = false; 20110 } 20111 if (!suppressEvents && this.vars[callback]) { 20112 this._callback(callback); 20113 } 20114 } 20115 }; 20116 20117 p.getActive = function(nested, tweens, timelines) { 20118 if (nested == null) { 20119 nested = true; 20120 } 20121 if (tweens == null) { 20122 tweens = true; 20123 } 20124 if (timelines == null) { 20125 timelines = false; 20126 } 20127 var a = [], 20128 all = this.getChildren(nested, tweens, timelines), 20129 cnt = 0, 20130 l = all.length, 20131 i, tween; 20132 for (i = 0; i < l; i++) { 20133 tween = all[i]; 20134 if (tween.isActive()) { 20135 a[cnt++] = tween; 20136 } 20137 } 20138 return a; 20139 }; 20140 20141 20142 p.getLabelAfter = function(time) { 20143 if (!time) if (time !== 0) { //faster than isNan() 20144 time = this._time; 20145 } 20146 var labels = this.getLabelsArray(), 20147 l = labels.length, 20148 i; 20149 for (i = 0; i < l; i++) { 20150 if (labels[i].time > time) { 20151 return labels[i].name; 20152 } 20153 } 20154 return null; 20155 }; 20156 20157 p.getLabelBefore = function(time) { 20158 if (time == null) { 20159 time = this._time; 20160 } 20161 var labels = this.getLabelsArray(), 20162 i = labels.length; 20163 while (--i > -1) { 20164 if (labels[i].time < time) { 20165 return labels[i].name; 20166 } 20167 } 20168 return null; 20169 }; 20170 20171 p.getLabelsArray = function() { 20172 var a = [], 20173 cnt = 0, 20174 p; 20175 for (p in this._labels) { 20176 a[cnt++] = {time:this._labels[p], name:p}; 20177 } 20178 a.sort(function(a,b) { 20179 return a.time - b.time; 20180 }); 20181 return a; 20182 }; 20183 20184 p.invalidate = function() { 20185 this._locked = false; //unlock and set cycle in case invalidate() is called from inside an onRepeat 20186 return TimelineLite.prototype.invalidate.call(this); 20187 }; 20188 20189 20190//---- GETTERS / SETTERS ------------------------------------------------------------------------------------------------------- 20191 20192 p.progress = function(value, suppressEvents) { 20193 return (!arguments.length) ? (this._time / this.duration()) || 0 : this.totalTime( this.duration() * ((this._yoyo && (this._cycle & 1) !== 0) ? 1 - value : value) + (this._cycle * (this._duration + this._repeatDelay)), suppressEvents); 20194 }; 20195 20196 p.totalProgress = function(value, suppressEvents) { 20197 return (!arguments.length) ? (this._totalTime / this.totalDuration()) || 0 : this.totalTime( this.totalDuration() * value, suppressEvents); 20198 }; 20199 20200 p.totalDuration = function(value) { 20201 if (!arguments.length) { 20202 if (this._dirty) { 20203 TimelineLite.prototype.totalDuration.call(this); //just forces refresh 20204 //Instead of Infinity, we use 999999999999 so that we can accommodate reverses. 20205 this._totalDuration = (this._repeat === -1) ? 999999999999 : this._duration * (this._repeat + 1) + (this._repeatDelay * this._repeat); 20206 } 20207 return this._totalDuration; 20208 } 20209 return (this._repeat === -1 || !value) ? this : this.timeScale( this.totalDuration() / value ); 20210 }; 20211 20212 p.time = function(value, suppressEvents) { 20213 if (!arguments.length) { 20214 return this._time; 20215 } 20216 if (this._dirty) { 20217 this.totalDuration(); 20218 } 20219 if (value > this._duration) { 20220 value = this._duration; 20221 } 20222 if (this._yoyo && (this._cycle & 1) !== 0) { 20223 value = (this._duration - value) + (this._cycle * (this._duration + this._repeatDelay)); 20224 } else if (this._repeat !== 0) { 20225 value += this._cycle * (this._duration + this._repeatDelay); 20226 } 20227 return this.totalTime(value, suppressEvents); 20228 }; 20229 20230 p.repeat = function(value) { 20231 if (!arguments.length) { 20232 return this._repeat; 20233 } 20234 this._repeat = value; 20235 return this._uncache(true); 20236 }; 20237 20238 p.repeatDelay = function(value) { 20239 if (!arguments.length) { 20240 return this._repeatDelay; 20241 } 20242 this._repeatDelay = value; 20243 return this._uncache(true); 20244 }; 20245 20246 p.yoyo = function(value) { 20247 if (!arguments.length) { 20248 return this._yoyo; 20249 } 20250 this._yoyo = value; 20251 return this; 20252 }; 20253 20254 p.currentLabel = function(value) { 20255 if (!arguments.length) { 20256 return this.getLabelBefore(this._time + 0.00000001); 20257 } 20258 return this.seek(value, true); 20259 }; 20260 20261 return TimelineMax; 20262 20263 }, true); 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276/* 20277 * ---------------------------------------------------------------- 20278 * BezierPlugin 20279 * ---------------------------------------------------------------- 20280 */ 20281 (function() { 20282 20283 var _RAD2DEG = 180 / Math.PI, 20284 _r1 = [], 20285 _r2 = [], 20286 _r3 = [], 20287 _corProps = {}, 20288 _globals = _gsScope._gsDefine.globals, 20289 Segment = function(a, b, c, d) { 20290 if (c === d) { //if c and d match, the final autoRotate value could lock at -90 degrees, so differentiate them slightly. 20291 c = d - (d - b) / 1000000; 20292 } 20293 if (a === b) { //if a and b match, the starting autoRotate value could lock at -90 degrees, so differentiate them slightly. 20294 b = a + (c - a) / 1000000; 20295 } 20296 this.a = a; 20297 this.b = b; 20298 this.c = c; 20299 this.d = d; 20300 this.da = d - a; 20301 this.ca = c - a; 20302 this.ba = b - a; 20303 }, 20304 _correlate = ",x,y,z,left,top,right,bottom,marginTop,marginLeft,marginRight,marginBottom,paddingLeft,paddingTop,paddingRight,paddingBottom,backgroundPosition,backgroundPosition_y,", 20305 cubicToQuadratic = function(a, b, c, d) { 20306 var q1 = {a:a}, 20307 q2 = {}, 20308 q3 = {}, 20309 q4 = {c:d}, 20310 mab = (a + b) / 2, 20311 mbc = (b + c) / 2, 20312 mcd = (c + d) / 2, 20313 mabc = (mab + mbc) / 2, 20314 mbcd = (mbc + mcd) / 2, 20315 m8 = (mbcd - mabc) / 8; 20316 q1.b = mab + (a - mab) / 4; 20317 q2.b = mabc + m8; 20318 q1.c = q2.a = (q1.b + q2.b) / 2; 20319 q2.c = q3.a = (mabc + mbcd) / 2; 20320 q3.b = mbcd - m8; 20321 q4.b = mcd + (d - mcd) / 4; 20322 q3.c = q4.a = (q3.b + q4.b) / 2; 20323 return [q1, q2, q3, q4]; 20324 }, 20325 _calculateControlPoints = function(a, curviness, quad, basic, correlate) { 20326 var l = a.length - 1, 20327 ii = 0, 20328 cp1 = a[0].a, 20329 i, p1, p2, p3, seg, m1, m2, mm, cp2, qb, r1, r2, tl; 20330 for (i = 0; i < l; i++) { 20331 seg = a[ii]; 20332 p1 = seg.a; 20333 p2 = seg.d; 20334 p3 = a[ii+1].d; 20335 20336 if (correlate) { 20337 r1 = _r1[i]; 20338 r2 = _r2[i]; 20339 tl = ((r2 + r1) * curviness * 0.25) / (basic ? 0.5 : _r3[i] || 0.5); 20340 m1 = p2 - (p2 - p1) * (basic ? curviness * 0.5 : (r1 !== 0 ? tl / r1 : 0)); 20341 m2 = p2 + (p3 - p2) * (basic ? curviness * 0.5 : (r2 !== 0 ? tl / r2 : 0)); 20342 mm = p2 - (m1 + (((m2 - m1) * ((r1 * 3 / (r1 + r2)) + 0.5) / 4) || 0)); 20343 } else { 20344 m1 = p2 - (p2 - p1) * curviness * 0.5; 20345 m2 = p2 + (p3 - p2) * curviness * 0.5; 20346 mm = p2 - (m1 + m2) / 2; 20347 } 20348 m1 += mm; 20349 m2 += mm; 20350 20351 seg.c = cp2 = m1; 20352 if (i !== 0) { 20353 seg.b = cp1; 20354 } else { 20355 seg.b = cp1 = seg.a + (seg.c - seg.a) * 0.6; //instead of placing b on a exactly, we move it inline with c so that if the user specifies an ease like Back.easeIn or Elastic.easeIn which goes BEYOND the beginning, it will do so smoothly. 20356 } 20357 20358 seg.da = p2 - p1; 20359 seg.ca = cp2 - p1; 20360 seg.ba = cp1 - p1; 20361 20362 if (quad) { 20363 qb = cubicToQuadratic(p1, cp1, cp2, p2); 20364 a.splice(ii, 1, qb[0], qb[1], qb[2], qb[3]); 20365 ii += 4; 20366 } else { 20367 ii++; 20368 } 20369 20370 cp1 = m2; 20371 } 20372 seg = a[ii]; 20373 seg.b = cp1; 20374 seg.c = cp1 + (seg.d - cp1) * 0.4; //instead of placing c on d exactly, we move it inline with b so that if the user specifies an ease like Back.easeOut or Elastic.easeOut which goes BEYOND the end, it will do so smoothly. 20375 seg.da = seg.d - seg.a; 20376 seg.ca = seg.c - seg.a; 20377 seg.ba = cp1 - seg.a; 20378 if (quad) { 20379 qb = cubicToQuadratic(seg.a, cp1, seg.c, seg.d); 20380 a.splice(ii, 1, qb[0], qb[1], qb[2], qb[3]); 20381 } 20382 }, 20383 _parseAnchors = function(values, p, correlate, prepend) { 20384 var a = [], 20385 l, i, p1, p2, p3, tmp; 20386 if (prepend) {
20387 values = [prepend].concat(values); 20388 i = values.length; 20389 while (--i > -1) { 20390 if (typeof( (tmp = values[i][p]) ) === "string") if (tmp.charAt(1) === "=") { 20391 values[i][p] = prepend[p] + Number(tmp.charAt(0) + tmp.substr(2)); //accommodate relative values. Do it inline instead of breaking it out into a function for speed reasons 20392 } 20393 } 20394 } 20395 l = values.length - 2; 20396 if (l < 0) { 20397 a[0] = new Segment(values[0][p], 0, 0, values[0][p]); 20398 return a; 20399 } 20400 for (i = 0; i < l; i++) { 20401 p1 = values[i][p]; 20402 p2 = values[i+1][p]; 20403 a[i] = new Segment(p1, 0, 0, p2); 20404 if (correlate) { 20405 p3 = values[i+2][p]; 20406 _r1[i] = (_r1[i] || 0) + (p2 - p1) * (p2 - p1); 20407 _r2[i] = (_r2[i] || 0) + (p3 - p2) * (p3 - p2); 20408 } 20409 } 20410 a[i] = new Segment(values[i][p], 0, 0, values[i+1][p]); 20411 return a; 20412 }, 20413 bezierThrough = function(values, curviness, quadratic, basic, correlate, prepend) { 20414 var obj = {}, 20415 props = [], 20416 first = prepend || values[0], 20417 i, p, a, j, r, l, seamless, last; 20418 correlate = (typeof(correlate) === "string") ? ","+correlate+"," : _correlate; 20419 if (curviness == null) { 20420 curviness = 1; 20421 } 20422 for (p in values[0]) { 20423 props.push(p); 20424 } 20425 //check to see if the last and first values are identical (well, within 0.05). If so, make seamless by appending the second element to the very end of the values array and the 2nd-to-last element to the very beginning (we'll remove those segments later) 20426 if (values.length > 1) { 20427 last = values[values.length - 1]; 20428 seamless = true; 20429 i = props.length; 20430 while (--i > -1) { 20431 p = props[i]; 20432 if (Math.abs(first[p] - last[p]) > 0.05) { //build in a tolerance of +/-0.05 to accommodate rounding errors. 20433 seamless = false; 20434 break; 20435 } 20436 } 20437 if (seamless) { 20438 values = values.concat(); //duplicate the array to avoid contaminating the original which the user may be reusing for other tweens 20439 if (prepend) { 20440 values.unshift(prepend); 20441 } 20442 values.push(values[1]); 20443 prepend = values[values.length - 3]; 20444 } 20445 } 20446 _r1.length = _r2.length = _r3.length = 0; 20447 i = props.length; 20448 while (--i > -1) { 20449 p = props[i]; 20450 _corProps[p] = (correlate.indexOf(","+p+",") !== -1); 20451 obj[p] = _parseAnchors(values, p, _corProps[p], prepend); 20452 } 20453 i = _r1.length; 20454 while (--i > -1) { 20455 _r1[i] = Math.sqrt(_r1[i]); 20456 _r2[i] = Math.sqrt(_r2[i]); 20457 } 20458 if (!basic) { 20459 i = props.length; 20460 while (--i > -1) { 20461 if (_corProps[p]) { 20462 a = obj[props[i]]; 20463 l = a.length - 1; 20464 for (j = 0; j < l; j++) { 20465 r = (a[j+1].da / _r2[j] + a[j].da / _r1[j]) || 0; 20466 _r3[j] = (_r3[j] || 0) + r * r; 20467 } 20468 } 20469 } 20470 i = _r3.length; 20471 while (--i > -1) { 20472 _r3[i] = Math.sqrt(_r3[i]); 20473 } 20474 } 20475 i = props.length; 20476 j = quadratic ? 4 : 1; 20477 while (--i > -1) { 20478 p = props[i]; 20479 a = obj[p]; 20480 _calculateControlPoints(a, curviness, quadratic, basic, _corProps[p]); //this method requires that _parseAnchors() and _setSegmentRatios() ran first so that _r1, _r2, and _r3 values are populated for all properties 20481 if (seamless) { 20482 a.splice(0, j); 20483 a.splice(a.length - j, j); 20484 } 20485 } 20486 return obj; 20487 }, 20488 _parseBezierData = function(values, type, prepend) { 20489 type = type || "soft"; 20490 var obj = {}, 20491 inc = (type === "cubic") ? 3 : 2, 20492 soft = (type === "soft"), 20493 props = [], 20494 a, b, c, d, cur, i, j, l, p, cnt, tmp; 20495 if (soft && prepend) { 20496 values = [prepend].concat(values); 20497 } 20498 if (values == null || values.length < inc + 1) { throw "invalid Bezier data"; } 20499 for (p in values[0]) { 20500 props.push(p); 20501 } 20502 i = props.length; 20503 while (--i > -1) { 20504 p = props[i]; 20505 obj[p] = cur = []; 20506 cnt = 0; 20507 l = values.length; 20508 for (j = 0; j < l; j++) { 20509 a = (prepend == null) ? values[j][p] : (typeof( (tmp = values[j][p]) ) === "string" && tmp.charAt(1) === "=") ? prepend[p] + Number(tmp.charAt(0) + tmp.substr(2)) : Number(tmp); 20510 if (soft) if (j > 1) if (j < l - 1) { 20511 cur[cnt++] = (a + cur[cnt-2]) / 2; 20512 } 20513 cur[cnt++] = a; 20514 } 20515 l = cnt - inc + 1; 20516 cnt = 0; 20517 for (j = 0; j < l; j += inc) { 20518 a = cur[j]; 20519 b = cur[j+1]; 20520 c = cur[j+2]; 20521 d = (inc === 2) ? 0 : cur[j+3]; 20522 cur[cnt++] = tmp = (inc === 3) ? new Segment(a, b, c, d) : new Segment(a, (2 * b + a) / 3, (2 * b + c) / 3, c); 20523 } 20524 cur.length = cnt; 20525 } 20526 return obj; 20527 }, 20528 _addCubicLengths = function(a, steps, resolution) { 20529 var inc = 1 / resolution, 20530 j = a.length, 20531 d, d1, s, da, ca, ba, p, i, inv, bez, index; 20532 while (--j > -1) { 20533 bez = a[j]; 20534 s = bez.a; 20535 da = bez.d - s; 20536 ca = bez.c - s; 20537 ba = bez.b - s; 20538 d = d1 = 0; 20539 for (i = 1; i <= resolution; i++) { 20540 p = inc * i; 20541 inv = 1 - p; 20542 d = d1 - (d1 = (p * p * da + 3 * inv * (p * ca + inv * ba)) * p); 20543 index = j * resolution + i - 1; 20544 steps[index] = (steps[index] || 0) + d * d; 20545 } 20546 } 20547 }, 20548 _parseLengthData = function(obj, resolution) { 20549 resolution = resolution >> 0 || 6; 20550 var a = [], 20551 lengths = [], 20552 d = 0, 20553 total = 0, 20554 threshold = resolution - 1, 20555 segments = [], 20556 curLS = [], //current length segments array 20557 p, i, l, index; 20558 for (p in obj) { 20559 _addCubicLengths(obj[p], a, resolution); 20560 } 20561 l = a.length; 20562 for (i = 0; i < l; i++) { 20563 d += Math.sqrt(a[i]); 20564 index = i % resolution; 20565 curLS[index] = d; 20566 if (index === threshold) { 20567 total += d; 20568 index = (i / resolution) >> 0; 20569 segments[index] = curLS; 20570 lengths[index] = total; 20571 d = 0; 20572 curLS = []; 20573 } 20574 } 20575 return {length:total, lengths:lengths, segments:segments}; 20576 }, 20577 20578 20579 20580 BezierPlugin = _gsScope._gsDefine.plugin({ 20581 propName: "bezier", 20582 priority: -1, 20583 version: "1.3.8", 20584 API: 2, 20585 global:true, 20586 20587 //gets called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run. 20588 init: function(target, vars, tween) { 20589 this._target = target; 20590 if (vars instanceof Array) { 20591 vars = {values:vars}; 20592 } 20593 this._func = {}; 20594 this._mod = {}; 20595 this._props = []; 20596 this._timeRes = (vars.timeResolution == null) ? 6 : parseInt(vars.timeResolution, 10); 20597 var values = vars.values || [], 20598 first = {}, 20599 second = values[0], 20600 autoRotate = vars.autoRotate || tween.vars.orientToBezier, 20601 p, isFunc, i, j, prepend; 20602 20603 this._autoRotate = autoRotate ? (autoRotate instanceof Array) ? autoRotate : [["x","y","rotation",((autoRotate === true) ? 0 : Number(autoRotate) || 0)]] : null; 20604 for (p in second) { 20605 this._props.push(p); 20606 } 20607 20608 i = this._props.length; 20609 while (--i > -1) { 20610 p = this._props[i]; 20611 20612 this._overwriteProps.push(p); 20613 isFunc = this._func[p] = (typeof(target[p]) === "function"); 20614 first[p] = (!isFunc) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ](); 20615 if (!prepend) if (first[p] !== values[0][p]) { 20616 prepend = first; 20617 } 20618 } 20619 this._beziers = (vars.type !== "cubic" && vars.type !== "quadratic" && vars.type !== "soft") ? bezierThrough(values, isNaN(vars.curviness) ? 1 : vars.curviness, false, (vars.type === "thruBasic"), vars.correlate, prepend) : _parseBezierData(values, vars.type, first); 20620 this._segCount = this._beziers[p].length; 20621 20622 if (this._timeRes) { 20623 var ld = _parseLengthData(this._beziers, this._timeRes); 20624 this._length = ld.length; 20625 this._lengths = ld.lengths; 20626 this._segments = ld.segments; 20627 this._l1 = this._li = this._s1 = this._si = 0; 20628 this._l2 = this._lengths[0]; 20629 this._curSeg = this._segments[0]; 20630 this._s2 = this._curSeg[0]; 20631 this._prec = 1 / this._curSeg.length; 20632 } 20633 20634 if ((autoRotate = this._autoRotate)) { 20635 this._initialRotations = []; 20636 if (!(autoRotate[0] instanceof Array)) { 20637 this._autoRotate = autoRotate = [autoRotate]; 20638 } 20639 i = autoRotate.length; 20640 while (--i > -1) { 20641 for (j = 0; j < 3; j++) { 20642 p = autoRotate[i][j]; 20643 this._func[p] = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ] : false;
20644 } 20645 p = autoRotate[i][2]; 20646 this._initialRotations[i] = (this._func[p] ? this._func[p].call(this._target) : this._target[p]) || 0; 20647 this._overwriteProps.push(p); 20648 } 20649 } 20650 this._startRatio = tween.vars.runBackwards ? 1 : 0; //we determine the starting ratio when the tween inits which is always 0 unless the tween has runBackwards:true (indicating it's a from() tween) in which case it's 1. 20651 return true; 20652 }, 20653 20654 //called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.) 20655 set: function(v) { 20656 var segments = this._segCount, 20657 func = this._func, 20658 target = this._target, 20659 notStart = (v !== this._startRatio), 20660 curIndex, inv, i, p, b, t, val, l, lengths, curSeg; 20661 if (!this._timeRes) { 20662 curIndex = (v < 0) ? 0 : (v >= 1) ? segments - 1 : (segments * v) >> 0; 20663 t = (v - (curIndex * (1 / segments))) * segments; 20664 } else { 20665 lengths = this._lengths; 20666 curSeg = this._curSeg; 20667 v *= this._length; 20668 i = this._li; 20669 //find the appropriate segment (if the currently cached one isn't correct) 20670 if (v > this._l2 && i < segments - 1) { 20671 l = segments - 1; 20672 while (i < l && (this._l2 = lengths[++i]) <= v) { } 20673 this._l1 = lengths[i-1]; 20674 this._li = i; 20675 this._curSeg = curSeg = this._segments[i]; 20676 this._s2 = curSeg[(this._s1 = this._si = 0)]; 20677 } else if (v < this._l1 && i > 0) { 20678 while (i > 0 && (this._l1 = lengths[--i]) >= v) { } 20679 if (i === 0 && v < this._l1) { 20680 this._l1 = 0; 20681 } else { 20682 i++; 20683 } 20684 this._l2 = lengths[i]; 20685 this._li = i; 20686 this._curSeg = curSeg = this._segments[i]; 20687 this._s1 = curSeg[(this._si = curSeg.length - 1) - 1] || 0; 20688 this._s2 = curSeg[this._si]; 20689 } 20690 curIndex = i; 20691 //now find the appropriate sub-segment (we split it into the number of pieces that was defined by "precision" and measured each one) 20692 v -= this._l1; 20693 i = this._si; 20694 if (v > this._s2 && i < curSeg.length - 1) { 20695 l = curSeg.length - 1; 20696 while (i < l && (this._s2 = curSeg[++i]) <= v) { } 20697 this._s1 = curSeg[i-1]; 20698 this._si = i; 20699 } else if (v < this._s1 && i > 0) { 20700 while (i > 0 && (this._s1 = curSeg[--i]) >= v) { } 20701 if (i === 0 && v < this._s1) { 20702 this._s1 = 0; 20703 } else { 20704 i++; 20705 } 20706 this._s2 = curSeg[i]; 20707 this._si = i; 20708 } 20709 t = ((i + (v - this._s1) / (this._s2 - this._s1)) * this._prec) || 0; 20710 } 20711 inv = 1 - t; 20712 20713 i = this._props.length; 20714 while (--i > -1) { 20715 p = this._props[i]; 20716 b = this._beziers[p][curIndex]; 20717 val = (t * t * b.da + 3 * inv * (t * b.ca + inv * b.ba)) * t + b.a; 20718 if (this._mod[p]) { 20719 val = this._mod[p](val, target); 20720 } 20721 if (func[p]) { 20722 target[p](val); 20723 } else { 20724 target[p] = val; 20725 } 20726 } 20727 20728 if (this._autoRotate) { 20729 var ar = this._autoRotate, 20730 b2, x1, y1, x2, y2, add, conv; 20731 i = ar.length; 20732 while (--i > -1) { 20733 p = ar[i][2]; 20734 add = ar[i][3] || 0; 20735 conv = (ar[i][4] === true) ? 1 : _RAD2DEG; 20736 b = this._beziers[ar[i][0]]; 20737 b2 = this._beziers[ar[i][1]]; 20738 20739 if (b && b2) { //in case one of the properties got overwritten. 20740 b = b[curIndex]; 20741 b2 = b2[curIndex]; 20742 20743 x1 = b.a + (b.b - b.a) * t; 20744 x2 = b.b + (b.c - b.b) * t; 20745 x1 += (x2 - x1) * t; 20746 x2 += ((b.c + (b.d - b.c) * t) - x2) * t; 20747 20748 y1 = b2.a + (b2.b - b2.a) * t; 20749 y2 = b2.b + (b2.c - b2.b) * t; 20750 y1 += (y2 - y1) * t; 20751 y2 += ((b2.c + (b2.d - b2.c) * t) - y2) * t; 20752 20753 val = notStart ? Math.atan2(y2 - y1, x2 - x1) * conv + add : this._initialRotations[i]; 20754 20755 if (this._mod[p]) { 20756 val = this._mod[p](val, target); //for modProps 20757 } 20758 20759 if (func[p]) { 20760 target[p](val); 20761 } else { 20762 target[p] = val; 20763 } 20764 } 20765 } 20766 } 20767 } 20768 }), 20769 p = BezierPlugin.prototype; 20770 20771 20772 BezierPlugin.bezierThrough = bezierThrough; 20773 BezierPlugin.cubicToQuadratic = cubicToQuadratic; 20774 BezierPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite 20775 BezierPlugin.quadraticToCubic = function(a, b, c) { 20776 return new Segment(a, (2 * b + a) / 3, (2 * b + c) / 3, c); 20777 }; 20778 20779 BezierPlugin._cssRegister = function() { 20780 var CSSPlugin = _globals.CSSPlugin; 20781 if (!CSSPlugin) { 20782 return; 20783 } 20784 var _internals = CSSPlugin._internals, 20785 _parseToProxy = _internals._parseToProxy, 20786 _setPluginRatio = _internals._setPluginRatio, 20787 CSSPropTween = _internals.CSSPropTween; 20788 _internals._registerComplexSpecialProp("bezier", {parser:function(t, e, prop, cssp, pt, plugin) { 20789 if (e instanceof Array) { 20790 e = {values:e}; 20791 } 20792 plugin = new BezierPlugin(); 20793 var values = e.values, 20794 l = values.length - 1, 20795 pluginValues = [], 20796 v = {}, 20797 i, p, data; 20798 if (l < 0) { 20799 return pt; 20800 } 20801 for (i = 0; i <= l; i++) { 20802 data = _parseToProxy(t, values[i], cssp, pt, plugin, (l !== i)); 20803 pluginValues[i] = data.end; 20804 } 20805 for (p in e) { 20806 v[p] = e[p]; //duplicate the vars object because we need to alter some things which w
20806ould cause problems if the user plans to reuse the same vars object for another tween. 20807 } 20808 v.values = pluginValues; 20809 pt = new CSSPropTween(t, "bezier", 0, 0, data.pt, 2); 20810 pt.data = data; 20811 pt.plugin = plugin; 20812 pt.setRatio = _setPluginRatio; 20813 if (v.autoRotate === 0) { 20814 v.autoRotate = true; 20815 } 20816 if (v.autoRotate && !(v.autoRotate instanceof Array)) { 20817 i = (v.autoRotate === true) ? 0 : Number(v.autoRotate); 20818 v.autoRotate = (data.end.left != null) ? [["left","top","rotation",i,false]] : (data.end.x != null) ? [["x","y","rotation",i,false]] : false; 20819 } 20820 if (v.autoRotate) { 20821 if (!cssp._transform) { 20822 cssp._enableTransforms(false); 20823 } 20824 data.autoRotate = cssp._target._gsTransform; 20825 data.proxy.rotation = data.autoRotate.rotation || 0; 20826 cssp._overwriteProps.push("rotation"); 20827 } 20828 plugin._onInitTween(data.proxy, v, cssp._tween); 20829 return pt; 20830 }}); 20831 }; 20832 20833 p._mod = function(lookup) { 20834 var op = this._overwriteProps, 20835 i = op.length, 20836 val; 20837 while (--i > -1) { 20838 val = lookup[op[i]]; 20839 if (val && typeof(val) === "function") { 20840 this._mod[op[i]] = val; 20841 } 20842 } 20843 }; 20844 20845 p._kill = function(lookup) { 20846 var a = this._props, 20847 p, i; 20848 for (p in this._beziers) { 20849 if (p in lookup) { 20850 delete this._beziers[p]; 20851 delete this._func[p]; 20852 i = a.length; 20853 while (--i > -1) { 20854 if (a[i] === p) { 20855 a.splice(i, 1); 20856 } 20857 } 20858 } 20859 } 20860 a = this._autoRotate; 20861 if (a) { 20862 i = a.length; 20863 while (--i > -1) { 20864 if (lookup[a[i][2]]) { 20865 a.splice(i, 1); 20866 } 20867 } 20868 } 20869 return this._super._kill.call(this, lookup); 20870 }; 20871 20872 }()); 20873 20874 20875 20876 20877 20878 20879 20880 20881 20882 20883 20884 20885 20886 20887/* 20888 * ---------------------------------------------------------------- 20889 * CSSPlugin 20890 * ---------------------------------------------------------------- 20891 */ 20892 _gsScope._gsDefine("plugins.CSSPlugin", ["plugins.TweenPlugin","TweenLite"], function(TweenPlugin, TweenLite) { 20893 20894 /** @constructor **/ 20895 var CSSPlugin = function() { 20896 TweenPlugin.call(this, "css"); 20897 this._overwriteProps.length = 0; 20898 this.setRatio = CSSPlugin.prototype.setRatio; //speed optimization (avoid prototype lookup on this "hot" method) 20899 }, 20900 _globals = _gsScope._gsDefine.globals, 20901 _hasPriority, //turns true whenever a CSSPropTween instance is created that has a priority other than 0. This helps us discern whether or not we should spend the time organizing the linked list or not after a CSSPlugin's _onInitTween() method is called. 20902 _suffixMap, //we set this in _onInitTween() each time as a way to have a persistent variable we can use in other methods like _parse() without having to pass it around as a parameter and we keep _parse() decoupled from a particular CSSPlugin instance 20903 _cs, //computed style (we store this in a shared variable to conserve memory and make minification tighter 20904 _overwriteProps, //alias to the currently instantiating CSSPlugin's _overwriteProps array. We use this closure in order to avoid having to pass a reference around from method to method and aid in minification. 20905 _specialProps = {}, 20906 p = CSSPlugin.prototype = new TweenPlugin("css"); 20907 20908 p.constructor = CSSPlugin; 20909 CSSPlugin.version = "2.0.2"; 20910 CSSPlugin.API = 2; 20911 CSSPlugin.defaultTransformPerspective = 0; 20912 CSSPlugin.defaultSkewType = "compensated"; 20913 CSSPlugin.defaultSmoothOrigin = true; 20914 p = "px"; //we'll reuse the "p" variable to keep file size down 20915 CSSPlugin.suffixMap = {top:p, right:p, bottom:p, left:p, width:p, height:p, fontSize:p, padding:p, margin:p, perspective:p, lineHeight:""}; 20916 20917 20918 var _numExp = /(?:\-|\.|\b)(\d|\.|e\-)+/g, 20919 _relNumExp = /(?:\d|\-\d|\.\d|\-\.\d|\+=\d|\-=\d|\+=.\d|\-=\.\d)+/g, 20920 _valuesExp = /(?:\+=|\-=|\-|\b)[\d\-\.]+[a-zA-Z0-9]*(?:%|\b)/gi, //finds all the values that begin with numbers or += or -= and then a number. Includes suffixes. We use this to split complex values apart like "1px 5px 20px rgb(255,102,51)" 20921 _NaNExp = /(?![+-]?\d*\.?\d+|[+-]|e[+-]\d+)[^0-9]/g, //also allows scientific notation and doesn't kill the leading -/+ in -= and += 20922 _suffixExp = /(?:\d|\-|\+|=|#|\.)*/g, 20923 _opacityExp = /opacity *= *([^)]*)/i, 20924 _opacityValExp = /opacity:([^;]*)/i,
20925 _alphaFilterExp = /alpha\(opacity *=.+?\)/i, 20926 _rgbhslExp = /^(rgb|hsl)/, 20927 _capsExp = /([A-Z])/g, 20928 _camelExp = /-([a-z])/gi, 20929 _urlExp = /(^(?:url\(\"|url\())|(?:(\"\))$|\)$)/gi, //for pulling out urls from url(...) or url("...") strings (some browsers wrap urls in quotes, some don't when reporting things like backgroundImage) 20930 _camelFunc = function(s, g) { return g.toUpperCase(); }, 20931 _horizExp = /(?:Left|Right|Width)/i, 20932 _ieGetMatrixExp = /(M11|M12|M21|M22)=[\d\-\.e]+/gi, 20933 _ieSetMatrixExp = /progid\:DXImageTransform\.Microsoft\.Matrix\(.+?\)/i, 20934 _commasOutsideParenExp = /,(?=[^\)]*(?:\(|$))/gi, //finds any commas that are not within parenthesis 20935 _complexExp = /[\s,\(]/i, //for testing a string to find if it has a space, comma, or open parenthesis (clues that it's a complex value) 20936 _DEG2RAD = Math.PI / 180, 20937 _RAD2DEG = 180 / Math.PI, 20938 _forcePT = {}, 20939 _dummyElement = {style:{}}, 20940 _doc = _gsScope.document || {createElement: function() {return _dummyElement;}}, 20941 _createElement = function(type, ns) { 20942 return _doc.createElementNS ? _doc.createElementNS(ns || "http://www.w3.org/1999/xhtml", type) : _doc.createElement(type); 20943 }, 20944 _tempDiv = _createElement("div"), 20945 _tempImg = _createElement("img"), 20946 _internals = CSSPlugin._internals = {_specialProps:_specialProps}, //provides a hook to a few internal methods that we need to access from inside other plugins 20947 _agent = (_gsScope.navigator || {}).userAgent || "", 20948 _autoRound, 20949 _reqSafariFix, //we won't apply the Safari transform fix until we actually come across a tween that affects a transform property (to maintain best performance). 20950 20951 _isSafari, 20952 _isFirefox, //Firefox has a bug that causes 3D transformed elements to randomly disappear unless a repaint is forced after each update on each element. 20953 _isSafariLT6, //Safari (and Android 4 which uses a flavor of Safari) has a bug that prevents changes to "top" and "left" properties from rendering properly if changed on the same frame as a transform UNLESS we set the element's WebkitBackfaceVisibility to hidden (weird, I know). Doing this for Android 3 and earlier seems to actually cause other problems, though (fun!) 20954 _ieVers, 20955 _supportsOpacity = (function() { //we set _isSafari, _ieVers, _isFirefox, and _supportsOpacity all in one function here to reduce file size slightly, especially in the minified version. 20956 var i = _agent.indexOf("Android"), 20957 a = _createElement("a"); 20958 _isSafari = (_agent.indexOf("Safari") !== -1 && _agent.indexOf("Chrome") === -1 && (i === -1 || parseFloat(_agent.substr(i+8, 2)) > 3)); 20959 _isSafariLT6 = (_isSafari && (parseFloat(_agent.substr(_agent.indexOf("Version/")+8, 2)) < 6)); 20960 _isFirefox = (_agent.indexOf("Firefox") !== -1); 20961 if ((/MSIE ([0-9]{1,}[\.0-9]{0,})/).exec(_agent) || (/Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/).exec(_agent)) { 20962 _ieVers = parseFloat( RegExp.$1 ); 20963 } 20964 if (!a) { 20965 return false; 20966 } 20967 a.style.cssText = "top:1px;opacity:.55;"; 20968 return /^0.55/.test(a.style.opacity); 20969 }()), 20970 _getIEOpacity = function(v) { 20971 return (_opacityExp.test( ((typeof(v) === "string") ? v : (v.currentStyle ? v.currentStyle.filter : v.style.filter) || "") ) ? ( parseFloat( RegExp.$1 ) / 100 ) : 1); 20972 }, 20973 _log = function(s) {//for logging messages, but in a way that won't throw errors in old versions of IE. 20974 if (_gsScope.console) { 20975 console.log(s); 20976 } 20977 }, 20978 _target, //when initting a CSSPlugin, we set this variable so that we can access it from within many other functions without having to pass it around as params 20979 _index, //when initting a CSSPlugin, we set this variable so that we can access it from within many other functions without having to pass it around as params 20980 20981 _prefixCSS = "", //the non-camelCase vendor prefix like "-o-", "-moz-", "-ms-", or "-webkit-" 20982 _prefix = "", //camelCase vendor prefix like "O", "ms", "Webkit", or "Moz". 20983 20984 // @private feed in a camelCase property name like "transform" and it will check to see if it is valid as-is or if it needs a vendor prefix. It returns the corrected camelCase property name (i.e. "WebkitTransform" or "MozTransform" or "transform" or null if no such property is found, like if the browser is IE8 or before, "transform" won't be found at all) 20985 _checkPropPrefix = function(p, e) { 20986 e = e || _tempDiv; 20987 var s = e.style, 20988 a, i; 20989 if (s[p] !== undefined) { 20990 return p; 20991 } 20992 p = p.charAt(0).toUpperCase() + p.substr(1); 20993 a = ["O","Moz","ms","Ms","Webkit"]; 20994 i = 5; 20995 while (--i > -1 && s[a[i]+p] === undefined) { } 20996 if (i >= 0) { 20997 _prefix = (i === 3) ? "ms" : a[i]; 20998 _prefixCSS = "-" + _prefix.toLowerCase() + "-"; 20999 return _prefix + p; 21000 } 21001 return null; 21002 }, 21003 21004 _getComputedStyle = (typeof(window) !== "undefined" ? window : _doc.defaultView || {getComputedStyle:function() {}}).getComputedStyle, 21005 21006 /** 21007 * @private Returns the css style for a particular property of an element. For example, to get whatever the current "left" css value for an element with an ID of "myElement", you could do: 21008 * var currentLeft = CSSPlugin.getStyle( document.getElementById("myElement"), "left"); 21009 * 21010 * @param {!Object} t Target element whose style property you want to query 21011 * @param {!string} p Property name (like "left" or "top" or "marginTop", etc.) 21012 * @param {Object=} cs Computed style object. This just provides a way to speed processing if you're going to get several properties on the same element in quick succession - you can reuse the result of the getComputedStyle() call. 21013 * @param {boolean=} calc If true, the value will not be read directly from the element's "style" property (if it exists there), but instead the getComputedStyle() result will be used. This can be useful when you want to ensure that the browser itself is interpreting the value. 21014 * @param {string=} dflt Default value that should be returned in the place of null, "none", "auto" or "auto auto". 21015 * @return {?string} The current property value 21016 */ 21017 _getStyle = CSSPlugin.getStyle = function(t, p, cs, calc, dflt) { 21018 var rv; 21019 if (!_supportsOpacity) if (p === "opacity") { //several versions of IE don't use the standard "opacity" property - they use things like filter:alpha(opacity=50), so we parse that here. 21020 return _getIEOpacity(t); 21021 } 21022 if (!calc && t.style[p]) { 21023 rv = t.style[p]; 21024 } else if ((cs = cs || _getComputedStyle(t))) { 21025 rv = cs[p] || cs.getPropertyValue(p) || cs.getPropertyValue(p.replace(_capsExp, "-$1").toLowerCase()); 21026 } else if (t.currentStyle) { 21027 rv = t.currentStyle[p]; 21028 } 21029 return (dflt != null && (!rv || rv === "none" || rv === "auto" || rv === "auto auto")) ? dflt : rv; 21030 }, 21031 21032 /** 21033 * @private Pass the target element, the property name, the numeric value, and the suffix (like "%", "em", "px", etc.) and it will spit back the equivalent pixel number. 21034 * @param {!Object} t Target element 21035 * @param {!string} p Property name (like "left", "top", "marginLeft", etc.) 21036 * @param {!number} v Value 21037 * @param {string=} sfx Suffix (like "px" or "%" or "em") 21038 * @param {boolean=} recurse If true, the call is a recursive one. In some browsers (like IE7/8), occasionally the value isn't accurately reported initially, but if we run the function again it will take effect. 21039 * @return {number} value in pixels 21040 */ 21041 _convertToPixels = _internals.convertToPixels = function(t, p, v, sfx, recurse) { 21042 if (sfx === "px" || (!sfx && p !== "lineHeight")) { return v; } 21043 if (sfx === "auto" || !v) { return 0; } 21044 var horiz = _horizExp.test(p), 21045 node = t, 21046 style = _tempDiv.style, 21047 neg = (v < 0), 21048 precise = (v === 1), 21049 pix, cache, time; 21050 if (neg) { 21051 v = -v; 21052 } 21053 if (precise) { 21054 v *= 100; 21055 } 21056 if (p === "lineHeight" && !sfx) { //special case of when a simple lineHeight (without a unit) is used. Set it to the value, read back the computed value, and then revert. 21057 cache = _getComputedStyle(t).lineHeight; 21058 t.style.lineHeight = v; 21059 pix = parseFloat(_getComputedStyle(t).lineHeight); 21060 t.style.lineHeight = cache; 21061 } else if (sfx === "%" && p.indexOf("border") !== -1) { 21062 pix = (v / 100) * (horiz ? t.clientWidth : t.clientHeight); 21063 } else { 21064 style.cssText = "border:0 solid red;position:" + _getStyle(t, "position") + ";line-height:0;"; 21065 if (sfx === "%" || !node.appendChild || sfx.charAt(0) === "v" || sfx === "rem") { 21066 node = t.parentNode || _doc.body; 21067 if (_getStyle(node, "display").indexOf("flex") !== -1) { //Edge and IE11 have a bug that causes offsetWidth to report as 0 if the container has display:flex and the child is position:relative. Switching to position: absolute solves it. 21068 style.position = "absolute"; 21069 } 21070 cache = node._gsCache; 21071 time = TweenLite.ticker.frame; 21072 if (cache && horiz && cache.time === time) { //performance optimization: we record the width of elements along with the ticker frame so that we can quickly get it again on the same tick (seems relatively safe to assume it wouldn't change on the same tick) 21073 return cache.width * v / 100; 21074 } 21075 style[(horiz ? "width" : "height")] = v + sfx; 21076 } else { 21077 style[(horiz ? "borderLeftWidth" : "borderTopWidth")] = v + sfx; 21078 } 21079 node.appendChild(_tempDiv); 21080 pix = parseFloat(_tempDiv[(horiz ? "offsetWidth" : "offsetHeight")]); 21081 node.removeChild(_tempDiv); 21082 if (horiz && sfx === "%" && CSSPlugin.cacheWidths !== false) { 21083 cache = node._gsCache = node._gsCache || {}; 21084 cache.time = time; 21085 cache.width = pix / v * 100; 21086 } 21087 if (pix === 0 && !recurse) { 21088 pix = _convertToPixels(t, p, v, sfx, true); 21089 } 21090 } 21091 if (precise) { 21092 pix /= 100; 21093 } 21094 return neg ? -pix : pix; 21095 }, 21096 _calculateOffset = _internals.calculateOffset = function(t, p, cs) { //for figuring out "top" or "left" in px when it's "auto". We need to factor in margin with the offsetLeft/offsetTop 21097 if (_getStyle(t, "position", cs) !== "absolute") { return 0; } 21098 var dim = ((p === "left") ? "Left" : "Top"),
21099 v = _getStyle(t, "margin" + dim, cs); 21100 return t["offset" + dim] - (_convertToPixels(t, p, parseFloat(v), v.replace(_suffixExp, "")) || 0); 21101 }, 21102 21103 // @private returns at object containing ALL of the style properties in camelCase and their associated values. 21104 _getAllStyles = function(t, cs) { 21105 var s = {}, 21106 i, tr, p; 21107 if ((cs = cs || _getComputedStyle(t, null))) { 21108 if ((i = cs.length)) { 21109 while (--i > -1) { 21110 p = cs[i]; 21111 if (p.indexOf("-transform") === -1 || _transformPropCSS === p) { //Some webkit browsers duplicate transform values, one non-prefixed and one prefixed ("transform" and "WebkitTransform"), so we must weed out the extra one here. 21112 s[p.replace(_camelExp, _camelFunc)] = cs.getPropertyValue(p); 21113 } 21114 } 21115 } else { //some browsers behave differently - cs.length is always 0, so we must do a for...in loop. 21116 for (i in cs) { 21117 if (i.indexOf("Transform") === -1 || _transformProp === i) { //Some webkit browsers duplicate transform values, one non-prefixed and one prefixed ("transform" and "WebkitTransform"), so we must weed out the extra one here. 21118 s[i] = cs[i]; 21119 } 21120 } 21121 } 21122 } else if ((cs = t.currentStyle || t.style)) { 21123 for (i in cs) { 21124 if (typeof(i) === "string" && s[i] === undefined) { 21125 s[i.replace(_camelExp, _camelFunc)] = cs[i]; 21126 } 21127 } 21128 } 21129 if (!_supportsOpacity) { 21130 s.opacity = _getIEOpacity(t); 21131 } 21132 tr = _getTransform(t, cs, false); 21133 s.rotation = tr.rotation; 21134 s.skewX = tr.skewX; 21135 s.scaleX = tr.scaleX; 21136 s.scaleY = tr.scaleY; 21137 s.x = tr.x; 21138 s.y = tr.y; 21139 if (_supports3D) { 21140 s.z = tr.z; 21141 s.rotationX = tr.rotationX; 21142 s.rotationY = tr.rotationY; 21143 s.scaleZ = tr.scaleZ; 21144 } 21145 if (s.filters) { 21146 delete s.filters; 21147 } 21148 return s; 21149 }, 21150 21151 // @private analyzes two style objects (as returned by _getAllStyles()) and only looks for differences between them that contain tweenable values (like a number or color). It returns an object with a "difs" property which refers to an object c
21151ontaining only those isolated properties and values for tweening, and a "firstMPT" property which refers to the first MiniPropTween instance in a linked list that recorded all the starting values of the different properties so that we can revert to them at the end or beginning of the tween - we don't want the cascading to get messed up. The forceLookup parameter is an optional generic object with properties that should be forced into the results - this is necessary for className tweens that are overwriting others because imagine a scenario where a rollover/rollout adds/removes a class and the user swipes the mouse over the target SUPER fast, thus nothing actually changed yet and the subsequent comparison of the properties would indicate they match (especially when px rounding is taken into consideration), thus no tweening is necessary even though it SHOULD tween and remove those properties after the tween (otherwise the inline styles will contaminate things). See the className SpecialProp code for details. 21152 _cssDif = function(t, s1, s2, vars, forceLookup) { 21153 var difs = {}, 21154 style = t.style, 21155 val, p, mpt; 21156 for (p in s2) { 21157 if (p !== "cssText") if (p !== "length") if (isNaN(p)) if (s1[p] !== (val = s2[p]) || (forceLookup && forceLookup[p])) if (p.indexOf("Origin") === -1) if (typeof(val) === "number" || typeof(val) === "string") { 21158 difs[p] = (val === "auto" && (p === "left" || p === "top")) ? _calculateOffset(t, p) : ((val === "" || val === "auto" || val === "none") && typeof(s1[p]) === "string" && s1[p].replace(_NaNExp, "") !== "") ? 0 : val; //if the ending value is defaulting ("" or "auto"), we check the starting value and if it can be parsed into a number (a string which could have a suffix too, like 700px), then we swap in 0 for "" or "auto" so that things actually tween. 21159 if (style[p] !== undefined) { //for className tweens, we must remember which properties already existed inline - the ones that didn't should be removed when the tween isn't in progress because they were only introduced to facilitate the transition between classes. 21160 mpt = new MiniPropTween(style, p, style[p], mpt); 21161 } 21162 } 21163 } 21164 if (vars) { 21165 for (p in vars) { //copy properties (except className) 21166 if (p !== "className") { 21167 difs[p] = vars[p]; 21168 } 21169 } 21170 } 21171 return {difs:difs, firstMPT:mpt}; 21172 }, 21173 _dimensions = {width:["Left","Right"], height:["Top","Bottom"]}, 21174 _margins = ["marginLeft","marginRight","marginTop","marginBottom"], 21175 21176 /** 21177 * @private Gets the width or height of an element 21178 * @param {!Object} t Target element 21179 * @param {!string} p Property name ("width" or "height") 21180 * @param {Object=} cs Computed style object (if one exists). Just a speed optimization. 21181 * @return {number} Dimension (in pixels) 21182 */ 21183 _getDimension = function(t, p, cs) { 21184 if ((t.nodeName + "").toLowerCase() === "svg") { //Chrome no longer supports offsetWidth/offsetHeight on SVG elements. 21185 return (cs || _getComputedStyle(t))[p] || 0; 21186 } else if (t.getCTM && _isSVG(t)) { 21187 return t.getBBox()[p] || 0; 21188 } 21189 var v = parseFloat((p === "width") ? t.offsetWidth : t.offsetHeight), 21190 a = _dimensions[p], 21191 i = a.length; 21192 cs = cs || _getComputedStyle(t, null); 21193 while (--i > -1) { 21194 v -= parseFloat( _getStyle(t, "padding" + a[i], cs, true) ) || 0; 21195 v -= parseFloat( _getStyle(t, "border" + a[i] + "Width", cs, true) ) || 0; 21196 } 21197 return v; 21198 }, 21199 21200 // @private Parses position-related complex strings like "top left" or "50px 10px" or "70% 20%", etc. which are used for things like transformOrigin or backgroundPosition. Optionally decorates a supplied object (recObj) with the following properties: "ox" (offsetX), "oy" (offsetY), "oxp" (if true, "ox" is a percentage not a pixel value), and "oxy" (if true, "oy" is a percentage not a pixel value) 21201 _parsePosition = function(v, recObj) { 21202 if (v === "contain" || v === "auto" || v === "auto auto") { //note: Firefox uses "auto auto" as default whereas Chrome uses "auto". 21203 return v + " "; 21204 } 21205 if (v == null || v === "") { 21206 v = "0 0"; 21207 } 21208 var a = v.split(" "), 21209 x = (v.indexOf("left") !== -1) ? "0%" : (v.indexOf("right") !== -1) ? "100%" : a[0], 21210 y = (v.indexOf("top") !== -1) ? "0%" : (v.indexOf("bottom") !== -1) ? "100%" : a[1], 21211 i; 21212 if (a.length > 3 && !recObj) { //multiple positions 21213 a = v.split(", ").join(",").split(","); 21214 v = []; 21215 for (i = 0; i < a.length; i++) { 21216 v.push(_parsePosition(a[i])); 21217 } 21218 return v.join(","); 21219 } 21220 if (y == null) { 21221 y = (x === "center") ? "50%" : "0"; 21222 } else if (y === "center") { 21223 y = "50%"; 21224 } 21225 if (x === "center" || (isNaN(parseFloat(x)) && (x + "").indexOf("=") === -1)) { //remember, the user could flip-flop the values and say "bottom center" or "center bottom", etc. "center" is ambiguous because it c
21225ould be used to describe horizontal or vertical, hence the isNaN(). If there's an "=" sign in the value, it's relative. 21226 x = "50%"; 21227 } 21228 v = x + " " + y + ((a.length > 2) ? " " + a[2] : ""); 21229 if (recObj) { 21230 recObj.oxp = (x.indexOf("%") !== -1); 21231 recObj.oyp = (y.indexOf("%") !== -1); 21232 recObj.oxr = (x.charAt(1) === "="); 21233 recObj.oyr = (y.charAt(1) === "="); 21234 recObj.ox = parseFloat(x.replace(_NaNExp, "")); 21235 recObj.oy = parseFloat(y.replace(_NaNExp, "")); 21236 recObj.v = v; 21237 } 21238 return recObj || v; 21239 }, 21240 21241 /** 21242 * @private Takes an ending value (typically a string, but can be a number) and a starting value and returns the change between the two, looking for relative value indicators like += and -= and it also ignores suffixes (but make sure the ending value starts with a number or +=/-= and that the starting value is a NUMBER!) 21243 * @param {(number|string)} e End value which is typically a string, but could be a number 21244 * @param {(number|string)} b Beginning value which is typically a string but could be a number 21245 * @return {number} Amount of change between the beginning and ending values (relative values that have a "+=" or "-=" are recognized) 21246 */ 21247 _parseChange = function(e, b) { 21248 if (typeof(e) === "function") { 21249 e = e(_index, _target); 21250 } 21251 return (typeof(e) === "string" && e.charAt(1) === "=") ? parseInt(e.charAt(0) + "1", 10) * parseFloat(e.substr(2)) : (parseFloat(e) - parseFloat(b)) || 0; 21252 }, 21253 21254 /** 21255 * @private Takes a value and a default number, checks if the value is relative, null, or numeric and spits back a normalized number accordingly. Primarily used in the _parseTransform() function. 21256 * @param {Object} v Value to be parsed 21257 * @param {!number} d Default value (which is also used for relative calculations if "+=" or "-=" is found in the first parameter) 21258 * @return {number} Parsed value 21259 */ 21260 _parseVal = function(v, d) { 21261 if (typeof(v) === "function") { 21262 v = v(_index, _target); 21263 } 21264 var isRelative = (typeof(v) === "string" && v.charAt(1) === "="); 21265 if (typeof(v) === "string" && v.charAt(v.length - 2) === "v") { //convert vw and vh into px-equivalents. 21266 v = (isRelative ? v.substr(0, 2) : 0) + (window["inner" + ((v.substr(-2) === "vh") ? "Height" : "Width")] * (parseFloat(isRelative ? v.substr(2) : v) / 100)); 21267 } 21268 return (v == null) ? d : isRelative ? parseInt(v.charAt(0) + "1", 10) * parseFloat(v.substr(2)) + d : parseFloat(v) || 0; 21269 }, 21270 21271 /** 21272 * @private Translates strings like "40deg" or "40" or 40rad" or "+=40deg" or "270_short" or "-90_cw" or "+=45_ccw" to a numeric radian angle. Of course a starting/default value must be fed in too so that relative values can be calculated properly. 21273 * @param {Object} v Value to be parsed 21274 * @param {!number} d Default value (which is also used for relative calculations if "+=" or "-=" is found in the first parameter) 21275 * @param {string=} p property name for directionalEnd (optional - only used when the parsed value is directional ("_short", "_cw", or "_ccw" suffix). We need a way to store the uncompensated value so that at the end of the tween, we set it to exactly what was requested with no directional compensation). Property name would be "rotation", "rotationX", or "rotationY" 21276 * @param {Object=} directionalEnd An object that will store the raw end values for directional angles ("_short", "_cw", or "_ccw" suffix). We need a way to store the uncompensated value so that at the end of the tween, we set it to exactly what was requested with no directional compensation. 21277 * @return {number} parsed angle in radians 21278 */ 21279 _parseAngle = function(v, d, p, directionalEnd) { 21280 var min = 0.000001, 21281 cap, split, dif, result, isRelative; 21282 if (typeof(v) === "function") { 21283 v = v(_index, _target); 21284 } 21285 if (v == null) { 21286 result = d; 21287 } else if (typeof(v) === "number") { 21288 result = v; 21289 } else { 21290 cap = 360; 21291 split = v.split("_"); 21292 isRelative = (v.charAt(1) === "="); 21293 dif = (isRelative ? parseInt(v.charAt(0) + "1", 10) * parseFloat(split[0].substr(2)) : parseFloat(split[0])
21293) * ((v.indexOf("rad") === -1) ? 1 : _RAD2DEG) - (isRelative ? 0 : d); 21294 if (split.length) { 21295 if (directionalEnd) { 21296 directionalEnd[p] = d + dif; 21297 } 21298 if (v.indexOf("short") !== -1) { 21299 dif = dif % cap; 21300 if (dif !== dif % (cap / 2)) { 21301 dif = (dif < 0) ? dif + cap : dif - cap; 21302 } 21303 } 21304 if (v.indexOf("_cw") !== -1 && dif < 0) { 21305 dif = ((dif + cap * 9999999999) % cap) - ((dif / cap) | 0) * cap; 21306 } else if (v.indexOf("ccw") !== -1 && dif > 0) { 21307 dif = ((dif - cap * 9999999999) % cap) - ((dif / cap) | 0) * cap; 21308 } 21309 } 21310 result = d + dif; 21311 } 21312 if (result < min && result > -min) { 21313 result = 0; 21314 } 21315 return result; 21316 }, 21317 21318 _colorLookup = {aqua:[0,255,255], 21319 lime:[0,255,0], 21320 silver:[192,192,192], 21321 black:[0,0,0], 21322 maroon:[128,0,0], 21323 teal:[0,128,128], 21324 blue:[0,0,255], 21325 navy:[0,0,128], 21326 white:[255,255,255], 21327 fuchsia:[255,0,255], 21328 olive:[128,128,0], 21329 yellow:[255,255,0], 21330 orange:[255,165,0], 21331 gray:[128,128,128], 21332 purple:[128,0,128], 21333 green:[0,128,0], 21334 red:[255,0,0], 21335 pink:[255,192,203], 21336 cyan:[0,255,255], 21337 transparent:[255,255,255,0]}, 21338 21339 _hue = function(h, m1, m2) { 21340 h = (h < 0) ? h + 1 : (h > 1) ? h - 1 : h; 21341 return ((((h * 6 < 1) ? m1 + (m2 - m1) * h * 6 : (h < 0.5) ? m2 : (h * 3 < 2) ? m1 + (m2 - m1) * (2 / 3 - h) * 6 : m1) * 255) + 0.5) | 0; 21342 }, 21343 21344 /** 21345 * @private Parses a color (like #9F0, #FF9900, rgb(255,51,153) or hsl(108, 50%, 10%)) into an array with 3 elements for red, green, and blue or if toHSL parameter is true, it will populate the array with hue, saturation, and lightness values. If a relative value is found in an hsl() or hsla() string, it will preserve those relative prefixes and all the values in the array will be strings instead of numbers (in all other cases it will be populated with numbers). 21346 * @param {(string|number)} v The value the should be parsed which could be a string like #9F0 or rgb(255,102,51) or rgba(255,0,0,0.5) or it could be a number like 0xFF00CC or even a named color like red, blue, purple, etc. 21347 * @param {(boolean)} toHSL If true, an hsl() or hsla() value will be returned instead of rgb() or rgba() 21348 * @return {Array.<number>} An array containing red, green, and blue (and optionally alpha) in that order, or if the toHSL parameter was true, the array will contain hue, saturation and lightness (and optionally alpha) in that order. Always numbers unless there's a relative prefix found in an hsl() or hsla() string and toHSL is true. 21349 */ 21350 _parseColor = CSSPlugin.parseColor = function(v, toHSL) { 21351 var a, r, g, b, h, s, l, max, min, d, wasHSL; 21352 if (!v) { 21353 a = _colorLookup.black; 21354 } else if (typeof(v) === "number") { 21355 a = [v >> 16, (v >> 8) & 255, v & 255]; 21356 } else { 21357 if (v.charAt(v.length - 1) === ",") { //sometimes a trailing comma is included and we should chop it off (typically from a comma-delimited list of values like a textShadow:"2px 2px 2px blue, 5px 5px 5px rgb(255,0,0)" - in this example "blue," has a trailing comma. We could strip it out inside parseComplex() but we'd need to do it to the beginning and ending values plus it wouldn't provide protection from other potential scenarios like if the user passes in a similar value. 21358 v = v.substr(0, v.length - 1); 21359 } 21360 if (_colorLookup[v]) { 21361 a = _colorLookup[v]; 21362 } else if (v.charAt(0) === "#") { 21363 if (v.length === 4) { //for shorthand like #9F0 21364 r = v.charAt(1); 21365 g = v.charAt(2); 21366 b = v.charAt(3); 21367 v = "#" + r + r + g + g + b + b; 21368 } 21369 v = parseInt(v.substr(1), 16); 21370 a = [v >> 16, (v >> 8) & 255, v & 255]; 21371 } else if (v.substr(0, 3) === "hsl") { 21372 a = wasHSL = v.match(_numExp); 21373 if (!toHSL) { 21374 h = (Number(a[0]) % 360) / 360;
21375 s = Number(a[1]) / 100; 21376 l = Number(a[2]) / 100; 21377 g = (l <= 0.5) ? l * (s + 1) : l + s - l * s; 21378 r = l * 2 - g; 21379 if (a.length > 3) { 21380 a[3] = Number(a[3]); 21381 } 21382 a[0] = _hue(h + 1 / 3, r, g); 21383 a[1] = _hue(h, r, g); 21384 a[2] = _hue(h - 1 / 3, r, g); 21385 } else if (v.indexOf("=") !== -1) { //if relative values are found, just return the raw strings with the relative prefixes in place. 21386 return v.match(_relNumExp); 21387 } 21388 } else { 21389 a = v.match(_numExp) || _colorLookup.transparent; 21390 } 21391 a[0] = Number(a[0]); 21392 a[1] = Number(a[1]); 21393 a[2] = Number(a[2]); 21394 if (a.length > 3) { 21395 a[3] = Number(a[3]); 21396 } 21397 } 21398 if (toHSL && !wasHSL) { 21399 r = a[0] / 255; 21400 g = a[1] / 255; 21401 b = a[2] / 255; 21402 max = Math.max(r, g, b); 21403 min = Math.min(r, g, b); 21404 l = (max + min) / 2; 21405 if (max === min) { 21406 h = s = 0; 21407 } else { 21408 d = max - min; 21409 s = l > 0.5 ? d / (2 - max - min) : d / (max + min); 21410 h = (max === r) ? (g - b) / d + (g < b ? 6 : 0) : (max === g) ? (b - r) / d + 2 : (r - g) / d + 4; 21411 h *= 60; 21412 } 21413 a[0] = (h + 0.5) | 0; 21414 a[1] = (s * 100 + 0.5) | 0; 21415 a[2] = (l * 100 + 0.5) | 0; 21416 } 21417 return a; 21418 }, 21419 _formatColors = function(s, toHSL) { 21420 var colors = s.match(_colorExp) || [], 21421 charIndex = 0, 21422 parsed = "", 21423 i, color, temp; 21424 if (!colors.length) { 21425 return s; 21426 } 21427 for (i = 0; i < colors.length; i++) { 21428 color = colors[i]; 21429 temp = s.substr(charIndex, s.indexOf(color, charIndex)-charIndex); 21430 charIndex += temp.length + color.length; 21431 color = _parseColor(color, toHSL); 21432 if (color.length === 3) { 21433 color.push(1); 21434 } 21435 parsed += temp + (toHSL ? "hsla(" + color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : "rgba(" + color.join(",")) + ")"; 21436 } 21437 return parsed + s.substr(charIndex); 21438 }, 21439 _colorExp = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3}){1,2}\\b"; //we'll dynamically build this Regular Expression to conserve file size. After building it, it will be able to find rgb(), rgba(), # (hexadecimal), and named color values like red, blue, purple, etc. 21440 21441 for (p in _colorLookup) { 21442 _colorExp += "|" + p + "\\b"; 21443 } 21444 _colorExp = new RegExp(_colorExp+")", "gi"); 21445 21446 CSSPlugin.colorStringFilter = function(a) { 21447 var combined = a[0] + " " + a[1], 21448 toHSL; 21449 if (_colorExp.test(combined)) { 21450 toHSL = (combined.indexOf("hsl(") !== -1 || combined.indexOf("hsla(") !== -1); 21451 a[0] = _formatColors(a[0], toHSL); 21452 a[1] = _formatColors(a[1], toHSL); 21453 } 21454 _colorExp.lastIndex = 0; 21455 }; 21456 21457 if (!TweenLite.defaultStringFilter) { 21458 TweenLite.defaultStringFilter = CSSPlugin.colorStringFilter; 21459 } 21460 21461 /** 21462 * @private Returns a formatter function that handles taking a string (or number in some cases) and returning a consistently formatted one in terms of delimiters, quantity of values, etc. For example, we may get boxShadow values defined as "0px red" or "0px 0px 10px rgb(255,0,0)" or "0px 0px 20px 20px #F00" and we need to ensure that what we get back is described with 4 numbers and a color. This allows us to feed it into the _parseComplex() method and split the values up appropriately. The neat thing about this _getFormatter() function is that the dflt defines a pattern as well as a default, so for example, _getFormatter("0px 0px 0px 0px #777", true) not only sets the default as 0px for all distances and #777 for the color, but also sets the pattern such that 4 numbers and a color will always get returned. 21463 * @param {!string} dflt The default value and pattern to follow. So "0px 0px 0px 0px #777" will ensure that 4 numbers and a color will always get returned. 21464 * @param {boolean=} clr If true, the values should be searched for color-related data. For example, boxShadow values typically contain a color whereas borderRadius don't. 21465 * @param {boolean=} collapsible If true, the value is a top/left/right/bottom style one that acts like margin or padding, where if only one value is received, it's used for all 4; if 2 are received, the first is duplicated for 3rd (bottom) and the 2nd is duplicated for the 4th spot (left), etc. 21466 * @return {Function} formatter function 21467 */ 21468 var _getFormatter = function(dflt, clr, collapsible, multi) { 21469 if (dflt == null) { 21470 return function(v) {return v;}; 21471 } 21472 var dColor = clr ? (dflt.match(_colorExp) || [""])[0] : "", 21473 dVals = dflt.split(dColor).join("").match(_valuesExp) || [], 21474 pfx = dflt.substr(0, dflt.indexOf(dVals[0])), 21475 sfx = (dflt.charAt(dflt.length - 1) === ")") ? ")" : "", 21476 delim = (dflt.indexOf(" ") !== -1) ? " " : ",", 21477 numVals = dVals.length, 21478 dSfx = (numVals > 0) ? dVals[0].replace(_numExp, "") : "", 21479 formatter; 21480 if (!numVals) { 21481 return function(v) {return v;}; 21482 } 21483 if (clr) { 21484 formatter = function(v) { 21485 var color, vals, i, a; 21486 if (typeof(v) === "number") { 21487 v += dSfx; 21488 } else if (multi && _commasOutsideParenExp.test(v)) { 21489 a = v.replace(_commasOutsideParenExp, "|").split("|"); 21490 for (i = 0; i < a.length; i++) { 21491 a[i] = formatter(a[i]); 21492 } 21493 return a.join(","); 21494 } 21495 color = (v.match(_colorExp) || [dColor])[0]; 21496 vals = v.split(color).join("").match(_valuesExp) || []; 21497 i = vals.length; 21498 if (numVals > i--) { 21499 while (++i < numVals) { 21500 vals[i] = collapsible ? vals[(((i - 1) / 2) | 0)] : dVals[i]; 21501 } 21502 } 21503 return pfx + vals.join(delim) + delim + color + sfx + (v.indexOf("inset") !== -1 ? " inset" : ""); 21504 }; 21505 return formatter; 21506 21507 } 21508 formatter = function(v) { 21509 var vals, a, i; 21510 if (typeof(v) === "number") { 21511 v += dSfx; 21512 } else if (multi && _commasOutsideParenExp.test(v)) { 21513 a = v.replace(_commasOutsideParenExp, "|").split("|"); 21514 for (i = 0; i < a.length; i++) { 21515 a[i] = formatter(a[i]); 21516 } 21517 return a.join(","); 21518 } 21519 vals = v.match(_valuesExp) || []; 21520 i = vals.length; 21521 if (numVals > i--) { 21522 while (++i < numVals) { 21523 vals[i] = collapsible ? vals[(((i - 1) / 2) | 0)] : dVals[i]; 21524 } 21525 } 21526 return pfx + vals.join(delim) + sfx; 21527 }; 21528 return formatter; 21529 }, 21530 21531 /** 21532 * @private returns a formatter function that's used for edge-related values like marginTop, marginLeft, paddingBottom, paddingRight, etc. Just pass a comma-delimited list of property names related to the edges. 21533 * @param {!string} props a comma-delimited list of property names in order from top to left, like "marginTop,marginRight,marginBottom,marginLeft" 21534 * @return {Function} a formatter function 21535 */ 21536 _getEdgeParser = function(props) { 21537 props = props.split(","); 21538 return function(t, e, p, cssp, pt, plugin, vars) { 21539 var a = (e + "").split(" "), 21540 i; 21541 vars = {}; 21542 for (i = 0; i < 4; i++) { 21543 vars[props[i]] = a[i] = a[i] || a[(((i - 1) / 2) >> 0)]; 21544 } 21545 return cssp.parse(t, vars, pt, plugin); 21546 }; 21547 }, 21548 21549 // @private used when other plugins must tween values first, like BezierPlugin or ThrowPropsPlugin, etc. That plugin's setRatio() gets called first so that the values are updated, and then we loop through the MiniPropTweens which handle copying the values into their appropriate slots so that they can then be applied correctly in the main CSSPlugin setRatio() method. Remember, we typically create a proxy object that has a bunch of uniquely-named properties that we feed to the sub-plugin and it does its magic normally, and then we must interpret those values and apply them to the css because often numbers must get combined/concatenated, suffixes added, etc. to work with css, like boxShadow could have 4 values plus a color. 21550 _setPluginRatio = _internals._setPluginRatio = function(v) { 21551 this.plugin.setRatio(v); 21552 var d = this.data, 21553 proxy = d.proxy, 21554 mpt = d.firstMPT, 21555 min = 0.000001, 21556 val, pt, i, str, p; 21557 while (mpt) { 21558 val = proxy[mpt.v]; 21559 if (mpt.r) { 21560 val = mpt.r(val); 21561 } else if (val < min && val > -min) { 21562 val = 0; 21563 } 21564 mpt.t[mpt.p] = val; 21565 mpt = mpt._next; 21566 } 21567 if (d.autoRotate) { 21568 d.autoRotate.rotation = d.mod ? d.mod.call(this._tween, proxy.rotation, this.t, this._tween) : proxy.rotation; //special case for ModifyPlugin to hook into an auto-rotating bezier 21569 } 21570 //at the end, we must set the CSSPropTween's "e" (end) value dynamically here because that's what is used in the final setRatio() method. Same for "b" at the beginning. 21571 if (v === 1 || v === 0) { 21572 mpt = d.firstMPT; 21573 p = (v === 1) ? "e" : "b"; 21574 while (mpt) { 21575 pt = mpt.t; 21576 if (!pt.type) { 21577 pt[p] = pt.s + pt.xs0; 21578 } else if (pt.type === 1) { 21579 str = pt.xs0 + pt.s + pt.xs1; 21580 for (i = 1; i < pt.l; i++) {
21581 str += pt["xn"+i] + pt["xs"+(i+1)]; 21582 } 21583 pt[p] = str; 21584 } 21585 mpt = mpt._next; 21586 } 21587 } 21588 }, 21589 21590 /** 21591 * @private @constructor Used by a few SpecialProps to hold important values for proxies. For example, _parseToProxy() creates a MiniPropTween instance for each property that must get tweened on the proxy, and we record the original property name as well as the unique one we create for the proxy, plus whether or not the value needs to be rounded plus the original value. 21592 * @param {!Object} t target object whose property we're tweening (often a CSSPropTween) 21593 * @param {!string} p property name 21594 * @param {(number|string|object)} v value 21595 * @param {MiniPropTween=} next next MiniPropTween in the linked list 21596 * @param {boolean=} r if true, the tweened value should be rounded to the nearest integer 21597 */ 21598 MiniPropTween = function(t, p, v, next, r) { 21599 this.t = t; 21600 this.p = p; 21601 this.v = v; 21602 this.r = r; 21603 if (next) { 21604 next._prev = this; 21605 this._next = next; 21606 } 21607 }, 21608 21609 /** 21610 * @private Most other plugins (like BezierPlugin and ThrowPropsPlugin and others) can only tween numeric values, but CSSPlugin must accommodate special values that have a bunch of extra data (like a suffix or strings between numeric values, etc.). For example, boxShadow has values like "10px 10px 20px 30px rgb(255,0,0)" which would utterly confuse other plugins. This method allows us to split that data apart and grab only the numeric data and attach it to uniquely-named properties of a generic proxy object ({}) so that we can feed that to virtually any plugin to have the numbers tweened. However, we must also keep track of which properties from the proxy go with which CSSPropTween values and instances. So we create a linked list of MiniPropTweens. Each one records a target (the original CSSPropTween), property (like "s" or "xn1" or "xn2") that we're tweening and the unique property name that was used for the proxy (like "boxShadow_xn1" and "boxShadow_xn2") and whether or not they need to be rounded. That way, in the _setPluginRatio() method we can simply copy the values over from the proxy to the CSSPropTween instance(s). Then, when the main CSSPlugin setRatio() method runs and applies the CSSPropTween values accordingly, they're updated nicely. So the external plugin tweens the numbers, _setPluginRatio() copies them over, and setRatio() acts normally, applying css-specific values to the element. 21611 * This method returns an object that has the following properties:
21612 * - proxy: a generic object containing the starting values for all the properties that will be tweened by the external plugin. This is what we feed to the external _onInitTween() as the target 21613 * - end: a generic object containing the ending values for all the properties that will be tweened by the external plugin. This is what we feed to the external plugin's _onInitTween() as the destination values 21614 * - firstMPT: the first MiniPropTween in the linked list 21615 * - pt: the first CSSPropTween in the linked list that was created when parsing. If shallow is true, this linked list will NOT attach to the one passed into the _parseToProxy() as the "pt" (4th) parameter. 21616 * @param {!Object} t target object to be tweened 21617 * @param {!(Object|string)} vars the object containing the information about the tweening values (typically the end/destination values) that should be parsed 21618 * @param {!CSSPlugin} cssp The CSSPlugin instance 21619 * @param {CSSPropTween=} pt the next CSSPropTween in the linked list 21620 * @param {TweenPlugin=} plugin the external TweenPlugin instance that will be handling tweening the numeric values 21621 * @param {boolean=} shallow if true, the resulting linked list from the parse will NOT be attached to the CSSPropTween that was passed in as the "pt" (4th) parameter. 21622 * @return An object containing the following properties: proxy, end, firstMPT, and pt (see above for descriptions) 21623 */ 21624 _parseToProxy = _internals._parseToProxy = function(t, vars, cssp, pt, plugin, shallow) { 21625 var bpt = pt, 21626 start = {}, 21627 end = {}, 21628 transform = cssp._transform, 21629 oldForce = _forcePT, 21630 i, p, xp, mpt, firstPT; 21631 cssp._transform = null; 21632 _forcePT = vars; 21633 pt = firstPT = cssp.parse(t, vars, pt, plugin); 21634 _forcePT = oldForce; 21635 //break off from the linked list so the new ones are isolated. 21636 if (shallow) { 21637 cssp._transform = transform; 21638 if (bpt) { 21639 bpt._prev = null; 21640 if (bpt._prev) { 21641 bpt._prev._next = null; 21642 } 21643 } 21644 } 21645 while (pt && pt !== bpt) { 21646 if (pt.type <= 1) { 21647 p = pt.p; 21648 end[p] = pt.s + pt.c; 21649 start[p] = pt.s; 21650 if (!shallow) { 21651 mpt = new MiniPropTween(pt, "s", p, mpt, pt.r); 21652 pt.c = 0; 21653 } 21654 if (pt.type === 1) { 21655 i = pt.l; 21656 while (--i > 0) { 21657 xp = "xn" + i; 21658 p = pt.p + "_" + xp; 21659 end[p] = pt.data[xp]; 21660 start[p] = pt[xp]; 21661 if (!shallow) { 21662 mpt = new MiniPropTween(pt, xp, p, mpt, pt.rxp[xp]); 21663 } 21664 } 21665 } 21666 } 21667 pt = pt._next; 21668 } 21669 return {proxy:start, end:end, firstMPT:mpt, pt:firstPT}; 21670 }, 21671 21672 21673 21674 /** 21675 * @constructor Each property that is tweened has at least one CSSPropTween associated with it. These instances store important information like the target, property, starting value, amount of change, etc. They can also optionally have a number of "extra" strings and numeric values named xs1, xn1, xs2, xn2, xs3, xn3, etc. where "s" indicates string and "n" indicates number. These can be pieced together in a complex-value tween (type:1) that has alternating types of data like a string, number, string, number, etc. For example, boxShadow could be "5px 5px 8px rgb(102, 102, 51)". In that value, there are 6 numbers that may need to tween and then pieced back together into a string again with spaces, suffixes, etc. xs0 is special in that it stores the suffix for standard (type:0) tweens, -OR- the first string (prefix) in a complex-value (type:1) CSSPropTween -OR- it can be the non-tweening value in a type:-1 CSSPropTween. We do this to conserve memory. 21676 * CSSPropTweens have the following optional properties as well (not defined through the constructor): 21677 * - l: Length in terms of the number of extra properties that the CSSPropTween has (default: 0). For example, for a boxShadow we may need to tween 5 numbers in which case l would be 5; Keep in mind that the start/end values for the first number that's tweened are always stored in the s and c properties to conserve memory. All additional values thereafter are stored in xn1, xn2, etc. 21678 * - xfirst: The first instance of any sub-CSSPropTweens that are tweening properties of this instance. For example, we may split up a boxShadow tween so that there's a main CSSPropTween of type:1 that has various xs* and xn* values associated with the h-shadow, v-shadow, blur, color, etc. Then we spawn a CSSPropTween for each of those that has a higher priority and runs BEFORE the main CSSPropTween so that the values are all set by the time it needs to re-assemble them. The xfirst gives us an easy way to identify the first one in that chain which typically ends at the main one (because they're all prepende to the linked list) 21679 * - plugin: The TweenPlugin instance that will handle the tweening of any complex values. For example, sometimes we don't want to use normal subt
21679weens (like xfirst refers to) to tween the values - we might want ThrowPropsPlugin or BezierPlugin some other plugin to do the actual tweening, so we create a plugin instance and store a reference here. We need this reference so that if we get a request to round values or disable a tween, we can pass along that request. 21680 * - data: Arbitrary data that needs to be stored with the CSSPropTween. Typically if we're going to have a plugin handle the tweening of a complex-value tween, we create a generic object that stores the END values that we're tweening to and the CSSPropTween's xs1, xs2, etc. have the starting values. We store that object as data. That way, we can simply pass that object to the plugin and use the CSSPropTween as the target. 21681 * - setRatio: Only used for type:2 tweens that require custom functionality. In this case, we call the CSSPropTween's setRatio() method and pass the ratio each time the tween updates. This isn't quite as efficient as doing things directly in the CSSPlugin's setRatio() method, but it's very convenient and flexible. 21682 * @param {!Object} t Target object whose property will be tweened. Often a DOM element, but not always. It could be anything. 21683 * @param {string} p Property to tween (name). For example, to tween element.width, p would be "width". 21684 * @param {number} s Starting numeric value 21685 * @param {number} c Change in numeric value over the course of the entire tween. For example, if element.width starts at 5 and should end at 100, c would be 95. 21686 * @param {CSSPropTween=} next The next CSSPropTween in the linked list. If one is defined, we will define its _prev as the new instance, and the new instance's _next will be pointed at it. 21687 * @param {number=} type The type of CSSPropTween where -1 = a non-tweening value, 0 = a standard simple tween, 1 = a complex value (like one that has multiple numbers in a comma- or space-delimited string like border:"1px solid red"), and 2 = one that uses a custom setRatio function that does all of the work of applying the values on each update. 21688 * @param {string=} n Name of the property that should be used for overwriting purposes which is typically the same as p but not always. For example, we may need to create a subtween for the 2nd part of a "clip:rect(...)" tween in which case "p" might be xs1 but "n" is still "clip" 21689 * @param {boolean=} r If true, the value(s) should be rounded 21690 * @param {number=} pr Priority in the linked list order. Higher priority CSSPropTweens will be updated before lower priority ones. The default priority is 0. 21691 * @param {string=} b Beginning value. We store this to ensure that it is EXACTLY what it was when the tween began without any risk of interpretation issues. 21692 * @param {string=} e Ending value. We store this to ensure that it is EXACTLY what the user defined at the end of the tween without any risk of interpretation issues. 21693 */ 21694 CSSPropTween = _internals.CSSPropTween = function(t, p, s, c, next, type, n, r, pr, b, e) { 21695 this.t = t; //target 21696 this.p = p; //property 21697 this.s = s; //starting value 21698 this.c = c; //change value 21699 this.n = n || p; //name that this CSSPropTween should be associated to (usually the same as p, but not always - n is what overwriting looks at) 21700 if (!(t instanceof CSSPropTween)) { 21701 _overwriteProps.push(this.n); 21702 } 21703 this.r = !r ? r : (typeof(r) === "function") ? r : Math.round; //round (boolean) 21704 this.type = type || 0; //0 = normal tween, -1 = non-tweening (in which case xs0 will be applied to the target's property, like tp.t[tp.p] = tp.xs0), 1 = complex-value SpecialProp, 2 = custom setRatio() that does all the work 21705 if (pr) { 21706 this.pr = pr; 21707 _hasPriority = true; 21708 } 21709 this.b = (b === undefined) ? s : b; 21710 this.e = (e === undefined) ? s + c : e; 21711 if (next) { 21712 this._next = next; 21713 next._prev = this; 21714 } 21715 }, 21716 21717 _addNonTweeningNumericPT = function(target, prop, start, end, next, overwriteProp) { //cleans up some code redundancies and helps minification. Just a fast way to add a NUMERIC non-tweening CSSPropTween
21718 var pt = new CSSPropTween(target, prop, start, end - start, next, -1, overwriteProp); 21719 pt.b = start; 21720 pt.e = pt.xs0 = end; 21721 return pt; 21722 }, 21723 21724 /** 21725 * Takes a target, the beginning value and ending value (as strings) and parses them into a CSSPropTween (possibly with child CSSPropTweens) that accommodates multiple numbers, colors, comma-delimited values, etc. For example: 21726 * sp.parseComplex(element, "boxShadow", "5px 10px 20px rgb(255,102,51)", "0px 0px 0px red", true, "0px 0px 0px rgb(0,0,0,0)", pt); 21727 * It will walk through the beginning and ending values (which should be in the same format with the same number and type of values) and figure out which parts are numbers, what strings separate the numeric/tweenable values, and then create the CSSPropTweens accordingly. If a plugin is defined, no child CSSPropTweens will be created. Instead, the ending values will be stored in the "data" property of the returned CSSPropTween like: {s:-5, xn1:-10, xn2:-20, xn3:255, xn4:0, xn5:0} so that it can be fed to any other plugin and it'll be plain numeric tweens but the recomposition of the complex value will be handled inside CSSPlugin's setRatio(). 21728 * If a setRatio is defined, the type of the CSSPropTween will be set to 2 and recomposition of the values will be the responsibility of that method. 21729 * 21730 * @param {!Object} t Target whose property will be tweened 21731 * @param {!string} p Property that will be tweened (its name, like "left" or "backgroundColor" or "boxShadow") 21732 * @param {string} b Beginning value 21733 * @param {string} e Ending value 21734 * @param {boolean} clrs If true, the value could contain a color value like "rgb(255,0,0)" or "#F00" or "red". The default is false, so no colors will be recognized (a performance optimization) 21735 * @param {(string|number|Object)} dflt The default beginning value that should be used if no valid beginning value is defined or if the number of values inside the complex beginning and ending values don't match 21736 * @param {?CSSPropTween} pt CSSPropTween instance that is the current head of the linked list (we'll prepend to this). 21737 * @param {number=} pr Priority in the linked list order. Higher priority properties will be updated before lower priority ones. The default priority is 0. 21738 * @param {TweenPlugin=} plugin If a plugin should handle the tweening of extra properties, pass the plugin instance here. If one is defined, then NO subtweens will be created for any extra properties (the properties will be created - just not additional CSSPropTween instances to tween them) because the plugin is expected to do so. However, the end values WILL be populated in the "data" property, like {s:100, xn1:50, xn2:300} 21739 * @param {function(number)=} setRatio If values should be set in a custom function instead of being pieced together in a type:1 (complex-value) CSSPropTween, define that custom function here. 21740 * @return {CSSPropTween} The first CSSPropTween in the linked list which includes the new one(s) added by the parseComplex() call. 21741 */ 21742 _parseComplex = CSSPlugin.parseComplex = function(t, p, b, e, clrs, dflt, pt, pr, plugin, setRatio) { 21743 //DEBUG: _log("parseComplex: "+p+", b: "+b+", e: "+e); 21744 b = b || dflt || ""; 21745 if (typeof(e) === "function") { 21746 e = e(_index, _target); 21747 } 21748 pt = new CSSPropTween(t, p, 0, 0, pt, (setRatio ? 2 : 1), null, false, pr, b, e); 21749 e += ""; //ensures it's a string 21750 if (clrs && _colorExp.test(e + b)) { //if colors are found, normalize the formatting to rgba() or hsla(). 21751 e = [b, e]; 21752 CSSPlugin.colorStringFilter(e); 21753 b = e[0]; 21754 e = e[1]; 21755 } 21756 var ba = b.split(", ").join(",").split(" "), //beginning array 21757 ea = e.split(", ").join(",").split(" "), //ending array 21758 l = ba.length, 21759 autoRound = (_autoRound !== false), 21760 i, xi, ni, bv, ev, bnums, enums, bn, hasAlpha, temp, cv, str, useHSL; 21761 if (e.indexOf(",") !== -1 || b.indexOf(",") !== -1) { 21762 if ((e + b).indexOf("rgb") !== -1 || (e + b).indexOf("hsl") !== -1) { //keep rgb(), rgba(), hsl(), and hsla() values together! (remember, we're splitting on spaces) 21763 ba = ba.join(" ").replace(_commasOutsideParenExp, ", ").split(" "); 21764 ea = ea.join(" ").replace(_commasOutsideParenExp, ", ").split(" "); 21765 } else { 21766 ba = ba.join(" ").split(",").join(", ").split(" "); 21767 ea = ea.join(" ").split(",").join(", ").split(" "); 21768 } 21769 l = ba.length; 21770 } 21771 if (l !== ea.length) { 21772 //DEBUG: _log("mismatched formatting detected on " + p + " (" + b + " vs " + e + ")"); 21773 ba = (dflt || "").split(" "); 21774 l = ba.length; 21775 } 21776 pt.plugin = plugin; 21777 pt.setRatio = setRatio; 21778 _colorExp.lastIndex = 0; 21779 for (i = 0; i < l; i++) { 21780 bv = ba[i]; 21781 ev = ea[i] + ""; 21782 bn = parseFloat(bv); 21783 //if the value begins with a number (most common). It's fine if it has a suffix like px 21784 if (bn || bn === 0) { 21785 pt.appendXtra("", bn, _parseChange(ev, bn), ev.replace(_relNumExp, ""), (autoRound && ev.indexOf("px") !== -1) ? Math.round : false, true); 21786 21787 //if the value is a color 21788 } else if (clrs && _colorExp.test(bv)) { 21789 str = ev.indexOf(")") + 1; 21790 str = ")" + (str ? ev.substr(str) : ""); //if there's a comma or ) at the end, retain it. 21791 useHSL = (ev.indexOf("hsl") !== -1 && _supportsOpacity); 21792 temp = ev; //original string value so we can look for any prefix later. 21793 bv = _parseColor(bv, useHSL); 21794 ev = _parseColor(ev, useHSL); 21795 hasAlpha = (bv.length + ev.length > 6); 21796 if (hasAlpha && !_supportsOpacity && ev[3] === 0) { //older versions of IE don't support rgba(), so if the destination alpha is 0, just use "transparent" for the end color 21797 pt["xs" + pt.l] += pt.l ? " transparent" : "transparent";
21798 pt.e = pt.e.split(ea[i]).join("transparent"); 21799 } else { 21800 if (!_supportsOpacity) { //old versions of IE don't support rgba(). 21801 hasAlpha = false; 21802 } 21803 if (useHSL) { 21804 pt.appendXtra(temp.substr(0, temp.indexOf("hsl")) + (hasAlpha ? "hsla(" : "hsl("), bv[0], _parseChange(ev[0], bv[0]), ",", false, true) 21805 .appendXtra("", bv[1], _parseChange(ev[1], bv[1]), "%,", false) 21806 .appendXtra("", bv[2], _parseChange(ev[2], bv[2]), (hasAlpha ? "%," : "%" + str), false); 21807 } else { 21808 pt.appendXtra(temp.substr(0, temp.indexOf("rgb")) + (hasAlpha ? "rgba(" : "rgb("), bv[0], ev[0] - bv[0], ",", Math.round, true) 21809 .appendXtra("", bv[1], ev[1] - bv[1], ",", Math.round) 21810 .appendXtra("", bv[2], ev[2] - bv[2], (hasAlpha ? "," : str), Math.round); 21811 } 21812 21813 if (hasAlpha) { 21814 bv = (bv.length < 4) ? 1 : bv[3]; 21815 pt.appendXtra("", bv, ((ev.length < 4) ? 1 : ev[3]) - bv, str, false); 21816 } 21817 } 21818 _colorExp.lastIndex = 0; //otherwise the test() on the RegExp could move the lastIndex and taint future results. 21819 21820 } else { 21821 bnums = bv.match(_numExp); //gets each group of numbers in the beginning value string and drops them into an array 21822 21823 //if no number is found, treat it as a non-tweening value and just append the string to the current xs. 21824 if (!bnums) { 21825 pt["xs" + pt.l] += (pt.l || pt["xs" + pt.l]) ? " " + ev : ev; 21826 21827 //loop through all the numbers that are found and construct the extra values on the pt. 21828 } else { 21829 enums = ev.match(_relNumExp); //get each group of numbers in the end value string and drop them into an array. We allow relative values too, like +=50 or -=.5 21830 if (!enums || enums.length !== bnums.length) { 21831 //DEBUG: _log("mismatched formatting detected on " + p + " (" + b + " vs " + e + ")"); 21832 return pt; 21833 } 21834 ni = 0; 21835 for (xi = 0; xi < bnums.length; xi++) { 21836 cv = bnums[xi]; 21837 temp = bv.indexOf(cv, ni); 21838 pt.appendXtra(bv.substr(ni, temp - ni), Number(cv), _parseChange(enums[xi], cv), "", (autoRound && bv.substr(temp + cv.length, 2) === "px") ? Math.round : false, (xi === 0)); 21839 ni = temp + cv.length; 21840 } 21841 pt["xs" + pt.l] += bv.substr(ni); 21842 } 21843 } 21844 } 21845 //if there are relative values ("+=" or "-=" prefix), we need to adjust the ending value to eliminate the prefixes and combine the values properly. 21846 if (e.indexOf("=") !== -1) if (pt.data) { 21847 str = pt.xs0 + pt.data.s; 21848 for (i = 1; i < pt.l; i++) { 21849 str += pt["xs" + i] + pt.data["xn" + i]; 21850 } 21851 pt.e = str + pt["xs" + i]; 21852 } 21853 if (!pt.l) { 21854 pt.type = -1; 21855 pt.xs0 = pt.e; 21856 } 21857 return pt.xfirst || pt; 21858 }, 21859 i = 9; 21860 21861 21862 p = CSSPropTween.prototype; 21863 p.l = p.pr = 0; //length (number of extra properties like xn1, xn2, xn3, etc. 21864 while (--i > 0) { 21865 p["xn" + i] = 0; 21866 p["xs" + i] = ""; 21867 } 21868 p.xs0 = ""; 21869 p._next = p._prev = p.xfirst = p.data = p.plugin = p.setRatio = p.rxp = null; 21870 21871 21872 /** 21873 * Appends and extra tweening value to a CSSPropTween and automatically manages any prefix and suffix strings. The first extra value is stored in the s and c of the main CSSPropTween instance, but thereafter any extras are stored in the xn1, xn2, xn3, etc. The prefixes and suffixes are stored in the xs0, xs1, xs2, etc. properties. For example, if I walk through a clip value like "rect(10px, 5px, 0px, 20px)", the values would be stored like this: 21874 * xs0:"rect(", s:10, xs1:"px, ", xn1:5, xs2:"px, ", xn2:0, xs3:"px, ", xn3:20, xn4:"px)" 21875 * And they'd all get joined together when the CSSPlugin renders (in the setRatio() method). 21876 * @param {string=} pfx Prefix (if any) 21877 * @param {!number} s Starting value 21878 * @param {!number} c Change in numeric value over the course of the entire tween. For example, if the start is 5 and the end is 100, the change would be 95. 21879 * @param {string=} sfx Suffix (if any) 21880 * @param {boolean=} r Round (if true). 21881 * @param {boolean=} pad If true, this extra value should be separated by the previous one by a space. If there is no previous extra and pad is true, it will automatically drop the space. 21882 * @return {CSSPropTween} returns itself so that multiple methods can be chained together. 21883 */ 21884 p.appendXtra = function(pfx, s, c, sfx, r, pad) { 21885 var pt = this, 21886 l = pt.l; 21887 pt["xs" + l] += (pad && (l || pt["xs" + l])) ? " " + pfx : pfx || ""; 21888 if (!c) if (l !== 0 && !pt.plugin) { //typically we'll combine non-changing values right into the xs to optimize performance, but we don't combine them when there's a plugin that will be tweening the values because it may depend on the values being split apart, like for a bezier, if a value doesn't change between the first and second iteration but then it does on the 3rd, we'll run into trouble because there's no xn slot for that value! 21889 pt["xs" + l] += s + (sfx || ""); 21890 return pt; 21891 } 21892 pt.l++; 21893 pt.type = pt.setRatio ? 2 : 1; 21894 pt["xs" + pt.l] = sfx || ""; 21895 if (l > 0) { 21896 pt.data["xn" + l] = s + c; 21897 pt.rxp["xn" + l] = r; //round extra property (we need to tap into this in the _parseToProxy() method) 21898 pt["xn" + l] = s; 21899 if (!pt.plugin) { 21900 pt.xfirst = new CSSPropTween(pt, "xn" + l, s, c, pt.xfirst || pt, 0, pt.n, r, pt.pr); 21901 pt.xfirst.xs0 = 0; //just to ensure that the property stays numeric which helps modern browsers speed up processing. Remember, in the setRatio() method, we do pt.t[pt.p] = val + pt.xs0 so if pt.xs0 is "" (the default), it'll cast the end value as a string. When a property is a number sometimes and a string sometimes, it prevents the compiler from locking in the data type, slowing things down slightly. 21902 } 21903 return pt; 21904 } 21905 pt.data = {s:s + c}; 21906 pt.rxp = {}; 21907 pt.s = s; 21908 pt.c = c; 21909 pt.r = r; 21910 return pt; 21911 }; 21912 21913 /** 21914 * @constructor A SpecialProp is basically a css property that needs to be treated in a non-standard way, like if it may contain a complex value like boxShadow:"5px 10px 15px rgb(255, 102, 51)" or if it is associated with another plugin like ThrowPropsPlugin or BezierPlugin. Every SpecialProp is associated with a particular property name like "boxShadow" or "throwProps" or "bezier" and it will intercept those values in the vars object that's passed to the CSSPlugin and handle them accordingly. 21915 * @param {!string} p Property name (like "boxShadow" or "throwProps") 21916 * @param {Object=}
21916 options An object containing any of the following configuration options: 21917 * - defaultValue: the default value 21918 * - parser: A function that should be called when the associated property name is found in the vars. This function should return a CSSPropTween instance and it should ensure that it is properly inserted into the linked list. It will receive 4 paramters: 1) The target, 2) The value defined in the vars, 3) The CSSPlugin instance (whose _firstPT should be used for the linked list), and 4) A computed style object if one was calculated (this is a speed optimization that allows retrieval of starting values quicker) 21919 * - formatter: a function that formats any value received for this special property (for example, boxShadow could take "5px 5px red" and format it to "5px 5px 0px 0px red" so that both the beginning and ending values have a common order and quantity of values.) 21920 * - prefix: if true, we'll determine whether or not this property requires a vendor prefix (like Webkit or Moz or ms or O) 21921 * - color: set this to true if the value for this SpecialProp may contain color-related values like rgb(), rgba(), etc. 21922 * - priority: priority in the linked list order. Higher priority SpecialProps will be updated before lower priority ones. The default priority is 0. 21923 * - multi: if true, the formatter should accommodate a comma-delimited list of values, like boxShadow could have multiple boxShadows listed out. 21924 * - collapsible: if true, the formatter should treat the value like it's a top/right/bottom/left value that could be collapsed, like "5px" would apply to all, "5px, 10px" would use 5px for top/bottom and 10px for right/left, etc. 21925 * - keyword: a special keyword that can [optionally] be found inside the value (like "inset" for boxShadow). This allows us to validate beginning/ending values to make sure they match (if the keyword is found in one, it'll be added to the other for consistency by default). 21926 */ 21927 var SpecialProp = function(p, options) { 21928 options = options || {}; 21929 this.p = options.prefix ? _checkPropPrefix(p) || p : p; 21930 _specialProps[p] = _specialProps[this.p] = this; 21931 this.format = options.formatter || _getFormatter(options.defaultValue, options.color, options.collapsible, options.multi); 21932 if (options.parser) { 21933 this.parse = options.parser; 21934 } 21935 this.clrs = options.color; 21936 this.multi = options.multi; 21937 this.keyword = options.keyword; 21938 this.dflt = options.defaultValue; 21939 this.pr = options.priority || 0; 21940 }, 21941 21942 //shortcut for creating a new SpecialProp that can accept multiple properties as a comma-delimited list (helps minification). dflt can be an array for multiple values (we don't do a comma-delimited list because the default value may contain commas, like rect(0px,0px,0px,0px)). We attach this method to the SpecialProp class/object instead of using a private _createSpecialProp() method so that we can tap into it externally if necessary, like from another plugin. 21943 _registerComplexSpecialProp = _internals._registerComplexSpecialProp = function(p, options, defaults) { 21944 if (typeof(options) !== "object") { 21945 options = {parser:defaults}; //to make backwards compatible with older versions of BezierPlugin and ThrowPropsPlugin 21946 } 21947 var a = p.split(","), 21948 d = options.defaultValue, 21949 i, temp; 21950 defaults = defaults || [d]; 21951 for (i = 0; i < a.length; i++) { 21952 options.prefix = (i === 0 && options.prefix); 21953 options.defaultValue = defaults[i] || d; 21954 temp = new SpecialProp(a[i], options); 21955 } 21956 }, 21957 21958 //creates a placeholder special prop for a plugin so that the property gets caught the first time a tween of it is attempted, and at that time it makes the plugin register itself, thus taking over for all future tweens of that property. This allows us to not mandate that things load in a particular order and it also allows us to log() an error that informs the user when they attempt to tween an external plugin-related property without loading its .js file. 21959 _registerPluginProp = _internals._registerPluginProp = function(p) { 21960 if (!_specialProps[p]) { 21961 var pluginName = p.charAt(0).toUpperCase() + p.substr(1) + "Plugin"; 21962 _registerComplexSpecialProp(p, {parser:function(t, e, p, cssp, pt, plugin, vars) { 21963 var pluginClass = _globals.com.greensock.plugins[pluginName]; 21964 if (!pluginClass) { 21965 _log("Error: " + pluginName + " js file not loaded."); 21966 return pt; 21967 } 21968 pluginClass._cssRegister(); 21969 return _specialProps[p].parse(t, e, p, cssp, pt, plugin, vars); 21970 }}); 21971 } 21972 }; 21973 21974 21975 p = SpecialProp.prototype; 21976 21977 /** 21978 * Alias for _parseComplex() that automatically plugs in certain values for this SpecialProp, like its property name, whether or not colors should be sensed, the default value, and priority. It also looks for any keyword that the SpecialProp defines (like "inset" for boxSh
21978adow) and ensures that the beginning and ending values have the same number of values for SpecialProps where multi is true (like boxShadow and textShadow can have a comma-delimited list) 21979 * @param {!Object} t target element 21980 * @param {(string|number|object)} b beginning value 21981 * @param {(string|number|object)} e ending (destination) value 21982 * @param {CSSPropTween=} pt next CSSPropTween in the linked list 21983 * @param {TweenPlugin=} plugin If another plugin will be tweening the complex value, that TweenPlugin instance goes here. 21984 * @param {function=} setRatio If a custom setRatio() method should be used to handle this complex value, that goes here. 21985 * @return {CSSPropTween=} First CSSPropTween in the linked list 21986 */ 21987 p.parseComplex = function(t, b, e, pt, plugin, setRatio) { 21988 var kwd = this.keyword, 21989 i, ba, ea, l, bi, ei; 21990 //if this SpecialProp's value can contain a comma-delimited list of values (like boxShadow or textShadow), we must parse them in a special way, and look for a keyword (like "inset" for boxShadow) and ensure that the beginning and ending BOTH have it if the end defines it as such. We also must ensure that there are an equal number of values specified (we can't tween 1 boxShadow to 3 for example) 21991 if (this.multi) if (_commasOutsideParenExp.test(e) || _commasOutsideParenExp.test(b)) { 21992 ba = b.replace(_commasOutsideParenExp, "|").split("|"); 21993 ea = e.replace(_commasOutsideParenExp, "|").split("|"); 21994 } else if (kwd) { 21995 ba = [b]; 21996 ea = [e]; 21997 } 21998 if (ea) { 21999 l = (ea.length > ba.length) ? ea.length : ba.length; 22000 for (i = 0; i < l; i++) { 22001 b = ba[i] = ba[i] || this.dflt; 22002 e = ea[i] = ea[i] || this.dflt; 22003 if (kwd) { 22004 bi = b.indexOf(kwd); 22005 ei = e.indexOf(kwd); 22006 if (bi !== ei) { 22007 if (ei === -1) { //if the keyword isn't in the end value, remove it from the beginning one. 22008 ba[i] = ba[i].split(kwd).join(""); 22009 } else if (bi === -1) { //if the keyword isn't in the beginning, add it. 22010 ba[i] += " " + kwd; 22011 } 22012 } 22013 } 22014 } 22015 b = ba.join(", "); 22016 e = ea.join(", "); 22017 } 22018 return _parseComplex(t, this.p, b, e, this.clrs, this.dflt, pt, this.pr, plugin, setRatio); 22019 }; 22020 22021 /** 22022 * Accepts a target and end value and spits back a CSSPropTween that has been inserted into the CSSPlugin's linked list and conforms with all the conventions we use internally, like type:-1, 0, 1, or 2, setting up any extra property tweens, priority, etc. For example, if we have a boxShadow SpecialProp and call: 22023 * this._firstPT = sp.parse(element, "5px 10px 20px rgb(2550,102,51)", "boxShadow", this); 22024 * It should figure out the starting value of the element's boxShadow, compare it to the provided end value and create all the necessary CSSPropTweens of the appropriate types to tween the boxShadow. The CSSPropTween that gets spit back should already be inserted into the linked list (the 4th parameter is the current head, so prepend to that). 22025 * @param {!Object} t Target object whose property is being tweened 22026 * @param {Object} e End value as provided in the vars object (typically a string, but not always - like a throwProps would be an object). 22027 * @param {!string} p Property name 22028 * @param {!CSSPlugin} cssp The CSSPlugin instance that should be associated with this tween. 22029 * @param {?CSSPropTween} pt The CSSPropTween that is the current head of the linked list (we'll prepend to it) 22030 * @param {TweenPlugin=} plugin If a plugin will be used to tween the parsed value, this is the plugin instance. 22031 * @param {Object=} vars Original vars object that contains the data for parsing. 22032 * @return {CSSPropTween} The first CSSPropTween in the linked list which includes the new one(s) added by the parse() call. 22033 */ 22034 p.parse = function(t, e, p, cssp, pt, plugin, vars) { 22035 return this.parseComplex(t.style, this.format(_getStyle(t, this.p, _cs, false, this.dflt)), this.format(e), pt, plugin); 22036 }; 22037 22038 /** 22039 * Registers a special property that should be intercepted from any "css" objects defined in tweens. This allows you to handle them however you want without CSSPlugin doing it for you. The 2nd parameter should be a function that accepts 3 parameters: 22040 * 1) Target object whose property should be tweened (typically a DOM element) 22041 * 2) The end/destination value (could be a string, number, object, or whatever you want) 22042 * 3) The tween instance (you probably don't need to worry about this, but it can be useful for looking up information like the duration) 22043 * 22044 * Then, your function should return a function which will be called each time the tween gets rendered, passing a numeric "ratio" parameter to your function that indicates the change factor (usually between 0 and 1). For example: 22045 * 22046 * CSSPlugin.registerSpecialProp("myCustomProp", function(target, value, tween) { 22047 * var start = target.style.width;
22048 * return function(ratio) { 22049 * target.style.width = (start + value * ratio) + "px"; 22050 * console.log("set width to " + target.style.width); 22051 * } 22052 * }, 0); 22053 * 22054 * Then, when I do this tween, it will trigger my special property: 22055 * 22056 * TweenLite.to(element, 1, {css:{myCustomProp:100}}); 22057 * 22058 * In the example, of course, we're just changing the width, but you can do anything you want. 22059 * 22060 * @param {!string} name Property name (or comma-delimited list of property names) that should be intercepted and handled by your function. For example, if I define "myCustomProp", then it would handle that portion of the following tween: TweenLite.to(element, 1, {css:{myCustomProp:100}}) 22061 * @param {!function(Object, Object, Object, string):function(number)} onInitTween The function that will be called when a tween of this special property is performed. The function will receive 4 parameters: 1) Target object that should be tweened, 2) Value that was passed to the tween, 3) The tween instance itself (rarely used), and 4) The property name that's being tweened. Your function should return a function that should be called on every update of the tween. That function will receive a single parameter that is a "change factor" value (typically between 0 and 1) indicating the amount of change as a ratio. You can use this to determine how to set the values appropriately in your function. 22062 * @param {number=} priority Priority that helps the engine determine the order in which to set the properties (default: 0). Higher priority properties will be updated before lower priority ones. 22063 */ 22064 CSSPlugin.registerSpecialProp = function(name, onInitTween, priority) { 22065 _registerComplexSpecialProp(name, {parser:function(t, e, p, cssp, pt, plugin, vars) { 22066 var rv = new CSSPropTween(t, p, 0, 0, pt, 2, p, false, priority); 22067 rv.plugin = plugin; 22068 rv.setRatio = onInitTween(t, e, cssp._tween, p); 22069 return rv; 22070 }, priority:priority}); 22071 }; 22072 22073 22074 22075 22076 22077 22078 //transform-related methods and properties 22079 CSSPlugin.useSVGTransformAttr = true; //Safari and Firefox both have some rendering bugs when applying CSS transforms to SVG elements, so default to using the "transform" attribute instead (users can override this). 22080 var _transformProps = ("scaleX,scaleY,scaleZ,x,y,z,skewX,skewY,rotation,rotationX,rotationY,perspective,xPercent,yPercent").split(","), 22081 _transformProp = _checkPropPrefix("transform"), //the Javascript (camelCase) transform property, like msTransform, WebkitTransform, MozTransform, or OTransform. 22082 _transformPropCSS = _prefixCSS + "transform", 22083 _transformOriginProp = _checkPropPrefix("transformOrigin"), 22084 _supports3D = (_checkPropPrefix("perspective") !== null), 22085 Transform = _internals.Transform = function() { 22086 this.perspective = parseFloat(CSSPlugin.defaultTransformPerspective) || 0; 22087 this.force3D = (CSSPlugin.defaultForce3D === false || !_supports3D) ? false : CSSPlugin.defaultForce3D || "auto"; 22088 }, 22089 _SVGElement = _gsScope.SVGElement, 22090 _useSVGTransformAttr, 22091 //Some browsers (like Firefox and IE) don't honor transform-origin properly in SVG elements, so we need to manually adjust the matrix accordingly. We feature detect here rather than always doing the conversion for certain browsers because they may fix the problem at some point in the future. 22092 22093 _createSVG = function(type, container, attributes) { 22094 var element = _doc.createElementNS("http://www.w3.org/2000/svg", type), 22095 reg = /([a-z])([A-Z])/g, 22096 p; 22097 for (p in attributes) { 22098 element.setAttributeNS(null, p.replace(reg, "$1-$2").toLowerCase(), attributes[p]); 22099 } 22100 container.appendChild(element); 22101 return element; 22102 }, 22103 _docElement = _doc.documentElement || {}, 22104 _forceSVGTransformAttr = (function() { 22105 //IE and Android stock don't support CSS transforms on SVG elements, so we must write them to the "transform" attribute. We populate this variable in the _parseTransform() method, and only if/when we come across an SVG element 22106 var force = _ieVers || (/Android/i.test(_agent) && !_gsScope.chrome), 22107 svg, rect, width; 22108 if (_doc.createElementNS && !force) { //IE8 and earlier doesn't support SVG anyway 22109 svg = _createSVG("svg", _docElement); 22110 rect = _createSVG("rect", svg, {width:100, height:50, x:100}); 22111 width = rect.getBoundingClientRect().width; 22112 rect.style[_transformOriginProp] = "50% 50%"; 22113 rect.style[_transformProp] = "scaleX(0.5)"; 22114 force = (width === rect.getBoundingClientRect().width && !(_is
22114Firefox && _supports3D)); //note: Firefox fails the test even though it does support CSS transforms in 3D. Since we can't push 3D stuff into the transform attribute, we force Firefox to pass the test here (as long as it does truly support 3D). 22115 _docElement.removeChild(svg); 22116 } 22117 return force; 22118 })(), 22119 _parseSVGOrigin = function(e, local, decoratee, absolute, smoothOrigin, skipRecord) { 22120 var tm = e._gsTransform, 22121 m = _getMatrix(e, true), 22122 v, x, y, xOrigin, yOrigin, a, b, c, d, tx, ty, determinant, xOriginOld, yOriginOld; 22123 if (tm) { 22124 xOriginOld = tm.xOrigin; //record the original values before we alter them. 22125 yOriginOld = tm.yOrigin; 22126 } 22127 if (!absolute || (v = absolute.split(" ")).length < 2) { 22128 b = e.getBBox(); 22129 if (b.x === 0 && b.y === 0 && b.width + b.height === 0) { //some browsers (like Firefox) misreport the bounds if the element has zero width and height (it just assumes it's at x:0, y:0), thus we need to manually grab the position in that case. 22130 b = {x: parseFloat(e.hasAttribute("x") ? e.getAttribute("x") : e.hasAttribute("cx") ? e.getAttribute("cx") : 0) || 0, y: parseFloat(e.hasAttribute("y") ? e.getAttribute("y") : e.hasAttribute("cy") ? e.getAttribute("cy") : 0) || 0, width:0, height:0}; 22131 } 22132 local = _parsePosition(local).split(" "); 22133 v = [(local[0].indexOf("%") !== -1 ? parseFloat(local[0]) / 100 * b.width : parseFloat(local[0])) + b.x, 22134 (local[1].indexOf("%") !== -1 ? parseFloat(local[1]) / 100 * b.height : parseFloat(local[1])) + b.y]; 22135 } 22136 decoratee.xOrigin = xOrigin = parseFloat(v[0]); 22137 decoratee.yOrigin = yOrigin = parseFloat(v[1]); 22138 if (absolute && m !== _identity2DMatrix) { //if svgOrigin is being set, we must invert the matrix and determine where the absolute point is, factoring in the current transforms. Otherwise, the svgOrigin would be based on the element's non-transformed position on the canvas. 22139 a = m[0]; 22140 b = m[1]; 22141 c = m[2]; 22142 d = m[3]; 22143 tx = m[4]; 22144 ty = m[5]; 22145 determinant = (a * d - b * c); 22146 if (determinant) { //if it's zero (like if scaleX and scaleY are zero), skip it to avoid errors with dividing by zero. 22147 x = xOrigin * (d / determinant) + yOrigin * (-c / determinant) + ((c * ty - d * tx) / determinant); 22148 y = xOrigin * (-b / determinant) + yOrigin * (a / determinant) - ((a * ty - b * tx) / determinant); 22149 xOrigin = decoratee.xOrigin = v[0] = x; 22150 yOrigin = decoratee.yOrigin = v[1] = y; 22151 } 22152 } 22153 if (tm) { //avoid jump when transformOrigin is changed - adjust the x/y values accordingly 22154 if (skipRecord) { 22155 decoratee.xOffset = tm.xOffset; 22156 decoratee.yOffset = tm.yOffset; 22157 tm = decoratee; 22158 } 22159 if (smoothOrigin || (smoothOrigin !== false && CSSPlugin.defaultSmoothOrigin !== false)) { 22160 x = xOrigin - xOriginOld; 22161 y = yOrigin - yOriginOld; 22162 //originally, we simply adjusted the x and y values, but that would cause problems if, for example, you created a rotational tween part-way through an x/y tween. Managing the offset in a separate variable gives us ultimate flexibility. 22163 //tm.x -= x - (x * m[0] + y * m[2]); 22164 //tm.y -= y - (x * m[1] + y * m[3]); 22165 tm.xOffset += (x * m[0] + y * m[2]) - x; 22166 tm.yOffset += (x * m[1] + y * m[3]) - y; 22167 } else { 22168 tm.xOffset = tm.yOffset = 0; 22169 } 22170 } 22171 if (!skipRecord) { 22172 e.setAttribute("data-svg-origin", v.join(" ")); 22173 } 22174 }, 22175 _getBBoxHack = function(swapIfPossible) { //works around issues in some browsers (like Firefox) that don't correctly report getBBox() on SVG elements inside a <defs> element and/or <mask>. We try creating an SVG, adding it to the documentElement and toss the element in there so that it's definitely part of the rendering tree, then grab the bbox and if it works, we actually swap out the original getBBox() method for our own that does these extra steps whenever getBBox is needed. This helps ensure that performance is optimal (only do all these extra steps when absolutely necessary...most elements don't need it). 22176 var svg = _createElement("svg", (this.ownerSVGElement && this.ownerSVGElement.getAttribute("xmlns")) || "http://www.w3.org/2000/svg"), 22177 oldParent = this.parentNode, 22178 oldSibling = this.nextSibling, 22179 oldCSS = this.style.cssText, 22180 bbox; 22181 _docElement.appendChild(svg); 22182 svg.appendChild(this); 22183 this.style.display = "block"; 22184 if (swapIfPossible) { 22185 try { 22186 bbox = this.getBBox(); 22187 this._originalGetBBox = this.getBBox; 22188 this.getBBox = _getBBoxHack; 22189 } catch (e) { } 22190 } else if (this._originalGetBBox) { 22191 bbox = this._originalGetBBox(); 22192 } 22193 if (oldSibling) { 22194 oldParent.insertBefore(this, oldSibling); 22195 } else { 22196 oldParent.appendChild(this); 22197 } 22198 _docElement.removeChild(svg); 22199 this.style.cssText = oldCSS; 22200 return bbox; 22201 }, 22202 _getBBox = function(e) { 22203 try { 22204 return e.getBBox(); //Firefox throws errors if you try calling getBBox() on an SVG element that's not rendered (like in a <symbol> or <defs>). https://bugzilla.mozilla.org/show_bug.cgi?id=612118 22205 } catch (error) { 22206 return _getBBoxHack.call(e, true); 22207 } 22208 }, 22209 _isSVG = function(e) { //reports if the element is an SVG on which getBBox() actually works 22210 return !!(_SVGElement && e.getCTM && (!e.parentNode || e.ownerSVGElement) && _getBBox(e)); 22211 }, 22212 _identity2DMatrix = [1,0,0,1,0,0], 22213 _getMatrix = function(e, force2D) { 22214 var tm = e._gsTransform || new Transform(), 22215 rnd = 100000, 22216 style = e.style, 22217 isDefault, s, m, n, dec, none; 22218 if (_transformProp) { 22219 s = _getStyle(e, _transformPropCSS, null, true); 22220 } else if (e.currentStyle) { 22221 //for older versions of IE, we need to interpret the filter portion that is in the format: progid:DXImageTransform.Microsoft.Matrix(M11=6.123233995736766e-17, M12=-1, M21=1, M22=6.123233995736766e-17, sizingMethod='auto expand') Notice that we need to swap b and c compared to a normal matrix. 22222 s = e.currentStyle.filter.match(_ieGetMatrixExp); 22223 s = (s && s.length === 4) ? [s[0].substr(4), Number(s[2].substr(4)), Number(s[1].substr(4)), s[3].substr(4), (tm.x || 0), (tm.y || 0)].join(",") : ""; 22224 }
22225 isDefault = (!s || s === "none" || s === "matrix(1, 0, 0, 1, 0, 0)"); 22226 if (_transformProp && ((none = (!_getComputedStyle(e) || _getComputedStyle(e).display === "none")) || !e.parentNode)) { //note: Firefox returns null for getComputedStyle() if the element is in an iframe that has display:none. https://bugzilla.mozilla.org/show_bug.cgi?id=548397 22227 if (none) { //browsers don't report transforms accurately unless the element is in the DOM and has a display value that's not "none". Firefox and Microsoft browsers have a partial bug where they'll report transforms even if display:none BUT not any percentage-based values like translate(-50%, 8px) will be reported as if it's translate(0, 8px). 22228 n = style.display; 22229 style.display = "block"; 22230 } 22231 if (!e.parentNode) { 22232 dec = 1; //flag 22233 _docElement.appendChild(e); 22234 } 22235 s = _getStyle(e, _transformPropCSS, null, true); 22236 isDefault = (!s || s === "none" || s === "matrix(1, 0, 0, 1, 0, 0)"); 22237 if (n) { 22238 style.display = n; 22239 } else if (none) { 22240 _removeProp(style, "display"); 22241 } 22242 if (dec) { 22243 _docElement.removeChild(e); 22244 } 22245 } 22246 if (tm.svg || (e.getCTM && _isSVG(e))) { 22247 if (isDefault && (style[_transformProp] + "").indexOf("matrix") !== -1) { //some browsers (like Chrome 40) don't correctly report transforms that are applied inline on an SVG element (they don't get included in the computed style), so we double-check here and accept matrix values 22248 s = style[_transformProp]; 22249 isDefault = 0; 22250 } 22251 m = e.getAttribute("transform"); 22252 if (isDefault && m) { 22253 m = e.transform.baseVal.consolidate().matrix; //ensures that even complex values like "translate(50,60) rotate(135,0,0)" are parsed because it mashes it into a matrix. 22254 s = "matrix(" + m.a + "," + m.b + "," + m.c + "," + m.d + "," + m.e + "," + m.f + ")"; 22255 isDefault = 0; 22256 } 22257 } 22258 if (isDefault) { 22259 return _identity2DMatrix; 22260 } 22261 //split the matrix values out into an array (m for matrix) 22262 m = (s || "").match(_numExp) || []; 22263 i = m.length; 22264 while (--i > -1) { 22265 n = Number(m[i]); 22266 m[i] = (dec = n - (n |= 0)) ? ((dec * rnd + (dec < 0 ? -0.5 : 0.5)) | 0) / rnd + n : n; //convert strings to Numbers and round to 5 decimal places to avoid issues with tiny numbers. Roughly 20x faster than Number.toFixed(). We also must make sure to round before dividing so that values like 0.9999999999 become 1 to avoid glitches in browser rendering and interpretation of flipped/rotated 3D matrices. And don't just multiply the number by rnd, floor it, and then divide by rnd because the bitwise operations max out at a 32-bit signed integer, thus it could get clipped at a relatively low value (like 22,000.00000 for example). 22267 } 22268 return (force2D && m.length > 6) ? [m[0], m[1], m[4], m[5], m[12], m[13]] : m; 22269 }, 22270 22271 /** 22272 * Parses the transform values for an element, returning an object with x, y, z, scaleX, scaleY, scaleZ, rotation, rotationX, rotationY, skewX, and skewY properties. Note: by default (for performance reasons), all skewing is combined into skewX and rotation but skewY still has a place in the transform object so that we can record how much of the skew is attributed to skewX vs skewY. Remember, a skewY of 10 looks the same as a rotation of 10 and skewX of -10. 22273 * @param {!Object} t target element 22274 * @param {Object=} cs computed style object (optional) 22275 * @param {boolean=} rec if true, the transform values will be recorded to the target element's _gsTransform object, like target._gsTransform = {x:0, y:0, z:0, scaleX:1...} 22276 * @param {boolean=} parse if true, we'll ignore any _gsTransform values that already exist on the element, and force a reparsing of the css (calculated style) 22277 * @return {object}
22277 object containing all of the transform properties/values like {x:0, y:0, z:0, scaleX:1...} 22278 */ 22279 _getTransform = _internals.getTransform = function(t, cs, rec, parse) { 22280 if (t._gsTransform && rec && !parse) { 22281 return t._gsTransform; //if the element already has a _gsTransform, use that. Note: some browsers don't accurately return the calculated style for the transform (particularly for SVG), so it's almost always safest to just use the values we've already applied rather than re-parsing things. 22282 } 22283 var tm = rec ? t._gsTransform || new Transform() : new Transform(), 22284 invX = (tm.scaleX < 0), //in order to interpret things properly, we need to know if the user applied a negative scaleX previously so that we can adjust the rotation and skewX accordingly. Otherwise, if we always interpret a flipped matrix as affecting scaleY and the user only wants to tween the scaleX on multiple sequential tweens, it would keep the negative scaleY without that being the user's intent. 22285 min = 0.00002, 22286 rnd = 100000, 22287 zOrigin = _supports3D ? parseFloat(_getStyle(t, _transformOriginProp, cs, false, "0 0 0").split(" ")[2]) || tm.zOrigin || 0 : 0, 22288 defaultTransformPerspective = parseFloat(CSSPlugin.defaultTransformPerspective) || 0, 22289 m, i, scaleX, scaleY, rotation, skewX; 22290 22291 tm.svg = !!(t.getCTM && _isSVG(t)); 22292 if (tm.svg) { 22293 _parseSVGOrigin(t, _getStyle(t, _transformOriginProp, cs, false, "50% 50%") + "", tm, t.getAttribute("data-svg-origin")); 22294 _useSVGTransformAttr = CSSPlugin.useSVGTransformAttr || _forceSVGTransformAttr; 22295 } 22296 m = _getMatrix(t); 22297 if (m !== _identity2DMatrix) { 22298 22299 if (m.length === 16) { 22300 //we'll only look at these position-related 6 variables first because if x/y/z all match, it's relatively safe to assume we don't need to re-parse everything which risks losing important rotational information (like rotationX:180 plus rotationY:180 would look the same as rotation:180 - there's no way to know for sure which direction was taken based solely on the matrix3d() values) 22301 var a11 = m[0], a21 = m[1], a31 = m[2], a41 = m[3], 22302 a12 = m[4], a22 = m[5], a32 = m[6], a42 = m[7], 22303 a13 = m[8], a23 = m[9], a33 = m[10], 22304 a14 = m[12], a24 = m[13], a34 = m[14], 22305 a43 = m[11], 22306 angle = Math.atan2(a32, a33), 22307 t1, t2, t3, t4, cos, sin; 22308 //we manually compensate for non-zero z component of transformOrigin to work around bugs in Safari 22309 if (tm.zOrigin) { 22310 a34 = -tm.zOrigin; 22311 a14 = a13*a34-m[12]; 22312 a24 = a23*a34-m[13]; 22313 a34 = a33*a34+tm.zOrigin-m[14]; 22314 } 22315 //note for possible future consolidation: rotationX: Math.atan2(a32, a33), rotationY: Math.atan2(-a31, Math.sqrt(a33 * a33 + a32 * a32)), rotation: Math.atan2(a21, a11), skew: Math.atan2(a12, a22). However, it doesn't seem to be quite as reliable as the full-on backwards rotation procedure. 22316 tm.rotationX = angle * _RAD2DEG; 22317 //rotationX 22318 if (angle) { 22319 cos = Math.cos(-angle); 22320 sin = Math.sin(-angle); 22321 t1 = a12*cos+a13*sin; 22322 t2 = a22*cos+a23*sin; 22323 t3 = a32*cos+a33*sin; 22324 a13 = a12*-sin+a13*cos; 22325 a23 = a22*-sin+a23*cos; 22326 a33 = a32*-sin+a33*cos; 22327 a43 = a42*-sin+a43*cos; 22328 a12 = t1; 22329 a22 = t2; 22330 a32 = t3; 22331 } 22332 //rotationY 22333 angle = Math.atan2(-a31, a33); 22334 tm.rotationY = angle * _RAD2DEG; 22335 if (angle) { 22336 cos = Math.cos(-angle); 22337 sin = Math.sin(-angle); 22338 t1 = a11*cos-a13*sin; 22339 t2 = a21*cos-a23*sin; 22340 t3 = a31*cos-a33*sin; 22341 a23 = a21*sin+a23*cos; 22342 a33 = a31*sin+a33*cos; 22343 a43 = a41*sin+a43*cos; 22344 a11 = t1; 22345 a21 = t2; 22346 a31 = t3; 22347 } 22348 //rotationZ 22349 angle = Math.atan2(a21, a11); 22350 tm.rotation = angle * _RAD2DEG; 22351 if (angle) { 22352 cos = Math.cos(angle); 22353 sin = Math.sin(angle); 22354 t1 = a11*cos+a21*sin; 22355 t2 = a12*cos+a22*sin; 22356 t3 = a13*cos+a23*sin; 22357 a21 = a21*cos-a11*sin; 22358 a22 = a22*cos-a12*sin; 22359 a23 = a23*cos-a13*sin; 22360 a11 = t1; 22361 a12 = t2; 22362 a13 = t3; 22363 } 22364 22365 if (tm.rotationX && Math.abs(tm.rotationX) + Math.abs(tm.rotation) > 359.9) { //when rotationY is set, it will often be parsed as 180 degrees different than it should be, and rotationX and rotation both being 180 (it looks the same), so we adjust for that here. 22366 tm.rotationX = tm.rotation = 0; 22367 tm.rotationY = 180 - tm.rotationY; 22368 } 22369 22370 //skewX 22371 angle = Math.atan2(a12, a22); 22372 22373 //scales 22374 tm.scaleX = ((Math.sqrt(a11 * a11 + a21 * a21 + a31 * a31) * rnd + 0.5) | 0) / rnd; 22375 tm.scaleY = ((Math.sqrt(a22 * a22 + a32 * a32) * rnd + 0.5) | 0) / rnd; 22376 tm.scaleZ = ((Math.sqrt(a13 * a13 + a23 * a23 + a33 * a33) * rnd + 0.5) | 0) / rnd; 22377 a11 /= tm.scaleX; 22378 a12 /= tm.scaleY; 22379 a21 /= tm.scaleX; 22380 a22 /= tm.scaleY; 22381 if (Math.abs(angle) > min) { 22382 tm.skewX = angle * _RAD2DEG; 22383 a12 = 0;
22383 //unskews 22384 if (tm.skewType !== "simple") { 22385 tm.scaleY *= 1 / Math.cos(angle); //by default, we compensate the scale based on the skew so that the element maintains a similar proportion when skewed, so we have to alter the scaleY here accordingly to match the default (non-adjusted) skewing that CSS does (stretching more and more as it skews). 22386 } 22387 22388 } else { 22389 tm.skewX = 0; 22390 } 22391 22392 /* //for testing purposes 22393 var transform = "matrix3d(", 22394 comma = ",", 22395 zero = "0"; 22396 a13 /= tm.scaleZ; 22397 a23 /= tm.scaleZ; 22398 a31 /= tm.scaleX; 22399 a32 /= tm.scaleY; 22400 a33 /= tm.scaleZ; 22401 transform += ((a11 < min && a11 > -min) ? zero : a11) + comma + ((a21 < min && a21 > -min) ? zero : a21) + comma + ((a31 < min && a31 > -min) ? zero : a31); 22402 transform += comma + ((a41 < min && a41 > -min) ? zero : a41) + comma + ((a12 < min && a12 > -min) ? zero : a12) + comma + ((a22 < min && a22 > -min) ? zero : a22); 22403 transform += comma + ((a32 < min && a32 > -min) ? zero : a32) + comma + ((a42 < min && a42 > -min) ? zero : a42) + comma + ((a13 < min && a13 > -min) ? zero : a13); 22404 transform += comma + ((a23 < min && a23 > -min) ? zero : a23) + comma + ((a33 < min && a33 > -min) ? zero : a33) + comma + ((a43 < min && a43 > -min) ? zero : a43) + comma; 22405 transform += a14 + comma + a24 + comma + a34 + comma + (tm.perspective ? (1 + (-a34 / tm.perspective)) : 1) + ")"; 22406 console.log(transform); 22407 document.querySelector(".test").style[_transformProp] = transform; 22408 */ 22409 22410 tm.perspective = a43 ? 1 / ((a43 < 0) ? -a43 : a43) : 0; 22411 tm.x = a14; 22412 tm.y = a24; 22413 tm.z = a34; 22414 if (tm.svg) { 22415 tm.x -= tm.xOrigin - (tm.xOrigin * a11 - tm.yOrigin * a12); 22416 tm.y -= tm.yOrigin - (tm.yOrigin * a21 - tm.xOrigin * a22); 22417 } 22418 22419 } else if ((!_supports3D || parse || !m.length || tm.x !== m[4] || tm.y !== m[5] || (!tm.rotationX && !tm.rotationY))) { //sometimes a 6-element matrix is returned even when we performed 3D transforms, like if rotationX and rotationY are 180. In cases like this, we still need to honor the 3D transforms. If we just rely on the 2D info, it could affect how the data is interpreted, like scaleY might get set to -1 or rotation could get offset by 180 degrees. For example, do a TweenLite.to(element, 1, {css:{rotationX:180, rotationY:180}}) and then later, TweenLite.to(element, 1, {css:{rotationX:0}}) and without this conditional logic in place, it'd jump to a state of being unrotated when the 2nd tween starts. Then again, we need to honor the fact that the user COULD alter the transforms outside of CSSPlugin, like by manually applying new css, so we try to sense that by looking at x and y because if those changed, we know the changes were made outside CSSPlugin and we force a reinterpretation of the matrix values. Also, in Webkit browsers, if the element's "display" is "none", its calculated style value will always return empty, so if we've already recorded the values in the _gsTransform object, we'll just rely on those. 22420 var k = (m.length >= 6), 22421 a = k ? m[0] : 1, 22422 b = m[1] || 0, 22423 c = m[2] || 0, 22424 d = k ? m[3] : 1; 22425 tm.x = m[4] || 0; 22426 tm.y = m[5] || 0; 22427 scaleX = Math.sqrt(a * a + b * b); 22428 scaleY = Math.sqrt(d * d + c * c); 22429 rotation = (a || b) ? Math.atan2(b, a) * _RAD2DEG : tm.rotation || 0; //note: if scaleX is 0, we cannot accurately measure rotation. Same for skewX with a scaleY of 0. Therefore, we default to the previously recorded value (or zero if that doesn't exist). 22430 skewX = (c || d) ? Math.atan2(c, d) * _RAD2DEG + rotation : tm.skewX || 0; 22431 tm.scaleX = scaleX; 22432 tm.scaleY = scaleY; 22433 tm.rotation = rotation; 22434 tm.skewX = skewX; 22435 if (_supports3D) { 22436 tm.rotationX = tm.rotationY = tm.z = 0; 22437 tm.perspective = defaultTransformPerspective; 22438 tm.scaleZ = 1; 22439 } 22440 if (tm.svg) { 22441 tm.x -= tm.xOrigin - (tm.xOrigin * a + tm.yOrigin * c); 22442 tm.y -= tm.yOrigin - (tm.xOrigin * b + tm.yOrigin * d); 22443 } 22444 } 22445 if (Math.abs(tm.skewX) > 90 && Math.abs(tm.skewX) < 270) { 22446 if (invX) { 22447 tm.scaleX *= -1; 22448 tm.skewX += (tm.rotation <= 0) ? 180 : -180; 22449 tm.rotation += (tm.rotation <= 0) ? 180 : -180; 22450 } else { 22451 tm.scaleY *= -1; 22452 tm.skewX += (tm.skewX <= 0) ? 180 : -180; 22453 } 22454 } 22455 tm.zOrigin = zOrigin;
22456 //some browsers have a hard time with very small values like 2.4492935982947064e-16 (notice the "e-" towards the end) and would render the object slightly off. So we round to 0 in these cases. The conditional logic here is faster than calling Math.abs(). Also, browsers tend to render a SLIGHTLY rotated object in a fuzzy way, so we need to snap to exactly 0 when appropriate. 22457 for (i in tm) { 22458 if (tm[i] < min) if (tm[i] > -min) { 22459 tm[i] = 0; 22460 } 22461 } 22462 } 22463 //DEBUG: _log("parsed rotation of " + t.getAttribute("id")+": "+(tm.rotationX)+", "+(tm.rotationY)+", "+(tm.rotation)+", scale: "+tm.scaleX+", "+tm.scaleY+", "+tm.scaleZ+", position: "+tm.x+", "+tm.y+", "+tm.z+", perspective: "+tm.perspective+ ", origin: "+ tm.xOrigin+ ","+ tm.yOrigin); 22464 if (rec) { 22465 t._gsTransform = tm; //record to the object's _gsTransform which we use so that tweens can control individual properties independently (we need all the properties to accurately recompose the matrix in the setRatio() method) 22466 if (tm.svg) { //if we're supposed to apply transforms to the SVG element's "transform" attribute, make sure there aren't any CSS transforms applied or they'll override the attribute ones. Also clear the transform attribute if we're using CSS, just to be clean. 22467 if (_useSVGTransformAttr && t.style[_transformProp]) { 22468 TweenLite.delayedCall(0.001, function(){ //if we apply this right away (before anything has rendered), we risk there being no transforms for a brief moment and it also interferes with adjusting the transformOrigin in a tween with immediateRender:true (it'd try reading the matrix and it wouldn't have the appropriate data in place because we just removed it). 22469 _removeProp(t.style, _transformProp); 22470 }); 22471 } else if (!_useSVGTransformAttr && t.getAttribute("transform")) { 22472 TweenLite.delayedCall(0.001, function(){ 22473 t.removeAttribute("transform"); 22474 }); 22475 } 22476 } 22477 } 22478 return tm; 22479 }, 22480 22481 //for setting 2D transforms in IE6, IE7, and IE8 (must use a "filter" to emulate the behavior of modern day browser transforms) 22482 _setIETransformRatio = function(v) { 22483 var t = this.data, //refers to the element's _gsTransform object 22484 ang = -t.rotation * _DEG2RAD, 22485 skew = ang + t.skewX * _DEG2RAD, 22486 rnd = 100000, 22487 a = ((Math.cos(ang) * t.scaleX * rnd) | 0) / rnd, 22488 b = ((Math.sin(ang) * t.scaleX * rnd) | 0) / rnd, 22489 c = ((Math.sin(skew) * -t.scaleY * rnd) | 0) / rnd, 22490 d = ((Math.cos(skew) * t.scaleY * rnd) | 0) / rnd, 22491 style = this.t.style, 22492 cs = this.t.currentStyle, 22493 filters, val; 22494 if (!cs) { 22495 return; 22496 } 22497 val = b; //just for swapping the variables an inverting them (reused "val" to avoid creating another variable in memory). IE's filter matrix uses a non-standard matrix configuration (angle goes the opposite way, and b and c are reversed and inverted) 22498 b = -c; 22499 c = -val; 22500 filters = cs.filter; 22501 style.filter = ""; //remove filters so that we can accurately measure offsetWidth/offsetHeight 22502 var w = this.t.offsetWidth, 22503 h = this.t.offsetHeight, 22504 clip = (cs.position !== "absolute"), 22505 m = "progid:DXImageTransform.Microsoft.Matrix(M11=" + a + ", M12=" + b + ", M21=" + c + ", M22=" + d, 22506 ox = t.x + (w * t.xPercent / 100), 22507 oy = t.y + (h * t.yPercent / 100), 22508 dx, dy; 22509 22510 //if transformOrigin is being used, adjust the offset x and y 22511 if (t.ox != null) { 22512 dx = ((t.oxp) ? w * t.ox * 0.01 : t.ox) - w / 2; 22513 dy = ((t.oyp) ? h * t.oy * 0.01 : t.oy) - h / 2; 22514 ox += dx - (dx * a + dy * b); 22515 oy += dy - (dx * c + dy * d); 22516 } 22517 22518 if (!clip) { 22519 m += ", sizingMethod='auto expand')"; 22520 } else { 22521 dx = (w / 2); 22522 dy = (h / 2); 22523 //translate to ensure that transformations occur around the correct origin (default is center). 22524 m += ", Dx=" + (dx - (dx * a + dy * b) + ox) + ", Dy=" + (dy - (dx * c + dy * d) + oy) + ")"; 22525 } 22526 if (filters.indexOf("DXImageTransform.Microsoft.Matrix(") !== -1) { 22527 style.filter = filters.replace(_ieSetMatrixExp, m); 22528 } else { 22529 style.filter = m + " " + filters;
22529 //we must always put the transform/matrix FIRST (before alpha(opacity=xx)) to avoid an IE bug that slices part of the object when rotation is applied with alpha. 22530 } 22531 22532 //at the end or beginning of the tween, if the matrix is normal (1, 0, 0, 1) and opacity is 100 (or doesn't exist), remove the filter to improve browser performance. 22533 if (v === 0 || v === 1) if (a === 1) if (b === 0) if (c === 0) if (d === 1) if (!clip || m.indexOf("Dx=0, Dy=0") !== -1) if (!_opacityExp.test(filters) || parseFloat(RegExp.$1) === 100) if (filters.indexOf("gradient(" && filters.indexOf("Alpha")) === -1) { 22534 style.removeAttribute("filter"); 22535 } 22536 22537 //we must set the margins AFTER applying the filter in order to avoid some bugs in IE8 that could (in rare scenarios) cause them to be ignored intermittently (vibration). 22538 if (!clip) { 22539 var mult = (_ieVers < 8) ? 1 : -1, //in Internet Explorer 7 and before, the box model is broken, causing the browser to treat the width/height of the actual rotated filtered image as the width/height of the box itself, but Microsoft corrected that in IE8. We must use a negative offset in IE8 on the right/bottom 22540 marg, prop, dif; 22541 dx = t.ieOffsetX || 0; 22542 dy = t.ieOffsetY || 0; 22543 t.ieOffsetX = Math.round((w - ((a < 0 ? -a : a) * w + (b < 0 ? -b : b) * h)) / 2 + ox); 22544 t.ieOffsetY = Math.round((h - ((d < 0 ? -d : d) * h + (c < 0 ? -c : c) * w)) / 2 + oy); 22545 for (i = 0; i < 4; i++) { 22546 prop = _margins[i]; 22547 marg = cs[prop]; 22548 //we need to get the current margin in case it is being tweened separately (we want to respect that tween's changes) 22549 val = (marg.indexOf("px") !== -1) ? parseFloat(marg) : _convertToPixels(this.t, prop, parseFloat(marg), marg.replace(_suffixExp, "")) || 0; 22550 if (val !== t[prop]) { 22551 dif = (i < 2) ? -t.ieOffsetX : -t.ieOffsetY; //if another tween is controlling a margin, we cannot only apply the difference in the ieOffsets, so we essentially zero-out the dx and dy here in that case. We record the margin(s) later so that we can keep comparing them, making this code very flexible. 22552 } else { 22553 dif = (i < 2) ? dx - t.ieOffsetX : dy - t.ieOffsetY; 22554 } 22555 style[prop] = (t[prop] = Math.round( val - dif * ((i === 0 || i === 2) ? 1 : mult) )) + "px"; 22556 } 22557 } 22558 }, 22559 22560 /* translates a super small decimal to a string WITHOUT scientific notation 22561 _safeDecimal = function(n) { 22562 var s = (n < 0 ? -n : n) + "", 22563 a = s.split("e-"); 22564 return (n < 0 ? "-0." : "0.") + new Array(parseInt(a[1], 10) || 0).join("0") + a[0].split(".").join(""); 22565 }, 22566 */ 22567 22568 _setTransformRatio = _internals.set3DTransformRatio = _internals.setTransformRatio = function(v) { 22569 var t = this.data, //refers to the element's _gsTransform object 22570 style = this.t.style, 22571 angle = t.rotation, 22572 rotationX = t.rotationX, 22573 rotationY = t.rotationY, 22574 sx = t.scaleX, 22575 sy = t.scaleY, 22576 sz = t.scaleZ, 22577 x = t.x, 22578 y = t.y, 22579 z = t.z, 22580 isSVG = t.svg, 22581 perspective = t.perspective, 22582 force3D = t.force3D, 22583 skewY = t.skewY, 22584 skewX = t.skewX, 22585 t1, a11, a12, a13, a21, a22, a23, a31, a32, a33, a41, a42, a43, 22586 zOrigin, min, cos, sin, t2, transform, comma, zero, skew, rnd; 22587 if (skewY) { //for performance reasons, we combine all skewing into the skewX and rotation values. Remember, a skewY of 10 degrees looks the same as a rotation of 10 degrees plus a skewX of 10 degrees. 22588 skewX += skewY; 22589 angle += skewY; 22590 } 22591 22592 //check to see if we should render as 2D (and SVGs must use 2D when _useSVGTransformAttr is true) 22593 if (((((v === 1 || v === 0) && force3D === "auto" && (this.tween._totalTime === this.tween._totalDuration || !this.tween._totalTime)) || !force3D) && !z && !perspective && !rotationY && !rotationX && sz === 1) || (_useSVGTransformAttr && isSVG) || !_supports3D) { //on the final render (which could be 0 for a from tween), if there are no 3D aspects, render in 2D to free up memory and improve performance especially on mobile devices. Check the tween's totalTime/totalDuration too in order to make sure it doesn't happen between repeats if it's a repeating tween. 22594 22595 //2D 22596 if (angle || skewX || isSVG) { 22597 angle *= _DEG2RAD; 22598 skew = skewX * _DEG2RAD; 22599 rnd = 100000; 22600 a11 = Math.cos(angle) * sx; 22601 a21 = Math.sin(angle) * sx; 22602 a12 = Math.sin(angle - skew) * -sy;
22603 a22 = Math.cos(angle - skew) * sy; 22604 if (skew && t.skewType === "simple") { //by default, we compensate skewing on the other axis to make it look more natural, but you can set the skewType to "simple" to use the uncompensated skewing that CSS does 22605 t1 = Math.tan(skew - skewY * _DEG2RAD); 22606 t1 = Math.sqrt(1 + t1 * t1); 22607 a12 *= t1; 22608 a22 *= t1; 22609 if (skewY) { 22610 t1 = Math.tan(skewY * _DEG2RAD); 22611 t1 = Math.sqrt(1 + t1 * t1); 22612 a11 *= t1; 22613 a21 *= t1; 22614 } 22615 } 22616 if (isSVG) { 22617 x += t.xOrigin - (t.xOrigin * a11 + t.yOrigin * a12) + t.xOffset; 22618 y += t.yOrigin - (t.xOrigin * a21 + t.yOrigin * a22) + t.yOffset; 22619 if (_useSVGTransformAttr && (t.xPercent || t.yPercent)) { //The SVG spec doesn't support percentage-based translation in the "transform" attribute, so we merge it into the matrix to simulate it. 22620 min = this.t.getBBox(); 22621 x += t.xPercent * 0.01 * min.width; 22622 y += t.yPercent * 0.01 * min.height; 22623 } 22624 min = 0.000001; 22625 if (x < min) if (x > -min) { 22626 x = 0; 22627 } 22628 if (y < min) if (y > -min) { 22629 y = 0; 22630 } 22631 } 22632 transform = (((a11 * rnd) | 0) / rnd) + "," + (((a21 * rnd) | 0) / rnd) + "," + (((a12 * rnd) | 0) / rnd) + "," + (((a22 * rnd) | 0) / rnd) + "," + x + "," + y + ")"; 22633 if (isSVG && _useSVGTransformAttr) {
22634 this.t.setAttribute("transform", "matrix(" + transform); 22635 } else { 22636 //some browsers have a hard time with very small values like 2.4492935982947064e-16 (notice the "e-" towards the end) and would render the object slightly off. So we round to 5 decimal places. 22637 style[_transformProp] = ((t.xPercent || t.yPercent) ? "translate(" + t.xPercent + "%," + t.yPercent + "%) matrix(" : "matrix(") + transform; 22638 } 22639 } else { 22640 style[_transformProp] = ((t.xPercent || t.yPercent) ? "translate(" + t.xPercent + "%," + t.yPercent + "%) matrix(" : "matrix(") + sx + ",0,0," + sy + "," + x + "," + y + ")"; 22641 } 22642 return; 22643 22644 } 22645 if (_isFirefox) { //Firefox has a bug (at least in v25) that causes it to render the transparent part of 32-bit PNG images as black when displayed inside an iframe and the 3D scale is very small and doesn't change sufficiently enough between renders (like if you use a Power4.easeInOut to scale from 0 to 1 where the beginning values only change a tiny amount to begin the tween before accelerating). In this case, we force the scale to be 0.00002 instead which is visually the same but works around the Firefox issue. 22646 min = 0.0001; 22647 if (sx < min && sx > -min) { 22648 sx = sz = 0.00002; 22649 } 22650 if (sy < min && sy > -min) { 22651 sy = sz = 0.00002; 22652 } 22653 if (perspective && !t.z && !t.rotationX && !t.rotationY) { //Firefox has a bug that causes elements to have an odd super-thin, broken/dotted black border on elements that have a perspective set but aren't utilizing 3D space (no rotationX, rotationY, or z). 22654 perspective = 0; 22655 } 22656 } 22657 if (angle || skewX) { 22658 angle *= _DEG2RAD; 22659 cos = a11 = Math.cos(angle); 22660 sin = a21 = Math.sin(angle); 22661 if (skewX) { 22662 angle -= skewX * _DEG2RAD; 22663 cos = Math.cos(angle); 22664 sin = Math.sin(angle); 22665 if (t.skewType === "simple") { //by default, we compensate skewing on the other axis to make it look more natural, but you can set the skewType to "simple" to use the uncompensated skewing that CSS does 22666 t1 = Math.tan((skewX - skewY) * _DEG2RAD); 22667 t1 = Math.sqrt(1 + t1 * t1); 22668 cos *= t1; 22669 sin *= t1; 22670 if (t.skewY) { 22671 t1 = Math.tan(skewY * _DEG2RAD); 22672 t1 = Math.sqrt(1 + t1 * t1); 22673 a11 *= t1; 22674 a21 *= t1; 22675 } 22676 } 22677 } 22678 a12 = -sin; 22679 a22 = cos; 22680 22681 } else if (!rotationY && !rotationX && sz === 1 && !perspective && !isSVG) { //if we're only translating and/or 2D scaling, this is faster... 22682 style[_transformProp] = ((t.xPercent || t.yPercent) ? "translate(" + t.xPercent + "%," + t.yPercent + "%) translate3d(" : "translate3d(") + x + "px," + y + "px," + z +"px)" + ((sx !== 1 || sy !== 1) ? " scale(" + sx + "," + sy + ")" : ""); 22683 return; 22684 } else { 22685 a11 = a22 = 1; 22686 a12 = a21 = 0; 22687 } 22688 // KEY INDEX AFFECTS a[row][column] 22689 // a11 0 rotation, rotationY, scaleX 22690 // a21 1 rotation, rotationY, scaleX 22691 // a31 2 rotationY, scaleX 22692 // a41 3 rotationY, scaleX 22693 // a12 4 rotation, skewX, rotationX, scaleY 22694 // a22 5 rotation, skewX, rotationX, scaleY 22695 // a32 6 rotationX, scaleY 22696 // a42 7 rotationX, scaleY 22697 // a13 8 rotationY, rotationX, scaleZ 22698 // a23 9 rotationY, rotationX, scaleZ 22699 // a33 10 rotationY, rotationX, scaleZ 22700 // a43 11 rotationY, rotationX, perspective, scaleZ 22701 // a14 12 x, zOrigin, svgOrigin 22702 // a24 13 y, zOrigin, svgOrigin 22703 // a34 14 z, zOrigin 22704 // a44 15 22705 // rotation: Math.atan2(a21, a11) 22706 // rotationY: Math.atan2(a13, a33) (or Math.atan2(a13, a11)) 22707 // rotationX: Math.atan2(a32, a33) 22708 a33 = 1; 22709 a13 = a23 = a31 = a32 = a41 = a42 = 0; 22710 a43 = (perspective) ? -1 / perspective : 0; 22711 zOrigin = t.zOrigin; 22712 min = 0.000001; //threshold below which browsers use scientific notation which won't work. 22713 comma = ","; 22714 zero = "0"; 22715 angle = rotationY * _DEG2RAD; 22716 if (angle) { 22717 cos = Math.cos(angle); 22718 sin = Math.sin(angle);
22719 a31 = -sin; 22720 a41 = a43*-sin; 22721 a13 = a11*sin; 22722 a23 = a21*sin; 22723 a33 = cos; 22724 a43 *= cos; 22725 a11 *= cos; 22726 a21 *= cos; 22727 } 22728 angle = rotationX * _DEG2RAD; 22729 if (angle) { 22730 cos = Math.cos(angle); 22731 sin = Math.sin(angle); 22732 t1 = a12*cos+a13*sin; 22733 t2 = a22*cos+a23*sin; 22734 a32 = a33*sin; 22735 a42 = a43*sin; 22736 a13 = a12*-sin+a13*cos; 22737 a23 = a22*-sin+a23*cos; 22738 a33 = a33*cos; 22739 a43 = a43*cos; 22740 a12 = t1; 22741 a22 = t2; 22742 } 22743 if (sz !== 1) { 22744 a13*=sz; 22745 a23*=sz; 22746 a33*=sz; 22747 a43*=sz; 22748 } 22749 if (sy !== 1) { 22750 a12*=sy; 22751 a22*=sy; 22752 a32*=sy; 22753 a42*=sy; 22754 } 22755 if (sx !== 1) { 22756 a11*=sx; 22757 a21*=sx; 22758 a31*=sx; 22759 a41*=sx; 22760 } 22761 22762 if (zOrigin || isSVG) { 22763 if (zOrigin) { 22764 x += a13*-zOrigin; 22765 y += a23*-zOrigin; 22766 z += a33*-zOrigin+zOrigin; 22767 } 22768 if (isSVG) { //due to bugs in some browsers, we need to manage the transform-origin of SVG manually 22769 x += t.xOrigin - (t.xOrigin * a11 + t.yOrigin * a12) + t.xOffset; 22770 y += t.yOrigin - (t.xOrigin * a21 + t.yOrigin * a22) + t.yOffset; 22771 } 22772 if (x < min && x > -min) { 22773 x = zero; 22774 } 22775 if (y < min && y > -min) { 22776 y = zero; 22777 } 22778 if (z < min && z > -min) { 22779 z = 0; //don't use string because we calculate perspective later and need the number. 22780 } 22781 } 22782 22783 //optimized way of concatenating all the values into a string. If we do it all in one shot, it's slower because of the way browsers have to create temp strings and the way it affects memory. If we do it piece-by-piece with +=, it's a bit slower too. We found that doing it in these sized chunks works best overall: 22784 transform = ((t.xPercent || t.yPercent) ? "translate(" + t.xPercent + "%," + t.yPercent + "%) matrix3d(" : "matrix3d("); 22785 transform += ((a11 < min && a11 > -min) ? zero : a11) + comma + ((a21 < min && a21 > -min) ? zero : a21) + comma + ((a31 < min && a31 > -min) ? zero : a31); 22786 transform += comma + ((a41 < min && a41 > -min) ? zero : a41) + comma + ((a12 < min && a12 > -min) ? zero : a12) + comma + ((a22 < min && a22 > -min) ? zero : a22); 22787 if (rotationX || rotationY || sz !== 1) { //performance optimization (often there's no rotationX or rotationY, so we can skip these calculations) 22788 transform += comma + ((a32 < min && a32 > -min) ? zero : a32) + comma + ((a42 < min && a42 > -min) ? zero : a42) + comma + ((a13 < min && a13 > -min) ? zero : a13); 22789 transform += comma + ((a23 < min && a23 > -min) ? zero : a23) + comma + ((a33 < min && a33 > -min) ? zero : a33) + comma + ((a43 < min && a43 > -min) ? zero : a43) + comma; 22790 } else { 22791 transform += ",0,0,0,0,1,0,"; 22792 } 22793 transform += x + comma + y + comma + z + comma + (perspective ? (1 + (-z / perspective)) : 1) + ")"; 22794 22795 style[_transformProp] = transform; 22796 }; 22797 22798 p = Transform.prototype; 22799 p.x = p.y = p.z = p.skewX = p.skewY = p.rotation = p.rotationX = p.rotationY = p.zOrigin = p.xPercent = p.yPercent = p.xOffset = p.yOffset = 0; 22800 p.scaleX = p.scaleY = p.scaleZ = 1; 22801 22802 _registerComplexSpecialProp("transform,scale,scaleX,scaleY,scaleZ,x,y,z,rotation,rotationX,rotationY,rotationZ,skewX,skewY,shortRotation,shortRotationX,shortRotationY,shortRotationZ,transformOrigin,svgOrigin,transformPerspective,directionalRotation,parseTransform,force3D,skewType,xPercent,yPercent,smoothOrigin", {parser:function(t, e, parsingProp, cssp, pt, plugin, vars) { 22803 if (cssp._lastParsedTransform === vars) { return pt; } //only need to parse the transform once, and only if the browser supports it. 22804 cssp._lastParsedTransform = vars; 22805 var scaleFunc = (vars.scale && typeof(vars.scale) === "function") ? vars.scale : 0, //if there's a function-based "scale" value, swap in the resulting numeric value temporarily. Otherwise, if it's called for both scaleX and scaleY independently, they may not match (like if the function uses Math.random()). 22806 swapFunc; 22807 if (typeof(vars[parsingProp]) === "function") { //whatever property triggers the initial parsing might be a function-based value in which case it already got called in parse(), thus we don't want to call it again in here. The most efficient way to avoid this is to temporarily swap the value directly into the vars object, and then after we do all our parsing in this function, we'll swap it back again. 22808 swapFunc = vars[parsingProp]; 22809 vars[parsingProp] = e; 22810 } 22811 if (scaleFunc) { 22812 vars.scale = scaleFunc(_index, t); 22813 } 22814 var originalGSTransform = t._gsTransform, 22815 style = t.style, 22816 min = 0.000001, 22817 i = _transformProps.length, 22818 v = vars, 22819 endRotations = {}, 22820 transformOriginString = "transformOrigin", 22821 m1 = _getTransform(t, _cs, true, v.parseTransform), 22822 orig = v.transform && ((typeof(v.transform) === "function") ? v.transform(_index, _target) : v.transform), 22823 m2, copy, has3D, hasChange, dr, x, y, matrix, p; 22824 m1.skewType = v.skewType || m1.skewType || CSSPlugin.defaultSkewType; 22825 cssp._transform = m1; 22826 if ("rotationZ" in v) { 22827 v.rotation = v.rotationZ; 22828 } 22829 if (orig && typeof(orig) === "string" && _transformProp) { //for values like transform:"rotate(60deg) scale(0.5, 0.8)" 22830 copy = _tempDiv.style; //don't use the original target because it might be SVG in which case some browsers don't report computed style correctly. 22831 copy[_transformProp] = orig; 22832 copy.display = "block"; //if display is "none", the browser often refuses to report the transform properties correctly. 22833 copy.position = "absolute"; 22834 if (orig.indexOf("%") !== -1) { //%-based translations will fail unless we set the width/height to match the original target... 22835 copy.width = _getStyle(t, "width");
22836 copy.height = _getStyle(t, "height"); 22837 } 22838 _doc.body.appendChild(_tempDiv); 22839 m2 = _getTransform(_tempDiv, null, false); 22840 if (m1.skewType === "simple") { //the default _getTransform() reports the skewX/scaleY as if skewType is "compensated", thus we need to adjust that here if skewType is "simple". 22841 m2.scaleY *= Math.cos(m2.skewX * _DEG2RAD); 22842 } 22843 if (m1.svg) { //if it's an SVG element, x/y part of the matrix will be affected by whatever we use as the origin and the offsets, so compensate here... 22844 x = m1.xOrigin; 22845 y = m1.yOrigin; 22846 m2.x -= m1.xOffset; 22847 m2.y -= m1.yOffset; 22848 if (v.transformOrigin || v.svgOrigin) { //if this tween is altering the origin, we must factor that in here. The actual work of recording the transformOrigin values and setting up the PropTween is done later (still inside this function) so we cannot leave the changes intact here - we only want to update the x/y accordingly. 22849 orig = {}; 22850 _parseSVGOrigin(t, _parsePosition(v.transformOrigin), orig, v.svgOrigin, v.smoothOrigin, true); 22851 x = orig.xOrigin; 22852 y = orig.yOrigin; 22853 m2.x -= orig.xOffset - m1.xOffset; 22854 m2.y -= orig.yOffset - m1.yOffset; 22855 } 22856 if (x || y) { 22857 matrix = _getMatrix(_tempDiv, true); 22858 m2.x -= x - (x * matrix[0] + y * matrix[2]); 22859 m2.y -= y - (x * matrix[1] + y * matrix[3]); 22860 } 22861 } 22862 _doc.body.removeChild(_tempDiv); 22863 if (!m2.perspective) { 22864 m2.perspective = m1.perspective; //tweening to no perspective gives very unintuitive results - just keep the same perspective in that case. 22865 } 22866 if (v.xPercent != null) { 22867 m2.xPercent = _parseVal(v.xPercent, m1.xPercent); 22868 } 22869 if (v.yPercent != null) { 22870 m2.yPercent = _parseVal(v.yPercent, m1.yPercent); 22871 } 22872 } else if (typeof(v) === "object") { //for values like scaleX, scaleY, rotation, x, y, skewX, and skewY or transform:{...} (object) 22873 m2 = {scaleX:_parseVal((v.scaleX != null) ? v.scaleX : v.scale, m1.scaleX), 22874 scaleY:_parseVal((v.scaleY != null) ? v.scaleY : v.scale, m1.scaleY), 22875 scaleZ:_parseVal(v.scaleZ, m1.scaleZ), 22876 x:_parseVal(v.x, m1.x), 22877 y:_parseVal(v.y, m1.y), 22878 z:_parseVal(v.z, m1.z), 22879 xPercent:_parseVal(v.xPercent, m1.xPercent), 22880 yPercent:_parseVal(v.yPercent, m1.yPercent), 22881 perspective:_parseVal(v.transformPerspective, m1.perspective)}; 22882 dr = v.directionalRotation; 22883 if (dr != null) { 22884 if (typeof(dr) === "object") { 22885 for (copy in dr) { 22886 v[copy] = dr[copy]; 22887 } 22888 } else { 22889 v.rotation = dr; 22890 } 22891 } 22892 if (typeof(v.x) === "string" && v.x.indexOf("%") !== -1) { 22893 m2.x = 0; 22894 m2.xPercent = _parseVal(v.x, m1.xPercent); 22895 } 22896 if (typeof(v.y) === "string" && v.y.indexOf("%") !== -1) { 22897 m2.y = 0; 22898 m2.yPercent = _parseVal(v.y, m1.yPercent); 22899 } 22900 22901 m2.rotation = _parseAngle(("rotation" in v) ? v.rotation : ("shortRotation" in v) ? v.shortRotation + "_short" : m1.rotation, m1.rotation, "rotation", endRotations); 22902 if (_supports3D) { 22903 m2.rotationX = _parseAngle(("rotationX" in v) ? v.rotationX : ("shortRotationX" in v) ? v.shortRotationX + "_short" : m1.rotationX || 0, m1.rotationX, "rotationX", endRotations); 22904 m2.rotationY = _parseAngle(("rotationY" in v) ? v.rotationY : ("shortRotationY" in v) ? v.shortRotationY + "_short" : m1.rotationY || 0, m1.rotationY, "rotationY", endRotations); 22905 } 22906 m2.skewX = _parseAngle(v.skewX, m1.skewX); 22907 m2.skewY = _parseAngle(v.skewY, m1.skewY); 22908 } 22909 if (_supports3D && v.force3D != null) { 22910 m1.force3D = v.force3D; 22911 hasChange = true; 22912 } 22913 22914 has3D = (m1.force3D || m1.z || m1.rotationX || m1.rotationY || m2.z || m2.rotationX || m2.rotationY || m2.perspective); 22915 if (!has3D && v.scale != null) { 22916 m2.scaleZ = 1; //no need to tween scaleZ. 22917 } 22918 22919 while (--i > -1) { 22920 p = _transformProps[i]; 22921 orig = m2[p] - m1[p]; 22922 if (orig > min || orig < -min || v[p] != null || _forcePT[p] != null) { 22923 hasChange = true; 22924 pt = new CSSPropTween(m1, p, m1[p], orig, pt); 22925 if (p in endRotations) { 22926 pt.e = endRotations[p]; //directional rotations typically have compensated values during the tween, but we need to make sure they end at exactly what the user requested 22927 } 22928 pt.xs0 = 0; //ensures the value stays numeric in setRatio() 22929 pt.plugin = plugin; 22930 cssp._overwriteProps.push(pt.n); 22931 } 22932 } 22933 22934 orig = v.transformOrigin; 22935 if (m1.svg && (orig || v.svgOrigin)) { 22936 x = m1.xOffset; //when we change the origin, in order to prevent things from jumping we adjust the x/y so we must record those here so that we can create PropTweens for them and flip them at the same time as the origin 22937 y = m1.yOffset; 22938 _parseSVGOrigin(t, _parsePosition(orig), m2, v.svgOrigin, v.smoothOrigin); 22939 pt = _addNonTweeningNumericPT(m1, "xOrigin", (originalGSTransform ? m1 : m2).xOrigin, m2.xOrigin, pt, transformOriginString); //note: if there wasn't a transformOrigin defined yet, just start with the destination one; it's wasteful otherwise, and it causes problems with fromTo() tweens. For example, TweenLite.to("#wheel", 3, {rotation:180, transformOrigin:"50% 50%", delay:1}); TweenLite.fromTo("#wheel", 3, {scale:0.5, transformOrigin:"50% 50%"}, {scale:1, delay:2}); would cause a jump when the from values revert at the beginning of the 2nd tween.
22940 pt = _addNonTweeningNumericPT(m1, "yOrigin", (originalGSTransform ? m1 : m2).yOrigin, m2.yOrigin, pt, transformOriginString); 22941 if (x !== m1.xOffset || y !== m1.yOffset) { 22942 pt = _addNonTweeningNumericPT(m1, "xOffset", (originalGSTransform ? x : m1.xOffset), m1.xOffset, pt, transformOriginString); 22943 pt = _addNonTweeningNumericPT(m1, "yOffset", (originalGSTransform ? y : m1.yOffset), m1.yOffset, pt, transformOriginString); 22944 } 22945 orig = "0px 0px"; //certain browsers (like firefox) completely botch transform-origin, so we must remove it to prevent it from contaminating transforms. We manage it ourselves with xOrigin and yOrigin 22946 } 22947 if (orig || (_supports3D && has3D && m1.zOrigin)) { //if anything 3D is happening and there's a transformOrigin with a z component that's non-zero, we must ensure that the transformOrigin's z-component is set to 0 so that we can manually do those calculations to get around Safari bugs. Even if the user didn't specifically define a "transformOrigin" in this particular tween (maybe they did it via css directly). 22948 if (_transformProp) { 22949 hasChange = true; 22950 p = _transformOriginProp; 22951 orig = (orig || _getStyle(t, p, _cs, false, "50% 50%")) + ""; //cast as string to avoid errors 22952 pt = new CSSPropTween(style, p, 0, 0, pt, -1, transformOriginString); 22953 pt.b = style[p]; 22954 pt.plugin = plugin; 22955 if (_supports3D) { 22956 copy = m1.zOrigin; 22957 orig = orig.split(" "); 22958 m1.zOrigin = ((orig.length > 2 && !(copy !== 0 && orig[2] === "0px")) ? parseFloat(orig[2]) : copy) || 0; //Safari doesn't handle the z part of transformOrigin correctly, so we'll manually handle it in the _set3DTransformRatio() method. 22959 pt.xs0 = pt.e = orig[0] + " " + (orig[1] || "50%") + " 0px"; //we must define a z value of 0px specifically otherwise iOS 5 Safari will stick with the old one (if one was defined)! 22960 pt = new CSSPropTween(m1, "zOrigin", 0, 0, pt, -1, pt.n); //we must create a CSSPropTween for the _gsTransform.zOrigin so that it gets reset properly at the beginning if the tween runs backward (as opposed to just setting m1.zOrigin here) 22961 pt.b = copy; 22962 pt.xs0 = pt.e = m1.zOrigin; 22963 } else { 22964 pt.xs0 = pt.e = orig; 22965 } 22966 22967 //for older versions of IE (6-8), we need to manually calculate things inside the setRatio() function. We record origin x and y (ox and oy) and whether or not the values are percentages (oxp and oyp). 22968 } else { 22969 _parsePosition(orig + "", m1); 22970 } 22971 } 22972 if (hasChange) { 22973 cssp._transformType = (!(m1.svg && _useSVGTransformAttr) && (has3D || this._transformType === 3)) ? 3 : 2; //quicker than calling cssp._enableTransforms(); 22974 } 22975 if (swapFunc) { 22976 vars[parsingProp] = swapFunc; 22977 } 22978 if (scaleFunc) { 22979 vars.scale = scaleFunc; 22980 } 22981 return pt; 22982 }, prefix:true}); 22983 22984 _registerComplexSpecialProp("boxShadow", {defaultValue:"0px 0px 0px 0px #999", prefix:true, color:true, multi:true, keyword:"inset"}); 22985 22986 _registerComplexSpecialProp("borderRadius", {defaultValue:"0px", parser:function(t, e, p, cssp, pt, plugin) { 22987 e = this.format(e); 22988 var props = ["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"], 22989 style = t.style, 22990 ea1, i, es2, bs2, bs, es, bn, en, w, h, esfx, bsfx, rel, hn, vn, em; 22991 w = parseFloat(t.offsetWidth); 22992 h = parseFloat(t.offsetHeight); 22993 ea1 = e.split(" "); 22994 for (i = 0; i < props.length; i++) { //if we're dealing with percentages, we must convert things separately for the horizontal and vertical axis! 22995 if (this.p.indexOf("border")) { //older browsers used a prefix 22996 props[i] = _checkPropPrefix(props[i]); 22997 } 22998 bs = bs2 = _getStyle(t, props[i], _cs, false, "0px"); 22999 if (bs.indexOf(" ") !== -1) { 23000 bs2 = bs.split(" "); 23001 bs = bs2[0]; 23002 bs2 = bs2[1]; 23003 } 23004 es = es2 = ea1[i]; 23005 bn = parseFloat(bs); 23006 bsfx = bs.substr((bn + "").length); 23007 rel = (es.charAt(1) === "="); 23008 if (rel) { 23009 en = parseInt(es.charAt(0)+"1", 10); 23010 es = es.substr(2); 23011 en *= parseFloat(es); 23012 esfx = es.substr((en + "").length - (en < 0 ? 1 : 0)) || ""; 23013 } else { 23014 en = parseFloat(es); 23015 esfx = es.substr((en + "").length); 23016 } 23017 if (esfx === "") { 23018 esfx = _suffixMap[p] || bsfx; 23019 } 23020 if (esfx !== bsfx) { 23021 hn = _convertToPixels(t, "borderLeft", bn, bsfx); //horizontal number (we use a bogus "borderLeft" property just because the _convertToPixels() method searches for the keywords "Left", "Right", "Top", and "Bottom" to determine of it's a horizontal or vertical property, and we need "border" in the name so that it knows it should measure relative to the element itself, not its parent. 23022 vn = _convertToPixels(t, "borderTop", bn, bsfx); //vertical number 23023 if (esfx === "%") { 23024 bs = (hn / w * 100) + "%"; 23025 bs2 = (vn / h * 100) + "%"; 23026 } else if (esfx === "em") { 23027 em = _convertToPixels(t, "borderLeft", 1, "em"); 23028 bs = (hn / em) + "em"; 23029 bs2 = (vn / em) + "em"; 23030 } else { 23031 bs = hn + "px"; 23032 bs2 = vn + "px"; 23033 } 23034 if (rel) { 23035 es = (parseFloat(bs) + en) + esfx; 23036 es2 = (parseFloat(bs2) + en) + esfx; 23037 } 23038 } 23039 pt = _parseComplex(style, props[i], bs + " " + bs2, es + " " + es2, false, "0px", pt); 23040 } 23041 return pt; 23042 }, prefix:true, formatter:_getFormatter("0px 0px 0px 0px", false, true)}); 23043 _registerComplexSpecialProp("borderBottomLeftRadius,borderBottomRightRadius,borderTopLeftRadius,borderTopRightRadius", {defaultValue:"0px", parser:function(t, e, p, cssp, pt, plugin) { 23044 return _parseComplex(t.style, p, this.format(_getStyle(t, p, _cs, false, "0px 0px")), this.format(e), false, "0px", pt); 23045 }, prefix:true, formatter:_getFormatter("0px 0px", false, true)}); 23046 _registerComplexSpecialProp("backgroundPosition", {defaultValue:"0 0", parser:function(t, e, p, cssp, pt, plugin) { 23047 var bp = "background-position", 23048 cs = (_cs || _getComputedStyle(t, null)), 23049 bs = this.format( ((cs) ? _ieVers ? cs.getPropertyValue(bp + "-x") + " " + cs.getPropertyValue(bp + "-y") : cs.getPropertyValue(bp) : t.currentStyle.backgroundPositionX + " " + t.currentStyle.backgroundPositionY) || "0 0"), //Internet Explorer doesn't report background-position correctly - we must query background-position-x and background-position-y and combine them (even in IE10). Before IE9, we must do the same with the currentStyle object and use camelCase 23050 es = this.format(e), 23051 ba, ea, i, pct, overlap, src; 23052 if ((bs.indexOf("%") !== -1) !== (es.indexOf("%") !== -1) && es.split(",").length < 2) { 23053 src = _getStyle(t, "backgroundImage").replace(_urlExp, ""); 23054 if (src && src !== "none") { 23055 ba = bs.split(" "); 23056 ea = es.split(" "); 23057 _tempImg.setAttribute("src", src); //set the temp IMG's src to the background-image so that we can measure its width/height 23058 i = 2; 23059 while (--i > -1) { 23060 bs = ba[i]; 23061 pct = (bs.indexOf("%") !== -1); 23062 if (pct !== (ea[i].indexOf("%") !== -1)) { 23063 overlap = (i === 0) ? t.offsetWidth - _tempImg.width : t.offsetHeight - _tempImg.height; 23064 ba[i] = pct ? (parseFloat(bs) / 100 * overlap) + "px" : (parseFloat(bs) / overlap * 100) + "%"; 23065 } 23066 } 23067 bs = ba.join(" "); 23068 } 23069 } 23070 return this.parseComplex(t.style, bs, es, pt, plugin); 23071 }, formatter:_parsePosition}); 23072 _registerComplexSpecialProp("backgroundSize", {defaultValue:"0 0", formatter:function(v) { 23073 v += ""; //ensure it's a string 23074 return (v.substr(0,2) === "co") ? v : _parsePosition(v.indexOf(" ") === -1 ? v + " " + v : v); //if set to something like "100% 100%", Safari typically reports the computed style as just "100%" (no 2nd value), but we should ensure that there are two values, so copy the first one. Otherwise, it'd be interpreted as "100% 0" (wrong). Also remember that it could be "cover" or "contain" which we can't tween but should be able to set. 23075 }}); 23076 _registerComplexSpecialProp("perspective", {defaultValue:"0px", prefix:true}); 23077 _registerComplexSpecialProp("perspectiveOrigin", {defaultValue:"50% 50%", prefix:true}); 23078 _registerComplexSpecialProp("transformStyle", {prefix:true}); 23079 _registerComplexSpecialProp("backfaceVisibility", {prefix:true}); 23080 _registerComplexSpecialProp("userSelect", {prefix:true}); 23081 _registerComplexSpecialProp("margin", {parser:_getEdgeParser("marginTop,marginRight,marginBottom,marginLeft")}); 23082 _registerComplexSpecialProp("padding", {parser:_getEdgeParser("paddingTop,paddingRight,paddingBottom,paddingLeft")}); 23083 _registerComplexSpecialProp("clip", {defaultValue:"rect(0px,0px,0px,0px)", parser:function(t, e, p, cssp, pt, plugin){ 23084 var b, cs, delim; 23085 if (_ieVers < 9) { //IE8 and earlier don't report a "clip" value in the currentStyle - instead, the values are split apart into clipTop, clipRight, clipBottom, and clipLeft. Also, in IE7 and earlier, the values inside rect() are space-delimited, not comma-delimited. 23086 cs = t.currentStyle; 23087 delim = _ieVers < 8 ? " " : ","; 23088 b = "rect(" + cs.clipTop + delim + cs.clipRight + delim + cs.clipBottom + delim + cs.clipLeft + ")"; 23089 e = this.format(e).split(",").join(delim); 23090 } else { 23091 b = this.format(_getStyle(t, this.p, _cs, false, this.dflt)); 23092 e = this.format(e); 23093 } 23094 return this.parseComplex(t.style, b, e, pt, plugin); 23095 }}); 23096 _registerComplexSpecialProp("textShadow", {defaultValue:"0px 0px 0px #999", color:true, multi:true}); 23097 _registerComplexSpecialProp("autoRound,strictUnits", {parser:function(t, e, p, cssp, pt) {return pt;}}); //just so that we can ignore these properties (not tween them) 23098 _registerComplexSpecialProp("border", {defaultValue:"0px solid #000", parser:function(t, e, p, cssp, pt, plugin) { 23099 var bw = _getStyle(t, "borderTopWidth", _cs, false, "0px"), 23100 end = this.format(e).split(" "), 23101 esfx = end[0].replace(_suffixExp, ""); 23102 if (esfx !== "px") { //if we're animating to a non-px value, we need to convert the beginning width to that unit. 23103 bw = (parseFloat(bw) / _convertToPixels(t, "borderTopWidth", 1, esfx)) + esfx; 23104 } 23105 return this.parseComplex(t.style, this.format(bw + " " + _getStyle(t, "borderTopStyle", _cs, false, "solid") + " " + _getStyle(t, "borderTopColor", _cs, false, "#000")), end.join(" "), pt, plugin); 23106 }, color:true, formatter:function(v) { 23107 var a = v.split(" "); 23108 return a[0] + " " + (a[1] || "solid") + " " + (v.match(_colorExp) || ["#000"])[0]; 23109 }}); 23110 _registerComplexSpecialProp("borderWidth", {parser:_getEdgeParser("borderTopWidth,borderRightWidth,borderBottomWidth,borderLeftWidth")}); //Firefox doesn't pick up on borderWidth set in style sheets (only inline). 23111 _registerComplexSpecialProp("float,cssFloat,styleFloat", {parser:function(t, e, p, cssp, pt, plugin) { 23112 var s = t.style, 23113 prop = ("cssFloat" in s) ? "cssFloat" : "styleFloat"; 23114 return new CSSPropTween(s, prop, 0, 0, pt, -1, p, false, 0, s[prop], e); 23115 }}); 23116 23117 //opacity-related 23118 var _setIEOpacityRatio = function(v) { 23119 var t = this.t, //refers to the element's style property 23120 filters = t.filter || _getStyle(this.data, "filter") || "", 23121 val = (this.s + this.c * v) | 0, 23122 skip; 23123 if (val === 100) { //for older versions of IE that need to use a filter to apply opacity, we should remove the filter if opacity hits 1 in order to improve performance, but make sure there isn't a transform (matrix) or gradient in the filters. 23124 if (filters.indexOf("atrix(") === -1 && filters.indexOf("radient(") === -1 && filters.indexOf("oader(") === -1) { 23125 t.removeAttribute("filter"); 23126 skip = (!_getStyle(this.data, "filter")); //if a class is applied that has an alpha filter, it will take effect (we don't want that), so re-apply our alpha filter in that case. We must first remove it and then check. 23127 } else {
23128 t.filter = filters.replace(_alphaFilterExp, ""); 23129 skip = true; 23130 } 23131 } 23132 if (!skip) { 23133 if (this.xn1) { 23134 t.filter = filters = filters || ("alpha(opacity=" + val + ")"); //works around bug in IE7/8 that prevents changes to "visibility" from being applied properly if the filter is changed to a different alpha on the same frame. 23135 } 23136 if (filters.indexOf("pacity") === -1) { //only used if browser doesn't support the standard opacity style property (IE 7 and 8). We omit the "O" to avoid case-sensitivity issues 23137 if (val !== 0 || !this.xn1) { //bugs in IE7/8 won't render the filter properly if opacity is ADDED on the same frame/render as "visibility" changes (this.xn1 is 1 if this tween is an "autoAlpha" tween) 23138 t.filter = filters + " alpha(opacity=" + val + ")"; //we round the value because otherwise, bugs in IE7/8 can prevent "visibility" changes from being applied properly. 23139 } 23140 } else { 23141 t.filter = filters.replace(_opacityExp, "opacity=" + val); 23142 } 23143 } 23144 }; 23145 _registerComplexSpecialProp("opacity,alpha,autoAlpha", {defaultValue:"1", parser:function(t, e, p, cssp, pt, plugin) { 23146 var b = parseFloat(_getStyle(t, "opacity", _cs, false, "1")), 23147 style = t.style, 23148 isAutoAlpha = (p === "autoAlpha"); 23149 if (typeof(e) === "string" && e.charAt(1) === "=") { 23150 e = ((e.charAt(0) === "-") ? -1 : 1) * parseFloat(e.substr(2)) + b; 23151 } 23152 if (isAutoAlpha && b === 1 && _getStyle(t, "visibility", _cs) === "hidden" && e !== 0) { //if visibility is initially set to "hidden", we should interpret that as intent to make opacity 0 (a convenience) 23153 b = 0; 23154 } 23155 if (_supportsOpacity) { 23156 pt = new CSSPropTween(style, "opacity", b, e - b, pt); 23157 } else { 23158 pt = new CSSPropTween(style, "opacity", b * 100, (e - b) * 100, pt); 23159 pt.xn1 = isAutoAlpha ? 1 : 0; //we need to record whether or not this is an autoAlpha so that in the setRatio(), we know to duplicate the setting of the alpha in order to work around a bug in IE7 and IE8 that prevents changes to "visibility" from taking effect if the filter is changed to a different alpha(opacity) at the same time. Setting it to the SAME value first, then the new value works around the IE7/8 bug. 23160 style.zoom = 1; //helps correct an IE issue. 23161 pt.type = 2; 23162 pt.b = "alpha(opacity=" + pt.s + ")"; 23163 pt.e = "alpha(opacity=" + (pt.s + pt.c) + ")"; 23164 pt.data = t; 23165 pt.plugin = plugin; 23166 pt.setRatio = _setIEOpacityRatio; 23167 } 23168 if (isAutoAlpha) { //we have to create the "visibility" PropTween after the opacity one in the linked list so that they run in the order that works properly in IE8 and earlier 23169 pt = new CSSPropTween(style, "visibility", 0, 0, pt, -1, null, false, 0, ((b !== 0) ? "inherit" : "hidden"), ((e === 0) ? "hidden" : "inherit")); 23170 pt.xs0 = "inherit"; 23171 cssp._overwriteProps.push(pt.n); 23172 cssp._overwriteProps.push(p); 23173 } 23174 return pt; 23175 }}); 23176 23177 23178 var _removeProp = function(s, p) { 23179 if (p) { 23180 if (s.removeProperty) { 23181 if (p.substr(0,2) === "ms" || p.substr(0,6) === "webkit") { //Microsoft and some Webkit browsers don't conform to the standard of capitalizing the first prefix character, so we adjust so that when we prefix the caps with a dash, it's correct (otherwise it'd be "ms-transform" instead of "-ms-transform" for IE9, for example) 23182 p = "-" + p; 23183 } 23184 s.removeProperty(p.replace(_capsExp, "-$1").toLowerCase()); 23185 } else { //note: old versions of IE use "removeAttribute()" instead of "removeProperty()" 23186 s.removeAttribute(p); 23187 } 23188 } 23189 }, 23190 _setClassNameRatio = function(v) { 23191 this.t._gsClassPT = this; 23192 if (v === 1 || v === 0) { 23193 this.t.setAttribute("class", (v === 0) ? this.b : this.e); 23194 var mpt = this.data, //first MiniPropTween 23195 s = this.t.style; 23196 while (mpt) { 23197 if (!mpt.v) { 23198 _removeProp(s, mpt.p); 23199 } else { 23200 s[mpt.p] = mpt.v; 23201 } 23202 mpt = mpt._next; 23203 } 23204 if (v === 1 && this.t._gsClassPT === this) { 23205 this.t._gsClassPT = null; 23206 } 23207 } else if (this.t.getAttribute("class") !== this.e) { 23208 this.t.setAttribute("class", this.e); 23209 } 23210 }; 23211 _registerComplexSpecialProp("className", {parser:function(t, e, p, cssp, pt, plugin, vars) { 23212 var b = t.getAttribute("class") || "", //don't use t.className because it doesn't work consistently on SVG elements; getAttribute("class") and setAttribute("class", value") is more reliable. 23213 cssText = t.style.cssText, 23214 difData, bs, cnpt, cnptLookup, mpt; 23215 pt = cssp._classNamePT = new CSSPropTween(t, p, 0, 0, pt, 2); 23216 pt.setRatio = _setClassNameRatio; 23217 pt.pr = -11; 23218 _hasPriority = true; 23219 pt.b = b; 23220 bs = _getAllStyles(t, _cs); 23221 //if there's a className tween already operating on the target, force it to its end so that the necessary inline styles are removed and the class name is applied before we determine the end state (we don't want inline styles interfer
23221ing that were there just for class-specific values) 23222 cnpt = t._gsClassPT; 23223 if (cnpt) { 23224 cnptLookup = {}; 23225 mpt = cnpt.data; //first MiniPropTween which stores the inline styles - we need to force these so that the inline styles don't contaminate things. Otherwise, there's a small chance that a tween could start and the inline values match the destination values and they never get cleaned. 23226 while (mpt) { 23227 cnptLookup[mpt.p] = 1; 23228 mpt = mpt._next; 23229 } 23230 cnpt.setRatio(1); 23231 } 23232 t._gsClassPT = pt; 23233 pt.e = (e.charAt(1) !== "=") ? e : b.replace(new RegExp("(?:\\s|^)" + e.substr(2) + "(?![\\w-])"), "") + ((e.charAt(0) === "+") ? " " + e.substr(2) : ""); 23234 t.setAttribute("class", pt.e); 23235 difData = _cssDif(t, bs, _getAllStyles(t), vars, cnptLookup); 23236 t.setAttribute("class", b); 23237 pt.data = difData.firstMPT; 23238 t.style.cssText = cssText; //we recorded cssText before we swapped classes and ran _getAllStyles() because in cases when a className tween is overwritten, we remove all the related tweening properties from that class change (otherwise class-specific stuff can't override properties we've directly set on the target's style object due to specificity). 23239 pt = pt.xfirst = cssp.parse(t, difData.difs, pt, plugin); //we record the CSSPropTween as the xfirst so that we can handle overwriting propertly (if "className" gets overwritten, we must kill all the properties associated with the className part of the tween, so we can loop through from xfirst to the pt itself) 23240 return pt; 23241 }}); 23242 23243 23244 var _setClearPropsRatio = function(v) { 23245 if (v === 1 || v === 0) if (this.data._totalTime === this.data._totalDuration && this.data.data !== "isFromStart") { //this.data refers to the tween. Only clear at the END of the tween (remember, from() tweens make the ratio go from 1 to 0, so we can't just check that and if the tween is the zero-duration one that's created internally to render the starting values in a from() tween, ignore that because otherwise, for example, from(...{height:100, clearProps:"height", delay:1}) would wipe the height at the beginning of the tween and after 1 second, it'd kick back in). 23246 var s = this.t.style, 23247 transformParse = _specialProps.transform.parse, 23248 a, p, i, clearTransform, transform; 23249 if (this.e === "all") { 23250 s.cssText = ""; 23251 clearTransform = true; 23252 } else { 23253 a = this.e.split(" ").join("").split(","); 23254 i = a.length; 23255 while (--i > -1) { 23256 p = a[i]; 23257 if (_specialProps[p]) { 23258 if (_specialProps[p].parse === transformParse) { 23259 clearTransform = true; 23260 } else { 23261 p = (p === "transformOrigin") ? _transformOriginProp : _specialProps[p].p; //ensures that special properties use the proper browser-specific property name, like "scaleX" might be "-webkit-transform" or "boxShadow" might be "-moz-box-shadow" 23262 } 23263 } 23264 _removeProp(s, p); 23265 } 23266 } 23267 if (clearTransform) { 23268 _removeProp(s, _transformProp); 23269 transform = this.t._gsTransform; 23270 if (transform) { 23271 if (transform.svg) { 23272 this.t.removeAttribute("data-svg-origin"); 23273 this.t.removeAttribute("transform"); 23274 } 23275 delete this.t._gsTransform; 23276 } 23277 } 23278 23279 } 23280 }; 23281 _registerComplexSpecialProp("clearProps", {parser:function(t, e, p, cssp, pt) { 23282 pt = new CSSPropTween(t, p, 0, 0, pt, 2); 23283 pt.setRatio = _setClearPropsRatio; 23284 pt.e = e; 23285 pt.pr = -10; 23286 pt.data = cssp._tween; 23287 _hasPriority = true; 23288 return pt; 23289 }}); 23290 23291 p = "bezier,throwProps,physicsProps,physics2D".split(","); 23292 i = p.length; 23293 while (i--) { 23294 _registerPluginProp(p[i]); 23295 } 23296 23297 23298 23299 23300 23301 23302 23303 23304 p = CSSPlugin.prototype; 23305 p._firstPT = p._lastParsedTransform = p._transform = null; 23306 23307 //gets called when the tween renders for the first time. This kicks everything off, recording start/end values, etc. 23308 p._onInitTween = function(target, vars, tween, index) { 23309 if (!target.nodeType) { //css is only for dom elements 23310 return false; 23311 } 23312 this._target = _target = target; 23313 this._tween = tween; 23314 this._vars = vars; 23315 _index = index; 23316 _autoRound = vars.autoRound; 23317 _hasPriority = false;
23318 _suffixMap = vars.suffixMap || CSSPlugin.suffixMap; 23319 _cs = _getComputedStyle(target, ""); 23320 _overwriteProps = this._overwriteProps; 23321 var style = target.style, 23322 v, pt, pt2, first, last, next, zIndex, tpt, threeD; 23323 if (_reqSafariFix) if (style.zIndex === "") { 23324 v = _getStyle(target, "zIndex", _cs); 23325 if (v === "auto" || v === "") { 23326 //corrects a bug in [non-Android] Safari that prevents it from repainting elements in their new positions if they don't have a zIndex set. We also can't just apply this inside _parseTransform() because anything that's moved in any way (like using "left" or "top" instead of transforms like "x" and "y") can be affected, so it is best to ensure that anything that's tweening has a z-index. Setting "WebkitPerspective" to a non-zero value worked too except that on iOS Safari things would flicker randomly. Plus zIndex is less memory-intensive. 23327 this._addLazySet(style, "zIndex", 0); 23328 } 23329 } 23330 23331 if (typeof(vars) === "string") { 23332 first = style.cssText; 23333 v = _getAllStyles(target, _cs); 23334 style.cssText = first + ";" + vars; 23335 v = _cssDif(target, v, _getAllStyles(target)).difs; 23336 if (!_supportsOpacity && _opacityValExp.test(vars)) { 23337 v.opacity = parseFloat( RegExp.$1 ); 23338 } 23339 vars = v; 23340 style.cssText = first; 23341 } 23342 23343 if (vars.className) { //className tweens will combine any differences they find in the css with the vars that are passed in, so {className:"myClass", scale:0.5, left:20} would work. 23344 this._firstPT = pt = _specialProps.className.parse(target, vars.className, "className", this, null, null, vars); 23345 } else { 23346 this._firstPT = pt = this.parse(target, vars, null); 23347 } 23348 23349 if (this._transformType) { 23350 threeD = (this._transformType === 3); 23351 if (!_transformProp) { 23352 style.zoom = 1; //helps correct an IE issue. 23353 } else if (_isSafari) { 23354 _reqSafariFix = true; 23355 //if zIndex isn't set, iOS Safari doesn't repaint things correctly sometimes (seemingly at random). 23356 if (style.zIndex === "") { 23357 zIndex = _getStyle(target, "zIndex", _cs); 23358 if (zIndex === "auto" || zIndex === "") { 23359 this._addLazySet(style, "zIndex", 0); 23360 } 23361 } 23362 //Setting WebkitBackfaceVisibility corrects 3 bugs: 23363 // 1) [non-Android] Safari skips rendering changes to "top" and "left" that are made on the same frame/render as a transform update. 23364 // 2) iOS Safari sometimes neglects to repaint elements in their new positions. Setting "WebkitPerspective" to a non-zero value worked too except that on iOS Safari things would flicker randomly. 23365 // 3) Safari sometimes displayed odd artifacts when tweening the transform (or WebkitTransform) property, like ghosts of the edges of the element remained. Definitely a browser bug. 23366 //Note: we allow the user to override the auto-setting by defining WebkitBackfaceVisibility in the vars of the tween. 23367 if (_isSafariLT6) { 23368 this._addLazySet(style, "WebkitBackfaceVisibility", this._vars.WebkitBackfaceVisibility || (threeD ? "visible" : "hidden")); 23369 } 23370 } 23371 pt2 = pt; 23372 while (pt2 && pt2._next) { 23373 pt2 = pt2._next; 23374 } 23375 tpt = new CSSPropTween(target, "transform", 0, 0, null, 2); 23376 this._linkCSSP(tpt, null, pt2); 23377 tpt.setRatio = _transformProp ? _setTransformRatio : _setIETransformRatio; 23378 tpt.data = this._transform || _getTransform(target, _cs, true); 23379 tpt.tween = tween; 23380 tpt.pr = -1; //ensures that the transforms get applied after the components are updated. 23381 _overwriteProps.pop(); //we don't want to force the overwrite of all "transform" tweens of the target - we only care about individual transform properties like scaleX, rotation, etc. The CSSPropTween constructor automatically adds the property to _overwriteProps which is why we need to pop() here. 23382 } 23383 23384 if (_hasPriority) { 23385 //reorders the linked list in order of pr (priority) 23386 while (pt) { 23387 next = pt._next; 23388 pt2 = first; 23389 while (pt2 && pt2.pr > pt.pr) { 23390 pt2 = pt2._next; 23391 } 23392 if ((pt._prev = pt2 ? pt2._prev : last)) { 23393 pt._prev._next = pt; 23394 } else { 23395 first = pt; 23396 } 23397 if ((pt._next = pt2)) { 23398 pt2._prev = pt; 23399 } else { 23400 last = pt; 23401 } 23402 pt = next; 23403 } 23404 this._firstPT = first; 23405 } 23406 return true; 23407 }; 23408 23409 23410 p.parse = function(target, vars, pt, plugin) { 23411 var style = target.style, 23412 p, sp, bn, en, bs, es, bsfx, esfx, isStr, rel; 23413 for (p in vars) { 23414 es = vars[p]; //ending value string 23415 if (typeof(es) === "function") { 23416 es = es(_index, _target); 23417 } 23418 sp = _specialProps[p]; //SpecialProp lookup. 23419 if (sp) { 23420 pt = sp.parse(target, es, p, this, pt, plugin, vars); 23421 } else if (p.substr(0,2) === "--") { //for tweening CSS variables (which always start with "--"). To maximize performance and simplicity, we bypass CSSPlugin altogether and just add a normal property tween to the tween instance itself. 23422 this._tween._propLookup[p] = this._addTween.call(this._tween, target.style, "setProperty", _getComputedStyle(target).getPropertyValue(p) + "", es + "", p, false, p); 23423 continue; 23424 } else { 23425 bs = _getStyle(target, p, _cs) + ""; 23426 isStr = (typeof(es) === "string"); 23427 if (p === "color" || p === "fill" || p === "stroke" || p.indexOf("Color") !== -1 || (isStr && _rgbhslExp.test(es))) { //Opera uses background: to define color sometimes in addition to backgroundColor: 23428 if (!isStr) { 23429 es = _parseColor(es); 23430 es = ((es.length > 3) ? "rgba(" : "rgb(") + es.join(",") + ")"; 23431 } 23432 pt = _parseComplex(style, p, bs, es, true, "transparent", pt, 0, plugin); 23433 23434 } else if (isStr && _complexExp.test(es)) { 23435 pt = _parseComplex(style, p, bs, es, true, null, pt, 0, plugin); 23436 23437 } else { 23438 bn = parseFloat(bs); 23439 bsfx = (bn || bn === 0) ? bs.substr((bn + "").length) : ""; //remember, bs could be non-numeric like "normal" for fontWeight, so we should default to a blank suffix in that case. 23440 23441 if (bs === "" || bs === "auto") { 23442 if (p === "width" || p === "height") { 23443 bn = _getDimension(target, p, _cs); 23444 bsfx = "px"; 23445 } else if (p === "left" || p === "top") {
23446 bn = _calculateOffset(target, p, _cs); 23447 bsfx = "px"; 23448 } else { 23449 bn = (p !== "opacity") ? 0 : 1; 23450 bsfx = ""; 23451 } 23452 } 23453 23454 rel = (isStr && es.charAt(1) === "="); 23455 if (rel) { 23456 en = parseInt(es.charAt(0) + "1", 10); 23457 es = es.substr(2); 23458 en *= parseFloat(es); 23459 esfx = es.replace(_suffixExp, ""); 23460 } else { 23461 en = parseFloat(es); 23462 esfx = isStr ? es.replace(_suffixExp, "") : ""; 23463 } 23464 23465 if (esfx === "") { 23466 esfx = (p in _suffixMap) ? _suffixMap[p] : bsfx; //populate the end suffix, prioritizing the map, then if none is found, use the beginning suffix. 23467 } 23468 23469 es = (en || en === 0) ? (rel ? en + bn : en) + esfx : vars[p]; //ensures that any += or -= prefixes are taken care of. Record the end value before normalizing the suffix because we always want to end the tween on exactly what they intended even if it doesn't match the beginning value's suffix. 23470 //if the beginning/ending suffixes don't match, normalize them... 23471 if (bsfx !== esfx) if (esfx !== "" || p === "lineHeight") if (en || en === 0) if (bn) { //note: if the beginning value (bn) is 0, we don't need to convert units! 23472 bn = _convertToPixels(target, p, bn, bsfx); 23473 if (esfx === "%") { 23474 bn /= _convertToPixels(target, p, 100, "%") / 100; 23475 if (vars.strictUnits !== true) { //some browsers report only "px" values instead of allowing "%" with getComputedStyle(), so we assume that if we're tweening to a %, we should start there too unless strictUnits:true is defined. This approach is particularly useful for responsive designs that use from() tweens. 23476 bs = bn + "%"; 23477 } 23478 23479 } else if (esfx === "em" || esfx === "rem" || esfx === "vw" || esfx === "vh") { 23480 bn /= _convertToPixels(target, p, 1, esfx); 23481 23482 //otherwise convert to pixels. 23483 } else if (esfx !== "px") { 23484 en = _convertToPixels(target, p, en, esfx); 23485 esfx = "px"; //we don't use bsfx after this, so we don't need to set it to px too. 23486 } 23487 if (rel) if (en || en === 0) { 23488 es = (en + bn) + esfx; //the changes we made affect relative calculations, so adjust the end value here. 23489 } 23490 } 23491 23492 if (rel) { 23493 en += bn; 23494 } 23495 23496 if ((bn || bn === 0) && (en || en === 0)) { //faster than isNaN(). Also, previously we required en !== bn but that doesn't really gain much performance and it prevents _parseToProxy() from working properly if beginning and ending values match but need to get tweened by an external plugin anyway. For example, a bezier tween where the target starts at left:0 and has these points: [{left:50},{left:0}] wouldn't work properly because when parsing the last point, it'd match the first (current) one and a non-tweening CSSPropTween would be recorded when we actually need a normal tween (type:0) so that things get updated during the tween properly. 23497 pt = new CSSPropTween(style, p, bn, en - bn, pt, 0, p, (_autoRound !== false && (esfx === "px" || p === "zIndex")), 0, bs, es); 23498 pt.xs0 = esfx; 23499 //DEBUG: _log("tween "+p+" from "+pt.b+" ("+bn+esfx+") to "+pt.e+" with suffix: "+pt.xs0); 23500 } else if (style[p] === undefined || !es && (es + "" === "NaN" || es == null)) { 23501 _log("invalid " + p + " tween value: " + vars[p]); 23502 } else { 23503 pt = new CSSPropTween(style, p, en || bn || 0, 0, pt, -1, p, false, 0, bs, es); 23504 pt.xs0 = (es === "none" && (p === "display" || p.indexOf("Style") !== -1)) ? bs : es; //intermediate value should typically be set immediately (end value) except for "display" or things like borderTopStyle, borderBottomStyle, etc. which should use the beginning value during the tween. 23505 //DEBUG: _log("non-tweening value "+p+": "+pt.xs0); 23506 } 23507 } 23508 } 23509 if (plugin) if (pt && !pt.plugin) { 23510 pt.plugin = plugin; 23511 } 23512 } 23513 return pt; 23514 }; 23515 23516 23517 //gets called every time the tween updates, passing the new ratio (typically a value between 0 and 1, but not always (for example, if an Elastic.easeOut is used, the value can jump above 1 mid-tween). It will always start and 0 and end at 1. 23518 p.setRatio = function(v) { 23519 var pt = this._firstPT, 23520 min = 0.000001, 23521 val, str, i; 23522 //at the end of the tween, we set the values to exactly what we received in order to make sure non-tweening values (like "position" or "float" or whatever) are set and so that if the beginning/ending suffixes (units) didn't match and we normalized to px, the value that the user passed in is used here. We check to see if the tween is at its beginning in case it's a from() tween in which case the ratio will actually go from 1 to 0 over the course of the tween (backwards). 23523 if (v === 1 && (this._tween._time === this._tween._duration || this._tween._time === 0)) { 23524 while (pt) { 23525 if (pt.type !== 2) { 23526 if (pt.r && pt.type !== -1) { 23527 val = pt.r(pt.s + pt.c); 23528 if (!pt.type) { 23529 pt.t[pt.p] = val + pt.xs0; 23530 } else if (pt.type === 1) { //complex value (one that typically has multiple numbers inside a string, like "rect(5px,10px,20px,25px)" 23531 i = pt.l; 23532 str = pt.xs0 + val + pt.xs1; 23533 for (i = 1; i < pt.l; i++) {
23534 str += pt["xn"+i] + pt["xs"+(i+1)]; 23535 } 23536 pt.t[pt.p] = str; 23537 } 23538 } else { 23539 pt.t[pt.p] = pt.e; 23540 } 23541 } else { 23542 pt.setRatio(v); 23543 } 23544 pt = pt._next; 23545 } 23546 23547 } else if (v || !(this._tween._time === this._tween._duration || this._tween._time === 0) || this._tween._rawPrevTime === -0.000001) { 23548 while (pt) { 23549 val = pt.c * v + pt.s; 23550 if (pt.r) { 23551 val = pt.r(val); 23552 } else if (val < min) if (val > -min) { 23553 val = 0; 23554 } 23555 if (!pt.type) { 23556 pt.t[pt.p] = val + pt.xs0; 23557 } else if (pt.type === 1) { //complex value (one that typically has multiple numbers inside a string, like "rect(5px,10px,20px,25px)" 23558 i = pt.l; 23559 if (i === 2) { 23560 pt.t[pt.p] = pt.xs0 + val + pt.xs1 + pt.xn1 + pt.xs2; 23561 } else if (i === 3) { 23562 pt.t[pt.p] = pt.xs0 + val + pt.xs1 + pt.xn1 + pt.xs2 + pt.xn2 + pt.xs3; 23563 } else if (i === 4) { 23564 pt.t[pt.p] = pt.xs0 + val + pt.xs1 + pt.xn1 + pt.xs2 + pt.xn2 + pt.xs3 + pt.xn3 + pt.xs4; 23565 } else if (i === 5) { 23566 pt.t[pt.p] = pt.xs0 + val + pt.xs1 + pt.xn1 + pt.xs2 + pt.xn2 + pt.xs3 + pt.xn3 + pt.xs4 + pt.xn4 + pt.xs5; 23567 } else { 23568 str = pt.xs0 + val + pt.xs1; 23569 for (i = 1; i < pt.l; i++) { 23570 str += pt["xn"+i] + pt["xs"+(i+1)]; 23571 } 23572 pt.t[pt.p] = str; 23573 } 23574 23575 } else if (pt.type === -1) { //non-tweening value 23576 pt.t[pt.p] = pt.xs0; 23577 23578 } else if (pt.setRatio) { //custom setRatio() for things like SpecialProps, external plugins, etc. 23579 pt.setRatio(v); 23580 } 23581 pt = pt._next; 23582 } 23583 23584 //if the tween is reversed all the way back to the beginning, we need to restore the original values which may have different units (like % instead of px or em or whatever). 23585 } else { 23586 while (pt) { 23587 if (pt.type !== 2) { 23588 pt.t[pt.p] = pt.b; 23589 } else { 23590 pt.setRatio(v); 23591 } 23592 pt = pt._next; 23593 } 23594 } 23595 }; 23596 23597 /** 23598 * @private 23599 * Forces rendering of the target's transforms (rotation, scale, etc.) whenever the CSSPlugin's setRatio() is called. 23600 * Basically, this tells the CSSPlugin to create a CSSPropTween (type 2) after instantiation that runs last in the linked 23601 * list and calls the appropriate (3D or 2D) rendering function. We separate this into its own method so that we can call 23602 * it from other plugins like BezierPlugin if, for example, it needs to apply an autoRotation and this CSSPlugin 23603 * doesn't have any transform-related properties of its own. You can call this method as many times as you 23604 * want and it won't create duplicate CSSPropTweens. 23605 * 23606 * @param {boolean} threeD if true, it should apply 3D tweens (otherwise, just 2D ones are fine and typically faster) 23607 */ 23608 p._enableTransforms = function(threeD) { 23609 this._transform = this._transform || _getTransform(this._target, _cs, true); //ensures that the element has a _gsTransform property with the appropriate values. 23610 this._transformType = (!(this._transform.svg && _useSVGTransformAttr) && (threeD || this._transformType === 3)) ? 3 : 2; 23611 }; 23612 23613 var lazySet = function(v) { 23614 this.t[this.p] = this.e; 23615 this.data._linkCSSP(this, this._next, null, true); //we purposefully keep this._next even though it'd make sense to null it, but this is a performance optimization, as this happens during the while (pt) {} loop in setRatio() at the bottom of which it sets pt = pt._next, so if we null it, the linked list will be broken in that loop. 23616 }; 23617 /** @private Gives us a way to set a value on the first render (and only the first render). **/ 23618 p._addLazySet = function(t, p, v) { 23619 var pt = this._firstPT = new CSSPropTween(t, p, 0, 0, this._firstPT, 2); 23620 pt.e = v; 23621 pt.setRatio = lazySet; 23622 pt.data = this; 23623 }; 23624 23625 /** @private **/ 23626 p._linkCSSP = function(pt, next, prev, remove) { 23627 if (pt) { 23628 if (next) { 23629 next._prev = pt; 23630 } 23631 if (pt._next) { 23632 pt._next._prev = pt._prev; 23633 } 23634 if (pt._prev) { 23635 pt._prev._next = pt._next; 23636 } else if (this._firstPT === pt) { 23637 this._firstPT = pt._next; 23638 remove = true; //just to prevent resetting this._firstPT 5 lines down in case pt._next is null. (optimized for speed) 23639 } 23640 if (prev) { 23641 prev._next = pt; 23642 } else if (!remove && this._firstPT === null) { 23643 this._firstPT = pt; 23644 } 23645 pt._next = next; 23646 pt._prev = prev; 23647 } 23648 return pt; 23649 }; 23650 23651 p._mod = function(lookup) { 23652 var pt = this._firstPT; 23653 while (pt) { 23654 if (typeof(lookup[pt.p]) === "function") { //only gets called by RoundPropsPlugin (ModifyPlugin manages all the rendering internally for CSSPlugin properties that need modification). Remember, we handle rounding a bit differently in this plugin for performance reasons, leveraging "r" as an indicator that the value should be roun
23654ded internally. 23655 pt.r = lookup[pt.p]; 23656 } 23657 pt = pt._next; 23658 } 23659 }; 23660 23661 //we need to make sure that if alpha or autoAlpha is killed, opacity is too. And autoAlpha affects the "visibility" property. 23662 p._kill = function(lookup) { 23663 var copy = lookup, 23664 pt, p, xfirst; 23665 if (lookup.autoAlpha || lookup.alpha) { 23666 copy = {}; 23667 for (p in lookup) { //copy the lookup so that we're not changing the original which may be passed elsewhere. 23668 copy[p] = lookup[p]; 23669 } 23670 copy.opacity = 1; 23671 if (copy.autoAlpha) { 23672 copy.visibility = 1; 23673 } 23674 } 23675 if (lookup.className && (pt = this._classNamePT)) { //for className tweens, we need to kill any associated CSSPropTweens too; a linked list starts at the className's "xfirst". 23676 xfirst = pt.xfirst; 23677 if (xfirst && xfirst._prev) { 23678 this._linkCSSP(xfirst._prev, pt._next, xfirst._prev._prev); //break off the prev 23679 } else if (xfirst === this._firstPT) { 23680 this._firstPT = pt._next; 23681 } 23682 if (pt._next) { 23683 this._linkCSSP(pt._next, pt._next._next, xfirst._prev); 23684 } 23685 this._classNamePT = null; 23686 } 23687 pt = this._firstPT; 23688 while (pt) { 23689 if (pt.plugin && pt.plugin !== p && pt.plugin._kill) { //for plugins that are registered with CSSPlugin, we should notify them of the kill. 23690 pt.plugin._kill(lookup); 23691 p = pt.plugin; 23692 } 23693 pt = pt._next; 23694 } 23695 return TweenPlugin.prototype._kill.call(this, copy); 23696 }; 23697 23698 23699 23700 //used by cascadeTo() for gathering all the style properties of each child element into an array for comparison. 23701 var _getChildStyles = function(e, props, targets) { 23702 var children, i, child, type; 23703 if (e.slice) { 23704 i = e.length; 23705 while (--i > -1) { 23706 _getChildStyles(e[i], props, targets); 23707 } 23708 return; 23709 } 23710 children = e.childNodes; 23711 i = children.length; 23712 while (--i > -1) { 23713 child = children[i]; 23714 type = child.type; 23715 if (child.style) { 23716 props.push(_getAllStyles(child)); 23717 if (targets) { 23718 targets.push(child); 23719 } 23720 } 23721 if ((type === 1 || type === 9 || type === 11) && child.childNodes.length) { 23722 _getChildStyles(child, props, targets); 23723 } 23724 } 23725 }; 23726 23727 /** 23728 * Typically only useful for className tweens that may affect child elements, this method creates a TweenLite 23729 * and then compares the style properties of all the target's child elements at the tween's start and end, and 23730 * if any are different, it also creates tweens for those and returns an array containing ALL of the resulting 23731 * tweens (so that you can easily add() them to a TimelineLite, for example). The reason this functionality is 23732 * wrapped into a separate static method of CSSPlugin instead of being integrated into all regular className tweens 23733 * is because it creates entirely new tweens that may have completely different targets than the original tween, 23734 * so if they were all lumped into the original tween instance, it would be inconsistent with the rest of the API 23735 * and it would create other problems. For example: 23736 * - If I create a tween of elementA, that tween instance may suddenly change its target to include 50 other elements (unintuitive if I specifically defined the target I wanted) 23737 * - We can't just create new independent tweens because otherwise, what happens if the original/parent tween is reversed or pause or dropped into a TimelineLite for tight control? You'd expect that tween's behavior to affect all the others. 23738 * - Analyzing every style property of every child before and after the tween is an expensive operation when there are many children, so this behavior shouldn't be imposed on all className tweens by default, especially since it's probably rare that this extra functionality is needed. 23739 * 23740 * @param {Object} target object to be tweened 23741 * @param {number} Duration in seconds (or frames for frames-based tweens) 23742 * @param {Object} Object containing the end values, like {className:"newClass", ease:Linear.easeNone} 23743 * @return {Array} An array of TweenLite instances 23744 */ 23745 CSSPlugin.cascadeTo = function(target, duration, vars) { 23746 var tween = TweenLite.to(target, duration, vars), 23747 results = [tween], 23748 b = [], 23749 e = [], 23750 targets = [], 23751 _reservedProps = TweenLite._internals.reservedProps, 23752 i, difs, p, from; 23753 target = tween._targets || tween.target; 23754 _getChildStyles(target, b, targets); 23755 tween.render(duration, true, true); 23756 _getChildStyles(target, e); 23757 tween.render(0, true, true); 23758 tween._enabled(true); 23759 i = targets.length; 23760 while (--i > -1) { 23761 difs = _cssDif(targets[i], b[i], e[i]); 23762 if (difs.firstMPT) { 23763 difs = difs.difs; 23764 for (p in vars) { 23765 if (_reservedProps[p]) { 23766 difs[p] = vars[p]; 23767 } 23768 } 23769 from = {}; 23770 for (p in difs) { 23771 from[p] = b[i][p]; 23772 } 23773 results.push(TweenLite.fromTo(targets[i], duration, from, difs)); 23774 } 23775 } 23776 return results; 23777 }; 23778 23779 TweenPlugin.activate([CSSPlugin]); 23780 return CSSPlugin; 23781 23782 }, true); 23783 23784 23785 23786 23787 23788 23789 23790 23791 23792 23793 23794/* 23795 * ---------------------------------------------------------------- 23796 * RoundPropsPlugin 23797 * ---------------------------------------------------------------- 23798 */ 23799 (function() { 23800 23801 var RoundPropsPlugin = _gsScope._gsDefine.plugin({ 23802 propName: "roundProps", 23803 version: "1.7.0", 23804 priority: -1, 23805 API: 2, 23806 23807 //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run. 23808 init: function(target, value, tween) { 23809 this._tween = tween; 23810 return true; 23811 } 23812 23813 }), 23814 _getRoundFunc = function(v) { //pass in 0.1 get a function that'll round to the nearest tenth, or 5 to round to the closest 5, or 0.001 to the closest 1000th, etc. 23815 var p = v < 1 ? Math.pow(10, (v + "").length - 2) : 1; //to avoid floating point math errors (like 24 * 0.1 == 2.4000000000000004), we chop off at a specific number of decimal places (much faster than toFixed() 23816 return function(n) { 23817 return ((Math.round(n / v) * v * p) | 0) / p; 23818 }; 23819 }, 23820 _roundLinkedList = function(node, mod) { 23821 while (node) { 23822 if (!node.f && !node.blob) { 23823 node.m = mod || Math.round; 23824 } 23825 node = node._next; 23826 } 23827 }, 23828 p = RoundPropsPlugin.prototype; 23829 23830 p._onInitAllProps = function() { 23831 var tween = this._tween,
23832 rp = tween.vars.roundProps, 23833 lookup = {}, 23834 rpt = tween._propLookup.roundProps, 23835 pt, next, i, p; 23836 if (typeof(rp) === "object" && !rp.push) { 23837 for (p in rp) { 23838 lookup[p] = _getRoundFunc(rp[p]); 23839 } 23840 } else { 23841 if (typeof(rp) === "string") { 23842 rp = rp.split(","); 23843 } 23844 i = rp.length; 23845 while (--i > -1) { 23846 lookup[rp[i]] = Math.round; 23847 } 23848 } 23849 23850 for (p in lookup) { 23851 pt = tween._firstPT; 23852 while (pt) { 23853 next = pt._next; //record here, because it may get removed 23854 if (pt.pg) { 23855 pt.t._mod(lookup); 23856 } else if (pt.n === p) { 23857 if (pt.f === 2 && pt.t) { //a blob (text containing multiple numeric values) 23858 _roundLinkedList(pt.t._firstPT, lookup[p]); 23859 } else { 23860 this._add(pt.t, p, pt.s, pt.c, lookup[p]); 23861 //remove from linked list 23862 if (next) { 23863 next._prev = pt._prev; 23864 } 23865 if (pt._prev) { 23866 pt._prev._next = next; 23867 } else if (tween._firstPT === pt) { 23868 tween._firstPT = next; 23869 } 23870 pt._next = pt._prev = null; 23871 tween._propLookup[p] = rpt; 23872 } 23873 } 23874 pt = next; 23875 } 23876 } 23877 return false; 23878 }; 23879 23880 p._add = function(target, p, s, c, mod) { 23881 this._addTween(target, p, s, s + c, p, mod || Math.round); 23882 this._overwriteProps.push(p); 23883 }; 23884 23885 }()); 23886 23887 23888 23889 23890 23891 23892 23893 23894 23895 23896/* 23897 * ---------------------------------------------------------------- 23898 * AttrPlugin 23899 * ---------------------------------------------------------------- 23900 */ 23901 23902 (function() { 23903 23904 _gsScope._gsDefine.plugin({ 23905 propName: "attr", 23906 API: 2, 23907 version: "0.6.1", 23908 23909 //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run. 23910 init: function(target, value, tween, index) { 23911 var p, end; 23912 if (typeof(target.setAttribute) !== "function") { 23913 return false; 23914 } 23915 for (p in value) { 23916 end = value[p]; 23917 if (typeof(end) === "function") { 23918 end = end(index, target); 23919 } 23920 this._addTween(target, "setAttribute", target.getAttribute(p) + "", end + "", p, false, p); 23921 this._overwriteProps.push(p); 23922 } 23923 return true; 23924 } 23925 23926 }); 23927 23928 }()); 23929 23930 23931 23932 23933 23934 23935 23936 23937 23938 23939/* 23940 * ---------------------------------------------------------------- 23941 * DirectionalRotationPlugin 23942 * ---------------------------------------------------------------- 23943 */ 23944 _gsScope._gsDefine.plugin({ 23945 propName: "directionalRotation", 23946 version: "0.3.1", 23947 API: 2, 23948 23949 //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run. 23950 init: function(target, value, tween, index) { 23951 if (typeof(value) !== "object") { 23952 value = {rotation:value}; 23953 } 23954 this.finals = {}; 23955 var cap = (value.useRadians === true) ? Math.PI * 2 : 360, 23956 min = 0.000001, 23957 p, v, start, end, dif, split; 23958 for (p in value) { 23959 if (p !== "useRadians") { 23960 end = value[p]; 23961 if (typeof(end) === "function") { 23962 end = end(index, target); 23963 } 23964 split = (end + "").split("_"); 23965 v = split[0]; 23966 start = parseFloat( (typeof(target[p]) !== "function") ? target[p] : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() ); 23967 end = this.finals[p] = (typeof(v) === "string" && v.charAt(1) === "=") ? start + parseInt(v.charAt(0) + "1", 10) * Number(v.substr(2)) : Number(v) || 0; 23968 dif = end - start; 23969 if (split.length) { 23970 v = split.join("_"); 23971 if (v.indexOf("short") !== -1) { 23972 dif = dif % cap; 23973 if (dif !== dif % (cap / 2)) { 23974 dif = (dif < 0) ? dif + cap : dif - cap; 23975 } 23976 } 23977 if (v.indexOf("_cw") !== -1 && dif < 0) { 23978 dif = ((dif + cap * 9999999999) % cap) - ((dif / cap) | 0) * cap; 23979 } else if (v.indexOf("ccw") !== -1 && dif > 0) { 23980 dif = ((dif - cap * 9999999999) % cap) - ((dif / cap) | 0) * cap; 23981 } 23982 } 23983 if (dif > min || dif < -min) { 23984 this._addTween(target, p, start, start + dif, p); 23985 this._overwriteProps.push(p); 23986 } 23987 } 23988 } 23989 return true; 23990 }, 23991 23992 //called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
23993 set: function(ratio) { 23994 var pt; 23995 if (ratio !== 1) { 23996 this._super.setRatio.call(this, ratio); 23997 } else { 23998 pt = this._firstPT; 23999 while (pt) { 24000 if (pt.f) { 24001 pt.t[pt.p](this.finals[pt.p]); 24002 } else { 24003 pt.t[pt.p] = this.finals[pt.p]; 24004 } 24005 pt = pt._next; 24006 } 24007 } 24008 } 24009 24010 })._autoCSS = true; 24011 24012 24013 24014 24015 24016 24017 24018 24019 24020 24021 24022/* 24023 * ---------------------------------------------------------------- 24024 * EasePack 24025 * ---------------------------------------------------------------- 24026 */ 24027 _gsScope._gsDefine("easing.Back", ["easing.Ease"], function(Ease) { 24028 24029 var w = (_gsScope.GreenSockGlobals || _gsScope), 24030 gs = w.com.greensock, 24031 _2PI = Math.PI * 2, 24032 _HALF_PI = Math.PI / 2, 24033 _class = gs._class, 24034 _create = function(n, f) { 24035 var C = _class("easing." + n, function(){}, true), 24036 p = C.prototype = new Ease(); 24037 p.constructor = C; 24038 p.getRatio = f; 24039 return C; 24040 }, 24041 _easeReg = Ease.register || function(){}, //put an empty function in place just as a safety measure in case someone loads an OLD version of TweenLite.js where Ease.register doesn't exist. 24042 _wrap = function(name, EaseOut, EaseIn, EaseInOut, aliases) { 24043 var C = _class("easing."+name, { 24044 easeOut:new EaseOut(), 24045 easeIn:new EaseIn(), 24046 easeInOut:new EaseInOut() 24047 }, true); 24048 _easeReg(C, name); 24049 return C; 24050 }, 24051 EasePoint = function(time, value, next) { 24052 this.t = time; 24053 this.v = value; 24054 if (next) { 24055 this.next = next; 24056 next.prev = this; 24057 this.c = next.v - value; 24058 this.gap = next.t - time; 24059 } 24060 }, 24061 24062 //Back 24063 _createBack = function(n, f) { 24064 var C = _class("easing." + n, function(overshoot) { 24065 this._p1 = (overshoot || overshoot === 0) ? overshoot : 1.70158; 24066 this._p2 = this._p1 * 1.525; 24067 }, true), 24068 p = C.prototype = new Ease(); 24069 p.constructor = C; 24070 p.getRatio = f; 24071 p.config = function(overshoot) { 24072 return new C(overshoot); 24073 }; 24074 return C; 24075 }, 24076 24077 Back = _wrap("Back", 24078 _createBack("BackOut", function(p) { 24079 return ((p = p - 1) * p * ((this._p1 + 1) * p + this._p1) + 1); 24080 }), 24081 _createBack("BackIn", function(p) { 24082 return p * p * ((this._p1 + 1) * p - this._p1); 24083 }), 24084 _createBack("BackInOut", function(p) { 24085 return ((p *= 2) < 1) ? 0.5 * p * p * ((this._p2 + 1) * p - this._p2) : 0.5 * ((p -= 2) * p * ((this._p2 + 1) * p + this._p2) + 2); 24086 }) 24087 ), 24088 24089 24090 //SlowMo 24091 SlowMo = _class("easing.SlowMo", function(linearRatio, power, yoyoMode) { 24092 power = (power || power === 0) ? power : 0.7; 24093 if (linearRatio == null) { 24094 linearRatio = 0.7; 24095 } else if (linearRatio > 1) { 24096 linearRatio = 1; 24097 } 24098 this._p = (linearRatio !== 1) ? power : 0; 24099 this._p1 = (1 - linearRatio) / 2; 24100 this._p2 = linearRatio; 24101 this._p3 = this._p1 + this._p2; 24102 this._calcEnd = (yoyoMode === true); 24103 }, true), 24104 p = SlowMo.prototype = new Ease(), 24105 SteppedEase, ExpoScaleEase, RoughEase, _createElastic; 24106 24107 p.constructor = SlowMo; 24108 p.getRatio = function(p) { 24109 var r = p + (0.5 - p) * this._p; 24110 if (p < this._p1) { 24111 return this._calcEnd ? 1 - ((p = 1 - (p / this._p1)) * p) : r - ((p = 1 - (p / this._p1)) * p * p * p * r); 24112 } else if (p > this._p3) { 24113 return this._calcEnd ? (p === 1 ? 0 : 1 - (p = (p - this._p3) / this._p1) * p) : r + ((p - r) * (p = (p - this._p3) / this._p1) * p * p * p); //added p === 1 ? 0 to avoid floating point rounding errors from affecting the final value, like 1 - 0.7 = 0.30000000000000004 instead of 0.3 24114 } 24115 return this._calcEnd ? 1 : r; 24116 }; 24117 SlowMo.ease = new SlowMo(0.7, 0.7); 24118 24119 p.config = SlowMo.config = function(linearRatio, power, yoyoMode) { 24120 return new SlowMo(linearRatio, power, yoyoMode); 24121 }; 24122 24123 24124 //SteppedEase 24125 SteppedEase = _class("easing.SteppedEase", function(steps, immediateStart) { 24126 steps = steps || 1; 24127 this._p1 = 1 / steps; 24128 this._p2 = steps + (immediateStart ? 0 : 1); 24129 this._p3 = immediateStart ? 1 : 0; 24130 }, true); 24131 p = SteppedEase.prototype = new Ease(); 24132 p.constructor = SteppedEase; 24133 p.getRatio = function(p) { 24134 if (p < 0) { 24135 p = 0; 24136 } else if (p >= 1) { 24137 p = 0.999999999; 24138 } 24139 return (((this._p2 * p) | 0) + this._p3) * this._p1; 24140 }; 24141 p.config = SteppedEase.config = function(steps, immediateStart) { 24142 return new SteppedEase(steps, immediateStart); 24143 }; 24144 24145 //ExpoScaleEase 24146 ExpoScaleEase = _class("easing.ExpoScaleEase", function(start, end, ease) { 24147 this._p1 = Math.log(end / start); 24148 this._p2 = end - start; 24149 this._p3 = start; 24150 this._ease = ease; 24151 }, true); 24152 p = ExpoScaleEase.prototype = new Ease(); 24153 p.constructor = ExpoScaleEase; 24154 p.getRatio = function(p) { 24155 if (this._ease) { 24156 p = this._ease.getRatio(p); 24157 } 24158 return (this._p3 * Math.exp(this._p1 * p) - this._p3) / this._p2; 24159 }; 24160 p.config = ExpoScaleEase.config = function(start, end, ease) { 24161 return new ExpoScaleEase(start, end, ease); 24162 }; 24163 24164 24165 //RoughEase 24166 RoughEase = _class("easing.RoughEase", function(vars) { 24167 vars = vars || {}; 24168 var taper = vars.taper || "none", 24169 a = [], 24170 cnt = 0, 24171 points = (vars.points || 20) | 0, 24172 i = points, 24173 randomize = (vars.randomize !== false), 24174 clamp = (vars.clamp === true), 24175 template = (vars.template instanceof Ease) ? vars.template : null,
24176 strength = (typeof(vars.strength) === "number") ? vars.strength * 0.4 : 0.4, 24177 x, y, bump, invX, obj, pnt; 24178 while (--i > -1) { 24179 x = randomize ? Math.random() : (1 / points) * i; 24180 y = template ? template.getRatio(x) : x; 24181 if (taper === "none") { 24182 bump = strength; 24183 } else if (taper === "out") { 24184 invX = 1 - x; 24185 bump = invX * invX * strength; 24186 } else if (taper === "in") { 24187 bump = x * x * strength; 24188 } else if (x < 0.5) { //"both" (start) 24189 invX = x * 2; 24190 bump = invX * invX * 0.5 * strength; 24191 } else { //"both" (end) 24192 invX = (1 - x) * 2; 24193 bump = invX * invX * 0.5 * strength; 24194 } 24195 if (randomize) { 24196 y += (Math.random() * bump) - (bump * 0.5); 24197 } else if (i % 2) { 24198 y += bump * 0.5; 24199 } else { 24200 y -= bump * 0.5; 24201 } 24202 if (clamp) { 24203 if (y > 1) { 24204 y = 1; 24205 } else if (y < 0) { 24206 y = 0; 24207 } 24208 } 24209 a[cnt++] = {x:x, y:y}; 24210 } 24211 a.sort(function(a, b) { 24212 return a.x - b.x; 24213 }); 24214 24215 pnt = new EasePoint(1, 1, null); 24216 i = points; 24217 while (--i > -1) { 24218 obj = a[i]; 24219 pnt = new EasePoint(obj.x, obj.y, pnt); 24220 } 24221 24222 this._prev = new EasePoint(0, 0, (pnt.t !== 0) ? pnt : pnt.next); 24223 }, true); 24224 p = RoughEase.prototype = new Ease(); 24225 p.constructor = RoughEase; 24226 p.getRatio = function(p) { 24227 var pnt = this._prev; 24228 if (p > pnt.t) { 24229 while (pnt.next && p >= pnt.t) { 24230 pnt = pnt.next; 24231 } 24232 pnt = pnt.prev; 24233 } else { 24234 while (pnt.prev && p <= pnt.t) { 24235 pnt = pnt.prev; 24236 } 24237 } 24238 this._prev = pnt; 24239 return (pnt.v + ((p - pnt.t) / pnt.gap) * pnt.c); 24240 }; 24241 p.config = function(vars) { 24242 return new RoughEase(vars); 24243 }; 24244 RoughEase.ease = new RoughEase(); 24245 24246 24247 //Bounce 24248 _wrap("Bounce", 24249 _create("BounceOut", function(p) { 24250 if (p < 1 / 2.75) { 24251 return 7.5625 * p * p; 24252 } else if (p < 2 / 2.75) { 24253 return 7.5625 * (p -= 1.5 / 2.75) * p + 0.75; 24254 } else if (p < 2.5 / 2.75) { 24255 return 7.5625 * (p -= 2.25 / 2.75) * p + 0.9375; 24256 } 24257 return 7.5625 * (p -= 2.625 / 2.75) * p + 0.984375; 24258 }), 24259 _create("BounceIn", function(p) { 24260 if ((p = 1 - p) < 1 / 2.75) { 24261 return 1 - (7.5625 * p * p); 24262 } else if (p < 2 / 2.75) { 24263 return 1 - (7.5625 * (p -= 1.5 / 2.75) * p + 0.75); 24264 } else if (p < 2.5 / 2.75) { 24265 return 1 - (7.5625 * (p -= 2.25 / 2.75) * p + 0.9375); 24266 } 24267 return 1 - (7.5625 * (p -= 2.625 / 2.75) * p + 0.984375); 24268 }), 24269 _create("BounceInOut", function(p) { 24270 var invert = (p < 0.5); 24271 if (invert) { 24272 p = 1 - (p * 2); 24273 } else { 24274 p = (p * 2) - 1; 24275 } 24276 if (p < 1 / 2.75) { 24277 p = 7.5625 * p * p; 24278 } else if (p < 2 / 2.75) { 24279 p = 7.5625 * (p -= 1.5 / 2.75) * p + 0.75; 24280 } else if (p < 2.5 / 2.75) { 24281 p = 7.5625 * (p -= 2.25 / 2.75) * p + 0.9375; 24282 } else { 24283 p = 7.5625 * (p -= 2.625 / 2.75) * p + 0.984375; 24284 } 24285 return invert ? (1 - p) * 0.5 : p * 0.5 + 0.5; 24286 }) 24287 ); 24288 24289 24290 //CIRC 24291 _wrap("Circ", 24292 _create("CircOut", function(p) { 24293 return Math.sqrt(1 - (p = p - 1) * p); 24294 }), 24295 _create("CircIn", function(p) { 24296 return -(Math.sqrt(1 - (p * p)) - 1); 24297 }), 24298 _create("CircInOut", function(p) { 24299 return ((p*=2) < 1) ? -0.5 * (Math.sqrt(1 - p * p) - 1) : 0.5 * (Math.sqrt(1 - (p -= 2) * p) + 1); 24300 }) 24301 ); 24302 24303 24304 //Elastic 24305 _createElastic = function(n, f, def) { 24306 var C = _class("easing." + n, function(amplitude, period) { 24307 this._p1 = (amplitude >= 1) ? amplitude : 1; //note: if amplitude is < 1, we simply adjust the period for a more natural feel. Otherwise the math doesn't work right and the curve starts at 1. 24308 this._p2 = (period || def) / (amplitude < 1 ? amplitude : 1); 24309 this._p3 = this._p2 / _2PI * (Math.asin(1 / this._p1) || 0); 24310 this._p2 = _2PI / this._p2; //precalculate to optimize 24311 }, true), 24312 p = C.prototype = new Ease(); 24313 p.constructor = C; 24314 p.getRatio = f; 24315 p.config = function(amplitude, period) { 24316 return new C(amplitude, period); 24317 }; 24318 return C; 24319 }; 24320 _wrap("Elastic", 24321 _createElastic("ElasticOut", function(p) { 24322 return this._p1 * Math.pow(2, -10 * p) * Math.sin( (p - this._p3) * this._p2 ) + 1; 24323 }, 0.3), 24324 _createElastic("ElasticIn", function(p) { 24325 return -(this._p1 * Math.pow(2, 10 * (p -= 1)) * Math.sin( (p - this._p3) * this._p2 )); 24326 }, 0.3), 24327 _createElastic("ElasticInOut", function(p) { 24328 return ((p *= 2) < 1) ? -0.5 * (this._p1 * Math.pow(2, 10 * (p -= 1)) * Math.sin( (p - this._p3) * this._p2)) : this._p1 * Math.pow(2, -10 *(p -= 1)) * Math.sin( (p - this._p3) * this._p2 ) * 0.5 + 1; 24329 }, 0.45) 24330 ); 24331 24332 24333 //Expo 24334 _wrap("Expo", 24335 _create("ExpoOut", function(p) { 24336 return 1 - Math.pow(2, -10 * p); 24337 }), 24338 _create("ExpoIn", function(p) { 24339 return Math.pow(2, 10 * (p - 1)) - 0.001; 24340 }), 24341 _create("ExpoInOut", function(p) { 24342 return ((p *= 2) < 1) ? 0.5 * Math.pow(2, 10 * (p - 1)) : 0.5 * (2 - Math.pow(2, -10 * (p - 1))); 24343 }) 24344 ); 24345 24346 24347 //Sine 24348 _wrap("Sine", 24349 _create("SineOut", function(p) { 24350 return Math.sin(p * _HALF_PI); 24351 }), 24352 _create("SineIn", function(p) { 24353 return -Math.cos(p * _HALF_PI) + 1; 24354 }), 24355 _create("SineInOut", function(p) { 24356 return -0.5 * (Math.cos(Math.PI * p) - 1); 24357 }) 24358 ); 24359 24360 _class("easing.EaseLookup", { 24361 find:function(s) { 24362 return Ease.map[s]; 24363 } 24364 }, true); 24365 24366 //register the non-standard eases 24367 _easeReg(w.SlowMo, "SlowMo", "ease,"); 24368 _easeReg(RoughEase, "RoughEase", "ease,");
24369 _easeReg(SteppedEase, "SteppedEase", "ease,"); 24370 24371 return Back; 24372 24373 }, true); 24374 24375 24376}); 24377 24378if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); } //necessary in case TweenLite was already loaded separately. 24379 24380 24381 24382 24383 24384 24385 24386 24387 24388 24389 24390/* 24391 * ---------------------------------------------------------------- 24392 * Base classes like TweenLite, SimpleTimeline, Ease, Ticker, etc. 24393 * ---------------------------------------------------------------- 24394 */ 24395(function(window, moduleName) { 24396 24397 "use strict"; 24398 var _exports = {}, 24399 _doc = window.document, 24400 _globals = window.GreenSockGlobals = window.GreenSockGlobals || window, 24401 existingModule = _globals[moduleName]; 24402 if (existingModule) { 24403 if (typeof(module) !== "undefined" && module.exports) { //node 24404 module.exports = existingModule; 24405 } 24406 return existingModule; //in case the core set of classes is already loaded, don't instantiate twice. 24407 } 24408 var _namespace = function(ns) { 24409 var a = ns.split("."), 24410 p = _globals, i; 24411 for (i = 0; i < a.length; i++) { 24412 p[a[i]] = p = p[a[i]] || {}; 24413 } 24414 return p; 24415 }, 24416 gs = _namespace("com.greensock"), 24417 _tinyNum = 0.0000000001, 24418 _slice = function(a) { //don't use Array.prototype.slice.call(target, 0) because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll() 24419 var b = [], 24420 l = a.length, 24421 i; 24422 for (i = 0; i !== l; b.push(a[i++])) {} 24423 return b; 24424 }, 24425 _emptyFunc = function() {}, 24426 _isArray = (function() { //works around issues in iframe environments where the Array global isn't shared, thus if the object originates in a different window/iframe, "(obj instanceof Array)" will evaluate false. We added some speed optimizations to avoid Object.prototype.toString.call() unless it's absolutely necessary because it's VERY slow (like 20x slower) 24427 var toString = Object.prototype.toString, 24428 array = toString.call([]); 24429 return function(obj) { 24430 return obj != null && (obj instanceof Array || (typeof(obj) === "object" && !!obj.push && toString.call(obj) === array)); 24431 }; 24432 }()), 24433 a, i, p, _ticker, _tickerActive, 24434 _defLookup = {}, 24435 24436 /** 24437 * @constructor 24438 * Defines a GreenSock class, optionally with an array of dependencies that must be instantiated first and passed into the definition. 24439 * This allows users to load GreenSock JS files in any order even if they have interdependencies (like CSSPlugin extends TweenPlugin which is 24440 * inside TweenLite.js, but if CSSPlugin is loaded first, it should wait to run its code until TweenLite.js loads and instantiates TweenPlugin 24441 * and then pass TweenPlugin to CSSPlugin's definition). This is all done automatically and internally. 24442 * 24443 * Every definition will be added to a "com.greensock" global object (typically window, but if a window.GreenSockGlobals object is found, 24444 * it will go there as of v1.7). For example, TweenLite will be found at window.com.greensock.TweenLite and since it's a global class that should be available anywhere, 24445 * it is ALSO referenced at window.TweenLite. However some classes aren't considered global, like the base com.greensock.core.Animation class, so 24446 * those will only be at the package like window.com.greensock.core.Animation. Again, if you define a GreenSockGlobals object on the window, everything 24447 * gets tucked neatly inside there instead of on the window directly. This allows you to do advanced things like load multiple versions of GreenSock 24448 * files and put them into distinct objects (imagine a banner ad uses a newer version but the main site uses an older one). In that case, you could 24449 * sandbox the banner one like: 24450 * 24451 * <script> 24452 * var gs = window.GreenSockGlobals = {}; //the newer version we're about to load could now be referenced in a "gs" object, like gs.TweenLite.to(...). Use whatever alias you want as long as it's unique, "gs" or "banner" or whatever. 24453 * </script> 24454 * <script src="js/greensock/v1.7/TweenMax.js"></script> 24455 * <script> 24456 * window.GreenSockGlobals = window._gsQueue = window._gsDefine = null; //reset it back to null (along with the special _gsQueue variable) so that the next load of TweenMax affects the window and we can reference things directly like TweenLite.to(...) 24457 * </script> 24458 * <script src="js/greensock/v1.6/TweenMax.js"></script> 24459 * <script> 24460 * gs.TweenLite.to(...); //would use v1.7 24461 * TweenLite.to(...); //would use v1.6 24462 * </script> 24463 * 24464 * @param {!string} ns The namespace of the class definition, leaving off "com.greensock." as that's assumed. For example, "TweenLite" or "plugins.CSSPlugin" or "easing.Back". 24465 * @param {!Array.<string>}
24465 dependencies An array of dependencies (described as their namespaces minus "com.greensock." prefix). For example ["TweenLite","plugins.TweenPlugin","core.Animation"] 24466 * @param {!function():Object} func The function that should be called and passed the resolved dependencies which will return the actual class for this definition. 24467 * @param {boolean=} global If true, the class will be added to the global scope (typically window unless you define a window.GreenSockGlobals object) 24468 */ 24469 Definition = function(ns, dependencies, func, global) { 24470 this.sc = (_defLookup[ns]) ? _defLookup[ns].sc : []; //subclasses 24471 _defLookup[ns] = this; 24472 this.gsClass = null; 24473 this.func = func; 24474 var _classes = []; 24475 this.check = function(init) { 24476 var i = dependencies.length, 24477 missing = i, 24478 cur, a, n, cl; 24479 while (--i > -1) { 24480 if ((cur = _defLookup[dependencies[i]] || new Definition(dependencies[i], [])).gsClass) { 24481 _classes[i] = cur.gsClass; 24482 missing--; 24483 } else if (init) { 24484 cur.sc.push(this); 24485 } 24486 } 24487 if (missing === 0 && func) { 24488 a = ("com.greensock." + ns).split("."); 24489 n = a.pop(); 24490 cl = _namespace(a.join("."))[n] = this.gsClass = func.apply(func, _classes); 24491 24492 //exports to multiple environments 24493 if (global) { 24494 _globals[n] = _exports[n] = cl; //provides a way to avoid global namespace pollution. By default, the main classes like TweenLite, Power1, Strong, etc. are added to window unless a GreenSockGlobals is defined. So if you want to have things added to a custom object instead, just do something like window.GreenSockGlobals = {} before loading any GreenSock files. You can even set up an alias like window.GreenSockGlobals = windows.gs = {} so that you can access everything like gs.TweenLite. Also remember that ALL classes are added to the window.com.greensock object (in their respective packages, like com.greensock.easing.Power1, com.greensock.TweenLite, etc.) 24495 if (typeof(module) !== "undefined" && module.exports) { //node 24496 if (ns === moduleName) { 24497 module.exports = _exports[moduleName] = cl; 24498 for (i in _exports) { 24499 cl[i] = _exports[i]; 24500 } 24501 } else if (_exports[moduleName]) { 24502 _exports[moduleName][n] = cl; 24503 } 24504 } else if (typeof(define) === "function" && define.amd){ //AMD 24505 define((window.GreenSockAMDPath ? window.GreenSockAMDPath + "/" : "") + ns.split(".").pop(), [], function() { return cl; }); 24506 } 24507 } 24508 for (i = 0; i < this.sc.length; i++) { 24509 this.sc[i].check(); 24510 } 24511 } 24512 }; 24513 this.check(true); 24514 }, 24515 24516 //used to create Definition instances (which basically registers a class that has dependencies). 24517 _gsDefine = window._gsDefine = function(ns, dependencies, func, global) { 24518 return new Definition(ns, dependencies, func, global); 24519 }, 24520 24521 //a quick way to create a class that doesn't have any dependencies. Returns the class, but first registers it in the GreenSock namespace so that other classes can grab it (other classes might be dependent on the class). 24522 _class = gs._class = function(ns, func, global) { 24523 func = func || function() {}; 24524 _gsDefine(ns, [], function(){ return func; }, global); 24525 return func; 24526 }; 24527 24528 _gsDefine.globals = _globals; 24529 24530 24531 24532/* 24533 * ---------------------------------------------------------------- 24534 * Ease 24535 * ---------------------------------------------------------------- 24536 */ 24537 var _baseParams = [0, 0, 1, 1], 24538 Ease = _class("easing.Ease", function(func, extraParams, type, power) { 24539 this._func = func; 24540 this._type = type || 0; 24541 this._power = power || 0; 24542 this._params = extraParams ? _baseParams.concat(extraParams) : _baseParams; 24543 }, true), 24544 _easeMap = Ease.map = {}, 24545 _easeReg = Ease.register = function(ease, names, types, create) { 24546 var na = names.split(","), 24547 i = na.length, 24548 ta = (types || "easeIn,easeOut,easeInOut").split(","), 24549 e, name, j, type; 24550 while (--i > -1) { 24551 name = na[i]; 24552 e = create ? _class("easing."+name, null, true) : gs.easing[name] || {}; 24553 j = ta.length; 24554 while (--j > -1) { 24555 type = ta[j]; 24556 _easeMap[name + "." + type] = _easeMap[type + name] = e[type] = ease.getRatio ? ease : ease[type] || new ease(); 24557 } 24558 } 24559 }; 24560 24561 p = Ease.prototype; 24562 p._calcEnd = false;
24563 p.getRatio = function(p) { 24564 if (this._func) { 24565 this._params[0] = p; 24566 return this._func.apply(null, this._params); 24567 } 24568 var t = this._type, 24569 pw = this._power, 24570 r = (t === 1) ? 1 - p : (t === 2) ? p : (p < 0.5) ? p * 2 : (1 - p) * 2; 24571 if (pw === 1) { 24572 r *= r; 24573 } else if (pw === 2) { 24574 r *= r * r; 24575 } else if (pw === 3) { 24576 r *= r * r * r; 24577 } else if (pw === 4) { 24578 r *= r * r * r * r; 24579 } 24580 return (t === 1) ? 1 - r : (t === 2) ? r : (p < 0.5) ? r / 2 : 1 - (r / 2); 24581 }; 24582 24583 //create all the standard eases like Linear, Quad, Cubic, Quart, Quint, Strong, Power0, Power1, Power2, Power3, and Power4 (each with easeIn, easeOut, and easeInOut) 24584 a = ["Linear","Quad","Cubic","Quart","Quint,Strong"]; 24585 i = a.length; 24586 while (--i > -1) { 24587 p = a[i]+",Power"+i; 24588 _easeReg(new Ease(null,null,1,i), p, "easeOut", true); 24589 _easeReg(new Ease(null,null,2,i), p, "easeIn" + ((i === 0) ? ",easeNone" : "")); 24590 _easeReg(new Ease(null,null,3,i), p, "easeInOut"); 24591 } 24592 _easeMap.linear = gs.easing.Linear.easeIn; 24593 _easeMap.swing = gs.easing.Quad.easeInOut; //for jQuery folks 24594 24595 24596/* 24597 * ---------------------------------------------------------------- 24598 * EventDispatcher 24599 * ---------------------------------------------------------------- 24600 */ 24601 var EventDispatcher = _class("events.EventDispatcher", function(target) { 24602 this._listeners = {}; 24603 this._eventTarget = target || this; 24604 }); 24605 p = EventDispatcher.prototype; 24606 24607 p.addEventListener = function(type, callback, scope, useParam, priority) { 24608 priority = priority || 0; 24609 var list = this._listeners[type], 24610 index = 0, 24611 listener, i; 24612 if (this === _ticker && !_tickerActive) { 24613 _ticker.wake(); 24614 } 24615 if (list == null) { 24616 this._listeners[type] = list = []; 24617 } 24618 i = list.length; 24619 while (--i > -1) { 24620 listener = list[i]; 24621 if (listener.c === callback && listener.s === scope) { 24622 list.splice(i, 1); 24623 } else if (index === 0 && listener.pr < priority) { 24624 index = i + 1; 24625 } 24626 } 24627 list.splice(index, 0, {c:callback, s:scope, up:useParam, pr:priority}); 24628 }; 24629 24630 p.removeEventListener = function(type, callback) { 24631 var list = this._listeners[type], i; 24632 if (list) { 24633 i = list.length; 24634 while (--i > -1) { 24635 if (list[i].c === callback) { 24636 list.splice(i, 1); 24637 return; 24638 } 24639 } 24640 } 24641 }; 24642 24643 p.dispatchEvent = function(type) { 24644 var list = this._listeners[type], 24645 i, t, listener; 24646 if (list) { 24647 i = list.length; 24648 if (i > 1) { 24649 list = list.slice(0); //in case addEventListener() is called from within a listener/callback (otherwise the index could change, resulting in a skip) 24650 } 24651 t = this._eventTarget; 24652 while (--i > -1) { 24653 listener = list[i]; 24654 if (listener) { 24655 if (listener.up) { 24656 listener.c.call(listener.s || t, {type:type, target:t}); 24657 } else { 24658 listener.c.call(listener.s || t); 24659 } 24660 } 24661 } 24662 } 24663 }; 24664 24665 24666/* 24667 * ---------------------------------------------------------------- 24668 * Ticker 24669 * ---------------------------------------------------------------- 24670 */ 24671 var _reqAnimFrame = window.requestAnimationFrame, 24672 _cancelAnimFrame = window.cancelAnimationFrame, 24673 _getTime = Date.now || function() {return new Date().getTime();}, 24674 _lastUpdate = _getTime(); 24675 24676 //now try to determine the requestAnimationFrame and cancelAnimationFrame functions and if none are found, we'll use a setTimeout()/clearTimeout() polyfill. 24677 a = ["ms","moz","webkit","o"]; 24678 i = a.length; 24679 while (--i > -1 && !_reqAnimFrame) { 24680 _reqAnimFrame = window[a[i] + "RequestAnimationFrame"]; 24681 _cancelAnimFrame = window[a[i] + "CancelAnimationFrame"] || window[a[i] + "CancelRequestAnimationFrame"]; 24682 } 24683 24684 _class("Ticker", function(fps, useRAF) { 24685 var _self = this, 24686 _startTime = _getTime(), 24687 _useRAF = (useRAF !== false && _reqAnimFrame) ? "auto" : false, 24688 _lagThreshold = 500, 24689 _adjustedLag = 33, 24690 _tickWord = "tick", //helps reduce gc burden 24691 _fps, _req, _id, _gap, _nextTime, 24692 _tick = function(manual) { 24693 var elapsed = _getTime() - _lastUpdate, 24694 overlap, dispatch; 24695 if (elapsed > _lagThreshold) { 24696 _startTime += elapsed - _adjustedLag; 24697 } 24698 _lastUpdate += elapsed; 24699 _self.time = (_lastUpdate - _startTime) / 1000; 24700 overlap = _self.time - _nextTime; 24701 if (!_fps || overlap > 0 || manual === true) { 24702 _self.frame++; 24703 _nextTime += overlap + (overlap >= _gap ? 0.004 : _gap - overlap); 24704 dispatch = true; 24705 } 24706 if (manual !== true) { //make sure the request is made before we dispatch the "tick" event so that timing is maintained. Otherwise, if processing the "tick" requires a bunch of time (like 15ms) and we're using a setTimeout() that's based on 16.7ms, it'd technically take 31.7ms between frames otherwise. 24707 _id = _req(_tick); 24708 }
24709 if (dispatch) { 24710 _self.dispatchEvent(_tickWord); 24711 } 24712 }; 24713 24714 EventDispatcher.call(_self); 24715 _self.time = _self.frame = 0; 24716 _self.tick = function() { 24717 _tick(true); 24718 }; 24719 24720 _self.lagSmoothing = function(threshold, adjustedLag) { 24721 if (!arguments.length) { //if lagSmoothing() is called with no arguments, treat it like a getter that returns a boolean indicating if it's enabled or not. This is purposely undocumented and is for internal use. 24722 return (_lagThreshold < 1 / _tinyNum); 24723 } 24724 _lagThreshold = threshold || (1 / _tinyNum); //zero should be interpreted as basically unlimited 24725 _adjustedLag = Math.min(adjustedLag, _lagThreshold, 0); 24726 }; 24727 24728 _self.sleep = function() { 24729 if (_id == null) { 24730 return; 24731 } 24732 if (!_useRAF || !_cancelAnimFrame) { 24733 clearTimeout(_id); 24734 } else { 24735 _cancelAnimFrame(_id); 24736 } 24737 _req = _emptyFunc; 24738 _id = null; 24739 if (_self === _ticker) { 24740 _tickerActive = false; 24741 } 24742 }; 24743 24744 _self.wake = function(seamless) { 24745 if (_id !== null) { 24746 _self.sleep(); 24747 } else if (seamless) { 24748 _startTime += -_lastUpdate + (_lastUpdate = _getTime()); 24749 } else if (_self.frame > 10) { //don't trigger lagSmoothing if we're just waking up, and make sure that at least 10 frames have elapsed because of the iOS bug that we work around below with the 1.5-second setTimout(). 24750 _lastUpdate = _getTime() - _lagThreshold + 5; 24751 } 24752 _req = (_fps === 0) ? _emptyFunc : (!_useRAF || !_reqAnimFrame) ? function(f) { return setTimeout(f, ((_nextTime - _self.time) * 1000 + 1) | 0); } : _reqAnimFrame; 24753 if (_self === _ticker) { 24754 _tickerActive = true; 24755 } 24756 _tick(2); 24757 }; 24758 24759 _self.fps = function(value) { 24760 if (!arguments.length) { 24761 return _fps; 24762 } 24763 _fps = value; 24764 _gap = 1 / (_fps || 60); 24765 _nextTime = this.time + _gap; 24766 _self.wake(); 24767 }; 24768 24769 _self.useRAF = function(value) { 24770 if (!arguments.length) { 24771 return _useRAF; 24772 } 24773 _self.sleep(); 24774 _useRAF = value; 24775 _self.fps(_fps); 24776 }; 24777 _self.fps(fps); 24778 24779 //a bug in iOS 6 Safari occasionally prevents the requestAnimationFrame from working initially, so we use a 1.5-second timeout that automatically falls back to setTimeout() if it senses this condition. 24780 setTimeout(function() { 24781 if (_useRAF === "auto" && _self.frame < 5 && (_doc || {}).visibilityState !== "hidden") { 24782 _self.useRAF(false); 24783 } 24784 }, 1500); 24785 }); 24786 24787 p = gs.Ticker.prototype = new gs.events.EventDispatcher(); 24788 p.constructor = gs.Ticker; 24789 24790 24791/* 24792 * ---------------------------------------------------------------- 24793 * Animation 24794 * ---------------------------------------------------------------- 24795 */ 24796 var Animation = _class("core.Animation", function(duration, vars) { 24797 this.vars = vars = vars || {}; 24798 this._duration = this._totalDuration = duration || 0; 24799 this._delay = Number(vars.delay) || 0; 24800 this._timeScale = 1; 24801 this._active = (vars.immediateRender === true); 24802 this.data = vars.data; 24803 this._reversed = (vars.reversed === true); 24804 24805 if (!_rootTimeline) { 24806 return; 24807 } 24808 if (!_tickerActive) { //some browsers (like iOS 6 Safari) shut down JavaScript execution when the tab is disabled and they [occasionally] neglect to start up requestAnimationFrame again when returning - this code ensures that the engine starts up again properly. 24809 _ticker.wake(); 24810 } 24811 24812 var tl = this.vars.useFrames ? _rootFramesTimeline : _rootTimeline; 24813 tl.add(this, tl._time); 24814 24815 if (this.vars.paused) { 24816 this.paused(true); 24817 } 24818 }); 24819 24820 _ticker = Animation.ticker = new gs.Ticker(); 24821 p = Animation.prototype; 24822 p._dirty = p._gc = p._initted = p._paused = false; 24823 p._totalTime = p._time = 0; 24824 p._rawPrevTime = -1; 24825 p._next = p._last = p._onUpdate = p._timeline = p.timeline = null; 24826 p._paused = false; 24827 24828 24829 //some browsers (like iOS) occasionally drop the requestAnimationFrame event when the user switches to a different tab and then comes back again, so we use a 2-second setTimeout() to sense if/when that condition occurs and then wake() the ticker. 24830 var _checkTimeout = function() { 24831 if (_tickerActive && _getTime() - _lastUpdate > 2000 && ((_doc || {}).visibilityState !== "hidden" || !_ticker.lagSmoothing())) { //note: if the tab is hidden, we should still wake if lagSmoothing has been disabled. 24832 _ticker.wake(); 24833 } 24834 var t = setTimeout(_checkTimeout, 2000); 24835 if (t.unref) { 24836 // allows a node process to exit even if the timeout’s callback hasn't been invoked. Without it, the node process could hang as this function is called every two seconds. 24837 t.unref(); 24838 } 24839 }; 24840 _checkTimeout(); 24841 24842 24843 p.play = function(from, suppressEvents) { 24844 if (from != null) { 24845 this.seek(from, suppressEvents); 24846 } 24847 return this.reversed(false).paused(false); 24848 }; 24849 24850 p.pause = function(atTime, suppressEvents) { 24851 if (atTime != null) { 24852 this.seek(atTime, suppressEvents); 24853 } 24854 return this.paused(true); 24855 }; 24856 24857 p.resume = function(from, suppressEvents) { 24858 if (from != null) { 24859 this.seek(from, suppressEvents); 24860 } 24861 return this.paused(false); 24862 }; 24863 24864 p.seek = function(time, suppressEvents) { 24865 return this.totalTime(Number(time), suppressEvents !== false); 24866 }; 24867 24868 p.restart = function(includeDelay, suppressEvents) { 24869 return this.reversed(false).paused(false).totalTime(includeDelay ? -this._delay : 0, (suppressEvents !== false), true); 24870 }; 24871 24872 p.reverse = function(from, suppressEvents) { 24873 if (from != null) { 24874 this.seek((from || this.totalDuration()), suppressEvents); 24875 } 24876 return this.reversed(true).paused(false); 24877 }; 24878 24879 p.render = function(time, suppressEvents, force) { 24880 //stub - we override this method in subclasses. 24881 }; 24882 24883 p.invalidate = function() { 24884 this._time = this._totalTime = 0; 24885 this._initted = this._gc = false;
24886 this._rawPrevTime = -1; 24887 if (this._gc || !this.timeline) { 24888 this._enabled(true); 24889 } 24890 return this; 24891 }; 24892 24893 p.isActive = function() { 24894 var tl = this._timeline, //the 2 root timelines won't have a _timeline; they're always active. 24895 startTime = this._startTime, 24896 rawTime; 24897 return (!tl || (!this._gc && !this._paused && tl.isActive() && (rawTime = tl.rawTime(true)) >= startTime && rawTime < startTime + this.totalDuration() / this._timeScale - 0.0000001)); 24898 }; 24899 24900 p._enabled = function (enabled, ignoreTimeline) { 24901 if (!_tickerActive) { 24902 _ticker.wake(); 24903 } 24904 this._gc = !enabled; 24905 this._active = this.isActive(); 24906 if (ignoreTimeline !== true) { 24907 if (enabled && !this.timeline) { 24908 this._timeline.add(this, this._startTime - this._delay); 24909 } else if (!enabled && this.timeline) { 24910 this._timeline._remove(this, true); 24911 } 24912 } 24913 return false; 24914 }; 24915 24916 24917 p._kill = function(vars, target) { 24918 return this._enabled(false, false); 24919 }; 24920 24921 p.kill = function(vars, target) { 24922 this._kill(vars, target); 24923 return this; 24924 }; 24925 24926 p._uncache = function(includeSelf) { 24927 var tween = includeSelf ? this : this.timeline; 24928 while (tween) { 24929 tween._dirty = true; 24930 tween = tween.timeline; 24931 } 24932 return this; 24933 }; 24934 24935 p._swapSelfInParams = function(params) { 24936 var i = params.length, 24937 copy = params.concat(); 24938 while (--i > -1) { 24939 if (params[i] === "{self}") { 24940 copy[i] = this; 24941 } 24942 } 24943 return copy; 24944 }; 24945 24946 p._callback = function(type) { 24947 var v = this.vars, 24948 callback = v[type], 24949 params = v[type + "Params"], 24950 scope = v[type + "Scope"] || v.callbackScope || this, 24951 l = params ? params.length : 0; 24952 switch (l) { //speed optimization; call() is faster than apply() so use it when there are only a few parameters (which is by far most common). Previously we simply did var v = this.vars; v[type].apply(v[type + "Scope"] || v.callbackScope || this, v[type + "Params"] || _blankArray); 24953 case 0: callback.call(scope); break; 24954 case 1: callback.call(scope, params[0]); break; 24955 case 2: callback.call(scope, params[0], params[1]); break; 24956 default: callback.apply(scope, params); 24957 } 24958 }; 24959 24960//----Animation getters/setters -------------------------------------------------------- 24961 24962 p.eventCallback = function(type, callback, params, scope) { 24963 if ((type || "").substr(0,2) === "on") { 24964 var v = this.vars; 24965 if (arguments.length === 1) { 24966 return v[type]; 24967 } 24968 if (callback == null) { 24969 delete v[type]; 24970 } else { 24971 v[type] = callback; 24972 v[type + "Params"] = (_isArray(params) && params.join("").indexOf("{self}") !== -1) ? this._swapSelfInParams(params) : params; 24973 v[type + "Scope"] = scope; 24974 } 24975 if (type === "onUpdate") { 24976 this._onUpdate = callback; 24977 } 24978 } 24979 return this; 24980 }; 24981 24982 p.delay = function(value) { 24983 if (!arguments.length) { 24984 return this._delay; 24985 } 24986 if (this._timeline.smoothChildTiming) { 24987 this.startTime( this._startTime + value - this._delay ); 24988 } 24989 this._delay = value; 24990 return this; 24991 }; 24992 24993 p.duration = function(value) { 24994 if (!arguments.length) { 24995 this._dirty = false; 24996 return this._duration; 24997 } 24998 this._duration = this._totalDuration = value; 24999 this._uncache(true); //true in case it's a TweenMax or TimelineMax that has a repeat - we'll need to refresh the totalDuration. 25000 if (this._timeline.smoothChildTiming) if (this._time > 0) if (this._time < this._duration) if (value !== 0) { 25001 this.totalTime(this._totalTime * (value / this._duration), true); 25002 } 25003 return this; 25004 }; 25005 25006 p.totalDuration = function(value) { 25007 this._dirty = false; 25008 return (!arguments.length) ? this._totalDuration : this.duration(value); 25009 }; 25010 25011 p.time = function(value, suppressEvents) { 25012 if (!arguments.length) { 25013 return this._time; 25014 } 25015 if (this._dirty) { 25016 this.totalDuration(); 25017 } 25018 return this.totalTime((value > this._duration) ? this._duration : value, suppressEvents); 25019 }; 25020 25021 p.totalTime = function(time, suppressEvents, uncapped) { 25022 if (!_tickerActive) { 25023 _ticker.wake(); 25024 } 25025 if (!arguments.length) { 25026 return this._totalTime; 25027 } 25028 if (this._timeline) { 25029 if (time < 0 && !uncapped) { 25030 time += this.totalDuration(); 25031 } 25032 if (this._timeline.smoothChildTiming) { 25033 if (this._dirty) { 25034 this.totalDuration(); 25035 } 25036 var totalDuration = this._totalDuration, 25037 tl = this._timeline; 25038 if (time > totalDuration && !uncapped) { 25039 time = totalDuration; 25040 } 25041 this._startTime = (this._paused ? this._pauseTime : tl._time) - ((!this._reversed ? time : totalDuration - time) / this._timeScale); 25042 if (!tl._dirty) { //for performance improvement. If the parent's cache is already dirty, it already took care of marking the ancestors as dirty too, so skip the function call here. 25043 this._uncache(false); 25044 } 25045 //in case any of the ancestor timelines had completed but should now be enabled, we should reset the
25045ir totalTime() which will also ensure that they're lined up properly and enabled. Skip for animations that are on the root (wasteful). Example: a TimelineLite.exportRoot() is performed when there's a paused tween on the root, the export will not complete until that tween is unpaused, but imagine a child gets restarted later, after all [unpaused] tweens have completed. The startTime of that child would get pushed out, but one of the ancestors may have completed. 25046 if (tl._timeline) { 25047 while (tl._timeline) { 25048 if (tl._timeline._time !== (tl._startTime + tl._totalTime) / tl._timeScale) { 25049 tl.totalTime(tl._totalTime, true); 25050 } 25051 tl = tl._timeline; 25052 } 25053 } 25054 } 25055 if (this._gc) { 25056 this._enabled(true, false); 25057 } 25058 if (this._totalTime !== time || this._duration === 0) { 25059 if (_lazyTweens.length) { 25060 _lazyRender(); 25061 } 25062 this.render(time, suppressEvents, false); 25063 if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when someone calls seek() or time() or progress(), they expect an immediate render. 25064 _lazyRender(); 25065 } 25066 } 25067 } 25068 return this; 25069 }; 25070 25071 p.progress = p.totalProgress = function(value, suppressEvents) { 25072 var duration = this.duration(); 25073 return (!arguments.length) ? (duration ? this._time / duration : this.ratio) : this.totalTime(duration * value, suppressEvents); 25074 }; 25075 25076 p.startTime = function(value) { 25077 if (!arguments.length) { 25078 return this._startTime; 25079 } 25080 if (value !== this._startTime) { 25081 this._startTime = value; 25082 if (this.timeline) if (this.timeline._sortChildren) { 25083 this.timeline.add(this, value - this._delay); //ensures that any necessary re-sequencing of Animations in the timeline occurs to make sure the rendering order is correct. 25084 } 25085 } 25086 return this; 25087 }; 25088 25089 p.endTime = function(includeRepeats) { 25090 return this._startTime + ((includeRepeats != false) ? this.totalDuration() : this.duration()) / this._timeScale; 25091 }; 25092 25093 p.timeScale = function(value) { 25094 if (!arguments.length) { 25095 return this._timeScale; 25096 } 25097 var pauseTime, t; 25098 value = value || _tinyNum; //can't allow zero because it'll throw the math off 25099 if (this._timeline && this._timeline.smoothChildTiming) { 25100 pauseTime = this._pauseTime; 25101 t = (pauseTime || pauseTime === 0) ? pauseTime : this._timeline.totalTime(); 25102 this._startTime = t - ((t - this._startTime) * this._timeScale / value); 25103 } 25104 this._timeScale = value; 25105 t = this.timeline; 25106 while (t && t.timeline) { //must update the duration/totalDuration of all ancestor timelines immediately in case in the middle of a render loop, one tween alters another tween's timeScale which shoves its startTime before 0, forcing the parent timeline to shift around and shiftChildren() which could affect that next tween's render (startTime). Doesn't matter for the root timeline though. 25107 t._dirty = true; 25108 t.totalDuration(); 25109 t = t.timeline; 25110 } 25111 return this; 25112 }; 25113 25114 p.reversed = function(value) { 25115 if (!arguments.length) { 25116 return this._reversed; 25117 } 25118 if (value != this._reversed) { 25119 this._reversed = value; 25120 this.totalTime(((this._timeline && !this._timeline.smoothChildTiming) ? this.totalDuration() - this._totalTime : this._totalTime), true); 25121 } 25122 return this; 25123 }; 25124 25125 p.paused = function(value) { 25126 if (!arguments.length) { 25127 return this._paused; 25128 } 25129 var tl = this._timeline, 25130 raw, elapsed; 25131 if (value != this._paused) if (tl) { 25132 if (!_tickerActive && !value) { 25133 _ticker.wake(); 25134 } 25135 raw = tl.rawTime(); 25136 elapsed = raw - this._pauseTime; 25137 if (!value && tl.smoothChildTiming) { 25138 this._startTime += elapsed; 25139 this._uncache(false); 25140 } 25141 this._pauseTime = value ? raw : null; 25142 this._paused = value; 25143 this._active = this.isActive(); 25144 if (!value && elapsed !== 0 && this._initted && this.duration()) { 25145 raw = tl.smoothChildTiming ? this._totalTime : (raw - this._startTime) / this._timeScale; 25146 this.render(raw, (raw === this._totalTime), true); //in case the target's properties changed via some other tween or manual update by the user, we should force a render. 25147 } 25148 } 25149 if (this._gc && !value) { 25150 this._enabled(true, false); 25151 } 25152 return this; 25153 }; 25154 25155
25156/* 25157 * ---------------------------------------------------------------- 25158 * SimpleTimeline 25159 * ---------------------------------------------------------------- 25160 */ 25161 var SimpleTimeline = _class("core.SimpleTimeline", function(vars) { 25162 Animation.call(this, 0, vars); 25163 this.autoRemoveChildren = this.smoothChildTiming = true; 25164 }); 25165 25166 p = SimpleTimeline.prototype = new Animation(); 25167 p.constructor = SimpleTimeline; 25168 p.kill()._gc = false; 25169 p._first = p._last = p._recent = null; 25170 p._sortChildren = false; 25171 25172 p.add = p.insert = function(child, position, align, stagger) { 25173 var prevTween, st; 25174 child._startTime = Number(position || 0) + child._delay; 25175 if (child._paused) if (this !== child._timeline) { //we only adjust the _pauseTime if it wasn't in this timeline already. Remember, sometimes a tween will be inserted again into the same timeline when its startTime is changed so that the tweens in the TimelineLite/Max are re-ordered properly in the linked list (so everything renders in the proper order). 25176 child._pauseTime = this.rawTime() - (child._timeline.rawTime() - child._pauseTime); 25177 } 25178 if (child.timeline) { 25179 child.timeline._remove(child, true); //removes from existing timeline so that it can be properly added to this one. 25180 } 25181 child.timeline = child._timeline = this; 25182 if (child._gc) { 25183 child._enabled(true, true); 25184 } 25185 prevTween = this._last; 25186 if (this._sortChildren) { 25187 st = child._startTime; 25188 while (prevTween && prevTween._startTime > st) { 25189 prevTween = prevTween._prev; 25190 } 25191 } 25192 if (prevTween) { 25193 child._next = prevTween._next; 25194 prevTween._next = child; 25195 } else { 25196 child._next = this._first; 25197 this._first = child; 25198 } 25199 if (child._next) { 25200 child._next._prev = child; 25201 } else { 25202 this._last = child; 25203 } 25204 child._prev = prevTween; 25205 this._recent = child; 25206 if (this._timeline) { 25207 this._uncache(true); 25208 } 25209 return this; 25210 }; 25211 25212 p._remove = function(tween, skipDisable) { 25213 if (tween.timeline === this) { 25214 if (!skipDisable) { 25215 tween._enabled(false, true); 25216 } 25217 25218 if (tween._prev) { 25219 tween._prev._next = tween._next; 25220 } else if (this._first === tween) { 25221 this._first = tween._next; 25222 } 25223 if (tween._next) { 25224 tween._next._prev = tween._prev; 25225 } else if (this._last === tween) { 25226 this._last = tween._prev; 25227 } 25228 tween._next = tween._prev = tween.timeline = null; 25229 if (tween === this._recent) { 25230 this._recent = this._last; 25231 } 25232 25233 if (this._timeline) { 25234 this._uncache(true); 25235 } 25236 } 25237 return this; 25238 }; 25239 25240 p.render = function(time, suppressEvents, force) { 25241 var tween = this._first, 25242 next; 25243 this._totalTime = this._time = this._rawPrevTime = time; 25244 while (tween) { 25245 next = tween._next; //record it here because the value could change after rendering... 25246 if (tween._active || (time >= tween._startTime && !tween._paused && !tween._gc)) { 25247 if (!tween._reversed) { 25248 tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force); 25249 } else { 25250 tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force); 25251 } 25252 } 25253 tween = next; 25254 } 25255 }; 25256 25257 p.rawTime = function() { 25258 if (!_tickerActive) { 25259 _ticker.wake(); 25260 } 25261 return this._totalTime; 25262 }; 25263 25264/* 25265 * ---------------------------------------------------------------- 25266 * TweenLite 25267 * ---------------------------------------------------------------- 25268 */ 25269 var TweenLite = _class("TweenLite", function(target, duration, vars) { 25270 Animation.call(this, duration, vars); 25271 this.render = TweenLite.prototype.render; //speed optimization (avoid prototype lookup on this "hot" method) 25272 25273 if (target == null) { 25274 throw "Cannot tween a null target."; 25275 } 25276 25277 this.target = target = (typeof(target) !== "string") ? target : TweenLite.selector(target) || target; 25278 25279 var isSelector = (target.jquery || (target.length && target !== window && target[0] && (target[0] === window || (target[0].nodeType && target[0].style && !target.nodeType)))),
25280 overwrite = this.vars.overwrite, 25281 i, targ, targets; 25282 25283 this._overwrite = overwrite = (overwrite == null) ? _overwriteLookup[TweenLite.defaultOverwrite] : (typeof(overwrite) === "number") ? overwrite >> 0 : _overwriteLookup[overwrite]; 25284 25285 if ((isSelector || target instanceof Array || (target.push && _isArray(target))) && typeof(target[0]) !== "number") { 25286 this._targets = targets = _slice(target); //don't use Array.prototype.slice.call(target, 0) because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll() 25287 this._propLookup = []; 25288 this._siblings = []; 25289 for (i = 0; i < targets.length; i++) { 25290 targ = targets[i]; 25291 if (!targ) { 25292 targets.splice(i--, 1); 25293 continue; 25294 } else if (typeof(targ) === "string") { 25295 targ = targets[i--] = TweenLite.selector(targ); //in case it's an array of strings 25296 if (typeof(targ) === "string") { 25297 targets.splice(i+1, 1); //to avoid an endless loop (can't imagine why the selector would return a string, but just in case) 25298 } 25299 continue; 25300 } else if (targ.length && targ !== window && targ[0] && (targ[0] === window || (targ[0].nodeType && targ[0].style && !targ.nodeType))) { //in case the user is passing in an array of selector objects (like jQuery objects), we need to check one more level and pull things out if necessary. Also note that <select> elements pass all the criteria regarding length and the first child having style, so we must also check to ensure the target isn't an HTML node itself. 25301 targets.splice(i--, 1); 25302 this._targets = targets = targets.concat(_slice(targ)); 25303 continue; 25304 } 25305 this._siblings[i] = _register(targ, this, false); 25306 if (overwrite === 1) if (this._siblings[i].length > 1) { 25307 _applyOverwrite(targ, this, null, 1, this._siblings[i]); 25308 } 25309 } 25310 25311 } else { 25312 this._propLookup = {}; 25313 this._siblings = _register(target, this, false); 25314 if (overwrite === 1) if (this._siblings.length > 1) { 25315 _applyOverwrite(target, this, null, 1, this._siblings); 25316 } 25317 } 25318 if (this.vars.immediateRender || (duration === 0 && this._delay === 0 && this.vars.immediateRender !== false)) { 25319 this._time = -_tinyNum; //forces a render without having to set the render() "force" parameter to true because we want to allow lazying by default (using the "force" parameter always forces an immediate full render) 25320 this.render(Math.min(0, -this._delay)); //in case delay is negative 25321 } 25322 }, true), 25323 _isSelector = function(v) { 25324 return (v && v.length && v !== window && v[0] && (v[0] === window || (v[0].nodeType && v[0].style && !v.nodeType))); //we cannot check "nodeType" if the target is window from within an iframe, otherwise it will trigger a security error in some browsers like Firefox. 25325 }, 25326 _autoCSS = function(vars, target) { 25327 var css = {}, 25328 p; 25329 for (p in vars) { 25330 if (!_reservedProps[p] && (!(p in target) || p === "transform" || p === "x" || p === "y" || p === "width" || p === "height" || p === "className" || p === "border") && (!_plugins[p] || (_plugins[p] && _plugins[p]._autoCSS))) { //note: <img> elements contain read-only "x" and "y" properties. We should also prioritize editing css width/height rather than the element's properties. 25331 css[p] = vars[p]; 25332 delete vars[p]; 25333 } 25334 } 25335 vars.css = css; 25336 }; 25337 25338 p = TweenLite.prototype = new Animation(); 25339 p.constructor = TweenLite; 25340 p.kill()._gc = false; 25341 25342//----TweenLite defaults, overwrite management, and root updates ---------------------------------------------------- 25343 25344 p.ratio = 0; 25345 p._firstPT = p._targets = p._overwrittenProps = p._startAt = null; 25346 p._notifyPluginsOfEnabled = p._lazy = false; 25347 25348 TweenLite.version = "2.0.2"; 25349 TweenLite.defaultEase = p._ease = new Ease(null, null, 1, 1); 25350 TweenLite.defaultOverwrite = "auto"; 25351 TweenLite.ticker = _ticker; 25352 TweenLite.autoSleep = 120; 25353 TweenLite.lagSmoothing = function(threshold, adjustedLag) { 25354 _ticker.lagSmoothing(threshold, adjustedLag); 25355 }; 25356 25357 TweenLite.selector = window.$ || window.jQuery || function(e) { 25358 var selector = window.$ || window.jQuery; 25359 if (selector) { 25360 TweenLite.selector = selector; 25361 return selector(e); 25362 } 25363 if (!_doc) { //in some dev environments (like Angular 6), GSAP gets loaded before the document is defined! So re-query it here if/when necessary. 25364 _doc = window.document; 25365 } 25366 return (!_doc) ? e : (_doc.querySelectorAll ? _doc.querySelectorAll(e) : _doc.getElementById((e.charAt(0) === "#") ? e.substr(1) : e)); 25367 }; 25368 25369 var _lazyTweens = [], 25370 _lazyLookup = {}, 25371 _numbersExp = /(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig, 25372 _relExp = /[\+-]=-?[\.\d]/, 25373 //_nonNumbersExp = /(?:([\-+](?!(\d|=)))|[^\d\-+=e]|(e(?![\-+][\d])))+/ig, 25374 _setRatio = function(v) { 25375 var pt = this._firstPT, 25376 min = 0.000001, 25377 val; 25378 while (pt) { 25379 val = !pt.blob ? pt.c * v + pt.s : (v === 1 && this.end != null) ? this.end : v ? this.join("") : this.start; 25380 if (pt.m) { 25381 val = pt.m.call(this._tween, val, this._target || pt.t, this._tween); 25382 } else if (val < min) if (val >
25382 -min && !pt.blob) { //prevents issues with converting very small numbers to strings in the browser 25383 val = 0; 25384 } 25385 if (!pt.f) { 25386 pt.t[pt.p] = val; 25387 } else if (pt.fp) { 25388 pt.t[pt.p](pt.fp, val); 25389 } else { 25390 pt.t[pt.p](val); 25391 } 25392 pt = pt._next; 25393 } 25394 }, 25395 //compares two strings (start/end), finds the numbers that are different and spits back an array representing the whole value but with the changing values isolated as elements. For example, "rgb(0,0,0)" and "rgb(100,50,0)" would become ["rgb(", 0, ",", 50, ",0)"]. Notice it merges the parts that are identical (performance optimization). The array also has a linked list of PropTweens attached starting with _firstPT that contain the tweening data (t, p, s, c, f, etc.). It also stores the starting value as a "start" property so that we can revert to it if/when necessary, like when a tween rewinds fully. If the quantity of numbers differs between the start and end, it will always prioritize the end value(s). The pt parameter is optional - it's for a PropTween that will be appended to the end of the linked list and is typically for actually setting the value after all of the elements have been updated (with array.join("")). 25396 _blobDif = function(start, end, filter, pt) { 25397 var a = [], 25398 charIndex = 0, 25399 s = "", 25400 color = 0, 25401 startNums, endNums, num, i, l, nonNumbers, currentNum; 25402 a.start = start; 25403 a.end = end; 25404 start = a[0] = start + ""; //ensure values are strings 25405 end = a[1] = end + ""; 25406 if (filter) { 25407 filter(a); //pass an array with the starting and ending values and let the filter do whatever it needs to the values. 25408 start = a[0]; 25409 end = a[1]; 25410 } 25411 a.length = 0; 25412 startNums = start.match(_numbersExp) || []; 25413 endNums = end.match(_numbersExp) || []; 25414 if (pt) { 25415 pt._next = null; 25416 pt.blob = 1; 25417 a._firstPT = a._applyPT = pt; //apply last in the linked list (which means inserting it first) 25418 } 25419 l = endNums.length; 25420 for (i = 0; i < l; i++) { 25421 currentNum = endNums[i]; 25422 nonNumbers = end.substr(charIndex, end.indexOf(currentNum, charIndex)-charIndex); 25423 s += (nonNumbers || !i) ? nonNumbers : ","; //note: SVG spec allows omission of comma/space when a negative sign is wedged between two numbers, like 2.5-5.3 instead of 2.5,-5.3 but when tweening, the negative value may switch to positive, so we insert the comma just in case. 25424 charIndex += nonNumbers.length; 25425 if (color) { //sense rgba() values and round them. 25426 color = (color + 1) % 5; 25427 } else if (nonNumbers.substr(-5) === "rgba(") { 25428 color = 1; 25429 } 25430 if (currentNum === startNums[i] || startNums.length <= i) { 25431 s += currentNum; 25432 } else { 25433 if (s) { 25434 a.push(s); 25435 s = ""; 25436 } 25437 num = parseFloat(startNums[i]); 25438 a.push(num); 25439 a._firstPT = {_next: a._firstPT, t:a, p: a.length-1, s:num, c:((currentNum.charAt(1) === "=") ? parseInt(currentNum.charAt(0) + "1", 10) * parseFloat(currentNum.substr(2)) : (parseFloat(currentNum) - num)) || 0, f:0, m:(color && color < 4) ? Math.round : 0}; 25440 //note: we don't set _prev because we'll never need to remove individual PropTweens from this list. 25441 } 25442 charIndex += currentNum.length; 25443 } 25444 s += end.substr(charIndex); 25445 if (s) { 25446 a.push(s); 25447 } 25448 a.setRatio = _setRatio; 25449 if (_relExp.test(end)) { //if the end string contains relative values, delete it so that on the final render (in _setRatio()), we don't actually set it to the string with += or -= characters (forces it to use the calculated value). 25450 a.end = null; 25451 } 25452 return a; 25453 }, 25454 //note: "funcParam" is only necessary for function-based getters/setters that require an extra parameter like getAttribute("width") and setAttribute("width", value). In this example, funcParam would be "width". Used by AttrPlugin for example. 25455 _addPropTween = function(target, prop, start, end, overwriteProp, mod, funcParam, stringFilter, index) { 25456 if (typeof(end) === "function") { 25457 end = end(index || 0, target); 25458 } 25459 var type = typeof(target[prop]), 25460 getterName = (type !== "function") ? "" : ((prop.indexOf("set") || typeof(target["get" + prop.substr(3)]) !== "function") ? prop : "get" + prop.substr(3)), 25461 s = (start !== "get") ? start : !getterName ? target[prop] : funcParam ? target[getterName](funcParam) : target[getterName](), 25462 isRelative = (typeof(end) === "string" && end.charAt(1) === "="), 25463 pt = {t:target, p:prop, s:s, f:(type === "function"), pg:0, n:overwriteProp || prop, m:(!mod ? 0 : (typeof(mod) === "function") ? mod : Math.round), pr:0, c:isRelative ? parseInt(end.charAt(0) + "1", 10) * parseFloat(end.substr(2)) : (parseFloat(end) - s) || 0}, 25464 blob; 25465 25466 if (typeof(s) !== "number" || (typeof(end) !== "number" && !isRelative)) { 25467 if (funcParam || isNaN(s) || (!isRelative && isNaN(end)) || typeof(s) === "boolean" || typeof(end) === "boolean") { 25468 //a blob (string that has multiple numbers in it) 25469 pt.fp = funcParam; 25470 blob = _blobDif(s, (isRelative ? (parseFloat(pt.s) + pt.c) + (pt.s + "").replace(/[0-9\-\.]/g, "") : end), stringFilter || TweenLite.defaultStringFilter, pt); 25471 pt = {t: blob, p: "setRatio", s: 0, c: 1, f: 2, pg: 0, n: overwriteProp || prop, pr: 0, m: 0}; //"2" indicates it's a Blob property tween. Needed for RoundPropsPlugin for example. 25472 } else { 25473 pt.s = parseFloat(s); 25474 if (!isRelative) { 25475 pt.c = (parseFloat(end) - pt.s) || 0; 25476 } 25477 } 25478 } 25479 if (pt.c) { //only add it to the linked list if there's a change. 25480 if ((pt._next = this._firstPT)) { 25481 pt._next._prev = pt; 25482 } 25483 this._firstPT = pt; 25484 return pt; 25485 } 25486 }, 25487 _internals = TweenLite._internals = {isArray:_isArray, isSelector:_isSelector, lazyTweens:_lazyTweens, blobDif:_blobDif}, //gives us a way to expose certain private values to other GreenSock classes without contaminating tha main TweenLite object. 25488 _plugins = TweenLite._plugins = {}, 25489 _tweenLookup = _internals.tweenLookup = {}, 25490 _tweenLookupNum = 0, 25491 _reservedProps = _internals.reservedProps = {ease:1, delay:1, overwrite:1, onComplete:1, onCompleteParams:1, onCompleteScope:1, useFrames:1, runBackwards:1, startAt:1, onUp
25491date:1, onUpdateParams:1, onUpdateScope:1, onStart:1, onStartParams:1, onStartScope:1, onReverseComplete:1, onReverseCompleteParams:1, onReverseCompleteScope:1, onRepeat:1, onRepeatParams:1, onRepeatScope:1, easeParams:1, yoyo:1, immediateRender:1, repeat:1, repeatDelay:1, data:1, paused:1, reversed:1, autoCSS:1, lazy:1, onOverwrite:1, callbackScope:1, stringFilter:1, id:1, yoyoEase:1}, 25492 _overwriteLookup = {none:0, all:1, auto:2, concurrent:3, allOnStart:4, preexisting:5, "true":1, "false":0}, 25493 _rootFramesTimeline = Animation._rootFramesTimeline = new SimpleTimeline(), 25494 _rootTimeline = Animation._rootTimeline = new SimpleTimeline(), 25495 _nextGCFrame = 30, 25496 _lazyRender = _internals.lazyRender = function() { 25497 var i = _lazyTweens.length, 25498 tween; 25499 _lazyLookup = {}; 25500 while (--i > -1) { 25501 tween = _lazyTweens[i]; 25502 if (tween && tween._lazy !== false) { 25503 tween.render(tween._lazy[0], tween._lazy[1], true); 25504 tween._lazy = false; 25505 } 25506 } 25507 _lazyTweens.length = 0; 25508 }; 25509 25510 _rootTimeline._startTime = _ticker.time; 25511 _rootFramesTimeline._startTime = _ticker.frame; 25512 _rootTimeline._active = _rootFramesTimeline._active = true; 25513 setTimeout(_lazyRender, 1); //on some mobile devices, there isn't a "tick" before code runs which means any lazy renders wouldn't run before the next official "tick". 25514 25515 Animation._updateRoot = TweenLite.render = function() { 25516 var i, a, p; 25517 if (_lazyTweens.length) { //if code is run outside of the requestAnimationFrame loop, there may be tweens queued AFTER the engine refreshed, so we need to ensure any pending renders occur before we refresh again. 25518 _lazyRender(); 25519 } 25520 _rootTimeline.render((_ticker.time - _rootTimeline._startTime) * _rootTimeline._timeScale, false, false); 25521 _rootFramesTimeline.render((_ticker.frame - _rootFramesTimeline._startTime) * _rootFramesTimeline._timeScale, false, false); 25522 if (_lazyTweens.length) { 25523 _lazyRender(); 25524 } 25525 if (_ticker.frame >= _nextGCFrame) { //dump garbage every 120 frames or whatever the user sets TweenLite.autoSleep to 25526 _nextGCFrame = _ticker.frame + (parseInt(TweenLite.autoSleep, 10) || 120); 25527 for (p in _tweenLookup) { 25528 a = _tweenLookup[p].tweens; 25529 i = a.length; 25530 while (--i > -1) { 25531 if (a[i]._gc) { 25532 a.splice(i, 1); 25533 } 25534 } 25535 if (a.length === 0) { 25536 delete _tweenLookup[p]; 25537 } 25538 } 25539 //if there are no more tweens in the root timelines, or if they're all paused, make the _timer sleep to reduce load on the CPU slightly 25540 p = _rootTimeline._first; 25541 if (!p || p._paused) if (TweenLite.autoSleep && !_rootFramesTimeline._first && _ticker._listeners.tick.length === 1) { 25542 while (p && p._paused) { 25543 p = p._next; 25544 } 25545 if (!p) { 25546 _ticker.sleep(); 25547 } 25548 } 25549 } 25550 }; 25551 25552 _ticker.addEventListener("tick", Animation._updateRoot); 25553 25554 var _register = function(target, tween, scrub) { 25555 var id = target._gsTweenID, a, i; 25556 if (!_tweenLookup[id || (target._gsTweenID = id = "t" + (_tweenLookupNum++))]) { 25557 _tweenLookup[id] = {target:target, tweens:[]}; 25558 } 25559 if (tween) { 25560 a = _tweenLookup[id].tweens; 25561 a[(i = a.length)] = tween; 25562 if (scrub) { 25563 while (--i > -1) { 25564 if (a[i] === tween) { 25565 a.splice(i, 1); 25566 } 25567 } 25568 } 25569 } 25570 return _tweenLookup[id].tweens; 25571 }, 25572 _onOverwrite = function(overwrittenTween, overwritingTween, target, killedProps) { 25573 var func = overwrittenTween.vars.onOverwrite, r1, r2; 25574 if (func) { 25575 r1 = func(overwrittenTween, overwritingTween, target, killedProps); 25576 } 25577 func = TweenLite.onOverwrite; 25578 if (func) { 25579 r2 = func(overwrittenTween, overwritingTween, target, killedProps); 25580 } 25581 return (r1 !== false && r2 !== false); 25582 }, 25583 _applyOverwrite = function(target, tween, props, mode, siblings) { 25584 var i, changed, curTween, l; 25585 if (mode === 1 || mode >= 4) { 25586 l = siblings.length; 25587 for (i = 0; i < l; i++) { 25588 if ((curTween = siblings[i]) !== tween) { 25589 if (!curTween._gc) { 25590 if (curTween._kill(null, target, tween)) { 25591 changed = true; 25592 } 25593 } 25594 } else if (mode === 5) { 25595 break; 25596 } 25597 } 25598 return changed; 25599 } 25600 //NOTE: Add 0.0000000001 to overcome floating point errors that can cause the startTime to be VERY slightly off (when a tween's time() is set for example) 25601 var startTime = tween._startTime + _tinyNum, 25602 overlaps = [], 25603 oCount = 0, 25604 zeroDur = (tween._duration === 0), 25605 globalStart; 25606 i = siblings.length; 25607 while (--i > -1) { 25608 if ((curTween = siblings[i]) === tween || curTween._gc || curTween._paused) { 25609 //ignore 25610 } else if (curTween._timeline !== tween._timeline) { 25611 globalStart = globalStart || _checkOverlap(tween, 0, zeroDur); 25612 if (_checkOverlap(curTween, globalStart, zeroDur) === 0) { 25613 overlaps[oCount++] = curTween; 25614 } 25615 } else if (curTween._startTime <= startTime) if (curTween._startTime + curTween.totalDuration() / curTween._timeScale > startTime) if (!((zeroDur || !curTween._initted) && startTime - curTween._startTime <= 0.0000000002)) { 25616 overlaps[oCount++] = curTween; 25617 } 25618 } 25619 25620 i = oCount; 25621 while (--i > -1) { 25622 curTween = overlaps[i]; 25623 l = curTween._firstPT; //we need to discern if there were property tweens originally; if they all get removed in the next line's _kill() call, the tween should be killed. See https://github.com/greensock/GreenSock-JS/issues/278 25624 if (mode === 2) if (curTween._kill(props, target, tween)) { 25625 changed = true; 25626 } 25627 if (mode !== 2 || (!curTween._firstPT && curTween._initted && l)) { 25628 if (mode !== 2 && !_onOverwrite(curTween, tween)) { 25629 continue; 25630 } 25631 if (curTween._enabled(false, false)) { //if all property tweens have been overwritten, kill the tween. 25632 changed = true; 25633 } 25634 } 25635 } 25636 return changed; 25637 }, 25638 _checkOverlap = function(tween, reference, zeroDur) { 25639 var tl = tween._timeline, 25640 ts = tl._timeScale, 25641 t = tween._startTime; 25642 while (tl._timeline) { 25643 t += tl._startTime; 25644 ts *= tl._timeScale; 25645 if (tl._paused) { 25646 return -100; 25647 } 25648 tl = tl._timeline; 25649 } 25650 t /= ts; 25651 return (t > reference) ? t - reference : ((zeroDur && t === reference) || (!tween._initted && t - reference < 2 * _tinyNum)) ? _tinyNum : ((t += tween.totalDuration() / tween._timeScale / ts) > reference + _tinyNum) ? 0 : t - reference - _tinyNum; 25652 }; 25653 25654 25655//---- TweenLite instance methods ----------------------------------------------------------------------------- 25656 25657 p._init = function() { 25658 var v = this.vars, 25659 op = this._overwrittenProps, 25660 dur = this._duration, 25661 immediate = !!v.immediateRender, 25662 ease = v.ease, 25663 i, initPlugins, pt, p, startVars, l; 25664 if (v.startAt) { 25665 if (this._startAt) { 25666 this._startAt.render(-1, true); //if we've run a startAt previously (when the tween instantiated), we should revert it so that the values re-instantiate correctly particularly for relative tweens. Without this, a TweenLite.fromTo(obj, 1, {x:"+=100"}, {x:"-=100"}), for example, would actually jump to +=200 because the startAt would run twice, doubling the relative change. 25667 this._startAt.kill(); 25668 } 25669 startVars = {}; 25670 for (p in v.startAt) { //copy the properties/values into a new object to avoid collisions, like var to = {x:0}, from = {x:500}; timeline.fromTo(e, 1, from, to).fromTo(e, 1, to, from); 25671 startVars[p] = v.startAt[p]; 25672 } 25673 startVars.data = "isStart"; 25674 startVars.overwrite = false;
25675 startVars.immediateRender = true; 25676 startVars.lazy = (immediate && v.lazy !== false); 25677 startVars.startAt = startVars.delay = null; //no nesting of startAt objects allowed (otherwise it could cause an infinite loop). 25678 startVars.onUpdate = v.onUpdate; 25679 startVars.onUpdateParams = v.onUpdateParams; 25680 startVars.onUpdateScope = v.onUpdateScope || v.callbackScope || this; 25681 this._startAt = TweenLite.to(this.target || {}, 0, startVars); 25682 if (immediate) { 25683 if (this._time > 0) { 25684 this._startAt = null; //tweens that render immediately (like most from() and fromTo() tweens) shouldn't revert when their parent timeline's playhead goes backward past the startTime because the initial render could have happened anytime and it shouldn't be directly correlated to this tween's startTime. Imagine setting up a complex animation where the beginning states of various objects are rendered immediately but the tween doesn't happen for quite some time - if we revert to the starting values as soon as the playhead goes backward past the tween's startTime, it will throw things off visually. Reversion should only happen in TimelineLite/Max instances where immediateRender was false (which is the default in the convenience methods like from()). 25685 } else if (dur !== 0) { 25686 return; //we skip initialization here so that overwriting doesn't occur until the tween actually begins. Otherwise, if you create several immediateRender:true tweens of the same target/properties to drop into a TimelineLite or TimelineMax, the last one created would overwrite the first ones because they didn't get placed into the timeline yet before the first render occurs and kicks in overwriting. 25687 } 25688 } 25689 } else if (v.runBackwards && dur !== 0) { 25690 //from() tweens must be handled uniquely: their beginning values must be rendered but we don't want overwriting to occur yet (when time is still 0). Wait until the tween actually begins before doing all the routines like overwriting. At that time, we should render at the END of the tween to ensure that things initialize correctly (remember, from() tweens go backwards) 25691 if (this._startAt) { 25692 this._startAt.render(-1, true); 25693 this._startAt.kill(); 25694 this._startAt = null; 25695 } else { 25696 if (this._time !== 0) { //in rare cases (like if a from() tween runs and then is invalidate()-ed), immediateRender could be true but the initial forced-render gets skipped, so there's no need to force the render in this context when the _time is greater than 0 25697 immediate = false; 25698 } 25699 pt = {}; 25700 for (p in v) { //copy props into a new object and skip any reserved props, otherwise onComplete or onUpdate or onStart could fire. We should, however, permit autoCSS to go through. 25701 if (!_reservedProps[p] || p === "autoCSS") { 25702 pt[p] = v[p]; 25703 } 25704 } 25705 pt.overwrite = 0; 25706 pt.data = "isFromStart"; //we tag the tween with as "isFromStart" so that if [inside a plugin] we need to only do something at the very END of a tween, we have a way of identifying this tween as merely the one that's setting the beginning values for a "from()" tween. For example, clearProps in CSSPlugin should only get applied at the very END of a tween and without this tag, from(...{height:100, clearProps:"height", delay:1}) would wipe the height at the beginning of the tween and after 1 second, it'd kick back in. 25707 pt.lazy = (immediate && v.lazy !== false); 25708 pt.immediateRender = immediate; //zero-duration tweens render immediately by default, but if we're not specifically instructed to render this tween immediately, we should skip this and merely _init() to record the starting values (rendering them immediately would push them to completion which is wasteful in that case - we'd have to render(-1) immediately after) 25709 this._startAt = TweenLite.to(this.target, 0, pt); 25710 if (!immediate) { 25711 this._startAt._init(); //ensures that the initial values are recorded 25712 this._startAt._enabled(false); //no need to have the tween render on the next cycle. Disable it because we'll always manually control the renders of the _startAt tween. 25713 if (this.vars.immediateRender) { 25714 this._startAt = null; 25715 } 25716 } else if (this._time === 0) { 25717 return; 25718 } 25719 } 25720 } 25721 this._ease = ease = (!ease) ? TweenLite.defaultEase : (ease instanceof Ease) ? ease : (typeof(ease) === "function") ? new Ease(ease, v.easeParams) : _easeMap[ease] || TweenLite.defaultEase; 25722 if (v.easeParams instanceof Array && ease.config) { 25723 this._ease = ease.config.apply(ease, v.easeParams); 25724 } 25725 this._easeType = this._ease._type; 25726 this._easePower = this._ease._power; 25727 this._firstPT = null; 25728 25729 if (this._targets) { 25730 l = this._targets.length; 25731 for (i = 0; i < l; i++) { 25732 if ( this._initProps( this._targets[i], (this._propLookup[i] = {}), this._siblings[i], (op ? op[i] : null), i) ) { 25733 initPlugins = true; 25734 } 25735 } 25736 } else { 25737 initPlugins = this._initProps(this.target, this._propLookup, this._siblings, op, 0); 25738 } 25739 25740 if (initPlugins) { 25741 TweenLite._onPluginEvent("_onInitAllProps", this); //reorders the array in order of priority. Uses a static TweenPlugin method in order to minimize file size in TweenLite 25742 } 25743 if (op) if (!this._firstPT) if (typeof(this.target) !== "function") { //if all tweening properties have been overwritten, kill the tween. If the target is a function, it's probably a delayedCall so let it live. 25744 this._enabled(false, false); 25745 } 25746 if (v.runBackwards) { 25747 pt = this._firstPT; 25748 while (pt) { 25749 pt.s += pt.c; 25750 pt.c = -pt.c; 25751 pt = pt._next; 25752 } 25753 } 25754 this._onUpdate = v.onUpdate; 25755 this._initted = true; 25756 }; 25757 25758 p._initProps = function(target, propLookup, siblings, overwrittenProps, index) { 25759 var p, i, initPlugins, plugin, pt, v; 25760 if (target == null) { 25761 return false;
25762 } 25763 25764 if (_lazyLookup[target._gsTweenID]) { 25765 _lazyRender(); //if other tweens of the same target have recently initted but haven't rendered yet, we've got to force the render so that the starting values are correct (imagine populating a timeline with a bunch of sequential tweens and then jumping to the end) 25766 } 25767 25768 if (!this.vars.css) if (target.style) if (target !== window && target.nodeType) if (_plugins.css) if (this.vars.autoCSS !== false) { //it's so common to use TweenLite/Max to animate the css of DOM elements, we assume that if the target is a DOM element, that's what is intended (a convenience so that users don't have to wrap things in css:{}, although we still recommend it for a slight performance boost and better specificity). Note: we cannot check "nodeType" on the window inside an iframe. 25769 _autoCSS(this.vars, target); 25770 } 25771 for (p in this.vars) { 25772 v = this.vars[p]; 25773 if (_reservedProps[p]) { 25774 if (v) if ((v instanceof Array) || (v.push && _isArray(v))) if (v.join("").indexOf("{self}") !== -1) { 25775 this.vars[p] = v = this._swapSelfInParams(v, this); 25776 } 25777 25778 } else if (_plugins[p] && (plugin = new _plugins[p]())._onInitTween(target, this.vars[p], this, index)) { 25779 25780 //t - target [object] 25781 //p - property [string] 25782 //s - start [number] 25783 //c - change [number] 25784 //f - isFunction [boolean] 25785 //n - name [string] 25786 //pg - isPlugin [boolean] 25787 //pr - priority [number] 25788 //m - mod [function | 0] 25789 this._firstPT = pt = {_next:this._firstPT, t:plugin, p:"setRatio", s:0, c:1, f:1, n:p, pg:1, pr:plugin._priority, m:0}; 25790 i = plugin._overwriteProps.length; 25791 while (--i > -1) { 25792 propLookup[plugin._overwriteProps[i]] = this._firstPT; 25793 } 25794 if (plugin._priority || plugin._onInitAllProps) { 25795 initPlugins = true; 25796 } 25797 if (plugin._onDisable || plugin._onEnable) { 25798 this._notifyPluginsOfEnabled = true; 25799 } 25800 if (pt._next) { 25801 pt._next._prev = pt; 25802 } 25803 25804 } else { 25805 propLookup[p] = _addPropTween.call(this, target, p, "get", v, p, 0, null, this.vars.stringFilter, index); 25806 } 25807 } 25808 25809 if (overwrittenProps) if (this._kill(overwrittenProps, target)) { //another tween may have tried to overwrite properties of this tween before init() was called (like if two tweens start at the same time, the one created second will run first) 25810 return this._initProps(target, propLookup, siblings, overwrittenProps, index); 25811 } 25812 if (this._overwrite > 1) if (this._firstPT) if (siblings.length > 1) if (_applyOverwrite(target, this, propLookup, this._overwrite, siblings)) { 25813 this._kill(propLookup, target); 25814 return this._initProps(target, propLookup, siblings, overwrittenProps, index); 25815 } 25816 if (this._firstPT) if ((this.vars.lazy !== false && this._duration) || (this.vars.lazy && !this._duration)) { //zero duration tweens don't lazy render by default; everything else does. 25817 _lazyLookup[target._gsTweenID] = true; 25818 } 25819 return initPlugins; 25820 }; 25821 25822 p.render = function(time, suppressEvents, force) { 25823 var prevTime = this._time, 25824 duration = this._duration, 25825 prevRawPrevTime = this._rawPrevTime, 25826 isComplete, callback, pt, rawPrevTime; 25827 if (time >= duration - 0.0000001 && time >= 0) { //to work around occasional floating point math artifacts. 25828 this._totalTime = this._time = duration; 25829 this.ratio = this._ease._calcEnd ? this._ease.getRatio(1) : 1; 25830 if (!this._reversed ) { 25831 isComplete = true; 25832 callback = "onComplete"; 25833 force = (force || this._timeline.autoRemoveChildren); //otherwise, if the animation is unpaused/activated after it's already finished, it doesn't get removed from the parent timeline. 25834 } 25835 if (duration === 0) if (this._initted || !this.vars.lazy || force) { //zero-duration tweens are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered. 25836 if (this._startTime === this._timeline._duration) { //if a zero-duration tween is at the VERY end of a timeline and that timeline renders at its end, it will typically add a tiny bit of cushion to the render time to prevent roun
25836ding errors from getting in the way of tweens rendering their VERY end. If we then reverse() that timeline, the zero-duration tween will trigger its onReverseComplete even though technically the playhead didn't pass over it again. It's a very specific edge case we must accommodate. 25837 time = 0; 25838 } 25839 if (prevRawPrevTime < 0 || (time <= 0 && time >= -0.0000001) || (prevRawPrevTime === _tinyNum && this.data !== "isPause")) if (prevRawPrevTime !== time) { //note: when this.data is "isPause", it's a callback added by addPause() on a timeline that we should not be triggered when LEAVING its exact start time. In other words, tl.addPause(1).play(1) shouldn't pause. 25840 force = true; 25841 if (prevRawPrevTime > _tinyNum) { 25842 callback = "onReverseComplete"; 25843 } 25844 } 25845 this._rawPrevTime = rawPrevTime = (!suppressEvents || time || prevRawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient. 25846 } 25847 25848 } else if (time < 0.0000001) { //to work around occasional floating point math artifacts, round super small values to 0. 25849 this._totalTime = this._time = 0; 25850 this.ratio = this._ease._calcEnd ? this._ease.getRatio(0) : 0; 25851 if (prevTime !== 0 || (duration === 0 && prevRawPrevTime > 0)) { 25852 callback = "onReverseComplete"; 25853 isComplete = this._reversed; 25854 } 25855 if (time < 0) { 25856 this._active = false; 25857 if (duration === 0) if (this._initted || !this.vars.lazy || force) { //zero-duration tweens are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered. 25858 if (prevRawPrevTime >= 0 && !(prevRawPrevTime === _tinyNum && this.data === "isPause")) { 25859 force = true; 25860 } 25861 this._rawPrevTime = rawPrevTime = (!suppressEvents || time || prevRawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient. 25862 } 25863 } 25864 if (!this._initted || (this._startAt && this._startAt.progress())) { //if we render the very beginning (time == 0) of a fromTo(), we must force the render (normal tweens wouldn't need to render at a time of 0 when the prevTime was also 0). This is also mandatory to make sure overwriting kicks in immediately. Also, we check progress() because if startAt has already rendered at its end, we should force a render at its beginning. Otherwise, if you put the playhead directly on top of where a fromTo({immediateRender:false}) starts, and then move it backwards, the from() won't revert its values. 25865 force = true; 25866 } 25867 } else { 25868 this._totalTime = this._time = time; 25869 25870 if (this._easeType) { 25871 var r = time / duration, type = this._easeType, pow = this._easePower; 25872 if (type === 1 || (type === 3 && r >= 0.5)) { 25873 r = 1 - r; 25874 } 25875 if (type === 3) { 25876 r *= 2; 25877 } 25878 if (pow === 1) { 25879 r *= r; 25880 } else if (pow === 2) { 25881 r *= r * r; 25882 } else if (pow === 3) { 25883 r *= r * r * r; 25884 } else if (pow === 4) { 25885 r *= r * r * r * r; 25886 } 25887 25888 if (type === 1) { 25889 this.ratio = 1 - r; 25890 } else if (type === 2) { 25891 this.ratio = r; 25892 } else if (time / duration < 0.5) { 25893 this.ratio = r / 2; 25894 } else { 25895 this.ratio = 1 - (r / 2); 25896 } 25897 25898 } else { 25899 this.ratio = this._ease.getRatio(time / duration); 25900 } 25901 } 25902 25903 if (this._time === prevTime && !force) { 25904 return; 25905 } else if (!this._initted) { 25906 this._init(); 25907 if (!this._initted || this._gc) { //immediateRender tweens typically won't initialize until the playhead advances (_time is greater than 0) in order to ensure that over
25907writing occurs properly. Also, if all of the tweening properties have been overwritten (which would cause _gc to be true, as set in _init()), we shouldn't continue otherwise an onStart callback could be called for example. 25908 return; 25909 } else if (!force && this._firstPT && ((this.vars.lazy !== false && this._duration) || (this.vars.lazy && !this._duration))) { 25910 this._time = this._totalTime = prevTime; 25911 this._rawPrevTime = prevRawPrevTime; 25912 _lazyTweens.push(this); 25913 this._lazy = [time, suppressEvents]; 25914 return; 25915 } 25916 //_ease is initially set to defaultEase, so now that init() has run, _ease is set properly and we need to recalculate the ratio. Overall this is faster than using conditional logic earlier in the method to avoid having to set ratio twice because we only init() once but renderTime() gets called VERY frequently. 25917 if (this._time && !isComplete) { 25918 this.ratio = this._ease.getRatio(this._time / duration); 25919 } else if (isComplete && this._ease._calcEnd) { 25920 this.ratio = this._ease.getRatio((this._time === 0) ? 0 : 1); 25921 } 25922 } 25923 if (this._lazy !== false) { //in case a lazy render is pending, we should flush it because the new render is occurring now (imagine a lazy tween instantiating and then immediately the user calls tween.seek(tween.duration()), skipping to the end - the end render would be forced, and then if we didn't flush the lazy render, it'd fire AFTER the seek(), rendering it at the wrong time. 25924 this._lazy = false; 25925 } 25926 if (!this._active) if (!this._paused && this._time !== prevTime && time >= 0) { 25927 this._active = true; //so that if the user renders a tween (as opposed to the timeline rendering it), the timeline is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the tween already finished but the user manually re-renders it as halfway done. 25928 } 25929 if (prevTime === 0) { 25930 if (this._startAt) { 25931 if (time >= 0) { 25932 this._startAt.render(time, true, force); 25933 } else if (!callback) { 25934 callback = "_dummyGS"; //if no callback is defined, use a dummy value just so that the condition at the end evaluates as true because _startAt should render AFTER the normal render loop when the time is negative. We could handle this in a more intuitive way, of course, but the render loop is the MOST important thing to optimize, so this technique allows us to avoid adding extra conditional logic in a high-frequency area. 25935 } 25936 } 25937 if (this.vars.onStart) if (this._time !== 0 || duration === 0) if (!suppressEvents) { 25938 this._callback("onStart"); 25939 } 25940 } 25941 pt = this._firstPT; 25942 while (pt) { 25943 if (pt.f) { 25944 pt.t[pt.p](pt.c * this.ratio + pt.s); 25945 } else { 25946 pt.t[pt.p] = pt.c * this.ratio + pt.s; 25947 } 25948 pt = pt._next; 25949 } 25950 25951 if (this._onUpdate) { 25952 if (time < 0) if (this._startAt && time !== -0.0001) { //if the tween is positioned at the VERY beginning (_startTime 0) of its parent timeline, it's illegal for the playhead to go back further, so we should not render the recorded startAt values. 25953 this._startAt.render(time, true, force); //note: for performance reasons, we tuck this conditional logic inside less traveled areas (most tweens don't have an onUpdate). We'd just have it at the end before the onComplete, but the values should be updated before any onUpdate is called, so we ALSO put it here and then if it's not called, we do so later near the onComplete. 25954 } 25955 if (!suppressEvents) if (this._time !== prevTime || isComplete || force) { 25956 this._callback("onUpdate"); 25957 } 25958 } 25959 if (callback) if (!this._gc || force) { //check _gc because there's a chance that kill() could be called in an onUpdate 25960 if (time < 0 && this._startAt && !this._onUpdate && time !== -0.0001) { //-0.0001 is a special value that we use when looping back to the beginning of a repeated TimelineMax, in which case we shouldn't render the _startAt values. 25961 this._startAt.render(time, true, force); 25962 } 25963 if (isComplete) { 25964 if (this._timeline.autoRemoveChildren) { 25965 this._enabled(false, false); 25966 } 25967 this._active = false;
25968 } 25969 if (!suppressEvents && this.vars[callback]) { 25970 this._callback(callback); 25971 } 25972 if (duration === 0 && this._rawPrevTime === _tinyNum && rawPrevTime !== _tinyNum) { //the onComplete or onReverseComplete could trigger movement of the playhead and for zero-duration tweens (which must discern direction) that land directly back on their start time, we don't want to fire again on the next render. Think of several addPause()'s in a timeline that forces the playhead to a certain spot, but what if it's already paused and another tween is tweening the "time" of the timeline? Each time it moves [forward] past that spot, it would move back, and since suppressEvents is true, it'd reset _rawPrevTime to _tinyNum so that when it begins again, the callback would fire (so ultimately it could bounce back and forth during that tween). Again, this is a very uncommon scenario, but possible nonetheless. 25973 this._rawPrevTime = 0; 25974 } 25975 } 25976 }; 25977 25978 p._kill = function(vars, target, overwritingTween) { 25979 if (vars === "all") { 25980 vars = null; 25981 } 25982 if (vars == null) if (target == null || target === this.target) { 25983 this._lazy = false; 25984 return this._enabled(false, false); 25985 } 25986 target = (typeof(target) !== "string") ? (target || this._targets || this.target) : TweenLite.selector(target) || target; 25987 var simultaneousOverwrite = (overwritingTween && this._time && overwritingTween._startTime === this._startTime && this._timeline === overwritingTween._timeline), 25988 firstPT = this._firstPT, 25989 i, overwrittenProps, p, pt, propLookup, changed, killProps, record, killed; 25990 if ((_isArray(target) || _isSelector(target)) && typeof(target[0]) !== "number") { 25991 i = target.length; 25992 while (--i > -1) { 25993 if (this._kill(vars, target[i], overwritingTween)) { 25994 changed = true; 25995 } 25996 } 25997 } else { 25998 if (this._targets) { 25999 i = this._targets.length; 26000 while (--i > -1) { 26001 if (target === this._targets[i]) { 26002 propLookup = this._propLookup[i] || {}; 26003 this._overwrittenProps = this._overwrittenProps || []; 26004 overwrittenProps = this._overwrittenProps[i] = vars ? this._overwrittenProps[i] || {} : "all"; 26005 break; 26006 } 26007 } 26008 } else if (target !== this.target) { 26009 return false; 26010 } else { 26011 propLookup = this._propLookup; 26012 overwrittenProps = this._overwrittenProps = vars ? this._overwrittenProps || {} : "all"; 26013 } 26014 26015 if (propLookup) { 26016 killProps = vars || propLookup; 26017 record = (vars !== overwrittenProps && overwrittenProps !== "all" && vars !== propLookup && (typeof(vars) !== "object" || !vars._tempKill)); //_tempKill is a super-secret way to delete a particular tweening property but NOT have it remembered as an official overwritten property (like in BezierPlugin) 26018 if (overwritingTween && (TweenLite.onOverwrite || this.vars.onOverwrite)) { 26019 for (p in killProps) { 26020 if (propLookup[p]) { 26021 if (!killed) { 26022 killed = []; 26023 } 26024 killed.push(p); 26025 } 26026 } 26027 if ((killed || !vars) && !_onOverwrite(this, overwritingTween, target, killed)) { //if the onOverwrite returned false, that means the user wants to override the overwriting (cancel it). 26028 return false; 26029 } 26030 } 26031 26032 for (p in killProps) { 26033 if ((pt = propLookup[p])) { 26034 if (simultaneousOverwrite) { //if another tween overwrites this one and they both start at exactly the same time, yet this tween has already rendered once (for example, at 0.001) because it's first in the queue, we should revert the values to where they were at 0 so that the starting values aren't contaminated on the overwriting tween. 26035 if (pt.f) { 26036 pt.t[pt.p](pt.s); 26037 } else { 26038 pt.t[pt.p] = pt.s; 26039 } 26040 changed = true; 26041 } 26042 if (pt.pg && pt.t._kill(killProps)) { 26043 changed = true; //some plugins need to be notified so they can perform cleanup tasks first 26044 } 26045 if (!pt.pg || pt.t._overwriteProps.length === 0) { 26046 if (pt._prev) { 26047 pt._prev._next = pt._next; 26048 } else if (pt === this._firstPT) { 26049 this._firstPT = pt._next; 26050 } 26051 if (pt._next) { 26052 pt._next._prev = pt._prev; 26053 } 26054 pt._next = pt._prev = null; 26055 } 26056 delete propLookup[p]; 26057 } 26058 if (record) { 26059 overwrittenProps[p] = 1; 26060 } 26061 } 26062 if (!this._firstPT && this._initted && firstPT) { //if all tweening properties are killed, kill the tween. Without this line, if there's a tween with multiple targets and then you killTweensOf() each target individually, the tween would technically still remain active and fire its onComplete even though there aren't any more properties tweening. 26063 this._enabled(false, false); 26064 } 26065 } 26066 } 26067 return changed; 26068 }; 26069 26070 p.invalidate = function() { 26071 if (this._notifyPluginsOfEnabled) { 26072 TweenLite._onPluginEvent("_onDisable", this); 26073 } 26074 this._firstPT = this._overwrittenProps = this._startAt = this._onUpdate = null; 26075 this._notifyPluginsOfEnabled = this._active = this._lazy = false;
26076 this._propLookup = (this._targets) ? {} : []; 26077 Animation.prototype.invalidate.call(this); 26078 if (this.vars.immediateRender) { 26079 this._time = -_tinyNum; //forces a render without having to set the render() "force" parameter to true because we want to allow lazying by default (using the "force" parameter always forces an immediate full render) 26080 this.render(Math.min(0, -this._delay)); //in case delay is negative. 26081 } 26082 return this; 26083 }; 26084 26085 p._enabled = function(enabled, ignoreTimeline) { 26086 if (!_tickerActive) { 26087 _ticker.wake(); 26088 } 26089 if (enabled && this._gc) { 26090 var targets = this._targets, 26091 i; 26092 if (targets) { 26093 i = targets.length; 26094 while (--i > -1) { 26095 this._siblings[i] = _register(targets[i], this, true); 26096 } 26097 } else { 26098 this._siblings = _register(this.target, this, true); 26099 } 26100 } 26101 Animation.prototype._enabled.call(this, enabled, ignoreTimeline); 26102 if (this._notifyPluginsOfEnabled) if (this._firstPT) { 26103 return TweenLite._onPluginEvent((enabled ? "_onEnable" : "_onDisable"), this); 26104 } 26105 return false; 26106 }; 26107 26108 26109//----TweenLite static methods ----------------------------------------------------- 26110 26111 TweenLite.to = function(target, duration, vars) { 26112 return new TweenLite(target, duration, vars); 26113 }; 26114 26115 TweenLite.from = function(target, duration, vars) { 26116 vars.runBackwards = true; 26117 vars.immediateRender = (vars.immediateRender != false); 26118 return new TweenLite(target, duration, vars); 26119 }; 26120 26121 TweenLite.fromTo = function(target, duration, fromVars, toVars) { 26122 toVars.startAt = fromVars; 26123 toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false); 26124 return new TweenLite(target, duration, toVars); 26125 }; 26126 26127 TweenLite.delayedCall = function(delay, callback, params, scope, useFrames) { 26128 return new TweenLite(callback, 0, {delay:delay, onComplete:callback, onCompleteParams:params, callbackScope:scope, onReverseComplete:callback, onReverseCompleteParams:params, immediateRender:false, lazy:false, useFrames:useFrames, overwrite:0}); 26129 }; 26130 26131 TweenLite.set = function(target, vars) { 26132 return new TweenLite(target, 0, vars); 26133 }; 26134 26135 TweenLite.getTweensOf = function(target, onlyActive) { 26136 if (target == null) { return []; } 26137 target = (typeof(target) !== "string") ? target : TweenLite.selector(target) || target; 26138 var i, a, j, t; 26139 if ((_isArray(target) || _isSelector(target)) && typeof(target[0]) !== "number") { 26140 i = target.length; 26141 a = []; 26142 while (--i > -1) { 26143 a = a.concat(TweenLite.getTweensOf(target[i], onlyActive)); 26144 } 26145 i = a.length; 26146 //now get rid of any duplicates (tweens of arrays of objects could cause duplicates) 26147 while (--i > -1) { 26148 t = a[i]; 26149 j = i; 26150 while (--j > -1) { 26151 if (t === a[j]) { 26152 a.splice(i, 1); 26153 } 26154 } 26155 } 26156 } else if (target._gsTweenID) { 26157 a = _register(target).concat(); 26158 i = a.length; 26159 while (--i > -1) { 26160 if (a[i]._gc || (onlyActive && !a[i].isActive())) { 26161 a.splice(i, 1); 26162 } 26163 } 26164 } 26165 return a || []; 26166 }; 26167 26168 TweenLite.killTweensOf = TweenLite.killDelayedCallsTo = function(target, onlyActive, vars) { 26169 if (typeof(onlyActive) === "object") { 26170 vars = onlyActive; //for backwards compatibility (before "onlyActive" parameter was inserted) 26171 onlyActive = false; 26172 } 26173 var a = TweenLite.getTweensOf(target, onlyActive), 26174 i = a.length; 26175 while (--i > -1) { 26176 a[i]._kill(vars, target); 26177 } 26178 }; 26179 26180 26181 26182/* 26183 * ---------------------------------------------------------------- 26184 * TweenPlugin (could easily be split out as a separate file/class, but included for ease of use (so that people don't need to include another script call before loading plugins which is easy to forget) 26185 * ---------------------------------------------------------------- 26186 */ 26187 var TweenPlugin = _class("plugins.TweenPlugin", function(props, priority) { 26188 this._overwriteProps = (props || "").split(","); 26189 this._propName = this._overwriteProps[0]; 26190 this._priority = priority || 0; 26191 this._super = TweenPlugin.prototype; 26192 }, true); 26193 26194 p = TweenPlugin.prototype; 26195 TweenPlugin.version = "1.19.0"; 26196 TweenPlugin.API = 2; 26197 p._firstPT = null; 26198 p._addTween = _addPropTween; 26199 p.setRatio = _setRatio; 26200 26201 p._kill = function(lookup) { 26202 var a = this._overwriteProps, 26203 pt = this._firstPT, 26204 i; 26205 if (lookup[this._propName] != null) { 26206 this._overwriteProps = []; 26207 } else { 26208 i = a.length; 26209 while (--i > -1) { 26210 if (lookup[a[i]] != null) { 26211 a.splice(i, 1); 26212 } 26213 } 26214 } 26215 while (pt) { 26216 if (lookup[pt.n] != null) { 26217 if (pt._next) { 26218 pt._next._prev = pt._prev; 26219 } 26220 if (pt._prev) { 26221 pt._prev._next = pt._next; 26222 pt._prev = null; 26223 } else if (this._firstPT === pt) { 26224 this._firstPT = pt._next; 26225 } 26226 } 26227 pt = pt._next; 26228 } 26229 return false;
26230 }; 26231 26232 p._mod = p._roundProps = function(lookup) { 26233 var pt = this._firstPT, 26234 val; 26235 while (pt) { 26236 val = lookup[this._propName] || (pt.n != null && lookup[ pt.n.split(this._propName + "_").join("") ]); 26237 if (val && typeof(val) === "function") { //some properties that are very plugin-specific add a prefix named after the _propName plus an underscore, so we need to ignore that extra stuff here. 26238 if (pt.f === 2) { 26239 pt.t._applyPT.m = val; 26240 } else { 26241 pt.m = val; 26242 } 26243 } 26244 pt = pt._next; 26245 } 26246 }; 26247 26248 TweenLite._onPluginEvent = function(type, tween) { 26249 var pt = tween._firstPT, 26250 changed, pt2, first, last, next; 26251 if (type === "_onInitAllProps") { 26252 //sorts the PropTween linked list in order of priority because some plugins need to render earlier/later than others, like MotionBlurPlugin applies its effects after all x/y/alpha tweens have rendered on each frame. 26253 while (pt) { 26254 next = pt._next; 26255 pt2 = first; 26256 while (pt2 && pt2.pr > pt.pr) { 26257 pt2 = pt2._next; 26258 } 26259 if ((pt._prev = pt2 ? pt2._prev : last)) { 26260 pt._prev._next = pt; 26261 } else { 26262 first = pt; 26263 } 26264 if ((pt._next = pt2)) { 26265 pt2._prev = pt; 26266 } else { 26267 last = pt; 26268 } 26269 pt = next; 26270 } 26271 pt = tween._firstPT = first; 26272 } 26273 while (pt) { 26274 if (pt.pg) if (typeof(pt.t[type]) === "function") if (pt.t[type]()) { 26275 changed = true; 26276 } 26277 pt = pt._next; 26278 } 26279 return changed; 26280 }; 26281 26282 TweenPlugin.activate = function(plugins) { 26283 var i = plugins.length; 26284 while (--i > -1) { 26285 if (plugins[i].API === TweenPlugin.API) { 26286 _plugins[(new plugins[i]())._propName] = plugins[i]; 26287 } 26288 } 26289 return true; 26290 }; 26291 26292 //provides a more concise way to define plugins that have no dependencies besides TweenPlugin and TweenLite, wrapping common boilerplate stuff into one function (added in 1.9.0). You don't NEED to use this to define a plugin - the old way still works and can be useful in certain (rare) situations. 26293 _gsDefine.plugin = function(config) { 26294 if (!config || !config.propName || !config.init || !config.API) { throw "illegal plugin definition."; } 26295 var propName = config.propName, 26296 priority = config.priority || 0, 26297 overwriteProps = config.overwriteProps, 26298 map = {init:"_onInitTween", set:"setRatio", kill:"_kill", round:"_mod", mod:"_mod", initAll:"_onInitAllProps"}, 26299 Plugin = _class("plugins." + propName.charAt(0).toUpperCase() + propName.substr(1) + "Plugin", 26300 function() { 26301 TweenPlugin.call(this, propName, priority); 26302 this._overwriteProps = overwriteProps || []; 26303 }, (config.global === true)), 26304 p = Plugin.prototype = new TweenPlugin(propName), 26305 prop; 26306 p.constructor = Plugin; 26307 Plugin.API = config.API; 26308 for (prop in map) { 26309 if (typeof(config[prop]) === "function") { 26310 p[map[prop]] = config[prop]; 26311 } 26312 } 26313 Plugin.version = config.version; 26314 TweenPlugin.activate([Plugin]); 26315 return Plugin; 26316 }; 26317 26318 26319 //now run through all the dependencies discovered and if any are missing, log that to the console as a warning. This is why it's best to have TweenLite load last - it can check all the dependencies for you. 26320 a = window._gsQueue; 26321 if (a) { 26322 for (i = 0; i < a.length; i++) { 26323 a[i](); 26324 } 26325 for (p in _defLookup) { 26326 if (!_defLookup[p].func) { 26327 window.console.log("GSAP encountered missing dependency: " + p); 26328 } 26329 } 26330 } 26331 26332 _tickerActive = false; //ensures that the first official animation forces a ticker.tick() to update the time when it is instantiated 26333 26334})((typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || window, "TweenMax"); 26335/*! 26336Waypoints - 4.0.1 26337Copyright © 2011-2016 Caleb Troughton 26338Licensed under the MIT license. 26339https://github.com/imakewebthings/waypoints/blob/master/licenses.txt 26340*/ 26341(function() { 26342 'use strict' 26343 26344 var keyCounter = 0 26345 var allWaypoints = {} 26346 26347 /* http://imakewebthings.com/waypoints/api/waypoint */ 26348 function Waypoint(options) { 26349 if (!options) { 26350 throw new Error('No options passed to Waypoint constructor') 26351 } 26352 if (!options.element) { 26353 throw new Error('No element option passed to Waypoint constructor') 26354 } 26355 if (!options.handler) { 26356 throw new Error('No handler option passed to Waypoint constructor') 26357 } 26358 26359 this.key = 'waypoint-' + keyCounter 26360 this.options = Waypoint.Adapter.extend({}, Waypoint.defaults, options) 26361 this.element = this.options.element 26362 this.adapter = new Waypoint.Adapter(this.element) 26363 this.callback = options.handler 26364 this.axis = this.options.horizontal ? 'horizontal' : 'vertical' 26365 this.enabled = this.options.enabled 26366 this.triggerPoint = null 26367 this.group = Waypoint.Group.findOrCreate({ 26368 name: this.options.group, 26369 axis: this.axis 26370 }) 26371 this.context = Waypoint.Context.findOrCreateByElement(this.options.context) 26372 26373 if (Waypoint.offsetAliases[this.options.offset]) { 26374 this.options.offset = Waypoint.offsetAliases[this.options.offset] 26375 } 26376 this.group.add(this) 26377 this.context.add(this) 26378 allWaypoints[this.key] = this 26379 keyCounter += 1 26380 } 26381 26382 /* Private */ 26383 Waypoint.prototype.queueTrigger = function(direction) { 26384 this.group.queueTrigger(this, direction) 26385 } 26386 26387 /* Private */ 26388 Waypoint.prototype.trigger = function(args) { 26389 if (!this.enabled) { 26390 return 26391 } 26392 if (this.callback) { 26393 this.callback.apply(this, args) 26394 } 26395 } 26396 26397 /* Public */ 26398 /* http://imakewebthings.com/waypoints/api/destroy */ 26399 Waypoint.prototype.destroy = function() { 26400 this.context.remove(this) 26401 this.group.remove(this) 26402 delete allWaypoints[this.key] 26403 } 26404 26405 /* Public */ 26406 /* http://imakewebthings.com/waypoints/api/disable */ 26407 Waypoint.prototype.disable = function() { 26408 this.enabled = false 26409 return this 26410 } 26411 26412 /* Public */ 26413 /* http://imakewebthings.com/waypoints/api/enable */ 26414 Waypoint.prototype.enable = function() { 26415 this.context.refresh() 26416 this.enabled = true 26417 return this 26418 } 26419 26420 /* Public */ 26421 /* http://imakewebthings.com/waypoints/api/next */ 26422 Waypoint.prototype.next = function() { 26423 return this.group.next(this) 26424 } 26425 26426 /* Public */ 26427 /* http://imakewebthings.com/waypoints/api/previous */ 26428 Waypoint.prototype.previous = function() { 26429 return this.group.previous(this) 26430 } 26431 26432 /* Private */ 26433 Waypoint.invokeAll = function(method) { 26434 var allWaypointsArray = []
26435 for (var waypointKey in allWaypoints) { 26436 allWaypointsArray.push(allWaypoints[waypointKey]) 26437 } 26438 for (var i = 0, end = allWaypointsArray.length; i < end; i++) { 26439 allWaypointsArray[i][method]() 26440 } 26441 } 26442 26443 /* Public */ 26444 /* http://imakewebthings.com/waypoints/api/destroy-all */ 26445 Waypoint.destroyAll = function() { 26446 Waypoint.invokeAll('destroy') 26447 } 26448 26449 /* Public */ 26450 /* http://imakewebthings.com/waypoints/api/disable-all */ 26451 Waypoint.disableAll = function() { 26452 Waypoint.invokeAll('disable') 26453 } 26454 26455 /* Public */ 26456 /* http://imakewebthings.com/waypoints/api/enable-all */ 26457 Waypoint.enableAll = function() { 26458 Waypoint.Context.refreshAll() 26459 for (var waypointKey in allWaypoints) { 26460 allWaypoints[waypointKey].enabled = true 26461 } 26462 return this 26463 } 26464 26465 /* Public */ 26466 /* http://imakewebthings.com/waypoints/api/refresh-all */ 26467 Waypoint.refreshAll = function() { 26468 Waypoint.Context.refreshAll() 26469 } 26470 26471 /* Public */ 26472 /* http://imakewebthings.com/waypoints/api/viewport-height */ 26473 Waypoint.viewportHeight = function() { 26474 return window.innerHeight || document.documentElement.clientHeight 26475 } 26476 26477 /* Public */ 26478 /* http://imakewebthings.com/waypoints/api/viewport-width */ 26479 Waypoint.viewportWidth = function() { 26480 return document.documentElement.clientWidth 26481 } 26482 26483 Waypoint.adapters = [] 26484 26485 Waypoint.defaults = { 26486 context: window, 26487 continuous: true, 26488 enabled: true, 26489 group: 'default', 26490 horizontal: false, 26491 offset: 0 26492 } 26493 26494 Waypoint.offsetAliases = { 26495 'bottom-in-view': function() { 26496 return this.context.innerHeight() - this.adapter.outerHeight() 26497 }, 26498 'right-in-view': function() { 26499 return this.context.innerWidth() - this.adapter.outerWidth() 26500 } 26501 } 26502 26503 window.Waypoint = Waypoint 26504}()) 26505;(function() { 26506 'use strict' 26507 26508 function requestAnimationFrameShim(callback) { 26509 window.setTimeout(callback, 1000 / 60) 26510 } 26511 26512 var keyCounter = 0 26513 var contexts = {} 26514 var Waypoint = window.Waypoint 26515 var oldWindowLoad = window.onload 26516 26517 /* http://imakewebthings.com/waypoints/api/context */ 26518 function Context(element) { 26519 this.element = element 26520 this.Adapter = Waypoint.Adapter 26521 this.adapter = new this.Adapter(element) 26522 this.key = 'waypoint-context-' + keyCounter 26523 this.didScroll = false 26524 this.didResize = false 26525 this.oldScroll = { 26526 x: this.adapter.scrollLeft(), 26527 y: this.adapter.scrollTop() 26528 } 26529 this.waypoints = { 26530 vertical: {}, 26531 horizontal: {} 26532 } 26533 26534 element.waypointContextKey = this.key 26535 contexts[element.waypointContextKey] = this 26536 keyCounter += 1 26537 if (!Waypoint.windowContext) { 26538 Waypoint.windowContext = true 26539 Waypoint.windowContext = new Context(window) 26540 } 26541 26542 this.createThrottledScrollHandler() 26543 this.createThrottledResizeHandler() 26544 } 26545 26546 /* Private */ 26547 Context.prototype.add = function(waypoint) { 26548 var axis = waypoint.options.horizontal ? 'horizontal' : 'vertical' 26549 this.waypoints[axis][waypoint.key] = waypoint 26550 this.refresh() 26551 } 26552 26553 /* Private */ 26554 Context.prototype.checkEmpty = function() { 26555 var horizontalEmpty = this.Adapter.isEmptyObject(this.waypoints.horizontal) 26556 var verticalEmpty = this.Adapter.isEmptyObject(this.waypoints.vertical) 26557 var isWindow = this.element == this.element.window 26558 if (horizontalEmpty && verticalEmpty && !isWindow) { 26559 this.adapter.off('.waypoints') 26560 delete contexts[this.key] 26561 } 26562 } 26563 26564 /* Private */ 26565 Context.prototype.createThrottledResizeHandler = function() { 26566 var self = this 26567 26568 function resizeHandler() { 26569 self.handleResize() 26570 self.didResize = false 26571 } 26572 26573 this.adapter.on('resize.waypoints', function() { 26574 if (!self.didResize) { 26575 self.didResize = true 26576 Waypoint.requestAnimationFrame(resizeHandler) 26577 } 26578 }) 26579 } 26580 26581 /* Private */ 26582 Context.prototype.createThrottledScrollHandler = function() { 26583 var self = this 26584 function scrollHandler() { 26585 self.handleScroll() 26586 self.didScroll = false 26587 } 26588 26589 this.adapter.on('scroll.waypoints', function() { 26590 if (!self.didScroll || Waypoint.isTouch) { 26591 self.didScroll = true 26592 Waypoint.requestAnimationFrame(scrollHandler) 26593 } 26594 }) 26595 } 26596 26597 /* Private */ 26598 Context.prototype.handleResize = function() { 26599 Waypoint.Context.refreshAll() 26600 } 26601 26602 /* Private */ 26603 Context.prototype.handleScroll = function() { 26604 var triggeredGroups = {} 26605 var axes = { 26606 horizontal: { 26607 newScroll: this.adapter.scrollLeft(), 26608 oldScroll: this.oldScroll.x, 26609 forward: 'right', 26610 backward: 'left' 26611 }, 26612 vertical: { 26613 newScroll: this.adapter.scrollTop(), 26614 oldScroll: this.oldScroll.y, 26615 forward: 'down', 26616 backward: 'up' 26617 } 26618 } 26619 26620 for (var axisKey in axes) { 26621 var axis = axes[axisKey] 26622 var isForward = axis.newScroll > axis.oldScroll 26623 var direction = isForward ? axis.forward : axis.backward 26624
26625 for (var waypointKey in this.waypoints[axisKey]) { 26626 var waypoint = this.waypoints[axisKey][waypointKey] 26627 if (waypoint.triggerPoint === null) { 26628 continue 26629 } 26630 var wasBeforeTriggerPoint = axis.oldScroll < waypoint.triggerPoint 26631 var nowAfterTriggerPoint = axis.newScroll >= waypoint.triggerPoint 26632 var crossedForward = wasBeforeTriggerPoint && nowAfterTriggerPoint 26633 var crossedBackward = !wasBeforeTriggerPoint && !nowAfterTriggerPoint 26634 if (crossedForward || crossedBackward) { 26635 waypoint.queueTrigger(direction) 26636 triggeredGroups[waypoint.group.id] = waypoint.group 26637 } 26638 } 26639 } 26640 26641 for (var groupKey in triggeredGroups) { 26642 triggeredGroups[groupKey].flushTriggers() 26643 } 26644 26645 this.oldScroll = { 26646 x: axes.horizontal.newScroll, 26647 y: axes.vertical.newScroll 26648 } 26649 } 26650 26651 /* Private */ 26652 Context.prototype.innerHeight = function() { 26653 /*eslint-disable eqeqeq */ 26654 if (this.element == this.element.window) { 26655 return Waypoint.viewportHeight() 26656 } 26657 /*eslint-enable eqeqeq */ 26658 return this.adapter.innerHeight() 26659 } 26660 26661 /* Private */ 26662 Context.prototype.remove = function(waypoint) { 26663 delete this.waypoints[waypoint.axis][waypoint.key] 26664 this.checkEmpty() 26665 } 26666 26667 /* Private */ 26668 Context.prototype.innerWidth = function() { 26669 /*eslint-disable eqeqeq */ 26670 if (this.element == this.element.window) { 26671 return Waypoint.viewportWidth() 26672 } 26673 /*eslint-enable eqeqeq */ 26674 return this.adapter.innerWidth() 26675 } 26676 26677 /* Public */ 26678 /* http://imakewebthings.com/waypoints/api/context-destroy */ 26679 Context.prototype.destroy = function() { 26680 var allWaypoints = [] 26681 for (var axis in this.waypoints) {
26682 for (var waypointKey in this.waypoints[axis]) { 26683 allWaypoints.push(this.waypoints[axis][waypointKey]) 26684 } 26685 } 26686 for (var i = 0, end = allWaypoints.length; i < end; i++) { 26687 allWaypoints[i].destroy() 26688 } 26689 } 26690 26691 /* Public */ 26692 /* http://imakewebthings.com/waypoints/api/context-refresh */ 26693 Context.prototype.refresh = function() { 26694 /*eslint-disable eqeqeq */ 26695 var isWindow = this.element == this.element.window 26696 /*eslint-enable eqeqeq */ 26697 var contextOffset = isWindow ? undefined : this.adapter.offset() 26698 var triggeredGroups = {} 26699 var axes 26700 26701 this.handleScroll() 26702 axes = { 26703 horizontal: { 26704 contextOffset: isWindow ? 0 : contextOffset.left, 26705 contextScroll: isWindow ? 0 : this.oldScroll.x, 26706 contextDimension: this.innerWidth(), 26707 oldScroll: this.oldScroll.x, 26708 forward: 'right', 26709 backward: 'left', 26710 offsetProp: 'left' 26711 }, 26712 vertical: { 26713 contextOffset: isWindow ? 0 : contextOffset.top, 26714 contextScroll: isWindow ? 0 : this.oldScroll.y, 26715 contextDimension: this.innerHeight(), 26716 oldScroll: this.oldScroll.y, 26717 forward: 'down', 26718 backward: 'up', 26719 offsetProp: 'top' 26720 } 26721 } 26722 26723 for (var axisKey in axes) { 26724 var axis = axes[axisKey]
26725 for (var waypointKey in this.waypoints[axisKey]) { 26726 var waypoint = this.waypoints[axisKey][waypointKey] 26727 var adjustment = waypoint.options.offset 26728 var oldTriggerPoint = waypoint.triggerPoint 26729 var elementOffset = 0 26730 var freshWaypoint = oldTriggerPoint == null 26731 var contextModifier, wasBeforeScroll, nowAfterScroll 26732 var triggeredBackward, triggeredForward 26733 26734 if (waypoint.element !== waypoint.element.window) { 26735 elementOffset = waypoint.adapter.offset()[axis.offsetProp] 26736 } 26737 26738 if (typeof adjustment === 'function') { 26739 adjustment = adjustment.apply(waypoint) 26740 } 26741 else if (typeof adjustment === 'string') { 26742 adjustment = parseFloat(adjustment) 26743 if (waypoint.options.offset.indexOf('%') > - 1) { 26744 adjustment = Math.ceil(axis.contextDimension * adjustment / 100) 26745 } 26746 } 26747 26748 contextModifier = axis.contextScroll - axis.contextOffset 26749 waypoint.triggerPoint = Math.floor(elementOffset + contextModifier - adjustment) 26750 wasBeforeScroll = oldTriggerPoint < axis.oldScroll 26751 nowAfterScroll = waypoint.triggerPoint >= axis.oldScroll 26752 triggeredBackward = wasBeforeScroll && nowAfterScroll 26753 triggeredForward = !wasBeforeScroll && !nowAfterScroll 26754 26755 if (!freshWaypoint && triggeredBackward) { 26756 waypoint.queueTrigger(axis.backward) 26757 triggeredGroups[waypoint.group.id] = waypoint.group 26758 } 26759 else if (!freshWaypoint && triggeredForward) { 26760 waypoint.queueTrigger(axis.forward) 26761 triggeredGroups[waypoint.group.id] = waypoint.group 26762 } 26763 else if (freshWaypoint && axis.oldScroll >= waypoint.triggerPoint) { 26764 waypoint.queueTrigger(axis.forward) 26765 triggeredGroups[waypoint.group.id] = waypoint.group 26766 } 26767 } 26768 } 26769 26770 Waypoint.requestAnimationFrame(function() { 26771 for (var groupKey in triggeredGroups) { 26772 triggeredGroups[groupKey].flushTriggers() 26773 } 26774 }) 26775 26776 return this 26777 } 26778 26779 /* Private */ 26780 Context.findOrCreateByElement = function(element) { 26781 return Context.findByElement(element) || new Context(element) 26782 } 26783 26784 /* Private */ 26785 Context.refreshAll = function() { 26786 for (var contextId in contexts) { 26787 contexts[contextId].refresh() 26788 } 26789 } 26790 26791 /* Public */ 26792 /* http://imakewebthings.com/waypoints/api/context-find-by-element */ 26793 Context.findByElement = function(element) { 26794 return contexts[element.waypointContextKey] 26795 } 26796 26797 window.onload = function() { 26798 if (oldWindowLoad) { 26799 oldWindowLoad() 26800 } 26801 Context.refreshAll() 26802 } 26803 26804 26805 Waypoint.requestAnimationFrame = function(callback) { 26806 var requestFn = window.requestAnimationFrame || 26807 window.mozRequestAnimationFrame || 26808 window.webkitRequestAnimationFrame || 26809 requestAnimationFrameShim 26810 requestFn.call(window, callback) 26811 } 26812 Waypoint.Context = Context 26813}()) 26814;(function() { 26815 'use strict' 26816 26817 function byTriggerPoint(a, b) { 26818 return a.triggerPoint - b.triggerPoint 26819 } 26820 26821 function byReverseTriggerPoint(a, b) { 26822 return b.triggerPoint - a.triggerPoint 26823 } 26824 26825 var groups = { 26826 vertical: {}, 26827 horizontal: {} 26828 } 26829 var Waypoint = window.Waypoint 26830 26831 /* http://imakewebthings.com/waypoints/api/group */ 26832 function Group(options) { 26833 this.name = options.name 26834 this.axis = options.axis 26835 this.id = this.name + '-' + this.axis 26836 this.waypoints = [] 26837 this.clearTriggerQueues() 26838 groups[this.axis][this.name] = this 26839 } 26840 26841 /* Private */ 26842 Group.prototype.add = function(waypoint) { 26843 this.waypoints.push(waypoint) 26844 } 26845 26846 /* Private */ 26847 Group.prototype.clearTriggerQueues = function() { 26848 this.triggerQueues = { 26849 up: [], 26850 down: [], 26851 left: [], 26852 right: [] 26853 } 26854 } 26855 26856 /* Private */ 26857 Group.prototype.flushTriggers = function() { 26858 for (var direction in this.triggerQueues) { 26859 var waypoints = this.triggerQueues[direction] 26860 var reverse = direction === 'up' || direction === 'left' 26861 waypoints.sort(reverse ? byReverseTriggerPoint : byTriggerPoint) 26862 for (var i = 0, end = waypoints.length; i < end; i += 1) { 26863 var waypoint = waypoints[i] 26864 if (waypoint.options.continuous || i === waypoints.length - 1) { 26865 waypoint.trigger([direction]) 26866 } 26867 } 26868 } 26869 this.clearTriggerQueues() 26870 } 26871 26872 /* Private */ 26873 Group.prototype.next = function(waypoint) { 26874 this.waypoints.sort(byTriggerPoint) 26875 var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) 26876 var isLast = index === this.waypoints.length - 1 26877 return isLast ? null : this.waypoints[index + 1] 26878 } 26879 26880 /* Private */ 26881 Group.prototype.previous = function(waypoint) { 26882 this.waypoints.sort(byTriggerPoint) 26883 var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) 26884 return index ? this.waypoints[index - 1] : null 26885 } 26886 26887 /* Private */ 26888 Group.prototype.queueTrigger = function(waypoint, direction) { 26889 this.triggerQueues[direction].push(waypoint) 26890 } 26891 26892 /* Private */ 26893 Group.prototype.remove = function(waypoint) { 26894 var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) 26895 if (index > -1) { 26896 this.waypoints.splice(index, 1) 26897 } 26898 } 26899 26900 /* Public */ 26901 /* http://imakewebthings.com/waypoints/api/first */ 26902 Group.prototype.first = function() { 26903 return this.waypoints[0] 26904 } 26905 26906 /* Public */ 26907 /* http://imakewebthings.com/waypoints/api/last */ 26908 Group.prototype.last = function() { 26909 return this.waypoints[this.waypoints.length - 1] 26910 } 26911 26912 /* Private */ 26913 Group.findOrCreate = function(options) { 26914 return groups[options.axis][options.name] || new Group(options) 26915 } 26916 26917 Waypoint.Group = Group 26918}()) 26919;(function() { 26920 'use strict' 26921 26922 var $ = window.jQuery 26923 var Waypoint = window.Waypoint 26924 26925 function JQueryAdapter(element) { 26926 this.$element = $(element) 26927 } 26928 26929 $.each([
26930 'innerHeight', 26931 'innerWidth', 26932 'off', 26933 'offset', 26934 'on', 26935 'outerHeight', 26936 'outerWidth', 26937 'scrollLeft', 26938 'scrollTop' 26939 ], function(i, method) { 26940 JQueryAdapter.prototype[method] = function() { 26941 var args = Array.prototype.slice.call(arguments) 26942 return this.$element[method].apply(this.$element, args) 26943 } 26944 }) 26945 26946 $.each([ 26947 'extend', 26948 'inArray', 26949 'isEmptyObject' 26950 ], function(i, method) { 26951 JQueryAdapter[method] = $[method] 26952 }) 26953 26954 Waypoint.adapters.push({ 26955 name: 'jquery', 26956 Adapter: JQueryAdapter 26957 }) 26958 Waypoint.Adapter = JQueryAdapter 26959}()) 26960;(function() { 26961 'use strict' 26962 26963 var Waypoint = window.Waypoint 26964 26965 function createExtension(framework) { 26966 return function() { 26967 var waypoints = [] 26968 var overrides = arguments[0] 26969 26970 if (framework.isFunction(arguments[0])) { 26971 overrides = framework.extend({}, arguments[1]) 26972 overrides.handler = arguments[0] 26973 } 26974 26975 this.each(function() { 26976 var options = framework.extend({}, overrides, { 26977 element: this 26978 }) 26979 if (typeof options.context === 'string') { 26980 options.context = framework(this).closest(options.context)[0] 26981 } 26982 waypoints.push(new Waypoint(options)) 26983 }) 26984 26985 return waypoints 26986 } 26987 } 26988 26989 if (window.jQuery) { 26990 window.jQuery.fn.waypoint = createExtension(window.jQuery) 26991 } 26992 if (window.Zepto) { 26993 window.Zepto.fn.waypoint = createExtension(window.Zepto) 26994 } 26995}()) 26996; 26997/*! luxy.js v0.0.7 | (c) 2018 Mineo Okuda | MIT License | git+ssh://[email protected]:min30327/luxy.git */ 26998!(function(t,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.luxy=e()})(this,(function(){"use strict";var t={wrapper:"#luxy",targets:".luxy-el",wrapperSpeed:.08,targetSpeed:.02,targetPercentage:.1},e=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;window.requestAnimationFrame=e;var i=window.cancelAnimationFrame||window.mozCancelAnimationFrame,s=function(){for(var t={},e=0,i=arguments.length;e<i;e++){var s=arguments[e];!(function(e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(s)}return t},r=function(){this.Targets=[],this.TargetsLength=0,this.wrapper="",this.windowHeight=0,this.wapperOffset=0};return r.prototype={isAnimate:!1,isResize:!1,scrollId:"",resizeId:"",init:function(e){if(this.settings=s(t,e||{}),this.wrapper=document.querySelector(this.settings.wrapper),"undefined"===this.wrapper)return!1;this.targets=document.querySelectorAll(this.settings.targets),document.body.style.height=this.wrapper.clientHeight+"px",this.windowHeight=window.clientHeight,this.attachEvent(),this.apply(this.targets,this.wrapper),this.animate(),this.resize()},apply:function(t,e){this.wrapperInit(),this.targetsLength=t.length;for(var i=0;i<this.targetsLength;i++){var s={offset:t[i].getAttribute("data-offset"),speedX:t[i].getAttribute("data-speed-x"),speedY:t[i].getAttribute("data-speed-Y"),percentage:t[i].getAttribute("data-percentage"),horizontal:t[i].getAttribute("data-horizontal")};this.targetsInit(t[i],s)}},wrapperInit:function(){this.wrapper.style.width="100%",this.wrapper.style.position="fixed"},targetsInit:function(t,e){this.Targets.push({elm:t,offset:e.offset?e.offset:0,horizontal:e.horizontal?e.horizontal:0,top:0,left:0,speedX:e.speedX?e.speedX:1,speedY:e.speedY?e.speedY:1,percentage:e.percentage?e.percentage:0})},scroll:function(){document.documentElement.scrollTop||document.body.scrollTop;this.scrollTop=document.documentElement.scrollTop||document.body.scrollTop;this.scrollTop,this.windowHeight;this.wrapperUpdate(this.scrollTop);for(var t=0;t<this.Targets.length;t++)this.targetsUpdate(this.Targets[t])},animate:function(){this.scroll(),this.scrollId=e(this.animate.bind(this))},wrapperUpdate:function(){this.wapperOffset+=(this.scrollTop-this.wapperOffset)*this.settings.wrapperSpeed,this.wrapper.style.transform="translate3d(0,"+Math.round(100*-this.wapperOffset)/100+"px ,0)"},targetsUpdate:function(t){t.top+=(this.scrollTop*Number(this.settings.targetSpeed)*Number(t.speedY)-t.to
vendor: 908 bytes, line 26998
26998p)*this.settings.targetPercentage,t.left+=(this.scrollTop*Number(this.settings.targetSpeed)*Number(t.speedX)-t.left)*this.settings.targetPercentage;var e=parseInt(t.percentage)-t.top-parseInt(t.offset),i=Math.round(-100*e)/100,s=0;if(t.horizontal){var r=parseInt(t.percentage)-t.left-parseInt(t.offset);s=Math.round(-100*r)/100}t.elm.style.transform="translate3d("+s+"px ,"+i+"px ,0)"},resize:function(){var t=this;t.windowHeight=window.innerHeight||document.documentElement.clientHeight||0,parseInt(t.wrapper.clientHeight)!=parseInt(document.body.style.height)&&(document.body.style.height=t.wrapper.clientHeight+"px"),t.resizeId=e(t.resize.bind(t))},attachEvent:function(){var t=this;window.addEventListener("resize",(function(){t.isResize||(i(t.resizeId),i(t.scrollId),t.isResize=!0,setTimeout((function(){t.isResize=!1,t.resizeId=e(t.resize.bind(t)),t.scrollId=e(t.animate.bind(t))}),200))}))}},new r}));
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.