1/*! 2 * jQuery JavaScript Library v1.12.4 3 * http://jquery.com/ 4 * 5 * Includes Sizzle.js 6 * http://sizzlejs.com/ 7 * 8 * Copyright jQuery Foundation and other contributors 9 * Released under the MIT license 10 * http://jquery.org/license 11 * 12 * Date: 2016-05-20T17:17Z 13 */ 14 15 16(function( global, factory ) { 17 18 if ( typeof module === "object" && typeof module.exports === "object" ) { 19 // For CommonJS and CommonJS-like environments where a proper `window` 20 // is present, execute the factory and get jQuery. 21 // For environments that do not have a `window` with a `document` 22 // (such as Node.js), expose a factory as module.exports. 23 // This accentuates the need for the creation of a real `window`. 24 // e.g. var jQuery = require("jquery")(window); 25 // See ticket #14549 for more info. 26 module.exports = global.document ? 27 factory( global, true ) : 28 function( w ) { 29 if ( !w.document ) { 30 throw new Error( "jQuery requires a window with a document" ); 31 } 32 return factory( w ); 33 }; 34 } else { 35 factory( global ); 36 } 37 38// Pass this if window is not defined yet 39}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { 40 41// Support: Firefox 18+ 42// Can't be in strict mode, several libs including ASP.NET trace 43// the stack via arguments.caller.callee and Firefox dies if 44// you try to trace through "use strict" call chains. (#13335) 45//"use strict"; 46var deletedIds = []; 47 48var document = window.document; 49 50var slice = deletedIds.slice; 51 52var concat = deletedIds.concat; 53 54var push = deletedIds.push; 55 56var indexOf = deletedIds.indexOf; 57 58var class2type = {}; 59 60var toString = class2type.toString; 61 62var hasOwn = class2type.hasOwnProperty; 63 64var support = {}; 65 66 67 68var 69 version = "1.12.4", 70 71 // Define a local copy of jQuery 72 jQuery = function( selector, context ) { 73 74 // The jQuery object is actually just the init constructor 'enhanced' 75 // Need init if jQuery is called (just allow error to be thrown if not included) 76 return new jQuery.fn.init( selector, context ); 77 }, 78 79 // Support: Android<4.1, IE<9 80 // Make sure we trim BOM and NBSP 81 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, 82 83 // Matches dashed string for camelizing 84 rmsPrefix = /^-ms-/, 85 rdashAlpha = /-([\da-z])/gi, 86 87 // Used by jQuery.camelCase as callback to replace() 88 fcamelCase = function( all, letter ) { 89 return letter.toUpperCase(); 90 }; 91 92jQuery.fn = jQuery.prototype = { 93 94 // The current version of jQuery being used 95 jquery: version, 96 97 constructor: jQuery, 98 99 // Start with an empty selector 100 selector: "", 101 102 // The default length of a jQuery object is 0 103 length: 0, 104 105 toArray: function() { 106 return slice.call( this ); 107 }, 108 109 // Get the Nth element in the matched element set OR 110 // Get the whole matched element set as a clean array 111 get: function( num ) { 112 return num != null ? 113 114 // Return just the one element from the set 115 ( num < 0 ? this[ num + this.length ] : this[ num ] ) : 116 117 // Return all the elements in a clean array 118 slice.call( this ); 119 }, 120 121 // Take an array of elements and push it onto the stack 122 // (returning the new matched element set) 123 pushStack: function( elems ) { 124 125 // Build a new jQuery matched element set 126 var ret = jQuery.merge( this.constructor(), elems ); 127 128 // Add the old object onto the stack (as a reference) 129 ret.prevObject = this; 130 ret.context = this.context; 131 132 // Return the newly-formed element set 133 return ret; 134 }, 135 136 // Execute a callback for every element in the matched set. 137 each: function( callback ) { 138 return jQuery.each( this, callback ); 139 }, 140 141 map: function( callback ) { 142 return this.pushStack( jQuery.map( this, function( elem, i ) { 143 return callback.call( elem, i, elem ); 144 } ) ); 145 }, 146 147 slice: function() { 148 return this.pushStack( slice.apply( this, arguments ) ); 149 }, 150 151 first: function() { 152 return this.eq( 0 ); 153 }, 154 155 last: function() { 156 return this.eq( -1 ); 157 }, 158 159 eq: function( i ) { 160 var len = this.length, 161 j = +i + ( i < 0 ? len : 0 ); 162 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); 163 }, 164 165 end: function() { 166 return this.prevObject || this.constructor(); 167 }, 168 169 // For internal use only. 170 // Behaves like an Array's method, not like a jQuery method. 171 push: push, 172 sort: deletedIds.sort, 173 splice: deletedIds.splice 174}; 175 176jQuery.extend = jQuery.fn.extend = function() { 177 var src, copyIsArray, copy, name, options, clone, 178 target = arguments[ 0 ] || {}, 179 i = 1, 180 length = arguments.length, 181 deep = false;
182 183 // Handle a deep copy situation 184 if ( typeof target === "boolean" ) { 185 deep = target; 186 187 // skip the boolean and the target 188 target = arguments[ i ] || {}; 189 i++; 190 } 191 192 // Handle case when target is a string or something (possible in deep copy) 193 if ( typeof target !== "object" && !jQuery.isFunction( target ) ) { 194 target = {}; 195 } 196 197 // extend jQuery itself if only one argument is passed 198 if ( i === length ) { 199 target = this; 200 i--; 201 } 202 203 for ( ; i < length; i++ ) { 204 205 // Only deal with non-null/undefined values 206 if ( ( options = arguments[ i ] ) != null ) { 207 208 // Extend the base object 209 for ( name in options ) { 210 src = target[ name ]; 211 copy = options[ name ]; 212 213 // Prevent never-ending loop 214 if ( target === copy ) { 215 continue; 216 } 217 218 // Recurse if we're merging plain objects or arrays 219 if ( deep && copy && ( jQuery.isPlainObject( copy ) || 220 ( copyIsArray = jQuery.isArray( copy ) ) ) ) { 221 222 if ( copyIsArray ) { 223 copyIsArray = false; 224 clone = src && jQuery.isArray( src ) ? src : []; 225 226 } else { 227 clone = src && jQuery.isPlainObject( src ) ? src : {}; 228 } 229 230 // Never move original objects, clone them 231 target[ name ] = jQuery.extend( deep, clone, copy ); 232 233 // Don't bring in undefined values 234 } else if ( copy !== undefined ) { 235 target[ name ] = copy; 236 } 237 } 238 } 239 } 240 241 // Return the modified object 242 return target; 243}; 244 245jQuery.extend( { 246 247 // Unique for each copy of jQuery on the page 248 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), 249 250 // Assume jQuery is ready without the ready module 251 isReady: true, 252 253 error: function( msg ) { 254 throw new Error( msg ); 255 }, 256 257 noop: function() {}, 258 259 // See test/unit/core.js for details concerning isFunction. 260 // Since version 1.3, DOM methods and functions like alert 261 // aren't supported. They return false on IE (#2968). 262 isFunction: function( obj ) { 263 return jQuery.type( obj ) === "function"; 264 }, 265 266 isArray: Array.isArray || function( obj ) { 267 return jQuery.type( obj ) === "array"; 268 }, 269 270 isWindow: function( obj ) { 271 /* jshint eqeqeq: false */ 272 return obj != null && obj == obj.window; 273 }, 274 275 isNumeric: function( obj ) { 276 277 // parseFloat NaNs numeric-cast false positives (null|true|false|"") 278 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") 279 // subtraction forces infinities to NaN 280 // adding 1 corrects loss of precision from parseFloat (#15100) 281 var realStringObj = obj && obj.toString(); 282 return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0; 283 }, 284 285 isEmptyObject: function( obj ) { 286 var name; 287 for ( name in obj ) { 288 return false; 289 } 290 return true; 291 }, 292 293 isPlainObject: function( obj ) { 294 var key; 295 296 // Must be an Object. 297 // Because of IE, we also have to check the presence of the constructor property. 298 // Make sure that DOM nodes and window objects don't pass through, as well 299 if ( !obj || jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { 300 return false; 301 } 302 303 try { 304 305 // Not own constructor property must be Object 306 if ( obj.constructor && 307 !hasOwn.call( obj, "constructor" ) && 308 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) { 309 return false; 310 } 311 } catch ( e ) { 312 313 // IE8,9 Will throw exceptions on certain host objects #9897 314 return false; 315 } 316 317 // Support: IE<9 318 // Handle iteration over inherited properties before own properties. 319 if ( !support.ownFirst ) { 320 for ( key in obj ) { 321 return hasOwn.call( obj, key ); 322 } 323 } 324 325 // Own properties are enumerated firstly, so to speed up, 326 // if last one is own, then all properties are own. 327 for ( key in obj ) {} 328 329 return key === undefined || hasOwn.call( obj, key ); 330 }, 331 332 type: function( obj ) { 333 if ( obj == null ) { 334 return obj + ""; 335 } 336 return typeof obj === "object" || typeof obj === "function" ? 337 class2type[ toString.call( obj ) ] || "object" : 338 typeof obj; 339 }, 340 341 // Workarounds based on findings by Jim Driscoll 342 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context 343 globalEval: function( data ) { 344 if ( data && jQuery.trim( data ) ) { 345 346 // We use execScript on Internet Explorer 347 // We use an anonymous function so that context is window 348 // rather than jQuery in Firefox 349 ( window.execScript || function( data ) { 350 window[ "eval" ].call( window, data ); // jscs:ignore requireDotNotation 351 } )( data ); 352 } 353 }, 354 355 // Convert dashed to camelCase; used by the css and data modules 356 // Microsoft forgot to hump their vendor prefix (#9572) 357 camelCase: function( string ) { 358 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); 359 }, 360
361 nodeName: function( elem, name ) { 362 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); 363 }, 364 365 each: function( obj, callback ) { 366 var length, i = 0; 367 368 if ( isArrayLike( obj ) ) { 369 length = obj.length; 370 for ( ; i < length; i++ ) { 371 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 372 break; 373 } 374 } 375 } else { 376 for ( i in obj ) { 377 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 378 break; 379 } 380 } 381 } 382 383 return obj; 384 }, 385 386 // Support: Android<4.1, IE<9 387 trim: function( text ) { 388 return text == null ? 389 "" : 390 ( text + "" ).replace( rtrim, "" ); 391 }, 392 393 // results is for internal usage only 394 makeArray: function( arr, results ) { 395 var ret = results || []; 396 397 if ( arr != null ) { 398 if ( isArrayLike( Object( arr ) ) ) { 399 jQuery.merge( ret, 400 typeof arr === "string" ? 401 [ arr ] : arr 402 ); 403 } else { 404 push.call( ret, arr ); 405 } 406 } 407 408 return ret; 409 }, 410 411 inArray: function( elem, arr, i ) { 412 var len; 413 414 if ( arr ) { 415 if ( indexOf ) { 416 return indexOf.call( arr, elem, i ); 417 } 418 419 len = arr.length; 420 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; 421 422 for ( ; i < len; i++ ) { 423 424 // Skip accessing in sparse arrays 425 if ( i in arr && arr[ i ] === elem ) { 426 return i; 427 } 428 } 429 } 430 431 return -1; 432 }, 433 434 merge: function( first, second ) { 435 var len = +second.length, 436 j = 0, 437 i = first.length; 438 439 while ( j < len ) { 440 first[ i++ ] = second[ j++ ]; 441 } 442 443 // Support: IE<9 444 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists) 445 if ( len !== len ) { 446 while ( second[ j ] !== undefined ) { 447 first[ i++ ] = second[ j++ ]; 448 } 449 } 450 451 first.length = i; 452 453 return first; 454 }, 455 456 grep: function( elems, callback, invert ) { 457 var callbackInverse, 458 matches = [], 459 i = 0, 460 length = elems.length, 461 callbackExpect = !invert; 462 463 // Go through the array, only saving the items 464 // that pass the validator function 465 for ( ; i < length; i++ ) { 466 callbackInverse = !callback( elems[ i ], i ); 467 if ( callbackInverse !== callbackExpect ) { 468 matches.push( elems[ i ] ); 469 } 470 } 471 472 return matches; 473 }, 474 475 // arg is for internal usage only 476 map: function( elems, callback, arg ) { 477 var length, value, 478 i = 0, 479 ret = []; 480 481 // Go through the array, translating each of the items to their new values 482 if ( isArrayLike( elems ) ) { 483 length = elems.length; 484 for ( ; i < length; i++ ) { 485 value = callback( elems[ i ], i, arg ); 486 487 if ( value != null ) { 488 ret.push( value ); 489 } 490 } 491 492 // Go through every key on the object, 493 } else { 494 for ( i in elems ) { 495 value = callback( elems[ i ], i, arg ); 496 497 if ( value != null ) { 498 ret.push( value ); 499 } 500 } 501 } 502 503 // Flatten any nested arrays 504 return concat.apply( [], ret ); 505 }, 506 507 // A global GUID counter for objects 508 guid: 1, 509 510 // Bind a function to a context, optionally partially applying any 511 // arguments. 512 proxy: function( fn, context ) { 513 var args, proxy, tmp; 514 515 if ( typeof context === "string" ) { 516 tmp = fn[ context ]; 517 context = fn; 518 fn = tmp; 519 } 520 521 // Quick check to determine if target is callable, in the spec 522 // this throws a TypeError, but we will just return undefined. 523 if ( !jQuery.isFunction( fn ) ) { 524 return undefined; 525 } 526 527 // Simulated bind 528 args = slice.call( arguments, 2 ); 529 proxy = function() { 530 return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); 531 }; 532 533 // Set the guid of unique handler to the same of original handler, so it can be removed 534 proxy.guid = fn.guid = fn.guid || jQuery.guid++; 535 536 return proxy; 537 }, 538 539 now: function() { 540 return +( new Date() ); 541 }, 542 543 // jQuery.support is not used in Core but other projects attach their 544 // properties to it so it needs to exist. 545 support: support 546} ); 547 548// JSHint would error on this code due to the Symbol not being defined in ES5. 549// Defining this global in .jshintrc would create a danger of using the global 550// unguarded in another place, it seems safer to just disable JSHint for these 551// three lines. 552/* jshint ignore: start */ 553if ( typeof Symbol === "function" ) { 554 jQuery.fn[ Symbol.iterator ] = deletedIds[ Symbol.iterator ]; 555} 556/* jshint ignore: end */ 557 558// Populate the class2type map 559jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), 560function( i, name ) { 561 class2type[ "[object " + name + "]" ] = name.toLowerCase(); 562} ); 563 564function isArrayLike( obj ) { 565 566 // Support: iOS 8.2 (not reproducible in simulator) 567 // `in` check used to prevent JIT error (gh-2145) 568 // hasOwn isn't used here due to false negatives 569 // regarding Nodelist length in IE 570 var length = !!obj && "length" in obj && obj.length, 571 type = jQuery.type( obj ); 572 573 if ( type === "function" || jQuery.isWindow( obj ) ) { 574 return false;
575 } 576 577 return type === "array" || length === 0 || 578 typeof length === "number" && length > 0 && ( length - 1 ) in obj; 579} 580var Sizzle = 581/*! 582 * Sizzle CSS Selector Engine v2.2.1 583 * http://sizzlejs.com/ 584 * 585 * Copyright jQuery Foundation and other contributors 586 * Released under the MIT license 587 * http://jquery.org/license 588 * 589 * Date: 2015-10-17 590 */ 591(function( window ) { 592 593var i, 594 support, 595 Expr, 596 getText, 597 isXML, 598 tokenize, 599 compile, 600 select, 601 outermostContext, 602 sortInput, 603 hasDuplicate, 604 605 // Local document vars 606 setDocument, 607 document, 608 docElem, 609 documentIsHTML, 610 rbuggyQSA, 611 rbuggyMatches, 612 matches, 613 contains, 614 615 // Instance-specific data 616 expando = "sizzle" + 1 * new Date(), 617 preferredDoc = window.document, 618 dirruns = 0, 619 done = 0, 620 classCache = createCache(), 621 tokenCache = createCache(), 622 compilerCache = createCache(), 623 sortOrder = function( a, b ) { 624 if ( a === b ) { 625 hasDuplicate = true; 626 } 627 return 0; 628 }, 629 630 // General-purpose constants 631 MAX_NEGATIVE = 1 << 31, 632 633 // Instance methods 634 hasOwn = ({}).hasOwnProperty, 635 arr = [], 636 pop = arr.pop, 637 push_native = arr.push, 638 push = arr.push, 639 slice = arr.slice, 640 // Use a stripped-down indexOf as it's faster than native 641 // http://jsperf.com/thor-indexof-vs-for/5 642 indexOf = function( list, elem ) { 643 var i = 0, 644 len = list.length; 645 for ( ; i < len; i++ ) { 646 if ( list[i] === elem ) { 647 return i; 648 } 649 } 650 return -1; 651 }, 652 653 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", 654 655 // Regular expressions 656 657 // http://www.w3.org/TR/css3-selectors/#whitespace 658 whitespace = "[\\x20\\t\\r\\n\\f]", 659 660 // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier 661 identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", 662 663 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors 664 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + 665 // Operator (capture 2) 666 "*([*^$|!~]?=)" + whitespace + 667 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" 668 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + 669 "*\\]", 670 671 pseudos = ":(" + identifier + ")(?:\\((" + 672 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: 673 // 1. quoted (capture 3; capture 4 or capture 5) 674 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + 675 // 2. simple (capture 6) 676 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + 677 // 3. anything else (capture 2) 678 ".*" + 679 ")\\)|)", 680 681 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter 682 rwhitespace = new RegExp( whitespace + "+", "g" ), 683 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), 684 685 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), 686 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), 687 688 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), 689 690 rpseudo = new RegExp( pseudos ), 691 ridentifier = new RegExp( "^" + identifier + "$" ), 692 693 matchExpr = { 694 "ID": new RegExp( "^#(" + identifier + ")" ), 695 "CLASS": new RegExp( "^\\.(" + identifier + ")" ), 696 "TAG": new RegExp( "^(" + identifier + "|[*])" ), 697 "ATTR": new RegExp( "^" + attributes ), 698 "PSEUDO": new RegExp( "^" + pseudos ), 699 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + 700 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + 701 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), 702 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), 703 // For use in libraries implementing .is() 704 // We use this for POS matching in `select` 705 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + 706 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) 707 }, 708 709 rinputs = /^(?:input|select|textarea|button)$/i, 710 rheader = /^h\d$/i, 711 712 rnative = /^[^{]+\{\s*\[native \w/, 713 714 // Easily-parseable/retrievable ID or TAG or CLASS selectors 715 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, 716 717 rsibling = /[+~]/, 718 rescape = /'|\\/g, 719 720 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters 721 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), 722 funescape = function( _, escaped, escapedWhitespace ) { 723 var high = "0x" + escaped - 0x10000; 724 // NaN means non-codepoint
725 // Support: Firefox<24 726 // Workaround erroneous numeric interpretation of +"0x" 727 return high !== high || escapedWhitespace ? 728 escaped : 729 high < 0 ? 730 // BMP codepoint 731 String.fromCharCode( high + 0x10000 ) : 732 // Supplemental Plane codepoint (surrogate pair) 733 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); 734 }, 735 736 // Used for iframes 737 // See setDocument() 738 // Removing the function wrapper causes a "Permission Denied" 739 // error in IE 740 unloadHandler = function() { 741 setDocument(); 742 }; 743 744// Optimize for push.apply( _, NodeList ) 745try { 746 push.apply( 747 (arr = slice.call( preferredDoc.childNodes )), 748 preferredDoc.childNodes 749 ); 750 // Support: Android<4.0 751 // Detect silently failing push.apply 752 arr[ preferredDoc.childNodes.length ].nodeType; 753} catch ( e ) { 754 push = { apply: arr.length ? 755 756 // Leverage slice if possible 757 function( target, els ) { 758 push_native.apply( target, slice.call(els) ); 759 } : 760 761 // Support: IE<9 762 // Otherwise append directly 763 function( target, els ) { 764 var j = target.length, 765 i = 0; 766 // Can't trust NodeList.length 767 while ( (target[j++] = els[i++]) ) {} 768 target.length = j - 1; 769 } 770 }; 771} 772 773function Sizzle( selector, context, results, seed ) { 774 var m, i, elem, nid, nidselect, match, groups, newSelector, 775 newContext = context && context.ownerDocument, 776 777 // nodeType defaults to 9, since context defaults to document 778 nodeType = context ? context.nodeType : 9; 779 780 results = results || []; 781 782 // Return early from calls with invalid selector or context 783 if ( typeof selector !== "string" || !selector || 784 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { 785 786 return results; 787 } 788 789 // Try to shortcut find operations (as opposed to filters) in HTML documents 790 if ( !seed ) { 791 792 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { 793 setDocument( context ); 794 } 795 context = context || document; 796 797 if ( documentIsHTML ) { 798 799 // If the selector is sufficiently simple, try using a "get*By*" DOM method 800 // (excepting DocumentFragment context, where the methods don't exist) 801 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { 802 803 // ID selector 804 if ( (m = match[1]) ) { 805 806 // Document context 807 if ( nodeType === 9 ) { 808 if ( (elem = context.getElementById( m )) ) { 809 810 // Support: IE, Opera, Webkit 811 // TODO: identify versions 812 // getElementById can match elements by name instead of ID 813 if ( elem.id === m ) { 814 results.push( elem ); 815 return results; 816 } 817 } else { 818 return results; 819 } 820 821 // Element context 822 } else { 823 824 // Support: IE, Opera, Webkit 825 // TODO: identify versions 826 // getElementById can match elements by name instead of ID 827 if ( newContext && (elem = newContext.getElementById( m )) && 828 contains( context, elem ) && 829 elem.id === m ) { 830 831 results.push( elem ); 832 return results; 833 } 834 } 835 836 // Type selector 837 } else if ( match[2] ) { 838 push.apply( results, context.getElementsByTagName( selector ) ); 839 return results; 840 841 // Class selector 842 } else if ( (m = match[3]) && support.getElementsByClassName && 843 context.getElementsByClassName ) { 844 845 push.apply( results, context.getElementsByClassName( m ) ); 846 return results; 847 } 848 } 849 850 // Take advantage of querySelectorAll 851 if ( support.qsa && 852 !compilerCache[ selector + " " ] && 853 (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { 854 855 if ( nodeType !== 1 ) { 856 newContext = context; 857 newSelector = selector; 858 859 // qSA looks outside Element context, which is not what we want 860 // Thanks to Andrew Dupont for this workaround technique 861 // Support: IE <=8 862 // Exclude object elements 863 } else if ( context.nodeName.toLowerCase() !== "object" ) { 864 865 // Capture the context ID, setting it first if necessary 866 if ( (nid = context.getAttribute( "id" )) ) { 867 nid = nid.replace( rescape, "\\$&" ); 868 } else { 869 context.setAttribute( "id", (nid = expando) ); 870 } 871 872 // Prefix every selector in the list 873 groups = tokenize( selector ); 874 i = groups.length; 875 nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']"; 876 while ( i-- ) { 877 groups[i] = nidselect + " " + toSelector( groups[i] ); 878 } 879 newSelector = groups.join( "," ); 880 881 // Expand context for sibling selectors
882 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || 883 context; 884 } 885 886 if ( newSelector ) { 887 try { 888 push.apply( results, 889 newContext.querySelectorAll( newSelector ) 890 ); 891 return results; 892 } catch ( qsaError ) { 893 } finally { 894 if ( nid === expando ) { 895 context.removeAttribute( "id" ); 896 } 897 } 898 } 899 } 900 } 901 } 902 903 // All others 904 return select( selector.replace( rtrim, "$1" ), context, results, seed ); 905} 906 907/** 908 * Create key-value caches of limited size 909 * @returns {function(string, object)} Returns the Object data after storing it on itself with 910 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) 911 * deleting the oldest entry 912 */ 913function createCache() { 914 var keys = []; 915 916 function cache( key, value ) { 917 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) 918 if ( keys.push( key + " " ) > Expr.cacheLength ) { 919 // Only keep the most recent entries 920 delete cache[ keys.shift() ]; 921 } 922 return (cache[ key + " " ] = value); 923 } 924 return cache; 925} 926 927/** 928 * Mark a function for special use by Sizzle 929 * @param {Function} fn The function to mark 930 */ 931function markFunction( fn ) { 932 fn[ expando ] = true; 933 return fn; 934} 935 936/** 937 * Support testing using an element 938 * @param {Function} fn Passed the created div and expects a boolean result 939 */ 940function assert( fn ) { 941 var div = document.createElement("div"); 942 943 try { 944 return !!fn( div ); 945 } catch (e) { 946 return false; 947 } finally { 948 // Remove from its parent by default 949 if ( div.parentNode ) { 950 div.parentNode.removeChild( div ); 951 } 952 // release memory in IE 953 div = null; 954 } 955} 956 957/** 958 * Adds the same handler for all of the specified attrs 959 * @param {String} attrs Pipe-separated list of attributes 960 * @param {Function} handler The method that will be applied 961 */ 962function addHandle( attrs, handler ) { 963 var arr = attrs.split("|"), 964 i = arr.length; 965 966 while ( i-- ) { 967 Expr.attrHandle[ arr[i] ] = handler; 968 } 969} 970 971/** 972 * Checks document order of two siblings 973 * @param {Element} a 974 * @param {Element} b 975 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b 976 */ 977function siblingCheck( a, b ) { 978 var cur = b && a, 979 diff = cur && a.nodeType === 1 && b.nodeType === 1 && 980 ( ~b.sourceIndex || MAX_NEGATIVE ) - 981 ( ~a.sourceIndex || MAX_NEGATIVE ); 982 983 // Use IE sourceIndex if available on both nodes 984 if ( diff ) { 985 return diff; 986 } 987 988 // Check if b follows a 989 if ( cur ) { 990 while ( (cur = cur.nextSibling) ) { 991 if ( cur === b ) { 992 return -1; 993 } 994 } 995 } 996 997 return a ? 1 : -1; 998} 999 1000/** 1001 * Returns a function to use in pseudos for input types 1002 * @param {String} type 1003 */ 1004function createInputPseudo( type ) { 1005 return function( elem ) { 1006 var name = elem.nodeName.toLowerCase(); 1007 return name === "input" && elem.type === type; 1008 }; 1009} 1010 1011/** 1012 * Returns a function to use in pseudos for buttons 1013 * @param {String} type 1014 */ 1015function createButtonPseudo( type ) { 1016 return function( elem ) { 1017 var name = elem.nodeName.toLowerCase(); 1018 return (name === "input" || name === "button") && elem.type === type; 1019 }; 1020} 1021 1022/** 1023 * Returns a function to use in pseudos for positionals 1024 * @param {Function} fn 1025 */ 1026function createPositionalPseudo( fn ) { 1027 return markFunction(function( argument ) { 1028 argument = +argument; 1029 return markFunction(function( seed, matches ) { 1030 var j, 1031 matchIndexes = fn( [], seed.length, argument ), 1032 i = matchIndexes.length; 1033 1034 // Match elements found at the specified indexes 1035 while ( i-- ) { 1036 if ( seed[ (j = matchIndexes[i]) ] ) { 1037 seed[j] = !(matches[j] = seed[j]); 1038 } 1039 } 1040 }); 1041 }); 1042} 1043 1044/** 1045 * Checks a node for validity as a Sizzle context 1046 * @param {Element|Object=} context 1047 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value 1048 */ 1049function testContext( context ) { 1050 return context && typeof context.getElementsByTagName !== "undefined" && context; 1051} 1052 1053// Expose support vars for convenience 1054support = Sizzle.support = {}; 1055 1056/** 1057 * Detects XML nodes 1058 * @param {Element|Object} elem An element or a document 1059 * @returns {Boolean} True iff elem is a non-HTML XML node 1060 */ 1061isXML = Sizzle.isXML = function( elem ) { 1062 // documentElement is verified for cases where it doesn't yet exist 1063 // (such as loading iframes in IE - #4833) 1064 var documentElement = elem && (elem.ownerDocument || elem).documentElement; 1065 return documentElement ? documentElement.nodeName !== "HTML" : false;
1066}; 1067 1068/** 1069 * Sets document-related variables once based on the current document 1070 * @param {Element|Object} [doc] An element or document object to use to set the document 1071 * @returns {Object} Returns the current document 1072 */ 1073setDocument = Sizzle.setDocument = function( node ) { 1074 var hasCompare, parent, 1075 doc = node ? node.ownerDocument || node : preferredDoc; 1076 1077 // Return early if doc is invalid or already selected 1078 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { 1079 return document; 1080 } 1081 1082 // Update global variables 1083 document = doc; 1084 docElem = document.documentElement; 1085 documentIsHTML = !isXML( document ); 1086 1087 // Support: IE 9-11, Edge 1088 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) 1089 if ( (parent = document.defaultView) && parent.top !== parent ) { 1090 // Support: IE 11 1091 if ( parent.addEventListener ) { 1092 parent.addEventListener( "unload", unloadHandler, false ); 1093 1094 // Support: IE 9 - 10 only 1095 } else if ( parent.attachEvent ) { 1096 parent.attachEvent( "onunload", unloadHandler ); 1097 } 1098 } 1099 1100 /* Attributes 1101 ---------------------------------------------------------------------- */ 1102 1103 // Support: IE<8 1104 // Verify that getAttribute really returns attributes and not properties 1105 // (excepting IE8 booleans) 1106 support.attributes = assert(function( div ) { 1107 div.className = "i"; 1108 return !div.getAttribute("className"); 1109 }); 1110 1111 /* getElement(s)By* 1112 ---------------------------------------------------------------------- */ 1113 1114 // Check if getElementsByTagName("*") returns only elements 1115 support.getElementsByTagName = assert(function( div ) { 1116 div.appendChild( document.createComment("") ); 1117 return !div.getElementsByTagName("*").length; 1118 }); 1119 1120 // Support: IE<9 1121 support.getElementsByClassName = rnative.test( document.getElementsByClassName ); 1122 1123 // Support: IE<10 1124 // Check if getElementById returns elements by name 1125 // The broken getElementById methods don't pick up programatically-set names, 1126 // so use a roundabout getElementsByName test 1127 support.getById = assert(function( div ) { 1128 docElem.appendChild( div ).id = expando; 1129 return !document.getElementsByName || !document.getElementsByName( expando ).length; 1130 }); 1131 1132 // ID find and filter 1133 if ( support.getById ) { 1134 Expr.find["ID"] = function( id, context ) { 1135 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 1136 var m = context.getElementById( id ); 1137 return m ? [ m ] : []; 1138 } 1139 }; 1140 Expr.filter["ID"] = function( id ) { 1141 var attrId = id.replace( runescape, funescape ); 1142 return function( elem ) { 1143 return elem.getAttribute("id") === attrId; 1144 }; 1145 }; 1146 } else {
1147 // Support: IE6/7 1148 // getElementById is not reliable as a find shortcut 1149 delete Expr.find["ID"]; 1150 1151 Expr.filter["ID"] = function( id ) { 1152 var attrId = id.replace( runescape, funescape ); 1153 return function( elem ) { 1154 var node = typeof elem.getAttributeNode !== "undefined" && 1155 elem.getAttributeNode("id"); 1156 return node && node.value === attrId; 1157 }; 1158 }; 1159 } 1160 1161 // Tag 1162 Expr.find["TAG"] = support.getElementsByTagName ? 1163 function( tag, context ) { 1164 if ( typeof context.getElementsByTagName !== "undefined" ) { 1165 return context.getElementsByTagName( tag ); 1166 1167 // DocumentFragment nodes don't have gEBTN 1168 } else if ( support.qsa ) { 1169 return context.querySelectorAll( tag ); 1170 } 1171 } : 1172 1173 function( tag, context ) { 1174 var elem, 1175 tmp = [], 1176 i = 0, 1177 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too 1178 results = context.getElementsByTagName( tag ); 1179 1180 // Filter out possible comments 1181 if ( tag === "*" ) { 1182 while ( (elem = results[i++]) ) { 1183 if ( elem.nodeType === 1 ) { 1184 tmp.push( elem ); 1185 } 1186 } 1187 1188 return tmp; 1189 } 1190 return results; 1191 }; 1192 1193 // Class 1194 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { 1195 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { 1196 return context.getElementsByClassName( className ); 1197 } 1198 }; 1199 1200 /* QSA/matchesSelector 1201 ---------------------------------------------------------------------- */ 1202 1203 // QSA and matchesSelector support 1204 1205 // matchesSelector(:active) reports false when true (IE9/Opera 11.5) 1206 rbuggyMatches = []; 1207 1208 // qSa(:focus) reports false when true (Chrome 21) 1209 // We allow this because of a bug in IE8/9 that throws an error 1210 // whenever `document.activeElement` is accessed on an iframe 1211 // So, we allow :focus to pass through QSA all the time to avoid the IE error 1212 // See http://bugs.jquery.com/ticket/13378 1213 rbuggyQSA = []; 1214 1215 if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { 1216 // Build QSA regex 1217 // Regex strategy adopted from Diego Perini 1218 assert(function( div ) { 1219 // Select is set to empty string on purpose 1220 // This is to test IE's treatment of not explicitly 1221 // setting a boolean content attribute, 1222 // since its presence should be enough 1223 // http://bugs.jquery.com/ticket/12359 1224 docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" + 1225 "<select id='" + expando + "-\r\\' msallowcapture=''>" + 1226 "<option selected=''></option></select>"; 1227 1228 // Support: IE8, Opera 11-12.16 1229 // Nothing should be selected when empty strings follow ^= or $= or *= 1230 // The test attribute must be unknown in Opera but "safe" for WinRT 1231 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section 1232 if ( div.querySelectorAll("[msallowcapture^='']").length ) { 1233 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); 1234 } 1235 1236 // Support: IE8 1237 // Boolean attributes and "value" are not treated correctly 1238 if ( !div.querySelectorAll("[selected]").length ) { 1239 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); 1240 } 1241 1242 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ 1243 if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { 1244 rbuggyQSA.push("~="); 1245 } 1246 1247 // Webkit/Opera - :checked should return selected option elements 1248 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 1249 // IE8 throws error here and will not see later tests 1250 if ( !div.querySelectorAll(":checked").length ) { 1251 rbuggyQSA.push(":checked"); 1252 } 1253 1254 // Support: Safari 8+, iOS 8+ 1255 // https://bugs.webkit.org/show_bug.cgi?id=136851 1256 // In-page `selector#id sibing-combinator selector` fails 1257 if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { 1258 rbuggyQSA.push(".#.+[+~]"); 1259 } 1260 }); 1261 1262 assert(function( div ) { 1263 // Support: Windows 8 Native Apps 1264 // The type and name attributes are restricted during .innerHTML assignment 1265 var input = document.createElement("input"); 1266 input.setAttribute( "type", "hidden" ); 1267 div.appendChild( input ).setAttribute( "name", "D" ); 1268
1269 // Support: IE8 1270 // Enforce case-sensitivity of name attribute 1271 if ( div.querySelectorAll("[name=d]").length ) { 1272 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); 1273 } 1274 1275 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) 1276 // IE8 throws error here and will not see later tests 1277 if ( !div.querySelectorAll(":enabled").length ) { 1278 rbuggyQSA.push( ":enabled", ":disabled" ); 1279 } 1280 1281 // Opera 10-11 does not throw on post-comma invalid pseudos 1282 div.querySelectorAll("*,:x"); 1283 rbuggyQSA.push(",.*:"); 1284 }); 1285 } 1286 1287 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || 1288 docElem.webkitMatchesSelector || 1289 docElem.mozMatchesSelector || 1290 docElem.oMatchesSelector || 1291 docElem.msMatchesSelector) )) ) { 1292 1293 assert(function( div ) { 1294 // Check to see if it's possible to do matchesSelector 1295 // on a disconnected node (IE 9) 1296 support.disconnectedMatch = matches.call( div, "div" ); 1297 1298 // This should fail with an exception 1299 // Gecko does not error, returns false instead 1300 matches.call( div, "[s!='']:x" ); 1301 rbuggyMatches.push( "!=", pseudos ); 1302 }); 1303 } 1304 1305 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); 1306 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); 1307 1308 /* Contains 1309 ---------------------------------------------------------------------- */ 1310 hasCompare = rnative.test( docElem.compareDocumentPosition ); 1311 1312 // Element contains another 1313 // Purposefully self-exclusive 1314 // As in, an element does not contain itself 1315 contains = hasCompare || rnative.test( docElem.contains ) ? 1316 function( a, b ) { 1317 var adown = a.nodeType === 9 ? a.documentElement : a, 1318 bup = b && b.parentNode; 1319 return a === bup || !!( bup && bup.nodeType === 1 && ( 1320 adown.contains ? 1321 adown.contains( bup ) : 1322 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 1323 )); 1324 } : 1325 function( a, b ) { 1326 if ( b ) { 1327 while ( (b = b.parentNode) ) { 1328 if ( b === a ) { 1329 return true; 1330 } 1331 } 1332 } 1333 return false; 1334 }; 1335 1336 /* Sorting 1337 ---------------------------------------------------------------------- */ 1338 1339 // Document order sorting 1340 sortOrder = hasCompare ? 1341 function( a, b ) { 1342 1343 // Flag for duplicate removal 1344 if ( a === b ) { 1345 hasDuplicate = true; 1346 return 0; 1347 } 1348 1349 // Sort on method existence if only one input has compareDocumentPosition 1350 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; 1351 if ( compare ) { 1352 return compare; 1353 } 1354 1355 // Calculate position if both inputs belong to the same document 1356 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? 1357 a.compareDocumentPosition( b ) : 1358 1359 // Otherwise we know they are disconnected 1360 1; 1361 1362 // Disconnected nodes 1363 if ( compare & 1 || 1364 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { 1365 1366 // Choose the first element that is related to our preferred document 1367 if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { 1368 return -1; 1369 } 1370 if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { 1371 return 1; 1372 } 1373 1374 // Maintain original order 1375 return sortInput ? 1376 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 1377 0; 1378 } 1379 1380 return compare & 4 ? -1 : 1; 1381 } : 1382 function( a, b ) { 1383 // Exit early if the nodes are identical 1384 if ( a === b ) { 1385 hasDuplicate = true; 1386 return 0; 1387 } 1388 1389 var cur, 1390 i = 0, 1391 aup = a.parentNode, 1392 bup = b.parentNode, 1393 ap = [ a ], 1394 bp = [ b ]; 1395 1396 // Parentless nodes are either documents or disconnected 1397 if ( !aup || !bup ) { 1398 return a === document ? -1 : 1399 b === document ? 1 : 1400 aup ? -1 : 1401 bup ? 1 : 1402 sortInput ? 1403 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 1404 0; 1405 1406 // If the nodes are siblings, we can do a quick check 1407 } else if ( aup === bup ) { 1408 return siblingCheck( a, b ); 1409 } 1410 1411 // Otherwise we need full lists of their ancestors for comparison 1412 cur = a; 1413 while ( (cur = cur.parentNode) ) { 1414 ap.unshift( cur ); 1415 } 1416 cur = b; 1417 while ( (cur = cur.parentNode) ) { 1418 bp.unshift( cur ); 1419 } 1420 1421 // Walk down the tree looking for a discrepancy 1422 while ( ap[i] === bp[i] ) { 1423 i++; 1424 } 1425 1426 return i ? 1427 // Do a sibling check if the nodes have a common ancestor 1428 siblingCheck( ap[i], bp[i] ) : 1429 1430 // Otherwise nodes in our document sort first 1431 ap[i] === preferredDoc ? -1 : 1432 bp[i] === preferredDoc ? 1 : 1433 0; 1434 }; 1435 1436 return document; 1437}; 1438 1439Sizzle.matches = function( expr, elements ) { 1440 return Sizzle( expr, null, null, elements ); 1441}; 1442 1443Sizzle.matchesSelector = function( elem, expr ) { 1444 // Set document vars if needed 1445 if ( ( elem.ownerDocument || elem ) !== document ) { 1446 setDocument( elem ); 1447 } 1448 1449 // Make sure that attribute selectors are quoted 1450 expr = expr.replace( rattributeQuotes, "='$1']" ); 1451 1452 if ( support.matchesSelector && documentIsHTML && 1453 !compilerCache[ expr + " " ] && 1454 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && 1455 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { 1456 1457 try { 1458 var ret = matches.call( elem, expr ); 1459 1460 // IE 9's matchesSelector returns false on disconnected nodes 1461 if ( ret || support.disconnectedMatch || 1462 // As well, disconnected nodes are said to be in a document 1463 // fragment in IE 9 1464 elem.document && elem.document.nodeType !== 11 ) { 1465 return ret; 1466 } 1467 } catch (e) {} 1468 } 1469 1470 return Sizzle( expr, document, null, [ elem ] ).length > 0; 1471}; 1472 1473Sizzle.contains = function( context, elem ) { 1474 // Set document vars if needed 1475 if ( ( context.ownerDocument || context ) !== document ) { 1476 setDocument( context ); 1477 } 1478 return contains( context, elem ); 1479}; 1480 1481Sizzle.attr = function( elem, name ) { 1482 // Set document vars if needed 1483 if ( ( elem.ownerDocument || elem ) !== document ) { 1484 setDocument( elem ); 1485 } 1486 1487 var fn = Expr.attrHandle[ name.toLowerCase() ], 1488 // Don't get fooled by Object.prototype properties (jQuery #13807) 1489 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? 1490 fn( elem, name, !documentIsHTML ) : 1491 undefined; 1492 1493 return val !== undefined ? 1494 val : 1495 support.attributes || !documentIsHTML ? 1496 elem.getAttribute( name ) : 1497 (val = elem.getAttributeNode(name)) && val.specified ? 1498 val.value : 1499 null; 1500}; 1501 1502Sizzle.error = function( msg ) { 1503 throw new Error( "Syntax error, unrecognized expression: " + msg ); 1504}; 1505 1506/** 1507 * Document sorting and removing duplicates 1508 * @param {ArrayLike} results 1509 */ 1510Sizzle.uniqueSort = function( results ) { 1511 var elem, 1512 duplicates = [], 1513 j = 0, 1514 i = 0; 1515 1516 // Unless we *know* we can detect duplicates, assume their presence 1517 hasDuplicate = !support.detectDuplicates; 1518 sortInput = !support.sortStable && results.slice( 0 ); 1519 results.sort( sortOrder ); 1520 1521 if ( hasDuplicate ) { 1522 while ( (elem = results[i++]) ) { 1523 if ( elem === results[ i ] ) { 1524 j = duplicates.push( i ); 1525 } 1526 } 1527 while ( j-- ) { 1528 results.splice( duplicates[ j ], 1 ); 1529 } 1530 } 1531 1532 // Clear input after sorting to release objects 1533 // See https://github.com/jquery/sizzle/pull/225 1534 sortInput = null; 1535 1536 return results; 1537}; 1538 1539/** 1540 * Utility function for retrieving the text value of an array of DOM nodes 1541 * @param {Array|Element} elem 1542 */ 1543getText = Sizzle.getText = function( elem ) { 1544 var node, 1545 ret = "", 1546 i = 0, 1547 nodeType = elem.nodeType; 1548 1549 if ( !nodeType ) { 1550 // If no nodeType, this is expected to be an array 1551 while ( (node = elem[i++]) ) {
1552 // Do not traverse comment nodes 1553 ret += getText( node ); 1554 } 1555 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { 1556 // Use textContent for elements 1557 // innerText usage removed for consistency of new lines (jQuery #11153) 1558 if ( typeof elem.textContent === "string" ) { 1559 return elem.textContent; 1560 } else { 1561 // Traverse its children 1562 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 1563 ret += getText( elem ); 1564 } 1565 } 1566 } else if ( nodeType === 3 || nodeType === 4 ) { 1567 return elem.nodeValue; 1568 } 1569 // Do not include comment or processing instruction nodes 1570 1571 return ret; 1572}; 1573 1574Expr = Sizzle.selectors = { 1575 1576 // Can be adjusted by the user 1577 cacheLength: 50, 1578 1579 createPseudo: markFunction, 1580 1581 match: matchExpr, 1582 1583 attrHandle: {}, 1584 1585 find: {}, 1586 1587 relative: { 1588 ">": { dir: "parentNode", first: true }, 1589 " ": { dir: "parentNode" }, 1590 "+": { dir: "previousSibling", first: true }, 1591 "~": { dir: "previousSibling" } 1592 }, 1593 1594 preFilter: { 1595 "ATTR": function( match ) { 1596 match[1] = match[1].replace( runescape, funescape ); 1597 1598 // Move the given value to match[3] whether quoted or unquoted 1599 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); 1600 1601 if ( match[2] === "~=" ) { 1602 match[3] = " " + match[3] + " "; 1603 } 1604 1605 return match.slice( 0, 4 ); 1606 }, 1607 1608 "CHILD": function( match ) { 1609 /* matches from matchExpr["CHILD"] 1610 1 type (only|nth|...) 1611 2 what (child|of-type) 1612 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) 1613 4 xn-component of xn+y argument ([+-]?\d*n|) 1614 5 sign of xn-component 1615 6 x of xn-component 1616 7 sign of y-component 1617 8 y of y-component 1618 */ 1619 match[1] = match[1].toLowerCase(); 1620 1621 if ( match[1].slice( 0, 3 ) === "nth" ) { 1622 // nth-* requires argument 1623 if ( !match[3] ) { 1624 Sizzle.error( match[0] ); 1625 } 1626 1627 // numeric x and y parameters for Expr.filter.CHILD 1628 // remember that false/true cast respectively to 0/1 1629 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); 1630 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); 1631 1632 // other types prohibit arguments 1633 } else if ( match[3] ) { 1634 Sizzle.error( match[0] ); 1635 } 1636 1637 return match; 1638 }, 1639 1640 "PSEUDO": function( match ) { 1641 var excess, 1642 unquoted = !match[6] && match[2]; 1643 1644 if ( matchExpr["CHILD"].test( match[0] ) ) { 1645 return null; 1646 } 1647 1648 // Accept quoted arguments as-is 1649 if ( match[3] ) { 1650 match[2] = match[4] || match[5] || ""; 1651 1652 // Strip excess characters from unquoted arguments 1653 } else if ( unquoted && rpseudo.test( unquoted ) && 1654 // Get excess from tokenize (recursively) 1655 (excess = tokenize( unquoted, true )) && 1656 // advance to the next closing parenthesis 1657 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { 1658 1659 // excess is a negative index 1660 match[0] = match[0].slice( 0, excess ); 1661 match[2] = unquoted.slice( 0, excess ); 1662 } 1663 1664 // Return only captures needed by the pseudo filter method (type and argument) 1665 return match.slice( 0, 3 ); 1666 } 1667 }, 1668 1669 filter: { 1670 1671 "TAG": function( nodeNameSelector ) { 1672 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); 1673 return nodeNameSelector === "*" ? 1674 function() { return true; } : 1675 function( elem ) { 1676 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; 1677 }; 1678 }, 1679 1680 "CLASS": function( className ) { 1681 var pattern = classCache[ className + " " ]; 1682 1683 return pattern || 1684 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && 1685 classCache( className, function( elem ) { 1686 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); 1687 }); 1688 }, 1689 1690 "ATTR": function( name, operator, check ) { 1691 return function( elem ) { 1692 var result = Sizzle.attr( elem, name ); 1693 1694 if ( result == null ) { 1695 return operator === "!="; 1696 } 1697 if ( !operator ) { 1698 return true; 1699 } 1700 1701 result += ""; 1702 1703 return operator === "=" ? result === check : 1704 operator === "!=" ? result !== check :
1705 operator === "^=" ? check && result.indexOf( check ) === 0 : 1706 operator === "*=" ? check && result.indexOf( check ) > -1 : 1707 operator === "$=" ? check && result.slice( -check.length ) === check : 1708 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : 1709 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : 1710 false; 1711 }; 1712 }, 1713 1714 "CHILD": function( type, what, argument, first, last ) { 1715 var simple = type.slice( 0, 3 ) !== "nth", 1716 forward = type.slice( -4 ) !== "last", 1717 ofType = what === "of-type"; 1718 1719 return first === 1 && last === 0 ? 1720 1721 // Shortcut for :nth-*(n) 1722 function( elem ) { 1723 return !!elem.parentNode; 1724 } : 1725 1726 function( elem, context, xml ) { 1727 var cache, uniqueCache, outerCache, node, nodeIndex, start, 1728 dir = simple !== forward ? "nextSibling" : "previousSibling", 1729 parent = elem.parentNode, 1730 name = ofType && elem.nodeName.toLowerCase(), 1731 useCache = !xml && !ofType, 1732 diff = false;
vendor: 6,763 bytes, lines 1733-1950
1733 1734 if ( parent ) { 1735 1736 // :(first|last|only)-(child|of-type) 1737 if ( simple ) { 1738 while ( dir ) { 1739 node = elem; 1740 while ( (node = node[ dir ]) ) { 1741 if ( ofType ? 1742 node.nodeName.toLowerCase() === name : 1743 node.nodeType === 1 ) { 1744 1745 return false; 1746 } 1747 } 1748 // Reverse direction for :only-* (if we haven't yet done so) 1749 start = dir = type === "only" && !start && "nextSibling"; 1750 } 1751 return true; 1752 } 1753 1754 start = [ forward ? parent.firstChild : parent.lastChild ]; 1755 1756 // non-xml :nth-child(...) stores cache data on `parent` 1757 if ( forward && useCache ) { 1758 1759 // Seek `elem` from a previously-cached index 1760 1761 // ...in a gzip-friendly way 1762 node = parent; 1763 outerCache = node[ expando ] || (node[ expando ] = {}); 1764 1765 // Support: IE <9 only 1766 // Defend against cloned attroperties (jQuery gh-1709) 1767 uniqueCache = outerCache[ node.uniqueID ] || 1768 (outerCache[ node.uniqueID ] = {}); 1769 1770 cache = uniqueCache[ type ] || []; 1771 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 1772 diff = nodeIndex && cache[ 2 ]; 1773 node = nodeIndex && parent.childNodes[ nodeIndex ]; 1774 1775 while ( (node = ++nodeIndex && node && node[ dir ] || 1776 1777 // Fallback to seeking `elem` from the start 1778 (diff = nodeIndex = 0) || start.pop()) ) { 1779 1780 // When found, cache indexes on `parent` and break 1781 if ( node.nodeType === 1 && ++diff && node === elem ) { 1782 uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; 1783 break; 1784 } 1785 } 1786 1787 } else { 1788 // Use previously-cached element index if available 1789 if ( useCache ) { 1790 // ...in a gzip-friendly way 1791 node = elem; 1792 outerCache = node[ expando ] || (node[ expando ] = {}); 1793 1794 // Support: IE <9 only 1795 // Defend against cloned attroperties (jQuery gh-1709) 1796 uniqueCache = outerCache[ node.uniqueID ] || 1797 (outerCache[ node.uniqueID ] = {}); 1798 1799 cache = uniqueCache[ type ] || []; 1800 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 1801 diff = nodeIndex; 1802 } 1803 1804 // xml :nth-child(...) 1805 // or :nth-last-child(...) or :nth(-last)?-of-type(...) 1806 if ( diff === false ) { 1807 // Use the same loop as above to seek `elem` from the start 1808 while ( (node = ++nodeIndex && node && node[ dir ] || 1809 (diff = nodeIndex = 0) || start.pop()) ) { 1810 1811 if ( ( ofType ? 1812 node.nodeName.toLowerCase() === name : 1813 node.nodeType === 1 ) && 1814 ++diff ) { 1815 1816 // Cache the index of each encountered element 1817 if ( useCache ) { 1818 outerCache = node[ expando ] || (node[ expando ] = {}); 1819 1820 // Support: IE <9 only 1821 // Defend against cloned attroperties (jQuery gh-1709) 1822 uniqueCache = outerCache[ node.uniqueID ] || 1823 (outerCache[ node.uniqueID ] = {}); 1824 1825 uniqueCache[ type ] = [ dirruns, diff ]; 1826 } 1827 1828 if ( node === elem ) { 1829 break; 1830 } 1831 } 1832 } 1833 } 1834 } 1835 1836 // Incorporate the offset, then check against cycle size 1837 diff -= last; 1838 return diff === first || ( diff % first === 0 && diff / first >= 0 ); 1839 } 1840 }; 1841 }, 1842 1843 "PSEUDO": function( pseudo, argument ) { 1844 // pseudo-class names are case-insensitive 1845 // http://www.w3.org/TR/selectors/#pseudo-classes 1846 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters 1847 // Remember that setFilters inherits from pseudos 1848 var args, 1849 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || 1850 Sizzle.error( "unsupported pseudo: " + pseudo ); 1851 1852 // The user may use createPseudo to indicate that 1853 // arguments are needed to create the filter function 1854 // just as Sizzle does 1855 if ( fn[ expando ] ) { 1856 return fn( argument ); 1857 } 1858 1859 // But maintain support for old signatures 1860 if ( fn.length > 1 ) { 1861 args = [ pseudo, pseudo, "", argument ]; 1862 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? 1863 markFunction(function( seed, matches ) { 1864 var idx, 1865 matched = fn( seed, argument ), 1866 i = matched.length; 1867 while ( i-- ) { 1868 idx = indexOf( seed, matched[i] ); 1869 seed[ idx ] = !( matches[ idx ] = matched[i] ); 1870 } 1871 }) : 1872 function( elem ) { 1873 return fn( elem, 0, args ); 1874 }; 1875 } 1876 1877 return fn; 1878 } 1879 }, 1880 1881 pseudos: { 1882 // Potentially complex pseudos 1883 "not": markFunction(function( selector ) { 1884 // Trim the selector passed to compile 1885 // to avoid treating leading and trailing 1886 // spaces as combinators 1887 var input = [], 1888 results = [], 1889 matcher = compile( selector.replace( rtrim, "$1" ) ); 1890 1891 return matcher[ expando ] ? 1892 markFunction(function( seed, matches, context, xml ) { 1893 var elem, 1894 unmatched = matcher( seed, null, xml, [] ), 1895 i = seed.length; 1896 1897 // Match elements unmatched by `matcher` 1898 while ( i-- ) { 1899 if ( (elem = unmatched[i]) ) { 1900 seed[i] = !(matches[i] = elem); 1901 } 1902 } 1903 }) : 1904 function( elem, context, xml ) { 1905 input[0] = elem; 1906 matcher( input, null, xml, results ); 1907 // Don't keep the element (issue #299) 1908 input[0] = null; 1909 return !results.pop(); 1910 }; 1911 }), 1912 1913 "has": markFunction(function( selector ) { 1914 return function( elem ) { 1915 return Sizzle( selector, elem ).length > 0; 1916 }; 1917 }), 1918 1919 "contains": markFunction(function( text ) { 1920 text = text.replace( runescape, funescape ); 1921 return function( elem ) { 1922 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; 1923 }; 1924 }), 1925 1926 // "Whether an element is represented by a :lang() selector 1927 // is based solely on the element's language value 1928 // being equal to the identifier C, 1929 // or beginning with the identifier C immediately followed by "-". 1930 // The matching of C against the element's language value is performed case-insensitively. 1931 // The identifier C does not have to be a valid language name." 1932 // http://www.w3.org/TR/selectors/#lang-pseudo 1933 "lang": markFunction( function( lang ) { 1934 // lang value must be a valid identifier 1935 if ( !ridentifier.test(lang || "") ) { 1936 Sizzle.error( "unsupported lang: " + lang ); 1937 } 1938 lang = lang.replace( runescape, funescape ).toLowerCase(); 1939 return function( elem ) { 1940 var elemLang; 1941 do { 1942 if ( (elemLang = documentIsHTML ? 1943 elem.lang : 1944 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { 1945 1946 elemLang = elemLang.toLowerCase(); 1947 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; 1948 } 1949 } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); 1950 return false;
1951 }; 1952 }), 1953 1954 // Miscellaneous 1955 "target": function( elem ) { 1956 var hash = window.location && window.location.hash; 1957 return hash && hash.slice( 1 ) === elem.id; 1958 }, 1959 1960 "root": function( elem ) { 1961 return elem === docElem; 1962 }, 1963 1964 "focus": function( elem ) { 1965 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); 1966 }, 1967 1968 // Boolean properties 1969 "enabled": function( elem ) { 1970 return elem.disabled === false; 1971 }, 1972 1973 "disabled": function( elem ) { 1974 return elem.disabled === true; 1975 }, 1976 1977 "checked": function( elem ) { 1978 // In CSS3, :checked should return both checked and selected elements 1979 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 1980 var nodeName = elem.nodeName.toLowerCase(); 1981 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); 1982 }, 1983 1984 "selected": function( elem ) { 1985 // Accessing this property makes selected-by-default 1986 // options in Safari work properly 1987 if ( elem.parentNode ) { 1988 elem.parentNode.selectedIndex; 1989 } 1990 1991 return elem.selected === true; 1992 }, 1993 1994 // Contents 1995 "empty": function( elem ) { 1996 // http://www.w3.org/TR/selectors/#empty-pseudo 1997 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), 1998 // but not by others (comment: 8; processing instruction: 7; etc.) 1999 // nodeType < 6 works because attributes (2) do not appear as children 2000 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 2001 if ( elem.nodeType < 6 ) { 2002 return false; 2003 } 2004 } 2005 return true; 2006 }, 2007 2008 "parent": function( elem ) { 2009 return !Expr.pseudos["empty"]( elem ); 2010 }, 2011 2012 // Element/input types 2013 "header": function( elem ) { 2014 return rheader.test( elem.nodeName ); 2015 }, 2016 2017 "input": function( elem ) { 2018 return rinputs.test( elem.nodeName ); 2019 }, 2020 2021 "button": function( elem ) { 2022 var name = elem.nodeName.toLowerCase(); 2023 return name === "input" && elem.type === "button" || name === "button"; 2024 }, 2025 2026 "text": function( elem ) { 2027 var attr; 2028 return elem.nodeName.toLowerCase() === "input" && 2029 elem.type === "text" && 2030 2031 // Support: IE<8 2032 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" 2033 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); 2034 }, 2035 2036 // Position-in-collection 2037 "first": createPositionalPseudo(function() { 2038 return [ 0 ]; 2039 }), 2040 2041 "last": createPositionalPseudo(function( matchIndexes, length ) { 2042 return [ length - 1 ]; 2043 }), 2044 2045 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { 2046 return [ argument < 0 ? argument + length : argument ]; 2047 }), 2048 2049 "even": createPositionalPseudo(function( matchIndexes, length ) { 2050 var i = 0; 2051 for ( ; i < length; i += 2 ) { 2052 matchIndexes.push( i ); 2053 } 2054 return matchIndexes; 2055 }), 2056 2057 "odd": createPositionalPseudo(function( matchIndexes, length ) { 2058 var i = 1; 2059 for ( ; i < length; i += 2 ) { 2060 matchIndexes.push( i ); 2061 } 2062 return matchIndexes; 2063 }), 2064 2065 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { 2066 var i = argument < 0 ? argument + length : argument; 2067 for ( ; --i >= 0; ) { 2068 matchIndexes.push( i ); 2069 } 2070 return matchIndexes; 2071 }), 2072 2073 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { 2074 var i = argument < 0 ? argument + length : argument; 2075 for ( ; ++i < length; ) { 2076 matchIndexes.push( i ); 2077 } 2078 return matchIndexes; 2079 }) 2080 } 2081}; 2082 2083Expr.pseudos["nth"] = Expr.pseudos["eq"]; 2084 2085// Add button/input type pseudos 2086for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { 2087 Expr.pseudos[ i ] = createInputPseudo( i ); 2088} 2089for ( i in { submit: true, reset: true } ) { 2090 Expr.pseudos[ i ] = createButtonPseudo( i ); 2091} 2092 2093// Easy API for creating new setFilters 2094function setFilters() {} 2095setFilters.prototype = Expr.filters = Expr.pseudos; 2096Expr.setFilters = new setFilters(); 2097 2098tokenize = Sizzle.tokenize = function( selector, parseOnly ) { 2099 var matched, match, tokens, type, 2100 soFar, groups, preFilters, 2101 cached = tokenCache[ selector + " " ]; 2102 2103 if ( cached ) { 2104 return parseOnly ? 0 : cached.slice( 0 ); 2105 } 2106 2107 soFar = selector; 2108 groups = []; 2109 preFilters = Expr.preFilter; 2110 2111 while ( soFar ) { 2112 2113 // Comma and first run 2114 if ( !matched || (match = rcomma.exec( soFar )) ) { 2115 if ( match ) { 2116 // Don't consume trailing commas as valid 2117 soFar = soFar.slice( match[0].length ) || soFar; 2118 } 2119 groups.push( (tokens = []) ); 2120 } 2121 2122 matched = false;
vendor: 14,389 bytes, lines 2123-2619
2123 2124 // Combinators 2125 if ( (match = rcombinators.exec( soFar )) ) { 2126 matched = match.shift(); 2127 tokens.push({ 2128 value: matched, 2129 // Cast descendant combinators to space 2130 type: match[0].replace( rtrim, " " ) 2131 }); 2132 soFar = soFar.slice( matched.length ); 2133 } 2134 2135 // Filters 2136 for ( type in Expr.filter ) { 2137 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || 2138 (match = preFilters[ type ]( match ))) ) { 2139 matched = match.shift(); 2140 tokens.push({ 2141 value: matched, 2142 type: type, 2143 matches: match 2144 }); 2145 soFar = soFar.slice( matched.length ); 2146 } 2147 } 2148 2149 if ( !matched ) { 2150 break; 2151 } 2152 } 2153 2154 // Return the length of the invalid excess 2155 // if we're just parsing 2156 // Otherwise, throw an error or return tokens 2157 return parseOnly ? 2158 soFar.length : 2159 soFar ? 2160 Sizzle.error( selector ) : 2161 // Cache the tokens 2162 tokenCache( selector, groups ).slice( 0 ); 2163}; 2164 2165function toSelector( tokens ) { 2166 var i = 0, 2167 len = tokens.length, 2168 selector = ""; 2169 for ( ; i < len; i++ ) { 2170 selector += tokens[i].value; 2171 } 2172 return selector; 2173} 2174 2175function addCombinator( matcher, combinator, base ) { 2176 var dir = combinator.dir, 2177 checkNonElements = base && dir === "parentNode", 2178 doneName = done++; 2179 2180 return combinator.first ? 2181 // Check against closest ancestor/preceding element 2182 function( elem, context, xml ) { 2183 while ( (elem = elem[ dir ]) ) { 2184 if ( elem.nodeType === 1 || checkNonElements ) { 2185 return matcher( elem, context, xml ); 2186 } 2187 } 2188 } : 2189 2190 // Check against all ancestor/preceding elements 2191 function( elem, context, xml ) { 2192 var oldCache, uniqueCache, outerCache, 2193 newCache = [ dirruns, doneName ]; 2194 2195 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching 2196 if ( xml ) { 2197 while ( (elem = elem[ dir ]) ) { 2198 if ( elem.nodeType === 1 || checkNonElements ) { 2199 if ( matcher( elem, context, xml ) ) { 2200 return true; 2201 } 2202 } 2203 } 2204 } else { 2205 while ( (elem = elem[ dir ]) ) { 2206 if ( elem.nodeType === 1 || checkNonElements ) { 2207 outerCache = elem[ expando ] || (elem[ expando ] = {}); 2208 2209 // Support: IE <9 only 2210 // Defend against cloned attroperties (jQuery gh-1709) 2211 uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); 2212 2213 if ( (oldCache = uniqueCache[ dir ]) && 2214 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { 2215 2216 // Assign to newCache so results back-propagate to previous elements 2217 return (newCache[ 2 ] = oldCache[ 2 ]); 2218 } else { 2219 // Reuse newcache so results back-propagate to previous elements 2220 uniqueCache[ dir ] = newCache; 2221 2222 // A match means we're done; a fail means we have to keep checking 2223 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { 2224 return true; 2225 } 2226 } 2227 } 2228 } 2229 } 2230 }; 2231} 2232 2233function elementMatcher( matchers ) { 2234 return matchers.length > 1 ? 2235 function( elem, context, xml ) { 2236 var i = matchers.length; 2237 while ( i-- ) { 2238 if ( !matchers[i]( elem, context, xml ) ) { 2239 return false; 2240 } 2241 } 2242 return true; 2243 } : 2244 matchers[0]; 2245} 2246 2247function multipleContexts( selector, contexts, results ) { 2248 var i = 0, 2249 len = contexts.length; 2250 for ( ; i < len; i++ ) { 2251 Sizzle( selector, contexts[i], results ); 2252 } 2253 return results; 2254} 2255 2256function condense( unmatched, map, filter, context, xml ) { 2257 var elem, 2258 newUnmatched = [], 2259 i = 0, 2260 len = unmatched.length, 2261 mapped = map != null; 2262 2263 for ( ; i < len; i++ ) { 2264 if ( (elem = unmatched[i]) ) { 2265 if ( !filter || filter( elem, context, xml ) ) { 2266 newUnmatched.push( elem ); 2267 if ( mapped ) { 2268 map.push( i ); 2269 } 2270 } 2271 } 2272 } 2273 2274 return newUnmatched; 2275} 2276 2277function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { 2278 if ( postFilter && !postFilter[ expando ] ) { 2279 postFilter = setMatcher( postFilter ); 2280 } 2281 if ( postFinder && !postFinder[ expando ] ) { 2282 postFinder = setMatcher( postFinder, postSelector ); 2283 } 2284 return markFunction(function( seed, results, context, xml ) { 2285 var temp, i, elem, 2286 preMap = [], 2287 postMap = [], 2288 preexisting = results.length, 2289 2290 // Get initial elements from seed or context 2291 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), 2292 2293 // Prefilter to get matcher input, preserving a map for seed-results synchronization 2294 matcherIn = preFilter && ( seed || !selector ) ? 2295 condense( elems, preMap, preFilter, context, xml ) : 2296 elems, 2297 2298 matcherOut = matcher ? 2299 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, 2300 postFinder || ( seed ? preFilter : preexisting || postFilter ) ? 2301 2302 // ...intermediate processing is necessary 2303 [] : 2304 2305 // ...otherwise use results directly 2306 results : 2307 matcherIn; 2308 2309 // Find primary matches 2310 if ( matcher ) { 2311 matcher( matcherIn, matcherOut, context, xml ); 2312 } 2313 2314 // Apply postFilter 2315 if ( postFilter ) { 2316 temp = condense( matcherOut, postMap ); 2317 postFilter( temp, [], context, xml ); 2318 2319 // Un-match failing elements by moving them back to matcherIn 2320 i = temp.length; 2321 while ( i-- ) { 2322 if ( (elem = temp[i]) ) { 2323 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); 2324 } 2325 } 2326 } 2327 2328 if ( seed ) { 2329 if ( postFinder || preFilter ) { 2330 if ( postFinder ) { 2331 // Get the final matcherOut by condensing this intermediate into postFinder contexts 2332 temp = []; 2333 i = matcherOut.length; 2334 while ( i-- ) { 2335 if ( (elem = matcherOut[i]) ) { 2336 // Restore matcherIn since elem is not yet a final match 2337 temp.push( (matcherIn[i] = elem) ); 2338 } 2339 } 2340 postFinder( null, (matcherOut = []), temp, xml ); 2341 } 2342 2343 // Move matched elements from seed to results to keep them synchronized 2344 i = matcherOut.length; 2345 while ( i-- ) { 2346 if ( (elem = matcherOut[i]) && 2347 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { 2348 2349 seed[temp] = !(results[temp] = elem); 2350 } 2351 } 2352 } 2353 2354 // Add elements to results, through postFinder if defined 2355 } else { 2356 matcherOut = condense( 2357 matcherOut === results ? 2358 matcherOut.splice( preexisting, matcherOut.length ) : 2359 matcherOut 2360 ); 2361 if ( postFinder ) { 2362 postFinder( null, results, matcherOut, xml ); 2363 } else { 2364 push.apply( results, matcherOut ); 2365 } 2366 } 2367 }); 2368} 2369 2370function matcherFromTokens( tokens ) { 2371 var checkContext, matcher, j, 2372 len = tokens.length, 2373 leadingRelative = Expr.relative[ tokens[0].type ], 2374 implicitRelative = leadingRelative || Expr.relative[" "], 2375 i = leadingRelative ? 1 : 0, 2376 2377 // The foundational matcher ensures that elements are reachable from top-level context(s) 2378 matchContext = addCombinator( function( elem ) { 2379 return elem === checkContext; 2380 }, implicitRelative, true ), 2381 matchAnyContext = addCombinator( function( elem ) { 2382 return indexOf( checkContext, elem ) > -1; 2383 }, implicitRelative, true ), 2384 matchers = [ function( elem, context, xml ) { 2385 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( 2386 (checkContext = context).nodeType ? 2387 matchContext( elem, context, xml ) : 2388 matchAnyContext( elem, context, xml ) ); 2389 // Avoid hanging onto element (issue #299) 2390 checkContext = null; 2391 return ret; 2392 } ]; 2393 2394 for ( ; i < len; i++ ) { 2395 if ( (matcher = Expr.relative[ tokens[i].type ]) ) { 2396 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; 2397 } else { 2398 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); 2399 2400 // Return special upon seeing a positional matcher 2401 if ( matcher[ expando ] ) { 2402 // Find the next relative operator (if any) for proper handling 2403 j = ++i; 2404 for ( ; j < len; j++ ) { 2405 if ( Expr.relative[ tokens[j].type ] ) { 2406 break; 2407 } 2408 } 2409 return setMatcher( 2410 i > 1 && elementMatcher( matchers ), 2411 i > 1 && toSelector( 2412 // If the preceding token was a descendant combinator, insert an implicit any-element `*` 2413 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) 2414 ).replace( rtrim, "$1" ), 2415 matcher, 2416 i < j && matcherFromTokens( tokens.slice( i, j ) ), 2417 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), 2418 j < len && toSelector( tokens ) 2419 ); 2420 } 2421 matchers.push( matcher ); 2422 } 2423 } 2424 2425 return elementMatcher( matchers ); 2426} 2427 2428function matcherFromGroupMatchers( elementMatchers, setMatchers ) { 2429 var bySet = setMatchers.length > 0, 2430 byElement = elementMatchers.length > 0, 2431 superMatcher = function( seed, context, xml, results, outermost ) { 2432 var elem, j, matcher, 2433 matchedCount = 0, 2434 i = "0", 2435 unmatched = seed && [], 2436 setMatched = [], 2437 contextBackup = outermostContext, 2438 // We must always have either seed elements or outermost context 2439 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), 2440 // Use integer dirruns iff this is the outermost matcher 2441 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), 2442 len = elems.length; 2443 2444 if ( outermost ) { 2445 outermostContext = context === document || context || outermost; 2446 } 2447 2448 // Add elements passing elementMatchers directly to results 2449 // Support: IE<9, Safari 2450 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id 2451 for ( ; i !== len && (elem = elems[i]) != null; i++ ) { 2452 if ( byElement && elem ) { 2453 j = 0; 2454 if ( !context && elem.ownerDocument !== document ) { 2455 setDocument( elem ); 2456 xml = !documentIsHTML; 2457 } 2458 while ( (matcher = elementMatchers[j++]) ) { 2459 if ( matcher( elem, context || document, xml) ) { 2460 results.push( elem ); 2461 break; 2462 } 2463 } 2464 if ( outermost ) { 2465 dirruns = dirrunsUnique; 2466 } 2467 } 2468 2469 // Track unmatched elements for set filters 2470 if ( bySet ) { 2471 // They will have gone through all possible matchers 2472 if ( (elem = !matcher && elem) ) { 2473 matchedCount--; 2474 } 2475 2476 // Lengthen the array for every element, matched or not 2477 if ( seed ) { 2478 unmatched.push( elem ); 2479 } 2480 } 2481 } 2482 2483 // `i` is now the count of elements visited above, and adding it to `matchedCount` 2484 // makes the latter nonnegative. 2485 matchedCount += i; 2486 2487 // Apply set filters to unmatched elements 2488 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` 2489 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have 2490 // no element matchers and no seed. 2491 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that 2492 // case, which will result in a "00" `matchedCount` that differs from `i` but is also 2493 // numerically zero. 2494 if ( bySet && i !== matchedCount ) { 2495 j = 0; 2496 while ( (matcher = setMatchers[j++]) ) { 2497 matcher( unmatched, setMatched, context, xml ); 2498 } 2499 2500 if ( seed ) { 2501 // Reintegrate element matches to eliminate the need for sorting 2502 if ( matchedCount > 0 ) { 2503 while ( i-- ) { 2504 if ( !(unmatched[i] || setMatched[i]) ) { 2505 setMatched[i] = pop.call( results ); 2506 } 2507 } 2508 } 2509 2510 // Discard index placeholder values to get only actual matches 2511 setMatched = condense( setMatched ); 2512 } 2513 2514 // Add matches to results 2515 push.apply( results, setMatched ); 2516 2517 // Seedless set matches succeeding multiple successful matchers stipulate sorting 2518 if ( outermost && !seed && setMatched.length > 0 && 2519 ( matchedCount + setMatchers.length ) > 1 ) { 2520 2521 Sizzle.uniqueSort( results ); 2522 } 2523 } 2524 2525 // Override manipulation of globals by nested matchers 2526 if ( outermost ) { 2527 dirruns = dirrunsUnique; 2528 outermostContext = contextBackup; 2529 } 2530 2531 return unmatched; 2532 }; 2533 2534 return bySet ? 2535 markFunction( superMatcher ) : 2536 superMatcher; 2537} 2538 2539compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { 2540 var i, 2541 setMatchers = [], 2542 elementMatchers = [], 2543 cached = compilerCache[ selector + " " ]; 2544 2545 if ( !cached ) { 2546 // Generate a function of recursive functions that can be used to check each element 2547 if ( !match ) { 2548 match = tokenize( selector ); 2549 } 2550 i = match.length; 2551 while ( i-- ) { 2552 cached = matcherFromTokens( match[i] ); 2553 if ( cached[ expando ] ) { 2554 setMatchers.push( cached ); 2555 } else { 2556 elementMatchers.push( cached ); 2557 } 2558 } 2559 2560 // Cache the compiled function 2561 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); 2562 2563 // Save selector and tokenization 2564 cached.selector = selector; 2565 } 2566 return cached; 2567}; 2568 2569/** 2570 * A low-level selection function that works with Sizzle's compiled 2571 * selector functions 2572 * @param {String|Function} selector A selector or a pre-compiled 2573 * selector function built with Sizzle.compile 2574 * @param {Element} context 2575 * @param {Array} [results] 2576 * @param {Array} [seed] A set of elements to match against 2577 */ 2578select = Sizzle.select = function( selector, context, results, seed ) { 2579 var i, tokens, token, type, find, 2580 compiled = typeof selector === "function" && selector, 2581 match = !seed && tokenize( (selector = compiled.selector || selector) ); 2582 2583 results = results || []; 2584 2585 // Try to minimize operations if there is only one selector in the list and no seed 2586 // (the latter of which guarantees us context) 2587 if ( match.length === 1 ) { 2588 2589 // Reduce context if the leading compound selector is an ID 2590 tokens = match[0] = match[0].slice( 0 ); 2591 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && 2592 support.getById && context.nodeType === 9 && documentIsHTML && 2593 Expr.relative[ tokens[1].type ] ) { 2594 2595 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; 2596 if ( !context ) { 2597 return results; 2598 2599 // Precompiled matchers will still verify ancestry, so step up a level 2600 } else if ( compiled ) { 2601 context = context.parentNode; 2602 } 2603 2604 selector = selector.slice( tokens.shift().value.length ); 2605 } 2606 2607 // Fetch a seed set for right-to-left matching 2608 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; 2609 while ( i-- ) { 2610 token = tokens[i]; 2611 2612 // Abort if we hit a combinator 2613 if ( Expr.relative[ (type = token.type) ] ) { 2614 break; 2615 } 2616 if ( (find = Expr.find[ type ]) ) { 2617 // Search, expanding context for leading sibling combinators 2618 if ( (seed = find( 2619 token.matches[0].replace( runescape, funescape ),
2620 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context 2621 )) ) { 2622 2623 // If seed is empty or no tokens remain, we can return early 2624 tokens.splice( i, 1 ); 2625 selector = seed.length && toSelector( tokens ); 2626 if ( !selector ) { 2627 push.apply( results, seed ); 2628 return results; 2629 } 2630 2631 break; 2632 } 2633 } 2634 } 2635 } 2636 2637 // Compile and execute a filtering function if one is not provided 2638 // Provide `match` to avoid retokenization if we modified the selector above 2639 ( compiled || compile( selector, match ) )( 2640 seed, 2641 context, 2642 !documentIsHTML, 2643 results, 2644 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context 2645 ); 2646 return results; 2647}; 2648 2649// One-time assignments 2650 2651// Sort stability 2652support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; 2653 2654// Support: Chrome 14-35+ 2655// Always assume duplicates if they aren't passed to the comparison function 2656support.detectDuplicates = !!hasDuplicate; 2657 2658// Initialize against the default document 2659setDocument(); 2660 2661// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) 2662// Detached nodes confoundingly follow *each other* 2663support.sortDetached = assert(function( div1 ) { 2664 // Should return 1, but returns 4 (following) 2665 return div1.compareDocumentPosition( document.createElement("div") ) & 1; 2666}); 2667 2668// Support: IE<8 2669// Prevent attribute/property "interpolation" 2670// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx 2671if ( !assert(function( div ) { 2672 div.innerHTML = "<a href='#'></a>"; 2673 return div.firstChild.getAttribute("href") === "#" ; 2674}) ) { 2675 addHandle( "type|href|height|width", function( elem, name, isXML ) { 2676 if ( !isXML ) { 2677 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); 2678 } 2679 }); 2680} 2681 2682// Support: IE<9 2683// Use defaultValue in place of getAttribute("value") 2684if ( !support.attributes || !assert(function( div ) { 2685 div.innerHTML = "<input/>"; 2686 div.firstChild.setAttribute( "value", "" ); 2687 return div.firstChild.getAttribute( "value" ) === ""; 2688}) ) { 2689 addHandle( "value", function( elem, name, isXML ) { 2690 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { 2691 return elem.defaultValue; 2692 } 2693 }); 2694} 2695 2696// Support: IE<9 2697// Use getAttributeNode to fetch booleans when getAttribute lies 2698if ( !assert(function( div ) { 2699 return div.getAttribute("disabled") == null; 2700}) ) { 2701 addHandle( booleans, function( elem, name, isXML ) { 2702 var val; 2703 if ( !isXML ) { 2704 return elem[ name ] === true ? name.toLowerCase() : 2705 (val = elem.getAttributeNode( name )) && val.specified ? 2706 val.value : 2707 null; 2708 } 2709 }); 2710} 2711 2712return Sizzle; 2713 2714})( window ); 2715 2716 2717 2718jQuery.find = Sizzle; 2719jQuery.expr = Sizzle.selectors; 2720jQuery.expr[ ":" ] = jQuery.expr.pseudos; 2721jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; 2722jQuery.text = Sizzle.getText; 2723jQuery.isXMLDoc = Sizzle.isXML; 2724jQuery.contains = Sizzle.contains; 2725 2726 2727 2728var dir = function( elem, dir, until ) { 2729 var matched = [], 2730 truncate = until !== undefined; 2731 2732 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { 2733 if ( elem.nodeType === 1 ) { 2734 if ( truncate && jQuery( elem ).is( until ) ) { 2735 break; 2736 } 2737 matched.push( elem ); 2738 } 2739 } 2740 return matched; 2741}; 2742 2743 2744var siblings = function( n, elem ) { 2745 var matched = []; 2746 2747 for ( ; n; n = n.nextSibling ) { 2748 if ( n.nodeType === 1 && n !== elem ) { 2749 matched.push( n ); 2750 } 2751 } 2752 2753 return matched; 2754}; 2755 2756 2757var rneedsContext = jQuery.expr.match.needsContext; 2758 2759var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ ); 2760 2761 2762 2763var risSimple = /^.[^:#\[\.,]*$/; 2764 2765// Implement the identical functionality for filter and not 2766function winnow( elements, qualifier, not ) { 2767 if ( jQuery.isFunction( qualifier ) ) { 2768 return jQuery.grep( elements, function( elem, i ) { 2769 /* jshint -W018 */ 2770 return !!qualifier.call( elem, i, elem ) !== not; 2771 } ); 2772 2773 } 2774 2775 if ( qualifier.nodeType ) { 2776 return jQuery.grep( elements, function( elem ) { 2777 return ( elem === qualifier ) !== not; 2778 } ); 2779 2780 } 2781 2782 if ( typeof qualifier === "string" ) { 2783 if ( risSimple.test( qualifier ) ) { 2784 return jQuery.filter( qualifier, elements, not ); 2785 } 2786 2787 qualifier = jQuery.filter( qualifier, elements ); 2788 } 2789 2790 return jQuery.grep( elements, function( elem ) { 2791 return ( jQuery.inArray( elem, qualifier ) > -1 ) !== not; 2792 } ); 2793} 2794 2795jQuery.filter = function( expr, elems, not ) { 2796 var elem = elems[ 0 ]; 2797 2798 if ( not ) { 2799 expr = ":not(" + expr + ")"; 2800 } 2801 2802 return elems.length === 1 && elem.nodeType === 1 ? 2803 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : 2804 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { 2805 return elem.nodeType === 1; 2806 } ) ); 2807}; 2808 2809jQuery.fn.extend( { 2810 find: function( selector ) { 2811 var i, 2812 ret = [], 2813 self = this, 2814 len = self.length; 2815 2816 if ( typeof selector !== "string" ) {
2817 return this.pushStack( jQuery( selector ).filter( function() { 2818 for ( i = 0; i < len; i++ ) { 2819 if ( jQuery.contains( self[ i ], this ) ) { 2820 return true; 2821 } 2822 } 2823 } ) ); 2824 } 2825 2826 for ( i = 0; i < len; i++ ) { 2827 jQuery.find( selector, self[ i ], ret ); 2828 } 2829 2830 // Needed because $( selector, context ) becomes $( context ).find( selector ) 2831 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); 2832 ret.selector = this.selector ? this.selector + " " + selector : selector; 2833 return ret; 2834 }, 2835 filter: function( selector ) { 2836 return this.pushStack( winnow( this, selector || [], false ) ); 2837 }, 2838 not: function( selector ) { 2839 return this.pushStack( winnow( this, selector || [], true ) ); 2840 }, 2841 is: function( selector ) { 2842 return !!winnow( 2843 this, 2844 2845 // If this is a positional/relative selector, check membership in the returned set 2846 // so $("p:first").is("p:last") won't return true for a doc with two "p". 2847 typeof selector === "string" && rneedsContext.test( selector ) ? 2848 jQuery( selector ) : 2849 selector || [], 2850 false 2851 ).length; 2852 } 2853} ); 2854 2855 2856// Initialize a jQuery object 2857 2858 2859// A central reference to the root jQuery(document) 2860var rootjQuery, 2861 2862 // A simple way to check for HTML strings 2863 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) 2864 // Strict HTML recognition (#11290: must start with <) 2865 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, 2866 2867 init = jQuery.fn.init = function( selector, context, root ) { 2868 var match, elem; 2869 2870 // HANDLE: $(""), $(null), $(undefined), $(false) 2871 if ( !selector ) { 2872 return this; 2873 } 2874 2875 // init accepts an alternate rootjQuery 2876 // so migrate can support jQuery.sub (gh-2101) 2877 root = root || rootjQuery; 2878 2879 // Handle HTML strings 2880 if ( typeof selector === "string" ) { 2881 if ( selector.charAt( 0 ) === "<" && 2882 selector.charAt( selector.length - 1 ) === ">" && 2883 selector.length >= 3 ) { 2884 2885 // Assume that strings that start and end with <> are HTML and skip the regex check 2886 match = [ null, selector, null ]; 2887 2888 } else { 2889 match = rquickExpr.exec( selector ); 2890 } 2891 2892 // Match html or make sure no context is specified for #id 2893 if ( match && ( match[ 1 ] || !context ) ) { 2894 2895 // HANDLE: $(html) -> $(array) 2896 if ( match[ 1 ] ) { 2897 context = context instanceof jQuery ? context[ 0 ] : context; 2898 2899 // scripts is true for back-compat 2900 // Intentionally let the error be thrown if parseHTML is not present 2901 jQuery.merge( this, jQuery.parseHTML( 2902 match[ 1 ], 2903 context && context.nodeType ? context.ownerDocument || context : document, 2904 true 2905 ) ); 2906 2907 // HANDLE: $(html, props) 2908 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { 2909 for ( match in context ) { 2910 2911 // Properties of context are called as methods if possible 2912 if ( jQuery.isFunction( this[ match ] ) ) { 2913 this[ match ]( context[ match ] ); 2914 2915 // ...and otherwise set as attributes 2916 } else { 2917 this.attr( match, context[ match ] ); 2918 } 2919 } 2920 } 2921 2922 return this; 2923 2924 // HANDLE: $(#id) 2925 } else { 2926 elem = document.getElementById( match[ 2 ] ); 2927 2928 // Check parentNode to catch when Blackberry 4.6 returns 2929 // nodes that are no longer in the document #6963 2930 if ( elem && elem.parentNode ) { 2931 2932 // Handle the case where IE and Opera return items 2933 // by name instead of ID 2934 if ( elem.id !== match[ 2 ] ) { 2935 return rootjQuery.find( selector ); 2936 } 2937 2938 // Otherwise, we inject the element directly into the jQuery object 2939 this.length = 1; 2940 this[ 0 ] = elem; 2941 } 2942 2943 this.context = document; 2944 this.selector = selector; 2945 return this; 2946 } 2947 2948 // HANDLE: $(expr, $(...)) 2949 } else if ( !context || context.jquery ) { 2950 return ( context || root ).find( selector ); 2951 2952 // HANDLE: $(expr, context) 2953 // (which is just equivalent to: $(context).find(expr) 2954 } else { 2955 return this.constructor( context ).find( selector ); 2956 } 2957 2958 // HANDLE: $(DOMElement) 2959 } else if ( selector.nodeType ) { 2960 this.context = this[ 0 ] = selector; 2961 this.length = 1; 2962 return this; 2963 2964 // HANDLE: $(function) 2965 // Shortcut for document ready 2966 } else if ( jQuery.isFunction( selector ) ) { 2967 return typeof root.ready !== "undefined" ? 2968 root.ready( selector ) : 2969 2970 // Execute immediately if ready is not present 2971 selector( jQuery ); 2972 } 2973 2974 if ( selector.selector !== undefined ) { 2975 this.selector = selector.selector; 2976 this.context = selector.context; 2977 } 2978 2979 return jQuery.makeArray( selector, this ); 2980 }; 2981 2982// Give the init function the jQuery prototype for later instantiation 2983init.prototype = jQuery.fn; 2984 2985// Initialize central reference 2986rootjQuery = jQuery( document ); 2987 2988 2989var rparentsprev = /^(?:parents|prev(?:Until|All))/, 2990 2991 // methods guaranteed to produce a unique set when starting from a unique set 2992 guaranteedUnique = { 2993 children: true, 2994 contents: true, 2995 next: true, 2996 prev: true 2997 }; 2998 2999jQuery.fn.extend( { 3000 has: function( target ) { 3001 var i, 3002 targets = jQuery( target, this ), 3003 len = targets.length; 3004 3005 return this.filter( function() { 3006 for ( i = 0; i < len; i++ ) { 3007 if ( jQuery.contains( this, targets[ i ] ) ) { 3008 return true; 3009 } 3010 } 3011 } ); 3012 }, 3013 3014 closest: function( selectors, context ) { 3015 var cur, 3016 i = 0, 3017 l = this.length, 3018 matched = [], 3019 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
vendor: 5,562 bytes, lines 3020-3238
3020 jQuery( selectors, context || this.context ) : 3021 0; 3022 3023 for ( ; i < l; i++ ) { 3024 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { 3025 3026 // Always skip document fragments 3027 if ( cur.nodeType < 11 && ( pos ? 3028 pos.index( cur ) > -1 : 3029 3030 // Don't pass non-elements to Sizzle 3031 cur.nodeType === 1 && 3032 jQuery.find.matchesSelector( cur, selectors ) ) ) { 3033 3034 matched.push( cur ); 3035 break; 3036 } 3037 } 3038 } 3039 3040 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); 3041 }, 3042 3043 // Determine the position of an element within 3044 // the matched set of elements 3045 index: function( elem ) { 3046 3047 // No argument, return index in parent 3048 if ( !elem ) { 3049 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; 3050 } 3051 3052 // index in selector 3053 if ( typeof elem === "string" ) { 3054 return jQuery.inArray( this[ 0 ], jQuery( elem ) ); 3055 } 3056 3057 // Locate the position of the desired element 3058 return jQuery.inArray( 3059 3060 // If it receives a jQuery object, the first element is used 3061 elem.jquery ? elem[ 0 ] : elem, this ); 3062 }, 3063 3064 add: function( selector, context ) { 3065 return this.pushStack( 3066 jQuery.uniqueSort( 3067 jQuery.merge( this.get(), jQuery( selector, context ) ) 3068 ) 3069 ); 3070 }, 3071 3072 addBack: function( selector ) { 3073 return this.add( selector == null ? 3074 this.prevObject : this.prevObject.filter( selector ) 3075 ); 3076 } 3077} ); 3078 3079function sibling( cur, dir ) { 3080 do { 3081 cur = cur[ dir ]; 3082 } while ( cur && cur.nodeType !== 1 ); 3083 3084 return cur; 3085} 3086 3087jQuery.each( { 3088 parent: function( elem ) { 3089 var parent = elem.parentNode; 3090 return parent && parent.nodeType !== 11 ? parent : null; 3091 }, 3092 parents: function( elem ) { 3093 return dir( elem, "parentNode" ); 3094 }, 3095 parentsUntil: function( elem, i, until ) { 3096 return dir( elem, "parentNode", until ); 3097 }, 3098 next: function( elem ) { 3099 return sibling( elem, "nextSibling" ); 3100 }, 3101 prev: function( elem ) { 3102 return sibling( elem, "previousSibling" ); 3103 }, 3104 nextAll: function( elem ) { 3105 return dir( elem, "nextSibling" ); 3106 }, 3107 prevAll: function( elem ) { 3108 return dir( elem, "previousSibling" ); 3109 }, 3110 nextUntil: function( elem, i, until ) { 3111 return dir( elem, "nextSibling", until ); 3112 }, 3113 prevUntil: function( elem, i, until ) { 3114 return dir( elem, "previousSibling", until ); 3115 }, 3116 siblings: function( elem ) { 3117 return siblings( ( elem.parentNode || {} ).firstChild, elem ); 3118 }, 3119 children: function( elem ) { 3120 return siblings( elem.firstChild ); 3121 }, 3122 contents: function( elem ) { 3123 return jQuery.nodeName( elem, "iframe" ) ? 3124 elem.contentDocument || elem.contentWindow.document : 3125 jQuery.merge( [], elem.childNodes ); 3126 } 3127}, function( name, fn ) { 3128 jQuery.fn[ name ] = function( until, selector ) { 3129 var ret = jQuery.map( this, fn, until ); 3130 3131 if ( name.slice( -5 ) !== "Until" ) { 3132 selector = until; 3133 } 3134 3135 if ( selector && typeof selector === "string" ) { 3136 ret = jQuery.filter( selector, ret ); 3137 } 3138 3139 if ( this.length > 1 ) { 3140 3141 // Remove duplicates 3142 if ( !guaranteedUnique[ name ] ) { 3143 ret = jQuery.uniqueSort( ret ); 3144 } 3145 3146 // Reverse order for parents* and prev-derivatives 3147 if ( rparentsprev.test( name ) ) { 3148 ret = ret.reverse(); 3149 } 3150 } 3151 3152 return this.pushStack( ret ); 3153 }; 3154} ); 3155var rnotwhite = ( /\S+/g ); 3156 3157 3158 3159// Convert String-formatted options into Object-formatted ones 3160function createOptions( options ) { 3161 var object = {}; 3162 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { 3163 object[ flag ] = true; 3164 } ); 3165 return object; 3166} 3167 3168/* 3169 * Create a callback list using the following parameters: 3170 * 3171 * options: an optional list of space-separated options that will change how 3172 * the callback list behaves or a more traditional option object 3173 * 3174 * By default a callback list will act like an event callback list and can be 3175 * "fired" multiple times. 3176 * 3177 * Possible options: 3178 * 3179 * once: will ensure the callback list can only be fired once (like a Deferred) 3180 * 3181 * memory: will keep track of previous values and will call any callback added 3182 * after the list has been fired right away with the latest "memorized" 3183 * values (like a Deferred) 3184 * 3185 * unique: will ensure a callback can only be added once (no duplicate in the list) 3186 * 3187 * stopOnFalse: interrupt callings when a callback returns false 3188 * 3189 */ 3190jQuery.Callbacks = function( options ) { 3191 3192 // Convert options from String-formatted to Object-formatted if needed 3193 // (we check in cache first) 3194 options = typeof options === "string" ? 3195 createOptions( options ) : 3196 jQuery.extend( {}, options ); 3197 3198 var // Flag to know if list is currently firing 3199 firing, 3200 3201 // Last fire value for non-forgettable lists 3202 memory, 3203 3204 // Flag to know if list was already fired 3205 fired, 3206 3207 // Flag to prevent firing 3208 locked, 3209 3210 // Actual callback list 3211 list = [], 3212 3213 // Queue of execution data for repeatable lists 3214 queue = [], 3215 3216 // Index of currently firing callback (modified by add/remove as needed) 3217 firingIndex = -1, 3218 3219 // Fire callbacks 3220 fire = function() { 3221 3222 // Enforce single-firing 3223 locked = options.once; 3224 3225 // Execute callbacks for all pending executions, 3226 // respecting firingIndex overrides and runtime changes 3227 fired = firing = true; 3228 for ( ; queue.length; firingIndex = -1 ) { 3229 memory = queue.shift(); 3230 while ( ++firingIndex < list.length ) { 3231 3232 // Run callback and check for early termination 3233 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && 3234 options.stopOnFalse ) { 3235 3236 // Jump to end and forget the data so .add doesn't re-fire 3237 firingIndex = list.length; 3238 memory = false;
3239 } 3240 } 3241 } 3242 3243 // Forget the data if we're done with it 3244 if ( !options.memory ) { 3245 memory = false; 3246 } 3247 3248 firing = false; 3249 3250 // Clean up if we're done firing for good 3251 if ( locked ) { 3252 3253 // Keep an empty list if we have data for future add calls 3254 if ( memory ) { 3255 list = []; 3256 3257 // Otherwise, this object is spent 3258 } else { 3259 list = ""; 3260 } 3261 } 3262 }, 3263 3264 // Actual Callbacks object 3265 self = { 3266 3267 // Add a callback or a collection of callbacks to the list 3268 add: function() { 3269 if ( list ) { 3270 3271 // If we have memory from a past run, we should fire after adding 3272 if ( memory && !firing ) { 3273 firingIndex = list.length - 1; 3274 queue.push( memory ); 3275 } 3276 3277 ( function add( args ) { 3278 jQuery.each( args, function( _, arg ) { 3279 if ( jQuery.isFunction( arg ) ) { 3280 if ( !options.unique || !self.has( arg ) ) { 3281 list.push( arg ); 3282 } 3283 } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { 3284 3285 // Inspect recursively 3286 add( arg ); 3287 } 3288 } ); 3289 } )( arguments ); 3290 3291 if ( memory && !firing ) { 3292 fire(); 3293 } 3294 } 3295 return this; 3296 }, 3297 3298 // Remove a callback from the list 3299 remove: function() { 3300 jQuery.each( arguments, function( _, arg ) { 3301 var index; 3302 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { 3303 list.splice( index, 1 ); 3304 3305 // Handle firing indexes 3306 if ( index <= firingIndex ) { 3307 firingIndex--; 3308 } 3309 } 3310 } ); 3311 return this; 3312 }, 3313 3314 // Check if a given callback is in the list. 3315 // If no argument is given, return whether or not list has callbacks attached. 3316 has: function( fn ) { 3317 return fn ? 3318 jQuery.inArray( fn, list ) > -1 : 3319 list.length > 0; 3320 }, 3321 3322 // Remove all callbacks from the list 3323 empty: function() { 3324 if ( list ) { 3325 list = []; 3326 } 3327 return this; 3328 }, 3329 3330 // Disable .fire and .add 3331 // Abort any current/pending executions 3332 // Clear all callbacks and values 3333 disable: function() { 3334 locked = queue = []; 3335 list = memory = ""; 3336 return this; 3337 }, 3338 disabled: function() { 3339 return !list; 3340 }, 3341 3342 // Disable .fire 3343 // Also disable .add unless we have memory (since it would have no effect) 3344 // Abort any pending executions 3345 lock: function() { 3346 locked = true; 3347 if ( !memory ) { 3348 self.disable(); 3349 } 3350 return this; 3351 }, 3352 locked: function() { 3353 return !!locked; 3354 }, 3355 3356 // Call all callbacks with the given context and arguments 3357 fireWith: function( context, args ) { 3358 if ( !locked ) { 3359 args = args || []; 3360 args = [ context, args.slice ? args.slice() : args ]; 3361 queue.push( args ); 3362 if ( !firing ) { 3363 fire(); 3364 } 3365 } 3366 return this; 3367 }, 3368 3369 // Call all the callbacks with the given arguments 3370 fire: function() { 3371 self.fireWith( this, arguments ); 3372 return this; 3373 }, 3374 3375 // To know if the callbacks have already been called at least once 3376 fired: function() { 3377 return !!fired; 3378 } 3379 }; 3380 3381 return self; 3382}; 3383 3384 3385jQuery.extend( { 3386 3387 Deferred: function( func ) { 3388 var tuples = [ 3389 3390 // action, add listener, listener list, final state 3391 [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ], 3392 [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ], 3393 [ "notify", "progress", jQuery.Callbacks( "memory" ) ] 3394 ], 3395 state = "pending", 3396 promise = { 3397 state: function() { 3398 return state; 3399 }, 3400 always: function() { 3401 deferred.done( arguments ).fail( arguments ); 3402 return this; 3403 }, 3404 then: function( /* fnDone, fnFail, fnProgress */ ) { 3405 var fns = arguments; 3406 return jQuery.Deferred( function( newDefer ) { 3407 jQuery.each( tuples, function( i, tuple ) { 3408 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; 3409 3410 // deferred[ done | fail | progress ] for forwarding actions to newDefer 3411 deferred[ tuple[ 1 ] ]( function() { 3412 var returned = fn && fn.apply( this, arguments ); 3413 if ( returned && jQuery.isFunction( returned.promise ) ) { 3414 returned.promise() 3415 .progress( newDefer.notify ) 3416 .done( newDefer.resolve ) 3417 .fail( newDefer.reject ); 3418 } else { 3419 newDefer[ tuple[ 0 ] + "With" ]( 3420 this === promise ? newDefer.promise() : this, 3421 fn ? [ returned ] : arguments 3422 ); 3423 } 3424 } ); 3425 } ); 3426 fns = null; 3427 } ).promise(); 3428 }, 3429 3430 // Get a promise for this deferred 3431 // If obj is provided, the promise aspect is added to the object 3432 promise: function( obj ) { 3433 return obj != null ? jQuery.extend( obj, promise ) : promise; 3434 } 3435 }, 3436 deferred = {}; 3437 3438 // Keep pipe for back-compat 3439 promise.pipe = promise.then; 3440 3441 // Add list-specific methods 3442 jQuery.each( tuples, function( i, tuple ) { 3443 var list = tuple[ 2 ], 3444 stateString = tuple[ 3 ]; 3445 3446 // promise[ done | fail | progress ] = list.add 3447 promise[ tuple[ 1 ] ] = list.add; 3448 3449 // Handle state 3450 if ( stateString ) { 3451 list.add( function() { 3452 3453 // state = [ resolved | rejected ] 3454 state = stateString; 3455 3456 // [ reject_list | resolve_list ].disable; progress_list.lock 3457 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); 3458 } 3459 3460 // deferred[ resolve | reject | notify ] 3461 deferred[ tuple[ 0 ] ] = function() { 3462 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments ); 3463 return this; 3464 }; 3465 deferred[ tuple[ 0 ] + "With" ] = list.fireWith; 3466 } ); 3467 3468 // Make the deferred a promise 3469 promise.promise( deferred ); 3470 3471 // Call given func if any 3472 if ( func ) { 3473 func.call( deferred, deferred ); 3474 } 3475 3476 // All done! 3477 return deferred; 3478 }, 3479 3480 // Deferred helper 3481 when: function( subordinate /* , ..., subordinateN */ ) { 3482 var i = 0, 3483 resolveValues = slice.call( arguments ), 3484 length = resolveValues.length, 3485 3486 // the count of uncompleted subordinates 3487 remaining = length !== 1 || 3488 ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, 3489 3490 // the master Deferred. 3491 // If resolveValues consist of only a single Deferred, just use that. 3492 deferred = remaining === 1 ? subordinate : jQuery.Deferred(), 3493 3494 // Update function for both resolve and progress values 3495 updateFunc = function( i, contexts, values ) { 3496 return function( value ) { 3497 contexts[ i ] = this; 3498 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; 3499 if ( values === progressValues ) { 3500 deferred.notifyWith( contexts, values ); 3501 3502 } else if ( !( --remaining ) ) { 3503 deferred.resolveWith( contexts, values ); 3504 } 3505 }; 3506 }, 3507 3508 progressValues, progressContexts, resolveContexts; 3509 3510 // add listeners to Deferred subordinates; treat others as resolved 3511 if ( length > 1 ) { 3512 progressValues = new Array( length ); 3513 progressContexts = new Array( length ); 3514 resolveContexts = new Array( length ); 3515 for ( ; i < length; i++ ) { 3516 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { 3517 resolveValues[ i ].promise() 3518 .progress( updateFunc( i, progressContexts, progressValues ) ) 3519 .done( updateFunc( i, resolveContexts, resolveValues ) ) 3520 .fail( deferred.reject ); 3521 } else { 3522 --remaining; 3523 } 3524 } 3525 } 3526 3527 // if we're not waiting on anything, resolve the master 3528 if ( !remaining ) {
3529 deferred.resolveWith( resolveContexts, resolveValues ); 3530 } 3531 3532 return deferred.promise(); 3533 } 3534} ); 3535 3536 3537// The deferred used on DOM ready 3538var readyList; 3539 3540jQuery.fn.ready = function( fn ) { 3541 3542 // Add the callback 3543 jQuery.ready.promise().done( fn ); 3544 3545 return this; 3546}; 3547 3548jQuery.extend( { 3549 3550 // Is the DOM ready to be used? Set to true once it occurs. 3551 isReady: false, 3552 3553 // A counter to track how many items to wait for before 3554 // the ready event fires. See #6781 3555 readyWait: 1, 3556 3557 // Hold (or release) the ready event 3558 holdReady: function( hold ) { 3559 if ( hold ) { 3560 jQuery.readyWait++; 3561 } else { 3562 jQuery.ready( true ); 3563 } 3564 }, 3565 3566 // Handle when the DOM is ready 3567 ready: function( wait ) { 3568 3569 // Abort if there are pending holds or we're already ready 3570 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { 3571 return; 3572 } 3573 3574 // Remember that the DOM is ready 3575 jQuery.isReady = true; 3576 3577 // If a normal DOM Ready event fired, decrement, and wait if need be 3578 if ( wait !== true && --jQuery.readyWait > 0 ) { 3579 return; 3580 } 3581 3582 // If there are functions bound, to execute 3583 readyList.resolveWith( document, [ jQuery ] ); 3584 3585 // Trigger any bound ready events 3586 if ( jQuery.fn.triggerHandler ) { 3587 jQuery( document ).triggerHandler( "ready" ); 3588 jQuery( document ).off( "ready" ); 3589 } 3590 } 3591} ); 3592 3593/** 3594 * Clean-up method for dom ready events 3595 */ 3596function detach() { 3597 if ( document.addEventListener ) { 3598 document.removeEventListener( "DOMContentLoaded", completed ); 3599 window.removeEventListener( "load", completed ); 3600 3601 } else { 3602 document.detachEvent( "onreadystatechange", completed ); 3603 window.detachEvent( "onload", completed ); 3604 } 3605} 3606 3607/** 3608 * The ready event handler and self cleanup method 3609 */ 3610function completed() { 3611 3612 // readyState === "complete" is good enough for us to call the dom ready in oldIE 3613 if ( document.addEventListener || 3614 window.event.type === "load" || 3615 document.readyState === "complete" ) { 3616 3617 detach(); 3618 jQuery.ready(); 3619 } 3620} 3621 3622jQuery.ready.promise = function( obj ) { 3623 if ( !readyList ) { 3624 3625 readyList = jQuery.Deferred(); 3626 3627 // Catch cases where $(document).ready() is called 3628 // after the browser event has already occurred.
3629 // Support: IE6-10 3630 // Older IE sometimes signals "interactive" too soon 3631 if ( document.readyState === "complete" || 3632 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { 3633 3634 // Handle it asynchronously to allow scripts the opportunity to delay ready 3635 window.setTimeout( jQuery.ready ); 3636 3637 // Standards-based browsers support DOMContentLoaded 3638 } else if ( document.addEventListener ) { 3639 3640 // Use the handy event callback 3641 document.addEventListener( "DOMContentLoaded", completed ); 3642 3643 // A fallback to window.onload, that will always work 3644 window.addEventListener( "load", completed ); 3645 3646 // If IE event model is used 3647 } else { 3648 3649 // Ensure firing before onload, maybe late but safe also for iframes 3650 document.attachEvent( "onreadystatechange", completed ); 3651 3652 // A fallback to window.onload, that will always work 3653 window.attachEvent( "onload", completed ); 3654 3655 // If IE and not a frame 3656 // continually check to see if the document is ready 3657 var top = false; 3658 3659 try { 3660 top = window.frameElement == null && document.documentElement; 3661 } catch ( e ) {} 3662 3663 if ( top && top.doScroll ) { 3664 ( function doScrollCheck() { 3665 if ( !jQuery.isReady ) { 3666 3667 try { 3668 3669 // Use the trick by Diego Perini 3670 // http://javascript.nwbox.com/IEContentLoaded/ 3671 top.doScroll( "left" ); 3672 } catch ( e ) { 3673 return window.setTimeout( doScrollCheck, 50 ); 3674 } 3675 3676 // detach all dom ready events 3677 detach(); 3678 3679 // and execute any waiting functions 3680 jQuery.ready(); 3681 } 3682 } )(); 3683 } 3684 } 3685 } 3686 return readyList.promise( obj ); 3687}; 3688 3689// Kick off the DOM ready check even if the user does not 3690jQuery.ready.promise(); 3691 3692 3693 3694 3695// Support: IE<9 3696// Iteration over object's inherited properties before its own 3697var i; 3698for ( i in jQuery( support ) ) { 3699 break; 3700} 3701support.ownFirst = i === "0"; 3702 3703// Note: most support tests are defined in their respective modules. 3704// false until the test is run 3705support.inlineBlockNeedsLayout = false; 3706 3707// Execute ASAP in case we need to set body.style.zoom 3708jQuery( function() { 3709 3710 // Minified: var a,b,c,d 3711 var val, div, body, container; 3712 3713 body = document.getElementsByTagName( "body" )[ 0 ]; 3714 if ( !body || !body.style ) { 3715 3716 // Return for frameset docs that don't have a body 3717 return; 3718 } 3719 3720 // Setup 3721 div = document.createElement( "div" ); 3722 container = document.createElement( "div" ); 3723 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px"; 3724 body.appendChild( container ).appendChild( div ); 3725 3726 if ( typeof div.style.zoom !== "undefined" ) { 3727 3728 // Support: IE<8 3729 // Check if natively block-level elements act like inline-block 3730 // elements when setting their display to 'inline' and giving 3731 // them layout 3732 div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1"; 3733 3734 support.inlineBlockNeedsLayout = val = div.offsetWidth === 3; 3735 if ( val ) { 3736 3737 // Prevent IE 6 from affecting layout for positioned elements #11048 3738 // Prevent IE from shrinking the body in IE 7 mode #12869 3739 // Support: IE<8 3740 body.style.zoom = 1; 3741 } 3742 } 3743 3744 body.removeChild( container ); 3745} ); 3746 3747 3748( function() { 3749 var div = document.createElement( "div" ); 3750 3751 // Support: IE<9 3752 support.deleteExpando = true; 3753 try { 3754 delete div.test; 3755 } catch ( e ) { 3756 support.deleteExpando = false; 3757 } 3758 3759 // Null elements to avoid leaks in IE. 3760 div = null; 3761} )(); 3762var acceptData = function( elem ) { 3763 var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ], 3764 nodeType = +elem.nodeType || 1; 3765 3766 // Do not set data on non-element DOM nodes because it will not be cleared (#8335). 3767 return nodeType !== 1 && nodeType !== 9 ? 3768 false : 3769 3770 // Nodes accept data unless otherwise specified; rejection can be conditional 3771 !noData || noData !== true && elem.getAttribute( "classid" ) === noData; 3772}; 3773 3774 3775 3776 3777var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, 3778 rmultiDash = /([A-Z])/g; 3779 3780function dataAttr( elem, key, data ) { 3781 3782 // If nothing was found internally, try to fetch any 3783 // data from the HTML5 data-* attribute 3784 if ( data === undefined && elem.nodeType === 1 ) { 3785 3786 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); 3787 3788 data = elem.getAttribute( name ); 3789 3790 if ( typeof data === "string" ) { 3791 try { 3792 data = data === "true" ? true :
3793 data === "false" ? false : 3794 data === "null" ? null : 3795 3796 // Only convert to a number if it doesn't change the string 3797 +data + "" === data ? +data : 3798 rbrace.test( data ) ? jQuery.parseJSON( data ) : 3799 data; 3800 } catch ( e ) {} 3801 3802 // Make sure we set the data so it isn't changed later 3803 jQuery.data( elem, key, data ); 3804 3805 } else { 3806 data = undefined; 3807 } 3808 } 3809 3810 return data; 3811} 3812 3813// checks a cache object for emptiness 3814function isEmptyDataObject( obj ) { 3815 var name; 3816 for ( name in obj ) { 3817 3818 // if the public data object is empty, the private is still empty 3819 if ( name === "data" && jQuery.isEmptyObject( obj[ name ] ) ) { 3820 continue; 3821 } 3822 if ( name !== "toJSON" ) { 3823 return false; 3824 } 3825 } 3826 3827 return true; 3828} 3829 3830function internalData( elem, name, data, pvt /* Internal Use Only */ ) { 3831 if ( !acceptData( elem ) ) { 3832 return; 3833 } 3834 3835 var ret, thisCache, 3836 internalKey = jQuery.expando, 3837 3838 // We have to handle DOM nodes and JS objects differently because IE6-7 3839 // can't GC object references properly across the DOM-JS boundary 3840 isNode = elem.nodeType, 3841 3842 // Only DOM nodes need the global jQuery cache; JS object data is 3843 // attached directly to the object so GC can occur automatically 3844 cache = isNode ? jQuery.cache : elem, 3845 3846 // Only defining an ID for JS objects if its cache already exists allows 3847 // the code to shortcut on the same path as a DOM node with no cache 3848 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; 3849 3850 // Avoid doing any more work than we need to when trying to get data on an 3851 // object that has no data at all 3852 if ( ( !id || !cache[ id ] || ( !pvt && !cache[ id ].data ) ) && 3853 data === undefined && typeof name === "string" ) { 3854 return; 3855 } 3856 3857 if ( !id ) { 3858 3859 // Only DOM nodes need a new unique ID for each element since their data 3860 // ends up in the global cache 3861 if ( isNode ) { 3862 id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++; 3863 } else { 3864 id = internalKey; 3865 } 3866 } 3867 3868 if ( !cache[ id ] ) { 3869 3870 // Avoid exposing jQuery metadata on plain JS objects when the object 3871 // is serialized using JSON.stringify 3872 cache[ id ] = isNode ? {} : { toJSON: jQuery.noop }; 3873 } 3874 3875 // An object can be passed to jQuery.data instead of a key/value pair; this gets 3876 // shallow copied over onto the existing cache 3877 if ( typeof name === "object" || typeof name === "function" ) { 3878 if ( pvt ) { 3879 cache[ id ] = jQuery.extend( cache[ id ], name ); 3880 } else { 3881 cache[ id ].data = jQuery.extend( cache[ id ].data, name ); 3882 } 3883 } 3884 3885 thisCache = cache[ id ]; 3886 3887 // jQuery data() is stored in a separate object inside the object's internal data 3888 // cache in order to avoid key collisions between internal data and user-defined 3889 // data. 3890 if ( !pvt ) { 3891 if ( !thisCache.data ) { 3892 thisCache.data = {}; 3893 } 3894 3895 thisCache = thisCache.data; 3896 } 3897 3898 if ( data !== undefined ) { 3899 thisCache[ jQuery.camelCase( name ) ] = data; 3900 } 3901 3902 // Check for both converted-to-camel and non-converted data property names 3903 // If a data property was specified 3904 if ( typeof name === "string" ) { 3905 3906 // First Try to find as-is property data 3907 ret = thisCache[ name ]; 3908 3909 // Test for null|undefined property data 3910 if ( ret == null ) { 3911 3912 // Try to find the camelCased property 3913 ret = thisCache[ jQuery.camelCase( name ) ]; 3914 } 3915 } else { 3916 ret = thisCache; 3917 } 3918 3919 return ret; 3920} 3921 3922function internalRemoveData( elem, name, pvt ) { 3923 if ( !acceptData( elem ) ) { 3924 return; 3925 } 3926 3927 var thisCache, i, 3928 isNode = elem.nodeType, 3929 3930 // See jQuery.data for more information 3931 cache = isNode ? jQuery.cache : elem, 3932 id = isNode ? elem[ jQuery.expando ] : jQuery.expando; 3933 3934 // If there is already no cache entry for this object, there is no 3935 // purpose in continuing 3936 if ( !cache[ id ] ) { 3937 return; 3938 } 3939 3940 if ( name ) { 3941 3942 thisCache = pvt ? cache[ id ] : cache[ id ].data; 3943 3944 if ( thisCache ) { 3945 3946 // Support array or space separated string names for data keys 3947 if ( !jQuery.isArray( name ) ) { 3948 3949 // try the string as a key before any manipulation 3950 if ( name in thisCache ) { 3951 name = [ name ]; 3952 } else { 3953 3954 // split the camel cased version by spaces unless a key with the spaces exists 3955 name = jQuery.camelCase( name );
3956 if ( name in thisCache ) { 3957 name = [ name ]; 3958 } else { 3959 name = name.split( " " ); 3960 } 3961 } 3962 } else { 3963 3964 // If "name" is an array of keys... 3965 // When data is initially created, via ("key", "val") signature, 3966 // keys will be converted to camelCase. 3967 // Since there is no way to tell _how_ a key was added, remove 3968 // both plain key and camelCase key. #12786 3969 // This will only penalize the array argument path. 3970 name = name.concat( jQuery.map( name, jQuery.camelCase ) ); 3971 } 3972 3973 i = name.length; 3974 while ( i-- ) { 3975 delete thisCache[ name[ i ] ]; 3976 } 3977 3978 // If there is no data left in the cache, we want to continue 3979 // and let the cache object itself get destroyed 3980 if ( pvt ? !isEmptyDataObject( thisCache ) : !jQuery.isEmptyObject( thisCache ) ) { 3981 return; 3982 } 3983 } 3984 } 3985 3986 // See jQuery.data for more information 3987 if ( !pvt ) { 3988 delete cache[ id ].data; 3989 3990 // Don't destroy the parent cache unless the internal data object 3991 // had been the only thing left in it 3992 if ( !isEmptyDataObject( cache[ id ] ) ) { 3993 return; 3994 } 3995 } 3996 3997 // Destroy the cache 3998 if ( isNode ) { 3999 jQuery.cleanData( [ elem ], true ); 4000 4001 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) 4002 /* jshint eqeqeq: false */ 4003 } else if ( support.deleteExpando || cache != cache.window ) { 4004 /* jshint eqeqeq: true */ 4005 delete cache[ id ]; 4006 4007 // When all else fails, undefined 4008 } else { 4009 cache[ id ] = undefined; 4010 } 4011} 4012 4013jQuery.extend( { 4014 cache: {}, 4015 4016 // The following elements (space-suffixed to avoid Object.prototype collisions) 4017 // throw uncatchable exceptions if you attempt to set expando properties 4018 noData: { 4019 "applet ": true, 4020 "embed ": true, 4021 4022 // ...but Flash objects (which have this classid) *can* handle expandos 4023 "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 4024 }, 4025 4026 hasData: function( elem ) { 4027 elem = elem.nodeType ? jQuery.cache[ elem[ jQuery.expando ] ] : elem[ jQuery.expando ]; 4028 return !!elem && !isEmptyDataObject( elem ); 4029 }, 4030 4031 data: function( elem, name, data ) { 4032 return internalData( elem, name, data ); 4033 }, 4034 4035 removeData: function( elem, name ) { 4036 return internalRemoveData( elem, name ); 4037 }, 4038 4039 // For internal use only. 4040 _data: function( elem, name, data ) { 4041 return internalData( elem, name, data, true ); 4042 }, 4043 4044 _removeData: function( elem, name ) { 4045 return internalRemoveData( elem, name, true ); 4046 } 4047} ); 4048 4049jQuery.fn.extend( { 4050 data: function( key, value ) { 4051 var i, name, data, 4052 elem = this[ 0 ], 4053 attrs = elem && elem.attributes; 4054 4055 // Special expections of .data basically thwart jQuery.access, 4056 // so implement the relevant behavior ourselves 4057 4058 // Gets all values 4059 if ( key === undefined ) { 4060 if ( this.length ) { 4061 data = jQuery.data( elem ); 4062 4063 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { 4064 i = attrs.length; 4065 while ( i-- ) { 4066 4067 // Support: IE11+ 4068 // The attrs elements can be null (#14894) 4069 if ( attrs[ i ] ) { 4070 name = attrs[ i ].name; 4071 if ( name.indexOf( "data-" ) === 0 ) { 4072 name = jQuery.camelCase( name.slice( 5 ) ); 4073 dataAttr( elem, name, data[ name ] ); 4074 } 4075 } 4076 } 4077 jQuery._data( elem, "parsedAttrs", true ); 4078 } 4079 } 4080 4081 return data; 4082 } 4083 4084 // Sets multiple values 4085 if ( typeof key === "object" ) { 4086 return this.each( function() { 4087 jQuery.data( this, key ); 4088 } ); 4089 } 4090 4091 return arguments.length > 1 ? 4092 4093 // Sets one value 4094 this.each( function() { 4095 jQuery.data( this, key, value ); 4096 } ) : 4097 4098 // Gets one value 4099 // Try to fetch any internally stored data first 4100 elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined; 4101 }, 4102 4103 removeData: function( key ) { 4104 return this.each( function() { 4105 jQuery.removeData( this, key ); 4106 } ); 4107 } 4108} ); 4109 4110 4111jQuery.extend( { 4112 queue: function( elem, type, data ) { 4113 var queue; 4114 4115 if ( elem ) { 4116 type = ( type || "fx" ) + "queue"; 4117 queue = jQuery._data( elem, type ); 4118 4119 // Speed up dequeue by getting out quickly if this is just a lookup 4120 if ( data ) { 4121 if ( !queue || jQuery.isArray( data ) ) { 4122 queue = jQuery._data( elem, type, jQuery.makeArray( data ) ); 4123 } else { 4124 queue.push( data ); 4125 } 4126 } 4127 return queue || []; 4128 } 4129 }, 4130 4131 dequeue: function( elem, type ) {
vendor: 2,750 bytes, lines 4132-4257
4132 type = type || "fx"; 4133 4134 var queue = jQuery.queue( elem, type ), 4135 startLength = queue.length, 4136 fn = queue.shift(), 4137 hooks = jQuery._queueHooks( elem, type ), 4138 next = function() { 4139 jQuery.dequeue( elem, type ); 4140 }; 4141 4142 // If the fx queue is dequeued, always remove the progress sentinel 4143 if ( fn === "inprogress" ) { 4144 fn = queue.shift(); 4145 startLength--; 4146 } 4147 4148 if ( fn ) { 4149 4150 // Add a progress sentinel to prevent the fx queue from being 4151 // automatically dequeued 4152 if ( type === "fx" ) { 4153 queue.unshift( "inprogress" ); 4154 } 4155 4156 // clear up the last queue stop function 4157 delete hooks.stop; 4158 fn.call( elem, next, hooks ); 4159 } 4160 4161 if ( !startLength && hooks ) { 4162 hooks.empty.fire(); 4163 } 4164 }, 4165 4166 // not intended for public consumption - generates a queueHooks object, 4167 // or returns the current one 4168 _queueHooks: function( elem, type ) { 4169 var key = type + "queueHooks"; 4170 return jQuery._data( elem, key ) || jQuery._data( elem, key, { 4171 empty: jQuery.Callbacks( "once memory" ).add( function() { 4172 jQuery._removeData( elem, type + "queue" ); 4173 jQuery._removeData( elem, key ); 4174 } ) 4175 } ); 4176 } 4177} ); 4178 4179jQuery.fn.extend( { 4180 queue: function( type, data ) { 4181 var setter = 2; 4182 4183 if ( typeof type !== "string" ) { 4184 data = type; 4185 type = "fx"; 4186 setter--; 4187 } 4188 4189 if ( arguments.length < setter ) { 4190 return jQuery.queue( this[ 0 ], type ); 4191 } 4192 4193 return data === undefined ? 4194 this : 4195 this.each( function() { 4196 var queue = jQuery.queue( this, type, data ); 4197 4198 // ensure a hooks for this queue 4199 jQuery._queueHooks( this, type ); 4200 4201 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { 4202 jQuery.dequeue( this, type ); 4203 } 4204 } ); 4205 }, 4206 dequeue: function( type ) { 4207 return this.each( function() { 4208 jQuery.dequeue( this, type ); 4209 } ); 4210 }, 4211 clearQueue: function( type ) { 4212 return this.queue( type || "fx", [] ); 4213 }, 4214 4215 // Get a promise resolved when queues of a certain type 4216 // are emptied (fx is the type by default) 4217 promise: function( type, obj ) { 4218 var tmp, 4219 count = 1, 4220 defer = jQuery.Deferred(), 4221 elements = this, 4222 i = this.length, 4223 resolve = function() { 4224 if ( !( --count ) ) { 4225 defer.resolveWith( elements, [ elements ] ); 4226 } 4227 }; 4228 4229 if ( typeof type !== "string" ) { 4230 obj = type; 4231 type = undefined; 4232 } 4233 type = type || "fx"; 4234 4235 while ( i-- ) { 4236 tmp = jQuery._data( elements[ i ], type + "queueHooks" ); 4237 if ( tmp && tmp.empty ) { 4238 count++; 4239 tmp.empty.add( resolve ); 4240 } 4241 } 4242 resolve(); 4243 return defer.promise( obj ); 4244 } 4245} ); 4246 4247 4248( function() { 4249 var shrinkWrapBlocksVal; 4250 4251 support.shrinkWrapBlocks = function() { 4252 if ( shrinkWrapBlocksVal != null ) { 4253 return shrinkWrapBlocksVal; 4254 } 4255 4256 // Will be changed later if needed. 4257 shrinkWrapBlocksVal = false;
4258 4259 // Minified: var b,c,d 4260 var div, body, container; 4261 4262 body = document.getElementsByTagName( "body" )[ 0 ]; 4263 if ( !body || !body.style ) { 4264 4265 // Test fired too early or in an unsupported environment, exit. 4266 return; 4267 } 4268 4269 // Setup 4270 div = document.createElement( "div" ); 4271 container = document.createElement( "div" ); 4272 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px"; 4273 body.appendChild( container ).appendChild( div ); 4274 4275 // Support: IE6 4276 // Check if elements with layout shrink-wrap their children 4277 if ( typeof div.style.zoom !== "undefined" ) { 4278 4279 // Reset CSS: box-sizing; display; margin; border 4280 div.style.cssText = 4281 4282 // Support: Firefox<29, Android 2.3 4283 // Vendor-prefix box-sizing 4284 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" + 4285 "box-sizing:content-box;display:block;margin:0;border:0;" + 4286 "padding:1px;width:1px;zoom:1"; 4287 div.appendChild( document.createElement( "div" ) ).style.width = "5px"; 4288 shrinkWrapBlocksVal = div.offsetWidth !== 3; 4289 } 4290 4291 body.removeChild( container ); 4292 4293 return shrinkWrapBlocksVal; 4294 }; 4295 4296} )(); 4297var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; 4298 4299var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); 4300 4301 4302var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; 4303 4304var isHidden = function( elem, el ) { 4305 4306 // isHidden might be called from jQuery#filter function; 4307 // in that case, element will be second argument 4308 elem = el || elem; 4309 return jQuery.css( elem, "display" ) === "none" || 4310 !jQuery.contains( elem.ownerDocument, elem ); 4311 }; 4312 4313 4314 4315function adjustCSS( elem, prop, valueParts, tween ) { 4316 var adjusted, 4317 scale = 1, 4318 maxIterations = 20, 4319 currentValue = tween ? 4320 function() { return tween.cur(); } : 4321 function() { return jQuery.css( elem, prop, "" ); }, 4322 initial = currentValue(), 4323 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), 4324 4325 // Starting value computation is required for potential unit mismatches 4326 initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && 4327 rcssNum.exec( jQuery.css( elem, prop ) ); 4328 4329 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { 4330 4331 // Trust units reported by jQuery.css 4332 unit = unit || initialInUnit[ 3 ]; 4333 4334 // Make sure we update the tween properties later on 4335 valueParts = valueParts || []; 4336 4337 // Iteratively approximate from a nonzero starting point 4338 initialInUnit = +initial || 1; 4339 4340 do { 4341 4342 // If previous iteration zeroed out, double until we get *something*. 4343 // Use string for doubling so we don't accidentally see scale as unchanged below 4344 scale = scale || ".5"; 4345 4346 // Adjust and apply 4347 initialInUnit = initialInUnit / scale; 4348 jQuery.style( elem, prop, initialInUnit + unit ); 4349 4350 // Update scale, tolerating zero or NaN from tween.cur() 4351 // Break the loop if scale is unchanged or perfect, or if we've just had enough. 4352 } while ( 4353 scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations 4354 ); 4355 } 4356 4357 if ( valueParts ) { 4358 initialInUnit = +initialInUnit || +initial || 0; 4359 4360 // Apply relative offset (+=/-=) if specified 4361 adjusted = valueParts[ 1 ] ? 4362 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : 4363 +valueParts[ 2 ]; 4364 if ( tween ) { 4365 tween.unit = unit; 4366 tween.start = initialInUnit; 4367 tween.end = adjusted; 4368 } 4369 } 4370 return adjusted; 4371} 4372 4373 4374// Multifunctional method to get and set values of a collection 4375// The value/s can optionally be executed if it's a function 4376var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { 4377 var i = 0, 4378 length = elems.length, 4379 bulk = key == null; 4380 4381 // Sets many values 4382 if ( jQuery.type( key ) === "object" ) { 4383 chainable = true; 4384 for ( i in key ) { 4385 access( elems, fn, i, key[ i ], true, emptyGet, raw ); 4386 } 4387 4388 // Sets one value 4389 } else if ( value !== undefined ) { 4390 chainable = true; 4391 4392 if ( !jQuery.isFunction( value ) ) { 4393 raw = true; 4394 } 4395 4396 if ( bulk ) { 4397 4398 // Bulk operations run against the entire set 4399 if ( raw ) { 4400 fn.call( elems, value ); 4401 fn = null; 4402 4403 // ...except when executing function values 4404 } else { 4405 bulk = fn; 4406 fn = function( elem, key, value ) {
4407 return bulk.call( jQuery( elem ), value ); 4408 }; 4409 } 4410 } 4411 4412 if ( fn ) { 4413 for ( ; i < length; i++ ) { 4414 fn( 4415 elems[ i ], 4416 key, 4417 raw ? value : value.call( elems[ i ], i, fn( elems[ i ], key ) ) 4418 ); 4419 } 4420 } 4421 } 4422 4423 return chainable ? 4424 elems : 4425 4426 // Gets 4427 bulk ? 4428 fn.call( elems ) : 4429 length ? fn( elems[ 0 ], key ) : emptyGet; 4430}; 4431var rcheckableType = ( /^(?:checkbox|radio)$/i ); 4432 4433var rtagName = ( /<([\w:-]+)/ ); 4434 4435var rscriptType = ( /^$|\/(?:java|ecma)script/i ); 4436 4437var rleadingWhitespace = ( /^\s+/ ); 4438 4439var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|" + 4440 "details|dialog|figcaption|figure|footer|header|hgroup|main|" + 4441 "mark|meter|nav|output|picture|progress|section|summary|template|time|video"; 4442 4443 4444 4445function createSafeFragment( document ) { 4446 var list = nodeNames.split( "|" ), 4447 safeFrag = document.createDocumentFragment(); 4448 4449 if ( safeFrag.createElement ) { 4450 while ( list.length ) { 4451 safeFrag.createElement( 4452 list.pop() 4453 ); 4454 } 4455 } 4456 return safeFrag; 4457} 4458 4459 4460( function() { 4461 var div = document.createElement( "div" ), 4462 fragment = document.createDocumentFragment(), 4463 input = document.createElement( "input" ); 4464 4465 // Setup 4466 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; 4467 4468 // IE strips leading whitespace when .innerHTML is used 4469 support.leadingWhitespace = div.firstChild.nodeType === 3; 4470 4471 // Make sure that tbody elements aren't automatically inserted 4472 // IE will insert them into empty tables 4473 support.tbody = !div.getElementsByTagName( "tbody" ).length; 4474 4475 // Make sure that link elements get serialized correctly by innerHTML 4476 // This requires a wrapper element in IE 4477 support.htmlSerialize = !!div.getElementsByTagName( "link" ).length; 4478 4479 // Makes sure cloning an html5 element does not cause problems 4480 // Where outerHTML is undefined, this still works 4481 support.html5Clone = 4482 document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>"; 4483 4484 // Check if a disconnected checkbox will retain its checked 4485 // value of true after appended to the DOM (IE6/7) 4486 input.type = "checkbox"; 4487 input.checked = true; 4488 fragment.appendChild( input ); 4489 support.appendChecked = input.checked; 4490 4491 // Make sure textarea (and checkbox) defaultValue is properly cloned 4492 // Support: IE6-IE11+ 4493 div.innerHTML = "<textarea>x</textarea>"; 4494 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; 4495 4496 // #11217 - WebKit loses check when the name is after the checked attribute 4497 fragment.appendChild( div ); 4498 4499 // Support: Windows Web Apps (WWA) 4500 // `name` and `type` must use .setAttribute for WWA (#14901) 4501 input = document.createElement( "input" ); 4502 input.setAttribute( "type", "radio" ); 4503 input.setAttribute( "checked", "checked" ); 4504 input.setAttribute( "name", "t" ); 4505 4506 div.appendChild( input ); 4507 4508 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 4509 // old WebKit doesn't clone checked state correctly in fragments 4510 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; 4511 4512 // Support: IE<9 4513 // Cloned elements keep attachEvent handlers, we use addEventListener on IE9+ 4514 support.noCloneEvent = !!div.addEventListener; 4515 4516 // Support: IE<9 4517 // Since attributes and properties are the same in IE, 4518 // cleanData must set properties to undefined rather than use removeAttribute 4519 div[ jQuery.expando ] = 1; 4520 support.attributes = !div.getAttribute( jQuery.expando ); 4521} )(); 4522 4523 4524// We have to close these tags to support XHTML (#13200) 4525var wrapMap = { 4526 option: [ 1, "<select multiple='multiple'>", "</select>" ], 4527 legend: [ 1, "<fieldset>", "</fieldset>" ], 4528 area: [ 1, "<map>", "</map>" ], 4529 4530 // Support: IE8 4531 param: [ 1, "<object>", "</object>" ], 4532 thead: [ 1, "<table>", "</table>" ], 4533 tr: [ 2, "<table><tbody>", "</tbody></table>" ], 4534 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], 4535 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], 4536 4537 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, 4538 // unless wrapped in a div with non-breaking characters in front of it. 4539 _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ] 4540}; 4541 4542// Support: IE8-IE9 4543wrapMap.optgroup = wrapMap.option; 4544 4545wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; 4546wrapMap.th = wrapMap.td; 4547 4548 4549function getAll( context, tag ) { 4550 var elems, elem, 4551 i = 0, 4552 found = typeof context.getElementsByTagName !== "undefined" ? 4553 context.getElementsByTagName( tag || "*" ) : 4554 typeof context.querySelectorAll !== "undefined" ? 4555 context.querySelectorAll( tag || "*" ) : 4556 undefined; 4557 4558 if ( !found ) { 4559 for ( found = [], elems = context.childNodes || context; 4560 ( elem = elems[ i ] ) != null; 4561 i++ 4562 ) { 4563 if ( !tag || jQuery.nodeName( elem, tag ) ) { 4564 found.push( elem ); 4565 } else { 4566 jQuery.merge( found, getAll( elem, tag ) ); 4567 } 4568 } 4569 } 4570 4571 return tag === undefined || tag && jQuery.nodeName( context, tag ) ? 4572 jQuery.merge( [ context ], found ) : 4573 found; 4574} 4575 4576 4577// Mark scripts as having already been evaluated 4578function setGlobalEval( elems, refElements ) { 4579 var elem, 4580 i = 0; 4581 for ( ; ( elem = elems[ i ] ) != null; i++ ) { 4582 jQuery._data( 4583 elem, 4584 "globalEval", 4585 !refElements || jQuery._data( refElements[ i ], "globalEval" ) 4586 ); 4587 } 4588} 4589 4590
4591var rhtml = /<|&#?\w+;/, 4592 rtbody = /<tbody/i; 4593 4594function fixDefaultChecked( elem ) { 4595 if ( rcheckableType.test( elem.type ) ) { 4596 elem.defaultChecked = elem.checked; 4597 } 4598} 4599 4600function buildFragment( elems, context, scripts, selection, ignored ) { 4601 var j, elem, contains, 4602 tmp, tag, tbody, wrap, 4603 l = elems.length, 4604 4605 // Ensure a safe fragment 4606 safe = createSafeFragment( context ), 4607 4608 nodes = [], 4609 i = 0; 4610 4611 for ( ; i < l; i++ ) { 4612 elem = elems[ i ]; 4613 4614 if ( elem || elem === 0 ) { 4615 4616 // Add nodes directly 4617 if ( jQuery.type( elem ) === "object" ) { 4618 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); 4619 4620 // Convert non-html into a text node 4621 } else if ( !rhtml.test( elem ) ) { 4622 nodes.push( context.createTextNode( elem ) ); 4623 4624 // Convert html into DOM nodes 4625 } else { 4626 tmp = tmp || safe.appendChild( context.createElement( "div" ) ); 4627 4628 // Deserialize a standard representation 4629 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); 4630 wrap = wrapMap[ tag ] || wrapMap._default; 4631 4632 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; 4633 4634 // Descend through wrappers to the right content 4635 j = wrap[ 0 ]; 4636 while ( j-- ) { 4637 tmp = tmp.lastChild; 4638 } 4639 4640 // Manually add leading whitespace removed by IE 4641 if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { 4642 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[ 0 ] ) ); 4643 } 4644 4645 // Remove IE's autoinserted <tbody> from table fragments 4646 if ( !support.tbody ) { 4647 4648 // String was a <table>, *may* have spurious <tbody> 4649 elem = tag === "table" && !rtbody.test( elem ) ? 4650 tmp.firstChild : 4651 4652 // String was a bare <thead> or <tfoot> 4653 wrap[ 1 ] === "<table>" && !rtbody.test( elem ) ? 4654 tmp : 4655 0; 4656 4657 j = elem && elem.childNodes.length; 4658 while ( j-- ) { 4659 if ( jQuery.nodeName( ( tbody = elem.childNodes[ j ] ), "tbody" ) && 4660 !tbody.childNodes.length ) { 4661 4662 elem.removeChild( tbody ); 4663 } 4664 } 4665 } 4666 4667 jQuery.merge( nodes, tmp.childNodes ); 4668 4669 // Fix #12392 for WebKit and IE > 9 4670 tmp.textContent = ""; 4671 4672 // Fix #12392 for oldIE 4673 while ( tmp.firstChild ) { 4674 tmp.removeChild( tmp.firstChild ); 4675 } 4676 4677 // Remember the top-level container for proper cleanup 4678 tmp = safe.lastChild; 4679 } 4680 } 4681 } 4682 4683 // Fix #11356: Clear elements from fragment 4684 if ( tmp ) { 4685 safe.removeChild( tmp ); 4686 } 4687 4688 // Reset defaultChecked for any radios and checkboxes 4689 // about to be appended to the DOM in IE 6/7 (#8060) 4690 if ( !support.appendChecked ) { 4691 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked ); 4692 } 4693 4694 i = 0; 4695 while ( ( elem = nodes[ i++ ] ) ) { 4696 4697 // Skip elements already in the context collection (trac-4087) 4698 if ( selection && jQuery.inArray( elem, selection ) > -1 ) { 4699 if ( ignored ) { 4700 ignored.push( elem ); 4701 } 4702 4703 continue; 4704 } 4705 4706 contains = jQuery.contains( elem.ownerDocument, elem ); 4707 4708 // Append to fragment 4709 tmp = getAll( safe.appendChild( elem ), "script" ); 4710 4711 // Preserve script evaluation history 4712 if ( contains ) { 4713 setGlobalEval( tmp ); 4714 } 4715 4716 // Capture executables 4717 if ( scripts ) { 4718 j = 0; 4719 while ( ( elem = tmp[ j++ ] ) ) { 4720 if ( rscriptType.test( elem.type || "" ) ) { 4721 scripts.push( elem ); 4722 } 4723 } 4724 } 4725 } 4726 4727 tmp = null; 4728 4729 return safe; 4730} 4731 4732 4733( function() { 4734 var i, eventName, 4735 div = document.createElement( "div" ); 4736 4737 // Support: IE<9 (lack submit/change bubble), Firefox (lack focus(in | out) events) 4738 for ( i in { submit: true, change: true, focusin: true } ) { 4739 eventName = "on" + i; 4740
4741 if ( !( support[ i ] = eventName in window ) ) { 4742 4743 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP) 4744 div.setAttribute( eventName, "t" ); 4745 support[ i ] = div.attributes[ eventName ].expando === false; 4746 } 4747 } 4748 4749 // Null elements to avoid leaks in IE. 4750 div = null; 4751} )(); 4752 4753 4754var rformElems = /^(?:input|select|textarea)$/i, 4755 rkeyEvent = /^key/, 4756 rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, 4757 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, 4758 rtypenamespace = /^([^.]*)(?:\.(.+)|)/; 4759 4760function returnTrue() { 4761 return true; 4762} 4763 4764function returnFalse() { 4765 return false; 4766} 4767 4768// Support: IE9 4769// See #13393 for more info 4770function safeActiveElement() { 4771 try { 4772 return document.activeElement; 4773 } catch ( err ) { } 4774} 4775 4776function on( elem, types, selector, data, fn, one ) { 4777 var origFn, type; 4778 4779 // Types can be a map of types/handlers 4780 if ( typeof types === "object" ) { 4781 4782 // ( types-Object, selector, data ) 4783 if ( typeof selector !== "string" ) { 4784 4785 // ( types-Object, data ) 4786 data = data || selector; 4787 selector = undefined; 4788 } 4789 for ( type in types ) { 4790 on( elem, type, selector, data, types[ type ], one ); 4791 } 4792 return elem; 4793 } 4794 4795 if ( data == null && fn == null ) { 4796 4797 // ( types, fn ) 4798 fn = selector; 4799 data = selector = undefined; 4800 } else if ( fn == null ) { 4801 if ( typeof selector === "string" ) { 4802 4803 // ( types, selector, fn ) 4804 fn = data; 4805 data = undefined; 4806 } else { 4807 4808 // ( types, data, fn ) 4809 fn = data; 4810 data = selector; 4811 selector = undefined; 4812 } 4813 } 4814 if ( fn === false ) { 4815 fn = returnFalse; 4816 } else if ( !fn ) { 4817 return elem; 4818 } 4819 4820 if ( one === 1 ) { 4821 origFn = fn; 4822 fn = function( event ) { 4823 4824 // Can use an empty set, since event contains the info 4825 jQuery().off( event ); 4826 return origFn.apply( this, arguments ); 4827 }; 4828 4829 // Use same guid so caller can remove using origFn 4830 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); 4831 } 4832 return elem.each( function() { 4833 jQuery.event.add( this, types, fn, data, selector ); 4834 } ); 4835} 4836 4837/* 4838 * Helper functions for managing events -- not part of the public interface. 4839 * Props to Dean Edwards' addEvent library for many of the ideas. 4840 */ 4841jQuery.event = { 4842 4843 global: {}, 4844 4845 add: function( elem, types, handler, data, selector ) { 4846 var tmp, events, t, handleObjIn, 4847 special, eventHandle, handleObj, 4848 handlers, type, namespaces, origType, 4849 elemData = jQuery._data( elem ); 4850 4851 // Don't attach events to noData or text/comment nodes (but allow plain objects) 4852 if ( !elemData ) { 4853 return; 4854 } 4855 4856 // Caller can pass in an object of custom data in lieu of the handler 4857 if ( handler.handler ) { 4858 handleObjIn = handler; 4859 handler = handleObjIn.handler; 4860 selector = handleObjIn.selector; 4861 } 4862 4863 // Make sure that the handler has a unique ID, used to find/remove it later 4864 if ( !handler.guid ) { 4865 handler.guid = jQuery.guid++; 4866 } 4867 4868 // Init the element's event structure and main handler, if this is the first 4869 if ( !( events = elemData.events ) ) { 4870 events = elemData.events = {}; 4871 } 4872 if ( !( eventHandle = elemData.handle ) ) { 4873 eventHandle = elemData.handle = function( e ) { 4874 4875 // Discard the second event of a jQuery.event.trigger() and 4876 // when an event is called after a page has unloaded 4877 return typeof jQuery !== "undefined" && 4878 ( !e || jQuery.event.triggered !== e.type ) ? 4879 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : 4880 undefined; 4881 }; 4882 4883 // Add elem as a property of the handle fn to prevent a memory leak 4884 // with IE non-native events 4885 eventHandle.elem = elem; 4886 } 4887 4888 // Handle multiple events separated by a space 4889 types = ( types || "" ).match( rnotwhite ) || [ "" ]; 4890 t = types.length; 4891 while ( t-- ) { 4892 tmp = rtypenamespace.exec( types[ t ] ) || []; 4893 type = origType = tmp[ 1 ]; 4894 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 4895 4896 // There *must* be a type, no attaching namespace-only handlers 4897 if ( !type ) { 4898 continue; 4899 } 4900 4901 // If event changes its type, use the special event handlers for the changed type 4902 special = jQuery.event.special[ type ] || {}; 4903 4904 // If selector defined, determine special event api type, otherwise given type 4905 type = ( selector ? special.delegateType : special.bindType ) || type; 4906 4907 // Update special based on newly reset type 4908 special = jQuery.event.special[ type ] || {}; 4909 4910 // handleObj is passed to all event handlers 4911 handleObj = jQuery.extend( { 4912 type: type, 4913 origType: origType, 4914 data: data, 4915 handler: handler, 4916 guid: handler.guid, 4917 selector: selector, 4918 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), 4919 namespace: namespaces.join( "." ) 4920 }, handleObjIn ); 4921 4922 // Init the event handler queue if we're the first 4923 if ( !( handlers = events[ type ] ) ) { 4924 handlers = events[ type ] = []; 4925 handlers.delegateCount = 0; 4926 4927 // Only use addEventListener/attachEvent if the special events handler returns false 4928 if ( !special.setup || 4929 special.setup.call( elem, data, namespaces, eventHandle ) === false ) { 4930 4931 // Bind the global event handler to the element 4932 if ( elem.addEventListener ) { 4933 elem.addEventListener( type, eventHandle, false ); 4934 4935 } else if ( elem.attachEvent ) { 4936 elem.attachEvent( "on" + type, eventHandle ); 4937 } 4938 } 4939 } 4940 4941 if ( special.add ) { 4942 special.add.call( elem, handleObj ); 4943 4944 if ( !handleObj.handler.guid ) { 4945 handleObj.handler.guid = handler.guid; 4946 } 4947 } 4948 4949 // Add to the element's handler list, delegates in front 4950 if ( selector ) { 4951 handlers.splice( handlers.delegateCount++, 0, handleObj ); 4952 } else { 4953 handlers.push( handleObj ); 4954 } 4955 4956 // Keep track of which events have ever been used, for event optimization 4957 jQuery.event.global[ type ] = true; 4958 } 4959 4960 // Nullify elem to prevent memory leaks in IE 4961 elem = null; 4962 }, 4963 4964 // Detach an event or set of events from an element 4965 remove: function( elem, types, handler, selector, mappedTypes ) { 4966 var j, handleObj, tmp, 4967 origCount, t, events, 4968 special, handlers, type, 4969 namespaces, origType, 4970 elemData = jQuery.hasData( elem ) && jQuery._data( elem ); 4971 4972 if ( !elemData || !( events = elemData.events ) ) { 4973 return; 4974 } 4975
vendor: 7,639 bytes, lines 4976-5220
4976 // Once for each type.namespace in types; type may be omitted 4977 types = ( types || "" ).match( rnotwhite ) || [ "" ]; 4978 t = types.length; 4979 while ( t-- ) { 4980 tmp = rtypenamespace.exec( types[ t ] ) || []; 4981 type = origType = tmp[ 1 ]; 4982 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 4983 4984 // Unbind all events (on this namespace, if provided) for the element 4985 if ( !type ) { 4986 for ( type in events ) { 4987 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); 4988 } 4989 continue; 4990 } 4991 4992 special = jQuery.event.special[ type ] || {}; 4993 type = ( selector ? special.delegateType : special.bindType ) || type; 4994 handlers = events[ type ] || []; 4995 tmp = tmp[ 2 ] && 4996 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); 4997 4998 // Remove matching events 4999 origCount = j = handlers.length; 5000 while ( j-- ) { 5001 handleObj = handlers[ j ]; 5002 5003 if ( ( mappedTypes || origType === handleObj.origType ) && 5004 ( !handler || handler.guid === handleObj.guid ) && 5005 ( !tmp || tmp.test( handleObj.namespace ) ) && 5006 ( !selector || selector === handleObj.selector || 5007 selector === "**" && handleObj.selector ) ) { 5008 handlers.splice( j, 1 ); 5009 5010 if ( handleObj.selector ) { 5011 handlers.delegateCount--; 5012 } 5013 if ( special.remove ) { 5014 special.remove.call( elem, handleObj ); 5015 } 5016 } 5017 } 5018 5019 // Remove generic event handler if we removed something and no more handlers exist 5020 // (avoids potential for endless recursion during removal of special event handlers) 5021 if ( origCount && !handlers.length ) { 5022 if ( !special.teardown || 5023 special.teardown.call( elem, namespaces, elemData.handle ) === false ) { 5024 5025 jQuery.removeEvent( elem, type, elemData.handle ); 5026 } 5027 5028 delete events[ type ]; 5029 } 5030 } 5031 5032 // Remove the expando if it's no longer used 5033 if ( jQuery.isEmptyObject( events ) ) { 5034 delete elemData.handle; 5035 5036 // removeData also checks for emptiness and clears the expando if empty 5037 // so use it instead of delete 5038 jQuery._removeData( elem, "events" ); 5039 } 5040 }, 5041 5042 trigger: function( event, data, elem, onlyHandlers ) { 5043 var handle, ontype, cur, 5044 bubbleType, special, tmp, i, 5045 eventPath = [ elem || document ], 5046 type = hasOwn.call( event, "type" ) ? event.type : event, 5047 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; 5048 5049 cur = tmp = elem = elem || document; 5050 5051 // Don't do events on text and comment nodes 5052 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { 5053 return; 5054 } 5055 5056 // focus/blur morphs to focusin/out; ensure we're not firing them right now 5057 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { 5058 return; 5059 } 5060 5061 if ( type.indexOf( "." ) > -1 ) { 5062 5063 // Namespaced trigger; create a regexp to match event type in handle() 5064 namespaces = type.split( "." ); 5065 type = namespaces.shift(); 5066 namespaces.sort(); 5067 } 5068 ontype = type.indexOf( ":" ) < 0 && "on" + type; 5069 5070 // Caller can pass in a jQuery.Event object, Object, or just an event type string 5071 event = event[ jQuery.expando ] ? 5072 event : 5073 new jQuery.Event( type, typeof event === "object" && event ); 5074 5075 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) 5076 event.isTrigger = onlyHandlers ? 2 : 3; 5077 event.namespace = namespaces.join( "." ); 5078 event.rnamespace = event.namespace ? 5079 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : 5080 null; 5081 5082 // Clean up the event in case it is being reused 5083 event.result = undefined; 5084 if ( !event.target ) { 5085 event.target = elem; 5086 } 5087 5088 // Clone any incoming data and prepend the event, creating the handler arg list 5089 data = data == null ? 5090 [ event ] : 5091 jQuery.makeArray( data, [ event ] ); 5092 5093 // Allow special events to draw outside the lines 5094 special = jQuery.event.special[ type ] || {}; 5095 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { 5096 return; 5097 } 5098 5099 // Determine event propagation path in advance, per W3C events spec (#9951) 5100 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) 5101 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { 5102 5103 bubbleType = special.delegateType || type; 5104 if ( !rfocusMorph.test( bubbleType + type ) ) { 5105 cur = cur.parentNode; 5106 } 5107 for ( ; cur; cur = cur.parentNode ) { 5108 eventPath.push( cur ); 5109 tmp = cur; 5110 } 5111 5112 // Only add window if we got to document (e.g., not plain obj or detached DOM) 5113 if ( tmp === ( elem.ownerDocument || document ) ) { 5114 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); 5115 } 5116 } 5117 5118 // Fire handlers on the event path 5119 i = 0; 5120 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { 5121 5122 event.type = i > 1 ? 5123 bubbleType : 5124 special.bindType || type; 5125 5126 // jQuery handler 5127 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && 5128 jQuery._data( cur, "handle" ); 5129 5130 if ( handle ) { 5131 handle.apply( cur, data ); 5132 } 5133 5134 // Native handler 5135 handle = ontype && cur[ ontype ]; 5136 if ( handle && handle.apply && acceptData( cur ) ) { 5137 event.result = handle.apply( cur, data ); 5138 if ( event.result === false ) { 5139 event.preventDefault(); 5140 } 5141 } 5142 } 5143 event.type = type; 5144 5145 // If nobody prevented the default action, do it now 5146 if ( !onlyHandlers && !event.isDefaultPrevented() ) { 5147 5148 if ( 5149 ( !special._default || 5150 special._default.apply( eventPath.pop(), data ) === false 5151 ) && acceptData( elem ) 5152 ) { 5153 5154 // Call a native DOM method on the target with the same name name as the event. 5155 // Can't use an .isFunction() check here because IE6/7 fails that test. 5156 // Don't do default actions on window, that's where global variables be (#6170) 5157 if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { 5158 5159 // Don't re-trigger an onFOO event when we call its FOO() method 5160 tmp = elem[ ontype ]; 5161 5162 if ( tmp ) { 5163 elem[ ontype ] = null; 5164 } 5165 5166 // Prevent re-triggering of the same event, since we already bubbled it above 5167 jQuery.event.triggered = type; 5168 try { 5169 elem[ type ](); 5170 } catch ( e ) { 5171 5172 // IE<9 dies on focus/blur to hidden element (#1486,#12518) 5173 // only reproducible on winXP IE8 native, not IE9 in IE8 mode 5174 } 5175 jQuery.event.triggered = undefined; 5176 5177 if ( tmp ) { 5178 elem[ ontype ] = tmp; 5179 } 5180 } 5181 } 5182 } 5183 5184 return event.result; 5185 }, 5186 5187 dispatch: function( event ) { 5188 5189 // Make a writable jQuery.Event from the native event object 5190 event = jQuery.event.fix( event ); 5191 5192 var i, j, ret, matched, handleObj, 5193 handlerQueue = [], 5194 args = slice.call( arguments ), 5195 handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [], 5196 special = jQuery.event.special[ event.type ] || {}; 5197 5198 // Use the fix-ed jQuery.Event rather than the (read-only) native event 5199 args[ 0 ] = event; 5200 event.delegateTarget = this; 5201 5202 // Call the preDispatch hook for the mapped type, and let it bail if desired 5203 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { 5204 return; 5205 } 5206 5207 // Determine handlers 5208 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); 5209 5210 // Run delegates first; they may want to stop propagation beneath us 5211 i = 0; 5212 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { 5213 event.currentTarget = matched.elem; 5214 5215 j = 0; 5216 while ( ( handleObj = matched.handlers[ j++ ] ) && 5217 !event.isImmediatePropagationStopped() ) { 5218 5219 // Triggered event must either 1) have no namespace, or 2) have namespace(s) 5220 // a subset or equal to those in the bound event (both can have no namespace).
5221 if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) { 5222 5223 event.handleObj = handleObj; 5224 event.data = handleObj.data; 5225 5226 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || 5227 handleObj.handler ).apply( matched.elem, args ); 5228 5229 if ( ret !== undefined ) { 5230 if ( ( event.result = ret ) === false ) { 5231 event.preventDefault(); 5232 event.stopPropagation(); 5233 } 5234 } 5235 } 5236 } 5237 } 5238 5239 // Call the postDispatch hook for the mapped type 5240 if ( special.postDispatch ) { 5241 special.postDispatch.call( this, event ); 5242 } 5243 5244 return event.result; 5245 }, 5246 5247 handlers: function( event, handlers ) { 5248 var i, matches, sel, handleObj, 5249 handlerQueue = [], 5250 delegateCount = handlers.delegateCount, 5251 cur = event.target; 5252 5253 // Support (at least): Chrome, IE9 5254 // Find delegate handlers 5255 // Black-hole SVG <use> instance trees (#13180) 5256 // 5257 // Support: Firefox<=42+ 5258 // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343) 5259 if ( delegateCount && cur.nodeType && 5260 ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) { 5261 5262 /* jshint eqeqeq: false */ 5263 for ( ; cur != this; cur = cur.parentNode || this ) { 5264 /* jshint eqeqeq: true */ 5265 5266 // Don't check non-elements (#13208) 5267 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) 5268 if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) { 5269 matches = []; 5270 for ( i = 0; i < delegateCount; i++ ) { 5271 handleObj = handlers[ i ]; 5272 5273 // Don't conflict with Object.prototype properties (#13203) 5274 sel = handleObj.selector + " "; 5275 5276 if ( matches[ sel ] === undefined ) { 5277 matches[ sel ] = handleObj.needsContext ? 5278 jQuery( sel, this ).index( cur ) > -1 : 5279 jQuery.find( sel, this, null, [ cur ] ).length; 5280 } 5281 if ( matches[ sel ] ) { 5282 matches.push( handleObj ); 5283 } 5284 } 5285 if ( matches.length ) { 5286 handlerQueue.push( { elem: cur, handlers: matches } ); 5287 } 5288 } 5289 } 5290 } 5291 5292 // Add the remaining (directly-bound) handlers 5293 if ( delegateCount < handlers.length ) { 5294 handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } ); 5295 } 5296 5297 return handlerQueue; 5298 }, 5299 5300 fix: function( event ) { 5301 if ( event[ jQuery.expando ] ) { 5302 return event; 5303 } 5304 5305 // Create a writable copy of the event object and normalize some properties 5306 var i, prop, copy, 5307 type = event.type, 5308 originalEvent = event, 5309 fixHook = this.fixHooks[ type ]; 5310 5311 if ( !fixHook ) { 5312 this.fixHooks[ type ] = fixHook = 5313 rmouseEvent.test( type ) ? this.mouseHooks : 5314 rkeyEvent.test( type ) ? this.keyHooks : 5315 {}; 5316 } 5317 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; 5318 5319 event = new jQuery.Event( originalEvent ); 5320 5321 i = copy.length; 5322 while ( i-- ) { 5323 prop = copy[ i ]; 5324 event[ prop ] = originalEvent[ prop ]; 5325 } 5326 5327 // Support: IE<9 5328 // Fix target property (#1925) 5329 if ( !event.target ) { 5330 event.target = originalEvent.srcElement || document; 5331 } 5332 5333 // Support: Safari 6-8+ 5334 // Target should not be a text node (#504, #13143) 5335 if ( event.target.nodeType === 3 ) { 5336 event.target = event.target.parentNode; 5337 } 5338 5339 // Support: IE<9 5340 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328) 5341 event.metaKey = !!event.metaKey; 5342 5343 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; 5344 }, 5345 5346 // Includes some event props shared by KeyEvent and MouseEvent 5347 props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " + 5348 "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ), 5349 5350 fixHooks: {}, 5351 5352 keyHooks: { 5353 props: "char charCode key keyCode".split( " " ), 5354 filter: function( event, original ) { 5355 5356 // Add which for key events 5357 if ( event.which == null ) { 5358 event.which = original.charCode != null ? original.charCode : original.keyCode; 5359 } 5360 5361 return event; 5362 } 5363 }, 5364 5365 mouseHooks: { 5366 props: ( "button buttons clientX clientY fromElement offsetX offsetY " + 5367 "pageX pageY screenX screenY toElement" ).split( " " ), 5368 filter: function( event, original ) { 5369 var body, eventDoc, doc, 5370 button = original.button, 5371 fromElement = original.fromElement; 5372 5373 // Calculate pageX/Y if missing and clientX/Y available 5374 if ( event.pageX == null && original.clientX != null ) { 5375 eventDoc = event.target.ownerDocument || document; 5376 doc = eventDoc.documentElement; 5377 body = eventDoc.body; 5378 5379 event.pageX = original.clientX + 5380 ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - 5381 ( doc && doc.clientLeft || body && body.clientLeft || 0 ); 5382 event.pageY = original.clientY + 5383 ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - 5384 ( doc && doc.clientTop || body && body.clientTop || 0 ); 5385 } 5386 5387 // Add relatedTarget, if necessary 5388 if ( !event.relatedTarget && fromElement ) { 5389 event.relatedTarget = fromElement === event.target ? 5390 original.toElement : 5391 fromElement; 5392 } 5393 5394 // Add which for click: 1 === left; 2 === middle; 3 === right 5395 // Note: button is not normalized, so don't use it 5396 if ( !event.which && button !== undefined ) { 5397 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); 5398 } 5399 5400 return event; 5401 } 5402 }, 5403 5404 special: { 5405 load: { 5406 5407 // Prevent triggered image.load events from bubbling to window.load 5408 noBubble: true 5409 }, 5410 focus: { 5411 5412 // Fire native event if possible so blur/focus sequence is correct 5413 trigger: function() { 5414 if ( this !== safeActiveElement() && this.focus ) { 5415 try { 5416 this.focus(); 5417 return false;
5418 } catch ( e ) { 5419 5420 // Support: IE<9 5421 // If we error on focus to hidden element (#1486, #12518), 5422 // let .trigger() run the handlers 5423 } 5424 } 5425 }, 5426 delegateType: "focusin" 5427 }, 5428 blur: { 5429 trigger: function() { 5430 if ( this === safeActiveElement() && this.blur ) { 5431 this.blur(); 5432 return false; 5433 } 5434 }, 5435 delegateType: "focusout" 5436 }, 5437 click: { 5438 5439 // For checkbox, fire native event so checked state will be right 5440 trigger: function() { 5441 if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) { 5442 this.click(); 5443 return false; 5444 } 5445 }, 5446 5447 // For cross-browser consistency, don't fire native .click() on links 5448 _default: function( event ) { 5449 return jQuery.nodeName( event.target, "a" ); 5450 } 5451 }, 5452 5453 beforeunload: { 5454 postDispatch: function( event ) { 5455 5456 // Support: Firefox 20+ 5457 // Firefox doesn't alert if the returnValue field is not set. 5458 if ( event.result !== undefined && event.originalEvent ) { 5459 event.originalEvent.returnValue = event.result; 5460 } 5461 } 5462 } 5463 }, 5464 5465 // Piggyback on a donor event to simulate a different one 5466 simulate: function( type, elem, event ) { 5467 var e = jQuery.extend( 5468 new jQuery.Event(), 5469 event, 5470 { 5471 type: type, 5472 isSimulated: true 5473 5474 // Previously, `originalEvent: {}` was set here, so stopPropagation call 5475 // would not be triggered on donor event, since in our own 5476 // jQuery.event.stopPropagation function we had a check for existence of 5477 // originalEvent.stopPropagation method, so, consequently it would be a noop. 5478 // 5479 // Guard for simulated events was moved to jQuery.event.stopPropagation function 5480 // since `originalEvent` should point to the original event for the 5481 // constancy with other events and for more focused logic 5482 } 5483 ); 5484 5485 jQuery.event.trigger( e, null, elem ); 5486 5487 if ( e.isDefaultPrevented() ) { 5488 event.preventDefault(); 5489 } 5490 } 5491}; 5492 5493jQuery.removeEvent = document.removeEventListener ? 5494 function( elem, type, handle ) { 5495 5496 // This "if" is needed for plain objects 5497 if ( elem.removeEventListener ) { 5498 elem.removeEventListener( type, handle ); 5499 } 5500 } : 5501 function( elem, type, handle ) { 5502 var name = "on" + type; 5503 5504 if ( elem.detachEvent ) { 5505 5506 // #8545, #7054, preventing memory leaks for custom events in IE6-8 5507 // detachEvent needed property on element, by name of that event, 5508 // to properly expose it to GC 5509 if ( typeof elem[ name ] === "undefined" ) { 5510 elem[ name ] = null; 5511 } 5512 5513 elem.detachEvent( name, handle ); 5514 } 5515 }; 5516 5517jQuery.Event = function( src, props ) { 5518 5519 // Allow instantiation without the 'new' keyword 5520 if ( !( this instanceof jQuery.Event ) ) { 5521 return new jQuery.Event( src, props ); 5522 } 5523 5524 // Event object 5525 if ( src && src.type ) { 5526 this.originalEvent = src; 5527 this.type = src.type; 5528 5529 // Events bubbling up the document may have been marked as prevented 5530 // by a handler lower down the tree; reflect the correct value. 5531 this.isDefaultPrevented = src.defaultPrevented || 5532 src.defaultPrevented === undefined && 5533 5534 // Support: IE < 9, Android < 4.0 5535 src.returnValue === false ? 5536 returnTrue : 5537 returnFalse; 5538 5539 // Event type 5540 } else { 5541 this.type = src; 5542 } 5543 5544 // Put explicitly provided properties onto the event object 5545 if ( props ) { 5546 jQuery.extend( this, props ); 5547 } 5548 5549 // Create a timestamp if incoming event doesn't have one 5550 this.timeStamp = src && src.timeStamp || jQuery.now(); 5551 5552 // Mark it as fixed 5553 this[ jQuery.expando ] = true; 5554}; 5555 5556// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding 5557// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html 5558jQuery.Event.prototype = { 5559 constructor: jQuery.Event, 5560 isDefaultPrevented: returnFalse, 5561 isPropagationStopped: returnFalse, 5562 isImmediatePropagationStopped: returnFalse, 5563 5564 preventDefault: function() { 5565 var e = this.originalEvent; 5566 5567 this.isDefaultPrevented = returnTrue; 5568 if ( !e ) { 5569 return; 5570 } 5571 5572 // If preventDefault exists, run it on the original event 5573 if ( e.preventDefault ) { 5574 e.preventDefault(); 5575 5576 // Support: IE 5577 // Otherwise set the returnValue property of the original event to false 5578 } else { 5579 e.returnValue = false;
5580 } 5581 }, 5582 stopPropagation: function() { 5583 var e = this.originalEvent; 5584 5585 this.isPropagationStopped = returnTrue; 5586 5587 if ( !e || this.isSimulated ) { 5588 return; 5589 } 5590 5591 // If stopPropagation exists, run it on the original event 5592 if ( e.stopPropagation ) { 5593 e.stopPropagation(); 5594 } 5595 5596 // Support: IE 5597 // Set the cancelBubble property of the original event to true 5598 e.cancelBubble = true; 5599 }, 5600 stopImmediatePropagation: function() { 5601 var e = this.originalEvent; 5602 5603 this.isImmediatePropagationStopped = returnTrue; 5604 5605 if ( e && e.stopImmediatePropagation ) { 5606 e.stopImmediatePropagation(); 5607 } 5608 5609 this.stopPropagation(); 5610 } 5611}; 5612 5613// Create mouseenter/leave events using mouseover/out and event-time checks 5614// so that event delegation works in jQuery. 5615// Do the same for pointerenter/pointerleave and pointerover/pointerout 5616// 5617// Support: Safari 7 only 5618// Safari sends mouseenter too often; see: 5619// https://code.google.com/p/chromium/issues/detail?id=470258 5620// for the description of the bug (it existed in older Chrome versions as well). 5621jQuery.each( { 5622 mouseenter: "mouseover", 5623 mouseleave: "mouseout", 5624 pointerenter: "pointerover", 5625 pointerleave: "pointerout" 5626}, function( orig, fix ) { 5627 jQuery.event.special[ orig ] = { 5628 delegateType: fix, 5629 bindType: fix, 5630 5631 handle: function( event ) { 5632 var ret, 5633 target = this, 5634 related = event.relatedTarget, 5635 handleObj = event.handleObj; 5636 5637 // For mouseenter/leave call the handler if related is outside the target. 5638 // NB: No relatedTarget if the mouse left/entered the browser window 5639 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { 5640 event.type = handleObj.origType; 5641 ret = handleObj.handler.apply( this, arguments ); 5642 event.type = fix; 5643 } 5644 return ret; 5645 } 5646 }; 5647} ); 5648 5649// IE submit delegation 5650if ( !support.submit ) { 5651 5652 jQuery.event.special.submit = { 5653 setup: function() { 5654 5655 // Only need this for delegated form submit events 5656 if ( jQuery.nodeName( this, "form" ) ) { 5657 return false; 5658 } 5659 5660 // Lazy-add a submit handler when a descendant form may potentially be submitted 5661 jQuery.event.add( this, "click._submit keypress._submit", function( e ) { 5662 5663 // Node name check avoids a VML-related crash in IE (#9807) 5664 var elem = e.target, 5665 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? 5666 5667 // Support: IE <=8 5668 // We use jQuery.prop instead of elem.form 5669 // to allow fixing the IE8 delegated submit issue (gh-2332) 5670 // by 3rd party polyfills/workarounds. 5671 jQuery.prop( elem, "form" ) : 5672 undefined; 5673 5674 if ( form && !jQuery._data( form, "submit" ) ) { 5675 jQuery.event.add( form, "submit._submit", function( event ) { 5676 event._submitBubble = true; 5677 } ); 5678 jQuery._data( form, "submit", true ); 5679 } 5680 } ); 5681 5682 // return undefined since we don't need an event listener 5683 }, 5684 5685 postDispatch: function( event ) { 5686 5687 // If form was submitted by the user, bubble the event up the tree 5688 if ( event._submitBubble ) { 5689 delete event._submitBubble; 5690 if ( this.parentNode && !event.isTrigger ) { 5691 jQuery.event.simulate( "submit", this.parentNode, event ); 5692 } 5693 } 5694 }, 5695 5696 teardown: function() { 5697 5698 // Only need this for delegated form submit events 5699 if ( jQuery.nodeName( this, "form" ) ) { 5700 return false; 5701 } 5702 5703 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above 5704 jQuery.event.remove( this, "._submit" ); 5705 } 5706 }; 5707} 5708 5709// IE change delegation and checkbox/radio fix 5710if ( !support.change ) { 5711 5712 jQuery.event.special.change = { 5713 5714 setup: function() { 5715 5716 if ( rformElems.test( this.nodeName ) ) { 5717 5718 // IE doesn't fire change on a check/radio until blur; trigger it on click 5719 // after a propertychange. Eat the blur-change in special.change.handle. 5720 // This still fires onchange a second time for check/radio after blur. 5721 if ( this.type === "checkbox" || this.type === "radio" ) { 5722 jQuery.event.add( this, "propertychange._change", function( event ) { 5723 if ( event.originalEvent.propertyName === "checked" ) { 5724 this._justChanged = true; 5725 } 5726 } ); 5727 jQuery.event.add( this, "click._change", function( event ) { 5728 if ( this._justChanged && !event.isTrigger ) { 5729 this._justChanged = false;
5730 } 5731 5732 // Allow triggered, simulated change events (#11500) 5733 jQuery.event.simulate( "change", this, event ); 5734 } ); 5735 } 5736 return false; 5737 } 5738 5739 // Delegated event; lazy-add a change handler on descendant inputs 5740 jQuery.event.add( this, "beforeactivate._change", function( e ) { 5741 var elem = e.target; 5742 5743 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "change" ) ) { 5744 jQuery.event.add( elem, "change._change", function( event ) { 5745 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { 5746 jQuery.event.simulate( "change", this.parentNode, event ); 5747 } 5748 } ); 5749 jQuery._data( elem, "change", true ); 5750 } 5751 } ); 5752 }, 5753 5754 handle: function( event ) { 5755 var elem = event.target; 5756 5757 // Swallow native change events from checkbox/radio, we already triggered them above 5758 if ( this !== elem || event.isSimulated || event.isTrigger || 5759 ( elem.type !== "radio" && elem.type !== "checkbox" ) ) { 5760 5761 return event.handleObj.handler.apply( this, arguments ); 5762 } 5763 }, 5764 5765 teardown: function() { 5766 jQuery.event.remove( this, "._change" ); 5767 5768 return !rformElems.test( this.nodeName ); 5769 } 5770 }; 5771} 5772 5773// Support: Firefox 5774// Firefox doesn't have focus(in | out) events 5775// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 5776// 5777// Support: Chrome, Safari 5778// focus(in | out) events fire after focus & blur events, 5779// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order 5780// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857 5781if ( !support.focusin ) { 5782 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { 5783 5784 // Attach a single capturing handler on the document while someone wants focusin/focusout 5785 var handler = function( event ) { 5786 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); 5787 }; 5788 5789 jQuery.event.special[ fix ] = { 5790 setup: function() { 5791 var doc = this.ownerDocument || this, 5792 attaches = jQuery._data( doc, fix ); 5793 5794 if ( !attaches ) { 5795 doc.addEventListener( orig, handler, true ); 5796 } 5797 jQuery._data( doc, fix, ( attaches || 0 ) + 1 ); 5798 }, 5799 teardown: function() { 5800 var doc = this.ownerDocument || this, 5801 attaches = jQuery._data( doc, fix ) - 1; 5802 5803 if ( !attaches ) { 5804 doc.removeEventListener( orig, handler, true ); 5805 jQuery._removeData( doc, fix ); 5806 } else { 5807 jQuery._data( doc, fix, attaches ); 5808 } 5809 } 5810 }; 5811 } ); 5812} 5813 5814jQuery.fn.extend( { 5815 5816 on: function( types, selector, data, fn ) { 5817 return on( this, types, selector, data, fn ); 5818 }, 5819 one: function( types, selector, data, fn ) { 5820 return on( this, types, selector, data, fn, 1 ); 5821 }, 5822 off: function( types, selector, fn ) { 5823 var handleObj, type; 5824 if ( types && types.preventDefault && types.handleObj ) { 5825 5826 // ( event ) dispatched jQuery.Event 5827 handleObj = types.handleObj; 5828 jQuery( types.delegateTarget ).off( 5829 handleObj.namespace ? 5830 handleObj.origType + "." + handleObj.namespace : 5831 handleObj.origType, 5832 handleObj.selector, 5833 handleObj.handler 5834 ); 5835 return this; 5836 } 5837 if ( typeof types === "object" ) { 5838 5839 // ( types-object [, selector] ) 5840 for ( type in types ) { 5841 this.off( type, selector, types[ type ] ); 5842 } 5843 return this; 5844 } 5845 if ( selector === false || typeof selector === "function" ) { 5846 5847 // ( types [, fn] ) 5848 fn = selector; 5849 selector = undefined; 5850 } 5851 if ( fn === false ) { 5852 fn = returnFalse; 5853 } 5854 return this.each( function() { 5855 jQuery.event.remove( this, types, fn, selector ); 5856 } ); 5857 }, 5858 5859 trigger: function( type, data ) { 5860 return this.each( function() { 5861 jQuery.event.trigger( type, data, this ); 5862 } ); 5863 }, 5864 triggerHandler: function( type, data ) { 5865 var elem = this[ 0 ]; 5866 if ( elem ) { 5867 return jQuery.event.trigger( type, data, elem, true ); 5868 } 5869 } 5870} ); 5871 5872 5873var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, 5874 rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ), 5875 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, 5876 5877 // Support: IE 10-11, Edge 10240+ 5878 // In IE/Edge using regex groups here causes severe slowdowns. 5879 // See https://connect.microsoft.com/IE/feedback/details/1736512/ 5880 rnoInnerhtml = /<script|<style|<link/i, 5881 5882 // checked="checked" or checked 5883 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, 5884 rscriptTypeMasked = /^true\/(.*)/, 5885 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, 5886 safeFragment = createSafeFragment( document ), 5887 fragmentDiv = safeFragment.appendChild( document.createElement( "div" ) ); 5888 5889// Support: IE<8 5890// Manipulating tables requires a tbody 5891function manipulationTarget( elem, content ) { 5892 return jQuery.nodeName( elem, "table" ) && 5893 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? 5894 5895 elem.getElementsByTagName( "tbody" )[ 0 ] || 5896 elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) : 5897 elem; 5898} 5899 5900// Replace/restore the type attribute of script elements for safe DOM manipulation 5901function disableScript( elem ) { 5902 elem.type = ( jQuery.find.attr( elem, "type" ) !== null ) + "/" + elem.type; 5903 return elem; 5904} 5905function restoreScript( elem ) { 5906 var match = rscriptTypeMasked.exec( elem.type ); 5907 if ( match ) { 5908 elem.type = match[ 1 ]; 5909 } else { 5910 elem.removeAttribute( "type" ); 5911 } 5912 return elem; 5913} 5914 5915function cloneCopyEvent( src, dest ) {
5916 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { 5917 return; 5918 } 5919 5920 var type, i, l, 5921 oldData = jQuery._data( src ), 5922 curData = jQuery._data( dest, oldData ), 5923 events = oldData.events; 5924 5925 if ( events ) { 5926 delete curData.handle; 5927 curData.events = {}; 5928 5929 for ( type in events ) { 5930 for ( i = 0, l = events[ type ].length; i < l; i++ ) { 5931 jQuery.event.add( dest, type, events[ type ][ i ] ); 5932 } 5933 } 5934 } 5935 5936 // make the cloned public data object a copy from the original 5937 if ( curData.data ) { 5938 curData.data = jQuery.extend( {}, curData.data ); 5939 } 5940} 5941 5942function fixCloneNodeIssues( src, dest ) { 5943 var nodeName, e, data; 5944 5945 // We do not need to do anything for non-Elements 5946 if ( dest.nodeType !== 1 ) { 5947 return; 5948 } 5949 5950 nodeName = dest.nodeName.toLowerCase(); 5951 5952 // IE6-8 copies events bound via attachEvent when using cloneNode. 5953 if ( !support.noCloneEvent && dest[ jQuery.expando ] ) { 5954 data = jQuery._data( dest ); 5955 5956 for ( e in data.events ) { 5957 jQuery.removeEvent( dest, e, data.handle ); 5958 } 5959 5960 // Event data gets referenced instead of copied if the expando gets copied too 5961 dest.removeAttribute( jQuery.expando ); 5962 } 5963 5964 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text 5965 if ( nodeName === "script" && dest.text !== src.text ) { 5966 disableScript( dest ).text = src.text; 5967 restoreScript( dest ); 5968 5969 // IE6-10 improperly clones children of object elements using classid. 5970 // IE10 throws NoModificationAllowedError if parent is null, #12132. 5971 } else if ( nodeName === "object" ) { 5972 if ( dest.parentNode ) { 5973 dest.outerHTML = src.outerHTML; 5974 } 5975 5976 // This path appears unavoidable for IE9. When cloning an object 5977 // element in IE9, the outerHTML strategy above is not sufficient. 5978 // If the src has innerHTML and the destination does not, 5979 // copy the src.innerHTML into the dest.innerHTML. #10324 5980 if ( support.html5Clone && ( src.innerHTML && !jQuery.trim( dest.innerHTML ) ) ) { 5981 dest.innerHTML = src.innerHTML; 5982 } 5983 5984 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) { 5985 5986 // IE6-8 fails to persist the checked state of a cloned checkbox 5987 // or radio button. Worse, IE6-7 fail to give the cloned element 5988 // a checked appearance if the defaultChecked value isn't also set 5989 5990 dest.defaultChecked = dest.checked = src.checked; 5991 5992 // IE6-7 get confused and end up setting the value of a cloned 5993 // checkbox/radio button to an empty string instead of "on" 5994 if ( dest.value !== src.value ) { 5995 dest.value = src.value; 5996 } 5997 5998 // IE6-8 fails to return the selected option to the default selected 5999 // state when cloning options 6000 } else if ( nodeName === "option" ) { 6001 dest.defaultSelected = dest.selected = src.defaultSelected; 6002 6003 // IE6-8 fails to set the defaultValue to the correct value when 6004 // cloning other types of input fields 6005 } else if ( nodeName === "input" || nodeName === "textarea" ) { 6006 dest.defaultValue = src.defaultValue; 6007 } 6008} 6009 6010function domManip( collection, args, callback, ignored ) { 6011 6012 // Flatten any nested arrays 6013 args = concat.apply( [], args ); 6014 6015 var first, node, hasScripts, 6016 scripts, doc, fragment, 6017 i = 0, 6018 l = collection.length, 6019 iNoClone = l - 1, 6020 value = args[ 0 ], 6021 isFunction = jQuery.isFunction( value ); 6022 6023 // We can't cloneNode fragments that contain checked, in WebKit 6024 if ( isFunction || 6025 ( l > 1 && typeof value === "string" && 6026 !support.checkClone && rchecked.test( value ) ) ) { 6027 return collection.each( function( index ) { 6028 var self = collection.eq( index ); 6029 if ( isFunction ) { 6030 args[ 0 ] = value.call( this, index, self.html() ); 6031 } 6032 domManip( self, args, callback, ignored ); 6033 } ); 6034 } 6035 6036 if ( l ) { 6037 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); 6038 first = fragment.firstChild; 6039 6040 if ( fragment.childNodes.length === 1 ) { 6041 fragment = first; 6042 } 6043 6044 // Require either new content or an interest in ignored elements to invoke the callback 6045 if ( first || ignored ) { 6046 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); 6047 hasScripts = scripts.length; 6048 6049 // Use the original fragment for the last item 6050 // instead of the first because it can end up 6051 // being emptied incorrectly in certain situations (#8070). 6052 for ( ; i < l; i++ ) { 6053 node = fragment; 6054 6055 if ( i !== iNoClone ) { 6056 node = jQuery.clone( node, true, true ); 6057 6058 // Keep references to cloned scripts for later restoration 6059 if ( hasScripts ) { 6060
6061 // Support: Android<4.1, PhantomJS<2 6062 // push.apply(_, arraylike) throws on ancient WebKit 6063 jQuery.merge( scripts, getAll( node, "script" ) ); 6064 } 6065 } 6066 6067 callback.call( collection[ i ], node, i ); 6068 } 6069 6070 if ( hasScripts ) { 6071 doc = scripts[ scripts.length - 1 ].ownerDocument; 6072 6073 // Reenable scripts 6074 jQuery.map( scripts, restoreScript ); 6075 6076 // Evaluate executable scripts on first document insertion 6077 for ( i = 0; i < hasScripts; i++ ) { 6078 node = scripts[ i ]; 6079 if ( rscriptType.test( node.type || "" ) && 6080 !jQuery._data( node, "globalEval" ) && 6081 jQuery.contains( doc, node ) ) { 6082 6083 if ( node.src ) { 6084 6085 // Optional AJAX dependency, but won't run scripts if not present 6086 if ( jQuery._evalUrl ) { 6087 jQuery._evalUrl( node.src ); 6088 } 6089 } else { 6090 jQuery.globalEval( 6091 ( node.text || node.textContent || node.innerHTML || "" ) 6092 .replace( rcleanScript, "" ) 6093 ); 6094 } 6095 } 6096 } 6097 } 6098 6099 // Fix #11809: Avoid leaking memory 6100 fragment = first = null; 6101 } 6102 } 6103 6104 return collection; 6105} 6106 6107function remove( elem, selector, keepData ) { 6108 var node, 6109 elems = selector ? jQuery.filter( selector, elem ) : elem, 6110 i = 0; 6111 6112 for ( ; ( node = elems[ i ] ) != null; i++ ) { 6113 6114 if ( !keepData && node.nodeType === 1 ) { 6115 jQuery.cleanData( getAll( node ) ); 6116 } 6117 6118 if ( node.parentNode ) { 6119 if ( keepData && jQuery.contains( node.ownerDocument, node ) ) { 6120 setGlobalEval( getAll( node, "script" ) ); 6121 } 6122 node.parentNode.removeChild( node ); 6123 } 6124 } 6125 6126 return elem; 6127} 6128 6129jQuery.extend( { 6130 htmlPrefilter: function( html ) { 6131 return html.replace( rxhtmlTag, "<$1></$2>" ); 6132 }, 6133 6134 clone: function( elem, dataAndEvents, deepDataAndEvents ) { 6135 var destElements, node, clone, i, srcElements, 6136 inPage = jQuery.contains( elem.ownerDocument, elem ); 6137 6138 if ( support.html5Clone || jQuery.isXMLDoc( elem ) || 6139 !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { 6140 6141 clone = elem.cloneNode( true ); 6142 6143 // IE<=8 does not properly clone detached, unknown element nodes 6144 } else { 6145 fragmentDiv.innerHTML = elem.outerHTML; 6146 fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); 6147 } 6148 6149 if ( ( !support.noCloneEvent || !support.noCloneChecked ) && 6150 ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) { 6151 6152 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 6153 destElements = getAll( clone ); 6154 srcElements = getAll( elem ); 6155 6156 // Fix all IE cloning issues 6157 for ( i = 0; ( node = srcElements[ i ] ) != null; ++i ) { 6158 6159 // Ensure that the destination node is not null; Fixes #9587 6160 if ( destElements[ i ] ) { 6161 fixCloneNodeIssues( node, destElements[ i ] ); 6162 } 6163 } 6164 } 6165 6166 // Copy the events from the original to the clone 6167 if ( dataAndEvents ) { 6168 if ( deepDataAndEvents ) { 6169 srcElements = srcElements || getAll( elem ); 6170 destElements = destElements || getAll( clone ); 6171 6172 for ( i = 0; ( node = srcElements[ i ] ) != null; i++ ) { 6173 cloneCopyEvent( node, destElements[ i ] ); 6174 } 6175 } else { 6176 cloneCopyEvent( elem, clone ); 6177 } 6178 } 6179 6180 // Preserve script evaluation history 6181 destElements = getAll( clone, "script" ); 6182 if ( destElements.length > 0 ) { 6183 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); 6184 } 6185 6186 destElements = srcElements = node = null; 6187 6188 // Return the cloned set 6189 return clone; 6190 }, 6191 6192 cleanData: function( elems, /* internal */ forceAcceptData ) { 6193 var elem, type, id, data, 6194 i = 0, 6195 internalKey = jQuery.expando, 6196 cache = jQuery.cache, 6197 attributes = support.attributes, 6198 special = jQuery.event.special; 6199 6200 for ( ; ( elem = elems[ i ] ) != null; i++ ) { 6201 if ( forceAcceptData || acceptData( elem ) ) { 6202 6203 id = elem[ internalKey ]; 6204 data = id && cache[ id ]; 6205 6206 if ( data ) { 6207 if ( data.events ) { 6208 for ( type in data.events ) { 6209 if ( special[ type ] ) { 6210 jQuery.event.remove( elem, type ); 6211 6212 // This is a shortcut to avoid jQuery.event.remove's overhead 6213 } else { 6214 jQuery.removeEvent( elem, type, data.handle ); 6215 } 6216 } 6217 } 6218 6219 // Remove cache only if it was not already removed by jQuery.event.remove 6220 if ( cache[ id ] ) { 6221 6222 delete cache[ id ]; 6223
6224 // Support: IE<9 6225 // IE does not allow us to delete expando properties from nodes 6226 // IE creates expando attributes along with the property 6227 // IE does not have a removeAttribute function on Document nodes 6228 if ( !attributes && typeof elem.removeAttribute !== "undefined" ) { 6229 elem.removeAttribute( internalKey ); 6230 6231 // Webkit & Blink performance suffers when deleting properties 6232 // from DOM nodes, so set to undefined instead 6233 // https://code.google.com/p/chromium/issues/detail?id=378607 6234 } else { 6235 elem[ internalKey ] = undefined; 6236 } 6237 6238 deletedIds.push( id ); 6239 } 6240 } 6241 } 6242 } 6243 } 6244} ); 6245 6246jQuery.fn.extend( { 6247 6248 // Keep domManip exposed until 3.0 (gh-2225) 6249 domManip: domManip, 6250 6251 detach: function( selector ) { 6252 return remove( this, selector, true ); 6253 }, 6254 6255 remove: function( selector ) { 6256 return remove( this, selector ); 6257 }, 6258 6259 text: function( value ) { 6260 return access( this, function( value ) { 6261 return value === undefined ? 6262 jQuery.text( this ) : 6263 this.empty().append( 6264 ( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value ) 6265 ); 6266 }, null, value, arguments.length ); 6267 }, 6268 6269 append: function() { 6270 return domManip( this, arguments, function( elem ) { 6271 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 6272 var target = manipulationTarget( this, elem ); 6273 target.appendChild( elem ); 6274 } 6275 } ); 6276 }, 6277
6278 prepend: function() { 6279 return domManip( this, arguments, function( elem ) { 6280 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 6281 var target = manipulationTarget( this, elem ); 6282 target.insertBefore( elem, target.firstChild ); 6283 } 6284 } ); 6285 }, 6286 6287 before: function() { 6288 return domManip( this, arguments, function( elem ) { 6289 if ( this.parentNode ) { 6290 this.parentNode.insertBefore( elem, this ); 6291 } 6292 } ); 6293 }, 6294 6295 after: function() { 6296 return domManip( this, arguments, function( elem ) { 6297 if ( this.parentNode ) { 6298 this.parentNode.insertBefore( elem, this.nextSibling ); 6299 } 6300 } ); 6301 }, 6302 6303 empty: function() { 6304 var elem, 6305 i = 0; 6306 6307 for ( ; ( elem = this[ i ] ) != null; i++ ) { 6308 6309 // Remove element nodes and prevent memory leaks 6310 if ( elem.nodeType === 1 ) { 6311 jQuery.cleanData( getAll( elem, false ) ); 6312 } 6313 6314 // Remove any remaining nodes 6315 while ( elem.firstChild ) { 6316 elem.removeChild( elem.firstChild ); 6317 } 6318 6319 // If this is a select, ensure that it displays empty (#12336) 6320 // Support: IE<9 6321 if ( elem.options && jQuery.nodeName( elem, "select" ) ) { 6322 elem.options.length = 0; 6323 } 6324 } 6325 6326 return this; 6327 }, 6328 6329 clone: function( dataAndEvents, deepDataAndEvents ) { 6330 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; 6331 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; 6332 6333 return this.map( function() { 6334 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); 6335 } ); 6336 }, 6337 6338 html: function( value ) { 6339 return access( this, function( value ) { 6340 var elem = this[ 0 ] || {}, 6341 i = 0, 6342 l = this.length; 6343 6344 if ( value === undefined ) { 6345 return elem.nodeType === 1 ? 6346 elem.innerHTML.replace( rinlinejQuery, "" ) : 6347 undefined; 6348 } 6349 6350 // See if we can take a shortcut and just use innerHTML 6351 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && 6352 ( support.htmlSerialize || !rnoshimcache.test( value ) ) && 6353 ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && 6354 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { 6355 6356 value = jQuery.htmlPrefilter( value ); 6357 6358 try { 6359 for ( ; i < l; i++ ) { 6360 6361 // Remove element nodes and prevent memory leaks 6362 elem = this[ i ] || {}; 6363 if ( elem.nodeType === 1 ) { 6364 jQuery.cleanData( getAll( elem, false ) ); 6365 elem.innerHTML = value; 6366 } 6367 } 6368 6369 elem = 0; 6370 6371 // If using innerHTML throws an exception, use the fallback method 6372 } catch ( e ) {} 6373 } 6374 6375 if ( elem ) { 6376 this.empty().append( value ); 6377 } 6378 }, null, value, arguments.length ); 6379 }, 6380 6381 replaceWith: function() { 6382 var ignored = []; 6383 6384 // Make the changes, replacing each non-ignored context element with the new content 6385 return domManip( this, arguments, function( elem ) { 6386 var parent = this.parentNode; 6387 6388 if ( jQuery.inArray( this, ignored ) < 0 ) { 6389 jQuery.cleanData( getAll( this ) ); 6390 if ( parent ) { 6391 parent.replaceChild( elem, this ); 6392 } 6393 } 6394 6395 // Force callback invocation 6396 }, ignored ); 6397 } 6398} ); 6399 6400jQuery.each( { 6401 appendTo: "append", 6402 prependTo: "prepend", 6403 insertBefore: "before", 6404 insertAfter: "after", 6405 replaceAll: "replaceWith" 6406}, function( name, original ) { 6407 jQuery.fn[ name ] = function( selector ) { 6408 var elems, 6409 i = 0, 6410 ret = [], 6411 insert = jQuery( selector ), 6412 last = insert.length - 1; 6413 6414 for ( ; i <= last; i++ ) { 6415 elems = i === last ? this : this.clone( true ); 6416 jQuery( insert[ i ] )[ original ]( elems ); 6417 6418 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get() 6419 push.apply( ret, elems.get() ); 6420 } 6421 6422 return this.pushStack( ret ); 6423 }; 6424} ); 6425 6426 6427var iframe, 6428 elemdisplay = { 6429 6430 // Support: Firefox 6431 // We have to pre-define these values for FF (#10227) 6432 HTML: "block", 6433 BODY: "block" 6434 }; 6435 6436/** 6437 * Retrieve the actual display of a element 6438 * @param {String} name nodeName of the element 6439 * @param {Object} doc Document object 6440 */ 6441 6442// Called only from within defaultDisplay 6443function actualDisplay( name, doc ) { 6444 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), 6445 6446 display = jQuery.css( elem[ 0 ], "display" ); 6447 6448 // We don't have any data stored on the element, 6449 // so use "detach" method as fast way to get rid of the element 6450 elem.detach(); 6451
6452 return display; 6453} 6454 6455/** 6456 * Try to determine the default display value of an element 6457 * @param {String} nodeName 6458 */ 6459function defaultDisplay( nodeName ) { 6460 var doc = document, 6461 display = elemdisplay[ nodeName ]; 6462 6463 if ( !display ) { 6464 display = actualDisplay( nodeName, doc ); 6465 6466 // If the simple way fails, read from inside an iframe 6467 if ( display === "none" || !display ) { 6468 6469 // Use the already-created iframe if possible 6470 iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) ) 6471 .appendTo( doc.documentElement ); 6472 6473 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse 6474 doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document; 6475 6476 // Support: IE 6477 doc.write(); 6478 doc.close(); 6479 6480 display = actualDisplay( nodeName, doc ); 6481 iframe.detach(); 6482 } 6483 6484 // Store the correct default display 6485 elemdisplay[ nodeName ] = display; 6486 } 6487 6488 return display; 6489} 6490var rmargin = ( /^margin/ ); 6491 6492var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); 6493 6494var swap = function( elem, options, callback, args ) { 6495 var ret, name, 6496 old = {}; 6497 6498 // Remember the old values, and insert the new ones 6499 for ( name in options ) { 6500 old[ name ] = elem.style[ name ]; 6501 elem.style[ name ] = options[ name ]; 6502 } 6503 6504 ret = callback.apply( elem, args || [] ); 6505 6506 // Revert the old values 6507 for ( name in options ) { 6508 elem.style[ name ] = old[ name ]; 6509 } 6510 6511 return ret; 6512}; 6513 6514 6515var documentElement = document.documentElement; 6516 6517 6518 6519( function() { 6520 var pixelPositionVal, pixelMarginRightVal, boxSizingReliableVal, 6521 reliableHiddenOffsetsVal, reliableMarginRightVal, reliableMarginLeftVal, 6522 container = document.createElement( "div" ), 6523 div = document.createElement( "div" ); 6524 6525 // Finish early in limited (non-browser) environments 6526 if ( !div.style ) { 6527 return; 6528 } 6529 6530 div.style.cssText = "float:left;opacity:.5"; 6531 6532 // Support: IE<9 6533 // Make sure that element opacity exists (as opposed to filter) 6534 support.opacity = div.style.opacity === "0.5"; 6535 6536 // Verify style float existence 6537 // (IE uses styleFloat instead of cssFloat) 6538 support.cssFloat = !!div.style.cssFloat; 6539 6540 div.style.backgroundClip = "content-box"; 6541 div.cloneNode( true ).style.backgroundClip = ""; 6542 support.clearCloneStyle = div.style.backgroundClip === "content-box"; 6543 6544 container = document.createElement( "div" ); 6545 container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" + 6546 "padding:0;margin-top:1px;position:absolute"; 6547 div.innerHTML = ""; 6548 container.appendChild( div ); 6549 6550 // Support: Firefox<29, Android 2.3 6551 // Vendor-prefix box-sizing 6552 support.boxSizing = div.style.boxSizing === "" || div.style.MozBoxSizing === "" || 6553 div.style.WebkitBoxSizing === ""; 6554 6555 jQuery.extend( support, { 6556 reliableHiddenOffsets: function() { 6557 if ( pixelPositionVal == null ) { 6558 computeStyleTests(); 6559 } 6560 return reliableHiddenOffsetsVal; 6561 }, 6562 6563 boxSizingReliable: function() { 6564 6565 // We're checking for pixelPositionVal here instead of boxSizingReliableVal 6566 // since that compresses better and they're computed together anyway. 6567 if ( pixelPositionVal == null ) { 6568 computeStyleTests(); 6569 } 6570 return boxSizingReliableVal; 6571 }, 6572 6573 pixelMarginRight: function() { 6574 6575 // Support: Android 4.0-4.3 6576 if ( pixelPositionVal == null ) { 6577 computeStyleTests(); 6578 } 6579 return pixelMarginRightVal; 6580 }, 6581 6582 pixelPosition: function() { 6583 if ( pixelPositionVal == null ) { 6584 computeStyleTests(); 6585 } 6586 return pixelPositionVal; 6587 }, 6588 6589 reliableMarginRight: function() { 6590 6591 // Support: Android 2.3 6592 if ( pixelPositionVal == null ) { 6593 computeStyleTests(); 6594 } 6595 return reliableMarginRightVal; 6596 }, 6597 6598 reliableMarginLeft: function() { 6599 6600 // Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37 6601 if ( pixelPositionVal == null ) { 6602 computeStyleTests(); 6603 } 6604 return reliableMarginLeftVal; 6605 } 6606 } ); 6607 6608 function computeStyleTests() { 6609 var contents, divStyle, 6610 documentElement = document.documentElement; 6611 6612 // Setup 6613 documentElement.appendChild( container ); 6614 6615 div.style.cssText = 6616 6617 // Support: Android 2.3 6618 // Vendor-prefix box-sizing 6619 "-webkit-box-sizing:border-box;box-sizing:border-box;" + 6620 "position:relative;display:block;" + 6621 "margin:auto;border:1px;padding:1px;" + 6622 "top:1%;width:50%"; 6623
6624 // Support: IE<9 6625 // Assume reasonable values in the absence of getComputedStyle 6626 pixelPositionVal = boxSizingReliableVal = reliableMarginLeftVal = false; 6627 pixelMarginRightVal = reliableMarginRightVal = true; 6628 6629 // Check for getComputedStyle so that this code is not run in IE<9. 6630 if ( window.getComputedStyle ) { 6631 divStyle = window.getComputedStyle( div ); 6632 pixelPositionVal = ( divStyle || {} ).top !== "1%"; 6633 reliableMarginLeftVal = ( divStyle || {} ).marginLeft === "2px"; 6634 boxSizingReliableVal = ( divStyle || { width: "4px" } ).width === "4px"; 6635 6636 // Support: Android 4.0 - 4.3 only 6637 // Some styles come back with percentage values, even though they shouldn't 6638 div.style.marginRight = "50%"; 6639 pixelMarginRightVal = ( divStyle || { marginRight: "4px" } ).marginRight === "4px"; 6640 6641 // Support: Android 2.3 only 6642 // Div with explicit width and no margin-right incorrectly 6643 // gets computed margin-right based on width of container (#3333) 6644 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right 6645 contents = div.appendChild( document.createElement( "div" ) ); 6646 6647 // Reset CSS: box-sizing; display; margin; border; padding 6648 contents.style.cssText = div.style.cssText = 6649 6650 // Support: Android 2.3 6651 // Vendor-prefix box-sizing 6652 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" + 6653 "box-sizing:content-box;display:block;margin:0;border:0;padding:0"; 6654 contents.style.marginRight = contents.style.width = "0"; 6655 div.style.width = "1px"; 6656 6657 reliableMarginRightVal = 6658 !parseFloat( ( window.getComputedStyle( contents ) || {} ).marginRight ); 6659 6660 div.removeChild( contents ); 6661 } 6662 6663 // Support: IE6-8 6664 // First check that getClientRects works as expected 6665 // Check if table cells still have offsetWidth/Height when they are set 6666 // to display:none and there are still other visible table cells in a 6667 // table row; if so, offsetWidth/Height are not reliable for use when 6668 // determining if an element has been hidden directly using 6669 // display:none (it is still safe to use offsets if a parent element is 6670 // hidden; don safety goggles and see bug #4512 for more information). 6671 div.style.display = "none"; 6672 reliableHiddenOffsetsVal = div.getClientRects().length === 0; 6673 if ( reliableHiddenOffsetsVal ) { 6674 div.style.display = ""; 6675 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>"; 6676 div.childNodes[ 0 ].style.borderCollapse = "separate"; 6677 contents = div.getElementsByTagName( "td" ); 6678 contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none"; 6679 reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0; 6680 if ( reliableHiddenOffsetsVal ) { 6681 contents[ 0 ].style.display = ""; 6682 contents[ 1 ].style.display = "none"; 6683 reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0; 6684 } 6685 } 6686 6687 // Teardown 6688 documentElement.removeChild( container ); 6689 } 6690 6691} )(); 6692 6693 6694var getStyles, curCSS, 6695 rposition = /^(top|right|bottom|left)$/; 6696 6697if ( window.getComputedStyle ) { 6698 getStyles = function( elem ) { 6699 6700 // Support: IE<=11+, Firefox<=30+ (#15098, #14150) 6701 // IE throws on elements created in popups 6702 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" 6703 var view = elem.ownerDocument.defaultView; 6704 6705 if ( !view || !view.opener ) { 6706 view = window; 6707 } 6708 6709 return view.getComputedStyle( elem ); 6710 }; 6711 6712 curCSS = function( elem, name, computed ) { 6713 var width, minWidth, maxWidth, ret, 6714 style = elem.style; 6715 6716 computed = computed || getStyles( elem ); 6717 6718 // getPropertyValue is only needed for .css('filter') in IE9, see #12537 6719 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined; 6720 6721 // Support: Opera 12.1x only 6722 // Fall back to style even without computed 6723 // computed is undefined for elems on document fragments 6724 if ( ( ret === "" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) { 6725 ret = jQuery.style( elem, name ); 6726 } 6727 6728 if ( computed ) { 6729 6730 // A tribute to the "awesome hack by Dean Edwards" 6731 // Chrome < 17 and Safari 5.0 uses "computed value" 6732 // instead of "used value" for margin-right 6733 // Safari 5.1.7 (at least) returns percentage for a larger set of values, 6734 // but width seems to be reliably pixels 6735 // this is against the CSSOM draft spec: 6736 // http://dev.w3.org/csswg/cssom/#resolved-values 6737 if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) { 6738 6739 // Remember the original values 6740 width = style.width; 6741 minWidth = style.minWidth; 6742 maxWidth = style.maxWidth; 6743 6744 // Put in the new values to get a computed value out 6745 style.minWidth = style.maxWidth = style.width = ret; 6746 ret = computed.width; 6747 6748 // Revert the changed values 6749 style.width = width; 6750 style.minWidth = minWidth; 6751 style.maxWidth = maxWidth; 6752 } 6753 } 6754
6755 // Support: IE 6756 // IE returns zIndex value as an integer. 6757 return ret === undefined ? 6758 ret : 6759 ret + ""; 6760 }; 6761} else if ( documentElement.currentStyle ) { 6762 getStyles = function( elem ) { 6763 return elem.currentStyle; 6764 }; 6765 6766 curCSS = function( elem, name, computed ) { 6767 var left, rs, rsLeft, ret, 6768 style = elem.style; 6769 6770 computed = computed || getStyles( elem ); 6771 ret = computed ? computed[ name ] : undefined; 6772 6773 // Avoid setting ret to empty string here 6774 // so we don't default to auto 6775 if ( ret == null && style && style[ name ] ) { 6776 ret = style[ name ]; 6777 } 6778 6779 // From the awesome hack by Dean Edwards 6780 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 6781 6782 // If we're not dealing with a regular pixel number 6783 // but a number that has a weird ending, we need to convert it to pixels 6784 // but not position css attributes, as those are 6785 // proportional to the parent element instead 6786 // and we can't measure the parent instead because it 6787 // might trigger a "stacking dolls" problem 6788 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { 6789 6790 // Remember the original values 6791 left = style.left; 6792 rs = elem.runtimeStyle; 6793 rsLeft = rs && rs.left; 6794 6795 // Put in the new values to get a computed value out 6796 if ( rsLeft ) { 6797 rs.left = elem.currentStyle.left; 6798 } 6799 style.left = name === "fontSize" ? "1em" : ret; 6800 ret = style.pixelLeft + "px"; 6801 6802 // Revert the changed values 6803 style.left = left; 6804 if ( rsLeft ) { 6805 rs.left = rsLeft; 6806 } 6807 } 6808 6809 // Support: IE 6810 // IE returns zIndex value as an integer. 6811 return ret === undefined ? 6812 ret : 6813 ret + "" || "auto"; 6814 }; 6815} 6816 6817 6818 6819 6820function addGetHookIf( conditionFn, hookFn ) { 6821 6822 // Define the hook, we'll check on the first run if it's really needed. 6823 return { 6824 get: function() { 6825 if ( conditionFn() ) { 6826 6827 // Hook not needed (or it's not possible to use it due 6828 // to missing dependency), remove it. 6829 delete this.get; 6830 return; 6831 } 6832 6833 // Hook needed; redefine it so that the support test is not executed again. 6834 return ( this.get = hookFn ).apply( this, arguments ); 6835 } 6836 }; 6837} 6838 6839 6840var 6841 6842 ralpha = /alpha\([^)]*\)/i, 6843 ropacity = /opacity\s*=\s*([^)]*)/i, 6844 6845 // swappable if display is none or starts with table except 6846 // "table", "table-cell", or "table-caption" 6847 // see here for display values: 6848 // https://developer.mozilla.org/en-US/docs/CSS/display 6849 rdisplayswap = /^(none|table(?!-c[ea]).+)/, 6850 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ), 6851 6852 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, 6853 cssNormalTransform = { 6854 letterSpacing: "0", 6855 fontWeight: "400" 6856 }, 6857 6858 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ], 6859 emptyStyle = document.createElement( "div" ).style; 6860 6861 6862// return a css property mapped to a potentially vendor prefixed property 6863function vendorPropName( name ) { 6864 6865 // shortcut for names that are not vendor prefixed 6866 if ( name in emptyStyle ) { 6867 return name; 6868 } 6869 6870 // check for vendor prefixed names 6871 var capName = name.charAt( 0 ).toUpperCase() + name.slice( 1 ), 6872 i = cssPrefixes.length; 6873 6874 while ( i-- ) { 6875 name = cssPrefixes[ i ] + capName; 6876 if ( name in emptyStyle ) { 6877 return name; 6878 } 6879 } 6880} 6881 6882function showHide( elements, show ) { 6883 var display, elem, hidden, 6884 values = [], 6885 index = 0, 6886 length = elements.length; 6887 6888 for ( ; index < length; index++ ) { 6889 elem = elements[ index ]; 6890 if ( !elem.style ) { 6891 continue; 6892 } 6893 6894 values[ index ] = jQuery._data( elem, "olddisplay" ); 6895 display = elem.style.display; 6896 if ( show ) { 6897 6898 // Reset the inline display of this element to learn if it is 6899 // being hidden by cascaded rules or not 6900 if ( !values[ index ] && display === "none" ) { 6901 elem.style.display = ""; 6902 } 6903 6904 // Set elements which have been overridden with display: none 6905 // in a stylesheet to whatever the default browser style is 6906 // for such an element 6907 if ( elem.style.display === "" && isHidden( elem ) ) { 6908 values[ index ] = 6909 jQuery._data( elem, "olddisplay", defaultDisplay( elem.nodeName ) ); 6910 } 6911 } else { 6912 hidden = isHidden( elem ); 6913 6914 if ( display && display !== "none" || !hidden ) { 6915 jQuery._data( 6916 elem, 6917 "olddisplay",
6918 hidden ? display : jQuery.css( elem, "display" ) 6919 ); 6920 } 6921 } 6922 } 6923 6924 // Set the display of most of the elements in a second loop 6925 // to avoid the constant reflow 6926 for ( index = 0; index < length; index++ ) { 6927 elem = elements[ index ]; 6928 if ( !elem.style ) { 6929 continue; 6930 } 6931 if ( !show || elem.style.display === "none" || elem.style.display === "" ) { 6932 elem.style.display = show ? values[ index ] || "" : "none"; 6933 } 6934 } 6935 6936 return elements; 6937} 6938 6939function setPositiveNumber( elem, value, subtract ) { 6940 var matches = rnumsplit.exec( value ); 6941 return matches ? 6942 6943 // Guard against undefined "subtract", e.g., when used as in cssHooks 6944 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : 6945 value; 6946} 6947 6948function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { 6949 var i = extra === ( isBorderBox ? "border" : "content" ) ? 6950 6951 // If we already have the right measurement, avoid augmentation 6952 4 : 6953 6954 // Otherwise initialize for horizontal or vertical properties 6955 name === "width" ? 1 : 0, 6956 6957 val = 0; 6958 6959 for ( ; i < 4; i += 2 ) { 6960 6961 // both box models exclude margin, so add it if we want it 6962 if ( extra === "margin" ) { 6963 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); 6964 } 6965 6966 if ( isBorderBox ) { 6967 6968 // border-box includes padding, so remove it if we want content 6969 if ( extra === "content" ) { 6970 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 6971 } 6972 6973 // at this point, extra isn't border nor margin, so remove border 6974 if ( extra !== "margin" ) { 6975 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 6976 } 6977 } else { 6978 6979 // at this point, extra isn't content, so add padding 6980 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 6981 6982 // at this point, extra isn't content nor padding, so add border 6983 if ( extra !== "padding" ) { 6984 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 6985 } 6986 } 6987 } 6988 6989 return val; 6990} 6991 6992function getWidthOrHeight( elem, name, extra ) { 6993 6994 // Start with offset property, which is equivalent to the border-box value 6995 var valueIsBorderBox = true, 6996 val = name === "width" ? elem.offsetWidth : elem.offsetHeight, 6997 styles = getStyles( elem ), 6998 isBorderBox = support.boxSizing && 6999 jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; 7000 7001 // some non-html elements return undefined for offsetWidth, so check for null/undefined 7002 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 7003 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 7004 if ( val <= 0 || val == null ) { 7005 7006 // Fall back to computed then uncomputed css if necessary 7007 val = curCSS( elem, name, styles ); 7008 if ( val < 0 || val == null ) { 7009 val = elem.style[ name ]; 7010 } 7011 7012 // Computed unit is not pixels. Stop here and return. 7013 if ( rnumnonpx.test( val ) ) { 7014 return val; 7015 } 7016 7017 // we need the check for style in case a browser which returns unreliable values 7018 // for getComputedStyle silently falls back to the reliable elem.style 7019 valueIsBorderBox = isBorderBox && 7020 ( support.boxSizingReliable() || val === elem.style[ name ] ); 7021 7022 // Normalize "", auto, and prepare for extra 7023 val = parseFloat( val ) || 0; 7024 } 7025 7026 // use the active box-sizing model to add/subtract irrelevant styles 7027 return ( val + 7028 augmentWidthOrHeight( 7029 elem, 7030 name, 7031 extra || ( isBorderBox ? "border" : "content" ), 7032 valueIsBorderBox, 7033 styles 7034 ) 7035 ) + "px"; 7036} 7037 7038jQuery.extend( { 7039 7040 // Add in style property hooks for overriding the default 7041 // behavior of getting and setting a style property 7042 cssHooks: { 7043 opacity: { 7044 get: function( elem, computed ) { 7045 if ( computed ) { 7046 7047 // We should always get a number back from opacity 7048 var ret = curCSS( elem, "opacity" ); 7049 return ret === "" ? "1" : ret; 7050 } 7051 } 7052 } 7053 }, 7054 7055 // Don't automatically add "px" to these possibly-unitless properties 7056 cssNumber: { 7057 "animationIterationCount": true, 7058 "columnCount": true, 7059 "fillOpacity": true, 7060 "flexGrow": true, 7061 "flexShrink": true, 7062 "fontWeight": true, 7063 "lineHeight": true, 7064 "opacity": true, 7065 "order": true, 7066 "orphans": true, 7067 "widows": true, 7068 "zIndex": true, 7069 "zoom": true 7070 }, 7071 7072 // Add in properties whose names you wish to fix before 7073 // setting or getting the value 7074 cssProps: { 7075 7076 // normalize float css property 7077 "float": support.cssFloat ? "cssFloat" : "styleFloat" 7078 }, 7079 7080 // Get and set the style property on a DOM Node 7081 style: function( elem, name, value, extra ) { 7082 7083 // Don't set styles on text and comment nodes 7084 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { 7085 return; 7086 } 7087 7088 // Make sure that we're working with the right name 7089 var ret, type, hooks, 7090 origName = jQuery.camelCase( name ), 7091 style = elem.style; 7092 7093 name = jQuery.cssProps[ origName ] || 7094 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); 7095 7096 // gets hook for the prefixed version 7097 // followed by the unprefixed version 7098 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 7099 7100 // Check if we're setting a value 7101 if ( value !== undefined ) { 7102 type = typeof value; 7103 7104 // Convert "+=" or "-=" to relative numbers (#7345) 7105 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { 7106 value = adjustCSS( elem, name, ret ); 7107 7108 // Fixes bug #9237 7109 type = "number"; 7110 } 7111 7112 // Make sure that null and NaN values aren't set. See: #7116 7113 if ( value == null || value !== value ) { 7114 return; 7115 } 7116 7117 // If a number was passed in, add the unit (except for certain CSS properties) 7118 if ( type === "number" ) { 7119 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); 7120 } 7121 7122 // Fixes #8908, it can be done more correctly by specifing setters in cssHooks, 7123 // but it would mean to define eight 7124 // (for every problematic property) identical functions 7125 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { 7126 style[ name ] = "inherit"; 7127 } 7128 7129 // If a hook was provided, use that value, otherwise just set the specified value
7130 if ( !hooks || !( "set" in hooks ) || 7131 ( value = hooks.set( elem, value, extra ) ) !== undefined ) { 7132 7133 // Support: IE 7134 // Swallow errors from 'invalid' CSS values (#5509) 7135 try { 7136 style[ name ] = value; 7137 } catch ( e ) {} 7138 } 7139 7140 } else { 7141 7142 // If a hook was provided get the non-computed value from there 7143 if ( hooks && "get" in hooks && 7144 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { 7145 7146 return ret; 7147 } 7148 7149 // Otherwise just get the value from the style object 7150 return style[ name ]; 7151 } 7152 }, 7153 7154 css: function( elem, name, extra, styles ) { 7155 var num, val, hooks, 7156 origName = jQuery.camelCase( name ); 7157 7158 // Make sure that we're working with the right name 7159 name = jQuery.cssProps[ origName ] || 7160 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); 7161 7162 // gets hook for the prefixed version 7163 // followed by the unprefixed version 7164 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 7165 7166 // If a hook was provided get the computed value from there 7167 if ( hooks && "get" in hooks ) { 7168 val = hooks.get( elem, true, extra ); 7169 } 7170 7171 // Otherwise, if a way to get the computed value exists, use that 7172 if ( val === undefined ) { 7173 val = curCSS( elem, name, styles ); 7174 } 7175 7176 //convert "normal" to computed value 7177 if ( val === "normal" && name in cssNormalTransform ) { 7178 val = cssNormalTransform[ name ]; 7179 } 7180 7181 // Return, converting to number if forced or a qualifier was provided and val looks numeric 7182 if ( extra === "" || extra ) { 7183 num = parseFloat( val ); 7184 return extra === true || isFinite( num ) ? num || 0 : val; 7185 } 7186 return val; 7187 } 7188} ); 7189 7190jQuery.each( [ "height", "width" ], function( i, name ) { 7191 jQuery.cssHooks[ name ] = { 7192 get: function( elem, computed, extra ) { 7193 if ( computed ) { 7194 7195 // certain elements can have dimension info if we invisibly show them 7196 // however, it must have a current display style that would benefit from this 7197 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && 7198 elem.offsetWidth === 0 ? 7199 swap( elem, cssShow, function() { 7200 return getWidthOrHeight( elem, name, extra ); 7201 } ) : 7202 getWidthOrHeight( elem, name, extra ); 7203 } 7204 }, 7205 7206 set: function( elem, value, extra ) { 7207 var styles = extra && getStyles( elem ); 7208 return setPositiveNumber( elem, value, extra ? 7209 augmentWidthOrHeight( 7210 elem, 7211 name, 7212 extra, 7213 support.boxSizing && 7214 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 7215 styles 7216 ) : 0 7217 ); 7218 } 7219 }; 7220} ); 7221 7222if ( !support.opacity ) { 7223 jQuery.cssHooks.opacity = { 7224 get: function( elem, computed ) { 7225 7226 // IE uses filters for opacity 7227 return ropacity.test( ( computed && elem.currentStyle ? 7228 elem.currentStyle.filter : 7229 elem.style.filter ) || "" ) ? 7230 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" : 7231 computed ? "1" : ""; 7232 }, 7233 7234 set: function( elem, value ) { 7235 var style = elem.style, 7236 currentStyle = elem.currentStyle, 7237 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "", 7238 filter = currentStyle && currentStyle.filter || style.filter || ""; 7239 7240 // IE has trouble with opacity if it does not have layout 7241 // Force it by setting the zoom level 7242 style.zoom = 1; 7243 7244 // if setting opacity to 1, and no other filters exist - 7245 // attempt to remove filter attribute #6652 7246 // if value === "", then remove inline opacity #12685 7247 if ( ( value >= 1 || value === "" ) && 7248 jQuery.trim( filter.replace( ralpha, "" ) ) === "" && 7249 style.removeAttribute ) { 7250 7251 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText 7252 // if "filter:" is present at all, clearType is disabled, we want to avoid this 7253 // style.removeAttribute is IE Only, but so apparently is this code path... 7254 style.removeAttribute( "filter" ); 7255 7256 // if there is no filter style applied in a css rule 7257 // or unset inline opacity, we are done 7258 if ( value === "" || currentStyle && !currentStyle.filter ) { 7259 return; 7260 } 7261 } 7262 7263 // otherwise, set new filter values 7264 style.filter = ralpha.test( filter ) ? 7265 filter.replace( ralpha, opacity ) : 7266 filter + " " + opacity; 7267 } 7268 }; 7269} 7270 7271jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, 7272 function( elem, computed ) { 7273 if ( computed ) { 7274 return swap( elem, { "display": "inline-block" }, 7275 curCSS, [ elem, "marginRight" ] ); 7276 } 7277 } 7278); 7279 7280jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, 7281 function( elem, computed ) { 7282 if ( computed ) { 7283 return ( 7284 parseFloat( curCSS( elem, "marginLeft" ) ) || 7285
vendor: 4,625 bytes, lines 7286-7464
7286 // Support: IE<=11+ 7287 // Running getBoundingClientRect on a disconnected node in IE throws an error 7288 // Support: IE8 only 7289 // getClientRects() errors on disconnected elems 7290 ( jQuery.contains( elem.ownerDocument, elem ) ? 7291 elem.getBoundingClientRect().left - 7292 swap( elem, { marginLeft: 0 }, function() { 7293 return elem.getBoundingClientRect().left; 7294 } ) : 7295 0 7296 ) 7297 ) + "px"; 7298 } 7299 } 7300); 7301 7302// These hooks are used by animate to expand properties 7303jQuery.each( { 7304 margin: "", 7305 padding: "", 7306 border: "Width" 7307}, function( prefix, suffix ) { 7308 jQuery.cssHooks[ prefix + suffix ] = { 7309 expand: function( value ) { 7310 var i = 0, 7311 expanded = {}, 7312 7313 // assumes a single number if not a string 7314 parts = typeof value === "string" ? value.split( " " ) : [ value ]; 7315 7316 for ( ; i < 4; i++ ) { 7317 expanded[ prefix + cssExpand[ i ] + suffix ] = 7318 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; 7319 } 7320 7321 return expanded; 7322 } 7323 }; 7324 7325 if ( !rmargin.test( prefix ) ) { 7326 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; 7327 } 7328} ); 7329 7330jQuery.fn.extend( { 7331 css: function( name, value ) { 7332 return access( this, function( elem, name, value ) { 7333 var styles, len, 7334 map = {}, 7335 i = 0; 7336 7337 if ( jQuery.isArray( name ) ) { 7338 styles = getStyles( elem ); 7339 len = name.length; 7340 7341 for ( ; i < len; i++ ) { 7342 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); 7343 } 7344 7345 return map; 7346 } 7347 7348 return value !== undefined ? 7349 jQuery.style( elem, name, value ) : 7350 jQuery.css( elem, name ); 7351 }, name, value, arguments.length > 1 ); 7352 }, 7353 show: function() { 7354 return showHide( this, true ); 7355 }, 7356 hide: function() { 7357 return showHide( this ); 7358 }, 7359 toggle: function( state ) { 7360 if ( typeof state === "boolean" ) { 7361 return state ? this.show() : this.hide(); 7362 } 7363 7364 return this.each( function() { 7365 if ( isHidden( this ) ) { 7366 jQuery( this ).show(); 7367 } else { 7368 jQuery( this ).hide(); 7369 } 7370 } ); 7371 } 7372} ); 7373 7374 7375function Tween( elem, options, prop, end, easing ) { 7376 return new Tween.prototype.init( elem, options, prop, end, easing ); 7377} 7378jQuery.Tween = Tween; 7379 7380Tween.prototype = { 7381 constructor: Tween, 7382 init: function( elem, options, prop, end, easing, unit ) { 7383 this.elem = elem; 7384 this.prop = prop; 7385 this.easing = easing || jQuery.easing._default; 7386 this.options = options; 7387 this.start = this.now = this.cur(); 7388 this.end = end; 7389 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); 7390 }, 7391 cur: function() { 7392 var hooks = Tween.propHooks[ this.prop ]; 7393 7394 return hooks && hooks.get ? 7395 hooks.get( this ) : 7396 Tween.propHooks._default.get( this ); 7397 }, 7398 run: function( percent ) { 7399 var eased, 7400 hooks = Tween.propHooks[ this.prop ]; 7401 7402 if ( this.options.duration ) { 7403 this.pos = eased = jQuery.easing[ this.easing ]( 7404 percent, this.options.duration * percent, 0, 1, this.options.duration 7405 ); 7406 } else { 7407 this.pos = eased = percent; 7408 } 7409 this.now = ( this.end - this.start ) * eased + this.start; 7410 7411 if ( this.options.step ) { 7412 this.options.step.call( this.elem, this.now, this ); 7413 } 7414 7415 if ( hooks && hooks.set ) { 7416 hooks.set( this ); 7417 } else { 7418 Tween.propHooks._default.set( this ); 7419 } 7420 return this; 7421 } 7422}; 7423 7424Tween.prototype.init.prototype = Tween.prototype; 7425 7426Tween.propHooks = { 7427 _default: { 7428 get: function( tween ) { 7429 var result; 7430 7431 // Use a property on the element directly when it is not a DOM element, 7432 // or when there is no matching style property that exists. 7433 if ( tween.elem.nodeType !== 1 || 7434 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { 7435 return tween.elem[ tween.prop ]; 7436 } 7437 7438 // passing an empty string as a 3rd parameter to .css will automatically 7439 // attempt a parseFloat and fallback to a string if the parse fails 7440 // so, simple values such as "10px" are parsed to Float. 7441 // complex values such as "rotate(1rad)" are returned as is. 7442 result = jQuery.css( tween.elem, tween.prop, "" ); 7443 7444 // Empty strings, null, undefined and "auto" are converted to 0. 7445 return !result || result === "auto" ? 0 : result; 7446 }, 7447 set: function( tween ) { 7448 7449 // use step hook for back compat - use cssHook if its there - use .style if its 7450 // available and use plain properties where available 7451 if ( jQuery.fx.step[ tween.prop ] ) { 7452 jQuery.fx.step[ tween.prop ]( tween ); 7453 } else if ( tween.elem.nodeType === 1 && 7454 ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || 7455 jQuery.cssHooks[ tween.prop ] ) ) { 7456 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); 7457 } else { 7458 tween.elem[ tween.prop ] = tween.now; 7459 } 7460 } 7461 } 7462}; 7463 7464// Support: IE <=9
7465// Panic based approach to setting things on disconnected nodes 7466 7467Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { 7468 set: function( tween ) { 7469 if ( tween.elem.nodeType && tween.elem.parentNode ) { 7470 tween.elem[ tween.prop ] = tween.now; 7471 } 7472 } 7473}; 7474 7475jQuery.easing = { 7476 linear: function( p ) { 7477 return p; 7478 }, 7479 swing: function( p ) { 7480 return 0.5 - Math.cos( p * Math.PI ) / 2; 7481 }, 7482 _default: "swing" 7483}; 7484 7485jQuery.fx = Tween.prototype.init; 7486 7487// Back Compat <1.8 extension point 7488jQuery.fx.step = {}; 7489 7490 7491 7492 7493var 7494 fxNow, timerId, 7495 rfxtypes = /^(?:toggle|show|hide)$/, 7496 rrun = /queueHooks$/; 7497 7498// Animations created synchronously will run synchronously 7499function createFxNow() { 7500 window.setTimeout( function() { 7501 fxNow = undefined; 7502 } ); 7503 return ( fxNow = jQuery.now() ); 7504} 7505 7506// Generate parameters to create a standard animation 7507function genFx( type, includeWidth ) { 7508 var which, 7509 attrs = { height: type }, 7510 i = 0; 7511 7512 // if we include width, step value is 1 to do all cssExpand values, 7513 // if we don't include width, step value is 2 to skip over Left and Right 7514 includeWidth = includeWidth ? 1 : 0; 7515 for ( ; i < 4 ; i += 2 - includeWidth ) { 7516 which = cssExpand[ i ]; 7517 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; 7518 } 7519 7520 if ( includeWidth ) { 7521 attrs.opacity = attrs.width = type; 7522 } 7523 7524 return attrs; 7525} 7526 7527function createTween( value, prop, animation ) { 7528 var tween, 7529 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), 7530 index = 0, 7531 length = collection.length; 7532 for ( ; index < length; index++ ) { 7533 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { 7534 7535 // we're done with this property 7536 return tween; 7537 } 7538 } 7539} 7540 7541function defaultPrefilter( elem, props, opts ) { 7542 /* jshint validthis: true */ 7543 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay, 7544 anim = this, 7545 orig = {}, 7546 style = elem.style, 7547 hidden = elem.nodeType && isHidden( elem ), 7548 dataShow = jQuery._data( elem, "fxshow" ); 7549 7550 // handle queue: false promises 7551 if ( !opts.queue ) { 7552 hooks = jQuery._queueHooks( elem, "fx" ); 7553 if ( hooks.unqueued == null ) { 7554 hooks.unqueued = 0; 7555 oldfire = hooks.empty.fire; 7556 hooks.empty.fire = function() { 7557 if ( !hooks.unqueued ) { 7558 oldfire(); 7559 } 7560 }; 7561 } 7562 hooks.unqueued++; 7563 7564 anim.always( function() { 7565 7566 // doing this makes sure that the complete handler will be called 7567 // before this completes 7568 anim.always( function() { 7569 hooks.unqueued--; 7570 if ( !jQuery.queue( elem, "fx" ).length ) { 7571 hooks.empty.fire(); 7572 } 7573 } ); 7574 } ); 7575 } 7576 7577 // height/width overflow pass 7578 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { 7579 7580 // Make sure that nothing sneaks out 7581 // Record all 3 overflow attributes because IE does not 7582 // change the overflow attribute when overflowX and 7583 // overflowY are set to the same value 7584 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; 7585 7586 // Set display property to inline-block for height/width 7587 // animations on inline elements that are having width/height animated 7588 display = jQuery.css( elem, "display" ); 7589 7590 // Test default display if display is currently "none" 7591 checkDisplay = display === "none" ? 7592 jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; 7593 7594 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { 7595 7596 // inline-level elements accept inline-block; 7597 // block-level elements need to be inline with layout 7598 if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) { 7599 style.display = "inline-block"; 7600 } else { 7601 style.zoom = 1; 7602 } 7603 } 7604 } 7605 7606 if ( opts.overflow ) { 7607 style.overflow = "hidden"; 7608 if ( !support.shrinkWrapBlocks() ) { 7609 anim.always( function() { 7610 style.overflow = opts.overflow[ 0 ]; 7611 style.overflowX = opts.overflow[ 1 ]; 7612 style.overflowY = opts.overflow[ 2 ]; 7613 } ); 7614 } 7615 } 7616 7617 // show/hide pass 7618 for ( prop in props ) { 7619 value = props[ prop ]; 7620 if ( rfxtypes.exec( value ) ) { 7621 delete props[ prop ]; 7622 toggle = toggle || value === "toggle"; 7623 if ( value === ( hidden ? "hide" : "show" ) ) { 7624 7625 // If there is dataShow left over from a stopped hide or show 7626 // and we are going to proceed with show, we should pretend to be hidden 7627 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { 7628 hidden = true; 7629 } else { 7630 continue; 7631 } 7632 } 7633 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); 7634 7635 // Any non-fx value stops us from restoring the original display value 7636 } else { 7637 display = undefined; 7638 } 7639 } 7640 7641 if ( !jQuery.isEmptyObject( orig ) ) { 7642 if ( dataShow ) { 7643 if ( "hidden" in dataShow ) { 7644 hidden = dataShow.hidden; 7645 } 7646 } else { 7647 dataShow = jQuery._data( elem, "fxshow", {} ); 7648 } 7649 7650 // store state if its toggle - enables .stop().toggle() to "reverse" 7651 if ( toggle ) { 7652 dataShow.hidden = !hidden; 7653 } 7654 if ( hidden ) { 7655 jQuery( elem ).show(); 7656 } else { 7657 anim.done( function() { 7658 jQuery( elem ).hide(); 7659 } ); 7660 } 7661 anim.done( function() { 7662 var prop; 7663 jQuery._removeData( elem, "fxshow" ); 7664 for ( prop in orig ) { 7665 jQuery.style( elem, prop, orig[ prop ] ); 7666 } 7667 } ); 7668 for ( prop in orig ) { 7669 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); 7670 7671 if ( !( prop in dataShow ) ) { 7672 dataShow[ prop ] = tween.start; 7673 if ( hidden ) { 7674 tween.end = tween.start; 7675 tween.start = prop === "width" || prop === "height" ? 1 : 0; 7676 } 7677 } 7678 } 7679 7680 // If this is a noop like .hide().hide(), restore an overwritten display value 7681 } else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : dis
vendor: 10,851 bytes, lines 7681-8113
7681play ) === "inline" ) { 7682 style.display = display; 7683 } 7684} 7685 7686function propFilter( props, specialEasing ) { 7687 var index, name, easing, value, hooks; 7688 7689 // camelCase, specialEasing and expand cssHook pass 7690 for ( index in props ) { 7691 name = jQuery.camelCase( index ); 7692 easing = specialEasing[ name ]; 7693 value = props[ index ]; 7694 if ( jQuery.isArray( value ) ) { 7695 easing = value[ 1 ]; 7696 value = props[ index ] = value[ 0 ]; 7697 } 7698 7699 if ( index !== name ) { 7700 props[ name ] = value; 7701 delete props[ index ]; 7702 } 7703 7704 hooks = jQuery.cssHooks[ name ]; 7705 if ( hooks && "expand" in hooks ) { 7706 value = hooks.expand( value ); 7707 delete props[ name ]; 7708 7709 // not quite $.extend, this wont overwrite keys already present. 7710 // also - reusing 'index' from above because we have the correct "name" 7711 for ( index in value ) { 7712 if ( !( index in props ) ) { 7713 props[ index ] = value[ index ]; 7714 specialEasing[ index ] = easing; 7715 } 7716 } 7717 } else { 7718 specialEasing[ name ] = easing; 7719 } 7720 } 7721} 7722 7723function Animation( elem, properties, options ) { 7724 var result, 7725 stopped, 7726 index = 0, 7727 length = Animation.prefilters.length, 7728 deferred = jQuery.Deferred().always( function() { 7729 7730 // don't match elem in the :animated selector 7731 delete tick.elem; 7732 } ), 7733 tick = function() { 7734 if ( stopped ) { 7735 return false; 7736 } 7737 var currentTime = fxNow || createFxNow(), 7738 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), 7739 7740 // Support: Android 2.3 7741 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) 7742 temp = remaining / animation.duration || 0, 7743 percent = 1 - temp, 7744 index = 0, 7745 length = animation.tweens.length; 7746 7747 for ( ; index < length ; index++ ) { 7748 animation.tweens[ index ].run( percent ); 7749 } 7750 7751 deferred.notifyWith( elem, [ animation, percent, remaining ] ); 7752 7753 if ( percent < 1 && length ) { 7754 return remaining; 7755 } else { 7756 deferred.resolveWith( elem, [ animation ] ); 7757 return false; 7758 } 7759 }, 7760 animation = deferred.promise( { 7761 elem: elem, 7762 props: jQuery.extend( {}, properties ), 7763 opts: jQuery.extend( true, { 7764 specialEasing: {}, 7765 easing: jQuery.easing._default 7766 }, options ), 7767 originalProperties: properties, 7768 originalOptions: options, 7769 startTime: fxNow || createFxNow(), 7770 duration: options.duration, 7771 tweens: [], 7772 createTween: function( prop, end ) { 7773 var tween = jQuery.Tween( elem, animation.opts, prop, end, 7774 animation.opts.specialEasing[ prop ] || animation.opts.easing ); 7775 animation.tweens.push( tween ); 7776 return tween; 7777 }, 7778 stop: function( gotoEnd ) { 7779 var index = 0, 7780 7781 // if we are going to the end, we want to run all the tweens 7782 // otherwise we skip this part 7783 length = gotoEnd ? animation.tweens.length : 0; 7784 if ( stopped ) { 7785 return this; 7786 } 7787 stopped = true; 7788 for ( ; index < length ; index++ ) { 7789 animation.tweens[ index ].run( 1 ); 7790 } 7791 7792 // resolve when we played the last frame 7793 // otherwise, reject 7794 if ( gotoEnd ) { 7795 deferred.notifyWith( elem, [ animation, 1, 0 ] ); 7796 deferred.resolveWith( elem, [ animation, gotoEnd ] ); 7797 } else { 7798 deferred.rejectWith( elem, [ animation, gotoEnd ] ); 7799 } 7800 return this; 7801 } 7802 } ), 7803 props = animation.props; 7804 7805 propFilter( props, animation.opts.specialEasing ); 7806 7807 for ( ; index < length ; index++ ) { 7808 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); 7809 if ( result ) { 7810 if ( jQuery.isFunction( result.stop ) ) { 7811 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = 7812 jQuery.proxy( result.stop, result ); 7813 } 7814 return result; 7815 } 7816 } 7817 7818 jQuery.map( props, createTween, animation ); 7819 7820 if ( jQuery.isFunction( animation.opts.start ) ) { 7821 animation.opts.start.call( elem, animation ); 7822 } 7823 7824 jQuery.fx.timer( 7825 jQuery.extend( tick, { 7826 elem: elem, 7827 anim: animation, 7828 queue: animation.opts.queue 7829 } ) 7830 ); 7831 7832 // attach callbacks from options 7833 return animation.progress( animation.opts.progress ) 7834 .done( animation.opts.done, animation.opts.complete ) 7835 .fail( animation.opts.fail ) 7836 .always( animation.opts.always ); 7837} 7838 7839jQuery.Animation = jQuery.extend( Animation, { 7840 7841 tweeners: { 7842 "*": [ function( prop, value ) { 7843 var tween = this.createTween( prop, value ); 7844 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); 7845 return tween; 7846 } ] 7847 }, 7848 7849 tweener: function( props, callback ) { 7850 if ( jQuery.isFunction( props ) ) { 7851 callback = props; 7852 props = [ "*" ]; 7853 } else { 7854 props = props.match( rnotwhite ); 7855 } 7856 7857 var prop, 7858 index = 0, 7859 length = props.length; 7860 7861 for ( ; index < length ; index++ ) { 7862 prop = props[ index ]; 7863 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; 7864 Animation.tweeners[ prop ].unshift( callback ); 7865 } 7866 }, 7867 7868 prefilters: [ defaultPrefilter ], 7869 7870 prefilter: function( callback, prepend ) { 7871 if ( prepend ) { 7872 Animation.prefilters.unshift( callback ); 7873 } else { 7874 Animation.prefilters.push( callback ); 7875 } 7876 } 7877} ); 7878 7879jQuery.speed = function( speed, easing, fn ) { 7880 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { 7881 complete: fn || !fn && easing || 7882 jQuery.isFunction( speed ) && speed, 7883 duration: speed, 7884 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing 7885 }; 7886 7887 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : 7888 opt.duration in jQuery.fx.speeds ? 7889 jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; 7890 7891 // normalize opt.queue - true/undefined/null -> "fx" 7892 if ( opt.queue == null || opt.queue === true ) { 7893 opt.queue = "fx"; 7894 } 7895 7896 // Queueing 7897 opt.old = opt.complete; 7898 7899 opt.complete = function() { 7900 if ( jQuery.isFunction( opt.old ) ) { 7901 opt.old.call( this ); 7902 } 7903 7904 if ( opt.queue ) { 7905 jQuery.dequeue( this, opt.queue ); 7906 } 7907 }; 7908 7909 return opt; 7910}; 7911 7912jQuery.fn.extend( { 7913 fadeTo: function( speed, to, easing, callback ) { 7914 7915 // show any hidden elements after setting opacity to 0 7916 return this.filter( isHidden ).css( "opacity", 0 ).show() 7917 7918 // animate to the value specified 7919 .end().animate( { opacity: to }, speed, easing, callback ); 7920 }, 7921 animate: function( prop, speed, easing, callback ) { 7922 var empty = jQuery.isEmptyObject( prop ), 7923 optall = jQuery.speed( speed, easing, callback ), 7924 doAnimation = function() { 7925 7926 // Operate on a copy of prop so per-property easing won't be lost 7927 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); 7928 7929 // Empty animations, or finishing resolves immediately 7930 if ( empty || jQuery._data( this, "finish" ) ) { 7931 anim.stop( true ); 7932 } 7933 }; 7934 doAnimation.finish = doAnimation; 7935 7936 return empty || optall.queue === false ? 7937 this.each( doAnimation ) : 7938 this.queue( optall.queue, doAnimation ); 7939 }, 7940 stop: function( type, clearQueue, gotoEnd ) { 7941 var stopQueue = function( hooks ) { 7942 var stop = hooks.stop; 7943 delete hooks.stop; 7944 stop( gotoEnd ); 7945 }; 7946 7947 if ( typeof type !== "string" ) { 7948 gotoEnd = clearQueue; 7949 clearQueue = type; 7950 type = undefined; 7951 } 7952 if ( clearQueue && type !== false ) { 7953 this.queue( type || "fx", [] ); 7954 } 7955 7956 return this.each( function() { 7957 var dequeue = true, 7958 index = type != null && type + "queueHooks", 7959 timers = jQuery.timers, 7960 data = jQuery._data( this ); 7961 7962 if ( index ) { 7963 if ( data[ index ] && data[ index ].stop ) { 7964 stopQueue( data[ index ] ); 7965 } 7966 } else { 7967 for ( index in data ) { 7968 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { 7969 stopQueue( data[ index ] ); 7970 } 7971 } 7972 } 7973 7974 for ( index = timers.length; index--; ) { 7975 if ( timers[ index ].elem === this && 7976 ( type == null || timers[ index ].queue === type ) ) { 7977 7978 timers[ index ].anim.stop( gotoEnd ); 7979 dequeue = false; 7980 timers.splice( index, 1 ); 7981 } 7982 } 7983 7984 // start the next in the queue if the last step wasn't forced 7985 // timers currently will call their complete callbacks, which will dequeue 7986 // but only if they were gotoEnd 7987 if ( dequeue || !gotoEnd ) { 7988 jQuery.dequeue( this, type ); 7989 } 7990 } ); 7991 }, 7992 finish: function( type ) { 7993 if ( type !== false ) { 7994 type = type || "fx"; 7995 } 7996 return this.each( function() { 7997 var index, 7998 data = jQuery._data( this ), 7999 queue = data[ type + "queue" ], 8000 hooks = data[ type + "queueHooks" ], 8001 timers = jQuery.timers, 8002 length = queue ? queue.length : 0; 8003 8004 // enable finishing flag on private data 8005 data.finish = true; 8006 8007 // empty the queue first 8008 jQuery.queue( this, type, [] ); 8009 8010 if ( hooks && hooks.stop ) { 8011 hooks.stop.call( this, true ); 8012 } 8013 8014 // look for any active animations, and finish them 8015 for ( index = timers.length; index--; ) { 8016 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { 8017 timers[ index ].anim.stop( true ); 8018 timers.splice( index, 1 ); 8019 } 8020 } 8021 8022 // look for any animations in the old queue and finish them 8023 for ( index = 0; index < length; index++ ) { 8024 if ( queue[ index ] && queue[ index ].finish ) { 8025 queue[ index ].finish.call( this ); 8026 } 8027 } 8028 8029 // turn off finishing flag 8030 delete data.finish; 8031 } ); 8032 } 8033} ); 8034 8035jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) { 8036 var cssFn = jQuery.fn[ name ]; 8037 jQuery.fn[ name ] = function( speed, easing, callback ) { 8038 return speed == null || typeof speed === "boolean" ? 8039 cssFn.apply( this, arguments ) : 8040 this.animate( genFx( name, true ), speed, easing, callback ); 8041 }; 8042} ); 8043 8044// Generate shortcuts for custom animations 8045jQuery.each( { 8046 slideDown: genFx( "show" ), 8047 slideUp: genFx( "hide" ), 8048 slideToggle: genFx( "toggle" ), 8049 fadeIn: { opacity: "show" }, 8050 fadeOut: { opacity: "hide" }, 8051 fadeToggle: { opacity: "toggle" } 8052}, function( name, props ) { 8053 jQuery.fn[ name ] = function( speed, easing, callback ) { 8054 return this.animate( props, speed, easing, callback ); 8055 }; 8056} ); 8057 8058jQuery.timers = []; 8059jQuery.fx.tick = function() { 8060 var timer, 8061 timers = jQuery.timers, 8062 i = 0; 8063 8064 fxNow = jQuery.now(); 8065 8066 for ( ; i < timers.length; i++ ) { 8067 timer = timers[ i ]; 8068 8069 // Checks the timer has not already been removed 8070 if ( !timer() && timers[ i ] === timer ) { 8071 timers.splice( i--, 1 ); 8072 } 8073 } 8074 8075 if ( !timers.length ) { 8076 jQuery.fx.stop(); 8077 } 8078 fxNow = undefined; 8079}; 8080 8081jQuery.fx.timer = function( timer ) { 8082 jQuery.timers.push( timer ); 8083 if ( timer() ) { 8084 jQuery.fx.start(); 8085 } else { 8086 jQuery.timers.pop(); 8087 } 8088}; 8089 8090jQuery.fx.interval = 13; 8091 8092jQuery.fx.start = function() { 8093 if ( !timerId ) { 8094 timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval ); 8095 } 8096}; 8097 8098jQuery.fx.stop = function() { 8099 window.clearInterval( timerId ); 8100 timerId = null; 8101}; 8102 8103jQuery.fx.speeds = { 8104 slow: 600, 8105 fast: 200, 8106 8107 // Default speed 8108 _default: 400 8109}; 8110 8111 8112// Based off of the plugin by Clint Helfers, with permission. 8113// http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
8114jQuery.fn.delay = function( time, type ) { 8115 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; 8116 type = type || "fx"; 8117 8118 return this.queue( type, function( next, hooks ) { 8119 var timeout = window.setTimeout( next, time ); 8120 hooks.stop = function() { 8121 window.clearTimeout( timeout ); 8122 }; 8123 } ); 8124}; 8125 8126 8127( function() { 8128 var a, 8129 input = document.createElement( "input" ), 8130 div = document.createElement( "div" ), 8131 select = document.createElement( "select" ), 8132 opt = select.appendChild( document.createElement( "option" ) ); 8133 8134 // Setup 8135 div = document.createElement( "div" ); 8136 div.setAttribute( "className", "t" ); 8137 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; 8138 a = div.getElementsByTagName( "a" )[ 0 ]; 8139 8140 // Support: Windows Web Apps (WWA) 8141 // `type` must use .setAttribute for WWA (#14901) 8142 input.setAttribute( "type", "checkbox" ); 8143 div.appendChild( input ); 8144 8145 a = div.getElementsByTagName( "a" )[ 0 ]; 8146 8147 // First batch of tests. 8148 a.style.cssText = "top:1px"; 8149 8150 // Test setAttribute on camelCase class. 8151 // If it works, we need attrFixes when doing get/setAttribute (ie6/7)
8152 support.getSetAttribute = div.className !== "t"; 8153 8154 // Get the style information from getAttribute 8155 // (IE uses .cssText instead) 8156 support.style = /top/.test( a.getAttribute( "style" ) ); 8157 8158 // Make sure that URLs aren't manipulated 8159 // (IE normalizes it by default) 8160 support.hrefNormalized = a.getAttribute( "href" ) === "/a"; 8161 8162 // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere) 8163 support.checkOn = !!input.value; 8164 8165 // Make sure that a selected-by-default option has a working selected property. 8166 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) 8167 support.optSelected = opt.selected; 8168 8169 // Tests for enctype support on a form (#6743) 8170 support.enctype = !!document.createElement( "form" ).enctype; 8171 8172 // Make sure that the options inside disabled selects aren't marked as disabled 8173 // (WebKit marks them as disabled) 8174 select.disabled = true; 8175 support.optDisabled = !opt.disabled; 8176 8177 // Support: IE8 only 8178 // Check if we can trust getAttribute("value") 8179 input = document.createElement( "input" ); 8180 input.setAttribute( "value", "" ); 8181 support.input = input.getAttribute( "value" ) === ""; 8182 8183 // Check if an input maintains its value after becoming a radio 8184 input.value = "t"; 8185 input.setAttribute( "type", "radio" ); 8186 support.radioValue = input.value === "t"; 8187} )(); 8188 8189 8190var rreturn = /\r/g, 8191 rspaces = /[\x20\t\r\n\f]+/g; 8192 8193jQuery.fn.extend( { 8194 val: function( value ) { 8195 var hooks, ret, isFunction, 8196 elem = this[ 0 ]; 8197 8198 if ( !arguments.length ) { 8199 if ( elem ) { 8200 hooks = jQuery.valHooks[ elem.type ] || 8201 jQuery.valHooks[ elem.nodeName.toLowerCase() ]; 8202 8203 if ( 8204 hooks && 8205 "get" in hooks && 8206 ( ret = hooks.get( elem, "value" ) ) !== undefined 8207 ) { 8208 return ret; 8209 } 8210 8211 ret = elem.value; 8212 8213 return typeof ret === "string" ? 8214 8215 // handle most common string cases 8216 ret.replace( rreturn, "" ) : 8217 8218 // handle cases where value is null/undef or number 8219 ret == null ? "" : ret; 8220 } 8221 8222 return; 8223 } 8224 8225 isFunction = jQuery.isFunction( value ); 8226 8227 return this.each( function( i ) { 8228 var val; 8229 8230 if ( this.nodeType !== 1 ) { 8231 return; 8232 } 8233 8234 if ( isFunction ) { 8235 val = value.call( this, i, jQuery( this ).val() ); 8236 } else { 8237 val = value; 8238 } 8239 8240 // Treat null/undefined as ""; convert numbers to string 8241 if ( val == null ) { 8242 val = ""; 8243 } else if ( typeof val === "number" ) { 8244 val += ""; 8245 } else if ( jQuery.isArray( val ) ) { 8246 val = jQuery.map( val, function( value ) { 8247 return value == null ? "" : value + ""; 8248 } ); 8249 } 8250 8251 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; 8252 8253 // If set returns undefined, fall back to normal setting
8254 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { 8255 this.value = val; 8256 } 8257 } ); 8258 } 8259} ); 8260 8261jQuery.extend( { 8262 valHooks: { 8263 option: { 8264 get: function( elem ) { 8265 var val = jQuery.find.attr( elem, "value" ); 8266 return val != null ? 8267 val : 8268 8269 // Support: IE10-11+ 8270 // option.text throws exceptions (#14686, #14858) 8271 // Strip and collapse whitespace 8272 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace 8273 jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " ); 8274 } 8275 }, 8276 select: { 8277 get: function( elem ) { 8278 var value, option, 8279 options = elem.options, 8280 index = elem.selectedIndex, 8281 one = elem.type === "select-one" || index < 0, 8282 values = one ? null : [], 8283 max = one ? index + 1 : options.length, 8284 i = index < 0 ? 8285 max : 8286 one ? index : 0; 8287 8288 // Loop through all the selected options 8289 for ( ; i < max; i++ ) { 8290 option = options[ i ]; 8291 8292 // oldIE doesn't update selected after form reset (#2551) 8293 if ( ( option.selected || i === index ) && 8294 8295 // Don't return options that are disabled or in a disabled optgroup 8296 ( support.optDisabled ? 8297 !option.disabled : 8298 option.getAttribute( "disabled" ) === null ) && 8299 ( !option.parentNode.disabled || 8300 !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { 8301 8302 // Get the specific value for the option 8303 value = jQuery( option ).val(); 8304 8305 // We don't need an array for one selects 8306 if ( one ) { 8307 return value; 8308 } 8309 8310 // Multi-Selects return an array 8311 values.push( value ); 8312 } 8313 } 8314 8315 return values; 8316 }, 8317 8318 set: function( elem, value ) { 8319 var optionSet, option, 8320 options = elem.options, 8321 values = jQuery.makeArray( value ), 8322 i = options.length; 8323 8324 while ( i-- ) { 8325 option = options[ i ]; 8326 8327 if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 ) { 8328 8329 // Support: IE6 8330 // When new option element is added to select box we need to 8331 // force reflow of newly added node in order to workaround delay 8332 // of initialization properties 8333 try { 8334 option.selected = optionSet = true; 8335 8336 } catch ( _ ) { 8337 8338 // Will be executed only in IE6 8339 option.scrollHeight; 8340 } 8341 8342 } else { 8343 option.selected = false; 8344 } 8345 } 8346 8347 // Force browsers to behave consistently when non-matching value is set 8348 if ( !optionSet ) { 8349 elem.selectedIndex = -1; 8350 } 8351 8352 return options; 8353 } 8354 } 8355 } 8356} ); 8357 8358// Radios and checkboxes getter/setter 8359jQuery.each( [ "radio", "checkbox" ], function() { 8360 jQuery.valHooks[ this ] = { 8361 set: function( elem, value ) { 8362 if ( jQuery.isArray( value ) ) { 8363 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); 8364 } 8365 } 8366 }; 8367 if ( !support.checkOn ) { 8368 jQuery.valHooks[ this ].get = function( elem ) { 8369 return elem.getAttribute( "value" ) === null ? "on" : elem.value; 8370 }; 8371 } 8372} ); 8373 8374 8375 8376 8377var nodeHook, boolHook, 8378 attrHandle = jQuery.expr.attrHandle, 8379 ruseDefault = /^(?:checked|selected)$/i, 8380 getSetAttribute = support.getSetAttribute, 8381 getSetInput = support.input; 8382 8383jQuery.fn.extend( { 8384 attr: function( name, value ) { 8385 return access( this, jQuery.attr, name, value, arguments.length > 1 ); 8386 }, 8387 8388 removeAttr: function( name ) { 8389 return this.each( function() { 8390 jQuery.removeAttr( this, name ); 8391 } ); 8392 } 8393} ); 8394 8395jQuery.extend( { 8396 attr: function( elem, name, value ) { 8397 var ret, hooks, 8398 nType = elem.nodeType; 8399 8400 // Don't get/set attributes on text, comment and attribute nodes 8401 if ( nType === 3 || nType === 8 || nType === 2 ) { 8402 return; 8403 } 8404 8405 // Fallback to prop when attributes are not supported 8406 if ( typeof elem.getAttribute === "undefined" ) { 8407 return jQuery.prop( elem, name, value ); 8408 } 8409 8410 // All attributes are lowercase 8411 // Grab necessary hook if one is defined 8412 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 8413 name = name.toLowerCase(); 8414 hooks = jQuery.attrHooks[ name ] || 8415 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook ); 8416 } 8417 8418 if ( value !== undefined ) { 8419 if ( value === null ) { 8420 jQuery.removeAttr( elem, name ); 8421 return; 8422 } 8423 8424 if ( hooks && "set" in hooks && 8425 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 8426 return ret; 8427 } 8428 8429 elem.setAttribute( name, value + "" ); 8430 return value; 8431 } 8432 8433 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 8434 return ret; 8435 } 8436 8437 ret = jQuery.find.attr( elem, name ); 8438 8439 // Non-existent attributes return null, we normalize to undefined 8440 return ret == null ? undefined : ret; 8441 }, 8442 8443 attrHooks: { 8444 type: {
8445 set: function( elem, value ) { 8446 if ( !support.radioValue && value === "radio" && 8447 jQuery.nodeName( elem, "input" ) ) { 8448 8449 // Setting the type on a radio button after the value resets the value in IE8-9 8450 // Reset value to default in case type is set after value during creation 8451 var val = elem.value; 8452 elem.setAttribute( "type", value ); 8453 if ( val ) { 8454 elem.value = val; 8455 } 8456 return value; 8457 } 8458 } 8459 } 8460 }, 8461 8462 removeAttr: function( elem, value ) { 8463 var name, propName, 8464 i = 0, 8465 attrNames = value && value.match( rnotwhite ); 8466 8467 if ( attrNames && elem.nodeType === 1 ) { 8468 while ( ( name = attrNames[ i++ ] ) ) { 8469 propName = jQuery.propFix[ name ] || name; 8470 8471 // Boolean attributes get special treatment (#10870) 8472 if ( jQuery.expr.match.bool.test( name ) ) { 8473 8474 // Set corresponding property to false 8475 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { 8476 elem[ propName ] = false; 8477 8478 // Support: IE<9 8479 // Also clear defaultChecked/defaultSelected (if appropriate) 8480 } else { 8481 elem[ jQuery.camelCase( "default-" + name ) ] = 8482 elem[ propName ] = false; 8483 } 8484 8485 // See #9699 for explanation of this approach (setting first, then removal) 8486 } else { 8487 jQuery.attr( elem, name, "" ); 8488 } 8489 8490 elem.removeAttribute( getSetAttribute ? name : propName ); 8491 } 8492 } 8493 } 8494} ); 8495 8496// Hooks for boolean attributes 8497boolHook = { 8498 set: function( elem, value, name ) { 8499 if ( value === false ) { 8500 8501 // Remove boolean attributes when set to false 8502 jQuery.removeAttr( elem, name ); 8503 } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { 8504 8505 // IE<8 needs the *property* name 8506 elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name ); 8507 8508 } else { 8509 8510 // Support: IE<9 8511 // Use defaultChecked and defaultSelected for oldIE 8512 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true; 8513 } 8514 return name; 8515 } 8516}; 8517 8518jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { 8519 var getter = attrHandle[ name ] || jQuery.find.attr; 8520 8521 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { 8522 attrHandle[ name ] = function( elem, name, isXML ) { 8523 var ret, handle; 8524 if ( !isXML ) { 8525 8526 // Avoid an infinite loop by temporarily removing this function from the getter 8527 handle = attrHandle[ name ]; 8528 attrHandle[ name ] = ret; 8529 ret = getter( elem, name, isXML ) != null ? 8530 name.toLowerCase() : 8531 null; 8532 attrHandle[ name ] = handle; 8533 } 8534 return ret; 8535 }; 8536 } else { 8537 attrHandle[ name ] = function( elem, name, isXML ) { 8538 if ( !isXML ) { 8539 return elem[ jQuery.camelCase( "default-" + name ) ] ? 8540 name.toLowerCase() : 8541 null; 8542 } 8543 }; 8544 } 8545} ); 8546 8547// fix oldIE attroperties 8548if ( !getSetInput || !getSetAttribute ) { 8549 jQuery.attrHooks.value = { 8550 set: function( elem, value, name ) { 8551 if ( jQuery.nodeName( elem, "input" ) ) { 8552 8553 // Does not return so that setAttribute is also used 8554 elem.defaultValue = value; 8555 } else { 8556 8557 // Use nodeHook if defined (#1954); otherwise setAttribute is fine 8558 return nodeHook && nodeHook.set( elem, value, name ); 8559 } 8560 } 8561 }; 8562} 8563 8564// IE6/7 do not support getting/setting some attributes with get/setAttribute 8565if ( !getSetAttribute ) { 8566 8567 // Use this for any attribute in IE6/7 8568 // This fixes almost every IE6/7 issue 8569 nodeHook = { 8570 set: function( elem, value, name ) { 8571 8572 // Set the existing or create a new attribute node 8573 var ret = elem.getAttributeNode( name ); 8574 if ( !ret ) { 8575 elem.setAttributeNode( 8576 ( ret = elem.ownerDocument.createAttribute( name ) ) 8577 ); 8578 } 8579 8580 ret.value = value += ""; 8581 8582 // Break association with cloned elements by also using setAttribute (#9646) 8583 if ( name === "value" || value === elem.getAttribute( name ) ) { 8584 return value; 8585 } 8586 } 8587 }; 8588 8589 // Some attributes are constructed with empty-string values when not defined 8590 attrHandle.id = attrHandle.name = attrHandle.coords = 8591 function( elem, name, isXML ) { 8592 var ret; 8593 if ( !isXML ) { 8594 return ( ret = elem.getAttributeNode( name ) ) && ret.value !== "" ? 8595 ret.value : 8596 null; 8597 } 8598 }; 8599 8600 // Fixing value retrieval on a button requires this module 8601 jQuery.valHooks.button = { 8602 get: function( elem, name ) { 8603 var ret = elem.getAttributeNode( name ); 8604 if ( ret && ret.specified ) { 8605 return ret.value; 8606 } 8607 }, 8608 set: nodeHook.set 8609 }; 8610 8611 // Set contenteditable to false on removals(#10429)
8612 // Setting to empty string throws an error as an invalid value 8613 jQuery.attrHooks.contenteditable = { 8614 set: function( elem, value, name ) { 8615 nodeHook.set( elem, value === "" ? false : value, name ); 8616 } 8617 }; 8618 8619 // Set width and height to auto instead of 0 on empty string( Bug #8150 ) 8620 // This is for removals 8621 jQuery.each( [ "width", "height" ], function( i, name ) { 8622 jQuery.attrHooks[ name ] = { 8623 set: function( elem, value ) { 8624 if ( value === "" ) { 8625 elem.setAttribute( name, "auto" ); 8626 return value; 8627 } 8628 } 8629 }; 8630 } ); 8631} 8632 8633if ( !support.style ) { 8634 jQuery.attrHooks.style = { 8635 get: function( elem ) { 8636 8637 // Return undefined in the case of empty string 8638 // Note: IE uppercases css property names, but if we were to .toLowerCase() 8639 // .cssText, that would destroy case sensitivity in URL's, like in "background" 8640 return elem.style.cssText || undefined; 8641 }, 8642 set: function( elem, value ) { 8643 return ( elem.style.cssText = value + "" ); 8644 } 8645 }; 8646} 8647 8648 8649 8650 8651var rfocusable = /^(?:input|select|textarea|button|object)$/i, 8652 rclickable = /^(?:a|area)$/i; 8653 8654jQuery.fn.extend( { 8655 prop: function( name, value ) { 8656 return access( this, jQuery.prop, name, value, arguments.length > 1 ); 8657 }, 8658 8659 removeProp: function( name ) { 8660 name = jQuery.propFix[ name ] || name; 8661 return this.each( function() { 8662 8663 // try/catch handles cases where IE balks (such as removing a property on window) 8664 try { 8665 this[ name ] = undefined; 8666 delete this[ name ]; 8667 } catch ( e ) {} 8668 } ); 8669 } 8670} ); 8671 8672jQuery.extend( { 8673 prop: function( elem, name, value ) { 8674 var ret, hooks, 8675 nType = elem.nodeType; 8676 8677 // Don't get/set properties on text, comment and attribute nodes 8678 if ( nType === 3 || nType === 8 || nType === 2 ) { 8679 return; 8680 } 8681 8682 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 8683 8684 // Fix name and attach hooks 8685 name = jQuery.propFix[ name ] || name; 8686 hooks = jQuery.propHooks[ name ]; 8687 } 8688 8689 if ( value !== undefined ) { 8690 if ( hooks && "set" in hooks && 8691 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 8692 return ret; 8693 } 8694 8695 return ( elem[ name ] = value ); 8696 } 8697 8698 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 8699 return ret; 8700 } 8701 8702 return elem[ name ]; 8703 }, 8704 8705 propHooks: { 8706 tabIndex: { 8707 get: function( elem ) { 8708 8709 // elem.tabIndex doesn't always return the 8710 // correct value when it hasn't been explicitly set 8711 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ 8712 // Use proper attribute retrieval(#12072) 8713 var tabindex = jQuery.find.attr( elem, "tabindex" ); 8714 8715 return tabindex ? 8716 parseInt( tabindex, 10 ) : 8717 rfocusable.test( elem.nodeName ) || 8718 rclickable.test( elem.nodeName ) && elem.href ? 8719 0 : 8720 -1; 8721 } 8722 } 8723 }, 8724 8725 propFix: { 8726 "for": "htmlFor", 8727 "class": "className" 8728 } 8729} ); 8730 8731// Some attributes require a special call on IE 8732// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx 8733if ( !support.hrefNormalized ) { 8734 8735 // href/src property should get the full normalized URL (#10299/#12915) 8736 jQuery.each( [ "href", "src" ], function( i, name ) { 8737 jQuery.propHooks[ name ] = { 8738 get: function( elem ) { 8739 return elem.getAttribute( name, 4 ); 8740 } 8741 }; 8742 } ); 8743} 8744 8745// Support: Safari, IE9+ 8746// Accessing the selectedIndex property 8747// forces the browser to respect setting selected 8748// on the option 8749// The getter ensures a default option is selected 8750// when in an optgroup 8751if ( !support.optSelected ) { 8752 jQuery.propHooks.selected = { 8753 get: function( elem ) { 8754 var parent = elem.parentNode; 8755 8756 if ( parent ) { 8757 parent.selectedIndex; 8758 8759 // Make sure that it also works with optgroups, see #5701 8760 if ( parent.parentNode ) { 8761 parent.parentNode.selectedIndex; 8762 } 8763 } 8764 return null; 8765 }, 8766 set: function( elem ) { 8767 var parent = elem.parentNode; 8768 if ( parent ) { 8769 parent.selectedIndex; 8770 8771 if ( parent.parentNode ) { 8772 parent.parentNode.selectedIndex; 8773 } 8774 } 8775 } 8776 }; 8777} 8778 8779jQuery.each( [ 8780 "tabIndex", 8781 "readOnly", 8782 "maxLength", 8783 "cellSpacing", 8784 "cellPadding", 8785 "rowSpan", 8786 "colSpan", 8787 "useMap", 8788 "frameBorder", 8789 "contentEditable" 8790], function() { 8791 jQuery.propFix[ this.toLowerCase() ] = this; 8792} ); 8793 8794// IE6/7 call enctype encoding 8795if ( !support.enctype ) { 8796 jQuery.propFix.enctype = "encoding"; 8797} 8798 8799 8800 8801 8802var rclass = /[\t\r\n\f]/g; 8803 8804function getClass( elem ) { 8805 return jQuery.attr( elem, "class" ) || ""; 8806} 8807 8808jQuery.fn.extend( { 8809 addClass: function( value ) { 8810 var classes, elem, cur, curValue, clazz, j, finalValue, 8811 i = 0; 8812 8813 if ( jQuery.isFunction( value ) ) { 8814 return this.each( function( j ) { 8815 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); 8816 } ); 8817 } 8818 8819 if ( typeof value === "string" && value ) { 8820 classes = value.match( rnotwhite ) || []; 8821 8822 while ( ( elem = this[ i++ ] ) ) { 8823 curValue = getClass( elem ); 8824 cur = elem.nodeType === 1 && 8825 ( " " + curValue + " " ).replace( rclass, " " ); 8826 8827 if ( cur ) { 8828 j = 0; 8829 while ( ( clazz = classes[ j++ ] ) ) { 8830 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { 8831 cur += clazz + " "; 8832 } 8833 } 8834 8835 // only assign if different to avoid unneeded rendering. 8836 finalValue = jQuery.trim( cur ); 8837 if ( curValue !== finalValue ) { 8838 jQuery.attr( elem, "class", finalValue ); 8839 } 8840 } 8841 } 8842 } 8843 8844 return this; 8845 }, 8846 8847 removeClass: function( value ) { 8848 var classes, elem, cur, curValue, clazz, j, finalValue, 8849 i = 0; 8850 8851 if ( jQuery.isFunction( value ) ) { 8852 return this.each( function( j ) { 8853 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); 8854 } ); 8855 } 8856 8857 if ( !arguments.length ) { 8858 return this.attr( "class", "" ); 8859 } 8860 8861 if ( typeof value === "string" && value ) { 8862 classes = value.match( rnotwhite ) || []; 8863 8864 while ( ( elem = this[ i++ ] ) ) { 8865 curValue = getClass( elem ); 8866 8867 // This expression is here for better compressibility (see addClass) 8868 cur = elem.nodeType === 1 && 8869 ( " " + curValue + " " ).replace( rclass, " " ); 8870 8871 if ( cur ) { 8872 j = 0; 8873 while ( ( clazz = classes[ j++ ] ) ) { 8874
8875 // Remove *all* instances 8876 while ( cur.indexOf( " " + clazz + " " ) > -1 ) { 8877 cur = cur.replace( " " + clazz + " ", " " ); 8878 } 8879 } 8880 8881 // Only assign if different to avoid unneeded rendering. 8882 finalValue = jQuery.trim( cur ); 8883 if ( curValue !== finalValue ) { 8884 jQuery.attr( elem, "class", finalValue ); 8885 } 8886 } 8887 } 8888 } 8889 8890 return this; 8891 }, 8892 8893 toggleClass: function( value, stateVal ) { 8894 var type = typeof value; 8895 8896 if ( typeof stateVal === "boolean" && type === "string" ) { 8897 return stateVal ? this.addClass( value ) : this.removeClass( value ); 8898 } 8899 8900 if ( jQuery.isFunction( value ) ) { 8901 return this.each( function( i ) { 8902 jQuery( this ).toggleClass( 8903 value.call( this, i, getClass( this ), stateVal ), 8904 stateVal 8905 ); 8906 } ); 8907 } 8908 8909 return this.each( function() { 8910 var className, i, self, classNames; 8911 8912 if ( type === "string" ) { 8913 8914 // Toggle individual class names 8915 i = 0; 8916 self = jQuery( this ); 8917 classNames = value.match( rnotwhite ) || []; 8918 8919 while ( ( className = classNames[ i++ ] ) ) { 8920 8921 // Check each className given, space separated list 8922 if ( self.hasClass( className ) ) { 8923 self.removeClass( className ); 8924 } else { 8925 self.addClass( className ); 8926 } 8927 } 8928 8929 // Toggle whole class name 8930 } else if ( value === undefined || type === "boolean" ) { 8931 className = getClass( this ); 8932 if ( className ) { 8933 8934 // store className if set 8935 jQuery._data( this, "__className__", className ); 8936 } 8937 8938 // If the element has a class name or if we're passed "false", 8939 // then remove the whole classname (if there was one, the above saved it). 8940 // Otherwise bring back whatever was previously saved (if anything), 8941 // falling back to the empty string if nothing was stored. 8942 jQuery.attr( this, "class", 8943 className || value === false ? 8944 "" : 8945 jQuery._data( this, "__className__" ) || "" 8946 ); 8947 } 8948 } ); 8949 }, 8950 8951 hasClass: function( selector ) { 8952 var className, elem, 8953 i = 0; 8954 8955 className = " " + selector + " "; 8956 while ( ( elem = this[ i++ ] ) ) { 8957 if ( elem.nodeType === 1 && 8958 ( " " + getClass( elem ) + " " ).replace( rclass, " " ) 8959 .indexOf( className ) > -1 8960 ) { 8961 return true; 8962 } 8963 } 8964 8965 return false; 8966 } 8967} ); 8968 8969 8970 8971 8972// Return jQuery for attributes-only inclusion 8973 8974 8975jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " + 8976 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + 8977 "change select submit keydown keypress keyup error contextmenu" ).split( " " ), 8978 function( i, name ) { 8979 8980 // Handle event binding 8981 jQuery.fn[ name ] = function( data, fn ) { 8982 return arguments.length > 0 ? 8983 this.on( name, null, data, fn ) : 8984 this.trigger( name ); 8985 }; 8986} ); 8987 8988jQuery.fn.extend( { 8989 hover: function( fnOver, fnOut ) { 8990 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); 8991 } 8992} ); 8993 8994 8995var location = window.location; 8996 8997var nonce = jQuery.now(); 8998 8999var rquery = ( /\?/ ); 9000 9001 9002 9003var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g; 9004 9005jQuery.parseJSON = function( data ) { 9006 9007 // Attempt to parse using the native JSON parser first 9008 if ( window.JSON && window.JSON.parse ) { 9009 9010 // Support: Android 2.3 9011 // Workaround failure to string-cast null input 9012 return window.JSON.parse( data + "" ); 9013 } 9014 9015 var requireNonComma, 9016 depth = null, 9017 str = jQuery.trim( data + "" ); 9018 9019 // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains 9020 // after removing valid tokens 9021 return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) { 9022 9023 // Force termination if we see a misplaced comma 9024 if ( requireNonComma && comma ) { 9025 depth = 0; 9026 } 9027 9028 // Perform no more replacements after returning to outermost depth 9029 if ( depth === 0 ) { 9030 return token; 9031 } 9032 9033 // Commas must not follow "[", "{", or "," 9034 requireNonComma = open || comma; 9035 9036 // Determine new depth 9037 // array/object open ("[" or "{"): depth += true - false (increment) 9038 // array/object close ("]" or "}"): depth += false - true (decrement) 9039 // other cases ("," or primitive): depth += true - true (numeric cast) 9040 depth += !close - !open; 9041 9042 // Remove this token 9043 return ""; 9044 } ) ) ? 9045 ( Function( "return " + str ) )() : 9046 jQuery.error( "Invalid JSON: " + data ); 9047}; 9048 9049 9050// Cross-browser xml parsing
9051jQuery.parseXML = function( data ) { 9052 var xml, tmp; 9053 if ( !data || typeof data !== "string" ) { 9054 return null; 9055 } 9056 try { 9057 if ( window.DOMParser ) { // Standard 9058 tmp = new window.DOMParser(); 9059 xml = tmp.parseFromString( data, "text/xml" ); 9060 } else { // IE 9061 xml = new window.ActiveXObject( "Microsoft.XMLDOM" ); 9062 xml.async = "false"; 9063 xml.loadXML( data ); 9064 } 9065 } catch ( e ) { 9066 xml = undefined; 9067 } 9068 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { 9069 jQuery.error( "Invalid XML: " + data ); 9070 } 9071 return xml; 9072}; 9073 9074 9075var 9076 rhash = /#.*$/, 9077 rts = /([?&])_=[^&]*/, 9078 9079 // IE leaves an \r character at EOL 9080 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, 9081 9082 // #7653, #8125, #8152: local protocol detection 9083 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, 9084 rnoContent = /^(?:GET|HEAD)$/, 9085 rprotocol = /^\/\//, 9086 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/, 9087 9088 /* Prefilters 9089 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) 9090 * 2) These are called: 9091 * - BEFORE asking for a transport 9092 * - AFTER param serialization (s.data is a string if s.processData is true) 9093 * 3) key is the dataType 9094 * 4) the catchall symbol "*" can be used 9095 * 5) execution will start with transport dataType and THEN continue down to "*" if needed 9096 */ 9097 prefilters = {}, 9098 9099 /* Transports bindings 9100 * 1) key is the dataType 9101 * 2) the catchall symbol "*" can be used 9102 * 3) selection will start with transport dataType and THEN go to "*" if needed 9103 */ 9104 transports = {}, 9105 9106 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression 9107 allTypes = "*/".concat( "*" ), 9108 9109 // Document location 9110 ajaxLocation = location.href, 9111 9112 // Segment location into parts 9113 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; 9114 9115// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport 9116function addToPrefiltersOrTransports( structure ) { 9117 9118 // dataTypeExpression is optional and defaults to "*" 9119 return function( dataTypeExpression, func ) { 9120 9121 if ( typeof dataTypeExpression !== "string" ) { 9122 func = dataTypeExpression; 9123 dataTypeExpression = "*"; 9124 } 9125 9126 var dataType, 9127 i = 0, 9128 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || []; 9129 9130 if ( jQuery.isFunction( func ) ) { 9131 9132 // For each dataType in the dataTypeExpression 9133 while ( ( dataType = dataTypes[ i++ ] ) ) { 9134 9135 // Prepend if requested 9136 if ( dataType.charAt( 0 ) === "+" ) { 9137 dataType = dataType.slice( 1 ) || "*"; 9138 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); 9139 9140 // Otherwise append 9141 } else { 9142 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); 9143 } 9144 } 9145 } 9146 }; 9147} 9148 9149// Base inspection function for prefilters and transports 9150function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { 9151 9152 var inspected = {}, 9153 seekingTransport = ( structure === transports ); 9154 9155 function inspect( dataType ) { 9156 var selected; 9157 inspected[ dataType ] = true; 9158 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { 9159 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); 9160 if ( typeof dataTypeOrTransport === "string" && 9161 !seekingTransport && !inspected[ dataTypeOrTransport ] ) { 9162 9163 options.dataTypes.unshift( dataTypeOrTransport ); 9164 inspect( dataTypeOrTransport ); 9165 return false; 9166 } else if ( seekingTransport ) { 9167 return !( selected = dataTypeOrTransport ); 9168 } 9169 } ); 9170 return selected; 9171 } 9172 9173 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); 9174} 9175 9176// A special extend for ajax options 9177// that takes "flat" options (not to be deep extended) 9178// Fixes #9887 9179function ajaxExtend( target, src ) { 9180 var deep, key, 9181 flatOptions = jQuery.ajaxSettings.flatOptions || {}; 9182 9183 for ( key in src ) { 9184 if ( src[ key ] !== undefined ) { 9185 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; 9186 } 9187 } 9188 if ( deep ) { 9189 jQuery.extend( true, target, deep ); 9190 } 9191 9192 return target; 9193} 9194 9195/* Handles responses to an ajax request: 9196 * - finds the right dataType (mediates between content-type and expected dataType) 9197 * - returns the corresponding response 9198 */ 9199function ajaxHandleResponses( s, jqXHR, responses ) { 9200 var firstDataType, ct, finalDataType, type, 9201 contents = s.contents, 9202 dataTypes = s.dataTypes; 9203 9204 // Remove auto dataType and get content-type in the process 9205 while ( dataTypes[ 0 ] === "*" ) { 9206 dataTypes.shift(); 9207 if ( ct === undefined ) { 9208 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); 9209 } 9210 } 9211 9212 // Check if we're dealing with a known content-type 9213 if ( ct ) { 9214 for ( type in contents ) { 9215 if ( contents[ type ] && contents[ type ].test( ct ) ) { 9216 dataTypes.unshift( type ); 9217 break; 9218 } 9219 } 9220 } 9221 9222 // Check to see if we have a response for the expected dataType 9223 if ( dataTypes[ 0 ] in responses ) { 9224 finalDataType = dataTypes[ 0 ]; 9225 } else { 9226
vendor: 5,407 bytes, lines 9227-9456
9227 // Try convertible dataTypes 9228 for ( type in responses ) { 9229 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { 9230 finalDataType = type; 9231 break; 9232 } 9233 if ( !firstDataType ) { 9234 firstDataType = type; 9235 } 9236 } 9237 9238 // Or just use first one 9239 finalDataType = finalDataType || firstDataType; 9240 } 9241 9242 // If we found a dataType 9243 // We add the dataType to the list if needed 9244 // and return the corresponding response 9245 if ( finalDataType ) { 9246 if ( finalDataType !== dataTypes[ 0 ] ) { 9247 dataTypes.unshift( finalDataType ); 9248 } 9249 return responses[ finalDataType ]; 9250 } 9251} 9252 9253/* Chain conversions given the request and the original response 9254 * Also sets the responseXXX fields on the jqXHR instance 9255 */ 9256function ajaxConvert( s, response, jqXHR, isSuccess ) { 9257 var conv2, current, conv, tmp, prev, 9258 converters = {}, 9259 9260 // Work with a copy of dataTypes in case we need to modify it for conversion 9261 dataTypes = s.dataTypes.slice(); 9262 9263 // Create converters map with lowercased keys 9264 if ( dataTypes[ 1 ] ) { 9265 for ( conv in s.converters ) { 9266 converters[ conv.toLowerCase() ] = s.converters[ conv ]; 9267 } 9268 } 9269 9270 current = dataTypes.shift(); 9271 9272 // Convert to each sequential dataType 9273 while ( current ) { 9274 9275 if ( s.responseFields[ current ] ) { 9276 jqXHR[ s.responseFields[ current ] ] = response; 9277 } 9278 9279 // Apply the dataFilter if provided 9280 if ( !prev && isSuccess && s.dataFilter ) { 9281 response = s.dataFilter( response, s.dataType ); 9282 } 9283 9284 prev = current; 9285 current = dataTypes.shift(); 9286 9287 if ( current ) { 9288 9289 // There's only work to do if current dataType is non-auto 9290 if ( current === "*" ) { 9291 9292 current = prev; 9293 9294 // Convert response if prev dataType is non-auto and differs from current 9295 } else if ( prev !== "*" && prev !== current ) { 9296 9297 // Seek a direct converter 9298 conv = converters[ prev + " " + current ] || converters[ "* " + current ]; 9299 9300 // If none found, seek a pair 9301 if ( !conv ) { 9302 for ( conv2 in converters ) { 9303 9304 // If conv2 outputs current 9305 tmp = conv2.split( " " ); 9306 if ( tmp[ 1 ] === current ) { 9307 9308 // If prev can be converted to accepted input 9309 conv = converters[ prev + " " + tmp[ 0 ] ] || 9310 converters[ "* " + tmp[ 0 ] ]; 9311 if ( conv ) { 9312 9313 // Condense equivalence converters 9314 if ( conv === true ) { 9315 conv = converters[ conv2 ]; 9316 9317 // Otherwise, insert the intermediate dataType 9318 } else if ( converters[ conv2 ] !== true ) { 9319 current = tmp[ 0 ]; 9320 dataTypes.unshift( tmp[ 1 ] ); 9321 } 9322 break; 9323 } 9324 } 9325 } 9326 } 9327 9328 // Apply converter (if not an equivalence) 9329 if ( conv !== true ) { 9330 9331 // Unless errors are allowed to bubble, catch and return them 9332 if ( conv && s[ "throws" ] ) { // jscs:ignore requireDotNotation 9333 response = conv( response ); 9334 } else { 9335 try { 9336 response = conv( response ); 9337 } catch ( e ) { 9338 return { 9339 state: "parsererror", 9340 error: conv ? e : "No conversion from " + prev + " to " + current 9341 }; 9342 } 9343 } 9344 } 9345 } 9346 } 9347 } 9348 9349 return { state: "success", data: response }; 9350} 9351 9352jQuery.extend( { 9353 9354 // Counter for holding the number of active queries 9355 active: 0, 9356 9357 // Last-Modified header cache for next request 9358 lastModified: {}, 9359 etag: {}, 9360 9361 ajaxSettings: { 9362 url: ajaxLocation, 9363 type: "GET", 9364 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), 9365 global: true, 9366 processData: true, 9367 async: true, 9368 contentType: "application/x-www-form-urlencoded; charset=UTF-8", 9369 /* 9370 timeout: 0, 9371 data: null, 9372 dataType: null, 9373 username: null, 9374 password: null, 9375 cache: null, 9376 throws: false, 9377 traditional: false, 9378 headers: {}, 9379 */ 9380 9381 accepts: { 9382 "*": allTypes, 9383 text: "text/plain", 9384 html: "text/html", 9385 xml: "application/xml, text/xml", 9386 json: "application/json, text/javascript" 9387 }, 9388 9389 contents: { 9390 xml: /\bxml\b/, 9391 html: /\bhtml/, 9392 json: /\bjson\b/ 9393 }, 9394 9395 responseFields: { 9396 xml: "responseXML", 9397 text: "responseText", 9398 json: "responseJSON" 9399 }, 9400 9401 // Data converters 9402 // Keys separate source (or catchall "*") and destination types with a single space 9403 converters: { 9404 9405 // Convert anything to text 9406 "* text": String, 9407 9408 // Text to html (true = no transformation) 9409 "text html": true, 9410 9411 // Evaluate text as a json expression 9412 "text json": jQuery.parseJSON, 9413 9414 // Parse text as xml 9415 "text xml": jQuery.parseXML 9416 }, 9417 9418 // For options that shouldn't be deep extended: 9419 // you can add your own custom options here if 9420 // and when you create one that shouldn't be 9421 // deep extended (see ajaxExtend) 9422 flatOptions: { 9423 url: true, 9424 context: true 9425 } 9426 }, 9427 9428 // Creates a full fledged settings object into target 9429 // with both ajaxSettings and settings fields. 9430 // If target is omitted, writes into ajaxSettings. 9431 ajaxSetup: function( target, settings ) { 9432 return settings ? 9433 9434 // Building a settings object 9435 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : 9436 9437 // Extending ajaxSettings 9438 ajaxExtend( jQuery.ajaxSettings, target ); 9439 }, 9440 9441 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), 9442 ajaxTransport: addToPrefiltersOrTransports( transports ), 9443 9444 // Main method 9445 ajax: function( url, options ) { 9446 9447 // If url is an object, simulate pre-1.5 signature 9448 if ( typeof url === "object" ) { 9449 options = url; 9450 url = undefined; 9451 } 9452 9453 // Force options to be an object 9454 options = options || {}; 9455 9456 var
9457 9458 // Cross-domain detection vars 9459 parts, 9460 9461 // Loop variable 9462 i, 9463 9464 // URL without anti-cache param 9465 cacheURL, 9466 9467 // Response headers as string 9468 responseHeadersString, 9469 9470 // timeout handle 9471 timeoutTimer, 9472 9473 // To know if global events are to be dispatched 9474 fireGlobals, 9475 9476 transport, 9477 9478 // Response headers 9479 responseHeaders, 9480 9481 // Create the final options object 9482 s = jQuery.ajaxSetup( {}, options ), 9483 9484 // Callbacks context 9485 callbackContext = s.context || s, 9486 9487 // Context for global events is callbackContext if it is a DOM node or jQuery collection 9488 globalEventContext = s.context && 9489 ( callbackContext.nodeType || callbackContext.jquery ) ? 9490 jQuery( callbackContext ) : 9491 jQuery.event, 9492 9493 // Deferreds 9494 deferred = jQuery.Deferred(), 9495 completeDeferred = jQuery.Callbacks( "once memory" ), 9496 9497 // Status-dependent callbacks 9498 statusCode = s.statusCode || {}, 9499 9500 // Headers (they are sent all at once) 9501 requestHeaders = {}, 9502 requestHeadersNames = {}, 9503 9504 // The jqXHR state 9505 state = 0, 9506 9507 // Default abort message 9508 strAbort = "canceled", 9509 9510 // Fake xhr 9511 jqXHR = { 9512 readyState: 0, 9513 9514 // Builds headers hashtable if needed 9515 getResponseHeader: function( key ) { 9516 var match; 9517 if ( state === 2 ) { 9518 if ( !responseHeaders ) { 9519 responseHeaders = {}; 9520 while ( ( match = rheaders.exec( responseHeadersString ) ) ) { 9521 responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ]; 9522 } 9523 } 9524 match = responseHeaders[ key.toLowerCase() ]; 9525 } 9526 return match == null ? null : match; 9527 }, 9528 9529 // Raw string 9530 getAllResponseHeaders: function() { 9531 return state === 2 ? responseHeadersString : null; 9532 }, 9533 9534 // Caches the header 9535 setRequestHeader: function( name, value ) { 9536 var lname = name.toLowerCase(); 9537 if ( !state ) { 9538 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; 9539 requestHeaders[ name ] = value; 9540 } 9541 return this; 9542 }, 9543 9544 // Overrides response content-type header 9545 overrideMimeType: function( type ) { 9546 if ( !state ) { 9547 s.mimeType = type; 9548 } 9549 return this; 9550 }, 9551 9552 // Status-dependent callbacks 9553 statusCode: function( map ) { 9554 var code; 9555 if ( map ) { 9556 if ( state < 2 ) { 9557 for ( code in map ) { 9558 9559 // Lazy-add the new callback in a way that preserves old ones 9560 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; 9561 } 9562 } else { 9563 9564 // Execute the appropriate callbacks 9565 jqXHR.always( map[ jqXHR.status ] ); 9566 } 9567 } 9568 return this; 9569 }, 9570 9571 // Cancel the request 9572 abort: function( statusText ) { 9573 var finalText = statusText || strAbort; 9574 if ( transport ) { 9575 transport.abort( finalText ); 9576 } 9577 done( 0, finalText ); 9578 return this; 9579 } 9580 }; 9581 9582 // Attach deferreds 9583 deferred.promise( jqXHR ).complete = completeDeferred.add; 9584 jqXHR.success = jqXHR.done; 9585 jqXHR.error = jqXHR.fail; 9586 9587 // Remove hash character (#7531: and string promotion) 9588 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) 9589 // Handle falsy url in the settings object (#10093: consistency with old signature) 9590 // We also use the url parameter if available 9591 s.url = ( ( url || s.url || ajaxLocation ) + "" ) 9592 .replace( rhash, "" ) 9593 .replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); 9594 9595 // Alias method option to type as per ticket #12004 9596 s.type = options.method || options.type || s.method || s.type; 9597 9598 // Extract dataTypes list 9599 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ]; 9600 9601 // A cross-domain request is in order when we have a protocol:host:port mismatch 9602 if ( s.crossDomain == null ) { 9603 parts = rurl.exec( s.url.toLowerCase() ); 9604 s.crossDomain = !!( parts && 9605 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] || 9606 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !== 9607 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) ) 9608 ); 9609 } 9610 9611 // Convert data if not already a string 9612 if ( s.data && s.processData && typeof s.data !== "string" ) { 9613 s.data = jQuery.param( s.data, s.traditional ); 9614 } 9615 9616 // Apply prefilters 9617 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); 9618 9619 // If request was aborted inside a prefilter, stop there 9620 if ( state === 2 ) { 9621 return jqXHR; 9622 } 9623 9624 // We can fire global events as of now if asked to 9625 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) 9626 fireGlobals = jQuery.event && s.global; 9627 9628 // Watch for a new set of requests 9629 if ( fireGlobals && jQuery.active++ === 0 ) { 9630 jQuery.event.trigger( "ajaxStart" ); 9631 } 9632 9633 // Uppercase the type 9634 s.type = s.type.toUpperCase(); 9635 9636 // Determine if request has content 9637 s.hasContent = !rnoContent.test( s.type ); 9638 9639 // Save the URL in case we're toying with the If-Modified-Since 9640 // and/or If-None-Match header later on 9641 cacheURL = s.url; 9642 9643 // More options handling for requests with no content 9644 if ( !s.hasContent ) { 9645 9646 // If data is available, append data to url 9647 if ( s.data ) {
9648 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data ); 9649 9650 // #9682: remove data so that it's not used in an eventual retry 9651 delete s.data; 9652 } 9653 9654 // Add anti-cache in url if needed 9655 if ( s.cache === false ) { 9656 s.url = rts.test( cacheURL ) ? 9657 9658 // If there is already a '_' parameter, set its value 9659 cacheURL.replace( rts, "$1_=" + nonce++ ) : 9660 9661 // Otherwise add one to the end 9662 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++; 9663 } 9664 } 9665 9666 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 9667 if ( s.ifModified ) { 9668 if ( jQuery.lastModified[ cacheURL ] ) { 9669 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); 9670 } 9671 if ( jQuery.etag[ cacheURL ] ) { 9672 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); 9673 } 9674 } 9675 9676 // Set the correct header, if data is being sent 9677 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { 9678 jqXHR.setRequestHeader( "Content-Type", s.contentType ); 9679 } 9680 9681 // Set the Accepts header for the server, depending on the dataType 9682 jqXHR.setRequestHeader( 9683 "Accept", 9684 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? 9685 s.accepts[ s.dataTypes[ 0 ] ] + 9686 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : 9687 s.accepts[ "*" ] 9688 ); 9689 9690 // Check for headers option 9691 for ( i in s.headers ) { 9692 jqXHR.setRequestHeader( i, s.headers[ i ] ); 9693 } 9694 9695 // Allow custom headers/mimetypes and early abort 9696 if ( s.beforeSend && 9697 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { 9698 9699 // Abort if not done already and return 9700 return jqXHR.abort(); 9701 } 9702 9703 // aborting is no longer a cancellation 9704 strAbort = "abort"; 9705 9706 // Install callbacks on deferreds 9707 for ( i in { success: 1, error: 1, complete: 1 } ) { 9708 jqXHR[ i ]( s[ i ] ); 9709 } 9710 9711 // Get transport 9712 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); 9713 9714 // If no transport, we auto-abort 9715 if ( !transport ) { 9716 done( -1, "No Transport" ); 9717 } else { 9718 jqXHR.readyState = 1; 9719 9720 // Send global event 9721 if ( fireGlobals ) { 9722 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); 9723 } 9724 9725 // If request was aborted inside ajaxSend, stop there 9726 if ( state === 2 ) { 9727 return jqXHR; 9728 } 9729 9730 // Timeout 9731 if ( s.async && s.timeout > 0 ) { 9732 timeoutTimer = window.setTimeout( function() { 9733 jqXHR.abort( "timeout" ); 9734 }, s.timeout ); 9735 } 9736 9737 try { 9738 state = 1; 9739 transport.send( requestHeaders, done ); 9740 } catch ( e ) { 9741 9742 // Propagate exception as error if not done 9743 if ( state < 2 ) { 9744 done( -1, e ); 9745 9746 // Simply rethrow otherwise 9747 } else { 9748 throw e; 9749 } 9750 } 9751 } 9752 9753 // Callback for when everything is done 9754 function done( status, nativeStatusText, responses, headers ) { 9755 var isSuccess, success, error, response, modified, 9756 statusText = nativeStatusText; 9757 9758 // Called once 9759 if ( state === 2 ) { 9760 return; 9761 } 9762 9763 // State is "done" now 9764 state = 2; 9765 9766 // Clear timeout if it exists 9767 if ( timeoutTimer ) { 9768 window.clearTimeout( timeoutTimer ); 9769 } 9770 9771 // Dereference transport for early garbage collection 9772 // (no matter how long the jqXHR object will be used) 9773 transport = undefined; 9774 9775 // Cache response headers 9776 responseHeadersString = headers || ""; 9777 9778 // Set readyState 9779 jqXHR.readyState = status > 0 ? 4 : 0; 9780 9781 // Determine if successful 9782 isSuccess = status >= 200 && status < 300 || status === 304; 9783 9784 // Get response data 9785 if ( responses ) { 9786 response = ajaxHandleResponses( s, jqXHR, responses ); 9787 } 9788 9789 // Convert no matter what (that way responseXXX fields are always set) 9790 response = ajaxConvert( s, response, jqXHR, isSuccess ); 9791 9792 // If successful, handle type chaining 9793 if ( isSuccess ) { 9794 9795 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 9796 if ( s.ifModified ) { 9797 modified = jqXHR.getResponseHeader( "Last-Modified" ); 9798 if ( modified ) { 9799 jQuery.lastModified[ cacheURL ] = modified; 9800 } 9801 modified = jqXHR.getResponseHeader( "etag" ); 9802 if ( modified ) { 9803 jQuery.etag[ cacheURL ] = modified; 9804 } 9805 } 9806 9807 // if no content 9808 if ( status === 204 || s.type === "HEAD" ) { 9809 statusText = "nocontent"; 9810 9811 // if not modified 9812 } else if ( status === 304 ) { 9813 statusText = "notmodified"; 9814 9815 // If we have data, let's convert it 9816 } else { 9817 statusText = response.state; 9818 success = response.data; 9819 error = response.error; 9820 isSuccess = !error; 9821 } 9822 } else { 9823 9824 // We extract error from statusText 9825 // then normalize statusText and status for non-aborts 9826 error = statusText; 9827 if ( status || !statusText ) { 9828 statusText = "error"; 9829 if ( status < 0 ) { 9830 status = 0; 9831 } 9832 } 9833 } 9834 9835 // Set data for the fake xhr object 9836 jqXHR.status = status; 9837 jqXHR.statusText = ( nativeStatusText || statusText ) + ""; 9838 9839 // Success/Error 9840 if ( isSuccess ) { 9841 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); 9842 } else { 9843 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); 9844 } 9845 9846 // Status-dependent callbacks 9847 jqXHR.statusCode( statusCode ); 9848 statusCode = undefined; 9849 9850 if ( fireGlobals ) { 9851 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", 9852 [ jqXHR, s, isSuccess ? success : error ] ); 9853 } 9854 9855 // Complete 9856 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); 9857 9858 if ( fireGlobals ) { 9859 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); 9860 9861 // Handle the global AJAX counter 9862 if ( !( --jQuery.active ) ) { 9863 jQuery.event.trigger( "ajaxStop" ); 9864 } 9865 } 9866 } 9867 9868 return jqXHR; 9869 }, 9870 9871 getJSON: function( url, data, callback ) { 9872 return jQuery.get( url, data, callback, "json" ); 9873 }, 9874 9875 getScript: function( url, callback ) { 9876 return jQuery.get( url, undefined, callback, "script" ); 9877 } 9878} ); 9879 9880jQuery.each( [ "get", "post" ], function( i, method ) { 9881 jQuery[ method ] = function( url, data, callback, type ) { 9882 9883 // shift arguments if data argument was omitted 9884 if ( jQuery.isFunction( data ) ) { 9885 type = type || callback; 9886 callback = data; 9887 data = undefined; 9888 } 9889 9890 // The url can be an options object (which then must have .url) 9891 return jQuery.ajax( jQuery.extend( { 9892 url: url, 9893 type: method, 9894 dataType: type, 9895 data: data, 9896 success: callback 9897 }, jQuery.isPlainObject( url ) && url ) ); 9898 }; 9899} ); 9900 9901 9902jQuery._evalUrl = function( url ) { 9903 return jQuery.ajax( { 9904 url: url, 9905 9906 // Make this explicit, since user can override this through ajaxSetup (#11264) 9907 type: "GET", 9908 dataType: "script", 9909 cache: true, 9910 async: false, 9911 global: false, 9912 "throws": true 9913 } ); 9914}; 9915 9916 9917jQuery.fn.extend( { 9918 wrapAll: function( html ) { 9919 if ( jQuery.isFunction( html ) ) { 9920 return this.each( function( i ) { 9921 jQuery( this ).wrapAll( html.call( this, i ) ); 9922 } ); 9923 } 9924 9925 if ( this[ 0 ] ) { 9926 9927 // The elements to wrap the target around 9928 var wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); 9929 9930 if ( this[ 0 ].parentNode ) { 9931 wrap.insertBefore( this[ 0 ] ); 9932 } 9933 9934 wrap.map( function() { 9935 var elem = this; 9936 9937 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { 9938 elem = elem.firstChild; 9939 } 9940 9941 return elem; 9942 } ).append( this ); 9943 } 9944 9945 return this; 9946 }, 9947 9948 wrapInner: function( html ) { 9949 if ( jQuery.isFunction( html ) ) { 9950 return this.each( function( i ) { 9951 jQuery( this ).wrapInner( html.call( this, i ) ); 9952 } ); 9953 } 9954 9955 return this.each( function() { 9956 var self = jQuery( this ), 9957 contents = self.contents(); 9958 9959 if ( contents.length ) { 9960 contents.wrapAll( html ); 9961 9962 } else { 9963 self.append( html ); 9964 } 9965 } ); 9966 }, 9967 9968 wrap: function( html ) { 9969 var isFunction = jQuery.isFunction( html ); 9970 9971 return this.each( function( i ) { 9972 jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html ); 9973 } ); 9974 }, 9975 9976 unwrap: function() { 9977 return this.parent().each( function() { 9978 if ( !jQuery.nodeName( this, "body" ) ) { 9979 jQuery( this ).replaceWith( this.childNodes ); 9980 } 9981 } ).end(); 9982 } 9983} ); 9984 9985 9986function getDisplay( elem ) { 9987 return elem.style && elem.style.display || jQuery.css( elem, "dis
9987play" ); 9988} 9989 9990function filterHidden( elem ) { 9991 9992 // Disconnected elements are considered hidden 9993 if ( !jQuery.contains( elem.ownerDocument || document, elem ) ) { 9994 return true; 9995 } 9996 while ( elem && elem.nodeType === 1 ) { 9997 if ( getDisplay( elem ) === "none" || elem.type === "hidden" ) { 9998 return true; 9999 } 10000 elem = elem.parentNode; 10001 } 10002 return false; 10003} 10004 10005jQuery.expr.filters.hidden = function( elem ) { 10006 10007 // Support: Opera <= 12.12 10008 // Opera reports offsetWidths and offsetHeights less than zero on some elements 10009 return support.reliableHiddenOffsets() ? 10010 ( elem.offsetWidth <= 0 && elem.offsetHeight <= 0 && 10011 !elem.getClientRects().length ) : 10012 filterHidden( elem ); 10013}; 10014 10015jQuery.expr.filters.visible = function( elem ) { 10016 return !jQuery.expr.filters.hidden( elem ); 10017}; 10018 10019 10020 10021 10022var r20 = /%20/g, 10023 rbracket = /\[\]$/, 10024 rCRLF = /\r?\n/g, 10025 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, 10026 rsubmittable = /^(?:input|select|textarea|keygen)/i; 10027 10028function buildParams( prefix, obj, traditional, add ) { 10029 var name; 10030 10031 if ( jQuery.isArray( obj ) ) { 10032 10033 // Serialize array item. 10034 jQuery.each( obj, function( i, v ) { 10035 if ( traditional || rbracket.test( prefix ) ) { 10036 10037 // Treat each array item as a scalar. 10038 add( prefix, v ); 10039 10040 } else { 10041 10042 // Item is non-scalar (array or object), encode its numeric index. 10043 buildParams( 10044 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", 10045 v, 10046 traditional, 10047 add 10048 ); 10049 } 10050 } ); 10051 10052 } else if ( !traditional && jQuery.type( obj ) === "object" ) { 10053 10054 // Serialize object item. 10055 for ( name in obj ) { 10056 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); 10057 } 10058 10059 } else { 10060 10061 // Serialize scalar item. 10062 add( prefix, obj ); 10063 } 10064} 10065 10066// Serialize an array of form elements or a set of 10067// key/values into a query string 10068jQuery.param = function( a, traditional ) { 10069 var prefix, 10070 s = [], 10071 add = function( key, value ) { 10072 10073 // If value is a function, invoke it and return its value 10074 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); 10075 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); 10076 }; 10077 10078 // Set traditional to true for jQuery <= 1.3.2 behavior. 10079 if ( traditional === undefined ) { 10080 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; 10081 } 10082 10083 // If an array was passed in, assume that it is an array of form elements. 10084 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { 10085 10086 // Serialize the form elements 10087 jQuery.each( a, function() { 10088 add( this.name, this.value ); 10089 } ); 10090 10091 } else { 10092 10093 // If traditional, encode the "old" way (the way 1.3.2 or older 10094 // did it), otherwise encode params recursively. 10095 for ( prefix in a ) { 10096 buildParams( prefix, a[ prefix ], traditional, add ); 10097 } 10098 } 10099 10100 // Return the resulting serialization 10101 return s.join( "&" ).replace( r20, "+" ); 10102}; 10103 10104jQuery.fn.extend( { 10105 serialize: function() { 10106 return jQuery.param( this.serializeArray() ); 10107 }, 10108 serializeArray: function() { 10109 return this.map( function() { 10110 10111 // Can add propHook for "elements" to filter or add form elements 10112 var elements = jQuery.prop( this, "elements" ); 10113 return elements ? jQuery.makeArray( elements ) : this; 10114 } ) 10115 .filter( function() { 10116 var type = this.type; 10117 10118 // Use .is(":disabled") so that fieldset[disabled] works 10119 return this.name && !jQuery( this ).is( ":disabled" ) && 10120 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && 10121 ( this.checked || !rcheckableType.test( type ) ); 10122 } ) 10123 .map( function( i, elem ) { 10124 var val = jQuery( this ).val(); 10125 10126 return val == null ? 10127 null : 10128 jQuery.isArray( val ) ? 10129 jQuery.map( val, function( val ) { 10130 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 10131 } ) : 10132 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 10133 } ).get(); 10134 } 10135} ); 10136 10137 10138// Create the request object 10139// (This is still attached to ajaxSettings for backward compatibility) 10140jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ? 10141 10142 // Support: IE6-IE8 10143 function() { 10144 10145 // XHR cannot access local files, always use ActiveX for that case 10146 if ( this.isLocal ) { 10147 return createActiveXHR(); 10148 } 10149
10150 // Support: IE 9-11 10151 // IE seems to error on cross-domain PATCH requests when ActiveX XHR 10152 // is used. In IE 9+ always use the native XHR. 10153 // Note: this condition won't catch Edge as it doesn't define 10154 // document.documentMode but it also doesn't support ActiveX so it won't 10155 // reach this code. 10156 if ( document.documentMode > 8 ) { 10157 return createStandardXHR(); 10158 } 10159 10160 // Support: IE<9 10161 // oldIE XHR does not support non-RFC2616 methods (#13240) 10162 // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx 10163 // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9 10164 // Although this check for six methods instead of eight 10165 // since IE also does not support "trace" and "connect" 10166 return /^(get|post|head|put|delete|options)$/i.test( this.type ) && 10167 createStandardXHR() || createActiveXHR(); 10168 } : 10169 10170 // For all other browsers, use the standard XMLHttpRequest object 10171 createStandardXHR; 10172 10173var xhrId = 0, 10174 xhrCallbacks = {}, 10175 xhrSupported = jQuery.ajaxSettings.xhr(); 10176 10177// Support: IE<10 10178// Open requests must be manually aborted on unload (#5280) 10179// See https://support.microsoft.com/kb/2856746 for more info 10180if ( window.attachEvent ) { 10181 window.attachEvent( "onunload", function() { 10182 for ( var key in xhrCallbacks ) { 10183 xhrCallbacks[ key ]( undefined, true ); 10184 } 10185 } ); 10186} 10187 10188// Determine support properties 10189support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); 10190xhrSupported = support.ajax = !!xhrSupported; 10191 10192// Create transport if the browser can provide an xhr 10193if ( xhrSupported ) { 10194 10195 jQuery.ajaxTransport( function( options ) { 10196 10197 // Cross domain only allowed if supported through XMLHttpRequest 10198 if ( !options.crossDomain || support.cors ) { 10199 10200 var callback; 10201 10202 return { 10203 send: function( headers, complete ) { 10204 var i, 10205 xhr = options.xhr(), 10206 id = ++xhrId; 10207 10208 // Open the socket 10209 xhr.open( 10210 options.type, 10211 options.url, 10212 options.async, 10213 options.username, 10214 options.password 10215 ); 10216 10217 // Apply custom fields if provided 10218 if ( options.xhrFields ) { 10219 for ( i in options.xhrFields ) { 10220 xhr[ i ] = options.xhrFields[ i ]; 10221 } 10222 } 10223 10224 // Override mime type if needed 10225 if ( options.mimeType && xhr.overrideMimeType ) { 10226 xhr.overrideMimeType( options.mimeType ); 10227 } 10228 10229 // X-Requested-With header 10230 // For cross-domain requests, seeing as conditions for a preflight are 10231 // akin to a jigsaw puzzle, we simply never set it to be sure. 10232 // (it can always be set on a per-request basis or even using ajaxSetup)
10233 // For same-domain requests, won't change header if already provided. 10234 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { 10235 headers[ "X-Requested-With" ] = "XMLHttpRequest"; 10236 } 10237 10238 // Set headers 10239 for ( i in headers ) { 10240 10241 // Support: IE<9 10242 // IE's ActiveXObject throws a 'Type Mismatch' exception when setting 10243 // request header to a null-value. 10244 // 10245 // To keep consistent with other XHR implementations, cast the value 10246 // to string and ignore `undefined`. 10247 if ( headers[ i ] !== undefined ) { 10248 xhr.setRequestHeader( i, headers[ i ] + "" ); 10249 } 10250 } 10251 10252 // Do send the request 10253 // This may raise an exception which is actually 10254 // handled in jQuery.ajax (so no try/catch here) 10255 xhr.send( ( options.hasContent && options.data ) || null ); 10256 10257 // Listener 10258 callback = function( _, isAbort ) { 10259 var status, statusText, responses; 10260 10261 // Was never called and is aborted or complete 10262 if ( callback && ( isAbort || xhr.readyState === 4 ) ) { 10263 10264 // Clean up 10265 delete xhrCallbacks[ id ]; 10266 callback = undefined; 10267 xhr.onreadystatechange = jQuery.noop; 10268 10269 // Abort manually if needed 10270 if ( isAbort ) { 10271 if ( xhr.readyState !== 4 ) { 10272 xhr.abort(); 10273 } 10274 } else { 10275 responses = {}; 10276 status = xhr.status; 10277 10278 // Support: IE<10 10279 // Accessing binary-data responseText throws an exception 10280 // (#11426) 10281 if ( typeof xhr.responseText === "string" ) { 10282 responses.text = xhr.responseText; 10283 } 10284 10285 // Firefox throws an exception when accessing 10286 // statusText for faulty cross-domain requests 10287 try { 10288 statusText = xhr.statusText; 10289 } catch ( e ) { 10290 10291 // We normalize with Webkit giving an empty statusText 10292 statusText = ""; 10293 } 10294 10295 // Filter status for non standard behaviors 10296 10297 // If the request is local and we have data: assume a success 10298 // (success with no data won't get notified, that's the best we 10299 // can do given current implementations) 10300 if ( !status && options.isLocal && !options.crossDomain ) { 10301 status = responses.text ? 200 : 404; 10302 10303 // IE - #1450: sometimes returns 1223 when it should be 204 10304 } else if ( status === 1223 ) { 10305 status = 204; 10306 } 10307 } 10308 } 10309 10310 // Call complete if needed 10311 if ( responses ) { 10312 complete( status, statusText, responses, xhr.getAllResponseHeaders() ); 10313 } 10314 }; 10315 10316 // Do send the request 10317 // `xhr.send` may raise an exception, but it will be 10318 // handled in jQuery.ajax (so no try/catch here) 10319 if ( !options.async ) { 10320 10321 // If we're in sync mode we fire the callback 10322 callback(); 10323 } else if ( xhr.readyState === 4 ) { 10324 10325 // (IE6 & IE7) if it's in cache and has been 10326 // retrieved directly we need to fire the callback 10327 window.setTimeout( callback ); 10328 } else { 10329 10330 // Register the callback, but delay it in case `xhr.send` throws 10331 // Add to the list of active xhr callbacks 10332 xhr.onreadystatechange = xhrCallbacks[ id ] = callback; 10333 } 10334 }, 10335 10336 abort: function() { 10337 if ( callback ) { 10338 callback( undefined, true ); 10339 } 10340 } 10341 }; 10342 } 10343 } ); 10344} 10345 10346// Functions to create xhrs 10347function createStandardXHR() { 10348 try { 10349 return new window.XMLHttpRequest(); 10350 } catch ( e ) {} 10351} 10352 10353function createActiveXHR() { 10354 try { 10355 return new window.ActiveXObject( "Microsoft.XMLHTTP" ); 10356 } catch ( e ) {} 10357} 10358 10359 10360 10361 10362// Install script dataType 10363jQuery.ajaxSetup( { 10364 accepts: { 10365 script: "text/javascript, application/javascript, " + 10366 "application/ecmascript, application/x-ecmascript" 10367 }, 10368 contents: { 10369 script: /\b(?:java|ecma)script\b/ 10370 }, 10371 converters: { 10372 "text script": function( text ) { 10373 jQuery.globalEval( text ); 10374 return text; 10375 } 10376 } 10377} ); 10378 10379// Handle cache's special case and global 10380jQuery.ajaxPrefilter( "script", function( s ) { 10381 if ( s.cache === undefined ) { 10382 s.cache = false; 10383 } 10384 if ( s.crossDomain ) { 10385 s.type = "GET"; 10386 s.global = false;
10387 } 10388} ); 10389 10390// Bind script tag hack transport 10391jQuery.ajaxTransport( "script", function( s ) { 10392 10393 // This transport only deals with cross domain requests 10394 if ( s.crossDomain ) { 10395 10396 var script, 10397 head = document.head || jQuery( "head" )[ 0 ] || document.documentElement; 10398 10399 return { 10400 10401 send: function( _, callback ) { 10402 10403 script = document.createElement( "script" ); 10404 10405 script.async = true; 10406 10407 if ( s.scriptCharset ) { 10408 script.charset = s.scriptCharset; 10409 } 10410 10411 script.src = s.url; 10412 10413 // Attach handlers for all browsers 10414 script.onload = script.onreadystatechange = function( _, isAbort ) { 10415 10416 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { 10417 10418 // Handle memory leak in IE 10419 script.onload = script.onreadystatechange = null; 10420 10421 // Remove the script 10422 if ( script.parentNode ) { 10423 script.parentNode.removeChild( script ); 10424 } 10425 10426 // Dereference the script 10427 script = null; 10428 10429 // Callback if not abort 10430 if ( !isAbort ) { 10431 callback( 200, "success" ); 10432 } 10433 } 10434 }; 10435 10436 // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending 10437 // Use native DOM manipulation to avoid our domManip AJAX trickery 10438 head.insertBefore( script, head.firstChild ); 10439 }, 10440 10441 abort: function() { 10442 if ( script ) { 10443 script.onload( undefined, true ); 10444 } 10445 } 10446 }; 10447 } 10448} ); 10449 10450 10451 10452 10453var oldCallbacks = [], 10454 rjsonp = /(=)\?(?=&|$)|\?\?/; 10455 10456// Default jsonp settings 10457jQuery.ajaxSetup( { 10458 jsonp: "callback", 10459 jsonpCallback: function() { 10460 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); 10461 this[ callback ] = true; 10462 return callback; 10463 } 10464} ); 10465 10466// Detect, normalize options and install callbacks for jsonp requests 10467jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 10468 10469 var callbackName, overwritten, responseContainer, 10470 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? 10471 "url" : 10472 typeof s.data === "string" && 10473 ( s.contentType || "" ) 10474 .indexOf( "application/x-www-form-urlencoded" ) === 0 && 10475 rjsonp.test( s.data ) && "data" 10476 ); 10477 10478 // Handle iff the expected data type is "jsonp" or we have a parameter to set 10479 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { 10480 10481 // Get callback name, remembering preexisting value associated with it 10482 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? 10483 s.jsonpCallback() : 10484 s.jsonpCallback; 10485 10486 // Insert callback into url or form data 10487 if ( jsonProp ) { 10488 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); 10489 } else if ( s.jsonp !== false ) { 10490 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; 10491 } 10492 10493 // Use data converter to retrieve json after script execution 10494 s.converters[ "script json" ] = function() { 10495 if ( !responseContainer ) { 10496 jQuery.error( callbackName + " was not called" ); 10497 } 10498 return responseContainer[ 0 ]; 10499 }; 10500 10501 // force json dataType 10502 s.dataTypes[ 0 ] = "json"; 10503 10504 // Install callback 10505 overwritten = window[ callbackName ]; 10506 window[ callbackName ] = function() { 10507 responseContainer = arguments; 10508 }; 10509 10510 // Clean-up function (fires after converters) 10511 jqXHR.always( function() { 10512 10513 // If previous value didn't exist - remove it 10514 if ( overwritten === undefined ) { 10515 jQuery( window ).removeProp( callbackName ); 10516 10517 // Otherwise restore preexisting value 10518 } else { 10519 window[ callbackName ] = overwritten; 10520 } 10521 10522 // Save back as free 10523 if ( s[ callbackName ] ) { 10524 10525 // make sure that re-using the options doesn't screw things around 10526 s.jsonpCallback = originalSettings.jsonpCallback; 10527 10528 // save the callback name for future use 10529 oldCallbacks.push( callbackName ); 10530 } 10531 10532 // Call if it was a function and we have a response 10533 if ( responseContainer && jQuery.isFunction( overwritten ) ) { 10534 overwritten( responseContainer[ 0 ] ); 10535 } 10536 10537 responseContainer = overwritten = undefined; 10538 } ); 10539 10540 // Delegate to script 10541 return "script"; 10542 } 10543} ); 10544 10545 10546 10547 10548// data: string of html 10549// context (optional): If specified, the fragment will be created in this context, 10550// defaults to document 10551// keepScripts (optional): If true, will include scripts passed in the html string 10552jQuery.parseHTML = function( data, context, keepScripts ) { 10553 if ( !data || typeof data !== "string" ) { 10554 return null; 10555 } 10556 if ( typeof context === "boolean" ) { 10557 keepScripts = context; 10558 context = false;
10559 } 10560 context = context || document; 10561 10562 var parsed = rsingleTag.exec( data ), 10563 scripts = !keepScripts && []; 10564 10565 // Single tag 10566 if ( parsed ) { 10567 return [ context.createElement( parsed[ 1 ] ) ]; 10568 } 10569 10570 parsed = buildFragment( [ data ], context, scripts ); 10571 10572 if ( scripts && scripts.length ) { 10573 jQuery( scripts ).remove(); 10574 } 10575 10576 return jQuery.merge( [], parsed.childNodes ); 10577}; 10578 10579 10580// Keep a copy of the old load method 10581var _load = jQuery.fn.load; 10582 10583/** 10584 * Load a url into a page 10585 */ 10586jQuery.fn.load = function( url, params, callback ) { 10587 if ( typeof url !== "string" && _load ) { 10588 return _load.apply( this, arguments ); 10589 } 10590 10591 var selector, type, response, 10592 self = this, 10593 off = url.indexOf( " " ); 10594 10595 if ( off > -1 ) { 10596 selector = jQuery.trim( url.slice( off, url.length ) ); 10597 url = url.slice( 0, off ); 10598 } 10599 10600 // If it's a function 10601 if ( jQuery.isFunction( params ) ) { 10602 10603 // We assume that it's the callback 10604 callback = params; 10605 params = undefined; 10606 10607 // Otherwise, build a param string 10608 } else if ( params && typeof params === "object" ) { 10609 type = "POST"; 10610 } 10611 10612 // If we have elements to modify, make the request 10613 if ( self.length > 0 ) { 10614 jQuery.ajax( { 10615 url: url, 10616 10617 // If "type" variable is undefined, then "GET" method will be used. 10618 // Make value of this field explicit since 10619 // user can override it through ajaxSetup method 10620 type: type || "GET", 10621 dataType: "html", 10622 data: params 10623 } ).done( function( responseText ) { 10624 10625 // Save response for use in complete callback 10626 response = arguments; 10627 10628 self.html( selector ? 10629 10630 // If a selector was specified, locate the right elements in a dummy div 10631 // Exclude scripts to avoid IE 'Permission Denied' errors 10632 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : 10633 10634 // Otherwise use the full result 10635 responseText ); 10636 10637 // If the request succeeds, this function gets "data", "status", "jqXHR" 10638 // but they are ignored because response was set above. 10639 // If it fails, this function gets "jqXHR", "status", "error" 10640 } ).always( callback && function( jqXHR, status ) { 10641 self.each( function() { 10642 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] ); 10643 } ); 10644 } ); 10645 } 10646 10647 return this; 10648}; 10649 10650 10651 10652 10653// Attach a bunch of functions for handling common AJAX events 10654jQuery.each( [ 10655 "ajaxStart", 10656 "ajaxStop", 10657 "ajaxComplete", 10658 "ajaxError", 10659 "ajaxSuccess", 10660 "ajaxSend" 10661], function( i, type ) { 10662 jQuery.fn[ type ] = function( fn ) { 10663 return this.on( type, fn ); 10664 }; 10665} ); 10666 10667 10668 10669 10670jQuery.expr.filters.animated = function( elem ) { 10671 return jQuery.grep( jQuery.timers, function( fn ) { 10672 return elem === fn.elem; 10673 } ).length; 10674}; 10675 10676 10677 10678 10679 10680/** 10681 * Gets a window from an element 10682 */ 10683function getWindow( elem ) { 10684 return jQuery.isWindow( elem ) ? 10685 elem : 10686 elem.nodeType === 9 ? 10687 elem.defaultView || elem.parentWindow : 10688 false; 10689} 10690 10691jQuery.offset = { 10692 setOffset: function( elem, options, i ) { 10693 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, 10694 position = jQuery.css( elem, "position" ), 10695 curElem = jQuery( elem ), 10696 props = {}; 10697 10698 // set position first, in-case top/left are set even on static elem 10699 if ( position === "static" ) { 10700 elem.style.position = "relative"; 10701 } 10702 10703 curOffset = curElem.offset(); 10704 curCSSTop = jQuery.css( elem, "top" ); 10705 curCSSLeft = jQuery.css( elem, "left" ); 10706 calculatePosition = ( position === "absolute" || position === "fixed" ) && 10707 jQuery.inArray( "auto", [ curCSSTop, curCSSLeft ] ) > -1; 10708 10709 // need to be able to calculate position if either top or left 10710 // is auto and position is either absolute or fixed 10711 if ( calculatePosition ) { 10712 curPosition = curElem.position(); 10713 curTop = curPosition.top; 10714 curLeft = curPosition.left; 10715 } else { 10716 curTop = parseFloat( curCSSTop ) || 0; 10717 curLeft = parseFloat( curCSSLeft ) || 0; 10718 } 10719 10720 if ( jQuery.isFunction( options ) ) { 10721 10722 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) 10723 options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); 10724 } 10725 10726 if ( options.top != null ) { 10727 props.top = ( options.top - curOffset.top ) + curTop; 10728 } 10729 if ( options.left != null ) { 10730 props.left = ( options.left - curOffset.left ) + curLeft; 10731 } 10732 10733 if ( "using" in options ) { 10734 options.using.call( elem, props ); 10735 } else { 10736 curElem.css( props ); 10737 } 10738 } 10739}; 10740 10741jQuery.fn.extend( { 10742 offset: function( options ) { 10743 if ( arguments.length ) { 10744 return options === undefined ? 10745 this : 10746 this.each( function( i ) { 10747 jQuery.offset.setOffset( this, options, i ); 10748 } ); 10749 } 10750 10751 var docElem, win, 10752 box = { top: 0, left: 0 }, 10753 elem = this[ 0 ], 10754 doc = elem && elem.ownerDocument; 10755 10756 if ( !doc ) { 10757 return; 10758 } 10759 10760 docElem = doc.documentElement; 10761 10762 // Make sure it's not a disconnected DOM node 10763 if ( !jQuery.contains( docElem, elem ) ) { 10764 return box; 10765 } 10766 10767 // If we don't have gBCR, just use 0,0 rather than error 10768 // BlackBerry 5, iOS 3 (original iPhone) 10769 if ( typeof elem.getBoundingClientRect !== "undefined" ) { 10770 box = elem.getBoundingClientRect(); 10771 } 10772 win = getWindow( doc ); 10773 return { 10774 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ), 10775 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 ) 10776 }; 10777 }, 10778 10779 position: function() { 10780 if ( !this[ 0 ] ) { 10781 return; 10782 } 10783 10784 var offsetParent, offset, 10785 parentOffset = { top: 0, left: 0 }, 10786 elem = this[ 0 ]; 10787 10788 // Fixed elements are offset from window (parentOffset = {top:0, left
10788: 0}, 10789 // because it is its only offset parent 10790 if ( jQuery.css( elem, "position" ) === "fixed" ) { 10791 10792 // we assume that getBoundingClientRect is available when computed position is fixed 10793 offset = elem.getBoundingClientRect(); 10794 } else { 10795 10796 // Get *real* offsetParent 10797 offsetParent = this.offsetParent(); 10798 10799 // Get correct offsets 10800 offset = this.offset(); 10801 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { 10802 parentOffset = offsetParent.offset(); 10803 } 10804 10805 // Add offsetParent borders 10806 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ); 10807 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ); 10808 } 10809 10810 // Subtract parent offsets and element margins 10811 // note: when an element has margin: auto the offsetLeft and marginLeft 10812 // are the same in Safari causing offset.left to incorrectly be 0 10813 return { 10814 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), 10815 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) 10816 }; 10817 }, 10818 10819 offsetParent: function() { 10820 return this.map( function() { 10821 var offsetParent = this.offsetParent; 10822 10823 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && 10824 jQuery.css( offsetParent, "position" ) === "static" ) ) { 10825 offsetParent = offsetParent.offsetParent; 10826 } 10827 return offsetParent || documentElement; 10828 } ); 10829 } 10830} ); 10831 10832// Create scrollLeft and scrollTop methods 10833jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { 10834 var top = /Y/.test( prop ); 10835 10836 jQuery.fn[ method ] = function( val ) { 10837 return access( this, function( elem, method, val ) { 10838 var win = getWindow( elem ); 10839 10840 if ( val === undefined ) { 10841 return win ? ( prop in win ) ? win[ prop ] : 10842 win.document.documentElement[ method ] : 10843 elem[ method ]; 10844 } 10845 10846 if ( win ) { 10847 win.scrollTo( 10848 !top ? val : jQuery( win ).scrollLeft(), 10849 top ? val : jQuery( win ).scrollTop() 10850 ); 10851 10852 } else { 10853 elem[ method ] = val; 10854 } 10855 }, method, val, arguments.length, null ); 10856 }; 10857} ); 10858 10859// Support: Safari<7-8+, Chrome<37-44+ 10860// Add the top/left cssHooks using jQuery.fn.position 10861// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 10862// getComputedStyle returns percent when specified for top/left/bottom/right 10863// rather than make the css module depend on the offset module, we just check for it here 10864jQuery.each( [ "top", "left" ], function( i, prop ) { 10865 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, 10866 function( elem, computed ) { 10867 if ( computed ) { 10868 computed = curCSS( elem, prop ); 10869 10870 // if curCSS returns percentage, fallback to offset 10871 return rnumnonpx.test( computed ) ? 10872 jQuery( elem ).position()[ prop ] + "px" : 10873 computed; 10874 } 10875 } 10876 ); 10877} ); 10878 10879 10880// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods 10881jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { 10882 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, 10883 function( defaultExtra, funcName ) { 10884 10885 // margin is only for outerHeight, outerWidth 10886 jQuery.fn[ funcName ] = function( margin, value ) { 10887 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), 10888 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); 10889 10890 return access( this, function( elem, type, value ) { 10891 var doc; 10892 10893 if ( jQuery.isWindow( elem ) ) { 10894 10895 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there 10896 // isn't a whole lot we can do. See pull request at this URL for discussion: 10897 // https://github.com/jquery/jquery/pull/764 10898 return elem.document.documentElement[ "client" + name ]; 10899 } 10900 10901 // Get document width or height 10902 if ( elem.nodeType === 9 ) { 10903 doc = elem.documentElement; 10904 10905 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], 10906 // whichever is greatest 10907 // unfortunately, this causes bug #3838 in IE6/8 only, 10908 // but there is currently no good, small way to fix it. 10909 return Math.max( 10910 elem.body[ "scroll" + name ], doc[ "scroll" + name ], 10911 elem.body[ "offset" + name ], doc[ "offset" + name ], 10912 doc[ "client" + name ] 10913 ); 10914 } 10915 10916 return value === undefined ? 10917 10918 // Get width or height on the element, requesting but not forcing parseFloat 10919 jQuery.css( elem, type, extra ) : 10920 10921 // Set width or height on the element 10922 jQuery.style( elem, type, value, extra ); 10923 }, type, chainable ? margin : undefined, chainable, null ); 10924 }; 10925 } ); 10926} ); 10927 10928 10929jQuery.fn.extend( { 10930 10931 bind: function( types, data, fn ) { 10932 return this.on( types, null, data, fn ); 10933 }, 10934 unbind: function( types, fn ) { 10935 return this.off( types, null, fn ); 10936 }, 10937 10938 delegate: function( selector, types, data, fn ) { 10939 return this.on( types, selector, data, fn ); 10940 }, 10941 undelegate: function( selector, types, fn ) { 10942 10943 // ( namespace ) or ( selector, types [, fn] ) 10944 return arguments.length === 1 ? 10945 this.off( selector, "**" ) : 10946 this.off( types, selector || "**", fn ); 10947 } 10948} ); 10949 10950// The number of elements contained in the matched element set 10951jQuery.fn.size = function() { 10952 return this.length; 10953}; 10954 10955jQuery.fn.andSelf = jQuery.fn.addBack; 10956 10957 10958 10959 10960// Register as a named AMD module, since jQuery can be concatenated with other 10961// files that may use define, but not via a proper concatenation script that 10962// understands anonymous AMD modules. A named AMD is safest and most robust 10963// way to register. Lowercase jquery is used because AMD module names are 10964// derived from file names, and jQuery is normally delivered in a lowercase 10965// file name. Do this after creating the global so that if an AMD module wants 10966// to call noConflict to hide this version of jQuery, it will work. 10967 10968// Note that for maximum portability, libraries that are not jQuery should 10969// declare themselves as anonymous modules, and avoid setting a global if an 10970// AMD loader is present. jQuery is a special case. For more information, see
10971// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon 10972 10973if ( typeof define === "function" && define.amd ) { 10974 define( "jquery", [], function() { 10975 return jQuery; 10976 } ); 10977} 10978 10979 10980 10981var 10982 10983 // Map over jQuery in case of overwrite 10984 _jQuery = window.jQuery, 10985 10986 // Map over the $ in case of overwrite 10987 _$ = window.$; 10988 10989jQuery.noConflict = function( deep ) { 10990 if ( window.$ === jQuery ) { 10991 window.$ = _$; 10992 } 10993 10994 if ( deep && window.jQuery === jQuery ) { 10995 window.jQuery = _jQuery; 10996 } 10997 10998 return jQuery; 10999}; 11000 11001// Expose jQuery and $ identifiers, even in 11002// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557) 11003// and CommonJS for browser emulators (#13566) 11004if ( !noGlobal ) { 11005 window.jQuery = window.$ = jQuery; 11006} 11007 11008return jQuery; 11009})); 11010(function($, undefined) { 11011 11012/** 11013 * Unobtrusive scripting adapter for jQuery 11014 * https://github.com/rails/jquery-ujs 11015 * 11016 * Requires jQuery 1.8.0 or later. 11017 * 11018 * Released under the MIT license 11019 * 11020 */ 11021 11022 // Cut down on the number of issues from people inadvertently including jquery_ujs twice 11023 // by detecting and raising an error when it happens. 11024 'use strict'; 11025 11026 if ( $.rails !== undefined ) { 11027 $.error('jquery-ujs has already been loaded!'); 11028 } 11029 11030 // Shorthand to make it a little easier to call public rails functions from within rails.js 11031 var rails; 11032 var $document = $(document); 11033 11034 $.rails = rails = { 11035 // Link elements bound by jquery-ujs 11036 linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]', 11037 11038 // Button elements bound by jquery-ujs 11039 buttonClickSelector: 'button[data-remote]:not([form]):not(form button), button[data-confirm]:not([form]):not(form button)', 11040 11041 // Select elements bound by jquery-ujs 11042 inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]', 11043 11044 // Form elements bound by jquery-ujs 11045 formSubmitSelector: 'form', 11046 11047 // Form input elements bound by jquery-ujs 11048 formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])', 11049 11050 // Form input elements disabled during form submission 11051 disableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled', 11052 11053 // Form input elements re-enabled after form submission 11054 enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled', 11055 11056 // Form required input elements 11057 requiredInputSelector: 'input[name][required]:not([disabled]), textarea[name][required]:not([disabled])', 11058 11059 // Form file input elements 11060 fileInputSelector: 'input[name][type=file]:not([disabled])', 11061 11062 // Link onClick disable selector with possible reenable after remote submission 11063 linkDisableSelector: 'a[data-disable-with], a[data-disable]', 11064 11065 // Button onClick disable selector with possible reenable after remote submission 11066 buttonDisableSelector: 'button[data-remote][data-disable-with], button[data-remote][data-disable]', 11067 11068 // Up-to-date Cross-Site Request Forgery token 11069 csrfToken: function() { 11070 return $('meta[name=csrf-token]').attr('content'); 11071 }, 11072 11073 // URL param that must contain the CSRF token 11074 csrfParam: function() { 11075 return $('meta[name=csrf-param]').attr('content'); 11076 }, 11077 11078 // Make sure that every Ajax request sends the CSRF token 11079 CSRFProtection: function(xhr) { 11080 var token = rails.csrfToken(); 11081 if (token) xhr.setRequestHeader('X-CSRF-Token', token); 11082 }, 11083 11084 // Make sure that all forms have actual up-to-date tokens (cached forms contain old ones) 11085 refreshCSRFTokens: function(){ 11086 $('form input[name="' + rails.csrfParam() + '"]').val(rails.csrfToken()); 11087 }, 11088 11089 // Triggers an event on an element and returns false if the event result is false 11090 fire: function(obj, name, data) { 11091 var event = $.Event(name); 11092 obj.trigger(event, data); 11093 return event.result !== false; 11094 }, 11095 11096 // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm 11097 confirm: function(message) { 11098 return confirm(message); 11099 }, 11100 11101 // Default ajax function, may be overridden with custom function in $.rails.ajax 11102 ajax: function(options) { 11103 return $.ajax(options); 11104 }, 11105 11106 // Default way to get an element's href. May be overridden at $.rails.href. 11107 href: function(element) { 11108 return element[0].href; 11109 }, 11110 11111 // Checks "data-remote" if true to handle the request through a XHR request. 11112 isRemote: function(element) { 11113 return element.data('remote') !== undefined && element.data('remote') !== false; 11114 }, 11115 11116 // Submits "remote" forms and links with ajax 11117 handleRemote: function(element) { 11118 var method, url, data, withCredentials, dataType, options; 11119 11120 if (rails.fire(element, 'ajax:before')) { 11121 withCredentials = element.data('with-credentials') || null; 11122 dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType); 11123 11124 if (element.is('form')) { 11125 method = element.data('ujs:submit-button-formmethod') || element.attr('method'); 11126 url = element.data('ujs:submit-button-formaction') || element.attr('action'); 11127 data = $(element[0]).serializeArray(); 11128 // memoized value from clicked submit button 11129 var button = element.data('ujs:submit-button'); 11130 if (button) { 11131 data.push(button); 11132 element.data('ujs:submit-button', null); 11133 } 11134 element.data('ujs:submit-button-formmethod', null); 11135 element.data('ujs:submit-button-formaction', null); 11136 } else if (element.is(rails.inputChangeSelector)) { 11137 method = element.data('method'); 11138 url = element.data('url'); 11139 data = element.serialize(); 11140 if (element.data('params')) data = data + '&' + element.data('params'); 11141 } else if (element.is(rails.buttonClickSelector)) { 11142 method = element.data('method') || 'get'; 11143 url = element.data('url'); 11144 data = element.serialize(); 11145 if (element.data('params')) data = data + '&' + element.data('params'); 11146 } else { 11147 method = element.data('method'); 11148 url = rails.href(element); 11149 data = element.data('params') || null; 11150 } 11151 11152 options = { 11153 type: method || 'GET', data: data, dataType: dataType, 11154 // stopping the "ajax:beforeSend" event will cancel the ajax request 11155 beforeSend: function(xhr, settings) { 11156 if (settings.dataType === undefined) { 11157 xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script); 11158 } 11159 if (rails.fire(element, 'ajax:beforeSend', [xhr, settings])) {
11160 element.trigger('ajax:send', xhr); 11161 } else { 11162 return false; 11163 } 11164 }, 11165 success: function(data, status, xhr) { 11166 element.trigger('ajax:success', [data, status, xhr]); 11167 }, 11168 complete: function(xhr, status) { 11169 element.trigger('ajax:complete', [xhr, status]); 11170 }, 11171 error: function(xhr, status, error) { 11172 element.trigger('ajax:error', [xhr, status, error]); 11173 }, 11174 crossDomain: rails.isCrossDomain(url) 11175 }; 11176 11177 // There is no withCredentials for IE6-8 when 11178 // "Enable native XMLHTTP support" is disabled 11179 if (withCredentials) { 11180 options.xhrFields = { 11181 withCredentials: withCredentials 11182 }; 11183 } 11184 11185 // Only pass url to `ajax` options if not blank 11186 if (url) { options.url = url; } 11187 11188 return rails.ajax(options); 11189 } else { 11190 return false; 11191 } 11192 }, 11193 11194 // Determines if the request is a cross domain request. 11195 isCrossDomain: function(url) { 11196 var originAnchor = document.createElement('a'); 11197 originAnchor.href = location.href; 11198 var urlAnchor = document.createElement('a'); 11199 11200 try { 11201 urlAnchor.href = url; 11202 // This is a workaround to a IE bug. 11203 urlAnchor.href = urlAnchor.href; 11204 11205 // If URL protocol is false or is a string containing a single colon 11206 // *and* host are false, assume it is not a cross-domain request 11207 // (should only be the case for IE7 and IE compatibility mode). 11208 // Otherwise, evaluate protocol and host of the URL against the origin 11209 // protocol and host. 11210 return !(((!urlAnchor.protocol || urlAnchor.protocol === ':') && !urlAnchor.host) || 11211 (originAnchor.protocol + '//' + originAnchor.host === 11212 urlAnchor.protocol + '//' + urlAnchor.host)); 11213 } catch (e) { 11214 // If there is an error parsing the URL, assume it is crossDomain. 11215 return true; 11216 } 11217 }, 11218 11219 // Handles "data-method" on links such as: 11220 // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a> 11221 handleMethod: function(link) { 11222 var href = rails.href(link), 11223 method = link.data('method'), 11224 target = link.attr('target'), 11225 csrfToken = rails.csrfToken(), 11226 csrfParam = rails.csrfParam(), 11227 form = $('<form method="post" action="' + href + '"></form>'), 11228 metadataInput = '<input name="_method" value="' + method + '" type="hidden" />'; 11229 11230 if (csrfParam !== undefined && csrfToken !== undefined && !rails.isCrossDomain(href)) { 11231 metadataInput += '<input name="' + csrfParam + '" value="' + csrfToken + '" type="hidden" />'; 11232 } 11233 11234 if (target) { form.attr('target', target); } 11235 11236 form.hide().append(metadataInput).appendTo('body'); 11237 form.submit(); 11238 }, 11239 11240 // Helper function that returns form elements that match the specified CSS selector 11241 // If form is actually a "form" element this will return associated elements outside the from that have 11242 // the html form attribute set 11243 formElements: function(form, selector) { 11244 return form.is('form') ? $(form[0].elements).filter(selector) : form.find(selector); 11245 }, 11246 11247 /* Disables form elements: 11248 - Caches element value in 'ujs:enable-with' data store 11249 - Replaces element text with value of 'data-disable-with' attribute 11250 - Sets disabled property to true 11251 */ 11252 disableFormElements: function(form) { 11253 rails.formElements(form, rails.disableSelector).each(function() { 11254 rails.disableFormElement($(this)); 11255 }); 11256 }, 11257 11258 disableFormElement: function(element) { 11259 var method, replacement; 11260 11261 method = element.is('button') ? 'html' : 'val'; 11262 replacement = element.data('disable-with'); 11263 11264 if (replacement !== undefined) { 11265 element.data('ujs:enable-with', element[method]()); 11266 element[method](replacement); 11267 } 11268 11269 element.prop('disabled', true); 11270 element.data('ujs:disabled', true); 11271 }, 11272 11273 /* Re-enables disabled form elements: 11274 - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`) 11275 - Sets disabled property to false 11276 */ 11277 enableFormElements: function(form) { 11278 rails.formElements(form, rails.enableSelector).each(function() { 11279 rails.enableFormElement($(this)); 11280 }); 11281 }, 11282 11283 enableFormElement: function(element) { 11284 var method = element.is('button') ? 'html' : 'val'; 11285 if (element.data('ujs:enable-with') !== undefined) { 11286 element[method](element.data('ujs:enable-with')); 11287 element.removeData('ujs:enable-with'); // clean up cache 11288 } 11289 element.prop('disabled', false); 11290 element.removeData('ujs:disabled'); 11291 }, 11292 11293 /* For 'data-confirm' attribute: 11294 - Fires `confirm` event 11295 - Shows the confirmation dialog 11296 - Fires the `confirm:complete` event 11297 11298 Returns `true` if no function stops the chain and user chose yes; `false` otherwise. 11299 Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog. 11300 Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
11301 return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog. 11302 */ 11303 allowAction: function(element) { 11304 var message = element.data('confirm'), 11305 answer = false, callback; 11306 if (!message) { return true; } 11307 11308 if (rails.fire(element, 'confirm')) { 11309 try { 11310 answer = rails.confirm(message); 11311 } catch (e) { 11312 (console.error || console.log).call(console, e.stack || e); 11313 } 11314 callback = rails.fire(element, 'confirm:complete', [answer]); 11315 } 11316 return answer && callback; 11317 }, 11318 11319 // Helper function which checks for blank inputs in a form that match the specified CSS selector 11320 blankInputs: function(form, specifiedSelector, nonBlank) { 11321 var foundInputs = $(), 11322 input, 11323 valueToCheck, 11324 radiosForNameWithNoneSelected, 11325 radioName, 11326 selector = specifiedSelector || 'input,textarea', 11327 requiredInputs = form.find(selector), 11328 checkedRadioButtonNames = {}; 11329 11330 requiredInputs.each(function() { 11331 input = $(this); 11332 if (input.is('input[type=radio]')) { 11333 11334 // Don't count unchecked required radio as blank if other radio with same name is checked, 11335 // regardless of whether same-name radio input has required attribute or not. The spec 11336 // states https://www.w3.org/TR/html5/forms.html#the-required-attribute 11337 radioName = input.attr('name'); 11338 11339 // Skip if we've already seen the radio with this name. 11340 if (!checkedRadioButtonNames[radioName]) { 11341 11342 // If none checked 11343 if (form.find('input[type=radio]:checked[name="' + radioName + '"]').length === 0) { 11344 radiosForNameWithNoneSelected = form.find( 11345 'input[type=radio][name="' + radioName + '"]'); 11346 foundInputs = foundInputs.add(radiosForNameWithNoneSelected); 11347 } 11348 11349 // We only need to check each name once. 11350 checkedRadioButtonNames[radioName] = radioName; 11351 } 11352 } else { 11353 valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : !!input.val(); 11354 if (valueToCheck === nonBlank) { 11355 foundInputs = foundInputs.add(input); 11356 } 11357 } 11358 }); 11359 return foundInputs.length ? foundInputs : false; 11360 }, 11361 11362 // Helper function which checks for non-blank inputs in a form that match the specified CSS selector 11363 nonBlankInputs: function(form, specifiedSelector) { 11364 return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank 11365 }, 11366 11367 // Helper function, needed to provide consistent behavior in IE 11368 stopEverything: function(e) { 11369 $(e.target).trigger('ujs:everythingStopped'); 11370 e.stopImmediatePropagation(); 11371 return false; 11372 }, 11373 11374 // Replace element's html with the 'data-disable-with' after storing original html 11375 // and prevent clicking on it 11376 disableElement: function(element) { 11377 var replacement = element.data('disable-with'); 11378 11379 if (replacement !== undefined) { 11380 element.data('ujs:enable-with', element.html()); // store enabled state 11381 element.html(replacement); 11382 } 11383 11384 element.bind('click.railsDisable', function(e) { // prevent further clicking 11385 return rails.stopEverything(e); 11386 }); 11387 element.data('ujs:disabled', true); 11388 }, 11389 11390 // Restore element to its original state which was disabled by 'disableElement' above 11391 enableElement: function(element) { 11392 if (element.data('ujs:enable-with') !== undefined) { 11393 element.html(element.data('ujs:enable-with')); // set to old enabled state 11394 element.removeData('ujs:enable-with'); // clean up cache 11395 } 11396 element.unbind('click.railsDisable'); // enable element 11397 element.removeData('ujs:disabled'); 11398 } 11399 }; 11400 11401 if (rails.fire($document, 'rails:attachBindings')) { 11402 11403 $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }}); 11404 11405 // This event works the same as the load event, except that it fires every 11406 // time the page is loaded. 11407 // 11408 // See https://github.com/rails/jquery-ujs/issues/357 11409 // See https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching 11410 $(window).on('pageshow.rails', function () { 11411 $($.rails.enableSelector).each(function () { 11412 var element = $(this); 11413 11414 if (element.data('ujs:disabled')) { 11415 $.rails.enableFormElement(element); 11416 } 11417 }); 11418 11419 $($.rails.linkDisableSelector).each(function () { 11420 var element = $(this); 11421 11422 if (element.data('ujs:disabled')) { 11423 $.rails.enableElement(element); 11424 } 11425 }); 11426 }); 11427 11428 $document.on('ajax:complete', rails.linkDisableSelector, function() { 11429 rails.enableElement($(this)); 11430 }); 11431 11432 $document.on('ajax:complete', rails.buttonDisableSelector, function() { 11433 rails.enableFormElement($(this)); 11434 }); 11435 11436 $document.on('click.rails', rails.linkClickSelector, function(e) { 11437 var link = $(this), method = link.data('method'), data = link.data('params'), metaClick = e.metaKey || e.ctrlKey; 11438 if (!rails.allowAction(link)) return rails.stopEverything(e); 11439 11440 if (!metaClick && link.is(rails.linkDisableSelector)) rails.disableElement(link); 11441 11442 if (rails.isRemote(link)) { 11443 if (metaClick && (!method || method === 'GET') && !data) { return true; } 11444 11445 var handleRemote = rails.handleRemote(link); 11446 // Response from rails.handleRemote() will either be false or a deferred object promise. 11447 if (handleRemote === false) { 11448 rails.enableElement(link); 11449 } else { 11450 handleRemote.fail( function() { rails.enableElement(link); } ); 11451 } 11452 return false;
11453 11454 } else if (method) { 11455 rails.handleMethod(link); 11456 return false; 11457 } 11458 }); 11459 11460 $document.on('click.rails', rails.buttonClickSelector, function(e) { 11461 var button = $(this); 11462 11463 if (!rails.allowAction(button) || !rails.isRemote(button)) return rails.stopEverything(e); 11464 11465 if (button.is(rails.buttonDisableSelector)) rails.disableFormElement(button); 11466 11467 var handleRemote = rails.handleRemote(button); 11468 // Response from rails.handleRemote() will either be false or a deferred object promise. 11469 if (handleRemote === false) { 11470 rails.enableFormElement(button); 11471 } else { 11472 handleRemote.fail( function() { rails.enableFormElement(button); } ); 11473 } 11474 return false; 11475 }); 11476 11477 $document.on('change.rails', rails.inputChangeSelector, function(e) { 11478 var link = $(this); 11479 if (!rails.allowAction(link) || !rails.isRemote(link)) return rails.stopEverything(e); 11480 11481 rails.handleRemote(link); 11482 return false; 11483 }); 11484 11485 $document.on('submit.rails', rails.formSubmitSelector, function(e) { 11486 var form = $(this), 11487 remote = rails.isRemote(form), 11488 blankRequiredInputs, 11489 nonBlankFileInputs; 11490 11491 if (!rails.allowAction(form)) return rails.stopEverything(e); 11492 11493 // Skip other logic when required values are missing or file upload is present 11494 if (form.attr('novalidate') === undefined) { 11495 if (form.data('ujs:formnovalidate-button') === undefined) { 11496 blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector, false); 11497 if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) { 11498 return rails.stopEverything(e); 11499 } 11500 } else { 11501 // Clear the formnovalidate in case the next button click is not on a formnovalidate button 11502 // Not strictly necessary to do here, since it is also reset on each button click, but just to be certain 11503 form.data('ujs:formnovalidate-button', undefined); 11504 } 11505 } 11506 11507 if (remote) { 11508 nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector); 11509 if (nonBlankFileInputs) { 11510 // Slight timeout so that the submit button gets properly serialized 11511 // (make it easy for event handler to serialize form without disabled values) 11512 setTimeout(function(){ rails.disableFormElements(form); }, 13); 11513 var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]); 11514 11515 // Re-enable form elements if event bindings return false (canceling normal form submission) 11516 if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); } 11517 11518 return aborted; 11519 } 11520 11521 rails.handleRemote(form); 11522 return false; 11523 11524 } else { 11525 // Slight timeout so that the submit button gets properly serialized 11526 setTimeout(function(){ rails.disableFormElements(form); }, 13); 11527 } 11528 }); 11529 11530 $document.on('click.rails', rails.formInputClickSelector, function(event) { 11531 var button = $(this); 11532 11533 if (!rails.allowAction(button)) return rails.stopEverything(event); 11534 11535 // Register the pressed submit button 11536 var name = button.attr('name'), 11537 data = name ? {name:name, value:button.val()} : null; 11538 11539 var form = button.closest('form'); 11540 if (form.length === 0) { 11541 form = $('#' + button.attr('form')); 11542 } 11543 form.data('ujs:submit-button', data); 11544 11545 // Save attributes from button 11546 form.data('ujs:formnovalidate-button', button.attr('formnovalidate')); 11547 form.data('ujs:submit-button-formaction', button.attr('formaction')); 11548 form.data('ujs:submit-button-formmethod', button.attr('formmethod')); 11549 }); 11550 11551 $document.on('ajax:send.rails', rails.formSubmitSelector, function(event) { 11552 if (this === event.target) rails.disableFormElements($(this)); 11553 }); 11554 11555 $document.on('ajax:complete.rails', rails.formSubmitSelector, function(event) { 11556 if (this === event.target) rails.enableFormElements($(this)); 11557 }); 11558 11559 $(function(){ 11560 rails.refreshCSRFTokens(); 11561 }); 11562 } 11563 11564})( jQuery ); 11565 11566
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.