Mercurial > hg > rc2
comparison program/js/jquery.js @ 20:4aec5e272733
missed earlier?
| author | Charlie Root |
|---|---|
| date | Wed, 08 Oct 2025 09:42:21 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 19:b6a96bdd6b29 | 20:4aec5e272733 |
|---|---|
| 1 /*! | |
| 2 * jQuery JavaScript Library v1.11.0 | |
| 3 * http://jquery.com/ | |
| 4 * | |
| 5 * Includes Sizzle.js | |
| 6 * http://sizzlejs.com/ | |
| 7 * | |
| 8 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors | |
| 9 * Released under the MIT license | |
| 10 * http://jquery.org/license | |
| 11 * | |
| 12 * Date: 2014-01-23T21:02Z | |
| 13 */ | |
| 14 | |
| 15 (function( global, factory ) { | |
| 16 | |
| 17 if ( typeof module === "object" && typeof module.exports === "object" ) { | |
| 18 // For CommonJS and CommonJS-like environments where a proper window is present, | |
| 19 // execute the factory and get jQuery | |
| 20 // For environments that do not inherently posses a window with a document | |
| 21 // (such as Node.js), expose a jQuery-making factory as module.exports | |
| 22 // This accentuates the need for the creation of a real window | |
| 23 // e.g. var jQuery = require("jquery")(window); | |
| 24 // See ticket #14549 for more info | |
| 25 module.exports = global.document ? | |
| 26 factory( global, true ) : | |
| 27 function( w ) { | |
| 28 if ( !w.document ) { | |
| 29 throw new Error( "jQuery requires a window with a document" ); | |
| 30 } | |
| 31 return factory( w ); | |
| 32 }; | |
| 33 } else { | |
| 34 factory( global ); | |
| 35 } | |
| 36 | |
| 37 // Pass this if window is not defined yet | |
| 38 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { | |
| 39 | |
| 40 // Can't do this because several apps including ASP.NET trace | |
| 41 // the stack via arguments.caller.callee and Firefox dies if | |
| 42 // you try to trace through "use strict" call chains. (#13335) | |
| 43 // Support: Firefox 18+ | |
| 44 // | |
| 45 | |
| 46 var deletedIds = []; | |
| 47 | |
| 48 var slice = deletedIds.slice; | |
| 49 | |
| 50 var concat = deletedIds.concat; | |
| 51 | |
| 52 var push = deletedIds.push; | |
| 53 | |
| 54 var indexOf = deletedIds.indexOf; | |
| 55 | |
| 56 var class2type = {}; | |
| 57 | |
| 58 var toString = class2type.toString; | |
| 59 | |
| 60 var hasOwn = class2type.hasOwnProperty; | |
| 61 | |
| 62 var trim = "".trim; | |
| 63 | |
| 64 var support = {}; | |
| 65 | |
| 66 | |
| 67 | |
| 68 var | |
| 69 version = "1.11.0", | |
| 70 | |
| 71 // Define a local copy of jQuery | |
| 72 jQuery = function( selector, context ) { | |
| 73 // The jQuery object is actually just the init constructor 'enhanced' | |
| 74 // Need init if jQuery is called (just allow error to be thrown if not included) | |
| 75 return new jQuery.fn.init( selector, context ); | |
| 76 }, | |
| 77 | |
| 78 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) | |
| 79 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, | |
| 80 | |
| 81 // Matches dashed string for camelizing | |
| 82 rmsPrefix = /^-ms-/, | |
| 83 rdashAlpha = /-([\da-z])/gi, | |
| 84 | |
| 85 // Used by jQuery.camelCase as callback to replace() | |
| 86 fcamelCase = function( all, letter ) { | |
| 87 return letter.toUpperCase(); | |
| 88 }; | |
| 89 | |
| 90 jQuery.fn = jQuery.prototype = { | |
| 91 // The current version of jQuery being used | |
| 92 jquery: version, | |
| 93 | |
| 94 constructor: jQuery, | |
| 95 | |
| 96 // Start with an empty selector | |
| 97 selector: "", | |
| 98 | |
| 99 // The default length of a jQuery object is 0 | |
| 100 length: 0, | |
| 101 | |
| 102 toArray: function() { | |
| 103 return slice.call( this ); | |
| 104 }, | |
| 105 | |
| 106 // Get the Nth element in the matched element set OR | |
| 107 // Get the whole matched element set as a clean array | |
| 108 get: function( num ) { | |
| 109 return num != null ? | |
| 110 | |
| 111 // Return a 'clean' array | |
| 112 ( num < 0 ? this[ num + this.length ] : this[ num ] ) : | |
| 113 | |
| 114 // Return just the object | |
| 115 slice.call( this ); | |
| 116 }, | |
| 117 | |
| 118 // Take an array of elements and push it onto the stack | |
| 119 // (returning the new matched element set) | |
| 120 pushStack: function( elems ) { | |
| 121 | |
| 122 // Build a new jQuery matched element set | |
| 123 var ret = jQuery.merge( this.constructor(), elems ); | |
| 124 | |
| 125 // Add the old object onto the stack (as a reference) | |
| 126 ret.prevObject = this; | |
| 127 ret.context = this.context; | |
| 128 | |
| 129 // Return the newly-formed element set | |
| 130 return ret; | |
| 131 }, | |
| 132 | |
| 133 // Execute a callback for every element in the matched set. | |
| 134 // (You can seed the arguments with an array of args, but this is | |
| 135 // only used internally.) | |
| 136 each: function( callback, args ) { | |
| 137 return jQuery.each( this, callback, args ); | |
| 138 }, | |
| 139 | |
| 140 map: function( callback ) { | |
| 141 return this.pushStack( jQuery.map(this, function( elem, i ) { | |
| 142 return callback.call( elem, i, elem ); | |
| 143 })); | |
| 144 }, | |
| 145 | |
| 146 slice: function() { | |
| 147 return this.pushStack( slice.apply( this, arguments ) ); | |
| 148 }, | |
| 149 | |
| 150 first: function() { | |
| 151 return this.eq( 0 ); | |
| 152 }, | |
| 153 | |
| 154 last: function() { | |
| 155 return this.eq( -1 ); | |
| 156 }, | |
| 157 | |
| 158 eq: function( i ) { | |
| 159 var len = this.length, | |
| 160 j = +i + ( i < 0 ? len : 0 ); | |
| 161 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); | |
| 162 }, | |
| 163 | |
| 164 end: function() { | |
| 165 return this.prevObject || this.constructor(null); | |
| 166 }, | |
| 167 | |
| 168 // For internal use only. | |
| 169 // Behaves like an Array's method, not like a jQuery method. | |
| 170 push: push, | |
| 171 sort: deletedIds.sort, | |
| 172 splice: deletedIds.splice | |
| 173 }; | |
| 174 | |
| 175 jQuery.extend = jQuery.fn.extend = function() { | |
| 176 var src, copyIsArray, copy, name, options, clone, | |
| 177 target = arguments[0] || {}, | |
| 178 i = 1, | |
| 179 length = arguments.length, | |
| 180 deep = false; | |
| 181 | |
| 182 // Handle a deep copy situation | |
| 183 if ( typeof target === "boolean" ) { | |
| 184 deep = target; | |
| 185 | |
| 186 // skip the boolean and the target | |
| 187 target = arguments[ i ] || {}; | |
| 188 i++; | |
| 189 } | |
| 190 | |
| 191 // Handle case when target is a string or something (possible in deep copy) | |
| 192 if ( typeof target !== "object" && !jQuery.isFunction(target) ) { | |
| 193 target = {}; | |
| 194 } | |
| 195 | |
| 196 // extend jQuery itself if only one argument is passed | |
| 197 if ( i === length ) { | |
| 198 target = this; | |
| 199 i--; | |
| 200 } | |
| 201 | |
| 202 for ( ; i < length; i++ ) { | |
| 203 // Only deal with non-null/undefined values | |
| 204 if ( (options = arguments[ i ]) != null ) { | |
| 205 // Extend the base object | |
| 206 for ( name in options ) { | |
| 207 src = target[ name ]; | |
| 208 copy = options[ name ]; | |
| 209 | |
| 210 // Prevent never-ending loop | |
| 211 if ( target === copy ) { | |
| 212 continue; | |
| 213 } | |
| 214 | |
| 215 // Recurse if we're merging plain objects or arrays | |
| 216 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { | |
| 217 if ( copyIsArray ) { | |
| 218 copyIsArray = false; | |
| 219 clone = src && jQuery.isArray(src) ? src : []; | |
| 220 | |
| 221 } else { | |
| 222 clone = src && jQuery.isPlainObject(src) ? src : {}; | |
| 223 } | |
| 224 | |
| 225 // Never move original objects, clone them | |
| 226 target[ name ] = jQuery.extend( deep, clone, copy ); | |
| 227 | |
| 228 // Don't bring in undefined values | |
| 229 } else if ( copy !== undefined ) { | |
| 230 target[ name ] = copy; | |
| 231 } | |
| 232 } | |
| 233 } | |
| 234 } | |
| 235 | |
| 236 // Return the modified object | |
| 237 return target; | |
| 238 }; | |
| 239 | |
| 240 jQuery.extend({ | |
| 241 // Unique for each copy of jQuery on the page | |
| 242 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), | |
| 243 | |
| 244 // Assume jQuery is ready without the ready module | |
| 245 isReady: true, | |
| 246 | |
| 247 error: function( msg ) { | |
| 248 throw new Error( msg ); | |
| 249 }, | |
| 250 | |
| 251 noop: function() {}, | |
| 252 | |
| 253 // See test/unit/core.js for details concerning isFunction. | |
| 254 // Since version 1.3, DOM methods and functions like alert | |
| 255 // aren't supported. They return false on IE (#2968). | |
| 256 isFunction: function( obj ) { | |
| 257 return jQuery.type(obj) === "function"; | |
| 258 }, | |
| 259 | |
| 260 isArray: Array.isArray || function( obj ) { | |
| 261 return jQuery.type(obj) === "array"; | |
| 262 }, | |
| 263 | |
| 264 isWindow: function( obj ) { | |
| 265 /* jshint eqeqeq: false */ | |
| 266 return obj != null && obj == obj.window; | |
| 267 }, | |
| 268 | |
| 269 isNumeric: function( obj ) { | |
| 270 // parseFloat NaNs numeric-cast false positives (null|true|false|"") | |
| 271 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") | |
| 272 // subtraction forces infinities to NaN | |
| 273 return obj - parseFloat( obj ) >= 0; | |
| 274 }, | |
| 275 | |
| 276 isEmptyObject: function( obj ) { | |
| 277 var name; | |
| 278 for ( name in obj ) { | |
| 279 return false; | |
| 280 } | |
| 281 return true; | |
| 282 }, | |
| 283 | |
| 284 isPlainObject: function( obj ) { | |
| 285 var key; | |
| 286 | |
| 287 // Must be an Object. | |
| 288 // Because of IE, we also have to check the presence of the constructor property. | |
| 289 // Make sure that DOM nodes and window objects don't pass through, as well | |
| 290 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { | |
| 291 return false; | |
| 292 } | |
| 293 | |
| 294 try { | |
| 295 // Not own constructor property must be Object | |
| 296 if ( obj.constructor && | |
| 297 !hasOwn.call(obj, "constructor") && | |
| 298 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { | |
| 299 return false; | |
| 300 } | |
| 301 } catch ( e ) { | |
| 302 // IE8,9 Will throw exceptions on certain host objects #9897 | |
| 303 return false; | |
| 304 } | |
| 305 | |
| 306 // Support: IE<9 | |
| 307 // Handle iteration over inherited properties before own properties. | |
| 308 if ( support.ownLast ) { | |
| 309 for ( key in obj ) { | |
| 310 return hasOwn.call( obj, key ); | |
| 311 } | |
| 312 } | |
| 313 | |
| 314 // Own properties are enumerated firstly, so to speed up, | |
| 315 // if last one is own, then all properties are own. | |
| 316 for ( key in obj ) {} | |
| 317 | |
| 318 return key === undefined || hasOwn.call( obj, key ); | |
| 319 }, | |
| 320 | |
| 321 type: function( obj ) { | |
| 322 if ( obj == null ) { | |
| 323 return obj + ""; | |
| 324 } | |
| 325 return typeof obj === "object" || typeof obj === "function" ? | |
| 326 class2type[ toString.call(obj) ] || "object" : | |
| 327 typeof obj; | |
| 328 }, | |
| 329 | |
| 330 // Evaluates a script in a global context | |
| 331 // Workarounds based on findings by Jim Driscoll | |
| 332 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context | |
| 333 globalEval: function( data ) { | |
| 334 if ( data && jQuery.trim( data ) ) { | |
| 335 // We use execScript on Internet Explorer | |
| 336 // We use an anonymous function so that context is window | |
| 337 // rather than jQuery in Firefox | |
| 338 ( window.execScript || function( data ) { | |
| 339 window[ "eval" ].call( window, data ); | |
| 340 } )( data ); | |
| 341 } | |
| 342 }, | |
| 343 | |
| 344 // Convert dashed to camelCase; used by the css and data modules | |
| 345 // Microsoft forgot to hump their vendor prefix (#9572) | |
| 346 camelCase: function( string ) { | |
| 347 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); | |
| 348 }, | |
| 349 | |
| 350 nodeName: function( elem, name ) { | |
| 351 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); | |
| 352 }, | |
| 353 | |
| 354 // args is for internal usage only | |
| 355 each: function( obj, callback, args ) { | |
| 356 var value, | |
| 357 i = 0, | |
| 358 length = obj.length, | |
| 359 isArray = isArraylike( obj ); | |
| 360 | |
| 361 if ( args ) { | |
| 362 if ( isArray ) { | |
| 363 for ( ; i < length; i++ ) { | |
| 364 value = callback.apply( obj[ i ], args ); | |
| 365 | |
| 366 if ( value === false ) { | |
| 367 break; | |
| 368 } | |
| 369 } | |
| 370 } else { | |
| 371 for ( i in obj ) { | |
| 372 value = callback.apply( obj[ i ], args ); | |
| 373 | |
| 374 if ( value === false ) { | |
| 375 break; | |
| 376 } | |
| 377 } | |
| 378 } | |
| 379 | |
| 380 // A special, fast, case for the most common use of each | |
| 381 } else { | |
| 382 if ( isArray ) { | |
| 383 for ( ; i < length; i++ ) { | |
| 384 value = callback.call( obj[ i ], i, obj[ i ] ); | |
| 385 | |
| 386 if ( value === false ) { | |
| 387 break; | |
| 388 } | |
| 389 } | |
| 390 } else { | |
| 391 for ( i in obj ) { | |
| 392 value = callback.call( obj[ i ], i, obj[ i ] ); | |
| 393 | |
| 394 if ( value === false ) { | |
| 395 break; | |
| 396 } | |
| 397 } | |
| 398 } | |
| 399 } | |
| 400 | |
| 401 return obj; | |
| 402 }, | |
| 403 | |
| 404 // Use native String.trim function wherever possible | |
| 405 trim: trim && !trim.call("\uFEFF\xA0") ? | |
| 406 function( text ) { | |
| 407 return text == null ? | |
| 408 "" : | |
| 409 trim.call( text ); | |
| 410 } : | |
| 411 | |
| 412 // Otherwise use our own trimming functionality | |
| 413 function( text ) { | |
| 414 return text == null ? | |
| 415 "" : | |
| 416 ( text + "" ).replace( rtrim, "" ); | |
| 417 }, | |
| 418 | |
| 419 // results is for internal usage only | |
| 420 makeArray: function( arr, results ) { | |
| 421 var ret = results || []; | |
| 422 | |
| 423 if ( arr != null ) { | |
| 424 if ( isArraylike( Object(arr) ) ) { | |
| 425 jQuery.merge( ret, | |
| 426 typeof arr === "string" ? | |
| 427 [ arr ] : arr | |
| 428 ); | |
| 429 } else { | |
| 430 push.call( ret, arr ); | |
| 431 } | |
| 432 } | |
| 433 | |
| 434 return ret; | |
| 435 }, | |
| 436 | |
| 437 inArray: function( elem, arr, i ) { | |
| 438 var len; | |
| 439 | |
| 440 if ( arr ) { | |
| 441 if ( indexOf ) { | |
| 442 return indexOf.call( arr, elem, i ); | |
| 443 } | |
| 444 | |
| 445 len = arr.length; | |
| 446 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; | |
| 447 | |
| 448 for ( ; i < len; i++ ) { | |
| 449 // Skip accessing in sparse arrays | |
| 450 if ( i in arr && arr[ i ] === elem ) { | |
| 451 return i; | |
| 452 } | |
| 453 } | |
| 454 } | |
| 455 | |
| 456 return -1; | |
| 457 }, | |
| 458 | |
| 459 merge: function( first, second ) { | |
| 460 var len = +second.length, | |
| 461 j = 0, | |
| 462 i = first.length; | |
| 463 | |
| 464 while ( j < len ) { | |
| 465 first[ i++ ] = second[ j++ ]; | |
| 466 } | |
| 467 | |
| 468 // Support: IE<9 | |
| 469 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists) | |
| 470 if ( len !== len ) { | |
| 471 while ( second[j] !== undefined ) { | |
| 472 first[ i++ ] = second[ j++ ]; | |
| 473 } | |
| 474 } | |
| 475 | |
| 476 first.length = i; | |
| 477 | |
| 478 return first; | |
| 479 }, | |
| 480 | |
| 481 grep: function( elems, callback, invert ) { | |
| 482 var callbackInverse, | |
| 483 matches = [], | |
| 484 i = 0, | |
| 485 length = elems.length, | |
| 486 callbackExpect = !invert; | |
| 487 | |
| 488 // Go through the array, only saving the items | |
| 489 // that pass the validator function | |
| 490 for ( ; i < length; i++ ) { | |
| 491 callbackInverse = !callback( elems[ i ], i ); | |
| 492 if ( callbackInverse !== callbackExpect ) { | |
| 493 matches.push( elems[ i ] ); | |
| 494 } | |
| 495 } | |
| 496 | |
| 497 return matches; | |
| 498 }, | |
| 499 | |
| 500 // arg is for internal usage only | |
| 501 map: function( elems, callback, arg ) { | |
| 502 var value, | |
| 503 i = 0, | |
| 504 length = elems.length, | |
| 505 isArray = isArraylike( elems ), | |
| 506 ret = []; | |
| 507 | |
| 508 // Go through the array, translating each of the items to their new values | |
| 509 if ( isArray ) { | |
| 510 for ( ; i < length; i++ ) { | |
| 511 value = callback( elems[ i ], i, arg ); | |
| 512 | |
| 513 if ( value != null ) { | |
| 514 ret.push( value ); | |
| 515 } | |
| 516 } | |
| 517 | |
| 518 // Go through every key on the object, | |
| 519 } else { | |
| 520 for ( i in elems ) { | |
| 521 value = callback( elems[ i ], i, arg ); | |
| 522 | |
| 523 if ( value != null ) { | |
| 524 ret.push( value ); | |
| 525 } | |
| 526 } | |
| 527 } | |
| 528 | |
| 529 // Flatten any nested arrays | |
| 530 return concat.apply( [], ret ); | |
| 531 }, | |
| 532 | |
| 533 // A global GUID counter for objects | |
| 534 guid: 1, | |
| 535 | |
| 536 // Bind a function to a context, optionally partially applying any | |
| 537 // arguments. | |
| 538 proxy: function( fn, context ) { | |
| 539 var args, proxy, tmp; | |
| 540 | |
| 541 if ( typeof context === "string" ) { | |
| 542 tmp = fn[ context ]; | |
| 543 context = fn; | |
| 544 fn = tmp; | |
| 545 } | |
| 546 | |
| 547 // Quick check to determine if target is callable, in the spec | |
| 548 // this throws a TypeError, but we will just return undefined. | |
| 549 if ( !jQuery.isFunction( fn ) ) { | |
| 550 return undefined; | |
| 551 } | |
| 552 | |
| 553 // Simulated bind | |
| 554 args = slice.call( arguments, 2 ); | |
| 555 proxy = function() { | |
| 556 return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); | |
| 557 }; | |
| 558 | |
| 559 // Set the guid of unique handler to the same of original handler, so it can be removed | |
| 560 proxy.guid = fn.guid = fn.guid || jQuery.guid++; | |
| 561 | |
| 562 return proxy; | |
| 563 }, | |
| 564 | |
| 565 now: function() { | |
| 566 return +( new Date() ); | |
| 567 }, | |
| 568 | |
| 569 // jQuery.support is not used in Core but other projects attach their | |
| 570 // properties to it so it needs to exist. | |
| 571 support: support | |
| 572 }); | |
| 573 | |
| 574 // Populate the class2type map | |
| 575 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { | |
| 576 class2type[ "[object " + name + "]" ] = name.toLowerCase(); | |
| 577 }); | |
| 578 | |
| 579 function isArraylike( obj ) { | |
| 580 var length = obj.length, | |
| 581 type = jQuery.type( obj ); | |
| 582 | |
| 583 if ( type === "function" || jQuery.isWindow( obj ) ) { | |
| 584 return false; | |
| 585 } | |
| 586 | |
| 587 if ( obj.nodeType === 1 && length ) { | |
| 588 return true; | |
| 589 } | |
| 590 | |
| 591 return type === "array" || length === 0 || | |
| 592 typeof length === "number" && length > 0 && ( length - 1 ) in obj; | |
| 593 } | |
| 594 var Sizzle = | |
| 595 /*! | |
| 596 * Sizzle CSS Selector Engine v1.10.16 | |
| 597 * http://sizzlejs.com/ | |
| 598 * | |
| 599 * Copyright 2013 jQuery Foundation, Inc. and other contributors | |
| 600 * Released under the MIT license | |
| 601 * http://jquery.org/license | |
| 602 * | |
| 603 * Date: 2014-01-13 | |
| 604 */ | |
| 605 (function( window ) { | |
| 606 | |
| 607 var i, | |
| 608 support, | |
| 609 Expr, | |
| 610 getText, | |
| 611 isXML, | |
| 612 compile, | |
| 613 outermostContext, | |
| 614 sortInput, | |
| 615 hasDuplicate, | |
| 616 | |
| 617 // Local document vars | |
| 618 setDocument, | |
| 619 document, | |
| 620 docElem, | |
| 621 documentIsHTML, | |
| 622 rbuggyQSA, | |
| 623 rbuggyMatches, | |
| 624 matches, | |
| 625 contains, | |
| 626 | |
| 627 // Instance-specific data | |
| 628 expando = "sizzle" + -(new Date()), | |
| 629 preferredDoc = window.document, | |
| 630 dirruns = 0, | |
| 631 done = 0, | |
| 632 classCache = createCache(), | |
| 633 tokenCache = createCache(), | |
| 634 compilerCache = createCache(), | |
| 635 sortOrder = function( a, b ) { | |
| 636 if ( a === b ) { | |
| 637 hasDuplicate = true; | |
| 638 } | |
| 639 return 0; | |
| 640 }, | |
| 641 | |
| 642 // General-purpose constants | |
| 643 strundefined = typeof undefined, | |
| 644 MAX_NEGATIVE = 1 << 31, | |
| 645 | |
| 646 // Instance methods | |
| 647 hasOwn = ({}).hasOwnProperty, | |
| 648 arr = [], | |
| 649 pop = arr.pop, | |
| 650 push_native = arr.push, | |
| 651 push = arr.push, | |
| 652 slice = arr.slice, | |
| 653 // Use a stripped-down indexOf if we can't use a native one | |
| 654 indexOf = arr.indexOf || function( elem ) { | |
| 655 var i = 0, | |
| 656 len = this.length; | |
| 657 for ( ; i < len; i++ ) { | |
| 658 if ( this[i] === elem ) { | |
| 659 return i; | |
| 660 } | |
| 661 } | |
| 662 return -1; | |
| 663 }, | |
| 664 | |
| 665 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", | |
| 666 | |
| 667 // Regular expressions | |
| 668 | |
| 669 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace | |
| 670 whitespace = "[\\x20\\t\\r\\n\\f]", | |
| 671 // http://www.w3.org/TR/css3-syntax/#characters | |
| 672 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", | |
| 673 | |
| 674 // Loosely modeled on CSS identifier characters | |
| 675 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors | |
| 676 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier | |
| 677 identifier = characterEncoding.replace( "w", "w#" ), | |
| 678 | |
| 679 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors | |
| 680 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + | |
| 681 "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", | |
| 682 | |
| 683 // Prefer arguments quoted, | |
| 684 // then not containing pseudos/brackets, | |
| 685 // then attribute selectors/non-parenthetical expressions, | |
| 686 // then anything else | |
| 687 // These preferences are here to reduce the number of selectors | |
| 688 // needing tokenize in the PSEUDO preFilter | |
| 689 pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)", | |
| 690 | |
| 691 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter | |
| 692 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), | |
| 693 | |
| 694 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), | |
| 695 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), | |
| 696 | |
| 697 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), | |
| 698 | |
| 699 rpseudo = new RegExp( pseudos ), | |
| 700 ridentifier = new RegExp( "^" + identifier + "$" ), | |
| 701 | |
| 702 matchExpr = { | |
| 703 "ID": new RegExp( "^#(" + characterEncoding + ")" ), | |
| 704 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), | |
| 705 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), | |
| 706 "ATTR": new RegExp( "^" + attributes ), | |
| 707 "PSEUDO": new RegExp( "^" + pseudos ), | |
| 708 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + | |
| 709 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + | |
| 710 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), | |
| 711 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), | |
| 712 // For use in libraries implementing .is() | |
| 713 // We use this for POS matching in `select` | |
| 714 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + | |
| 715 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) | |
| 716 }, | |
| 717 | |
| 718 rinputs = /^(?:input|select|textarea|button)$/i, | |
| 719 rheader = /^h\d$/i, | |
| 720 | |
| 721 rnative = /^[^{]+\{\s*\[native \w/, | |
| 722 | |
| 723 // Easily-parseable/retrievable ID or TAG or CLASS selectors | |
| 724 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, | |
| 725 | |
| 726 rsibling = /[+~]/, | |
| 727 rescape = /'|\\/g, | |
| 728 | |
| 729 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters | |
| 730 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), | |
| 731 funescape = function( _, escaped, escapedWhitespace ) { | |
| 732 var high = "0x" + escaped - 0x10000; | |
| 733 // NaN means non-codepoint | |
| 734 // Support: Firefox | |
| 735 // Workaround erroneous numeric interpretation of +"0x" | |
| 736 return high !== high || escapedWhitespace ? | |
| 737 escaped : | |
| 738 high < 0 ? | |
| 739 // BMP codepoint | |
| 740 String.fromCharCode( high + 0x10000 ) : | |
| 741 // Supplemental Plane codepoint (surrogate pair) | |
| 742 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); | |
| 743 }; | |
| 744 | |
| 745 // Optimize for push.apply( _, NodeList ) | |
| 746 try { | |
| 747 push.apply( | |
| 748 (arr = slice.call( preferredDoc.childNodes )), | |
| 749 preferredDoc.childNodes | |
| 750 ); | |
| 751 // Support: Android<4.0 | |
| 752 // Detect silently failing push.apply | |
| 753 arr[ preferredDoc.childNodes.length ].nodeType; | |
| 754 } catch ( e ) { | |
| 755 push = { apply: arr.length ? | |
| 756 | |
| 757 // Leverage slice if possible | |
| 758 function( target, els ) { | |
| 759 push_native.apply( target, slice.call(els) ); | |
| 760 } : | |
| 761 | |
| 762 // Support: IE<9 | |
| 763 // Otherwise append directly | |
| 764 function( target, els ) { | |
| 765 var j = target.length, | |
| 766 i = 0; | |
| 767 // Can't trust NodeList.length | |
| 768 while ( (target[j++] = els[i++]) ) {} | |
| 769 target.length = j - 1; | |
| 770 } | |
| 771 }; | |
| 772 } | |
| 773 | |
| 774 function Sizzle( selector, context, results, seed ) { | |
| 775 var match, elem, m, nodeType, | |
| 776 // QSA vars | |
| 777 i, groups, old, nid, newContext, newSelector; | |
| 778 | |
| 779 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { | |
| 780 setDocument( context ); | |
| 781 } | |
| 782 | |
| 783 context = context || document; | |
| 784 results = results || []; | |
| 785 | |
| 786 if ( !selector || typeof selector !== "string" ) { | |
| 787 return results; | |
| 788 } | |
| 789 | |
| 790 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { | |
| 791 return []; | |
| 792 } | |
| 793 | |
| 794 if ( documentIsHTML && !seed ) { | |
| 795 | |
| 796 // Shortcuts | |
| 797 if ( (match = rquickExpr.exec( selector )) ) { | |
| 798 // Speed-up: Sizzle("#ID") | |
| 799 if ( (m = match[1]) ) { | |
| 800 if ( nodeType === 9 ) { | |
| 801 elem = context.getElementById( m ); | |
| 802 // Check parentNode to catch when Blackberry 4.6 returns | |
| 803 // nodes that are no longer in the document (jQuery #6963) | |
| 804 if ( elem && elem.parentNode ) { | |
| 805 // Handle the case where IE, Opera, and Webkit return items | |
| 806 // by name instead of ID | |
| 807 if ( elem.id === m ) { | |
| 808 results.push( elem ); | |
| 809 return results; | |
| 810 } | |
| 811 } else { | |
| 812 return results; | |
| 813 } | |
| 814 } else { | |
| 815 // Context is not a document | |
| 816 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && | |
| 817 contains( context, elem ) && elem.id === m ) { | |
| 818 results.push( elem ); | |
| 819 return results; | |
| 820 } | |
| 821 } | |
| 822 | |
| 823 // Speed-up: Sizzle("TAG") | |
| 824 } else if ( match[2] ) { | |
| 825 push.apply( results, context.getElementsByTagName( selector ) ); | |
| 826 return results; | |
| 827 | |
| 828 // Speed-up: Sizzle(".CLASS") | |
| 829 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) { | |
| 830 push.apply( results, context.getElementsByClassName( m ) ); | |
| 831 return results; | |
| 832 } | |
| 833 } | |
| 834 | |
| 835 // QSA path | |
| 836 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { | |
| 837 nid = old = expando; | |
| 838 newContext = context; | |
| 839 newSelector = nodeType === 9 && selector; | |
| 840 | |
| 841 // qSA works strangely on Element-rooted queries | |
| 842 // We can work around this by specifying an extra ID on the root | |
| 843 // and working up from there (Thanks to Andrew Dupont for the technique) | |
| 844 // IE 8 doesn't work on object elements | |
| 845 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { | |
| 846 groups = tokenize( selector ); | |
| 847 | |
| 848 if ( (old = context.getAttribute("id")) ) { | |
| 849 nid = old.replace( rescape, "\\$&" ); | |
| 850 } else { | |
| 851 context.setAttribute( "id", nid ); | |
| 852 } | |
| 853 nid = "[id='" + nid + "'] "; | |
| 854 | |
| 855 i = groups.length; | |
| 856 while ( i-- ) { | |
| 857 groups[i] = nid + toSelector( groups[i] ); | |
| 858 } | |
| 859 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context; | |
| 860 newSelector = groups.join(","); | |
| 861 } | |
| 862 | |
| 863 if ( newSelector ) { | |
| 864 try { | |
| 865 push.apply( results, | |
| 866 newContext.querySelectorAll( newSelector ) | |
| 867 ); | |
| 868 return results; | |
| 869 } catch(qsaError) { | |
| 870 } finally { | |
| 871 if ( !old ) { | |
| 872 context.removeAttribute("id"); | |
| 873 } | |
| 874 } | |
| 875 } | |
| 876 } | |
| 877 } | |
| 878 | |
| 879 // All others | |
| 880 return select( selector.replace( rtrim, "$1" ), context, results, seed ); | |
| 881 } | |
| 882 | |
| 883 /** | |
| 884 * Create key-value caches of limited size | |
| 885 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with | |
| 886 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) | |
| 887 * deleting the oldest entry | |
| 888 */ | |
| 889 function createCache() { | |
| 890 var keys = []; | |
| 891 | |
| 892 function cache( key, value ) { | |
| 893 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) | |
| 894 if ( keys.push( key + " " ) > Expr.cacheLength ) { | |
| 895 // Only keep the most recent entries | |
| 896 delete cache[ keys.shift() ]; | |
| 897 } | |
| 898 return (cache[ key + " " ] = value); | |
| 899 } | |
| 900 return cache; | |
| 901 } | |
| 902 | |
| 903 /** | |
| 904 * Mark a function for special use by Sizzle | |
| 905 * @param {Function} fn The function to mark | |
| 906 */ | |
| 907 function markFunction( fn ) { | |
| 908 fn[ expando ] = true; | |
| 909 return fn; | |
| 910 } | |
| 911 | |
| 912 /** | |
| 913 * Support testing using an element | |
| 914 * @param {Function} fn Passed the created div and expects a boolean result | |
| 915 */ | |
| 916 function assert( fn ) { | |
| 917 var div = document.createElement("div"); | |
| 918 | |
| 919 try { | |
| 920 return !!fn( div ); | |
| 921 } catch (e) { | |
| 922 return false; | |
| 923 } finally { | |
| 924 // Remove from its parent by default | |
| 925 if ( div.parentNode ) { | |
| 926 div.parentNode.removeChild( div ); | |
| 927 } | |
| 928 // release memory in IE | |
| 929 div = null; | |
| 930 } | |
| 931 } | |
| 932 | |
| 933 /** | |
| 934 * Adds the same handler for all of the specified attrs | |
| 935 * @param {String} attrs Pipe-separated list of attributes | |
| 936 * @param {Function} handler The method that will be applied | |
| 937 */ | |
| 938 function addHandle( attrs, handler ) { | |
| 939 var arr = attrs.split("|"), | |
| 940 i = attrs.length; | |
| 941 | |
| 942 while ( i-- ) { | |
| 943 Expr.attrHandle[ arr[i] ] = handler; | |
| 944 } | |
| 945 } | |
| 946 | |
| 947 /** | |
| 948 * Checks document order of two siblings | |
| 949 * @param {Element} a | |
| 950 * @param {Element} b | |
| 951 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b | |
| 952 */ | |
| 953 function siblingCheck( a, b ) { | |
| 954 var cur = b && a, | |
| 955 diff = cur && a.nodeType === 1 && b.nodeType === 1 && | |
| 956 ( ~b.sourceIndex || MAX_NEGATIVE ) - | |
| 957 ( ~a.sourceIndex || MAX_NEGATIVE ); | |
| 958 | |
| 959 // Use IE sourceIndex if available on both nodes | |
| 960 if ( diff ) { | |
| 961 return diff; | |
| 962 } | |
| 963 | |
| 964 // Check if b follows a | |
| 965 if ( cur ) { | |
| 966 while ( (cur = cur.nextSibling) ) { | |
| 967 if ( cur === b ) { | |
| 968 return -1; | |
| 969 } | |
| 970 } | |
| 971 } | |
| 972 | |
| 973 return a ? 1 : -1; | |
| 974 } | |
| 975 | |
| 976 /** | |
| 977 * Returns a function to use in pseudos for input types | |
| 978 * @param {String} type | |
| 979 */ | |
| 980 function createInputPseudo( type ) { | |
| 981 return function( elem ) { | |
| 982 var name = elem.nodeName.toLowerCase(); | |
| 983 return name === "input" && elem.type === type; | |
| 984 }; | |
| 985 } | |
| 986 | |
| 987 /** | |
| 988 * Returns a function to use in pseudos for buttons | |
| 989 * @param {String} type | |
| 990 */ | |
| 991 function createButtonPseudo( type ) { | |
| 992 return function( elem ) { | |
| 993 var name = elem.nodeName.toLowerCase(); | |
| 994 return (name === "input" || name === "button") && elem.type === type; | |
| 995 }; | |
| 996 } | |
| 997 | |
| 998 /** | |
| 999 * Returns a function to use in pseudos for positionals | |
| 1000 * @param {Function} fn | |
| 1001 */ | |
| 1002 function createPositionalPseudo( fn ) { | |
| 1003 return markFunction(function( argument ) { | |
| 1004 argument = +argument; | |
| 1005 return markFunction(function( seed, matches ) { | |
| 1006 var j, | |
| 1007 matchIndexes = fn( [], seed.length, argument ), | |
| 1008 i = matchIndexes.length; | |
| 1009 | |
| 1010 // Match elements found at the specified indexes | |
| 1011 while ( i-- ) { | |
| 1012 if ( seed[ (j = matchIndexes[i]) ] ) { | |
| 1013 seed[j] = !(matches[j] = seed[j]); | |
| 1014 } | |
| 1015 } | |
| 1016 }); | |
| 1017 }); | |
| 1018 } | |
| 1019 | |
| 1020 /** | |
| 1021 * Checks a node for validity as a Sizzle context | |
| 1022 * @param {Element|Object=} context | |
| 1023 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value | |
| 1024 */ | |
| 1025 function testContext( context ) { | |
| 1026 return context && typeof context.getElementsByTagName !== strundefined && context; | |
| 1027 } | |
| 1028 | |
| 1029 // Expose support vars for convenience | |
| 1030 support = Sizzle.support = {}; | |
| 1031 | |
| 1032 /** | |
| 1033 * Detects XML nodes | |
| 1034 * @param {Element|Object} elem An element or a document | |
| 1035 * @returns {Boolean} True iff elem is a non-HTML XML node | |
| 1036 */ | |
| 1037 isXML = Sizzle.isXML = function( elem ) { | |
| 1038 // documentElement is verified for cases where it doesn't yet exist | |
| 1039 // (such as loading iframes in IE - #4833) | |
| 1040 var documentElement = elem && (elem.ownerDocument || elem).documentElement; | |
| 1041 return documentElement ? documentElement.nodeName !== "HTML" : false; | |
| 1042 }; | |
| 1043 | |
| 1044 /** | |
| 1045 * Sets document-related variables once based on the current document | |
| 1046 * @param {Element|Object} [doc] An element or document object to use to set the document | |
| 1047 * @returns {Object} Returns the current document | |
| 1048 */ | |
| 1049 setDocument = Sizzle.setDocument = function( node ) { | |
| 1050 var hasCompare, | |
| 1051 doc = node ? node.ownerDocument || node : preferredDoc, | |
| 1052 parent = doc.defaultView; | |
| 1053 | |
| 1054 // If no document and documentElement is available, return | |
| 1055 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { | |
| 1056 return document; | |
| 1057 } | |
| 1058 | |
| 1059 // Set our document | |
| 1060 document = doc; | |
| 1061 docElem = doc.documentElement; | |
| 1062 | |
| 1063 // Support tests | |
| 1064 documentIsHTML = !isXML( doc ); | |
| 1065 | |
| 1066 // Support: IE>8 | |
| 1067 // If iframe document is assigned to "document" variable and if iframe has been reloaded, | |
| 1068 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 | |
| 1069 // IE6-8 do not support the defaultView property so parent will be undefined | |
| 1070 if ( parent && parent !== parent.top ) { | |
| 1071 // IE11 does not have attachEvent, so all must suffer | |
| 1072 if ( parent.addEventListener ) { | |
| 1073 parent.addEventListener( "unload", function() { | |
| 1074 setDocument(); | |
| 1075 }, false ); | |
| 1076 } else if ( parent.attachEvent ) { | |
| 1077 parent.attachEvent( "onunload", function() { | |
| 1078 setDocument(); | |
| 1079 }); | |
| 1080 } | |
| 1081 } | |
| 1082 | |
| 1083 /* Attributes | |
| 1084 ---------------------------------------------------------------------- */ | |
| 1085 | |
| 1086 // Support: IE<8 | |
| 1087 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans) | |
| 1088 support.attributes = assert(function( div ) { | |
| 1089 div.className = "i"; | |
| 1090 return !div.getAttribute("className"); | |
| 1091 }); | |
| 1092 | |
| 1093 /* getElement(s)By* | |
| 1094 ---------------------------------------------------------------------- */ | |
| 1095 | |
| 1096 // Check if getElementsByTagName("*") returns only elements | |
| 1097 support.getElementsByTagName = assert(function( div ) { | |
| 1098 div.appendChild( doc.createComment("") ); | |
| 1099 return !div.getElementsByTagName("*").length; | |
| 1100 }); | |
| 1101 | |
| 1102 // Check if getElementsByClassName can be trusted | |
| 1103 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) { | |
| 1104 div.innerHTML = "<div class='a'></div><div class='a i'></div>"; | |
| 1105 | |
| 1106 // Support: Safari<4 | |
| 1107 // Catch class over-caching | |
| 1108 div.firstChild.className = "i"; | |
| 1109 // Support: Opera<10 | |
| 1110 // Catch gEBCN failure to find non-leading classes | |
| 1111 return div.getElementsByClassName("i").length === 2; | |
| 1112 }); | |
| 1113 | |
| 1114 // Support: IE<10 | |
| 1115 // Check if getElementById returns elements by name | |
| 1116 // The broken getElementById methods don't pick up programatically-set names, | |
| 1117 // so use a roundabout getElementsByName test | |
| 1118 support.getById = assert(function( div ) { | |
| 1119 docElem.appendChild( div ).id = expando; | |
| 1120 return !doc.getElementsByName || !doc.getElementsByName( expando ).length; | |
| 1121 }); | |
| 1122 | |
| 1123 // ID find and filter | |
| 1124 if ( support.getById ) { | |
| 1125 Expr.find["ID"] = function( id, context ) { | |
| 1126 if ( typeof context.getElementById !== strundefined && documentIsHTML ) { | |
| 1127 var m = context.getElementById( id ); | |
| 1128 // Check parentNode to catch when Blackberry 4.6 returns | |
| 1129 // nodes that are no longer in the document #6963 | |
| 1130 return m && m.parentNode ? [m] : []; | |
| 1131 } | |
| 1132 }; | |
| 1133 Expr.filter["ID"] = function( id ) { | |
| 1134 var attrId = id.replace( runescape, funescape ); | |
| 1135 return function( elem ) { | |
| 1136 return elem.getAttribute("id") === attrId; | |
| 1137 }; | |
| 1138 }; | |
| 1139 } else { | |
| 1140 // Support: IE6/7 | |
| 1141 // getElementById is not reliable as a find shortcut | |
| 1142 delete Expr.find["ID"]; | |
| 1143 | |
| 1144 Expr.filter["ID"] = function( id ) { | |
| 1145 var attrId = id.replace( runescape, funescape ); | |
| 1146 return function( elem ) { | |
| 1147 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); | |
| 1148 return node && node.value === attrId; | |
| 1149 }; | |
| 1150 }; | |
| 1151 } | |
| 1152 | |
| 1153 // Tag | |
| 1154 Expr.find["TAG"] = support.getElementsByTagName ? | |
| 1155 function( tag, context ) { | |
| 1156 if ( typeof context.getElementsByTagName !== strundefined ) { | |
| 1157 return context.getElementsByTagName( tag ); | |
| 1158 } | |
| 1159 } : | |
| 1160 function( tag, context ) { | |
| 1161 var elem, | |
| 1162 tmp = [], | |
| 1163 i = 0, | |
| 1164 results = context.getElementsByTagName( tag ); | |
| 1165 | |
| 1166 // Filter out possible comments | |
| 1167 if ( tag === "*" ) { | |
| 1168 while ( (elem = results[i++]) ) { | |
| 1169 if ( elem.nodeType === 1 ) { | |
| 1170 tmp.push( elem ); | |
| 1171 } | |
| 1172 } | |
| 1173 | |
| 1174 return tmp; | |
| 1175 } | |
| 1176 return results; | |
| 1177 }; | |
| 1178 | |
| 1179 // Class | |
| 1180 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { | |
| 1181 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) { | |
| 1182 return context.getElementsByClassName( className ); | |
| 1183 } | |
| 1184 }; | |
| 1185 | |
| 1186 /* QSA/matchesSelector | |
| 1187 ---------------------------------------------------------------------- */ | |
| 1188 | |
| 1189 // QSA and matchesSelector support | |
| 1190 | |
| 1191 // matchesSelector(:active) reports false when true (IE9/Opera 11.5) | |
| 1192 rbuggyMatches = []; | |
| 1193 | |
| 1194 // qSa(:focus) reports false when true (Chrome 21) | |
| 1195 // We allow this because of a bug in IE8/9 that throws an error | |
| 1196 // whenever `document.activeElement` is accessed on an iframe | |
| 1197 // So, we allow :focus to pass through QSA all the time to avoid the IE error | |
| 1198 // See http://bugs.jquery.com/ticket/13378 | |
| 1199 rbuggyQSA = []; | |
| 1200 | |
| 1201 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { | |
| 1202 // Build QSA regex | |
| 1203 // Regex strategy adopted from Diego Perini | |
| 1204 assert(function( div ) { | |
| 1205 // Select is set to empty string on purpose | |
| 1206 // This is to test IE's treatment of not explicitly | |
| 1207 // setting a boolean content attribute, | |
| 1208 // since its presence should be enough | |
| 1209 // http://bugs.jquery.com/ticket/12359 | |
| 1210 div.innerHTML = "<select t=''><option selected=''></option></select>"; | |
| 1211 | |
| 1212 // Support: IE8, Opera 10-12 | |
| 1213 // Nothing should be selected when empty strings follow ^= or $= or *= | |
| 1214 if ( div.querySelectorAll("[t^='']").length ) { | |
| 1215 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); | |
| 1216 } | |
| 1217 | |
| 1218 // Support: IE8 | |
| 1219 // Boolean attributes and "value" are not treated correctly | |
| 1220 if ( !div.querySelectorAll("[selected]").length ) { | |
| 1221 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); | |
| 1222 } | |
| 1223 | |
| 1224 // Webkit/Opera - :checked should return selected option elements | |
| 1225 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked | |
| 1226 // IE8 throws error here and will not see later tests | |
| 1227 if ( !div.querySelectorAll(":checked").length ) { | |
| 1228 rbuggyQSA.push(":checked"); | |
| 1229 } | |
| 1230 }); | |
| 1231 | |
| 1232 assert(function( div ) { | |
| 1233 // Support: Windows 8 Native Apps | |
| 1234 // The type and name attributes are restricted during .innerHTML assignment | |
| 1235 var input = doc.createElement("input"); | |
| 1236 input.setAttribute( "type", "hidden" ); | |
| 1237 div.appendChild( input ).setAttribute( "name", "D" ); | |
| 1238 | |
| 1239 // Support: IE8 | |
| 1240 // Enforce case-sensitivity of name attribute | |
| 1241 if ( div.querySelectorAll("[name=d]").length ) { | |
| 1242 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); | |
| 1243 } | |
| 1244 | |
| 1245 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) | |
| 1246 // IE8 throws error here and will not see later tests | |
| 1247 if ( !div.querySelectorAll(":enabled").length ) { | |
| 1248 rbuggyQSA.push( ":enabled", ":disabled" ); | |
| 1249 } | |
| 1250 | |
| 1251 // Opera 10-11 does not throw on post-comma invalid pseudos | |
| 1252 div.querySelectorAll("*,:x"); | |
| 1253 rbuggyQSA.push(",.*:"); | |
| 1254 }); | |
| 1255 } | |
| 1256 | |
| 1257 if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector || | |
| 1258 docElem.mozMatchesSelector || | |
| 1259 docElem.oMatchesSelector || | |
| 1260 docElem.msMatchesSelector) )) ) { | |
| 1261 | |
| 1262 assert(function( div ) { | |
| 1263 // Check to see if it's possible to do matchesSelector | |
| 1264 // on a disconnected node (IE 9) | |
| 1265 support.disconnectedMatch = matches.call( div, "div" ); | |
| 1266 | |
| 1267 // This should fail with an exception | |
| 1268 // Gecko does not error, returns false instead | |
| 1269 matches.call( div, "[s!='']:x" ); | |
| 1270 rbuggyMatches.push( "!=", pseudos ); | |
| 1271 }); | |
| 1272 } | |
| 1273 | |
| 1274 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); | |
| 1275 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); | |
| 1276 | |
| 1277 /* Contains | |
| 1278 ---------------------------------------------------------------------- */ | |
| 1279 hasCompare = rnative.test( docElem.compareDocumentPosition ); | |
| 1280 | |
| 1281 // Element contains another | |
| 1282 // Purposefully does not implement inclusive descendent | |
| 1283 // As in, an element does not contain itself | |
| 1284 contains = hasCompare || rnative.test( docElem.contains ) ? | |
| 1285 function( a, b ) { | |
| 1286 var adown = a.nodeType === 9 ? a.documentElement : a, | |
| 1287 bup = b && b.parentNode; | |
| 1288 return a === bup || !!( bup && bup.nodeType === 1 && ( | |
| 1289 adown.contains ? | |
| 1290 adown.contains( bup ) : | |
| 1291 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 | |
| 1292 )); | |
| 1293 } : | |
| 1294 function( a, b ) { | |
| 1295 if ( b ) { | |
| 1296 while ( (b = b.parentNode) ) { | |
| 1297 if ( b === a ) { | |
| 1298 return true; | |
| 1299 } | |
| 1300 } | |
| 1301 } | |
| 1302 return false; | |
| 1303 }; | |
| 1304 | |
| 1305 /* Sorting | |
| 1306 ---------------------------------------------------------------------- */ | |
| 1307 | |
| 1308 // Document order sorting | |
| 1309 sortOrder = hasCompare ? | |
| 1310 function( a, b ) { | |
| 1311 | |
| 1312 // Flag for duplicate removal | |
| 1313 if ( a === b ) { | |
| 1314 hasDuplicate = true; | |
| 1315 return 0; | |
| 1316 } | |
| 1317 | |
| 1318 // Sort on method existence if only one input has compareDocumentPosition | |
| 1319 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; | |
| 1320 if ( compare ) { | |
| 1321 return compare; | |
| 1322 } | |
| 1323 | |
| 1324 // Calculate position if both inputs belong to the same document | |
| 1325 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? | |
| 1326 a.compareDocumentPosition( b ) : | |
| 1327 | |
| 1328 // Otherwise we know they are disconnected | |
| 1329 1; | |
| 1330 | |
| 1331 // Disconnected nodes | |
| 1332 if ( compare & 1 || | |
| 1333 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { | |
| 1334 | |
| 1335 // Choose the first element that is related to our preferred document | |
| 1336 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { | |
| 1337 return -1; | |
| 1338 } | |
| 1339 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { | |
| 1340 return 1; | |
| 1341 } | |
| 1342 | |
| 1343 // Maintain original order | |
| 1344 return sortInput ? | |
| 1345 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : | |
| 1346 0; | |
| 1347 } | |
| 1348 | |
| 1349 return compare & 4 ? -1 : 1; | |
| 1350 } : | |
| 1351 function( a, b ) { | |
| 1352 // Exit early if the nodes are identical | |
| 1353 if ( a === b ) { | |
| 1354 hasDuplicate = true; | |
| 1355 return 0; | |
| 1356 } | |
| 1357 | |
| 1358 var cur, | |
| 1359 i = 0, | |
| 1360 aup = a.parentNode, | |
| 1361 bup = b.parentNode, | |
| 1362 ap = [ a ], | |
| 1363 bp = [ b ]; | |
| 1364 | |
| 1365 // Parentless nodes are either documents or disconnected | |
| 1366 if ( !aup || !bup ) { | |
| 1367 return a === doc ? -1 : | |
| 1368 b === doc ? 1 : | |
| 1369 aup ? -1 : | |
| 1370 bup ? 1 : | |
| 1371 sortInput ? | |
| 1372 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : | |
| 1373 0; | |
| 1374 | |
| 1375 // If the nodes are siblings, we can do a quick check | |
| 1376 } else if ( aup === bup ) { | |
| 1377 return siblingCheck( a, b ); | |
| 1378 } | |
| 1379 | |
| 1380 // Otherwise we need full lists of their ancestors for comparison | |
| 1381 cur = a; | |
| 1382 while ( (cur = cur.parentNode) ) { | |
| 1383 ap.unshift( cur ); | |
| 1384 } | |
| 1385 cur = b; | |
| 1386 while ( (cur = cur.parentNode) ) { | |
| 1387 bp.unshift( cur ); | |
| 1388 } | |
| 1389 | |
| 1390 // Walk down the tree looking for a discrepancy | |
| 1391 while ( ap[i] === bp[i] ) { | |
| 1392 i++; | |
| 1393 } | |
| 1394 | |
| 1395 return i ? | |
| 1396 // Do a sibling check if the nodes have a common ancestor | |
| 1397 siblingCheck( ap[i], bp[i] ) : | |
| 1398 | |
| 1399 // Otherwise nodes in our document sort first | |
| 1400 ap[i] === preferredDoc ? -1 : | |
| 1401 bp[i] === preferredDoc ? 1 : | |
| 1402 0; | |
| 1403 }; | |
| 1404 | |
| 1405 return doc; | |
| 1406 }; | |
| 1407 | |
| 1408 Sizzle.matches = function( expr, elements ) { | |
| 1409 return Sizzle( expr, null, null, elements ); | |
| 1410 }; | |
| 1411 | |
| 1412 Sizzle.matchesSelector = function( elem, expr ) { | |
| 1413 // Set document vars if needed | |
| 1414 if ( ( elem.ownerDocument || elem ) !== document ) { | |
| 1415 setDocument( elem ); | |
| 1416 } | |
| 1417 | |
| 1418 // Make sure that attribute selectors are quoted | |
| 1419 expr = expr.replace( rattributeQuotes, "='$1']" ); | |
| 1420 | |
| 1421 if ( support.matchesSelector && documentIsHTML && | |
| 1422 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && | |
| 1423 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { | |
| 1424 | |
| 1425 try { | |
| 1426 var ret = matches.call( elem, expr ); | |
| 1427 | |
| 1428 // IE 9's matchesSelector returns false on disconnected nodes | |
| 1429 if ( ret || support.disconnectedMatch || | |
| 1430 // As well, disconnected nodes are said to be in a document | |
| 1431 // fragment in IE 9 | |
| 1432 elem.document && elem.document.nodeType !== 11 ) { | |
| 1433 return ret; | |
| 1434 } | |
| 1435 } catch(e) {} | |
| 1436 } | |
| 1437 | |
| 1438 return Sizzle( expr, document, null, [elem] ).length > 0; | |
| 1439 }; | |
| 1440 | |
| 1441 Sizzle.contains = function( context, elem ) { | |
| 1442 // Set document vars if needed | |
| 1443 if ( ( context.ownerDocument || context ) !== document ) { | |
| 1444 setDocument( context ); | |
| 1445 } | |
| 1446 return contains( context, elem ); | |
| 1447 }; | |
| 1448 | |
| 1449 Sizzle.attr = function( elem, name ) { | |
| 1450 // Set document vars if needed | |
| 1451 if ( ( elem.ownerDocument || elem ) !== document ) { | |
| 1452 setDocument( elem ); | |
| 1453 } | |
| 1454 | |
| 1455 var fn = Expr.attrHandle[ name.toLowerCase() ], | |
| 1456 // Don't get fooled by Object.prototype properties (jQuery #13807) | |
| 1457 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? | |
| 1458 fn( elem, name, !documentIsHTML ) : | |
| 1459 undefined; | |
| 1460 | |
| 1461 return val !== undefined ? | |
| 1462 val : | |
| 1463 support.attributes || !documentIsHTML ? | |
| 1464 elem.getAttribute( name ) : | |
| 1465 (val = elem.getAttributeNode(name)) && val.specified ? | |
| 1466 val.value : | |
| 1467 null; | |
| 1468 }; | |
| 1469 | |
| 1470 Sizzle.error = function( msg ) { | |
| 1471 throw new Error( "Syntax error, unrecognized expression: " + msg ); | |
| 1472 }; | |
| 1473 | |
| 1474 /** | |
| 1475 * Document sorting and removing duplicates | |
| 1476 * @param {ArrayLike} results | |
| 1477 */ | |
| 1478 Sizzle.uniqueSort = function( results ) { | |
| 1479 var elem, | |
| 1480 duplicates = [], | |
| 1481 j = 0, | |
| 1482 i = 0; | |
| 1483 | |
| 1484 // Unless we *know* we can detect duplicates, assume their presence | |
| 1485 hasDuplicate = !support.detectDuplicates; | |
| 1486 sortInput = !support.sortStable && results.slice( 0 ); | |
| 1487 results.sort( sortOrder ); | |
| 1488 | |
| 1489 if ( hasDuplicate ) { | |
| 1490 while ( (elem = results[i++]) ) { | |
| 1491 if ( elem === results[ i ] ) { | |
| 1492 j = duplicates.push( i ); | |
| 1493 } | |
| 1494 } | |
| 1495 while ( j-- ) { | |
| 1496 results.splice( duplicates[ j ], 1 ); | |
| 1497 } | |
| 1498 } | |
| 1499 | |
| 1500 // Clear input after sorting to release objects | |
| 1501 // See https://github.com/jquery/sizzle/pull/225 | |
| 1502 sortInput = null; | |
| 1503 | |
| 1504 return results; | |
| 1505 }; | |
| 1506 | |
| 1507 /** | |
| 1508 * Utility function for retrieving the text value of an array of DOM nodes | |
| 1509 * @param {Array|Element} elem | |
| 1510 */ | |
| 1511 getText = Sizzle.getText = function( elem ) { | |
| 1512 var node, | |
| 1513 ret = "", | |
| 1514 i = 0, | |
| 1515 nodeType = elem.nodeType; | |
| 1516 | |
| 1517 if ( !nodeType ) { | |
| 1518 // If no nodeType, this is expected to be an array | |
| 1519 while ( (node = elem[i++]) ) { | |
| 1520 // Do not traverse comment nodes | |
| 1521 ret += getText( node ); | |
| 1522 } | |
| 1523 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { | |
| 1524 // Use textContent for elements | |
| 1525 // innerText usage removed for consistency of new lines (jQuery #11153) | |
| 1526 if ( typeof elem.textContent === "string" ) { | |
| 1527 return elem.textContent; | |
| 1528 } else { | |
| 1529 // Traverse its children | |
| 1530 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { | |
| 1531 ret += getText( elem ); | |
| 1532 } | |
| 1533 } | |
| 1534 } else if ( nodeType === 3 || nodeType === 4 ) { | |
| 1535 return elem.nodeValue; | |
| 1536 } | |
| 1537 // Do not include comment or processing instruction nodes | |
| 1538 | |
| 1539 return ret; | |
| 1540 }; | |
| 1541 | |
| 1542 Expr = Sizzle.selectors = { | |
| 1543 | |
| 1544 // Can be adjusted by the user | |
| 1545 cacheLength: 50, | |
| 1546 | |
| 1547 createPseudo: markFunction, | |
| 1548 | |
| 1549 match: matchExpr, | |
| 1550 | |
| 1551 attrHandle: {}, | |
| 1552 | |
| 1553 find: {}, | |
| 1554 | |
| 1555 relative: { | |
| 1556 ">": { dir: "parentNode", first: true }, | |
| 1557 " ": { dir: "parentNode" }, | |
| 1558 "+": { dir: "previousSibling", first: true }, | |
| 1559 "~": { dir: "previousSibling" } | |
| 1560 }, | |
| 1561 | |
| 1562 preFilter: { | |
| 1563 "ATTR": function( match ) { | |
| 1564 match[1] = match[1].replace( runescape, funescape ); | |
| 1565 | |
| 1566 // Move the given value to match[3] whether quoted or unquoted | |
| 1567 match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape ); | |
| 1568 | |
| 1569 if ( match[2] === "~=" ) { | |
| 1570 match[3] = " " + match[3] + " "; | |
| 1571 } | |
| 1572 | |
| 1573 return match.slice( 0, 4 ); | |
| 1574 }, | |
| 1575 | |
| 1576 "CHILD": function( match ) { | |
| 1577 /* matches from matchExpr["CHILD"] | |
| 1578 1 type (only|nth|...) | |
| 1579 2 what (child|of-type) | |
| 1580 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) | |
| 1581 4 xn-component of xn+y argument ([+-]?\d*n|) | |
| 1582 5 sign of xn-component | |
| 1583 6 x of xn-component | |
| 1584 7 sign of y-component | |
| 1585 8 y of y-component | |
| 1586 */ | |
| 1587 match[1] = match[1].toLowerCase(); | |
| 1588 | |
| 1589 if ( match[1].slice( 0, 3 ) === "nth" ) { | |
| 1590 // nth-* requires argument | |
| 1591 if ( !match[3] ) { | |
| 1592 Sizzle.error( match[0] ); | |
| 1593 } | |
| 1594 | |
| 1595 // numeric x and y parameters for Expr.filter.CHILD | |
| 1596 // remember that false/true cast respectively to 0/1 | |
| 1597 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); | |
| 1598 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); | |
| 1599 | |
| 1600 // other types prohibit arguments | |
| 1601 } else if ( match[3] ) { | |
| 1602 Sizzle.error( match[0] ); | |
| 1603 } | |
| 1604 | |
| 1605 return match; | |
| 1606 }, | |
| 1607 | |
| 1608 "PSEUDO": function( match ) { | |
| 1609 var excess, | |
| 1610 unquoted = !match[5] && match[2]; | |
| 1611 | |
| 1612 if ( matchExpr["CHILD"].test( match[0] ) ) { | |
| 1613 return null; | |
| 1614 } | |
| 1615 | |
| 1616 // Accept quoted arguments as-is | |
| 1617 if ( match[3] && match[4] !== undefined ) { | |
| 1618 match[2] = match[4]; | |
| 1619 | |
| 1620 // Strip excess characters from unquoted arguments | |
| 1621 } else if ( unquoted && rpseudo.test( unquoted ) && | |
| 1622 // Get excess from tokenize (recursively) | |
| 1623 (excess = tokenize( unquoted, true )) && | |
| 1624 // advance to the next closing parenthesis | |
| 1625 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { | |
| 1626 | |
| 1627 // excess is a negative index | |
| 1628 match[0] = match[0].slice( 0, excess ); | |
| 1629 match[2] = unquoted.slice( 0, excess ); | |
| 1630 } | |
| 1631 | |
| 1632 // Return only captures needed by the pseudo filter method (type and argument) | |
| 1633 return match.slice( 0, 3 ); | |
| 1634 } | |
| 1635 }, | |
| 1636 | |
| 1637 filter: { | |
| 1638 | |
| 1639 "TAG": function( nodeNameSelector ) { | |
| 1640 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); | |
| 1641 return nodeNameSelector === "*" ? | |
| 1642 function() { return true; } : | |
| 1643 function( elem ) { | |
| 1644 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; | |
| 1645 }; | |
| 1646 }, | |
| 1647 | |
| 1648 "CLASS": function( className ) { | |
| 1649 var pattern = classCache[ className + " " ]; | |
| 1650 | |
| 1651 return pattern || | |
| 1652 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && | |
| 1653 classCache( className, function( elem ) { | |
| 1654 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" ); | |
| 1655 }); | |
| 1656 }, | |
| 1657 | |
| 1658 "ATTR": function( name, operator, check ) { | |
| 1659 return function( elem ) { | |
| 1660 var result = Sizzle.attr( elem, name ); | |
| 1661 | |
| 1662 if ( result == null ) { | |
| 1663 return operator === "!="; | |
| 1664 } | |
| 1665 if ( !operator ) { | |
| 1666 return true; | |
| 1667 } | |
| 1668 | |
| 1669 result += ""; | |
| 1670 | |
| 1671 return operator === "=" ? result === check : | |
| 1672 operator === "!=" ? result !== check : | |
| 1673 operator === "^=" ? check && result.indexOf( check ) === 0 : | |
| 1674 operator === "*=" ? check && result.indexOf( check ) > -1 : | |
| 1675 operator === "$=" ? check && result.slice( -check.length ) === check : | |
| 1676 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : | |
| 1677 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : | |
| 1678 false; | |
| 1679 }; | |
| 1680 }, | |
| 1681 | |
| 1682 "CHILD": function( type, what, argument, first, last ) { | |
| 1683 var simple = type.slice( 0, 3 ) !== "nth", | |
| 1684 forward = type.slice( -4 ) !== "last", | |
| 1685 ofType = what === "of-type"; | |
| 1686 | |
| 1687 return first === 1 && last === 0 ? | |
| 1688 | |
| 1689 // Shortcut for :nth-*(n) | |
| 1690 function( elem ) { | |
| 1691 return !!elem.parentNode; | |
| 1692 } : | |
| 1693 | |
| 1694 function( elem, context, xml ) { | |
| 1695 var cache, outerCache, node, diff, nodeIndex, start, | |
| 1696 dir = simple !== forward ? "nextSibling" : "previousSibling", | |
| 1697 parent = elem.parentNode, | |
| 1698 name = ofType && elem.nodeName.toLowerCase(), | |
| 1699 useCache = !xml && !ofType; | |
| 1700 | |
| 1701 if ( parent ) { | |
| 1702 | |
| 1703 // :(first|last|only)-(child|of-type) | |
| 1704 if ( simple ) { | |
| 1705 while ( dir ) { | |
| 1706 node = elem; | |
| 1707 while ( (node = node[ dir ]) ) { | |
| 1708 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { | |
| 1709 return false; | |
| 1710 } | |
| 1711 } | |
| 1712 // Reverse direction for :only-* (if we haven't yet done so) | |
| 1713 start = dir = type === "only" && !start && "nextSibling"; | |
| 1714 } | |
| 1715 return true; | |
| 1716 } | |
| 1717 | |
| 1718 start = [ forward ? parent.firstChild : parent.lastChild ]; | |
| 1719 | |
| 1720 // non-xml :nth-child(...) stores cache data on `parent` | |
| 1721 if ( forward && useCache ) { | |
| 1722 // Seek `elem` from a previously-cached index | |
| 1723 outerCache = parent[ expando ] || (parent[ expando ] = {}); | |
| 1724 cache = outerCache[ type ] || []; | |
| 1725 nodeIndex = cache[0] === dirruns && cache[1]; | |
| 1726 diff = cache[0] === dirruns && cache[2]; | |
| 1727 node = nodeIndex && parent.childNodes[ nodeIndex ]; | |
| 1728 | |
| 1729 while ( (node = ++nodeIndex && node && node[ dir ] || | |
| 1730 | |
| 1731 // Fallback to seeking `elem` from the start | |
| 1732 (diff = nodeIndex = 0) || start.pop()) ) { | |
| 1733 | |
| 1734 // When found, cache indexes on `parent` and break | |
| 1735 if ( node.nodeType === 1 && ++diff && node === elem ) { | |
| 1736 outerCache[ type ] = [ dirruns, nodeIndex, diff ]; | |
| 1737 break; | |
| 1738 } | |
| 1739 } | |
| 1740 | |
| 1741 // Use previously-cached element index if available | |
| 1742 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { | |
| 1743 diff = cache[1]; | |
| 1744 | |
| 1745 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) | |
| 1746 } else { | |
| 1747 // Use the same loop as above to seek `elem` from the start | |
| 1748 while ( (node = ++nodeIndex && node && node[ dir ] || | |
| 1749 (diff = nodeIndex = 0) || start.pop()) ) { | |
| 1750 | |
| 1751 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { | |
| 1752 // Cache the index of each encountered element | |
| 1753 if ( useCache ) { | |
| 1754 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; | |
| 1755 } | |
| 1756 | |
| 1757 if ( node === elem ) { | |
| 1758 break; | |
| 1759 } | |
| 1760 } | |
| 1761 } | |
| 1762 } | |
| 1763 | |
| 1764 // Incorporate the offset, then check against cycle size | |
| 1765 diff -= last; | |
| 1766 return diff === first || ( diff % first === 0 && diff / first >= 0 ); | |
| 1767 } | |
| 1768 }; | |
| 1769 }, | |
| 1770 | |
| 1771 "PSEUDO": function( pseudo, argument ) { | |
| 1772 // pseudo-class names are case-insensitive | |
| 1773 // http://www.w3.org/TR/selectors/#pseudo-classes | |
| 1774 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters | |
| 1775 // Remember that setFilters inherits from pseudos | |
| 1776 var args, | |
| 1777 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || | |
| 1778 Sizzle.error( "unsupported pseudo: " + pseudo ); | |
| 1779 | |
| 1780 // The user may use createPseudo to indicate that | |
| 1781 // arguments are needed to create the filter function | |
| 1782 // just as Sizzle does | |
| 1783 if ( fn[ expando ] ) { | |
| 1784 return fn( argument ); | |
| 1785 } | |
| 1786 | |
| 1787 // But maintain support for old signatures | |
| 1788 if ( fn.length > 1 ) { | |
| 1789 args = [ pseudo, pseudo, "", argument ]; | |
| 1790 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? | |
| 1791 markFunction(function( seed, matches ) { | |
| 1792 var idx, | |
| 1793 matched = fn( seed, argument ), | |
| 1794 i = matched.length; | |
| 1795 while ( i-- ) { | |
| 1796 idx = indexOf.call( seed, matched[i] ); | |
| 1797 seed[ idx ] = !( matches[ idx ] = matched[i] ); | |
| 1798 } | |
| 1799 }) : | |
| 1800 function( elem ) { | |
| 1801 return fn( elem, 0, args ); | |
| 1802 }; | |
| 1803 } | |
| 1804 | |
| 1805 return fn; | |
| 1806 } | |
| 1807 }, | |
| 1808 | |
| 1809 pseudos: { | |
| 1810 // Potentially complex pseudos | |
| 1811 "not": markFunction(function( selector ) { | |
| 1812 // Trim the selector passed to compile | |
| 1813 // to avoid treating leading and trailing | |
| 1814 // spaces as combinators | |
| 1815 var input = [], | |
| 1816 results = [], | |
| 1817 matcher = compile( selector.replace( rtrim, "$1" ) ); | |
| 1818 | |
| 1819 return matcher[ expando ] ? | |
| 1820 markFunction(function( seed, matches, context, xml ) { | |
| 1821 var elem, | |
| 1822 unmatched = matcher( seed, null, xml, [] ), | |
| 1823 i = seed.length; | |
| 1824 | |
| 1825 // Match elements unmatched by `matcher` | |
| 1826 while ( i-- ) { | |
| 1827 if ( (elem = unmatched[i]) ) { | |
| 1828 seed[i] = !(matches[i] = elem); | |
| 1829 } | |
| 1830 } | |
| 1831 }) : | |
| 1832 function( elem, context, xml ) { | |
| 1833 input[0] = elem; | |
| 1834 matcher( input, null, xml, results ); | |
| 1835 return !results.pop(); | |
| 1836 }; | |
| 1837 }), | |
| 1838 | |
| 1839 "has": markFunction(function( selector ) { | |
| 1840 return function( elem ) { | |
| 1841 return Sizzle( selector, elem ).length > 0; | |
| 1842 }; | |
| 1843 }), | |
| 1844 | |
| 1845 "contains": markFunction(function( text ) { | |
| 1846 return function( elem ) { | |
| 1847 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; | |
| 1848 }; | |
| 1849 }), | |
| 1850 | |
| 1851 // "Whether an element is represented by a :lang() selector | |
| 1852 // is based solely on the element's language value | |
| 1853 // being equal to the identifier C, | |
| 1854 // or beginning with the identifier C immediately followed by "-". | |
| 1855 // The matching of C against the element's language value is performed case-insensitively. | |
| 1856 // The identifier C does not have to be a valid language name." | |
| 1857 // http://www.w3.org/TR/selectors/#lang-pseudo | |
| 1858 "lang": markFunction( function( lang ) { | |
| 1859 // lang value must be a valid identifier | |
| 1860 if ( !ridentifier.test(lang || "") ) { | |
| 1861 Sizzle.error( "unsupported lang: " + lang ); | |
| 1862 } | |
| 1863 lang = lang.replace( runescape, funescape ).toLowerCase(); | |
| 1864 return function( elem ) { | |
| 1865 var elemLang; | |
| 1866 do { | |
| 1867 if ( (elemLang = documentIsHTML ? | |
| 1868 elem.lang : | |
| 1869 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { | |
| 1870 | |
| 1871 elemLang = elemLang.toLowerCase(); | |
| 1872 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; | |
| 1873 } | |
| 1874 } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); | |
| 1875 return false; | |
| 1876 }; | |
| 1877 }), | |
| 1878 | |
| 1879 // Miscellaneous | |
| 1880 "target": function( elem ) { | |
| 1881 var hash = window.location && window.location.hash; | |
| 1882 return hash && hash.slice( 1 ) === elem.id; | |
| 1883 }, | |
| 1884 | |
| 1885 "root": function( elem ) { | |
| 1886 return elem === docElem; | |
| 1887 }, | |
| 1888 | |
| 1889 "focus": function( elem ) { | |
| 1890 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); | |
| 1891 }, | |
| 1892 | |
| 1893 // Boolean properties | |
| 1894 "enabled": function( elem ) { | |
| 1895 return elem.disabled === false; | |
| 1896 }, | |
| 1897 | |
| 1898 "disabled": function( elem ) { | |
| 1899 return elem.disabled === true; | |
| 1900 }, | |
| 1901 | |
| 1902 "checked": function( elem ) { | |
| 1903 // In CSS3, :checked should return both checked and selected elements | |
| 1904 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked | |
| 1905 var nodeName = elem.nodeName.toLowerCase(); | |
| 1906 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); | |
| 1907 }, | |
| 1908 | |
| 1909 "selected": function( elem ) { | |
| 1910 // Accessing this property makes selected-by-default | |
| 1911 // options in Safari work properly | |
| 1912 if ( elem.parentNode ) { | |
| 1913 elem.parentNode.selectedIndex; | |
| 1914 } | |
| 1915 | |
| 1916 return elem.selected === true; | |
| 1917 }, | |
| 1918 | |
| 1919 // Contents | |
| 1920 "empty": function( elem ) { | |
| 1921 // http://www.w3.org/TR/selectors/#empty-pseudo | |
| 1922 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), | |
| 1923 // but not by others (comment: 8; processing instruction: 7; etc.) | |
| 1924 // nodeType < 6 works because attributes (2) do not appear as children | |
| 1925 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { | |
| 1926 if ( elem.nodeType < 6 ) { | |
| 1927 return false; | |
| 1928 } | |
| 1929 } | |
| 1930 return true; | |
| 1931 }, | |
| 1932 | |
| 1933 "parent": function( elem ) { | |
| 1934 return !Expr.pseudos["empty"]( elem ); | |
| 1935 }, | |
| 1936 | |
| 1937 // Element/input types | |
| 1938 "header": function( elem ) { | |
| 1939 return rheader.test( elem.nodeName ); | |
| 1940 }, | |
| 1941 | |
| 1942 "input": function( elem ) { | |
| 1943 return rinputs.test( elem.nodeName ); | |
| 1944 }, | |
| 1945 | |
| 1946 "button": function( elem ) { | |
| 1947 var name = elem.nodeName.toLowerCase(); | |
| 1948 return name === "input" && elem.type === "button" || name === "button"; | |
| 1949 }, | |
| 1950 | |
| 1951 "text": function( elem ) { | |
| 1952 var attr; | |
| 1953 return elem.nodeName.toLowerCase() === "input" && | |
| 1954 elem.type === "text" && | |
| 1955 | |
| 1956 // Support: IE<8 | |
| 1957 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" | |
| 1958 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); | |
| 1959 }, | |
| 1960 | |
| 1961 // Position-in-collection | |
| 1962 "first": createPositionalPseudo(function() { | |
| 1963 return [ 0 ]; | |
| 1964 }), | |
| 1965 | |
| 1966 "last": createPositionalPseudo(function( matchIndexes, length ) { | |
| 1967 return [ length - 1 ]; | |
| 1968 }), | |
| 1969 | |
| 1970 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
| 1971 return [ argument < 0 ? argument + length : argument ]; | |
| 1972 }), | |
| 1973 | |
| 1974 "even": createPositionalPseudo(function( matchIndexes, length ) { | |
| 1975 var i = 0; | |
| 1976 for ( ; i < length; i += 2 ) { | |
| 1977 matchIndexes.push( i ); | |
| 1978 } | |
| 1979 return matchIndexes; | |
| 1980 }), | |
| 1981 | |
| 1982 "odd": createPositionalPseudo(function( matchIndexes, length ) { | |
| 1983 var i = 1; | |
| 1984 for ( ; i < length; i += 2 ) { | |
| 1985 matchIndexes.push( i ); | |
| 1986 } | |
| 1987 return matchIndexes; | |
| 1988 }), | |
| 1989 | |
| 1990 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
| 1991 var i = argument < 0 ? argument + length : argument; | |
| 1992 for ( ; --i >= 0; ) { | |
| 1993 matchIndexes.push( i ); | |
| 1994 } | |
| 1995 return matchIndexes; | |
| 1996 }), | |
| 1997 | |
| 1998 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
| 1999 var i = argument < 0 ? argument + length : argument; | |
| 2000 for ( ; ++i < length; ) { | |
| 2001 matchIndexes.push( i ); | |
| 2002 } | |
| 2003 return matchIndexes; | |
| 2004 }) | |
| 2005 } | |
| 2006 }; | |
| 2007 | |
| 2008 Expr.pseudos["nth"] = Expr.pseudos["eq"]; | |
| 2009 | |
| 2010 // Add button/input type pseudos | |
| 2011 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { | |
| 2012 Expr.pseudos[ i ] = createInputPseudo( i ); | |
| 2013 } | |
| 2014 for ( i in { submit: true, reset: true } ) { | |
| 2015 Expr.pseudos[ i ] = createButtonPseudo( i ); | |
| 2016 } | |
| 2017 | |
| 2018 // Easy API for creating new setFilters | |
| 2019 function setFilters() {} | |
| 2020 setFilters.prototype = Expr.filters = Expr.pseudos; | |
| 2021 Expr.setFilters = new setFilters(); | |
| 2022 | |
| 2023 function tokenize( selector, parseOnly ) { | |
| 2024 var matched, match, tokens, type, | |
| 2025 soFar, groups, preFilters, | |
| 2026 cached = tokenCache[ selector + " " ]; | |
| 2027 | |
| 2028 if ( cached ) { | |
| 2029 return parseOnly ? 0 : cached.slice( 0 ); | |
| 2030 } | |
| 2031 | |
| 2032 soFar = selector; | |
| 2033 groups = []; | |
| 2034 preFilters = Expr.preFilter; | |
| 2035 | |
| 2036 while ( soFar ) { | |
| 2037 | |
| 2038 // Comma and first run | |
| 2039 if ( !matched || (match = rcomma.exec( soFar )) ) { | |
| 2040 if ( match ) { | |
| 2041 // Don't consume trailing commas as valid | |
| 2042 soFar = soFar.slice( match[0].length ) || soFar; | |
| 2043 } | |
| 2044 groups.push( (tokens = []) ); | |
| 2045 } | |
| 2046 | |
| 2047 matched = false; | |
| 2048 | |
| 2049 // Combinators | |
| 2050 if ( (match = rcombinators.exec( soFar )) ) { | |
| 2051 matched = match.shift(); | |
| 2052 tokens.push({ | |
| 2053 value: matched, | |
| 2054 // Cast descendant combinators to space | |
| 2055 type: match[0].replace( rtrim, " " ) | |
| 2056 }); | |
| 2057 soFar = soFar.slice( matched.length ); | |
| 2058 } | |
| 2059 | |
| 2060 // Filters | |
| 2061 for ( type in Expr.filter ) { | |
| 2062 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || | |
| 2063 (match = preFilters[ type ]( match ))) ) { | |
| 2064 matched = match.shift(); | |
| 2065 tokens.push({ | |
| 2066 value: matched, | |
| 2067 type: type, | |
| 2068 matches: match | |
| 2069 }); | |
| 2070 soFar = soFar.slice( matched.length ); | |
| 2071 } | |
| 2072 } | |
| 2073 | |
| 2074 if ( !matched ) { | |
| 2075 break; | |
| 2076 } | |
| 2077 } | |
| 2078 | |
| 2079 // Return the length of the invalid excess | |
| 2080 // if we're just parsing | |
| 2081 // Otherwise, throw an error or return tokens | |
| 2082 return parseOnly ? | |
| 2083 soFar.length : | |
| 2084 soFar ? | |
| 2085 Sizzle.error( selector ) : | |
| 2086 // Cache the tokens | |
| 2087 tokenCache( selector, groups ).slice( 0 ); | |
| 2088 } | |
| 2089 | |
| 2090 function toSelector( tokens ) { | |
| 2091 var i = 0, | |
| 2092 len = tokens.length, | |
| 2093 selector = ""; | |
| 2094 for ( ; i < len; i++ ) { | |
| 2095 selector += tokens[i].value; | |
| 2096 } | |
| 2097 return selector; | |
| 2098 } | |
| 2099 | |
| 2100 function addCombinator( matcher, combinator, base ) { | |
| 2101 var dir = combinator.dir, | |
| 2102 checkNonElements = base && dir === "parentNode", | |
| 2103 doneName = done++; | |
| 2104 | |
| 2105 return combinator.first ? | |
| 2106 // Check against closest ancestor/preceding element | |
| 2107 function( elem, context, xml ) { | |
| 2108 while ( (elem = elem[ dir ]) ) { | |
| 2109 if ( elem.nodeType === 1 || checkNonElements ) { | |
| 2110 return matcher( elem, context, xml ); | |
| 2111 } | |
| 2112 } | |
| 2113 } : | |
| 2114 | |
| 2115 // Check against all ancestor/preceding elements | |
| 2116 function( elem, context, xml ) { | |
| 2117 var oldCache, outerCache, | |
| 2118 newCache = [ dirruns, doneName ]; | |
| 2119 | |
| 2120 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching | |
| 2121 if ( xml ) { | |
| 2122 while ( (elem = elem[ dir ]) ) { | |
| 2123 if ( elem.nodeType === 1 || checkNonElements ) { | |
| 2124 if ( matcher( elem, context, xml ) ) { | |
| 2125 return true; | |
| 2126 } | |
| 2127 } | |
| 2128 } | |
| 2129 } else { | |
| 2130 while ( (elem = elem[ dir ]) ) { | |
| 2131 if ( elem.nodeType === 1 || checkNonElements ) { | |
| 2132 outerCache = elem[ expando ] || (elem[ expando ] = {}); | |
| 2133 if ( (oldCache = outerCache[ dir ]) && | |
| 2134 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { | |
| 2135 | |
| 2136 // Assign to newCache so results back-propagate to previous elements | |
| 2137 return (newCache[ 2 ] = oldCache[ 2 ]); | |
| 2138 } else { | |
| 2139 // Reuse newcache so results back-propagate to previous elements | |
| 2140 outerCache[ dir ] = newCache; | |
| 2141 | |
| 2142 // A match means we're done; a fail means we have to keep checking | |
| 2143 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { | |
| 2144 return true; | |
| 2145 } | |
| 2146 } | |
| 2147 } | |
| 2148 } | |
| 2149 } | |
| 2150 }; | |
| 2151 } | |
| 2152 | |
| 2153 function elementMatcher( matchers ) { | |
| 2154 return matchers.length > 1 ? | |
| 2155 function( elem, context, xml ) { | |
| 2156 var i = matchers.length; | |
| 2157 while ( i-- ) { | |
| 2158 if ( !matchers[i]( elem, context, xml ) ) { | |
| 2159 return false; | |
| 2160 } | |
| 2161 } | |
| 2162 return true; | |
| 2163 } : | |
| 2164 matchers[0]; | |
| 2165 } | |
| 2166 | |
| 2167 function condense( unmatched, map, filter, context, xml ) { | |
| 2168 var elem, | |
| 2169 newUnmatched = [], | |
| 2170 i = 0, | |
| 2171 len = unmatched.length, | |
| 2172 mapped = map != null; | |
| 2173 | |
| 2174 for ( ; i < len; i++ ) { | |
| 2175 if ( (elem = unmatched[i]) ) { | |
| 2176 if ( !filter || filter( elem, context, xml ) ) { | |
| 2177 newUnmatched.push( elem ); | |
| 2178 if ( mapped ) { | |
| 2179 map.push( i ); | |
| 2180 } | |
| 2181 } | |
| 2182 } | |
| 2183 } | |
| 2184 | |
| 2185 return newUnmatched; | |
| 2186 } | |
| 2187 | |
| 2188 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { | |
| 2189 if ( postFilter && !postFilter[ expando ] ) { | |
| 2190 postFilter = setMatcher( postFilter ); | |
| 2191 } | |
| 2192 if ( postFinder && !postFinder[ expando ] ) { | |
| 2193 postFinder = setMatcher( postFinder, postSelector ); | |
| 2194 } | |
| 2195 return markFunction(function( seed, results, context, xml ) { | |
| 2196 var temp, i, elem, | |
| 2197 preMap = [], | |
| 2198 postMap = [], | |
| 2199 preexisting = results.length, | |
| 2200 | |
| 2201 // Get initial elements from seed or context | |
| 2202 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), | |
| 2203 | |
| 2204 // Prefilter to get matcher input, preserving a map for seed-results synchronization | |
| 2205 matcherIn = preFilter && ( seed || !selector ) ? | |
| 2206 condense( elems, preMap, preFilter, context, xml ) : | |
| 2207 elems, | |
| 2208 | |
| 2209 matcherOut = matcher ? | |
| 2210 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, | |
| 2211 postFinder || ( seed ? preFilter : preexisting || postFilter ) ? | |
| 2212 | |
| 2213 // ...intermediate processing is necessary | |
| 2214 [] : | |
| 2215 | |
| 2216 // ...otherwise use results directly | |
| 2217 results : | |
| 2218 matcherIn; | |
| 2219 | |
| 2220 // Find primary matches | |
| 2221 if ( matcher ) { | |
| 2222 matcher( matcherIn, matcherOut, context, xml ); | |
| 2223 } | |
| 2224 | |
| 2225 // Apply postFilter | |
| 2226 if ( postFilter ) { | |
| 2227 temp = condense( matcherOut, postMap ); | |
| 2228 postFilter( temp, [], context, xml ); | |
| 2229 | |
| 2230 // Un-match failing elements by moving them back to matcherIn | |
| 2231 i = temp.length; | |
| 2232 while ( i-- ) { | |
| 2233 if ( (elem = temp[i]) ) { | |
| 2234 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); | |
| 2235 } | |
| 2236 } | |
| 2237 } | |
| 2238 | |
| 2239 if ( seed ) { | |
| 2240 if ( postFinder || preFilter ) { | |
| 2241 if ( postFinder ) { | |
| 2242 // Get the final matcherOut by condensing this intermediate into postFinder contexts | |
| 2243 temp = []; | |
| 2244 i = matcherOut.length; | |
| 2245 while ( i-- ) { | |
| 2246 if ( (elem = matcherOut[i]) ) { | |
| 2247 // Restore matcherIn since elem is not yet a final match | |
| 2248 temp.push( (matcherIn[i] = elem) ); | |
| 2249 } | |
| 2250 } | |
| 2251 postFinder( null, (matcherOut = []), temp, xml ); | |
| 2252 } | |
| 2253 | |
| 2254 // Move matched elements from seed to results to keep them synchronized | |
| 2255 i = matcherOut.length; | |
| 2256 while ( i-- ) { | |
| 2257 if ( (elem = matcherOut[i]) && | |
| 2258 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { | |
| 2259 | |
| 2260 seed[temp] = !(results[temp] = elem); | |
| 2261 } | |
| 2262 } | |
| 2263 } | |
| 2264 | |
| 2265 // Add elements to results, through postFinder if defined | |
| 2266 } else { | |
| 2267 matcherOut = condense( | |
| 2268 matcherOut === results ? | |
| 2269 matcherOut.splice( preexisting, matcherOut.length ) : | |
| 2270 matcherOut | |
| 2271 ); | |
| 2272 if ( postFinder ) { | |
| 2273 postFinder( null, results, matcherOut, xml ); | |
| 2274 } else { | |
| 2275 push.apply( results, matcherOut ); | |
| 2276 } | |
| 2277 } | |
| 2278 }); | |
| 2279 } | |
| 2280 | |
| 2281 function matcherFromTokens( tokens ) { | |
| 2282 var checkContext, matcher, j, | |
| 2283 len = tokens.length, | |
| 2284 leadingRelative = Expr.relative[ tokens[0].type ], | |
| 2285 implicitRelative = leadingRelative || Expr.relative[" "], | |
| 2286 i = leadingRelative ? 1 : 0, | |
| 2287 | |
| 2288 // The foundational matcher ensures that elements are reachable from top-level context(s) | |
| 2289 matchContext = addCombinator( function( elem ) { | |
| 2290 return elem === checkContext; | |
| 2291 }, implicitRelative, true ), | |
| 2292 matchAnyContext = addCombinator( function( elem ) { | |
| 2293 return indexOf.call( checkContext, elem ) > -1; | |
| 2294 }, implicitRelative, true ), | |
| 2295 matchers = [ function( elem, context, xml ) { | |
| 2296 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( | |
| 2297 (checkContext = context).nodeType ? | |
| 2298 matchContext( elem, context, xml ) : | |
| 2299 matchAnyContext( elem, context, xml ) ); | |
| 2300 } ]; | |
| 2301 | |
| 2302 for ( ; i < len; i++ ) { | |
| 2303 if ( (matcher = Expr.relative[ tokens[i].type ]) ) { | |
| 2304 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; | |
| 2305 } else { | |
| 2306 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); | |
| 2307 | |
| 2308 // Return special upon seeing a positional matcher | |
| 2309 if ( matcher[ expando ] ) { | |
| 2310 // Find the next relative operator (if any) for proper handling | |
| 2311 j = ++i; | |
| 2312 for ( ; j < len; j++ ) { | |
| 2313 if ( Expr.relative[ tokens[j].type ] ) { | |
| 2314 break; | |
| 2315 } | |
| 2316 } | |
| 2317 return setMatcher( | |
| 2318 i > 1 && elementMatcher( matchers ), | |
| 2319 i > 1 && toSelector( | |
| 2320 // If the preceding token was a descendant combinator, insert an implicit any-element `*` | |
| 2321 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) | |
| 2322 ).replace( rtrim, "$1" ), | |
| 2323 matcher, | |
| 2324 i < j && matcherFromTokens( tokens.slice( i, j ) ), | |
| 2325 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), | |
| 2326 j < len && toSelector( tokens ) | |
| 2327 ); | |
| 2328 } | |
| 2329 matchers.push( matcher ); | |
| 2330 } | |
| 2331 } | |
| 2332 | |
| 2333 return elementMatcher( matchers ); | |
| 2334 } | |
| 2335 | |
| 2336 function matcherFromGroupMatchers( elementMatchers, setMatchers ) { | |
| 2337 var bySet = setMatchers.length > 0, | |
| 2338 byElement = elementMatchers.length > 0, | |
| 2339 superMatcher = function( seed, context, xml, results, outermost ) { | |
| 2340 var elem, j, matcher, | |
| 2341 matchedCount = 0, | |
| 2342 i = "0", | |
| 2343 unmatched = seed && [], | |
| 2344 setMatched = [], | |
| 2345 contextBackup = outermostContext, | |
| 2346 // We must always have either seed elements or outermost context | |
| 2347 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), | |
| 2348 // Use integer dirruns iff this is the outermost matcher | |
| 2349 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), | |
| 2350 len = elems.length; | |
| 2351 | |
| 2352 if ( outermost ) { | |
| 2353 outermostContext = context !== document && context; | |
| 2354 } | |
| 2355 | |
| 2356 // Add elements passing elementMatchers directly to results | |
| 2357 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below | |
| 2358 // Support: IE<9, Safari | |
| 2359 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id | |
| 2360 for ( ; i !== len && (elem = elems[i]) != null; i++ ) { | |
| 2361 if ( byElement && elem ) { | |
| 2362 j = 0; | |
| 2363 while ( (matcher = elementMatchers[j++]) ) { | |
| 2364 if ( matcher( elem, context, xml ) ) { | |
| 2365 results.push( elem ); | |
| 2366 break; | |
| 2367 } | |
| 2368 } | |
| 2369 if ( outermost ) { | |
| 2370 dirruns = dirrunsUnique; | |
| 2371 } | |
| 2372 } | |
| 2373 | |
| 2374 // Track unmatched elements for set filters | |
| 2375 if ( bySet ) { | |
| 2376 // They will have gone through all possible matchers | |
| 2377 if ( (elem = !matcher && elem) ) { | |
| 2378 matchedCount--; | |
| 2379 } | |
| 2380 | |
| 2381 // Lengthen the array for every element, matched or not | |
| 2382 if ( seed ) { | |
| 2383 unmatched.push( elem ); | |
| 2384 } | |
| 2385 } | |
| 2386 } | |
| 2387 | |
| 2388 // Apply set filters to unmatched elements | |
| 2389 matchedCount += i; | |
| 2390 if ( bySet && i !== matchedCount ) { | |
| 2391 j = 0; | |
| 2392 while ( (matcher = setMatchers[j++]) ) { | |
| 2393 matcher( unmatched, setMatched, context, xml ); | |
| 2394 } | |
| 2395 | |
| 2396 if ( seed ) { | |
| 2397 // Reintegrate element matches to eliminate the need for sorting | |
| 2398 if ( matchedCount > 0 ) { | |
| 2399 while ( i-- ) { | |
| 2400 if ( !(unmatched[i] || setMatched[i]) ) { | |
| 2401 setMatched[i] = pop.call( results ); | |
| 2402 } | |
| 2403 } | |
| 2404 } | |
| 2405 | |
| 2406 // Discard index placeholder values to get only actual matches | |
| 2407 setMatched = condense( setMatched ); | |
| 2408 } | |
| 2409 | |
| 2410 // Add matches to results | |
| 2411 push.apply( results, setMatched ); | |
| 2412 | |
| 2413 // Seedless set matches succeeding multiple successful matchers stipulate sorting | |
| 2414 if ( outermost && !seed && setMatched.length > 0 && | |
| 2415 ( matchedCount + setMatchers.length ) > 1 ) { | |
| 2416 | |
| 2417 Sizzle.uniqueSort( results ); | |
| 2418 } | |
| 2419 } | |
| 2420 | |
| 2421 // Override manipulation of globals by nested matchers | |
| 2422 if ( outermost ) { | |
| 2423 dirruns = dirrunsUnique; | |
| 2424 outermostContext = contextBackup; | |
| 2425 } | |
| 2426 | |
| 2427 return unmatched; | |
| 2428 }; | |
| 2429 | |
| 2430 return bySet ? | |
| 2431 markFunction( superMatcher ) : | |
| 2432 superMatcher; | |
| 2433 } | |
| 2434 | |
| 2435 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { | |
| 2436 var i, | |
| 2437 setMatchers = [], | |
| 2438 elementMatchers = [], | |
| 2439 cached = compilerCache[ selector + " " ]; | |
| 2440 | |
| 2441 if ( !cached ) { | |
| 2442 // Generate a function of recursive functions that can be used to check each element | |
| 2443 if ( !group ) { | |
| 2444 group = tokenize( selector ); | |
| 2445 } | |
| 2446 i = group.length; | |
| 2447 while ( i-- ) { | |
| 2448 cached = matcherFromTokens( group[i] ); | |
| 2449 if ( cached[ expando ] ) { | |
| 2450 setMatchers.push( cached ); | |
| 2451 } else { | |
| 2452 elementMatchers.push( cached ); | |
| 2453 } | |
| 2454 } | |
| 2455 | |
| 2456 // Cache the compiled function | |
| 2457 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); | |
| 2458 } | |
| 2459 return cached; | |
| 2460 }; | |
| 2461 | |
| 2462 function multipleContexts( selector, contexts, results ) { | |
| 2463 var i = 0, | |
| 2464 len = contexts.length; | |
| 2465 for ( ; i < len; i++ ) { | |
| 2466 Sizzle( selector, contexts[i], results ); | |
| 2467 } | |
| 2468 return results; | |
| 2469 } | |
| 2470 | |
| 2471 function select( selector, context, results, seed ) { | |
| 2472 var i, tokens, token, type, find, | |
| 2473 match = tokenize( selector ); | |
| 2474 | |
| 2475 if ( !seed ) { | |
| 2476 // Try to minimize operations if there is only one group | |
| 2477 if ( match.length === 1 ) { | |
| 2478 | |
| 2479 // Take a shortcut and set the context if the root selector is an ID | |
| 2480 tokens = match[0] = match[0].slice( 0 ); | |
| 2481 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && | |
| 2482 support.getById && context.nodeType === 9 && documentIsHTML && | |
| 2483 Expr.relative[ tokens[1].type ] ) { | |
| 2484 | |
| 2485 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; | |
| 2486 if ( !context ) { | |
| 2487 return results; | |
| 2488 } | |
| 2489 selector = selector.slice( tokens.shift().value.length ); | |
| 2490 } | |
| 2491 | |
| 2492 // Fetch a seed set for right-to-left matching | |
| 2493 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; | |
| 2494 while ( i-- ) { | |
| 2495 token = tokens[i]; | |
| 2496 | |
| 2497 // Abort if we hit a combinator | |
| 2498 if ( Expr.relative[ (type = token.type) ] ) { | |
| 2499 break; | |
| 2500 } | |
| 2501 if ( (find = Expr.find[ type ]) ) { | |
| 2502 // Search, expanding context for leading sibling combinators | |
| 2503 if ( (seed = find( | |
| 2504 token.matches[0].replace( runescape, funescape ), | |
| 2505 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context | |
| 2506 )) ) { | |
| 2507 | |
| 2508 // If seed is empty or no tokens remain, we can return early | |
| 2509 tokens.splice( i, 1 ); | |
| 2510 selector = seed.length && toSelector( tokens ); | |
| 2511 if ( !selector ) { | |
| 2512 push.apply( results, seed ); | |
| 2513 return results; | |
| 2514 } | |
| 2515 | |
| 2516 break; | |
| 2517 } | |
| 2518 } | |
| 2519 } | |
| 2520 } | |
| 2521 } | |
| 2522 | |
| 2523 // Compile and execute a filtering function | |
| 2524 // Provide `match` to avoid retokenization if we modified the selector above | |
| 2525 compile( selector, match )( | |
| 2526 seed, | |
| 2527 context, | |
| 2528 !documentIsHTML, | |
| 2529 results, | |
| 2530 rsibling.test( selector ) && testContext( context.parentNode ) || context | |
| 2531 ); | |
| 2532 return results; | |
| 2533 } | |
| 2534 | |
| 2535 // One-time assignments | |
| 2536 | |
| 2537 // Sort stability | |
| 2538 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; | |
| 2539 | |
| 2540 // Support: Chrome<14 | |
| 2541 // Always assume duplicates if they aren't passed to the comparison function | |
| 2542 support.detectDuplicates = !!hasDuplicate; | |
| 2543 | |
| 2544 // Initialize against the default document | |
| 2545 setDocument(); | |
| 2546 | |
| 2547 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) | |
| 2548 // Detached nodes confoundingly follow *each other* | |
| 2549 support.sortDetached = assert(function( div1 ) { | |
| 2550 // Should return 1, but returns 4 (following) | |
| 2551 return div1.compareDocumentPosition( document.createElement("div") ) & 1; | |
| 2552 }); | |
| 2553 | |
| 2554 // Support: IE<8 | |
| 2555 // Prevent attribute/property "interpolation" | |
| 2556 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx | |
| 2557 if ( !assert(function( div ) { | |
| 2558 div.innerHTML = "<a href='#'></a>"; | |
| 2559 return div.firstChild.getAttribute("href") === "#" ; | |
| 2560 }) ) { | |
| 2561 addHandle( "type|href|height|width", function( elem, name, isXML ) { | |
| 2562 if ( !isXML ) { | |
| 2563 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); | |
| 2564 } | |
| 2565 }); | |
| 2566 } | |
| 2567 | |
| 2568 // Support: IE<9 | |
| 2569 // Use defaultValue in place of getAttribute("value") | |
| 2570 if ( !support.attributes || !assert(function( div ) { | |
| 2571 div.innerHTML = "<input/>"; | |
| 2572 div.firstChild.setAttribute( "value", "" ); | |
| 2573 return div.firstChild.getAttribute( "value" ) === ""; | |
| 2574 }) ) { | |
| 2575 addHandle( "value", function( elem, name, isXML ) { | |
| 2576 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { | |
| 2577 return elem.defaultValue; | |
| 2578 } | |
| 2579 }); | |
| 2580 } | |
| 2581 | |
| 2582 // Support: IE<9 | |
| 2583 // Use getAttributeNode to fetch booleans when getAttribute lies | |
| 2584 if ( !assert(function( div ) { | |
| 2585 return div.getAttribute("disabled") == null; | |
| 2586 }) ) { | |
| 2587 addHandle( booleans, function( elem, name, isXML ) { | |
| 2588 var val; | |
| 2589 if ( !isXML ) { | |
| 2590 return elem[ name ] === true ? name.toLowerCase() : | |
| 2591 (val = elem.getAttributeNode( name )) && val.specified ? | |
| 2592 val.value : | |
| 2593 null; | |
| 2594 } | |
| 2595 }); | |
| 2596 } | |
| 2597 | |
| 2598 return Sizzle; | |
| 2599 | |
| 2600 })( window ); | |
| 2601 | |
| 2602 | |
| 2603 | |
| 2604 jQuery.find = Sizzle; | |
| 2605 jQuery.expr = Sizzle.selectors; | |
| 2606 jQuery.expr[":"] = jQuery.expr.pseudos; | |
| 2607 jQuery.unique = Sizzle.uniqueSort; | |
| 2608 jQuery.text = Sizzle.getText; | |
| 2609 jQuery.isXMLDoc = Sizzle.isXML; | |
| 2610 jQuery.contains = Sizzle.contains; | |
| 2611 | |
| 2612 | |
| 2613 | |
| 2614 var rneedsContext = jQuery.expr.match.needsContext; | |
| 2615 | |
| 2616 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); | |
| 2617 | |
| 2618 | |
| 2619 | |
| 2620 var risSimple = /^.[^:#\[\.,]*$/; | |
| 2621 | |
| 2622 // Implement the identical functionality for filter and not | |
| 2623 function winnow( elements, qualifier, not ) { | |
| 2624 if ( jQuery.isFunction( qualifier ) ) { | |
| 2625 return jQuery.grep( elements, function( elem, i ) { | |
| 2626 /* jshint -W018 */ | |
| 2627 return !!qualifier.call( elem, i, elem ) !== not; | |
| 2628 }); | |
| 2629 | |
| 2630 } | |
| 2631 | |
| 2632 if ( qualifier.nodeType ) { | |
| 2633 return jQuery.grep( elements, function( elem ) { | |
| 2634 return ( elem === qualifier ) !== not; | |
| 2635 }); | |
| 2636 | |
| 2637 } | |
| 2638 | |
| 2639 if ( typeof qualifier === "string" ) { | |
| 2640 if ( risSimple.test( qualifier ) ) { | |
| 2641 return jQuery.filter( qualifier, elements, not ); | |
| 2642 } | |
| 2643 | |
| 2644 qualifier = jQuery.filter( qualifier, elements ); | |
| 2645 } | |
| 2646 | |
| 2647 return jQuery.grep( elements, function( elem ) { | |
| 2648 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not; | |
| 2649 }); | |
| 2650 } | |
| 2651 | |
| 2652 jQuery.filter = function( expr, elems, not ) { | |
| 2653 var elem = elems[ 0 ]; | |
| 2654 | |
| 2655 if ( not ) { | |
| 2656 expr = ":not(" + expr + ")"; | |
| 2657 } | |
| 2658 | |
| 2659 return elems.length === 1 && elem.nodeType === 1 ? | |
| 2660 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : | |
| 2661 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { | |
| 2662 return elem.nodeType === 1; | |
| 2663 })); | |
| 2664 }; | |
| 2665 | |
| 2666 jQuery.fn.extend({ | |
| 2667 find: function( selector ) { | |
| 2668 var i, | |
| 2669 ret = [], | |
| 2670 self = this, | |
| 2671 len = self.length; | |
| 2672 | |
| 2673 if ( typeof selector !== "string" ) { | |
| 2674 return this.pushStack( jQuery( selector ).filter(function() { | |
| 2675 for ( i = 0; i < len; i++ ) { | |
| 2676 if ( jQuery.contains( self[ i ], this ) ) { | |
| 2677 return true; | |
| 2678 } | |
| 2679 } | |
| 2680 }) ); | |
| 2681 } | |
| 2682 | |
| 2683 for ( i = 0; i < len; i++ ) { | |
| 2684 jQuery.find( selector, self[ i ], ret ); | |
| 2685 } | |
| 2686 | |
| 2687 // Needed because $( selector, context ) becomes $( context ).find( selector ) | |
| 2688 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); | |
| 2689 ret.selector = this.selector ? this.selector + " " + selector : selector; | |
| 2690 return ret; | |
| 2691 }, | |
| 2692 filter: function( selector ) { | |
| 2693 return this.pushStack( winnow(this, selector || [], false) ); | |
| 2694 }, | |
| 2695 not: function( selector ) { | |
| 2696 return this.pushStack( winnow(this, selector || [], true) ); | |
| 2697 }, | |
| 2698 is: function( selector ) { | |
| 2699 return !!winnow( | |
| 2700 this, | |
| 2701 | |
| 2702 // If this is a positional/relative selector, check membership in the returned set | |
| 2703 // so $("p:first").is("p:last") won't return true for a doc with two "p". | |
| 2704 typeof selector === "string" && rneedsContext.test( selector ) ? | |
| 2705 jQuery( selector ) : | |
| 2706 selector || [], | |
| 2707 false | |
| 2708 ).length; | |
| 2709 } | |
| 2710 }); | |
| 2711 | |
| 2712 | |
| 2713 // Initialize a jQuery object | |
| 2714 | |
| 2715 | |
| 2716 // A central reference to the root jQuery(document) | |
| 2717 var rootjQuery, | |
| 2718 | |
| 2719 // Use the correct document accordingly with window argument (sandbox) | |
| 2720 document = window.document, | |
| 2721 | |
| 2722 // A simple way to check for HTML strings | |
| 2723 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) | |
| 2724 // Strict HTML recognition (#11290: must start with <) | |
| 2725 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, | |
| 2726 | |
| 2727 init = jQuery.fn.init = function( selector, context ) { | |
| 2728 var match, elem; | |
| 2729 | |
| 2730 // HANDLE: $(""), $(null), $(undefined), $(false) | |
| 2731 if ( !selector ) { | |
| 2732 return this; | |
| 2733 } | |
| 2734 | |
| 2735 // Handle HTML strings | |
| 2736 if ( typeof selector === "string" ) { | |
| 2737 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { | |
| 2738 // Assume that strings that start and end with <> are HTML and skip the regex check | |
| 2739 match = [ null, selector, null ]; | |
| 2740 | |
| 2741 } else { | |
| 2742 match = rquickExpr.exec( selector ); | |
| 2743 } | |
| 2744 | |
| 2745 // Match html or make sure no context is specified for #id | |
| 2746 if ( match && (match[1] || !context) ) { | |
| 2747 | |
| 2748 // HANDLE: $(html) -> $(array) | |
| 2749 if ( match[1] ) { | |
| 2750 context = context instanceof jQuery ? context[0] : context; | |
| 2751 | |
| 2752 // scripts is true for back-compat | |
| 2753 // Intentionally let the error be thrown if parseHTML is not present | |
| 2754 jQuery.merge( this, jQuery.parseHTML( | |
| 2755 match[1], | |
| 2756 context && context.nodeType ? context.ownerDocument || context : document, | |
| 2757 true | |
| 2758 ) ); | |
| 2759 | |
| 2760 // HANDLE: $(html, props) | |
| 2761 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { | |
| 2762 for ( match in context ) { | |
| 2763 // Properties of context are called as methods if possible | |
| 2764 if ( jQuery.isFunction( this[ match ] ) ) { | |
| 2765 this[ match ]( context[ match ] ); | |
| 2766 | |
| 2767 // ...and otherwise set as attributes | |
| 2768 } else { | |
| 2769 this.attr( match, context[ match ] ); | |
| 2770 } | |
| 2771 } | |
| 2772 } | |
| 2773 | |
| 2774 return this; | |
| 2775 | |
| 2776 // HANDLE: $(#id) | |
| 2777 } else { | |
| 2778 elem = document.getElementById( match[2] ); | |
| 2779 | |
| 2780 // Check parentNode to catch when Blackberry 4.6 returns | |
| 2781 // nodes that are no longer in the document #6963 | |
| 2782 if ( elem && elem.parentNode ) { | |
| 2783 // Handle the case where IE and Opera return items | |
| 2784 // by name instead of ID | |
| 2785 if ( elem.id !== match[2] ) { | |
| 2786 return rootjQuery.find( selector ); | |
| 2787 } | |
| 2788 | |
| 2789 // Otherwise, we inject the element directly into the jQuery object | |
| 2790 this.length = 1; | |
| 2791 this[0] = elem; | |
| 2792 } | |
| 2793 | |
| 2794 this.context = document; | |
| 2795 this.selector = selector; | |
| 2796 return this; | |
| 2797 } | |
| 2798 | |
| 2799 // HANDLE: $(expr, $(...)) | |
| 2800 } else if ( !context || context.jquery ) { | |
| 2801 return ( context || rootjQuery ).find( selector ); | |
| 2802 | |
| 2803 // HANDLE: $(expr, context) | |
| 2804 // (which is just equivalent to: $(context).find(expr) | |
| 2805 } else { | |
| 2806 return this.constructor( context ).find( selector ); | |
| 2807 } | |
| 2808 | |
| 2809 // HANDLE: $(DOMElement) | |
| 2810 } else if ( selector.nodeType ) { | |
| 2811 this.context = this[0] = selector; | |
| 2812 this.length = 1; | |
| 2813 return this; | |
| 2814 | |
| 2815 // HANDLE: $(function) | |
| 2816 // Shortcut for document ready | |
| 2817 } else if ( jQuery.isFunction( selector ) ) { | |
| 2818 return typeof rootjQuery.ready !== "undefined" ? | |
| 2819 rootjQuery.ready( selector ) : | |
| 2820 // Execute immediately if ready is not present | |
| 2821 selector( jQuery ); | |
| 2822 } | |
| 2823 | |
| 2824 if ( selector.selector !== undefined ) { | |
| 2825 this.selector = selector.selector; | |
| 2826 this.context = selector.context; | |
| 2827 } | |
| 2828 | |
| 2829 return jQuery.makeArray( selector, this ); | |
| 2830 }; | |
| 2831 | |
| 2832 // Give the init function the jQuery prototype for later instantiation | |
| 2833 init.prototype = jQuery.fn; | |
| 2834 | |
| 2835 // Initialize central reference | |
| 2836 rootjQuery = jQuery( document ); | |
| 2837 | |
| 2838 | |
| 2839 var rparentsprev = /^(?:parents|prev(?:Until|All))/, | |
| 2840 // methods guaranteed to produce a unique set when starting from a unique set | |
| 2841 guaranteedUnique = { | |
| 2842 children: true, | |
| 2843 contents: true, | |
| 2844 next: true, | |
| 2845 prev: true | |
| 2846 }; | |
| 2847 | |
| 2848 jQuery.extend({ | |
| 2849 dir: function( elem, dir, until ) { | |
| 2850 var matched = [], | |
| 2851 cur = elem[ dir ]; | |
| 2852 | |
| 2853 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { | |
| 2854 if ( cur.nodeType === 1 ) { | |
| 2855 matched.push( cur ); | |
| 2856 } | |
| 2857 cur = cur[dir]; | |
| 2858 } | |
| 2859 return matched; | |
| 2860 }, | |
| 2861 | |
| 2862 sibling: function( n, elem ) { | |
| 2863 var r = []; | |
| 2864 | |
| 2865 for ( ; n; n = n.nextSibling ) { | |
| 2866 if ( n.nodeType === 1 && n !== elem ) { | |
| 2867 r.push( n ); | |
| 2868 } | |
| 2869 } | |
| 2870 | |
| 2871 return r; | |
| 2872 } | |
| 2873 }); | |
| 2874 | |
| 2875 jQuery.fn.extend({ | |
| 2876 has: function( target ) { | |
| 2877 var i, | |
| 2878 targets = jQuery( target, this ), | |
| 2879 len = targets.length; | |
| 2880 | |
| 2881 return this.filter(function() { | |
| 2882 for ( i = 0; i < len; i++ ) { | |
| 2883 if ( jQuery.contains( this, targets[i] ) ) { | |
| 2884 return true; | |
| 2885 } | |
| 2886 } | |
| 2887 }); | |
| 2888 }, | |
| 2889 | |
| 2890 closest: function( selectors, context ) { | |
| 2891 var cur, | |
| 2892 i = 0, | |
| 2893 l = this.length, | |
| 2894 matched = [], | |
| 2895 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? | |
| 2896 jQuery( selectors, context || this.context ) : | |
| 2897 0; | |
| 2898 | |
| 2899 for ( ; i < l; i++ ) { | |
| 2900 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { | |
| 2901 // Always skip document fragments | |
| 2902 if ( cur.nodeType < 11 && (pos ? | |
| 2903 pos.index(cur) > -1 : | |
| 2904 | |
| 2905 // Don't pass non-elements to Sizzle | |
| 2906 cur.nodeType === 1 && | |
| 2907 jQuery.find.matchesSelector(cur, selectors)) ) { | |
| 2908 | |
| 2909 matched.push( cur ); | |
| 2910 break; | |
| 2911 } | |
| 2912 } | |
| 2913 } | |
| 2914 | |
| 2915 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); | |
| 2916 }, | |
| 2917 | |
| 2918 // Determine the position of an element within | |
| 2919 // the matched set of elements | |
| 2920 index: function( elem ) { | |
| 2921 | |
| 2922 // No argument, return index in parent | |
| 2923 if ( !elem ) { | |
| 2924 return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1; | |
| 2925 } | |
| 2926 | |
| 2927 // index in selector | |
| 2928 if ( typeof elem === "string" ) { | |
| 2929 return jQuery.inArray( this[0], jQuery( elem ) ); | |
| 2930 } | |
| 2931 | |
| 2932 // Locate the position of the desired element | |
| 2933 return jQuery.inArray( | |
| 2934 // If it receives a jQuery object, the first element is used | |
| 2935 elem.jquery ? elem[0] : elem, this ); | |
| 2936 }, | |
| 2937 | |
| 2938 add: function( selector, context ) { | |
| 2939 return this.pushStack( | |
| 2940 jQuery.unique( | |
| 2941 jQuery.merge( this.get(), jQuery( selector, context ) ) | |
| 2942 ) | |
| 2943 ); | |
| 2944 }, | |
| 2945 | |
| 2946 addBack: function( selector ) { | |
| 2947 return this.add( selector == null ? | |
| 2948 this.prevObject : this.prevObject.filter(selector) | |
| 2949 ); | |
| 2950 } | |
| 2951 }); | |
| 2952 | |
| 2953 function sibling( cur, dir ) { | |
| 2954 do { | |
| 2955 cur = cur[ dir ]; | |
| 2956 } while ( cur && cur.nodeType !== 1 ); | |
| 2957 | |
| 2958 return cur; | |
| 2959 } | |
| 2960 | |
| 2961 jQuery.each({ | |
| 2962 parent: function( elem ) { | |
| 2963 var parent = elem.parentNode; | |
| 2964 return parent && parent.nodeType !== 11 ? parent : null; | |
| 2965 }, | |
| 2966 parents: function( elem ) { | |
| 2967 return jQuery.dir( elem, "parentNode" ); | |
| 2968 }, | |
| 2969 parentsUntil: function( elem, i, until ) { | |
| 2970 return jQuery.dir( elem, "parentNode", until ); | |
| 2971 }, | |
| 2972 next: function( elem ) { | |
| 2973 return sibling( elem, "nextSibling" ); | |
| 2974 }, | |
| 2975 prev: function( elem ) { | |
| 2976 return sibling( elem, "previousSibling" ); | |
| 2977 }, | |
| 2978 nextAll: function( elem ) { | |
| 2979 return jQuery.dir( elem, "nextSibling" ); | |
| 2980 }, | |
| 2981 prevAll: function( elem ) { | |
| 2982 return jQuery.dir( elem, "previousSibling" ); | |
| 2983 }, | |
| 2984 nextUntil: function( elem, i, until ) { | |
| 2985 return jQuery.dir( elem, "nextSibling", until ); | |
| 2986 }, | |
| 2987 prevUntil: function( elem, i, until ) { | |
| 2988 return jQuery.dir( elem, "previousSibling", until ); | |
| 2989 }, | |
| 2990 siblings: function( elem ) { | |
| 2991 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); | |
| 2992 }, | |
| 2993 children: function( elem ) { | |
| 2994 return jQuery.sibling( elem.firstChild ); | |
| 2995 }, | |
| 2996 contents: function( elem ) { | |
| 2997 return jQuery.nodeName( elem, "iframe" ) ? | |
| 2998 elem.contentDocument || elem.contentWindow.document : | |
| 2999 jQuery.merge( [], elem.childNodes ); | |
| 3000 } | |
| 3001 }, function( name, fn ) { | |
| 3002 jQuery.fn[ name ] = function( until, selector ) { | |
| 3003 var ret = jQuery.map( this, fn, until ); | |
| 3004 | |
| 3005 if ( name.slice( -5 ) !== "Until" ) { | |
| 3006 selector = until; | |
| 3007 } | |
| 3008 | |
| 3009 if ( selector && typeof selector === "string" ) { | |
| 3010 ret = jQuery.filter( selector, ret ); | |
| 3011 } | |
| 3012 | |
| 3013 if ( this.length > 1 ) { | |
| 3014 // Remove duplicates | |
| 3015 if ( !guaranteedUnique[ name ] ) { | |
| 3016 ret = jQuery.unique( ret ); | |
| 3017 } | |
| 3018 | |
| 3019 // Reverse order for parents* and prev-derivatives | |
| 3020 if ( rparentsprev.test( name ) ) { | |
| 3021 ret = ret.reverse(); | |
| 3022 } | |
| 3023 } | |
| 3024 | |
| 3025 return this.pushStack( ret ); | |
| 3026 }; | |
| 3027 }); | |
| 3028 var rnotwhite = (/\S+/g); | |
| 3029 | |
| 3030 | |
| 3031 | |
| 3032 // String to Object options format cache | |
| 3033 var optionsCache = {}; | |
| 3034 | |
| 3035 // Convert String-formatted options into Object-formatted ones and store in cache | |
| 3036 function createOptions( options ) { | |
| 3037 var object = optionsCache[ options ] = {}; | |
| 3038 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { | |
| 3039 object[ flag ] = true; | |
| 3040 }); | |
| 3041 return object; | |
| 3042 } | |
| 3043 | |
| 3044 /* | |
| 3045 * Create a callback list using the following parameters: | |
| 3046 * | |
| 3047 * options: an optional list of space-separated options that will change how | |
| 3048 * the callback list behaves or a more traditional option object | |
| 3049 * | |
| 3050 * By default a callback list will act like an event callback list and can be | |
| 3051 * "fired" multiple times. | |
| 3052 * | |
| 3053 * Possible options: | |
| 3054 * | |
| 3055 * once: will ensure the callback list can only be fired once (like a Deferred) | |
| 3056 * | |
| 3057 * memory: will keep track of previous values and will call any callback added | |
| 3058 * after the list has been fired right away with the latest "memorized" | |
| 3059 * values (like a Deferred) | |
| 3060 * | |
| 3061 * unique: will ensure a callback can only be added once (no duplicate in the list) | |
| 3062 * | |
| 3063 * stopOnFalse: interrupt callings when a callback returns false | |
| 3064 * | |
| 3065 */ | |
| 3066 jQuery.Callbacks = function( options ) { | |
| 3067 | |
| 3068 // Convert options from String-formatted to Object-formatted if needed | |
| 3069 // (we check in cache first) | |
| 3070 options = typeof options === "string" ? | |
| 3071 ( optionsCache[ options ] || createOptions( options ) ) : | |
| 3072 jQuery.extend( {}, options ); | |
| 3073 | |
| 3074 var // Flag to know if list is currently firing | |
| 3075 firing, | |
| 3076 // Last fire value (for non-forgettable lists) | |
| 3077 memory, | |
| 3078 // Flag to know if list was already fired | |
| 3079 fired, | |
| 3080 // End of the loop when firing | |
| 3081 firingLength, | |
| 3082 // Index of currently firing callback (modified by remove if needed) | |
| 3083 firingIndex, | |
| 3084 // First callback to fire (used internally by add and fireWith) | |
| 3085 firingStart, | |
| 3086 // Actual callback list | |
| 3087 list = [], | |
| 3088 // Stack of fire calls for repeatable lists | |
| 3089 stack = !options.once && [], | |
| 3090 // Fire callbacks | |
| 3091 fire = function( data ) { | |
| 3092 memory = options.memory && data; | |
| 3093 fired = true; | |
| 3094 firingIndex = firingStart || 0; | |
| 3095 firingStart = 0; | |
| 3096 firingLength = list.length; | |
| 3097 firing = true; | |
| 3098 for ( ; list && firingIndex < firingLength; firingIndex++ ) { | |
| 3099 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { | |
| 3100 memory = false; // To prevent further calls using add | |
| 3101 break; | |
| 3102 } | |
| 3103 } | |
| 3104 firing = false; | |
| 3105 if ( list ) { | |
| 3106 if ( stack ) { | |
| 3107 if ( stack.length ) { | |
| 3108 fire( stack.shift() ); | |
| 3109 } | |
| 3110 } else if ( memory ) { | |
| 3111 list = []; | |
| 3112 } else { | |
| 3113 self.disable(); | |
| 3114 } | |
| 3115 } | |
| 3116 }, | |
| 3117 // Actual Callbacks object | |
| 3118 self = { | |
| 3119 // Add a callback or a collection of callbacks to the list | |
| 3120 add: function() { | |
| 3121 if ( list ) { | |
| 3122 // First, we save the current length | |
| 3123 var start = list.length; | |
| 3124 (function add( args ) { | |
| 3125 jQuery.each( args, function( _, arg ) { | |
| 3126 var type = jQuery.type( arg ); | |
| 3127 if ( type === "function" ) { | |
| 3128 if ( !options.unique || !self.has( arg ) ) { | |
| 3129 list.push( arg ); | |
| 3130 } | |
| 3131 } else if ( arg && arg.length && type !== "string" ) { | |
| 3132 // Inspect recursively | |
| 3133 add( arg ); | |
| 3134 } | |
| 3135 }); | |
| 3136 })( arguments ); | |
| 3137 // Do we need to add the callbacks to the | |
| 3138 // current firing batch? | |
| 3139 if ( firing ) { | |
| 3140 firingLength = list.length; | |
| 3141 // With memory, if we're not firing then | |
| 3142 // we should call right away | |
| 3143 } else if ( memory ) { | |
| 3144 firingStart = start; | |
| 3145 fire( memory ); | |
| 3146 } | |
| 3147 } | |
| 3148 return this; | |
| 3149 }, | |
| 3150 // Remove a callback from the list | |
| 3151 remove: function() { | |
| 3152 if ( list ) { | |
| 3153 jQuery.each( arguments, function( _, arg ) { | |
| 3154 var index; | |
| 3155 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { | |
| 3156 list.splice( index, 1 ); | |
| 3157 // Handle firing indexes | |
| 3158 if ( firing ) { | |
| 3159 if ( index <= firingLength ) { | |
| 3160 firingLength--; | |
| 3161 } | |
| 3162 if ( index <= firingIndex ) { | |
| 3163 firingIndex--; | |
| 3164 } | |
| 3165 } | |
| 3166 } | |
| 3167 }); | |
| 3168 } | |
| 3169 return this; | |
| 3170 }, | |
| 3171 // Check if a given callback is in the list. | |
| 3172 // If no argument is given, return whether or not list has callbacks attached. | |
| 3173 has: function( fn ) { | |
| 3174 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); | |
| 3175 }, | |
| 3176 // Remove all callbacks from the list | |
| 3177 empty: function() { | |
| 3178 list = []; | |
| 3179 firingLength = 0; | |
| 3180 return this; | |
| 3181 }, | |
| 3182 // Have the list do nothing anymore | |
| 3183 disable: function() { | |
| 3184 list = stack = memory = undefined; | |
| 3185 return this; | |
| 3186 }, | |
| 3187 // Is it disabled? | |
| 3188 disabled: function() { | |
| 3189 return !list; | |
| 3190 }, | |
| 3191 // Lock the list in its current state | |
| 3192 lock: function() { | |
| 3193 stack = undefined; | |
| 3194 if ( !memory ) { | |
| 3195 self.disable(); | |
| 3196 } | |
| 3197 return this; | |
| 3198 }, | |
| 3199 // Is it locked? | |
| 3200 locked: function() { | |
| 3201 return !stack; | |
| 3202 }, | |
| 3203 // Call all callbacks with the given context and arguments | |
| 3204 fireWith: function( context, args ) { | |
| 3205 if ( list && ( !fired || stack ) ) { | |
| 3206 args = args || []; | |
| 3207 args = [ context, args.slice ? args.slice() : args ]; | |
| 3208 if ( firing ) { | |
| 3209 stack.push( args ); | |
| 3210 } else { | |
| 3211 fire( args ); | |
| 3212 } | |
| 3213 } | |
| 3214 return this; | |
| 3215 }, | |
| 3216 // Call all the callbacks with the given arguments | |
| 3217 fire: function() { | |
| 3218 self.fireWith( this, arguments ); | |
| 3219 return this; | |
| 3220 }, | |
| 3221 // To know if the callbacks have already been called at least once | |
| 3222 fired: function() { | |
| 3223 return !!fired; | |
| 3224 } | |
| 3225 }; | |
| 3226 | |
| 3227 return self; | |
| 3228 }; | |
| 3229 | |
| 3230 | |
| 3231 jQuery.extend({ | |
| 3232 | |
| 3233 Deferred: function( func ) { | |
| 3234 var tuples = [ | |
| 3235 // action, add listener, listener list, final state | |
| 3236 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], | |
| 3237 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], | |
| 3238 [ "notify", "progress", jQuery.Callbacks("memory") ] | |
| 3239 ], | |
| 3240 state = "pending", | |
| 3241 promise = { | |
| 3242 state: function() { | |
| 3243 return state; | |
| 3244 }, | |
| 3245 always: function() { | |
| 3246 deferred.done( arguments ).fail( arguments ); | |
| 3247 return this; | |
| 3248 }, | |
| 3249 then: function( /* fnDone, fnFail, fnProgress */ ) { | |
| 3250 var fns = arguments; | |
| 3251 return jQuery.Deferred(function( newDefer ) { | |
| 3252 jQuery.each( tuples, function( i, tuple ) { | |
| 3253 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; | |
| 3254 // deferred[ done | fail | progress ] for forwarding actions to newDefer | |
| 3255 deferred[ tuple[1] ](function() { | |
| 3256 var returned = fn && fn.apply( this, arguments ); | |
| 3257 if ( returned && jQuery.isFunction( returned.promise ) ) { | |
| 3258 returned.promise() | |
| 3259 .done( newDefer.resolve ) | |
| 3260 .fail( newDefer.reject ) | |
| 3261 .progress( newDefer.notify ); | |
| 3262 } else { | |
| 3263 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); | |
| 3264 } | |
| 3265 }); | |
| 3266 }); | |
| 3267 fns = null; | |
| 3268 }).promise(); | |
| 3269 }, | |
| 3270 // Get a promise for this deferred | |
| 3271 // If obj is provided, the promise aspect is added to the object | |
| 3272 promise: function( obj ) { | |
| 3273 return obj != null ? jQuery.extend( obj, promise ) : promise; | |
| 3274 } | |
| 3275 }, | |
| 3276 deferred = {}; | |
| 3277 | |
| 3278 // Keep pipe for back-compat | |
| 3279 promise.pipe = promise.then; | |
| 3280 | |
| 3281 // Add list-specific methods | |
| 3282 jQuery.each( tuples, function( i, tuple ) { | |
| 3283 var list = tuple[ 2 ], | |
| 3284 stateString = tuple[ 3 ]; | |
| 3285 | |
| 3286 // promise[ done | fail | progress ] = list.add | |
| 3287 promise[ tuple[1] ] = list.add; | |
| 3288 | |
| 3289 // Handle state | |
| 3290 if ( stateString ) { | |
| 3291 list.add(function() { | |
| 3292 // state = [ resolved | rejected ] | |
| 3293 state = stateString; | |
| 3294 | |
| 3295 // [ reject_list | resolve_list ].disable; progress_list.lock | |
| 3296 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); | |
| 3297 } | |
| 3298 | |
| 3299 // deferred[ resolve | reject | notify ] | |
| 3300 deferred[ tuple[0] ] = function() { | |
| 3301 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); | |
| 3302 return this; | |
| 3303 }; | |
| 3304 deferred[ tuple[0] + "With" ] = list.fireWith; | |
| 3305 }); | |
| 3306 | |
| 3307 // Make the deferred a promise | |
| 3308 promise.promise( deferred ); | |
| 3309 | |
| 3310 // Call given func if any | |
| 3311 if ( func ) { | |
| 3312 func.call( deferred, deferred ); | |
| 3313 } | |
| 3314 | |
| 3315 // All done! | |
| 3316 return deferred; | |
| 3317 }, | |
| 3318 | |
| 3319 // Deferred helper | |
| 3320 when: function( subordinate /* , ..., subordinateN */ ) { | |
| 3321 var i = 0, | |
| 3322 resolveValues = slice.call( arguments ), | |
| 3323 length = resolveValues.length, | |
| 3324 | |
| 3325 // the count of uncompleted subordinates | |
| 3326 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, | |
| 3327 | |
| 3328 // the master Deferred. If resolveValues consist of only a single Deferred, just use that. | |
| 3329 deferred = remaining === 1 ? subordinate : jQuery.Deferred(), | |
| 3330 | |
| 3331 // Update function for both resolve and progress values | |
| 3332 updateFunc = function( i, contexts, values ) { | |
| 3333 return function( value ) { | |
| 3334 contexts[ i ] = this; | |
| 3335 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; | |
| 3336 if ( values === progressValues ) { | |
| 3337 deferred.notifyWith( contexts, values ); | |
| 3338 | |
| 3339 } else if ( !(--remaining) ) { | |
| 3340 deferred.resolveWith( contexts, values ); | |
| 3341 } | |
| 3342 }; | |
| 3343 }, | |
| 3344 | |
| 3345 progressValues, progressContexts, resolveContexts; | |
| 3346 | |
| 3347 // add listeners to Deferred subordinates; treat others as resolved | |
| 3348 if ( length > 1 ) { | |
| 3349 progressValues = new Array( length ); | |
| 3350 progressContexts = new Array( length ); | |
| 3351 resolveContexts = new Array( length ); | |
| 3352 for ( ; i < length; i++ ) { | |
| 3353 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { | |
| 3354 resolveValues[ i ].promise() | |
| 3355 .done( updateFunc( i, resolveContexts, resolveValues ) ) | |
| 3356 .fail( deferred.reject ) | |
| 3357 .progress( updateFunc( i, progressContexts, progressValues ) ); | |
| 3358 } else { | |
| 3359 --remaining; | |
| 3360 } | |
| 3361 } | |
| 3362 } | |
| 3363 | |
| 3364 // if we're not waiting on anything, resolve the master | |
| 3365 if ( !remaining ) { | |
| 3366 deferred.resolveWith( resolveContexts, resolveValues ); | |
| 3367 } | |
| 3368 | |
| 3369 return deferred.promise(); | |
| 3370 } | |
| 3371 }); | |
| 3372 | |
| 3373 | |
| 3374 // The deferred used on DOM ready | |
| 3375 var readyList; | |
| 3376 | |
| 3377 jQuery.fn.ready = function( fn ) { | |
| 3378 // Add the callback | |
| 3379 jQuery.ready.promise().done( fn ); | |
| 3380 | |
| 3381 return this; | |
| 3382 }; | |
| 3383 | |
| 3384 jQuery.extend({ | |
| 3385 // Is the DOM ready to be used? Set to true once it occurs. | |
| 3386 isReady: false, | |
| 3387 | |
| 3388 // A counter to track how many items to wait for before | |
| 3389 // the ready event fires. See #6781 | |
| 3390 readyWait: 1, | |
| 3391 | |
| 3392 // Hold (or release) the ready event | |
| 3393 holdReady: function( hold ) { | |
| 3394 if ( hold ) { | |
| 3395 jQuery.readyWait++; | |
| 3396 } else { | |
| 3397 jQuery.ready( true ); | |
| 3398 } | |
| 3399 }, | |
| 3400 | |
| 3401 // Handle when the DOM is ready | |
| 3402 ready: function( wait ) { | |
| 3403 | |
| 3404 // Abort if there are pending holds or we're already ready | |
| 3405 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { | |
| 3406 return; | |
| 3407 } | |
| 3408 | |
| 3409 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). | |
| 3410 if ( !document.body ) { | |
| 3411 return setTimeout( jQuery.ready ); | |
| 3412 } | |
| 3413 | |
| 3414 // Remember that the DOM is ready | |
| 3415 jQuery.isReady = true; | |
| 3416 | |
| 3417 // If a normal DOM Ready event fired, decrement, and wait if need be | |
| 3418 if ( wait !== true && --jQuery.readyWait > 0 ) { | |
| 3419 return; | |
| 3420 } | |
| 3421 | |
| 3422 // If there are functions bound, to execute | |
| 3423 readyList.resolveWith( document, [ jQuery ] ); | |
| 3424 | |
| 3425 // Trigger any bound ready events | |
| 3426 if ( jQuery.fn.trigger ) { | |
| 3427 jQuery( document ).trigger("ready").off("ready"); | |
| 3428 } | |
| 3429 } | |
| 3430 }); | |
| 3431 | |
| 3432 /** | |
| 3433 * Clean-up method for dom ready events | |
| 3434 */ | |
| 3435 function detach() { | |
| 3436 if ( document.addEventListener ) { | |
| 3437 document.removeEventListener( "DOMContentLoaded", completed, false ); | |
| 3438 window.removeEventListener( "load", completed, false ); | |
| 3439 | |
| 3440 } else { | |
| 3441 document.detachEvent( "onreadystatechange", completed ); | |
| 3442 window.detachEvent( "onload", completed ); | |
| 3443 } | |
| 3444 } | |
| 3445 | |
| 3446 /** | |
| 3447 * The ready event handler and self cleanup method | |
| 3448 */ | |
| 3449 function completed() { | |
| 3450 // readyState === "complete" is good enough for us to call the dom ready in oldIE | |
| 3451 if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) { | |
| 3452 detach(); | |
| 3453 jQuery.ready(); | |
| 3454 } | |
| 3455 } | |
| 3456 | |
| 3457 jQuery.ready.promise = function( obj ) { | |
| 3458 if ( !readyList ) { | |
| 3459 | |
| 3460 readyList = jQuery.Deferred(); | |
| 3461 | |
| 3462 // Catch cases where $(document).ready() is called after the browser event has already occurred. | |
| 3463 // we once tried to use readyState "interactive" here, but it caused issues like the one | |
| 3464 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 | |
| 3465 if ( document.readyState === "complete" ) { | |
| 3466 // Handle it asynchronously to allow scripts the opportunity to delay ready | |
| 3467 setTimeout( jQuery.ready ); | |
| 3468 | |
| 3469 // Standards-based browsers support DOMContentLoaded | |
| 3470 } else if ( document.addEventListener ) { | |
| 3471 // Use the handy event callback | |
| 3472 document.addEventListener( "DOMContentLoaded", completed, false ); | |
| 3473 | |
| 3474 // A fallback to window.onload, that will always work | |
| 3475 window.addEventListener( "load", completed, false ); | |
| 3476 | |
| 3477 // If IE event model is used | |
| 3478 } else { | |
| 3479 // Ensure firing before onload, maybe late but safe also for iframes | |
| 3480 document.attachEvent( "onreadystatechange", completed ); | |
| 3481 | |
| 3482 // A fallback to window.onload, that will always work | |
| 3483 window.attachEvent( "onload", completed ); | |
| 3484 | |
| 3485 // If IE and not a frame | |
| 3486 // continually check to see if the document is ready | |
| 3487 var top = false; | |
| 3488 | |
| 3489 try { | |
| 3490 top = window.frameElement == null && document.documentElement; | |
| 3491 } catch(e) {} | |
| 3492 | |
| 3493 if ( top && top.doScroll ) { | |
| 3494 (function doScrollCheck() { | |
| 3495 if ( !jQuery.isReady ) { | |
| 3496 | |
| 3497 try { | |
| 3498 // Use the trick by Diego Perini | |
| 3499 // http://javascript.nwbox.com/IEContentLoaded/ | |
| 3500 top.doScroll("left"); | |
| 3501 } catch(e) { | |
| 3502 return setTimeout( doScrollCheck, 50 ); | |
| 3503 } | |
| 3504 | |
| 3505 // detach all dom ready events | |
| 3506 detach(); | |
| 3507 | |
| 3508 // and execute any waiting functions | |
| 3509 jQuery.ready(); | |
| 3510 } | |
| 3511 })(); | |
| 3512 } | |
| 3513 } | |
| 3514 } | |
| 3515 return readyList.promise( obj ); | |
| 3516 }; | |
| 3517 | |
| 3518 | |
| 3519 var strundefined = typeof undefined; | |
| 3520 | |
| 3521 | |
| 3522 | |
| 3523 // Support: IE<9 | |
| 3524 // Iteration over object's inherited properties before its own | |
| 3525 var i; | |
| 3526 for ( i in jQuery( support ) ) { | |
| 3527 break; | |
| 3528 } | |
| 3529 support.ownLast = i !== "0"; | |
| 3530 | |
| 3531 // Note: most support tests are defined in their respective modules. | |
| 3532 // false until the test is run | |
| 3533 support.inlineBlockNeedsLayout = false; | |
| 3534 | |
| 3535 jQuery(function() { | |
| 3536 // We need to execute this one support test ASAP because we need to know | |
| 3537 // if body.style.zoom needs to be set. | |
| 3538 | |
| 3539 var container, div, | |
| 3540 body = document.getElementsByTagName("body")[0]; | |
| 3541 | |
| 3542 if ( !body ) { | |
| 3543 // Return for frameset docs that don't have a body | |
| 3544 return; | |
| 3545 } | |
| 3546 | |
| 3547 // Setup | |
| 3548 container = document.createElement( "div" ); | |
| 3549 container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px"; | |
| 3550 | |
| 3551 div = document.createElement( "div" ); | |
| 3552 body.appendChild( container ).appendChild( div ); | |
| 3553 | |
| 3554 if ( typeof div.style.zoom !== strundefined ) { | |
| 3555 // Support: IE<8 | |
| 3556 // Check if natively block-level elements act like inline-block | |
| 3557 // elements when setting their display to 'inline' and giving | |
| 3558 // them layout | |
| 3559 div.style.cssText = "border:0;margin:0;width:1px;padding:1px;display:inline;zoom:1"; | |
| 3560 | |
| 3561 if ( (support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 )) ) { | |
| 3562 // Prevent IE 6 from affecting layout for positioned elements #11048 | |
| 3563 // Prevent IE from shrinking the body in IE 7 mode #12869 | |
| 3564 // Support: IE<8 | |
| 3565 body.style.zoom = 1; | |
| 3566 } | |
| 3567 } | |
| 3568 | |
| 3569 body.removeChild( container ); | |
| 3570 | |
| 3571 // Null elements to avoid leaks in IE | |
| 3572 container = div = null; | |
| 3573 }); | |
| 3574 | |
| 3575 | |
| 3576 | |
| 3577 | |
| 3578 (function() { | |
| 3579 var div = document.createElement( "div" ); | |
| 3580 | |
| 3581 // Execute the test only if not already executed in another module. | |
| 3582 if (support.deleteExpando == null) { | |
| 3583 // Support: IE<9 | |
| 3584 support.deleteExpando = true; | |
| 3585 try { | |
| 3586 delete div.test; | |
| 3587 } catch( e ) { | |
| 3588 support.deleteExpando = false; | |
| 3589 } | |
| 3590 } | |
| 3591 | |
| 3592 // Null elements to avoid leaks in IE. | |
| 3593 div = null; | |
| 3594 })(); | |
| 3595 | |
| 3596 | |
| 3597 /** | |
| 3598 * Determines whether an object can have data | |
| 3599 */ | |
| 3600 jQuery.acceptData = function( elem ) { | |
| 3601 var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ], | |
| 3602 nodeType = +elem.nodeType || 1; | |
| 3603 | |
| 3604 // Do not set data on non-element DOM nodes because it will not be cleared (#8335). | |
| 3605 return nodeType !== 1 && nodeType !== 9 ? | |
| 3606 false : | |
| 3607 | |
| 3608 // Nodes accept data unless otherwise specified; rejection can be conditional | |
| 3609 !noData || noData !== true && elem.getAttribute("classid") === noData; | |
| 3610 }; | |
| 3611 | |
| 3612 | |
| 3613 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, | |
| 3614 rmultiDash = /([A-Z])/g; | |
| 3615 | |
| 3616 function dataAttr( elem, key, data ) { | |
| 3617 // If nothing was found internally, try to fetch any | |
| 3618 // data from the HTML5 data-* attribute | |
| 3619 if ( data === undefined && elem.nodeType === 1 ) { | |
| 3620 | |
| 3621 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); | |
| 3622 | |
| 3623 data = elem.getAttribute( name ); | |
| 3624 | |
| 3625 if ( typeof data === "string" ) { | |
| 3626 try { | |
| 3627 data = data === "true" ? true : | |
| 3628 data === "false" ? false : | |
| 3629 data === "null" ? null : | |
| 3630 // Only convert to a number if it doesn't change the string | |
| 3631 +data + "" === data ? +data : | |
| 3632 rbrace.test( data ) ? jQuery.parseJSON( data ) : | |
| 3633 data; | |
| 3634 } catch( e ) {} | |
| 3635 | |
| 3636 // Make sure we set the data so it isn't changed later | |
| 3637 jQuery.data( elem, key, data ); | |
| 3638 | |
| 3639 } else { | |
| 3640 data = undefined; | |
| 3641 } | |
| 3642 } | |
| 3643 | |
| 3644 return data; | |
| 3645 } | |
| 3646 | |
| 3647 // checks a cache object for emptiness | |
| 3648 function isEmptyDataObject( obj ) { | |
| 3649 var name; | |
| 3650 for ( name in obj ) { | |
| 3651 | |
| 3652 // if the public data object is empty, the private is still empty | |
| 3653 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { | |
| 3654 continue; | |
| 3655 } | |
| 3656 if ( name !== "toJSON" ) { | |
| 3657 return false; | |
| 3658 } | |
| 3659 } | |
| 3660 | |
| 3661 return true; | |
| 3662 } | |
| 3663 | |
| 3664 function internalData( elem, name, data, pvt /* Internal Use Only */ ) { | |
| 3665 if ( !jQuery.acceptData( elem ) ) { | |
| 3666 return; | |
| 3667 } | |
| 3668 | |
| 3669 var ret, thisCache, | |
| 3670 internalKey = jQuery.expando, | |
| 3671 | |
| 3672 // We have to handle DOM nodes and JS objects differently because IE6-7 | |
| 3673 // can't GC object references properly across the DOM-JS boundary | |
| 3674 isNode = elem.nodeType, | |
| 3675 | |
| 3676 // Only DOM nodes need the global jQuery cache; JS object data is | |
| 3677 // attached directly to the object so GC can occur automatically | |
| 3678 cache = isNode ? jQuery.cache : elem, | |
| 3679 | |
| 3680 // Only defining an ID for JS objects if its cache already exists allows | |
| 3681 // the code to shortcut on the same path as a DOM node with no cache | |
| 3682 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; | |
| 3683 | |
| 3684 // Avoid doing any more work than we need to when trying to get data on an | |
| 3685 // object that has no data at all | |
| 3686 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) { | |
| 3687 return; | |
| 3688 } | |
| 3689 | |
| 3690 if ( !id ) { | |
| 3691 // Only DOM nodes need a new unique ID for each element since their data | |
| 3692 // ends up in the global cache | |
| 3693 if ( isNode ) { | |
| 3694 id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++; | |
| 3695 } else { | |
| 3696 id = internalKey; | |
| 3697 } | |
| 3698 } | |
| 3699 | |
| 3700 if ( !cache[ id ] ) { | |
| 3701 // Avoid exposing jQuery metadata on plain JS objects when the object | |
| 3702 // is serialized using JSON.stringify | |
| 3703 cache[ id ] = isNode ? {} : { toJSON: jQuery.noop }; | |
| 3704 } | |
| 3705 | |
| 3706 // An object can be passed to jQuery.data instead of a key/value pair; this gets | |
| 3707 // shallow copied over onto the existing cache | |
| 3708 if ( typeof name === "object" || typeof name === "function" ) { | |
| 3709 if ( pvt ) { | |
| 3710 cache[ id ] = jQuery.extend( cache[ id ], name ); | |
| 3711 } else { | |
| 3712 cache[ id ].data = jQuery.extend( cache[ id ].data, name ); | |
| 3713 } | |
| 3714 } | |
| 3715 | |
| 3716 thisCache = cache[ id ]; | |
| 3717 | |
| 3718 // jQuery data() is stored in a separate object inside the object's internal data | |
| 3719 // cache in order to avoid key collisions between internal data and user-defined | |
| 3720 // data. | |
| 3721 if ( !pvt ) { | |
| 3722 if ( !thisCache.data ) { | |
| 3723 thisCache.data = {}; | |
| 3724 } | |
| 3725 | |
| 3726 thisCache = thisCache.data; | |
| 3727 } | |
| 3728 | |
| 3729 if ( data !== undefined ) { | |
| 3730 thisCache[ jQuery.camelCase( name ) ] = data; | |
| 3731 } | |
| 3732 | |
| 3733 // Check for both converted-to-camel and non-converted data property names | |
| 3734 // If a data property was specified | |
| 3735 if ( typeof name === "string" ) { | |
| 3736 | |
| 3737 // First Try to find as-is property data | |
| 3738 ret = thisCache[ name ]; | |
| 3739 | |
| 3740 // Test for null|undefined property data | |
| 3741 if ( ret == null ) { | |
| 3742 | |
| 3743 // Try to find the camelCased property | |
| 3744 ret = thisCache[ jQuery.camelCase( name ) ]; | |
| 3745 } | |
| 3746 } else { | |
| 3747 ret = thisCache; | |
| 3748 } | |
| 3749 | |
| 3750 return ret; | |
| 3751 } | |
| 3752 | |
| 3753 function internalRemoveData( elem, name, pvt ) { | |
| 3754 if ( !jQuery.acceptData( elem ) ) { | |
| 3755 return; | |
| 3756 } | |
| 3757 | |
| 3758 var thisCache, i, | |
| 3759 isNode = elem.nodeType, | |
| 3760 | |
| 3761 // See jQuery.data for more information | |
| 3762 cache = isNode ? jQuery.cache : elem, | |
| 3763 id = isNode ? elem[ jQuery.expando ] : jQuery.expando; | |
| 3764 | |
| 3765 // If there is already no cache entry for this object, there is no | |
| 3766 // purpose in continuing | |
| 3767 if ( !cache[ id ] ) { | |
| 3768 return; | |
| 3769 } | |
| 3770 | |
| 3771 if ( name ) { | |
| 3772 | |
| 3773 thisCache = pvt ? cache[ id ] : cache[ id ].data; | |
| 3774 | |
| 3775 if ( thisCache ) { | |
| 3776 | |
| 3777 // Support array or space separated string names for data keys | |
| 3778 if ( !jQuery.isArray( name ) ) { | |
| 3779 | |
| 3780 // try the string as a key before any manipulation | |
| 3781 if ( name in thisCache ) { | |
| 3782 name = [ name ]; | |
| 3783 } else { | |
| 3784 | |
| 3785 // split the camel cased version by spaces unless a key with the spaces exists | |
| 3786 name = jQuery.camelCase( name ); | |
| 3787 if ( name in thisCache ) { | |
| 3788 name = [ name ]; | |
| 3789 } else { | |
| 3790 name = name.split(" "); | |
| 3791 } | |
| 3792 } | |
| 3793 } else { | |
| 3794 // If "name" is an array of keys... | |
| 3795 // When data is initially created, via ("key", "val") signature, | |
| 3796 // keys will be converted to camelCase. | |
| 3797 // Since there is no way to tell _how_ a key was added, remove | |
| 3798 // both plain key and camelCase key. #12786 | |
| 3799 // This will only penalize the array argument path. | |
| 3800 name = name.concat( jQuery.map( name, jQuery.camelCase ) ); | |
| 3801 } | |
| 3802 | |
| 3803 i = name.length; | |
| 3804 while ( i-- ) { | |
| 3805 delete thisCache[ name[i] ]; | |
| 3806 } | |
| 3807 | |
| 3808 // If there is no data left in the cache, we want to continue | |
| 3809 // and let the cache object itself get destroyed | |
| 3810 if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) { | |
| 3811 return; | |
| 3812 } | |
| 3813 } | |
| 3814 } | |
| 3815 | |
| 3816 // See jQuery.data for more information | |
| 3817 if ( !pvt ) { | |
| 3818 delete cache[ id ].data; | |
| 3819 | |
| 3820 // Don't destroy the parent cache unless the internal data object | |
| 3821 // had been the only thing left in it | |
| 3822 if ( !isEmptyDataObject( cache[ id ] ) ) { | |
| 3823 return; | |
| 3824 } | |
| 3825 } | |
| 3826 | |
| 3827 // Destroy the cache | |
| 3828 if ( isNode ) { | |
| 3829 jQuery.cleanData( [ elem ], true ); | |
| 3830 | |
| 3831 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) | |
| 3832 /* jshint eqeqeq: false */ | |
| 3833 } else if ( support.deleteExpando || cache != cache.window ) { | |
| 3834 /* jshint eqeqeq: true */ | |
| 3835 delete cache[ id ]; | |
| 3836 | |
| 3837 // When all else fails, null | |
| 3838 } else { | |
| 3839 cache[ id ] = null; | |
| 3840 } | |
| 3841 } | |
| 3842 | |
| 3843 jQuery.extend({ | |
| 3844 cache: {}, | |
| 3845 | |
| 3846 // The following elements (space-suffixed to avoid Object.prototype collisions) | |
| 3847 // throw uncatchable exceptions if you attempt to set expando properties | |
| 3848 noData: { | |
| 3849 "applet ": true, | |
| 3850 "embed ": true, | |
| 3851 // ...but Flash objects (which have this classid) *can* handle expandos | |
| 3852 "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" | |
| 3853 }, | |
| 3854 | |
| 3855 hasData: function( elem ) { | |
| 3856 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; | |
| 3857 return !!elem && !isEmptyDataObject( elem ); | |
| 3858 }, | |
| 3859 | |
| 3860 data: function( elem, name, data ) { | |
| 3861 return internalData( elem, name, data ); | |
| 3862 }, | |
| 3863 | |
| 3864 removeData: function( elem, name ) { | |
| 3865 return internalRemoveData( elem, name ); | |
| 3866 }, | |
| 3867 | |
| 3868 // For internal use only. | |
| 3869 _data: function( elem, name, data ) { | |
| 3870 return internalData( elem, name, data, true ); | |
| 3871 }, | |
| 3872 | |
| 3873 _removeData: function( elem, name ) { | |
| 3874 return internalRemoveData( elem, name, true ); | |
| 3875 } | |
| 3876 }); | |
| 3877 | |
| 3878 jQuery.fn.extend({ | |
| 3879 data: function( key, value ) { | |
| 3880 var i, name, data, | |
| 3881 elem = this[0], | |
| 3882 attrs = elem && elem.attributes; | |
| 3883 | |
| 3884 // Special expections of .data basically thwart jQuery.access, | |
| 3885 // so implement the relevant behavior ourselves | |
| 3886 | |
| 3887 // Gets all values | |
| 3888 if ( key === undefined ) { | |
| 3889 if ( this.length ) { | |
| 3890 data = jQuery.data( elem ); | |
| 3891 | |
| 3892 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { | |
| 3893 i = attrs.length; | |
| 3894 while ( i-- ) { | |
| 3895 name = attrs[i].name; | |
| 3896 | |
| 3897 if ( name.indexOf("data-") === 0 ) { | |
| 3898 name = jQuery.camelCase( name.slice(5) ); | |
| 3899 | |
| 3900 dataAttr( elem, name, data[ name ] ); | |
| 3901 } | |
| 3902 } | |
| 3903 jQuery._data( elem, "parsedAttrs", true ); | |
| 3904 } | |
| 3905 } | |
| 3906 | |
| 3907 return data; | |
| 3908 } | |
| 3909 | |
| 3910 // Sets multiple values | |
| 3911 if ( typeof key === "object" ) { | |
| 3912 return this.each(function() { | |
| 3913 jQuery.data( this, key ); | |
| 3914 }); | |
| 3915 } | |
| 3916 | |
| 3917 return arguments.length > 1 ? | |
| 3918 | |
| 3919 // Sets one value | |
| 3920 this.each(function() { | |
| 3921 jQuery.data( this, key, value ); | |
| 3922 }) : | |
| 3923 | |
| 3924 // Gets one value | |
| 3925 // Try to fetch any internally stored data first | |
| 3926 elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined; | |
| 3927 }, | |
| 3928 | |
| 3929 removeData: function( key ) { | |
| 3930 return this.each(function() { | |
| 3931 jQuery.removeData( this, key ); | |
| 3932 }); | |
| 3933 } | |
| 3934 }); | |
| 3935 | |
| 3936 | |
| 3937 jQuery.extend({ | |
| 3938 queue: function( elem, type, data ) { | |
| 3939 var queue; | |
| 3940 | |
| 3941 if ( elem ) { | |
| 3942 type = ( type || "fx" ) + "queue"; | |
| 3943 queue = jQuery._data( elem, type ); | |
| 3944 | |
| 3945 // Speed up dequeue by getting out quickly if this is just a lookup | |
| 3946 if ( data ) { | |
| 3947 if ( !queue || jQuery.isArray(data) ) { | |
| 3948 queue = jQuery._data( elem, type, jQuery.makeArray(data) ); | |
| 3949 } else { | |
| 3950 queue.push( data ); | |
| 3951 } | |
| 3952 } | |
| 3953 return queue || []; | |
| 3954 } | |
| 3955 }, | |
| 3956 | |
| 3957 dequeue: function( elem, type ) { | |
| 3958 type = type || "fx"; | |
| 3959 | |
| 3960 var queue = jQuery.queue( elem, type ), | |
| 3961 startLength = queue.length, | |
| 3962 fn = queue.shift(), | |
| 3963 hooks = jQuery._queueHooks( elem, type ), | |
| 3964 next = function() { | |
| 3965 jQuery.dequeue( elem, type ); | |
| 3966 }; | |
| 3967 | |
| 3968 // If the fx queue is dequeued, always remove the progress sentinel | |
| 3969 if ( fn === "inprogress" ) { | |
| 3970 fn = queue.shift(); | |
| 3971 startLength--; | |
| 3972 } | |
| 3973 | |
| 3974 if ( fn ) { | |
| 3975 | |
| 3976 // Add a progress sentinel to prevent the fx queue from being | |
| 3977 // automatically dequeued | |
| 3978 if ( type === "fx" ) { | |
| 3979 queue.unshift( "inprogress" ); | |
| 3980 } | |
| 3981 | |
| 3982 // clear up the last queue stop function | |
| 3983 delete hooks.stop; | |
| 3984 fn.call( elem, next, hooks ); | |
| 3985 } | |
| 3986 | |
| 3987 if ( !startLength && hooks ) { | |
| 3988 hooks.empty.fire(); | |
| 3989 } | |
| 3990 }, | |
| 3991 | |
| 3992 // not intended for public consumption - generates a queueHooks object, or returns the current one | |
| 3993 _queueHooks: function( elem, type ) { | |
| 3994 var key = type + "queueHooks"; | |
| 3995 return jQuery._data( elem, key ) || jQuery._data( elem, key, { | |
| 3996 empty: jQuery.Callbacks("once memory").add(function() { | |
| 3997 jQuery._removeData( elem, type + "queue" ); | |
| 3998 jQuery._removeData( elem, key ); | |
| 3999 }) | |
| 4000 }); | |
| 4001 } | |
| 4002 }); | |
| 4003 | |
| 4004 jQuery.fn.extend({ | |
| 4005 queue: function( type, data ) { | |
| 4006 var setter = 2; | |
| 4007 | |
| 4008 if ( typeof type !== "string" ) { | |
| 4009 data = type; | |
| 4010 type = "fx"; | |
| 4011 setter--; | |
| 4012 } | |
| 4013 | |
| 4014 if ( arguments.length < setter ) { | |
| 4015 return jQuery.queue( this[0], type ); | |
| 4016 } | |
| 4017 | |
| 4018 return data === undefined ? | |
| 4019 this : | |
| 4020 this.each(function() { | |
| 4021 var queue = jQuery.queue( this, type, data ); | |
| 4022 | |
| 4023 // ensure a hooks for this queue | |
| 4024 jQuery._queueHooks( this, type ); | |
| 4025 | |
| 4026 if ( type === "fx" && queue[0] !== "inprogress" ) { | |
| 4027 jQuery.dequeue( this, type ); | |
| 4028 } | |
| 4029 }); | |
| 4030 }, | |
| 4031 dequeue: function( type ) { | |
| 4032 return this.each(function() { | |
| 4033 jQuery.dequeue( this, type ); | |
| 4034 }); | |
| 4035 }, | |
| 4036 clearQueue: function( type ) { | |
| 4037 return this.queue( type || "fx", [] ); | |
| 4038 }, | |
| 4039 // Get a promise resolved when queues of a certain type | |
| 4040 // are emptied (fx is the type by default) | |
| 4041 promise: function( type, obj ) { | |
| 4042 var tmp, | |
| 4043 count = 1, | |
| 4044 defer = jQuery.Deferred(), | |
| 4045 elements = this, | |
| 4046 i = this.length, | |
| 4047 resolve = function() { | |
| 4048 if ( !( --count ) ) { | |
| 4049 defer.resolveWith( elements, [ elements ] ); | |
| 4050 } | |
| 4051 }; | |
| 4052 | |
| 4053 if ( typeof type !== "string" ) { | |
| 4054 obj = type; | |
| 4055 type = undefined; | |
| 4056 } | |
| 4057 type = type || "fx"; | |
| 4058 | |
| 4059 while ( i-- ) { | |
| 4060 tmp = jQuery._data( elements[ i ], type + "queueHooks" ); | |
| 4061 if ( tmp && tmp.empty ) { | |
| 4062 count++; | |
| 4063 tmp.empty.add( resolve ); | |
| 4064 } | |
| 4065 } | |
| 4066 resolve(); | |
| 4067 return defer.promise( obj ); | |
| 4068 } | |
| 4069 }); | |
| 4070 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; | |
| 4071 | |
| 4072 var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; | |
| 4073 | |
| 4074 var isHidden = function( elem, el ) { | |
| 4075 // isHidden might be called from jQuery#filter function; | |
| 4076 // in that case, element will be second argument | |
| 4077 elem = el || elem; | |
| 4078 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); | |
| 4079 }; | |
| 4080 | |
| 4081 | |
| 4082 | |
| 4083 // Multifunctional method to get and set values of a collection | |
| 4084 // The value/s can optionally be executed if it's a function | |
| 4085 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { | |
| 4086 var i = 0, | |
| 4087 length = elems.length, | |
| 4088 bulk = key == null; | |
| 4089 | |
| 4090 // Sets many values | |
| 4091 if ( jQuery.type( key ) === "object" ) { | |
| 4092 chainable = true; | |
| 4093 for ( i in key ) { | |
| 4094 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); | |
| 4095 } | |
| 4096 | |
| 4097 // Sets one value | |
| 4098 } else if ( value !== undefined ) { | |
| 4099 chainable = true; | |
| 4100 | |
| 4101 if ( !jQuery.isFunction( value ) ) { | |
| 4102 raw = true; | |
| 4103 } | |
| 4104 | |
| 4105 if ( bulk ) { | |
| 4106 // Bulk operations run against the entire set | |
| 4107 if ( raw ) { | |
| 4108 fn.call( elems, value ); | |
| 4109 fn = null; | |
| 4110 | |
| 4111 // ...except when executing function values | |
| 4112 } else { | |
| 4113 bulk = fn; | |
| 4114 fn = function( elem, key, value ) { | |
| 4115 return bulk.call( jQuery( elem ), value ); | |
| 4116 }; | |
| 4117 } | |
| 4118 } | |
| 4119 | |
| 4120 if ( fn ) { | |
| 4121 for ( ; i < length; i++ ) { | |
| 4122 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); | |
| 4123 } | |
| 4124 } | |
| 4125 } | |
| 4126 | |
| 4127 return chainable ? | |
| 4128 elems : | |
| 4129 | |
| 4130 // Gets | |
| 4131 bulk ? | |
| 4132 fn.call( elems ) : | |
| 4133 length ? fn( elems[0], key ) : emptyGet; | |
| 4134 }; | |
| 4135 var rcheckableType = (/^(?:checkbox|radio)$/i); | |
| 4136 | |
| 4137 | |
| 4138 | |
| 4139 (function() { | |
| 4140 var fragment = document.createDocumentFragment(), | |
| 4141 div = document.createElement("div"), | |
| 4142 input = document.createElement("input"); | |
| 4143 | |
| 4144 // Setup | |
| 4145 div.setAttribute( "className", "t" ); | |
| 4146 div.innerHTML = " <link/><table></table><a href='/a'>a</a>"; | |
| 4147 | |
| 4148 // IE strips leading whitespace when .innerHTML is used | |
| 4149 support.leadingWhitespace = div.firstChild.nodeType === 3; | |
| 4150 | |
| 4151 // Make sure that tbody elements aren't automatically inserted | |
| 4152 // IE will insert them into empty tables | |
| 4153 support.tbody = !div.getElementsByTagName( "tbody" ).length; | |
| 4154 | |
| 4155 // Make sure that link elements get serialized correctly by innerHTML | |
| 4156 // This requires a wrapper element in IE | |
| 4157 support.htmlSerialize = !!div.getElementsByTagName( "link" ).length; | |
| 4158 | |
| 4159 // Makes sure cloning an html5 element does not cause problems | |
| 4160 // Where outerHTML is undefined, this still works | |
| 4161 support.html5Clone = | |
| 4162 document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>"; | |
| 4163 | |
| 4164 // Check if a disconnected checkbox will retain its checked | |
| 4165 // value of true after appended to the DOM (IE6/7) | |
| 4166 input.type = "checkbox"; | |
| 4167 input.checked = true; | |
| 4168 fragment.appendChild( input ); | |
| 4169 support.appendChecked = input.checked; | |
| 4170 | |
| 4171 // Make sure textarea (and checkbox) defaultValue is properly cloned | |
| 4172 // Support: IE6-IE11+ | |
| 4173 div.innerHTML = "<textarea>x</textarea>"; | |
| 4174 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; | |
| 4175 | |
| 4176 // #11217 - WebKit loses check when the name is after the checked attribute | |
| 4177 fragment.appendChild( div ); | |
| 4178 div.innerHTML = "<input type='radio' checked='checked' name='t'/>"; | |
| 4179 | |
| 4180 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 | |
| 4181 // old WebKit doesn't clone checked state correctly in fragments | |
| 4182 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; | |
| 4183 | |
| 4184 // Support: IE<9 | |
| 4185 // Opera does not clone events (and typeof div.attachEvent === undefined). | |
| 4186 // IE9-10 clones events bound via attachEvent, but they don't trigger with .click() | |
| 4187 support.noCloneEvent = true; | |
| 4188 if ( div.attachEvent ) { | |
| 4189 div.attachEvent( "onclick", function() { | |
| 4190 support.noCloneEvent = false; | |
| 4191 }); | |
| 4192 | |
| 4193 div.cloneNode( true ).click(); | |
| 4194 } | |
| 4195 | |
| 4196 // Execute the test only if not already executed in another module. | |
| 4197 if (support.deleteExpando == null) { | |
| 4198 // Support: IE<9 | |
| 4199 support.deleteExpando = true; | |
| 4200 try { | |
| 4201 delete div.test; | |
| 4202 } catch( e ) { | |
| 4203 support.deleteExpando = false; | |
| 4204 } | |
| 4205 } | |
| 4206 | |
| 4207 // Null elements to avoid leaks in IE. | |
| 4208 fragment = div = input = null; | |
| 4209 })(); | |
| 4210 | |
| 4211 | |
| 4212 (function() { | |
| 4213 var i, eventName, | |
| 4214 div = document.createElement( "div" ); | |
| 4215 | |
| 4216 // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event) | |
| 4217 for ( i in { submit: true, change: true, focusin: true }) { | |
| 4218 eventName = "on" + i; | |
| 4219 | |
| 4220 if ( !(support[ i + "Bubbles" ] = eventName in window) ) { | |
| 4221 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP) | |
| 4222 div.setAttribute( eventName, "t" ); | |
| 4223 support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false; | |
| 4224 } | |
| 4225 } | |
| 4226 | |
| 4227 // Null elements to avoid leaks in IE. | |
| 4228 div = null; | |
| 4229 })(); | |
| 4230 | |
| 4231 | |
| 4232 var rformElems = /^(?:input|select|textarea)$/i, | |
| 4233 rkeyEvent = /^key/, | |
| 4234 rmouseEvent = /^(?:mouse|contextmenu)|click/, | |
| 4235 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, | |
| 4236 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; | |
| 4237 | |
| 4238 function returnTrue() { | |
| 4239 return true; | |
| 4240 } | |
| 4241 | |
| 4242 function returnFalse() { | |
| 4243 return false; | |
| 4244 } | |
| 4245 | |
| 4246 function safeActiveElement() { | |
| 4247 try { | |
| 4248 return document.activeElement; | |
| 4249 } catch ( err ) { } | |
| 4250 } | |
| 4251 | |
| 4252 /* | |
| 4253 * Helper functions for managing events -- not part of the public interface. | |
| 4254 * Props to Dean Edwards' addEvent library for many of the ideas. | |
| 4255 */ | |
| 4256 jQuery.event = { | |
| 4257 | |
| 4258 global: {}, | |
| 4259 | |
| 4260 add: function( elem, types, handler, data, selector ) { | |
| 4261 var tmp, events, t, handleObjIn, | |
| 4262 special, eventHandle, handleObj, | |
| 4263 handlers, type, namespaces, origType, | |
| 4264 elemData = jQuery._data( elem ); | |
| 4265 | |
| 4266 // Don't attach events to noData or text/comment nodes (but allow plain objects) | |
| 4267 if ( !elemData ) { | |
| 4268 return; | |
| 4269 } | |
| 4270 | |
| 4271 // Caller can pass in an object of custom data in lieu of the handler | |
| 4272 if ( handler.handler ) { | |
| 4273 handleObjIn = handler; | |
| 4274 handler = handleObjIn.handler; | |
| 4275 selector = handleObjIn.selector; | |
| 4276 } | |
| 4277 | |
| 4278 // Make sure that the handler has a unique ID, used to find/remove it later | |
| 4279 if ( !handler.guid ) { | |
| 4280 handler.guid = jQuery.guid++; | |
| 4281 } | |
| 4282 | |
| 4283 // Init the element's event structure and main handler, if this is the first | |
| 4284 if ( !(events = elemData.events) ) { | |
| 4285 events = elemData.events = {}; | |
| 4286 } | |
| 4287 if ( !(eventHandle = elemData.handle) ) { | |
| 4288 eventHandle = elemData.handle = function( e ) { | |
| 4289 // Discard the second event of a jQuery.event.trigger() and | |
| 4290 // when an event is called after a page has unloaded | |
| 4291 return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ? | |
| 4292 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : | |
| 4293 undefined; | |
| 4294 }; | |
| 4295 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events | |
| 4296 eventHandle.elem = elem; | |
| 4297 } | |
| 4298 | |
| 4299 // Handle multiple events separated by a space | |
| 4300 types = ( types || "" ).match( rnotwhite ) || [ "" ]; | |
| 4301 t = types.length; | |
| 4302 while ( t-- ) { | |
| 4303 tmp = rtypenamespace.exec( types[t] ) || []; | |
| 4304 type = origType = tmp[1]; | |
| 4305 namespaces = ( tmp[2] || "" ).split( "." ).sort(); | |
| 4306 | |
| 4307 // There *must* be a type, no attaching namespace-only handlers | |
| 4308 if ( !type ) { | |
| 4309 continue; | |
| 4310 } | |
| 4311 | |
| 4312 // If event changes its type, use the special event handlers for the changed type | |
| 4313 special = jQuery.event.special[ type ] || {}; | |
| 4314 | |
| 4315 // If selector defined, determine special event api type, otherwise given type | |
| 4316 type = ( selector ? special.delegateType : special.bindType ) || type; | |
| 4317 | |
| 4318 // Update special based on newly reset type | |
| 4319 special = jQuery.event.special[ type ] || {}; | |
| 4320 | |
| 4321 // handleObj is passed to all event handlers | |
| 4322 handleObj = jQuery.extend({ | |
| 4323 type: type, | |
| 4324 origType: origType, | |
| 4325 data: data, | |
| 4326 handler: handler, | |
| 4327 guid: handler.guid, | |
| 4328 selector: selector, | |
| 4329 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), | |
| 4330 namespace: namespaces.join(".") | |
| 4331 }, handleObjIn ); | |
| 4332 | |
| 4333 // Init the event handler queue if we're the first | |
| 4334 if ( !(handlers = events[ type ]) ) { | |
| 4335 handlers = events[ type ] = []; | |
| 4336 handlers.delegateCount = 0; | |
| 4337 | |
| 4338 // Only use addEventListener/attachEvent if the special events handler returns false | |
| 4339 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { | |
| 4340 // Bind the global event handler to the element | |
| 4341 if ( elem.addEventListener ) { | |
| 4342 elem.addEventListener( type, eventHandle, false ); | |
| 4343 | |
| 4344 } else if ( elem.attachEvent ) { | |
| 4345 elem.attachEvent( "on" + type, eventHandle ); | |
| 4346 } | |
| 4347 } | |
| 4348 } | |
| 4349 | |
| 4350 if ( special.add ) { | |
| 4351 special.add.call( elem, handleObj ); | |
| 4352 | |
| 4353 if ( !handleObj.handler.guid ) { | |
| 4354 handleObj.handler.guid = handler.guid; | |
| 4355 } | |
| 4356 } | |
| 4357 | |
| 4358 // Add to the element's handler list, delegates in front | |
| 4359 if ( selector ) { | |
| 4360 handlers.splice( handlers.delegateCount++, 0, handleObj ); | |
| 4361 } else { | |
| 4362 handlers.push( handleObj ); | |
| 4363 } | |
| 4364 | |
| 4365 // Keep track of which events have ever been used, for event optimization | |
| 4366 jQuery.event.global[ type ] = true; | |
| 4367 } | |
| 4368 | |
| 4369 // Nullify elem to prevent memory leaks in IE | |
| 4370 elem = null; | |
| 4371 }, | |
| 4372 | |
| 4373 // Detach an event or set of events from an element | |
| 4374 remove: function( elem, types, handler, selector, mappedTypes ) { | |
| 4375 var j, handleObj, tmp, | |
| 4376 origCount, t, events, | |
| 4377 special, handlers, type, | |
| 4378 namespaces, origType, | |
| 4379 elemData = jQuery.hasData( elem ) && jQuery._data( elem ); | |
| 4380 | |
| 4381 if ( !elemData || !(events = elemData.events) ) { | |
| 4382 return; | |
| 4383 } | |
| 4384 | |
| 4385 // Once for each type.namespace in types; type may be omitted | |
| 4386 types = ( types || "" ).match( rnotwhite ) || [ "" ]; | |
| 4387 t = types.length; | |
| 4388 while ( t-- ) { | |
| 4389 tmp = rtypenamespace.exec( types[t] ) || []; | |
| 4390 type = origType = tmp[1]; | |
| 4391 namespaces = ( tmp[2] || "" ).split( "." ).sort(); | |
| 4392 | |
| 4393 // Unbind all events (on this namespace, if provided) for the element | |
| 4394 if ( !type ) { | |
| 4395 for ( type in events ) { | |
| 4396 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); | |
| 4397 } | |
| 4398 continue; | |
| 4399 } | |
| 4400 | |
| 4401 special = jQuery.event.special[ type ] || {}; | |
| 4402 type = ( selector ? special.delegateType : special.bindType ) || type; | |
| 4403 handlers = events[ type ] || []; | |
| 4404 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); | |
| 4405 | |
| 4406 // Remove matching events | |
| 4407 origCount = j = handlers.length; | |
| 4408 while ( j-- ) { | |
| 4409 handleObj = handlers[ j ]; | |
| 4410 | |
| 4411 if ( ( mappedTypes || origType === handleObj.origType ) && | |
| 4412 ( !handler || handler.guid === handleObj.guid ) && | |
| 4413 ( !tmp || tmp.test( handleObj.namespace ) ) && | |
| 4414 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { | |
| 4415 handlers.splice( j, 1 ); | |
| 4416 | |
| 4417 if ( handleObj.selector ) { | |
| 4418 handlers.delegateCount--; | |
| 4419 } | |
| 4420 if ( special.remove ) { | |
| 4421 special.remove.call( elem, handleObj ); | |
| 4422 } | |
| 4423 } | |
| 4424 } | |
| 4425 | |
| 4426 // Remove generic event handler if we removed something and no more handlers exist | |
| 4427 // (avoids potential for endless recursion during removal of special event handlers) | |
| 4428 if ( origCount && !handlers.length ) { | |
| 4429 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { | |
| 4430 jQuery.removeEvent( elem, type, elemData.handle ); | |
| 4431 } | |
| 4432 | |
| 4433 delete events[ type ]; | |
| 4434 } | |
| 4435 } | |
| 4436 | |
| 4437 // Remove the expando if it's no longer used | |
| 4438 if ( jQuery.isEmptyObject( events ) ) { | |
| 4439 delete elemData.handle; | |
| 4440 | |
| 4441 // removeData also checks for emptiness and clears the expando if empty | |
| 4442 // so use it instead of delete | |
| 4443 jQuery._removeData( elem, "events" ); | |
| 4444 } | |
| 4445 }, | |
| 4446 | |
| 4447 trigger: function( event, data, elem, onlyHandlers ) { | |
| 4448 var handle, ontype, cur, | |
| 4449 bubbleType, special, tmp, i, | |
| 4450 eventPath = [ elem || document ], | |
| 4451 type = hasOwn.call( event, "type" ) ? event.type : event, | |
| 4452 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; | |
| 4453 | |
| 4454 cur = tmp = elem = elem || document; | |
| 4455 | |
| 4456 // Don't do events on text and comment nodes | |
| 4457 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { | |
| 4458 return; | |
| 4459 } | |
| 4460 | |
| 4461 // focus/blur morphs to focusin/out; ensure we're not firing them right now | |
| 4462 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { | |
| 4463 return; | |
| 4464 } | |
| 4465 | |
| 4466 if ( type.indexOf(".") >= 0 ) { | |
| 4467 // Namespaced trigger; create a regexp to match event type in handle() | |
| 4468 namespaces = type.split("."); | |
| 4469 type = namespaces.shift(); | |
| 4470 namespaces.sort(); | |
| 4471 } | |
| 4472 ontype = type.indexOf(":") < 0 && "on" + type; | |
| 4473 | |
| 4474 // Caller can pass in a jQuery.Event object, Object, or just an event type string | |
| 4475 event = event[ jQuery.expando ] ? | |
| 4476 event : | |
| 4477 new jQuery.Event( type, typeof event === "object" && event ); | |
| 4478 | |
| 4479 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) | |
| 4480 event.isTrigger = onlyHandlers ? 2 : 3; | |
| 4481 event.namespace = namespaces.join("."); | |
| 4482 event.namespace_re = event.namespace ? | |
| 4483 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : | |
| 4484 null; | |
| 4485 | |
| 4486 // Clean up the event in case it is being reused | |
| 4487 event.result = undefined; | |
| 4488 if ( !event.target ) { | |
| 4489 event.target = elem; | |
| 4490 } | |
| 4491 | |
| 4492 // Clone any incoming data and prepend the event, creating the handler arg list | |
| 4493 data = data == null ? | |
| 4494 [ event ] : | |
| 4495 jQuery.makeArray( data, [ event ] ); | |
| 4496 | |
| 4497 // Allow special events to draw outside the lines | |
| 4498 special = jQuery.event.special[ type ] || {}; | |
| 4499 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { | |
| 4500 return; | |
| 4501 } | |
| 4502 | |
| 4503 // Determine event propagation path in advance, per W3C events spec (#9951) | |
| 4504 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) | |
| 4505 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { | |
| 4506 | |
| 4507 bubbleType = special.delegateType || type; | |
| 4508 if ( !rfocusMorph.test( bubbleType + type ) ) { | |
| 4509 cur = cur.parentNode; | |
| 4510 } | |
| 4511 for ( ; cur; cur = cur.parentNode ) { | |
| 4512 eventPath.push( cur ); | |
| 4513 tmp = cur; | |
| 4514 } | |
| 4515 | |
| 4516 // Only add window if we got to document (e.g., not plain obj or detached DOM) | |
| 4517 if ( tmp === (elem.ownerDocument || document) ) { | |
| 4518 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); | |
| 4519 } | |
| 4520 } | |
| 4521 | |
| 4522 // Fire handlers on the event path | |
| 4523 i = 0; | |
| 4524 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { | |
| 4525 | |
| 4526 event.type = i > 1 ? | |
| 4527 bubbleType : | |
| 4528 special.bindType || type; | |
| 4529 | |
| 4530 // jQuery handler | |
| 4531 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); | |
| 4532 if ( handle ) { | |
| 4533 handle.apply( cur, data ); | |
| 4534 } | |
| 4535 | |
| 4536 // Native handler | |
| 4537 handle = ontype && cur[ ontype ]; | |
| 4538 if ( handle && handle.apply && jQuery.acceptData( cur ) ) { | |
| 4539 event.result = handle.apply( cur, data ); | |
| 4540 if ( event.result === false ) { | |
| 4541 event.preventDefault(); | |
| 4542 } | |
| 4543 } | |
| 4544 } | |
| 4545 event.type = type; | |
| 4546 | |
| 4547 // If nobody prevented the default action, do it now | |
| 4548 if ( !onlyHandlers && !event.isDefaultPrevented() ) { | |
| 4549 | |
| 4550 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && | |
| 4551 jQuery.acceptData( elem ) ) { | |
| 4552 | |
| 4553 // Call a native DOM method on the target with the same name name as the event. | |
| 4554 // Can't use an .isFunction() check here because IE6/7 fails that test. | |
| 4555 // Don't do default actions on window, that's where global variables be (#6170) | |
| 4556 if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { | |
| 4557 | |
| 4558 // Don't re-trigger an onFOO event when we call its FOO() method | |
| 4559 tmp = elem[ ontype ]; | |
| 4560 | |
| 4561 if ( tmp ) { | |
| 4562 elem[ ontype ] = null; | |
| 4563 } | |
| 4564 | |
| 4565 // Prevent re-triggering of the same event, since we already bubbled it above | |
| 4566 jQuery.event.triggered = type; | |
| 4567 try { | |
| 4568 elem[ type ](); | |
| 4569 } catch ( e ) { | |
| 4570 // IE<9 dies on focus/blur to hidden element (#1486,#12518) | |
| 4571 // only reproducible on winXP IE8 native, not IE9 in IE8 mode | |
| 4572 } | |
| 4573 jQuery.event.triggered = undefined; | |
| 4574 | |
| 4575 if ( tmp ) { | |
| 4576 elem[ ontype ] = tmp; | |
| 4577 } | |
| 4578 } | |
| 4579 } | |
| 4580 } | |
| 4581 | |
| 4582 return event.result; | |
| 4583 }, | |
| 4584 | |
| 4585 dispatch: function( event ) { | |
| 4586 | |
| 4587 // Make a writable jQuery.Event from the native event object | |
| 4588 event = jQuery.event.fix( event ); | |
| 4589 | |
| 4590 var i, ret, handleObj, matched, j, | |
| 4591 handlerQueue = [], | |
| 4592 args = slice.call( arguments ), | |
| 4593 handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [], | |
| 4594 special = jQuery.event.special[ event.type ] || {}; | |
| 4595 | |
| 4596 // Use the fix-ed jQuery.Event rather than the (read-only) native event | |
| 4597 args[0] = event; | |
| 4598 event.delegateTarget = this; | |
| 4599 | |
| 4600 // Call the preDispatch hook for the mapped type, and let it bail if desired | |
| 4601 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { | |
| 4602 return; | |
| 4603 } | |
| 4604 | |
| 4605 // Determine handlers | |
| 4606 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); | |
| 4607 | |
| 4608 // Run delegates first; they may want to stop propagation beneath us | |
| 4609 i = 0; | |
| 4610 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { | |
| 4611 event.currentTarget = matched.elem; | |
| 4612 | |
| 4613 j = 0; | |
| 4614 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { | |
| 4615 | |
| 4616 // Triggered event must either 1) have no namespace, or | |
| 4617 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). | |
| 4618 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { | |
| 4619 | |
| 4620 event.handleObj = handleObj; | |
| 4621 event.data = handleObj.data; | |
| 4622 | |
| 4623 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) | |
| 4624 .apply( matched.elem, args ); | |
| 4625 | |
| 4626 if ( ret !== undefined ) { | |
| 4627 if ( (event.result = ret) === false ) { | |
| 4628 event.preventDefault(); | |
| 4629 event.stopPropagation(); | |
| 4630 } | |
| 4631 } | |
| 4632 } | |
| 4633 } | |
| 4634 } | |
| 4635 | |
| 4636 // Call the postDispatch hook for the mapped type | |
| 4637 if ( special.postDispatch ) { | |
| 4638 special.postDispatch.call( this, event ); | |
| 4639 } | |
| 4640 | |
| 4641 return event.result; | |
| 4642 }, | |
| 4643 | |
| 4644 handlers: function( event, handlers ) { | |
| 4645 var sel, handleObj, matches, i, | |
| 4646 handlerQueue = [], | |
| 4647 delegateCount = handlers.delegateCount, | |
| 4648 cur = event.target; | |
| 4649 | |
| 4650 // Find delegate handlers | |
| 4651 // Black-hole SVG <use> instance trees (#13180) | |
| 4652 // Avoid non-left-click bubbling in Firefox (#3861) | |
| 4653 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { | |
| 4654 | |
| 4655 /* jshint eqeqeq: false */ | |
| 4656 for ( ; cur != this; cur = cur.parentNode || this ) { | |
| 4657 /* jshint eqeqeq: true */ | |
| 4658 | |
| 4659 // Don't check non-elements (#13208) | |
| 4660 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) | |
| 4661 if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) { | |
| 4662 matches = []; | |
| 4663 for ( i = 0; i < delegateCount; i++ ) { | |
| 4664 handleObj = handlers[ i ]; | |
| 4665 | |
| 4666 // Don't conflict with Object.prototype properties (#13203) | |
| 4667 sel = handleObj.selector + " "; | |
| 4668 | |
| 4669 if ( matches[ sel ] === undefined ) { | |
| 4670 matches[ sel ] = handleObj.needsContext ? | |
| 4671 jQuery( sel, this ).index( cur ) >= 0 : | |
| 4672 jQuery.find( sel, this, null, [ cur ] ).length; | |
| 4673 } | |
| 4674 if ( matches[ sel ] ) { | |
| 4675 matches.push( handleObj ); | |
| 4676 } | |
| 4677 } | |
| 4678 if ( matches.length ) { | |
| 4679 handlerQueue.push({ elem: cur, handlers: matches }); | |
| 4680 } | |
| 4681 } | |
| 4682 } | |
| 4683 } | |
| 4684 | |
| 4685 // Add the remaining (directly-bound) handlers | |
| 4686 if ( delegateCount < handlers.length ) { | |
| 4687 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); | |
| 4688 } | |
| 4689 | |
| 4690 return handlerQueue; | |
| 4691 }, | |
| 4692 | |
| 4693 fix: function( event ) { | |
| 4694 if ( event[ jQuery.expando ] ) { | |
| 4695 return event; | |
| 4696 } | |
| 4697 | |
| 4698 // Create a writable copy of the event object and normalize some properties | |
| 4699 var i, prop, copy, | |
| 4700 type = event.type, | |
| 4701 originalEvent = event, | |
| 4702 fixHook = this.fixHooks[ type ]; | |
| 4703 | |
| 4704 if ( !fixHook ) { | |
| 4705 this.fixHooks[ type ] = fixHook = | |
| 4706 rmouseEvent.test( type ) ? this.mouseHooks : | |
| 4707 rkeyEvent.test( type ) ? this.keyHooks : | |
| 4708 {}; | |
| 4709 } | |
| 4710 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; | |
| 4711 | |
| 4712 event = new jQuery.Event( originalEvent ); | |
| 4713 | |
| 4714 i = copy.length; | |
| 4715 while ( i-- ) { | |
| 4716 prop = copy[ i ]; | |
| 4717 event[ prop ] = originalEvent[ prop ]; | |
| 4718 } | |
| 4719 | |
| 4720 // Support: IE<9 | |
| 4721 // Fix target property (#1925) | |
| 4722 if ( !event.target ) { | |
| 4723 event.target = originalEvent.srcElement || document; | |
| 4724 } | |
| 4725 | |
| 4726 // Support: Chrome 23+, Safari? | |
| 4727 // Target should not be a text node (#504, #13143) | |
| 4728 if ( event.target.nodeType === 3 ) { | |
| 4729 event.target = event.target.parentNode; | |
| 4730 } | |
| 4731 | |
| 4732 // Support: IE<9 | |
| 4733 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328) | |
| 4734 event.metaKey = !!event.metaKey; | |
| 4735 | |
| 4736 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; | |
| 4737 }, | |
| 4738 | |
| 4739 // Includes some event props shared by KeyEvent and MouseEvent | |
| 4740 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), | |
| 4741 | |
| 4742 fixHooks: {}, | |
| 4743 | |
| 4744 keyHooks: { | |
| 4745 props: "char charCode key keyCode".split(" "), | |
| 4746 filter: function( event, original ) { | |
| 4747 | |
| 4748 // Add which for key events | |
| 4749 if ( event.which == null ) { | |
| 4750 event.which = original.charCode != null ? original.charCode : original.keyCode; | |
| 4751 } | |
| 4752 | |
| 4753 return event; | |
| 4754 } | |
| 4755 }, | |
| 4756 | |
| 4757 mouseHooks: { | |
| 4758 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), | |
| 4759 filter: function( event, original ) { | |
| 4760 var body, eventDoc, doc, | |
| 4761 button = original.button, | |
| 4762 fromElement = original.fromElement; | |
| 4763 | |
| 4764 // Calculate pageX/Y if missing and clientX/Y available | |
| 4765 if ( event.pageX == null && original.clientX != null ) { | |
| 4766 eventDoc = event.target.ownerDocument || document; | |
| 4767 doc = eventDoc.documentElement; | |
| 4768 body = eventDoc.body; | |
| 4769 | |
| 4770 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); | |
| 4771 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); | |
| 4772 } | |
| 4773 | |
| 4774 // Add relatedTarget, if necessary | |
| 4775 if ( !event.relatedTarget && fromElement ) { | |
| 4776 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; | |
| 4777 } | |
| 4778 | |
| 4779 // Add which for click: 1 === left; 2 === middle; 3 === right | |
| 4780 // Note: button is not normalized, so don't use it | |
| 4781 if ( !event.which && button !== undefined ) { | |
| 4782 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); | |
| 4783 } | |
| 4784 | |
| 4785 return event; | |
| 4786 } | |
| 4787 }, | |
| 4788 | |
| 4789 special: { | |
| 4790 load: { | |
| 4791 // Prevent triggered image.load events from bubbling to window.load | |
| 4792 noBubble: true | |
| 4793 }, | |
| 4794 focus: { | |
| 4795 // Fire native event if possible so blur/focus sequence is correct | |
| 4796 trigger: function() { | |
| 4797 if ( this !== safeActiveElement() && this.focus ) { | |
| 4798 try { | |
| 4799 this.focus(); | |
| 4800 return false; | |
| 4801 } catch ( e ) { | |
| 4802 // Support: IE<9 | |
| 4803 // If we error on focus to hidden element (#1486, #12518), | |
| 4804 // let .trigger() run the handlers | |
| 4805 } | |
| 4806 } | |
| 4807 }, | |
| 4808 delegateType: "focusin" | |
| 4809 }, | |
| 4810 blur: { | |
| 4811 trigger: function() { | |
| 4812 if ( this === safeActiveElement() && this.blur ) { | |
| 4813 this.blur(); | |
| 4814 return false; | |
| 4815 } | |
| 4816 }, | |
| 4817 delegateType: "focusout" | |
| 4818 }, | |
| 4819 click: { | |
| 4820 // For checkbox, fire native event so checked state will be right | |
| 4821 trigger: function() { | |
| 4822 if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) { | |
| 4823 this.click(); | |
| 4824 return false; | |
| 4825 } | |
| 4826 }, | |
| 4827 | |
| 4828 // For cross-browser consistency, don't fire native .click() on links | |
| 4829 _default: function( event ) { | |
| 4830 return jQuery.nodeName( event.target, "a" ); | |
| 4831 } | |
| 4832 }, | |
| 4833 | |
| 4834 beforeunload: { | |
| 4835 postDispatch: function( event ) { | |
| 4836 | |
| 4837 // Even when returnValue equals to undefined Firefox will still show alert | |
| 4838 if ( event.result !== undefined ) { | |
| 4839 event.originalEvent.returnValue = event.result; | |
| 4840 } | |
| 4841 } | |
| 4842 } | |
| 4843 }, | |
| 4844 | |
| 4845 simulate: function( type, elem, event, bubble ) { | |
| 4846 // Piggyback on a donor event to simulate a different one. | |
| 4847 // Fake originalEvent to avoid donor's stopPropagation, but if the | |
| 4848 // simulated event prevents default then we do the same on the donor. | |
| 4849 var e = jQuery.extend( | |
| 4850 new jQuery.Event(), | |
| 4851 event, | |
| 4852 { | |
| 4853 type: type, | |
| 4854 isSimulated: true, | |
| 4855 originalEvent: {} | |
| 4856 } | |
| 4857 ); | |
| 4858 if ( bubble ) { | |
| 4859 jQuery.event.trigger( e, null, elem ); | |
| 4860 } else { | |
| 4861 jQuery.event.dispatch.call( elem, e ); | |
| 4862 } | |
| 4863 if ( e.isDefaultPrevented() ) { | |
| 4864 event.preventDefault(); | |
| 4865 } | |
| 4866 } | |
| 4867 }; | |
| 4868 | |
| 4869 jQuery.removeEvent = document.removeEventListener ? | |
| 4870 function( elem, type, handle ) { | |
| 4871 if ( elem.removeEventListener ) { | |
| 4872 elem.removeEventListener( type, handle, false ); | |
| 4873 } | |
| 4874 } : | |
| 4875 function( elem, type, handle ) { | |
| 4876 var name = "on" + type; | |
| 4877 | |
| 4878 if ( elem.detachEvent ) { | |
| 4879 | |
| 4880 // #8545, #7054, preventing memory leaks for custom events in IE6-8 | |
| 4881 // detachEvent needed property on element, by name of that event, to properly expose it to GC | |
| 4882 if ( typeof elem[ name ] === strundefined ) { | |
| 4883 elem[ name ] = null; | |
| 4884 } | |
| 4885 | |
| 4886 elem.detachEvent( name, handle ); | |
| 4887 } | |
| 4888 }; | |
| 4889 | |
| 4890 jQuery.Event = function( src, props ) { | |
| 4891 // Allow instantiation without the 'new' keyword | |
| 4892 if ( !(this instanceof jQuery.Event) ) { | |
| 4893 return new jQuery.Event( src, props ); | |
| 4894 } | |
| 4895 | |
| 4896 // Event object | |
| 4897 if ( src && src.type ) { | |
| 4898 this.originalEvent = src; | |
| 4899 this.type = src.type; | |
| 4900 | |
| 4901 // Events bubbling up the document may have been marked as prevented | |
| 4902 // by a handler lower down the tree; reflect the correct value. | |
| 4903 this.isDefaultPrevented = src.defaultPrevented || | |
| 4904 src.defaultPrevented === undefined && ( | |
| 4905 // Support: IE < 9 | |
| 4906 src.returnValue === false || | |
| 4907 // Support: Android < 4.0 | |
| 4908 src.getPreventDefault && src.getPreventDefault() ) ? | |
| 4909 returnTrue : | |
| 4910 returnFalse; | |
| 4911 | |
| 4912 // Event type | |
| 4913 } else { | |
| 4914 this.type = src; | |
| 4915 } | |
| 4916 | |
| 4917 // Put explicitly provided properties onto the event object | |
| 4918 if ( props ) { | |
| 4919 jQuery.extend( this, props ); | |
| 4920 } | |
| 4921 | |
| 4922 // Create a timestamp if incoming event doesn't have one | |
| 4923 this.timeStamp = src && src.timeStamp || jQuery.now(); | |
| 4924 | |
| 4925 // Mark it as fixed | |
| 4926 this[ jQuery.expando ] = true; | |
| 4927 }; | |
| 4928 | |
| 4929 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding | |
| 4930 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html | |
| 4931 jQuery.Event.prototype = { | |
| 4932 isDefaultPrevented: returnFalse, | |
| 4933 isPropagationStopped: returnFalse, | |
| 4934 isImmediatePropagationStopped: returnFalse, | |
| 4935 | |
| 4936 preventDefault: function() { | |
| 4937 var e = this.originalEvent; | |
| 4938 | |
| 4939 this.isDefaultPrevented = returnTrue; | |
| 4940 if ( !e ) { | |
| 4941 return; | |
| 4942 } | |
| 4943 | |
| 4944 // If preventDefault exists, run it on the original event | |
| 4945 if ( e.preventDefault ) { | |
| 4946 e.preventDefault(); | |
| 4947 | |
| 4948 // Support: IE | |
| 4949 // Otherwise set the returnValue property of the original event to false | |
| 4950 } else { | |
| 4951 e.returnValue = false; | |
| 4952 } | |
| 4953 }, | |
| 4954 stopPropagation: function() { | |
| 4955 var e = this.originalEvent; | |
| 4956 | |
| 4957 this.isPropagationStopped = returnTrue; | |
| 4958 if ( !e ) { | |
| 4959 return; | |
| 4960 } | |
| 4961 // If stopPropagation exists, run it on the original event | |
| 4962 if ( e.stopPropagation ) { | |
| 4963 e.stopPropagation(); | |
| 4964 } | |
| 4965 | |
| 4966 // Support: IE | |
| 4967 // Set the cancelBubble property of the original event to true | |
| 4968 e.cancelBubble = true; | |
| 4969 }, | |
| 4970 stopImmediatePropagation: function() { | |
| 4971 this.isImmediatePropagationStopped = returnTrue; | |
| 4972 this.stopPropagation(); | |
| 4973 } | |
| 4974 }; | |
| 4975 | |
| 4976 // Create mouseenter/leave events using mouseover/out and event-time checks | |
| 4977 jQuery.each({ | |
| 4978 mouseenter: "mouseover", | |
| 4979 mouseleave: "mouseout" | |
| 4980 }, function( orig, fix ) { | |
| 4981 jQuery.event.special[ orig ] = { | |
| 4982 delegateType: fix, | |
| 4983 bindType: fix, | |
| 4984 | |
| 4985 handle: function( event ) { | |
| 4986 var ret, | |
| 4987 target = this, | |
| 4988 related = event.relatedTarget, | |
| 4989 handleObj = event.handleObj; | |
| 4990 | |
| 4991 // For mousenter/leave call the handler if related is outside the target. | |
| 4992 // NB: No relatedTarget if the mouse left/entered the browser window | |
| 4993 if ( !related || (related !== target && !jQuery.contains( target, related )) ) { | |
| 4994 event.type = handleObj.origType; | |
| 4995 ret = handleObj.handler.apply( this, arguments ); | |
| 4996 event.type = fix; | |
| 4997 } | |
| 4998 return ret; | |
| 4999 } | |
| 5000 }; | |
| 5001 }); | |
| 5002 | |
| 5003 // IE submit delegation | |
| 5004 if ( !support.submitBubbles ) { | |
| 5005 | |
| 5006 jQuery.event.special.submit = { | |
| 5007 setup: function() { | |
| 5008 // Only need this for delegated form submit events | |
| 5009 if ( jQuery.nodeName( this, "form" ) ) { | |
| 5010 return false; | |
| 5011 } | |
| 5012 | |
| 5013 // Lazy-add a submit handler when a descendant form may potentially be submitted | |
| 5014 jQuery.event.add( this, "click._submit keypress._submit", function( e ) { | |
| 5015 // Node name check avoids a VML-related crash in IE (#9807) | |
| 5016 var elem = e.target, | |
| 5017 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; | |
| 5018 if ( form && !jQuery._data( form, "submitBubbles" ) ) { | |
| 5019 jQuery.event.add( form, "submit._submit", function( event ) { | |
| 5020 event._submit_bubble = true; | |
| 5021 }); | |
| 5022 jQuery._data( form, "submitBubbles", true ); | |
| 5023 } | |
| 5024 }); | |
| 5025 // return undefined since we don't need an event listener | |
| 5026 }, | |
| 5027 | |
| 5028 postDispatch: function( event ) { | |
| 5029 // If form was submitted by the user, bubble the event up the tree | |
| 5030 if ( event._submit_bubble ) { | |
| 5031 delete event._submit_bubble; | |
| 5032 if ( this.parentNode && !event.isTrigger ) { | |
| 5033 jQuery.event.simulate( "submit", this.parentNode, event, true ); | |
| 5034 } | |
| 5035 } | |
| 5036 }, | |
| 5037 | |
| 5038 teardown: function() { | |
| 5039 // Only need this for delegated form submit events | |
| 5040 if ( jQuery.nodeName( this, "form" ) ) { | |
| 5041 return false; | |
| 5042 } | |
| 5043 | |
| 5044 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above | |
| 5045 jQuery.event.remove( this, "._submit" ); | |
| 5046 } | |
| 5047 }; | |
| 5048 } | |
| 5049 | |
| 5050 // IE change delegation and checkbox/radio fix | |
| 5051 if ( !support.changeBubbles ) { | |
| 5052 | |
| 5053 jQuery.event.special.change = { | |
| 5054 | |
| 5055 setup: function() { | |
| 5056 | |
| 5057 if ( rformElems.test( this.nodeName ) ) { | |
| 5058 // IE doesn't fire change on a check/radio until blur; trigger it on click | |
| 5059 // after a propertychange. Eat the blur-change in special.change.handle. | |
| 5060 // This still fires onchange a second time for check/radio after blur. | |
| 5061 if ( this.type === "checkbox" || this.type === "radio" ) { | |
| 5062 jQuery.event.add( this, "propertychange._change", function( event ) { | |
| 5063 if ( event.originalEvent.propertyName === "checked" ) { | |
| 5064 this._just_changed = true; | |
| 5065 } | |
| 5066 }); | |
| 5067 jQuery.event.add( this, "click._change", function( event ) { | |
| 5068 if ( this._just_changed && !event.isTrigger ) { | |
| 5069 this._just_changed = false; | |
| 5070 } | |
| 5071 // Allow triggered, simulated change events (#11500) | |
| 5072 jQuery.event.simulate( "change", this, event, true ); | |
| 5073 }); | |
| 5074 } | |
| 5075 return false; | |
| 5076 } | |
| 5077 // Delegated event; lazy-add a change handler on descendant inputs | |
| 5078 jQuery.event.add( this, "beforeactivate._change", function( e ) { | |
| 5079 var elem = e.target; | |
| 5080 | |
| 5081 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) { | |
| 5082 jQuery.event.add( elem, "change._change", function( event ) { | |
| 5083 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { | |
| 5084 jQuery.event.simulate( "change", this.parentNode, event, true ); | |
| 5085 } | |
| 5086 }); | |
| 5087 jQuery._data( elem, "changeBubbles", true ); | |
| 5088 } | |
| 5089 }); | |
| 5090 }, | |
| 5091 | |
| 5092 handle: function( event ) { | |
| 5093 var elem = event.target; | |
| 5094 | |
| 5095 // Swallow native change events from checkbox/radio, we already triggered them above | |
| 5096 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { | |
| 5097 return event.handleObj.handler.apply( this, arguments ); | |
| 5098 } | |
| 5099 }, | |
| 5100 | |
| 5101 teardown: function() { | |
| 5102 jQuery.event.remove( this, "._change" ); | |
| 5103 | |
| 5104 return !rformElems.test( this.nodeName ); | |
| 5105 } | |
| 5106 }; | |
| 5107 } | |
| 5108 | |
| 5109 // Create "bubbling" focus and blur events | |
| 5110 if ( !support.focusinBubbles ) { | |
| 5111 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { | |
| 5112 | |
| 5113 // Attach a single capturing handler on the document while someone wants focusin/focusout | |
| 5114 var handler = function( event ) { | |
| 5115 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); | |
| 5116 }; | |
| 5117 | |
| 5118 jQuery.event.special[ fix ] = { | |
| 5119 setup: function() { | |
| 5120 var doc = this.ownerDocument || this, | |
| 5121 attaches = jQuery._data( doc, fix ); | |
| 5122 | |
| 5123 if ( !attaches ) { | |
| 5124 doc.addEventListener( orig, handler, true ); | |
| 5125 } | |
| 5126 jQuery._data( doc, fix, ( attaches || 0 ) + 1 ); | |
| 5127 }, | |
| 5128 teardown: function() { | |
| 5129 var doc = this.ownerDocument || this, | |
| 5130 attaches = jQuery._data( doc, fix ) - 1; | |
| 5131 | |
| 5132 if ( !attaches ) { | |
| 5133 doc.removeEventListener( orig, handler, true ); | |
| 5134 jQuery._removeData( doc, fix ); | |
| 5135 } else { | |
| 5136 jQuery._data( doc, fix, attaches ); | |
| 5137 } | |
| 5138 } | |
| 5139 }; | |
| 5140 }); | |
| 5141 } | |
| 5142 | |
| 5143 jQuery.fn.extend({ | |
| 5144 | |
| 5145 on: function( types, selector, data, fn, /*INTERNAL*/ one ) { | |
| 5146 var type, origFn; | |
| 5147 | |
| 5148 // Types can be a map of types/handlers | |
| 5149 if ( typeof types === "object" ) { | |
| 5150 // ( types-Object, selector, data ) | |
| 5151 if ( typeof selector !== "string" ) { | |
| 5152 // ( types-Object, data ) | |
| 5153 data = data || selector; | |
| 5154 selector = undefined; | |
| 5155 } | |
| 5156 for ( type in types ) { | |
| 5157 this.on( type, selector, data, types[ type ], one ); | |
| 5158 } | |
| 5159 return this; | |
| 5160 } | |
| 5161 | |
| 5162 if ( data == null && fn == null ) { | |
| 5163 // ( types, fn ) | |
| 5164 fn = selector; | |
| 5165 data = selector = undefined; | |
| 5166 } else if ( fn == null ) { | |
| 5167 if ( typeof selector === "string" ) { | |
| 5168 // ( types, selector, fn ) | |
| 5169 fn = data; | |
| 5170 data = undefined; | |
| 5171 } else { | |
| 5172 // ( types, data, fn ) | |
| 5173 fn = data; | |
| 5174 data = selector; | |
| 5175 selector = undefined; | |
| 5176 } | |
| 5177 } | |
| 5178 if ( fn === false ) { | |
| 5179 fn = returnFalse; | |
| 5180 } else if ( !fn ) { | |
| 5181 return this; | |
| 5182 } | |
| 5183 | |
| 5184 if ( one === 1 ) { | |
| 5185 origFn = fn; | |
| 5186 fn = function( event ) { | |
| 5187 // Can use an empty set, since event contains the info | |
| 5188 jQuery().off( event ); | |
| 5189 return origFn.apply( this, arguments ); | |
| 5190 }; | |
| 5191 // Use same guid so caller can remove using origFn | |
| 5192 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); | |
| 5193 } | |
| 5194 return this.each( function() { | |
| 5195 jQuery.event.add( this, types, fn, data, selector ); | |
| 5196 }); | |
| 5197 }, | |
| 5198 one: function( types, selector, data, fn ) { | |
| 5199 return this.on( types, selector, data, fn, 1 ); | |
| 5200 }, | |
| 5201 off: function( types, selector, fn ) { | |
| 5202 var handleObj, type; | |
| 5203 if ( types && types.preventDefault && types.handleObj ) { | |
| 5204 // ( event ) dispatched jQuery.Event | |
| 5205 handleObj = types.handleObj; | |
| 5206 jQuery( types.delegateTarget ).off( | |
| 5207 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, | |
| 5208 handleObj.selector, | |
| 5209 handleObj.handler | |
| 5210 ); | |
| 5211 return this; | |
| 5212 } | |
| 5213 if ( typeof types === "object" ) { | |
| 5214 // ( types-object [, selector] ) | |
| 5215 for ( type in types ) { | |
| 5216 this.off( type, selector, types[ type ] ); | |
| 5217 } | |
| 5218 return this; | |
| 5219 } | |
| 5220 if ( selector === false || typeof selector === "function" ) { | |
| 5221 // ( types [, fn] ) | |
| 5222 fn = selector; | |
| 5223 selector = undefined; | |
| 5224 } | |
| 5225 if ( fn === false ) { | |
| 5226 fn = returnFalse; | |
| 5227 } | |
| 5228 return this.each(function() { | |
| 5229 jQuery.event.remove( this, types, fn, selector ); | |
| 5230 }); | |
| 5231 }, | |
| 5232 | |
| 5233 trigger: function( type, data ) { | |
| 5234 return this.each(function() { | |
| 5235 jQuery.event.trigger( type, data, this ); | |
| 5236 }); | |
| 5237 }, | |
| 5238 triggerHandler: function( type, data ) { | |
| 5239 var elem = this[0]; | |
| 5240 if ( elem ) { | |
| 5241 return jQuery.event.trigger( type, data, elem, true ); | |
| 5242 } | |
| 5243 } | |
| 5244 }); | |
| 5245 | |
| 5246 | |
| 5247 function createSafeFragment( document ) { | |
| 5248 var list = nodeNames.split( "|" ), | |
| 5249 safeFrag = document.createDocumentFragment(); | |
| 5250 | |
| 5251 if ( safeFrag.createElement ) { | |
| 5252 while ( list.length ) { | |
| 5253 safeFrag.createElement( | |
| 5254 list.pop() | |
| 5255 ); | |
| 5256 } | |
| 5257 } | |
| 5258 return safeFrag; | |
| 5259 } | |
| 5260 | |
| 5261 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + | |
| 5262 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", | |
| 5263 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, | |
| 5264 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), | |
| 5265 rleadingWhitespace = /^\s+/, | |
| 5266 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, | |
| 5267 rtagName = /<([\w:]+)/, | |
| 5268 rtbody = /<tbody/i, | |
| 5269 rhtml = /<|&#?\w+;/, | |
| 5270 rnoInnerhtml = /<(?:script|style|link)/i, | |
| 5271 // checked="checked" or checked | |
| 5272 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, | |
| 5273 rscriptType = /^$|\/(?:java|ecma)script/i, | |
| 5274 rscriptTypeMasked = /^true\/(.*)/, | |
| 5275 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, | |
| 5276 | |
| 5277 // We have to close these tags to support XHTML (#13200) | |
| 5278 wrapMap = { | |
| 5279 option: [ 1, "<select multiple='multiple'>", "</select>" ], | |
| 5280 legend: [ 1, "<fieldset>", "</fieldset>" ], | |
| 5281 area: [ 1, "<map>", "</map>" ], | |
| 5282 param: [ 1, "<object>", "</object>" ], | |
| 5283 thead: [ 1, "<table>", "</table>" ], | |
| 5284 tr: [ 2, "<table><tbody>", "</tbody></table>" ], | |
| 5285 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], | |
| 5286 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], | |
| 5287 | |
| 5288 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, | |
| 5289 // unless wrapped in a div with non-breaking characters in front of it. | |
| 5290 _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ] | |
| 5291 }, | |
| 5292 safeFragment = createSafeFragment( document ), | |
| 5293 fragmentDiv = safeFragment.appendChild( document.createElement("div") ); | |
| 5294 | |
| 5295 wrapMap.optgroup = wrapMap.option; | |
| 5296 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; | |
| 5297 wrapMap.th = wrapMap.td; | |
| 5298 | |
| 5299 function getAll( context, tag ) { | |
| 5300 var elems, elem, | |
| 5301 i = 0, | |
| 5302 found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) : | |
| 5303 typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) : | |
| 5304 undefined; | |
| 5305 | |
| 5306 if ( !found ) { | |
| 5307 for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) { | |
| 5308 if ( !tag || jQuery.nodeName( elem, tag ) ) { | |
| 5309 found.push( elem ); | |
| 5310 } else { | |
| 5311 jQuery.merge( found, getAll( elem, tag ) ); | |
| 5312 } | |
| 5313 } | |
| 5314 } | |
| 5315 | |
| 5316 return tag === undefined || tag && jQuery.nodeName( context, tag ) ? | |
| 5317 jQuery.merge( [ context ], found ) : | |
| 5318 found; | |
| 5319 } | |
| 5320 | |
| 5321 // Used in buildFragment, fixes the defaultChecked property | |
| 5322 function fixDefaultChecked( elem ) { | |
| 5323 if ( rcheckableType.test( elem.type ) ) { | |
| 5324 elem.defaultChecked = elem.checked; | |
| 5325 } | |
| 5326 } | |
| 5327 | |
| 5328 // Support: IE<8 | |
| 5329 // Manipulating tables requires a tbody | |
| 5330 function manipulationTarget( elem, content ) { | |
| 5331 return jQuery.nodeName( elem, "table" ) && | |
| 5332 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? | |
| 5333 | |
| 5334 elem.getElementsByTagName("tbody")[0] || | |
| 5335 elem.appendChild( elem.ownerDocument.createElement("tbody") ) : | |
| 5336 elem; | |
| 5337 } | |
| 5338 | |
| 5339 // Replace/restore the type attribute of script elements for safe DOM manipulation | |
| 5340 function disableScript( elem ) { | |
| 5341 elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type; | |
| 5342 return elem; | |
| 5343 } | |
| 5344 function restoreScript( elem ) { | |
| 5345 var match = rscriptTypeMasked.exec( elem.type ); | |
| 5346 if ( match ) { | |
| 5347 elem.type = match[1]; | |
| 5348 } else { | |
| 5349 elem.removeAttribute("type"); | |
| 5350 } | |
| 5351 return elem; | |
| 5352 } | |
| 5353 | |
| 5354 // Mark scripts as having already been evaluated | |
| 5355 function setGlobalEval( elems, refElements ) { | |
| 5356 var elem, | |
| 5357 i = 0; | |
| 5358 for ( ; (elem = elems[i]) != null; i++ ) { | |
| 5359 jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) ); | |
| 5360 } | |
| 5361 } | |
| 5362 | |
| 5363 function cloneCopyEvent( src, dest ) { | |
| 5364 | |
| 5365 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { | |
| 5366 return; | |
| 5367 } | |
| 5368 | |
| 5369 var type, i, l, | |
| 5370 oldData = jQuery._data( src ), | |
| 5371 curData = jQuery._data( dest, oldData ), | |
| 5372 events = oldData.events; | |
| 5373 | |
| 5374 if ( events ) { | |
| 5375 delete curData.handle; | |
| 5376 curData.events = {}; | |
| 5377 | |
| 5378 for ( type in events ) { | |
| 5379 for ( i = 0, l = events[ type ].length; i < l; i++ ) { | |
| 5380 jQuery.event.add( dest, type, events[ type ][ i ] ); | |
| 5381 } | |
| 5382 } | |
| 5383 } | |
| 5384 | |
| 5385 // make the cloned public data object a copy from the original | |
| 5386 if ( curData.data ) { | |
| 5387 curData.data = jQuery.extend( {}, curData.data ); | |
| 5388 } | |
| 5389 } | |
| 5390 | |
| 5391 function fixCloneNodeIssues( src, dest ) { | |
| 5392 var nodeName, e, data; | |
| 5393 | |
| 5394 // We do not need to do anything for non-Elements | |
| 5395 if ( dest.nodeType !== 1 ) { | |
| 5396 return; | |
| 5397 } | |
| 5398 | |
| 5399 nodeName = dest.nodeName.toLowerCase(); | |
| 5400 | |
| 5401 // IE6-8 copies events bound via attachEvent when using cloneNode. | |
| 5402 if ( !support.noCloneEvent && dest[ jQuery.expando ] ) { | |
| 5403 data = jQuery._data( dest ); | |
| 5404 | |
| 5405 for ( e in data.events ) { | |
| 5406 jQuery.removeEvent( dest, e, data.handle ); | |
| 5407 } | |
| 5408 | |
| 5409 // Event data gets referenced instead of copied if the expando gets copied too | |
| 5410 dest.removeAttribute( jQuery.expando ); | |
| 5411 } | |
| 5412 | |
| 5413 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text | |
| 5414 if ( nodeName === "script" && dest.text !== src.text ) { | |
| 5415 disableScript( dest ).text = src.text; | |
| 5416 restoreScript( dest ); | |
| 5417 | |
| 5418 // IE6-10 improperly clones children of object elements using classid. | |
| 5419 // IE10 throws NoModificationAllowedError if parent is null, #12132. | |
| 5420 } else if ( nodeName === "object" ) { | |
| 5421 if ( dest.parentNode ) { | |
| 5422 dest.outerHTML = src.outerHTML; | |
| 5423 } | |
| 5424 | |
| 5425 // This path appears unavoidable for IE9. When cloning an object | |
| 5426 // element in IE9, the outerHTML strategy above is not sufficient. | |
| 5427 // If the src has innerHTML and the destination does not, | |
| 5428 // copy the src.innerHTML into the dest.innerHTML. #10324 | |
| 5429 if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) { | |
| 5430 dest.innerHTML = src.innerHTML; | |
| 5431 } | |
| 5432 | |
| 5433 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) { | |
| 5434 // IE6-8 fails to persist the checked state of a cloned checkbox | |
| 5435 // or radio button. Worse, IE6-7 fail to give the cloned element | |
| 5436 // a checked appearance if the defaultChecked value isn't also set | |
| 5437 | |
| 5438 dest.defaultChecked = dest.checked = src.checked; | |
| 5439 | |
| 5440 // IE6-7 get confused and end up setting the value of a cloned | |
| 5441 // checkbox/radio button to an empty string instead of "on" | |
| 5442 if ( dest.value !== src.value ) { | |
| 5443 dest.value = src.value; | |
| 5444 } | |
| 5445 | |
| 5446 // IE6-8 fails to return the selected option to the default selected | |
| 5447 // state when cloning options | |
| 5448 } else if ( nodeName === "option" ) { | |
| 5449 dest.defaultSelected = dest.selected = src.defaultSelected; | |
| 5450 | |
| 5451 // IE6-8 fails to set the defaultValue to the correct value when | |
| 5452 // cloning other types of input fields | |
| 5453 } else if ( nodeName === "input" || nodeName === "textarea" ) { | |
| 5454 dest.defaultValue = src.defaultValue; | |
| 5455 } | |
| 5456 } | |
| 5457 | |
| 5458 jQuery.extend({ | |
| 5459 clone: function( elem, dataAndEvents, deepDataAndEvents ) { | |
| 5460 var destElements, node, clone, i, srcElements, | |
| 5461 inPage = jQuery.contains( elem.ownerDocument, elem ); | |
| 5462 | |
| 5463 if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { | |
| 5464 clone = elem.cloneNode( true ); | |
| 5465 | |
| 5466 // IE<=8 does not properly clone detached, unknown element nodes | |
| 5467 } else { | |
| 5468 fragmentDiv.innerHTML = elem.outerHTML; | |
| 5469 fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); | |
| 5470 } | |
| 5471 | |
| 5472 if ( (!support.noCloneEvent || !support.noCloneChecked) && | |
| 5473 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { | |
| 5474 | |
| 5475 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 | |
| 5476 destElements = getAll( clone ); | |
| 5477 srcElements = getAll( elem ); | |
| 5478 | |
| 5479 // Fix all IE cloning issues | |
| 5480 for ( i = 0; (node = srcElements[i]) != null; ++i ) { | |
| 5481 // Ensure that the destination node is not null; Fixes #9587 | |
| 5482 if ( destElements[i] ) { | |
| 5483 fixCloneNodeIssues( node, destElements[i] ); | |
| 5484 } | |
| 5485 } | |
| 5486 } | |
| 5487 | |
| 5488 // Copy the events from the original to the clone | |
| 5489 if ( dataAndEvents ) { | |
| 5490 if ( deepDataAndEvents ) { | |
| 5491 srcElements = srcElements || getAll( elem ); | |
| 5492 destElements = destElements || getAll( clone ); | |
| 5493 | |
| 5494 for ( i = 0; (node = srcElements[i]) != null; i++ ) { | |
| 5495 cloneCopyEvent( node, destElements[i] ); | |
| 5496 } | |
| 5497 } else { | |
| 5498 cloneCopyEvent( elem, clone ); | |
| 5499 } | |
| 5500 } | |
| 5501 | |
| 5502 // Preserve script evaluation history | |
| 5503 destElements = getAll( clone, "script" ); | |
| 5504 if ( destElements.length > 0 ) { | |
| 5505 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); | |
| 5506 } | |
| 5507 | |
| 5508 destElements = srcElements = node = null; | |
| 5509 | |
| 5510 // Return the cloned set | |
| 5511 return clone; | |
| 5512 }, | |
| 5513 | |
| 5514 buildFragment: function( elems, context, scripts, selection ) { | |
| 5515 var j, elem, contains, | |
| 5516 tmp, tag, tbody, wrap, | |
| 5517 l = elems.length, | |
| 5518 | |
| 5519 // Ensure a safe fragment | |
| 5520 safe = createSafeFragment( context ), | |
| 5521 | |
| 5522 nodes = [], | |
| 5523 i = 0; | |
| 5524 | |
| 5525 for ( ; i < l; i++ ) { | |
| 5526 elem = elems[ i ]; | |
| 5527 | |
| 5528 if ( elem || elem === 0 ) { | |
| 5529 | |
| 5530 // Add nodes directly | |
| 5531 if ( jQuery.type( elem ) === "object" ) { | |
| 5532 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); | |
| 5533 | |
| 5534 // Convert non-html into a text node | |
| 5535 } else if ( !rhtml.test( elem ) ) { | |
| 5536 nodes.push( context.createTextNode( elem ) ); | |
| 5537 | |
| 5538 // Convert html into DOM nodes | |
| 5539 } else { | |
| 5540 tmp = tmp || safe.appendChild( context.createElement("div") ); | |
| 5541 | |
| 5542 // Deserialize a standard representation | |
| 5543 tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase(); | |
| 5544 wrap = wrapMap[ tag ] || wrapMap._default; | |
| 5545 | |
| 5546 tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2]; | |
| 5547 | |
| 5548 // Descend through wrappers to the right content | |
| 5549 j = wrap[0]; | |
| 5550 while ( j-- ) { | |
| 5551 tmp = tmp.lastChild; | |
| 5552 } | |
| 5553 | |
| 5554 // Manually add leading whitespace removed by IE | |
| 5555 if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { | |
| 5556 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) ); | |
| 5557 } | |
| 5558 | |
| 5559 // Remove IE's autoinserted <tbody> from table fragments | |
| 5560 if ( !support.tbody ) { | |
| 5561 | |
| 5562 // String was a <table>, *may* have spurious <tbody> | |
| 5563 elem = tag === "table" && !rtbody.test( elem ) ? | |
| 5564 tmp.firstChild : | |
| 5565 | |
| 5566 // String was a bare <thead> or <tfoot> | |
| 5567 wrap[1] === "<table>" && !rtbody.test( elem ) ? | |
| 5568 tmp : | |
| 5569 0; | |
| 5570 | |
| 5571 j = elem && elem.childNodes.length; | |
| 5572 while ( j-- ) { | |
| 5573 if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) { | |
| 5574 elem.removeChild( tbody ); | |
| 5575 } | |
| 5576 } | |
| 5577 } | |
| 5578 | |
| 5579 jQuery.merge( nodes, tmp.childNodes ); | |
| 5580 | |
| 5581 // Fix #12392 for WebKit and IE > 9 | |
| 5582 tmp.textContent = ""; | |
| 5583 | |
| 5584 // Fix #12392 for oldIE | |
| 5585 while ( tmp.firstChild ) { | |
| 5586 tmp.removeChild( tmp.firstChild ); | |
| 5587 } | |
| 5588 | |
| 5589 // Remember the top-level container for proper cleanup | |
| 5590 tmp = safe.lastChild; | |
| 5591 } | |
| 5592 } | |
| 5593 } | |
| 5594 | |
| 5595 // Fix #11356: Clear elements from fragment | |
| 5596 if ( tmp ) { | |
| 5597 safe.removeChild( tmp ); | |
| 5598 } | |
| 5599 | |
| 5600 // Reset defaultChecked for any radios and checkboxes | |
| 5601 // about to be appended to the DOM in IE 6/7 (#8060) | |
| 5602 if ( !support.appendChecked ) { | |
| 5603 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked ); | |
| 5604 } | |
| 5605 | |
| 5606 i = 0; | |
| 5607 while ( (elem = nodes[ i++ ]) ) { | |
| 5608 | |
| 5609 // #4087 - If origin and destination elements are the same, and this is | |
| 5610 // that element, do not do anything | |
| 5611 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { | |
| 5612 continue; | |
| 5613 } | |
| 5614 | |
| 5615 contains = jQuery.contains( elem.ownerDocument, elem ); | |
| 5616 | |
| 5617 // Append to fragment | |
| 5618 tmp = getAll( safe.appendChild( elem ), "script" ); | |
| 5619 | |
| 5620 // Preserve script evaluation history | |
| 5621 if ( contains ) { | |
| 5622 setGlobalEval( tmp ); | |
| 5623 } | |
| 5624 | |
| 5625 // Capture executables | |
| 5626 if ( scripts ) { | |
| 5627 j = 0; | |
| 5628 while ( (elem = tmp[ j++ ]) ) { | |
| 5629 if ( rscriptType.test( elem.type || "" ) ) { | |
| 5630 scripts.push( elem ); | |
| 5631 } | |
| 5632 } | |
| 5633 } | |
| 5634 } | |
| 5635 | |
| 5636 tmp = null; | |
| 5637 | |
| 5638 return safe; | |
| 5639 }, | |
| 5640 | |
| 5641 cleanData: function( elems, /* internal */ acceptData ) { | |
| 5642 var elem, type, id, data, | |
| 5643 i = 0, | |
| 5644 internalKey = jQuery.expando, | |
| 5645 cache = jQuery.cache, | |
| 5646 deleteExpando = support.deleteExpando, | |
| 5647 special = jQuery.event.special; | |
| 5648 | |
| 5649 for ( ; (elem = elems[i]) != null; i++ ) { | |
| 5650 if ( acceptData || jQuery.acceptData( elem ) ) { | |
| 5651 | |
| 5652 id = elem[ internalKey ]; | |
| 5653 data = id && cache[ id ]; | |
| 5654 | |
| 5655 if ( data ) { | |
| 5656 if ( data.events ) { | |
| 5657 for ( type in data.events ) { | |
| 5658 if ( special[ type ] ) { | |
| 5659 jQuery.event.remove( elem, type ); | |
| 5660 | |
| 5661 // This is a shortcut to avoid jQuery.event.remove's overhead | |
| 5662 } else { | |
| 5663 jQuery.removeEvent( elem, type, data.handle ); | |
| 5664 } | |
| 5665 } | |
| 5666 } | |
| 5667 | |
| 5668 // Remove cache only if it was not already removed by jQuery.event.remove | |
| 5669 if ( cache[ id ] ) { | |
| 5670 | |
| 5671 delete cache[ id ]; | |
| 5672 | |
| 5673 // IE does not allow us to delete expando properties from nodes, | |
| 5674 // nor does it have a removeAttribute function on Document nodes; | |
| 5675 // we must handle all of these cases | |
| 5676 if ( deleteExpando ) { | |
| 5677 delete elem[ internalKey ]; | |
| 5678 | |
| 5679 } else if ( typeof elem.removeAttribute !== strundefined ) { | |
| 5680 elem.removeAttribute( internalKey ); | |
| 5681 | |
| 5682 } else { | |
| 5683 elem[ internalKey ] = null; | |
| 5684 } | |
| 5685 | |
| 5686 deletedIds.push( id ); | |
| 5687 } | |
| 5688 } | |
| 5689 } | |
| 5690 } | |
| 5691 } | |
| 5692 }); | |
| 5693 | |
| 5694 jQuery.fn.extend({ | |
| 5695 text: function( value ) { | |
| 5696 return access( this, function( value ) { | |
| 5697 return value === undefined ? | |
| 5698 jQuery.text( this ) : | |
| 5699 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); | |
| 5700 }, null, value, arguments.length ); | |
| 5701 }, | |
| 5702 | |
| 5703 append: function() { | |
| 5704 return this.domManip( arguments, function( elem ) { | |
| 5705 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { | |
| 5706 var target = manipulationTarget( this, elem ); | |
| 5707 target.appendChild( elem ); | |
| 5708 } | |
| 5709 }); | |
| 5710 }, | |
| 5711 | |
| 5712 prepend: function() { | |
| 5713 return this.domManip( arguments, function( elem ) { | |
| 5714 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { | |
| 5715 var target = manipulationTarget( this, elem ); | |
| 5716 target.insertBefore( elem, target.firstChild ); | |
| 5717 } | |
| 5718 }); | |
| 5719 }, | |
| 5720 | |
| 5721 before: function() { | |
| 5722 return this.domManip( arguments, function( elem ) { | |
| 5723 if ( this.parentNode ) { | |
| 5724 this.parentNode.insertBefore( elem, this ); | |
| 5725 } | |
| 5726 }); | |
| 5727 }, | |
| 5728 | |
| 5729 after: function() { | |
| 5730 return this.domManip( arguments, function( elem ) { | |
| 5731 if ( this.parentNode ) { | |
| 5732 this.parentNode.insertBefore( elem, this.nextSibling ); | |
| 5733 } | |
| 5734 }); | |
| 5735 }, | |
| 5736 | |
| 5737 remove: function( selector, keepData /* Internal Use Only */ ) { | |
| 5738 var elem, | |
| 5739 elems = selector ? jQuery.filter( selector, this ) : this, | |
| 5740 i = 0; | |
| 5741 | |
| 5742 for ( ; (elem = elems[i]) != null; i++ ) { | |
| 5743 | |
| 5744 if ( !keepData && elem.nodeType === 1 ) { | |
| 5745 jQuery.cleanData( getAll( elem ) ); | |
| 5746 } | |
| 5747 | |
| 5748 if ( elem.parentNode ) { | |
| 5749 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { | |
| 5750 setGlobalEval( getAll( elem, "script" ) ); | |
| 5751 } | |
| 5752 elem.parentNode.removeChild( elem ); | |
| 5753 } | |
| 5754 } | |
| 5755 | |
| 5756 return this; | |
| 5757 }, | |
| 5758 | |
| 5759 empty: function() { | |
| 5760 var elem, | |
| 5761 i = 0; | |
| 5762 | |
| 5763 for ( ; (elem = this[i]) != null; i++ ) { | |
| 5764 // Remove element nodes and prevent memory leaks | |
| 5765 if ( elem.nodeType === 1 ) { | |
| 5766 jQuery.cleanData( getAll( elem, false ) ); | |
| 5767 } | |
| 5768 | |
| 5769 // Remove any remaining nodes | |
| 5770 while ( elem.firstChild ) { | |
| 5771 elem.removeChild( elem.firstChild ); | |
| 5772 } | |
| 5773 | |
| 5774 // If this is a select, ensure that it displays empty (#12336) | |
| 5775 // Support: IE<9 | |
| 5776 if ( elem.options && jQuery.nodeName( elem, "select" ) ) { | |
| 5777 elem.options.length = 0; | |
| 5778 } | |
| 5779 } | |
| 5780 | |
| 5781 return this; | |
| 5782 }, | |
| 5783 | |
| 5784 clone: function( dataAndEvents, deepDataAndEvents ) { | |
| 5785 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; | |
| 5786 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; | |
| 5787 | |
| 5788 return this.map(function() { | |
| 5789 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); | |
| 5790 }); | |
| 5791 }, | |
| 5792 | |
| 5793 html: function( value ) { | |
| 5794 return access( this, function( value ) { | |
| 5795 var elem = this[ 0 ] || {}, | |
| 5796 i = 0, | |
| 5797 l = this.length; | |
| 5798 | |
| 5799 if ( value === undefined ) { | |
| 5800 return elem.nodeType === 1 ? | |
| 5801 elem.innerHTML.replace( rinlinejQuery, "" ) : | |
| 5802 undefined; | |
| 5803 } | |
| 5804 | |
| 5805 // See if we can take a shortcut and just use innerHTML | |
| 5806 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && | |
| 5807 ( support.htmlSerialize || !rnoshimcache.test( value ) ) && | |
| 5808 ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && | |
| 5809 !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) { | |
| 5810 | |
| 5811 value = value.replace( rxhtmlTag, "<$1></$2>" ); | |
| 5812 | |
| 5813 try { | |
| 5814 for (; i < l; i++ ) { | |
| 5815 // Remove element nodes and prevent memory leaks | |
| 5816 elem = this[i] || {}; | |
| 5817 if ( elem.nodeType === 1 ) { | |
| 5818 jQuery.cleanData( getAll( elem, false ) ); | |
| 5819 elem.innerHTML = value; | |
| 5820 } | |
| 5821 } | |
| 5822 | |
| 5823 elem = 0; | |
| 5824 | |
| 5825 // If using innerHTML throws an exception, use the fallback method | |
| 5826 } catch(e) {} | |
| 5827 } | |
| 5828 | |
| 5829 if ( elem ) { | |
| 5830 this.empty().append( value ); | |
| 5831 } | |
| 5832 }, null, value, arguments.length ); | |
| 5833 }, | |
| 5834 | |
| 5835 replaceWith: function() { | |
| 5836 var arg = arguments[ 0 ]; | |
| 5837 | |
| 5838 // Make the changes, replacing each context element with the new content | |
| 5839 this.domManip( arguments, function( elem ) { | |
| 5840 arg = this.parentNode; | |
| 5841 | |
| 5842 jQuery.cleanData( getAll( this ) ); | |
| 5843 | |
| 5844 if ( arg ) { | |
| 5845 arg.replaceChild( elem, this ); | |
| 5846 } | |
| 5847 }); | |
| 5848 | |
| 5849 // Force removal if there was no new content (e.g., from empty arguments) | |
| 5850 return arg && (arg.length || arg.nodeType) ? this : this.remove(); | |
| 5851 }, | |
| 5852 | |
| 5853 detach: function( selector ) { | |
| 5854 return this.remove( selector, true ); | |
| 5855 }, | |
| 5856 | |
| 5857 domManip: function( args, callback ) { | |
| 5858 | |
| 5859 // Flatten any nested arrays | |
| 5860 args = concat.apply( [], args ); | |
| 5861 | |
| 5862 var first, node, hasScripts, | |
| 5863 scripts, doc, fragment, | |
| 5864 i = 0, | |
| 5865 l = this.length, | |
| 5866 set = this, | |
| 5867 iNoClone = l - 1, | |
| 5868 value = args[0], | |
| 5869 isFunction = jQuery.isFunction( value ); | |
| 5870 | |
| 5871 // We can't cloneNode fragments that contain checked, in WebKit | |
| 5872 if ( isFunction || | |
| 5873 ( l > 1 && typeof value === "string" && | |
| 5874 !support.checkClone && rchecked.test( value ) ) ) { | |
| 5875 return this.each(function( index ) { | |
| 5876 var self = set.eq( index ); | |
| 5877 if ( isFunction ) { | |
| 5878 args[0] = value.call( this, index, self.html() ); | |
| 5879 } | |
| 5880 self.domManip( args, callback ); | |
| 5881 }); | |
| 5882 } | |
| 5883 | |
| 5884 if ( l ) { | |
| 5885 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); | |
| 5886 first = fragment.firstChild; | |
| 5887 | |
| 5888 if ( fragment.childNodes.length === 1 ) { | |
| 5889 fragment = first; | |
| 5890 } | |
| 5891 | |
| 5892 if ( first ) { | |
| 5893 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); | |
| 5894 hasScripts = scripts.length; | |
| 5895 | |
| 5896 // Use the original fragment for the last item instead of the first because it can end up | |
| 5897 // being emptied incorrectly in certain situations (#8070). | |
| 5898 for ( ; i < l; i++ ) { | |
| 5899 node = fragment; | |
| 5900 | |
| 5901 if ( i !== iNoClone ) { | |
| 5902 node = jQuery.clone( node, true, true ); | |
| 5903 | |
| 5904 // Keep references to cloned scripts for later restoration | |
| 5905 if ( hasScripts ) { | |
| 5906 jQuery.merge( scripts, getAll( node, "script" ) ); | |
| 5907 } | |
| 5908 } | |
| 5909 | |
| 5910 callback.call( this[i], node, i ); | |
| 5911 } | |
| 5912 | |
| 5913 if ( hasScripts ) { | |
| 5914 doc = scripts[ scripts.length - 1 ].ownerDocument; | |
| 5915 | |
| 5916 // Reenable scripts | |
| 5917 jQuery.map( scripts, restoreScript ); | |
| 5918 | |
| 5919 // Evaluate executable scripts on first document insertion | |
| 5920 for ( i = 0; i < hasScripts; i++ ) { | |
| 5921 node = scripts[ i ]; | |
| 5922 if ( rscriptType.test( node.type || "" ) && | |
| 5923 !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) { | |
| 5924 | |
| 5925 if ( node.src ) { | |
| 5926 // Optional AJAX dependency, but won't run scripts if not present | |
| 5927 if ( jQuery._evalUrl ) { | |
| 5928 jQuery._evalUrl( node.src ); | |
| 5929 } | |
| 5930 } else { | |
| 5931 jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) ); | |
| 5932 } | |
| 5933 } | |
| 5934 } | |
| 5935 } | |
| 5936 | |
| 5937 // Fix #11809: Avoid leaking memory | |
| 5938 fragment = first = null; | |
| 5939 } | |
| 5940 } | |
| 5941 | |
| 5942 return this; | |
| 5943 } | |
| 5944 }); | |
| 5945 | |
| 5946 jQuery.each({ | |
| 5947 appendTo: "append", | |
| 5948 prependTo: "prepend", | |
| 5949 insertBefore: "before", | |
| 5950 insertAfter: "after", | |
| 5951 replaceAll: "replaceWith" | |
| 5952 }, function( name, original ) { | |
| 5953 jQuery.fn[ name ] = function( selector ) { | |
| 5954 var elems, | |
| 5955 i = 0, | |
| 5956 ret = [], | |
| 5957 insert = jQuery( selector ), | |
| 5958 last = insert.length - 1; | |
| 5959 | |
| 5960 for ( ; i <= last; i++ ) { | |
| 5961 elems = i === last ? this : this.clone(true); | |
| 5962 jQuery( insert[i] )[ original ]( elems ); | |
| 5963 | |
| 5964 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get() | |
| 5965 push.apply( ret, elems.get() ); | |
| 5966 } | |
| 5967 | |
| 5968 return this.pushStack( ret ); | |
| 5969 }; | |
| 5970 }); | |
| 5971 | |
| 5972 | |
| 5973 var iframe, | |
| 5974 elemdisplay = {}; | |
| 5975 | |
| 5976 /** | |
| 5977 * Retrieve the actual display of a element | |
| 5978 * @param {String} name nodeName of the element | |
| 5979 * @param {Object} doc Document object | |
| 5980 */ | |
| 5981 // Called only from within defaultDisplay | |
| 5982 function actualDisplay( name, doc ) { | |
| 5983 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), | |
| 5984 | |
| 5985 // getDefaultComputedStyle might be reliably used only on attached element | |
| 5986 display = window.getDefaultComputedStyle ? | |
| 5987 | |
| 5988 // Use of this method is a temporary fix (more like optmization) until something better comes along, | |
| 5989 // since it was removed from specification and supported only in FF | |
| 5990 window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" ); | |
| 5991 | |
| 5992 // We don't have any data stored on the element, | |
| 5993 // so use "detach" method as fast way to get rid of the element | |
| 5994 elem.detach(); | |
| 5995 | |
| 5996 return display; | |
| 5997 } | |
| 5998 | |
| 5999 /** | |
| 6000 * Try to determine the default display value of an element | |
| 6001 * @param {String} nodeName | |
| 6002 */ | |
| 6003 function defaultDisplay( nodeName ) { | |
| 6004 var doc = document, | |
| 6005 display = elemdisplay[ nodeName ]; | |
| 6006 | |
| 6007 if ( !display ) { | |
| 6008 display = actualDisplay( nodeName, doc ); | |
| 6009 | |
| 6010 // If the simple way fails, read from inside an iframe | |
| 6011 if ( display === "none" || !display ) { | |
| 6012 | |
| 6013 // Use the already-created iframe if possible | |
| 6014 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement ); | |
| 6015 | |
| 6016 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse | |
| 6017 doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document; | |
| 6018 | |
| 6019 // Support: IE | |
| 6020 doc.write(); | |
| 6021 doc.close(); | |
| 6022 | |
| 6023 display = actualDisplay( nodeName, doc ); | |
| 6024 iframe.detach(); | |
| 6025 } | |
| 6026 | |
| 6027 // Store the correct default display | |
| 6028 elemdisplay[ nodeName ] = display; | |
| 6029 } | |
| 6030 | |
| 6031 return display; | |
| 6032 } | |
| 6033 | |
| 6034 | |
| 6035 (function() { | |
| 6036 var a, shrinkWrapBlocksVal, | |
| 6037 div = document.createElement( "div" ), | |
| 6038 divReset = | |
| 6039 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" + | |
| 6040 "display:block;padding:0;margin:0;border:0"; | |
| 6041 | |
| 6042 // Setup | |
| 6043 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; | |
| 6044 a = div.getElementsByTagName( "a" )[ 0 ]; | |
| 6045 | |
| 6046 a.style.cssText = "float:left;opacity:.5"; | |
| 6047 | |
| 6048 // Make sure that element opacity exists | |
| 6049 // (IE uses filter instead) | |
| 6050 // Use a regex to work around a WebKit issue. See #5145 | |
| 6051 support.opacity = /^0.5/.test( a.style.opacity ); | |
| 6052 | |
| 6053 // Verify style float existence | |
| 6054 // (IE uses styleFloat instead of cssFloat) | |
| 6055 support.cssFloat = !!a.style.cssFloat; | |
| 6056 | |
| 6057 div.style.backgroundClip = "content-box"; | |
| 6058 div.cloneNode( true ).style.backgroundClip = ""; | |
| 6059 support.clearCloneStyle = div.style.backgroundClip === "content-box"; | |
| 6060 | |
| 6061 // Null elements to avoid leaks in IE. | |
| 6062 a = div = null; | |
| 6063 | |
| 6064 support.shrinkWrapBlocks = function() { | |
| 6065 var body, container, div, containerStyles; | |
| 6066 | |
| 6067 if ( shrinkWrapBlocksVal == null ) { | |
| 6068 body = document.getElementsByTagName( "body" )[ 0 ]; | |
| 6069 if ( !body ) { | |
| 6070 // Test fired too early or in an unsupported environment, exit. | |
| 6071 return; | |
| 6072 } | |
| 6073 | |
| 6074 containerStyles = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px"; | |
| 6075 container = document.createElement( "div" ); | |
| 6076 div = document.createElement( "div" ); | |
| 6077 | |
| 6078 body.appendChild( container ).appendChild( div ); | |
| 6079 | |
| 6080 // Will be changed later if needed. | |
| 6081 shrinkWrapBlocksVal = false; | |
| 6082 | |
| 6083 if ( typeof div.style.zoom !== strundefined ) { | |
| 6084 // Support: IE6 | |
| 6085 // Check if elements with layout shrink-wrap their children | |
| 6086 div.style.cssText = divReset + ";width:1px;padding:1px;zoom:1"; | |
| 6087 div.innerHTML = "<div></div>"; | |
| 6088 div.firstChild.style.width = "5px"; | |
| 6089 shrinkWrapBlocksVal = div.offsetWidth !== 3; | |
| 6090 } | |
| 6091 | |
| 6092 body.removeChild( container ); | |
| 6093 | |
| 6094 // Null elements to avoid leaks in IE. | |
| 6095 body = container = div = null; | |
| 6096 } | |
| 6097 | |
| 6098 return shrinkWrapBlocksVal; | |
| 6099 }; | |
| 6100 | |
| 6101 })(); | |
| 6102 var rmargin = (/^margin/); | |
| 6103 | |
| 6104 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); | |
| 6105 | |
| 6106 | |
| 6107 | |
| 6108 var getStyles, curCSS, | |
| 6109 rposition = /^(top|right|bottom|left)$/; | |
| 6110 | |
| 6111 if ( window.getComputedStyle ) { | |
| 6112 getStyles = function( elem ) { | |
| 6113 return elem.ownerDocument.defaultView.getComputedStyle( elem, null ); | |
| 6114 }; | |
| 6115 | |
| 6116 curCSS = function( elem, name, computed ) { | |
| 6117 var width, minWidth, maxWidth, ret, | |
| 6118 style = elem.style; | |
| 6119 | |
| 6120 computed = computed || getStyles( elem ); | |
| 6121 | |
| 6122 // getPropertyValue is only needed for .css('filter') in IE9, see #12537 | |
| 6123 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined; | |
| 6124 | |
| 6125 if ( computed ) { | |
| 6126 | |
| 6127 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { | |
| 6128 ret = jQuery.style( elem, name ); | |
| 6129 } | |
| 6130 | |
| 6131 // A tribute to the "awesome hack by Dean Edwards" | |
| 6132 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right | |
| 6133 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels | |
| 6134 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values | |
| 6135 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { | |
| 6136 | |
| 6137 // Remember the original values | |
| 6138 width = style.width; | |
| 6139 minWidth = style.minWidth; | |
| 6140 maxWidth = style.maxWidth; | |
| 6141 | |
| 6142 // Put in the new values to get a computed value out | |
| 6143 style.minWidth = style.maxWidth = style.width = ret; | |
| 6144 ret = computed.width; | |
| 6145 | |
| 6146 // Revert the changed values | |
| 6147 style.width = width; | |
| 6148 style.minWidth = minWidth; | |
| 6149 style.maxWidth = maxWidth; | |
| 6150 } | |
| 6151 } | |
| 6152 | |
| 6153 // Support: IE | |
| 6154 // IE returns zIndex value as an integer. | |
| 6155 return ret === undefined ? | |
| 6156 ret : | |
| 6157 ret + ""; | |
| 6158 }; | |
| 6159 } else if ( document.documentElement.currentStyle ) { | |
| 6160 getStyles = function( elem ) { | |
| 6161 return elem.currentStyle; | |
| 6162 }; | |
| 6163 | |
| 6164 curCSS = function( elem, name, computed ) { | |
| 6165 var left, rs, rsLeft, ret, | |
| 6166 style = elem.style; | |
| 6167 | |
| 6168 computed = computed || getStyles( elem ); | |
| 6169 ret = computed ? computed[ name ] : undefined; | |
| 6170 | |
| 6171 // Avoid setting ret to empty string here | |
| 6172 // so we don't default to auto | |
| 6173 if ( ret == null && style && style[ name ] ) { | |
| 6174 ret = style[ name ]; | |
| 6175 } | |
| 6176 | |
| 6177 // From the awesome hack by Dean Edwards | |
| 6178 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 | |
| 6179 | |
| 6180 // If we're not dealing with a regular pixel number | |
| 6181 // but a number that has a weird ending, we need to convert it to pixels | |
| 6182 // but not position css attributes, as those are proportional to the parent element instead | |
| 6183 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem | |
| 6184 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { | |
| 6185 | |
| 6186 // Remember the original values | |
| 6187 left = style.left; | |
| 6188 rs = elem.runtimeStyle; | |
| 6189 rsLeft = rs && rs.left; | |
| 6190 | |
| 6191 // Put in the new values to get a computed value out | |
| 6192 if ( rsLeft ) { | |
| 6193 rs.left = elem.currentStyle.left; | |
| 6194 } | |
| 6195 style.left = name === "fontSize" ? "1em" : ret; | |
| 6196 ret = style.pixelLeft + "px"; | |
| 6197 | |
| 6198 // Revert the changed values | |
| 6199 style.left = left; | |
| 6200 if ( rsLeft ) { | |
| 6201 rs.left = rsLeft; | |
| 6202 } | |
| 6203 } | |
| 6204 | |
| 6205 // Support: IE | |
| 6206 // IE returns zIndex value as an integer. | |
| 6207 return ret === undefined ? | |
| 6208 ret : | |
| 6209 ret + "" || "auto"; | |
| 6210 }; | |
| 6211 } | |
| 6212 | |
| 6213 | |
| 6214 | |
| 6215 | |
| 6216 function addGetHookIf( conditionFn, hookFn ) { | |
| 6217 // Define the hook, we'll check on the first run if it's really needed. | |
| 6218 return { | |
| 6219 get: function() { | |
| 6220 var condition = conditionFn(); | |
| 6221 | |
| 6222 if ( condition == null ) { | |
| 6223 // The test was not ready at this point; screw the hook this time | |
| 6224 // but check again when needed next time. | |
| 6225 return; | |
| 6226 } | |
| 6227 | |
| 6228 if ( condition ) { | |
| 6229 // Hook not needed (or it's not possible to use it due to missing dependency), | |
| 6230 // remove it. | |
| 6231 // Since there are no other hooks for marginRight, remove the whole object. | |
| 6232 delete this.get; | |
| 6233 return; | |
| 6234 } | |
| 6235 | |
| 6236 // Hook needed; redefine it so that the support test is not executed again. | |
| 6237 | |
| 6238 return (this.get = hookFn).apply( this, arguments ); | |
| 6239 } | |
| 6240 }; | |
| 6241 } | |
| 6242 | |
| 6243 | |
| 6244 (function() { | |
| 6245 var a, reliableHiddenOffsetsVal, boxSizingVal, boxSizingReliableVal, | |
| 6246 pixelPositionVal, reliableMarginRightVal, | |
| 6247 div = document.createElement( "div" ), | |
| 6248 containerStyles = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px", | |
| 6249 divReset = | |
| 6250 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" + | |
| 6251 "display:block;padding:0;margin:0;border:0"; | |
| 6252 | |
| 6253 // Setup | |
| 6254 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; | |
| 6255 a = div.getElementsByTagName( "a" )[ 0 ]; | |
| 6256 | |
| 6257 a.style.cssText = "float:left;opacity:.5"; | |
| 6258 | |
| 6259 // Make sure that element opacity exists | |
| 6260 // (IE uses filter instead) | |
| 6261 // Use a regex to work around a WebKit issue. See #5145 | |
| 6262 support.opacity = /^0.5/.test( a.style.opacity ); | |
| 6263 | |
| 6264 // Verify style float existence | |
| 6265 // (IE uses styleFloat instead of cssFloat) | |
| 6266 support.cssFloat = !!a.style.cssFloat; | |
| 6267 | |
| 6268 div.style.backgroundClip = "content-box"; | |
| 6269 div.cloneNode( true ).style.backgroundClip = ""; | |
| 6270 support.clearCloneStyle = div.style.backgroundClip === "content-box"; | |
| 6271 | |
| 6272 // Null elements to avoid leaks in IE. | |
| 6273 a = div = null; | |
| 6274 | |
| 6275 jQuery.extend(support, { | |
| 6276 reliableHiddenOffsets: function() { | |
| 6277 if ( reliableHiddenOffsetsVal != null ) { | |
| 6278 return reliableHiddenOffsetsVal; | |
| 6279 } | |
| 6280 | |
| 6281 var container, tds, isSupported, | |
| 6282 div = document.createElement( "div" ), | |
| 6283 body = document.getElementsByTagName( "body" )[ 0 ]; | |
| 6284 | |
| 6285 if ( !body ) { | |
| 6286 // Return for frameset docs that don't have a body | |
| 6287 return; | |
| 6288 } | |
| 6289 | |
| 6290 // Setup | |
| 6291 div.setAttribute( "className", "t" ); | |
| 6292 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; | |
| 6293 | |
| 6294 container = document.createElement( "div" ); | |
| 6295 container.style.cssText = containerStyles; | |
| 6296 | |
| 6297 body.appendChild( container ).appendChild( div ); | |
| 6298 | |
| 6299 // Support: IE8 | |
| 6300 // Check if table cells still have offsetWidth/Height when they are set | |
| 6301 // to display:none and there are still other visible table cells in a | |
| 6302 // table row; if so, offsetWidth/Height are not reliable for use when | |
| 6303 // determining if an element has been hidden directly using | |
| 6304 // display:none (it is still safe to use offsets if a parent element is | |
| 6305 // hidden; don safety goggles and see bug #4512 for more information). | |
| 6306 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>"; | |
| 6307 tds = div.getElementsByTagName( "td" ); | |
| 6308 tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; | |
| 6309 isSupported = ( tds[ 0 ].offsetHeight === 0 ); | |
| 6310 | |
| 6311 tds[ 0 ].style.display = ""; | |
| 6312 tds[ 1 ].style.display = "none"; | |
| 6313 | |
| 6314 // Support: IE8 | |
| 6315 // Check if empty table cells still have offsetWidth/Height | |
| 6316 reliableHiddenOffsetsVal = isSupported && ( tds[ 0 ].offsetHeight === 0 ); | |
| 6317 | |
| 6318 body.removeChild( container ); | |
| 6319 | |
| 6320 // Null elements to avoid leaks in IE. | |
| 6321 div = body = null; | |
| 6322 | |
| 6323 return reliableHiddenOffsetsVal; | |
| 6324 }, | |
| 6325 | |
| 6326 boxSizing: function() { | |
| 6327 if ( boxSizingVal == null ) { | |
| 6328 computeStyleTests(); | |
| 6329 } | |
| 6330 return boxSizingVal; | |
| 6331 }, | |
| 6332 | |
| 6333 boxSizingReliable: function() { | |
| 6334 if ( boxSizingReliableVal == null ) { | |
| 6335 computeStyleTests(); | |
| 6336 } | |
| 6337 return boxSizingReliableVal; | |
| 6338 }, | |
| 6339 | |
| 6340 pixelPosition: function() { | |
| 6341 if ( pixelPositionVal == null ) { | |
| 6342 computeStyleTests(); | |
| 6343 } | |
| 6344 return pixelPositionVal; | |
| 6345 }, | |
| 6346 | |
| 6347 reliableMarginRight: function() { | |
| 6348 var body, container, div, marginDiv; | |
| 6349 | |
| 6350 // Use window.getComputedStyle because jsdom on node.js will break without it. | |
| 6351 if ( reliableMarginRightVal == null && window.getComputedStyle ) { | |
| 6352 body = document.getElementsByTagName( "body" )[ 0 ]; | |
| 6353 if ( !body ) { | |
| 6354 // Test fired too early or in an unsupported environment, exit. | |
| 6355 return; | |
| 6356 } | |
| 6357 | |
| 6358 container = document.createElement( "div" ); | |
| 6359 div = document.createElement( "div" ); | |
| 6360 container.style.cssText = containerStyles; | |
| 6361 | |
| 6362 body.appendChild( container ).appendChild( div ); | |
| 6363 | |
| 6364 // Check if div with explicit width and no margin-right incorrectly | |
| 6365 // gets computed margin-right based on width of container. (#3333) | |
| 6366 // Fails in WebKit before Feb 2011 nightlies | |
| 6367 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right | |
| 6368 marginDiv = div.appendChild( document.createElement( "div" ) ); | |
| 6369 marginDiv.style.cssText = div.style.cssText = divReset; | |
| 6370 marginDiv.style.marginRight = marginDiv.style.width = "0"; | |
| 6371 div.style.width = "1px"; | |
| 6372 | |
| 6373 reliableMarginRightVal = | |
| 6374 !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); | |
| 6375 | |
| 6376 body.removeChild( container ); | |
| 6377 } | |
| 6378 | |
| 6379 return reliableMarginRightVal; | |
| 6380 } | |
| 6381 }); | |
| 6382 | |
| 6383 function computeStyleTests() { | |
| 6384 var container, div, | |
| 6385 body = document.getElementsByTagName( "body" )[ 0 ]; | |
| 6386 | |
| 6387 if ( !body ) { | |
| 6388 // Test fired too early or in an unsupported environment, exit. | |
| 6389 return; | |
| 6390 } | |
| 6391 | |
| 6392 container = document.createElement( "div" ); | |
| 6393 div = document.createElement( "div" ); | |
| 6394 container.style.cssText = containerStyles; | |
| 6395 | |
| 6396 body.appendChild( container ).appendChild( div ); | |
| 6397 | |
| 6398 div.style.cssText = | |
| 6399 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" + | |
| 6400 "position:absolute;display:block;padding:1px;border:1px;width:4px;" + | |
| 6401 "margin-top:1%;top:1%"; | |
| 6402 | |
| 6403 // Workaround failing boxSizing test due to offsetWidth returning wrong value | |
| 6404 // with some non-1 values of body zoom, ticket #13543 | |
| 6405 jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() { | |
| 6406 boxSizingVal = div.offsetWidth === 4; | |
| 6407 }); | |
| 6408 | |
| 6409 // Will be changed later if needed. | |
| 6410 boxSizingReliableVal = true; | |
| 6411 pixelPositionVal = false; | |
| 6412 reliableMarginRightVal = true; | |
| 6413 | |
| 6414 // Use window.getComputedStyle because jsdom on node.js will break without it. | |
| 6415 if ( window.getComputedStyle ) { | |
| 6416 pixelPositionVal = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; | |
| 6417 boxSizingReliableVal = | |
| 6418 ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; | |
| 6419 } | |
| 6420 | |
| 6421 body.removeChild( container ); | |
| 6422 | |
| 6423 // Null elements to avoid leaks in IE. | |
| 6424 div = body = null; | |
| 6425 } | |
| 6426 | |
| 6427 })(); | |
| 6428 | |
| 6429 | |
| 6430 // A method for quickly swapping in/out CSS properties to get correct calculations. | |
| 6431 jQuery.swap = function( elem, options, callback, args ) { | |
| 6432 var ret, name, | |
| 6433 old = {}; | |
| 6434 | |
| 6435 // Remember the old values, and insert the new ones | |
| 6436 for ( name in options ) { | |
| 6437 old[ name ] = elem.style[ name ]; | |
| 6438 elem.style[ name ] = options[ name ]; | |
| 6439 } | |
| 6440 | |
| 6441 ret = callback.apply( elem, args || [] ); | |
| 6442 | |
| 6443 // Revert the old values | |
| 6444 for ( name in options ) { | |
| 6445 elem.style[ name ] = old[ name ]; | |
| 6446 } | |
| 6447 | |
| 6448 return ret; | |
| 6449 }; | |
| 6450 | |
| 6451 | |
| 6452 var | |
| 6453 ralpha = /alpha\([^)]*\)/i, | |
| 6454 ropacity = /opacity\s*=\s*([^)]*)/, | |
| 6455 | |
| 6456 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" | |
| 6457 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display | |
| 6458 rdisplayswap = /^(none|table(?!-c[ea]).+)/, | |
| 6459 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ), | |
| 6460 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ), | |
| 6461 | |
| 6462 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, | |
| 6463 cssNormalTransform = { | |
| 6464 letterSpacing: 0, | |
| 6465 fontWeight: 400 | |
| 6466 }, | |
| 6467 | |
| 6468 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; | |
| 6469 | |
| 6470 | |
| 6471 // return a css property mapped to a potentially vendor prefixed property | |
| 6472 function vendorPropName( style, name ) { | |
| 6473 | |
| 6474 // shortcut for names that are not vendor prefixed | |
| 6475 if ( name in style ) { | |
| 6476 return name; | |
| 6477 } | |
| 6478 | |
| 6479 // check for vendor prefixed names | |
| 6480 var capName = name.charAt(0).toUpperCase() + name.slice(1), | |
| 6481 origName = name, | |
| 6482 i = cssPrefixes.length; | |
| 6483 | |
| 6484 while ( i-- ) { | |
| 6485 name = cssPrefixes[ i ] + capName; | |
| 6486 if ( name in style ) { | |
| 6487 return name; | |
| 6488 } | |
| 6489 } | |
| 6490 | |
| 6491 return origName; | |
| 6492 } | |
| 6493 | |
| 6494 function showHide( elements, show ) { | |
| 6495 var display, elem, hidden, | |
| 6496 values = [], | |
| 6497 index = 0, | |
| 6498 length = elements.length; | |
| 6499 | |
| 6500 for ( ; index < length; index++ ) { | |
| 6501 elem = elements[ index ]; | |
| 6502 if ( !elem.style ) { | |
| 6503 continue; | |
| 6504 } | |
| 6505 | |
| 6506 values[ index ] = jQuery._data( elem, "olddisplay" ); | |
| 6507 display = elem.style.display; | |
| 6508 if ( show ) { | |
| 6509 // Reset the inline display of this element to learn if it is | |
| 6510 // being hidden by cascaded rules or not | |
| 6511 if ( !values[ index ] && display === "none" ) { | |
| 6512 elem.style.display = ""; | |
| 6513 } | |
| 6514 | |
| 6515 // Set elements which have been overridden with display: none | |
| 6516 // in a stylesheet to whatever the default browser style is | |
| 6517 // for such an element | |
| 6518 if ( elem.style.display === "" && isHidden( elem ) ) { | |
| 6519 values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) ); | |
| 6520 } | |
| 6521 } else { | |
| 6522 | |
| 6523 if ( !values[ index ] ) { | |
| 6524 hidden = isHidden( elem ); | |
| 6525 | |
| 6526 if ( display && display !== "none" || !hidden ) { | |
| 6527 jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); | |
| 6528 } | |
| 6529 } | |
| 6530 } | |
| 6531 } | |
| 6532 | |
| 6533 // Set the display of most of the elements in a second loop | |
| 6534 // to avoid the constant reflow | |
| 6535 for ( index = 0; index < length; index++ ) { | |
| 6536 elem = elements[ index ]; | |
| 6537 if ( !elem.style ) { | |
| 6538 continue; | |
| 6539 } | |
| 6540 if ( !show || elem.style.display === "none" || elem.style.display === "" ) { | |
| 6541 elem.style.display = show ? values[ index ] || "" : "none"; | |
| 6542 } | |
| 6543 } | |
| 6544 | |
| 6545 return elements; | |
| 6546 } | |
| 6547 | |
| 6548 function setPositiveNumber( elem, value, subtract ) { | |
| 6549 var matches = rnumsplit.exec( value ); | |
| 6550 return matches ? | |
| 6551 // Guard against undefined "subtract", e.g., when used as in cssHooks | |
| 6552 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : | |
| 6553 value; | |
| 6554 } | |
| 6555 | |
| 6556 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { | |
| 6557 var i = extra === ( isBorderBox ? "border" : "content" ) ? | |
| 6558 // If we already have the right measurement, avoid augmentation | |
| 6559 4 : | |
| 6560 // Otherwise initialize for horizontal or vertical properties | |
| 6561 name === "width" ? 1 : 0, | |
| 6562 | |
| 6563 val = 0; | |
| 6564 | |
| 6565 for ( ; i < 4; i += 2 ) { | |
| 6566 // both box models exclude margin, so add it if we want it | |
| 6567 if ( extra === "margin" ) { | |
| 6568 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); | |
| 6569 } | |
| 6570 | |
| 6571 if ( isBorderBox ) { | |
| 6572 // border-box includes padding, so remove it if we want content | |
| 6573 if ( extra === "content" ) { | |
| 6574 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); | |
| 6575 } | |
| 6576 | |
| 6577 // at this point, extra isn't border nor margin, so remove border | |
| 6578 if ( extra !== "margin" ) { | |
| 6579 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); | |
| 6580 } | |
| 6581 } else { | |
| 6582 // at this point, extra isn't content, so add padding | |
| 6583 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); | |
| 6584 | |
| 6585 // at this point, extra isn't content nor padding, so add border | |
| 6586 if ( extra !== "padding" ) { | |
| 6587 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); | |
| 6588 } | |
| 6589 } | |
| 6590 } | |
| 6591 | |
| 6592 return val; | |
| 6593 } | |
| 6594 | |
| 6595 function getWidthOrHeight( elem, name, extra ) { | |
| 6596 | |
| 6597 // Start with offset property, which is equivalent to the border-box value | |
| 6598 var valueIsBorderBox = true, | |
| 6599 val = name === "width" ? elem.offsetWidth : elem.offsetHeight, | |
| 6600 styles = getStyles( elem ), | |
| 6601 isBorderBox = support.boxSizing() && jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; | |
| 6602 | |
| 6603 // some non-html elements return undefined for offsetWidth, so check for null/undefined | |
| 6604 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 | |
| 6605 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 | |
| 6606 if ( val <= 0 || val == null ) { | |
| 6607 // Fall back to computed then uncomputed css if necessary | |
| 6608 val = curCSS( elem, name, styles ); | |
| 6609 if ( val < 0 || val == null ) { | |
| 6610 val = elem.style[ name ]; | |
| 6611 } | |
| 6612 | |
| 6613 // Computed unit is not pixels. Stop here and return. | |
| 6614 if ( rnumnonpx.test(val) ) { | |
| 6615 return val; | |
| 6616 } | |
| 6617 | |
| 6618 // we need the check for style in case a browser which returns unreliable values | |
| 6619 // for getComputedStyle silently falls back to the reliable elem.style | |
| 6620 valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] ); | |
| 6621 | |
| 6622 // Normalize "", auto, and prepare for extra | |
| 6623 val = parseFloat( val ) || 0; | |
| 6624 } | |
| 6625 | |
| 6626 // use the active box-sizing model to add/subtract irrelevant styles | |
| 6627 return ( val + | |
| 6628 augmentWidthOrHeight( | |
| 6629 elem, | |
| 6630 name, | |
| 6631 extra || ( isBorderBox ? "border" : "content" ), | |
| 6632 valueIsBorderBox, | |
| 6633 styles | |
| 6634 ) | |
| 6635 ) + "px"; | |
| 6636 } | |
| 6637 | |
| 6638 jQuery.extend({ | |
| 6639 // Add in style property hooks for overriding the default | |
| 6640 // behavior of getting and setting a style property | |
| 6641 cssHooks: { | |
| 6642 opacity: { | |
| 6643 get: function( elem, computed ) { | |
| 6644 if ( computed ) { | |
| 6645 // We should always get a number back from opacity | |
| 6646 var ret = curCSS( elem, "opacity" ); | |
| 6647 return ret === "" ? "1" : ret; | |
| 6648 } | |
| 6649 } | |
| 6650 } | |
| 6651 }, | |
| 6652 | |
| 6653 // Don't automatically add "px" to these possibly-unitless properties | |
| 6654 cssNumber: { | |
| 6655 "columnCount": true, | |
| 6656 "fillOpacity": true, | |
| 6657 "fontWeight": true, | |
| 6658 "lineHeight": true, | |
| 6659 "opacity": true, | |
| 6660 "order": true, | |
| 6661 "orphans": true, | |
| 6662 "widows": true, | |
| 6663 "zIndex": true, | |
| 6664 "zoom": true | |
| 6665 }, | |
| 6666 | |
| 6667 // Add in properties whose names you wish to fix before | |
| 6668 // setting or getting the value | |
| 6669 cssProps: { | |
| 6670 // normalize float css property | |
| 6671 "float": support.cssFloat ? "cssFloat" : "styleFloat" | |
| 6672 }, | |
| 6673 | |
| 6674 // Get and set the style property on a DOM Node | |
| 6675 style: function( elem, name, value, extra ) { | |
| 6676 // Don't set styles on text and comment nodes | |
| 6677 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { | |
| 6678 return; | |
| 6679 } | |
| 6680 | |
| 6681 // Make sure that we're working with the right name | |
| 6682 var ret, type, hooks, | |
| 6683 origName = jQuery.camelCase( name ), | |
| 6684 style = elem.style; | |
| 6685 | |
| 6686 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); | |
| 6687 | |
| 6688 // gets hook for the prefixed version | |
| 6689 // followed by the unprefixed version | |
| 6690 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; | |
| 6691 | |
| 6692 // Check if we're setting a value | |
| 6693 if ( value !== undefined ) { | |
| 6694 type = typeof value; | |
| 6695 | |
| 6696 // convert relative number strings (+= or -=) to relative numbers. #7345 | |
| 6697 if ( type === "string" && (ret = rrelNum.exec( value )) ) { | |
| 6698 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); | |
| 6699 // Fixes bug #9237 | |
| 6700 type = "number"; | |
| 6701 } | |
| 6702 | |
| 6703 // Make sure that null and NaN values aren't set. See: #7116 | |
| 6704 if ( value == null || value !== value ) { | |
| 6705 return; | |
| 6706 } | |
| 6707 | |
| 6708 // If a number was passed in, add 'px' to the (except for certain CSS properties) | |
| 6709 if ( type === "number" && !jQuery.cssNumber[ origName ] ) { | |
| 6710 value += "px"; | |
| 6711 } | |
| 6712 | |
| 6713 // Fixes #8908, it can be done more correctly by specifing setters in cssHooks, | |
| 6714 // but it would mean to define eight (for every problematic property) identical functions | |
| 6715 if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) { | |
| 6716 style[ name ] = "inherit"; | |
| 6717 } | |
| 6718 | |
| 6719 // If a hook was provided, use that value, otherwise just set the specified value | |
| 6720 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { | |
| 6721 | |
| 6722 // Support: IE | |
| 6723 // Swallow errors from 'invalid' CSS values (#5509) | |
| 6724 try { | |
| 6725 // Support: Chrome, Safari | |
| 6726 // Setting style to blank string required to delete "style: x !important;" | |
| 6727 style[ name ] = ""; | |
| 6728 style[ name ] = value; | |
| 6729 } catch(e) {} | |
| 6730 } | |
| 6731 | |
| 6732 } else { | |
| 6733 // If a hook was provided get the non-computed value from there | |
| 6734 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { | |
| 6735 return ret; | |
| 6736 } | |
| 6737 | |
| 6738 // Otherwise just get the value from the style object | |
| 6739 return style[ name ]; | |
| 6740 } | |
| 6741 }, | |
| 6742 | |
| 6743 css: function( elem, name, extra, styles ) { | |
| 6744 var num, val, hooks, | |
| 6745 origName = jQuery.camelCase( name ); | |
| 6746 | |
| 6747 // Make sure that we're working with the right name | |
| 6748 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); | |
| 6749 | |
| 6750 // gets hook for the prefixed version | |
| 6751 // followed by the unprefixed version | |
| 6752 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; | |
| 6753 | |
| 6754 // If a hook was provided get the computed value from there | |
| 6755 if ( hooks && "get" in hooks ) { | |
| 6756 val = hooks.get( elem, true, extra ); | |
| 6757 } | |
| 6758 | |
| 6759 // Otherwise, if a way to get the computed value exists, use that | |
| 6760 if ( val === undefined ) { | |
| 6761 val = curCSS( elem, name, styles ); | |
| 6762 } | |
| 6763 | |
| 6764 //convert "normal" to computed value | |
| 6765 if ( val === "normal" && name in cssNormalTransform ) { | |
| 6766 val = cssNormalTransform[ name ]; | |
| 6767 } | |
| 6768 | |
| 6769 // Return, converting to number if forced or a qualifier was provided and val looks numeric | |
| 6770 if ( extra === "" || extra ) { | |
| 6771 num = parseFloat( val ); | |
| 6772 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; | |
| 6773 } | |
| 6774 return val; | |
| 6775 } | |
| 6776 }); | |
| 6777 | |
| 6778 jQuery.each([ "height", "width" ], function( i, name ) { | |
| 6779 jQuery.cssHooks[ name ] = { | |
| 6780 get: function( elem, computed, extra ) { | |
| 6781 if ( computed ) { | |
| 6782 // certain elements can have dimension info if we invisibly show them | |
| 6783 // however, it must have a current display style that would benefit from this | |
| 6784 return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ? | |
| 6785 jQuery.swap( elem, cssShow, function() { | |
| 6786 return getWidthOrHeight( elem, name, extra ); | |
| 6787 }) : | |
| 6788 getWidthOrHeight( elem, name, extra ); | |
| 6789 } | |
| 6790 }, | |
| 6791 | |
| 6792 set: function( elem, value, extra ) { | |
| 6793 var styles = extra && getStyles( elem ); | |
| 6794 return setPositiveNumber( elem, value, extra ? | |
| 6795 augmentWidthOrHeight( | |
| 6796 elem, | |
| 6797 name, | |
| 6798 extra, | |
| 6799 support.boxSizing() && jQuery.css( elem, "boxSizing", false, styles ) === "border-box", | |
| 6800 styles | |
| 6801 ) : 0 | |
| 6802 ); | |
| 6803 } | |
| 6804 }; | |
| 6805 }); | |
| 6806 | |
| 6807 if ( !support.opacity ) { | |
| 6808 jQuery.cssHooks.opacity = { | |
| 6809 get: function( elem, computed ) { | |
| 6810 // IE uses filters for opacity | |
| 6811 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? | |
| 6812 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" : | |
| 6813 computed ? "1" : ""; | |
| 6814 }, | |
| 6815 | |
| 6816 set: function( elem, value ) { | |
| 6817 var style = elem.style, | |
| 6818 currentStyle = elem.currentStyle, | |
| 6819 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "", | |
| 6820 filter = currentStyle && currentStyle.filter || style.filter || ""; | |
| 6821 | |
| 6822 // IE has trouble with opacity if it does not have layout | |
| 6823 // Force it by setting the zoom level | |
| 6824 style.zoom = 1; | |
| 6825 | |
| 6826 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 | |
| 6827 // if value === "", then remove inline opacity #12685 | |
| 6828 if ( ( value >= 1 || value === "" ) && | |
| 6829 jQuery.trim( filter.replace( ralpha, "" ) ) === "" && | |
| 6830 style.removeAttribute ) { | |
| 6831 | |
| 6832 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText | |
| 6833 // if "filter:" is present at all, clearType is disabled, we want to avoid this | |
| 6834 // style.removeAttribute is IE Only, but so apparently is this code path... | |
| 6835 style.removeAttribute( "filter" ); | |
| 6836 | |
| 6837 // if there is no filter style applied in a css rule or unset inline opacity, we are done | |
| 6838 if ( value === "" || currentStyle && !currentStyle.filter ) { | |
| 6839 return; | |
| 6840 } | |
| 6841 } | |
| 6842 | |
| 6843 // otherwise, set new filter values | |
| 6844 style.filter = ralpha.test( filter ) ? | |
| 6845 filter.replace( ralpha, opacity ) : | |
| 6846 filter + " " + opacity; | |
| 6847 } | |
| 6848 }; | |
| 6849 } | |
| 6850 | |
| 6851 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, | |
| 6852 function( elem, computed ) { | |
| 6853 if ( computed ) { | |
| 6854 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right | |
| 6855 // Work around by temporarily setting element display to inline-block | |
| 6856 return jQuery.swap( elem, { "display": "inline-block" }, | |
| 6857 curCSS, [ elem, "marginRight" ] ); | |
| 6858 } | |
| 6859 } | |
| 6860 ); | |
| 6861 | |
| 6862 // These hooks are used by animate to expand properties | |
| 6863 jQuery.each({ | |
| 6864 margin: "", | |
| 6865 padding: "", | |
| 6866 border: "Width" | |
| 6867 }, function( prefix, suffix ) { | |
| 6868 jQuery.cssHooks[ prefix + suffix ] = { | |
| 6869 expand: function( value ) { | |
| 6870 var i = 0, | |
| 6871 expanded = {}, | |
| 6872 | |
| 6873 // assumes a single number if not a string | |
| 6874 parts = typeof value === "string" ? value.split(" ") : [ value ]; | |
| 6875 | |
| 6876 for ( ; i < 4; i++ ) { | |
| 6877 expanded[ prefix + cssExpand[ i ] + suffix ] = | |
| 6878 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; | |
| 6879 } | |
| 6880 | |
| 6881 return expanded; | |
| 6882 } | |
| 6883 }; | |
| 6884 | |
| 6885 if ( !rmargin.test( prefix ) ) { | |
| 6886 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; | |
| 6887 } | |
| 6888 }); | |
| 6889 | |
| 6890 jQuery.fn.extend({ | |
| 6891 css: function( name, value ) { | |
| 6892 return access( this, function( elem, name, value ) { | |
| 6893 var styles, len, | |
| 6894 map = {}, | |
| 6895 i = 0; | |
| 6896 | |
| 6897 if ( jQuery.isArray( name ) ) { | |
| 6898 styles = getStyles( elem ); | |
| 6899 len = name.length; | |
| 6900 | |
| 6901 for ( ; i < len; i++ ) { | |
| 6902 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); | |
| 6903 } | |
| 6904 | |
| 6905 return map; | |
| 6906 } | |
| 6907 | |
| 6908 return value !== undefined ? | |
| 6909 jQuery.style( elem, name, value ) : | |
| 6910 jQuery.css( elem, name ); | |
| 6911 }, name, value, arguments.length > 1 ); | |
| 6912 }, | |
| 6913 show: function() { | |
| 6914 return showHide( this, true ); | |
| 6915 }, | |
| 6916 hide: function() { | |
| 6917 return showHide( this ); | |
| 6918 }, | |
| 6919 toggle: function( state ) { | |
| 6920 if ( typeof state === "boolean" ) { | |
| 6921 return state ? this.show() : this.hide(); | |
| 6922 } | |
| 6923 | |
| 6924 return this.each(function() { | |
| 6925 if ( isHidden( this ) ) { | |
| 6926 jQuery( this ).show(); | |
| 6927 } else { | |
| 6928 jQuery( this ).hide(); | |
| 6929 } | |
| 6930 }); | |
| 6931 } | |
| 6932 }); | |
| 6933 | |
| 6934 | |
| 6935 function Tween( elem, options, prop, end, easing ) { | |
| 6936 return new Tween.prototype.init( elem, options, prop, end, easing ); | |
| 6937 } | |
| 6938 jQuery.Tween = Tween; | |
| 6939 | |
| 6940 Tween.prototype = { | |
| 6941 constructor: Tween, | |
| 6942 init: function( elem, options, prop, end, easing, unit ) { | |
| 6943 this.elem = elem; | |
| 6944 this.prop = prop; | |
| 6945 this.easing = easing || "swing"; | |
| 6946 this.options = options; | |
| 6947 this.start = this.now = this.cur(); | |
| 6948 this.end = end; | |
| 6949 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); | |
| 6950 }, | |
| 6951 cur: function() { | |
| 6952 var hooks = Tween.propHooks[ this.prop ]; | |
| 6953 | |
| 6954 return hooks && hooks.get ? | |
| 6955 hooks.get( this ) : | |
| 6956 Tween.propHooks._default.get( this ); | |
| 6957 }, | |
| 6958 run: function( percent ) { | |
| 6959 var eased, | |
| 6960 hooks = Tween.propHooks[ this.prop ]; | |
| 6961 | |
| 6962 if ( this.options.duration ) { | |
| 6963 this.pos = eased = jQuery.easing[ this.easing ]( | |
| 6964 percent, this.options.duration * percent, 0, 1, this.options.duration | |
| 6965 ); | |
| 6966 } else { | |
| 6967 this.pos = eased = percent; | |
| 6968 } | |
| 6969 this.now = ( this.end - this.start ) * eased + this.start; | |
| 6970 | |
| 6971 if ( this.options.step ) { | |
| 6972 this.options.step.call( this.elem, this.now, this ); | |
| 6973 } | |
| 6974 | |
| 6975 if ( hooks && hooks.set ) { | |
| 6976 hooks.set( this ); | |
| 6977 } else { | |
| 6978 Tween.propHooks._default.set( this ); | |
| 6979 } | |
| 6980 return this; | |
| 6981 } | |
| 6982 }; | |
| 6983 | |
| 6984 Tween.prototype.init.prototype = Tween.prototype; | |
| 6985 | |
| 6986 Tween.propHooks = { | |
| 6987 _default: { | |
| 6988 get: function( tween ) { | |
| 6989 var result; | |
| 6990 | |
| 6991 if ( tween.elem[ tween.prop ] != null && | |
| 6992 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { | |
| 6993 return tween.elem[ tween.prop ]; | |
| 6994 } | |
| 6995 | |
| 6996 // passing an empty string as a 3rd parameter to .css will automatically | |
| 6997 // attempt a parseFloat and fallback to a string if the parse fails | |
| 6998 // so, simple values such as "10px" are parsed to Float. | |
| 6999 // complex values such as "rotate(1rad)" are returned as is. | |
| 7000 result = jQuery.css( tween.elem, tween.prop, "" ); | |
| 7001 // Empty strings, null, undefined and "auto" are converted to 0. | |
| 7002 return !result || result === "auto" ? 0 : result; | |
| 7003 }, | |
| 7004 set: function( tween ) { | |
| 7005 // use step hook for back compat - use cssHook if its there - use .style if its | |
| 7006 // available and use plain properties where available | |
| 7007 if ( jQuery.fx.step[ tween.prop ] ) { | |
| 7008 jQuery.fx.step[ tween.prop ]( tween ); | |
| 7009 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { | |
| 7010 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); | |
| 7011 } else { | |
| 7012 tween.elem[ tween.prop ] = tween.now; | |
| 7013 } | |
| 7014 } | |
| 7015 } | |
| 7016 }; | |
| 7017 | |
| 7018 // Support: IE <=9 | |
| 7019 // Panic based approach to setting things on disconnected nodes | |
| 7020 | |
| 7021 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { | |
| 7022 set: function( tween ) { | |
| 7023 if ( tween.elem.nodeType && tween.elem.parentNode ) { | |
| 7024 tween.elem[ tween.prop ] = tween.now; | |
| 7025 } | |
| 7026 } | |
| 7027 }; | |
| 7028 | |
| 7029 jQuery.easing = { | |
| 7030 linear: function( p ) { | |
| 7031 return p; | |
| 7032 }, | |
| 7033 swing: function( p ) { | |
| 7034 return 0.5 - Math.cos( p * Math.PI ) / 2; | |
| 7035 } | |
| 7036 }; | |
| 7037 | |
| 7038 jQuery.fx = Tween.prototype.init; | |
| 7039 | |
| 7040 // Back Compat <1.8 extension point | |
| 7041 jQuery.fx.step = {}; | |
| 7042 | |
| 7043 | |
| 7044 | |
| 7045 | |
| 7046 var | |
| 7047 fxNow, timerId, | |
| 7048 rfxtypes = /^(?:toggle|show|hide)$/, | |
| 7049 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ), | |
| 7050 rrun = /queueHooks$/, | |
| 7051 animationPrefilters = [ defaultPrefilter ], | |
| 7052 tweeners = { | |
| 7053 "*": [ function( prop, value ) { | |
| 7054 var tween = this.createTween( prop, value ), | |
| 7055 target = tween.cur(), | |
| 7056 parts = rfxnum.exec( value ), | |
| 7057 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), | |
| 7058 | |
| 7059 // Starting value computation is required for potential unit mismatches | |
| 7060 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) && | |
| 7061 rfxnum.exec( jQuery.css( tween.elem, prop ) ), | |
| 7062 scale = 1, | |
| 7063 maxIterations = 20; | |
| 7064 | |
| 7065 if ( start && start[ 3 ] !== unit ) { | |
| 7066 // Trust units reported by jQuery.css | |
| 7067 unit = unit || start[ 3 ]; | |
| 7068 | |
| 7069 // Make sure we update the tween properties later on | |
| 7070 parts = parts || []; | |
| 7071 | |
| 7072 // Iteratively approximate from a nonzero starting point | |
| 7073 start = +target || 1; | |
| 7074 | |
| 7075 do { | |
| 7076 // If previous iteration zeroed out, double until we get *something* | |
| 7077 // Use a string for doubling factor so we don't accidentally see scale as unchanged below | |
| 7078 scale = scale || ".5"; | |
| 7079 | |
| 7080 // Adjust and apply | |
| 7081 start = start / scale; | |
| 7082 jQuery.style( tween.elem, prop, start + unit ); | |
| 7083 | |
| 7084 // Update scale, tolerating zero or NaN from tween.cur() | |
| 7085 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough | |
| 7086 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations ); | |
| 7087 } | |
| 7088 | |
| 7089 // Update tween properties | |
| 7090 if ( parts ) { | |
| 7091 start = tween.start = +start || +target || 0; | |
| 7092 tween.unit = unit; | |
| 7093 // If a +=/-= token was provided, we're doing a relative animation | |
| 7094 tween.end = parts[ 1 ] ? | |
| 7095 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] : | |
| 7096 +parts[ 2 ]; | |
| 7097 } | |
| 7098 | |
| 7099 return tween; | |
| 7100 } ] | |
| 7101 }; | |
| 7102 | |
| 7103 // Animations created synchronously will run synchronously | |
| 7104 function createFxNow() { | |
| 7105 setTimeout(function() { | |
| 7106 fxNow = undefined; | |
| 7107 }); | |
| 7108 return ( fxNow = jQuery.now() ); | |
| 7109 } | |
| 7110 | |
| 7111 // Generate parameters to create a standard animation | |
| 7112 function genFx( type, includeWidth ) { | |
| 7113 var which, | |
| 7114 attrs = { height: type }, | |
| 7115 i = 0; | |
| 7116 | |
| 7117 // if we include width, step value is 1 to do all cssExpand values, | |
| 7118 // if we don't include width, step value is 2 to skip over Left and Right | |
| 7119 includeWidth = includeWidth ? 1 : 0; | |
| 7120 for ( ; i < 4 ; i += 2 - includeWidth ) { | |
| 7121 which = cssExpand[ i ]; | |
| 7122 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; | |
| 7123 } | |
| 7124 | |
| 7125 if ( includeWidth ) { | |
| 7126 attrs.opacity = attrs.width = type; | |
| 7127 } | |
| 7128 | |
| 7129 return attrs; | |
| 7130 } | |
| 7131 | |
| 7132 function createTween( value, prop, animation ) { | |
| 7133 var tween, | |
| 7134 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), | |
| 7135 index = 0, | |
| 7136 length = collection.length; | |
| 7137 for ( ; index < length; index++ ) { | |
| 7138 if ( (tween = collection[ index ].call( animation, prop, value )) ) { | |
| 7139 | |
| 7140 // we're done with this property | |
| 7141 return tween; | |
| 7142 } | |
| 7143 } | |
| 7144 } | |
| 7145 | |
| 7146 function defaultPrefilter( elem, props, opts ) { | |
| 7147 /* jshint validthis: true */ | |
| 7148 var prop, value, toggle, tween, hooks, oldfire, display, dDisplay, | |
| 7149 anim = this, | |
| 7150 orig = {}, | |
| 7151 style = elem.style, | |
| 7152 hidden = elem.nodeType && isHidden( elem ), | |
| 7153 dataShow = jQuery._data( elem, "fxshow" ); | |
| 7154 | |
| 7155 // handle queue: false promises | |
| 7156 if ( !opts.queue ) { | |
| 7157 hooks = jQuery._queueHooks( elem, "fx" ); | |
| 7158 if ( hooks.unqueued == null ) { | |
| 7159 hooks.unqueued = 0; | |
| 7160 oldfire = hooks.empty.fire; | |
| 7161 hooks.empty.fire = function() { | |
| 7162 if ( !hooks.unqueued ) { | |
| 7163 oldfire(); | |
| 7164 } | |
| 7165 }; | |
| 7166 } | |
| 7167 hooks.unqueued++; | |
| 7168 | |
| 7169 anim.always(function() { | |
| 7170 // doing this makes sure that the complete handler will be called | |
| 7171 // before this completes | |
| 7172 anim.always(function() { | |
| 7173 hooks.unqueued--; | |
| 7174 if ( !jQuery.queue( elem, "fx" ).length ) { | |
| 7175 hooks.empty.fire(); | |
| 7176 } | |
| 7177 }); | |
| 7178 }); | |
| 7179 } | |
| 7180 | |
| 7181 // height/width overflow pass | |
| 7182 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { | |
| 7183 // Make sure that nothing sneaks out | |
| 7184 // Record all 3 overflow attributes because IE does not | |
| 7185 // change the overflow attribute when overflowX and | |
| 7186 // overflowY are set to the same value | |
| 7187 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; | |
| 7188 | |
| 7189 // Set display property to inline-block for height/width | |
| 7190 // animations on inline elements that are having width/height animated | |
| 7191 display = jQuery.css( elem, "display" ); | |
| 7192 dDisplay = defaultDisplay( elem.nodeName ); | |
| 7193 if ( display === "none" ) { | |
| 7194 display = dDisplay; | |
| 7195 } | |
| 7196 if ( display === "inline" && | |
| 7197 jQuery.css( elem, "float" ) === "none" ) { | |
| 7198 | |
| 7199 // inline-level elements accept inline-block; | |
| 7200 // block-level elements need to be inline with layout | |
| 7201 if ( !support.inlineBlockNeedsLayout || dDisplay === "inline" ) { | |
| 7202 style.display = "inline-block"; | |
| 7203 } else { | |
| 7204 style.zoom = 1; | |
| 7205 } | |
| 7206 } | |
| 7207 } | |
| 7208 | |
| 7209 if ( opts.overflow ) { | |
| 7210 style.overflow = "hidden"; | |
| 7211 if ( !support.shrinkWrapBlocks() ) { | |
| 7212 anim.always(function() { | |
| 7213 style.overflow = opts.overflow[ 0 ]; | |
| 7214 style.overflowX = opts.overflow[ 1 ]; | |
| 7215 style.overflowY = opts.overflow[ 2 ]; | |
| 7216 }); | |
| 7217 } | |
| 7218 } | |
| 7219 | |
| 7220 // show/hide pass | |
| 7221 for ( prop in props ) { | |
| 7222 value = props[ prop ]; | |
| 7223 if ( rfxtypes.exec( value ) ) { | |
| 7224 delete props[ prop ]; | |
| 7225 toggle = toggle || value === "toggle"; | |
| 7226 if ( value === ( hidden ? "hide" : "show" ) ) { | |
| 7227 | |
| 7228 // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden | |
| 7229 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { | |
| 7230 hidden = true; | |
| 7231 } else { | |
| 7232 continue; | |
| 7233 } | |
| 7234 } | |
| 7235 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); | |
| 7236 } | |
| 7237 } | |
| 7238 | |
| 7239 if ( !jQuery.isEmptyObject( orig ) ) { | |
| 7240 if ( dataShow ) { | |
| 7241 if ( "hidden" in dataShow ) { | |
| 7242 hidden = dataShow.hidden; | |
| 7243 } | |
| 7244 } else { | |
| 7245 dataShow = jQuery._data( elem, "fxshow", {} ); | |
| 7246 } | |
| 7247 | |
| 7248 // store state if its toggle - enables .stop().toggle() to "reverse" | |
| 7249 if ( toggle ) { | |
| 7250 dataShow.hidden = !hidden; | |
| 7251 } | |
| 7252 if ( hidden ) { | |
| 7253 jQuery( elem ).show(); | |
| 7254 } else { | |
| 7255 anim.done(function() { | |
| 7256 jQuery( elem ).hide(); | |
| 7257 }); | |
| 7258 } | |
| 7259 anim.done(function() { | |
| 7260 var prop; | |
| 7261 jQuery._removeData( elem, "fxshow" ); | |
| 7262 for ( prop in orig ) { | |
| 7263 jQuery.style( elem, prop, orig[ prop ] ); | |
| 7264 } | |
| 7265 }); | |
| 7266 for ( prop in orig ) { | |
| 7267 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); | |
| 7268 | |
| 7269 if ( !( prop in dataShow ) ) { | |
| 7270 dataShow[ prop ] = tween.start; | |
| 7271 if ( hidden ) { | |
| 7272 tween.end = tween.start; | |
| 7273 tween.start = prop === "width" || prop === "height" ? 1 : 0; | |
| 7274 } | |
| 7275 } | |
| 7276 } | |
| 7277 } | |
| 7278 } | |
| 7279 | |
| 7280 function propFilter( props, specialEasing ) { | |
| 7281 var index, name, easing, value, hooks; | |
| 7282 | |
| 7283 // camelCase, specialEasing and expand cssHook pass | |
| 7284 for ( index in props ) { | |
| 7285 name = jQuery.camelCase( index ); | |
| 7286 easing = specialEasing[ name ]; | |
| 7287 value = props[ index ]; | |
| 7288 if ( jQuery.isArray( value ) ) { | |
| 7289 easing = value[ 1 ]; | |
| 7290 value = props[ index ] = value[ 0 ]; | |
| 7291 } | |
| 7292 | |
| 7293 if ( index !== name ) { | |
| 7294 props[ name ] = value; | |
| 7295 delete props[ index ]; | |
| 7296 } | |
| 7297 | |
| 7298 hooks = jQuery.cssHooks[ name ]; | |
| 7299 if ( hooks && "expand" in hooks ) { | |
| 7300 value = hooks.expand( value ); | |
| 7301 delete props[ name ]; | |
| 7302 | |
| 7303 // not quite $.extend, this wont overwrite keys already present. | |
| 7304 // also - reusing 'index' from above because we have the correct "name" | |
| 7305 for ( index in value ) { | |
| 7306 if ( !( index in props ) ) { | |
| 7307 props[ index ] = value[ index ]; | |
| 7308 specialEasing[ index ] = easing; | |
| 7309 } | |
| 7310 } | |
| 7311 } else { | |
| 7312 specialEasing[ name ] = easing; | |
| 7313 } | |
| 7314 } | |
| 7315 } | |
| 7316 | |
| 7317 function Animation( elem, properties, options ) { | |
| 7318 var result, | |
| 7319 stopped, | |
| 7320 index = 0, | |
| 7321 length = animationPrefilters.length, | |
| 7322 deferred = jQuery.Deferred().always( function() { | |
| 7323 // don't match elem in the :animated selector | |
| 7324 delete tick.elem; | |
| 7325 }), | |
| 7326 tick = function() { | |
| 7327 if ( stopped ) { | |
| 7328 return false; | |
| 7329 } | |
| 7330 var currentTime = fxNow || createFxNow(), | |
| 7331 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), | |
| 7332 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497) | |
| 7333 temp = remaining / animation.duration || 0, | |
| 7334 percent = 1 - temp, | |
| 7335 index = 0, | |
| 7336 length = animation.tweens.length; | |
| 7337 | |
| 7338 for ( ; index < length ; index++ ) { | |
| 7339 animation.tweens[ index ].run( percent ); | |
| 7340 } | |
| 7341 | |
| 7342 deferred.notifyWith( elem, [ animation, percent, remaining ]); | |
| 7343 | |
| 7344 if ( percent < 1 && length ) { | |
| 7345 return remaining; | |
| 7346 } else { | |
| 7347 deferred.resolveWith( elem, [ animation ] ); | |
| 7348 return false; | |
| 7349 } | |
| 7350 }, | |
| 7351 animation = deferred.promise({ | |
| 7352 elem: elem, | |
| 7353 props: jQuery.extend( {}, properties ), | |
| 7354 opts: jQuery.extend( true, { specialEasing: {} }, options ), | |
| 7355 originalProperties: properties, | |
| 7356 originalOptions: options, | |
| 7357 startTime: fxNow || createFxNow(), | |
| 7358 duration: options.duration, | |
| 7359 tweens: [], | |
| 7360 createTween: function( prop, end ) { | |
| 7361 var tween = jQuery.Tween( elem, animation.opts, prop, end, | |
| 7362 animation.opts.specialEasing[ prop ] || animation.opts.easing ); | |
| 7363 animation.tweens.push( tween ); | |
| 7364 return tween; | |
| 7365 }, | |
| 7366 stop: function( gotoEnd ) { | |
| 7367 var index = 0, | |
| 7368 // if we are going to the end, we want to run all the tweens | |
| 7369 // otherwise we skip this part | |
| 7370 length = gotoEnd ? animation.tweens.length : 0; | |
| 7371 if ( stopped ) { | |
| 7372 return this; | |
| 7373 } | |
| 7374 stopped = true; | |
| 7375 for ( ; index < length ; index++ ) { | |
| 7376 animation.tweens[ index ].run( 1 ); | |
| 7377 } | |
| 7378 | |
| 7379 // resolve when we played the last frame | |
| 7380 // otherwise, reject | |
| 7381 if ( gotoEnd ) { | |
| 7382 deferred.resolveWith( elem, [ animation, gotoEnd ] ); | |
| 7383 } else { | |
| 7384 deferred.rejectWith( elem, [ animation, gotoEnd ] ); | |
| 7385 } | |
| 7386 return this; | |
| 7387 } | |
| 7388 }), | |
| 7389 props = animation.props; | |
| 7390 | |
| 7391 propFilter( props, animation.opts.specialEasing ); | |
| 7392 | |
| 7393 for ( ; index < length ; index++ ) { | |
| 7394 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); | |
| 7395 if ( result ) { | |
| 7396 return result; | |
| 7397 } | |
| 7398 } | |
| 7399 | |
| 7400 jQuery.map( props, createTween, animation ); | |
| 7401 | |
| 7402 if ( jQuery.isFunction( animation.opts.start ) ) { | |
| 7403 animation.opts.start.call( elem, animation ); | |
| 7404 } | |
| 7405 | |
| 7406 jQuery.fx.timer( | |
| 7407 jQuery.extend( tick, { | |
| 7408 elem: elem, | |
| 7409 anim: animation, | |
| 7410 queue: animation.opts.queue | |
| 7411 }) | |
| 7412 ); | |
| 7413 | |
| 7414 // attach callbacks from options | |
| 7415 return animation.progress( animation.opts.progress ) | |
| 7416 .done( animation.opts.done, animation.opts.complete ) | |
| 7417 .fail( animation.opts.fail ) | |
| 7418 .always( animation.opts.always ); | |
| 7419 } | |
| 7420 | |
| 7421 jQuery.Animation = jQuery.extend( Animation, { | |
| 7422 tweener: function( props, callback ) { | |
| 7423 if ( jQuery.isFunction( props ) ) { | |
| 7424 callback = props; | |
| 7425 props = [ "*" ]; | |
| 7426 } else { | |
| 7427 props = props.split(" "); | |
| 7428 } | |
| 7429 | |
| 7430 var prop, | |
| 7431 index = 0, | |
| 7432 length = props.length; | |
| 7433 | |
| 7434 for ( ; index < length ; index++ ) { | |
| 7435 prop = props[ index ]; | |
| 7436 tweeners[ prop ] = tweeners[ prop ] || []; | |
| 7437 tweeners[ prop ].unshift( callback ); | |
| 7438 } | |
| 7439 }, | |
| 7440 | |
| 7441 prefilter: function( callback, prepend ) { | |
| 7442 if ( prepend ) { | |
| 7443 animationPrefilters.unshift( callback ); | |
| 7444 } else { | |
| 7445 animationPrefilters.push( callback ); | |
| 7446 } | |
| 7447 } | |
| 7448 }); | |
| 7449 | |
| 7450 jQuery.speed = function( speed, easing, fn ) { | |
| 7451 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { | |
| 7452 complete: fn || !fn && easing || | |
| 7453 jQuery.isFunction( speed ) && speed, | |
| 7454 duration: speed, | |
| 7455 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing | |
| 7456 }; | |
| 7457 | |
| 7458 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : | |
| 7459 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; | |
| 7460 | |
| 7461 // normalize opt.queue - true/undefined/null -> "fx" | |
| 7462 if ( opt.queue == null || opt.queue === true ) { | |
| 7463 opt.queue = "fx"; | |
| 7464 } | |
| 7465 | |
| 7466 // Queueing | |
| 7467 opt.old = opt.complete; | |
| 7468 | |
| 7469 opt.complete = function() { | |
| 7470 if ( jQuery.isFunction( opt.old ) ) { | |
| 7471 opt.old.call( this ); | |
| 7472 } | |
| 7473 | |
| 7474 if ( opt.queue ) { | |
| 7475 jQuery.dequeue( this, opt.queue ); | |
| 7476 } | |
| 7477 }; | |
| 7478 | |
| 7479 return opt; | |
| 7480 }; | |
| 7481 | |
| 7482 jQuery.fn.extend({ | |
| 7483 fadeTo: function( speed, to, easing, callback ) { | |
| 7484 | |
| 7485 // show any hidden elements after setting opacity to 0 | |
| 7486 return this.filter( isHidden ).css( "opacity", 0 ).show() | |
| 7487 | |
| 7488 // animate to the value specified | |
| 7489 .end().animate({ opacity: to }, speed, easing, callback ); | |
| 7490 }, | |
| 7491 animate: function( prop, speed, easing, callback ) { | |
| 7492 var empty = jQuery.isEmptyObject( prop ), | |
| 7493 optall = jQuery.speed( speed, easing, callback ), | |
| 7494 doAnimation = function() { | |
| 7495 // Operate on a copy of prop so per-property easing won't be lost | |
| 7496 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); | |
| 7497 | |
| 7498 // Empty animations, or finishing resolves immediately | |
| 7499 if ( empty || jQuery._data( this, "finish" ) ) { | |
| 7500 anim.stop( true ); | |
| 7501 } | |
| 7502 }; | |
| 7503 doAnimation.finish = doAnimation; | |
| 7504 | |
| 7505 return empty || optall.queue === false ? | |
| 7506 this.each( doAnimation ) : | |
| 7507 this.queue( optall.queue, doAnimation ); | |
| 7508 }, | |
| 7509 stop: function( type, clearQueue, gotoEnd ) { | |
| 7510 var stopQueue = function( hooks ) { | |
| 7511 var stop = hooks.stop; | |
| 7512 delete hooks.stop; | |
| 7513 stop( gotoEnd ); | |
| 7514 }; | |
| 7515 | |
| 7516 if ( typeof type !== "string" ) { | |
| 7517 gotoEnd = clearQueue; | |
| 7518 clearQueue = type; | |
| 7519 type = undefined; | |
| 7520 } | |
| 7521 if ( clearQueue && type !== false ) { | |
| 7522 this.queue( type || "fx", [] ); | |
| 7523 } | |
| 7524 | |
| 7525 return this.each(function() { | |
| 7526 var dequeue = true, | |
| 7527 index = type != null && type + "queueHooks", | |
| 7528 timers = jQuery.timers, | |
| 7529 data = jQuery._data( this ); | |
| 7530 | |
| 7531 if ( index ) { | |
| 7532 if ( data[ index ] && data[ index ].stop ) { | |
| 7533 stopQueue( data[ index ] ); | |
| 7534 } | |
| 7535 } else { | |
| 7536 for ( index in data ) { | |
| 7537 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { | |
| 7538 stopQueue( data[ index ] ); | |
| 7539 } | |
| 7540 } | |
| 7541 } | |
| 7542 | |
| 7543 for ( index = timers.length; index--; ) { | |
| 7544 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { | |
| 7545 timers[ index ].anim.stop( gotoEnd ); | |
| 7546 dequeue = false; | |
| 7547 timers.splice( index, 1 ); | |
| 7548 } | |
| 7549 } | |
| 7550 | |
| 7551 // start the next in the queue if the last step wasn't forced | |
| 7552 // timers currently will call their complete callbacks, which will dequeue | |
| 7553 // but only if they were gotoEnd | |
| 7554 if ( dequeue || !gotoEnd ) { | |
| 7555 jQuery.dequeue( this, type ); | |
| 7556 } | |
| 7557 }); | |
| 7558 }, | |
| 7559 finish: function( type ) { | |
| 7560 if ( type !== false ) { | |
| 7561 type = type || "fx"; | |
| 7562 } | |
| 7563 return this.each(function() { | |
| 7564 var index, | |
| 7565 data = jQuery._data( this ), | |
| 7566 queue = data[ type + "queue" ], | |
| 7567 hooks = data[ type + "queueHooks" ], | |
| 7568 timers = jQuery.timers, | |
| 7569 length = queue ? queue.length : 0; | |
| 7570 | |
| 7571 // enable finishing flag on private data | |
| 7572 data.finish = true; | |
| 7573 | |
| 7574 // empty the queue first | |
| 7575 jQuery.queue( this, type, [] ); | |
| 7576 | |
| 7577 if ( hooks && hooks.stop ) { | |
| 7578 hooks.stop.call( this, true ); | |
| 7579 } | |
| 7580 | |
| 7581 // look for any active animations, and finish them | |
| 7582 for ( index = timers.length; index--; ) { | |
| 7583 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { | |
| 7584 timers[ index ].anim.stop( true ); | |
| 7585 timers.splice( index, 1 ); | |
| 7586 } | |
| 7587 } | |
| 7588 | |
| 7589 // look for any animations in the old queue and finish them | |
| 7590 for ( index = 0; index < length; index++ ) { | |
| 7591 if ( queue[ index ] && queue[ index ].finish ) { | |
| 7592 queue[ index ].finish.call( this ); | |
| 7593 } | |
| 7594 } | |
| 7595 | |
| 7596 // turn off finishing flag | |
| 7597 delete data.finish; | |
| 7598 }); | |
| 7599 } | |
| 7600 }); | |
| 7601 | |
| 7602 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { | |
| 7603 var cssFn = jQuery.fn[ name ]; | |
| 7604 jQuery.fn[ name ] = function( speed, easing, callback ) { | |
| 7605 return speed == null || typeof speed === "boolean" ? | |
| 7606 cssFn.apply( this, arguments ) : | |
| 7607 this.animate( genFx( name, true ), speed, easing, callback ); | |
| 7608 }; | |
| 7609 }); | |
| 7610 | |
| 7611 // Generate shortcuts for custom animations | |
| 7612 jQuery.each({ | |
| 7613 slideDown: genFx("show"), | |
| 7614 slideUp: genFx("hide"), | |
| 7615 slideToggle: genFx("toggle"), | |
| 7616 fadeIn: { opacity: "show" }, | |
| 7617 fadeOut: { opacity: "hide" }, | |
| 7618 fadeToggle: { opacity: "toggle" } | |
| 7619 }, function( name, props ) { | |
| 7620 jQuery.fn[ name ] = function( speed, easing, callback ) { | |
| 7621 return this.animate( props, speed, easing, callback ); | |
| 7622 }; | |
| 7623 }); | |
| 7624 | |
| 7625 jQuery.timers = []; | |
| 7626 jQuery.fx.tick = function() { | |
| 7627 var timer, | |
| 7628 timers = jQuery.timers, | |
| 7629 i = 0; | |
| 7630 | |
| 7631 fxNow = jQuery.now(); | |
| 7632 | |
| 7633 for ( ; i < timers.length; i++ ) { | |
| 7634 timer = timers[ i ]; | |
| 7635 // Checks the timer has not already been removed | |
| 7636 if ( !timer() && timers[ i ] === timer ) { | |
| 7637 timers.splice( i--, 1 ); | |
| 7638 } | |
| 7639 } | |
| 7640 | |
| 7641 if ( !timers.length ) { | |
| 7642 jQuery.fx.stop(); | |
| 7643 } | |
| 7644 fxNow = undefined; | |
| 7645 }; | |
| 7646 | |
| 7647 jQuery.fx.timer = function( timer ) { | |
| 7648 jQuery.timers.push( timer ); | |
| 7649 if ( timer() ) { | |
| 7650 jQuery.fx.start(); | |
| 7651 } else { | |
| 7652 jQuery.timers.pop(); | |
| 7653 } | |
| 7654 }; | |
| 7655 | |
| 7656 jQuery.fx.interval = 13; | |
| 7657 | |
| 7658 jQuery.fx.start = function() { | |
| 7659 if ( !timerId ) { | |
| 7660 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); | |
| 7661 } | |
| 7662 }; | |
| 7663 | |
| 7664 jQuery.fx.stop = function() { | |
| 7665 clearInterval( timerId ); | |
| 7666 timerId = null; | |
| 7667 }; | |
| 7668 | |
| 7669 jQuery.fx.speeds = { | |
| 7670 slow: 600, | |
| 7671 fast: 200, | |
| 7672 // Default speed | |
| 7673 _default: 400 | |
| 7674 }; | |
| 7675 | |
| 7676 | |
| 7677 // Based off of the plugin by Clint Helfers, with permission. | |
| 7678 // http://blindsignals.com/index.php/2009/07/jquery-delay/ | |
| 7679 jQuery.fn.delay = function( time, type ) { | |
| 7680 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; | |
| 7681 type = type || "fx"; | |
| 7682 | |
| 7683 return this.queue( type, function( next, hooks ) { | |
| 7684 var timeout = setTimeout( next, time ); | |
| 7685 hooks.stop = function() { | |
| 7686 clearTimeout( timeout ); | |
| 7687 }; | |
| 7688 }); | |
| 7689 }; | |
| 7690 | |
| 7691 | |
| 7692 (function() { | |
| 7693 var a, input, select, opt, | |
| 7694 div = document.createElement("div" ); | |
| 7695 | |
| 7696 // Setup | |
| 7697 div.setAttribute( "className", "t" ); | |
| 7698 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; | |
| 7699 a = div.getElementsByTagName("a")[ 0 ]; | |
| 7700 | |
| 7701 // First batch of tests. | |
| 7702 select = document.createElement("select"); | |
| 7703 opt = select.appendChild( document.createElement("option") ); | |
| 7704 input = div.getElementsByTagName("input")[ 0 ]; | |
| 7705 | |
| 7706 a.style.cssText = "top:1px"; | |
| 7707 | |
| 7708 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) | |
| 7709 support.getSetAttribute = div.className !== "t"; | |
| 7710 | |
| 7711 // Get the style information from getAttribute | |
| 7712 // (IE uses .cssText instead) | |
| 7713 support.style = /top/.test( a.getAttribute("style") ); | |
| 7714 | |
| 7715 // Make sure that URLs aren't manipulated | |
| 7716 // (IE normalizes it by default) | |
| 7717 support.hrefNormalized = a.getAttribute("href") === "/a"; | |
| 7718 | |
| 7719 // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere) | |
| 7720 support.checkOn = !!input.value; | |
| 7721 | |
| 7722 // Make sure that a selected-by-default option has a working selected property. | |
| 7723 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) | |
| 7724 support.optSelected = opt.selected; | |
| 7725 | |
| 7726 // Tests for enctype support on a form (#6743) | |
| 7727 support.enctype = !!document.createElement("form").enctype; | |
| 7728 | |
| 7729 // Make sure that the options inside disabled selects aren't marked as disabled | |
| 7730 // (WebKit marks them as disabled) | |
| 7731 select.disabled = true; | |
| 7732 support.optDisabled = !opt.disabled; | |
| 7733 | |
| 7734 // Support: IE8 only | |
| 7735 // Check if we can trust getAttribute("value") | |
| 7736 input = document.createElement( "input" ); | |
| 7737 input.setAttribute( "value", "" ); | |
| 7738 support.input = input.getAttribute( "value" ) === ""; | |
| 7739 | |
| 7740 // Check if an input maintains its value after becoming a radio | |
| 7741 input.value = "t"; | |
| 7742 input.setAttribute( "type", "radio" ); | |
| 7743 support.radioValue = input.value === "t"; | |
| 7744 | |
| 7745 // Null elements to avoid leaks in IE. | |
| 7746 a = input = select = opt = div = null; | |
| 7747 })(); | |
| 7748 | |
| 7749 | |
| 7750 var rreturn = /\r/g; | |
| 7751 | |
| 7752 jQuery.fn.extend({ | |
| 7753 val: function( value ) { | |
| 7754 var hooks, ret, isFunction, | |
| 7755 elem = this[0]; | |
| 7756 | |
| 7757 if ( !arguments.length ) { | |
| 7758 if ( elem ) { | |
| 7759 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; | |
| 7760 | |
| 7761 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { | |
| 7762 return ret; | |
| 7763 } | |
| 7764 | |
| 7765 ret = elem.value; | |
| 7766 | |
| 7767 return typeof ret === "string" ? | |
| 7768 // handle most common string cases | |
| 7769 ret.replace(rreturn, "") : | |
| 7770 // handle cases where value is null/undef or number | |
| 7771 ret == null ? "" : ret; | |
| 7772 } | |
| 7773 | |
| 7774 return; | |
| 7775 } | |
| 7776 | |
| 7777 isFunction = jQuery.isFunction( value ); | |
| 7778 | |
| 7779 return this.each(function( i ) { | |
| 7780 var val; | |
| 7781 | |
| 7782 if ( this.nodeType !== 1 ) { | |
| 7783 return; | |
| 7784 } | |
| 7785 | |
| 7786 if ( isFunction ) { | |
| 7787 val = value.call( this, i, jQuery( this ).val() ); | |
| 7788 } else { | |
| 7789 val = value; | |
| 7790 } | |
| 7791 | |
| 7792 // Treat null/undefined as ""; convert numbers to string | |
| 7793 if ( val == null ) { | |
| 7794 val = ""; | |
| 7795 } else if ( typeof val === "number" ) { | |
| 7796 val += ""; | |
| 7797 } else if ( jQuery.isArray( val ) ) { | |
| 7798 val = jQuery.map( val, function( value ) { | |
| 7799 return value == null ? "" : value + ""; | |
| 7800 }); | |
| 7801 } | |
| 7802 | |
| 7803 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; | |
| 7804 | |
| 7805 // If set returns undefined, fall back to normal setting | |
| 7806 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { | |
| 7807 this.value = val; | |
| 7808 } | |
| 7809 }); | |
| 7810 } | |
| 7811 }); | |
| 7812 | |
| 7813 jQuery.extend({ | |
| 7814 valHooks: { | |
| 7815 option: { | |
| 7816 get: function( elem ) { | |
| 7817 var val = jQuery.find.attr( elem, "value" ); | |
| 7818 return val != null ? | |
| 7819 val : | |
| 7820 jQuery.text( elem ); | |
| 7821 } | |
| 7822 }, | |
| 7823 select: { | |
| 7824 get: function( elem ) { | |
| 7825 var value, option, | |
| 7826 options = elem.options, | |
| 7827 index = elem.selectedIndex, | |
| 7828 one = elem.type === "select-one" || index < 0, | |
| 7829 values = one ? null : [], | |
| 7830 max = one ? index + 1 : options.length, | |
| 7831 i = index < 0 ? | |
| 7832 max : | |
| 7833 one ? index : 0; | |
| 7834 | |
| 7835 // Loop through all the selected options | |
| 7836 for ( ; i < max; i++ ) { | |
| 7837 option = options[ i ]; | |
| 7838 | |
| 7839 // oldIE doesn't update selected after form reset (#2551) | |
| 7840 if ( ( option.selected || i === index ) && | |
| 7841 // Don't return options that are disabled or in a disabled optgroup | |
| 7842 ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) && | |
| 7843 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { | |
| 7844 | |
| 7845 // Get the specific value for the option | |
| 7846 value = jQuery( option ).val(); | |
| 7847 | |
| 7848 // We don't need an array for one selects | |
| 7849 if ( one ) { | |
| 7850 return value; | |
| 7851 } | |
| 7852 | |
| 7853 // Multi-Selects return an array | |
| 7854 values.push( value ); | |
| 7855 } | |
| 7856 } | |
| 7857 | |
| 7858 return values; | |
| 7859 }, | |
| 7860 | |
| 7861 set: function( elem, value ) { | |
| 7862 var optionSet, option, | |
| 7863 options = elem.options, | |
| 7864 values = jQuery.makeArray( value ), | |
| 7865 i = options.length; | |
| 7866 | |
| 7867 while ( i-- ) { | |
| 7868 option = options[ i ]; | |
| 7869 | |
| 7870 if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) { | |
| 7871 | |
| 7872 // Support: IE6 | |
| 7873 // When new option element is added to select box we need to | |
| 7874 // force reflow of newly added node in order to workaround delay | |
| 7875 // of initialization properties | |
| 7876 try { | |
| 7877 option.selected = optionSet = true; | |
| 7878 | |
| 7879 } catch ( _ ) { | |
| 7880 | |
| 7881 // Will be executed only in IE6 | |
| 7882 option.scrollHeight; | |
| 7883 } | |
| 7884 | |
| 7885 } else { | |
| 7886 option.selected = false; | |
| 7887 } | |
| 7888 } | |
| 7889 | |
| 7890 // Force browsers to behave consistently when non-matching value is set | |
| 7891 if ( !optionSet ) { | |
| 7892 elem.selectedIndex = -1; | |
| 7893 } | |
| 7894 | |
| 7895 return options; | |
| 7896 } | |
| 7897 } | |
| 7898 } | |
| 7899 }); | |
| 7900 | |
| 7901 // Radios and checkboxes getter/setter | |
| 7902 jQuery.each([ "radio", "checkbox" ], function() { | |
| 7903 jQuery.valHooks[ this ] = { | |
| 7904 set: function( elem, value ) { | |
| 7905 if ( jQuery.isArray( value ) ) { | |
| 7906 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); | |
| 7907 } | |
| 7908 } | |
| 7909 }; | |
| 7910 if ( !support.checkOn ) { | |
| 7911 jQuery.valHooks[ this ].get = function( elem ) { | |
| 7912 // Support: Webkit | |
| 7913 // "" is returned instead of "on" if a value isn't specified | |
| 7914 return elem.getAttribute("value") === null ? "on" : elem.value; | |
| 7915 }; | |
| 7916 } | |
| 7917 }); | |
| 7918 | |
| 7919 | |
| 7920 | |
| 7921 | |
| 7922 var nodeHook, boolHook, | |
| 7923 attrHandle = jQuery.expr.attrHandle, | |
| 7924 ruseDefault = /^(?:checked|selected)$/i, | |
| 7925 getSetAttribute = support.getSetAttribute, | |
| 7926 getSetInput = support.input; | |
| 7927 | |
| 7928 jQuery.fn.extend({ | |
| 7929 attr: function( name, value ) { | |
| 7930 return access( this, jQuery.attr, name, value, arguments.length > 1 ); | |
| 7931 }, | |
| 7932 | |
| 7933 removeAttr: function( name ) { | |
| 7934 return this.each(function() { | |
| 7935 jQuery.removeAttr( this, name ); | |
| 7936 }); | |
| 7937 } | |
| 7938 }); | |
| 7939 | |
| 7940 jQuery.extend({ | |
| 7941 attr: function( elem, name, value ) { | |
| 7942 var hooks, ret, | |
| 7943 nType = elem.nodeType; | |
| 7944 | |
| 7945 // don't get/set attributes on text, comment and attribute nodes | |
| 7946 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | |
| 7947 return; | |
| 7948 } | |
| 7949 | |
| 7950 // Fallback to prop when attributes are not supported | |
| 7951 if ( typeof elem.getAttribute === strundefined ) { | |
| 7952 return jQuery.prop( elem, name, value ); | |
| 7953 } | |
| 7954 | |
| 7955 // All attributes are lowercase | |
| 7956 // Grab necessary hook if one is defined | |
| 7957 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { | |
| 7958 name = name.toLowerCase(); | |
| 7959 hooks = jQuery.attrHooks[ name ] || | |
| 7960 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook ); | |
| 7961 } | |
| 7962 | |
| 7963 if ( value !== undefined ) { | |
| 7964 | |
| 7965 if ( value === null ) { | |
| 7966 jQuery.removeAttr( elem, name ); | |
| 7967 | |
| 7968 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { | |
| 7969 return ret; | |
| 7970 | |
| 7971 } else { | |
| 7972 elem.setAttribute( name, value + "" ); | |
| 7973 return value; | |
| 7974 } | |
| 7975 | |
| 7976 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { | |
| 7977 return ret; | |
| 7978 | |
| 7979 } else { | |
| 7980 ret = jQuery.find.attr( elem, name ); | |
| 7981 | |
| 7982 // Non-existent attributes return null, we normalize to undefined | |
| 7983 return ret == null ? | |
| 7984 undefined : | |
| 7985 ret; | |
| 7986 } | |
| 7987 }, | |
| 7988 | |
| 7989 removeAttr: function( elem, value ) { | |
| 7990 var name, propName, | |
| 7991 i = 0, | |
| 7992 attrNames = value && value.match( rnotwhite ); | |
| 7993 | |
| 7994 if ( attrNames && elem.nodeType === 1 ) { | |
| 7995 while ( (name = attrNames[i++]) ) { | |
| 7996 propName = jQuery.propFix[ name ] || name; | |
| 7997 | |
| 7998 // Boolean attributes get special treatment (#10870) | |
| 7999 if ( jQuery.expr.match.bool.test( name ) ) { | |
| 8000 // Set corresponding property to false | |
| 8001 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { | |
| 8002 elem[ propName ] = false; | |
| 8003 // Support: IE<9 | |
| 8004 // Also clear defaultChecked/defaultSelected (if appropriate) | |
| 8005 } else { | |
| 8006 elem[ jQuery.camelCase( "default-" + name ) ] = | |
| 8007 elem[ propName ] = false; | |
| 8008 } | |
| 8009 | |
| 8010 // See #9699 for explanation of this approach (setting first, then removal) | |
| 8011 } else { | |
| 8012 jQuery.attr( elem, name, "" ); | |
| 8013 } | |
| 8014 | |
| 8015 elem.removeAttribute( getSetAttribute ? name : propName ); | |
| 8016 } | |
| 8017 } | |
| 8018 }, | |
| 8019 | |
| 8020 attrHooks: { | |
| 8021 type: { | |
| 8022 set: function( elem, value ) { | |
| 8023 if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { | |
| 8024 // Setting the type on a radio button after the value resets the value in IE6-9 | |
| 8025 // Reset value to default in case type is set after value during creation | |
| 8026 var val = elem.value; | |
| 8027 elem.setAttribute( "type", value ); | |
| 8028 if ( val ) { | |
| 8029 elem.value = val; | |
| 8030 } | |
| 8031 return value; | |
| 8032 } | |
| 8033 } | |
| 8034 } | |
| 8035 } | |
| 8036 }); | |
| 8037 | |
| 8038 // Hook for boolean attributes | |
| 8039 boolHook = { | |
| 8040 set: function( elem, value, name ) { | |
| 8041 if ( value === false ) { | |
| 8042 // Remove boolean attributes when set to false | |
| 8043 jQuery.removeAttr( elem, name ); | |
| 8044 } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { | |
| 8045 // IE<8 needs the *property* name | |
| 8046 elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name ); | |
| 8047 | |
| 8048 // Use defaultChecked and defaultSelected for oldIE | |
| 8049 } else { | |
| 8050 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true; | |
| 8051 } | |
| 8052 | |
| 8053 return name; | |
| 8054 } | |
| 8055 }; | |
| 8056 | |
| 8057 // Retrieve booleans specially | |
| 8058 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { | |
| 8059 | |
| 8060 var getter = attrHandle[ name ] || jQuery.find.attr; | |
| 8061 | |
| 8062 attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ? | |
| 8063 function( elem, name, isXML ) { | |
| 8064 var ret, handle; | |
| 8065 if ( !isXML ) { | |
| 8066 // Avoid an infinite loop by temporarily removing this function from the getter | |
| 8067 handle = attrHandle[ name ]; | |
| 8068 attrHandle[ name ] = ret; | |
| 8069 ret = getter( elem, name, isXML ) != null ? | |
| 8070 name.toLowerCase() : | |
| 8071 null; | |
| 8072 attrHandle[ name ] = handle; | |
| 8073 } | |
| 8074 return ret; | |
| 8075 } : | |
| 8076 function( elem, name, isXML ) { | |
| 8077 if ( !isXML ) { | |
| 8078 return elem[ jQuery.camelCase( "default-" + name ) ] ? | |
| 8079 name.toLowerCase() : | |
| 8080 null; | |
| 8081 } | |
| 8082 }; | |
| 8083 }); | |
| 8084 | |
| 8085 // fix oldIE attroperties | |
| 8086 if ( !getSetInput || !getSetAttribute ) { | |
| 8087 jQuery.attrHooks.value = { | |
| 8088 set: function( elem, value, name ) { | |
| 8089 if ( jQuery.nodeName( elem, "input" ) ) { | |
| 8090 // Does not return so that setAttribute is also used | |
| 8091 elem.defaultValue = value; | |
| 8092 } else { | |
| 8093 // Use nodeHook if defined (#1954); otherwise setAttribute is fine | |
| 8094 return nodeHook && nodeHook.set( elem, value, name ); | |
| 8095 } | |
| 8096 } | |
| 8097 }; | |
| 8098 } | |
| 8099 | |
| 8100 // IE6/7 do not support getting/setting some attributes with get/setAttribute | |
| 8101 if ( !getSetAttribute ) { | |
| 8102 | |
| 8103 // Use this for any attribute in IE6/7 | |
| 8104 // This fixes almost every IE6/7 issue | |
| 8105 nodeHook = { | |
| 8106 set: function( elem, value, name ) { | |
| 8107 // Set the existing or create a new attribute node | |
| 8108 var ret = elem.getAttributeNode( name ); | |
| 8109 if ( !ret ) { | |
| 8110 elem.setAttributeNode( | |
| 8111 (ret = elem.ownerDocument.createAttribute( name )) | |
| 8112 ); | |
| 8113 } | |
| 8114 | |
| 8115 ret.value = value += ""; | |
| 8116 | |
| 8117 // Break association with cloned elements by also using setAttribute (#9646) | |
| 8118 if ( name === "value" || value === elem.getAttribute( name ) ) { | |
| 8119 return value; | |
| 8120 } | |
| 8121 } | |
| 8122 }; | |
| 8123 | |
| 8124 // Some attributes are constructed with empty-string values when not defined | |
| 8125 attrHandle.id = attrHandle.name = attrHandle.coords = | |
| 8126 function( elem, name, isXML ) { | |
| 8127 var ret; | |
| 8128 if ( !isXML ) { | |
| 8129 return (ret = elem.getAttributeNode( name )) && ret.value !== "" ? | |
| 8130 ret.value : | |
| 8131 null; | |
| 8132 } | |
| 8133 }; | |
| 8134 | |
| 8135 // Fixing value retrieval on a button requires this module | |
| 8136 jQuery.valHooks.button = { | |
| 8137 get: function( elem, name ) { | |
| 8138 var ret = elem.getAttributeNode( name ); | |
| 8139 if ( ret && ret.specified ) { | |
| 8140 return ret.value; | |
| 8141 } | |
| 8142 }, | |
| 8143 set: nodeHook.set | |
| 8144 }; | |
| 8145 | |
| 8146 // Set contenteditable to false on removals(#10429) | |
| 8147 // Setting to empty string throws an error as an invalid value | |
| 8148 jQuery.attrHooks.contenteditable = { | |
| 8149 set: function( elem, value, name ) { | |
| 8150 nodeHook.set( elem, value === "" ? false : value, name ); | |
| 8151 } | |
| 8152 }; | |
| 8153 | |
| 8154 // Set width and height to auto instead of 0 on empty string( Bug #8150 ) | |
| 8155 // This is for removals | |
| 8156 jQuery.each([ "width", "height" ], function( i, name ) { | |
| 8157 jQuery.attrHooks[ name ] = { | |
| 8158 set: function( elem, value ) { | |
| 8159 if ( value === "" ) { | |
| 8160 elem.setAttribute( name, "auto" ); | |
| 8161 return value; | |
| 8162 } | |
| 8163 } | |
| 8164 }; | |
| 8165 }); | |
| 8166 } | |
| 8167 | |
| 8168 if ( !support.style ) { | |
| 8169 jQuery.attrHooks.style = { | |
| 8170 get: function( elem ) { | |
| 8171 // Return undefined in the case of empty string | |
| 8172 // Note: IE uppercases css property names, but if we were to .toLowerCase() | |
| 8173 // .cssText, that would destroy case senstitivity in URL's, like in "background" | |
| 8174 return elem.style.cssText || undefined; | |
| 8175 }, | |
| 8176 set: function( elem, value ) { | |
| 8177 return ( elem.style.cssText = value + "" ); | |
| 8178 } | |
| 8179 }; | |
| 8180 } | |
| 8181 | |
| 8182 | |
| 8183 | |
| 8184 | |
| 8185 var rfocusable = /^(?:input|select|textarea|button|object)$/i, | |
| 8186 rclickable = /^(?:a|area)$/i; | |
| 8187 | |
| 8188 jQuery.fn.extend({ | |
| 8189 prop: function( name, value ) { | |
| 8190 return access( this, jQuery.prop, name, value, arguments.length > 1 ); | |
| 8191 }, | |
| 8192 | |
| 8193 removeProp: function( name ) { | |
| 8194 name = jQuery.propFix[ name ] || name; | |
| 8195 return this.each(function() { | |
| 8196 // try/catch handles cases where IE balks (such as removing a property on window) | |
| 8197 try { | |
| 8198 this[ name ] = undefined; | |
| 8199 delete this[ name ]; | |
| 8200 } catch( e ) {} | |
| 8201 }); | |
| 8202 } | |
| 8203 }); | |
| 8204 | |
| 8205 jQuery.extend({ | |
| 8206 propFix: { | |
| 8207 "for": "htmlFor", | |
| 8208 "class": "className" | |
| 8209 }, | |
| 8210 | |
| 8211 prop: function( elem, name, value ) { | |
| 8212 var ret, hooks, notxml, | |
| 8213 nType = elem.nodeType; | |
| 8214 | |
| 8215 // don't get/set properties on text, comment and attribute nodes | |
| 8216 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | |
| 8217 return; | |
| 8218 } | |
| 8219 | |
| 8220 notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); | |
| 8221 | |
| 8222 if ( notxml ) { | |
| 8223 // Fix name and attach hooks | |
| 8224 name = jQuery.propFix[ name ] || name; | |
| 8225 hooks = jQuery.propHooks[ name ]; | |
| 8226 } | |
| 8227 | |
| 8228 if ( value !== undefined ) { | |
| 8229 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? | |
| 8230 ret : | |
| 8231 ( elem[ name ] = value ); | |
| 8232 | |
| 8233 } else { | |
| 8234 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? | |
| 8235 ret : | |
| 8236 elem[ name ]; | |
| 8237 } | |
| 8238 }, | |
| 8239 | |
| 8240 propHooks: { | |
| 8241 tabIndex: { | |
| 8242 get: function( elem ) { | |
| 8243 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set | |
| 8244 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ | |
| 8245 // Use proper attribute retrieval(#12072) | |
| 8246 var tabindex = jQuery.find.attr( elem, "tabindex" ); | |
| 8247 | |
| 8248 return tabindex ? | |
| 8249 parseInt( tabindex, 10 ) : | |
| 8250 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? | |
| 8251 0 : | |
| 8252 -1; | |
| 8253 } | |
| 8254 } | |
| 8255 } | |
| 8256 }); | |
| 8257 | |
| 8258 // Some attributes require a special call on IE | |
| 8259 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx | |
| 8260 if ( !support.hrefNormalized ) { | |
| 8261 // href/src property should get the full normalized URL (#10299/#12915) | |
| 8262 jQuery.each([ "href", "src" ], function( i, name ) { | |
| 8263 jQuery.propHooks[ name ] = { | |
| 8264 get: function( elem ) { | |
| 8265 return elem.getAttribute( name, 4 ); | |
| 8266 } | |
| 8267 }; | |
| 8268 }); | |
| 8269 } | |
| 8270 | |
| 8271 // Support: Safari, IE9+ | |
| 8272 // mis-reports the default selected property of an option | |
| 8273 // Accessing the parent's selectedIndex property fixes it | |
| 8274 if ( !support.optSelected ) { | |
| 8275 jQuery.propHooks.selected = { | |
| 8276 get: function( elem ) { | |
| 8277 var parent = elem.parentNode; | |
| 8278 | |
| 8279 if ( parent ) { | |
| 8280 parent.selectedIndex; | |
| 8281 | |
| 8282 // Make sure that it also works with optgroups, see #5701 | |
| 8283 if ( parent.parentNode ) { | |
| 8284 parent.parentNode.selectedIndex; | |
| 8285 } | |
| 8286 } | |
| 8287 return null; | |
| 8288 } | |
| 8289 }; | |
| 8290 } | |
| 8291 | |
| 8292 jQuery.each([ | |
| 8293 "tabIndex", | |
| 8294 "readOnly", | |
| 8295 "maxLength", | |
| 8296 "cellSpacing", | |
| 8297 "cellPadding", | |
| 8298 "rowSpan", | |
| 8299 "colSpan", | |
| 8300 "useMap", | |
| 8301 "frameBorder", | |
| 8302 "contentEditable" | |
| 8303 ], function() { | |
| 8304 jQuery.propFix[ this.toLowerCase() ] = this; | |
| 8305 }); | |
| 8306 | |
| 8307 // IE6/7 call enctype encoding | |
| 8308 if ( !support.enctype ) { | |
| 8309 jQuery.propFix.enctype = "encoding"; | |
| 8310 } | |
| 8311 | |
| 8312 | |
| 8313 | |
| 8314 | |
| 8315 var rclass = /[\t\r\n\f]/g; | |
| 8316 | |
| 8317 jQuery.fn.extend({ | |
| 8318 addClass: function( value ) { | |
| 8319 var classes, elem, cur, clazz, j, finalValue, | |
| 8320 i = 0, | |
| 8321 len = this.length, | |
| 8322 proceed = typeof value === "string" && value; | |
| 8323 | |
| 8324 if ( jQuery.isFunction( value ) ) { | |
| 8325 return this.each(function( j ) { | |
| 8326 jQuery( this ).addClass( value.call( this, j, this.className ) ); | |
| 8327 }); | |
| 8328 } | |
| 8329 | |
| 8330 if ( proceed ) { | |
| 8331 // The disjunction here is for better compressibility (see removeClass) | |
| 8332 classes = ( value || "" ).match( rnotwhite ) || []; | |
| 8333 | |
| 8334 for ( ; i < len; i++ ) { | |
| 8335 elem = this[ i ]; | |
| 8336 cur = elem.nodeType === 1 && ( elem.className ? | |
| 8337 ( " " + elem.className + " " ).replace( rclass, " " ) : | |
| 8338 " " | |
| 8339 ); | |
| 8340 | |
| 8341 if ( cur ) { | |
| 8342 j = 0; | |
| 8343 while ( (clazz = classes[j++]) ) { | |
| 8344 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { | |
| 8345 cur += clazz + " "; | |
| 8346 } | |
| 8347 } | |
| 8348 | |
| 8349 // only assign if different to avoid unneeded rendering. | |
| 8350 finalValue = jQuery.trim( cur ); | |
| 8351 if ( elem.className !== finalValue ) { | |
| 8352 elem.className = finalValue; | |
| 8353 } | |
| 8354 } | |
| 8355 } | |
| 8356 } | |
| 8357 | |
| 8358 return this; | |
| 8359 }, | |
| 8360 | |
| 8361 removeClass: function( value ) { | |
| 8362 var classes, elem, cur, clazz, j, finalValue, | |
| 8363 i = 0, | |
| 8364 len = this.length, | |
| 8365 proceed = arguments.length === 0 || typeof value === "string" && value; | |
| 8366 | |
| 8367 if ( jQuery.isFunction( value ) ) { | |
| 8368 return this.each(function( j ) { | |
| 8369 jQuery( this ).removeClass( value.call( this, j, this.className ) ); | |
| 8370 }); | |
| 8371 } | |
| 8372 if ( proceed ) { | |
| 8373 classes = ( value || "" ).match( rnotwhite ) || []; | |
| 8374 | |
| 8375 for ( ; i < len; i++ ) { | |
| 8376 elem = this[ i ]; | |
| 8377 // This expression is here for better compressibility (see addClass) | |
| 8378 cur = elem.nodeType === 1 && ( elem.className ? | |
| 8379 ( " " + elem.className + " " ).replace( rclass, " " ) : | |
| 8380 "" | |
| 8381 ); | |
| 8382 | |
| 8383 if ( cur ) { | |
| 8384 j = 0; | |
| 8385 while ( (clazz = classes[j++]) ) { | |
| 8386 // Remove *all* instances | |
| 8387 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { | |
| 8388 cur = cur.replace( " " + clazz + " ", " " ); | |
| 8389 } | |
| 8390 } | |
| 8391 | |
| 8392 // only assign if different to avoid unneeded rendering. | |
| 8393 finalValue = value ? jQuery.trim( cur ) : ""; | |
| 8394 if ( elem.className !== finalValue ) { | |
| 8395 elem.className = finalValue; | |
| 8396 } | |
| 8397 } | |
| 8398 } | |
| 8399 } | |
| 8400 | |
| 8401 return this; | |
| 8402 }, | |
| 8403 | |
| 8404 toggleClass: function( value, stateVal ) { | |
| 8405 var type = typeof value; | |
| 8406 | |
| 8407 if ( typeof stateVal === "boolean" && type === "string" ) { | |
| 8408 return stateVal ? this.addClass( value ) : this.removeClass( value ); | |
| 8409 } | |
| 8410 | |
| 8411 if ( jQuery.isFunction( value ) ) { | |
| 8412 return this.each(function( i ) { | |
| 8413 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); | |
| 8414 }); | |
| 8415 } | |
| 8416 | |
| 8417 return this.each(function() { | |
| 8418 if ( type === "string" ) { | |
| 8419 // toggle individual class names | |
| 8420 var className, | |
| 8421 i = 0, | |
| 8422 self = jQuery( this ), | |
| 8423 classNames = value.match( rnotwhite ) || []; | |
| 8424 | |
| 8425 while ( (className = classNames[ i++ ]) ) { | |
| 8426 // check each className given, space separated list | |
| 8427 if ( self.hasClass( className ) ) { | |
| 8428 self.removeClass( className ); | |
| 8429 } else { | |
| 8430 self.addClass( className ); | |
| 8431 } | |
| 8432 } | |
| 8433 | |
| 8434 // Toggle whole class name | |
| 8435 } else if ( type === strundefined || type === "boolean" ) { | |
| 8436 if ( this.className ) { | |
| 8437 // store className if set | |
| 8438 jQuery._data( this, "__className__", this.className ); | |
| 8439 } | |
| 8440 | |
| 8441 // If the element has a class name or if we're passed "false", | |
| 8442 // then remove the whole classname (if there was one, the above saved it). | |
| 8443 // Otherwise bring back whatever was previously saved (if anything), | |
| 8444 // falling back to the empty string if nothing was stored. | |
| 8445 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; | |
| 8446 } | |
| 8447 }); | |
| 8448 }, | |
| 8449 | |
| 8450 hasClass: function( selector ) { | |
| 8451 var className = " " + selector + " ", | |
| 8452 i = 0, | |
| 8453 l = this.length; | |
| 8454 for ( ; i < l; i++ ) { | |
| 8455 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { | |
| 8456 return true; | |
| 8457 } | |
| 8458 } | |
| 8459 | |
| 8460 return false; | |
| 8461 } | |
| 8462 }); | |
| 8463 | |
| 8464 | |
| 8465 | |
| 8466 | |
| 8467 // Return jQuery for attributes-only inclusion | |
| 8468 | |
| 8469 | |
| 8470 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + | |
| 8471 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + | |
| 8472 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { | |
| 8473 | |
| 8474 // Handle event binding | |
| 8475 jQuery.fn[ name ] = function( data, fn ) { | |
| 8476 return arguments.length > 0 ? | |
| 8477 this.on( name, null, data, fn ) : | |
| 8478 this.trigger( name ); | |
| 8479 }; | |
| 8480 }); | |
| 8481 | |
| 8482 jQuery.fn.extend({ | |
| 8483 hover: function( fnOver, fnOut ) { | |
| 8484 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); | |
| 8485 }, | |
| 8486 | |
| 8487 bind: function( types, data, fn ) { | |
| 8488 return this.on( types, null, data, fn ); | |
| 8489 }, | |
| 8490 unbind: function( types, fn ) { | |
| 8491 return this.off( types, null, fn ); | |
| 8492 }, | |
| 8493 | |
| 8494 delegate: function( selector, types, data, fn ) { | |
| 8495 return this.on( types, selector, data, fn ); | |
| 8496 }, | |
| 8497 undelegate: function( selector, types, fn ) { | |
| 8498 // ( namespace ) or ( selector, types [, fn] ) | |
| 8499 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); | |
| 8500 } | |
| 8501 }); | |
| 8502 | |
| 8503 | |
| 8504 var nonce = jQuery.now(); | |
| 8505 | |
| 8506 var rquery = (/\?/); | |
| 8507 | |
| 8508 | |
| 8509 | |
| 8510 var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g; | |
| 8511 | |
| 8512 jQuery.parseJSON = function( data ) { | |
| 8513 // Attempt to parse using the native JSON parser first | |
| 8514 if ( window.JSON && window.JSON.parse ) { | |
| 8515 // Support: Android 2.3 | |
| 8516 // Workaround failure to string-cast null input | |
| 8517 return window.JSON.parse( data + "" ); | |
| 8518 } | |
| 8519 | |
| 8520 var requireNonComma, | |
| 8521 depth = null, | |
| 8522 str = jQuery.trim( data + "" ); | |
| 8523 | |
| 8524 // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains | |
| 8525 // after removing valid tokens | |
| 8526 return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) { | |
| 8527 | |
| 8528 // Force termination if we see a misplaced comma | |
| 8529 if ( requireNonComma && comma ) { | |
| 8530 depth = 0; | |
| 8531 } | |
| 8532 | |
| 8533 // Perform no more replacements after returning to outermost depth | |
| 8534 if ( depth === 0 ) { | |
| 8535 return token; | |
| 8536 } | |
| 8537 | |
| 8538 // Commas must not follow "[", "{", or "," | |
| 8539 requireNonComma = open || comma; | |
| 8540 | |
| 8541 // Determine new depth | |
| 8542 // array/object open ("[" or "{"): depth += true - false (increment) | |
| 8543 // array/object close ("]" or "}"): depth += false - true (decrement) | |
| 8544 // other cases ("," or primitive): depth += true - true (numeric cast) | |
| 8545 depth += !close - !open; | |
| 8546 | |
| 8547 // Remove this token | |
| 8548 return ""; | |
| 8549 }) ) ? | |
| 8550 ( Function( "return " + str ) )() : | |
| 8551 jQuery.error( "Invalid JSON: " + data ); | |
| 8552 }; | |
| 8553 | |
| 8554 | |
| 8555 // Cross-browser xml parsing | |
| 8556 jQuery.parseXML = function( data ) { | |
| 8557 var xml, tmp; | |
| 8558 if ( !data || typeof data !== "string" ) { | |
| 8559 return null; | |
| 8560 } | |
| 8561 try { | |
| 8562 if ( window.DOMParser ) { // Standard | |
| 8563 tmp = new DOMParser(); | |
| 8564 xml = tmp.parseFromString( data, "text/xml" ); | |
| 8565 } else { // IE | |
| 8566 xml = new ActiveXObject( "Microsoft.XMLDOM" ); | |
| 8567 xml.async = "false"; | |
| 8568 xml.loadXML( data ); | |
| 8569 } | |
| 8570 } catch( e ) { | |
| 8571 xml = undefined; | |
| 8572 } | |
| 8573 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { | |
| 8574 jQuery.error( "Invalid XML: " + data ); | |
| 8575 } | |
| 8576 return xml; | |
| 8577 }; | |
| 8578 | |
| 8579 | |
| 8580 var | |
| 8581 // Document location | |
| 8582 ajaxLocParts, | |
| 8583 ajaxLocation, | |
| 8584 | |
| 8585 rhash = /#.*$/, | |
| 8586 rts = /([?&])_=[^&]*/, | |
| 8587 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL | |
| 8588 // #7653, #8125, #8152: local protocol detection | |
| 8589 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, | |
| 8590 rnoContent = /^(?:GET|HEAD)$/, | |
| 8591 rprotocol = /^\/\//, | |
| 8592 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/, | |
| 8593 | |
| 8594 /* Prefilters | |
| 8595 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) | |
| 8596 * 2) These are called: | |
| 8597 * - BEFORE asking for a transport | |
| 8598 * - AFTER param serialization (s.data is a string if s.processData is true) | |
| 8599 * 3) key is the dataType | |
| 8600 * 4) the catchall symbol "*" can be used | |
| 8601 * 5) execution will start with transport dataType and THEN continue down to "*" if needed | |
| 8602 */ | |
| 8603 prefilters = {}, | |
| 8604 | |
| 8605 /* Transports bindings | |
| 8606 * 1) key is the dataType | |
| 8607 * 2) the catchall symbol "*" can be used | |
| 8608 * 3) selection will start with transport dataType and THEN go to "*" if needed | |
| 8609 */ | |
| 8610 transports = {}, | |
| 8611 | |
| 8612 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression | |
| 8613 allTypes = "*/".concat("*"); | |
| 8614 | |
| 8615 // #8138, IE may throw an exception when accessing | |
| 8616 // a field from window.location if document.domain has been set | |
| 8617 try { | |
| 8618 ajaxLocation = location.href; | |
| 8619 } catch( e ) { | |
| 8620 // Use the href attribute of an A element | |
| 8621 // since IE will modify it given document.location | |
| 8622 ajaxLocation = document.createElement( "a" ); | |
| 8623 ajaxLocation.href = ""; | |
| 8624 ajaxLocation = ajaxLocation.href; | |
| 8625 } | |
| 8626 | |
| 8627 // Segment location into parts | |
| 8628 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; | |
| 8629 | |
| 8630 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport | |
| 8631 function addToPrefiltersOrTransports( structure ) { | |
| 8632 | |
| 8633 // dataTypeExpression is optional and defaults to "*" | |
| 8634 return function( dataTypeExpression, func ) { | |
| 8635 | |
| 8636 if ( typeof dataTypeExpression !== "string" ) { | |
| 8637 func = dataTypeExpression; | |
| 8638 dataTypeExpression = "*"; | |
| 8639 } | |
| 8640 | |
| 8641 var dataType, | |
| 8642 i = 0, | |
| 8643 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || []; | |
| 8644 | |
| 8645 if ( jQuery.isFunction( func ) ) { | |
| 8646 // For each dataType in the dataTypeExpression | |
| 8647 while ( (dataType = dataTypes[i++]) ) { | |
| 8648 // Prepend if requested | |
| 8649 if ( dataType.charAt( 0 ) === "+" ) { | |
| 8650 dataType = dataType.slice( 1 ) || "*"; | |
| 8651 (structure[ dataType ] = structure[ dataType ] || []).unshift( func ); | |
| 8652 | |
| 8653 // Otherwise append | |
| 8654 } else { | |
| 8655 (structure[ dataType ] = structure[ dataType ] || []).push( func ); | |
| 8656 } | |
| 8657 } | |
| 8658 } | |
| 8659 }; | |
| 8660 } | |
| 8661 | |
| 8662 // Base inspection function for prefilters and transports | |
| 8663 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { | |
| 8664 | |
| 8665 var inspected = {}, | |
| 8666 seekingTransport = ( structure === transports ); | |
| 8667 | |
| 8668 function inspect( dataType ) { | |
| 8669 var selected; | |
| 8670 inspected[ dataType ] = true; | |
| 8671 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { | |
| 8672 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); | |
| 8673 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) { | |
| 8674 options.dataTypes.unshift( dataTypeOrTransport ); | |
| 8675 inspect( dataTypeOrTransport ); | |
| 8676 return false; | |
| 8677 } else if ( seekingTransport ) { | |
| 8678 return !( selected = dataTypeOrTransport ); | |
| 8679 } | |
| 8680 }); | |
| 8681 return selected; | |
| 8682 } | |
| 8683 | |
| 8684 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); | |
| 8685 } | |
| 8686 | |
| 8687 // A special extend for ajax options | |
| 8688 // that takes "flat" options (not to be deep extended) | |
| 8689 // Fixes #9887 | |
| 8690 function ajaxExtend( target, src ) { | |
| 8691 var deep, key, | |
| 8692 flatOptions = jQuery.ajaxSettings.flatOptions || {}; | |
| 8693 | |
| 8694 for ( key in src ) { | |
| 8695 if ( src[ key ] !== undefined ) { | |
| 8696 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ]; | |
| 8697 } | |
| 8698 } | |
| 8699 if ( deep ) { | |
| 8700 jQuery.extend( true, target, deep ); | |
| 8701 } | |
| 8702 | |
| 8703 return target; | |
| 8704 } | |
| 8705 | |
| 8706 /* Handles responses to an ajax request: | |
| 8707 * - finds the right dataType (mediates between content-type and expected dataType) | |
| 8708 * - returns the corresponding response | |
| 8709 */ | |
| 8710 function ajaxHandleResponses( s, jqXHR, responses ) { | |
| 8711 var firstDataType, ct, finalDataType, type, | |
| 8712 contents = s.contents, | |
| 8713 dataTypes = s.dataTypes; | |
| 8714 | |
| 8715 // Remove auto dataType and get content-type in the process | |
| 8716 while ( dataTypes[ 0 ] === "*" ) { | |
| 8717 dataTypes.shift(); | |
| 8718 if ( ct === undefined ) { | |
| 8719 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type"); | |
| 8720 } | |
| 8721 } | |
| 8722 | |
| 8723 // Check if we're dealing with a known content-type | |
| 8724 if ( ct ) { | |
| 8725 for ( type in contents ) { | |
| 8726 if ( contents[ type ] && contents[ type ].test( ct ) ) { | |
| 8727 dataTypes.unshift( type ); | |
| 8728 break; | |
| 8729 } | |
| 8730 } | |
| 8731 } | |
| 8732 | |
| 8733 // Check to see if we have a response for the expected dataType | |
| 8734 if ( dataTypes[ 0 ] in responses ) { | |
| 8735 finalDataType = dataTypes[ 0 ]; | |
| 8736 } else { | |
| 8737 // Try convertible dataTypes | |
| 8738 for ( type in responses ) { | |
| 8739 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { | |
| 8740 finalDataType = type; | |
| 8741 break; | |
| 8742 } | |
| 8743 if ( !firstDataType ) { | |
| 8744 firstDataType = type; | |
| 8745 } | |
| 8746 } | |
| 8747 // Or just use first one | |
| 8748 finalDataType = finalDataType || firstDataType; | |
| 8749 } | |
| 8750 | |
| 8751 // If we found a dataType | |
| 8752 // We add the dataType to the list if needed | |
| 8753 // and return the corresponding response | |
| 8754 if ( finalDataType ) { | |
| 8755 if ( finalDataType !== dataTypes[ 0 ] ) { | |
| 8756 dataTypes.unshift( finalDataType ); | |
| 8757 } | |
| 8758 return responses[ finalDataType ]; | |
| 8759 } | |
| 8760 } | |
| 8761 | |
| 8762 /* Chain conversions given the request and the original response | |
| 8763 * Also sets the responseXXX fields on the jqXHR instance | |
| 8764 */ | |
| 8765 function ajaxConvert( s, response, jqXHR, isSuccess ) { | |
| 8766 var conv2, current, conv, tmp, prev, | |
| 8767 converters = {}, | |
| 8768 // Work with a copy of dataTypes in case we need to modify it for conversion | |
| 8769 dataTypes = s.dataTypes.slice(); | |
| 8770 | |
| 8771 // Create converters map with lowercased keys | |
| 8772 if ( dataTypes[ 1 ] ) { | |
| 8773 for ( conv in s.converters ) { | |
| 8774 converters[ conv.toLowerCase() ] = s.converters[ conv ]; | |
| 8775 } | |
| 8776 } | |
| 8777 | |
| 8778 current = dataTypes.shift(); | |
| 8779 | |
| 8780 // Convert to each sequential dataType | |
| 8781 while ( current ) { | |
| 8782 | |
| 8783 if ( s.responseFields[ current ] ) { | |
| 8784 jqXHR[ s.responseFields[ current ] ] = response; | |
| 8785 } | |
| 8786 | |
| 8787 // Apply the dataFilter if provided | |
| 8788 if ( !prev && isSuccess && s.dataFilter ) { | |
| 8789 response = s.dataFilter( response, s.dataType ); | |
| 8790 } | |
| 8791 | |
| 8792 prev = current; | |
| 8793 current = dataTypes.shift(); | |
| 8794 | |
| 8795 if ( current ) { | |
| 8796 | |
| 8797 // There's only work to do if current dataType is non-auto | |
| 8798 if ( current === "*" ) { | |
| 8799 | |
| 8800 current = prev; | |
| 8801 | |
| 8802 // Convert response if prev dataType is non-auto and differs from current | |
| 8803 } else if ( prev !== "*" && prev !== current ) { | |
| 8804 | |
| 8805 // Seek a direct converter | |
| 8806 conv = converters[ prev + " " + current ] || converters[ "* " + current ]; | |
| 8807 | |
| 8808 // If none found, seek a pair | |
| 8809 if ( !conv ) { | |
| 8810 for ( conv2 in converters ) { | |
| 8811 | |
| 8812 // If conv2 outputs current | |
| 8813 tmp = conv2.split( " " ); | |
| 8814 if ( tmp[ 1 ] === current ) { | |
| 8815 | |
| 8816 // If prev can be converted to accepted input | |
| 8817 conv = converters[ prev + " " + tmp[ 0 ] ] || | |
| 8818 converters[ "* " + tmp[ 0 ] ]; | |
| 8819 if ( conv ) { | |
| 8820 // Condense equivalence converters | |
| 8821 if ( conv === true ) { | |
| 8822 conv = converters[ conv2 ]; | |
| 8823 | |
| 8824 // Otherwise, insert the intermediate dataType | |
| 8825 } else if ( converters[ conv2 ] !== true ) { | |
| 8826 current = tmp[ 0 ]; | |
| 8827 dataTypes.unshift( tmp[ 1 ] ); | |
| 8828 } | |
| 8829 break; | |
| 8830 } | |
| 8831 } | |
| 8832 } | |
| 8833 } | |
| 8834 | |
| 8835 // Apply converter (if not an equivalence) | |
| 8836 if ( conv !== true ) { | |
| 8837 | |
| 8838 // Unless errors are allowed to bubble, catch and return them | |
| 8839 if ( conv && s[ "throws" ] ) { | |
| 8840 response = conv( response ); | |
| 8841 } else { | |
| 8842 try { | |
| 8843 response = conv( response ); | |
| 8844 } catch ( e ) { | |
| 8845 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current }; | |
| 8846 } | |
| 8847 } | |
| 8848 } | |
| 8849 } | |
| 8850 } | |
| 8851 } | |
| 8852 | |
| 8853 return { state: "success", data: response }; | |
| 8854 } | |
| 8855 | |
| 8856 jQuery.extend({ | |
| 8857 | |
| 8858 // Counter for holding the number of active queries | |
| 8859 active: 0, | |
| 8860 | |
| 8861 // Last-Modified header cache for next request | |
| 8862 lastModified: {}, | |
| 8863 etag: {}, | |
| 8864 | |
| 8865 ajaxSettings: { | |
| 8866 url: ajaxLocation, | |
| 8867 type: "GET", | |
| 8868 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), | |
| 8869 global: true, | |
| 8870 processData: true, | |
| 8871 async: true, | |
| 8872 contentType: "application/x-www-form-urlencoded; charset=UTF-8", | |
| 8873 /* | |
| 8874 timeout: 0, | |
| 8875 data: null, | |
| 8876 dataType: null, | |
| 8877 username: null, | |
| 8878 password: null, | |
| 8879 cache: null, | |
| 8880 throws: false, | |
| 8881 traditional: false, | |
| 8882 headers: {}, | |
| 8883 */ | |
| 8884 | |
| 8885 accepts: { | |
| 8886 "*": allTypes, | |
| 8887 text: "text/plain", | |
| 8888 html: "text/html", | |
| 8889 xml: "application/xml, text/xml", | |
| 8890 json: "application/json, text/javascript" | |
| 8891 }, | |
| 8892 | |
| 8893 contents: { | |
| 8894 xml: /xml/, | |
| 8895 html: /html/, | |
| 8896 json: /json/ | |
| 8897 }, | |
| 8898 | |
| 8899 responseFields: { | |
| 8900 xml: "responseXML", | |
| 8901 text: "responseText", | |
| 8902 json: "responseJSON" | |
| 8903 }, | |
| 8904 | |
| 8905 // Data converters | |
| 8906 // Keys separate source (or catchall "*") and destination types with a single space | |
| 8907 converters: { | |
| 8908 | |
| 8909 // Convert anything to text | |
| 8910 "* text": String, | |
| 8911 | |
| 8912 // Text to html (true = no transformation) | |
| 8913 "text html": true, | |
| 8914 | |
| 8915 // Evaluate text as a json expression | |
| 8916 "text json": jQuery.parseJSON, | |
| 8917 | |
| 8918 // Parse text as xml | |
| 8919 "text xml": jQuery.parseXML | |
| 8920 }, | |
| 8921 | |
| 8922 // For options that shouldn't be deep extended: | |
| 8923 // you can add your own custom options here if | |
| 8924 // and when you create one that shouldn't be | |
| 8925 // deep extended (see ajaxExtend) | |
| 8926 flatOptions: { | |
| 8927 url: true, | |
| 8928 context: true | |
| 8929 } | |
| 8930 }, | |
| 8931 | |
| 8932 // Creates a full fledged settings object into target | |
| 8933 // with both ajaxSettings and settings fields. | |
| 8934 // If target is omitted, writes into ajaxSettings. | |
| 8935 ajaxSetup: function( target, settings ) { | |
| 8936 return settings ? | |
| 8937 | |
| 8938 // Building a settings object | |
| 8939 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : | |
| 8940 | |
| 8941 // Extending ajaxSettings | |
| 8942 ajaxExtend( jQuery.ajaxSettings, target ); | |
| 8943 }, | |
| 8944 | |
| 8945 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), | |
| 8946 ajaxTransport: addToPrefiltersOrTransports( transports ), | |
| 8947 | |
| 8948 // Main method | |
| 8949 ajax: function( url, options ) { | |
| 8950 | |
| 8951 // If url is an object, simulate pre-1.5 signature | |
| 8952 if ( typeof url === "object" ) { | |
| 8953 options = url; | |
| 8954 url = undefined; | |
| 8955 } | |
| 8956 | |
| 8957 // Force options to be an object | |
| 8958 options = options || {}; | |
| 8959 | |
| 8960 var // Cross-domain detection vars | |
| 8961 parts, | |
| 8962 // Loop variable | |
| 8963 i, | |
| 8964 // URL without anti-cache param | |
| 8965 cacheURL, | |
| 8966 // Response headers as string | |
| 8967 responseHeadersString, | |
| 8968 // timeout handle | |
| 8969 timeoutTimer, | |
| 8970 | |
| 8971 // To know if global events are to be dispatched | |
| 8972 fireGlobals, | |
| 8973 | |
| 8974 transport, | |
| 8975 // Response headers | |
| 8976 responseHeaders, | |
| 8977 // Create the final options object | |
| 8978 s = jQuery.ajaxSetup( {}, options ), | |
| 8979 // Callbacks context | |
| 8980 callbackContext = s.context || s, | |
| 8981 // Context for global events is callbackContext if it is a DOM node or jQuery collection | |
| 8982 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ? | |
| 8983 jQuery( callbackContext ) : | |
| 8984 jQuery.event, | |
| 8985 // Deferreds | |
| 8986 deferred = jQuery.Deferred(), | |
| 8987 completeDeferred = jQuery.Callbacks("once memory"), | |
| 8988 // Status-dependent callbacks | |
| 8989 statusCode = s.statusCode || {}, | |
| 8990 // Headers (they are sent all at once) | |
| 8991 requestHeaders = {}, | |
| 8992 requestHeadersNames = {}, | |
| 8993 // The jqXHR state | |
| 8994 state = 0, | |
| 8995 // Default abort message | |
| 8996 strAbort = "canceled", | |
| 8997 // Fake xhr | |
| 8998 jqXHR = { | |
| 8999 readyState: 0, | |
| 9000 | |
| 9001 // Builds headers hashtable if needed | |
| 9002 getResponseHeader: function( key ) { | |
| 9003 var match; | |
| 9004 if ( state === 2 ) { | |
| 9005 if ( !responseHeaders ) { | |
| 9006 responseHeaders = {}; | |
| 9007 while ( (match = rheaders.exec( responseHeadersString )) ) { | |
| 9008 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; | |
| 9009 } | |
| 9010 } | |
| 9011 match = responseHeaders[ key.toLowerCase() ]; | |
| 9012 } | |
| 9013 return match == null ? null : match; | |
| 9014 }, | |
| 9015 | |
| 9016 // Raw string | |
| 9017 getAllResponseHeaders: function() { | |
| 9018 return state === 2 ? responseHeadersString : null; | |
| 9019 }, | |
| 9020 | |
| 9021 // Caches the header | |
| 9022 setRequestHeader: function( name, value ) { | |
| 9023 var lname = name.toLowerCase(); | |
| 9024 if ( !state ) { | |
| 9025 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; | |
| 9026 requestHeaders[ name ] = value; | |
| 9027 } | |
| 9028 return this; | |
| 9029 }, | |
| 9030 | |
| 9031 // Overrides response content-type header | |
| 9032 overrideMimeType: function( type ) { | |
| 9033 if ( !state ) { | |
| 9034 s.mimeType = type; | |
| 9035 } | |
| 9036 return this; | |
| 9037 }, | |
| 9038 | |
| 9039 // Status-dependent callbacks | |
| 9040 statusCode: function( map ) { | |
| 9041 var code; | |
| 9042 if ( map ) { | |
| 9043 if ( state < 2 ) { | |
| 9044 for ( code in map ) { | |
| 9045 // Lazy-add the new callback in a way that preserves old ones | |
| 9046 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; | |
| 9047 } | |
| 9048 } else { | |
| 9049 // Execute the appropriate callbacks | |
| 9050 jqXHR.always( map[ jqXHR.status ] ); | |
| 9051 } | |
| 9052 } | |
| 9053 return this; | |
| 9054 }, | |
| 9055 | |
| 9056 // Cancel the request | |
| 9057 abort: function( statusText ) { | |
| 9058 var finalText = statusText || strAbort; | |
| 9059 if ( transport ) { | |
| 9060 transport.abort( finalText ); | |
| 9061 } | |
| 9062 done( 0, finalText ); | |
| 9063 return this; | |
| 9064 } | |
| 9065 }; | |
| 9066 | |
| 9067 // Attach deferreds | |
| 9068 deferred.promise( jqXHR ).complete = completeDeferred.add; | |
| 9069 jqXHR.success = jqXHR.done; | |
| 9070 jqXHR.error = jqXHR.fail; | |
| 9071 | |
| 9072 // Remove hash character (#7531: and string promotion) | |
| 9073 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) | |
| 9074 // Handle falsy url in the settings object (#10093: consistency with old signature) | |
| 9075 // We also use the url parameter if available | |
| 9076 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); | |
| 9077 | |
| 9078 // Alias method option to type as per ticket #12004 | |
| 9079 s.type = options.method || options.type || s.method || s.type; | |
| 9080 | |
| 9081 // Extract dataTypes list | |
| 9082 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ]; | |
| 9083 | |
| 9084 // A cross-domain request is in order when we have a protocol:host:port mismatch | |
| 9085 if ( s.crossDomain == null ) { | |
| 9086 parts = rurl.exec( s.url.toLowerCase() ); | |
| 9087 s.crossDomain = !!( parts && | |
| 9088 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] || | |
| 9089 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !== | |
| 9090 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) ) | |
| 9091 ); | |
| 9092 } | |
| 9093 | |
| 9094 // Convert data if not already a string | |
| 9095 if ( s.data && s.processData && typeof s.data !== "string" ) { | |
| 9096 s.data = jQuery.param( s.data, s.traditional ); | |
| 9097 } | |
| 9098 | |
| 9099 // Apply prefilters | |
| 9100 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); | |
| 9101 | |
| 9102 // If request was aborted inside a prefilter, stop there | |
| 9103 if ( state === 2 ) { | |
| 9104 return jqXHR; | |
| 9105 } | |
| 9106 | |
| 9107 // We can fire global events as of now if asked to | |
| 9108 fireGlobals = s.global; | |
| 9109 | |
| 9110 // Watch for a new set of requests | |
| 9111 if ( fireGlobals && jQuery.active++ === 0 ) { | |
| 9112 jQuery.event.trigger("ajaxStart"); | |
| 9113 } | |
| 9114 | |
| 9115 // Uppercase the type | |
| 9116 s.type = s.type.toUpperCase(); | |
| 9117 | |
| 9118 // Determine if request has content | |
| 9119 s.hasContent = !rnoContent.test( s.type ); | |
| 9120 | |
| 9121 // Save the URL in case we're toying with the If-Modified-Since | |
| 9122 // and/or If-None-Match header later on | |
| 9123 cacheURL = s.url; | |
| 9124 | |
| 9125 // More options handling for requests with no content | |
| 9126 if ( !s.hasContent ) { | |
| 9127 | |
| 9128 // If data is available, append data to url | |
| 9129 if ( s.data ) { | |
| 9130 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data ); | |
| 9131 // #9682: remove data so that it's not used in an eventual retry | |
| 9132 delete s.data; | |
| 9133 } | |
| 9134 | |
| 9135 // Add anti-cache in url if needed | |
| 9136 if ( s.cache === false ) { | |
| 9137 s.url = rts.test( cacheURL ) ? | |
| 9138 | |
| 9139 // If there is already a '_' parameter, set its value | |
| 9140 cacheURL.replace( rts, "$1_=" + nonce++ ) : | |
| 9141 | |
| 9142 // Otherwise add one to the end | |
| 9143 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++; | |
| 9144 } | |
| 9145 } | |
| 9146 | |
| 9147 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. | |
| 9148 if ( s.ifModified ) { | |
| 9149 if ( jQuery.lastModified[ cacheURL ] ) { | |
| 9150 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); | |
| 9151 } | |
| 9152 if ( jQuery.etag[ cacheURL ] ) { | |
| 9153 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); | |
| 9154 } | |
| 9155 } | |
| 9156 | |
| 9157 // Set the correct header, if data is being sent | |
| 9158 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { | |
| 9159 jqXHR.setRequestHeader( "Content-Type", s.contentType ); | |
| 9160 } | |
| 9161 | |
| 9162 // Set the Accepts header for the server, depending on the dataType | |
| 9163 jqXHR.setRequestHeader( | |
| 9164 "Accept", | |
| 9165 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? | |
| 9166 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : | |
| 9167 s.accepts[ "*" ] | |
| 9168 ); | |
| 9169 | |
| 9170 // Check for headers option | |
| 9171 for ( i in s.headers ) { | |
| 9172 jqXHR.setRequestHeader( i, s.headers[ i ] ); | |
| 9173 } | |
| 9174 | |
| 9175 // Allow custom headers/mimetypes and early abort | |
| 9176 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { | |
| 9177 // Abort if not done already and return | |
| 9178 return jqXHR.abort(); | |
| 9179 } | |
| 9180 | |
| 9181 // aborting is no longer a cancellation | |
| 9182 strAbort = "abort"; | |
| 9183 | |
| 9184 // Install callbacks on deferreds | |
| 9185 for ( i in { success: 1, error: 1, complete: 1 } ) { | |
| 9186 jqXHR[ i ]( s[ i ] ); | |
| 9187 } | |
| 9188 | |
| 9189 // Get transport | |
| 9190 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); | |
| 9191 | |
| 9192 // If no transport, we auto-abort | |
| 9193 if ( !transport ) { | |
| 9194 done( -1, "No Transport" ); | |
| 9195 } else { | |
| 9196 jqXHR.readyState = 1; | |
| 9197 | |
| 9198 // Send global event | |
| 9199 if ( fireGlobals ) { | |
| 9200 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); | |
| 9201 } | |
| 9202 // Timeout | |
| 9203 if ( s.async && s.timeout > 0 ) { | |
| 9204 timeoutTimer = setTimeout(function() { | |
| 9205 jqXHR.abort("timeout"); | |
| 9206 }, s.timeout ); | |
| 9207 } | |
| 9208 | |
| 9209 try { | |
| 9210 state = 1; | |
| 9211 transport.send( requestHeaders, done ); | |
| 9212 } catch ( e ) { | |
| 9213 // Propagate exception as error if not done | |
| 9214 if ( state < 2 ) { | |
| 9215 done( -1, e ); | |
| 9216 // Simply rethrow otherwise | |
| 9217 } else { | |
| 9218 throw e; | |
| 9219 } | |
| 9220 } | |
| 9221 } | |
| 9222 | |
| 9223 // Callback for when everything is done | |
| 9224 function done( status, nativeStatusText, responses, headers ) { | |
| 9225 var isSuccess, success, error, response, modified, | |
| 9226 statusText = nativeStatusText; | |
| 9227 | |
| 9228 // Called once | |
| 9229 if ( state === 2 ) { | |
| 9230 return; | |
| 9231 } | |
| 9232 | |
| 9233 // State is "done" now | |
| 9234 state = 2; | |
| 9235 | |
| 9236 // Clear timeout if it exists | |
| 9237 if ( timeoutTimer ) { | |
| 9238 clearTimeout( timeoutTimer ); | |
| 9239 } | |
| 9240 | |
| 9241 // Dereference transport for early garbage collection | |
| 9242 // (no matter how long the jqXHR object will be used) | |
| 9243 transport = undefined; | |
| 9244 | |
| 9245 // Cache response headers | |
| 9246 responseHeadersString = headers || ""; | |
| 9247 | |
| 9248 // Set readyState | |
| 9249 jqXHR.readyState = status > 0 ? 4 : 0; | |
| 9250 | |
| 9251 // Determine if successful | |
| 9252 isSuccess = status >= 200 && status < 300 || status === 304; | |
| 9253 | |
| 9254 // Get response data | |
| 9255 if ( responses ) { | |
| 9256 response = ajaxHandleResponses( s, jqXHR, responses ); | |
| 9257 } | |
| 9258 | |
| 9259 // Convert no matter what (that way responseXXX fields are always set) | |
| 9260 response = ajaxConvert( s, response, jqXHR, isSuccess ); | |
| 9261 | |
| 9262 // If successful, handle type chaining | |
| 9263 if ( isSuccess ) { | |
| 9264 | |
| 9265 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. | |
| 9266 if ( s.ifModified ) { | |
| 9267 modified = jqXHR.getResponseHeader("Last-Modified"); | |
| 9268 if ( modified ) { | |
| 9269 jQuery.lastModified[ cacheURL ] = modified; | |
| 9270 } | |
| 9271 modified = jqXHR.getResponseHeader("etag"); | |
| 9272 if ( modified ) { | |
| 9273 jQuery.etag[ cacheURL ] = modified; | |
| 9274 } | |
| 9275 } | |
| 9276 | |
| 9277 // if no content | |
| 9278 if ( status === 204 || s.type === "HEAD" ) { | |
| 9279 statusText = "nocontent"; | |
| 9280 | |
| 9281 // if not modified | |
| 9282 } else if ( status === 304 ) { | |
| 9283 statusText = "notmodified"; | |
| 9284 | |
| 9285 // If we have data, let's convert it | |
| 9286 } else { | |
| 9287 statusText = response.state; | |
| 9288 success = response.data; | |
| 9289 error = response.error; | |
| 9290 isSuccess = !error; | |
| 9291 } | |
| 9292 } else { | |
| 9293 // We extract error from statusText | |
| 9294 // then normalize statusText and status for non-aborts | |
| 9295 error = statusText; | |
| 9296 if ( status || !statusText ) { | |
| 9297 statusText = "error"; | |
| 9298 if ( status < 0 ) { | |
| 9299 status = 0; | |
| 9300 } | |
| 9301 } | |
| 9302 } | |
| 9303 | |
| 9304 // Set data for the fake xhr object | |
| 9305 jqXHR.status = status; | |
| 9306 jqXHR.statusText = ( nativeStatusText || statusText ) + ""; | |
| 9307 | |
| 9308 // Success/Error | |
| 9309 if ( isSuccess ) { | |
| 9310 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); | |
| 9311 } else { | |
| 9312 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); | |
| 9313 } | |
| 9314 | |
| 9315 // Status-dependent callbacks | |
| 9316 jqXHR.statusCode( statusCode ); | |
| 9317 statusCode = undefined; | |
| 9318 | |
| 9319 if ( fireGlobals ) { | |
| 9320 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", | |
| 9321 [ jqXHR, s, isSuccess ? success : error ] ); | |
| 9322 } | |
| 9323 | |
| 9324 // Complete | |
| 9325 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); | |
| 9326 | |
| 9327 if ( fireGlobals ) { | |
| 9328 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); | |
| 9329 // Handle the global AJAX counter | |
| 9330 if ( !( --jQuery.active ) ) { | |
| 9331 jQuery.event.trigger("ajaxStop"); | |
| 9332 } | |
| 9333 } | |
| 9334 } | |
| 9335 | |
| 9336 return jqXHR; | |
| 9337 }, | |
| 9338 | |
| 9339 getJSON: function( url, data, callback ) { | |
| 9340 return jQuery.get( url, data, callback, "json" ); | |
| 9341 }, | |
| 9342 | |
| 9343 getScript: function( url, callback ) { | |
| 9344 return jQuery.get( url, undefined, callback, "script" ); | |
| 9345 } | |
| 9346 }); | |
| 9347 | |
| 9348 jQuery.each( [ "get", "post" ], function( i, method ) { | |
| 9349 jQuery[ method ] = function( url, data, callback, type ) { | |
| 9350 // shift arguments if data argument was omitted | |
| 9351 if ( jQuery.isFunction( data ) ) { | |
| 9352 type = type || callback; | |
| 9353 callback = data; | |
| 9354 data = undefined; | |
| 9355 } | |
| 9356 | |
| 9357 return jQuery.ajax({ | |
| 9358 url: url, | |
| 9359 type: method, | |
| 9360 dataType: type, | |
| 9361 data: data, | |
| 9362 success: callback | |
| 9363 }); | |
| 9364 }; | |
| 9365 }); | |
| 9366 | |
| 9367 // Attach a bunch of functions for handling common AJAX events | |
| 9368 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) { | |
| 9369 jQuery.fn[ type ] = function( fn ) { | |
| 9370 return this.on( type, fn ); | |
| 9371 }; | |
| 9372 }); | |
| 9373 | |
| 9374 | |
| 9375 jQuery._evalUrl = function( url ) { | |
| 9376 return jQuery.ajax({ | |
| 9377 url: url, | |
| 9378 type: "GET", | |
| 9379 dataType: "script", | |
| 9380 async: false, | |
| 9381 global: false, | |
| 9382 "throws": true | |
| 9383 }); | |
| 9384 }; | |
| 9385 | |
| 9386 | |
| 9387 jQuery.fn.extend({ | |
| 9388 wrapAll: function( html ) { | |
| 9389 if ( jQuery.isFunction( html ) ) { | |
| 9390 return this.each(function(i) { | |
| 9391 jQuery(this).wrapAll( html.call(this, i) ); | |
| 9392 }); | |
| 9393 } | |
| 9394 | |
| 9395 if ( this[0] ) { | |
| 9396 // The elements to wrap the target around | |
| 9397 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); | |
| 9398 | |
| 9399 if ( this[0].parentNode ) { | |
| 9400 wrap.insertBefore( this[0] ); | |
| 9401 } | |
| 9402 | |
| 9403 wrap.map(function() { | |
| 9404 var elem = this; | |
| 9405 | |
| 9406 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { | |
| 9407 elem = elem.firstChild; | |
| 9408 } | |
| 9409 | |
| 9410 return elem; | |
| 9411 }).append( this ); | |
| 9412 } | |
| 9413 | |
| 9414 return this; | |
| 9415 }, | |
| 9416 | |
| 9417 wrapInner: function( html ) { | |
| 9418 if ( jQuery.isFunction( html ) ) { | |
| 9419 return this.each(function(i) { | |
| 9420 jQuery(this).wrapInner( html.call(this, i) ); | |
| 9421 }); | |
| 9422 } | |
| 9423 | |
| 9424 return this.each(function() { | |
| 9425 var self = jQuery( this ), | |
| 9426 contents = self.contents(); | |
| 9427 | |
| 9428 if ( contents.length ) { | |
| 9429 contents.wrapAll( html ); | |
| 9430 | |
| 9431 } else { | |
| 9432 self.append( html ); | |
| 9433 } | |
| 9434 }); | |
| 9435 }, | |
| 9436 | |
| 9437 wrap: function( html ) { | |
| 9438 var isFunction = jQuery.isFunction( html ); | |
| 9439 | |
| 9440 return this.each(function(i) { | |
| 9441 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); | |
| 9442 }); | |
| 9443 }, | |
| 9444 | |
| 9445 unwrap: function() { | |
| 9446 return this.parent().each(function() { | |
| 9447 if ( !jQuery.nodeName( this, "body" ) ) { | |
| 9448 jQuery( this ).replaceWith( this.childNodes ); | |
| 9449 } | |
| 9450 }).end(); | |
| 9451 } | |
| 9452 }); | |
| 9453 | |
| 9454 | |
| 9455 jQuery.expr.filters.hidden = function( elem ) { | |
| 9456 // Support: Opera <= 12.12 | |
| 9457 // Opera reports offsetWidths and offsetHeights less than zero on some elements | |
| 9458 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 || | |
| 9459 (!support.reliableHiddenOffsets() && | |
| 9460 ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none"); | |
| 9461 }; | |
| 9462 | |
| 9463 jQuery.expr.filters.visible = function( elem ) { | |
| 9464 return !jQuery.expr.filters.hidden( elem ); | |
| 9465 }; | |
| 9466 | |
| 9467 | |
| 9468 | |
| 9469 | |
| 9470 var r20 = /%20/g, | |
| 9471 rbracket = /\[\]$/, | |
| 9472 rCRLF = /\r?\n/g, | |
| 9473 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, | |
| 9474 rsubmittable = /^(?:input|select|textarea|keygen)/i; | |
| 9475 | |
| 9476 function buildParams( prefix, obj, traditional, add ) { | |
| 9477 var name; | |
| 9478 | |
| 9479 if ( jQuery.isArray( obj ) ) { | |
| 9480 // Serialize array item. | |
| 9481 jQuery.each( obj, function( i, v ) { | |
| 9482 if ( traditional || rbracket.test( prefix ) ) { | |
| 9483 // Treat each array item as a scalar. | |
| 9484 add( prefix, v ); | |
| 9485 | |
| 9486 } else { | |
| 9487 // Item is non-scalar (array or object), encode its numeric index. | |
| 9488 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); | |
| 9489 } | |
| 9490 }); | |
| 9491 | |
| 9492 } else if ( !traditional && jQuery.type( obj ) === "object" ) { | |
| 9493 // Serialize object item. | |
| 9494 for ( name in obj ) { | |
| 9495 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); | |
| 9496 } | |
| 9497 | |
| 9498 } else { | |
| 9499 // Serialize scalar item. | |
| 9500 add( prefix, obj ); | |
| 9501 } | |
| 9502 } | |
| 9503 | |
| 9504 // Serialize an array of form elements or a set of | |
| 9505 // key/values into a query string | |
| 9506 jQuery.param = function( a, traditional ) { | |
| 9507 var prefix, | |
| 9508 s = [], | |
| 9509 add = function( key, value ) { | |
| 9510 // If value is a function, invoke it and return its value | |
| 9511 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); | |
| 9512 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); | |
| 9513 }; | |
| 9514 | |
| 9515 // Set traditional to true for jQuery <= 1.3.2 behavior. | |
| 9516 if ( traditional === undefined ) { | |
| 9517 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; | |
| 9518 } | |
| 9519 | |
| 9520 // If an array was passed in, assume that it is an array of form elements. | |
| 9521 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { | |
| 9522 // Serialize the form elements | |
| 9523 jQuery.each( a, function() { | |
| 9524 add( this.name, this.value ); | |
| 9525 }); | |
| 9526 | |
| 9527 } else { | |
| 9528 // If traditional, encode the "old" way (the way 1.3.2 or older | |
| 9529 // did it), otherwise encode params recursively. | |
| 9530 for ( prefix in a ) { | |
| 9531 buildParams( prefix, a[ prefix ], traditional, add ); | |
| 9532 } | |
| 9533 } | |
| 9534 | |
| 9535 // Return the resulting serialization | |
| 9536 return s.join( "&" ).replace( r20, "+" ); | |
| 9537 }; | |
| 9538 | |
| 9539 jQuery.fn.extend({ | |
| 9540 serialize: function() { | |
| 9541 return jQuery.param( this.serializeArray() ); | |
| 9542 }, | |
| 9543 serializeArray: function() { | |
| 9544 return this.map(function() { | |
| 9545 // Can add propHook for "elements" to filter or add form elements | |
| 9546 var elements = jQuery.prop( this, "elements" ); | |
| 9547 return elements ? jQuery.makeArray( elements ) : this; | |
| 9548 }) | |
| 9549 .filter(function() { | |
| 9550 var type = this.type; | |
| 9551 // Use .is(":disabled") so that fieldset[disabled] works | |
| 9552 return this.name && !jQuery( this ).is( ":disabled" ) && | |
| 9553 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && | |
| 9554 ( this.checked || !rcheckableType.test( type ) ); | |
| 9555 }) | |
| 9556 .map(function( i, elem ) { | |
| 9557 var val = jQuery( this ).val(); | |
| 9558 | |
| 9559 return val == null ? | |
| 9560 null : | |
| 9561 jQuery.isArray( val ) ? | |
| 9562 jQuery.map( val, function( val ) { | |
| 9563 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; | |
| 9564 }) : | |
| 9565 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; | |
| 9566 }).get(); | |
| 9567 } | |
| 9568 }); | |
| 9569 | |
| 9570 | |
| 9571 // Create the request object | |
| 9572 // (This is still attached to ajaxSettings for backward compatibility) | |
| 9573 jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ? | |
| 9574 // Support: IE6+ | |
| 9575 function() { | |
| 9576 | |
| 9577 // XHR cannot access local files, always use ActiveX for that case | |
| 9578 return !this.isLocal && | |
| 9579 | |
| 9580 // Support: IE7-8 | |
| 9581 // oldIE XHR does not support non-RFC2616 methods (#13240) | |
| 9582 // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx | |
| 9583 // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9 | |
| 9584 // Although this check for six methods instead of eight | |
| 9585 // since IE also does not support "trace" and "connect" | |
| 9586 /^(get|post|head|put|delete|options)$/i.test( this.type ) && | |
| 9587 | |
| 9588 createStandardXHR() || createActiveXHR(); | |
| 9589 } : | |
| 9590 // For all other browsers, use the standard XMLHttpRequest object | |
| 9591 createStandardXHR; | |
| 9592 | |
| 9593 var xhrId = 0, | |
| 9594 xhrCallbacks = {}, | |
| 9595 xhrSupported = jQuery.ajaxSettings.xhr(); | |
| 9596 | |
| 9597 // Support: IE<10 | |
| 9598 // Open requests must be manually aborted on unload (#5280) | |
| 9599 if ( window.ActiveXObject ) { | |
| 9600 jQuery( window ).on( "unload", function() { | |
| 9601 for ( var key in xhrCallbacks ) { | |
| 9602 xhrCallbacks[ key ]( undefined, true ); | |
| 9603 } | |
| 9604 }); | |
| 9605 } | |
| 9606 | |
| 9607 // Determine support properties | |
| 9608 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); | |
| 9609 xhrSupported = support.ajax = !!xhrSupported; | |
| 9610 | |
| 9611 // Create transport if the browser can provide an xhr | |
| 9612 if ( xhrSupported ) { | |
| 9613 | |
| 9614 jQuery.ajaxTransport(function( options ) { | |
| 9615 // Cross domain only allowed if supported through XMLHttpRequest | |
| 9616 if ( !options.crossDomain || support.cors ) { | |
| 9617 | |
| 9618 var callback; | |
| 9619 | |
| 9620 return { | |
| 9621 send: function( headers, complete ) { | |
| 9622 var i, | |
| 9623 xhr = options.xhr(), | |
| 9624 id = ++xhrId; | |
| 9625 | |
| 9626 // Open the socket | |
| 9627 xhr.open( options.type, options.url, options.async, options.username, options.password ); | |
| 9628 | |
| 9629 // Apply custom fields if provided | |
| 9630 if ( options.xhrFields ) { | |
| 9631 for ( i in options.xhrFields ) { | |
| 9632 xhr[ i ] = options.xhrFields[ i ]; | |
| 9633 } | |
| 9634 } | |
| 9635 | |
| 9636 // Override mime type if needed | |
| 9637 if ( options.mimeType && xhr.overrideMimeType ) { | |
| 9638 xhr.overrideMimeType( options.mimeType ); | |
| 9639 } | |
| 9640 | |
| 9641 // X-Requested-With header | |
| 9642 // For cross-domain requests, seeing as conditions for a preflight are | |
| 9643 // akin to a jigsaw puzzle, we simply never set it to be sure. | |
| 9644 // (it can always be set on a per-request basis or even using ajaxSetup) | |
| 9645 // For same-domain requests, won't change header if already provided. | |
| 9646 if ( !options.crossDomain && !headers["X-Requested-With"] ) { | |
| 9647 headers["X-Requested-With"] = "XMLHttpRequest"; | |
| 9648 } | |
| 9649 | |
| 9650 // Set headers | |
| 9651 for ( i in headers ) { | |
| 9652 // Support: IE<9 | |
| 9653 // IE's ActiveXObject throws a 'Type Mismatch' exception when setting | |
| 9654 // request header to a null-value. | |
| 9655 // | |
| 9656 // To keep consistent with other XHR implementations, cast the value | |
| 9657 // to string and ignore `undefined`. | |
| 9658 if ( headers[ i ] !== undefined ) { | |
| 9659 xhr.setRequestHeader( i, headers[ i ] + "" ); | |
| 9660 } | |
| 9661 } | |
| 9662 | |
| 9663 // Do send the request | |
| 9664 // This may raise an exception which is actually | |
| 9665 // handled in jQuery.ajax (so no try/catch here) | |
| 9666 xhr.send( ( options.hasContent && options.data ) || null ); | |
| 9667 | |
| 9668 // Listener | |
| 9669 callback = function( _, isAbort ) { | |
| 9670 var status, statusText, responses; | |
| 9671 | |
| 9672 // Was never called and is aborted or complete | |
| 9673 if ( callback && ( isAbort || xhr.readyState === 4 ) ) { | |
| 9674 // Clean up | |
| 9675 delete xhrCallbacks[ id ]; | |
| 9676 callback = undefined; | |
| 9677 xhr.onreadystatechange = jQuery.noop; | |
| 9678 | |
| 9679 // Abort manually if needed | |
| 9680 if ( isAbort ) { | |
| 9681 if ( xhr.readyState !== 4 ) { | |
| 9682 xhr.abort(); | |
| 9683 } | |
| 9684 } else { | |
| 9685 responses = {}; | |
| 9686 status = xhr.status; | |
| 9687 | |
| 9688 // Support: IE<10 | |
| 9689 // Accessing binary-data responseText throws an exception | |
| 9690 // (#11426) | |
| 9691 if ( typeof xhr.responseText === "string" ) { | |
| 9692 responses.text = xhr.responseText; | |
| 9693 } | |
| 9694 | |
| 9695 // Firefox throws an exception when accessing | |
| 9696 // statusText for faulty cross-domain requests | |
| 9697 try { | |
| 9698 statusText = xhr.statusText; | |
| 9699 } catch( e ) { | |
| 9700 // We normalize with Webkit giving an empty statusText | |
| 9701 statusText = ""; | |
| 9702 } | |
| 9703 | |
| 9704 // Filter status for non standard behaviors | |
| 9705 | |
| 9706 // If the request is local and we have data: assume a success | |
| 9707 // (success with no data won't get notified, that's the best we | |
| 9708 // can do given current implementations) | |
| 9709 if ( !status && options.isLocal && !options.crossDomain ) { | |
| 9710 status = responses.text ? 200 : 404; | |
| 9711 // IE - #1450: sometimes returns 1223 when it should be 204 | |
| 9712 } else if ( status === 1223 ) { | |
| 9713 status = 204; | |
| 9714 } | |
| 9715 } | |
| 9716 } | |
| 9717 | |
| 9718 // Call complete if needed | |
| 9719 if ( responses ) { | |
| 9720 complete( status, statusText, responses, xhr.getAllResponseHeaders() ); | |
| 9721 } | |
| 9722 }; | |
| 9723 | |
| 9724 if ( !options.async ) { | |
| 9725 // if we're in sync mode we fire the callback | |
| 9726 callback(); | |
| 9727 } else if ( xhr.readyState === 4 ) { | |
| 9728 // (IE6 & IE7) if it's in cache and has been | |
| 9729 // retrieved directly we need to fire the callback | |
| 9730 setTimeout( callback ); | |
| 9731 } else { | |
| 9732 // Add to the list of active xhr callbacks | |
| 9733 xhr.onreadystatechange = xhrCallbacks[ id ] = callback; | |
| 9734 } | |
| 9735 }, | |
| 9736 | |
| 9737 abort: function() { | |
| 9738 if ( callback ) { | |
| 9739 callback( undefined, true ); | |
| 9740 } | |
| 9741 } | |
| 9742 }; | |
| 9743 } | |
| 9744 }); | |
| 9745 } | |
| 9746 | |
| 9747 // Functions to create xhrs | |
| 9748 function createStandardXHR() { | |
| 9749 try { | |
| 9750 return new window.XMLHttpRequest(); | |
| 9751 } catch( e ) {} | |
| 9752 } | |
| 9753 | |
| 9754 function createActiveXHR() { | |
| 9755 try { | |
| 9756 return new window.ActiveXObject( "Microsoft.XMLHTTP" ); | |
| 9757 } catch( e ) {} | |
| 9758 } | |
| 9759 | |
| 9760 | |
| 9761 | |
| 9762 | |
| 9763 // Install script dataType | |
| 9764 jQuery.ajaxSetup({ | |
| 9765 accepts: { | |
| 9766 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" | |
| 9767 }, | |
| 9768 contents: { | |
| 9769 script: /(?:java|ecma)script/ | |
| 9770 }, | |
| 9771 converters: { | |
| 9772 "text script": function( text ) { | |
| 9773 jQuery.globalEval( text ); | |
| 9774 return text; | |
| 9775 } | |
| 9776 } | |
| 9777 }); | |
| 9778 | |
| 9779 // Handle cache's special case and global | |
| 9780 jQuery.ajaxPrefilter( "script", function( s ) { | |
| 9781 if ( s.cache === undefined ) { | |
| 9782 s.cache = false; | |
| 9783 } | |
| 9784 if ( s.crossDomain ) { | |
| 9785 s.type = "GET"; | |
| 9786 s.global = false; | |
| 9787 } | |
| 9788 }); | |
| 9789 | |
| 9790 // Bind script tag hack transport | |
| 9791 jQuery.ajaxTransport( "script", function(s) { | |
| 9792 | |
| 9793 // This transport only deals with cross domain requests | |
| 9794 if ( s.crossDomain ) { | |
| 9795 | |
| 9796 var script, | |
| 9797 head = document.head || jQuery("head")[0] || document.documentElement; | |
| 9798 | |
| 9799 return { | |
| 9800 | |
| 9801 send: function( _, callback ) { | |
| 9802 | |
| 9803 script = document.createElement("script"); | |
| 9804 | |
| 9805 script.async = true; | |
| 9806 | |
| 9807 if ( s.scriptCharset ) { | |
| 9808 script.charset = s.scriptCharset; | |
| 9809 } | |
| 9810 | |
| 9811 script.src = s.url; | |
| 9812 | |
| 9813 // Attach handlers for all browsers | |
| 9814 script.onload = script.onreadystatechange = function( _, isAbort ) { | |
| 9815 | |
| 9816 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { | |
| 9817 | |
| 9818 // Handle memory leak in IE | |
| 9819 script.onload = script.onreadystatechange = null; | |
| 9820 | |
| 9821 // Remove the script | |
| 9822 if ( script.parentNode ) { | |
| 9823 script.parentNode.removeChild( script ); | |
| 9824 } | |
| 9825 | |
| 9826 // Dereference the script | |
| 9827 script = null; | |
| 9828 | |
| 9829 // Callback if not abort | |
| 9830 if ( !isAbort ) { | |
| 9831 callback( 200, "success" ); | |
| 9832 } | |
| 9833 } | |
| 9834 }; | |
| 9835 | |
| 9836 // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending | |
| 9837 // Use native DOM manipulation to avoid our domManip AJAX trickery | |
| 9838 head.insertBefore( script, head.firstChild ); | |
| 9839 }, | |
| 9840 | |
| 9841 abort: function() { | |
| 9842 if ( script ) { | |
| 9843 script.onload( undefined, true ); | |
| 9844 } | |
| 9845 } | |
| 9846 }; | |
| 9847 } | |
| 9848 }); | |
| 9849 | |
| 9850 | |
| 9851 | |
| 9852 | |
| 9853 var oldCallbacks = [], | |
| 9854 rjsonp = /(=)\?(?=&|$)|\?\?/; | |
| 9855 | |
| 9856 // Default jsonp settings | |
| 9857 jQuery.ajaxSetup({ | |
| 9858 jsonp: "callback", | |
| 9859 jsonpCallback: function() { | |
| 9860 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); | |
| 9861 this[ callback ] = true; | |
| 9862 return callback; | |
| 9863 } | |
| 9864 }); | |
| 9865 | |
| 9866 // Detect, normalize options and install callbacks for jsonp requests | |
| 9867 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { | |
| 9868 | |
| 9869 var callbackName, overwritten, responseContainer, | |
| 9870 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? | |
| 9871 "url" : | |
| 9872 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" | |
| 9873 ); | |
| 9874 | |
| 9875 // Handle iff the expected data type is "jsonp" or we have a parameter to set | |
| 9876 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { | |
| 9877 | |
| 9878 // Get callback name, remembering preexisting value associated with it | |
| 9879 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? | |
| 9880 s.jsonpCallback() : | |
| 9881 s.jsonpCallback; | |
| 9882 | |
| 9883 // Insert callback into url or form data | |
| 9884 if ( jsonProp ) { | |
| 9885 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); | |
| 9886 } else if ( s.jsonp !== false ) { | |
| 9887 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; | |
| 9888 } | |
| 9889 | |
| 9890 // Use data converter to retrieve json after script execution | |
| 9891 s.converters["script json"] = function() { | |
| 9892 if ( !responseContainer ) { | |
| 9893 jQuery.error( callbackName + " was not called" ); | |
| 9894 } | |
| 9895 return responseContainer[ 0 ]; | |
| 9896 }; | |
| 9897 | |
| 9898 // force json dataType | |
| 9899 s.dataTypes[ 0 ] = "json"; | |
| 9900 | |
| 9901 // Install callback | |
| 9902 overwritten = window[ callbackName ]; | |
| 9903 window[ callbackName ] = function() { | |
| 9904 responseContainer = arguments; | |
| 9905 }; | |
| 9906 | |
| 9907 // Clean-up function (fires after converters) | |
| 9908 jqXHR.always(function() { | |
| 9909 // Restore preexisting value | |
| 9910 window[ callbackName ] = overwritten; | |
| 9911 | |
| 9912 // Save back as free | |
| 9913 if ( s[ callbackName ] ) { | |
| 9914 // make sure that re-using the options doesn't screw things around | |
| 9915 s.jsonpCallback = originalSettings.jsonpCallback; | |
| 9916 | |
| 9917 // save the callback name for future use | |
| 9918 oldCallbacks.push( callbackName ); | |
| 9919 } | |
| 9920 | |
| 9921 // Call if it was a function and we have a response | |
| 9922 if ( responseContainer && jQuery.isFunction( overwritten ) ) { | |
| 9923 overwritten( responseContainer[ 0 ] ); | |
| 9924 } | |
| 9925 | |
| 9926 responseContainer = overwritten = undefined; | |
| 9927 }); | |
| 9928 | |
| 9929 // Delegate to script | |
| 9930 return "script"; | |
| 9931 } | |
| 9932 }); | |
| 9933 | |
| 9934 | |
| 9935 | |
| 9936 | |
| 9937 // data: string of html | |
| 9938 // context (optional): If specified, the fragment will be created in this context, defaults to document | |
| 9939 // keepScripts (optional): If true, will include scripts passed in the html string | |
| 9940 jQuery.parseHTML = function( data, context, keepScripts ) { | |
| 9941 if ( !data || typeof data !== "string" ) { | |
| 9942 return null; | |
| 9943 } | |
| 9944 if ( typeof context === "boolean" ) { | |
| 9945 keepScripts = context; | |
| 9946 context = false; | |
| 9947 } | |
| 9948 context = context || document; | |
| 9949 | |
| 9950 var parsed = rsingleTag.exec( data ), | |
| 9951 scripts = !keepScripts && []; | |
| 9952 | |
| 9953 // Single tag | |
| 9954 if ( parsed ) { | |
| 9955 return [ context.createElement( parsed[1] ) ]; | |
| 9956 } | |
| 9957 | |
| 9958 parsed = jQuery.buildFragment( [ data ], context, scripts ); | |
| 9959 | |
| 9960 if ( scripts && scripts.length ) { | |
| 9961 jQuery( scripts ).remove(); | |
| 9962 } | |
| 9963 | |
| 9964 return jQuery.merge( [], parsed.childNodes ); | |
| 9965 }; | |
| 9966 | |
| 9967 | |
| 9968 // Keep a copy of the old load method | |
| 9969 var _load = jQuery.fn.load; | |
| 9970 | |
| 9971 /** | |
| 9972 * Load a url into a page | |
| 9973 */ | |
| 9974 jQuery.fn.load = function( url, params, callback ) { | |
| 9975 if ( typeof url !== "string" && _load ) { | |
| 9976 return _load.apply( this, arguments ); | |
| 9977 } | |
| 9978 | |
| 9979 var selector, response, type, | |
| 9980 self = this, | |
| 9981 off = url.indexOf(" "); | |
| 9982 | |
| 9983 if ( off >= 0 ) { | |
| 9984 selector = url.slice( off, url.length ); | |
| 9985 url = url.slice( 0, off ); | |
| 9986 } | |
| 9987 | |
| 9988 // If it's a function | |
| 9989 if ( jQuery.isFunction( params ) ) { | |
| 9990 | |
| 9991 // We assume that it's the callback | |
| 9992 callback = params; | |
| 9993 params = undefined; | |
| 9994 | |
| 9995 // Otherwise, build a param string | |
| 9996 } else if ( params && typeof params === "object" ) { | |
| 9997 type = "POST"; | |
| 9998 } | |
| 9999 | |
| 10000 // If we have elements to modify, make the request | |
| 10001 if ( self.length > 0 ) { | |
| 10002 jQuery.ajax({ | |
| 10003 url: url, | |
| 10004 | |
| 10005 // if "type" variable is undefined, then "GET" method will be used | |
| 10006 type: type, | |
| 10007 dataType: "html", | |
| 10008 data: params | |
| 10009 }).done(function( responseText ) { | |
| 10010 | |
| 10011 // Save response for use in complete callback | |
| 10012 response = arguments; | |
| 10013 | |
| 10014 self.html( selector ? | |
| 10015 | |
| 10016 // If a selector was specified, locate the right elements in a dummy div | |
| 10017 // Exclude scripts to avoid IE 'Permission Denied' errors | |
| 10018 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) : | |
| 10019 | |
| 10020 // Otherwise use the full result | |
| 10021 responseText ); | |
| 10022 | |
| 10023 }).complete( callback && function( jqXHR, status ) { | |
| 10024 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); | |
| 10025 }); | |
| 10026 } | |
| 10027 | |
| 10028 return this; | |
| 10029 }; | |
| 10030 | |
| 10031 | |
| 10032 | |
| 10033 | |
| 10034 jQuery.expr.filters.animated = function( elem ) { | |
| 10035 return jQuery.grep(jQuery.timers, function( fn ) { | |
| 10036 return elem === fn.elem; | |
| 10037 }).length; | |
| 10038 }; | |
| 10039 | |
| 10040 | |
| 10041 | |
| 10042 | |
| 10043 | |
| 10044 var docElem = window.document.documentElement; | |
| 10045 | |
| 10046 /** | |
| 10047 * Gets a window from an element | |
| 10048 */ | |
| 10049 function getWindow( elem ) { | |
| 10050 return jQuery.isWindow( elem ) ? | |
| 10051 elem : | |
| 10052 elem.nodeType === 9 ? | |
| 10053 elem.defaultView || elem.parentWindow : | |
| 10054 false; | |
| 10055 } | |
| 10056 | |
| 10057 jQuery.offset = { | |
| 10058 setOffset: function( elem, options, i ) { | |
| 10059 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, | |
| 10060 position = jQuery.css( elem, "position" ), | |
| 10061 curElem = jQuery( elem ), | |
| 10062 props = {}; | |
| 10063 | |
| 10064 // set position first, in-case top/left are set even on static elem | |
| 10065 if ( position === "static" ) { | |
| 10066 elem.style.position = "relative"; | |
| 10067 } | |
| 10068 | |
| 10069 curOffset = curElem.offset(); | |
| 10070 curCSSTop = jQuery.css( elem, "top" ); | |
| 10071 curCSSLeft = jQuery.css( elem, "left" ); | |
| 10072 calculatePosition = ( position === "absolute" || position === "fixed" ) && | |
| 10073 jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1; | |
| 10074 | |
| 10075 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed | |
| 10076 if ( calculatePosition ) { | |
| 10077 curPosition = curElem.position(); | |
| 10078 curTop = curPosition.top; | |
| 10079 curLeft = curPosition.left; | |
| 10080 } else { | |
| 10081 curTop = parseFloat( curCSSTop ) || 0; | |
| 10082 curLeft = parseFloat( curCSSLeft ) || 0; | |
| 10083 } | |
| 10084 | |
| 10085 if ( jQuery.isFunction( options ) ) { | |
| 10086 options = options.call( elem, i, curOffset ); | |
| 10087 } | |
| 10088 | |
| 10089 if ( options.top != null ) { | |
| 10090 props.top = ( options.top - curOffset.top ) + curTop; | |
| 10091 } | |
| 10092 if ( options.left != null ) { | |
| 10093 props.left = ( options.left - curOffset.left ) + curLeft; | |
| 10094 } | |
| 10095 | |
| 10096 if ( "using" in options ) { | |
| 10097 options.using.call( elem, props ); | |
| 10098 } else { | |
| 10099 curElem.css( props ); | |
| 10100 } | |
| 10101 } | |
| 10102 }; | |
| 10103 | |
| 10104 jQuery.fn.extend({ | |
| 10105 offset: function( options ) { | |
| 10106 if ( arguments.length ) { | |
| 10107 return options === undefined ? | |
| 10108 this : | |
| 10109 this.each(function( i ) { | |
| 10110 jQuery.offset.setOffset( this, options, i ); | |
| 10111 }); | |
| 10112 } | |
| 10113 | |
| 10114 var docElem, win, | |
| 10115 box = { top: 0, left: 0 }, | |
| 10116 elem = this[ 0 ], | |
| 10117 doc = elem && elem.ownerDocument; | |
| 10118 | |
| 10119 if ( !doc ) { | |
| 10120 return; | |
| 10121 } | |
| 10122 | |
| 10123 docElem = doc.documentElement; | |
| 10124 | |
| 10125 // Make sure it's not a disconnected DOM node | |
| 10126 if ( !jQuery.contains( docElem, elem ) ) { | |
| 10127 return box; | |
| 10128 } | |
| 10129 | |
| 10130 // If we don't have gBCR, just use 0,0 rather than error | |
| 10131 // BlackBerry 5, iOS 3 (original iPhone) | |
| 10132 if ( typeof elem.getBoundingClientRect !== strundefined ) { | |
| 10133 box = elem.getBoundingClientRect(); | |
| 10134 } | |
| 10135 win = getWindow( doc ); | |
| 10136 return { | |
| 10137 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ), | |
| 10138 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 ) | |
| 10139 }; | |
| 10140 }, | |
| 10141 | |
| 10142 position: function() { | |
| 10143 if ( !this[ 0 ] ) { | |
| 10144 return; | |
| 10145 } | |
| 10146 | |
| 10147 var offsetParent, offset, | |
| 10148 parentOffset = { top: 0, left: 0 }, | |
| 10149 elem = this[ 0 ]; | |
| 10150 | |
| 10151 // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent | |
| 10152 if ( jQuery.css( elem, "position" ) === "fixed" ) { | |
| 10153 // we assume that getBoundingClientRect is available when computed position is fixed | |
| 10154 offset = elem.getBoundingClientRect(); | |
| 10155 } else { | |
| 10156 // Get *real* offsetParent | |
| 10157 offsetParent = this.offsetParent(); | |
| 10158 | |
| 10159 // Get correct offsets | |
| 10160 offset = this.offset(); | |
| 10161 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { | |
| 10162 parentOffset = offsetParent.offset(); | |
| 10163 } | |
| 10164 | |
| 10165 // Add offsetParent borders | |
| 10166 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ); | |
| 10167 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ); | |
| 10168 } | |
| 10169 | |
| 10170 // Subtract parent offsets and element margins | |
| 10171 // note: when an element has margin: auto the offsetLeft and marginLeft | |
| 10172 // are the same in Safari causing offset.left to incorrectly be 0 | |
| 10173 return { | |
| 10174 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), | |
| 10175 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true) | |
| 10176 }; | |
| 10177 }, | |
| 10178 | |
| 10179 offsetParent: function() { | |
| 10180 return this.map(function() { | |
| 10181 var offsetParent = this.offsetParent || docElem; | |
| 10182 | |
| 10183 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) { | |
| 10184 offsetParent = offsetParent.offsetParent; | |
| 10185 } | |
| 10186 return offsetParent || docElem; | |
| 10187 }); | |
| 10188 } | |
| 10189 }); | |
| 10190 | |
| 10191 // Create scrollLeft and scrollTop methods | |
| 10192 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { | |
| 10193 var top = /Y/.test( prop ); | |
| 10194 | |
| 10195 jQuery.fn[ method ] = function( val ) { | |
| 10196 return access( this, function( elem, method, val ) { | |
| 10197 var win = getWindow( elem ); | |
| 10198 | |
| 10199 if ( val === undefined ) { | |
| 10200 return win ? (prop in win) ? win[ prop ] : | |
| 10201 win.document.documentElement[ method ] : | |
| 10202 elem[ method ]; | |
| 10203 } | |
| 10204 | |
| 10205 if ( win ) { | |
| 10206 win.scrollTo( | |
| 10207 !top ? val : jQuery( win ).scrollLeft(), | |
| 10208 top ? val : jQuery( win ).scrollTop() | |
| 10209 ); | |
| 10210 | |
| 10211 } else { | |
| 10212 elem[ method ] = val; | |
| 10213 } | |
| 10214 }, method, val, arguments.length, null ); | |
| 10215 }; | |
| 10216 }); | |
| 10217 | |
| 10218 // Add the top/left cssHooks using jQuery.fn.position | |
| 10219 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 | |
| 10220 // getComputedStyle returns percent when specified for top/left/bottom/right | |
| 10221 // rather than make the css module depend on the offset module, we just check for it here | |
| 10222 jQuery.each( [ "top", "left" ], function( i, prop ) { | |
| 10223 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, | |
| 10224 function( elem, computed ) { | |
| 10225 if ( computed ) { | |
| 10226 computed = curCSS( elem, prop ); | |
| 10227 // if curCSS returns percentage, fallback to offset | |
| 10228 return rnumnonpx.test( computed ) ? | |
| 10229 jQuery( elem ).position()[ prop ] + "px" : | |
| 10230 computed; | |
| 10231 } | |
| 10232 } | |
| 10233 ); | |
| 10234 }); | |
| 10235 | |
| 10236 | |
| 10237 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods | |
| 10238 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { | |
| 10239 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { | |
| 10240 // margin is only for outerHeight, outerWidth | |
| 10241 jQuery.fn[ funcName ] = function( margin, value ) { | |
| 10242 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), | |
| 10243 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); | |
| 10244 | |
| 10245 return access( this, function( elem, type, value ) { | |
| 10246 var doc; | |
| 10247 | |
| 10248 if ( jQuery.isWindow( elem ) ) { | |
| 10249 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there | |
| 10250 // isn't a whole lot we can do. See pull request at this URL for discussion: | |
| 10251 // https://github.com/jquery/jquery/pull/764 | |
| 10252 return elem.document.documentElement[ "client" + name ]; | |
| 10253 } | |
| 10254 | |
| 10255 // Get document width or height | |
| 10256 if ( elem.nodeType === 9 ) { | |
| 10257 doc = elem.documentElement; | |
| 10258 | |
| 10259 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest | |
| 10260 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it. | |
| 10261 return Math.max( | |
| 10262 elem.body[ "scroll" + name ], doc[ "scroll" + name ], | |
| 10263 elem.body[ "offset" + name ], doc[ "offset" + name ], | |
| 10264 doc[ "client" + name ] | |
| 10265 ); | |
| 10266 } | |
| 10267 | |
| 10268 return value === undefined ? | |
| 10269 // Get width or height on the element, requesting but not forcing parseFloat | |
| 10270 jQuery.css( elem, type, extra ) : | |
| 10271 | |
| 10272 // Set width or height on the element | |
| 10273 jQuery.style( elem, type, value, extra ); | |
| 10274 }, type, chainable ? margin : undefined, chainable, null ); | |
| 10275 }; | |
| 10276 }); | |
| 10277 }); | |
| 10278 | |
| 10279 | |
| 10280 // The number of elements contained in the matched element set | |
| 10281 jQuery.fn.size = function() { | |
| 10282 return this.length; | |
| 10283 }; | |
| 10284 | |
| 10285 jQuery.fn.andSelf = jQuery.fn.addBack; | |
| 10286 | |
| 10287 | |
| 10288 | |
| 10289 | |
| 10290 // Register as a named AMD module, since jQuery can be concatenated with other | |
| 10291 // files that may use define, but not via a proper concatenation script that | |
| 10292 // understands anonymous AMD modules. A named AMD is safest and most robust | |
| 10293 // way to register. Lowercase jquery is used because AMD module names are | |
| 10294 // derived from file names, and jQuery is normally delivered in a lowercase | |
| 10295 // file name. Do this after creating the global so that if an AMD module wants | |
| 10296 // to call noConflict to hide this version of jQuery, it will work. | |
| 10297 if ( typeof define === "function" && define.amd ) { | |
| 10298 define( "jquery", [], function() { | |
| 10299 return jQuery; | |
| 10300 }); | |
| 10301 } | |
| 10302 | |
| 10303 | |
| 10304 | |
| 10305 | |
| 10306 var | |
| 10307 // Map over jQuery in case of overwrite | |
| 10308 _jQuery = window.jQuery, | |
| 10309 | |
| 10310 // Map over the $ in case of overwrite | |
| 10311 _$ = window.$; | |
| 10312 | |
| 10313 jQuery.noConflict = function( deep ) { | |
| 10314 if ( window.$ === jQuery ) { | |
| 10315 window.$ = _$; | |
| 10316 } | |
| 10317 | |
| 10318 if ( deep && window.jQuery === jQuery ) { | |
| 10319 window.jQuery = _jQuery; | |
| 10320 } | |
| 10321 | |
| 10322 return jQuery; | |
| 10323 }; | |
| 10324 | |
| 10325 // Expose jQuery and $ identifiers, even in | |
| 10326 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557) | |
| 10327 // and CommonJS for browser emulators (#13566) | |
| 10328 if ( typeof noGlobal === strundefined ) { | |
| 10329 window.jQuery = window.$ = jQuery; | |
| 10330 } | |
| 10331 | |
| 10332 | |
| 10333 | |
| 10334 | |
| 10335 return jQuery; | |
| 10336 | |
| 10337 })); | |
| 10338 /*! | |
| 10339 * jQuery JavaScript Library v2.1.4 | |
| 10340 * http://jquery.com/ | |
| 10341 * | |
| 10342 * Includes Sizzle.js | |
| 10343 * http://sizzlejs.com/ | |
| 10344 * | |
| 10345 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors | |
| 10346 * Released under the MIT license | |
| 10347 * http://jquery.org/license | |
| 10348 * | |
| 10349 * Date: 2015-04-28T16:01Z | |
| 10350 */ | |
| 10351 | |
| 10352 (function( global, factory ) { | |
| 10353 | |
| 10354 if ( typeof module === "object" && typeof module.exports === "object" ) { | |
| 10355 // For CommonJS and CommonJS-like environments where a proper `window` | |
| 10356 // is present, execute the factory and get jQuery. | |
| 10357 // For environments that do not have a `window` with a `document` | |
| 10358 // (such as Node.js), expose a factory as module.exports. | |
| 10359 // This accentuates the need for the creation of a real `window`. | |
| 10360 // e.g. var jQuery = require("jquery")(window); | |
| 10361 // See ticket #14549 for more info. | |
| 10362 module.exports = global.document ? | |
| 10363 factory( global, true ) : | |
| 10364 function( w ) { | |
| 10365 if ( !w.document ) { | |
| 10366 throw new Error( "jQuery requires a window with a document" ); | |
| 10367 } | |
| 10368 return factory( w ); | |
| 10369 }; | |
| 10370 } else { | |
| 10371 factory( global ); | |
| 10372 } | |
| 10373 | |
| 10374 // Pass this if window is not defined yet | |
| 10375 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { | |
| 10376 | |
| 10377 // Support: Firefox 18+ | |
| 10378 // Can't be in strict mode, several libs including ASP.NET trace | |
| 10379 // the stack via arguments.caller.callee and Firefox dies if | |
| 10380 // you try to trace through "use strict" call chains. (#13335) | |
| 10381 // | |
| 10382 | |
| 10383 var arr = []; | |
| 10384 | |
| 10385 var slice = arr.slice; | |
| 10386 | |
| 10387 var concat = arr.concat; | |
| 10388 | |
| 10389 var push = arr.push; | |
| 10390 | |
| 10391 var indexOf = arr.indexOf; | |
| 10392 | |
| 10393 var class2type = {}; | |
| 10394 | |
| 10395 var toString = class2type.toString; | |
| 10396 | |
| 10397 var hasOwn = class2type.hasOwnProperty; | |
| 10398 | |
| 10399 var support = {}; | |
| 10400 | |
| 10401 | |
| 10402 | |
| 10403 var | |
| 10404 // Use the correct document accordingly with window argument (sandbox) | |
| 10405 document = window.document, | |
| 10406 | |
| 10407 version = "2.1.4", | |
| 10408 | |
| 10409 // Define a local copy of jQuery | |
| 10410 jQuery = function( selector, context ) { | |
| 10411 // The jQuery object is actually just the init constructor 'enhanced' | |
| 10412 // Need init if jQuery is called (just allow error to be thrown if not included) | |
| 10413 return new jQuery.fn.init( selector, context ); | |
| 10414 }, | |
| 10415 | |
| 10416 // Support: Android<4.1 | |
| 10417 // Make sure we trim BOM and NBSP | |
| 10418 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, | |
| 10419 | |
| 10420 // Matches dashed string for camelizing | |
| 10421 rmsPrefix = /^-ms-/, | |
| 10422 rdashAlpha = /-([\da-z])/gi, | |
| 10423 | |
| 10424 // Used by jQuery.camelCase as callback to replace() | |
| 10425 fcamelCase = function( all, letter ) { | |
| 10426 return letter.toUpperCase(); | |
| 10427 }; | |
| 10428 | |
| 10429 jQuery.fn = jQuery.prototype = { | |
| 10430 // The current version of jQuery being used | |
| 10431 jquery: version, | |
| 10432 | |
| 10433 constructor: jQuery, | |
| 10434 | |
| 10435 // Start with an empty selector | |
| 10436 selector: "", | |
| 10437 | |
| 10438 // The default length of a jQuery object is 0 | |
| 10439 length: 0, | |
| 10440 | |
| 10441 toArray: function() { | |
| 10442 return slice.call( this ); | |
| 10443 }, | |
| 10444 | |
| 10445 // Get the Nth element in the matched element set OR | |
| 10446 // Get the whole matched element set as a clean array | |
| 10447 get: function( num ) { | |
| 10448 return num != null ? | |
| 10449 | |
| 10450 // Return just the one element from the set | |
| 10451 ( num < 0 ? this[ num + this.length ] : this[ num ] ) : | |
| 10452 | |
| 10453 // Return all the elements in a clean array | |
| 10454 slice.call( this ); | |
| 10455 }, | |
| 10456 | |
| 10457 // Take an array of elements and push it onto the stack | |
| 10458 // (returning the new matched element set) | |
| 10459 pushStack: function( elems ) { | |
| 10460 | |
| 10461 // Build a new jQuery matched element set | |
| 10462 var ret = jQuery.merge( this.constructor(), elems ); | |
| 10463 | |
| 10464 // Add the old object onto the stack (as a reference) | |
| 10465 ret.prevObject = this; | |
| 10466 ret.context = this.context; | |
| 10467 | |
| 10468 // Return the newly-formed element set | |
| 10469 return ret; | |
| 10470 }, | |
| 10471 | |
| 10472 // Execute a callback for every element in the matched set. | |
| 10473 // (You can seed the arguments with an array of args, but this is | |
| 10474 // only used internally.) | |
| 10475 each: function( callback, args ) { | |
| 10476 return jQuery.each( this, callback, args ); | |
| 10477 }, | |
| 10478 | |
| 10479 map: function( callback ) { | |
| 10480 return this.pushStack( jQuery.map(this, function( elem, i ) { | |
| 10481 return callback.call( elem, i, elem ); | |
| 10482 })); | |
| 10483 }, | |
| 10484 | |
| 10485 slice: function() { | |
| 10486 return this.pushStack( slice.apply( this, arguments ) ); | |
| 10487 }, | |
| 10488 | |
| 10489 first: function() { | |
| 10490 return this.eq( 0 ); | |
| 10491 }, | |
| 10492 | |
| 10493 last: function() { | |
| 10494 return this.eq( -1 ); | |
| 10495 }, | |
| 10496 | |
| 10497 eq: function( i ) { | |
| 10498 var len = this.length, | |
| 10499 j = +i + ( i < 0 ? len : 0 ); | |
| 10500 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); | |
| 10501 }, | |
| 10502 | |
| 10503 end: function() { | |
| 10504 return this.prevObject || this.constructor(null); | |
| 10505 }, | |
| 10506 | |
| 10507 // For internal use only. | |
| 10508 // Behaves like an Array's method, not like a jQuery method. | |
| 10509 push: push, | |
| 10510 sort: arr.sort, | |
| 10511 splice: arr.splice | |
| 10512 }; | |
| 10513 | |
| 10514 jQuery.extend = jQuery.fn.extend = function() { | |
| 10515 var options, name, src, copy, copyIsArray, clone, | |
| 10516 target = arguments[0] || {}, | |
| 10517 i = 1, | |
| 10518 length = arguments.length, | |
| 10519 deep = false; | |
| 10520 | |
| 10521 // Handle a deep copy situation | |
| 10522 if ( typeof target === "boolean" ) { | |
| 10523 deep = target; | |
| 10524 | |
| 10525 // Skip the boolean and the target | |
| 10526 target = arguments[ i ] || {}; | |
| 10527 i++; | |
| 10528 } | |
| 10529 | |
| 10530 // Handle case when target is a string or something (possible in deep copy) | |
| 10531 if ( typeof target !== "object" && !jQuery.isFunction(target) ) { | |
| 10532 target = {}; | |
| 10533 } | |
| 10534 | |
| 10535 // Extend jQuery itself if only one argument is passed | |
| 10536 if ( i === length ) { | |
| 10537 target = this; | |
| 10538 i--; | |
| 10539 } | |
| 10540 | |
| 10541 for ( ; i < length; i++ ) { | |
| 10542 // Only deal with non-null/undefined values | |
| 10543 if ( (options = arguments[ i ]) != null ) { | |
| 10544 // Extend the base object | |
| 10545 for ( name in options ) { | |
| 10546 src = target[ name ]; | |
| 10547 copy = options[ name ]; | |
| 10548 | |
| 10549 // Prevent never-ending loop | |
| 10550 if ( target === copy ) { | |
| 10551 continue; | |
| 10552 } | |
| 10553 | |
| 10554 // Recurse if we're merging plain objects or arrays | |
| 10555 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { | |
| 10556 if ( copyIsArray ) { | |
| 10557 copyIsArray = false; | |
| 10558 clone = src && jQuery.isArray(src) ? src : []; | |
| 10559 | |
| 10560 } else { | |
| 10561 clone = src && jQuery.isPlainObject(src) ? src : {}; | |
| 10562 } | |
| 10563 | |
| 10564 // Never move original objects, clone them | |
| 10565 target[ name ] = jQuery.extend( deep, clone, copy ); | |
| 10566 | |
| 10567 // Don't bring in undefined values | |
| 10568 } else if ( copy !== undefined ) { | |
| 10569 target[ name ] = copy; | |
| 10570 } | |
| 10571 } | |
| 10572 } | |
| 10573 } | |
| 10574 | |
| 10575 // Return the modified object | |
| 10576 return target; | |
| 10577 }; | |
| 10578 | |
| 10579 jQuery.extend({ | |
| 10580 // Unique for each copy of jQuery on the page | |
| 10581 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), | |
| 10582 | |
| 10583 // Assume jQuery is ready without the ready module | |
| 10584 isReady: true, | |
| 10585 | |
| 10586 error: function( msg ) { | |
| 10587 throw new Error( msg ); | |
| 10588 }, | |
| 10589 | |
| 10590 noop: function() {}, | |
| 10591 | |
| 10592 isFunction: function( obj ) { | |
| 10593 return jQuery.type(obj) === "function"; | |
| 10594 }, | |
| 10595 | |
| 10596 isArray: Array.isArray, | |
| 10597 | |
| 10598 isWindow: function( obj ) { | |
| 10599 return obj != null && obj === obj.window; | |
| 10600 }, | |
| 10601 | |
| 10602 isNumeric: function( obj ) { | |
| 10603 // parseFloat NaNs numeric-cast false positives (null|true|false|"") | |
| 10604 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") | |
| 10605 // subtraction forces infinities to NaN | |
| 10606 // adding 1 corrects loss of precision from parseFloat (#15100) | |
| 10607 return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0; | |
| 10608 }, | |
| 10609 | |
| 10610 isPlainObject: function( obj ) { | |
| 10611 // Not plain objects: | |
| 10612 // - Any object or value whose internal [[Class]] property is not "[object Object]" | |
| 10613 // - DOM nodes | |
| 10614 // - window | |
| 10615 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { | |
| 10616 return false; | |
| 10617 } | |
| 10618 | |
| 10619 if ( obj.constructor && | |
| 10620 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) { | |
| 10621 return false; | |
| 10622 } | |
| 10623 | |
| 10624 // If the function hasn't returned already, we're confident that | |
| 10625 // |obj| is a plain object, created by {} or constructed with new Object | |
| 10626 return true; | |
| 10627 }, | |
| 10628 | |
| 10629 isEmptyObject: function( obj ) { | |
| 10630 var name; | |
| 10631 for ( name in obj ) { | |
| 10632 return false; | |
| 10633 } | |
| 10634 return true; | |
| 10635 }, | |
| 10636 | |
| 10637 type: function( obj ) { | |
| 10638 if ( obj == null ) { | |
| 10639 return obj + ""; | |
| 10640 } | |
| 10641 // Support: Android<4.0, iOS<6 (functionish RegExp) | |
| 10642 return typeof obj === "object" || typeof obj === "function" ? | |
| 10643 class2type[ toString.call(obj) ] || "object" : | |
| 10644 typeof obj; | |
| 10645 }, | |
| 10646 | |
| 10647 // Evaluates a script in a global context | |
| 10648 globalEval: function( code ) { | |
| 10649 var script, | |
| 10650 indirect = eval; | |
| 10651 | |
| 10652 code = jQuery.trim( code ); | |
| 10653 | |
| 10654 if ( code ) { | |
| 10655 // If the code includes a valid, prologue position | |
| 10656 // strict mode pragma, execute code by injecting a | |
| 10657 // script tag into the document. | |
| 10658 if ( code.indexOf("use strict") === 1 ) { | |
| 10659 script = document.createElement("script"); | |
| 10660 script.text = code; | |
| 10661 document.head.appendChild( script ).parentNode.removeChild( script ); | |
| 10662 } else { | |
| 10663 // Otherwise, avoid the DOM node creation, insertion | |
| 10664 // and removal by using an indirect global eval | |
| 10665 indirect( code ); | |
| 10666 } | |
| 10667 } | |
| 10668 }, | |
| 10669 | |
| 10670 // Convert dashed to camelCase; used by the css and data modules | |
| 10671 // Support: IE9-11+ | |
| 10672 // Microsoft forgot to hump their vendor prefix (#9572) | |
| 10673 camelCase: function( string ) { | |
| 10674 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); | |
| 10675 }, | |
| 10676 | |
| 10677 nodeName: function( elem, name ) { | |
| 10678 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); | |
| 10679 }, | |
| 10680 | |
| 10681 // args is for internal usage only | |
| 10682 each: function( obj, callback, args ) { | |
| 10683 var value, | |
| 10684 i = 0, | |
| 10685 length = obj.length, | |
| 10686 isArray = isArraylike( obj ); | |
| 10687 | |
| 10688 if ( args ) { | |
| 10689 if ( isArray ) { | |
| 10690 for ( ; i < length; i++ ) { | |
| 10691 value = callback.apply( obj[ i ], args ); | |
| 10692 | |
| 10693 if ( value === false ) { | |
| 10694 break; | |
| 10695 } | |
| 10696 } | |
| 10697 } else { | |
| 10698 for ( i in obj ) { | |
| 10699 value = callback.apply( obj[ i ], args ); | |
| 10700 | |
| 10701 if ( value === false ) { | |
| 10702 break; | |
| 10703 } | |
| 10704 } | |
| 10705 } | |
| 10706 | |
| 10707 // A special, fast, case for the most common use of each | |
| 10708 } else { | |
| 10709 if ( isArray ) { | |
| 10710 for ( ; i < length; i++ ) { | |
| 10711 value = callback.call( obj[ i ], i, obj[ i ] ); | |
| 10712 | |
| 10713 if ( value === false ) { | |
| 10714 break; | |
| 10715 } | |
| 10716 } | |
| 10717 } else { | |
| 10718 for ( i in obj ) { | |
| 10719 value = callback.call( obj[ i ], i, obj[ i ] ); | |
| 10720 | |
| 10721 if ( value === false ) { | |
| 10722 break; | |
| 10723 } | |
| 10724 } | |
| 10725 } | |
| 10726 } | |
| 10727 | |
| 10728 return obj; | |
| 10729 }, | |
| 10730 | |
| 10731 // Support: Android<4.1 | |
| 10732 trim: function( text ) { | |
| 10733 return text == null ? | |
| 10734 "" : | |
| 10735 ( text + "" ).replace( rtrim, "" ); | |
| 10736 }, | |
| 10737 | |
| 10738 // results is for internal usage only | |
| 10739 makeArray: function( arr, results ) { | |
| 10740 var ret = results || []; | |
| 10741 | |
| 10742 if ( arr != null ) { | |
| 10743 if ( isArraylike( Object(arr) ) ) { | |
| 10744 jQuery.merge( ret, | |
| 10745 typeof arr === "string" ? | |
| 10746 [ arr ] : arr | |
| 10747 ); | |
| 10748 } else { | |
| 10749 push.call( ret, arr ); | |
| 10750 } | |
| 10751 } | |
| 10752 | |
| 10753 return ret; | |
| 10754 }, | |
| 10755 | |
| 10756 inArray: function( elem, arr, i ) { | |
| 10757 return arr == null ? -1 : indexOf.call( arr, elem, i ); | |
| 10758 }, | |
| 10759 | |
| 10760 merge: function( first, second ) { | |
| 10761 var len = +second.length, | |
| 10762 j = 0, | |
| 10763 i = first.length; | |
| 10764 | |
| 10765 for ( ; j < len; j++ ) { | |
| 10766 first[ i++ ] = second[ j ]; | |
| 10767 } | |
| 10768 | |
| 10769 first.length = i; | |
| 10770 | |
| 10771 return first; | |
| 10772 }, | |
| 10773 | |
| 10774 grep: function( elems, callback, invert ) { | |
| 10775 var callbackInverse, | |
| 10776 matches = [], | |
| 10777 i = 0, | |
| 10778 length = elems.length, | |
| 10779 callbackExpect = !invert; | |
| 10780 | |
| 10781 // Go through the array, only saving the items | |
| 10782 // that pass the validator function | |
| 10783 for ( ; i < length; i++ ) { | |
| 10784 callbackInverse = !callback( elems[ i ], i ); | |
| 10785 if ( callbackInverse !== callbackExpect ) { | |
| 10786 matches.push( elems[ i ] ); | |
| 10787 } | |
| 10788 } | |
| 10789 | |
| 10790 return matches; | |
| 10791 }, | |
| 10792 | |
| 10793 // arg is for internal usage only | |
| 10794 map: function( elems, callback, arg ) { | |
| 10795 var value, | |
| 10796 i = 0, | |
| 10797 length = elems.length, | |
| 10798 isArray = isArraylike( elems ), | |
| 10799 ret = []; | |
| 10800 | |
| 10801 // Go through the array, translating each of the items to their new values | |
| 10802 if ( isArray ) { | |
| 10803 for ( ; i < length; i++ ) { | |
| 10804 value = callback( elems[ i ], i, arg ); | |
| 10805 | |
| 10806 if ( value != null ) { | |
| 10807 ret.push( value ); | |
| 10808 } | |
| 10809 } | |
| 10810 | |
| 10811 // Go through every key on the object, | |
| 10812 } else { | |
| 10813 for ( i in elems ) { | |
| 10814 value = callback( elems[ i ], i, arg ); | |
| 10815 | |
| 10816 if ( value != null ) { | |
| 10817 ret.push( value ); | |
| 10818 } | |
| 10819 } | |
| 10820 } | |
| 10821 | |
| 10822 // Flatten any nested arrays | |
| 10823 return concat.apply( [], ret ); | |
| 10824 }, | |
| 10825 | |
| 10826 // A global GUID counter for objects | |
| 10827 guid: 1, | |
| 10828 | |
| 10829 // Bind a function to a context, optionally partially applying any | |
| 10830 // arguments. | |
| 10831 proxy: function( fn, context ) { | |
| 10832 var tmp, args, proxy; | |
| 10833 | |
| 10834 if ( typeof context === "string" ) { | |
| 10835 tmp = fn[ context ]; | |
| 10836 context = fn; | |
| 10837 fn = tmp; | |
| 10838 } | |
| 10839 | |
| 10840 // Quick check to determine if target is callable, in the spec | |
| 10841 // this throws a TypeError, but we will just return undefined. | |
| 10842 if ( !jQuery.isFunction( fn ) ) { | |
| 10843 return undefined; | |
| 10844 } | |
| 10845 | |
| 10846 // Simulated bind | |
| 10847 args = slice.call( arguments, 2 ); | |
| 10848 proxy = function() { | |
| 10849 return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); | |
| 10850 }; | |
| 10851 | |
| 10852 // Set the guid of unique handler to the same of original handler, so it can be removed | |
| 10853 proxy.guid = fn.guid = fn.guid || jQuery.guid++; | |
| 10854 | |
| 10855 return proxy; | |
| 10856 }, | |
| 10857 | |
| 10858 now: Date.now, | |
| 10859 | |
| 10860 // jQuery.support is not used in Core but other projects attach their | |
| 10861 // properties to it so it needs to exist. | |
| 10862 support: support | |
| 10863 }); | |
| 10864 | |
| 10865 // Populate the class2type map | |
| 10866 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { | |
| 10867 class2type[ "[object " + name + "]" ] = name.toLowerCase(); | |
| 10868 }); | |
| 10869 | |
| 10870 function isArraylike( obj ) { | |
| 10871 | |
| 10872 // Support: iOS 8.2 (not reproducible in simulator) | |
| 10873 // `in` check used to prevent JIT error (gh-2145) | |
| 10874 // hasOwn isn't used here due to false negatives | |
| 10875 // regarding Nodelist length in IE | |
| 10876 var length = "length" in obj && obj.length, | |
| 10877 type = jQuery.type( obj ); | |
| 10878 | |
| 10879 if ( type === "function" || jQuery.isWindow( obj ) ) { | |
| 10880 return false; | |
| 10881 } | |
| 10882 | |
| 10883 if ( obj.nodeType === 1 && length ) { | |
| 10884 return true; | |
| 10885 } | |
| 10886 | |
| 10887 return type === "array" || length === 0 || | |
| 10888 typeof length === "number" && length > 0 && ( length - 1 ) in obj; | |
| 10889 } | |
| 10890 var Sizzle = | |
| 10891 /*! | |
| 10892 * Sizzle CSS Selector Engine v2.2.0-pre | |
| 10893 * http://sizzlejs.com/ | |
| 10894 * | |
| 10895 * Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors | |
| 10896 * Released under the MIT license | |
| 10897 * http://jquery.org/license | |
| 10898 * | |
| 10899 * Date: 2014-12-16 | |
| 10900 */ | |
| 10901 (function( window ) { | |
| 10902 | |
| 10903 var i, | |
| 10904 support, | |
| 10905 Expr, | |
| 10906 getText, | |
| 10907 isXML, | |
| 10908 tokenize, | |
| 10909 compile, | |
| 10910 select, | |
| 10911 outermostContext, | |
| 10912 sortInput, | |
| 10913 hasDuplicate, | |
| 10914 | |
| 10915 // Local document vars | |
| 10916 setDocument, | |
| 10917 document, | |
| 10918 docElem, | |
| 10919 documentIsHTML, | |
| 10920 rbuggyQSA, | |
| 10921 rbuggyMatches, | |
| 10922 matches, | |
| 10923 contains, | |
| 10924 | |
| 10925 // Instance-specific data | |
| 10926 expando = "sizzle" + 1 * new Date(), | |
| 10927 preferredDoc = window.document, | |
| 10928 dirruns = 0, | |
| 10929 done = 0, | |
| 10930 classCache = createCache(), | |
| 10931 tokenCache = createCache(), | |
| 10932 compilerCache = createCache(), | |
| 10933 sortOrder = function( a, b ) { | |
| 10934 if ( a === b ) { | |
| 10935 hasDuplicate = true; | |
| 10936 } | |
| 10937 return 0; | |
| 10938 }, | |
| 10939 | |
| 10940 // General-purpose constants | |
| 10941 MAX_NEGATIVE = 1 << 31, | |
| 10942 | |
| 10943 // Instance methods | |
| 10944 hasOwn = ({}).hasOwnProperty, | |
| 10945 arr = [], | |
| 10946 pop = arr.pop, | |
| 10947 push_native = arr.push, | |
| 10948 push = arr.push, | |
| 10949 slice = arr.slice, | |
| 10950 // Use a stripped-down indexOf as it's faster than native | |
| 10951 // http://jsperf.com/thor-indexof-vs-for/5 | |
| 10952 indexOf = function( list, elem ) { | |
| 10953 var i = 0, | |
| 10954 len = list.length; | |
| 10955 for ( ; i < len; i++ ) { | |
| 10956 if ( list[i] === elem ) { | |
| 10957 return i; | |
| 10958 } | |
| 10959 } | |
| 10960 return -1; | |
| 10961 }, | |
| 10962 | |
| 10963 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", | |
| 10964 | |
| 10965 // Regular expressions | |
| 10966 | |
| 10967 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace | |
| 10968 whitespace = "[\\x20\\t\\r\\n\\f]", | |
| 10969 // http://www.w3.org/TR/css3-syntax/#characters | |
| 10970 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", | |
| 10971 | |
| 10972 // Loosely modeled on CSS identifier characters | |
| 10973 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors | |
| 10974 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier | |
| 10975 identifier = characterEncoding.replace( "w", "w#" ), | |
| 10976 | |
| 10977 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors | |
| 10978 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace + | |
| 10979 // Operator (capture 2) | |
| 10980 "*([*^$|!~]?=)" + whitespace + | |
| 10981 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" | |
| 10982 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + | |
| 10983 "*\\]", | |
| 10984 | |
| 10985 pseudos = ":(" + characterEncoding + ")(?:\\((" + | |
| 10986 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: | |
| 10987 // 1. quoted (capture 3; capture 4 or capture 5) | |
| 10988 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + | |
| 10989 // 2. simple (capture 6) | |
| 10990 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + | |
| 10991 // 3. anything else (capture 2) | |
| 10992 ".*" + | |
| 10993 ")\\)|)", | |
| 10994 | |
| 10995 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter | |
| 10996 rwhitespace = new RegExp( whitespace + "+", "g" ), | |
| 10997 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), | |
| 10998 | |
| 10999 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), | |
| 11000 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), | |
| 11001 | |
| 11002 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), | |
| 11003 | |
| 11004 rpseudo = new RegExp( pseudos ), | |
| 11005 ridentifier = new RegExp( "^" + identifier + "$" ), | |
| 11006 | |
| 11007 matchExpr = { | |
| 11008 "ID": new RegExp( "^#(" + characterEncoding + ")" ), | |
| 11009 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), | |
| 11010 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), | |
| 11011 "ATTR": new RegExp( "^" + attributes ), | |
| 11012 "PSEUDO": new RegExp( "^" + pseudos ), | |
| 11013 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + | |
| 11014 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + | |
| 11015 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), | |
| 11016 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), | |
| 11017 // For use in libraries implementing .is() | |
| 11018 // We use this for POS matching in `select` | |
| 11019 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + | |
| 11020 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) | |
| 11021 }, | |
| 11022 | |
| 11023 rinputs = /^(?:input|select|textarea|button)$/i, | |
| 11024 rheader = /^h\d$/i, | |
| 11025 | |
| 11026 rnative = /^[^{]+\{\s*\[native \w/, | |
| 11027 | |
| 11028 // Easily-parseable/retrievable ID or TAG or CLASS selectors | |
| 11029 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, | |
| 11030 | |
| 11031 rsibling = /[+~]/, | |
| 11032 rescape = /'|\\/g, | |
| 11033 | |
| 11034 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters | |
| 11035 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), | |
| 11036 funescape = function( _, escaped, escapedWhitespace ) { | |
| 11037 var high = "0x" + escaped - 0x10000; | |
| 11038 // NaN means non-codepoint | |
| 11039 // Support: Firefox<24 | |
| 11040 // Workaround erroneous numeric interpretation of +"0x" | |
| 11041 return high !== high || escapedWhitespace ? | |
| 11042 escaped : | |
| 11043 high < 0 ? | |
| 11044 // BMP codepoint | |
| 11045 String.fromCharCode( high + 0x10000 ) : | |
| 11046 // Supplemental Plane codepoint (surrogate pair) | |
| 11047 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); | |
| 11048 }, | |
| 11049 | |
| 11050 // Used for iframes | |
| 11051 // See setDocument() | |
| 11052 // Removing the function wrapper causes a "Permission Denied" | |
| 11053 // error in IE | |
| 11054 unloadHandler = function() { | |
| 11055 setDocument(); | |
| 11056 }; | |
| 11057 | |
| 11058 // Optimize for push.apply( _, NodeList ) | |
| 11059 try { | |
| 11060 push.apply( | |
| 11061 (arr = slice.call( preferredDoc.childNodes )), | |
| 11062 preferredDoc.childNodes | |
| 11063 ); | |
| 11064 // Support: Android<4.0 | |
| 11065 // Detect silently failing push.apply | |
| 11066 arr[ preferredDoc.childNodes.length ].nodeType; | |
| 11067 } catch ( e ) { | |
| 11068 push = { apply: arr.length ? | |
| 11069 | |
| 11070 // Leverage slice if possible | |
| 11071 function( target, els ) { | |
| 11072 push_native.apply( target, slice.call(els) ); | |
| 11073 } : | |
| 11074 | |
| 11075 // Support: IE<9 | |
| 11076 // Otherwise append directly | |
| 11077 function( target, els ) { | |
| 11078 var j = target.length, | |
| 11079 i = 0; | |
| 11080 // Can't trust NodeList.length | |
| 11081 while ( (target[j++] = els[i++]) ) {} | |
| 11082 target.length = j - 1; | |
| 11083 } | |
| 11084 }; | |
| 11085 } | |
| 11086 | |
| 11087 function Sizzle( selector, context, results, seed ) { | |
| 11088 var match, elem, m, nodeType, | |
| 11089 // QSA vars | |
| 11090 i, groups, old, nid, newContext, newSelector; | |
| 11091 | |
| 11092 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { | |
| 11093 setDocument( context ); | |
| 11094 } | |
| 11095 | |
| 11096 context = context || document; | |
| 11097 results = results || []; | |
| 11098 nodeType = context.nodeType; | |
| 11099 | |
| 11100 if ( typeof selector !== "string" || !selector || | |
| 11101 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { | |
| 11102 | |
| 11103 return results; | |
| 11104 } | |
| 11105 | |
| 11106 if ( !seed && documentIsHTML ) { | |
| 11107 | |
| 11108 // Try to shortcut find operations when possible (e.g., not under DocumentFragment) | |
| 11109 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { | |
| 11110 // Speed-up: Sizzle("#ID") | |
| 11111 if ( (m = match[1]) ) { | |
| 11112 if ( nodeType === 9 ) { | |
| 11113 elem = context.getElementById( m ); | |
| 11114 // Check parentNode to catch when Blackberry 4.6 returns | |
| 11115 // nodes that are no longer in the document (jQuery #6963) | |
| 11116 if ( elem && elem.parentNode ) { | |
| 11117 // Handle the case where IE, Opera, and Webkit return items | |
| 11118 // by name instead of ID | |
| 11119 if ( elem.id === m ) { | |
| 11120 results.push( elem ); | |
| 11121 return results; | |
| 11122 } | |
| 11123 } else { | |
| 11124 return results; | |
| 11125 } | |
| 11126 } else { | |
| 11127 // Context is not a document | |
| 11128 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && | |
| 11129 contains( context, elem ) && elem.id === m ) { | |
| 11130 results.push( elem ); | |
| 11131 return results; | |
| 11132 } | |
| 11133 } | |
| 11134 | |
| 11135 // Speed-up: Sizzle("TAG") | |
| 11136 } else if ( match[2] ) { | |
| 11137 push.apply( results, context.getElementsByTagName( selector ) ); | |
| 11138 return results; | |
| 11139 | |
| 11140 // Speed-up: Sizzle(".CLASS") | |
| 11141 } else if ( (m = match[3]) && support.getElementsByClassName ) { | |
| 11142 push.apply( results, context.getElementsByClassName( m ) ); | |
| 11143 return results; | |
| 11144 } | |
| 11145 } | |
| 11146 | |
| 11147 // QSA path | |
| 11148 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { | |
| 11149 nid = old = expando; | |
| 11150 newContext = context; | |
| 11151 newSelector = nodeType !== 1 && selector; | |
| 11152 | |
| 11153 // qSA works strangely on Element-rooted queries | |
| 11154 // We can work around this by specifying an extra ID on the root | |
| 11155 // and working up from there (Thanks to Andrew Dupont for the technique) | |
| 11156 // IE 8 doesn't work on object elements | |
| 11157 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { | |
| 11158 groups = tokenize( selector ); | |
| 11159 | |
| 11160 if ( (old = context.getAttribute("id")) ) { | |
| 11161 nid = old.replace( rescape, "\\$&" ); | |
| 11162 } else { | |
| 11163 context.setAttribute( "id", nid ); | |
| 11164 } | |
| 11165 nid = "[id='" + nid + "'] "; | |
| 11166 | |
| 11167 i = groups.length; | |
| 11168 while ( i-- ) { | |
| 11169 groups[i] = nid + toSelector( groups[i] ); | |
| 11170 } | |
| 11171 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context; | |
| 11172 newSelector = groups.join(","); | |
| 11173 } | |
| 11174 | |
| 11175 if ( newSelector ) { | |
| 11176 try { | |
| 11177 push.apply( results, | |
| 11178 newContext.querySelectorAll( newSelector ) | |
| 11179 ); | |
| 11180 return results; | |
| 11181 } catch(qsaError) { | |
| 11182 } finally { | |
| 11183 if ( !old ) { | |
| 11184 context.removeAttribute("id"); | |
| 11185 } | |
| 11186 } | |
| 11187 } | |
| 11188 } | |
| 11189 } | |
| 11190 | |
| 11191 // All others | |
| 11192 return select( selector.replace( rtrim, "$1" ), context, results, seed ); | |
| 11193 } | |
| 11194 | |
| 11195 /** | |
| 11196 * Create key-value caches of limited size | |
| 11197 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with | |
| 11198 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) | |
| 11199 * deleting the oldest entry | |
| 11200 */ | |
| 11201 function createCache() { | |
| 11202 var keys = []; | |
| 11203 | |
| 11204 function cache( key, value ) { | |
| 11205 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) | |
| 11206 if ( keys.push( key + " " ) > Expr.cacheLength ) { | |
| 11207 // Only keep the most recent entries | |
| 11208 delete cache[ keys.shift() ]; | |
| 11209 } | |
| 11210 return (cache[ key + " " ] = value); | |
| 11211 } | |
| 11212 return cache; | |
| 11213 } | |
| 11214 | |
| 11215 /** | |
| 11216 * Mark a function for special use by Sizzle | |
| 11217 * @param {Function} fn The function to mark | |
| 11218 */ | |
| 11219 function markFunction( fn ) { | |
| 11220 fn[ expando ] = true; | |
| 11221 return fn; | |
| 11222 } | |
| 11223 | |
| 11224 /** | |
| 11225 * Support testing using an element | |
| 11226 * @param {Function} fn Passed the created div and expects a boolean result | |
| 11227 */ | |
| 11228 function assert( fn ) { | |
| 11229 var div = document.createElement("div"); | |
| 11230 | |
| 11231 try { | |
| 11232 return !!fn( div ); | |
| 11233 } catch (e) { | |
| 11234 return false; | |
| 11235 } finally { | |
| 11236 // Remove from its parent by default | |
| 11237 if ( div.parentNode ) { | |
| 11238 div.parentNode.removeChild( div ); | |
| 11239 } | |
| 11240 // release memory in IE | |
| 11241 div = null; | |
| 11242 } | |
| 11243 } | |
| 11244 | |
| 11245 /** | |
| 11246 * Adds the same handler for all of the specified attrs | |
| 11247 * @param {String} attrs Pipe-separated list of attributes | |
| 11248 * @param {Function} handler The method that will be applied | |
| 11249 */ | |
| 11250 function addHandle( attrs, handler ) { | |
| 11251 var arr = attrs.split("|"), | |
| 11252 i = attrs.length; | |
| 11253 | |
| 11254 while ( i-- ) { | |
| 11255 Expr.attrHandle[ arr[i] ] = handler; | |
| 11256 } | |
| 11257 } | |
| 11258 | |
| 11259 /** | |
| 11260 * Checks document order of two siblings | |
| 11261 * @param {Element} a | |
| 11262 * @param {Element} b | |
| 11263 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b | |
| 11264 */ | |
| 11265 function siblingCheck( a, b ) { | |
| 11266 var cur = b && a, | |
| 11267 diff = cur && a.nodeType === 1 && b.nodeType === 1 && | |
| 11268 ( ~b.sourceIndex || MAX_NEGATIVE ) - | |
| 11269 ( ~a.sourceIndex || MAX_NEGATIVE ); | |
| 11270 | |
| 11271 // Use IE sourceIndex if available on both nodes | |
| 11272 if ( diff ) { | |
| 11273 return diff; | |
| 11274 } | |
| 11275 | |
| 11276 // Check if b follows a | |
| 11277 if ( cur ) { | |
| 11278 while ( (cur = cur.nextSibling) ) { | |
| 11279 if ( cur === b ) { | |
| 11280 return -1; | |
| 11281 } | |
| 11282 } | |
| 11283 } | |
| 11284 | |
| 11285 return a ? 1 : -1; | |
| 11286 } | |
| 11287 | |
| 11288 /** | |
| 11289 * Returns a function to use in pseudos for input types | |
| 11290 * @param {String} type | |
| 11291 */ | |
| 11292 function createInputPseudo( type ) { | |
| 11293 return function( elem ) { | |
| 11294 var name = elem.nodeName.toLowerCase(); | |
| 11295 return name === "input" && elem.type === type; | |
| 11296 }; | |
| 11297 } | |
| 11298 | |
| 11299 /** | |
| 11300 * Returns a function to use in pseudos for buttons | |
| 11301 * @param {String} type | |
| 11302 */ | |
| 11303 function createButtonPseudo( type ) { | |
| 11304 return function( elem ) { | |
| 11305 var name = elem.nodeName.toLowerCase(); | |
| 11306 return (name === "input" || name === "button") && elem.type === type; | |
| 11307 }; | |
| 11308 } | |
| 11309 | |
| 11310 /** | |
| 11311 * Returns a function to use in pseudos for positionals | |
| 11312 * @param {Function} fn | |
| 11313 */ | |
| 11314 function createPositionalPseudo( fn ) { | |
| 11315 return markFunction(function( argument ) { | |
| 11316 argument = +argument; | |
| 11317 return markFunction(function( seed, matches ) { | |
| 11318 var j, | |
| 11319 matchIndexes = fn( [], seed.length, argument ), | |
| 11320 i = matchIndexes.length; | |
| 11321 | |
| 11322 // Match elements found at the specified indexes | |
| 11323 while ( i-- ) { | |
| 11324 if ( seed[ (j = matchIndexes[i]) ] ) { | |
| 11325 seed[j] = !(matches[j] = seed[j]); | |
| 11326 } | |
| 11327 } | |
| 11328 }); | |
| 11329 }); | |
| 11330 } | |
| 11331 | |
| 11332 /** | |
| 11333 * Checks a node for validity as a Sizzle context | |
| 11334 * @param {Element|Object=} context | |
| 11335 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value | |
| 11336 */ | |
| 11337 function testContext( context ) { | |
| 11338 return context && typeof context.getElementsByTagName !== "undefined" && context; | |
| 11339 } | |
| 11340 | |
| 11341 // Expose support vars for convenience | |
| 11342 support = Sizzle.support = {}; | |
| 11343 | |
| 11344 /** | |
| 11345 * Detects XML nodes | |
| 11346 * @param {Element|Object} elem An element or a document | |
| 11347 * @returns {Boolean} True iff elem is a non-HTML XML node | |
| 11348 */ | |
| 11349 isXML = Sizzle.isXML = function( elem ) { | |
| 11350 // documentElement is verified for cases where it doesn't yet exist | |
| 11351 // (such as loading iframes in IE - #4833) | |
| 11352 var documentElement = elem && (elem.ownerDocument || elem).documentElement; | |
| 11353 return documentElement ? documentElement.nodeName !== "HTML" : false; | |
| 11354 }; | |
| 11355 | |
| 11356 /** | |
| 11357 * Sets document-related variables once based on the current document | |
| 11358 * @param {Element|Object} [doc] An element or document object to use to set the document | |
| 11359 * @returns {Object} Returns the current document | |
| 11360 */ | |
| 11361 setDocument = Sizzle.setDocument = function( node ) { | |
| 11362 var hasCompare, parent, | |
| 11363 doc = node ? node.ownerDocument || node : preferredDoc; | |
| 11364 | |
| 11365 // If no document and documentElement is available, return | |
| 11366 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { | |
| 11367 return document; | |
| 11368 } | |
| 11369 | |
| 11370 // Set our document | |
| 11371 document = doc; | |
| 11372 docElem = doc.documentElement; | |
| 11373 parent = doc.defaultView; | |
| 11374 | |
| 11375 // Support: IE>8 | |
| 11376 // If iframe document is assigned to "document" variable and if iframe has been reloaded, | |
| 11377 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 | |
| 11378 // IE6-8 do not support the defaultView property so parent will be undefined | |
| 11379 if ( parent && parent !== parent.top ) { | |
| 11380 // IE11 does not have attachEvent, so all must suffer | |
| 11381 if ( parent.addEventListener ) { | |
| 11382 parent.addEventListener( "unload", unloadHandler, false ); | |
| 11383 } else if ( parent.attachEvent ) { | |
| 11384 parent.attachEvent( "onunload", unloadHandler ); | |
| 11385 } | |
| 11386 } | |
| 11387 | |
| 11388 /* Support tests | |
| 11389 ---------------------------------------------------------------------- */ | |
| 11390 documentIsHTML = !isXML( doc ); | |
| 11391 | |
| 11392 /* Attributes | |
| 11393 ---------------------------------------------------------------------- */ | |
| 11394 | |
| 11395 // Support: IE<8 | |
| 11396 // Verify that getAttribute really returns attributes and not properties | |
| 11397 // (excepting IE8 booleans) | |
| 11398 support.attributes = assert(function( div ) { | |
| 11399 div.className = "i"; | |
| 11400 return !div.getAttribute("className"); | |
| 11401 }); | |
| 11402 | |
| 11403 /* getElement(s)By* | |
| 11404 ---------------------------------------------------------------------- */ | |
| 11405 | |
| 11406 // Check if getElementsByTagName("*") returns only elements | |
| 11407 support.getElementsByTagName = assert(function( div ) { | |
| 11408 div.appendChild( doc.createComment("") ); | |
| 11409 return !div.getElementsByTagName("*").length; | |
| 11410 }); | |
| 11411 | |
| 11412 // Support: IE<9 | |
| 11413 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ); | |
| 11414 | |
| 11415 // Support: IE<10 | |
| 11416 // Check if getElementById returns elements by name | |
| 11417 // The broken getElementById methods don't pick up programatically-set names, | |
| 11418 // so use a roundabout getElementsByName test | |
| 11419 support.getById = assert(function( div ) { | |
| 11420 docElem.appendChild( div ).id = expando; | |
| 11421 return !doc.getElementsByName || !doc.getElementsByName( expando ).length; | |
| 11422 }); | |
| 11423 | |
| 11424 // ID find and filter | |
| 11425 if ( support.getById ) { | |
| 11426 Expr.find["ID"] = function( id, context ) { | |
| 11427 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { | |
| 11428 var m = context.getElementById( id ); | |
| 11429 // Check parentNode to catch when Blackberry 4.6 returns | |
| 11430 // nodes that are no longer in the document #6963 | |
| 11431 return m && m.parentNode ? [ m ] : []; | |
| 11432 } | |
| 11433 }; | |
| 11434 Expr.filter["ID"] = function( id ) { | |
| 11435 var attrId = id.replace( runescape, funescape ); | |
| 11436 return function( elem ) { | |
| 11437 return elem.getAttribute("id") === attrId; | |
| 11438 }; | |
| 11439 }; | |
| 11440 } else { | |
| 11441 // Support: IE6/7 | |
| 11442 // getElementById is not reliable as a find shortcut | |
| 11443 delete Expr.find["ID"]; | |
| 11444 | |
| 11445 Expr.filter["ID"] = function( id ) { | |
| 11446 var attrId = id.replace( runescape, funescape ); | |
| 11447 return function( elem ) { | |
| 11448 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); | |
| 11449 return node && node.value === attrId; | |
| 11450 }; | |
| 11451 }; | |
| 11452 } | |
| 11453 | |
| 11454 // Tag | |
| 11455 Expr.find["TAG"] = support.getElementsByTagName ? | |
| 11456 function( tag, context ) { | |
| 11457 if ( typeof context.getElementsByTagName !== "undefined" ) { | |
| 11458 return context.getElementsByTagName( tag ); | |
| 11459 | |
| 11460 // DocumentFragment nodes don't have gEBTN | |
| 11461 } else if ( support.qsa ) { | |
| 11462 return context.querySelectorAll( tag ); | |
| 11463 } | |
| 11464 } : | |
| 11465 | |
| 11466 function( tag, context ) { | |
| 11467 var elem, | |
| 11468 tmp = [], | |
| 11469 i = 0, | |
| 11470 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too | |
| 11471 results = context.getElementsByTagName( tag ); | |
| 11472 | |
| 11473 // Filter out possible comments | |
| 11474 if ( tag === "*" ) { | |
| 11475 while ( (elem = results[i++]) ) { | |
| 11476 if ( elem.nodeType === 1 ) { | |
| 11477 tmp.push( elem ); | |
| 11478 } | |
| 11479 } | |
| 11480 | |
| 11481 return tmp; | |
| 11482 } | |
| 11483 return results; | |
| 11484 }; | |
| 11485 | |
| 11486 // Class | |
| 11487 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { | |
| 11488 if ( documentIsHTML ) { | |
| 11489 return context.getElementsByClassName( className ); | |
| 11490 } | |
| 11491 }; | |
| 11492 | |
| 11493 /* QSA/matchesSelector | |
| 11494 ---------------------------------------------------------------------- */ | |
| 11495 | |
| 11496 // QSA and matchesSelector support | |
| 11497 | |
| 11498 // matchesSelector(:active) reports false when true (IE9/Opera 11.5) | |
| 11499 rbuggyMatches = []; | |
| 11500 | |
| 11501 // qSa(:focus) reports false when true (Chrome 21) | |
| 11502 // We allow this because of a bug in IE8/9 that throws an error | |
| 11503 // whenever `document.activeElement` is accessed on an iframe | |
| 11504 // So, we allow :focus to pass through QSA all the time to avoid the IE error | |
| 11505 // See http://bugs.jquery.com/ticket/13378 | |
| 11506 rbuggyQSA = []; | |
| 11507 | |
| 11508 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { | |
| 11509 // Build QSA regex | |
| 11510 // Regex strategy adopted from Diego Perini | |
| 11511 assert(function( div ) { | |
| 11512 // Select is set to empty string on purpose | |
| 11513 // This is to test IE's treatment of not explicitly | |
| 11514 // setting a boolean content attribute, | |
| 11515 // since its presence should be enough | |
| 11516 // http://bugs.jquery.com/ticket/12359 | |
| 11517 docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" + | |
| 11518 "<select id='" + expando + "-\f]' msallowcapture=''>" + | |
| 11519 "<option selected=''></option></select>"; | |
| 11520 | |
| 11521 // Support: IE8, Opera 11-12.16 | |
| 11522 // Nothing should be selected when empty strings follow ^= or $= or *= | |
| 11523 // The test attribute must be unknown in Opera but "safe" for WinRT | |
| 11524 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section | |
| 11525 if ( div.querySelectorAll("[msallowcapture^='']").length ) { | |
| 11526 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); | |
| 11527 } | |
| 11528 | |
| 11529 // Support: IE8 | |
| 11530 // Boolean attributes and "value" are not treated correctly | |
| 11531 if ( !div.querySelectorAll("[selected]").length ) { | |
| 11532 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); | |
| 11533 } | |
| 11534 | |
| 11535 // Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+ | |
| 11536 if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { | |
| 11537 rbuggyQSA.push("~="); | |
| 11538 } | |
| 11539 | |
| 11540 // Webkit/Opera - :checked should return selected option elements | |
| 11541 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked | |
| 11542 // IE8 throws error here and will not see later tests | |
| 11543 if ( !div.querySelectorAll(":checked").length ) { | |
| 11544 rbuggyQSA.push(":checked"); | |
| 11545 } | |
| 11546 | |
| 11547 // Support: Safari 8+, iOS 8+ | |
| 11548 // https://bugs.webkit.org/show_bug.cgi?id=136851 | |
| 11549 // In-page `selector#id sibing-combinator selector` fails | |
| 11550 if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { | |
| 11551 rbuggyQSA.push(".#.+[+~]"); | |
| 11552 } | |
| 11553 }); | |
| 11554 | |
| 11555 assert(function( div ) { | |
| 11556 // Support: Windows 8 Native Apps | |
| 11557 // The type and name attributes are restricted during .innerHTML assignment | |
| 11558 var input = doc.createElement("input"); | |
| 11559 input.setAttribute( "type", "hidden" ); | |
| 11560 div.appendChild( input ).setAttribute( "name", "D" ); | |
| 11561 | |
| 11562 // Support: IE8 | |
| 11563 // Enforce case-sensitivity of name attribute | |
| 11564 if ( div.querySelectorAll("[name=d]").length ) { | |
| 11565 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); | |
| 11566 } | |
| 11567 | |
| 11568 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) | |
| 11569 // IE8 throws error here and will not see later tests | |
| 11570 if ( !div.querySelectorAll(":enabled").length ) { | |
| 11571 rbuggyQSA.push( ":enabled", ":disabled" ); | |
| 11572 } | |
| 11573 | |
| 11574 // Opera 10-11 does not throw on post-comma invalid pseudos | |
| 11575 div.querySelectorAll("*,:x"); | |
| 11576 rbuggyQSA.push(",.*:"); | |
| 11577 }); | |
| 11578 } | |
| 11579 | |
| 11580 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || | |
| 11581 docElem.webkitMatchesSelector || | |
| 11582 docElem.mozMatchesSelector || | |
| 11583 docElem.oMatchesSelector || | |
| 11584 docElem.msMatchesSelector) )) ) { | |
| 11585 | |
| 11586 assert(function( div ) { | |
| 11587 // Check to see if it's possible to do matchesSelector | |
| 11588 // on a disconnected node (IE 9) | |
| 11589 support.disconnectedMatch = matches.call( div, "div" ); | |
| 11590 | |
| 11591 // This should fail with an exception | |
| 11592 // Gecko does not error, returns false instead | |
| 11593 matches.call( div, "[s!='']:x" ); | |
| 11594 rbuggyMatches.push( "!=", pseudos ); | |
| 11595 }); | |
| 11596 } | |
| 11597 | |
| 11598 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); | |
| 11599 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); | |
| 11600 | |
| 11601 /* Contains | |
| 11602 ---------------------------------------------------------------------- */ | |
| 11603 hasCompare = rnative.test( docElem.compareDocumentPosition ); | |
| 11604 | |
| 11605 // Element contains another | |
| 11606 // Purposefully does not implement inclusive descendent | |
| 11607 // As in, an element does not contain itself | |
| 11608 contains = hasCompare || rnative.test( docElem.contains ) ? | |
| 11609 function( a, b ) { | |
| 11610 var adown = a.nodeType === 9 ? a.documentElement : a, | |
| 11611 bup = b && b.parentNode; | |
| 11612 return a === bup || !!( bup && bup.nodeType === 1 && ( | |
| 11613 adown.contains ? | |
| 11614 adown.contains( bup ) : | |
| 11615 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 | |
| 11616 )); | |
| 11617 } : | |
| 11618 function( a, b ) { | |
| 11619 if ( b ) { | |
| 11620 while ( (b = b.parentNode) ) { | |
| 11621 if ( b === a ) { | |
| 11622 return true; | |
| 11623 } | |
| 11624 } | |
| 11625 } | |
| 11626 return false; | |
| 11627 }; | |
| 11628 | |
| 11629 /* Sorting | |
| 11630 ---------------------------------------------------------------------- */ | |
| 11631 | |
| 11632 // Document order sorting | |
| 11633 sortOrder = hasCompare ? | |
| 11634 function( a, b ) { | |
| 11635 | |
| 11636 // Flag for duplicate removal | |
| 11637 if ( a === b ) { | |
| 11638 hasDuplicate = true; | |
| 11639 return 0; | |
| 11640 } | |
| 11641 | |
| 11642 // Sort on method existence if only one input has compareDocumentPosition | |
| 11643 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; | |
| 11644 if ( compare ) { | |
| 11645 return compare; | |
| 11646 } | |
| 11647 | |
| 11648 // Calculate position if both inputs belong to the same document | |
| 11649 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? | |
| 11650 a.compareDocumentPosition( b ) : | |
| 11651 | |
| 11652 // Otherwise we know they are disconnected | |
| 11653 1; | |
| 11654 | |
| 11655 // Disconnected nodes | |
| 11656 if ( compare & 1 || | |
| 11657 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { | |
| 11658 | |
| 11659 // Choose the first element that is related to our preferred document | |
| 11660 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { | |
| 11661 return -1; | |
| 11662 } | |
| 11663 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { | |
| 11664 return 1; | |
| 11665 } | |
| 11666 | |
| 11667 // Maintain original order | |
| 11668 return sortInput ? | |
| 11669 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : | |
| 11670 0; | |
| 11671 } | |
| 11672 | |
| 11673 return compare & 4 ? -1 : 1; | |
| 11674 } : | |
| 11675 function( a, b ) { | |
| 11676 // Exit early if the nodes are identical | |
| 11677 if ( a === b ) { | |
| 11678 hasDuplicate = true; | |
| 11679 return 0; | |
| 11680 } | |
| 11681 | |
| 11682 var cur, | |
| 11683 i = 0, | |
| 11684 aup = a.parentNode, | |
| 11685 bup = b.parentNode, | |
| 11686 ap = [ a ], | |
| 11687 bp = [ b ]; | |
| 11688 | |
| 11689 // Parentless nodes are either documents or disconnected | |
| 11690 if ( !aup || !bup ) { | |
| 11691 return a === doc ? -1 : | |
| 11692 b === doc ? 1 : | |
| 11693 aup ? -1 : | |
| 11694 bup ? 1 : | |
| 11695 sortInput ? | |
| 11696 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : | |
| 11697 0; | |
| 11698 | |
| 11699 // If the nodes are siblings, we can do a quick check | |
| 11700 } else if ( aup === bup ) { | |
| 11701 return siblingCheck( a, b ); | |
| 11702 } | |
| 11703 | |
| 11704 // Otherwise we need full lists of their ancestors for comparison | |
| 11705 cur = a; | |
| 11706 while ( (cur = cur.parentNode) ) { | |
| 11707 ap.unshift( cur ); | |
| 11708 } | |
| 11709 cur = b; | |
| 11710 while ( (cur = cur.parentNode) ) { | |
| 11711 bp.unshift( cur ); | |
| 11712 } | |
| 11713 | |
| 11714 // Walk down the tree looking for a discrepancy | |
| 11715 while ( ap[i] === bp[i] ) { | |
| 11716 i++; | |
| 11717 } | |
| 11718 | |
| 11719 return i ? | |
| 11720 // Do a sibling check if the nodes have a common ancestor | |
| 11721 siblingCheck( ap[i], bp[i] ) : | |
| 11722 | |
| 11723 // Otherwise nodes in our document sort first | |
| 11724 ap[i] === preferredDoc ? -1 : | |
| 11725 bp[i] === preferredDoc ? 1 : | |
| 11726 0; | |
| 11727 }; | |
| 11728 | |
| 11729 return doc; | |
| 11730 }; | |
| 11731 | |
| 11732 Sizzle.matches = function( expr, elements ) { | |
| 11733 return Sizzle( expr, null, null, elements ); | |
| 11734 }; | |
| 11735 | |
| 11736 Sizzle.matchesSelector = function( elem, expr ) { | |
| 11737 // Set document vars if needed | |
| 11738 if ( ( elem.ownerDocument || elem ) !== document ) { | |
| 11739 setDocument( elem ); | |
| 11740 } | |
| 11741 | |
| 11742 // Make sure that attribute selectors are quoted | |
| 11743 expr = expr.replace( rattributeQuotes, "='$1']" ); | |
| 11744 | |
| 11745 if ( support.matchesSelector && documentIsHTML && | |
| 11746 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && | |
| 11747 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { | |
| 11748 | |
| 11749 try { | |
| 11750 var ret = matches.call( elem, expr ); | |
| 11751 | |
| 11752 // IE 9's matchesSelector returns false on disconnected nodes | |
| 11753 if ( ret || support.disconnectedMatch || | |
| 11754 // As well, disconnected nodes are said to be in a document | |
| 11755 // fragment in IE 9 | |
| 11756 elem.document && elem.document.nodeType !== 11 ) { | |
| 11757 return ret; | |
| 11758 } | |
| 11759 } catch (e) {} | |
| 11760 } | |
| 11761 | |
| 11762 return Sizzle( expr, document, null, [ elem ] ).length > 0; | |
| 11763 }; | |
| 11764 | |
| 11765 Sizzle.contains = function( context, elem ) { | |
| 11766 // Set document vars if needed | |
| 11767 if ( ( context.ownerDocument || context ) !== document ) { | |
| 11768 setDocument( context ); | |
| 11769 } | |
| 11770 return contains( context, elem ); | |
| 11771 }; | |
| 11772 | |
| 11773 Sizzle.attr = function( elem, name ) { | |
| 11774 // Set document vars if needed | |
| 11775 if ( ( elem.ownerDocument || elem ) !== document ) { | |
| 11776 setDocument( elem ); | |
| 11777 } | |
| 11778 | |
| 11779 var fn = Expr.attrHandle[ name.toLowerCase() ], | |
| 11780 // Don't get fooled by Object.prototype properties (jQuery #13807) | |
| 11781 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? | |
| 11782 fn( elem, name, !documentIsHTML ) : | |
| 11783 undefined; | |
| 11784 | |
| 11785 return val !== undefined ? | |
| 11786 val : | |
| 11787 support.attributes || !documentIsHTML ? | |
| 11788 elem.getAttribute( name ) : | |
| 11789 (val = elem.getAttributeNode(name)) && val.specified ? | |
| 11790 val.value : | |
| 11791 null; | |
| 11792 }; | |
| 11793 | |
| 11794 Sizzle.error = function( msg ) { | |
| 11795 throw new Error( "Syntax error, unrecognized expression: " + msg ); | |
| 11796 }; | |
| 11797 | |
| 11798 /** | |
| 11799 * Document sorting and removing duplicates | |
| 11800 * @param {ArrayLike} results | |
| 11801 */ | |
| 11802 Sizzle.uniqueSort = function( results ) { | |
| 11803 var elem, | |
| 11804 duplicates = [], | |
| 11805 j = 0, | |
| 11806 i = 0; | |
| 11807 | |
| 11808 // Unless we *know* we can detect duplicates, assume their presence | |
| 11809 hasDuplicate = !support.detectDuplicates; | |
| 11810 sortInput = !support.sortStable && results.slice( 0 ); | |
| 11811 results.sort( sortOrder ); | |
| 11812 | |
| 11813 if ( hasDuplicate ) { | |
| 11814 while ( (elem = results[i++]) ) { | |
| 11815 if ( elem === results[ i ] ) { | |
| 11816 j = duplicates.push( i ); | |
| 11817 } | |
| 11818 } | |
| 11819 while ( j-- ) { | |
| 11820 results.splice( duplicates[ j ], 1 ); | |
| 11821 } | |
| 11822 } | |
| 11823 | |
| 11824 // Clear input after sorting to release objects | |
| 11825 // See https://github.com/jquery/sizzle/pull/225 | |
| 11826 sortInput = null; | |
| 11827 | |
| 11828 return results; | |
| 11829 }; | |
| 11830 | |
| 11831 /** | |
| 11832 * Utility function for retrieving the text value of an array of DOM nodes | |
| 11833 * @param {Array|Element} elem | |
| 11834 */ | |
| 11835 getText = Sizzle.getText = function( elem ) { | |
| 11836 var node, | |
| 11837 ret = "", | |
| 11838 i = 0, | |
| 11839 nodeType = elem.nodeType; | |
| 11840 | |
| 11841 if ( !nodeType ) { | |
| 11842 // If no nodeType, this is expected to be an array | |
| 11843 while ( (node = elem[i++]) ) { | |
| 11844 // Do not traverse comment nodes | |
| 11845 ret += getText( node ); | |
| 11846 } | |
| 11847 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { | |
| 11848 // Use textContent for elements | |
| 11849 // innerText usage removed for consistency of new lines (jQuery #11153) | |
| 11850 if ( typeof elem.textContent === "string" ) { | |
| 11851 return elem.textContent; | |
| 11852 } else { | |
| 11853 // Traverse its children | |
| 11854 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { | |
| 11855 ret += getText( elem ); | |
| 11856 } | |
| 11857 } | |
| 11858 } else if ( nodeType === 3 || nodeType === 4 ) { | |
| 11859 return elem.nodeValue; | |
| 11860 } | |
| 11861 // Do not include comment or processing instruction nodes | |
| 11862 | |
| 11863 return ret; | |
| 11864 }; | |
| 11865 | |
| 11866 Expr = Sizzle.selectors = { | |
| 11867 | |
| 11868 // Can be adjusted by the user | |
| 11869 cacheLength: 50, | |
| 11870 | |
| 11871 createPseudo: markFunction, | |
| 11872 | |
| 11873 match: matchExpr, | |
| 11874 | |
| 11875 attrHandle: {}, | |
| 11876 | |
| 11877 find: {}, | |
| 11878 | |
| 11879 relative: { | |
| 11880 ">": { dir: "parentNode", first: true }, | |
| 11881 " ": { dir: "parentNode" }, | |
| 11882 "+": { dir: "previousSibling", first: true }, | |
| 11883 "~": { dir: "previousSibling" } | |
| 11884 }, | |
| 11885 | |
| 11886 preFilter: { | |
| 11887 "ATTR": function( match ) { | |
| 11888 match[1] = match[1].replace( runescape, funescape ); | |
| 11889 | |
| 11890 // Move the given value to match[3] whether quoted or unquoted | |
| 11891 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); | |
| 11892 | |
| 11893 if ( match[2] === "~=" ) { | |
| 11894 match[3] = " " + match[3] + " "; | |
| 11895 } | |
| 11896 | |
| 11897 return match.slice( 0, 4 ); | |
| 11898 }, | |
| 11899 | |
| 11900 "CHILD": function( match ) { | |
| 11901 /* matches from matchExpr["CHILD"] | |
| 11902 1 type (only|nth|...) | |
| 11903 2 what (child|of-type) | |
| 11904 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) | |
| 11905 4 xn-component of xn+y argument ([+-]?\d*n|) | |
| 11906 5 sign of xn-component | |
| 11907 6 x of xn-component | |
| 11908 7 sign of y-component | |
| 11909 8 y of y-component | |
| 11910 */ | |
| 11911 match[1] = match[1].toLowerCase(); | |
| 11912 | |
| 11913 if ( match[1].slice( 0, 3 ) === "nth" ) { | |
| 11914 // nth-* requires argument | |
| 11915 if ( !match[3] ) { | |
| 11916 Sizzle.error( match[0] ); | |
| 11917 } | |
| 11918 | |
| 11919 // numeric x and y parameters for Expr.filter.CHILD | |
| 11920 // remember that false/true cast respectively to 0/1 | |
| 11921 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); | |
| 11922 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); | |
| 11923 | |
| 11924 // other types prohibit arguments | |
| 11925 } else if ( match[3] ) { | |
| 11926 Sizzle.error( match[0] ); | |
| 11927 } | |
| 11928 | |
| 11929 return match; | |
| 11930 }, | |
| 11931 | |
| 11932 "PSEUDO": function( match ) { | |
| 11933 var excess, | |
| 11934 unquoted = !match[6] && match[2]; | |
| 11935 | |
| 11936 if ( matchExpr["CHILD"].test( match[0] ) ) { | |
| 11937 return null; | |
| 11938 } | |
| 11939 | |
| 11940 // Accept quoted arguments as-is | |
| 11941 if ( match[3] ) { | |
| 11942 match[2] = match[4] || match[5] || ""; | |
| 11943 | |
| 11944 // Strip excess characters from unquoted arguments | |
| 11945 } else if ( unquoted && rpseudo.test( unquoted ) && | |
| 11946 // Get excess from tokenize (recursively) | |
| 11947 (excess = tokenize( unquoted, true )) && | |
| 11948 // advance to the next closing parenthesis | |
| 11949 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { | |
| 11950 | |
| 11951 // excess is a negative index | |
| 11952 match[0] = match[0].slice( 0, excess ); | |
| 11953 match[2] = unquoted.slice( 0, excess ); | |
| 11954 } | |
| 11955 | |
| 11956 // Return only captures needed by the pseudo filter method (type and argument) | |
| 11957 return match.slice( 0, 3 ); | |
| 11958 } | |
| 11959 }, | |
| 11960 | |
| 11961 filter: { | |
| 11962 | |
| 11963 "TAG": function( nodeNameSelector ) { | |
| 11964 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); | |
| 11965 return nodeNameSelector === "*" ? | |
| 11966 function() { return true; } : | |
| 11967 function( elem ) { | |
| 11968 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; | |
| 11969 }; | |
| 11970 }, | |
| 11971 | |
| 11972 "CLASS": function( className ) { | |
| 11973 var pattern = classCache[ className + " " ]; | |
| 11974 | |
| 11975 return pattern || | |
| 11976 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && | |
| 11977 classCache( className, function( elem ) { | |
| 11978 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); | |
| 11979 }); | |
| 11980 }, | |
| 11981 | |
| 11982 "ATTR": function( name, operator, check ) { | |
| 11983 return function( elem ) { | |
| 11984 var result = Sizzle.attr( elem, name ); | |
| 11985 | |
| 11986 if ( result == null ) { | |
| 11987 return operator === "!="; | |
| 11988 } | |
| 11989 if ( !operator ) { | |
| 11990 return true; | |
| 11991 } | |
| 11992 | |
| 11993 result += ""; | |
| 11994 | |
| 11995 return operator === "=" ? result === check : | |
| 11996 operator === "!=" ? result !== check : | |
| 11997 operator === "^=" ? check && result.indexOf( check ) === 0 : | |
| 11998 operator === "*=" ? check && result.indexOf( check ) > -1 : | |
| 11999 operator === "$=" ? check && result.slice( -check.length ) === check : | |
| 12000 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : | |
| 12001 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : | |
| 12002 false; | |
| 12003 }; | |
| 12004 }, | |
| 12005 | |
| 12006 "CHILD": function( type, what, argument, first, last ) { | |
| 12007 var simple = type.slice( 0, 3 ) !== "nth", | |
| 12008 forward = type.slice( -4 ) !== "last", | |
| 12009 ofType = what === "of-type"; | |
| 12010 | |
| 12011 return first === 1 && last === 0 ? | |
| 12012 | |
| 12013 // Shortcut for :nth-*(n) | |
| 12014 function( elem ) { | |
| 12015 return !!elem.parentNode; | |
| 12016 } : | |
| 12017 | |
| 12018 function( elem, context, xml ) { | |
| 12019 var cache, outerCache, node, diff, nodeIndex, start, | |
| 12020 dir = simple !== forward ? "nextSibling" : "previousSibling", | |
| 12021 parent = elem.parentNode, | |
| 12022 name = ofType && elem.nodeName.toLowerCase(), | |
| 12023 useCache = !xml && !ofType; | |
| 12024 | |
| 12025 if ( parent ) { | |
| 12026 | |
| 12027 // :(first|last|only)-(child|of-type) | |
| 12028 if ( simple ) { | |
| 12029 while ( dir ) { | |
| 12030 node = elem; | |
| 12031 while ( (node = node[ dir ]) ) { | |
| 12032 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { | |
| 12033 return false; | |
| 12034 } | |
| 12035 } | |
| 12036 // Reverse direction for :only-* (if we haven't yet done so) | |
| 12037 start = dir = type === "only" && !start && "nextSibling"; | |
| 12038 } | |
| 12039 return true; | |
| 12040 } | |
| 12041 | |
| 12042 start = [ forward ? parent.firstChild : parent.lastChild ]; | |
| 12043 | |
| 12044 // non-xml :nth-child(...) stores cache data on `parent` | |
| 12045 if ( forward && useCache ) { | |
| 12046 // Seek `elem` from a previously-cached index | |
| 12047 outerCache = parent[ expando ] || (parent[ expando ] = {}); | |
| 12048 cache = outerCache[ type ] || []; | |
| 12049 nodeIndex = cache[0] === dirruns && cache[1]; | |
| 12050 diff = cache[0] === dirruns && cache[2]; | |
| 12051 node = nodeIndex && parent.childNodes[ nodeIndex ]; | |
| 12052 | |
| 12053 while ( (node = ++nodeIndex && node && node[ dir ] || | |
| 12054 | |
| 12055 // Fallback to seeking `elem` from the start | |
| 12056 (diff = nodeIndex = 0) || start.pop()) ) { | |
| 12057 | |
| 12058 // When found, cache indexes on `parent` and break | |
| 12059 if ( node.nodeType === 1 && ++diff && node === elem ) { | |
| 12060 outerCache[ type ] = [ dirruns, nodeIndex, diff ]; | |
| 12061 break; | |
| 12062 } | |
| 12063 } | |
| 12064 | |
| 12065 // Use previously-cached element index if available | |
| 12066 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { | |
| 12067 diff = cache[1]; | |
| 12068 | |
| 12069 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) | |
| 12070 } else { | |
| 12071 // Use the same loop as above to seek `elem` from the start | |
| 12072 while ( (node = ++nodeIndex && node && node[ dir ] || | |
| 12073 (diff = nodeIndex = 0) || start.pop()) ) { | |
| 12074 | |
| 12075 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { | |
| 12076 // Cache the index of each encountered element | |
| 12077 if ( useCache ) { | |
| 12078 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; | |
| 12079 } | |
| 12080 | |
| 12081 if ( node === elem ) { | |
| 12082 break; | |
| 12083 } | |
| 12084 } | |
| 12085 } | |
| 12086 } | |
| 12087 | |
| 12088 // Incorporate the offset, then check against cycle size | |
| 12089 diff -= last; | |
| 12090 return diff === first || ( diff % first === 0 && diff / first >= 0 ); | |
| 12091 } | |
| 12092 }; | |
| 12093 }, | |
| 12094 | |
| 12095 "PSEUDO": function( pseudo, argument ) { | |
| 12096 // pseudo-class names are case-insensitive | |
| 12097 // http://www.w3.org/TR/selectors/#pseudo-classes | |
| 12098 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters | |
| 12099 // Remember that setFilters inherits from pseudos | |
| 12100 var args, | |
| 12101 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || | |
| 12102 Sizzle.error( "unsupported pseudo: " + pseudo ); | |
| 12103 | |
| 12104 // The user may use createPseudo to indicate that | |
| 12105 // arguments are needed to create the filter function | |
| 12106 // just as Sizzle does | |
| 12107 if ( fn[ expando ] ) { | |
| 12108 return fn( argument ); | |
| 12109 } | |
| 12110 | |
| 12111 // But maintain support for old signatures | |
| 12112 if ( fn.length > 1 ) { | |
| 12113 args = [ pseudo, pseudo, "", argument ]; | |
| 12114 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? | |
| 12115 markFunction(function( seed, matches ) { | |
| 12116 var idx, | |
| 12117 matched = fn( seed, argument ), | |
| 12118 i = matched.length; | |
| 12119 while ( i-- ) { | |
| 12120 idx = indexOf( seed, matched[i] ); | |
| 12121 seed[ idx ] = !( matches[ idx ] = matched[i] ); | |
| 12122 } | |
| 12123 }) : | |
| 12124 function( elem ) { | |
| 12125 return fn( elem, 0, args ); | |
| 12126 }; | |
| 12127 } | |
| 12128 | |
| 12129 return fn; | |
| 12130 } | |
| 12131 }, | |
| 12132 | |
| 12133 pseudos: { | |
| 12134 // Potentially complex pseudos | |
| 12135 "not": markFunction(function( selector ) { | |
| 12136 // Trim the selector passed to compile | |
| 12137 // to avoid treating leading and trailing | |
| 12138 // spaces as combinators | |
| 12139 var input = [], | |
| 12140 results = [], | |
| 12141 matcher = compile( selector.replace( rtrim, "$1" ) ); | |
| 12142 | |
| 12143 return matcher[ expando ] ? | |
| 12144 markFunction(function( seed, matches, context, xml ) { | |
| 12145 var elem, | |
| 12146 unmatched = matcher( seed, null, xml, [] ), | |
| 12147 i = seed.length; | |
| 12148 | |
| 12149 // Match elements unmatched by `matcher` | |
| 12150 while ( i-- ) { | |
| 12151 if ( (elem = unmatched[i]) ) { | |
| 12152 seed[i] = !(matches[i] = elem); | |
| 12153 } | |
| 12154 } | |
| 12155 }) : | |
| 12156 function( elem, context, xml ) { | |
| 12157 input[0] = elem; | |
| 12158 matcher( input, null, xml, results ); | |
| 12159 // Don't keep the element (issue #299) | |
| 12160 input[0] = null; | |
| 12161 return !results.pop(); | |
| 12162 }; | |
| 12163 }), | |
| 12164 | |
| 12165 "has": markFunction(function( selector ) { | |
| 12166 return function( elem ) { | |
| 12167 return Sizzle( selector, elem ).length > 0; | |
| 12168 }; | |
| 12169 }), | |
| 12170 | |
| 12171 "contains": markFunction(function( text ) { | |
| 12172 text = text.replace( runescape, funescape ); | |
| 12173 return function( elem ) { | |
| 12174 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; | |
| 12175 }; | |
| 12176 }), | |
| 12177 | |
| 12178 // "Whether an element is represented by a :lang() selector | |
| 12179 // is based solely on the element's language value | |
| 12180 // being equal to the identifier C, | |
| 12181 // or beginning with the identifier C immediately followed by "-". | |
| 12182 // The matching of C against the element's language value is performed case-insensitively. | |
| 12183 // The identifier C does not have to be a valid language name." | |
| 12184 // http://www.w3.org/TR/selectors/#lang-pseudo | |
| 12185 "lang": markFunction( function( lang ) { | |
| 12186 // lang value must be a valid identifier | |
| 12187 if ( !ridentifier.test(lang || "") ) { | |
| 12188 Sizzle.error( "unsupported lang: " + lang ); | |
| 12189 } | |
| 12190 lang = lang.replace( runescape, funescape ).toLowerCase(); | |
| 12191 return function( elem ) { | |
| 12192 var elemLang; | |
| 12193 do { | |
| 12194 if ( (elemLang = documentIsHTML ? | |
| 12195 elem.lang : | |
| 12196 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { | |
| 12197 | |
| 12198 elemLang = elemLang.toLowerCase(); | |
| 12199 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; | |
| 12200 } | |
| 12201 } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); | |
| 12202 return false; | |
| 12203 }; | |
| 12204 }), | |
| 12205 | |
| 12206 // Miscellaneous | |
| 12207 "target": function( elem ) { | |
| 12208 var hash = window.location && window.location.hash; | |
| 12209 return hash && hash.slice( 1 ) === elem.id; | |
| 12210 }, | |
| 12211 | |
| 12212 "root": function( elem ) { | |
| 12213 return elem === docElem; | |
| 12214 }, | |
| 12215 | |
| 12216 "focus": function( elem ) { | |
| 12217 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); | |
| 12218 }, | |
| 12219 | |
| 12220 // Boolean properties | |
| 12221 "enabled": function( elem ) { | |
| 12222 return elem.disabled === false; | |
| 12223 }, | |
| 12224 | |
| 12225 "disabled": function( elem ) { | |
| 12226 return elem.disabled === true; | |
| 12227 }, | |
| 12228 | |
| 12229 "checked": function( elem ) { | |
| 12230 // In CSS3, :checked should return both checked and selected elements | |
| 12231 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked | |
| 12232 var nodeName = elem.nodeName.toLowerCase(); | |
| 12233 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); | |
| 12234 }, | |
| 12235 | |
| 12236 "selected": function( elem ) { | |
| 12237 // Accessing this property makes selected-by-default | |
| 12238 // options in Safari work properly | |
| 12239 if ( elem.parentNode ) { | |
| 12240 elem.parentNode.selectedIndex; | |
| 12241 } | |
| 12242 | |
| 12243 return elem.selected === true; | |
| 12244 }, | |
| 12245 | |
| 12246 // Contents | |
| 12247 "empty": function( elem ) { | |
| 12248 // http://www.w3.org/TR/selectors/#empty-pseudo | |
| 12249 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), | |
| 12250 // but not by others (comment: 8; processing instruction: 7; etc.) | |
| 12251 // nodeType < 6 works because attributes (2) do not appear as children | |
| 12252 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { | |
| 12253 if ( elem.nodeType < 6 ) { | |
| 12254 return false; | |
| 12255 } | |
| 12256 } | |
| 12257 return true; | |
| 12258 }, | |
| 12259 | |
| 12260 "parent": function( elem ) { | |
| 12261 return !Expr.pseudos["empty"]( elem ); | |
| 12262 }, | |
| 12263 | |
| 12264 // Element/input types | |
| 12265 "header": function( elem ) { | |
| 12266 return rheader.test( elem.nodeName ); | |
| 12267 }, | |
| 12268 | |
| 12269 "input": function( elem ) { | |
| 12270 return rinputs.test( elem.nodeName ); | |
| 12271 }, | |
| 12272 | |
| 12273 "button": function( elem ) { | |
| 12274 var name = elem.nodeName.toLowerCase(); | |
| 12275 return name === "input" && elem.type === "button" || name === "button"; | |
| 12276 }, | |
| 12277 | |
| 12278 "text": function( elem ) { | |
| 12279 var attr; | |
| 12280 return elem.nodeName.toLowerCase() === "input" && | |
| 12281 elem.type === "text" && | |
| 12282 | |
| 12283 // Support: IE<8 | |
| 12284 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" | |
| 12285 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); | |
| 12286 }, | |
| 12287 | |
| 12288 // Position-in-collection | |
| 12289 "first": createPositionalPseudo(function() { | |
| 12290 return [ 0 ]; | |
| 12291 }), | |
| 12292 | |
| 12293 "last": createPositionalPseudo(function( matchIndexes, length ) { | |
| 12294 return [ length - 1 ]; | |
| 12295 }), | |
| 12296 | |
| 12297 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
| 12298 return [ argument < 0 ? argument + length : argument ]; | |
| 12299 }), | |
| 12300 | |
| 12301 "even": createPositionalPseudo(function( matchIndexes, length ) { | |
| 12302 var i = 0; | |
| 12303 for ( ; i < length; i += 2 ) { | |
| 12304 matchIndexes.push( i ); | |
| 12305 } | |
| 12306 return matchIndexes; | |
| 12307 }), | |
| 12308 | |
| 12309 "odd": createPositionalPseudo(function( matchIndexes, length ) { | |
| 12310 var i = 1; | |
| 12311 for ( ; i < length; i += 2 ) { | |
| 12312 matchIndexes.push( i ); | |
| 12313 } | |
| 12314 return matchIndexes; | |
| 12315 }), | |
| 12316 | |
| 12317 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
| 12318 var i = argument < 0 ? argument + length : argument; | |
| 12319 for ( ; --i >= 0; ) { | |
| 12320 matchIndexes.push( i ); | |
| 12321 } | |
| 12322 return matchIndexes; | |
| 12323 }), | |
| 12324 | |
| 12325 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
| 12326 var i = argument < 0 ? argument + length : argument; | |
| 12327 for ( ; ++i < length; ) { | |
| 12328 matchIndexes.push( i ); | |
| 12329 } | |
| 12330 return matchIndexes; | |
| 12331 }) | |
| 12332 } | |
| 12333 }; | |
| 12334 | |
| 12335 Expr.pseudos["nth"] = Expr.pseudos["eq"]; | |
| 12336 | |
| 12337 // Add button/input type pseudos | |
| 12338 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { | |
| 12339 Expr.pseudos[ i ] = createInputPseudo( i ); | |
| 12340 } | |
| 12341 for ( i in { submit: true, reset: true } ) { | |
| 12342 Expr.pseudos[ i ] = createButtonPseudo( i ); | |
| 12343 } | |
| 12344 | |
| 12345 // Easy API for creating new setFilters | |
| 12346 function setFilters() {} | |
| 12347 setFilters.prototype = Expr.filters = Expr.pseudos; | |
| 12348 Expr.setFilters = new setFilters(); | |
| 12349 | |
| 12350 tokenize = Sizzle.tokenize = function( selector, parseOnly ) { | |
| 12351 var matched, match, tokens, type, | |
| 12352 soFar, groups, preFilters, | |
| 12353 cached = tokenCache[ selector + " " ]; | |
| 12354 | |
| 12355 if ( cached ) { | |
| 12356 return parseOnly ? 0 : cached.slice( 0 ); | |
| 12357 } | |
| 12358 | |
| 12359 soFar = selector; | |
| 12360 groups = []; | |
| 12361 preFilters = Expr.preFilter; | |
| 12362 | |
| 12363 while ( soFar ) { | |
| 12364 | |
| 12365 // Comma and first run | |
| 12366 if ( !matched || (match = rcomma.exec( soFar )) ) { | |
| 12367 if ( match ) { | |
| 12368 // Don't consume trailing commas as valid | |
| 12369 soFar = soFar.slice( match[0].length ) || soFar; | |
| 12370 } | |
| 12371 groups.push( (tokens = []) ); | |
| 12372 } | |
| 12373 | |
| 12374 matched = false; | |
| 12375 | |
| 12376 // Combinators | |
| 12377 if ( (match = rcombinators.exec( soFar )) ) { | |
| 12378 matched = match.shift(); | |
| 12379 tokens.push({ | |
| 12380 value: matched, | |
| 12381 // Cast descendant combinators to space | |
| 12382 type: match[0].replace( rtrim, " " ) | |
| 12383 }); | |
| 12384 soFar = soFar.slice( matched.length ); | |
| 12385 } | |
| 12386 | |
| 12387 // Filters | |
| 12388 for ( type in Expr.filter ) { | |
| 12389 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || | |
| 12390 (match = preFilters[ type ]( match ))) ) { | |
| 12391 matched = match.shift(); | |
| 12392 tokens.push({ | |
| 12393 value: matched, | |
| 12394 type: type, | |
| 12395 matches: match | |
| 12396 }); | |
| 12397 soFar = soFar.slice( matched.length ); | |
| 12398 } | |
| 12399 } | |
| 12400 | |
| 12401 if ( !matched ) { | |
| 12402 break; | |
| 12403 } | |
| 12404 } | |
| 12405 | |
| 12406 // Return the length of the invalid excess | |
| 12407 // if we're just parsing | |
| 12408 // Otherwise, throw an error or return tokens | |
| 12409 return parseOnly ? | |
| 12410 soFar.length : | |
| 12411 soFar ? | |
| 12412 Sizzle.error( selector ) : | |
| 12413 // Cache the tokens | |
| 12414 tokenCache( selector, groups ).slice( 0 ); | |
| 12415 }; | |
| 12416 | |
| 12417 function toSelector( tokens ) { | |
| 12418 var i = 0, | |
| 12419 len = tokens.length, | |
| 12420 selector = ""; | |
| 12421 for ( ; i < len; i++ ) { | |
| 12422 selector += tokens[i].value; | |
| 12423 } | |
| 12424 return selector; | |
| 12425 } | |
| 12426 | |
| 12427 function addCombinator( matcher, combinator, base ) { | |
| 12428 var dir = combinator.dir, | |
| 12429 checkNonElements = base && dir === "parentNode", | |
| 12430 doneName = done++; | |
| 12431 | |
| 12432 return combinator.first ? | |
| 12433 // Check against closest ancestor/preceding element | |
| 12434 function( elem, context, xml ) { | |
| 12435 while ( (elem = elem[ dir ]) ) { | |
| 12436 if ( elem.nodeType === 1 || checkNonElements ) { | |
| 12437 return matcher( elem, context, xml ); | |
| 12438 } | |
| 12439 } | |
| 12440 } : | |
| 12441 | |
| 12442 // Check against all ancestor/preceding elements | |
| 12443 function( elem, context, xml ) { | |
| 12444 var oldCache, outerCache, | |
| 12445 newCache = [ dirruns, doneName ]; | |
| 12446 | |
| 12447 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching | |
| 12448 if ( xml ) { | |
| 12449 while ( (elem = elem[ dir ]) ) { | |
| 12450 if ( elem.nodeType === 1 || checkNonElements ) { | |
| 12451 if ( matcher( elem, context, xml ) ) { | |
| 12452 return true; | |
| 12453 } | |
| 12454 } | |
| 12455 } | |
| 12456 } else { | |
| 12457 while ( (elem = elem[ dir ]) ) { | |
| 12458 if ( elem.nodeType === 1 || checkNonElements ) { | |
| 12459 outerCache = elem[ expando ] || (elem[ expando ] = {}); | |
| 12460 if ( (oldCache = outerCache[ dir ]) && | |
| 12461 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { | |
| 12462 | |
| 12463 // Assign to newCache so results back-propagate to previous elements | |
| 12464 return (newCache[ 2 ] = oldCache[ 2 ]); | |
| 12465 } else { | |
| 12466 // Reuse newcache so results back-propagate to previous elements | |
| 12467 outerCache[ dir ] = newCache; | |
| 12468 | |
| 12469 // A match means we're done; a fail means we have to keep checking | |
| 12470 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { | |
| 12471 return true; | |
| 12472 } | |
| 12473 } | |
| 12474 } | |
| 12475 } | |
| 12476 } | |
| 12477 }; | |
| 12478 } | |
| 12479 | |
| 12480 function elementMatcher( matchers ) { | |
| 12481 return matchers.length > 1 ? | |
| 12482 function( elem, context, xml ) { | |
| 12483 var i = matchers.length; | |
| 12484 while ( i-- ) { | |
| 12485 if ( !matchers[i]( elem, context, xml ) ) { | |
| 12486 return false; | |
| 12487 } | |
| 12488 } | |
| 12489 return true; | |
| 12490 } : | |
| 12491 matchers[0]; | |
| 12492 } | |
| 12493 | |
| 12494 function multipleContexts( selector, contexts, results ) { | |
| 12495 var i = 0, | |
| 12496 len = contexts.length; | |
| 12497 for ( ; i < len; i++ ) { | |
| 12498 Sizzle( selector, contexts[i], results ); | |
| 12499 } | |
| 12500 return results; | |
| 12501 } | |
| 12502 | |
| 12503 function condense( unmatched, map, filter, context, xml ) { | |
| 12504 var elem, | |
| 12505 newUnmatched = [], | |
| 12506 i = 0, | |
| 12507 len = unmatched.length, | |
| 12508 mapped = map != null; | |
| 12509 | |
| 12510 for ( ; i < len; i++ ) { | |
| 12511 if ( (elem = unmatched[i]) ) { | |
| 12512 if ( !filter || filter( elem, context, xml ) ) { | |
| 12513 newUnmatched.push( elem ); | |
| 12514 if ( mapped ) { | |
| 12515 map.push( i ); | |
| 12516 } | |
| 12517 } | |
| 12518 } | |
| 12519 } | |
| 12520 | |
| 12521 return newUnmatched; | |
| 12522 } | |
| 12523 | |
| 12524 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { | |
| 12525 if ( postFilter && !postFilter[ expando ] ) { | |
| 12526 postFilter = setMatcher( postFilter ); | |
| 12527 } | |
| 12528 if ( postFinder && !postFinder[ expando ] ) { | |
| 12529 postFinder = setMatcher( postFinder, postSelector ); | |
| 12530 } | |
| 12531 return markFunction(function( seed, results, context, xml ) { | |
| 12532 var temp, i, elem, | |
| 12533 preMap = [], | |
| 12534 postMap = [], | |
| 12535 preexisting = results.length, | |
| 12536 | |
| 12537 // Get initial elements from seed or context | |
| 12538 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), | |
| 12539 | |
| 12540 // Prefilter to get matcher input, preserving a map for seed-results synchronization | |
| 12541 matcherIn = preFilter && ( seed || !selector ) ? | |
| 12542 condense( elems, preMap, preFilter, context, xml ) : | |
| 12543 elems, | |
| 12544 | |
| 12545 matcherOut = matcher ? | |
| 12546 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, | |
| 12547 postFinder || ( seed ? preFilter : preexisting || postFilter ) ? | |
| 12548 | |
| 12549 // ...intermediate processing is necessary | |
| 12550 [] : | |
| 12551 | |
| 12552 // ...otherwise use results directly | |
| 12553 results : | |
| 12554 matcherIn; | |
| 12555 | |
| 12556 // Find primary matches | |
| 12557 if ( matcher ) { | |
| 12558 matcher( matcherIn, matcherOut, context, xml ); | |
| 12559 } | |
| 12560 | |
| 12561 // Apply postFilter | |
| 12562 if ( postFilter ) { | |
| 12563 temp = condense( matcherOut, postMap ); | |
| 12564 postFilter( temp, [], context, xml ); | |
| 12565 | |
| 12566 // Un-match failing elements by moving them back to matcherIn | |
| 12567 i = temp.length; | |
| 12568 while ( i-- ) { | |
| 12569 if ( (elem = temp[i]) ) { | |
| 12570 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); | |
| 12571 } | |
| 12572 } | |
| 12573 } | |
| 12574 | |
| 12575 if ( seed ) { | |
| 12576 if ( postFinder || preFilter ) { | |
| 12577 if ( postFinder ) { | |
| 12578 // Get the final matcherOut by condensing this intermediate into postFinder contexts | |
| 12579 temp = []; | |
| 12580 i = matcherOut.length; | |
| 12581 while ( i-- ) { | |
| 12582 if ( (elem = matcherOut[i]) ) { | |
| 12583 // Restore matcherIn since elem is not yet a final match | |
| 12584 temp.push( (matcherIn[i] = elem) ); | |
| 12585 } | |
| 12586 } | |
| 12587 postFinder( null, (matcherOut = []), temp, xml ); | |
| 12588 } | |
| 12589 | |
| 12590 // Move matched elements from seed to results to keep them synchronized | |
| 12591 i = matcherOut.length; | |
| 12592 while ( i-- ) { | |
| 12593 if ( (elem = matcherOut[i]) && | |
| 12594 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { | |
| 12595 | |
| 12596 seed[temp] = !(results[temp] = elem); | |
| 12597 } | |
| 12598 } | |
| 12599 } | |
| 12600 | |
| 12601 // Add elements to results, through postFinder if defined | |
| 12602 } else { | |
| 12603 matcherOut = condense( | |
| 12604 matcherOut === results ? | |
| 12605 matcherOut.splice( preexisting, matcherOut.length ) : | |
| 12606 matcherOut | |
| 12607 ); | |
| 12608 if ( postFinder ) { | |
| 12609 postFinder( null, results, matcherOut, xml ); | |
| 12610 } else { | |
| 12611 push.apply( results, matcherOut ); | |
| 12612 } | |
| 12613 } | |
| 12614 }); | |
| 12615 } | |
| 12616 | |
| 12617 function matcherFromTokens( tokens ) { | |
| 12618 var checkContext, matcher, j, | |
| 12619 len = tokens.length, | |
| 12620 leadingRelative = Expr.relative[ tokens[0].type ], | |
| 12621 implicitRelative = leadingRelative || Expr.relative[" "], | |
| 12622 i = leadingRelative ? 1 : 0, | |
| 12623 | |
| 12624 // The foundational matcher ensures that elements are reachable from top-level context(s) | |
| 12625 matchContext = addCombinator( function( elem ) { | |
| 12626 return elem === checkContext; | |
| 12627 }, implicitRelative, true ), | |
| 12628 matchAnyContext = addCombinator( function( elem ) { | |
| 12629 return indexOf( checkContext, elem ) > -1; | |
| 12630 }, implicitRelative, true ), | |
| 12631 matchers = [ function( elem, context, xml ) { | |
| 12632 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( | |
| 12633 (checkContext = context).nodeType ? | |
| 12634 matchContext( elem, context, xml ) : | |
| 12635 matchAnyContext( elem, context, xml ) ); | |
| 12636 // Avoid hanging onto element (issue #299) | |
| 12637 checkContext = null; | |
| 12638 return ret; | |
| 12639 } ]; | |
| 12640 | |
| 12641 for ( ; i < len; i++ ) { | |
| 12642 if ( (matcher = Expr.relative[ tokens[i].type ]) ) { | |
| 12643 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; | |
| 12644 } else { | |
| 12645 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); | |
| 12646 | |
| 12647 // Return special upon seeing a positional matcher | |
| 12648 if ( matcher[ expando ] ) { | |
| 12649 // Find the next relative operator (if any) for proper handling | |
| 12650 j = ++i; | |
| 12651 for ( ; j < len; j++ ) { | |
| 12652 if ( Expr.relative[ tokens[j].type ] ) { | |
| 12653 break; | |
| 12654 } | |
| 12655 } | |
| 12656 return setMatcher( | |
| 12657 i > 1 && elementMatcher( matchers ), | |
| 12658 i > 1 && toSelector( | |
| 12659 // If the preceding token was a descendant combinator, insert an implicit any-element `*` | |
| 12660 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) | |
| 12661 ).replace( rtrim, "$1" ), | |
| 12662 matcher, | |
| 12663 i < j && matcherFromTokens( tokens.slice( i, j ) ), | |
| 12664 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), | |
| 12665 j < len && toSelector( tokens ) | |
| 12666 ); | |
| 12667 } | |
| 12668 matchers.push( matcher ); | |
| 12669 } | |
| 12670 } | |
| 12671 | |
| 12672 return elementMatcher( matchers ); | |
| 12673 } | |
| 12674 | |
| 12675 function matcherFromGroupMatchers( elementMatchers, setMatchers ) { | |
| 12676 var bySet = setMatchers.length > 0, | |
| 12677 byElement = elementMatchers.length > 0, | |
| 12678 superMatcher = function( seed, context, xml, results, outermost ) { | |
| 12679 var elem, j, matcher, | |
| 12680 matchedCount = 0, | |
| 12681 i = "0", | |
| 12682 unmatched = seed && [], | |
| 12683 setMatched = [], | |
| 12684 contextBackup = outermostContext, | |
| 12685 // We must always have either seed elements or outermost context | |
| 12686 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), | |
| 12687 // Use integer dirruns iff this is the outermost matcher | |
| 12688 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), | |
| 12689 len = elems.length; | |
| 12690 | |
| 12691 if ( outermost ) { | |
| 12692 outermostContext = context !== document && context; | |
| 12693 } | |
| 12694 | |
| 12695 // Add elements passing elementMatchers directly to results | |
| 12696 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below | |
| 12697 // Support: IE<9, Safari | |
| 12698 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id | |
| 12699 for ( ; i !== len && (elem = elems[i]) != null; i++ ) { | |
| 12700 if ( byElement && elem ) { | |
| 12701 j = 0; | |
| 12702 while ( (matcher = elementMatchers[j++]) ) { | |
| 12703 if ( matcher( elem, context, xml ) ) { | |
| 12704 results.push( elem ); | |
| 12705 break; | |
| 12706 } | |
| 12707 } | |
| 12708 if ( outermost ) { | |
| 12709 dirruns = dirrunsUnique; | |
| 12710 } | |
| 12711 } | |
| 12712 | |
| 12713 // Track unmatched elements for set filters | |
| 12714 if ( bySet ) { | |
| 12715 // They will have gone through all possible matchers | |
| 12716 if ( (elem = !matcher && elem) ) { | |
| 12717 matchedCount--; | |
| 12718 } | |
| 12719 | |
| 12720 // Lengthen the array for every element, matched or not | |
| 12721 if ( seed ) { | |
| 12722 unmatched.push( elem ); | |
| 12723 } | |
| 12724 } | |
| 12725 } | |
| 12726 | |
| 12727 // Apply set filters to unmatched elements | |
| 12728 matchedCount += i; | |
| 12729 if ( bySet && i !== matchedCount ) { | |
| 12730 j = 0; | |
| 12731 while ( (matcher = setMatchers[j++]) ) { | |
| 12732 matcher( unmatched, setMatched, context, xml ); | |
| 12733 } | |
| 12734 | |
| 12735 if ( seed ) { | |
| 12736 // Reintegrate element matches to eliminate the need for sorting | |
| 12737 if ( matchedCount > 0 ) { | |
| 12738 while ( i-- ) { | |
| 12739 if ( !(unmatched[i] || setMatched[i]) ) { | |
| 12740 setMatched[i] = pop.call( results ); | |
| 12741 } | |
| 12742 } | |
| 12743 } | |
| 12744 | |
| 12745 // Discard index placeholder values to get only actual matches | |
| 12746 setMatched = condense( setMatched ); | |
| 12747 } | |
| 12748 | |
| 12749 // Add matches to results | |
| 12750 push.apply( results, setMatched ); | |
| 12751 | |
| 12752 // Seedless set matches succeeding multiple successful matchers stipulate sorting | |
| 12753 if ( outermost && !seed && setMatched.length > 0 && | |
| 12754 ( matchedCount + setMatchers.length ) > 1 ) { | |
| 12755 | |
| 12756 Sizzle.uniqueSort( results ); | |
| 12757 } | |
| 12758 } | |
| 12759 | |
| 12760 // Override manipulation of globals by nested matchers | |
| 12761 if ( outermost ) { | |
| 12762 dirruns = dirrunsUnique; | |
| 12763 outermostContext = contextBackup; | |
| 12764 } | |
| 12765 | |
| 12766 return unmatched; | |
| 12767 }; | |
| 12768 | |
| 12769 return bySet ? | |
| 12770 markFunction( superMatcher ) : | |
| 12771 superMatcher; | |
| 12772 } | |
| 12773 | |
| 12774 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { | |
| 12775 var i, | |
| 12776 setMatchers = [], | |
| 12777 elementMatchers = [], | |
| 12778 cached = compilerCache[ selector + " " ]; | |
| 12779 | |
| 12780 if ( !cached ) { | |
| 12781 // Generate a function of recursive functions that can be used to check each element | |
| 12782 if ( !match ) { | |
| 12783 match = tokenize( selector ); | |
| 12784 } | |
| 12785 i = match.length; | |
| 12786 while ( i-- ) { | |
| 12787 cached = matcherFromTokens( match[i] ); | |
| 12788 if ( cached[ expando ] ) { | |
| 12789 setMatchers.push( cached ); | |
| 12790 } else { | |
| 12791 elementMatchers.push( cached ); | |
| 12792 } | |
| 12793 } | |
| 12794 | |
| 12795 // Cache the compiled function | |
| 12796 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); | |
| 12797 | |
| 12798 // Save selector and tokenization | |
| 12799 cached.selector = selector; | |
| 12800 } | |
| 12801 return cached; | |
| 12802 }; | |
| 12803 | |
| 12804 /** | |
| 12805 * A low-level selection function that works with Sizzle's compiled | |
| 12806 * selector functions | |
| 12807 * @param {String|Function} selector A selector or a pre-compiled | |
| 12808 * selector function built with Sizzle.compile | |
| 12809 * @param {Element} context | |
| 12810 * @param {Array} [results] | |
| 12811 * @param {Array} [seed] A set of elements to match against | |
| 12812 */ | |
| 12813 select = Sizzle.select = function( selector, context, results, seed ) { | |
| 12814 var i, tokens, token, type, find, | |
| 12815 compiled = typeof selector === "function" && selector, | |
| 12816 match = !seed && tokenize( (selector = compiled.selector || selector) ); | |
| 12817 | |
| 12818 results = results || []; | |
| 12819 | |
| 12820 // Try to minimize operations if there is no seed and only one group | |
| 12821 if ( match.length === 1 ) { | |
| 12822 | |
| 12823 // Take a shortcut and set the context if the root selector is an ID | |
| 12824 tokens = match[0] = match[0].slice( 0 ); | |
| 12825 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && | |
| 12826 support.getById && context.nodeType === 9 && documentIsHTML && | |
| 12827 Expr.relative[ tokens[1].type ] ) { | |
| 12828 | |
| 12829 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; | |
| 12830 if ( !context ) { | |
| 12831 return results; | |
| 12832 | |
| 12833 // Precompiled matchers will still verify ancestry, so step up a level | |
| 12834 } else if ( compiled ) { | |
| 12835 context = context.parentNode; | |
| 12836 } | |
| 12837 | |
| 12838 selector = selector.slice( tokens.shift().value.length ); | |
| 12839 } | |
| 12840 | |
| 12841 // Fetch a seed set for right-to-left matching | |
| 12842 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; | |
| 12843 while ( i-- ) { | |
| 12844 token = tokens[i]; | |
| 12845 | |
| 12846 // Abort if we hit a combinator | |
| 12847 if ( Expr.relative[ (type = token.type) ] ) { | |
| 12848 break; | |
| 12849 } | |
| 12850 if ( (find = Expr.find[ type ]) ) { | |
| 12851 // Search, expanding context for leading sibling combinators | |
| 12852 if ( (seed = find( | |
| 12853 token.matches[0].replace( runescape, funescape ), | |
| 12854 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context | |
| 12855 )) ) { | |
| 12856 | |
| 12857 // If seed is empty or no tokens remain, we can return early | |
| 12858 tokens.splice( i, 1 ); | |
| 12859 selector = seed.length && toSelector( tokens ); | |
| 12860 if ( !selector ) { | |
| 12861 push.apply( results, seed ); | |
| 12862 return results; | |
| 12863 } | |
| 12864 | |
| 12865 break; | |
| 12866 } | |
| 12867 } | |
| 12868 } | |
| 12869 } | |
| 12870 | |
| 12871 // Compile and execute a filtering function if one is not provided | |
| 12872 // Provide `match` to avoid retokenization if we modified the selector above | |
| 12873 ( compiled || compile( selector, match ) )( | |
| 12874 seed, | |
| 12875 context, | |
| 12876 !documentIsHTML, | |
| 12877 results, | |
| 12878 rsibling.test( selector ) && testContext( context.parentNode ) || context | |
| 12879 ); | |
| 12880 return results; | |
| 12881 }; | |
| 12882 | |
| 12883 // One-time assignments | |
| 12884 | |
| 12885 // Sort stability | |
| 12886 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; | |
| 12887 | |
| 12888 // Support: Chrome 14-35+ | |
| 12889 // Always assume duplicates if they aren't passed to the comparison function | |
| 12890 support.detectDuplicates = !!hasDuplicate; | |
| 12891 | |
| 12892 // Initialize against the default document | |
| 12893 setDocument(); | |
| 12894 | |
| 12895 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) | |
| 12896 // Detached nodes confoundingly follow *each other* | |
| 12897 support.sortDetached = assert(function( div1 ) { | |
| 12898 // Should return 1, but returns 4 (following) | |
| 12899 return div1.compareDocumentPosition( document.createElement("div") ) & 1; | |
| 12900 }); | |
| 12901 | |
| 12902 // Support: IE<8 | |
| 12903 // Prevent attribute/property "interpolation" | |
| 12904 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx | |
| 12905 if ( !assert(function( div ) { | |
| 12906 div.innerHTML = "<a href='#'></a>"; | |
| 12907 return div.firstChild.getAttribute("href") === "#" ; | |
| 12908 }) ) { | |
| 12909 addHandle( "type|href|height|width", function( elem, name, isXML ) { | |
| 12910 if ( !isXML ) { | |
| 12911 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); | |
| 12912 } | |
| 12913 }); | |
| 12914 } | |
| 12915 | |
| 12916 // Support: IE<9 | |
| 12917 // Use defaultValue in place of getAttribute("value") | |
| 12918 if ( !support.attributes || !assert(function( div ) { | |
| 12919 div.innerHTML = "<input/>"; | |
| 12920 div.firstChild.setAttribute( "value", "" ); | |
| 12921 return div.firstChild.getAttribute( "value" ) === ""; | |
| 12922 }) ) { | |
| 12923 addHandle( "value", function( elem, name, isXML ) { | |
| 12924 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { | |
| 12925 return elem.defaultValue; | |
| 12926 } | |
| 12927 }); | |
| 12928 } | |
| 12929 | |
| 12930 // Support: IE<9 | |
| 12931 // Use getAttributeNode to fetch booleans when getAttribute lies | |
| 12932 if ( !assert(function( div ) { | |
| 12933 return div.getAttribute("disabled") == null; | |
| 12934 }) ) { | |
| 12935 addHandle( booleans, function( elem, name, isXML ) { | |
| 12936 var val; | |
| 12937 if ( !isXML ) { | |
| 12938 return elem[ name ] === true ? name.toLowerCase() : | |
| 12939 (val = elem.getAttributeNode( name )) && val.specified ? | |
| 12940 val.value : | |
| 12941 null; | |
| 12942 } | |
| 12943 }); | |
| 12944 } | |
| 12945 | |
| 12946 return Sizzle; | |
| 12947 | |
| 12948 })( window ); | |
| 12949 | |
| 12950 | |
| 12951 | |
| 12952 jQuery.find = Sizzle; | |
| 12953 jQuery.expr = Sizzle.selectors; | |
| 12954 jQuery.expr[":"] = jQuery.expr.pseudos; | |
| 12955 jQuery.unique = Sizzle.uniqueSort; | |
| 12956 jQuery.text = Sizzle.getText; | |
| 12957 jQuery.isXMLDoc = Sizzle.isXML; | |
| 12958 jQuery.contains = Sizzle.contains; | |
| 12959 | |
| 12960 | |
| 12961 | |
| 12962 var rneedsContext = jQuery.expr.match.needsContext; | |
| 12963 | |
| 12964 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); | |
| 12965 | |
| 12966 | |
| 12967 | |
| 12968 var risSimple = /^.[^:#\[\.,]*$/; | |
| 12969 | |
| 12970 // Implement the identical functionality for filter and not | |
| 12971 function winnow( elements, qualifier, not ) { | |
| 12972 if ( jQuery.isFunction( qualifier ) ) { | |
| 12973 return jQuery.grep( elements, function( elem, i ) { | |
| 12974 /* jshint -W018 */ | |
| 12975 return !!qualifier.call( elem, i, elem ) !== not; | |
| 12976 }); | |
| 12977 | |
| 12978 } | |
| 12979 | |
| 12980 if ( qualifier.nodeType ) { | |
| 12981 return jQuery.grep( elements, function( elem ) { | |
| 12982 return ( elem === qualifier ) !== not; | |
| 12983 }); | |
| 12984 | |
| 12985 } | |
| 12986 | |
| 12987 if ( typeof qualifier === "string" ) { | |
| 12988 if ( risSimple.test( qualifier ) ) { | |
| 12989 return jQuery.filter( qualifier, elements, not ); | |
| 12990 } | |
| 12991 | |
| 12992 qualifier = jQuery.filter( qualifier, elements ); | |
| 12993 } | |
| 12994 | |
| 12995 return jQuery.grep( elements, function( elem ) { | |
| 12996 return ( indexOf.call( qualifier, elem ) >= 0 ) !== not; | |
| 12997 }); | |
| 12998 } | |
| 12999 | |
| 13000 jQuery.filter = function( expr, elems, not ) { | |
| 13001 var elem = elems[ 0 ]; | |
| 13002 | |
| 13003 if ( not ) { | |
| 13004 expr = ":not(" + expr + ")"; | |
| 13005 } | |
| 13006 | |
| 13007 return elems.length === 1 && elem.nodeType === 1 ? | |
| 13008 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : | |
| 13009 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { | |
| 13010 return elem.nodeType === 1; | |
| 13011 })); | |
| 13012 }; | |
| 13013 | |
| 13014 jQuery.fn.extend({ | |
| 13015 find: function( selector ) { | |
| 13016 var i, | |
| 13017 len = this.length, | |
| 13018 ret = [], | |
| 13019 self = this; | |
| 13020 | |
| 13021 if ( typeof selector !== "string" ) { | |
| 13022 return this.pushStack( jQuery( selector ).filter(function() { | |
| 13023 for ( i = 0; i < len; i++ ) { | |
| 13024 if ( jQuery.contains( self[ i ], this ) ) { | |
| 13025 return true; | |
| 13026 } | |
| 13027 } | |
| 13028 }) ); | |
| 13029 } | |
| 13030 | |
| 13031 for ( i = 0; i < len; i++ ) { | |
| 13032 jQuery.find( selector, self[ i ], ret ); | |
| 13033 } | |
| 13034 | |
| 13035 // Needed because $( selector, context ) becomes $( context ).find( selector ) | |
| 13036 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); | |
| 13037 ret.selector = this.selector ? this.selector + " " + selector : selector; | |
| 13038 return ret; | |
| 13039 }, | |
| 13040 filter: function( selector ) { | |
| 13041 return this.pushStack( winnow(this, selector || [], false) ); | |
| 13042 }, | |
| 13043 not: function( selector ) { | |
| 13044 return this.pushStack( winnow(this, selector || [], true) ); | |
| 13045 }, | |
| 13046 is: function( selector ) { | |
| 13047 return !!winnow( | |
| 13048 this, | |
| 13049 | |
| 13050 // If this is a positional/relative selector, check membership in the returned set | |
| 13051 // so $("p:first").is("p:last") won't return true for a doc with two "p". | |
| 13052 typeof selector === "string" && rneedsContext.test( selector ) ? | |
| 13053 jQuery( selector ) : | |
| 13054 selector || [], | |
| 13055 false | |
| 13056 ).length; | |
| 13057 } | |
| 13058 }); | |
| 13059 | |
| 13060 | |
| 13061 // Initialize a jQuery object | |
| 13062 | |
| 13063 | |
| 13064 // A central reference to the root jQuery(document) | |
| 13065 var rootjQuery, | |
| 13066 | |
| 13067 // A simple way to check for HTML strings | |
| 13068 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) | |
| 13069 // Strict HTML recognition (#11290: must start with <) | |
| 13070 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, | |
| 13071 | |
| 13072 init = jQuery.fn.init = function( selector, context ) { | |
| 13073 var match, elem; | |
| 13074 | |
| 13075 // HANDLE: $(""), $(null), $(undefined), $(false) | |
| 13076 if ( !selector ) { | |
| 13077 return this; | |
| 13078 } | |
| 13079 | |
| 13080 // Handle HTML strings | |
| 13081 if ( typeof selector === "string" ) { | |
| 13082 if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) { | |
| 13083 // Assume that strings that start and end with <> are HTML and skip the regex check | |
| 13084 match = [ null, selector, null ]; | |
| 13085 | |
| 13086 } else { | |
| 13087 match = rquickExpr.exec( selector ); | |
| 13088 } | |
| 13089 | |
| 13090 // Match html or make sure no context is specified for #id | |
| 13091 if ( match && (match[1] || !context) ) { | |
| 13092 | |
| 13093 // HANDLE: $(html) -> $(array) | |
| 13094 if ( match[1] ) { | |
| 13095 context = context instanceof jQuery ? context[0] : context; | |
| 13096 | |
| 13097 // Option to run scripts is true for back-compat | |
| 13098 // Intentionally let the error be thrown if parseHTML is not present | |
| 13099 jQuery.merge( this, jQuery.parseHTML( | |
| 13100 match[1], | |
| 13101 context && context.nodeType ? context.ownerDocument || context : document, | |
| 13102 true | |
| 13103 ) ); | |
| 13104 | |
| 13105 // HANDLE: $(html, props) | |
| 13106 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { | |
| 13107 for ( match in context ) { | |
| 13108 // Properties of context are called as methods if possible | |
| 13109 if ( jQuery.isFunction( this[ match ] ) ) { | |
| 13110 this[ match ]( context[ match ] ); | |
| 13111 | |
| 13112 // ...and otherwise set as attributes | |
| 13113 } else { | |
| 13114 this.attr( match, context[ match ] ); | |
| 13115 } | |
| 13116 } | |
| 13117 } | |
| 13118 | |
| 13119 return this; | |
| 13120 | |
| 13121 // HANDLE: $(#id) | |
| 13122 } else { | |
| 13123 elem = document.getElementById( match[2] ); | |
| 13124 | |
| 13125 // Support: Blackberry 4.6 | |
| 13126 // gEBID returns nodes no longer in the document (#6963) | |
| 13127 if ( elem && elem.parentNode ) { | |
| 13128 // Inject the element directly into the jQuery object | |
| 13129 this.length = 1; | |
| 13130 this[0] = elem; | |
| 13131 } | |
| 13132 | |
| 13133 this.context = document; | |
| 13134 this.selector = selector; | |
| 13135 return this; | |
| 13136 } | |
| 13137 | |
| 13138 // HANDLE: $(expr, $(...)) | |
| 13139 } else if ( !context || context.jquery ) { | |
| 13140 return ( context || rootjQuery ).find( selector ); | |
| 13141 | |
| 13142 // HANDLE: $(expr, context) | |
| 13143 // (which is just equivalent to: $(context).find(expr) | |
| 13144 } else { | |
| 13145 return this.constructor( context ).find( selector ); | |
| 13146 } | |
| 13147 | |
| 13148 // HANDLE: $(DOMElement) | |
| 13149 } else if ( selector.nodeType ) { | |
| 13150 this.context = this[0] = selector; | |
| 13151 this.length = 1; | |
| 13152 return this; | |
| 13153 | |
| 13154 // HANDLE: $(function) | |
| 13155 // Shortcut for document ready | |
| 13156 } else if ( jQuery.isFunction( selector ) ) { | |
| 13157 return typeof rootjQuery.ready !== "undefined" ? | |
| 13158 rootjQuery.ready( selector ) : | |
| 13159 // Execute immediately if ready is not present | |
| 13160 selector( jQuery ); | |
| 13161 } | |
| 13162 | |
| 13163 if ( selector.selector !== undefined ) { | |
| 13164 this.selector = selector.selector; | |
| 13165 this.context = selector.context; | |
| 13166 } | |
| 13167 | |
| 13168 return jQuery.makeArray( selector, this ); | |
| 13169 }; | |
| 13170 | |
| 13171 // Give the init function the jQuery prototype for later instantiation | |
| 13172 init.prototype = jQuery.fn; | |
| 13173 | |
| 13174 // Initialize central reference | |
| 13175 rootjQuery = jQuery( document ); | |
| 13176 | |
| 13177 | |
| 13178 var rparentsprev = /^(?:parents|prev(?:Until|All))/, | |
| 13179 // Methods guaranteed to produce a unique set when starting from a unique set | |
| 13180 guaranteedUnique = { | |
| 13181 children: true, | |
| 13182 contents: true, | |
| 13183 next: true, | |
| 13184 prev: true | |
| 13185 }; | |
| 13186 | |
| 13187 jQuery.extend({ | |
| 13188 dir: function( elem, dir, until ) { | |
| 13189 var matched = [], | |
| 13190 truncate = until !== undefined; | |
| 13191 | |
| 13192 while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) { | |
| 13193 if ( elem.nodeType === 1 ) { | |
| 13194 if ( truncate && jQuery( elem ).is( until ) ) { | |
| 13195 break; | |
| 13196 } | |
| 13197 matched.push( elem ); | |
| 13198 } | |
| 13199 } | |
| 13200 return matched; | |
| 13201 }, | |
| 13202 | |
| 13203 sibling: function( n, elem ) { | |
| 13204 var matched = []; | |
| 13205 | |
| 13206 for ( ; n; n = n.nextSibling ) { | |
| 13207 if ( n.nodeType === 1 && n !== elem ) { | |
| 13208 matched.push( n ); | |
| 13209 } | |
| 13210 } | |
| 13211 | |
| 13212 return matched; | |
| 13213 } | |
| 13214 }); | |
| 13215 | |
| 13216 jQuery.fn.extend({ | |
| 13217 has: function( target ) { | |
| 13218 var targets = jQuery( target, this ), | |
| 13219 l = targets.length; | |
| 13220 | |
| 13221 return this.filter(function() { | |
| 13222 var i = 0; | |
| 13223 for ( ; i < l; i++ ) { | |
| 13224 if ( jQuery.contains( this, targets[i] ) ) { | |
| 13225 return true; | |
| 13226 } | |
| 13227 } | |
| 13228 }); | |
| 13229 }, | |
| 13230 | |
| 13231 closest: function( selectors, context ) { | |
| 13232 var cur, | |
| 13233 i = 0, | |
| 13234 l = this.length, | |
| 13235 matched = [], | |
| 13236 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? | |
| 13237 jQuery( selectors, context || this.context ) : | |
| 13238 0; | |
| 13239 | |
| 13240 for ( ; i < l; i++ ) { | |
| 13241 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { | |
| 13242 // Always skip document fragments | |
| 13243 if ( cur.nodeType < 11 && (pos ? | |
| 13244 pos.index(cur) > -1 : | |
| 13245 | |
| 13246 // Don't pass non-elements to Sizzle | |
| 13247 cur.nodeType === 1 && | |
| 13248 jQuery.find.matchesSelector(cur, selectors)) ) { | |
| 13249 | |
| 13250 matched.push( cur ); | |
| 13251 break; | |
| 13252 } | |
| 13253 } | |
| 13254 } | |
| 13255 | |
| 13256 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); | |
| 13257 }, | |
| 13258 | |
| 13259 // Determine the position of an element within the set | |
| 13260 index: function( elem ) { | |
| 13261 | |
| 13262 // No argument, return index in parent | |
| 13263 if ( !elem ) { | |
| 13264 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; | |
| 13265 } | |
| 13266 | |
| 13267 // Index in selector | |
| 13268 if ( typeof elem === "string" ) { | |
| 13269 return indexOf.call( jQuery( elem ), this[ 0 ] ); | |
| 13270 } | |
| 13271 | |
| 13272 // Locate the position of the desired element | |
| 13273 return indexOf.call( this, | |
| 13274 | |
| 13275 // If it receives a jQuery object, the first element is used | |
| 13276 elem.jquery ? elem[ 0 ] : elem | |
| 13277 ); | |
| 13278 }, | |
| 13279 | |
| 13280 add: function( selector, context ) { | |
| 13281 return this.pushStack( | |
| 13282 jQuery.unique( | |
| 13283 jQuery.merge( this.get(), jQuery( selector, context ) ) | |
| 13284 ) | |
| 13285 ); | |
| 13286 }, | |
| 13287 | |
| 13288 addBack: function( selector ) { | |
| 13289 return this.add( selector == null ? | |
| 13290 this.prevObject : this.prevObject.filter(selector) | |
| 13291 ); | |
| 13292 } | |
| 13293 }); | |
| 13294 | |
| 13295 function sibling( cur, dir ) { | |
| 13296 while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {} | |
| 13297 return cur; | |
| 13298 } | |
| 13299 | |
| 13300 jQuery.each({ | |
| 13301 parent: function( elem ) { | |
| 13302 var parent = elem.parentNode; | |
| 13303 return parent && parent.nodeType !== 11 ? parent : null; | |
| 13304 }, | |
| 13305 parents: function( elem ) { | |
| 13306 return jQuery.dir( elem, "parentNode" ); | |
| 13307 }, | |
| 13308 parentsUntil: function( elem, i, until ) { | |
| 13309 return jQuery.dir( elem, "parentNode", until ); | |
| 13310 }, | |
| 13311 next: function( elem ) { | |
| 13312 return sibling( elem, "nextSibling" ); | |
| 13313 }, | |
| 13314 prev: function( elem ) { | |
| 13315 return sibling( elem, "previousSibling" ); | |
| 13316 }, | |
| 13317 nextAll: function( elem ) { | |
| 13318 return jQuery.dir( elem, "nextSibling" ); | |
| 13319 }, | |
| 13320 prevAll: function( elem ) { | |
| 13321 return jQuery.dir( elem, "previousSibling" ); | |
| 13322 }, | |
| 13323 nextUntil: function( elem, i, until ) { | |
| 13324 return jQuery.dir( elem, "nextSibling", until ); | |
| 13325 }, | |
| 13326 prevUntil: function( elem, i, until ) { | |
| 13327 return jQuery.dir( elem, "previousSibling", until ); | |
| 13328 }, | |
| 13329 siblings: function( elem ) { | |
| 13330 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); | |
| 13331 }, | |
| 13332 children: function( elem ) { | |
| 13333 return jQuery.sibling( elem.firstChild ); | |
| 13334 }, | |
| 13335 contents: function( elem ) { | |
| 13336 return elem.contentDocument || jQuery.merge( [], elem.childNodes ); | |
| 13337 } | |
| 13338 }, function( name, fn ) { | |
| 13339 jQuery.fn[ name ] = function( until, selector ) { | |
| 13340 var matched = jQuery.map( this, fn, until ); | |
| 13341 | |
| 13342 if ( name.slice( -5 ) !== "Until" ) { | |
| 13343 selector = until; | |
| 13344 } | |
| 13345 | |
| 13346 if ( selector && typeof selector === "string" ) { | |
| 13347 matched = jQuery.filter( selector, matched ); | |
| 13348 } | |
| 13349 | |
| 13350 if ( this.length > 1 ) { | |
| 13351 // Remove duplicates | |
| 13352 if ( !guaranteedUnique[ name ] ) { | |
| 13353 jQuery.unique( matched ); | |
| 13354 } | |
| 13355 | |
| 13356 // Reverse order for parents* and prev-derivatives | |
| 13357 if ( rparentsprev.test( name ) ) { | |
| 13358 matched.reverse(); | |
| 13359 } | |
| 13360 } | |
| 13361 | |
| 13362 return this.pushStack( matched ); | |
| 13363 }; | |
| 13364 }); | |
| 13365 var rnotwhite = (/\S+/g); | |
| 13366 | |
| 13367 | |
| 13368 | |
| 13369 // String to Object options format cache | |
| 13370 var optionsCache = {}; | |
| 13371 | |
| 13372 // Convert String-formatted options into Object-formatted ones and store in cache | |
| 13373 function createOptions( options ) { | |
| 13374 var object = optionsCache[ options ] = {}; | |
| 13375 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { | |
| 13376 object[ flag ] = true; | |
| 13377 }); | |
| 13378 return object; | |
| 13379 } | |
| 13380 | |
| 13381 /* | |
| 13382 * Create a callback list using the following parameters: | |
| 13383 * | |
| 13384 * options: an optional list of space-separated options that will change how | |
| 13385 * the callback list behaves or a more traditional option object | |
| 13386 * | |
| 13387 * By default a callback list will act like an event callback list and can be | |
| 13388 * "fired" multiple times. | |
| 13389 * | |
| 13390 * Possible options: | |
| 13391 * | |
| 13392 * once: will ensure the callback list can only be fired once (like a Deferred) | |
| 13393 * | |
| 13394 * memory: will keep track of previous values and will call any callback added | |
| 13395 * after the list has been fired right away with the latest "memorized" | |
| 13396 * values (like a Deferred) | |
| 13397 * | |
| 13398 * unique: will ensure a callback can only be added once (no duplicate in the list) | |
| 13399 * | |
| 13400 * stopOnFalse: interrupt callings when a callback returns false | |
| 13401 * | |
| 13402 */ | |
| 13403 jQuery.Callbacks = function( options ) { | |
| 13404 | |
| 13405 // Convert options from String-formatted to Object-formatted if needed | |
| 13406 // (we check in cache first) | |
| 13407 options = typeof options === "string" ? | |
| 13408 ( optionsCache[ options ] || createOptions( options ) ) : | |
| 13409 jQuery.extend( {}, options ); | |
| 13410 | |
| 13411 var // Last fire value (for non-forgettable lists) | |
| 13412 memory, | |
| 13413 // Flag to know if list was already fired | |
| 13414 fired, | |
| 13415 // Flag to know if list is currently firing | |
| 13416 firing, | |
| 13417 // First callback to fire (used internally by add and fireWith) | |
| 13418 firingStart, | |
| 13419 // End of the loop when firing | |
| 13420 firingLength, | |
| 13421 // Index of currently firing callback (modified by remove if needed) | |
| 13422 firingIndex, | |
| 13423 // Actual callback list | |
| 13424 list = [], | |
| 13425 // Stack of fire calls for repeatable lists | |
| 13426 stack = !options.once && [], | |
| 13427 // Fire callbacks | |
| 13428 fire = function( data ) { | |
| 13429 memory = options.memory && data; | |
| 13430 fired = true; | |
| 13431 firingIndex = firingStart || 0; | |
| 13432 firingStart = 0; | |
| 13433 firingLength = list.length; | |
| 13434 firing = true; | |
| 13435 for ( ; list && firingIndex < firingLength; firingIndex++ ) { | |
| 13436 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { | |
| 13437 memory = false; // To prevent further calls using add | |
| 13438 break; | |
| 13439 } | |
| 13440 } | |
| 13441 firing = false; | |
| 13442 if ( list ) { | |
| 13443 if ( stack ) { | |
| 13444 if ( stack.length ) { | |
| 13445 fire( stack.shift() ); | |
| 13446 } | |
| 13447 } else if ( memory ) { | |
| 13448 list = []; | |
| 13449 } else { | |
| 13450 self.disable(); | |
| 13451 } | |
| 13452 } | |
| 13453 }, | |
| 13454 // Actual Callbacks object | |
| 13455 self = { | |
| 13456 // Add a callback or a collection of callbacks to the list | |
| 13457 add: function() { | |
| 13458 if ( list ) { | |
| 13459 // First, we save the current length | |
| 13460 var start = list.length; | |
| 13461 (function add( args ) { | |
| 13462 jQuery.each( args, function( _, arg ) { | |
| 13463 var type = jQuery.type( arg ); | |
| 13464 if ( type === "function" ) { | |
| 13465 if ( !options.unique || !self.has( arg ) ) { | |
| 13466 list.push( arg ); | |
| 13467 } | |
| 13468 } else if ( arg && arg.length && type !== "string" ) { | |
| 13469 // Inspect recursively | |
| 13470 add( arg ); | |
| 13471 } | |
| 13472 }); | |
| 13473 })( arguments ); | |
| 13474 // Do we need to add the callbacks to the | |
| 13475 // current firing batch? | |
| 13476 if ( firing ) { | |
| 13477 firingLength = list.length; | |
| 13478 // With memory, if we're not firing then | |
| 13479 // we should call right away | |
| 13480 } else if ( memory ) { | |
| 13481 firingStart = start; | |
| 13482 fire( memory ); | |
| 13483 } | |
| 13484 } | |
| 13485 return this; | |
| 13486 }, | |
| 13487 // Remove a callback from the list | |
| 13488 remove: function() { | |
| 13489 if ( list ) { | |
| 13490 jQuery.each( arguments, function( _, arg ) { | |
| 13491 var index; | |
| 13492 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { | |
| 13493 list.splice( index, 1 ); | |
| 13494 // Handle firing indexes | |
| 13495 if ( firing ) { | |
| 13496 if ( index <= firingLength ) { | |
| 13497 firingLength--; | |
| 13498 } | |
| 13499 if ( index <= firingIndex ) { | |
| 13500 firingIndex--; | |
| 13501 } | |
| 13502 } | |
| 13503 } | |
| 13504 }); | |
| 13505 } | |
| 13506 return this; | |
| 13507 }, | |
| 13508 // Check if a given callback is in the list. | |
| 13509 // If no argument is given, return whether or not list has callbacks attached. | |
| 13510 has: function( fn ) { | |
| 13511 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); | |
| 13512 }, | |
| 13513 // Remove all callbacks from the list | |
| 13514 empty: function() { | |
| 13515 list = []; | |
| 13516 firingLength = 0; | |
| 13517 return this; | |
| 13518 }, | |
| 13519 // Have the list do nothing anymore | |
| 13520 disable: function() { | |
| 13521 list = stack = memory = undefined; | |
| 13522 return this; | |
| 13523 }, | |
| 13524 // Is it disabled? | |
| 13525 disabled: function() { | |
| 13526 return !list; | |
| 13527 }, | |
| 13528 // Lock the list in its current state | |
| 13529 lock: function() { | |
| 13530 stack = undefined; | |
| 13531 if ( !memory ) { | |
| 13532 self.disable(); | |
| 13533 } | |
| 13534 return this; | |
| 13535 }, | |
| 13536 // Is it locked? | |
| 13537 locked: function() { | |
| 13538 return !stack; | |
| 13539 }, | |
| 13540 // Call all callbacks with the given context and arguments | |
| 13541 fireWith: function( context, args ) { | |
| 13542 if ( list && ( !fired || stack ) ) { | |
| 13543 args = args || []; | |
| 13544 args = [ context, args.slice ? args.slice() : args ]; | |
| 13545 if ( firing ) { | |
| 13546 stack.push( args ); | |
| 13547 } else { | |
| 13548 fire( args ); | |
| 13549 } | |
| 13550 } | |
| 13551 return this; | |
| 13552 }, | |
| 13553 // Call all the callbacks with the given arguments | |
| 13554 fire: function() { | |
| 13555 self.fireWith( this, arguments ); | |
| 13556 return this; | |
| 13557 }, | |
| 13558 // To know if the callbacks have already been called at least once | |
| 13559 fired: function() { | |
| 13560 return !!fired; | |
| 13561 } | |
| 13562 }; | |
| 13563 | |
| 13564 return self; | |
| 13565 }; | |
| 13566 | |
| 13567 | |
| 13568 jQuery.extend({ | |
| 13569 | |
| 13570 Deferred: function( func ) { | |
| 13571 var tuples = [ | |
| 13572 // action, add listener, listener list, final state | |
| 13573 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], | |
| 13574 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], | |
| 13575 [ "notify", "progress", jQuery.Callbacks("memory") ] | |
| 13576 ], | |
| 13577 state = "pending", | |
| 13578 promise = { | |
| 13579 state: function() { | |
| 13580 return state; | |
| 13581 }, | |
| 13582 always: function() { | |
| 13583 deferred.done( arguments ).fail( arguments ); | |
| 13584 return this; | |
| 13585 }, | |
| 13586 then: function( /* fnDone, fnFail, fnProgress */ ) { | |
| 13587 var fns = arguments; | |
| 13588 return jQuery.Deferred(function( newDefer ) { | |
| 13589 jQuery.each( tuples, function( i, tuple ) { | |
| 13590 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; | |
| 13591 // deferred[ done | fail | progress ] for forwarding actions to newDefer | |
| 13592 deferred[ tuple[1] ](function() { | |
| 13593 var returned = fn && fn.apply( this, arguments ); | |
| 13594 if ( returned && jQuery.isFunction( returned.promise ) ) { | |
| 13595 returned.promise() | |
| 13596 .done( newDefer.resolve ) | |
| 13597 .fail( newDefer.reject ) | |
| 13598 .progress( newDefer.notify ); | |
| 13599 } else { | |
| 13600 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); | |
| 13601 } | |
| 13602 }); | |
| 13603 }); | |
| 13604 fns = null; | |
| 13605 }).promise(); | |
| 13606 }, | |
| 13607 // Get a promise for this deferred | |
| 13608 // If obj is provided, the promise aspect is added to the object | |
| 13609 promise: function( obj ) { | |
| 13610 return obj != null ? jQuery.extend( obj, promise ) : promise; | |
| 13611 } | |
| 13612 }, | |
| 13613 deferred = {}; | |
| 13614 | |
| 13615 // Keep pipe for back-compat | |
| 13616 promise.pipe = promise.then; | |
| 13617 | |
| 13618 // Add list-specific methods | |
| 13619 jQuery.each( tuples, function( i, tuple ) { | |
| 13620 var list = tuple[ 2 ], | |
| 13621 stateString = tuple[ 3 ]; | |
| 13622 | |
| 13623 // promise[ done | fail | progress ] = list.add | |
| 13624 promise[ tuple[1] ] = list.add; | |
| 13625 | |
| 13626 // Handle state | |
| 13627 if ( stateString ) { | |
| 13628 list.add(function() { | |
| 13629 // state = [ resolved | rejected ] | |
| 13630 state = stateString; | |
| 13631 | |
| 13632 // [ reject_list | resolve_list ].disable; progress_list.lock | |
| 13633 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); | |
| 13634 } | |
| 13635 | |
| 13636 // deferred[ resolve | reject | notify ] | |
| 13637 deferred[ tuple[0] ] = function() { | |
| 13638 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); | |
| 13639 return this; | |
| 13640 }; | |
| 13641 deferred[ tuple[0] + "With" ] = list.fireWith; | |
| 13642 }); | |
| 13643 | |
| 13644 // Make the deferred a promise | |
| 13645 promise.promise( deferred ); | |
| 13646 | |
| 13647 // Call given func if any | |
| 13648 if ( func ) { | |
| 13649 func.call( deferred, deferred ); | |
| 13650 } | |
| 13651 | |
| 13652 // All done! | |
| 13653 return deferred; | |
| 13654 }, | |
| 13655 | |
| 13656 // Deferred helper | |
| 13657 when: function( subordinate /* , ..., subordinateN */ ) { | |
| 13658 var i = 0, | |
| 13659 resolveValues = slice.call( arguments ), | |
| 13660 length = resolveValues.length, | |
| 13661 | |
| 13662 // the count of uncompleted subordinates | |
| 13663 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, | |
| 13664 | |
| 13665 // the master Deferred. If resolveValues consist of only a single Deferred, just use that. | |
| 13666 deferred = remaining === 1 ? subordinate : jQuery.Deferred(), | |
| 13667 | |
| 13668 // Update function for both resolve and progress values | |
| 13669 updateFunc = function( i, contexts, values ) { | |
| 13670 return function( value ) { | |
| 13671 contexts[ i ] = this; | |
| 13672 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; | |
| 13673 if ( values === progressValues ) { | |
| 13674 deferred.notifyWith( contexts, values ); | |
| 13675 } else if ( !( --remaining ) ) { | |
| 13676 deferred.resolveWith( contexts, values ); | |
| 13677 } | |
| 13678 }; | |
| 13679 }, | |
| 13680 | |
| 13681 progressValues, progressContexts, resolveContexts; | |
| 13682 | |
| 13683 // Add listeners to Deferred subordinates; treat others as resolved | |
| 13684 if ( length > 1 ) { | |
| 13685 progressValues = new Array( length ); | |
| 13686 progressContexts = new Array( length ); | |
| 13687 resolveContexts = new Array( length ); | |
| 13688 for ( ; i < length; i++ ) { | |
| 13689 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { | |
| 13690 resolveValues[ i ].promise() | |
| 13691 .done( updateFunc( i, resolveContexts, resolveValues ) ) | |
| 13692 .fail( deferred.reject ) | |
| 13693 .progress( updateFunc( i, progressContexts, progressValues ) ); | |
| 13694 } else { | |
| 13695 --remaining; | |
| 13696 } | |
| 13697 } | |
| 13698 } | |
| 13699 | |
| 13700 // If we're not waiting on anything, resolve the master | |
| 13701 if ( !remaining ) { | |
| 13702 deferred.resolveWith( resolveContexts, resolveValues ); | |
| 13703 } | |
| 13704 | |
| 13705 return deferred.promise(); | |
| 13706 } | |
| 13707 }); | |
| 13708 | |
| 13709 | |
| 13710 // The deferred used on DOM ready | |
| 13711 var readyList; | |
| 13712 | |
| 13713 jQuery.fn.ready = function( fn ) { | |
| 13714 // Add the callback | |
| 13715 jQuery.ready.promise().done( fn ); | |
| 13716 | |
| 13717 return this; | |
| 13718 }; | |
| 13719 | |
| 13720 jQuery.extend({ | |
| 13721 // Is the DOM ready to be used? Set to true once it occurs. | |
| 13722 isReady: false, | |
| 13723 | |
| 13724 // A counter to track how many items to wait for before | |
| 13725 // the ready event fires. See #6781 | |
| 13726 readyWait: 1, | |
| 13727 | |
| 13728 // Hold (or release) the ready event | |
| 13729 holdReady: function( hold ) { | |
| 13730 if ( hold ) { | |
| 13731 jQuery.readyWait++; | |
| 13732 } else { | |
| 13733 jQuery.ready( true ); | |
| 13734 } | |
| 13735 }, | |
| 13736 | |
| 13737 // Handle when the DOM is ready | |
| 13738 ready: function( wait ) { | |
| 13739 | |
| 13740 // Abort if there are pending holds or we're already ready | |
| 13741 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { | |
| 13742 return; | |
| 13743 } | |
| 13744 | |
| 13745 // Remember that the DOM is ready | |
| 13746 jQuery.isReady = true; | |
| 13747 | |
| 13748 // If a normal DOM Ready event fired, decrement, and wait if need be | |
| 13749 if ( wait !== true && --jQuery.readyWait > 0 ) { | |
| 13750 return; | |
| 13751 } | |
| 13752 | |
| 13753 // If there are functions bound, to execute | |
| 13754 readyList.resolveWith( document, [ jQuery ] ); | |
| 13755 | |
| 13756 // Trigger any bound ready events | |
| 13757 if ( jQuery.fn.triggerHandler ) { | |
| 13758 jQuery( document ).triggerHandler( "ready" ); | |
| 13759 jQuery( document ).off( "ready" ); | |
| 13760 } | |
| 13761 } | |
| 13762 }); | |
| 13763 | |
| 13764 /** | |
| 13765 * The ready event handler and self cleanup method | |
| 13766 */ | |
| 13767 function completed() { | |
| 13768 document.removeEventListener( "DOMContentLoaded", completed, false ); | |
| 13769 window.removeEventListener( "load", completed, false ); | |
| 13770 jQuery.ready(); | |
| 13771 } | |
| 13772 | |
| 13773 jQuery.ready.promise = function( obj ) { | |
| 13774 if ( !readyList ) { | |
| 13775 | |
| 13776 readyList = jQuery.Deferred(); | |
| 13777 | |
| 13778 // Catch cases where $(document).ready() is called after the browser event has already occurred. | |
| 13779 // We once tried to use readyState "interactive" here, but it caused issues like the one | |
| 13780 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 | |
| 13781 if ( document.readyState === "complete" ) { | |
| 13782 // Handle it asynchronously to allow scripts the opportunity to delay ready | |
| 13783 setTimeout( jQuery.ready ); | |
| 13784 | |
| 13785 } else { | |
| 13786 | |
| 13787 // Use the handy event callback | |
| 13788 document.addEventListener( "DOMContentLoaded", completed, false ); | |
| 13789 | |
| 13790 // A fallback to window.onload, that will always work | |
| 13791 window.addEventListener( "load", completed, false ); | |
| 13792 } | |
| 13793 } | |
| 13794 return readyList.promise( obj ); | |
| 13795 }; | |
| 13796 | |
| 13797 // Kick off the DOM ready check even if the user does not | |
| 13798 jQuery.ready.promise(); | |
| 13799 | |
| 13800 | |
| 13801 | |
| 13802 | |
| 13803 // Multifunctional method to get and set values of a collection | |
| 13804 // The value/s can optionally be executed if it's a function | |
| 13805 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { | |
| 13806 var i = 0, | |
| 13807 len = elems.length, | |
| 13808 bulk = key == null; | |
| 13809 | |
| 13810 // Sets many values | |
| 13811 if ( jQuery.type( key ) === "object" ) { | |
| 13812 chainable = true; | |
| 13813 for ( i in key ) { | |
| 13814 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); | |
| 13815 } | |
| 13816 | |
| 13817 // Sets one value | |
| 13818 } else if ( value !== undefined ) { | |
| 13819 chainable = true; | |
| 13820 | |
| 13821 if ( !jQuery.isFunction( value ) ) { | |
| 13822 raw = true; | |
| 13823 } | |
| 13824 | |
| 13825 if ( bulk ) { | |
| 13826 // Bulk operations run against the entire set | |
| 13827 if ( raw ) { | |
| 13828 fn.call( elems, value ); | |
| 13829 fn = null; | |
| 13830 | |
| 13831 // ...except when executing function values | |
| 13832 } else { | |
| 13833 bulk = fn; | |
| 13834 fn = function( elem, key, value ) { | |
| 13835 return bulk.call( jQuery( elem ), value ); | |
| 13836 }; | |
| 13837 } | |
| 13838 } | |
| 13839 | |
| 13840 if ( fn ) { | |
| 13841 for ( ; i < len; i++ ) { | |
| 13842 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); | |
| 13843 } | |
| 13844 } | |
| 13845 } | |
| 13846 | |
| 13847 return chainable ? | |
| 13848 elems : | |
| 13849 | |
| 13850 // Gets | |
| 13851 bulk ? | |
| 13852 fn.call( elems ) : | |
| 13853 len ? fn( elems[0], key ) : emptyGet; | |
| 13854 }; | |
| 13855 | |
| 13856 | |
| 13857 /** | |
| 13858 * Determines whether an object can have data | |
| 13859 */ | |
| 13860 jQuery.acceptData = function( owner ) { | |
| 13861 // Accepts only: | |
| 13862 // - Node | |
| 13863 // - Node.ELEMENT_NODE | |
| 13864 // - Node.DOCUMENT_NODE | |
| 13865 // - Object | |
| 13866 // - Any | |
| 13867 /* jshint -W018 */ | |
| 13868 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); | |
| 13869 }; | |
| 13870 | |
| 13871 | |
| 13872 function Data() { | |
| 13873 // Support: Android<4, | |
| 13874 // Old WebKit does not have Object.preventExtensions/freeze method, | |
| 13875 // return new empty object instead with no [[set]] accessor | |
| 13876 Object.defineProperty( this.cache = {}, 0, { | |
| 13877 get: function() { | |
| 13878 return {}; | |
| 13879 } | |
| 13880 }); | |
| 13881 | |
| 13882 this.expando = jQuery.expando + Data.uid++; | |
| 13883 } | |
| 13884 | |
| 13885 Data.uid = 1; | |
| 13886 Data.accepts = jQuery.acceptData; | |
| 13887 | |
| 13888 Data.prototype = { | |
| 13889 key: function( owner ) { | |
| 13890 // We can accept data for non-element nodes in modern browsers, | |
| 13891 // but we should not, see #8335. | |
| 13892 // Always return the key for a frozen object. | |
| 13893 if ( !Data.accepts( owner ) ) { | |
| 13894 return 0; | |
| 13895 } | |
| 13896 | |
| 13897 var descriptor = {}, | |
| 13898 // Check if the owner object already has a cache key | |
| 13899 unlock = owner[ this.expando ]; | |
| 13900 | |
| 13901 // If not, create one | |
| 13902 if ( !unlock ) { | |
| 13903 unlock = Data.uid++; | |
| 13904 | |
| 13905 // Secure it in a non-enumerable, non-writable property | |
| 13906 try { | |
| 13907 descriptor[ this.expando ] = { value: unlock }; | |
| 13908 Object.defineProperties( owner, descriptor ); | |
| 13909 | |
| 13910 // Support: Android<4 | |
| 13911 // Fallback to a less secure definition | |
| 13912 } catch ( e ) { | |
| 13913 descriptor[ this.expando ] = unlock; | |
| 13914 jQuery.extend( owner, descriptor ); | |
| 13915 } | |
| 13916 } | |
| 13917 | |
| 13918 // Ensure the cache object | |
| 13919 if ( !this.cache[ unlock ] ) { | |
| 13920 this.cache[ unlock ] = {}; | |
| 13921 } | |
| 13922 | |
| 13923 return unlock; | |
| 13924 }, | |
| 13925 set: function( owner, data, value ) { | |
| 13926 var prop, | |
| 13927 // There may be an unlock assigned to this node, | |
| 13928 // if there is no entry for this "owner", create one inline | |
| 13929 // and set the unlock as though an owner entry had always existed | |
| 13930 unlock = this.key( owner ), | |
| 13931 cache = this.cache[ unlock ]; | |
| 13932 | |
| 13933 // Handle: [ owner, key, value ] args | |
| 13934 if ( typeof data === "string" ) { | |
| 13935 cache[ data ] = value; | |
| 13936 | |
| 13937 // Handle: [ owner, { properties } ] args | |
| 13938 } else { | |
| 13939 // Fresh assignments by object are shallow copied | |
| 13940 if ( jQuery.isEmptyObject( cache ) ) { | |
| 13941 jQuery.extend( this.cache[ unlock ], data ); | |
| 13942 // Otherwise, copy the properties one-by-one to the cache object | |
| 13943 } else { | |
| 13944 for ( prop in data ) { | |
| 13945 cache[ prop ] = data[ prop ]; | |
| 13946 } | |
| 13947 } | |
| 13948 } | |
| 13949 return cache; | |
| 13950 }, | |
| 13951 get: function( owner, key ) { | |
| 13952 // Either a valid cache is found, or will be created. | |
| 13953 // New caches will be created and the unlock returned, | |
| 13954 // allowing direct access to the newly created | |
| 13955 // empty data object. A valid owner object must be provided. | |
| 13956 var cache = this.cache[ this.key( owner ) ]; | |
| 13957 | |
| 13958 return key === undefined ? | |
| 13959 cache : cache[ key ]; | |
| 13960 }, | |
| 13961 access: function( owner, key, value ) { | |
| 13962 var stored; | |
| 13963 // In cases where either: | |
| 13964 // | |
| 13965 // 1. No key was specified | |
| 13966 // 2. A string key was specified, but no value provided | |
| 13967 // | |
| 13968 // Take the "read" path and allow the get method to determine | |
| 13969 // which value to return, respectively either: | |
| 13970 // | |
| 13971 // 1. The entire cache object | |
| 13972 // 2. The data stored at the key | |
| 13973 // | |
| 13974 if ( key === undefined || | |
| 13975 ((key && typeof key === "string") && value === undefined) ) { | |
| 13976 | |
| 13977 stored = this.get( owner, key ); | |
| 13978 | |
| 13979 return stored !== undefined ? | |
| 13980 stored : this.get( owner, jQuery.camelCase(key) ); | |
| 13981 } | |
| 13982 | |
| 13983 // [*]When the key is not a string, or both a key and value | |
| 13984 // are specified, set or extend (existing objects) with either: | |
| 13985 // | |
| 13986 // 1. An object of properties | |
| 13987 // 2. A key and value | |
| 13988 // | |
| 13989 this.set( owner, key, value ); | |
| 13990 | |
| 13991 // Since the "set" path can have two possible entry points | |
| 13992 // return the expected data based on which path was taken[*] | |
| 13993 return value !== undefined ? value : key; | |
| 13994 }, | |
| 13995 remove: function( owner, key ) { | |
| 13996 var i, name, camel, | |
| 13997 unlock = this.key( owner ), | |
| 13998 cache = this.cache[ unlock ]; | |
| 13999 | |
| 14000 if ( key === undefined ) { | |
| 14001 this.cache[ unlock ] = {}; | |
| 14002 | |
| 14003 } else { | |
| 14004 // Support array or space separated string of keys | |
| 14005 if ( jQuery.isArray( key ) ) { | |
| 14006 // If "name" is an array of keys... | |
| 14007 // When data is initially created, via ("key", "val") signature, | |
| 14008 // keys will be converted to camelCase. | |
| 14009 // Since there is no way to tell _how_ a key was added, remove | |
| 14010 // both plain key and camelCase key. #12786 | |
| 14011 // This will only penalize the array argument path. | |
| 14012 name = key.concat( key.map( jQuery.camelCase ) ); | |
| 14013 } else { | |
| 14014 camel = jQuery.camelCase( key ); | |
| 14015 // Try the string as a key before any manipulation | |
| 14016 if ( key in cache ) { | |
| 14017 name = [ key, camel ]; | |
| 14018 } else { | |
| 14019 // If a key with the spaces exists, use it. | |
| 14020 // Otherwise, create an array by matching non-whitespace | |
| 14021 name = camel; | |
| 14022 name = name in cache ? | |
| 14023 [ name ] : ( name.match( rnotwhite ) || [] ); | |
| 14024 } | |
| 14025 } | |
| 14026 | |
| 14027 i = name.length; | |
| 14028 while ( i-- ) { | |
| 14029 delete cache[ name[ i ] ]; | |
| 14030 } | |
| 14031 } | |
| 14032 }, | |
| 14033 hasData: function( owner ) { | |
| 14034 return !jQuery.isEmptyObject( | |
| 14035 this.cache[ owner[ this.expando ] ] || {} | |
| 14036 ); | |
| 14037 }, | |
| 14038 discard: function( owner ) { | |
| 14039 if ( owner[ this.expando ] ) { | |
| 14040 delete this.cache[ owner[ this.expando ] ]; | |
| 14041 } | |
| 14042 } | |
| 14043 }; | |
| 14044 var data_priv = new Data(); | |
| 14045 | |
| 14046 var data_user = new Data(); | |
| 14047 | |
| 14048 | |
| 14049 | |
| 14050 // Implementation Summary | |
| 14051 // | |
| 14052 // 1. Enforce API surface and semantic compatibility with 1.9.x branch | |
| 14053 // 2. Improve the module's maintainability by reducing the storage | |
| 14054 // paths to a single mechanism. | |
| 14055 // 3. Use the same single mechanism to support "private" and "user" data. | |
| 14056 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) | |
| 14057 // 5. Avoid exposing implementation details on user objects (eg. expando properties) | |
| 14058 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014 | |
| 14059 | |
| 14060 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, | |
| 14061 rmultiDash = /([A-Z])/g; | |
| 14062 | |
| 14063 function dataAttr( elem, key, data ) { | |
| 14064 var name; | |
| 14065 | |
| 14066 // If nothing was found internally, try to fetch any | |
| 14067 // data from the HTML5 data-* attribute | |
| 14068 if ( data === undefined && elem.nodeType === 1 ) { | |
| 14069 name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); | |
| 14070 data = elem.getAttribute( name ); | |
| 14071 | |
| 14072 if ( typeof data === "string" ) { | |
| 14073 try { | |
| 14074 data = data === "true" ? true : | |
| 14075 data === "false" ? false : | |
| 14076 data === "null" ? null : | |
| 14077 // Only convert to a number if it doesn't change the string | |
| 14078 +data + "" === data ? +data : | |
| 14079 rbrace.test( data ) ? jQuery.parseJSON( data ) : | |
| 14080 data; | |
| 14081 } catch( e ) {} | |
| 14082 | |
| 14083 // Make sure we set the data so it isn't changed later | |
| 14084 data_user.set( elem, key, data ); | |
| 14085 } else { | |
| 14086 data = undefined; | |
| 14087 } | |
| 14088 } | |
| 14089 return data; | |
| 14090 } | |
| 14091 | |
| 14092 jQuery.extend({ | |
| 14093 hasData: function( elem ) { | |
| 14094 return data_user.hasData( elem ) || data_priv.hasData( elem ); | |
| 14095 }, | |
| 14096 | |
| 14097 data: function( elem, name, data ) { | |
| 14098 return data_user.access( elem, name, data ); | |
| 14099 }, | |
| 14100 | |
| 14101 removeData: function( elem, name ) { | |
| 14102 data_user.remove( elem, name ); | |
| 14103 }, | |
| 14104 | |
| 14105 // TODO: Now that all calls to _data and _removeData have been replaced | |
| 14106 // with direct calls to data_priv methods, these can be deprecated. | |
| 14107 _data: function( elem, name, data ) { | |
| 14108 return data_priv.access( elem, name, data ); | |
| 14109 }, | |
| 14110 | |
| 14111 _removeData: function( elem, name ) { | |
| 14112 data_priv.remove( elem, name ); | |
| 14113 } | |
| 14114 }); | |
| 14115 | |
| 14116 jQuery.fn.extend({ | |
| 14117 data: function( key, value ) { | |
| 14118 var i, name, data, | |
| 14119 elem = this[ 0 ], | |
| 14120 attrs = elem && elem.attributes; | |
| 14121 | |
| 14122 // Gets all values | |
| 14123 if ( key === undefined ) { | |
| 14124 if ( this.length ) { | |
| 14125 data = data_user.get( elem ); | |
| 14126 | |
| 14127 if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) { | |
| 14128 i = attrs.length; | |
| 14129 while ( i-- ) { | |
| 14130 | |
| 14131 // Support: IE11+ | |
| 14132 // The attrs elements can be null (#14894) | |
| 14133 if ( attrs[ i ] ) { | |
| 14134 name = attrs[ i ].name; | |
| 14135 if ( name.indexOf( "data-" ) === 0 ) { | |
| 14136 name = jQuery.camelCase( name.slice(5) ); | |
| 14137 dataAttr( elem, name, data[ name ] ); | |
| 14138 } | |
| 14139 } | |
| 14140 } | |
| 14141 data_priv.set( elem, "hasDataAttrs", true ); | |
| 14142 } | |
| 14143 } | |
| 14144 | |
| 14145 return data; | |
| 14146 } | |
| 14147 | |
| 14148 // Sets multiple values | |
| 14149 if ( typeof key === "object" ) { | |
| 14150 return this.each(function() { | |
| 14151 data_user.set( this, key ); | |
| 14152 }); | |
| 14153 } | |
| 14154 | |
| 14155 return access( this, function( value ) { | |
| 14156 var data, | |
| 14157 camelKey = jQuery.camelCase( key ); | |
| 14158 | |
| 14159 // The calling jQuery object (element matches) is not empty | |
| 14160 // (and therefore has an element appears at this[ 0 ]) and the | |
| 14161 // `value` parameter was not undefined. An empty jQuery object | |
| 14162 // will result in `undefined` for elem = this[ 0 ] which will | |
| 14163 // throw an exception if an attempt to read a data cache is made. | |
| 14164 if ( elem && value === undefined ) { | |
| 14165 // Attempt to get data from the cache | |
| 14166 // with the key as-is | |
| 14167 data = data_user.get( elem, key ); | |
| 14168 if ( data !== undefined ) { | |
| 14169 return data; | |
| 14170 } | |
| 14171 | |
| 14172 // Attempt to get data from the cache | |
| 14173 // with the key camelized | |
| 14174 data = data_user.get( elem, camelKey ); | |
| 14175 if ( data !== undefined ) { | |
| 14176 return data; | |
| 14177 } | |
| 14178 | |
| 14179 // Attempt to "discover" the data in | |
| 14180 // HTML5 custom data-* attrs | |
| 14181 data = dataAttr( elem, camelKey, undefined ); | |
| 14182 if ( data !== undefined ) { | |
| 14183 return data; | |
| 14184 } | |
| 14185 | |
| 14186 // We tried really hard, but the data doesn't exist. | |
| 14187 return; | |
| 14188 } | |
| 14189 | |
| 14190 // Set the data... | |
| 14191 this.each(function() { | |
| 14192 // First, attempt to store a copy or reference of any | |
| 14193 // data that might've been store with a camelCased key. | |
| 14194 var data = data_user.get( this, camelKey ); | |
| 14195 | |
| 14196 // For HTML5 data-* attribute interop, we have to | |
| 14197 // store property names with dashes in a camelCase form. | |
| 14198 // This might not apply to all properties...* | |
| 14199 data_user.set( this, camelKey, value ); | |
| 14200 | |
| 14201 // *... In the case of properties that might _actually_ | |
| 14202 // have dashes, we need to also store a copy of that | |
| 14203 // unchanged property. | |
| 14204 if ( key.indexOf("-") !== -1 && data !== undefined ) { | |
| 14205 data_user.set( this, key, value ); | |
| 14206 } | |
| 14207 }); | |
| 14208 }, null, value, arguments.length > 1, null, true ); | |
| 14209 }, | |
| 14210 | |
| 14211 removeData: function( key ) { | |
| 14212 return this.each(function() { | |
| 14213 data_user.remove( this, key ); | |
| 14214 }); | |
| 14215 } | |
| 14216 }); | |
| 14217 | |
| 14218 | |
| 14219 jQuery.extend({ | |
| 14220 queue: function( elem, type, data ) { | |
| 14221 var queue; | |
| 14222 | |
| 14223 if ( elem ) { | |
| 14224 type = ( type || "fx" ) + "queue"; | |
| 14225 queue = data_priv.get( elem, type ); | |
| 14226 | |
| 14227 // Speed up dequeue by getting out quickly if this is just a lookup | |
| 14228 if ( data ) { | |
| 14229 if ( !queue || jQuery.isArray( data ) ) { | |
| 14230 queue = data_priv.access( elem, type, jQuery.makeArray(data) ); | |
| 14231 } else { | |
| 14232 queue.push( data ); | |
| 14233 } | |
| 14234 } | |
| 14235 return queue || []; | |
| 14236 } | |
| 14237 }, | |
| 14238 | |
| 14239 dequeue: function( elem, type ) { | |
| 14240 type = type || "fx"; | |
| 14241 | |
| 14242 var queue = jQuery.queue( elem, type ), | |
| 14243 startLength = queue.length, | |
| 14244 fn = queue.shift(), | |
| 14245 hooks = jQuery._queueHooks( elem, type ), | |
| 14246 next = function() { | |
| 14247 jQuery.dequeue( elem, type ); | |
| 14248 }; | |
| 14249 | |
| 14250 // If the fx queue is dequeued, always remove the progress sentinel | |
| 14251 if ( fn === "inprogress" ) { | |
| 14252 fn = queue.shift(); | |
| 14253 startLength--; | |
| 14254 } | |
| 14255 | |
| 14256 if ( fn ) { | |
| 14257 | |
| 14258 // Add a progress sentinel to prevent the fx queue from being | |
| 14259 // automatically dequeued | |
| 14260 if ( type === "fx" ) { | |
| 14261 queue.unshift( "inprogress" ); | |
| 14262 } | |
| 14263 | |
| 14264 // Clear up the last queue stop function | |
| 14265 delete hooks.stop; | |
| 14266 fn.call( elem, next, hooks ); | |
| 14267 } | |
| 14268 | |
| 14269 if ( !startLength && hooks ) { | |
| 14270 hooks.empty.fire(); | |
| 14271 } | |
| 14272 }, | |
| 14273 | |
| 14274 // Not public - generate a queueHooks object, or return the current one | |
| 14275 _queueHooks: function( elem, type ) { | |
| 14276 var key = type + "queueHooks"; | |
| 14277 return data_priv.get( elem, key ) || data_priv.access( elem, key, { | |
| 14278 empty: jQuery.Callbacks("once memory").add(function() { | |
| 14279 data_priv.remove( elem, [ type + "queue", key ] ); | |
| 14280 }) | |
| 14281 }); | |
| 14282 } | |
| 14283 }); | |
| 14284 | |
| 14285 jQuery.fn.extend({ | |
| 14286 queue: function( type, data ) { | |
| 14287 var setter = 2; | |
| 14288 | |
| 14289 if ( typeof type !== "string" ) { | |
| 14290 data = type; | |
| 14291 type = "fx"; | |
| 14292 setter--; | |
| 14293 } | |
| 14294 | |
| 14295 if ( arguments.length < setter ) { | |
| 14296 return jQuery.queue( this[0], type ); | |
| 14297 } | |
| 14298 | |
| 14299 return data === undefined ? | |
| 14300 this : | |
| 14301 this.each(function() { | |
| 14302 var queue = jQuery.queue( this, type, data ); | |
| 14303 | |
| 14304 // Ensure a hooks for this queue | |
| 14305 jQuery._queueHooks( this, type ); | |
| 14306 | |
| 14307 if ( type === "fx" && queue[0] !== "inprogress" ) { | |
| 14308 jQuery.dequeue( this, type ); | |
| 14309 } | |
| 14310 }); | |
| 14311 }, | |
| 14312 dequeue: function( type ) { | |
| 14313 return this.each(function() { | |
| 14314 jQuery.dequeue( this, type ); | |
| 14315 }); | |
| 14316 }, | |
| 14317 clearQueue: function( type ) { | |
| 14318 return this.queue( type || "fx", [] ); | |
| 14319 }, | |
| 14320 // Get a promise resolved when queues of a certain type | |
| 14321 // are emptied (fx is the type by default) | |
| 14322 promise: function( type, obj ) { | |
| 14323 var tmp, | |
| 14324 count = 1, | |
| 14325 defer = jQuery.Deferred(), | |
| 14326 elements = this, | |
| 14327 i = this.length, | |
| 14328 resolve = function() { | |
| 14329 if ( !( --count ) ) { | |
| 14330 defer.resolveWith( elements, [ elements ] ); | |
| 14331 } | |
| 14332 }; | |
| 14333 | |
| 14334 if ( typeof type !== "string" ) { | |
| 14335 obj = type; | |
| 14336 type = undefined; | |
| 14337 } | |
| 14338 type = type || "fx"; | |
| 14339 | |
| 14340 while ( i-- ) { | |
| 14341 tmp = data_priv.get( elements[ i ], type + "queueHooks" ); | |
| 14342 if ( tmp && tmp.empty ) { | |
| 14343 count++; | |
| 14344 tmp.empty.add( resolve ); | |
| 14345 } | |
| 14346 } | |
| 14347 resolve(); | |
| 14348 return defer.promise( obj ); | |
| 14349 } | |
| 14350 }); | |
| 14351 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; | |
| 14352 | |
| 14353 var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; | |
| 14354 | |
| 14355 var isHidden = function( elem, el ) { | |
| 14356 // isHidden might be called from jQuery#filter function; | |
| 14357 // in that case, element will be second argument | |
| 14358 elem = el || elem; | |
| 14359 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); | |
| 14360 }; | |
| 14361 | |
| 14362 var rcheckableType = (/^(?:checkbox|radio)$/i); | |
| 14363 | |
| 14364 | |
| 14365 | |
| 14366 (function() { | |
| 14367 var fragment = document.createDocumentFragment(), | |
| 14368 div = fragment.appendChild( document.createElement( "div" ) ), | |
| 14369 input = document.createElement( "input" ); | |
| 14370 | |
| 14371 // Support: Safari<=5.1 | |
| 14372 // Check state lost if the name is set (#11217) | |
| 14373 // Support: Windows Web Apps (WWA) | |
| 14374 // `name` and `type` must use .setAttribute for WWA (#14901) | |
| 14375 input.setAttribute( "type", "radio" ); | |
| 14376 input.setAttribute( "checked", "checked" ); | |
| 14377 input.setAttribute( "name", "t" ); | |
| 14378 | |
| 14379 div.appendChild( input ); | |
| 14380 | |
| 14381 // Support: Safari<=5.1, Android<4.2 | |
| 14382 // Older WebKit doesn't clone checked state correctly in fragments | |
| 14383 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; | |
| 14384 | |
| 14385 // Support: IE<=11+ | |
| 14386 // Make sure textarea (and checkbox) defaultValue is properly cloned | |
| 14387 div.innerHTML = "<textarea>x</textarea>"; | |
| 14388 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; | |
| 14389 })(); | |
| 14390 var strundefined = typeof undefined; | |
| 14391 | |
| 14392 | |
| 14393 | |
| 14394 support.focusinBubbles = "onfocusin" in window; | |
| 14395 | |
| 14396 | |
| 14397 var | |
| 14398 rkeyEvent = /^key/, | |
| 14399 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/, | |
| 14400 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, | |
| 14401 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; | |
| 14402 | |
| 14403 function returnTrue() { | |
| 14404 return true; | |
| 14405 } | |
| 14406 | |
| 14407 function returnFalse() { | |
| 14408 return false; | |
| 14409 } | |
| 14410 | |
| 14411 function safeActiveElement() { | |
| 14412 try { | |
| 14413 return document.activeElement; | |
| 14414 } catch ( err ) { } | |
| 14415 } | |
| 14416 | |
| 14417 /* | |
| 14418 * Helper functions for managing events -- not part of the public interface. | |
| 14419 * Props to Dean Edwards' addEvent library for many of the ideas. | |
| 14420 */ | |
| 14421 jQuery.event = { | |
| 14422 | |
| 14423 global: {}, | |
| 14424 | |
| 14425 add: function( elem, types, handler, data, selector ) { | |
| 14426 | |
| 14427 var handleObjIn, eventHandle, tmp, | |
| 14428 events, t, handleObj, | |
| 14429 special, handlers, type, namespaces, origType, | |
| 14430 elemData = data_priv.get( elem ); | |
| 14431 | |
| 14432 // Don't attach events to noData or text/comment nodes (but allow plain objects) | |
| 14433 if ( !elemData ) { | |
| 14434 return; | |
| 14435 } | |
| 14436 | |
| 14437 // Caller can pass in an object of custom data in lieu of the handler | |
| 14438 if ( handler.handler ) { | |
| 14439 handleObjIn = handler; | |
| 14440 handler = handleObjIn.handler; | |
| 14441 selector = handleObjIn.selector; | |
| 14442 } | |
| 14443 | |
| 14444 // Make sure that the handler has a unique ID, used to find/remove it later | |
| 14445 if ( !handler.guid ) { | |
| 14446 handler.guid = jQuery.guid++; | |
| 14447 } | |
| 14448 | |
| 14449 // Init the element's event structure and main handler, if this is the first | |
| 14450 if ( !(events = elemData.events) ) { | |
| 14451 events = elemData.events = {}; | |
| 14452 } | |
| 14453 if ( !(eventHandle = elemData.handle) ) { | |
| 14454 eventHandle = elemData.handle = function( e ) { | |
| 14455 // Discard the second event of a jQuery.event.trigger() and | |
| 14456 // when an event is called after a page has unloaded | |
| 14457 return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ? | |
| 14458 jQuery.event.dispatch.apply( elem, arguments ) : undefined; | |
| 14459 }; | |
| 14460 } | |
| 14461 | |
| 14462 // Handle multiple events separated by a space | |
| 14463 types = ( types || "" ).match( rnotwhite ) || [ "" ]; | |
| 14464 t = types.length; | |
| 14465 while ( t-- ) { | |
| 14466 tmp = rtypenamespace.exec( types[t] ) || []; | |
| 14467 type = origType = tmp[1]; | |
| 14468 namespaces = ( tmp[2] || "" ).split( "." ).sort(); | |
| 14469 | |
| 14470 // There *must* be a type, no attaching namespace-only handlers | |
| 14471 if ( !type ) { | |
| 14472 continue; | |
| 14473 } | |
| 14474 | |
| 14475 // If event changes its type, use the special event handlers for the changed type | |
| 14476 special = jQuery.event.special[ type ] || {}; | |
| 14477 | |
| 14478 // If selector defined, determine special event api type, otherwise given type | |
| 14479 type = ( selector ? special.delegateType : special.bindType ) || type; | |
| 14480 | |
| 14481 // Update special based on newly reset type | |
| 14482 special = jQuery.event.special[ type ] || {}; | |
| 14483 | |
| 14484 // handleObj is passed to all event handlers | |
| 14485 handleObj = jQuery.extend({ | |
| 14486 type: type, | |
| 14487 origType: origType, | |
| 14488 data: data, | |
| 14489 handler: handler, | |
| 14490 guid: handler.guid, | |
| 14491 selector: selector, | |
| 14492 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), | |
| 14493 namespace: namespaces.join(".") | |
| 14494 }, handleObjIn ); | |
| 14495 | |
| 14496 // Init the event handler queue if we're the first | |
| 14497 if ( !(handlers = events[ type ]) ) { | |
| 14498 handlers = events[ type ] = []; | |
| 14499 handlers.delegateCount = 0; | |
| 14500 | |
| 14501 // Only use addEventListener if the special events handler returns false | |
| 14502 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { | |
| 14503 if ( elem.addEventListener ) { | |
| 14504 elem.addEventListener( type, eventHandle, false ); | |
| 14505 } | |
| 14506 } | |
| 14507 } | |
| 14508 | |
| 14509 if ( special.add ) { | |
| 14510 special.add.call( elem, handleObj ); | |
| 14511 | |
| 14512 if ( !handleObj.handler.guid ) { | |
| 14513 handleObj.handler.guid = handler.guid; | |
| 14514 } | |
| 14515 } | |
| 14516 | |
| 14517 // Add to the element's handler list, delegates in front | |
| 14518 if ( selector ) { | |
| 14519 handlers.splice( handlers.delegateCount++, 0, handleObj ); | |
| 14520 } else { | |
| 14521 handlers.push( handleObj ); | |
| 14522 } | |
| 14523 | |
| 14524 // Keep track of which events have ever been used, for event optimization | |
| 14525 jQuery.event.global[ type ] = true; | |
| 14526 } | |
| 14527 | |
| 14528 }, | |
| 14529 | |
| 14530 // Detach an event or set of events from an element | |
| 14531 remove: function( elem, types, handler, selector, mappedTypes ) { | |
| 14532 | |
| 14533 var j, origCount, tmp, | |
| 14534 events, t, handleObj, | |
| 14535 special, handlers, type, namespaces, origType, | |
| 14536 elemData = data_priv.hasData( elem ) && data_priv.get( elem ); | |
| 14537 | |
| 14538 if ( !elemData || !(events = elemData.events) ) { | |
| 14539 return; | |
| 14540 } | |
| 14541 | |
| 14542 // Once for each type.namespace in types; type may be omitted | |
| 14543 types = ( types || "" ).match( rnotwhite ) || [ "" ]; | |
| 14544 t = types.length; | |
| 14545 while ( t-- ) { | |
| 14546 tmp = rtypenamespace.exec( types[t] ) || []; | |
| 14547 type = origType = tmp[1]; | |
| 14548 namespaces = ( tmp[2] || "" ).split( "." ).sort(); | |
| 14549 | |
| 14550 // Unbind all events (on this namespace, if provided) for the element | |
| 14551 if ( !type ) { | |
| 14552 for ( type in events ) { | |
| 14553 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); | |
| 14554 } | |
| 14555 continue; | |
| 14556 } | |
| 14557 | |
| 14558 special = jQuery.event.special[ type ] || {}; | |
| 14559 type = ( selector ? special.delegateType : special.bindType ) || type; | |
| 14560 handlers = events[ type ] || []; | |
| 14561 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); | |
| 14562 | |
| 14563 // Remove matching events | |
| 14564 origCount = j = handlers.length; | |
| 14565 while ( j-- ) { | |
| 14566 handleObj = handlers[ j ]; | |
| 14567 | |
| 14568 if ( ( mappedTypes || origType === handleObj.origType ) && | |
| 14569 ( !handler || handler.guid === handleObj.guid ) && | |
| 14570 ( !tmp || tmp.test( handleObj.namespace ) ) && | |
| 14571 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { | |
| 14572 handlers.splice( j, 1 ); | |
| 14573 | |
| 14574 if ( handleObj.selector ) { | |
| 14575 handlers.delegateCount--; | |
| 14576 } | |
| 14577 if ( special.remove ) { | |
| 14578 special.remove.call( elem, handleObj ); | |
| 14579 } | |
| 14580 } | |
| 14581 } | |
| 14582 | |
| 14583 // Remove generic event handler if we removed something and no more handlers exist | |
| 14584 // (avoids potential for endless recursion during removal of special event handlers) | |
| 14585 if ( origCount && !handlers.length ) { | |
| 14586 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { | |
| 14587 jQuery.removeEvent( elem, type, elemData.handle ); | |
| 14588 } | |
| 14589 | |
| 14590 delete events[ type ]; | |
| 14591 } | |
| 14592 } | |
| 14593 | |
| 14594 // Remove the expando if it's no longer used | |
| 14595 if ( jQuery.isEmptyObject( events ) ) { | |
| 14596 delete elemData.handle; | |
| 14597 data_priv.remove( elem, "events" ); | |
| 14598 } | |
| 14599 }, | |
| 14600 | |
| 14601 trigger: function( event, data, elem, onlyHandlers ) { | |
| 14602 | |
| 14603 var i, cur, tmp, bubbleType, ontype, handle, special, | |
| 14604 eventPath = [ elem || document ], | |
| 14605 type = hasOwn.call( event, "type" ) ? event.type : event, | |
| 14606 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; | |
| 14607 | |
| 14608 cur = tmp = elem = elem || document; | |
| 14609 | |
| 14610 // Don't do events on text and comment nodes | |
| 14611 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { | |
| 14612 return; | |
| 14613 } | |
| 14614 | |
| 14615 // focus/blur morphs to focusin/out; ensure we're not firing them right now | |
| 14616 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { | |
| 14617 return; | |
| 14618 } | |
| 14619 | |
| 14620 if ( type.indexOf(".") >= 0 ) { | |
| 14621 // Namespaced trigger; create a regexp to match event type in handle() | |
| 14622 namespaces = type.split("."); | |
| 14623 type = namespaces.shift(); | |
| 14624 namespaces.sort(); | |
| 14625 } | |
| 14626 ontype = type.indexOf(":") < 0 && "on" + type; | |
| 14627 | |
| 14628 // Caller can pass in a jQuery.Event object, Object, or just an event type string | |
| 14629 event = event[ jQuery.expando ] ? | |
| 14630 event : | |
| 14631 new jQuery.Event( type, typeof event === "object" && event ); | |
| 14632 | |
| 14633 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) | |
| 14634 event.isTrigger = onlyHandlers ? 2 : 3; | |
| 14635 event.namespace = namespaces.join("."); | |
| 14636 event.namespace_re = event.namespace ? | |
| 14637 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : | |
| 14638 null; | |
| 14639 | |
| 14640 // Clean up the event in case it is being reused | |
| 14641 event.result = undefined; | |
| 14642 if ( !event.target ) { | |
| 14643 event.target = elem; | |
| 14644 } | |
| 14645 | |
| 14646 // Clone any incoming data and prepend the event, creating the handler arg list | |
| 14647 data = data == null ? | |
| 14648 [ event ] : | |
| 14649 jQuery.makeArray( data, [ event ] ); | |
| 14650 | |
| 14651 // Allow special events to draw outside the lines | |
| 14652 special = jQuery.event.special[ type ] || {}; | |
| 14653 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { | |
| 14654 return; | |
| 14655 } | |
| 14656 | |
| 14657 // Determine event propagation path in advance, per W3C events spec (#9951) | |
| 14658 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) | |
| 14659 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { | |
| 14660 | |
| 14661 bubbleType = special.delegateType || type; | |
| 14662 if ( !rfocusMorph.test( bubbleType + type ) ) { | |
| 14663 cur = cur.parentNode; | |
| 14664 } | |
| 14665 for ( ; cur; cur = cur.parentNode ) { | |
| 14666 eventPath.push( cur ); | |
| 14667 tmp = cur; | |
| 14668 } | |
| 14669 | |
| 14670 // Only add window if we got to document (e.g., not plain obj or detached DOM) | |
| 14671 if ( tmp === (elem.ownerDocument || document) ) { | |
| 14672 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); | |
| 14673 } | |
| 14674 } | |
| 14675 | |
| 14676 // Fire handlers on the event path | |
| 14677 i = 0; | |
| 14678 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { | |
| 14679 | |
| 14680 event.type = i > 1 ? | |
| 14681 bubbleType : | |
| 14682 special.bindType || type; | |
| 14683 | |
| 14684 // jQuery handler | |
| 14685 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" ); | |
| 14686 if ( handle ) { | |
| 14687 handle.apply( cur, data ); | |
| 14688 } | |
| 14689 | |
| 14690 // Native handler | |
| 14691 handle = ontype && cur[ ontype ]; | |
| 14692 if ( handle && handle.apply && jQuery.acceptData( cur ) ) { | |
| 14693 event.result = handle.apply( cur, data ); | |
| 14694 if ( event.result === false ) { | |
| 14695 event.preventDefault(); | |
| 14696 } | |
| 14697 } | |
| 14698 } | |
| 14699 event.type = type; | |
| 14700 | |
| 14701 // If nobody prevented the default action, do it now | |
| 14702 if ( !onlyHandlers && !event.isDefaultPrevented() ) { | |
| 14703 | |
| 14704 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && | |
| 14705 jQuery.acceptData( elem ) ) { | |
| 14706 | |
| 14707 // Call a native DOM method on the target with the same name name as the event. | |
| 14708 // Don't do default actions on window, that's where global variables be (#6170) | |
| 14709 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { | |
| 14710 | |
| 14711 // Don't re-trigger an onFOO event when we call its FOO() method | |
| 14712 tmp = elem[ ontype ]; | |
| 14713 | |
| 14714 if ( tmp ) { | |
| 14715 elem[ ontype ] = null; | |
| 14716 } | |
| 14717 | |
| 14718 // Prevent re-triggering of the same event, since we already bubbled it above | |
| 14719 jQuery.event.triggered = type; | |
| 14720 elem[ type ](); | |
| 14721 jQuery.event.triggered = undefined; | |
| 14722 | |
| 14723 if ( tmp ) { | |
| 14724 elem[ ontype ] = tmp; | |
| 14725 } | |
| 14726 } | |
| 14727 } | |
| 14728 } | |
| 14729 | |
| 14730 return event.result; | |
| 14731 }, | |
| 14732 | |
| 14733 dispatch: function( event ) { | |
| 14734 | |
| 14735 // Make a writable jQuery.Event from the native event object | |
| 14736 event = jQuery.event.fix( event ); | |
| 14737 | |
| 14738 var i, j, ret, matched, handleObj, | |
| 14739 handlerQueue = [], | |
| 14740 args = slice.call( arguments ), | |
| 14741 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [], | |
| 14742 special = jQuery.event.special[ event.type ] || {}; | |
| 14743 | |
| 14744 // Use the fix-ed jQuery.Event rather than the (read-only) native event | |
| 14745 args[0] = event; | |
| 14746 event.delegateTarget = this; | |
| 14747 | |
| 14748 // Call the preDispatch hook for the mapped type, and let it bail if desired | |
| 14749 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { | |
| 14750 return; | |
| 14751 } | |
| 14752 | |
| 14753 // Determine handlers | |
| 14754 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); | |
| 14755 | |
| 14756 // Run delegates first; they may want to stop propagation beneath us | |
| 14757 i = 0; | |
| 14758 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { | |
| 14759 event.currentTarget = matched.elem; | |
| 14760 | |
| 14761 j = 0; | |
| 14762 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { | |
| 14763 | |
| 14764 // Triggered event must either 1) have no namespace, or 2) have namespace(s) | |
| 14765 // a subset or equal to those in the bound event (both can have no namespace). | |
| 14766 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { | |
| 14767 | |
| 14768 event.handleObj = handleObj; | |
| 14769 event.data = handleObj.data; | |
| 14770 | |
| 14771 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) | |
| 14772 .apply( matched.elem, args ); | |
| 14773 | |
| 14774 if ( ret !== undefined ) { | |
| 14775 if ( (event.result = ret) === false ) { | |
| 14776 event.preventDefault(); | |
| 14777 event.stopPropagation(); | |
| 14778 } | |
| 14779 } | |
| 14780 } | |
| 14781 } | |
| 14782 } | |
| 14783 | |
| 14784 // Call the postDispatch hook for the mapped type | |
| 14785 if ( special.postDispatch ) { | |
| 14786 special.postDispatch.call( this, event ); | |
| 14787 } | |
| 14788 | |
| 14789 return event.result; | |
| 14790 }, | |
| 14791 | |
| 14792 handlers: function( event, handlers ) { | |
| 14793 var i, matches, sel, handleObj, | |
| 14794 handlerQueue = [], | |
| 14795 delegateCount = handlers.delegateCount, | |
| 14796 cur = event.target; | |
| 14797 | |
| 14798 // Find delegate handlers | |
| 14799 // Black-hole SVG <use> instance trees (#13180) | |
| 14800 // Avoid non-left-click bubbling in Firefox (#3861) | |
| 14801 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { | |
| 14802 | |
| 14803 for ( ; cur !== this; cur = cur.parentNode || this ) { | |
| 14804 | |
| 14805 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) | |
| 14806 if ( cur.disabled !== true || event.type !== "click" ) { | |
| 14807 matches = []; | |
| 14808 for ( i = 0; i < delegateCount; i++ ) { | |
| 14809 handleObj = handlers[ i ]; | |
| 14810 | |
| 14811 // Don't conflict with Object.prototype properties (#13203) | |
| 14812 sel = handleObj.selector + " "; | |
| 14813 | |
| 14814 if ( matches[ sel ] === undefined ) { | |
| 14815 matches[ sel ] = handleObj.needsContext ? | |
| 14816 jQuery( sel, this ).index( cur ) >= 0 : | |
| 14817 jQuery.find( sel, this, null, [ cur ] ).length; | |
| 14818 } | |
| 14819 if ( matches[ sel ] ) { | |
| 14820 matches.push( handleObj ); | |
| 14821 } | |
| 14822 } | |
| 14823 if ( matches.length ) { | |
| 14824 handlerQueue.push({ elem: cur, handlers: matches }); | |
| 14825 } | |
| 14826 } | |
| 14827 } | |
| 14828 } | |
| 14829 | |
| 14830 // Add the remaining (directly-bound) handlers | |
| 14831 if ( delegateCount < handlers.length ) { | |
| 14832 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); | |
| 14833 } | |
| 14834 | |
| 14835 return handlerQueue; | |
| 14836 }, | |
| 14837 | |
| 14838 // Includes some event props shared by KeyEvent and MouseEvent | |
| 14839 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), | |
| 14840 | |
| 14841 fixHooks: {}, | |
| 14842 | |
| 14843 keyHooks: { | |
| 14844 props: "char charCode key keyCode".split(" "), | |
| 14845 filter: function( event, original ) { | |
| 14846 | |
| 14847 // Add which for key events | |
| 14848 if ( event.which == null ) { | |
| 14849 event.which = original.charCode != null ? original.charCode : original.keyCode; | |
| 14850 } | |
| 14851 | |
| 14852 return event; | |
| 14853 } | |
| 14854 }, | |
| 14855 | |
| 14856 mouseHooks: { | |
| 14857 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), | |
| 14858 filter: function( event, original ) { | |
| 14859 var eventDoc, doc, body, | |
| 14860 button = original.button; | |
| 14861 | |
| 14862 // Calculate pageX/Y if missing and clientX/Y available | |
| 14863 if ( event.pageX == null && original.clientX != null ) { | |
| 14864 eventDoc = event.target.ownerDocument || document; | |
| 14865 doc = eventDoc.documentElement; | |
| 14866 body = eventDoc.body; | |
| 14867 | |
| 14868 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); | |
| 14869 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); | |
| 14870 } | |
| 14871 | |
| 14872 // Add which for click: 1 === left; 2 === middle; 3 === right | |
| 14873 // Note: button is not normalized, so don't use it | |
| 14874 if ( !event.which && button !== undefined ) { | |
| 14875 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); | |
| 14876 } | |
| 14877 | |
| 14878 return event; | |
| 14879 } | |
| 14880 }, | |
| 14881 | |
| 14882 fix: function( event ) { | |
| 14883 if ( event[ jQuery.expando ] ) { | |
| 14884 return event; | |
| 14885 } | |
| 14886 | |
| 14887 // Create a writable copy of the event object and normalize some properties | |
| 14888 var i, prop, copy, | |
| 14889 type = event.type, | |
| 14890 originalEvent = event, | |
| 14891 fixHook = this.fixHooks[ type ]; | |
| 14892 | |
| 14893 if ( !fixHook ) { | |
| 14894 this.fixHooks[ type ] = fixHook = | |
| 14895 rmouseEvent.test( type ) ? this.mouseHooks : | |
| 14896 rkeyEvent.test( type ) ? this.keyHooks : | |
| 14897 {}; | |
| 14898 } | |
| 14899 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; | |
| 14900 | |
| 14901 event = new jQuery.Event( originalEvent ); | |
| 14902 | |
| 14903 i = copy.length; | |
| 14904 while ( i-- ) { | |
| 14905 prop = copy[ i ]; | |
| 14906 event[ prop ] = originalEvent[ prop ]; | |
| 14907 } | |
| 14908 | |
| 14909 // Support: Cordova 2.5 (WebKit) (#13255) | |
| 14910 // All events should have a target; Cordova deviceready doesn't | |
| 14911 if ( !event.target ) { | |
| 14912 event.target = document; | |
| 14913 } | |
| 14914 | |
| 14915 // Support: Safari 6.0+, Chrome<28 | |
| 14916 // Target should not be a text node (#504, #13143) | |
| 14917 if ( event.target.nodeType === 3 ) { | |
| 14918 event.target = event.target.parentNode; | |
| 14919 } | |
| 14920 | |
| 14921 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; | |
| 14922 }, | |
| 14923 | |
| 14924 special: { | |
| 14925 load: { | |
| 14926 // Prevent triggered image.load events from bubbling to window.load | |
| 14927 noBubble: true | |
| 14928 }, | |
| 14929 focus: { | |
| 14930 // Fire native event if possible so blur/focus sequence is correct | |
| 14931 trigger: function() { | |
| 14932 if ( this !== safeActiveElement() && this.focus ) { | |
| 14933 this.focus(); | |
| 14934 return false; | |
| 14935 } | |
| 14936 }, | |
| 14937 delegateType: "focusin" | |
| 14938 }, | |
| 14939 blur: { | |
| 14940 trigger: function() { | |
| 14941 if ( this === safeActiveElement() && this.blur ) { | |
| 14942 this.blur(); | |
| 14943 return false; | |
| 14944 } | |
| 14945 }, | |
| 14946 delegateType: "focusout" | |
| 14947 }, | |
| 14948 click: { | |
| 14949 // For checkbox, fire native event so checked state will be right | |
| 14950 trigger: function() { | |
| 14951 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { | |
| 14952 this.click(); | |
| 14953 return false; | |
| 14954 } | |
| 14955 }, | |
| 14956 | |
| 14957 // For cross-browser consistency, don't fire native .click() on links | |
| 14958 _default: function( event ) { | |
| 14959 return jQuery.nodeName( event.target, "a" ); | |
| 14960 } | |
| 14961 }, | |
| 14962 | |
| 14963 beforeunload: { | |
| 14964 postDispatch: function( event ) { | |
| 14965 | |
| 14966 // Support: Firefox 20+ | |
| 14967 // Firefox doesn't alert if the returnValue field is not set. | |
| 14968 if ( event.result !== undefined && event.originalEvent ) { | |
| 14969 event.originalEvent.returnValue = event.result; | |
| 14970 } | |
| 14971 } | |
| 14972 } | |
| 14973 }, | |
| 14974 | |
| 14975 simulate: function( type, elem, event, bubble ) { | |
| 14976 // Piggyback on a donor event to simulate a different one. | |
| 14977 // Fake originalEvent to avoid donor's stopPropagation, but if the | |
| 14978 // simulated event prevents default then we do the same on the donor. | |
| 14979 var e = jQuery.extend( | |
| 14980 new jQuery.Event(), | |
| 14981 event, | |
| 14982 { | |
| 14983 type: type, | |
| 14984 isSimulated: true, | |
| 14985 originalEvent: {} | |
| 14986 } | |
| 14987 ); | |
| 14988 if ( bubble ) { | |
| 14989 jQuery.event.trigger( e, null, elem ); | |
| 14990 } else { | |
| 14991 jQuery.event.dispatch.call( elem, e ); | |
| 14992 } | |
| 14993 if ( e.isDefaultPrevented() ) { | |
| 14994 event.preventDefault(); | |
| 14995 } | |
| 14996 } | |
| 14997 }; | |
| 14998 | |
| 14999 jQuery.removeEvent = function( elem, type, handle ) { | |
| 15000 if ( elem.removeEventListener ) { | |
| 15001 elem.removeEventListener( type, handle, false ); | |
| 15002 } | |
| 15003 }; | |
| 15004 | |
| 15005 jQuery.Event = function( src, props ) { | |
| 15006 // Allow instantiation without the 'new' keyword | |
| 15007 if ( !(this instanceof jQuery.Event) ) { | |
| 15008 return new jQuery.Event( src, props ); | |
| 15009 } | |
| 15010 | |
| 15011 // Event object | |
| 15012 if ( src && src.type ) { | |
| 15013 this.originalEvent = src; | |
| 15014 this.type = src.type; | |
| 15015 | |
| 15016 // Events bubbling up the document may have been marked as prevented | |
| 15017 // by a handler lower down the tree; reflect the correct value. | |
| 15018 this.isDefaultPrevented = src.defaultPrevented || | |
| 15019 src.defaultPrevented === undefined && | |
| 15020 // Support: Android<4.0 | |
| 15021 src.returnValue === false ? | |
| 15022 returnTrue : | |
| 15023 returnFalse; | |
| 15024 | |
| 15025 // Event type | |
| 15026 } else { | |
| 15027 this.type = src; | |
| 15028 } | |
| 15029 | |
| 15030 // Put explicitly provided properties onto the event object | |
| 15031 if ( props ) { | |
| 15032 jQuery.extend( this, props ); | |
| 15033 } | |
| 15034 | |
| 15035 // Create a timestamp if incoming event doesn't have one | |
| 15036 this.timeStamp = src && src.timeStamp || jQuery.now(); | |
| 15037 | |
| 15038 // Mark it as fixed | |
| 15039 this[ jQuery.expando ] = true; | |
| 15040 }; | |
| 15041 | |
| 15042 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding | |
| 15043 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html | |
| 15044 jQuery.Event.prototype = { | |
| 15045 isDefaultPrevented: returnFalse, | |
| 15046 isPropagationStopped: returnFalse, | |
| 15047 isImmediatePropagationStopped: returnFalse, | |
| 15048 | |
| 15049 preventDefault: function() { | |
| 15050 var e = this.originalEvent; | |
| 15051 | |
| 15052 this.isDefaultPrevented = returnTrue; | |
| 15053 | |
| 15054 if ( e && e.preventDefault ) { | |
| 15055 e.preventDefault(); | |
| 15056 } | |
| 15057 }, | |
| 15058 stopPropagation: function() { | |
| 15059 var e = this.originalEvent; | |
| 15060 | |
| 15061 this.isPropagationStopped = returnTrue; | |
| 15062 | |
| 15063 if ( e && e.stopPropagation ) { | |
| 15064 e.stopPropagation(); | |
| 15065 } | |
| 15066 }, | |
| 15067 stopImmediatePropagation: function() { | |
| 15068 var e = this.originalEvent; | |
| 15069 | |
| 15070 this.isImmediatePropagationStopped = returnTrue; | |
| 15071 | |
| 15072 if ( e && e.stopImmediatePropagation ) { | |
| 15073 e.stopImmediatePropagation(); | |
| 15074 } | |
| 15075 | |
| 15076 this.stopPropagation(); | |
| 15077 } | |
| 15078 }; | |
| 15079 | |
| 15080 // Create mouseenter/leave events using mouseover/out and event-time checks | |
| 15081 // Support: Chrome 15+ | |
| 15082 jQuery.each({ | |
| 15083 mouseenter: "mouseover", | |
| 15084 mouseleave: "mouseout", | |
| 15085 pointerenter: "pointerover", | |
| 15086 pointerleave: "pointerout" | |
| 15087 }, function( orig, fix ) { | |
| 15088 jQuery.event.special[ orig ] = { | |
| 15089 delegateType: fix, | |
| 15090 bindType: fix, | |
| 15091 | |
| 15092 handle: function( event ) { | |
| 15093 var ret, | |
| 15094 target = this, | |
| 15095 related = event.relatedTarget, | |
| 15096 handleObj = event.handleObj; | |
| 15097 | |
| 15098 // For mousenter/leave call the handler if related is outside the target. | |
| 15099 // NB: No relatedTarget if the mouse left/entered the browser window | |
| 15100 if ( !related || (related !== target && !jQuery.contains( target, related )) ) { | |
| 15101 event.type = handleObj.origType; | |
| 15102 ret = handleObj.handler.apply( this, arguments ); | |
| 15103 event.type = fix; | |
| 15104 } | |
| 15105 return ret; | |
| 15106 } | |
| 15107 }; | |
| 15108 }); | |
| 15109 | |
| 15110 // Support: Firefox, Chrome, Safari | |
| 15111 // Create "bubbling" focus and blur events | |
| 15112 if ( !support.focusinBubbles ) { | |
| 15113 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { | |
| 15114 | |
| 15115 // Attach a single capturing handler on the document while someone wants focusin/focusout | |
| 15116 var handler = function( event ) { | |
| 15117 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); | |
| 15118 }; | |
| 15119 | |
| 15120 jQuery.event.special[ fix ] = { | |
| 15121 setup: function() { | |
| 15122 var doc = this.ownerDocument || this, | |
| 15123 attaches = data_priv.access( doc, fix ); | |
| 15124 | |
| 15125 if ( !attaches ) { | |
| 15126 doc.addEventListener( orig, handler, true ); | |
| 15127 } | |
| 15128 data_priv.access( doc, fix, ( attaches || 0 ) + 1 ); | |
| 15129 }, | |
| 15130 teardown: function() { | |
| 15131 var doc = this.ownerDocument || this, | |
| 15132 attaches = data_priv.access( doc, fix ) - 1; | |
| 15133 | |
| 15134 if ( !attaches ) { | |
| 15135 doc.removeEventListener( orig, handler, true ); | |
| 15136 data_priv.remove( doc, fix ); | |
| 15137 | |
| 15138 } else { | |
| 15139 data_priv.access( doc, fix, attaches ); | |
| 15140 } | |
| 15141 } | |
| 15142 }; | |
| 15143 }); | |
| 15144 } | |
| 15145 | |
| 15146 jQuery.fn.extend({ | |
| 15147 | |
| 15148 on: function( types, selector, data, fn, /*INTERNAL*/ one ) { | |
| 15149 var origFn, type; | |
| 15150 | |
| 15151 // Types can be a map of types/handlers | |
| 15152 if ( typeof types === "object" ) { | |
| 15153 // ( types-Object, selector, data ) | |
| 15154 if ( typeof selector !== "string" ) { | |
| 15155 // ( types-Object, data ) | |
| 15156 data = data || selector; | |
| 15157 selector = undefined; | |
| 15158 } | |
| 15159 for ( type in types ) { | |
| 15160 this.on( type, selector, data, types[ type ], one ); | |
| 15161 } | |
| 15162 return this; | |
| 15163 } | |
| 15164 | |
| 15165 if ( data == null && fn == null ) { | |
| 15166 // ( types, fn ) | |
| 15167 fn = selector; | |
| 15168 data = selector = undefined; | |
| 15169 } else if ( fn == null ) { | |
| 15170 if ( typeof selector === "string" ) { | |
| 15171 // ( types, selector, fn ) | |
| 15172 fn = data; | |
| 15173 data = undefined; | |
| 15174 } else { | |
| 15175 // ( types, data, fn ) | |
| 15176 fn = data; | |
| 15177 data = selector; | |
| 15178 selector = undefined; | |
| 15179 } | |
| 15180 } | |
| 15181 if ( fn === false ) { | |
| 15182 fn = returnFalse; | |
| 15183 } else if ( !fn ) { | |
| 15184 return this; | |
| 15185 } | |
| 15186 | |
| 15187 if ( one === 1 ) { | |
| 15188 origFn = fn; | |
| 15189 fn = function( event ) { | |
| 15190 // Can use an empty set, since event contains the info | |
| 15191 jQuery().off( event ); | |
| 15192 return origFn.apply( this, arguments ); | |
| 15193 }; | |
| 15194 // Use same guid so caller can remove using origFn | |
| 15195 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); | |
| 15196 } | |
| 15197 return this.each( function() { | |
| 15198 jQuery.event.add( this, types, fn, data, selector ); | |
| 15199 }); | |
| 15200 }, | |
| 15201 one: function( types, selector, data, fn ) { | |
| 15202 return this.on( types, selector, data, fn, 1 ); | |
| 15203 }, | |
| 15204 off: function( types, selector, fn ) { | |
| 15205 var handleObj, type; | |
| 15206 if ( types && types.preventDefault && types.handleObj ) { | |
| 15207 // ( event ) dispatched jQuery.Event | |
| 15208 handleObj = types.handleObj; | |
| 15209 jQuery( types.delegateTarget ).off( | |
| 15210 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, | |
| 15211 handleObj.selector, | |
| 15212 handleObj.handler | |
| 15213 ); | |
| 15214 return this; | |
| 15215 } | |
| 15216 if ( typeof types === "object" ) { | |
| 15217 // ( types-object [, selector] ) | |
| 15218 for ( type in types ) { | |
| 15219 this.off( type, selector, types[ type ] ); | |
| 15220 } | |
| 15221 return this; | |
| 15222 } | |
| 15223 if ( selector === false || typeof selector === "function" ) { | |
| 15224 // ( types [, fn] ) | |
| 15225 fn = selector; | |
| 15226 selector = undefined; | |
| 15227 } | |
| 15228 if ( fn === false ) { | |
| 15229 fn = returnFalse; | |
| 15230 } | |
| 15231 return this.each(function() { | |
| 15232 jQuery.event.remove( this, types, fn, selector ); | |
| 15233 }); | |
| 15234 }, | |
| 15235 | |
| 15236 trigger: function( type, data ) { | |
| 15237 return this.each(function() { | |
| 15238 jQuery.event.trigger( type, data, this ); | |
| 15239 }); | |
| 15240 }, | |
| 15241 triggerHandler: function( type, data ) { | |
| 15242 var elem = this[0]; | |
| 15243 if ( elem ) { | |
| 15244 return jQuery.event.trigger( type, data, elem, true ); | |
| 15245 } | |
| 15246 } | |
| 15247 }); | |
| 15248 | |
| 15249 | |
| 15250 var | |
| 15251 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, | |
| 15252 rtagName = /<([\w:]+)/, | |
| 15253 rhtml = /<|&#?\w+;/, | |
| 15254 rnoInnerhtml = /<(?:script|style|link)/i, | |
| 15255 // checked="checked" or checked | |
| 15256 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, | |
| 15257 rscriptType = /^$|\/(?:java|ecma)script/i, | |
| 15258 rscriptTypeMasked = /^true\/(.*)/, | |
| 15259 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, | |
| 15260 | |
| 15261 // We have to close these tags to support XHTML (#13200) | |
| 15262 wrapMap = { | |
| 15263 | |
| 15264 // Support: IE9 | |
| 15265 option: [ 1, "<select multiple='multiple'>", "</select>" ], | |
| 15266 | |
| 15267 thead: [ 1, "<table>", "</table>" ], | |
| 15268 col: [ 2, "<table><colgroup>", "</colgroup></table>" ], | |
| 15269 tr: [ 2, "<table><tbody>", "</tbody></table>" ], | |
| 15270 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], | |
| 15271 | |
| 15272 _default: [ 0, "", "" ] | |
| 15273 }; | |
| 15274 | |
| 15275 // Support: IE9 | |
| 15276 wrapMap.optgroup = wrapMap.option; | |
| 15277 | |
| 15278 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; | |
| 15279 wrapMap.th = wrapMap.td; | |
| 15280 | |
| 15281 // Support: 1.x compatibility | |
| 15282 // Manipulating tables requires a tbody | |
| 15283 function manipulationTarget( elem, content ) { | |
| 15284 return jQuery.nodeName( elem, "table" ) && | |
| 15285 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? | |
| 15286 | |
| 15287 elem.getElementsByTagName("tbody")[0] || | |
| 15288 elem.appendChild( elem.ownerDocument.createElement("tbody") ) : | |
| 15289 elem; | |
| 15290 } | |
| 15291 | |
| 15292 // Replace/restore the type attribute of script elements for safe DOM manipulation | |
| 15293 function disableScript( elem ) { | |
| 15294 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; | |
| 15295 return elem; | |
| 15296 } | |
| 15297 function restoreScript( elem ) { | |
| 15298 var match = rscriptTypeMasked.exec( elem.type ); | |
| 15299 | |
| 15300 if ( match ) { | |
| 15301 elem.type = match[ 1 ]; | |
| 15302 } else { | |
| 15303 elem.removeAttribute("type"); | |
| 15304 } | |
| 15305 | |
| 15306 return elem; | |
| 15307 } | |
| 15308 | |
| 15309 // Mark scripts as having already been evaluated | |
| 15310 function setGlobalEval( elems, refElements ) { | |
| 15311 var i = 0, | |
| 15312 l = elems.length; | |
| 15313 | |
| 15314 for ( ; i < l; i++ ) { | |
| 15315 data_priv.set( | |
| 15316 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" ) | |
| 15317 ); | |
| 15318 } | |
| 15319 } | |
| 15320 | |
| 15321 function cloneCopyEvent( src, dest ) { | |
| 15322 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; | |
| 15323 | |
| 15324 if ( dest.nodeType !== 1 ) { | |
| 15325 return; | |
| 15326 } | |
| 15327 | |
| 15328 // 1. Copy private data: events, handlers, etc. | |
| 15329 if ( data_priv.hasData( src ) ) { | |
| 15330 pdataOld = data_priv.access( src ); | |
| 15331 pdataCur = data_priv.set( dest, pdataOld ); | |
| 15332 events = pdataOld.events; | |
| 15333 | |
| 15334 if ( events ) { | |
| 15335 delete pdataCur.handle; | |
| 15336 pdataCur.events = {}; | |
| 15337 | |
| 15338 for ( type in events ) { | |
| 15339 for ( i = 0, l = events[ type ].length; i < l; i++ ) { | |
| 15340 jQuery.event.add( dest, type, events[ type ][ i ] ); | |
| 15341 } | |
| 15342 } | |
| 15343 } | |
| 15344 } | |
| 15345 | |
| 15346 // 2. Copy user data | |
| 15347 if ( data_user.hasData( src ) ) { | |
| 15348 udataOld = data_user.access( src ); | |
| 15349 udataCur = jQuery.extend( {}, udataOld ); | |
| 15350 | |
| 15351 data_user.set( dest, udataCur ); | |
| 15352 } | |
| 15353 } | |
| 15354 | |
| 15355 function getAll( context, tag ) { | |
| 15356 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) : | |
| 15357 context.querySelectorAll ? context.querySelectorAll( tag || "*" ) : | |
| 15358 []; | |
| 15359 | |
| 15360 return tag === undefined || tag && jQuery.nodeName( context, tag ) ? | |
| 15361 jQuery.merge( [ context ], ret ) : | |
| 15362 ret; | |
| 15363 } | |
| 15364 | |
| 15365 // Fix IE bugs, see support tests | |
| 15366 function fixInput( src, dest ) { | |
| 15367 var nodeName = dest.nodeName.toLowerCase(); | |
| 15368 | |
| 15369 // Fails to persist the checked state of a cloned checkbox or radio button. | |
| 15370 if ( nodeName === "input" && rcheckableType.test( src.type ) ) { | |
| 15371 dest.checked = src.checked; | |
| 15372 | |
| 15373 // Fails to return the selected option to the default selected state when cloning options | |
| 15374 } else if ( nodeName === "input" || nodeName === "textarea" ) { | |
| 15375 dest.defaultValue = src.defaultValue; | |
| 15376 } | |
| 15377 } | |
| 15378 | |
| 15379 jQuery.extend({ | |
| 15380 clone: function( elem, dataAndEvents, deepDataAndEvents ) { | |
| 15381 var i, l, srcElements, destElements, | |
| 15382 clone = elem.cloneNode( true ), | |
| 15383 inPage = jQuery.contains( elem.ownerDocument, elem ); | |
| 15384 | |
| 15385 // Fix IE cloning issues | |
| 15386 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && | |
| 15387 !jQuery.isXMLDoc( elem ) ) { | |
| 15388 | |
| 15389 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 | |
| 15390 destElements = getAll( clone ); | |
| 15391 srcElements = getAll( elem ); | |
| 15392 | |
| 15393 for ( i = 0, l = srcElements.length; i < l; i++ ) { | |
| 15394 fixInput( srcElements[ i ], destElements[ i ] ); | |
| 15395 } | |
| 15396 } | |
| 15397 | |
| 15398 // Copy the events from the original to the clone | |
| 15399 if ( dataAndEvents ) { | |
| 15400 if ( deepDataAndEvents ) { | |
| 15401 srcElements = srcElements || getAll( elem ); | |
| 15402 destElements = destElements || getAll( clone ); | |
| 15403 | |
| 15404 for ( i = 0, l = srcElements.length; i < l; i++ ) { | |
| 15405 cloneCopyEvent( srcElements[ i ], destElements[ i ] ); | |
| 15406 } | |
| 15407 } else { | |
| 15408 cloneCopyEvent( elem, clone ); | |
| 15409 } | |
| 15410 } | |
| 15411 | |
| 15412 // Preserve script evaluation history | |
| 15413 destElements = getAll( clone, "script" ); | |
| 15414 if ( destElements.length > 0 ) { | |
| 15415 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); | |
| 15416 } | |
| 15417 | |
| 15418 // Return the cloned set | |
| 15419 return clone; | |
| 15420 }, | |
| 15421 | |
| 15422 buildFragment: function( elems, context, scripts, selection ) { | |
| 15423 var elem, tmp, tag, wrap, contains, j, | |
| 15424 fragment = context.createDocumentFragment(), | |
| 15425 nodes = [], | |
| 15426 i = 0, | |
| 15427 l = elems.length; | |
| 15428 | |
| 15429 for ( ; i < l; i++ ) { | |
| 15430 elem = elems[ i ]; | |
| 15431 | |
| 15432 if ( elem || elem === 0 ) { | |
| 15433 | |
| 15434 // Add nodes directly | |
| 15435 if ( jQuery.type( elem ) === "object" ) { | |
| 15436 // Support: QtWebKit, PhantomJS | |
| 15437 // push.apply(_, arraylike) throws on ancient WebKit | |
| 15438 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); | |
| 15439 | |
| 15440 // Convert non-html into a text node | |
| 15441 } else if ( !rhtml.test( elem ) ) { | |
| 15442 nodes.push( context.createTextNode( elem ) ); | |
| 15443 | |
| 15444 // Convert html into DOM nodes | |
| 15445 } else { | |
| 15446 tmp = tmp || fragment.appendChild( context.createElement("div") ); | |
| 15447 | |
| 15448 // Deserialize a standard representation | |
| 15449 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); | |
| 15450 wrap = wrapMap[ tag ] || wrapMap._default; | |
| 15451 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ]; | |
| 15452 | |
| 15453 // Descend through wrappers to the right content | |
| 15454 j = wrap[ 0 ]; | |
| 15455 while ( j-- ) { | |
| 15456 tmp = tmp.lastChild; | |
| 15457 } | |
| 15458 | |
| 15459 // Support: QtWebKit, PhantomJS | |
| 15460 // push.apply(_, arraylike) throws on ancient WebKit | |
| 15461 jQuery.merge( nodes, tmp.childNodes ); | |
| 15462 | |
| 15463 // Remember the top-level container | |
| 15464 tmp = fragment.firstChild; | |
| 15465 | |
| 15466 // Ensure the created nodes are orphaned (#12392) | |
| 15467 tmp.textContent = ""; | |
| 15468 } | |
| 15469 } | |
| 15470 } | |
| 15471 | |
| 15472 // Remove wrapper from fragment | |
| 15473 fragment.textContent = ""; | |
| 15474 | |
| 15475 i = 0; | |
| 15476 while ( (elem = nodes[ i++ ]) ) { | |
| 15477 | |
| 15478 // #4087 - If origin and destination elements are the same, and this is | |
| 15479 // that element, do not do anything | |
| 15480 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { | |
| 15481 continue; | |
| 15482 } | |
| 15483 | |
| 15484 contains = jQuery.contains( elem.ownerDocument, elem ); | |
| 15485 | |
| 15486 // Append to fragment | |
| 15487 tmp = getAll( fragment.appendChild( elem ), "script" ); | |
| 15488 | |
| 15489 // Preserve script evaluation history | |
| 15490 if ( contains ) { | |
| 15491 setGlobalEval( tmp ); | |
| 15492 } | |
| 15493 | |
| 15494 // Capture executables | |
| 15495 if ( scripts ) { | |
| 15496 j = 0; | |
| 15497 while ( (elem = tmp[ j++ ]) ) { | |
| 15498 if ( rscriptType.test( elem.type || "" ) ) { | |
| 15499 scripts.push( elem ); | |
| 15500 } | |
| 15501 } | |
| 15502 } | |
| 15503 } | |
| 15504 | |
| 15505 return fragment; | |
| 15506 }, | |
| 15507 | |
| 15508 cleanData: function( elems ) { | |
| 15509 var data, elem, type, key, | |
| 15510 special = jQuery.event.special, | |
| 15511 i = 0; | |
| 15512 | |
| 15513 for ( ; (elem = elems[ i ]) !== undefined; i++ ) { | |
| 15514 if ( jQuery.acceptData( elem ) ) { | |
| 15515 key = elem[ data_priv.expando ]; | |
| 15516 | |
| 15517 if ( key && (data = data_priv.cache[ key ]) ) { | |
| 15518 if ( data.events ) { | |
| 15519 for ( type in data.events ) { | |
| 15520 if ( special[ type ] ) { | |
| 15521 jQuery.event.remove( elem, type ); | |
| 15522 | |
| 15523 // This is a shortcut to avoid jQuery.event.remove's overhead | |
| 15524 } else { | |
| 15525 jQuery.removeEvent( elem, type, data.handle ); | |
| 15526 } | |
| 15527 } | |
| 15528 } | |
| 15529 if ( data_priv.cache[ key ] ) { | |
| 15530 // Discard any remaining `private` data | |
| 15531 delete data_priv.cache[ key ]; | |
| 15532 } | |
| 15533 } | |
| 15534 } | |
| 15535 // Discard any remaining `user` data | |
| 15536 delete data_user.cache[ elem[ data_user.expando ] ]; | |
| 15537 } | |
| 15538 } | |
| 15539 }); | |
| 15540 | |
| 15541 jQuery.fn.extend({ | |
| 15542 text: function( value ) { | |
| 15543 return access( this, function( value ) { | |
| 15544 return value === undefined ? | |
| 15545 jQuery.text( this ) : | |
| 15546 this.empty().each(function() { | |
| 15547 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { | |
| 15548 this.textContent = value; | |
| 15549 } | |
| 15550 }); | |
| 15551 }, null, value, arguments.length ); | |
| 15552 }, | |
| 15553 | |
| 15554 append: function() { | |
| 15555 return this.domManip( arguments, function( elem ) { | |
| 15556 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { | |
| 15557 var target = manipulationTarget( this, elem ); | |
| 15558 target.appendChild( elem ); | |
| 15559 } | |
| 15560 }); | |
| 15561 }, | |
| 15562 | |
| 15563 prepend: function() { | |
| 15564 return this.domManip( arguments, function( elem ) { | |
| 15565 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { | |
| 15566 var target = manipulationTarget( this, elem ); | |
| 15567 target.insertBefore( elem, target.firstChild ); | |
| 15568 } | |
| 15569 }); | |
| 15570 }, | |
| 15571 | |
| 15572 before: function() { | |
| 15573 return this.domManip( arguments, function( elem ) { | |
| 15574 if ( this.parentNode ) { | |
| 15575 this.parentNode.insertBefore( elem, this ); | |
| 15576 } | |
| 15577 }); | |
| 15578 }, | |
| 15579 | |
| 15580 after: function() { | |
| 15581 return this.domManip( arguments, function( elem ) { | |
| 15582 if ( this.parentNode ) { | |
| 15583 this.parentNode.insertBefore( elem, this.nextSibling ); | |
| 15584 } | |
| 15585 }); | |
| 15586 }, | |
| 15587 | |
| 15588 remove: function( selector, keepData /* Internal Use Only */ ) { | |
| 15589 var elem, | |
| 15590 elems = selector ? jQuery.filter( selector, this ) : this, | |
| 15591 i = 0; | |
| 15592 | |
| 15593 for ( ; (elem = elems[i]) != null; i++ ) { | |
| 15594 if ( !keepData && elem.nodeType === 1 ) { | |
| 15595 jQuery.cleanData( getAll( elem ) ); | |
| 15596 } | |
| 15597 | |
| 15598 if ( elem.parentNode ) { | |
| 15599 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { | |
| 15600 setGlobalEval( getAll( elem, "script" ) ); | |
| 15601 } | |
| 15602 elem.parentNode.removeChild( elem ); | |
| 15603 } | |
| 15604 } | |
| 15605 | |
| 15606 return this; | |
| 15607 }, | |
| 15608 | |
| 15609 empty: function() { | |
| 15610 var elem, | |
| 15611 i = 0; | |
| 15612 | |
| 15613 for ( ; (elem = this[i]) != null; i++ ) { | |
| 15614 if ( elem.nodeType === 1 ) { | |
| 15615 | |
| 15616 // Prevent memory leaks | |
| 15617 jQuery.cleanData( getAll( elem, false ) ); | |
| 15618 | |
| 15619 // Remove any remaining nodes | |
| 15620 elem.textContent = ""; | |
| 15621 } | |
| 15622 } | |
| 15623 | |
| 15624 return this; | |
| 15625 }, | |
| 15626 | |
| 15627 clone: function( dataAndEvents, deepDataAndEvents ) { | |
| 15628 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; | |
| 15629 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; | |
| 15630 | |
| 15631 return this.map(function() { | |
| 15632 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); | |
| 15633 }); | |
| 15634 }, | |
| 15635 | |
| 15636 html: function( value ) { | |
| 15637 return access( this, function( value ) { | |
| 15638 var elem = this[ 0 ] || {}, | |
| 15639 i = 0, | |
| 15640 l = this.length; | |
| 15641 | |
| 15642 if ( value === undefined && elem.nodeType === 1 ) { | |
| 15643 return elem.innerHTML; | |
| 15644 } | |
| 15645 | |
| 15646 // See if we can take a shortcut and just use innerHTML | |
| 15647 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && | |
| 15648 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { | |
| 15649 | |
| 15650 value = value.replace( rxhtmlTag, "<$1></$2>" ); | |
| 15651 | |
| 15652 try { | |
| 15653 for ( ; i < l; i++ ) { | |
| 15654 elem = this[ i ] || {}; | |
| 15655 | |
| 15656 // Remove element nodes and prevent memory leaks | |
| 15657 if ( elem.nodeType === 1 ) { | |
| 15658 jQuery.cleanData( getAll( elem, false ) ); | |
| 15659 elem.innerHTML = value; | |
| 15660 } | |
| 15661 } | |
| 15662 | |
| 15663 elem = 0; | |
| 15664 | |
| 15665 // If using innerHTML throws an exception, use the fallback method | |
| 15666 } catch( e ) {} | |
| 15667 } | |
| 15668 | |
| 15669 if ( elem ) { | |
| 15670 this.empty().append( value ); | |
| 15671 } | |
| 15672 }, null, value, arguments.length ); | |
| 15673 }, | |
| 15674 | |
| 15675 replaceWith: function() { | |
| 15676 var arg = arguments[ 0 ]; | |
| 15677 | |
| 15678 // Make the changes, replacing each context element with the new content | |
| 15679 this.domManip( arguments, function( elem ) { | |
| 15680 arg = this.parentNode; | |
| 15681 | |
| 15682 jQuery.cleanData( getAll( this ) ); | |
| 15683 | |
| 15684 if ( arg ) { | |
| 15685 arg.replaceChild( elem, this ); | |
| 15686 } | |
| 15687 }); | |
| 15688 | |
| 15689 // Force removal if there was no new content (e.g., from empty arguments) | |
| 15690 return arg && (arg.length || arg.nodeType) ? this : this.remove(); | |
| 15691 }, | |
| 15692 | |
| 15693 detach: function( selector ) { | |
| 15694 return this.remove( selector, true ); | |
| 15695 }, | |
| 15696 | |
| 15697 domManip: function( args, callback ) { | |
| 15698 | |
| 15699 // Flatten any nested arrays | |
| 15700 args = concat.apply( [], args ); | |
| 15701 | |
| 15702 var fragment, first, scripts, hasScripts, node, doc, | |
| 15703 i = 0, | |
| 15704 l = this.length, | |
| 15705 set = this, | |
| 15706 iNoClone = l - 1, | |
| 15707 value = args[ 0 ], | |
| 15708 isFunction = jQuery.isFunction( value ); | |
| 15709 | |
| 15710 // We can't cloneNode fragments that contain checked, in WebKit | |
| 15711 if ( isFunction || | |
| 15712 ( l > 1 && typeof value === "string" && | |
| 15713 !support.checkClone && rchecked.test( value ) ) ) { | |
| 15714 return this.each(function( index ) { | |
| 15715 var self = set.eq( index ); | |
| 15716 if ( isFunction ) { | |
| 15717 args[ 0 ] = value.call( this, index, self.html() ); | |
| 15718 } | |
| 15719 self.domManip( args, callback ); | |
| 15720 }); | |
| 15721 } | |
| 15722 | |
| 15723 if ( l ) { | |
| 15724 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); | |
| 15725 first = fragment.firstChild; | |
| 15726 | |
| 15727 if ( fragment.childNodes.length === 1 ) { | |
| 15728 fragment = first; | |
| 15729 } | |
| 15730 | |
| 15731 if ( first ) { | |
| 15732 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); | |
| 15733 hasScripts = scripts.length; | |
| 15734 | |
| 15735 // Use the original fragment for the last item instead of the first because it can end up | |
| 15736 // being emptied incorrectly in certain situations (#8070). | |
| 15737 for ( ; i < l; i++ ) { | |
| 15738 node = fragment; | |
| 15739 | |
| 15740 if ( i !== iNoClone ) { | |
| 15741 node = jQuery.clone( node, true, true ); | |
| 15742 | |
| 15743 // Keep references to cloned scripts for later restoration | |
| 15744 if ( hasScripts ) { | |
| 15745 // Support: QtWebKit | |
| 15746 // jQuery.merge because push.apply(_, arraylike) throws | |
| 15747 jQuery.merge( scripts, getAll( node, "script" ) ); | |
| 15748 } | |
| 15749 } | |
| 15750 | |
| 15751 callback.call( this[ i ], node, i ); | |
| 15752 } | |
| 15753 | |
| 15754 if ( hasScripts ) { | |
| 15755 doc = scripts[ scripts.length - 1 ].ownerDocument; | |
| 15756 | |
| 15757 // Reenable scripts | |
| 15758 jQuery.map( scripts, restoreScript ); | |
| 15759 | |
| 15760 // Evaluate executable scripts on first document insertion | |
| 15761 for ( i = 0; i < hasScripts; i++ ) { | |
| 15762 node = scripts[ i ]; | |
| 15763 if ( rscriptType.test( node.type || "" ) && | |
| 15764 !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) { | |
| 15765 | |
| 15766 if ( node.src ) { | |
| 15767 // Optional AJAX dependency, but won't run scripts if not present | |
| 15768 if ( jQuery._evalUrl ) { | |
| 15769 jQuery._evalUrl( node.src ); | |
| 15770 } | |
| 15771 } else { | |
| 15772 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); | |
| 15773 } | |
| 15774 } | |
| 15775 } | |
| 15776 } | |
| 15777 } | |
| 15778 } | |
| 15779 | |
| 15780 return this; | |
| 15781 } | |
| 15782 }); | |
| 15783 | |
| 15784 jQuery.each({ | |
| 15785 appendTo: "append", | |
| 15786 prependTo: "prepend", | |
| 15787 insertBefore: "before", | |
| 15788 insertAfter: "after", | |
| 15789 replaceAll: "replaceWith" | |
| 15790 }, function( name, original ) { | |
| 15791 jQuery.fn[ name ] = function( selector ) { | |
| 15792 var elems, | |
| 15793 ret = [], | |
| 15794 insert = jQuery( selector ), | |
| 15795 last = insert.length - 1, | |
| 15796 i = 0; | |
| 15797 | |
| 15798 for ( ; i <= last; i++ ) { | |
| 15799 elems = i === last ? this : this.clone( true ); | |
| 15800 jQuery( insert[ i ] )[ original ]( elems ); | |
| 15801 | |
| 15802 // Support: QtWebKit | |
| 15803 // .get() because push.apply(_, arraylike) throws | |
| 15804 push.apply( ret, elems.get() ); | |
| 15805 } | |
| 15806 | |
| 15807 return this.pushStack( ret ); | |
| 15808 }; | |
| 15809 }); | |
| 15810 | |
| 15811 | |
| 15812 var iframe, | |
| 15813 elemdisplay = {}; | |
| 15814 | |
| 15815 /** | |
| 15816 * Retrieve the actual display of a element | |
| 15817 * @param {String} name nodeName of the element | |
| 15818 * @param {Object} doc Document object | |
| 15819 */ | |
| 15820 // Called only from within defaultDisplay | |
| 15821 function actualDisplay( name, doc ) { | |
| 15822 var style, | |
| 15823 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), | |
| 15824 | |
| 15825 // getDefaultComputedStyle might be reliably used only on attached element | |
| 15826 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ? | |
| 15827 | |
| 15828 // Use of this method is a temporary fix (more like optimization) until something better comes along, | |
| 15829 // since it was removed from specification and supported only in FF | |
| 15830 style.display : jQuery.css( elem[ 0 ], "display" ); | |
| 15831 | |
| 15832 // We don't have any data stored on the element, | |
| 15833 // so use "detach" method as fast way to get rid of the element | |
| 15834 elem.detach(); | |
| 15835 | |
| 15836 return display; | |
| 15837 } | |
| 15838 | |
| 15839 /** | |
| 15840 * Try to determine the default display value of an element | |
| 15841 * @param {String} nodeName | |
| 15842 */ | |
| 15843 function defaultDisplay( nodeName ) { | |
| 15844 var doc = document, | |
| 15845 display = elemdisplay[ nodeName ]; | |
| 15846 | |
| 15847 if ( !display ) { | |
| 15848 display = actualDisplay( nodeName, doc ); | |
| 15849 | |
| 15850 // If the simple way fails, read from inside an iframe | |
| 15851 if ( display === "none" || !display ) { | |
| 15852 | |
| 15853 // Use the already-created iframe if possible | |
| 15854 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement ); | |
| 15855 | |
| 15856 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse | |
| 15857 doc = iframe[ 0 ].contentDocument; | |
| 15858 | |
| 15859 // Support: IE | |
| 15860 doc.write(); | |
| 15861 doc.close(); | |
| 15862 | |
| 15863 display = actualDisplay( nodeName, doc ); | |
| 15864 iframe.detach(); | |
| 15865 } | |
| 15866 | |
| 15867 // Store the correct default display | |
| 15868 elemdisplay[ nodeName ] = display; | |
| 15869 } | |
| 15870 | |
| 15871 return display; | |
| 15872 } | |
| 15873 var rmargin = (/^margin/); | |
| 15874 | |
| 15875 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); | |
| 15876 | |
| 15877 var getStyles = function( elem ) { | |
| 15878 // Support: IE<=11+, Firefox<=30+ (#15098, #14150) | |
| 15879 // IE throws on elements created in popups | |
| 15880 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" | |
| 15881 if ( elem.ownerDocument.defaultView.opener ) { | |
| 15882 return elem.ownerDocument.defaultView.getComputedStyle( elem, null ); | |
| 15883 } | |
| 15884 | |
| 15885 return window.getComputedStyle( elem, null ); | |
| 15886 }; | |
| 15887 | |
| 15888 | |
| 15889 | |
| 15890 function curCSS( elem, name, computed ) { | |
| 15891 var width, minWidth, maxWidth, ret, | |
| 15892 style = elem.style; | |
| 15893 | |
| 15894 computed = computed || getStyles( elem ); | |
| 15895 | |
| 15896 // Support: IE9 | |
| 15897 // getPropertyValue is only needed for .css('filter') (#12537) | |
| 15898 if ( computed ) { | |
| 15899 ret = computed.getPropertyValue( name ) || computed[ name ]; | |
| 15900 } | |
| 15901 | |
| 15902 if ( computed ) { | |
| 15903 | |
| 15904 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { | |
| 15905 ret = jQuery.style( elem, name ); | |
| 15906 } | |
| 15907 | |
| 15908 // Support: iOS < 6 | |
| 15909 // A tribute to the "awesome hack by Dean Edwards" | |
| 15910 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels | |
| 15911 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values | |
| 15912 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { | |
| 15913 | |
| 15914 // Remember the original values | |
| 15915 width = style.width; | |
| 15916 minWidth = style.minWidth; | |
| 15917 maxWidth = style.maxWidth; | |
| 15918 | |
| 15919 // Put in the new values to get a computed value out | |
| 15920 style.minWidth = style.maxWidth = style.width = ret; | |
| 15921 ret = computed.width; | |
| 15922 | |
| 15923 // Revert the changed values | |
| 15924 style.width = width; | |
| 15925 style.minWidth = minWidth; | |
| 15926 style.maxWidth = maxWidth; | |
| 15927 } | |
| 15928 } | |
| 15929 | |
| 15930 return ret !== undefined ? | |
| 15931 // Support: IE | |
| 15932 // IE returns zIndex value as an integer. | |
| 15933 ret + "" : | |
| 15934 ret; | |
| 15935 } | |
| 15936 | |
| 15937 | |
| 15938 function addGetHookIf( conditionFn, hookFn ) { | |
| 15939 // Define the hook, we'll check on the first run if it's really needed. | |
| 15940 return { | |
| 15941 get: function() { | |
| 15942 if ( conditionFn() ) { | |
| 15943 // Hook not needed (or it's not possible to use it due | |
| 15944 // to missing dependency), remove it. | |
| 15945 delete this.get; | |
| 15946 return; | |
| 15947 } | |
| 15948 | |
| 15949 // Hook needed; redefine it so that the support test is not executed again. | |
| 15950 return (this.get = hookFn).apply( this, arguments ); | |
| 15951 } | |
| 15952 }; | |
| 15953 } | |
| 15954 | |
| 15955 | |
| 15956 (function() { | |
| 15957 var pixelPositionVal, boxSizingReliableVal, | |
| 15958 docElem = document.documentElement, | |
| 15959 container = document.createElement( "div" ), | |
| 15960 div = document.createElement( "div" ); | |
| 15961 | |
| 15962 if ( !div.style ) { | |
| 15963 return; | |
| 15964 } | |
| 15965 | |
| 15966 // Support: IE9-11+ | |
| 15967 // Style of cloned element affects source element cloned (#8908) | |
| 15968 div.style.backgroundClip = "content-box"; | |
| 15969 div.cloneNode( true ).style.backgroundClip = ""; | |
| 15970 support.clearCloneStyle = div.style.backgroundClip === "content-box"; | |
| 15971 | |
| 15972 container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" + | |
| 15973 "position:absolute"; | |
| 15974 container.appendChild( div ); | |
| 15975 | |
| 15976 // Executing both pixelPosition & boxSizingReliable tests require only one layout | |
| 15977 // so they're executed at the same time to save the second computation. | |
| 15978 function computePixelPositionAndBoxSizingReliable() { | |
| 15979 div.style.cssText = | |
| 15980 // Support: Firefox<29, Android 2.3 | |
| 15981 // Vendor-prefix box-sizing | |
| 15982 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" + | |
| 15983 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" + | |
| 15984 "border:1px;padding:1px;width:4px;position:absolute"; | |
| 15985 div.innerHTML = ""; | |
| 15986 docElem.appendChild( container ); | |
| 15987 | |
| 15988 var divStyle = window.getComputedStyle( div, null ); | |
| 15989 pixelPositionVal = divStyle.top !== "1%"; | |
| 15990 boxSizingReliableVal = divStyle.width === "4px"; | |
| 15991 | |
| 15992 docElem.removeChild( container ); | |
| 15993 } | |
| 15994 | |
| 15995 // Support: node.js jsdom | |
| 15996 // Don't assume that getComputedStyle is a property of the global object | |
| 15997 if ( window.getComputedStyle ) { | |
| 15998 jQuery.extend( support, { | |
| 15999 pixelPosition: function() { | |
| 16000 | |
| 16001 // This test is executed only once but we still do memoizing | |
| 16002 // since we can use the boxSizingReliable pre-computing. | |
| 16003 // No need to check if the test was already performed, though. | |
| 16004 computePixelPositionAndBoxSizingReliable(); | |
| 16005 return pixelPositionVal; | |
| 16006 }, | |
| 16007 boxSizingReliable: function() { | |
| 16008 if ( boxSizingReliableVal == null ) { | |
| 16009 computePixelPositionAndBoxSizingReliable(); | |
| 16010 } | |
| 16011 return boxSizingReliableVal; | |
| 16012 }, | |
| 16013 reliableMarginRight: function() { | |
| 16014 | |
| 16015 // Support: Android 2.3 | |
| 16016 // Check if div with explicit width and no margin-right incorrectly | |
| 16017 // gets computed margin-right based on width of container. (#3333) | |
| 16018 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right | |
| 16019 // This support function is only executed once so no memoizing is needed. | |
| 16020 var ret, | |
| 16021 marginDiv = div.appendChild( document.createElement( "div" ) ); | |
| 16022 | |
| 16023 // Reset CSS: box-sizing; display; margin; border; padding | |
| 16024 marginDiv.style.cssText = div.style.cssText = | |
| 16025 // Support: Firefox<29, Android 2.3 | |
| 16026 // Vendor-prefix box-sizing | |
| 16027 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" + | |
| 16028 "box-sizing:content-box;display:block;margin:0;border:0;padding:0"; | |
| 16029 marginDiv.style.marginRight = marginDiv.style.width = "0"; | |
| 16030 div.style.width = "1px"; | |
| 16031 docElem.appendChild( container ); | |
| 16032 | |
| 16033 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight ); | |
| 16034 | |
| 16035 docElem.removeChild( container ); | |
| 16036 div.removeChild( marginDiv ); | |
| 16037 | |
| 16038 return ret; | |
| 16039 } | |
| 16040 }); | |
| 16041 } | |
| 16042 })(); | |
| 16043 | |
| 16044 | |
| 16045 // A method for quickly swapping in/out CSS properties to get correct calculations. | |
| 16046 jQuery.swap = function( elem, options, callback, args ) { | |
| 16047 var ret, name, | |
| 16048 old = {}; | |
| 16049 | |
| 16050 // Remember the old values, and insert the new ones | |
| 16051 for ( name in options ) { | |
| 16052 old[ name ] = elem.style[ name ]; | |
| 16053 elem.style[ name ] = options[ name ]; | |
| 16054 } | |
| 16055 | |
| 16056 ret = callback.apply( elem, args || [] ); | |
| 16057 | |
| 16058 // Revert the old values | |
| 16059 for ( name in options ) { | |
| 16060 elem.style[ name ] = old[ name ]; | |
| 16061 } | |
| 16062 | |
| 16063 return ret; | |
| 16064 }; | |
| 16065 | |
| 16066 | |
| 16067 var | |
| 16068 // Swappable if display is none or starts with table except "table", "table-cell", or "table-caption" | |
| 16069 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display | |
| 16070 rdisplayswap = /^(none|table(?!-c[ea]).+)/, | |
| 16071 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ), | |
| 16072 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ), | |
| 16073 | |
| 16074 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, | |
| 16075 cssNormalTransform = { | |
| 16076 letterSpacing: "0", | |
| 16077 fontWeight: "400" | |
| 16078 }, | |
| 16079 | |
| 16080 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; | |
| 16081 | |
| 16082 // Return a css property mapped to a potentially vendor prefixed property | |
| 16083 function vendorPropName( style, name ) { | |
| 16084 | |
| 16085 // Shortcut for names that are not vendor prefixed | |
| 16086 if ( name in style ) { | |
| 16087 return name; | |
| 16088 } | |
| 16089 | |
| 16090 // Check for vendor prefixed names | |
| 16091 var capName = name[0].toUpperCase() + name.slice(1), | |
| 16092 origName = name, | |
| 16093 i = cssPrefixes.length; | |
| 16094 | |
| 16095 while ( i-- ) { | |
| 16096 name = cssPrefixes[ i ] + capName; | |
| 16097 if ( name in style ) { | |
| 16098 return name; | |
| 16099 } | |
| 16100 } | |
| 16101 | |
| 16102 return origName; | |
| 16103 } | |
| 16104 | |
| 16105 function setPositiveNumber( elem, value, subtract ) { | |
| 16106 var matches = rnumsplit.exec( value ); | |
| 16107 return matches ? | |
| 16108 // Guard against undefined "subtract", e.g., when used as in cssHooks | |
| 16109 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : | |
| 16110 value; | |
| 16111 } | |
| 16112 | |
| 16113 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { | |
| 16114 var i = extra === ( isBorderBox ? "border" : "content" ) ? | |
| 16115 // If we already have the right measurement, avoid augmentation | |
| 16116 4 : | |
| 16117 // Otherwise initialize for horizontal or vertical properties | |
| 16118 name === "width" ? 1 : 0, | |
| 16119 | |
| 16120 val = 0; | |
| 16121 | |
| 16122 for ( ; i < 4; i += 2 ) { | |
| 16123 // Both box models exclude margin, so add it if we want it | |
| 16124 if ( extra === "margin" ) { | |
| 16125 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); | |
| 16126 } | |
| 16127 | |
| 16128 if ( isBorderBox ) { | |
| 16129 // border-box includes padding, so remove it if we want content | |
| 16130 if ( extra === "content" ) { | |
| 16131 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); | |
| 16132 } | |
| 16133 | |
| 16134 // At this point, extra isn't border nor margin, so remove border | |
| 16135 if ( extra !== "margin" ) { | |
| 16136 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); | |
| 16137 } | |
| 16138 } else { | |
| 16139 // At this point, extra isn't content, so add padding | |
| 16140 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); | |
| 16141 | |
| 16142 // At this point, extra isn't content nor padding, so add border | |
| 16143 if ( extra !== "padding" ) { | |
| 16144 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); | |
| 16145 } | |
| 16146 } | |
| 16147 } | |
| 16148 | |
| 16149 return val; | |
| 16150 } | |
| 16151 | |
| 16152 function getWidthOrHeight( elem, name, extra ) { | |
| 16153 | |
| 16154 // Start with offset property, which is equivalent to the border-box value | |
| 16155 var valueIsBorderBox = true, | |
| 16156 val = name === "width" ? elem.offsetWidth : elem.offsetHeight, | |
| 16157 styles = getStyles( elem ), | |
| 16158 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; | |
| 16159 | |
| 16160 // Some non-html elements return undefined for offsetWidth, so check for null/undefined | |
| 16161 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 | |
| 16162 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 | |
| 16163 if ( val <= 0 || val == null ) { | |
| 16164 // Fall back to computed then uncomputed css if necessary | |
| 16165 val = curCSS( elem, name, styles ); | |
| 16166 if ( val < 0 || val == null ) { | |
| 16167 val = elem.style[ name ]; | |
| 16168 } | |
| 16169 | |
| 16170 // Computed unit is not pixels. Stop here and return. | |
| 16171 if ( rnumnonpx.test(val) ) { | |
| 16172 return val; | |
| 16173 } | |
| 16174 | |
| 16175 // Check for style in case a browser which returns unreliable values | |
| 16176 // for getComputedStyle silently falls back to the reliable elem.style | |
| 16177 valueIsBorderBox = isBorderBox && | |
| 16178 ( support.boxSizingReliable() || val === elem.style[ name ] ); | |
| 16179 | |
| 16180 // Normalize "", auto, and prepare for extra | |
| 16181 val = parseFloat( val ) || 0; | |
| 16182 } | |
| 16183 | |
| 16184 // Use the active box-sizing model to add/subtract irrelevant styles | |
| 16185 return ( val + | |
| 16186 augmentWidthOrHeight( | |
| 16187 elem, | |
| 16188 name, | |
| 16189 extra || ( isBorderBox ? "border" : "content" ), | |
| 16190 valueIsBorderBox, | |
| 16191 styles | |
| 16192 ) | |
| 16193 ) + "px"; | |
| 16194 } | |
| 16195 | |
| 16196 function showHide( elements, show ) { | |
| 16197 var display, elem, hidden, | |
| 16198 values = [], | |
| 16199 index = 0, | |
| 16200 length = elements.length; | |
| 16201 | |
| 16202 for ( ; index < length; index++ ) { | |
| 16203 elem = elements[ index ]; | |
| 16204 if ( !elem.style ) { | |
| 16205 continue; | |
| 16206 } | |
| 16207 | |
| 16208 values[ index ] = data_priv.get( elem, "olddisplay" ); | |
| 16209 display = elem.style.display; | |
| 16210 if ( show ) { | |
| 16211 // Reset the inline display of this element to learn if it is | |
| 16212 // being hidden by cascaded rules or not | |
| 16213 if ( !values[ index ] && display === "none" ) { | |
| 16214 elem.style.display = ""; | |
| 16215 } | |
| 16216 | |
| 16217 // Set elements which have been overridden with display: none | |
| 16218 // in a stylesheet to whatever the default browser style is | |
| 16219 // for such an element | |
| 16220 if ( elem.style.display === "" && isHidden( elem ) ) { | |
| 16221 values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) ); | |
| 16222 } | |
| 16223 } else { | |
| 16224 hidden = isHidden( elem ); | |
| 16225 | |
| 16226 if ( display !== "none" || !hidden ) { | |
| 16227 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); | |
| 16228 } | |
| 16229 } | |
| 16230 } | |
| 16231 | |
| 16232 // Set the display of most of the elements in a second loop | |
| 16233 // to avoid the constant reflow | |
| 16234 for ( index = 0; index < length; index++ ) { | |
| 16235 elem = elements[ index ]; | |
| 16236 if ( !elem.style ) { | |
| 16237 continue; | |
| 16238 } | |
| 16239 if ( !show || elem.style.display === "none" || elem.style.display === "" ) { | |
| 16240 elem.style.display = show ? values[ index ] || "" : "none"; | |
| 16241 } | |
| 16242 } | |
| 16243 | |
| 16244 return elements; | |
| 16245 } | |
| 16246 | |
| 16247 jQuery.extend({ | |
| 16248 | |
| 16249 // Add in style property hooks for overriding the default | |
| 16250 // behavior of getting and setting a style property | |
| 16251 cssHooks: { | |
| 16252 opacity: { | |
| 16253 get: function( elem, computed ) { | |
| 16254 if ( computed ) { | |
| 16255 | |
| 16256 // We should always get a number back from opacity | |
| 16257 var ret = curCSS( elem, "opacity" ); | |
| 16258 return ret === "" ? "1" : ret; | |
| 16259 } | |
| 16260 } | |
| 16261 } | |
| 16262 }, | |
| 16263 | |
| 16264 // Don't automatically add "px" to these possibly-unitless properties | |
| 16265 cssNumber: { | |
| 16266 "columnCount": true, | |
| 16267 "fillOpacity": true, | |
| 16268 "flexGrow": true, | |
| 16269 "flexShrink": true, | |
| 16270 "fontWeight": true, | |
| 16271 "lineHeight": true, | |
| 16272 "opacity": true, | |
| 16273 "order": true, | |
| 16274 "orphans": true, | |
| 16275 "widows": true, | |
| 16276 "zIndex": true, | |
| 16277 "zoom": true | |
| 16278 }, | |
| 16279 | |
| 16280 // Add in properties whose names you wish to fix before | |
| 16281 // setting or getting the value | |
| 16282 cssProps: { | |
| 16283 "float": "cssFloat" | |
| 16284 }, | |
| 16285 | |
| 16286 // Get and set the style property on a DOM Node | |
| 16287 style: function( elem, name, value, extra ) { | |
| 16288 | |
| 16289 // Don't set styles on text and comment nodes | |
| 16290 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { | |
| 16291 return; | |
| 16292 } | |
| 16293 | |
| 16294 // Make sure that we're working with the right name | |
| 16295 var ret, type, hooks, | |
| 16296 origName = jQuery.camelCase( name ), | |
| 16297 style = elem.style; | |
| 16298 | |
| 16299 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); | |
| 16300 | |
| 16301 // Gets hook for the prefixed version, then unprefixed version | |
| 16302 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; | |
| 16303 | |
| 16304 // Check if we're setting a value | |
| 16305 if ( value !== undefined ) { | |
| 16306 type = typeof value; | |
| 16307 | |
| 16308 // Convert "+=" or "-=" to relative numbers (#7345) | |
| 16309 if ( type === "string" && (ret = rrelNum.exec( value )) ) { | |
| 16310 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); | |
| 16311 // Fixes bug #9237 | |
| 16312 type = "number"; | |
| 16313 } | |
| 16314 | |
| 16315 // Make sure that null and NaN values aren't set (#7116) | |
| 16316 if ( value == null || value !== value ) { | |
| 16317 return; | |
| 16318 } | |
| 16319 | |
| 16320 // If a number, add 'px' to the (except for certain CSS properties) | |
| 16321 if ( type === "number" && !jQuery.cssNumber[ origName ] ) { | |
| 16322 value += "px"; | |
| 16323 } | |
| 16324 | |
| 16325 // Support: IE9-11+ | |
| 16326 // background-* props affect original clone's values | |
| 16327 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { | |
| 16328 style[ name ] = "inherit"; | |
| 16329 } | |
| 16330 | |
| 16331 // If a hook was provided, use that value, otherwise just set the specified value | |
| 16332 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { | |
| 16333 style[ name ] = value; | |
| 16334 } | |
| 16335 | |
| 16336 } else { | |
| 16337 // If a hook was provided get the non-computed value from there | |
| 16338 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { | |
| 16339 return ret; | |
| 16340 } | |
| 16341 | |
| 16342 // Otherwise just get the value from the style object | |
| 16343 return style[ name ]; | |
| 16344 } | |
| 16345 }, | |
| 16346 | |
| 16347 css: function( elem, name, extra, styles ) { | |
| 16348 var val, num, hooks, | |
| 16349 origName = jQuery.camelCase( name ); | |
| 16350 | |
| 16351 // Make sure that we're working with the right name | |
| 16352 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); | |
| 16353 | |
| 16354 // Try prefixed name followed by the unprefixed name | |
| 16355 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; | |
| 16356 | |
| 16357 // If a hook was provided get the computed value from there | |
| 16358 if ( hooks && "get" in hooks ) { | |
| 16359 val = hooks.get( elem, true, extra ); | |
| 16360 } | |
| 16361 | |
| 16362 // Otherwise, if a way to get the computed value exists, use that | |
| 16363 if ( val === undefined ) { | |
| 16364 val = curCSS( elem, name, styles ); | |
| 16365 } | |
| 16366 | |
| 16367 // Convert "normal" to computed value | |
| 16368 if ( val === "normal" && name in cssNormalTransform ) { | |
| 16369 val = cssNormalTransform[ name ]; | |
| 16370 } | |
| 16371 | |
| 16372 // Make numeric if forced or a qualifier was provided and val looks numeric | |
| 16373 if ( extra === "" || extra ) { | |
| 16374 num = parseFloat( val ); | |
| 16375 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; | |
| 16376 } | |
| 16377 return val; | |
| 16378 } | |
| 16379 }); | |
| 16380 | |
| 16381 jQuery.each([ "height", "width" ], function( i, name ) { | |
| 16382 jQuery.cssHooks[ name ] = { | |
| 16383 get: function( elem, computed, extra ) { | |
| 16384 if ( computed ) { | |
| 16385 | |
| 16386 // Certain elements can have dimension info if we invisibly show them | |
| 16387 // but it must have a current display style that would benefit | |
| 16388 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ? | |
| 16389 jQuery.swap( elem, cssShow, function() { | |
| 16390 return getWidthOrHeight( elem, name, extra ); | |
| 16391 }) : | |
| 16392 getWidthOrHeight( elem, name, extra ); | |
| 16393 } | |
| 16394 }, | |
| 16395 | |
| 16396 set: function( elem, value, extra ) { | |
| 16397 var styles = extra && getStyles( elem ); | |
| 16398 return setPositiveNumber( elem, value, extra ? | |
| 16399 augmentWidthOrHeight( | |
| 16400 elem, | |
| 16401 name, | |
| 16402 extra, | |
| 16403 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", | |
| 16404 styles | |
| 16405 ) : 0 | |
| 16406 ); | |
| 16407 } | |
| 16408 }; | |
| 16409 }); | |
| 16410 | |
| 16411 // Support: Android 2.3 | |
| 16412 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, | |
| 16413 function( elem, computed ) { | |
| 16414 if ( computed ) { | |
| 16415 return jQuery.swap( elem, { "display": "inline-block" }, | |
| 16416 curCSS, [ elem, "marginRight" ] ); | |
| 16417 } | |
| 16418 } | |
| 16419 ); | |
| 16420 | |
| 16421 // These hooks are used by animate to expand properties | |
| 16422 jQuery.each({ | |
| 16423 margin: "", | |
| 16424 padding: "", | |
| 16425 border: "Width" | |
| 16426 }, function( prefix, suffix ) { | |
| 16427 jQuery.cssHooks[ prefix + suffix ] = { | |
| 16428 expand: function( value ) { | |
| 16429 var i = 0, | |
| 16430 expanded = {}, | |
| 16431 | |
| 16432 // Assumes a single number if not a string | |
| 16433 parts = typeof value === "string" ? value.split(" ") : [ value ]; | |
| 16434 | |
| 16435 for ( ; i < 4; i++ ) { | |
| 16436 expanded[ prefix + cssExpand[ i ] + suffix ] = | |
| 16437 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; | |
| 16438 } | |
| 16439 | |
| 16440 return expanded; | |
| 16441 } | |
| 16442 }; | |
| 16443 | |
| 16444 if ( !rmargin.test( prefix ) ) { | |
| 16445 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; | |
| 16446 } | |
| 16447 }); | |
| 16448 | |
| 16449 jQuery.fn.extend({ | |
| 16450 css: function( name, value ) { | |
| 16451 return access( this, function( elem, name, value ) { | |
| 16452 var styles, len, | |
| 16453 map = {}, | |
| 16454 i = 0; | |
| 16455 | |
| 16456 if ( jQuery.isArray( name ) ) { | |
| 16457 styles = getStyles( elem ); | |
| 16458 len = name.length; | |
| 16459 | |
| 16460 for ( ; i < len; i++ ) { | |
| 16461 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); | |
| 16462 } | |
| 16463 | |
| 16464 return map; | |
| 16465 } | |
| 16466 | |
| 16467 return value !== undefined ? | |
| 16468 jQuery.style( elem, name, value ) : | |
| 16469 jQuery.css( elem, name ); | |
| 16470 }, name, value, arguments.length > 1 ); | |
| 16471 }, | |
| 16472 show: function() { | |
| 16473 return showHide( this, true ); | |
| 16474 }, | |
| 16475 hide: function() { | |
| 16476 return showHide( this ); | |
| 16477 }, | |
| 16478 toggle: function( state ) { | |
| 16479 if ( typeof state === "boolean" ) { | |
| 16480 return state ? this.show() : this.hide(); | |
| 16481 } | |
| 16482 | |
| 16483 return this.each(function() { | |
| 16484 if ( isHidden( this ) ) { | |
| 16485 jQuery( this ).show(); | |
| 16486 } else { | |
| 16487 jQuery( this ).hide(); | |
| 16488 } | |
| 16489 }); | |
| 16490 } | |
| 16491 }); | |
| 16492 | |
| 16493 | |
| 16494 function Tween( elem, options, prop, end, easing ) { | |
| 16495 return new Tween.prototype.init( elem, options, prop, end, easing ); | |
| 16496 } | |
| 16497 jQuery.Tween = Tween; | |
| 16498 | |
| 16499 Tween.prototype = { | |
| 16500 constructor: Tween, | |
| 16501 init: function( elem, options, prop, end, easing, unit ) { | |
| 16502 this.elem = elem; | |
| 16503 this.prop = prop; | |
| 16504 this.easing = easing || "swing"; | |
| 16505 this.options = options; | |
| 16506 this.start = this.now = this.cur(); | |
| 16507 this.end = end; | |
| 16508 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); | |
| 16509 }, | |
| 16510 cur: function() { | |
| 16511 var hooks = Tween.propHooks[ this.prop ]; | |
| 16512 | |
| 16513 return hooks && hooks.get ? | |
| 16514 hooks.get( this ) : | |
| 16515 Tween.propHooks._default.get( this ); | |
| 16516 }, | |
| 16517 run: function( percent ) { | |
| 16518 var eased, | |
| 16519 hooks = Tween.propHooks[ this.prop ]; | |
| 16520 | |
| 16521 if ( this.options.duration ) { | |
| 16522 this.pos = eased = jQuery.easing[ this.easing ]( | |
| 16523 percent, this.options.duration * percent, 0, 1, this.options.duration | |
| 16524 ); | |
| 16525 } else { | |
| 16526 this.pos = eased = percent; | |
| 16527 } | |
| 16528 this.now = ( this.end - this.start ) * eased + this.start; | |
| 16529 | |
| 16530 if ( this.options.step ) { | |
| 16531 this.options.step.call( this.elem, this.now, this ); | |
| 16532 } | |
| 16533 | |
| 16534 if ( hooks && hooks.set ) { | |
| 16535 hooks.set( this ); | |
| 16536 } else { | |
| 16537 Tween.propHooks._default.set( this ); | |
| 16538 } | |
| 16539 return this; | |
| 16540 } | |
| 16541 }; | |
| 16542 | |
| 16543 Tween.prototype.init.prototype = Tween.prototype; | |
| 16544 | |
| 16545 Tween.propHooks = { | |
| 16546 _default: { | |
| 16547 get: function( tween ) { | |
| 16548 var result; | |
| 16549 | |
| 16550 if ( tween.elem[ tween.prop ] != null && | |
| 16551 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { | |
| 16552 return tween.elem[ tween.prop ]; | |
| 16553 } | |
| 16554 | |
| 16555 // Passing an empty string as a 3rd parameter to .css will automatically | |
| 16556 // attempt a parseFloat and fallback to a string if the parse fails. | |
| 16557 // Simple values such as "10px" are parsed to Float; | |
| 16558 // complex values such as "rotate(1rad)" are returned as-is. | |
| 16559 result = jQuery.css( tween.elem, tween.prop, "" ); | |
| 16560 // Empty strings, null, undefined and "auto" are converted to 0. | |
| 16561 return !result || result === "auto" ? 0 : result; | |
| 16562 }, | |
| 16563 set: function( tween ) { | |
| 16564 // Use step hook for back compat. | |
| 16565 // Use cssHook if its there. | |
| 16566 // Use .style if available and use plain properties where available. | |
| 16567 if ( jQuery.fx.step[ tween.prop ] ) { | |
| 16568 jQuery.fx.step[ tween.prop ]( tween ); | |
| 16569 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { | |
| 16570 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); | |
| 16571 } else { | |
| 16572 tween.elem[ tween.prop ] = tween.now; | |
| 16573 } | |
| 16574 } | |
| 16575 } | |
| 16576 }; | |
| 16577 | |
| 16578 // Support: IE9 | |
| 16579 // Panic based approach to setting things on disconnected nodes | |
| 16580 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { | |
| 16581 set: function( tween ) { | |
| 16582 if ( tween.elem.nodeType && tween.elem.parentNode ) { | |
| 16583 tween.elem[ tween.prop ] = tween.now; | |
| 16584 } | |
| 16585 } | |
| 16586 }; | |
| 16587 | |
| 16588 jQuery.easing = { | |
| 16589 linear: function( p ) { | |
| 16590 return p; | |
| 16591 }, | |
| 16592 swing: function( p ) { | |
| 16593 return 0.5 - Math.cos( p * Math.PI ) / 2; | |
| 16594 } | |
| 16595 }; | |
| 16596 | |
| 16597 jQuery.fx = Tween.prototype.init; | |
| 16598 | |
| 16599 // Back Compat <1.8 extension point | |
| 16600 jQuery.fx.step = {}; | |
| 16601 | |
| 16602 | |
| 16603 | |
| 16604 | |
| 16605 var | |
| 16606 fxNow, timerId, | |
| 16607 rfxtypes = /^(?:toggle|show|hide)$/, | |
| 16608 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ), | |
| 16609 rrun = /queueHooks$/, | |
| 16610 animationPrefilters = [ defaultPrefilter ], | |
| 16611 tweeners = { | |
| 16612 "*": [ function( prop, value ) { | |
| 16613 var tween = this.createTween( prop, value ), | |
| 16614 target = tween.cur(), | |
| 16615 parts = rfxnum.exec( value ), | |
| 16616 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), | |
| 16617 | |
| 16618 // Starting value computation is required for potential unit mismatches | |
| 16619 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) && | |
| 16620 rfxnum.exec( jQuery.css( tween.elem, prop ) ), | |
| 16621 scale = 1, | |
| 16622 maxIterations = 20; | |
| 16623 | |
| 16624 if ( start && start[ 3 ] !== unit ) { | |
| 16625 // Trust units reported by jQuery.css | |
| 16626 unit = unit || start[ 3 ]; | |
| 16627 | |
| 16628 // Make sure we update the tween properties later on | |
| 16629 parts = parts || []; | |
| 16630 | |
| 16631 // Iteratively approximate from a nonzero starting point | |
| 16632 start = +target || 1; | |
| 16633 | |
| 16634 do { | |
| 16635 // If previous iteration zeroed out, double until we get *something*. | |
| 16636 // Use string for doubling so we don't accidentally see scale as unchanged below | |
| 16637 scale = scale || ".5"; | |
| 16638 | |
| 16639 // Adjust and apply | |
| 16640 start = start / scale; | |
| 16641 jQuery.style( tween.elem, prop, start + unit ); | |
| 16642 | |
| 16643 // Update scale, tolerating zero or NaN from tween.cur(), | |
| 16644 // break the loop if scale is unchanged or perfect, or if we've just had enough | |
| 16645 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations ); | |
| 16646 } | |
| 16647 | |
| 16648 // Update tween properties | |
| 16649 if ( parts ) { | |
| 16650 start = tween.start = +start || +target || 0; | |
| 16651 tween.unit = unit; | |
| 16652 // If a +=/-= token was provided, we're doing a relative animation | |
| 16653 tween.end = parts[ 1 ] ? | |
| 16654 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] : | |
| 16655 +parts[ 2 ]; | |
| 16656 } | |
| 16657 | |
| 16658 return tween; | |
| 16659 } ] | |
| 16660 }; | |
| 16661 | |
| 16662 // Animations created synchronously will run synchronously | |
| 16663 function createFxNow() { | |
| 16664 setTimeout(function() { | |
| 16665 fxNow = undefined; | |
| 16666 }); | |
| 16667 return ( fxNow = jQuery.now() ); | |
| 16668 } | |
| 16669 | |
| 16670 // Generate parameters to create a standard animation | |
| 16671 function genFx( type, includeWidth ) { | |
| 16672 var which, | |
| 16673 i = 0, | |
| 16674 attrs = { height: type }; | |
| 16675 | |
| 16676 // If we include width, step value is 1 to do all cssExpand values, | |
| 16677 // otherwise step value is 2 to skip over Left and Right | |
| 16678 includeWidth = includeWidth ? 1 : 0; | |
| 16679 for ( ; i < 4 ; i += 2 - includeWidth ) { | |
| 16680 which = cssExpand[ i ]; | |
| 16681 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; | |
| 16682 } | |
| 16683 | |
| 16684 if ( includeWidth ) { | |
| 16685 attrs.opacity = attrs.width = type; | |
| 16686 } | |
| 16687 | |
| 16688 return attrs; | |
| 16689 } | |
| 16690 | |
| 16691 function createTween( value, prop, animation ) { | |
| 16692 var tween, | |
| 16693 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), | |
| 16694 index = 0, | |
| 16695 length = collection.length; | |
| 16696 for ( ; index < length; index++ ) { | |
| 16697 if ( (tween = collection[ index ].call( animation, prop, value )) ) { | |
| 16698 | |
| 16699 // We're done with this property | |
| 16700 return tween; | |
| 16701 } | |
| 16702 } | |
| 16703 } | |
| 16704 | |
| 16705 function defaultPrefilter( elem, props, opts ) { | |
| 16706 /* jshint validthis: true */ | |
| 16707 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay, | |
| 16708 anim = this, | |
| 16709 orig = {}, | |
| 16710 style = elem.style, | |
| 16711 hidden = elem.nodeType && isHidden( elem ), | |
| 16712 dataShow = data_priv.get( elem, "fxshow" ); | |
| 16713 | |
| 16714 // Handle queue: false promises | |
| 16715 if ( !opts.queue ) { | |
| 16716 hooks = jQuery._queueHooks( elem, "fx" ); | |
| 16717 if ( hooks.unqueued == null ) { | |
| 16718 hooks.unqueued = 0; | |
| 16719 oldfire = hooks.empty.fire; | |
| 16720 hooks.empty.fire = function() { | |
| 16721 if ( !hooks.unqueued ) { | |
| 16722 oldfire(); | |
| 16723 } | |
| 16724 }; | |
| 16725 } | |
| 16726 hooks.unqueued++; | |
| 16727 | |
| 16728 anim.always(function() { | |
| 16729 // Ensure the complete handler is called before this completes | |
| 16730 anim.always(function() { | |
| 16731 hooks.unqueued--; | |
| 16732 if ( !jQuery.queue( elem, "fx" ).length ) { | |
| 16733 hooks.empty.fire(); | |
| 16734 } | |
| 16735 }); | |
| 16736 }); | |
| 16737 } | |
| 16738 | |
| 16739 // Height/width overflow pass | |
| 16740 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { | |
| 16741 // Make sure that nothing sneaks out | |
| 16742 // Record all 3 overflow attributes because IE9-10 do not | |
| 16743 // change the overflow attribute when overflowX and | |
| 16744 // overflowY are set to the same value | |
| 16745 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; | |
| 16746 | |
| 16747 // Set display property to inline-block for height/width | |
| 16748 // animations on inline elements that are having width/height animated | |
| 16749 display = jQuery.css( elem, "display" ); | |
| 16750 | |
| 16751 // Test default display if display is currently "none" | |
| 16752 checkDisplay = display === "none" ? | |
| 16753 data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; | |
| 16754 | |
| 16755 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { | |
| 16756 style.display = "inline-block"; | |
| 16757 } | |
| 16758 } | |
| 16759 | |
| 16760 if ( opts.overflow ) { | |
| 16761 style.overflow = "hidden"; | |
| 16762 anim.always(function() { | |
| 16763 style.overflow = opts.overflow[ 0 ]; | |
| 16764 style.overflowX = opts.overflow[ 1 ]; | |
| 16765 style.overflowY = opts.overflow[ 2 ]; | |
| 16766 }); | |
| 16767 } | |
| 16768 | |
| 16769 // show/hide pass | |
| 16770 for ( prop in props ) { | |
| 16771 value = props[ prop ]; | |
| 16772 if ( rfxtypes.exec( value ) ) { | |
| 16773 delete props[ prop ]; | |
| 16774 toggle = toggle || value === "toggle"; | |
| 16775 if ( value === ( hidden ? "hide" : "show" ) ) { | |
| 16776 | |
| 16777 // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden | |
| 16778 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { | |
| 16779 hidden = true; | |
| 16780 } else { | |
| 16781 continue; | |
| 16782 } | |
| 16783 } | |
| 16784 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); | |
| 16785 | |
| 16786 // Any non-fx value stops us from restoring the original display value | |
| 16787 } else { | |
| 16788 display = undefined; | |
| 16789 } | |
| 16790 } | |
| 16791 | |
| 16792 if ( !jQuery.isEmptyObject( orig ) ) { | |
| 16793 if ( dataShow ) { | |
| 16794 if ( "hidden" in dataShow ) { | |
| 16795 hidden = dataShow.hidden; | |
| 16796 } | |
| 16797 } else { | |
| 16798 dataShow = data_priv.access( elem, "fxshow", {} ); | |
| 16799 } | |
| 16800 | |
| 16801 // Store state if its toggle - enables .stop().toggle() to "reverse" | |
| 16802 if ( toggle ) { | |
| 16803 dataShow.hidden = !hidden; | |
| 16804 } | |
| 16805 if ( hidden ) { | |
| 16806 jQuery( elem ).show(); | |
| 16807 } else { | |
| 16808 anim.done(function() { | |
| 16809 jQuery( elem ).hide(); | |
| 16810 }); | |
| 16811 } | |
| 16812 anim.done(function() { | |
| 16813 var prop; | |
| 16814 | |
| 16815 data_priv.remove( elem, "fxshow" ); | |
| 16816 for ( prop in orig ) { | |
| 16817 jQuery.style( elem, prop, orig[ prop ] ); | |
| 16818 } | |
| 16819 }); | |
| 16820 for ( prop in orig ) { | |
| 16821 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); | |
| 16822 | |
| 16823 if ( !( prop in dataShow ) ) { | |
| 16824 dataShow[ prop ] = tween.start; | |
| 16825 if ( hidden ) { | |
| 16826 tween.end = tween.start; | |
| 16827 tween.start = prop === "width" || prop === "height" ? 1 : 0; | |
| 16828 } | |
| 16829 } | |
| 16830 } | |
| 16831 | |
| 16832 // If this is a noop like .hide().hide(), restore an overwritten display value | |
| 16833 } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) { | |
| 16834 style.display = display; | |
| 16835 } | |
| 16836 } | |
| 16837 | |
| 16838 function propFilter( props, specialEasing ) { | |
| 16839 var index, name, easing, value, hooks; | |
| 16840 | |
| 16841 // camelCase, specialEasing and expand cssHook pass | |
| 16842 for ( index in props ) { | |
| 16843 name = jQuery.camelCase( index ); | |
| 16844 easing = specialEasing[ name ]; | |
| 16845 value = props[ index ]; | |
| 16846 if ( jQuery.isArray( value ) ) { | |
| 16847 easing = value[ 1 ]; | |
| 16848 value = props[ index ] = value[ 0 ]; | |
| 16849 } | |
| 16850 | |
| 16851 if ( index !== name ) { | |
| 16852 props[ name ] = value; | |
| 16853 delete props[ index ]; | |
| 16854 } | |
| 16855 | |
| 16856 hooks = jQuery.cssHooks[ name ]; | |
| 16857 if ( hooks && "expand" in hooks ) { | |
| 16858 value = hooks.expand( value ); | |
| 16859 delete props[ name ]; | |
| 16860 | |
| 16861 // Not quite $.extend, this won't overwrite existing keys. | |
| 16862 // Reusing 'index' because we have the correct "name" | |
| 16863 for ( index in value ) { | |
| 16864 if ( !( index in props ) ) { | |
| 16865 props[ index ] = value[ index ]; | |
| 16866 specialEasing[ index ] = easing; | |
| 16867 } | |
| 16868 } | |
| 16869 } else { | |
| 16870 specialEasing[ name ] = easing; | |
| 16871 } | |
| 16872 } | |
| 16873 } | |
| 16874 | |
| 16875 function Animation( elem, properties, options ) { | |
| 16876 var result, | |
| 16877 stopped, | |
| 16878 index = 0, | |
| 16879 length = animationPrefilters.length, | |
| 16880 deferred = jQuery.Deferred().always( function() { | |
| 16881 // Don't match elem in the :animated selector | |
| 16882 delete tick.elem; | |
| 16883 }), | |
| 16884 tick = function() { | |
| 16885 if ( stopped ) { | |
| 16886 return false; | |
| 16887 } | |
| 16888 var currentTime = fxNow || createFxNow(), | |
| 16889 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), | |
| 16890 // Support: Android 2.3 | |
| 16891 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) | |
| 16892 temp = remaining / animation.duration || 0, | |
| 16893 percent = 1 - temp, | |
| 16894 index = 0, | |
| 16895 length = animation.tweens.length; | |
| 16896 | |
| 16897 for ( ; index < length ; index++ ) { | |
| 16898 animation.tweens[ index ].run( percent ); | |
| 16899 } | |
| 16900 | |
| 16901 deferred.notifyWith( elem, [ animation, percent, remaining ]); | |
| 16902 | |
| 16903 if ( percent < 1 && length ) { | |
| 16904 return remaining; | |
| 16905 } else { | |
| 16906 deferred.resolveWith( elem, [ animation ] ); | |
| 16907 return false; | |
| 16908 } | |
| 16909 }, | |
| 16910 animation = deferred.promise({ | |
| 16911 elem: elem, | |
| 16912 props: jQuery.extend( {}, properties ), | |
| 16913 opts: jQuery.extend( true, { specialEasing: {} }, options ), | |
| 16914 originalProperties: properties, | |
| 16915 originalOptions: options, | |
| 16916 startTime: fxNow || createFxNow(), | |
| 16917 duration: options.duration, | |
| 16918 tweens: [], | |
| 16919 createTween: function( prop, end ) { | |
| 16920 var tween = jQuery.Tween( elem, animation.opts, prop, end, | |
| 16921 animation.opts.specialEasing[ prop ] || animation.opts.easing ); | |
| 16922 animation.tweens.push( tween ); | |
| 16923 return tween; | |
| 16924 }, | |
| 16925 stop: function( gotoEnd ) { | |
| 16926 var index = 0, | |
| 16927 // If we are going to the end, we want to run all the tweens | |
| 16928 // otherwise we skip this part | |
| 16929 length = gotoEnd ? animation.tweens.length : 0; | |
| 16930 if ( stopped ) { | |
| 16931 return this; | |
| 16932 } | |
| 16933 stopped = true; | |
| 16934 for ( ; index < length ; index++ ) { | |
| 16935 animation.tweens[ index ].run( 1 ); | |
| 16936 } | |
| 16937 | |
| 16938 // Resolve when we played the last frame; otherwise, reject | |
| 16939 if ( gotoEnd ) { | |
| 16940 deferred.resolveWith( elem, [ animation, gotoEnd ] ); | |
| 16941 } else { | |
| 16942 deferred.rejectWith( elem, [ animation, gotoEnd ] ); | |
| 16943 } | |
| 16944 return this; | |
| 16945 } | |
| 16946 }), | |
| 16947 props = animation.props; | |
| 16948 | |
| 16949 propFilter( props, animation.opts.specialEasing ); | |
| 16950 | |
| 16951 for ( ; index < length ; index++ ) { | |
| 16952 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); | |
| 16953 if ( result ) { | |
| 16954 return result; | |
| 16955 } | |
| 16956 } | |
| 16957 | |
| 16958 jQuery.map( props, createTween, animation ); | |
| 16959 | |
| 16960 if ( jQuery.isFunction( animation.opts.start ) ) { | |
| 16961 animation.opts.start.call( elem, animation ); | |
| 16962 } | |
| 16963 | |
| 16964 jQuery.fx.timer( | |
| 16965 jQuery.extend( tick, { | |
| 16966 elem: elem, | |
| 16967 anim: animation, | |
| 16968 queue: animation.opts.queue | |
| 16969 }) | |
| 16970 ); | |
| 16971 | |
| 16972 // attach callbacks from options | |
| 16973 return animation.progress( animation.opts.progress ) | |
| 16974 .done( animation.opts.done, animation.opts.complete ) | |
| 16975 .fail( animation.opts.fail ) | |
| 16976 .always( animation.opts.always ); | |
| 16977 } | |
| 16978 | |
| 16979 jQuery.Animation = jQuery.extend( Animation, { | |
| 16980 | |
| 16981 tweener: function( props, callback ) { | |
| 16982 if ( jQuery.isFunction( props ) ) { | |
| 16983 callback = props; | |
| 16984 props = [ "*" ]; | |
| 16985 } else { | |
| 16986 props = props.split(" "); | |
| 16987 } | |
| 16988 | |
| 16989 var prop, | |
| 16990 index = 0, | |
| 16991 length = props.length; | |
| 16992 | |
| 16993 for ( ; index < length ; index++ ) { | |
| 16994 prop = props[ index ]; | |
| 16995 tweeners[ prop ] = tweeners[ prop ] || []; | |
| 16996 tweeners[ prop ].unshift( callback ); | |
| 16997 } | |
| 16998 }, | |
| 16999 | |
| 17000 prefilter: function( callback, prepend ) { | |
| 17001 if ( prepend ) { | |
| 17002 animationPrefilters.unshift( callback ); | |
| 17003 } else { | |
| 17004 animationPrefilters.push( callback ); | |
| 17005 } | |
| 17006 } | |
| 17007 }); | |
| 17008 | |
| 17009 jQuery.speed = function( speed, easing, fn ) { | |
| 17010 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { | |
| 17011 complete: fn || !fn && easing || | |
| 17012 jQuery.isFunction( speed ) && speed, | |
| 17013 duration: speed, | |
| 17014 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing | |
| 17015 }; | |
| 17016 | |
| 17017 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : | |
| 17018 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; | |
| 17019 | |
| 17020 // Normalize opt.queue - true/undefined/null -> "fx" | |
| 17021 if ( opt.queue == null || opt.queue === true ) { | |
| 17022 opt.queue = "fx"; | |
| 17023 } | |
| 17024 | |
| 17025 // Queueing | |
| 17026 opt.old = opt.complete; | |
| 17027 | |
| 17028 opt.complete = function() { | |
| 17029 if ( jQuery.isFunction( opt.old ) ) { | |
| 17030 opt.old.call( this ); | |
| 17031 } | |
| 17032 | |
| 17033 if ( opt.queue ) { | |
| 17034 jQuery.dequeue( this, opt.queue ); | |
| 17035 } | |
| 17036 }; | |
| 17037 | |
| 17038 return opt; | |
| 17039 }; | |
| 17040 | |
| 17041 jQuery.fn.extend({ | |
| 17042 fadeTo: function( speed, to, easing, callback ) { | |
| 17043 | |
| 17044 // Show any hidden elements after setting opacity to 0 | |
| 17045 return this.filter( isHidden ).css( "opacity", 0 ).show() | |
| 17046 | |
| 17047 // Animate to the value specified | |
| 17048 .end().animate({ opacity: to }, speed, easing, callback ); | |
| 17049 }, | |
| 17050 animate: function( prop, speed, easing, callback ) { | |
| 17051 var empty = jQuery.isEmptyObject( prop ), | |
| 17052 optall = jQuery.speed( speed, easing, callback ), | |
| 17053 doAnimation = function() { | |
| 17054 // Operate on a copy of prop so per-property easing won't be lost | |
| 17055 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); | |
| 17056 | |
| 17057 // Empty animations, or finishing resolves immediately | |
| 17058 if ( empty || data_priv.get( this, "finish" ) ) { | |
| 17059 anim.stop( true ); | |
| 17060 } | |
| 17061 }; | |
| 17062 doAnimation.finish = doAnimation; | |
| 17063 | |
| 17064 return empty || optall.queue === false ? | |
| 17065 this.each( doAnimation ) : | |
| 17066 this.queue( optall.queue, doAnimation ); | |
| 17067 }, | |
| 17068 stop: function( type, clearQueue, gotoEnd ) { | |
| 17069 var stopQueue = function( hooks ) { | |
| 17070 var stop = hooks.stop; | |
| 17071 delete hooks.stop; | |
| 17072 stop( gotoEnd ); | |
| 17073 }; | |
| 17074 | |
| 17075 if ( typeof type !== "string" ) { | |
| 17076 gotoEnd = clearQueue; | |
| 17077 clearQueue = type; | |
| 17078 type = undefined; | |
| 17079 } | |
| 17080 if ( clearQueue && type !== false ) { | |
| 17081 this.queue( type || "fx", [] ); | |
| 17082 } | |
| 17083 | |
| 17084 return this.each(function() { | |
| 17085 var dequeue = true, | |
| 17086 index = type != null && type + "queueHooks", | |
| 17087 timers = jQuery.timers, | |
| 17088 data = data_priv.get( this ); | |
| 17089 | |
| 17090 if ( index ) { | |
| 17091 if ( data[ index ] && data[ index ].stop ) { | |
| 17092 stopQueue( data[ index ] ); | |
| 17093 } | |
| 17094 } else { | |
| 17095 for ( index in data ) { | |
| 17096 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { | |
| 17097 stopQueue( data[ index ] ); | |
| 17098 } | |
| 17099 } | |
| 17100 } | |
| 17101 | |
| 17102 for ( index = timers.length; index--; ) { | |
| 17103 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { | |
| 17104 timers[ index ].anim.stop( gotoEnd ); | |
| 17105 dequeue = false; | |
| 17106 timers.splice( index, 1 ); | |
| 17107 } | |
| 17108 } | |
| 17109 | |
| 17110 // Start the next in the queue if the last step wasn't forced. | |
| 17111 // Timers currently will call their complete callbacks, which | |
| 17112 // will dequeue but only if they were gotoEnd. | |
| 17113 if ( dequeue || !gotoEnd ) { | |
| 17114 jQuery.dequeue( this, type ); | |
| 17115 } | |
| 17116 }); | |
| 17117 }, | |
| 17118 finish: function( type ) { | |
| 17119 if ( type !== false ) { | |
| 17120 type = type || "fx"; | |
| 17121 } | |
| 17122 return this.each(function() { | |
| 17123 var index, | |
| 17124 data = data_priv.get( this ), | |
| 17125 queue = data[ type + "queue" ], | |
| 17126 hooks = data[ type + "queueHooks" ], | |
| 17127 timers = jQuery.timers, | |
| 17128 length = queue ? queue.length : 0; | |
| 17129 | |
| 17130 // Enable finishing flag on private data | |
| 17131 data.finish = true; | |
| 17132 | |
| 17133 // Empty the queue first | |
| 17134 jQuery.queue( this, type, [] ); | |
| 17135 | |
| 17136 if ( hooks && hooks.stop ) { | |
| 17137 hooks.stop.call( this, true ); | |
| 17138 } | |
| 17139 | |
| 17140 // Look for any active animations, and finish them | |
| 17141 for ( index = timers.length; index--; ) { | |
| 17142 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { | |
| 17143 timers[ index ].anim.stop( true ); | |
| 17144 timers.splice( index, 1 ); | |
| 17145 } | |
| 17146 } | |
| 17147 | |
| 17148 // Look for any animations in the old queue and finish them | |
| 17149 for ( index = 0; index < length; index++ ) { | |
| 17150 if ( queue[ index ] && queue[ index ].finish ) { | |
| 17151 queue[ index ].finish.call( this ); | |
| 17152 } | |
| 17153 } | |
| 17154 | |
| 17155 // Turn off finishing flag | |
| 17156 delete data.finish; | |
| 17157 }); | |
| 17158 } | |
| 17159 }); | |
| 17160 | |
| 17161 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { | |
| 17162 var cssFn = jQuery.fn[ name ]; | |
| 17163 jQuery.fn[ name ] = function( speed, easing, callback ) { | |
| 17164 return speed == null || typeof speed === "boolean" ? | |
| 17165 cssFn.apply( this, arguments ) : | |
| 17166 this.animate( genFx( name, true ), speed, easing, callback ); | |
| 17167 }; | |
| 17168 }); | |
| 17169 | |
| 17170 // Generate shortcuts for custom animations | |
| 17171 jQuery.each({ | |
| 17172 slideDown: genFx("show"), | |
| 17173 slideUp: genFx("hide"), | |
| 17174 slideToggle: genFx("toggle"), | |
| 17175 fadeIn: { opacity: "show" }, | |
| 17176 fadeOut: { opacity: "hide" }, | |
| 17177 fadeToggle: { opacity: "toggle" } | |
| 17178 }, function( name, props ) { | |
| 17179 jQuery.fn[ name ] = function( speed, easing, callback ) { | |
| 17180 return this.animate( props, speed, easing, callback ); | |
| 17181 }; | |
| 17182 }); | |
| 17183 | |
| 17184 jQuery.timers = []; | |
| 17185 jQuery.fx.tick = function() { | |
| 17186 var timer, | |
| 17187 i = 0, | |
| 17188 timers = jQuery.timers; | |
| 17189 | |
| 17190 fxNow = jQuery.now(); | |
| 17191 | |
| 17192 for ( ; i < timers.length; i++ ) { | |
| 17193 timer = timers[ i ]; | |
| 17194 // Checks the timer has not already been removed | |
| 17195 if ( !timer() && timers[ i ] === timer ) { | |
| 17196 timers.splice( i--, 1 ); | |
| 17197 } | |
| 17198 } | |
| 17199 | |
| 17200 if ( !timers.length ) { | |
| 17201 jQuery.fx.stop(); | |
| 17202 } | |
| 17203 fxNow = undefined; | |
| 17204 }; | |
| 17205 | |
| 17206 jQuery.fx.timer = function( timer ) { | |
| 17207 jQuery.timers.push( timer ); | |
| 17208 if ( timer() ) { | |
| 17209 jQuery.fx.start(); | |
| 17210 } else { | |
| 17211 jQuery.timers.pop(); | |
| 17212 } | |
| 17213 }; | |
| 17214 | |
| 17215 jQuery.fx.interval = 13; | |
| 17216 | |
| 17217 jQuery.fx.start = function() { | |
| 17218 if ( !timerId ) { | |
| 17219 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); | |
| 17220 } | |
| 17221 }; | |
| 17222 | |
| 17223 jQuery.fx.stop = function() { | |
| 17224 clearInterval( timerId ); | |
| 17225 timerId = null; | |
| 17226 }; | |
| 17227 | |
| 17228 jQuery.fx.speeds = { | |
| 17229 slow: 600, | |
| 17230 fast: 200, | |
| 17231 // Default speed | |
| 17232 _default: 400 | |
| 17233 }; | |
| 17234 | |
| 17235 | |
| 17236 // Based off of the plugin by Clint Helfers, with permission. | |
| 17237 // http://blindsignals.com/index.php/2009/07/jquery-delay/ | |
| 17238 jQuery.fn.delay = function( time, type ) { | |
| 17239 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; | |
| 17240 type = type || "fx"; | |
| 17241 | |
| 17242 return this.queue( type, function( next, hooks ) { | |
| 17243 var timeout = setTimeout( next, time ); | |
| 17244 hooks.stop = function() { | |
| 17245 clearTimeout( timeout ); | |
| 17246 }; | |
| 17247 }); | |
| 17248 }; | |
| 17249 | |
| 17250 | |
| 17251 (function() { | |
| 17252 var input = document.createElement( "input" ), | |
| 17253 select = document.createElement( "select" ), | |
| 17254 opt = select.appendChild( document.createElement( "option" ) ); | |
| 17255 | |
| 17256 input.type = "checkbox"; | |
| 17257 | |
| 17258 // Support: iOS<=5.1, Android<=4.2+ | |
| 17259 // Default value for a checkbox should be "on" | |
| 17260 support.checkOn = input.value !== ""; | |
| 17261 | |
| 17262 // Support: IE<=11+ | |
| 17263 // Must access selectedIndex to make default options select | |
| 17264 support.optSelected = opt.selected; | |
| 17265 | |
| 17266 // Support: Android<=2.3 | |
| 17267 // Options inside disabled selects are incorrectly marked as disabled | |
| 17268 select.disabled = true; | |
| 17269 support.optDisabled = !opt.disabled; | |
| 17270 | |
| 17271 // Support: IE<=11+ | |
| 17272 // An input loses its value after becoming a radio | |
| 17273 input = document.createElement( "input" ); | |
| 17274 input.value = "t"; | |
| 17275 input.type = "radio"; | |
| 17276 support.radioValue = input.value === "t"; | |
| 17277 })(); | |
| 17278 | |
| 17279 | |
| 17280 var nodeHook, boolHook, | |
| 17281 attrHandle = jQuery.expr.attrHandle; | |
| 17282 | |
| 17283 jQuery.fn.extend({ | |
| 17284 attr: function( name, value ) { | |
| 17285 return access( this, jQuery.attr, name, value, arguments.length > 1 ); | |
| 17286 }, | |
| 17287 | |
| 17288 removeAttr: function( name ) { | |
| 17289 return this.each(function() { | |
| 17290 jQuery.removeAttr( this, name ); | |
| 17291 }); | |
| 17292 } | |
| 17293 }); | |
| 17294 | |
| 17295 jQuery.extend({ | |
| 17296 attr: function( elem, name, value ) { | |
| 17297 var hooks, ret, | |
| 17298 nType = elem.nodeType; | |
| 17299 | |
| 17300 // don't get/set attributes on text, comment and attribute nodes | |
| 17301 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | |
| 17302 return; | |
| 17303 } | |
| 17304 | |
| 17305 // Fallback to prop when attributes are not supported | |
| 17306 if ( typeof elem.getAttribute === strundefined ) { | |
| 17307 return jQuery.prop( elem, name, value ); | |
| 17308 } | |
| 17309 | |
| 17310 // All attributes are lowercase | |
| 17311 // Grab necessary hook if one is defined | |
| 17312 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { | |
| 17313 name = name.toLowerCase(); | |
| 17314 hooks = jQuery.attrHooks[ name ] || | |
| 17315 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook ); | |
| 17316 } | |
| 17317 | |
| 17318 if ( value !== undefined ) { | |
| 17319 | |
| 17320 if ( value === null ) { | |
| 17321 jQuery.removeAttr( elem, name ); | |
| 17322 | |
| 17323 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { | |
| 17324 return ret; | |
| 17325 | |
| 17326 } else { | |
| 17327 elem.setAttribute( name, value + "" ); | |
| 17328 return value; | |
| 17329 } | |
| 17330 | |
| 17331 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { | |
| 17332 return ret; | |
| 17333 | |
| 17334 } else { | |
| 17335 ret = jQuery.find.attr( elem, name ); | |
| 17336 | |
| 17337 // Non-existent attributes return null, we normalize to undefined | |
| 17338 return ret == null ? | |
| 17339 undefined : | |
| 17340 ret; | |
| 17341 } | |
| 17342 }, | |
| 17343 | |
| 17344 removeAttr: function( elem, value ) { | |
| 17345 var name, propName, | |
| 17346 i = 0, | |
| 17347 attrNames = value && value.match( rnotwhite ); | |
| 17348 | |
| 17349 if ( attrNames && elem.nodeType === 1 ) { | |
| 17350 while ( (name = attrNames[i++]) ) { | |
| 17351 propName = jQuery.propFix[ name ] || name; | |
| 17352 | |
| 17353 // Boolean attributes get special treatment (#10870) | |
| 17354 if ( jQuery.expr.match.bool.test( name ) ) { | |
| 17355 // Set corresponding property to false | |
| 17356 elem[ propName ] = false; | |
| 17357 } | |
| 17358 | |
| 17359 elem.removeAttribute( name ); | |
| 17360 } | |
| 17361 } | |
| 17362 }, | |
| 17363 | |
| 17364 attrHooks: { | |
| 17365 type: { | |
| 17366 set: function( elem, value ) { | |
| 17367 if ( !support.radioValue && value === "radio" && | |
| 17368 jQuery.nodeName( elem, "input" ) ) { | |
| 17369 var val = elem.value; | |
| 17370 elem.setAttribute( "type", value ); | |
| 17371 if ( val ) { | |
| 17372 elem.value = val; | |
| 17373 } | |
| 17374 return value; | |
| 17375 } | |
| 17376 } | |
| 17377 } | |
| 17378 } | |
| 17379 }); | |
| 17380 | |
| 17381 // Hooks for boolean attributes | |
| 17382 boolHook = { | |
| 17383 set: function( elem, value, name ) { | |
| 17384 if ( value === false ) { | |
| 17385 // Remove boolean attributes when set to false | |
| 17386 jQuery.removeAttr( elem, name ); | |
| 17387 } else { | |
| 17388 elem.setAttribute( name, name ); | |
| 17389 } | |
| 17390 return name; | |
| 17391 } | |
| 17392 }; | |
| 17393 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { | |
| 17394 var getter = attrHandle[ name ] || jQuery.find.attr; | |
| 17395 | |
| 17396 attrHandle[ name ] = function( elem, name, isXML ) { | |
| 17397 var ret, handle; | |
| 17398 if ( !isXML ) { | |
| 17399 // Avoid an infinite loop by temporarily removing this function from the getter | |
| 17400 handle = attrHandle[ name ]; | |
| 17401 attrHandle[ name ] = ret; | |
| 17402 ret = getter( elem, name, isXML ) != null ? | |
| 17403 name.toLowerCase() : | |
| 17404 null; | |
| 17405 attrHandle[ name ] = handle; | |
| 17406 } | |
| 17407 return ret; | |
| 17408 }; | |
| 17409 }); | |
| 17410 | |
| 17411 | |
| 17412 | |
| 17413 | |
| 17414 var rfocusable = /^(?:input|select|textarea|button)$/i; | |
| 17415 | |
| 17416 jQuery.fn.extend({ | |
| 17417 prop: function( name, value ) { | |
| 17418 return access( this, jQuery.prop, name, value, arguments.length > 1 ); | |
| 17419 }, | |
| 17420 | |
| 17421 removeProp: function( name ) { | |
| 17422 return this.each(function() { | |
| 17423 delete this[ jQuery.propFix[ name ] || name ]; | |
| 17424 }); | |
| 17425 } | |
| 17426 }); | |
| 17427 | |
| 17428 jQuery.extend({ | |
| 17429 propFix: { | |
| 17430 "for": "htmlFor", | |
| 17431 "class": "className" | |
| 17432 }, | |
| 17433 | |
| 17434 prop: function( elem, name, value ) { | |
| 17435 var ret, hooks, notxml, | |
| 17436 nType = elem.nodeType; | |
| 17437 | |
| 17438 // Don't get/set properties on text, comment and attribute nodes | |
| 17439 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | |
| 17440 return; | |
| 17441 } | |
| 17442 | |
| 17443 notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); | |
| 17444 | |
| 17445 if ( notxml ) { | |
| 17446 // Fix name and attach hooks | |
| 17447 name = jQuery.propFix[ name ] || name; | |
| 17448 hooks = jQuery.propHooks[ name ]; | |
| 17449 } | |
| 17450 | |
| 17451 if ( value !== undefined ) { | |
| 17452 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? | |
| 17453 ret : | |
| 17454 ( elem[ name ] = value ); | |
| 17455 | |
| 17456 } else { | |
| 17457 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? | |
| 17458 ret : | |
| 17459 elem[ name ]; | |
| 17460 } | |
| 17461 }, | |
| 17462 | |
| 17463 propHooks: { | |
| 17464 tabIndex: { | |
| 17465 get: function( elem ) { | |
| 17466 return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ? | |
| 17467 elem.tabIndex : | |
| 17468 -1; | |
| 17469 } | |
| 17470 } | |
| 17471 } | |
| 17472 }); | |
| 17473 | |
| 17474 if ( !support.optSelected ) { | |
| 17475 jQuery.propHooks.selected = { | |
| 17476 get: function( elem ) { | |
| 17477 var parent = elem.parentNode; | |
| 17478 if ( parent && parent.parentNode ) { | |
| 17479 parent.parentNode.selectedIndex; | |
| 17480 } | |
| 17481 return null; | |
| 17482 } | |
| 17483 }; | |
| 17484 } | |
| 17485 | |
| 17486 jQuery.each([ | |
| 17487 "tabIndex", | |
| 17488 "readOnly", | |
| 17489 "maxLength", | |
| 17490 "cellSpacing", | |
| 17491 "cellPadding", | |
| 17492 "rowSpan", | |
| 17493 "colSpan", | |
| 17494 "useMap", | |
| 17495 "frameBorder", | |
| 17496 "contentEditable" | |
| 17497 ], function() { | |
| 17498 jQuery.propFix[ this.toLowerCase() ] = this; | |
| 17499 }); | |
| 17500 | |
| 17501 | |
| 17502 | |
| 17503 | |
| 17504 var rclass = /[\t\r\n\f]/g; | |
| 17505 | |
| 17506 jQuery.fn.extend({ | |
| 17507 addClass: function( value ) { | |
| 17508 var classes, elem, cur, clazz, j, finalValue, | |
| 17509 proceed = typeof value === "string" && value, | |
| 17510 i = 0, | |
| 17511 len = this.length; | |
| 17512 | |
| 17513 if ( jQuery.isFunction( value ) ) { | |
| 17514 return this.each(function( j ) { | |
| 17515 jQuery( this ).addClass( value.call( this, j, this.className ) ); | |
| 17516 }); | |
| 17517 } | |
| 17518 | |
| 17519 if ( proceed ) { | |
| 17520 // The disjunction here is for better compressibility (see removeClass) | |
| 17521 classes = ( value || "" ).match( rnotwhite ) || []; | |
| 17522 | |
| 17523 for ( ; i < len; i++ ) { | |
| 17524 elem = this[ i ]; | |
| 17525 cur = elem.nodeType === 1 && ( elem.className ? | |
| 17526 ( " " + elem.className + " " ).replace( rclass, " " ) : | |
| 17527 " " | |
| 17528 ); | |
| 17529 | |
| 17530 if ( cur ) { | |
| 17531 j = 0; | |
| 17532 while ( (clazz = classes[j++]) ) { | |
| 17533 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { | |
| 17534 cur += clazz + " "; | |
| 17535 } | |
| 17536 } | |
| 17537 | |
| 17538 // only assign if different to avoid unneeded rendering. | |
| 17539 finalValue = jQuery.trim( cur ); | |
| 17540 if ( elem.className !== finalValue ) { | |
| 17541 elem.className = finalValue; | |
| 17542 } | |
| 17543 } | |
| 17544 } | |
| 17545 } | |
| 17546 | |
| 17547 return this; | |
| 17548 }, | |
| 17549 | |
| 17550 removeClass: function( value ) { | |
| 17551 var classes, elem, cur, clazz, j, finalValue, | |
| 17552 proceed = arguments.length === 0 || typeof value === "string" && value, | |
| 17553 i = 0, | |
| 17554 len = this.length; | |
| 17555 | |
| 17556 if ( jQuery.isFunction( value ) ) { | |
| 17557 return this.each(function( j ) { | |
| 17558 jQuery( this ).removeClass( value.call( this, j, this.className ) ); | |
| 17559 }); | |
| 17560 } | |
| 17561 if ( proceed ) { | |
| 17562 classes = ( value || "" ).match( rnotwhite ) || []; | |
| 17563 | |
| 17564 for ( ; i < len; i++ ) { | |
| 17565 elem = this[ i ]; | |
| 17566 // This expression is here for better compressibility (see addClass) | |
| 17567 cur = elem.nodeType === 1 && ( elem.className ? | |
| 17568 ( " " + elem.className + " " ).replace( rclass, " " ) : | |
| 17569 "" | |
| 17570 ); | |
| 17571 | |
| 17572 if ( cur ) { | |
| 17573 j = 0; | |
| 17574 while ( (clazz = classes[j++]) ) { | |
| 17575 // Remove *all* instances | |
| 17576 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { | |
| 17577 cur = cur.replace( " " + clazz + " ", " " ); | |
| 17578 } | |
| 17579 } | |
| 17580 | |
| 17581 // Only assign if different to avoid unneeded rendering. | |
| 17582 finalValue = value ? jQuery.trim( cur ) : ""; | |
| 17583 if ( elem.className !== finalValue ) { | |
| 17584 elem.className = finalValue; | |
| 17585 } | |
| 17586 } | |
| 17587 } | |
| 17588 } | |
| 17589 | |
| 17590 return this; | |
| 17591 }, | |
| 17592 | |
| 17593 toggleClass: function( value, stateVal ) { | |
| 17594 var type = typeof value; | |
| 17595 | |
| 17596 if ( typeof stateVal === "boolean" && type === "string" ) { | |
| 17597 return stateVal ? this.addClass( value ) : this.removeClass( value ); | |
| 17598 } | |
| 17599 | |
| 17600 if ( jQuery.isFunction( value ) ) { | |
| 17601 return this.each(function( i ) { | |
| 17602 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); | |
| 17603 }); | |
| 17604 } | |
| 17605 | |
| 17606 return this.each(function() { | |
| 17607 if ( type === "string" ) { | |
| 17608 // Toggle individual class names | |
| 17609 var className, | |
| 17610 i = 0, | |
| 17611 self = jQuery( this ), | |
| 17612 classNames = value.match( rnotwhite ) || []; | |
| 17613 | |
| 17614 while ( (className = classNames[ i++ ]) ) { | |
| 17615 // Check each className given, space separated list | |
| 17616 if ( self.hasClass( className ) ) { | |
| 17617 self.removeClass( className ); | |
| 17618 } else { | |
| 17619 self.addClass( className ); | |
| 17620 } | |
| 17621 } | |
| 17622 | |
| 17623 // Toggle whole class name | |
| 17624 } else if ( type === strundefined || type === "boolean" ) { | |
| 17625 if ( this.className ) { | |
| 17626 // store className if set | |
| 17627 data_priv.set( this, "__className__", this.className ); | |
| 17628 } | |
| 17629 | |
| 17630 // If the element has a class name or if we're passed `false`, | |
| 17631 // then remove the whole classname (if there was one, the above saved it). | |
| 17632 // Otherwise bring back whatever was previously saved (if anything), | |
| 17633 // falling back to the empty string if nothing was stored. | |
| 17634 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || ""; | |
| 17635 } | |
| 17636 }); | |
| 17637 }, | |
| 17638 | |
| 17639 hasClass: function( selector ) { | |
| 17640 var className = " " + selector + " ", | |
| 17641 i = 0, | |
| 17642 l = this.length; | |
| 17643 for ( ; i < l; i++ ) { | |
| 17644 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { | |
| 17645 return true; | |
| 17646 } | |
| 17647 } | |
| 17648 | |
| 17649 return false; | |
| 17650 } | |
| 17651 }); | |
| 17652 | |
| 17653 | |
| 17654 | |
| 17655 | |
| 17656 var rreturn = /\r/g; | |
| 17657 | |
| 17658 jQuery.fn.extend({ | |
| 17659 val: function( value ) { | |
| 17660 var hooks, ret, isFunction, | |
| 17661 elem = this[0]; | |
| 17662 | |
| 17663 if ( !arguments.length ) { | |
| 17664 if ( elem ) { | |
| 17665 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; | |
| 17666 | |
| 17667 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { | |
| 17668 return ret; | |
| 17669 } | |
| 17670 | |
| 17671 ret = elem.value; | |
| 17672 | |
| 17673 return typeof ret === "string" ? | |
| 17674 // Handle most common string cases | |
| 17675 ret.replace(rreturn, "") : | |
| 17676 // Handle cases where value is null/undef or number | |
| 17677 ret == null ? "" : ret; | |
| 17678 } | |
| 17679 | |
| 17680 return; | |
| 17681 } | |
| 17682 | |
| 17683 isFunction = jQuery.isFunction( value ); | |
| 17684 | |
| 17685 return this.each(function( i ) { | |
| 17686 var val; | |
| 17687 | |
| 17688 if ( this.nodeType !== 1 ) { | |
| 17689 return; | |
| 17690 } | |
| 17691 | |
| 17692 if ( isFunction ) { | |
| 17693 val = value.call( this, i, jQuery( this ).val() ); | |
| 17694 } else { | |
| 17695 val = value; | |
| 17696 } | |
| 17697 | |
| 17698 // Treat null/undefined as ""; convert numbers to string | |
| 17699 if ( val == null ) { | |
| 17700 val = ""; | |
| 17701 | |
| 17702 } else if ( typeof val === "number" ) { | |
| 17703 val += ""; | |
| 17704 | |
| 17705 } else if ( jQuery.isArray( val ) ) { | |
| 17706 val = jQuery.map( val, function( value ) { | |
| 17707 return value == null ? "" : value + ""; | |
| 17708 }); | |
| 17709 } | |
| 17710 | |
| 17711 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; | |
| 17712 | |
| 17713 // If set returns undefined, fall back to normal setting | |
| 17714 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { | |
| 17715 this.value = val; | |
| 17716 } | |
| 17717 }); | |
| 17718 } | |
| 17719 }); | |
| 17720 | |
| 17721 jQuery.extend({ | |
| 17722 valHooks: { | |
| 17723 option: { | |
| 17724 get: function( elem ) { | |
| 17725 var val = jQuery.find.attr( elem, "value" ); | |
| 17726 return val != null ? | |
| 17727 val : | |
| 17728 // Support: IE10-11+ | |
| 17729 // option.text throws exceptions (#14686, #14858) | |
| 17730 jQuery.trim( jQuery.text( elem ) ); | |
| 17731 } | |
| 17732 }, | |
| 17733 select: { | |
| 17734 get: function( elem ) { | |
| 17735 var value, option, | |
| 17736 options = elem.options, | |
| 17737 index = elem.selectedIndex, | |
| 17738 one = elem.type === "select-one" || index < 0, | |
| 17739 values = one ? null : [], | |
| 17740 max = one ? index + 1 : options.length, | |
| 17741 i = index < 0 ? | |
| 17742 max : | |
| 17743 one ? index : 0; | |
| 17744 | |
| 17745 // Loop through all the selected options | |
| 17746 for ( ; i < max; i++ ) { | |
| 17747 option = options[ i ]; | |
| 17748 | |
| 17749 // IE6-9 doesn't update selected after form reset (#2551) | |
| 17750 if ( ( option.selected || i === index ) && | |
| 17751 // Don't return options that are disabled or in a disabled optgroup | |
| 17752 ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) && | |
| 17753 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { | |
| 17754 | |
| 17755 // Get the specific value for the option | |
| 17756 value = jQuery( option ).val(); | |
| 17757 | |
| 17758 // We don't need an array for one selects | |
| 17759 if ( one ) { | |
| 17760 return value; | |
| 17761 } | |
| 17762 | |
| 17763 // Multi-Selects return an array | |
| 17764 values.push( value ); | |
| 17765 } | |
| 17766 } | |
| 17767 | |
| 17768 return values; | |
| 17769 }, | |
| 17770 | |
| 17771 set: function( elem, value ) { | |
| 17772 var optionSet, option, | |
| 17773 options = elem.options, | |
| 17774 values = jQuery.makeArray( value ), | |
| 17775 i = options.length; | |
| 17776 | |
| 17777 while ( i-- ) { | |
| 17778 option = options[ i ]; | |
| 17779 if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) { | |
| 17780 optionSet = true; | |
| 17781 } | |
| 17782 } | |
| 17783 | |
| 17784 // Force browsers to behave consistently when non-matching value is set | |
| 17785 if ( !optionSet ) { | |
| 17786 elem.selectedIndex = -1; | |
| 17787 } | |
| 17788 return values; | |
| 17789 } | |
| 17790 } | |
| 17791 } | |
| 17792 }); | |
| 17793 | |
| 17794 // Radios and checkboxes getter/setter | |
| 17795 jQuery.each([ "radio", "checkbox" ], function() { | |
| 17796 jQuery.valHooks[ this ] = { | |
| 17797 set: function( elem, value ) { | |
| 17798 if ( jQuery.isArray( value ) ) { | |
| 17799 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); | |
| 17800 } | |
| 17801 } | |
| 17802 }; | |
| 17803 if ( !support.checkOn ) { | |
| 17804 jQuery.valHooks[ this ].get = function( elem ) { | |
| 17805 return elem.getAttribute("value") === null ? "on" : elem.value; | |
| 17806 }; | |
| 17807 } | |
| 17808 }); | |
| 17809 | |
| 17810 | |
| 17811 | |
| 17812 | |
| 17813 // Return jQuery for attributes-only inclusion | |
| 17814 | |
| 17815 | |
| 17816 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + | |
| 17817 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + | |
| 17818 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { | |
| 17819 | |
| 17820 // Handle event binding | |
| 17821 jQuery.fn[ name ] = function( data, fn ) { | |
| 17822 return arguments.length > 0 ? | |
| 17823 this.on( name, null, data, fn ) : | |
| 17824 this.trigger( name ); | |
| 17825 }; | |
| 17826 }); | |
| 17827 | |
| 17828 jQuery.fn.extend({ | |
| 17829 hover: function( fnOver, fnOut ) { | |
| 17830 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); | |
| 17831 }, | |
| 17832 | |
| 17833 bind: function( types, data, fn ) { | |
| 17834 return this.on( types, null, data, fn ); | |
| 17835 }, | |
| 17836 unbind: function( types, fn ) { | |
| 17837 return this.off( types, null, fn ); | |
| 17838 }, | |
| 17839 | |
| 17840 delegate: function( selector, types, data, fn ) { | |
| 17841 return this.on( types, selector, data, fn ); | |
| 17842 }, | |
| 17843 undelegate: function( selector, types, fn ) { | |
| 17844 // ( namespace ) or ( selector, types [, fn] ) | |
| 17845 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); | |
| 17846 } | |
| 17847 }); | |
| 17848 | |
| 17849 | |
| 17850 var nonce = jQuery.now(); | |
| 17851 | |
| 17852 var rquery = (/\?/); | |
| 17853 | |
| 17854 | |
| 17855 | |
| 17856 // Support: Android 2.3 | |
| 17857 // Workaround failure to string-cast null input | |
| 17858 jQuery.parseJSON = function( data ) { | |
| 17859 return JSON.parse( data + "" ); | |
| 17860 }; | |
| 17861 | |
| 17862 | |
| 17863 // Cross-browser xml parsing | |
| 17864 jQuery.parseXML = function( data ) { | |
| 17865 var xml, tmp; | |
| 17866 if ( !data || typeof data !== "string" ) { | |
| 17867 return null; | |
| 17868 } | |
| 17869 | |
| 17870 // Support: IE9 | |
| 17871 try { | |
| 17872 tmp = new DOMParser(); | |
| 17873 xml = tmp.parseFromString( data, "text/xml" ); | |
| 17874 } catch ( e ) { | |
| 17875 xml = undefined; | |
| 17876 } | |
| 17877 | |
| 17878 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { | |
| 17879 jQuery.error( "Invalid XML: " + data ); | |
| 17880 } | |
| 17881 return xml; | |
| 17882 }; | |
| 17883 | |
| 17884 | |
| 17885 var | |
| 17886 rhash = /#.*$/, | |
| 17887 rts = /([?&])_=[^&]*/, | |
| 17888 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, | |
| 17889 // #7653, #8125, #8152: local protocol detection | |
| 17890 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, | |
| 17891 rnoContent = /^(?:GET|HEAD)$/, | |
| 17892 rprotocol = /^\/\//, | |
| 17893 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/, | |
| 17894 | |
| 17895 /* Prefilters | |
| 17896 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) | |
| 17897 * 2) These are called: | |
| 17898 * - BEFORE asking for a transport | |
| 17899 * - AFTER param serialization (s.data is a string if s.processData is true) | |
| 17900 * 3) key is the dataType | |
| 17901 * 4) the catchall symbol "*" can be used | |
| 17902 * 5) execution will start with transport dataType and THEN continue down to "*" if needed | |
| 17903 */ | |
| 17904 prefilters = {}, | |
| 17905 | |
| 17906 /* Transports bindings | |
| 17907 * 1) key is the dataType | |
| 17908 * 2) the catchall symbol "*" can be used | |
| 17909 * 3) selection will start with transport dataType and THEN go to "*" if needed | |
| 17910 */ | |
| 17911 transports = {}, | |
| 17912 | |
| 17913 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression | |
| 17914 allTypes = "*/".concat( "*" ), | |
| 17915 | |
| 17916 // Document location | |
| 17917 ajaxLocation = window.location.href, | |
| 17918 | |
| 17919 // Segment location into parts | |
| 17920 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; | |
| 17921 | |
| 17922 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport | |
| 17923 function addToPrefiltersOrTransports( structure ) { | |
| 17924 | |
| 17925 // dataTypeExpression is optional and defaults to "*" | |
| 17926 return function( dataTypeExpression, func ) { | |
| 17927 | |
| 17928 if ( typeof dataTypeExpression !== "string" ) { | |
| 17929 func = dataTypeExpression; | |
| 17930 dataTypeExpression = "*"; | |
| 17931 } | |
| 17932 | |
| 17933 var dataType, | |
| 17934 i = 0, | |
| 17935 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || []; | |
| 17936 | |
| 17937 if ( jQuery.isFunction( func ) ) { | |
| 17938 // For each dataType in the dataTypeExpression | |
| 17939 while ( (dataType = dataTypes[i++]) ) { | |
| 17940 // Prepend if requested | |
| 17941 if ( dataType[0] === "+" ) { | |
| 17942 dataType = dataType.slice( 1 ) || "*"; | |
| 17943 (structure[ dataType ] = structure[ dataType ] || []).unshift( func ); | |
| 17944 | |
| 17945 // Otherwise append | |
| 17946 } else { | |
| 17947 (structure[ dataType ] = structure[ dataType ] || []).push( func ); | |
| 17948 } | |
| 17949 } | |
| 17950 } | |
| 17951 }; | |
| 17952 } | |
| 17953 | |
| 17954 // Base inspection function for prefilters and transports | |
| 17955 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { | |
| 17956 | |
| 17957 var inspected = {}, | |
| 17958 seekingTransport = ( structure === transports ); | |
| 17959 | |
| 17960 function inspect( dataType ) { | |
| 17961 var selected; | |
| 17962 inspected[ dataType ] = true; | |
| 17963 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { | |
| 17964 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); | |
| 17965 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) { | |
| 17966 options.dataTypes.unshift( dataTypeOrTransport ); | |
| 17967 inspect( dataTypeOrTransport ); | |
| 17968 return false; | |
| 17969 } else if ( seekingTransport ) { | |
| 17970 return !( selected = dataTypeOrTransport ); | |
| 17971 } | |
| 17972 }); | |
| 17973 return selected; | |
| 17974 } | |
| 17975 | |
| 17976 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); | |
| 17977 } | |
| 17978 | |
| 17979 // A special extend for ajax options | |
| 17980 // that takes "flat" options (not to be deep extended) | |
| 17981 // Fixes #9887 | |
| 17982 function ajaxExtend( target, src ) { | |
| 17983 var key, deep, | |
| 17984 flatOptions = jQuery.ajaxSettings.flatOptions || {}; | |
| 17985 | |
| 17986 for ( key in src ) { | |
| 17987 if ( src[ key ] !== undefined ) { | |
| 17988 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ]; | |
| 17989 } | |
| 17990 } | |
| 17991 if ( deep ) { | |
| 17992 jQuery.extend( true, target, deep ); | |
| 17993 } | |
| 17994 | |
| 17995 return target; | |
| 17996 } | |
| 17997 | |
| 17998 /* Handles responses to an ajax request: | |
| 17999 * - finds the right dataType (mediates between content-type and expected dataType) | |
| 18000 * - returns the corresponding response | |
| 18001 */ | |
| 18002 function ajaxHandleResponses( s, jqXHR, responses ) { | |
| 18003 | |
| 18004 var ct, type, finalDataType, firstDataType, | |
| 18005 contents = s.contents, | |
| 18006 dataTypes = s.dataTypes; | |
| 18007 | |
| 18008 // Remove auto dataType and get content-type in the process | |
| 18009 while ( dataTypes[ 0 ] === "*" ) { | |
| 18010 dataTypes.shift(); | |
| 18011 if ( ct === undefined ) { | |
| 18012 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type"); | |
| 18013 } | |
| 18014 } | |
| 18015 | |
| 18016 // Check if we're dealing with a known content-type | |
| 18017 if ( ct ) { | |
| 18018 for ( type in contents ) { | |
| 18019 if ( contents[ type ] && contents[ type ].test( ct ) ) { | |
| 18020 dataTypes.unshift( type ); | |
| 18021 break; | |
| 18022 } | |
| 18023 } | |
| 18024 } | |
| 18025 | |
| 18026 // Check to see if we have a response for the expected dataType | |
| 18027 if ( dataTypes[ 0 ] in responses ) { | |
| 18028 finalDataType = dataTypes[ 0 ]; | |
| 18029 } else { | |
| 18030 // Try convertible dataTypes | |
| 18031 for ( type in responses ) { | |
| 18032 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { | |
| 18033 finalDataType = type; | |
| 18034 break; | |
| 18035 } | |
| 18036 if ( !firstDataType ) { | |
| 18037 firstDataType = type; | |
| 18038 } | |
| 18039 } | |
| 18040 // Or just use first one | |
| 18041 finalDataType = finalDataType || firstDataType; | |
| 18042 } | |
| 18043 | |
| 18044 // If we found a dataType | |
| 18045 // We add the dataType to the list if needed | |
| 18046 // and return the corresponding response | |
| 18047 if ( finalDataType ) { | |
| 18048 if ( finalDataType !== dataTypes[ 0 ] ) { | |
| 18049 dataTypes.unshift( finalDataType ); | |
| 18050 } | |
| 18051 return responses[ finalDataType ]; | |
| 18052 } | |
| 18053 } | |
| 18054 | |
| 18055 /* Chain conversions given the request and the original response | |
| 18056 * Also sets the responseXXX fields on the jqXHR instance | |
| 18057 */ | |
| 18058 function ajaxConvert( s, response, jqXHR, isSuccess ) { | |
| 18059 var conv2, current, conv, tmp, prev, | |
| 18060 converters = {}, | |
| 18061 // Work with a copy of dataTypes in case we need to modify it for conversion | |
| 18062 dataTypes = s.dataTypes.slice(); | |
| 18063 | |
| 18064 // Create converters map with lowercased keys | |
| 18065 if ( dataTypes[ 1 ] ) { | |
| 18066 for ( conv in s.converters ) { | |
| 18067 converters[ conv.toLowerCase() ] = s.converters[ conv ]; | |
| 18068 } | |
| 18069 } | |
| 18070 | |
| 18071 current = dataTypes.shift(); | |
| 18072 | |
| 18073 // Convert to each sequential dataType | |
| 18074 while ( current ) { | |
| 18075 | |
| 18076 if ( s.responseFields[ current ] ) { | |
| 18077 jqXHR[ s.responseFields[ current ] ] = response; | |
| 18078 } | |
| 18079 | |
| 18080 // Apply the dataFilter if provided | |
| 18081 if ( !prev && isSuccess && s.dataFilter ) { | |
| 18082 response = s.dataFilter( response, s.dataType ); | |
| 18083 } | |
| 18084 | |
| 18085 prev = current; | |
| 18086 current = dataTypes.shift(); | |
| 18087 | |
| 18088 if ( current ) { | |
| 18089 | |
| 18090 // There's only work to do if current dataType is non-auto | |
| 18091 if ( current === "*" ) { | |
| 18092 | |
| 18093 current = prev; | |
| 18094 | |
| 18095 // Convert response if prev dataType is non-auto and differs from current | |
| 18096 } else if ( prev !== "*" && prev !== current ) { | |
| 18097 | |
| 18098 // Seek a direct converter | |
| 18099 conv = converters[ prev + " " + current ] || converters[ "* " + current ]; | |
| 18100 | |
| 18101 // If none found, seek a pair | |
| 18102 if ( !conv ) { | |
| 18103 for ( conv2 in converters ) { | |
| 18104 | |
| 18105 // If conv2 outputs current | |
| 18106 tmp = conv2.split( " " ); | |
| 18107 if ( tmp[ 1 ] === current ) { | |
| 18108 | |
| 18109 // If prev can be converted to accepted input | |
| 18110 conv = converters[ prev + " " + tmp[ 0 ] ] || | |
| 18111 converters[ "* " + tmp[ 0 ] ]; | |
| 18112 if ( conv ) { | |
| 18113 // Condense equivalence converters | |
| 18114 if ( conv === true ) { | |
| 18115 conv = converters[ conv2 ]; | |
| 18116 | |
| 18117 // Otherwise, insert the intermediate dataType | |
| 18118 } else if ( converters[ conv2 ] !== true ) { | |
| 18119 current = tmp[ 0 ]; | |
| 18120 dataTypes.unshift( tmp[ 1 ] ); | |
| 18121 } | |
| 18122 break; | |
| 18123 } | |
| 18124 } | |
| 18125 } | |
| 18126 } | |
| 18127 | |
| 18128 // Apply converter (if not an equivalence) | |
| 18129 if ( conv !== true ) { | |
| 18130 | |
| 18131 // Unless errors are allowed to bubble, catch and return them | |
| 18132 if ( conv && s[ "throws" ] ) { | |
| 18133 response = conv( response ); | |
| 18134 } else { | |
| 18135 try { | |
| 18136 response = conv( response ); | |
| 18137 } catch ( e ) { | |
| 18138 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current }; | |
| 18139 } | |
| 18140 } | |
| 18141 } | |
| 18142 } | |
| 18143 } | |
| 18144 } | |
| 18145 | |
| 18146 return { state: "success", data: response }; | |
| 18147 } | |
| 18148 | |
| 18149 jQuery.extend({ | |
| 18150 | |
| 18151 // Counter for holding the number of active queries | |
| 18152 active: 0, | |
| 18153 | |
| 18154 // Last-Modified header cache for next request | |
| 18155 lastModified: {}, | |
| 18156 etag: {}, | |
| 18157 | |
| 18158 ajaxSettings: { | |
| 18159 url: ajaxLocation, | |
| 18160 type: "GET", | |
| 18161 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), | |
| 18162 global: true, | |
| 18163 processData: true, | |
| 18164 async: true, | |
| 18165 contentType: "application/x-www-form-urlencoded; charset=UTF-8", | |
| 18166 /* | |
| 18167 timeout: 0, | |
| 18168 data: null, | |
| 18169 dataType: null, | |
| 18170 username: null, | |
| 18171 password: null, | |
| 18172 cache: null, | |
| 18173 throws: false, | |
| 18174 traditional: false, | |
| 18175 headers: {}, | |
| 18176 */ | |
| 18177 | |
| 18178 accepts: { | |
| 18179 "*": allTypes, | |
| 18180 text: "text/plain", | |
| 18181 html: "text/html", | |
| 18182 xml: "application/xml, text/xml", | |
| 18183 json: "application/json, text/javascript" | |
| 18184 }, | |
| 18185 | |
| 18186 contents: { | |
| 18187 xml: /xml/, | |
| 18188 html: /html/, | |
| 18189 json: /json/ | |
| 18190 }, | |
| 18191 | |
| 18192 responseFields: { | |
| 18193 xml: "responseXML", | |
| 18194 text: "responseText", | |
| 18195 json: "responseJSON" | |
| 18196 }, | |
| 18197 | |
| 18198 // Data converters | |
| 18199 // Keys separate source (or catchall "*") and destination types with a single space | |
| 18200 converters: { | |
| 18201 | |
| 18202 // Convert anything to text | |
| 18203 "* text": String, | |
| 18204 | |
| 18205 // Text to html (true = no transformation) | |
| 18206 "text html": true, | |
| 18207 | |
| 18208 // Evaluate text as a json expression | |
| 18209 "text json": jQuery.parseJSON, | |
| 18210 | |
| 18211 // Parse text as xml | |
| 18212 "text xml": jQuery.parseXML | |
| 18213 }, | |
| 18214 | |
| 18215 // For options that shouldn't be deep extended: | |
| 18216 // you can add your own custom options here if | |
| 18217 // and when you create one that shouldn't be | |
| 18218 // deep extended (see ajaxExtend) | |
| 18219 flatOptions: { | |
| 18220 url: true, | |
| 18221 context: true | |
| 18222 } | |
| 18223 }, | |
| 18224 | |
| 18225 // Creates a full fledged settings object into target | |
| 18226 // with both ajaxSettings and settings fields. | |
| 18227 // If target is omitted, writes into ajaxSettings. | |
| 18228 ajaxSetup: function( target, settings ) { | |
| 18229 return settings ? | |
| 18230 | |
| 18231 // Building a settings object | |
| 18232 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : | |
| 18233 | |
| 18234 // Extending ajaxSettings | |
| 18235 ajaxExtend( jQuery.ajaxSettings, target ); | |
| 18236 }, | |
| 18237 | |
| 18238 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), | |
| 18239 ajaxTransport: addToPrefiltersOrTransports( transports ), | |
| 18240 | |
| 18241 // Main method | |
| 18242 ajax: function( url, options ) { | |
| 18243 | |
| 18244 // If url is an object, simulate pre-1.5 signature | |
| 18245 if ( typeof url === "object" ) { | |
| 18246 options = url; | |
| 18247 url = undefined; | |
| 18248 } | |
| 18249 | |
| 18250 // Force options to be an object | |
| 18251 options = options || {}; | |
| 18252 | |
| 18253 var transport, | |
| 18254 // URL without anti-cache param | |
| 18255 cacheURL, | |
| 18256 // Response headers | |
| 18257 responseHeadersString, | |
| 18258 responseHeaders, | |
| 18259 // timeout handle | |
| 18260 timeoutTimer, | |
| 18261 // Cross-domain detection vars | |
| 18262 parts, | |
| 18263 // To know if global events are to be dispatched | |
| 18264 fireGlobals, | |
| 18265 // Loop variable | |
| 18266 i, | |
| 18267 // Create the final options object | |
| 18268 s = jQuery.ajaxSetup( {}, options ), | |
| 18269 // Callbacks context | |
| 18270 callbackContext = s.context || s, | |
| 18271 // Context for global events is callbackContext if it is a DOM node or jQuery collection | |
| 18272 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ? | |
| 18273 jQuery( callbackContext ) : | |
| 18274 jQuery.event, | |
| 18275 // Deferreds | |
| 18276 deferred = jQuery.Deferred(), | |
| 18277 completeDeferred = jQuery.Callbacks("once memory"), | |
| 18278 // Status-dependent callbacks | |
| 18279 statusCode = s.statusCode || {}, | |
| 18280 // Headers (they are sent all at once) | |
| 18281 requestHeaders = {}, | |
| 18282 requestHeadersNames = {}, | |
| 18283 // The jqXHR state | |
| 18284 state = 0, | |
| 18285 // Default abort message | |
| 18286 strAbort = "canceled", | |
| 18287 // Fake xhr | |
| 18288 jqXHR = { | |
| 18289 readyState: 0, | |
| 18290 | |
| 18291 // Builds headers hashtable if needed | |
| 18292 getResponseHeader: function( key ) { | |
| 18293 var match; | |
| 18294 if ( state === 2 ) { | |
| 18295 if ( !responseHeaders ) { | |
| 18296 responseHeaders = {}; | |
| 18297 while ( (match = rheaders.exec( responseHeadersString )) ) { | |
| 18298 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; | |
| 18299 } | |
| 18300 } | |
| 18301 match = responseHeaders[ key.toLowerCase() ]; | |
| 18302 } | |
| 18303 return match == null ? null : match; | |
| 18304 }, | |
| 18305 | |
| 18306 // Raw string | |
| 18307 getAllResponseHeaders: function() { | |
| 18308 return state === 2 ? responseHeadersString : null; | |
| 18309 }, | |
| 18310 | |
| 18311 // Caches the header | |
| 18312 setRequestHeader: function( name, value ) { | |
| 18313 var lname = name.toLowerCase(); | |
| 18314 if ( !state ) { | |
| 18315 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; | |
| 18316 requestHeaders[ name ] = value; | |
| 18317 } | |
| 18318 return this; | |
| 18319 }, | |
| 18320 | |
| 18321 // Overrides response content-type header | |
| 18322 overrideMimeType: function( type ) { | |
| 18323 if ( !state ) { | |
| 18324 s.mimeType = type; | |
| 18325 } | |
| 18326 return this; | |
| 18327 }, | |
| 18328 | |
| 18329 // Status-dependent callbacks | |
| 18330 statusCode: function( map ) { | |
| 18331 var code; | |
| 18332 if ( map ) { | |
| 18333 if ( state < 2 ) { | |
| 18334 for ( code in map ) { | |
| 18335 // Lazy-add the new callback in a way that preserves old ones | |
| 18336 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; | |
| 18337 } | |
| 18338 } else { | |
| 18339 // Execute the appropriate callbacks | |
| 18340 jqXHR.always( map[ jqXHR.status ] ); | |
| 18341 } | |
| 18342 } | |
| 18343 return this; | |
| 18344 }, | |
| 18345 | |
| 18346 // Cancel the request | |
| 18347 abort: function( statusText ) { | |
| 18348 var finalText = statusText || strAbort; | |
| 18349 if ( transport ) { | |
| 18350 transport.abort( finalText ); | |
| 18351 } | |
| 18352 done( 0, finalText ); | |
| 18353 return this; | |
| 18354 } | |
| 18355 }; | |
| 18356 | |
| 18357 // Attach deferreds | |
| 18358 deferred.promise( jqXHR ).complete = completeDeferred.add; | |
| 18359 jqXHR.success = jqXHR.done; | |
| 18360 jqXHR.error = jqXHR.fail; | |
| 18361 | |
| 18362 // Remove hash character (#7531: and string promotion) | |
| 18363 // Add protocol if not provided (prefilters might expect it) | |
| 18364 // Handle falsy url in the settings object (#10093: consistency with old signature) | |
| 18365 // We also use the url parameter if available | |
| 18366 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ) | |
| 18367 .replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); | |
| 18368 | |
| 18369 // Alias method option to type as per ticket #12004 | |
| 18370 s.type = options.method || options.type || s.method || s.type; | |
| 18371 | |
| 18372 // Extract dataTypes list | |
| 18373 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ]; | |
| 18374 | |
| 18375 // A cross-domain request is in order when we have a protocol:host:port mismatch | |
| 18376 if ( s.crossDomain == null ) { | |
| 18377 parts = rurl.exec( s.url.toLowerCase() ); | |
| 18378 s.crossDomain = !!( parts && | |
| 18379 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] || | |
| 18380 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !== | |
| 18381 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) ) | |
| 18382 ); | |
| 18383 } | |
| 18384 | |
| 18385 // Convert data if not already a string | |
| 18386 if ( s.data && s.processData && typeof s.data !== "string" ) { | |
| 18387 s.data = jQuery.param( s.data, s.traditional ); | |
| 18388 } | |
| 18389 | |
| 18390 // Apply prefilters | |
| 18391 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); | |
| 18392 | |
| 18393 // If request was aborted inside a prefilter, stop there | |
| 18394 if ( state === 2 ) { | |
| 18395 return jqXHR; | |
| 18396 } | |
| 18397 | |
| 18398 // We can fire global events as of now if asked to | |
| 18399 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) | |
| 18400 fireGlobals = jQuery.event && s.global; | |
| 18401 | |
| 18402 // Watch for a new set of requests | |
| 18403 if ( fireGlobals && jQuery.active++ === 0 ) { | |
| 18404 jQuery.event.trigger("ajaxStart"); | |
| 18405 } | |
| 18406 | |
| 18407 // Uppercase the type | |
| 18408 s.type = s.type.toUpperCase(); | |
| 18409 | |
| 18410 // Determine if request has content | |
| 18411 s.hasContent = !rnoContent.test( s.type ); | |
| 18412 | |
| 18413 // Save the URL in case we're toying with the If-Modified-Since | |
| 18414 // and/or If-None-Match header later on | |
| 18415 cacheURL = s.url; | |
| 18416 | |
| 18417 // More options handling for requests with no content | |
| 18418 if ( !s.hasContent ) { | |
| 18419 | |
| 18420 // If data is available, append data to url | |
| 18421 if ( s.data ) { | |
| 18422 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data ); | |
| 18423 // #9682: remove data so that it's not used in an eventual retry | |
| 18424 delete s.data; | |
| 18425 } | |
| 18426 | |
| 18427 // Add anti-cache in url if needed | |
| 18428 if ( s.cache === false ) { | |
| 18429 s.url = rts.test( cacheURL ) ? | |
| 18430 | |
| 18431 // If there is already a '_' parameter, set its value | |
| 18432 cacheURL.replace( rts, "$1_=" + nonce++ ) : | |
| 18433 | |
| 18434 // Otherwise add one to the end | |
| 18435 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++; | |
| 18436 } | |
| 18437 } | |
| 18438 | |
| 18439 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. | |
| 18440 if ( s.ifModified ) { | |
| 18441 if ( jQuery.lastModified[ cacheURL ] ) { | |
| 18442 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); | |
| 18443 } | |
| 18444 if ( jQuery.etag[ cacheURL ] ) { | |
| 18445 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); | |
| 18446 } | |
| 18447 } | |
| 18448 | |
| 18449 // Set the correct header, if data is being sent | |
| 18450 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { | |
| 18451 jqXHR.setRequestHeader( "Content-Type", s.contentType ); | |
| 18452 } | |
| 18453 | |
| 18454 // Set the Accepts header for the server, depending on the dataType | |
| 18455 jqXHR.setRequestHeader( | |
| 18456 "Accept", | |
| 18457 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? | |
| 18458 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : | |
| 18459 s.accepts[ "*" ] | |
| 18460 ); | |
| 18461 | |
| 18462 // Check for headers option | |
| 18463 for ( i in s.headers ) { | |
| 18464 jqXHR.setRequestHeader( i, s.headers[ i ] ); | |
| 18465 } | |
| 18466 | |
| 18467 // Allow custom headers/mimetypes and early abort | |
| 18468 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { | |
| 18469 // Abort if not done already and return | |
| 18470 return jqXHR.abort(); | |
| 18471 } | |
| 18472 | |
| 18473 // Aborting is no longer a cancellation | |
| 18474 strAbort = "abort"; | |
| 18475 | |
| 18476 // Install callbacks on deferreds | |
| 18477 for ( i in { success: 1, error: 1, complete: 1 } ) { | |
| 18478 jqXHR[ i ]( s[ i ] ); | |
| 18479 } | |
| 18480 | |
| 18481 // Get transport | |
| 18482 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); | |
| 18483 | |
| 18484 // If no transport, we auto-abort | |
| 18485 if ( !transport ) { | |
| 18486 done( -1, "No Transport" ); | |
| 18487 } else { | |
| 18488 jqXHR.readyState = 1; | |
| 18489 | |
| 18490 // Send global event | |
| 18491 if ( fireGlobals ) { | |
| 18492 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); | |
| 18493 } | |
| 18494 // Timeout | |
| 18495 if ( s.async && s.timeout > 0 ) { | |
| 18496 timeoutTimer = setTimeout(function() { | |
| 18497 jqXHR.abort("timeout"); | |
| 18498 }, s.timeout ); | |
| 18499 } | |
| 18500 | |
| 18501 try { | |
| 18502 state = 1; | |
| 18503 transport.send( requestHeaders, done ); | |
| 18504 } catch ( e ) { | |
| 18505 // Propagate exception as error if not done | |
| 18506 if ( state < 2 ) { | |
| 18507 done( -1, e ); | |
| 18508 // Simply rethrow otherwise | |
| 18509 } else { | |
| 18510 throw e; | |
| 18511 } | |
| 18512 } | |
| 18513 } | |
| 18514 | |
| 18515 // Callback for when everything is done | |
| 18516 function done( status, nativeStatusText, responses, headers ) { | |
| 18517 var isSuccess, success, error, response, modified, | |
| 18518 statusText = nativeStatusText; | |
| 18519 | |
| 18520 // Called once | |
| 18521 if ( state === 2 ) { | |
| 18522 return; | |
| 18523 } | |
| 18524 | |
| 18525 // State is "done" now | |
| 18526 state = 2; | |
| 18527 | |
| 18528 // Clear timeout if it exists | |
| 18529 if ( timeoutTimer ) { | |
| 18530 clearTimeout( timeoutTimer ); | |
| 18531 } | |
| 18532 | |
| 18533 // Dereference transport for early garbage collection | |
| 18534 // (no matter how long the jqXHR object will be used) | |
| 18535 transport = undefined; | |
| 18536 | |
| 18537 // Cache response headers | |
| 18538 responseHeadersString = headers || ""; | |
| 18539 | |
| 18540 // Set readyState | |
| 18541 jqXHR.readyState = status > 0 ? 4 : 0; | |
| 18542 | |
| 18543 // Determine if successful | |
| 18544 isSuccess = status >= 200 && status < 300 || status === 304; | |
| 18545 | |
| 18546 // Get response data | |
| 18547 if ( responses ) { | |
| 18548 response = ajaxHandleResponses( s, jqXHR, responses ); | |
| 18549 } | |
| 18550 | |
| 18551 // Convert no matter what (that way responseXXX fields are always set) | |
| 18552 response = ajaxConvert( s, response, jqXHR, isSuccess ); | |
| 18553 | |
| 18554 // If successful, handle type chaining | |
| 18555 if ( isSuccess ) { | |
| 18556 | |
| 18557 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. | |
| 18558 if ( s.ifModified ) { | |
| 18559 modified = jqXHR.getResponseHeader("Last-Modified"); | |
| 18560 if ( modified ) { | |
| 18561 jQuery.lastModified[ cacheURL ] = modified; | |
| 18562 } | |
| 18563 modified = jqXHR.getResponseHeader("etag"); | |
| 18564 if ( modified ) { | |
| 18565 jQuery.etag[ cacheURL ] = modified; | |
| 18566 } | |
| 18567 } | |
| 18568 | |
| 18569 // if no content | |
| 18570 if ( status === 204 || s.type === "HEAD" ) { | |
| 18571 statusText = "nocontent"; | |
| 18572 | |
| 18573 // if not modified | |
| 18574 } else if ( status === 304 ) { | |
| 18575 statusText = "notmodified"; | |
| 18576 | |
| 18577 // If we have data, let's convert it | |
| 18578 } else { | |
| 18579 statusText = response.state; | |
| 18580 success = response.data; | |
| 18581 error = response.error; | |
| 18582 isSuccess = !error; | |
| 18583 } | |
| 18584 } else { | |
| 18585 // Extract error from statusText and normalize for non-aborts | |
| 18586 error = statusText; | |
| 18587 if ( status || !statusText ) { | |
| 18588 statusText = "error"; | |
| 18589 if ( status < 0 ) { | |
| 18590 status = 0; | |
| 18591 } | |
| 18592 } | |
| 18593 } | |
| 18594 | |
| 18595 // Set data for the fake xhr object | |
| 18596 jqXHR.status = status; | |
| 18597 jqXHR.statusText = ( nativeStatusText || statusText ) + ""; | |
| 18598 | |
| 18599 // Success/Error | |
| 18600 if ( isSuccess ) { | |
| 18601 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); | |
| 18602 } else { | |
| 18603 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); | |
| 18604 } | |
| 18605 | |
| 18606 // Status-dependent callbacks | |
| 18607 jqXHR.statusCode( statusCode ); | |
| 18608 statusCode = undefined; | |
| 18609 | |
| 18610 if ( fireGlobals ) { | |
| 18611 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", | |
| 18612 [ jqXHR, s, isSuccess ? success : error ] ); | |
| 18613 } | |
| 18614 | |
| 18615 // Complete | |
| 18616 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); | |
| 18617 | |
| 18618 if ( fireGlobals ) { | |
| 18619 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); | |
| 18620 // Handle the global AJAX counter | |
| 18621 if ( !( --jQuery.active ) ) { | |
| 18622 jQuery.event.trigger("ajaxStop"); | |
| 18623 } | |
| 18624 } | |
| 18625 } | |
| 18626 | |
| 18627 return jqXHR; | |
| 18628 }, | |
| 18629 | |
| 18630 getJSON: function( url, data, callback ) { | |
| 18631 return jQuery.get( url, data, callback, "json" ); | |
| 18632 }, | |
| 18633 | |
| 18634 getScript: function( url, callback ) { | |
| 18635 return jQuery.get( url, undefined, callback, "script" ); | |
| 18636 } | |
| 18637 }); | |
| 18638 | |
| 18639 jQuery.each( [ "get", "post" ], function( i, method ) { | |
| 18640 jQuery[ method ] = function( url, data, callback, type ) { | |
| 18641 // Shift arguments if data argument was omitted | |
| 18642 if ( jQuery.isFunction( data ) ) { | |
| 18643 type = type || callback; | |
| 18644 callback = data; | |
| 18645 data = undefined; | |
| 18646 } | |
| 18647 | |
| 18648 return jQuery.ajax({ | |
| 18649 url: url, | |
| 18650 type: method, | |
| 18651 dataType: type, | |
| 18652 data: data, | |
| 18653 success: callback | |
| 18654 }); | |
| 18655 }; | |
| 18656 }); | |
| 18657 | |
| 18658 | |
| 18659 jQuery._evalUrl = function( url ) { | |
| 18660 return jQuery.ajax({ | |
| 18661 url: url, | |
| 18662 type: "GET", | |
| 18663 dataType: "script", | |
| 18664 async: false, | |
| 18665 global: false, | |
| 18666 "throws": true | |
| 18667 }); | |
| 18668 }; | |
| 18669 | |
| 18670 | |
| 18671 jQuery.fn.extend({ | |
| 18672 wrapAll: function( html ) { | |
| 18673 var wrap; | |
| 18674 | |
| 18675 if ( jQuery.isFunction( html ) ) { | |
| 18676 return this.each(function( i ) { | |
| 18677 jQuery( this ).wrapAll( html.call(this, i) ); | |
| 18678 }); | |
| 18679 } | |
| 18680 | |
| 18681 if ( this[ 0 ] ) { | |
| 18682 | |
| 18683 // The elements to wrap the target around | |
| 18684 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); | |
| 18685 | |
| 18686 if ( this[ 0 ].parentNode ) { | |
| 18687 wrap.insertBefore( this[ 0 ] ); | |
| 18688 } | |
| 18689 | |
| 18690 wrap.map(function() { | |
| 18691 var elem = this; | |
| 18692 | |
| 18693 while ( elem.firstElementChild ) { | |
| 18694 elem = elem.firstElementChild; | |
| 18695 } | |
| 18696 | |
| 18697 return elem; | |
| 18698 }).append( this ); | |
| 18699 } | |
| 18700 | |
| 18701 return this; | |
| 18702 }, | |
| 18703 | |
| 18704 wrapInner: function( html ) { | |
| 18705 if ( jQuery.isFunction( html ) ) { | |
| 18706 return this.each(function( i ) { | |
| 18707 jQuery( this ).wrapInner( html.call(this, i) ); | |
| 18708 }); | |
| 18709 } | |
| 18710 | |
| 18711 return this.each(function() { | |
| 18712 var self = jQuery( this ), | |
| 18713 contents = self.contents(); | |
| 18714 | |
| 18715 if ( contents.length ) { | |
| 18716 contents.wrapAll( html ); | |
| 18717 | |
| 18718 } else { | |
| 18719 self.append( html ); | |
| 18720 } | |
| 18721 }); | |
| 18722 }, | |
| 18723 | |
| 18724 wrap: function( html ) { | |
| 18725 var isFunction = jQuery.isFunction( html ); | |
| 18726 | |
| 18727 return this.each(function( i ) { | |
| 18728 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); | |
| 18729 }); | |
| 18730 }, | |
| 18731 | |
| 18732 unwrap: function() { | |
| 18733 return this.parent().each(function() { | |
| 18734 if ( !jQuery.nodeName( this, "body" ) ) { | |
| 18735 jQuery( this ).replaceWith( this.childNodes ); | |
| 18736 } | |
| 18737 }).end(); | |
| 18738 } | |
| 18739 }); | |
| 18740 | |
| 18741 | |
| 18742 jQuery.expr.filters.hidden = function( elem ) { | |
| 18743 // Support: Opera <= 12.12 | |
| 18744 // Opera reports offsetWidths and offsetHeights less than zero on some elements | |
| 18745 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0; | |
| 18746 }; | |
| 18747 jQuery.expr.filters.visible = function( elem ) { | |
| 18748 return !jQuery.expr.filters.hidden( elem ); | |
| 18749 }; | |
| 18750 | |
| 18751 | |
| 18752 | |
| 18753 | |
| 18754 var r20 = /%20/g, | |
| 18755 rbracket = /\[\]$/, | |
| 18756 rCRLF = /\r?\n/g, | |
| 18757 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, | |
| 18758 rsubmittable = /^(?:input|select|textarea|keygen)/i; | |
| 18759 | |
| 18760 function buildParams( prefix, obj, traditional, add ) { | |
| 18761 var name; | |
| 18762 | |
| 18763 if ( jQuery.isArray( obj ) ) { | |
| 18764 // Serialize array item. | |
| 18765 jQuery.each( obj, function( i, v ) { | |
| 18766 if ( traditional || rbracket.test( prefix ) ) { | |
| 18767 // Treat each array item as a scalar. | |
| 18768 add( prefix, v ); | |
| 18769 | |
| 18770 } else { | |
| 18771 // Item is non-scalar (array or object), encode its numeric index. | |
| 18772 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); | |
| 18773 } | |
| 18774 }); | |
| 18775 | |
| 18776 } else if ( !traditional && jQuery.type( obj ) === "object" ) { | |
| 18777 // Serialize object item. | |
| 18778 for ( name in obj ) { | |
| 18779 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); | |
| 18780 } | |
| 18781 | |
| 18782 } else { | |
| 18783 // Serialize scalar item. | |
| 18784 add( prefix, obj ); | |
| 18785 } | |
| 18786 } | |
| 18787 | |
| 18788 // Serialize an array of form elements or a set of | |
| 18789 // key/values into a query string | |
| 18790 jQuery.param = function( a, traditional ) { | |
| 18791 var prefix, | |
| 18792 s = [], | |
| 18793 add = function( key, value ) { | |
| 18794 // If value is a function, invoke it and return its value | |
| 18795 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); | |
| 18796 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); | |
| 18797 }; | |
| 18798 | |
| 18799 // Set traditional to true for jQuery <= 1.3.2 behavior. | |
| 18800 if ( traditional === undefined ) { | |
| 18801 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; | |
| 18802 } | |
| 18803 | |
| 18804 // If an array was passed in, assume that it is an array of form elements. | |
| 18805 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { | |
| 18806 // Serialize the form elements | |
| 18807 jQuery.each( a, function() { | |
| 18808 add( this.name, this.value ); | |
| 18809 }); | |
| 18810 | |
| 18811 } else { | |
| 18812 // If traditional, encode the "old" way (the way 1.3.2 or older | |
| 18813 // did it), otherwise encode params recursively. | |
| 18814 for ( prefix in a ) { | |
| 18815 buildParams( prefix, a[ prefix ], traditional, add ); | |
| 18816 } | |
| 18817 } | |
| 18818 | |
| 18819 // Return the resulting serialization | |
| 18820 return s.join( "&" ).replace( r20, "+" ); | |
| 18821 }; | |
| 18822 | |
| 18823 jQuery.fn.extend({ | |
| 18824 serialize: function() { | |
| 18825 return jQuery.param( this.serializeArray() ); | |
| 18826 }, | |
| 18827 serializeArray: function() { | |
| 18828 return this.map(function() { | |
| 18829 // Can add propHook for "elements" to filter or add form elements | |
| 18830 var elements = jQuery.prop( this, "elements" ); | |
| 18831 return elements ? jQuery.makeArray( elements ) : this; | |
| 18832 }) | |
| 18833 .filter(function() { | |
| 18834 var type = this.type; | |
| 18835 | |
| 18836 // Use .is( ":disabled" ) so that fieldset[disabled] works | |
| 18837 return this.name && !jQuery( this ).is( ":disabled" ) && | |
| 18838 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && | |
| 18839 ( this.checked || !rcheckableType.test( type ) ); | |
| 18840 }) | |
| 18841 .map(function( i, elem ) { | |
| 18842 var val = jQuery( this ).val(); | |
| 18843 | |
| 18844 return val == null ? | |
| 18845 null : | |
| 18846 jQuery.isArray( val ) ? | |
| 18847 jQuery.map( val, function( val ) { | |
| 18848 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; | |
| 18849 }) : | |
| 18850 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; | |
| 18851 }).get(); | |
| 18852 } | |
| 18853 }); | |
| 18854 | |
| 18855 | |
| 18856 jQuery.ajaxSettings.xhr = function() { | |
| 18857 try { | |
| 18858 return new XMLHttpRequest(); | |
| 18859 } catch( e ) {} | |
| 18860 }; | |
| 18861 | |
| 18862 var xhrId = 0, | |
| 18863 xhrCallbacks = {}, | |
| 18864 xhrSuccessStatus = { | |
| 18865 // file protocol always yields status code 0, assume 200 | |
| 18866 0: 200, | |
| 18867 // Support: IE9 | |
| 18868 // #1450: sometimes IE returns 1223 when it should be 204 | |
| 18869 1223: 204 | |
| 18870 }, | |
| 18871 xhrSupported = jQuery.ajaxSettings.xhr(); | |
| 18872 | |
| 18873 // Support: IE9 | |
| 18874 // Open requests must be manually aborted on unload (#5280) | |
| 18875 // See https://support.microsoft.com/kb/2856746 for more info | |
| 18876 if ( window.attachEvent ) { | |
| 18877 window.attachEvent( "onunload", function() { | |
| 18878 for ( var key in xhrCallbacks ) { | |
| 18879 xhrCallbacks[ key ](); | |
| 18880 } | |
| 18881 }); | |
| 18882 } | |
| 18883 | |
| 18884 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); | |
| 18885 support.ajax = xhrSupported = !!xhrSupported; | |
| 18886 | |
| 18887 jQuery.ajaxTransport(function( options ) { | |
| 18888 var callback; | |
| 18889 | |
| 18890 // Cross domain only allowed if supported through XMLHttpRequest | |
| 18891 if ( support.cors || xhrSupported && !options.crossDomain ) { | |
| 18892 return { | |
| 18893 send: function( headers, complete ) { | |
| 18894 var i, | |
| 18895 xhr = options.xhr(), | |
| 18896 id = ++xhrId; | |
| 18897 | |
| 18898 xhr.open( options.type, options.url, options.async, options.username, options.password ); | |
| 18899 | |
| 18900 // Apply custom fields if provided | |
| 18901 if ( options.xhrFields ) { | |
| 18902 for ( i in options.xhrFields ) { | |
| 18903 xhr[ i ] = options.xhrFields[ i ]; | |
| 18904 } | |
| 18905 } | |
| 18906 | |
| 18907 // Override mime type if needed | |
| 18908 if ( options.mimeType && xhr.overrideMimeType ) { | |
| 18909 xhr.overrideMimeType( options.mimeType ); | |
| 18910 } | |
| 18911 | |
| 18912 // X-Requested-With header | |
| 18913 // For cross-domain requests, seeing as conditions for a preflight are | |
| 18914 // akin to a jigsaw puzzle, we simply never set it to be sure. | |
| 18915 // (it can always be set on a per-request basis or even using ajaxSetup) | |
| 18916 // For same-domain requests, won't change header if already provided. | |
| 18917 if ( !options.crossDomain && !headers["X-Requested-With"] ) { | |
| 18918 headers["X-Requested-With"] = "XMLHttpRequest"; | |
| 18919 } | |
| 18920 | |
| 18921 // Set headers | |
| 18922 for ( i in headers ) { | |
| 18923 xhr.setRequestHeader( i, headers[ i ] ); | |
| 18924 } | |
| 18925 | |
| 18926 // Callback | |
| 18927 callback = function( type ) { | |
| 18928 return function() { | |
| 18929 if ( callback ) { | |
| 18930 delete xhrCallbacks[ id ]; | |
| 18931 callback = xhr.onload = xhr.onerror = null; | |
| 18932 | |
| 18933 if ( type === "abort" ) { | |
| 18934 xhr.abort(); | |
| 18935 } else if ( type === "error" ) { | |
| 18936 complete( | |
| 18937 // file: protocol always yields status 0; see #8605, #14207 | |
| 18938 xhr.status, | |
| 18939 xhr.statusText | |
| 18940 ); | |
| 18941 } else { | |
| 18942 complete( | |
| 18943 xhrSuccessStatus[ xhr.status ] || xhr.status, | |
| 18944 xhr.statusText, | |
| 18945 // Support: IE9 | |
| 18946 // Accessing binary-data responseText throws an exception | |
| 18947 // (#11426) | |
| 18948 typeof xhr.responseText === "string" ? { | |
| 18949 text: xhr.responseText | |
| 18950 } : undefined, | |
| 18951 xhr.getAllResponseHeaders() | |
| 18952 ); | |
| 18953 } | |
| 18954 } | |
| 18955 }; | |
| 18956 }; | |
| 18957 | |
| 18958 // Listen to events | |
| 18959 xhr.onload = callback(); | |
| 18960 xhr.onerror = callback("error"); | |
| 18961 | |
| 18962 // Create the abort callback | |
| 18963 callback = xhrCallbacks[ id ] = callback("abort"); | |
| 18964 | |
| 18965 try { | |
| 18966 // Do send the request (this may raise an exception) | |
| 18967 xhr.send( options.hasContent && options.data || null ); | |
| 18968 } catch ( e ) { | |
| 18969 // #14683: Only rethrow if this hasn't been notified as an error yet | |
| 18970 if ( callback ) { | |
| 18971 throw e; | |
| 18972 } | |
| 18973 } | |
| 18974 }, | |
| 18975 | |
| 18976 abort: function() { | |
| 18977 if ( callback ) { | |
| 18978 callback(); | |
| 18979 } | |
| 18980 } | |
| 18981 }; | |
| 18982 } | |
| 18983 }); | |
| 18984 | |
| 18985 | |
| 18986 | |
| 18987 | |
| 18988 // Install script dataType | |
| 18989 jQuery.ajaxSetup({ | |
| 18990 accepts: { | |
| 18991 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" | |
| 18992 }, | |
| 18993 contents: { | |
| 18994 script: /(?:java|ecma)script/ | |
| 18995 }, | |
| 18996 converters: { | |
| 18997 "text script": function( text ) { | |
| 18998 jQuery.globalEval( text ); | |
| 18999 return text; | |
| 19000 } | |
| 19001 } | |
| 19002 }); | |
| 19003 | |
| 19004 // Handle cache's special case and crossDomain | |
| 19005 jQuery.ajaxPrefilter( "script", function( s ) { | |
| 19006 if ( s.cache === undefined ) { | |
| 19007 s.cache = false; | |
| 19008 } | |
| 19009 if ( s.crossDomain ) { | |
| 19010 s.type = "GET"; | |
| 19011 } | |
| 19012 }); | |
| 19013 | |
| 19014 // Bind script tag hack transport | |
| 19015 jQuery.ajaxTransport( "script", function( s ) { | |
| 19016 // This transport only deals with cross domain requests | |
| 19017 if ( s.crossDomain ) { | |
| 19018 var script, callback; | |
| 19019 return { | |
| 19020 send: function( _, complete ) { | |
| 19021 script = jQuery("<script>").prop({ | |
| 19022 async: true, | |
| 19023 charset: s.scriptCharset, | |
| 19024 src: s.url | |
| 19025 }).on( | |
| 19026 "load error", | |
| 19027 callback = function( evt ) { | |
| 19028 script.remove(); | |
| 19029 callback = null; | |
| 19030 if ( evt ) { | |
| 19031 complete( evt.type === "error" ? 404 : 200, evt.type ); | |
| 19032 } | |
| 19033 } | |
| 19034 ); | |
| 19035 document.head.appendChild( script[ 0 ] ); | |
| 19036 }, | |
| 19037 abort: function() { | |
| 19038 if ( callback ) { | |
| 19039 callback(); | |
| 19040 } | |
| 19041 } | |
| 19042 }; | |
| 19043 } | |
| 19044 }); | |
| 19045 | |
| 19046 | |
| 19047 | |
| 19048 | |
| 19049 var oldCallbacks = [], | |
| 19050 rjsonp = /(=)\?(?=&|$)|\?\?/; | |
| 19051 | |
| 19052 // Default jsonp settings | |
| 19053 jQuery.ajaxSetup({ | |
| 19054 jsonp: "callback", | |
| 19055 jsonpCallback: function() { | |
| 19056 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); | |
| 19057 this[ callback ] = true; | |
| 19058 return callback; | |
| 19059 } | |
| 19060 }); | |
| 19061 | |
| 19062 // Detect, normalize options and install callbacks for jsonp requests | |
| 19063 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { | |
| 19064 | |
| 19065 var callbackName, overwritten, responseContainer, | |
| 19066 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? | |
| 19067 "url" : | |
| 19068 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" | |
| 19069 ); | |
| 19070 | |
| 19071 // Handle iff the expected data type is "jsonp" or we have a parameter to set | |
| 19072 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { | |
| 19073 | |
| 19074 // Get callback name, remembering preexisting value associated with it | |
| 19075 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? | |
| 19076 s.jsonpCallback() : | |
| 19077 s.jsonpCallback; | |
| 19078 | |
| 19079 // Insert callback into url or form data | |
| 19080 if ( jsonProp ) { | |
| 19081 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); | |
| 19082 } else if ( s.jsonp !== false ) { | |
| 19083 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; | |
| 19084 } | |
| 19085 | |
| 19086 // Use data converter to retrieve json after script execution | |
| 19087 s.converters["script json"] = function() { | |
| 19088 if ( !responseContainer ) { | |
| 19089 jQuery.error( callbackName + " was not called" ); | |
| 19090 } | |
| 19091 return responseContainer[ 0 ]; | |
| 19092 }; | |
| 19093 | |
| 19094 // force json dataType | |
| 19095 s.dataTypes[ 0 ] = "json"; | |
| 19096 | |
| 19097 // Install callback | |
| 19098 overwritten = window[ callbackName ]; | |
| 19099 window[ callbackName ] = function() { | |
| 19100 responseContainer = arguments; | |
| 19101 }; | |
| 19102 | |
| 19103 // Clean-up function (fires after converters) | |
| 19104 jqXHR.always(function() { | |
| 19105 // Restore preexisting value | |
| 19106 window[ callbackName ] = overwritten; | |
| 19107 | |
| 19108 // Save back as free | |
| 19109 if ( s[ callbackName ] ) { | |
| 19110 // make sure that re-using the options doesn't screw things around | |
| 19111 s.jsonpCallback = originalSettings.jsonpCallback; | |
| 19112 | |
| 19113 // save the callback name for future use | |
| 19114 oldCallbacks.push( callbackName ); | |
| 19115 } | |
| 19116 | |
| 19117 // Call if it was a function and we have a response | |
| 19118 if ( responseContainer && jQuery.isFunction( overwritten ) ) { | |
| 19119 overwritten( responseContainer[ 0 ] ); | |
| 19120 } | |
| 19121 | |
| 19122 responseContainer = overwritten = undefined; | |
| 19123 }); | |
| 19124 | |
| 19125 // Delegate to script | |
| 19126 return "script"; | |
| 19127 } | |
| 19128 }); | |
| 19129 | |
| 19130 | |
| 19131 | |
| 19132 | |
| 19133 // data: string of html | |
| 19134 // context (optional): If specified, the fragment will be created in this context, defaults to document | |
| 19135 // keepScripts (optional): If true, will include scripts passed in the html string | |
| 19136 jQuery.parseHTML = function( data, context, keepScripts ) { | |
| 19137 if ( !data || typeof data !== "string" ) { | |
| 19138 return null; | |
| 19139 } | |
| 19140 if ( typeof context === "boolean" ) { | |
| 19141 keepScripts = context; | |
| 19142 context = false; | |
| 19143 } | |
| 19144 context = context || document; | |
| 19145 | |
| 19146 var parsed = rsingleTag.exec( data ), | |
| 19147 scripts = !keepScripts && []; | |
| 19148 | |
| 19149 // Single tag | |
| 19150 if ( parsed ) { | |
| 19151 return [ context.createElement( parsed[1] ) ]; | |
| 19152 } | |
| 19153 | |
| 19154 parsed = jQuery.buildFragment( [ data ], context, scripts ); | |
| 19155 | |
| 19156 if ( scripts && scripts.length ) { | |
| 19157 jQuery( scripts ).remove(); | |
| 19158 } | |
| 19159 | |
| 19160 return jQuery.merge( [], parsed.childNodes ); | |
| 19161 }; | |
| 19162 | |
| 19163 | |
| 19164 // Keep a copy of the old load method | |
| 19165 var _load = jQuery.fn.load; | |
| 19166 | |
| 19167 /** | |
| 19168 * Load a url into a page | |
| 19169 */ | |
| 19170 jQuery.fn.load = function( url, params, callback ) { | |
| 19171 if ( typeof url !== "string" && _load ) { | |
| 19172 return _load.apply( this, arguments ); | |
| 19173 } | |
| 19174 | |
| 19175 var selector, type, response, | |
| 19176 self = this, | |
| 19177 off = url.indexOf(" "); | |
| 19178 | |
| 19179 if ( off >= 0 ) { | |
| 19180 selector = jQuery.trim( url.slice( off ) ); | |
| 19181 url = url.slice( 0, off ); | |
| 19182 } | |
| 19183 | |
| 19184 // If it's a function | |
| 19185 if ( jQuery.isFunction( params ) ) { | |
| 19186 | |
| 19187 // We assume that it's the callback | |
| 19188 callback = params; | |
| 19189 params = undefined; | |
| 19190 | |
| 19191 // Otherwise, build a param string | |
| 19192 } else if ( params && typeof params === "object" ) { | |
| 19193 type = "POST"; | |
| 19194 } | |
| 19195 | |
| 19196 // If we have elements to modify, make the request | |
| 19197 if ( self.length > 0 ) { | |
| 19198 jQuery.ajax({ | |
| 19199 url: url, | |
| 19200 | |
| 19201 // if "type" variable is undefined, then "GET" method will be used | |
| 19202 type: type, | |
| 19203 dataType: "html", | |
| 19204 data: params | |
| 19205 }).done(function( responseText ) { | |
| 19206 | |
| 19207 // Save response for use in complete callback | |
| 19208 response = arguments; | |
| 19209 | |
| 19210 self.html( selector ? | |
| 19211 | |
| 19212 // If a selector was specified, locate the right elements in a dummy div | |
| 19213 // Exclude scripts to avoid IE 'Permission Denied' errors | |
| 19214 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) : | |
| 19215 | |
| 19216 // Otherwise use the full result | |
| 19217 responseText ); | |
| 19218 | |
| 19219 }).complete( callback && function( jqXHR, status ) { | |
| 19220 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); | |
| 19221 }); | |
| 19222 } | |
| 19223 | |
| 19224 return this; | |
| 19225 }; | |
| 19226 | |
| 19227 | |
| 19228 | |
| 19229 | |
| 19230 // Attach a bunch of functions for handling common AJAX events | |
| 19231 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) { | |
| 19232 jQuery.fn[ type ] = function( fn ) { | |
| 19233 return this.on( type, fn ); | |
| 19234 }; | |
| 19235 }); | |
| 19236 | |
| 19237 | |
| 19238 | |
| 19239 | |
| 19240 jQuery.expr.filters.animated = function( elem ) { | |
| 19241 return jQuery.grep(jQuery.timers, function( fn ) { | |
| 19242 return elem === fn.elem; | |
| 19243 }).length; | |
| 19244 }; | |
| 19245 | |
| 19246 | |
| 19247 | |
| 19248 | |
| 19249 var docElem = window.document.documentElement; | |
| 19250 | |
| 19251 /** | |
| 19252 * Gets a window from an element | |
| 19253 */ | |
| 19254 function getWindow( elem ) { | |
| 19255 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView; | |
| 19256 } | |
| 19257 | |
| 19258 jQuery.offset = { | |
| 19259 setOffset: function( elem, options, i ) { | |
| 19260 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, | |
| 19261 position = jQuery.css( elem, "position" ), | |
| 19262 curElem = jQuery( elem ), | |
| 19263 props = {}; | |
| 19264 | |
| 19265 // Set position first, in-case top/left are set even on static elem | |
| 19266 if ( position === "static" ) { | |
| 19267 elem.style.position = "relative"; | |
| 19268 } | |
| 19269 | |
| 19270 curOffset = curElem.offset(); | |
| 19271 curCSSTop = jQuery.css( elem, "top" ); | |
| 19272 curCSSLeft = jQuery.css( elem, "left" ); | |
| 19273 calculatePosition = ( position === "absolute" || position === "fixed" ) && | |
| 19274 ( curCSSTop + curCSSLeft ).indexOf("auto") > -1; | |
| 19275 | |
| 19276 // Need to be able to calculate position if either | |
| 19277 // top or left is auto and position is either absolute or fixed | |
| 19278 if ( calculatePosition ) { | |
| 19279 curPosition = curElem.position(); | |
| 19280 curTop = curPosition.top; | |
| 19281 curLeft = curPosition.left; | |
| 19282 | |
| 19283 } else { | |
| 19284 curTop = parseFloat( curCSSTop ) || 0; | |
| 19285 curLeft = parseFloat( curCSSLeft ) || 0; | |
| 19286 } | |
| 19287 | |
| 19288 if ( jQuery.isFunction( options ) ) { | |
| 19289 options = options.call( elem, i, curOffset ); | |
| 19290 } | |
| 19291 | |
| 19292 if ( options.top != null ) { | |
| 19293 props.top = ( options.top - curOffset.top ) + curTop; | |
| 19294 } | |
| 19295 if ( options.left != null ) { | |
| 19296 props.left = ( options.left - curOffset.left ) + curLeft; | |
| 19297 } | |
| 19298 | |
| 19299 if ( "using" in options ) { | |
| 19300 options.using.call( elem, props ); | |
| 19301 | |
| 19302 } else { | |
| 19303 curElem.css( props ); | |
| 19304 } | |
| 19305 } | |
| 19306 }; | |
| 19307 | |
| 19308 jQuery.fn.extend({ | |
| 19309 offset: function( options ) { | |
| 19310 if ( arguments.length ) { | |
| 19311 return options === undefined ? | |
| 19312 this : | |
| 19313 this.each(function( i ) { | |
| 19314 jQuery.offset.setOffset( this, options, i ); | |
| 19315 }); | |
| 19316 } | |
| 19317 | |
| 19318 var docElem, win, | |
| 19319 elem = this[ 0 ], | |
| 19320 box = { top: 0, left: 0 }, | |
| 19321 doc = elem && elem.ownerDocument; | |
| 19322 | |
| 19323 if ( !doc ) { | |
| 19324 return; | |
| 19325 } | |
| 19326 | |
| 19327 docElem = doc.documentElement; | |
| 19328 | |
| 19329 // Make sure it's not a disconnected DOM node | |
| 19330 if ( !jQuery.contains( docElem, elem ) ) { | |
| 19331 return box; | |
| 19332 } | |
| 19333 | |
| 19334 // Support: BlackBerry 5, iOS 3 (original iPhone) | |
| 19335 // If we don't have gBCR, just use 0,0 rather than error | |
| 19336 if ( typeof elem.getBoundingClientRect !== strundefined ) { | |
| 19337 box = elem.getBoundingClientRect(); | |
| 19338 } | |
| 19339 win = getWindow( doc ); | |
| 19340 return { | |
| 19341 top: box.top + win.pageYOffset - docElem.clientTop, | |
| 19342 left: box.left + win.pageXOffset - docElem.clientLeft | |
| 19343 }; | |
| 19344 }, | |
| 19345 | |
| 19346 position: function() { | |
| 19347 if ( !this[ 0 ] ) { | |
| 19348 return; | |
| 19349 } | |
| 19350 | |
| 19351 var offsetParent, offset, | |
| 19352 elem = this[ 0 ], | |
| 19353 parentOffset = { top: 0, left: 0 }; | |
| 19354 | |
| 19355 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent | |
| 19356 if ( jQuery.css( elem, "position" ) === "fixed" ) { | |
| 19357 // Assume getBoundingClientRect is there when computed position is fixed | |
| 19358 offset = elem.getBoundingClientRect(); | |
| 19359 | |
| 19360 } else { | |
| 19361 // Get *real* offsetParent | |
| 19362 offsetParent = this.offsetParent(); | |
| 19363 | |
| 19364 // Get correct offsets | |
| 19365 offset = this.offset(); | |
| 19366 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { | |
| 19367 parentOffset = offsetParent.offset(); | |
| 19368 } | |
| 19369 | |
| 19370 // Add offsetParent borders | |
| 19371 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ); | |
| 19372 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ); | |
| 19373 } | |
| 19374 | |
| 19375 // Subtract parent offsets and element margins | |
| 19376 return { | |
| 19377 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), | |
| 19378 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) | |
| 19379 }; | |
| 19380 }, | |
| 19381 | |
| 19382 offsetParent: function() { | |
| 19383 return this.map(function() { | |
| 19384 var offsetParent = this.offsetParent || docElem; | |
| 19385 | |
| 19386 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) { | |
| 19387 offsetParent = offsetParent.offsetParent; | |
| 19388 } | |
| 19389 | |
| 19390 return offsetParent || docElem; | |
| 19391 }); | |
| 19392 } | |
| 19393 }); | |
| 19394 | |
| 19395 // Create scrollLeft and scrollTop methods | |
| 19396 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { | |
| 19397 var top = "pageYOffset" === prop; | |
| 19398 | |
| 19399 jQuery.fn[ method ] = function( val ) { | |
| 19400 return access( this, function( elem, method, val ) { | |
| 19401 var win = getWindow( elem ); | |
| 19402 | |
| 19403 if ( val === undefined ) { | |
| 19404 return win ? win[ prop ] : elem[ method ]; | |
| 19405 } | |
| 19406 | |
| 19407 if ( win ) { | |
| 19408 win.scrollTo( | |
| 19409 !top ? val : window.pageXOffset, | |
| 19410 top ? val : window.pageYOffset | |
| 19411 ); | |
| 19412 | |
| 19413 } else { | |
| 19414 elem[ method ] = val; | |
| 19415 } | |
| 19416 }, method, val, arguments.length, null ); | |
| 19417 }; | |
| 19418 }); | |
| 19419 | |
| 19420 // Support: Safari<7+, Chrome<37+ | |
| 19421 // Add the top/left cssHooks using jQuery.fn.position | |
| 19422 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 | |
| 19423 // Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280 | |
| 19424 // getComputedStyle returns percent when specified for top/left/bottom/right; | |
| 19425 // rather than make the css module depend on the offset module, just check for it here | |
| 19426 jQuery.each( [ "top", "left" ], function( i, prop ) { | |
| 19427 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, | |
| 19428 function( elem, computed ) { | |
| 19429 if ( computed ) { | |
| 19430 computed = curCSS( elem, prop ); | |
| 19431 // If curCSS returns percentage, fallback to offset | |
| 19432 return rnumnonpx.test( computed ) ? | |
| 19433 jQuery( elem ).position()[ prop ] + "px" : | |
| 19434 computed; | |
| 19435 } | |
| 19436 } | |
| 19437 ); | |
| 19438 }); | |
| 19439 | |
| 19440 | |
| 19441 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods | |
| 19442 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { | |
| 19443 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { | |
| 19444 // Margin is only for outerHeight, outerWidth | |
| 19445 jQuery.fn[ funcName ] = function( margin, value ) { | |
| 19446 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), | |
| 19447 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); | |
| 19448 | |
| 19449 return access( this, function( elem, type, value ) { | |
| 19450 var doc; | |
| 19451 | |
| 19452 if ( jQuery.isWindow( elem ) ) { | |
| 19453 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there | |
| 19454 // isn't a whole lot we can do. See pull request at this URL for discussion: | |
| 19455 // https://github.com/jquery/jquery/pull/764 | |
| 19456 return elem.document.documentElement[ "client" + name ]; | |
| 19457 } | |
| 19458 | |
| 19459 // Get document width or height | |
| 19460 if ( elem.nodeType === 9 ) { | |
| 19461 doc = elem.documentElement; | |
| 19462 | |
| 19463 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], | |
| 19464 // whichever is greatest | |
| 19465 return Math.max( | |
| 19466 elem.body[ "scroll" + name ], doc[ "scroll" + name ], | |
| 19467 elem.body[ "offset" + name ], doc[ "offset" + name ], | |
| 19468 doc[ "client" + name ] | |
| 19469 ); | |
| 19470 } | |
| 19471 | |
| 19472 return value === undefined ? | |
| 19473 // Get width or height on the element, requesting but not forcing parseFloat | |
| 19474 jQuery.css( elem, type, extra ) : | |
| 19475 | |
| 19476 // Set width or height on the element | |
| 19477 jQuery.style( elem, type, value, extra ); | |
| 19478 }, type, chainable ? margin : undefined, chainable, null ); | |
| 19479 }; | |
| 19480 }); | |
| 19481 }); | |
| 19482 | |
| 19483 | |
| 19484 // The number of elements contained in the matched element set | |
| 19485 jQuery.fn.size = function() { | |
| 19486 return this.length; | |
| 19487 }; | |
| 19488 | |
| 19489 jQuery.fn.andSelf = jQuery.fn.addBack; | |
| 19490 | |
| 19491 | |
| 19492 | |
| 19493 | |
| 19494 // Register as a named AMD module, since jQuery can be concatenated with other | |
| 19495 // files that may use define, but not via a proper concatenation script that | |
| 19496 // understands anonymous AMD modules. A named AMD is safest and most robust | |
| 19497 // way to register. Lowercase jquery is used because AMD module names are | |
| 19498 // derived from file names, and jQuery is normally delivered in a lowercase | |
| 19499 // file name. Do this after creating the global so that if an AMD module wants | |
| 19500 // to call noConflict to hide this version of jQuery, it will work. | |
| 19501 | |
| 19502 // Note that for maximum portability, libraries that are not jQuery should | |
| 19503 // declare themselves as anonymous modules, and avoid setting a global if an | |
| 19504 // AMD loader is present. jQuery is a special case. For more information, see | |
| 19505 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon | |
| 19506 | |
| 19507 if ( typeof define === "function" && define.amd ) { | |
| 19508 define( "jquery", [], function() { | |
| 19509 return jQuery; | |
| 19510 }); | |
| 19511 } | |
| 19512 | |
| 19513 | |
| 19514 | |
| 19515 | |
| 19516 var | |
| 19517 // Map over jQuery in case of overwrite | |
| 19518 _jQuery = window.jQuery, | |
| 19519 | |
| 19520 // Map over the $ in case of overwrite | |
| 19521 _$ = window.$; | |
| 19522 | |
| 19523 jQuery.noConflict = function( deep ) { | |
| 19524 if ( window.$ === jQuery ) { | |
| 19525 window.$ = _$; | |
| 19526 } | |
| 19527 | |
| 19528 if ( deep && window.jQuery === jQuery ) { | |
| 19529 window.jQuery = _jQuery; | |
| 19530 } | |
| 19531 | |
| 19532 return jQuery; | |
| 19533 }; | |
| 19534 | |
| 19535 // Expose jQuery and $ identifiers, even in AMD | |
| 19536 // (#7102#comment:10, https://github.com/jquery/jquery/pull/557) | |
| 19537 // and CommonJS for browser emulators (#13566) | |
| 19538 if ( typeof noGlobal === strundefined ) { | |
| 19539 window.jQuery = window.$ = jQuery; | |
| 19540 } | |
| 19541 | |
| 19542 | |
| 19543 | |
| 19544 | |
| 19545 return jQuery; | |
| 19546 | |
| 19547 })); |
