Left

URL
MyAdmin_visual_inspection_twins/20220221_183058/objects/96c73f3774471cc8378c77a64ecf09b7f625d8b7.js
metadata
{"URL.host":"cdnjs.cloudflare.com", "URL.path":"/ajax/libs/jquery/1.11.3/jquery.js", "URL.port":"80", "URL.protocol":"https", "profile":"MyAdmin_ProductionEnv"}

Right

URL
MyAdmin_visual_inspection_twins/20220221_183122/objects/433836da7e015f2eb3fc386817de88b78248f6ef.js
metadata
{"URL.host":"cdnjs.cloudflare.com", "URL.path":"/ajax/libs/jquery/1.12.4/jquery.js", "URL.port":"80", "URL.protocol":"https", "profile":"MyAdmin_DevelopmentEnv"}

are DIFFERENT 28.70%%

rows
  • total : 11829
  • inserted : 615
  • deleted : 447
  • changed : 2332
  • equal : 8435
Left Right
1 /*! /*!
2 * jQuery JavaScript Library v1.11.3 * jQuery JavaScript Library v1.12.4
3 * http://jquery.com/ * http://jquery.com/
4 * *
5 * Includes Sizzle.js * Includes Sizzle.js
6 * http://sizzlejs.com/ * http://sizzlejs.com/
7 * *
8 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors * Copyright jQuery Foundation and other contributors
9 * Released under the MIT license * Released under the MIT license
10 * http://jquery.org/license * http://jquery.org/license
11 * *
12 * Date: 2015-04-28T16:19Z * Date: 2016-05-20T17:17Z
13 */ */
14
15 (function( global, factory ) { (function( global, factory ) {
16
17 if ( typeof module === "object" && typeof module.exports === "object" ) { if ( typeof module === "object" && typeof module.exports === "object" ) {
18 // For CommonJS and CommonJS-like environments where a proper window is present, // For CommonJS and CommonJS-like environments where a proper `window`
19 // execute the factory and get jQuery // is present, execute the factory and get jQuery.
20 // For environments that do not inherently posses a window with a document // For environments that do not have a `window` with a `document`
21 // (such as Node.js), expose a jQuery-making factory as module.exports // (such as Node.js), expose a factory as module.exports.
22 // This accentuates the need for the creation of a real window // This accentuates the need for the creation of a real `window`.
23 // e.g. var jQuery = require("jquery")(window); // e.g. var jQuery = require("jquery")(window);
24 // See ticket #14549 for more info // See ticket #14549 for more info.
25 module.exports = global.document ? module.exports = global.document ?
26 factory( global, true ) : factory( global, true ) :
27 function( w ) { function( w ) {
28 if ( !w.document ) { if ( !w.document ) {
29 throw new Error( "jQuery requires a window with a document" ); throw new Error( "jQuery requires a window with a document" );
30 } }
31 return factory( w ); return factory( w );
32 }; };
33 } else { } else {
34 factory( global ); factory( global );
35 } }
36
37 // Pass this if window is not defined yet // Pass this if window is not defined yet
38 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
39
40 // Can't do this because several apps including ASP.NET trace // Support: Firefox 18+
41 // Can't be in strict mode, several libs including ASP.NET trace
42 // the stack via arguments.caller.callee and Firefox dies if // the stack via arguments.caller.callee and Firefox dies if
43 // you try to trace through "use strict" call chains. (#13335) // you try to trace through "use strict" call chains. (#13335)
44 // Support: Firefox 18+ //"use strict";
45 //
46 var deletedIds = []; var deletedIds = [];
47
48 var document = window.document;
49
50 var slice = deletedIds.slice; var slice = deletedIds.slice;
51
52 var concat = deletedIds.concat; var concat = deletedIds.concat;
53
54 var push = deletedIds.push; var push = deletedIds.push;
55
56 var indexOf = deletedIds.indexOf; var indexOf = deletedIds.indexOf;
57
58 var class2type = {}; var class2type = {};
59
60 var toString = class2type.toString; var toString = class2type.toString;
61
62 var hasOwn = class2type.hasOwnProperty; var hasOwn = class2type.hasOwnProperty;
63
64 var support = {}; var support = {};
65
66
67
68 var var
69 version = "1.11.3", version = "1.12.4",
70
71 // Define a local copy of jQuery // Define a local copy of jQuery
72 jQuery = function( selector, context ) { jQuery = function( selector, context ) {
73
74 // The jQuery object is actually just the init constructor 'enhanced' // The jQuery object is actually just the init constructor 'enhanced'
75 // Need init if jQuery is called (just allow error to be thrown if not included) // Need init if jQuery is called (just allow error to be thrown if not included)
76 return new jQuery.fn.init( selector, context ); return new jQuery.fn.init( selector, context );
77 }, },
78
79 // Support: Android<4.1, IE<9 // Support: Android<4.1, IE<9
80 // Make sure we trim BOM and NBSP // Make sure we trim BOM and NBSP
81 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
82
83 // Matches dashed string for camelizing // Matches dashed string for camelizing
84 rmsPrefix = /^-ms-/, rmsPrefix = /^-ms-/,
85 rdashAlpha = /-([\da-z])/gi, rdashAlpha = /-([\da-z])/gi,
86
87 // Used by jQuery.camelCase as callback to replace() // Used by jQuery.camelCase as callback to replace()
88 fcamelCase = function( all, letter ) { fcamelCase = function( all, letter ) {
89 return letter.toUpperCase(); return letter.toUpperCase();
90 }; };
91
92 jQuery.fn = jQuery.prototype = { jQuery.fn = jQuery.prototype = {
93
94 // The current version of jQuery being used // The current version of jQuery being used
95 jquery: version, jquery: version,
96
97 constructor: jQuery, constructor: jQuery,
98
99 // Start with an empty selector // Start with an empty selector
100 selector: "", selector: "",
101
102 // The default length of a jQuery object is 0 // The default length of a jQuery object is 0
103 length: 0, length: 0,
104
105 toArray: function() { toArray: function() {
106 return slice.call( this ); return slice.call( this );
107 }, },
108
109 // Get the Nth element in the matched element set OR // Get the Nth element in the matched element set OR
110 // Get the whole matched element set as a clean array // Get the whole matched element set as a clean array
111 get: function( num ) { get: function( num ) {
112 return num != null ? return num != null ?
113
114 // Return just the one element from the set // Return just the one element from the set
115 ( num < 0 ? this[ num + this.length ] : this[ num ] ) : ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
116
117 // Return all the elements in a clean array // Return all the elements in a clean array
118 slice.call( this ); slice.call( this );
119 }, },
120
121 // Take an array of elements and push it onto the stack // Take an array of elements and push it onto the stack
122 // (returning the new matched element set) // (returning the new matched element set)
123 pushStack: function( elems ) { pushStack: function( elems ) {
124
125 // Build a new jQuery matched element set // Build a new jQuery matched element set
126 var ret = jQuery.merge( this.constructor(), elems ); var ret = jQuery.merge( this.constructor(), elems );
127
128 // Add the old object onto the stack (as a reference) // Add the old object onto the stack (as a reference)
129 ret.prevObject = this; ret.prevObject = this;
130 ret.context = this.context; ret.context = this.context;
131
132 // Return the newly-formed element set // Return the newly-formed element set
133 return ret; return ret;
134 }, },
135
136 // Execute a callback for every element in the matched set. // Execute a callback for every element in the matched set.
137 // (You can seed the arguments with an array of args, but this is each: function( callback ) {
138 // only used internally.) return jQuery.each( this, callback );
139 each: function( callback, args ) {
140 return jQuery.each( this, callback, args );
141 }, },
142
143 map: function( callback ) { map: function( callback ) {
144 return this.pushStack( jQuery.map(this, function( elem, i ) { return this.pushStack( jQuery.map( this, function( elem, i ) {
145 return callback.call( elem, i, elem ); return callback.call( elem, i, elem );
146 })); } ) );
147 }, },
148
149 slice: function() { slice: function() {
150 return this.pushStack( slice.apply( this, arguments ) ); return this.pushStack( slice.apply( this, arguments ) );
151 }, },
152
153 first: function() { first: function() {
154 return this.eq( 0 ); return this.eq( 0 );
155 }, },
156
157 last: function() { last: function() {
158 return this.eq( -1 ); return this.eq( -1 );
159 }, },
160
161 eq: function( i ) { eq: function( i ) {
162 var len = this.length, var len = this.length,
163 j = +i + ( i < 0 ? len : 0 ); j = +i + ( i < 0 ? len : 0 );
164 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
165 }, },
166
167 end: function() { end: function() {
168 return this.prevObject || this.constructor(null); return this.prevObject || this.constructor();
169 }, },
170
171 // For internal use only. // For internal use only.
172 // Behaves like an Array's method, not like a jQuery method. // Behaves like an Array's method, not like a jQuery method.
173 push: push, push: push,
174 sort: deletedIds.sort, sort: deletedIds.sort,
175 splice: deletedIds.splice splice: deletedIds.splice
176 }; };
177
178 jQuery.extend = jQuery.fn.extend = function() { jQuery.extend = jQuery.fn.extend = function() {
179 var src, copyIsArray, copy, name, options, clone, var src, copyIsArray, copy, name, options, clone,
180 target = arguments[0] || {}, target = arguments[ 0 ] || {},
181 i = 1, i = 1,
182 length = arguments.length, length = arguments.length,
183 deep = false; deep = false;
184
185 // Handle a deep copy situation // Handle a deep copy situation
186 if ( typeof target === "boolean" ) { if ( typeof target === "boolean" ) {
187 deep = target; deep = target;
188
189 // skip the boolean and the target // skip the boolean and the target
190 target = arguments[ i ] || {}; target = arguments[ i ] || {};
191 i++; i++;
192 } }
193
194 // Handle case when target is a string or something (possible in deep copy) // Handle case when target is a string or something (possible in deep copy)
195 if ( typeof target !== "object" && !jQuery.isFunction(target) ) { if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
196 target = {}; target = {};
197 } }
198
199 // extend jQuery itself if only one argument is passed // extend jQuery itself if only one argument is passed
200 if ( i === length ) { if ( i === length ) {
201 target = this; target = this;
202 i--; i--;
203 } }
204
205 for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
206
207 // Only deal with non-null/undefined values // Only deal with non-null/undefined values
208 if ( (options = arguments[ i ]) != null ) { if ( ( options = arguments[ i ] ) != null ) {
209 // Extend the base object // Extend the base object
210 for ( name in options ) { for ( name in options ) {
211 src = target[ name ]; src = target[ name ];
212 copy = options[ name ]; copy = options[ name ];
213
214 // Prevent never-ending loop // Prevent never-ending loop
215 if ( target === copy ) { if ( target === copy ) {
216 continue; continue;
217 } }
218
219 // Recurse if we're merging plain objects or arrays // Recurse if we're merging plain objects or arrays
220 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
221 ( copyIsArray = jQuery.isArray( copy ) ) ) ) {
222 if ( copyIsArray ) { if ( copyIsArray ) {
223 copyIsArray = false; copyIsArray = false;
224 clone = src && jQuery.isArray(src) ? src : []; clone = src && jQuery.isArray( src ) ? src : [];
225
226 } else { } else {
227 clone = src && jQuery.isPlainObject(src) ? src : {}; clone = src && jQuery.isPlainObject( src ) ? src : {};
228 } }
229
230 // Never move original objects, clone them // Never move original objects, clone them
231 target[ name ] = jQuery.extend( deep, clone, copy ); target[ name ] = jQuery.extend( deep, clone, copy );
232
233 // Don't bring in undefined values // Don't bring in undefined values
234 } else if ( copy !== undefined ) { } else if ( copy !== undefined ) {
235 target[ name ] = copy; target[ name ] = copy;
236 } }
237 } }
238 } }
239 } }
240
241 // Return the modified object // Return the modified object
242 return target; return target;
243 }; };
244
245 jQuery.extend({ jQuery.extend( {
246 // Unique for each copy of jQuery on the page // Unique for each copy of jQuery on the page
247 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
248
249 // Assume jQuery is ready without the ready module // Assume jQuery is ready without the ready module
250 isReady: true, isReady: true,
251
252 error: function( msg ) { error: function( msg ) {
253 throw new Error( msg ); throw new Error( msg );
254 }, },
255
256 noop: function() {}, noop: function() {},
257
258 // See test/unit/core.js for details concerning isFunction. // See test/unit/core.js for details concerning isFunction.
259 // Since version 1.3, DOM methods and functions like alert // Since version 1.3, DOM methods and functions like alert
260 // aren't supported. They return false on IE (#2968). // aren't supported. They return false on IE (#2968).
261 isFunction: function( obj ) { isFunction: function( obj ) {
262 return jQuery.type(obj) === "function"; return jQuery.type( obj ) === "function";
263 }, },
264
265 isArray: Array.isArray || function( obj ) { isArray: Array.isArray || function( obj ) {
266 return jQuery.type(obj) === "array"; return jQuery.type( obj ) === "array";
267 }, },
268
269 isWindow: function( obj ) { isWindow: function( obj ) {
270 /* jshint eqeqeq: false */ /* jshint eqeqeq: false */
271 return obj != null && obj == obj.window; return obj != null && obj == obj.window;
272 }, },
273
274 isNumeric: function( obj ) { isNumeric: function( obj ) {
275
276 // parseFloat NaNs numeric-cast false positives (null|true|false|"") // parseFloat NaNs numeric-cast false positives (null|true|false|"")
277 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
278 // subtraction forces infinities to NaN // subtraction forces infinities to NaN
279 // adding 1 corrects loss of precision from parseFloat (#15100) // adding 1 corrects loss of precision from parseFloat (#15100)
280 return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0; var realStringObj = obj && obj.toString();
281 return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
282 }, },
283
284 isEmptyObject: function( obj ) { isEmptyObject: function( obj ) {
285 var name; var name;
286 for ( name in obj ) { for ( name in obj ) {
287 return false; return false;
288 } }
289 return true; return true;
290 }, },
291
292 isPlainObject: function( obj ) { isPlainObject: function( obj ) {
293 var key; var key;
294
295 // Must be an Object. // Must be an Object.
296 // Because of IE, we also have to check the presence of the constructor property. // Because of IE, we also have to check the presence of the constructor property.
297 // Make sure that DOM nodes and window objects don't pass through, as well // Make sure that DOM nodes and window objects don't pass through, as well
298 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { if ( !obj || jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
299 return false; return false;
300 } }
301
302 try { try {
303
304 // Not own constructor property must be Object // Not own constructor property must be Object
305 if ( obj.constructor && if ( obj.constructor &&
306 !hasOwn.call(obj, "constructor") && !hasOwn.call( obj, "constructor" ) &&
307 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
308 return false; return false;
309 } }
310 } catch ( e ) { } catch ( e ) {
311
312 // IE8,9 Will throw exceptions on certain host objects #9897 // IE8,9 Will throw exceptions on certain host objects #9897
313 return false; return false;
314 } }
315
316 // Support: IE<9 // Support: IE<9
317 // Handle iteration over inherited properties before own properties. // Handle iteration over inherited properties before own properties.
318 if ( support.ownLast ) { if ( !support.ownFirst ) {
319 for ( key in obj ) { for ( key in obj ) {
320 return hasOwn.call( obj, key ); return hasOwn.call( obj, key );
321 } }
322 } }
323
324 // Own properties are enumerated firstly, so to speed up, // Own properties are enumerated firstly, so to speed up,
325 // if last one is own, then all properties are own. // if last one is own, then all properties are own.
326 for ( key in obj ) {} for ( key in obj ) {}
327
328 return key === undefined || hasOwn.call( obj, key ); return key === undefined || hasOwn.call( obj, key );
329 }, },
330
331 type: function( obj ) { type: function( obj ) {
332 if ( obj == null ) { if ( obj == null ) {
333 return obj + ""; return obj + "";
334 } }
335 return typeof obj === "object" || typeof obj === "function" ? return typeof obj === "object" || typeof obj === "function" ?
336 class2type[ toString.call(obj) ] || "object" : class2type[ toString.call( obj ) ] || "object" :
337 typeof obj; typeof obj;
338 }, },
339
340 // Evaluates a script in a global context
341 // Workarounds based on findings by Jim Driscoll // Workarounds based on findings by Jim Driscoll
342 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
343 globalEval: function( data ) { globalEval: function( data ) {
344 if ( data && jQuery.trim( data ) ) { if ( data && jQuery.trim( data ) ) {
345
346 // We use execScript on Internet Explorer // We use execScript on Internet Explorer
347 // We use an anonymous function so that context is window // We use an anonymous function so that context is window
348 // rather than jQuery in Firefox // rather than jQuery in Firefox
349 ( window.execScript || function( data ) { ( window.execScript || function( data ) {
350 window[ "eval" ].call( window, data ); window[ "eval" ].call( window, data ); // jscs:ignore requireDotNotation
351 } )( data ); } )( data );
352 } }
353 }, },
354
355 // Convert dashed to camelCase; used by the css and data modules // Convert dashed to camelCase; used by the css and data modules
356 // Microsoft forgot to hump their vendor prefix (#9572) // Microsoft forgot to hump their vendor prefix (#9572)
357 camelCase: function( string ) { camelCase: function( string ) {
358 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
359 }, },
360
361 nodeName: function( elem, name ) { nodeName: function( elem, name ) {
362 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
363 }, },
364
365 // args is for internal usage only each: function( obj, callback ) {
366 each: function( obj, callback, args ) { var length, i = 0;
367 var value,
368 i = 0,
369 length = obj.length,
370 isArray = isArraylike( obj );
371
372 if ( args ) { if ( isArrayLike( obj ) ) {
373 if ( isArray ) { length = obj.length;
374 for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
375 value = callback.apply( obj[ i ], args ); if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
376 break;
377 if ( value === false ) {
378 break;
379 }
380 } }
381 } else {
382 for ( i in obj ) {
383 value = callback.apply( obj[ i ], args );
384
385 if ( value === false ) {
386 break;
387 }
388 }
389 } }
390
391 // A special, fast, case for the most common use of each
392 } else { } else {
393 if ( isArray ) { for ( i in obj ) {
394 for ( ; i < length; i++ ) { if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
395 value = callback.call( obj[ i ], i, obj[ i ] ); break;
396
397 if ( value === false ) {
398 break;
399 }
400 } }
401 } else {
402 for ( i in obj ) {
403 value = callback.call( obj[ i ], i, obj[ i ] );
404
405 if ( value === false ) {
406 break;
407 }
408 }
409 } }
410 } }
411
412 return obj; return obj;
413 }, },
414
415 // Support: Android<4.1, IE<9 // Support: Android<4.1, IE<9
416 trim: function( text ) { trim: function( text ) {
417 return text == null ? return text == null ?
418 "" : "" :
419 ( text + "" ).replace( rtrim, "" ); ( text + "" ).replace( rtrim, "" );
420 }, },
421
422 // results is for internal usage only // results is for internal usage only
423 makeArray: function( arr, results ) { makeArray: function( arr, results ) {
424 var ret = results || []; var ret = results || [];
425
426 if ( arr != null ) { if ( arr != null ) {
427 if ( isArraylike( Object(arr) ) ) { if ( isArrayLike( Object( arr ) ) ) {
428 jQuery.merge( ret, jQuery.merge( ret,
429 typeof arr === "string" ? typeof arr === "string" ?
430 [ arr ] : arr [ arr ] : arr
431 ); );
432 } else { } else {
433 push.call( ret, arr ); push.call( ret, arr );
434 } }
435 } }
436
437 return ret; return ret;
438 }, },
439
440 inArray: function( elem, arr, i ) { inArray: function( elem, arr, i ) {
441 var len; var len;
442
443 if ( arr ) { if ( arr ) {
444 if ( indexOf ) { if ( indexOf ) {
445 return indexOf.call( arr, elem, i ); return indexOf.call( arr, elem, i );
446 } }
447
448 len = arr.length; len = arr.length;
449 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
450
451 for ( ; i < len; i++ ) { for ( ; i < len; i++ ) {
452
453 // Skip accessing in sparse arrays // Skip accessing in sparse arrays
454 if ( i in arr && arr[ i ] === elem ) { if ( i in arr && arr[ i ] === elem ) {
455 return i; return i;
456 } }
457 } }
458 } }
459
460 return -1; return -1;
461 }, },
462
463 merge: function( first, second ) { merge: function( first, second ) {
464 var len = +second.length, var len = +second.length,
465 j = 0, j = 0,
466 i = first.length; i = first.length;
467
468 while ( j < len ) { while ( j < len ) {
469 first[ i++ ] = second[ j++ ]; first[ i++ ] = second[ j++ ];
470 } }
471
472 // Support: IE<9 // Support: IE<9
473 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists) // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
474 if ( len !== len ) { if ( len !== len ) {
475 while ( second[j] !== undefined ) { while ( second[ j ] !== undefined ) {
476 first[ i++ ] = second[ j++ ]; first[ i++ ] = second[ j++ ];
477 } }
478 } }
479
480 first.length = i; first.length = i;
481
482 return first; return first;
483 }, },
484
485 grep: function( elems, callback, invert ) { grep: function( elems, callback, invert ) {
486 var callbackInverse, var callbackInverse,
487 matches = [], matches = [],
488 i = 0, i = 0,
489 length = elems.length, length = elems.length,
490 callbackExpect = !invert; callbackExpect = !invert;
491
492 // Go through the array, only saving the items // Go through the array, only saving the items
493 // that pass the validator function // that pass the validator function
494 for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
495 callbackInverse = !callback( elems[ i ], i ); callbackInverse = !callback( elems[ i ], i );
496 if ( callbackInverse !== callbackExpect ) { if ( callbackInverse !== callbackExpect ) {
497 matches.push( elems[ i ] ); matches.push( elems[ i ] );
498 } }
499 } }
500
501 return matches; return matches;
502 }, },
503
504 // arg is for internal usage only // arg is for internal usage only
505 map: function( elems, callback, arg ) { map: function( elems, callback, arg ) {
506 var value, var length, value,
507 i = 0, i = 0,
508 length = elems.length,
509 isArray = isArraylike( elems ),
510 ret = []; ret = [];
511
512 // Go through the array, translating each of the items to their new values // Go through the array, translating each of the items to their new values
513 if ( isArray ) { if ( isArrayLike( elems ) ) {
514 length = elems.length;
515 for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
516 value = callback( elems[ i ], i, arg ); value = callback( elems[ i ], i, arg );
517
518 if ( value != null ) { if ( value != null ) {
519 ret.push( value ); ret.push( value );
520 } }
521 } }
522
523 // Go through every key on the object, // Go through every key on the object,
524 } else { } else {
525 for ( i in elems ) { for ( i in elems ) {
526 value = callback( elems[ i ], i, arg ); value = callback( elems[ i ], i, arg );
527
528 if ( value != null ) { if ( value != null ) {
529 ret.push( value ); ret.push( value );
530 } }
531 } }
532 } }
533
534 // Flatten any nested arrays // Flatten any nested arrays
535 return concat.apply( [], ret ); return concat.apply( [], ret );
536 }, },
537
538 // A global GUID counter for objects // A global GUID counter for objects
539 guid: 1, guid: 1,
540
541 // Bind a function to a context, optionally partially applying any // Bind a function to a context, optionally partially applying any
542 // arguments. // arguments.
543 proxy: function( fn, context ) { proxy: function( fn, context ) {
544 var args, proxy, tmp; var args, proxy, tmp;
545
546 if ( typeof context === "string" ) { if ( typeof context === "string" ) {
547 tmp = fn[ context ]; tmp = fn[ context ];
548 context = fn; context = fn;
549 fn = tmp; fn = tmp;
550 } }
551
552 // Quick check to determine if target is callable, in the spec // Quick check to determine if target is callable, in the spec
553 // this throws a TypeError, but we will just return undefined. // this throws a TypeError, but we will just return undefined.
554 if ( !jQuery.isFunction( fn ) ) { if ( !jQuery.isFunction( fn ) ) {
555 return undefined; return undefined;
556 } }
557
558 // Simulated bind // Simulated bind
559 args = slice.call( arguments, 2 ); args = slice.call( arguments, 2 );
560 proxy = function() { proxy = function() {
561 return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
562 }; };
563
564 // Set the guid of unique handler to the same of original handler, so it can be removed // Set the guid of unique handler to the same of original handler, so it can be removed
565 proxy.guid = fn.guid = fn.guid || jQuery.guid++; proxy.guid = fn.guid = fn.guid || jQuery.guid++;
566
567 return proxy; return proxy;
568 }, },
569
570 now: function() { now: function() {
571 return +( new Date() ); return +( new Date() );
572 }, },
573
574 // jQuery.support is not used in Core but other projects attach their // jQuery.support is not used in Core but other projects attach their
575 // properties to it so it needs to exist. // properties to it so it needs to exist.
576 support: support support: support
577 }); } );
578
579 // JSHint would error on this code due to the Symbol not being defined in ES5.
580 // Defining this global in .jshintrc would create a danger of using the global
581 // unguarded in another place, it seems safer to just disable JSHint for these
582 // three lines.
583 /* jshint ignore: start */
584 if ( typeof Symbol === "function" ) {
585 jQuery.fn[ Symbol.iterator ] = deletedIds[ Symbol.iterator ];
586 }
587 /* jshint ignore: end */
588
589 // Populate the class2type map // Populate the class2type map
590 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
591 function( i, name ) {
592 class2type[ "[object " + name + "]" ] = name.toLowerCase(); class2type[ "[object " + name + "]" ] = name.toLowerCase();
593 }); } );
594
595 function isArraylike( obj ) { function isArrayLike( obj ) {
596
597 // Support: iOS 8.2 (not reproducible in simulator) // Support: iOS 8.2 (not reproducible in simulator)
598 // `in` check used to prevent JIT error (gh-2145) // `in` check used to prevent JIT error (gh-2145)
599 // hasOwn isn't used here due to false negatives // hasOwn isn't used here due to false negatives
600 // regarding Nodelist length in IE // regarding Nodelist length in IE
601 var length = "length" in obj && obj.length, var length = !!obj && "length" in obj && obj.length,
602 type = jQuery.type( obj ); type = jQuery.type( obj );
603
604 if ( type === "function" || jQuery.isWindow( obj ) ) { if ( type === "function" || jQuery.isWindow( obj ) ) {
605 return false; return false;
606 } }
607
608 if ( obj.nodeType === 1 && length ) {
609 return true;
610 }
611
612 return type === "array" || length === 0 || return type === "array" || length === 0 ||
613 typeof length === "number" && length > 0 && ( length - 1 ) in obj; typeof length === "number" && length > 0 && ( length - 1 ) in obj;
614 } }
615 var Sizzle = var Sizzle =
616 /*! /*!
617 * Sizzle CSS Selector Engine v2.2.0-pre * Sizzle CSS Selector Engine v2.2.1
618 * http://sizzlejs.com/ * http://sizzlejs.com/
619 * *
620 * Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors * Copyright jQuery Foundation and other contributors
621 * Released under the MIT license * Released under the MIT license
622 * http://jquery.org/license * http://jquery.org/license
623 * *
624 * Date: 2014-12-16 * Date: 2015-10-17
625 */ */
626 (function( window ) { (function( window ) {
627
628 var i, var i,
629 support, support,
630 Expr, Expr,
631 getText, getText,
632 isXML, isXML,
633 tokenize, tokenize,
634 compile, compile,
635 select, select,
636 outermostContext, outermostContext,
637 sortInput, sortInput,
638 hasDuplicate, hasDuplicate,
639
640 // Local document vars // Local document vars
641 setDocument, setDocument,
642 document, document,
643 docElem, docElem,
644 documentIsHTML, documentIsHTML,
645 rbuggyQSA, rbuggyQSA,
646 rbuggyMatches, rbuggyMatches,
647 matches, matches,
648 contains, contains,
649
650 // Instance-specific data // Instance-specific data
651 expando = "sizzle" + 1 * new Date(), expando = "sizzle" + 1 * new Date(),
652 preferredDoc = window.document, preferredDoc = window.document,
653 dirruns = 0, dirruns = 0,
654 done = 0, done = 0,
655 classCache = createCache(), classCache = createCache(),
656 tokenCache = createCache(), tokenCache = createCache(),
657 compilerCache = createCache(), compilerCache = createCache(),
658 sortOrder = function( a, b ) { sortOrder = function( a, b ) {
659 if ( a === b ) { if ( a === b ) {
660 hasDuplicate = true; hasDuplicate = true;
661 } }
662 return 0; return 0;
663 }, },
664
665 // General-purpose constants // General-purpose constants
666 MAX_NEGATIVE = 1 << 31, MAX_NEGATIVE = 1 << 31,
667
668 // Instance methods // Instance methods
669 hasOwn = ({}).hasOwnProperty, hasOwn = ({}).hasOwnProperty,
670 arr = [], arr = [],
671 pop = arr.pop, pop = arr.pop,
672 push_native = arr.push, push_native = arr.push,
673 push = arr.push, push = arr.push,
674 slice = arr.slice, slice = arr.slice,
675 // Use a stripped-down indexOf as it's faster than native // Use a stripped-down indexOf as it's faster than native
676 // http://jsperf.com/thor-indexof-vs-for/5 // http://jsperf.com/thor-indexof-vs-for/5
677 indexOf = function( list, elem ) { indexOf = function( list, elem ) {
678 var i = 0, var i = 0,
679 len = list.length; len = list.length;
680 for ( ; i < len; i++ ) { for ( ; i < len; i++ ) {
681 if ( list[i] === elem ) { if ( list[i] === elem ) {
682 return i; return i;
683 } }
684 } }
685 return -1; return -1;
686 }, },
687
688 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
689
690 // Regular expressions // Regular expressions
691
692 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace // http://www.w3.org/TR/css3-selectors/#whitespace
693 whitespace = "[\\x20\\t\\r\\n\\f]", whitespace = "[\\x20\\t\\r\\n\\f]",
694 // http://www.w3.org/TR/css3-syntax/#characters
695 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
696
697 // Loosely modeled on CSS identifier characters // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
698 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
699 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
700 identifier = characterEncoding.replace( "w", "w#" ),
701
702 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
703 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace + attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
704 // Operator (capture 2) // Operator (capture 2)
705 "*([*^$|!~]?=)" + whitespace + "*([*^$|!~]?=)" + whitespace +
706 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
707 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
708 "*\\]", "*\\]",
709
710 pseudos = ":(" + characterEncoding + ")(?:\\((" + pseudos = ":(" + identifier + ")(?:\\((" +
711 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
712 // 1. quoted (capture 3; capture 4 or capture 5) // 1. quoted (capture 3; capture 4 or capture 5)
713 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
714 // 2. simple (capture 6) // 2. simple (capture 6)
715 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
716 // 3. anything else (capture 2) // 3. anything else (capture 2)
717 ".*" + ".*" +
718 ")\\)|)", ")\\)|)",
719
720 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
721 rwhitespace = new RegExp( whitespace + "+", "g" ), rwhitespace = new RegExp( whitespace + "+", "g" ),
722 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
723
724 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
725 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
726
727 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
728
729 rpseudo = new RegExp( pseudos ), rpseudo = new RegExp( pseudos ),
730 ridentifier = new RegExp( "^" + identifier + "$" ), ridentifier = new RegExp( "^" + identifier + "$" ),
731
732 matchExpr = { matchExpr = {
733 "ID": new RegExp( "^#(" + characterEncoding + ")" ), "ID": new RegExp( "^#(" + identifier + ")" ),
734 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
735 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), "TAG": new RegExp( "^(" + identifier + "|[*])" ),
736 "ATTR": new RegExp( "^" + attributes ), "ATTR": new RegExp( "^" + attributes ),
737 "PSEUDO": new RegExp( "^" + pseudos ), "PSEUDO": new RegExp( "^" + pseudos ),
738 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
739 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
740 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
741 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
742 // For use in libraries implementing .is() // For use in libraries implementing .is()
743 // We use this for POS matching in `select` // We use this for POS matching in `select`
744 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
745 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
746 }, },
747
748 rinputs = /^(?:input|select|textarea|button)$/i, rinputs = /^(?:input|select|textarea|button)$/i,
749 rheader = /^h\d$/i, rheader = /^h\d$/i,
750
751 rnative = /^[^{]+\{\s*\[native \w/, rnative = /^[^{]+\{\s*\[native \w/,
752
753 // Easily-parseable/retrievable ID or TAG or CLASS selectors // Easily-parseable/retrievable ID or TAG or CLASS selectors
754 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
755
756 rsibling = /[+~]/, rsibling = /[+~]/,
757 rescape = /'|\\/g, rescape = /'|\\/g,
758
759 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
760 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
761 funescape = function( _, escaped, escapedWhitespace ) { funescape = function( _, escaped, escapedWhitespace ) {
762 var high = "0x" + escaped - 0x10000; var high = "0x" + escaped - 0x10000;
763 // NaN means non-codepoint // NaN means non-codepoint
764 // Support: Firefox<24 // Support: Firefox<24
765 // Workaround erroneous numeric interpretation of +"0x" // Workaround erroneous numeric interpretation of +"0x"
766 return high !== high || escapedWhitespace ? return high !== high || escapedWhitespace ?
767 escaped : escaped :
768 high < 0 ? high < 0 ?
769 // BMP codepoint // BMP codepoint
770 String.fromCharCode( high + 0x10000 ) : String.fromCharCode( high + 0x10000 ) :
771 // Supplemental Plane codepoint (surrogate pair) // Supplemental Plane codepoint (surrogate pair)
772 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
773 }, },
774
775 // Used for iframes // Used for iframes
776 // See setDocument() // See setDocument()
777 // Removing the function wrapper causes a "Permission Denied" // Removing the function wrapper causes a "Permission Denied"
778 // error in IE // error in IE
779 unloadHandler = function() { unloadHandler = function() {
780 setDocument(); setDocument();
781 }; };
782
783 // Optimize for push.apply( _, NodeList ) // Optimize for push.apply( _, NodeList )
784 try { try {
785 push.apply( push.apply(
786 (arr = slice.call( preferredDoc.childNodes )), (arr = slice.call( preferredDoc.childNodes )),
787 preferredDoc.childNodes preferredDoc.childNodes
788 ); );
789 // Support: Android<4.0 // Support: Android<4.0
790 // Detect silently failing push.apply // Detect silently failing push.apply
791 arr[ preferredDoc.childNodes.length ].nodeType; arr[ preferredDoc.childNodes.length ].nodeType;
792 } catch ( e ) { } catch ( e ) {
793 push = { apply: arr.length ? push = { apply: arr.length ?
794
795 // Leverage slice if possible // Leverage slice if possible
796 function( target, els ) { function( target, els ) {
797 push_native.apply( target, slice.call(els) ); push_native.apply( target, slice.call(els) );
798 } : } :
799
800 // Support: IE<9 // Support: IE<9
801 // Otherwise append directly // Otherwise append directly
802 function( target, els ) { function( target, els ) {
803 var j = target.length, var j = target.length,
804 i = 0; i = 0;
805 // Can't trust NodeList.length // Can't trust NodeList.length
806 while ( (target[j++] = els[i++]) ) {} while ( (target[j++] = els[i++]) ) {}
807 target.length = j - 1; target.length = j - 1;
808 } }
809 }; };
810 } }
811
812 function Sizzle( selector, context, results, seed ) { function Sizzle( selector, context, results, seed ) {
813 var match, elem, m, nodeType, var m, i, elem, nid, nidselect, match, groups, newSelector,
814 // QSA vars newContext = context && context.ownerDocument,
815 i, groups, old, nid, newContext, newSelector;
816
817 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { // nodeType defaults to 9, since context defaults to document
818 setDocument( context ); nodeType = context ? context.nodeType : 9;
819 }
820
821 context = context || document;
822 results = results || []; results = results || [];
823 nodeType = context.nodeType;
824
825 // Return early from calls with invalid selector or context
826 if ( typeof selector !== "string" || !selector || if ( typeof selector !== "string" || !selector ||
827 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
828
829 return results; return results;
830 } }
831
832 if ( !seed && documentIsHTML ) { // Try to shortcut find operations (as opposed to filters) in HTML documents
833 if ( !seed ) {
834
835 // Try to shortcut find operations when possible (e.g., not under DocumentFragment) if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
836 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { setDocument( context );
837 // Speed-up: Sizzle("#ID") }
838 if ( (m = match[1]) ) { context = context || document;
839 if ( nodeType === 9 ) {
840 elem = context.getElementById( m ); if ( documentIsHTML ) {
841 // Check parentNode to catch when Blackberry 4.6 returns
842 // nodes that are no longer in the document (jQuery #6963) // If the selector is sufficiently simple, try using a "get*By*" DOM method
843 if ( elem && elem.parentNode ) { // (excepting DocumentFragment context, where the methods don't exist)
844 // Handle the case where IE, Opera, and Webkit return items if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
845 // by name instead of ID
846 if ( elem.id === m ) { // ID selector
847 results.push( elem ); if ( (m = match[1]) ) {
848
849 // Document context
850 if ( nodeType === 9 ) {
851 if ( (elem = context.getElementById( m )) ) {
852
853 // Support: IE, Opera, Webkit
854 // TODO: identify versions
855 // getElementById can match elements by name instead of ID
856 if ( elem.id === m ) {
857 results.push( elem );
858 return results;
859 }
860 } else {
861 return results; return results;
862 } }
863
864 // Element context
865 } else { } else {
866 return results;
867 // Support: IE, Opera, Webkit
868 // TODO: identify versions
869 // getElementById can match elements by name instead of ID
870 if ( newContext && (elem = newContext.getElementById( m )) &&
871 contains( context, elem ) &&
872 elem.id === m ) {
873
874 results.push( elem );
875 return results;
876 }
877 } }
878 } else {
879 // Context is not a document
880 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
881 contains( context, elem ) && elem.id === m ) {
882 results.push( elem );
883 return results;
884 }
885 }
886
887 // Speed-up: Sizzle("TAG") // Type selector
888 } else if ( match[2] ) { } else if ( match[2] ) {
889 push.apply( results, context.getElementsByTagName( selector ) ); push.apply( results, context.getElementsByTagName( selector ) );
890 return results; return results;
891
892 // Speed-up: Sizzle(".CLASS") // Class selector
893 } else if ( (m = match[3]) && support.getElementsByClassName ) { } else if ( (m = match[3]) && support.getElementsByClassName &&
894 push.apply( results, context.getElementsByClassName( m ) ); context.getElementsByClassName ) {
895 return results;
896 push.apply( results, context.getElementsByClassName( m ) );
897 return results;
898 }
899 } }
900 }
901
902 // QSA path // Take advantage of querySelectorAll
903 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { if ( support.qsa &&
904 nid = old = expando; !compilerCache[ selector + " " ] &&
905 newContext = context; (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
906 newSelector = nodeType !== 1 && selector;
907
908 // qSA works strangely on Element-rooted queries if ( nodeType !== 1 ) {
909 // We can work around this by specifying an extra ID on the root newContext = context;
910 // and working up from there (Thanks to Andrew Dupont for the technique) newSelector = selector;
911 // IE 8 doesn't work on object elements
912 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
913 groups = tokenize( selector );
914
915 if ( (old = context.getAttribute("id")) ) { // qSA looks outside Element context, which is not what we want
916 nid = old.replace( rescape, "\\$&" ); // Thanks to Andrew Dupont for this workaround technique
917 } else { // Support: IE <=8
918 context.setAttribute( "id", nid ); // Exclude object elements
919 } } else if ( context.nodeName.toLowerCase() !== "object" ) {
920 nid = "[id='" + nid + "'] ";
921
922 i = groups.length; // Capture the context ID, setting it first if necessary
923 while ( i-- ) { if ( (nid = context.getAttribute( "id" )) ) {
924 groups[i] = nid + toSelector( groups[i] ); nid = nid.replace( rescape, "\\$&" );
925 } else {
926 context.setAttribute( "id", (nid = expando) );
927 }
928
929 // Prefix every selector in the list
930 groups = tokenize( selector );
931 i = groups.length;
932 nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']";
933 while ( i-- ) {
934 groups[i] = nidselect + " " + toSelector( groups[i] );
935 }
936 newSelector = groups.join( "," );
937
938 // Expand context for sibling selectors
939 newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
940 context;
941 } }
942 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
943 newSelector = groups.join(",");
944 }
945
946 if ( newSelector ) { if ( newSelector ) {
947 try { try {
948 push.apply( results, push.apply( results,
949 newContext.querySelectorAll( newSelector ) newContext.querySelectorAll( newSelector )
950 ); );
951 return results; return results;
952 } catch(qsaError) { } catch ( qsaError ) {
953 } finally { } finally {
954 if ( !old ) { if ( nid === expando ) {
955 context.removeAttribute("id"); context.removeAttribute( "id" );
956 }
957 } }
958 } }
959 } }
960 } }
961 } }
962
963 // All others // All others
964 return select( selector.replace( rtrim, "$1" ), context, results, seed ); return select( selector.replace( rtrim, "$1" ), context, results, seed );
965 } }
966
967 /** /**
968 * Create key-value caches of limited size * Create key-value caches of limited size
969 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with * @returns {function(string, object)} Returns the Object data after storing it on itself with
970 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
971 * deleting the oldest entry * deleting the oldest entry
972 */ */
973 function createCache() { function createCache() {
974 var keys = []; var keys = [];
975
976 function cache( key, value ) { function cache( key, value ) {
977 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
978 if ( keys.push( key + " " ) > Expr.cacheLength ) { if ( keys.push( key + " " ) > Expr.cacheLength ) {
979 // Only keep the most recent entries // Only keep the most recent entries
980 delete cache[ keys.shift() ]; delete cache[ keys.shift() ];
981 } }
982 return (cache[ key + " " ] = value); return (cache[ key + " " ] = value);
983 } }
984 return cache; return cache;
985 } }
986
987 /** /**
988 * Mark a function for special use by Sizzle * Mark a function for special use by Sizzle
989 * @param {Function} fn The function to mark * @param {Function} fn The function to mark
990 */ */
991 function markFunction( fn ) { function markFunction( fn ) {
992 fn[ expando ] = true; fn[ expando ] = true;
993 return fn; return fn;
994 } }
995
996 /** /**
997 * Support testing using an element * Support testing using an element
998 * @param {Function} fn Passed the created div and expects a boolean result * @param {Function} fn Passed the created div and expects a boolean result
999 */ */
1000 function assert( fn ) { function assert( fn ) {
1001 var div = document.createElement("div"); var div = document.createElement("div");
1002
1003 try { try {
1004 return !!fn( div ); return !!fn( div );
1005 } catch (e) { } catch (e) {
1006 return false; return false;
1007 } finally { } finally {
1008 // Remove from its parent by default // Remove from its parent by default
1009 if ( div.parentNode ) { if ( div.parentNode ) {
1010 div.parentNode.removeChild( div ); div.parentNode.removeChild( div );
1011 } }
1012 // release memory in IE // release memory in IE
1013 div = null; div = null;
1014 } }
1015 } }
1016
1017 /** /**
1018 * Adds the same handler for all of the specified attrs * Adds the same handler for all of the specified attrs
1019 * @param {String} attrs Pipe-separated list of attributes * @param {String} attrs Pipe-separated list of attributes
1020 * @param {Function} handler The method that will be applied * @param {Function} handler The method that will be applied
1021 */ */
1022 function addHandle( attrs, handler ) { function addHandle( attrs, handler ) {
1023 var arr = attrs.split("|"), var arr = attrs.split("|"),
1024 i = attrs.length; i = arr.length;
1025
1026 while ( i-- ) { while ( i-- ) {
1027 Expr.attrHandle[ arr[i] ] = handler; Expr.attrHandle[ arr[i] ] = handler;
1028 } }
1029 } }
1030
1031 /** /**
1032 * Checks document order of two siblings * Checks document order of two siblings
1033 * @param {Element} a * @param {Element} a
1034 * @param {Element} b * @param {Element} b
1035 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
1036 */ */
1037 function siblingCheck( a, b ) { function siblingCheck( a, b ) {
1038 var cur = b && a, var cur = b && a,
1039 diff = cur && a.nodeType === 1 && b.nodeType === 1 && diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
1040 ( ~b.sourceIndex || MAX_NEGATIVE ) - ( ~b.sourceIndex || MAX_NEGATIVE ) -
1041 ( ~a.sourceIndex || MAX_NEGATIVE ); ( ~a.sourceIndex || MAX_NEGATIVE );
1042
1043 // Use IE sourceIndex if available on both nodes // Use IE sourceIndex if available on both nodes
1044 if ( diff ) { if ( diff ) {
1045 return diff; return diff;
1046 } }
1047
1048 // Check if b follows a // Check if b follows a
1049 if ( cur ) { if ( cur ) {
1050 while ( (cur = cur.nextSibling) ) { while ( (cur = cur.nextSibling) ) {
1051 if ( cur === b ) { if ( cur === b ) {
1052 return -1; return -1;
1053 } }
1054 } }
1055 } }
1056
1057 return a ? 1 : -1; return a ? 1 : -1;
1058 } }
1059
1060 /** /**
1061 * Returns a function to use in pseudos for input types * Returns a function to use in pseudos for input types
1062 * @param {String} type * @param {String} type
1063 */ */
1064 function createInputPseudo( type ) { function createInputPseudo( type ) {
1065 return function( elem ) { return function( elem ) {
1066 var name = elem.nodeName.toLowerCase(); var name = elem.nodeName.toLowerCase();
1067 return name === "input" && elem.type === type; return name === "input" && elem.type === type;
1068 }; };
1069 } }
1070
1071 /** /**
1072 * Returns a function to use in pseudos for buttons * Returns a function to use in pseudos for buttons
1073 * @param {String} type * @param {String} type
1074 */ */
1075 function createButtonPseudo( type ) { function createButtonPseudo( type ) {
1076 return function( elem ) { return function( elem ) {
1077 var name = elem.nodeName.toLowerCase(); var name = elem.nodeName.toLowerCase();
1078 return (name === "input" || name === "button") && elem.type === type; return (name === "input" || name === "button") && elem.type === type;
1079 }; };
1080 } }
1081
1082 /** /**
1083 * Returns a function to use in pseudos for positionals * Returns a function to use in pseudos for positionals
1084 * @param {Function} fn * @param {Function} fn
1085 */ */
1086 function createPositionalPseudo( fn ) { function createPositionalPseudo( fn ) {
1087 return markFunction(function( argument ) { return markFunction(function( argument ) {
1088 argument = +argument; argument = +argument;
1089 return markFunction(function( seed, matches ) { return markFunction(function( seed, matches ) {
1090 var j, var j,
1091 matchIndexes = fn( [], seed.length, argument ), matchIndexes = fn( [], seed.length, argument ),
1092 i = matchIndexes.length; i = matchIndexes.length;
1093
1094 // Match elements found at the specified indexes // Match elements found at the specified indexes
1095 while ( i-- ) { while ( i-- ) {
1096 if ( seed[ (j = matchIndexes[i]) ] ) { if ( seed[ (j = matchIndexes[i]) ] ) {
1097 seed[j] = !(matches[j] = seed[j]); seed[j] = !(matches[j] = seed[j]);
1098 } }
1099 } }
1100 }); });
1101 }); });
1102 } }
1103
1104 /** /**
1105 * Checks a node for validity as a Sizzle context * Checks a node for validity as a Sizzle context
1106 * @param {Element|Object=} context * @param {Element|Object=} context
1107 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1108 */ */
1109 function testContext( context ) { function testContext( context ) {
1110 return context && typeof context.getElementsByTagName !== "undefined" && context; return context && typeof context.getElementsByTagName !== "undefined" && context;
1111 } }
1112
1113 // Expose support vars for convenience // Expose support vars for convenience
1114 support = Sizzle.support = {}; support = Sizzle.support = {};
1115
1116 /** /**
1117 * Detects XML nodes * Detects XML nodes
1118 * @param {Element|Object} elem An element or a document * @param {Element|Object} elem An element or a document
1119 * @returns {Boolean} True iff elem is a non-HTML XML node * @returns {Boolean} True iff elem is a non-HTML XML node
1120 */ */
1121 isXML = Sizzle.isXML = function( elem ) { isXML = Sizzle.isXML = function( elem ) {
1122 // documentElement is verified for cases where it doesn't yet exist // documentElement is verified for cases where it doesn't yet exist
1123 // (such as loading iframes in IE - #4833) // (such as loading iframes in IE - #4833)
1124 var documentElement = elem && (elem.ownerDocument || elem).documentElement; var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1125 return documentElement ? documentElement.nodeName !== "HTML" : false; return documentElement ? documentElement.nodeName !== "HTML" : false;
1126 }; };
1127
1128 /** /**
1129 * Sets document-related variables once based on the current document * Sets document-related variables once based on the current document
1130 * @param {Element|Object} [doc] An element or document object to use to set the document * @param {Element|Object} [doc] An element or document object to use to set the document
1131 * @returns {Object} Returns the current document * @returns {Object} Returns the current document
1132 */ */
1133 setDocument = Sizzle.setDocument = function( node ) { setDocument = Sizzle.setDocument = function( node ) {
1134 var hasCompare, parent, var hasCompare, parent,
1135 doc = node ? node.ownerDocument || node : preferredDoc; doc = node ? node.ownerDocument || node : preferredDoc;
1136
1137 // If no document and documentElement is available, return // Return early if doc is invalid or already selected
1138 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1139 return document; return document;
1140 } }
1141
1142 // Set our document // Update global variables
1143 document = doc; document = doc;
1144 docElem = doc.documentElement; docElem = document.documentElement;
1145 parent = doc.defaultView; documentIsHTML = !isXML( document );
1146
1147 // Support: IE>8 // Support: IE 9-11, Edge
1148 // If iframe document is assigned to "document" variable and if iframe has been reloaded, // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
1149 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 if ( (parent = document.defaultView) && parent.top !== parent ) {
1150 // IE6-8 do not support the defaultView property so parent will be undefined // Support: IE 11
1151 if ( parent && parent !== parent.top ) {
1152 // IE11 does not have attachEvent, so all must suffer
1153 if ( parent.addEventListener ) { if ( parent.addEventListener ) {
1154 parent.addEventListener( "unload", unloadHandler, false ); parent.addEventListener( "unload", unloadHandler, false );
1155
1156 // Support: IE 9 - 10 only
1157 } else if ( parent.attachEvent ) { } else if ( parent.attachEvent ) {
1158 parent.attachEvent( "onunload", unloadHandler ); parent.attachEvent( "onunload", unloadHandler );
1159 } }
1160 } }
1161
1162 /* Support tests
1163 ---------------------------------------------------------------------- */
1164 documentIsHTML = !isXML( doc );
1165
1166 /* Attributes /* Attributes
1167 ---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
1168
1169 // Support: IE<8 // Support: IE<8
1170 // Verify that getAttribute really returns attributes and not properties // Verify that getAttribute really returns attributes and not properties
1171 // (excepting IE8 booleans) // (excepting IE8 booleans)
1172 support.attributes = assert(function( div ) { support.attributes = assert(function( div ) {
1173 div.className = "i"; div.className = "i";
1174 return !div.getAttribute("className"); return !div.getAttribute("className");
1175 }); });
1176
1177 /* getElement(s)By* /* getElement(s)By*
1178 ---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
1179
1180 // Check if getElementsByTagName("*") returns only elements // Check if getElementsByTagName("*") returns only elements
1181 support.getElementsByTagName = assert(function( div ) { support.getElementsByTagName = assert(function( div ) {
1182 div.appendChild( doc.createComment("") ); div.appendChild( document.createComment("") );
1183 return !div.getElementsByTagName("*").length; return !div.getElementsByTagName("*").length;
1184 }); });
1185
1186 // Support: IE<9 // Support: IE<9
1187 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ); support.getElementsByClassName = rnative.test( document.getElementsByClassName );
1188
1189 // Support: IE<10 // Support: IE<10
1190 // Check if getElementById returns elements by name // Check if getElementById returns elements by name
1191 // The broken getElementById methods don't pick up programatically-set names, // The broken getElementById methods don't pick up programatically-set names,
1192 // so use a roundabout getElementsByName test // so use a roundabout getElementsByName test
1193 support.getById = assert(function( div ) { support.getById = assert(function( div ) {
1194 docElem.appendChild( div ).id = expando; docElem.appendChild( div ).id = expando;
1195 return !doc.getElementsByName || !doc.getElementsByName( expando ).length; return !document.getElementsByName || !document.getElementsByName( expando ).length;
1196 }); });
1197
1198 // ID find and filter // ID find and filter
1199 if ( support.getById ) { if ( support.getById ) {
1200 Expr.find["ID"] = function( id, context ) { Expr.find["ID"] = function( id, context ) {
1201 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1202 var m = context.getElementById( id ); var m = context.getElementById( id );
1203 // Check parentNode to catch when Blackberry 4.6 returns return m ? [ m ] : [];
1204 // nodes that are no longer in the document #6963
1205 return m && m.parentNode ? [ m ] : [];
1206 } }
1207 }; };
1208 Expr.filter["ID"] = function( id ) { Expr.filter["ID"] = function( id ) {
1209 var attrId = id.replace( runescape, funescape ); var attrId = id.replace( runescape, funescape );
1210 return function( elem ) { return function( elem ) {
1211 return elem.getAttribute("id") === attrId; return elem.getAttribute("id") === attrId;
1212 }; };
1213 }; };
1214 } else { } else {
1215 // Support: IE6/7 // Support: IE6/7
1216 // getElementById is not reliable as a find shortcut // getElementById is not reliable as a find shortcut
1217 delete Expr.find["ID"]; delete Expr.find["ID"];
1218
1219 Expr.filter["ID"] = function( id ) { Expr.filter["ID"] = function( id ) {
1220 var attrId = id.replace( runescape, funescape ); var attrId = id.replace( runescape, funescape );
1221 return function( elem ) { return function( elem ) {
1222 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); var node = typeof elem.getAttributeNode !== "undefined" &&
1223 elem.getAttributeNode("id");
1224 return node && node.value === attrId; return node && node.value === attrId;
1225 }; };
1226 }; };
1227 } }
1228
1229 // Tag // Tag
1230 Expr.find["TAG"] = support.getElementsByTagName ? Expr.find["TAG"] = support.getElementsByTagName ?
1231 function( tag, context ) { function( tag, context ) {
1232 if ( typeof context.getElementsByTagName !== "undefined" ) { if ( typeof context.getElementsByTagName !== "undefined" ) {
1233 return context.getElementsByTagName( tag ); return context.getElementsByTagName( tag );
1234
1235 // DocumentFragment nodes don't have gEBTN // DocumentFragment nodes don't have gEBTN
1236 } else if ( support.qsa ) { } else if ( support.qsa ) {
1237 return context.querySelectorAll( tag ); return context.querySelectorAll( tag );
1238 } }
1239 } : } :
1240
1241 function( tag, context ) { function( tag, context ) {
1242 var elem, var elem,
1243 tmp = [], tmp = [],
1244 i = 0, i = 0,
1245 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1246 results = context.getElementsByTagName( tag ); results = context.getElementsByTagName( tag );
1247
1248 // Filter out possible comments // Filter out possible comments
1249 if ( tag === "*" ) { if ( tag === "*" ) {
1250 while ( (elem = results[i++]) ) { while ( (elem = results[i++]) ) {
1251 if ( elem.nodeType === 1 ) { if ( elem.nodeType === 1 ) {
1252 tmp.push( elem ); tmp.push( elem );
1253 } }
1254 } }
1255
1256 return tmp; return tmp;
1257 } }
1258 return results; return results;
1259 }; };
1260
1261 // Class // Class
1262 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1263 if ( documentIsHTML ) { if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
1264 return context.getElementsByClassName( className ); return context.getElementsByClassName( className );
1265 } }
1266 }; };
1267
1268 /* QSA/matchesSelector /* QSA/matchesSelector
1269 ---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
1270
1271 // QSA and matchesSelector support // QSA and matchesSelector support
1272
1273 // matchesSelector(:active) reports false when true (IE9/Opera 11.5) // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1274 rbuggyMatches = []; rbuggyMatches = [];
1275
1276 // qSa(:focus) reports false when true (Chrome 21) // qSa(:focus) reports false when true (Chrome 21)
1277 // We allow this because of a bug in IE8/9 that throws an error // We allow this because of a bug in IE8/9 that throws an error
1278 // whenever `document.activeElement` is accessed on an iframe // whenever `document.activeElement` is accessed on an iframe
1279 // So, we allow :focus to pass through QSA all the time to avoid the IE error // So, we allow :focus to pass through QSA all the time to avoid the IE error
1280 // See http://bugs.jquery.com/ticket/13378 // See http://bugs.jquery.com/ticket/13378
1281 rbuggyQSA = []; rbuggyQSA = [];
1282
1283 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
1284 // Build QSA regex // Build QSA regex
1285 // Regex strategy adopted from Diego Perini // Regex strategy adopted from Diego Perini
1286 assert(function( div ) { assert(function( div ) {
1287 // Select is set to empty string on purpose // Select is set to empty string on purpose
1288 // This is to test IE's treatment of not explicitly // This is to test IE's treatment of not explicitly
1289 // setting a boolean content attribute, // setting a boolean content attribute,
1290 // since its presence should be enough // since its presence should be enough
1291 // http://bugs.jquery.com/ticket/12359 // http://bugs.jquery.com/ticket/12359
1292 docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" + docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
1293 "<select id='" + expando + "-\f]' msallowcapture=''>" + "<select id='" + expando + "-\r\\' msallowcapture=''>" +
1294 "<option selected=''></option></select>"; "<option selected=''></option></select>";
1295
1296 // Support: IE8, Opera 11-12.16 // Support: IE8, Opera 11-12.16
1297 // Nothing should be selected when empty strings follow ^= or $= or *= // Nothing should be selected when empty strings follow ^= or $= or *=
1298 // The test attribute must be unknown in Opera but "safe" for WinRT // The test attribute must be unknown in Opera but "safe" for WinRT
1299 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1300 if ( div.querySelectorAll("[msallowcapture^='']").length ) { if ( div.querySelectorAll("[msallowcapture^='']").length ) {
1301 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1302 } }
1303
1304 // Support: IE8 // Support: IE8
1305 // Boolean attributes and "value" are not treated correctly // Boolean attributes and "value" are not treated correctly
1306 if ( !div.querySelectorAll("[selected]").length ) { if ( !div.querySelectorAll("[selected]").length ) {
1307 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1308 } }
1309
1310 // Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+ // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
1311 if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
1312 rbuggyQSA.push("~="); rbuggyQSA.push("~=");
1313 } }
1314
1315 // Webkit/Opera - :checked should return selected option elements // Webkit/Opera - :checked should return selected option elements
1316 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1317 // IE8 throws error here and will not see later tests // IE8 throws error here and will not see later tests
1318 if ( !div.querySelectorAll(":checked").length ) { if ( !div.querySelectorAll(":checked").length ) {
1319 rbuggyQSA.push(":checked"); rbuggyQSA.push(":checked");
1320 } }
1321
1322 // Support: Safari 8+, iOS 8+ // Support: Safari 8+, iOS 8+
1323 // https://bugs.webkit.org/show_bug.cgi?id=136851 // https://bugs.webkit.org/show_bug.cgi?id=136851
1324 // In-page `selector#id sibing-combinator selector` fails // In-page `selector#id sibing-combinator selector` fails
1325 if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
1326 rbuggyQSA.push(".#.+[+~]"); rbuggyQSA.push(".#.+[+~]");
1327 } }
1328 }); });
1329
1330 assert(function( div ) { assert(function( div ) {
1331 // Support: Windows 8 Native Apps // Support: Windows 8 Native Apps
1332 // The type and name attributes are restricted during .innerHTML assignment // The type and name attributes are restricted during .innerHTML assignment
1333 var input = doc.createElement("input"); var input = document.createElement("input");
1334 input.setAttribute( "type", "hidden" ); input.setAttribute( "type", "hidden" );
1335 div.appendChild( input ).setAttribute( "name", "D" ); div.appendChild( input ).setAttribute( "name", "D" );
1336
1337 // Support: IE8 // Support: IE8
1338 // Enforce case-sensitivity of name attribute // Enforce case-sensitivity of name attribute
1339 if ( div.querySelectorAll("[name=d]").length ) { if ( div.querySelectorAll("[name=d]").length ) {
1340 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1341 } }
1342
1343 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1344 // IE8 throws error here and will not see later tests // IE8 throws error here and will not see later tests
1345 if ( !div.querySelectorAll(":enabled").length ) { if ( !div.querySelectorAll(":enabled").length ) {
1346 rbuggyQSA.push( ":enabled", ":disabled" ); rbuggyQSA.push( ":enabled", ":disabled" );
1347 } }
1348
1349 // Opera 10-11 does not throw on post-comma invalid pseudos // Opera 10-11 does not throw on post-comma invalid pseudos
1350 div.querySelectorAll("*,:x"); div.querySelectorAll("*,:x");
1351 rbuggyQSA.push(",.*:"); rbuggyQSA.push(",.*:");
1352 }); });
1353 } }
1354
1355 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
1356 docElem.webkitMatchesSelector || docElem.webkitMatchesSelector ||
1357 docElem.mozMatchesSelector || docElem.mozMatchesSelector ||
1358 docElem.oMatchesSelector || docElem.oMatchesSelector ||
1359 docElem.msMatchesSelector) )) ) { docElem.msMatchesSelector) )) ) {
1360
1361 assert(function( div ) { assert(function( div ) {
1362 // Check to see if it's possible to do matchesSelector // Check to see if it's possible to do matchesSelector
1363 // on a disconnected node (IE 9) // on a disconnected node (IE 9)
1364 support.disconnectedMatch = matches.call( div, "div" ); support.disconnectedMatch = matches.call( div, "div" );
1365
1366 // This should fail with an exception // This should fail with an exception
1367 // Gecko does not error, returns false instead // Gecko does not error, returns false instead
1368 matches.call( div, "[s!='']:x" ); matches.call( div, "[s!='']:x" );
1369 rbuggyMatches.push( "!=", pseudos ); rbuggyMatches.push( "!=", pseudos );
1370 }); });
1371 } }
1372
1373 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1374 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1375
1376 /* Contains /* Contains
1377 ---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
1378 hasCompare = rnative.test( docElem.compareDocumentPosition ); hasCompare = rnative.test( docElem.compareDocumentPosition );
1379
1380 // Element contains another // Element contains another
1381 // Purposefully does not implement inclusive descendent // Purposefully self-exclusive
1382 // As in, an element does not contain itself // As in, an element does not contain itself
1383 contains = hasCompare || rnative.test( docElem.contains ) ? contains = hasCompare || rnative.test( docElem.contains ) ?
1384 function( a, b ) { function( a, b ) {
1385 var adown = a.nodeType === 9 ? a.documentElement : a, var adown = a.nodeType === 9 ? a.documentElement : a,
1386 bup = b && b.parentNode; bup = b && b.parentNode;
1387 return a === bup || !!( bup && bup.nodeType === 1 && ( return a === bup || !!( bup && bup.nodeType === 1 && (
1388 adown.contains ? adown.contains ?
1389 adown.contains( bup ) : adown.contains( bup ) :
1390 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1391 )); ));
1392 } : } :
1393 function( a, b ) { function( a, b ) {
1394 if ( b ) { if ( b ) {
1395 while ( (b = b.parentNode) ) { while ( (b = b.parentNode) ) {
1396 if ( b === a ) { if ( b === a ) {
1397 return true; return true;
1398 } }
1399 } }
1400 } }
1401 return false; return false;
1402 }; };
1403
1404 /* Sorting /* Sorting
1405 ---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
1406
1407 // Document order sorting // Document order sorting
1408 sortOrder = hasCompare ? sortOrder = hasCompare ?
1409 function( a, b ) { function( a, b ) {
1410
1411 // Flag for duplicate removal // Flag for duplicate removal
1412 if ( a === b ) { if ( a === b ) {
1413 hasDuplicate = true; hasDuplicate = true;
1414 return 0; return 0;
1415 } }
1416
1417 // Sort on method existence if only one input has compareDocumentPosition // Sort on method existence if only one input has compareDocumentPosition
1418 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1419 if ( compare ) { if ( compare ) {
1420 return compare; return compare;
1421 } }
1422
1423 // Calculate position if both inputs belong to the same document // Calculate position if both inputs belong to the same document
1424 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1425 a.compareDocumentPosition( b ) : a.compareDocumentPosition( b ) :
1426
1427 // Otherwise we know they are disconnected // Otherwise we know they are disconnected
1428 1; 1;
1429
1430 // Disconnected nodes // Disconnected nodes
1431 if ( compare & 1 || if ( compare & 1 ||
1432 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1433
1434 // Choose the first element that is related to our preferred document // Choose the first element that is related to our preferred document
1435 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1436 return -1; return -1;
1437 } }
1438 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1439 return 1; return 1;
1440 } }
1441
1442 // Maintain original order // Maintain original order
1443 return sortInput ? return sortInput ?
1444 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1445 0; 0;
1446 } }
1447
1448 return compare & 4 ? -1 : 1; return compare & 4 ? -1 : 1;
1449 } : } :
1450 function( a, b ) { function( a, b ) {
1451 // Exit early if the nodes are identical // Exit early if the nodes are identical
1452 if ( a === b ) { if ( a === b ) {
1453 hasDuplicate = true; hasDuplicate = true;
1454 return 0; return 0;
1455 } }
1456
1457 var cur, var cur,
1458 i = 0, i = 0,
1459 aup = a.parentNode, aup = a.parentNode,
1460 bup = b.parentNode, bup = b.parentNode,
1461 ap = [ a ], ap = [ a ],
1462 bp = [ b ]; bp = [ b ];
1463
1464 // Parentless nodes are either documents or disconnected // Parentless nodes are either documents or disconnected
1465 if ( !aup || !bup ) { if ( !aup || !bup ) {
1466 return a === doc ? -1 : return a === document ? -1 :
1467 b === doc ? 1 : b === document ? 1 :
1468 aup ? -1 : aup ? -1 :
1469 bup ? 1 : bup ? 1 :
1470 sortInput ? sortInput ?
1471 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1472 0; 0;
1473
1474 // If the nodes are siblings, we can do a quick check // If the nodes are siblings, we can do a quick check
1475 } else if ( aup === bup ) { } else if ( aup === bup ) {
1476 return siblingCheck( a, b ); return siblingCheck( a, b );
1477 } }
1478
1479 // Otherwise we need full lists of their ancestors for comparison // Otherwise we need full lists of their ancestors for comparison
1480 cur = a; cur = a;
1481 while ( (cur = cur.parentNode) ) { while ( (cur = cur.parentNode) ) {
1482 ap.unshift( cur ); ap.unshift( cur );
1483 } }
1484 cur = b; cur = b;
1485 while ( (cur = cur.parentNode) ) { while ( (cur = cur.parentNode) ) {
1486 bp.unshift( cur ); bp.unshift( cur );
1487 } }
1488
1489 // Walk down the tree looking for a discrepancy // Walk down the tree looking for a discrepancy
1490 while ( ap[i] === bp[i] ) { while ( ap[i] === bp[i] ) {
1491 i++; i++;
1492 } }
1493
1494 return i ? return i ?
1495 // Do a sibling check if the nodes have a common ancestor // Do a sibling check if the nodes have a common ancestor
1496 siblingCheck( ap[i], bp[i] ) : siblingCheck( ap[i], bp[i] ) :
1497
1498 // Otherwise nodes in our document sort first // Otherwise nodes in our document sort first
1499 ap[i] === preferredDoc ? -1 : ap[i] === preferredDoc ? -1 :
1500 bp[i] === preferredDoc ? 1 : bp[i] === preferredDoc ? 1 :
1501 0; 0;
1502 }; };
1503
1504 return doc; return document;
1505 }; };
1506
1507 Sizzle.matches = function( expr, elements ) { Sizzle.matches = function( expr, elements ) {
1508 return Sizzle( expr, null, null, elements ); return Sizzle( expr, null, null, elements );
1509 }; };
1510
1511 Sizzle.matchesSelector = function( elem, expr ) { Sizzle.matchesSelector = function( elem, expr ) {
1512 // Set document vars if needed // Set document vars if needed
1513 if ( ( elem.ownerDocument || elem ) !== document ) { if ( ( elem.ownerDocument || elem ) !== document ) {
1514 setDocument( elem ); setDocument( elem );
1515 } }
1516
1517 // Make sure that attribute selectors are quoted // Make sure that attribute selectors are quoted
1518 expr = expr.replace( rattributeQuotes, "='$1']" ); expr = expr.replace( rattributeQuotes, "='$1']" );
1519
1520 if ( support.matchesSelector && documentIsHTML && if ( support.matchesSelector && documentIsHTML &&
1521 !compilerCache[ expr + " " ] &&
1522 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1523 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1524
1525 try { try {
1526 var ret = matches.call( elem, expr ); var ret = matches.call( elem, expr );
1527
1528 // IE 9's matchesSelector returns false on disconnected nodes // IE 9's matchesSelector returns false on disconnected nodes
1529 if ( ret || support.disconnectedMatch || if ( ret || support.disconnectedMatch ||
1530 // As well, disconnected nodes are said to be in a document // As well, disconnected nodes are said to be in a document
1531 // fragment in IE 9 // fragment in IE 9
1532 elem.document && elem.document.nodeType !== 11 ) { elem.document && elem.document.nodeType !== 11 ) {
1533 return ret; return ret;
1534 } }
1535 } catch (e) {} } catch (e) {}
1536 } }
1537
1538 return Sizzle( expr, document, null, [ elem ] ).length > 0; return Sizzle( expr, document, null, [ elem ] ).length > 0;
1539 }; };
1540
1541 Sizzle.contains = function( context, elem ) { Sizzle.contains = function( context, elem ) {
1542 // Set document vars if needed // Set document vars if needed
1543 if ( ( context.ownerDocument || context ) !== document ) { if ( ( context.ownerDocument || context ) !== document ) {
1544 setDocument( context ); setDocument( context );
1545 } }
1546 return contains( context, elem ); return contains( context, elem );
1547 }; };
1548
1549 Sizzle.attr = function( elem, name ) { Sizzle.attr = function( elem, name ) {
1550 // Set document vars if needed // Set document vars if needed
1551 if ( ( elem.ownerDocument || elem ) !== document ) { if ( ( elem.ownerDocument || elem ) !== document ) {
1552 setDocument( elem ); setDocument( elem );
1553 } }
1554
1555 var fn = Expr.attrHandle[ name.toLowerCase() ], var fn = Expr.attrHandle[ name.toLowerCase() ],
1556 // Don't get fooled by Object.prototype properties (jQuery #13807) // Don't get fooled by Object.prototype properties (jQuery #13807)
1557 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1558 fn( elem, name, !documentIsHTML ) : fn( elem, name, !documentIsHTML ) :
1559 undefined; undefined;
1560
1561 return val !== undefined ? return val !== undefined ?
1562 val : val :
1563 support.attributes || !documentIsHTML ? support.attributes || !documentIsHTML ?
1564 elem.getAttribute( name ) : elem.getAttribute( name ) :
1565 (val = elem.getAttributeNode(name)) && val.specified ? (val = elem.getAttributeNode(name)) && val.specified ?
1566 val.value : val.value :
1567 null; null;
1568 }; };
1569
1570 Sizzle.error = function( msg ) { Sizzle.error = function( msg ) {
1571 throw new Error( "Syntax error, unrecognized expression: " + msg ); throw new Error( "Syntax error, unrecognized expression: " + msg );
1572 }; };
1573
1574 /** /**
1575 * Document sorting and removing duplicates * Document sorting and removing duplicates
1576 * @param {ArrayLike} results * @param {ArrayLike} results
1577 */ */
1578 Sizzle.uniqueSort = function( results ) { Sizzle.uniqueSort = function( results ) {
1579 var elem, var elem,
1580 duplicates = [], duplicates = [],
1581 j = 0, j = 0,
1582 i = 0; i = 0;
1583
1584 // Unless we *know* we can detect duplicates, assume their presence // Unless we *know* we can detect duplicates, assume their presence
1585 hasDuplicate = !support.detectDuplicates; hasDuplicate = !support.detectDuplicates;
1586 sortInput = !support.sortStable && results.slice( 0 ); sortInput = !support.sortStable && results.slice( 0 );
1587 results.sort( sortOrder ); results.sort( sortOrder );
1588
1589 if ( hasDuplicate ) { if ( hasDuplicate ) {
1590 while ( (elem = results[i++]) ) { while ( (elem = results[i++]) ) {
1591 if ( elem === results[ i ] ) { if ( elem === results[ i ] ) {
1592 j = duplicates.push( i ); j = duplicates.push( i );
1593 } }
1594 } }
1595 while ( j-- ) { while ( j-- ) {
1596 results.splice( duplicates[ j ], 1 ); results.splice( duplicates[ j ], 1 );
1597 } }
1598 } }
1599
1600 // Clear input after sorting to release objects // Clear input after sorting to release objects
1601 // See https://github.com/jquery/sizzle/pull/225 // See https://github.com/jquery/sizzle/pull/225
1602 sortInput = null; sortInput = null;
1603
1604 return results; return results;
1605 }; };
1606
1607 /** /**
1608 * Utility function for retrieving the text value of an array of DOM nodes * Utility function for retrieving the text value of an array of DOM nodes
1609 * @param {Array|Element} elem * @param {Array|Element} elem
1610 */ */
1611 getText = Sizzle.getText = function( elem ) { getText = Sizzle.getText = function( elem ) {
1612 var node, var node,
1613 ret = "", ret = "",
1614 i = 0, i = 0,
1615 nodeType = elem.nodeType; nodeType = elem.nodeType;
1616
1617 if ( !nodeType ) { if ( !nodeType ) {
1618 // If no nodeType, this is expected to be an array // If no nodeType, this is expected to be an array
1619 while ( (node = elem[i++]) ) { while ( (node = elem[i++]) ) {
1620 // Do not traverse comment nodes // Do not traverse comment nodes
1621 ret += getText( node ); ret += getText( node );
1622 } }
1623 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1624 // Use textContent for elements // Use textContent for elements
1625 // innerText usage removed for consistency of new lines (jQuery #11153) // innerText usage removed for consistency of new lines (jQuery #11153)
1626 if ( typeof elem.textContent === "string" ) { if ( typeof elem.textContent === "string" ) {
1627 return elem.textContent; return elem.textContent;
1628 } else { } else {
1629 // Traverse its children // Traverse its children
1630 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1631 ret += getText( elem ); ret += getText( elem );
1632 } }
1633 } }
1634 } else if ( nodeType === 3 || nodeType === 4 ) { } else if ( nodeType === 3 || nodeType === 4 ) {
1635 return elem.nodeValue; return elem.nodeValue;
1636 } }
1637 // Do not include comment or processing instruction nodes // Do not include comment or processing instruction nodes
1638
1639 return ret; return ret;
1640 }; };
1641
1642 Expr = Sizzle.selectors = { Expr = Sizzle.selectors = {
1643
1644 // Can be adjusted by the user // Can be adjusted by the user
1645 cacheLength: 50, cacheLength: 50,
1646
1647 createPseudo: markFunction, createPseudo: markFunction,
1648
1649 match: matchExpr, match: matchExpr,
1650
1651 attrHandle: {}, attrHandle: {},
1652
1653 find: {}, find: {},
1654
1655 relative: { relative: {
1656 ">": { dir: "parentNode", first: true }, ">": { dir: "parentNode", first: true },
1657 " ": { dir: "parentNode" }, " ": { dir: "parentNode" },
1658 "+": { dir: "previousSibling", first: true }, "+": { dir: "previousSibling", first: true },
1659 "~": { dir: "previousSibling" } "~": { dir: "previousSibling" }
1660 }, },
1661
1662 preFilter: { preFilter: {
1663 "ATTR": function( match ) { "ATTR": function( match ) {
1664 match[1] = match[1].replace( runescape, funescape ); match[1] = match[1].replace( runescape, funescape );
1665
1666 // Move the given value to match[3] whether quoted or unquoted // Move the given value to match[3] whether quoted or unquoted
1667 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
1668
1669 if ( match[2] === "~=" ) { if ( match[2] === "~=" ) {
1670 match[3] = " " + match[3] + " "; match[3] = " " + match[3] + " ";
1671 } }
1672
1673 return match.slice( 0, 4 ); return match.slice( 0, 4 );
1674 }, },
1675
1676 "CHILD": function( match ) { "CHILD": function( match ) {
1677 /* matches from matchExpr["CHILD"] /* matches from matchExpr["CHILD"]
1678 1 type (only|nth|...) 1 type (only|nth|...)
1679 2 what (child|of-type) 2 what (child|of-type)
1680 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1681 4 xn-component of xn+y argument ([+-]?\d*n|) 4 xn-component of xn+y argument ([+-]?\d*n|)
1682 5 sign of xn-component 5 sign of xn-component
1683 6 x of xn-component 6 x of xn-component
1684 7 sign of y-component 7 sign of y-component
1685 8 y of y-component 8 y of y-component
1686 */ */
1687 match[1] = match[1].toLowerCase(); match[1] = match[1].toLowerCase();
1688
1689 if ( match[1].slice( 0, 3 ) === "nth" ) { if ( match[1].slice( 0, 3 ) === "nth" ) {
1690 // nth-* requires argument // nth-* requires argument
1691 if ( !match[3] ) { if ( !match[3] ) {
1692 Sizzle.error( match[0] ); Sizzle.error( match[0] );
1693 } }
1694
1695 // numeric x and y parameters for Expr.filter.CHILD // numeric x and y parameters for Expr.filter.CHILD
1696 // remember that false/true cast respectively to 0/1 // remember that false/true cast respectively to 0/1
1697 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1698 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1699
1700 // other types prohibit arguments // other types prohibit arguments
1701 } else if ( match[3] ) { } else if ( match[3] ) {
1702 Sizzle.error( match[0] ); Sizzle.error( match[0] );
1703 } }
1704
1705 return match; return match;
1706 }, },
1707
1708 "PSEUDO": function( match ) { "PSEUDO": function( match ) {
1709 var excess, var excess,
1710 unquoted = !match[6] && match[2]; unquoted = !match[6] && match[2];
1711
1712 if ( matchExpr["CHILD"].test( match[0] ) ) { if ( matchExpr["CHILD"].test( match[0] ) ) {
1713 return null; return null;
1714 } }
1715
1716 // Accept quoted arguments as-is // Accept quoted arguments as-is
1717 if ( match[3] ) { if ( match[3] ) {
1718 match[2] = match[4] || match[5] || ""; match[2] = match[4] || match[5] || "";
1719
1720 // Strip excess characters from unquoted arguments // Strip excess characters from unquoted arguments
1721 } else if ( unquoted && rpseudo.test( unquoted ) && } else if ( unquoted && rpseudo.test( unquoted ) &&
1722 // Get excess from tokenize (recursively) // Get excess from tokenize (recursively)
1723 (excess = tokenize( unquoted, true )) && (excess = tokenize( unquoted, true )) &&
1724 // advance to the next closing parenthesis // advance to the next closing parenthesis
1725 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1726
1727 // excess is a negative index // excess is a negative index
1728 match[0] = match[0].slice( 0, excess ); match[0] = match[0].slice( 0, excess );
1729 match[2] = unquoted.slice( 0, excess ); match[2] = unquoted.slice( 0, excess );
1730 } }
1731
1732 // Return only captures needed by the pseudo filter method (type and argument) // Return only captures needed by the pseudo filter method (type and argument)
1733 return match.slice( 0, 3 ); return match.slice( 0, 3 );
1734 } }
1735 }, },
1736
1737 filter: { filter: {
1738
1739 "TAG": function( nodeNameSelector ) { "TAG": function( nodeNameSelector ) {
1740 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1741 return nodeNameSelector === "*" ? return nodeNameSelector === "*" ?
1742 function() { return true; } : function() { return true; } :
1743 function( elem ) { function( elem ) {
1744 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1745 }; };
1746 }, },
1747
1748 "CLASS": function( className ) { "CLASS": function( className ) {
1749 var pattern = classCache[ className + " " ]; var pattern = classCache[ className + " " ];
1750
1751 return pattern || return pattern ||
1752 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1753 classCache( className, function( elem ) { classCache( className, function( elem ) {
1754 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
1755 }); });
1756 }, },
1757
1758 "ATTR": function( name, operator, check ) { "ATTR": function( name, operator, check ) {
1759 return function( elem ) { return function( elem ) {
1760 var result = Sizzle.attr( elem, name ); var result = Sizzle.attr( elem, name );
1761
1762 if ( result == null ) { if ( result == null ) {
1763 return operator === "!="; return operator === "!=";
1764 } }
1765 if ( !operator ) { if ( !operator ) {
1766 return true; return true;
1767 } }
1768
1769 result += ""; result += "";
1770
1771 return operator === "=" ? result === check : return operator === "=" ? result === check :
1772 operator === "!=" ? result !== check : operator === "!=" ? result !== check :
1773 operator === "^=" ? check && result.indexOf( check ) === 0 : operator === "^=" ? check && result.indexOf( check ) === 0 :
1774 operator === "*=" ? check && result.indexOf( check ) > -1 : operator === "*=" ? check && result.indexOf( check ) > -1 :
1775 operator === "$=" ? check && result.slice( -check.length ) === check : operator === "$=" ? check && result.slice( -check.length ) === check :
1776 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
1777 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1778 false; false;
1779 }; };
1780 }, },
1781
1782 "CHILD": function( type, what, argument, first, last ) { "CHILD": function( type, what, argument, first, last ) {
1783 var simple = type.slice( 0, 3 ) !== "nth", var simple = type.slice( 0, 3 ) !== "nth",
1784 forward = type.slice( -4 ) !== "last", forward = type.slice( -4 ) !== "last",
1785 ofType = what === "of-type"; ofType = what === "of-type";
1786
1787 return first === 1 && last === 0 ? return first === 1 && last === 0 ?
1788
1789 // Shortcut for :nth-*(n) // Shortcut for :nth-*(n)
1790 function( elem ) { function( elem ) {
1791 return !!elem.parentNode; return !!elem.parentNode;
1792 } : } :
1793
1794 function( elem, context, xml ) { function( elem, context, xml ) {
1795 var cache, outerCache, node, diff, nodeIndex, start, var cache, uniqueCache, outerCache, node, nodeIndex, start,
1796 dir = simple !== forward ? "nextSibling" : "previousSibling", dir = simple !== forward ? "nextSibling" : "previousSibling",
1797 parent = elem.parentNode, parent = elem.parentNode,
1798 name = ofType && elem.nodeName.toLowerCase(), name = ofType && elem.nodeName.toLowerCase(),
1799 useCache = !xml && !ofType; useCache = !xml && !ofType,
1800 diff = false;
1801
1802 if ( parent ) { if ( parent ) {
1803
1804 // :(first|last|only)-(child|of-type) // :(first|last|only)-(child|of-type)
1805 if ( simple ) { if ( simple ) {
1806 while ( dir ) { while ( dir ) {
1807 node = elem; node = elem;
1808 while ( (node = node[ dir ]) ) { while ( (node = node[ dir ]) ) {
1809 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { if ( ofType ?
1810 node.nodeName.toLowerCase() === name :
1811 node.nodeType === 1 ) {
1812 return false; return false;
1813 } }
1814 } }
1815 // Reverse direction for :only-* (if we haven't yet done so) // Reverse direction for :only-* (if we haven't yet done so)
1816 start = dir = type === "only" && !start && "nextSibling"; start = dir = type === "only" && !start && "nextSibling";
1817 } }
1818 return true; return true;
1819 } }
1820
1821 start = [ forward ? parent.firstChild : parent.lastChild ]; start = [ forward ? parent.firstChild : parent.lastChild ];
1822
1823 // non-xml :nth-child(...) stores cache data on `parent` // non-xml :nth-child(...) stores cache data on `parent`
1824 if ( forward && useCache ) { if ( forward && useCache ) {
1825
1826 // Seek `elem` from a previously-cached index // Seek `elem` from a previously-cached index
1827 outerCache = parent[ expando ] || (parent[ expando ] = {});
1828 cache = outerCache[ type ] || []; // ...in a gzip-friendly way
1829 nodeIndex = cache[0] === dirruns && cache[1]; node = parent;
1830 diff = cache[0] === dirruns && cache[2]; outerCache = node[ expando ] || (node[ expando ] = {});
1831
1832 // Support: IE <9 only
1833 // Defend against cloned attroperties (jQuery gh-1709)
1834 uniqueCache = outerCache[ node.uniqueID ] ||
1835 (outerCache[ node.uniqueID ] = {});
1836
1837 cache = uniqueCache[ type ] || [];
1838 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1839 diff = nodeIndex && cache[ 2 ];
1840 node = nodeIndex && parent.childNodes[ nodeIndex ]; node = nodeIndex && parent.childNodes[ nodeIndex ];
1841
1842 while ( (node = ++nodeIndex && node && node[ dir ] || while ( (node = ++nodeIndex && node && node[ dir ] ||
1843
1844 // Fallback to seeking `elem` from the start // Fallback to seeking `elem` from the start
1845 (diff = nodeIndex = 0) || start.pop()) ) { (diff = nodeIndex = 0) || start.pop()) ) {
1846
1847 // When found, cache indexes on `parent` and break // When found, cache indexes on `parent` and break
1848 if ( node.nodeType === 1 && ++diff && node === elem ) { if ( node.nodeType === 1 && ++diff && node === elem ) {
1849 outerCache[ type ] = [ dirruns, nodeIndex, diff ]; uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
1850 break; break;
1851 } }
1852 } }
1853
1854 // Use previously-cached element index if available
1855 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
1856 diff = cache[1];
1857
1858 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1859 } else { } else {
1860 // Use the same loop as above to seek `elem` from the start // Use previously-cached element index if available
1861 while ( (node = ++nodeIndex && node && node[ dir ] || if ( useCache ) {
1862 (diff = nodeIndex = 0) || start.pop()) ) { // ...in a gzip-friendly way
1863 node = elem;
1864 outerCache = node[ expando ] || (node[ expando ] = {});
1865
1866 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { // Support: IE <9 only
1867 // Cache the index of each encountered element // Defend against cloned attroperties (jQuery gh-1709)
1868 if ( useCache ) { uniqueCache = outerCache[ node.uniqueID ] ||
1869 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; (outerCache[ node.uniqueID ] = {});
1870 }
1871
1872 if ( node === elem ) { cache = uniqueCache[ type ] || [];
1873 break; nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1874 diff = nodeIndex;
1875 }
1876
1877 // xml :nth-child(...)
1878 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
1879 if ( diff === false ) {
1880 // Use the same loop as above to seek `elem` from the start
1881 while ( (node = ++nodeIndex && node && node[ dir ] ||
1882 (diff = nodeIndex = 0) || start.pop()) ) {
1883
1884 if ( ( ofType ?
1885 node.nodeName.toLowerCase() === name :
1886 node.nodeType === 1 ) &&
1887 ++diff ) {
1888
1889 // Cache the index of each encountered element
1890 if ( useCache ) {
1891 outerCache = node[ expando ] || (node[ expando ] = {});
1892
1893 // Support: IE <9 only
1894 // Defend against cloned attroperties (jQuery gh-1709)
1895 uniqueCache = outerCache[ node.uniqueID ] ||
1896 (outerCache[ node.uniqueID ] = {});
1897
1898 uniqueCache[ type ] = [ dirruns, diff ];
1899 }
1900
1901 if ( node === elem ) {
1902 break;
1903 }
1904 } }
1905 } }
1906 } }
1907 } }
1908
1909 // Incorporate the offset, then check against cycle size // Incorporate the offset, then check against cycle size
1910 diff -= last; diff -= last;
1911 return diff === first || ( diff % first === 0 && diff / first >= 0 ); return diff === first || ( diff % first === 0 && diff / first >= 0 );
1912 } }
1913 }; };
1914 }, },
1915
1916 "PSEUDO": function( pseudo, argument ) { "PSEUDO": function( pseudo, argument ) {
1917 // pseudo-class names are case-insensitive // pseudo-class names are case-insensitive
1918 // http://www.w3.org/TR/selectors/#pseudo-classes // http://www.w3.org/TR/selectors/#pseudo-classes
1919 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1920 // Remember that setFilters inherits from pseudos // Remember that setFilters inherits from pseudos
1921 var args, var args,
1922 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1923 Sizzle.error( "unsupported pseudo: " + pseudo ); Sizzle.error( "unsupported pseudo: " + pseudo );
1924
1925 // The user may use createPseudo to indicate that // The user may use createPseudo to indicate that
1926 // arguments are needed to create the filter function // arguments are needed to create the filter function
1927 // just as Sizzle does // just as Sizzle does
1928 if ( fn[ expando ] ) { if ( fn[ expando ] ) {
1929 return fn( argument ); return fn( argument );
1930 } }
1931
1932 // But maintain support for old signatures // But maintain support for old signatures
1933 if ( fn.length > 1 ) { if ( fn.length > 1 ) {
1934 args = [ pseudo, pseudo, "", argument ]; args = [ pseudo, pseudo, "", argument ];
1935 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1936 markFunction(function( seed, matches ) { markFunction(function( seed, matches ) {
1937 var idx, var idx,
1938 matched = fn( seed, argument ), matched = fn( seed, argument ),
1939 i = matched.length; i = matched.length;
1940 while ( i-- ) { while ( i-- ) {
1941 idx = indexOf( seed, matched[i] ); idx = indexOf( seed, matched[i] );
1942 seed[ idx ] = !( matches[ idx ] = matched[i] ); seed[ idx ] = !( matches[ idx ] = matched[i] );
1943 } }
1944 }) : }) :
1945 function( elem ) { function( elem ) {
1946 return fn( elem, 0, args ); return fn( elem, 0, args );
1947 }; };
1948 } }
1949
1950 return fn; return fn;
1951 } }
1952 }, },
1953
1954 pseudos: { pseudos: {
1955 // Potentially complex pseudos // Potentially complex pseudos
1956 "not": markFunction(function( selector ) { "not": markFunction(function( selector ) {
1957 // Trim the selector passed to compile // Trim the selector passed to compile
1958 // to avoid treating leading and trailing // to avoid treating leading and trailing
1959 // spaces as combinators // spaces as combinators
1960 var input = [], var input = [],
1961 results = [], results = [],
1962 matcher = compile( selector.replace( rtrim, "$1" ) ); matcher = compile( selector.replace( rtrim, "$1" ) );
1963
1964 return matcher[ expando ] ? return matcher[ expando ] ?
1965 markFunction(function( seed, matches, context, xml ) { markFunction(function( seed, matches, context, xml ) {
1966 var elem, var elem,
1967 unmatched = matcher( seed, null, xml, [] ), unmatched = matcher( seed, null, xml, [] ),
1968 i = seed.length; i = seed.length;
1969
1970 // Match elements unmatched by `matcher` // Match elements unmatched by `matcher`
1971 while ( i-- ) { while ( i-- ) {
1972 if ( (elem = unmatched[i]) ) { if ( (elem = unmatched[i]) ) {
1973 seed[i] = !(matches[i] = elem); seed[i] = !(matches[i] = elem);
1974 } }
1975 } }
1976 }) : }) :
1977 function( elem, context, xml ) { function( elem, context, xml ) {
1978 input[0] = elem; input[0] = elem;
1979 matcher( input, null, xml, results ); matcher( input, null, xml, results );
1980 // Don't keep the element (issue #299) // Don't keep the element (issue #299)
1981 input[0] = null; input[0] = null;
1982 return !results.pop(); return !results.pop();
1983 }; };
1984 }), }),
1985
1986 "has": markFunction(function( selector ) { "has": markFunction(function( selector ) {
1987 return function( elem ) { return function( elem ) {
1988 return Sizzle( selector, elem ).length > 0; return Sizzle( selector, elem ).length > 0;
1989 }; };
1990 }), }),
1991
1992 "contains": markFunction(function( text ) { "contains": markFunction(function( text ) {
1993 text = text.replace( runescape, funescape ); text = text.replace( runescape, funescape );
1994 return function( elem ) { return function( elem ) {
1995 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1996 }; };
1997 }), }),
1998
1999 // "Whether an element is represented by a :lang() selector // "Whether an element is represented by a :lang() selector
2000 // is based solely on the element's language value // is based solely on the element's language value
2001 // being equal to the identifier C, // being equal to the identifier C,
2002 // or beginning with the identifier C immediately followed by "-". // or beginning with the identifier C immediately followed by "-".
2003 // The matching of C against the element's language value is performed case-insensitively. // The matching of C against the element's language value is performed case-insensitively.
2004 // The identifier C does not have to be a valid language name." // The identifier C does not have to be a valid language name."
2005 // http://www.w3.org/TR/selectors/#lang-pseudo // http://www.w3.org/TR/selectors/#lang-pseudo
2006 "lang": markFunction( function( lang ) { "lang": markFunction( function( lang ) {
2007 // lang value must be a valid identifier // lang value must be a valid identifier
2008 if ( !ridentifier.test(lang || "") ) { if ( !ridentifier.test(lang || "") ) {
2009 Sizzle.error( "unsupported lang: " + lang ); Sizzle.error( "unsupported lang: " + lang );
2010 } }
2011 lang = lang.replace( runescape, funescape ).toLowerCase(); lang = lang.replace( runescape, funescape ).toLowerCase();
2012 return function( elem ) { return function( elem ) {
2013 var elemLang; var elemLang;
2014 do { do {
2015 if ( (elemLang = documentIsHTML ? if ( (elemLang = documentIsHTML ?
2016 elem.lang : elem.lang :
2017 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
2018
2019 elemLang = elemLang.toLowerCase(); elemLang = elemLang.toLowerCase();
2020 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
2021 } }
2022 } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
2023 return false; return false;
2024 }; };
2025 }), }),
2026
2027 // Miscellaneous // Miscellaneous
2028 "target": function( elem ) { "target": function( elem ) {
2029 var hash = window.location && window.location.hash; var hash = window.location && window.location.hash;
2030 return hash && hash.slice( 1 ) === elem.id; return hash && hash.slice( 1 ) === elem.id;
2031 }, },
2032
2033 "root": function( elem ) { "root": function( elem ) {
2034 return elem === docElem; return elem === docElem;
2035 }, },
2036
2037 "focus": function( elem ) { "focus": function( elem ) {
2038 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
2039 }, },
2040
2041 // Boolean properties // Boolean properties
2042 "enabled": function( elem ) { "enabled": function( elem ) {
2043 return elem.disabled === false; return elem.disabled === false;
2044 }, },
2045
2046 "disabled": function( elem ) { "disabled": function( elem ) {
2047 return elem.disabled === true; return elem.disabled === true;
2048 }, },
2049
2050 "checked": function( elem ) { "checked": function( elem ) {
2051 // In CSS3, :checked should return both checked and selected elements // In CSS3, :checked should return both checked and selected elements
2052 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
2053 var nodeName = elem.nodeName.toLowerCase(); var nodeName = elem.nodeName.toLowerCase();
2054 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
2055 }, },
2056
2057 "selected": function( elem ) { "selected": function( elem ) {
2058 // Accessing this property makes selected-by-default // Accessing this property makes selected-by-default
2059 // options in Safari work properly // options in Safari work properly
2060 if ( elem.parentNode ) { if ( elem.parentNode ) {
2061 elem.parentNode.selectedIndex; elem.parentNode.selectedIndex;
2062 } }
2063
2064 return elem.selected === true; return elem.selected === true;
2065 }, },
2066
2067 // Contents // Contents
2068 "empty": function( elem ) { "empty": function( elem ) {
2069 // http://www.w3.org/TR/selectors/#empty-pseudo // http://www.w3.org/TR/selectors/#empty-pseudo
2070 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
2071 // but not by others (comment: 8; processing instruction: 7; etc.) // but not by others (comment: 8; processing instruction: 7; etc.)
2072 // nodeType < 6 works because attributes (2) do not appear as children // nodeType < 6 works because attributes (2) do not appear as children
2073 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
2074 if ( elem.nodeType < 6 ) { if ( elem.nodeType < 6 ) {
2075 return false; return false;
2076 } }
2077 } }
2078 return true; return true;
2079 }, },
2080
2081 "parent": function( elem ) { "parent": function( elem ) {
2082 return !Expr.pseudos["empty"]( elem ); return !Expr.pseudos["empty"]( elem );
2083 }, },
2084
2085 // Element/input types // Element/input types
2086 "header": function( elem ) { "header": function( elem ) {
2087 return rheader.test( elem.nodeName ); return rheader.test( elem.nodeName );
2088 }, },
2089
2090 "input": function( elem ) { "input": function( elem ) {
2091 return rinputs.test( elem.nodeName ); return rinputs.test( elem.nodeName );
2092 }, },
2093
2094 "button": function( elem ) { "button": function( elem ) {
2095 var name = elem.nodeName.toLowerCase(); var name = elem.nodeName.toLowerCase();
2096 return name === "input" && elem.type === "button" || name === "button"; return name === "input" && elem.type === "button" || name === "button";
2097 }, },
2098
2099 "text": function( elem ) { "text": function( elem ) {
2100 var attr; var attr;
2101 return elem.nodeName.toLowerCase() === "input" && return elem.nodeName.toLowerCase() === "input" &&
2102 elem.type === "text" && elem.type === "text" &&
2103
2104 // Support: IE<8 // Support: IE<8
2105 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
2106 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
2107 }, },
2108
2109 // Position-in-collection // Position-in-collection
2110 "first": createPositionalPseudo(function() { "first": createPositionalPseudo(function() {
2111 return [ 0 ]; return [ 0 ];
2112 }), }),
2113
2114 "last": createPositionalPseudo(function( matchIndexes, length ) { "last": createPositionalPseudo(function( matchIndexes, length ) {
2115 return [ length - 1 ]; return [ length - 1 ];
2116 }), }),
2117
2118 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
2119 return [ argument < 0 ? argument + length : argument ]; return [ argument < 0 ? argument + length : argument ];
2120 }), }),
2121
2122 "even": createPositionalPseudo(function( matchIndexes, length ) { "even": createPositionalPseudo(function( matchIndexes, length ) {
2123 var i = 0; var i = 0;
2124 for ( ; i < length; i += 2 ) { for ( ; i < length; i += 2 ) {
2125 matchIndexes.push( i ); matchIndexes.push( i );
2126 } }
2127 return matchIndexes; return matchIndexes;
2128 }), }),
2129
2130 "odd": createPositionalPseudo(function( matchIndexes, length ) { "odd": createPositionalPseudo(function( matchIndexes, length ) {
2131 var i = 1; var i = 1;
2132 for ( ; i < length; i += 2 ) { for ( ; i < length; i += 2 ) {
2133 matchIndexes.push( i ); matchIndexes.push( i );
2134 } }
2135 return matchIndexes; return matchIndexes;
2136 }), }),
2137
2138 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2139 var i = argument < 0 ? argument + length : argument; var i = argument < 0 ? argument + length : argument;
2140 for ( ; --i >= 0; ) { for ( ; --i >= 0; ) {
2141 matchIndexes.push( i ); matchIndexes.push( i );
2142 } }
2143 return matchIndexes; return matchIndexes;
2144 }), }),
2145
2146 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2147 var i = argument < 0 ? argument + length : argument; var i = argument < 0 ? argument + length : argument;
2148 for ( ; ++i < length; ) { for ( ; ++i < length; ) {
2149 matchIndexes.push( i ); matchIndexes.push( i );
2150 } }
2151 return matchIndexes; return matchIndexes;
2152 }) })
2153 } }
2154 }; };
2155
2156 Expr.pseudos["nth"] = Expr.pseudos["eq"]; Expr.pseudos["nth"] = Expr.pseudos["eq"];
2157
2158 // Add button/input type pseudos // Add button/input type pseudos
2159 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2160 Expr.pseudos[ i ] = createInputPseudo( i ); Expr.pseudos[ i ] = createInputPseudo( i );
2161 } }
2162 for ( i in { submit: true, reset: true } ) { for ( i in { submit: true, reset: true } ) {
2163 Expr.pseudos[ i ] = createButtonPseudo( i ); Expr.pseudos[ i ] = createButtonPseudo( i );
2164 } }
2165
2166 // Easy API for creating new setFilters // Easy API for creating new setFilters
2167 function setFilters() {} function setFilters() {}
2168 setFilters.prototype = Expr.filters = Expr.pseudos; setFilters.prototype = Expr.filters = Expr.pseudos;
2169 Expr.setFilters = new setFilters(); Expr.setFilters = new setFilters();
2170
2171 tokenize = Sizzle.tokenize = function( selector, parseOnly ) { tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
2172 var matched, match, tokens, type, var matched, match, tokens, type,
2173 soFar, groups, preFilters, soFar, groups, preFilters,
2174 cached = tokenCache[ selector + " " ]; cached = tokenCache[ selector + " " ];
2175
2176 if ( cached ) { if ( cached ) {
2177 return parseOnly ? 0 : cached.slice( 0 ); return parseOnly ? 0 : cached.slice( 0 );
2178 } }
2179
2180 soFar = selector; soFar = selector;
2181 groups = []; groups = [];
2182 preFilters = Expr.preFilter; preFilters = Expr.preFilter;
2183
2184 while ( soFar ) { while ( soFar ) {
2185
2186 // Comma and first run // Comma and first run
2187 if ( !matched || (match = rcomma.exec( soFar )) ) { if ( !matched || (match = rcomma.exec( soFar )) ) {
2188 if ( match ) { if ( match ) {
2189 // Don't consume trailing commas as valid // Don't consume trailing commas as valid
2190 soFar = soFar.slice( match[0].length ) || soFar; soFar = soFar.slice( match[0].length ) || soFar;
2191 } }
2192 groups.push( (tokens = []) ); groups.push( (tokens = []) );
2193 } }
2194
2195 matched = false; matched = false;
2196
2197 // Combinators // Combinators
2198 if ( (match = rcombinators.exec( soFar )) ) { if ( (match = rcombinators.exec( soFar )) ) {
2199 matched = match.shift(); matched = match.shift();
2200 tokens.push({ tokens.push({
2201 value: matched, value: matched,
2202 // Cast descendant combinators to space // Cast descendant combinators to space
2203 type: match[0].replace( rtrim, " " ) type: match[0].replace( rtrim, " " )
2204 }); });
2205 soFar = soFar.slice( matched.length ); soFar = soFar.slice( matched.length );
2206 } }
2207
2208 // Filters // Filters
2209 for ( type in Expr.filter ) { for ( type in Expr.filter ) {
2210 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2211 (match = preFilters[ type ]( match ))) ) { (match = preFilters[ type ]( match ))) ) {
2212 matched = match.shift(); matched = match.shift();
2213 tokens.push({ tokens.push({
2214 value: matched, value: matched,
2215 type: type, type: type,
2216 matches: match matches: match
2217 }); });
2218 soFar = soFar.slice( matched.length ); soFar = soFar.slice( matched.length );
2219 } }
2220 } }
2221
2222 if ( !matched ) { if ( !matched ) {
2223 break; break;
2224 } }
2225 } }
2226
2227 // Return the length of the invalid excess // Return the length of the invalid excess
2228 // if we're just parsing // if we're just parsing
2229 // Otherwise, throw an error or return tokens // Otherwise, throw an error or return tokens
2230 return parseOnly ? return parseOnly ?
2231 soFar.length : soFar.length :
2232 soFar ? soFar ?
2233 Sizzle.error( selector ) : Sizzle.error( selector ) :
2234 // Cache the tokens // Cache the tokens
2235 tokenCache( selector, groups ).slice( 0 ); tokenCache( selector, groups ).slice( 0 );
2236 }; };
2237
2238 function toSelector( tokens ) { function toSelector( tokens ) {
2239 var i = 0, var i = 0,
2240 len = tokens.length, len = tokens.length,
2241 selector = ""; selector = "";
2242 for ( ; i < len; i++ ) { for ( ; i < len; i++ ) {
2243 selector += tokens[i].value; selector += tokens[i].value;
2244 } }
2245 return selector; return selector;
2246 } }
2247
2248 function addCombinator( matcher, combinator, base ) { function addCombinator( matcher, combinator, base ) {
2249 var dir = combinator.dir, var dir = combinator.dir,
2250 checkNonElements = base && dir === "parentNode", checkNonElements = base && dir === "parentNode",
2251 doneName = done++; doneName = done++;
2252
2253 return combinator.first ? return combinator.first ?
2254 // Check against closest ancestor/preceding element // Check against closest ancestor/preceding element
2255 function( elem, context, xml ) { function( elem, context, xml ) {
2256 while ( (elem = elem[ dir ]) ) { while ( (elem = elem[ dir ]) ) {
2257 if ( elem.nodeType === 1 || checkNonElements ) { if ( elem.nodeType === 1 || checkNonElements ) {
2258 return matcher( elem, context, xml ); return matcher( elem, context, xml );
2259 } }
2260 } }
2261 } : } :
2262
2263 // Check against all ancestor/preceding elements // Check against all ancestor/preceding elements
2264 function( elem, context, xml ) { function( elem, context, xml ) {
2265 var oldCache, outerCache, var oldCache, uniqueCache, outerCache,
2266 newCache = [ dirruns, doneName ]; newCache = [ dirruns, doneName ];
2267
2268 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2269 if ( xml ) { if ( xml ) {
2270 while ( (elem = elem[ dir ]) ) { while ( (elem = elem[ dir ]) ) {
2271 if ( elem.nodeType === 1 || checkNonElements ) { if ( elem.nodeType === 1 || checkNonElements ) {
2272 if ( matcher( elem, context, xml ) ) { if ( matcher( elem, context, xml ) ) {
2273 return true; return true;
2274 } }
2275 } }
2276 } }
2277 } else { } else {
2278 while ( (elem = elem[ dir ]) ) { while ( (elem = elem[ dir ]) ) {
2279 if ( elem.nodeType === 1 || checkNonElements ) { if ( elem.nodeType === 1 || checkNonElements ) {
2280 outerCache = elem[ expando ] || (elem[ expando ] = {}); outerCache = elem[ expando ] || (elem[ expando ] = {});
2281 if ( (oldCache = outerCache[ dir ]) &&
2282 // Support: IE <9 only
2283 // Defend against cloned attroperties (jQuery gh-1709)
2284 uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
2285
2286 if ( (oldCache = uniqueCache[ dir ]) &&
2287 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2288
2289 // Assign to newCache so results back-propagate to previous elements // Assign to newCache so results back-propagate to previous elements
2290 return (newCache[ 2 ] = oldCache[ 2 ]); return (newCache[ 2 ] = oldCache[ 2 ]);
2291 } else { } else {
2292 // Reuse newcache so results back-propagate to previous elements // Reuse newcache so results back-propagate to previous elements
2293 outerCache[ dir ] = newCache; uniqueCache[ dir ] = newCache;
2294
2295 // A match means we're done; a fail means we have to keep checking // A match means we're done; a fail means we have to keep checking
2296 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2297 return true; return true;
2298 } }
2299 } }
2300 } }
2301 } }
2302 } }
2303 }; };
2304 } }
2305
2306 function elementMatcher( matchers ) { function elementMatcher( matchers ) {
2307 return matchers.length > 1 ? return matchers.length > 1 ?
2308 function( elem, context, xml ) { function( elem, context, xml ) {
2309 var i = matchers.length; var i = matchers.length;
2310 while ( i-- ) { while ( i-- ) {
2311 if ( !matchers[i]( elem, context, xml ) ) { if ( !matchers[i]( elem, context, xml ) ) {
2312 return false; return false;
2313 } }
2314 } }
2315 return true; return true;
2316 } : } :
2317 matchers[0]; matchers[0];
2318 } }
2319
2320 function multipleContexts( selector, contexts, results ) { function multipleContexts( selector, contexts, results ) {
2321 var i = 0, var i = 0,
2322 len = contexts.length; len = contexts.length;
2323 for ( ; i < len; i++ ) { for ( ; i < len; i++ ) {
2324 Sizzle( selector, contexts[i], results ); Sizzle( selector, contexts[i], results );
2325 } }
2326 return results; return results;
2327 } }
2328
2329 function condense( unmatched, map, filter, context, xml ) { function condense( unmatched, map, filter, context, xml ) {
2330 var elem, var elem,
2331 newUnmatched = [], newUnmatched = [],
2332 i = 0, i = 0,
2333 len = unmatched.length, len = unmatched.length,
2334 mapped = map != null; mapped = map != null;
2335
2336 for ( ; i < len; i++ ) { for ( ; i < len; i++ ) {
2337 if ( (elem = unmatched[i]) ) { if ( (elem = unmatched[i]) ) {
2338 if ( !filter || filter( elem, context, xml ) ) { if ( !filter || filter( elem, context, xml ) ) {
2339 newUnmatched.push( elem ); newUnmatched.push( elem );
2340 if ( mapped ) { if ( mapped ) {
2341 map.push( i ); map.push( i );
2342 } }
2343 } }
2344 } }
2345 } }
2346
2347 return newUnmatched; return newUnmatched;
2348 } }
2349
2350 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2351 if ( postFilter && !postFilter[ expando ] ) { if ( postFilter && !postFilter[ expando ] ) {
2352 postFilter = setMatcher( postFilter ); postFilter = setMatcher( postFilter );
2353 } }
2354 if ( postFinder && !postFinder[ expando ] ) { if ( postFinder && !postFinder[ expando ] ) {
2355 postFinder = setMatcher( postFinder, postSelector ); postFinder = setMatcher( postFinder, postSelector );
2356 } }
2357 return markFunction(function( seed, results, context, xml ) { return markFunction(function( seed, results, context, xml ) {
2358 var temp, i, elem, var temp, i, elem,
2359 preMap = [], preMap = [],
2360 postMap = [], postMap = [],
2361 preexisting = results.length, preexisting = results.length,
2362
2363 // Get initial elements from seed or context // Get initial elements from seed or context
2364 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2365
2366 // Prefilter to get matcher input, preserving a map for seed-results synchronization // Prefilter to get matcher input, preserving a map for seed-results synchronization
2367 matcherIn = preFilter && ( seed || !selector ) ? matcherIn = preFilter && ( seed || !selector ) ?
2368 condense( elems, preMap, preFilter, context, xml ) : condense( elems, preMap, preFilter, context, xml ) :
2369 elems, elems,
2370
2371 matcherOut = matcher ? matcherOut = matcher ?
2372 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2373 postFinder || ( seed ? preFilter : preexisting || postFilter ) ? postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2374
2375 // ...intermediate processing is necessary // ...intermediate processing is necessary
2376 [] : [] :
2377
2378 // ...otherwise use results directly // ...otherwise use results directly
2379 results : results :
2380 matcherIn; matcherIn;
2381
2382 // Find primary matches // Find primary matches
2383 if ( matcher ) { if ( matcher ) {
2384 matcher( matcherIn, matcherOut, context, xml ); matcher( matcherIn, matcherOut, context, xml );
2385 } }
2386
2387 // Apply postFilter // Apply postFilter
2388 if ( postFilter ) { if ( postFilter ) {
2389 temp = condense( matcherOut, postMap ); temp = condense( matcherOut, postMap );
2390 postFilter( temp, [], context, xml ); postFilter( temp, [], context, xml );
2391
2392 // Un-match failing elements by moving them back to matcherIn // Un-match failing elements by moving them back to matcherIn
2393 i = temp.length; i = temp.length;
2394 while ( i-- ) { while ( i-- ) {
2395 if ( (elem = temp[i]) ) { if ( (elem = temp[i]) ) {
2396 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2397 } }
2398 } }
2399 } }
2400
2401 if ( seed ) { if ( seed ) {
2402 if ( postFinder || preFilter ) { if ( postFinder || preFilter ) {
2403 if ( postFinder ) { if ( postFinder ) {
2404 // Get the final matcherOut by condensing this intermediate into postFinder contexts // Get the final matcherOut by condensing this intermediate into postFinder contexts
2405 temp = []; temp = [];
2406 i = matcherOut.length; i = matcherOut.length;
2407 while ( i-- ) { while ( i-- ) {
2408 if ( (elem = matcherOut[i]) ) { if ( (elem = matcherOut[i]) ) {
2409 // Restore matcherIn since elem is not yet a final match // Restore matcherIn since elem is not yet a final match
2410 temp.push( (matcherIn[i] = elem) ); temp.push( (matcherIn[i] = elem) );
2411 } }
2412 } }
2413 postFinder( null, (matcherOut = []), temp, xml ); postFinder( null, (matcherOut = []), temp, xml );
2414 } }
2415
2416 // Move matched elements from seed to results to keep them synchronized // Move matched elements from seed to results to keep them synchronized
2417 i = matcherOut.length; i = matcherOut.length;
2418 while ( i-- ) { while ( i-- ) {
2419 if ( (elem = matcherOut[i]) && if ( (elem = matcherOut[i]) &&
2420 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
2421
2422 seed[temp] = !(results[temp] = elem); seed[temp] = !(results[temp] = elem);
2423 } }
2424 } }
2425 } }
2426
2427 // Add elements to results, through postFinder if defined // Add elements to results, through postFinder if defined
2428 } else { } else {
2429 matcherOut = condense( matcherOut = condense(
2430 matcherOut === results ? matcherOut === results ?
2431 matcherOut.splice( preexisting, matcherOut.length ) : matcherOut.splice( preexisting, matcherOut.length ) :
2432 matcherOut matcherOut
2433 ); );
2434 if ( postFinder ) { if ( postFinder ) {
2435 postFinder( null, results, matcherOut, xml ); postFinder( null, results, matcherOut, xml );
2436 } else { } else {
2437 push.apply( results, matcherOut ); push.apply( results, matcherOut );
2438 } }
2439 } }
2440 }); });
2441 } }
2442
2443 function matcherFromTokens( tokens ) { function matcherFromTokens( tokens ) {
2444 var checkContext, matcher, j, var checkContext, matcher, j,
2445 len = tokens.length, len = tokens.length,
2446 leadingRelative = Expr.relative[ tokens[0].type ], leadingRelative = Expr.relative[ tokens[0].type ],
2447 implicitRelative = leadingRelative || Expr.relative[" "], implicitRelative = leadingRelative || Expr.relative[" "],
2448 i = leadingRelative ? 1 : 0, i = leadingRelative ? 1 : 0,
2449
2450 // The foundational matcher ensures that elements are reachable from top-level context(s) // The foundational matcher ensures that elements are reachable from top-level context(s)
2451 matchContext = addCombinator( function( elem ) { matchContext = addCombinator( function( elem ) {
2452 return elem === checkContext; return elem === checkContext;
2453 }, implicitRelative, true ), }, implicitRelative, true ),
2454 matchAnyContext = addCombinator( function( elem ) { matchAnyContext = addCombinator( function( elem ) {
2455 return indexOf( checkContext, elem ) > -1; return indexOf( checkContext, elem ) > -1;
2456 }, implicitRelative, true ), }, implicitRelative, true ),
2457 matchers = [ function( elem, context, xml ) { matchers = [ function( elem, context, xml ) {
2458 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2459 (checkContext = context).nodeType ? (checkContext = context).nodeType ?
2460 matchContext( elem, context, xml ) : matchContext( elem, context, xml ) :
2461 matchAnyContext( elem, context, xml ) ); matchAnyContext( elem, context, xml ) );
2462 // Avoid hanging onto element (issue #299) // Avoid hanging onto element (issue #299)
2463 checkContext = null; checkContext = null;
2464 return ret; return ret;
2465 } ]; } ];
2466
2467 for ( ; i < len; i++ ) { for ( ; i < len; i++ ) {
2468 if ( (matcher = Expr.relative[ tokens[i].type ]) ) { if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2469 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2470 } else { } else {
2471 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2472
2473 // Return special upon seeing a positional matcher // Return special upon seeing a positional matcher
2474 if ( matcher[ expando ] ) { if ( matcher[ expando ] ) {
2475 // Find the next relative operator (if any) for proper handling // Find the next relative operator (if any) for proper handling
2476 j = ++i; j = ++i;
2477 for ( ; j < len; j++ ) { for ( ; j < len; j++ ) {
2478 if ( Expr.relative[ tokens[j].type ] ) { if ( Expr.relative[ tokens[j].type ] ) {
2479 break; break;
2480 } }
2481 } }
2482 return setMatcher( return setMatcher(
2483 i > 1 && elementMatcher( matchers ), i > 1 && elementMatcher( matchers ),
2484 i > 1 && toSelector( i > 1 && toSelector(
2485 // If the preceding token was a descendant combinator, insert an implicit any-element `*` // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2486 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2487 ).replace( rtrim, "$1" ), ).replace( rtrim, "$1" ),
2488 matcher, matcher,
2489 i < j && matcherFromTokens( tokens.slice( i, j ) ), i < j && matcherFromTokens( tokens.slice( i, j ) ),
2490 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2491 j < len && toSelector( tokens ) j < len && toSelector( tokens )
2492 ); );
2493 } }
2494 matchers.push( matcher ); matchers.push( matcher );
2495 } }
2496 } }
2497
2498 return elementMatcher( matchers ); return elementMatcher( matchers );
2499 } }
2500
2501 function matcherFromGroupMatchers( elementMatchers, setMatchers ) { function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2502 var bySet = setMatchers.length > 0, var bySet = setMatchers.length > 0,
2503 byElement = elementMatchers.length > 0, byElement = elementMatchers.length > 0,
2504 superMatcher = function( seed, context, xml, results, outermost ) { superMatcher = function( seed, context, xml, results, outermost ) {
2505 var elem, j, matcher, var elem, j, matcher,
2506 matchedCount = 0, matchedCount = 0,
2507 i = "0", i = "0",
2508 unmatched = seed && [], unmatched = seed && [],
2509 setMatched = [], setMatched = [],
2510 contextBackup = outermostContext, contextBackup = outermostContext,
2511 // We must always have either seed elements or outermost context // We must always have either seed elements or outermost context
2512 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2513 // Use integer dirruns iff this is the outermost matcher // Use integer dirruns iff this is the outermost matcher
2514 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2515 len = elems.length; len = elems.length;
2516
2517 if ( outermost ) { if ( outermost ) {
2518 outermostContext = context !== document && context; outermostContext = context === document || context || outermost;
2519 } }
2520
2521 // Add elements passing elementMatchers directly to results // Add elements passing elementMatchers directly to results
2522 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2523 // Support: IE<9, Safari // Support: IE<9, Safari
2524 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2525 for ( ; i !== len && (elem = elems[i]) != null; i++ ) { for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2526 if ( byElement && elem ) { if ( byElement && elem ) {
2527 j = 0; j = 0;
2528 if ( !context && elem.ownerDocument !== document ) {
2529 setDocument( elem );
2530 xml = !documentIsHTML;
2531 }
2532 while ( (matcher = elementMatchers[j++]) ) { while ( (matcher = elementMatchers[j++]) ) {
2533 if ( matcher( elem, context, xml ) ) { if ( matcher( elem, context || document, xml) ) {
2534 results.push( elem ); results.push( elem );
2535 break; break;
2536 } }
2537 } }
2538 if ( outermost ) { if ( outermost ) {
2539 dirruns = dirrunsUnique; dirruns = dirrunsUnique;
2540 } }
2541 } }
2542
2543 // Track unmatched elements for set filters // Track unmatched elements for set filters
2544 if ( bySet ) { if ( bySet ) {
2545 // They will have gone through all possible matchers // They will have gone through all possible matchers
2546 if ( (elem = !matcher && elem) ) { if ( (elem = !matcher && elem) ) {
2547 matchedCount--; matchedCount--;
2548 } }
2549
2550 // Lengthen the array for every element, matched or not // Lengthen the array for every element, matched or not
2551 if ( seed ) { if ( seed ) {
2552 unmatched.push( elem ); unmatched.push( elem );
2553 } }
2554 } }
2555 } }
2556
2557 // Apply set filters to unmatched elements // `i` is now the count of elements visited above, and adding it to `matchedCount`
2558 // makes the latter nonnegative.
2559 matchedCount += i; matchedCount += i;
2560
2561 // Apply set filters to unmatched elements
2562 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2563 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2564 // no element matchers and no seed.
2565 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2566 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2567 // numerically zero.
2568 if ( bySet && i !== matchedCount ) { if ( bySet && i !== matchedCount ) {
2569 j = 0; j = 0;
2570 while ( (matcher = setMatchers[j++]) ) { while ( (matcher = setMatchers[j++]) ) {
2571 matcher( unmatched, setMatched, context, xml ); matcher( unmatched, setMatched, context, xml );
2572 } }
2573
2574 if ( seed ) { if ( seed ) {
2575 // Reintegrate element matches to eliminate the need for sorting // Reintegrate element matches to eliminate the need for sorting
2576 if ( matchedCount > 0 ) { if ( matchedCount > 0 ) {
2577 while ( i-- ) { while ( i-- ) {
2578 if ( !(unmatched[i] || setMatched[i]) ) { if ( !(unmatched[i] || setMatched[i]) ) {
2579 setMatched[i] = pop.call( results ); setMatched[i] = pop.call( results );
2580 } }
2581 } }
2582 } }
2583
2584 // Discard index placeholder values to get only actual matches // Discard index placeholder values to get only actual matches
2585 setMatched = condense( setMatched ); setMatched = condense( setMatched );
2586 } }
2587
2588 // Add matches to results // Add matches to results
2589 push.apply( results, setMatched ); push.apply( results, setMatched );
2590
2591 // Seedless set matches succeeding multiple successful matchers stipulate sorting // Seedless set matches succeeding multiple successful matchers stipulate sorting
2592 if ( outermost && !seed && setMatched.length > 0 && if ( outermost && !seed && setMatched.length > 0 &&
2593 ( matchedCount + setMatchers.length ) > 1 ) { ( matchedCount + setMatchers.length ) > 1 ) {
2594
2595 Sizzle.uniqueSort( results ); Sizzle.uniqueSort( results );
2596 } }
2597 } }
2598
2599 // Override manipulation of globals by nested matchers // Override manipulation of globals by nested matchers
2600 if ( outermost ) { if ( outermost ) {
2601 dirruns = dirrunsUnique; dirruns = dirrunsUnique;
2602 outermostContext = contextBackup; outermostContext = contextBackup;
2603 } }
2604
2605 return unmatched; return unmatched;
2606 }; };
2607
2608 return bySet ? return bySet ?
2609 markFunction( superMatcher ) : markFunction( superMatcher ) :
2610 superMatcher; superMatcher;
2611 } }
2612
2613 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2614 var i, var i,
2615 setMatchers = [], setMatchers = [],
2616 elementMatchers = [], elementMatchers = [],
2617 cached = compilerCache[ selector + " " ]; cached = compilerCache[ selector + " " ];
2618
2619 if ( !cached ) { if ( !cached ) {
2620 // Generate a function of recursive functions that can be used to check each element // Generate a function of recursive functions that can be used to check each element
2621 if ( !match ) { if ( !match ) {
2622 match = tokenize( selector ); match = tokenize( selector );
2623 } }
2624 i = match.length; i = match.length;
2625 while ( i-- ) { while ( i-- ) {
2626 cached = matcherFromTokens( match[i] ); cached = matcherFromTokens( match[i] );
2627 if ( cached[ expando ] ) { if ( cached[ expando ] ) {
2628 setMatchers.push( cached ); setMatchers.push( cached );
2629 } else { } else {
2630 elementMatchers.push( cached ); elementMatchers.push( cached );
2631 } }
2632 } }
2633
2634 // Cache the compiled function // Cache the compiled function
2635 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2636
2637 // Save selector and tokenization // Save selector and tokenization
2638 cached.selector = selector; cached.selector = selector;
2639 } }
2640 return cached; return cached;
2641 }; };
2642
2643 /** /**
2644 * A low-level selection function that works with Sizzle's compiled * A low-level selection function that works with Sizzle's compiled
2645 * selector functions * selector functions
2646 * @param {String|Function} selector A selector or a pre-compiled * @param {String|Function} selector A selector or a pre-compiled
2647 * selector function built with Sizzle.compile * selector function built with Sizzle.compile
2648 * @param {Element} context * @param {Element} context
2649 * @param {Array} [results] * @param {Array} [results]
2650 * @param {Array} [seed] A set of elements to match against * @param {Array} [seed] A set of elements to match against
2651 */ */
2652 select = Sizzle.select = function( selector, context, results, seed ) { select = Sizzle.select = function( selector, context, results, seed ) {
2653 var i, tokens, token, type, find, var i, tokens, token, type, find,
2654 compiled = typeof selector === "function" && selector, compiled = typeof selector === "function" && selector,
2655 match = !seed && tokenize( (selector = compiled.selector || selector) ); match = !seed && tokenize( (selector = compiled.selector || selector) );
2656
2657 results = results || []; results = results || [];
2658
2659 // Try to minimize operations if there is no seed and only one group // Try to minimize operations if there is only one selector in the list and no seed
2660 // (the latter of which guarantees us context)
2661 if ( match.length === 1 ) { if ( match.length === 1 ) {
2662
2663 // Take a shortcut and set the context if the root selector is an ID // Reduce context if the leading compound selector is an ID
2664 tokens = match[0] = match[0].slice( 0 ); tokens = match[0] = match[0].slice( 0 );
2665 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2666 support.getById && context.nodeType === 9 && documentIsHTML && support.getById && context.nodeType === 9 && documentIsHTML &&
2667 Expr.relative[ tokens[1].type ] ) { Expr.relative[ tokens[1].type ] ) {
2668
2669 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2670 if ( !context ) { if ( !context ) {
2671 return results; return results;
2672
2673 // Precompiled matchers will still verify ancestry, so step up a level // Precompiled matchers will still verify ancestry, so step up a level
2674 } else if ( compiled ) { } else if ( compiled ) {
2675 context = context.parentNode; context = context.parentNode;
2676 } }
2677
2678 selector = selector.slice( tokens.shift().value.length ); selector = selector.slice( tokens.shift().value.length );
2679 } }
2680
2681 // Fetch a seed set for right-to-left matching // Fetch a seed set for right-to-left matching
2682 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2683 while ( i-- ) { while ( i-- ) {
2684 token = tokens[i]; token = tokens[i];
2685
2686 // Abort if we hit a combinator // Abort if we hit a combinator
2687 if ( Expr.relative[ (type = token.type) ] ) { if ( Expr.relative[ (type = token.type) ] ) {
2688 break; break;
2689 } }
2690 if ( (find = Expr.find[ type ]) ) { if ( (find = Expr.find[ type ]) ) {
2691 // Search, expanding context for leading sibling combinators // Search, expanding context for leading sibling combinators
2692 if ( (seed = find( if ( (seed = find(
2693 token.matches[0].replace( runescape, funescape ), token.matches[0].replace( runescape, funescape ),
2694 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2695 )) ) { )) ) {
2696
2697 // If seed is empty or no tokens remain, we can return early // If seed is empty or no tokens remain, we can return early
2698 tokens.splice( i, 1 ); tokens.splice( i, 1 );
2699 selector = seed.length && toSelector( tokens ); selector = seed.length && toSelector( tokens );
2700 if ( !selector ) { if ( !selector ) {
2701 push.apply( results, seed ); push.apply( results, seed );
2702 return results; return results;
2703 } }
2704
2705 break; break;
2706 } }
2707 } }
2708 } }
2709 } }
2710
2711 // Compile and execute a filtering function if one is not provided // Compile and execute a filtering function if one is not provided
2712 // Provide `match` to avoid retokenization if we modified the selector above // Provide `match` to avoid retokenization if we modified the selector above
2713 ( compiled || compile( selector, match ) )( ( compiled || compile( selector, match ) )(
2714 seed, seed,
2715 context, context,
2716 !documentIsHTML, !documentIsHTML,
2717 results, results,
2718 rsibling.test( selector ) && testContext( context.parentNode ) || context !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
2719 ); );
2720 return results; return results;
2721 }; };
2722
2723 // One-time assignments // One-time assignments
2724
2725 // Sort stability // Sort stability
2726 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2727
2728 // Support: Chrome 14-35+ // Support: Chrome 14-35+
2729 // Always assume duplicates if they aren't passed to the comparison function // Always assume duplicates if they aren't passed to the comparison function
2730 support.detectDuplicates = !!hasDuplicate; support.detectDuplicates = !!hasDuplicate;
2731
2732 // Initialize against the default document // Initialize against the default document
2733 setDocument(); setDocument();
2734
2735 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2736 // Detached nodes confoundingly follow *each other* // Detached nodes confoundingly follow *each other*
2737 support.sortDetached = assert(function( div1 ) { support.sortDetached = assert(function( div1 ) {
2738 // Should return 1, but returns 4 (following) // Should return 1, but returns 4 (following)
2739 return div1.compareDocumentPosition( document.createElement("div") ) & 1; return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2740 }); });
2741
2742 // Support: IE<8 // Support: IE<8
2743 // Prevent attribute/property "interpolation" // Prevent attribute/property "interpolation"
2744 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2745 if ( !assert(function( div ) { if ( !assert(function( div ) {
2746 div.innerHTML = "<a href='#'></a>"; div.innerHTML = "<a href='#'></a>";
2747 return div.firstChild.getAttribute("href") === "#" ; return div.firstChild.getAttribute("href") === "#" ;
2748 }) ) { }) ) {
2749 addHandle( "type|href|height|width", function( elem, name, isXML ) { addHandle( "type|href|height|width", function( elem, name, isXML ) {
2750 if ( !isXML ) { if ( !isXML ) {
2751 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2752 } }
2753 }); });
2754 } }
2755
2756 // Support: IE<9 // Support: IE<9
2757 // Use defaultValue in place of getAttribute("value") // Use defaultValue in place of getAttribute("value")
2758 if ( !support.attributes || !assert(function( div ) { if ( !support.attributes || !assert(function( div ) {
2759 div.innerHTML = "<input/>"; div.innerHTML = "<input/>";
2760 div.firstChild.setAttribute( "value", "" ); div.firstChild.setAttribute( "value", "" );
2761 return div.firstChild.getAttribute( "value" ) === ""; return div.firstChild.getAttribute( "value" ) === "";
2762 }) ) { }) ) {
2763 addHandle( "value", function( elem, name, isXML ) { addHandle( "value", function( elem, name, isXML ) {
2764 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2765 return elem.defaultValue; return elem.defaultValue;
2766 } }
2767 }); });
2768 } }
2769
2770 // Support: IE<9 // Support: IE<9
2771 // Use getAttributeNode to fetch booleans when getAttribute lies // Use getAttributeNode to fetch booleans when getAttribute lies
2772 if ( !assert(function( div ) { if ( !assert(function( div ) {
2773 return div.getAttribute("disabled") == null; return div.getAttribute("disabled") == null;
2774 }) ) { }) ) {
2775 addHandle( booleans, function( elem, name, isXML ) { addHandle( booleans, function( elem, name, isXML ) {
2776 var val; var val;
2777 if ( !isXML ) { if ( !isXML ) {
2778 return elem[ name ] === true ? name.toLowerCase() : return elem[ name ] === true ? name.toLowerCase() :
2779 (val = elem.getAttributeNode( name )) && val.specified ? (val = elem.getAttributeNode( name )) && val.specified ?
2780 val.value : val.value :
2781 null; null;
2782 } }
2783 }); });
2784 } }
2785
2786 return Sizzle; return Sizzle;
2787
2788 })( window ); })( window );
2789
2790
2791
2792 jQuery.find = Sizzle; jQuery.find = Sizzle;
2793 jQuery.expr = Sizzle.selectors; jQuery.expr = Sizzle.selectors;
2794 jQuery.expr[":"] = jQuery.expr.pseudos; jQuery.expr[ ":" ] = jQuery.expr.pseudos;
2795 jQuery.unique = Sizzle.uniqueSort; jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
2796 jQuery.text = Sizzle.getText; jQuery.text = Sizzle.getText;
2797 jQuery.isXMLDoc = Sizzle.isXML; jQuery.isXMLDoc = Sizzle.isXML;
2798 jQuery.contains = Sizzle.contains; jQuery.contains = Sizzle.contains;
2799
2800
2801
2802 var dir = function( elem, dir, until ) {
2803 var matched = [],
2804 truncate = until !== undefined;
2805
2806 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
2807 if ( elem.nodeType === 1 ) {
2808 if ( truncate && jQuery( elem ).is( until ) ) {
2809 break;
2810 }
2811 matched.push( elem );
2812 }
2813 }
2814 return matched;
2815 };
2816
2817
2818 var siblings = function( n, elem ) {
2819 var matched = [];
2820
2821 for ( ; n; n = n.nextSibling ) {
2822 if ( n.nodeType === 1 && n !== elem ) {
2823 matched.push( n );
2824 }
2825 }
2826
2827 return matched;
2828 };
2829
2830
2831 var rneedsContext = jQuery.expr.match.needsContext; var rneedsContext = jQuery.expr.match.needsContext;
2832
2833 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
2834
2835
2836
2837 var risSimple = /^.[^:#\[\.,]*$/; var risSimple = /^.[^:#\[\.,]*$/;
2838
2839 // Implement the identical functionality for filter and not // Implement the identical functionality for filter and not
2840 function winnow( elements, qualifier, not ) { function winnow( elements, qualifier, not ) {
2841 if ( jQuery.isFunction( qualifier ) ) { if ( jQuery.isFunction( qualifier ) ) {
2842 return jQuery.grep( elements, function( elem, i ) { return jQuery.grep( elements, function( elem, i ) {
2843 /* jshint -W018 */ /* jshint -W018 */
2844 return !!qualifier.call( elem, i, elem ) !== not; return !!qualifier.call( elem, i, elem ) !== not;
2845 }); } );
2846
2847 } }
2848
2849 if ( qualifier.nodeType ) { if ( qualifier.nodeType ) {
2850 return jQuery.grep( elements, function( elem ) { return jQuery.grep( elements, function( elem ) {
2851 return ( elem === qualifier ) !== not; return ( elem === qualifier ) !== not;
2852 }); } );
2853
2854 } }
2855
2856 if ( typeof qualifier === "string" ) { if ( typeof qualifier === "string" ) {
2857 if ( risSimple.test( qualifier ) ) { if ( risSimple.test( qualifier ) ) {
2858 return jQuery.filter( qualifier, elements, not ); return jQuery.filter( qualifier, elements, not );
2859 } }
2860
2861 qualifier = jQuery.filter( qualifier, elements ); qualifier = jQuery.filter( qualifier, elements );
2862 } }
2863
2864 return jQuery.grep( elements, function( elem ) { return jQuery.grep( elements, function( elem ) {
2865 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not; return ( jQuery.inArray( elem, qualifier ) > -1 ) !== not;
2866 }); } );
2867 } }
2868
2869 jQuery.filter = function( expr, elems, not ) { jQuery.filter = function( expr, elems, not ) {
2870 var elem = elems[ 0 ]; var elem = elems[ 0 ];
2871
2872 if ( not ) { if ( not ) {
2873 expr = ":not(" + expr + ")"; expr = ":not(" + expr + ")";
2874 } }
2875
2876 return elems.length === 1 && elem.nodeType === 1 ? return elems.length === 1 && elem.nodeType === 1 ?
2877 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2878 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2879 return elem.nodeType === 1; return elem.nodeType === 1;
2880 })); } ) );
2881 }; };
2882
2883 jQuery.fn.extend({ jQuery.fn.extend( {
2884 find: function( selector ) { find: function( selector ) {
2885 var i, var i,
2886 ret = [], ret = [],
2887 self = this, self = this,
2888 len = self.length; len = self.length;
2889
2890 if ( typeof selector !== "string" ) { if ( typeof selector !== "string" ) {
2891 return this.pushStack( jQuery( selector ).filter(function() { return this.pushStack( jQuery( selector ).filter( function() {
2892 for ( i = 0; i < len; i++ ) { for ( i = 0; i < len; i++ ) {
2893 if ( jQuery.contains( self[ i ], this ) ) { if ( jQuery.contains( self[ i ], this ) ) {
2894 return true; return true;
2895 } }
2896 } }
2897 }) ); } ) );
2898 } }
2899
2900 for ( i = 0; i < len; i++ ) { for ( i = 0; i < len; i++ ) {
2901 jQuery.find( selector, self[ i ], ret ); jQuery.find( selector, self[ i ], ret );
2902 } }
2903
2904 // Needed because $( selector, context ) becomes $( context ).find( selector ) // Needed because $( selector, context ) becomes $( context ).find( selector )
2905 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
2906 ret.selector = this.selector ? this.selector + " " + selector : selector; ret.selector = this.selector ? this.selector + " " + selector : selector;
2907 return ret; return ret;
2908 }, },
2909 filter: function( selector ) { filter: function( selector ) {
2910 return this.pushStack( winnow(this, selector || [], false) ); return this.pushStack( winnow( this, selector || [], false ) );
2911 }, },
2912 not: function( selector ) { not: function( selector ) {
2913 return this.pushStack( winnow(this, selector || [], true) ); return this.pushStack( winnow( this, selector || [], true ) );
2914 }, },
2915 is: function( selector ) { is: function( selector ) {
2916 return !!winnow( return !!winnow(
2917 this, this,
2918
2919 // If this is a positional/relative selector, check membership in the returned set // If this is a positional/relative selector, check membership in the returned set
2920 // so $("p:first").is("p:last") won't return true for a doc with two "p". // so $("p:first").is("p:last") won't return true for a doc with two "p".
2921 typeof selector === "string" && rneedsContext.test( selector ) ? typeof selector === "string" && rneedsContext.test( selector ) ?
2922 jQuery( selector ) : jQuery( selector ) :
2923 selector || [], selector || [],
2924 false false
2925 ).length; ).length;
2926 } }
2927 }); } );
2928
2929
2930 // Initialize a jQuery object // Initialize a jQuery object
2931
2932
2933 // A central reference to the root jQuery(document) // A central reference to the root jQuery(document)
2934 var rootjQuery, var rootjQuery,
2935
2936 // Use the correct document accordingly with window argument (sandbox)
2937 document = window.document,
2938
2939 // A simple way to check for HTML strings // A simple way to check for HTML strings
2940 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2941 // Strict HTML recognition (#11290: must start with <) // Strict HTML recognition (#11290: must start with <)
2942 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2943
2944 init = jQuery.fn.init = function( selector, context ) { init = jQuery.fn.init = function( selector, context, root ) {
2945 var match, elem; var match, elem;
2946
2947 // HANDLE: $(""), $(null), $(undefined), $(false) // HANDLE: $(""), $(null), $(undefined), $(false)
2948 if ( !selector ) { if ( !selector ) {
2949 return this; return this;
2950 } }
2951
2952 // init accepts an alternate rootjQuery
2953 // so migrate can support jQuery.sub (gh-2101)
2954 root = root || rootjQuery;
2955
2956 // Handle HTML strings // Handle HTML strings
2957 if ( typeof selector === "string" ) { if ( typeof selector === "string" ) {
2958 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { if ( selector.charAt( 0 ) === "<" &&
2959 selector.charAt( selector.length - 1 ) === ">" &&
2960 selector.length >= 3 ) {
2961 // Assume that strings that start and end with <> are HTML and skip the regex check // Assume that strings that start and end with <> are HTML and skip the regex check
2962 match = [ null, selector, null ]; match = [ null, selector, null ];
2963
2964 } else { } else {
2965 match = rquickExpr.exec( selector ); match = rquickExpr.exec( selector );
2966 } }
2967
2968 // Match html or make sure no context is specified for #id // Match html or make sure no context is specified for #id
2969 if ( match && (match[1] || !context) ) { if ( match && ( match[ 1 ] || !context ) ) {
2970
2971 // HANDLE: $(html) -> $(array) // HANDLE: $(html) -> $(array)
2972 if ( match[1] ) { if ( match[ 1 ] ) {
2973 context = context instanceof jQuery ? context[0] : context; context = context instanceof jQuery ? context[ 0 ] : context;
2974
2975 // scripts is true for back-compat // scripts is true for back-compat
2976 // Intentionally let the error be thrown if parseHTML is not present // Intentionally let the error be thrown if parseHTML is not present
2977 jQuery.merge( this, jQuery.parseHTML( jQuery.merge( this, jQuery.parseHTML(
2978 match[1], match[ 1 ],
2979 context && context.nodeType ? context.ownerDocument || context : document, context && context.nodeType ? context.ownerDocument || context : document,
2980 true true
2981 ) ); ) );
2982
2983 // HANDLE: $(html, props) // HANDLE: $(html, props)
2984 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
2985 for ( match in context ) { for ( match in context ) {
2986
2987 // Properties of context are called as methods if possible // Properties of context are called as methods if possible
2988 if ( jQuery.isFunction( this[ match ] ) ) { if ( jQuery.isFunction( this[ match ] ) ) {
2989 this[ match ]( context[ match ] ); this[ match ]( context[ match ] );
2990
2991 // ...and otherwise set as attributes // ...and otherwise set as attributes
2992 } else { } else {
2993 this.attr( match, context[ match ] ); this.attr( match, context[ match ] );
2994 } }
2995 } }
2996 } }
2997
2998 return this; return this;
2999
3000 // HANDLE: $(#id) // HANDLE: $(#id)
3001 } else { } else {
3002 elem = document.getElementById( match[2] ); elem = document.getElementById( match[ 2 ] );
3003
3004 // Check parentNode to catch when Blackberry 4.6 returns // Check parentNode to catch when Blackberry 4.6 returns
3005 // nodes that are no longer in the document #6963 // nodes that are no longer in the document #6963
3006 if ( elem && elem.parentNode ) { if ( elem && elem.parentNode ) {
3007
3008 // Handle the case where IE and Opera return items // Handle the case where IE and Opera return items
3009 // by name instead of ID // by name instead of ID
3010 if ( elem.id !== match[2] ) { if ( elem.id !== match[ 2 ] ) {
3011 return rootjQuery.find( selector ); return rootjQuery.find( selector );
3012 } }
3013
3014 // Otherwise, we inject the element directly into the jQuery object // Otherwise, we inject the element directly into the jQuery object
3015 this.length = 1; this.length = 1;
3016 this[0] = elem; this[ 0 ] = elem;
3017 } }
3018
3019 this.context = document; this.context = document;
3020 this.selector = selector; this.selector = selector;
3021 return this; return this;
3022 } }
3023
3024 // HANDLE: $(expr, $(...)) // HANDLE: $(expr, $(...))
3025 } else if ( !context || context.jquery ) { } else if ( !context || context.jquery ) {
3026 return ( context || rootjQuery ).find( selector ); return ( context || root ).find( selector );
3027
3028 // HANDLE: $(expr, context) // HANDLE: $(expr, context)
3029 // (which is just equivalent to: $(context).find(expr) // (which is just equivalent to: $(context).find(expr)
3030 } else { } else {
3031 return this.constructor( context ).find( selector ); return this.constructor( context ).find( selector );
3032 } }
3033
3034 // HANDLE: $(DOMElement) // HANDLE: $(DOMElement)
3035 } else if ( selector.nodeType ) { } else if ( selector.nodeType ) {
3036 this.context = this[0] = selector; this.context = this[ 0 ] = selector;
3037 this.length = 1; this.length = 1;
3038 return this; return this;
3039
3040 // HANDLE: $(function) // HANDLE: $(function)
3041 // Shortcut for document ready // Shortcut for document ready
3042 } else if ( jQuery.isFunction( selector ) ) { } else if ( jQuery.isFunction( selector ) ) {
3043 return typeof rootjQuery.ready !== "undefined" ? return typeof root.ready !== "undefined" ?
3044 rootjQuery.ready( selector ) : root.ready( selector ) :
3045 // Execute immediately if ready is not present // Execute immediately if ready is not present
3046 selector( jQuery ); selector( jQuery );
3047 } }
3048
3049 if ( selector.selector !== undefined ) { if ( selector.selector !== undefined ) {
3050 this.selector = selector.selector; this.selector = selector.selector;
3051 this.context = selector.context; this.context = selector.context;
3052 } }
3053
3054 return jQuery.makeArray( selector, this ); return jQuery.makeArray( selector, this );
3055 }; };
3056
3057 // Give the init function the jQuery prototype for later instantiation // Give the init function the jQuery prototype for later instantiation
3058 init.prototype = jQuery.fn; init.prototype = jQuery.fn;
3059
3060 // Initialize central reference // Initialize central reference
3061 rootjQuery = jQuery( document ); rootjQuery = jQuery( document );
3062
3063
3064 var rparentsprev = /^(?:parents|prev(?:Until|All))/, var rparentsprev = /^(?:parents|prev(?:Until|All))/,
3065
3066 // methods guaranteed to produce a unique set when starting from a unique set // methods guaranteed to produce a unique set when starting from a unique set
3067 guaranteedUnique = { guaranteedUnique = {
3068 children: true, children: true,
3069 contents: true, contents: true,
3070 next: true, next: true,
3071 prev: true prev: true
3072 }; };
3073
3074 jQuery.extend({ jQuery.fn.extend( {
3075 dir: function( elem, dir, until ) {
3076 var matched = [],
3077 cur = elem[ dir ];
3078
3079 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
3080 if ( cur.nodeType === 1 ) {
3081 matched.push( cur );
3082 }
3083 cur = cur[dir];
3084 }
3085 return matched;
3086 },
3087
3088 sibling: function( n, elem ) {
3089 var r = [];
3090
3091 for ( ; n; n = n.nextSibling ) {
3092 if ( n.nodeType === 1 && n !== elem ) {
3093 r.push( n );
3094 }
3095 }
3096
3097 return r;
3098 }
3099 });
3100
3101 jQuery.fn.extend({
3102 has: function( target ) { has: function( target ) {
3103 var i, var i,
3104 targets = jQuery( target, this ), targets = jQuery( target, this ),
3105 len = targets.length; len = targets.length;
3106
3107 return this.filter(function() { return this.filter( function() {
3108 for ( i = 0; i < len; i++ ) { for ( i = 0; i < len; i++ ) {
3109 if ( jQuery.contains( this, targets[i] ) ) { if ( jQuery.contains( this, targets[ i ] ) ) {
3110 return true; return true;
3111 } }
3112 } }
3113 }); } );
3114 }, },
3115
3116 closest: function( selectors, context ) { closest: function( selectors, context ) {
3117 var cur, var cur,
3118 i = 0, i = 0,
3119 l = this.length, l = this.length,
3120 matched = [], matched = [],
3121 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
3122 jQuery( selectors, context || this.context ) : jQuery( selectors, context || this.context ) :
3123 0; 0;
3124
3125 for ( ; i < l; i++ ) { for ( ; i < l; i++ ) {
3126 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
3127 // Always skip document fragments // Always skip document fragments
3128 if ( cur.nodeType < 11 && (pos ? if ( cur.nodeType < 11 && ( pos ?
3129 pos.index(cur) > -1 : pos.index( cur ) > -1 :
3130
3131 // Don't pass non-elements to Sizzle // Don't pass non-elements to Sizzle
3132 cur.nodeType === 1 && cur.nodeType === 1 &&
3133 jQuery.find.matchesSelector(cur, selectors)) ) { jQuery.find.matchesSelector( cur, selectors ) ) ) {
3134
3135 matched.push( cur ); matched.push( cur );
3136 break; break;
3137 } }
3138 } }
3139 } }
3140
3141 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
3142 }, },
3143
3144 // Determine the position of an element within // Determine the position of an element within
3145 // the matched set of elements // the matched set of elements
3146 index: function( elem ) { index: function( elem ) {
3147
3148 // No argument, return index in parent // No argument, return index in parent
3149 if ( !elem ) { if ( !elem ) {
3150 return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1; return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
3151 } }
3152
3153 // index in selector // index in selector
3154 if ( typeof elem === "string" ) { if ( typeof elem === "string" ) {
3155 return jQuery.inArray( this[0], jQuery( elem ) ); return jQuery.inArray( this[ 0 ], jQuery( elem ) );
3156 } }
3157
3158 // Locate the position of the desired element // Locate the position of the desired element
3159 return jQuery.inArray( return jQuery.inArray(
3160
3161 // If it receives a jQuery object, the first element is used // If it receives a jQuery object, the first element is used
3162 elem.jquery ? elem[0] : elem, this ); elem.jquery ? elem[ 0 ] : elem, this );
3163 }, },
3164
3165 add: function( selector, context ) { add: function( selector, context ) {
3166 return this.pushStack( return this.pushStack(
3167 jQuery.unique( jQuery.uniqueSort(
3168 jQuery.merge( this.get(), jQuery( selector, context ) ) jQuery.merge( this.get(), jQuery( selector, context ) )
3169 ) )
3170 ); );
3171 }, },
3172
3173 addBack: function( selector ) { addBack: function( selector ) {
3174 return this.add( selector == null ? return this.add( selector == null ?
3175 this.prevObject : this.prevObject.filter(selector) this.prevObject : this.prevObject.filter( selector )
3176 ); );
3177 } }
3178 }); } );
3179
3180 function sibling( cur, dir ) { function sibling( cur, dir ) {
3181 do { do {
3182 cur = cur[ dir ]; cur = cur[ dir ];
3183 } while ( cur && cur.nodeType !== 1 ); } while ( cur && cur.nodeType !== 1 );
3184
3185 return cur; return cur;
3186 } }
3187
3188 jQuery.each({ jQuery.each( {
3189 parent: function( elem ) { parent: function( elem ) {
3190 var parent = elem.parentNode; var parent = elem.parentNode;
3191 return parent && parent.nodeType !== 11 ? parent : null; return parent && parent.nodeType !== 11 ? parent : null;
3192 }, },
3193 parents: function( elem ) { parents: function( elem ) {
3194 return jQuery.dir( elem, "parentNode" ); return dir( elem, "parentNode" );
3195 }, },
3196 parentsUntil: function( elem, i, until ) { parentsUntil: function( elem, i, until ) {
3197 return jQuery.dir( elem, "parentNode", until ); return dir( elem, "parentNode", until );
3198 }, },
3199 next: function( elem ) { next: function( elem ) {
3200 return sibling( elem, "nextSibling" ); return sibling( elem, "nextSibling" );
3201 }, },
3202 prev: function( elem ) { prev: function( elem ) {
3203 return sibling( elem, "previousSibling" ); return sibling( elem, "previousSibling" );
3204 }, },
3205 nextAll: function( elem ) { nextAll: function( elem ) {
3206 return jQuery.dir( elem, "nextSibling" ); return dir( elem, "nextSibling" );
3207 }, },
3208 prevAll: function( elem ) { prevAll: function( elem ) {
3209 return jQuery.dir( elem, "previousSibling" ); return dir( elem, "previousSibling" );
3210 }, },
3211 nextUntil: function( elem, i, until ) { nextUntil: function( elem, i, until ) {
3212 return jQuery.dir( elem, "nextSibling", until ); return dir( elem, "nextSibling", until );
3213 }, },
3214 prevUntil: function( elem, i, until ) { prevUntil: function( elem, i, until ) {
3215 return jQuery.dir( elem, "previousSibling", until ); return dir( elem, "previousSibling", until );
3216 }, },
3217 siblings: function( elem ) { siblings: function( elem ) {
3218 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); return siblings( ( elem.parentNode || {} ).firstChild, elem );
3219 }, },
3220 children: function( elem ) { children: function( elem ) {
3221 return jQuery.sibling( elem.firstChild ); return siblings( elem.firstChild );
3222 }, },
3223 contents: function( elem ) { contents: function( elem ) {
3224 return jQuery.nodeName( elem, "iframe" ) ? return jQuery.nodeName( elem, "iframe" ) ?
3225 elem.contentDocument || elem.contentWindow.document : elem.contentDocument || elem.contentWindow.document :
3226 jQuery.merge( [], elem.childNodes ); jQuery.merge( [], elem.childNodes );
3227 } }
3228 }, function( name, fn ) { }, function( name, fn ) {
3229 jQuery.fn[ name ] = function( until, selector ) { jQuery.fn[ name ] = function( until, selector ) {
3230 var ret = jQuery.map( this, fn, until ); var ret = jQuery.map( this, fn, until );
3231
3232 if ( name.slice( -5 ) !== "Until" ) { if ( name.slice( -5 ) !== "Until" ) {
3233 selector = until; selector = until;
3234 } }
3235
3236 if ( selector && typeof selector === "string" ) { if ( selector && typeof selector === "string" ) {
3237 ret = jQuery.filter( selector, ret ); ret = jQuery.filter( selector, ret );
3238 } }
3239
3240 if ( this.length > 1 ) { if ( this.length > 1 ) {
3241
3242 // Remove duplicates // Remove duplicates
3243 if ( !guaranteedUnique[ name ] ) { if ( !guaranteedUnique[ name ] ) {
3244 ret = jQuery.unique( ret ); ret = jQuery.uniqueSort( ret );
3245 } }
3246
3247 // Reverse order for parents* and prev-derivatives // Reverse order for parents* and prev-derivatives
3248 if ( rparentsprev.test( name ) ) { if ( rparentsprev.test( name ) ) {
3249 ret = ret.reverse(); ret = ret.reverse();
3250 } }
3251 } }
3252
3253 return this.pushStack( ret ); return this.pushStack( ret );
3254 }; };
3255 }); } );
3256 var rnotwhite = (/\S+/g); var rnotwhite = ( /\S+/g );
3257
3258
3259
3260 // String to Object options format cache // Convert String-formatted options into Object-formatted ones
3261 var optionsCache = {};
3262
3263 // Convert String-formatted options into Object-formatted ones and store in cache
3264 function createOptions( options ) { function createOptions( options ) {
3265 var object = optionsCache[ options ] = {}; var object = {};
3266 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
3267 object[ flag ] = true; object[ flag ] = true;
3268 }); } );
3269 return object; return object;
3270 } }
3271
3272 /* /*
3273 * Create a callback list using the following parameters: * Create a callback list using the following parameters:
3274 * *
3275 * options: an optional list of space-separated options that will change how * options: an optional list of space-separated options that will change how
3276 * the callback list behaves or a more traditional option object * the callback list behaves or a more traditional option object
3277 * *
3278 * By default a callback list will act like an event callback list and can be * By default a callback list will act like an event callback list and can be
3279 * "fired" multiple times. * "fired" multiple times.
3280 * *
3281 * Possible options: * Possible options:
3282 * *
3283 * once: will ensure the callback list can only be fired once (like a Deferred) * once: will ensure the callback list can only be fired once (like a Deferred)
3284 * *
3285 * memory: will keep track of previous values and will call any callback added * memory: will keep track of previous values and will call any callback added
3286 * after the list has been fired right away with the latest "memorized" * after the list has been fired right away with the latest "memorized"
3287 * values (like a Deferred) * values (like a Deferred)
3288 * *
3289 * unique: will ensure a callback can only be added once (no duplicate in the list) * unique: will ensure a callback can only be added once (no duplicate in the list)
3290 * *
3291 * stopOnFalse: interrupt callings when a callback returns false * stopOnFalse: interrupt callings when a callback returns false
3292 * *
3293 */ */
3294 jQuery.Callbacks = function( options ) { jQuery.Callbacks = function( options ) {
3295
3296 // Convert options from String-formatted to Object-formatted if needed // Convert options from String-formatted to Object-formatted if needed
3297 // (we check in cache first) // (we check in cache first)
3298 options = typeof options === "string" ? options = typeof options === "string" ?
3299 ( optionsCache[ options ] || createOptions( options ) ) : createOptions( options ) :
3300 jQuery.extend( {}, options ); jQuery.extend( {}, options );
3301
3302 var // Flag to know if list is currently firing var // Flag to know if list is currently firing
3303 firing, firing,
3304 // Last fire value (for non-forgettable lists)
3305 // Last fire value for non-forgettable lists
3306 memory, memory,
3307
3308 // Flag to know if list was already fired // Flag to know if list was already fired
3309 fired, fired,
3310 // End of the loop when firing
3311 firingLength, // Flag to prevent firing
3312 // Index of currently firing callback (modified by remove if needed) locked,
3313 firingIndex,
3314 // First callback to fire (used internally by add and fireWith)
3315 firingStart,
3316 // Actual callback list // Actual callback list
3317 list = [], list = [],
3318 // Stack of fire calls for repeatable lists
3319 stack = !options.once && [], // Queue of execution data for repeatable lists
3320 queue = [],
3321
3322 // Index of currently firing callback (modified by add/remove as needed)
3323 firingIndex = -1,
3324 // Fire callbacks // Fire callbacks
3325 fire = function( data ) { fire = function() {
3326 memory = options.memory && data;
3327 fired = true; // Enforce single-firing
3328 firingIndex = firingStart || 0; locked = options.once;
3329 firingStart = 0;
3330 firingLength = list.length; // Execute callbacks for all pending executions,
3331 firing = true; // respecting firingIndex overrides and runtime changes
3332 for ( ; list && firingIndex < firingLength; firingIndex++ ) { fired = firing = true;
3333 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { for ( ; queue.length; firingIndex = -1 ) {
3334 memory = false; // To prevent further calls using add memory = queue.shift();
3335 break; while ( ++firingIndex < list.length ) {
3336
3337 // Run callback and check for early termination
3338 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
3339 options.stopOnFalse ) {
3340
3341 // Jump to end and forget the data so .add doesn't re-fire
3342 firingIndex = list.length;
3343 memory = false;
3344 }
3345 } }
3346 } }
3347
3348 // Forget the data if we're done with it
3349 if ( !options.memory ) {
3350 memory = false;
3351 }
3352
3353 firing = false; firing = false;
3354 if ( list ) {
3355 if ( stack ) { // Clean up if we're done firing for good
3356 if ( stack.length ) { if ( locked ) {
3357 fire( stack.shift() );
3358 } // Keep an empty list if we have data for future add calls
3359 } else if ( memory ) { if ( memory ) {
3360 list = []; list = [];
3361
3362 // Otherwise, this object is spent
3363 } else { } else {
3364 self.disable(); list = "";
3365 } }
3366 } }
3367 }, },
3368
3369 // Actual Callbacks object // Actual Callbacks object
3370 self = { self = {
3371
3372 // Add a callback or a collection of callbacks to the list // Add a callback or a collection of callbacks to the list
3373 add: function() { add: function() {
3374 if ( list ) { if ( list ) {
3375 // First, we save the current length
3376 var start = list.length; // If we have memory from a past run, we should fire after adding
3377 (function add( args ) { if ( memory && !firing ) {
3378 firingIndex = list.length - 1;
3379 queue.push( memory );
3380 }
3381
3382 ( function add( args ) {
3383 jQuery.each( args, function( _, arg ) { jQuery.each( args, function( _, arg ) {
3384 var type = jQuery.type( arg ); if ( jQuery.isFunction( arg ) ) {
3385 if ( type === "function" ) {
3386 if ( !options.unique || !self.has( arg ) ) { if ( !options.unique || !self.has( arg ) ) {
3387 list.push( arg ); list.push( arg );
3388 } }
3389 } else if ( arg && arg.length && type !== "string" ) { } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
3390 // Inspect recursively // Inspect recursively
3391 add( arg ); add( arg );
3392 } }
3393 }); } );
3394 })( arguments ); } )( arguments );
3395 // Do we need to add the callbacks to the
3396 // current firing batch? if ( memory && !firing ) {
3397 if ( firing ) { fire();
3398 firingLength = list.length;
3399 // With memory, if we're not firing then
3400 // we should call right away
3401 } else if ( memory ) {
3402 firingStart = start;
3403 fire( memory );
3404 } }
3405 } }
3406 return this; return this;
3407 }, },
3408
3409 // Remove a callback from the list // Remove a callback from the list
3410 remove: function() { remove: function() {
3411 if ( list ) { jQuery.each( arguments, function( _, arg ) {
3412 jQuery.each( arguments, function( _, arg ) { var index;
3413 var index; while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3414 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { list.splice( index, 1 );
3415 list.splice( index, 1 );
3416 // Handle firing indexes // Handle firing indexes
3417 if ( firing ) { if ( index <= firingIndex ) {
3418 if ( index <= firingLength ) { firingIndex--;
3419 firingLength--;
3420 }
3421 if ( index <= firingIndex ) {
3422 firingIndex--;
3423 }
3424 }
3425 } }
3426 }); }
3427 } } );
3428 return this; return this;
3429 }, },
3430
3431 // Check if a given callback is in the list. // Check if a given callback is in the list.
3432 // If no argument is given, return whether or not list has callbacks attached. // If no argument is given, return whether or not list has callbacks attached.
3433 has: function( fn ) { has: function( fn ) {
3434 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); return fn ?
3435 jQuery.inArray( fn, list ) > -1 :
3436 list.length > 0;
3437 }, },
3438
3439 // Remove all callbacks from the list // Remove all callbacks from the list
3440 empty: function() { empty: function() {
3441 list = []; if ( list ) {
3442 firingLength = 0; list = [];
3443 }
3444 return this; return this;
3445 }, },
3446 // Have the list do nothing anymore
3447 // Disable .fire and .add
3448 // Abort any current/pending executions
3449 // Clear all callbacks and values
3450 disable: function() { disable: function() {
3451 list = stack = memory = undefined; locked = queue = [];
3452 list = memory = "";
3453 return this; return this;
3454 }, },
3455 // Is it disabled?
3456 disabled: function() { disabled: function() {
3457 return !list; return !list;
3458 }, },
3459 // Lock the list in its current state
3460 // Disable .fire
3461 // Also disable .add unless we have memory (since it would have no effect)
3462 // Abort any pending executions
3463 lock: function() { lock: function() {
3464 stack = undefined; locked = true;
3465 if ( !memory ) { if ( !memory ) {
3466 self.disable(); self.disable();
3467 } }
3468 return this; return this;
3469 }, },
3470 // Is it locked?
3471 locked: function() { locked: function() {
3472 return !stack; return !!locked;
3473 }, },
3474
3475 // Call all callbacks with the given context and arguments // Call all callbacks with the given context and arguments
3476 fireWith: function( context, args ) { fireWith: function( context, args ) {
3477 if ( list && ( !fired || stack ) ) { if ( !locked ) {
3478 args = args || []; args = args || [];
3479 args = [ context, args.slice ? args.slice() : args ]; args = [ context, args.slice ? args.slice() : args ];
3480 if ( firing ) { queue.push( args );
3481 stack.push( args ); if ( !firing ) {
3482 } else { fire();
3483 fire( args );
3484 } }
3485 } }
3486 return this; return this;
3487 }, },
3488
3489 // Call all the callbacks with the given arguments // Call all the callbacks with the given arguments
3490 fire: function() { fire: function() {
3491 self.fireWith( this, arguments ); self.fireWith( this, arguments );
3492 return this; return this;
3493 }, },
3494
3495 // To know if the callbacks have already been called at least once // To know if the callbacks have already been called at least once
3496 fired: function() { fired: function() {
3497 return !!fired; return !!fired;
3498 } }
3499 }; };
3500
3501 return self; return self;
3502 }; };
3503
3504
3505 jQuery.extend({ jQuery.extend( {
3506
3507 Deferred: function( func ) { Deferred: function( func ) {
3508 var tuples = [ var tuples = [
3509
3510 // action, add listener, listener list, final state // action, add listener, listener list, final state
3511 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ],
3512 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ],
3513 [ "notify", "progress", jQuery.Callbacks("memory") ] [ "notify", "progress", jQuery.Callbacks( "memory" ) ]
3514 ], ],
3515 state = "pending", state = "pending",
3516 promise = { promise = {
3517 state: function() { state: function() {
3518 return state; return state;
3519 }, },
3520 always: function() { always: function() {
3521 deferred.done( arguments ).fail( arguments ); deferred.done( arguments ).fail( arguments );
3522 return this; return this;
3523 }, },
3524 then: function( /* fnDone, fnFail, fnProgress */ ) { then: function( /* fnDone, fnFail, fnProgress */ ) {
3525 var fns = arguments; var fns = arguments;
3526 return jQuery.Deferred(function( newDefer ) { return jQuery.Deferred( function( newDefer ) {
3527 jQuery.each( tuples, function( i, tuple ) { jQuery.each( tuples, function( i, tuple ) {
3528 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
3529
3530 // deferred[ done | fail | progress ] for forwarding actions to newDefer // deferred[ done | fail | progress ] for forwarding actions to newDefer
3531 deferred[ tuple[1] ](function() { deferred[ tuple[ 1 ] ]( function() {
3532 var returned = fn && fn.apply( this, arguments ); var returned = fn && fn.apply( this, arguments );
3533 if ( returned && jQuery.isFunction( returned.promise ) ) { if ( returned && jQuery.isFunction( returned.promise ) ) {
3534 returned.promise() returned.promise()
3535 .progress( newDefer.notify )
3536 .done( newDefer.resolve ) .done( newDefer.resolve )
3537 .fail( newDefer.reject ) .fail( newDefer.reject );
3538 .progress( newDefer.notify );
3539 } else { } else {
3540 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); newDefer[ tuple[ 0 ] + "With" ](
3541 this === promise ? newDefer.promise() : this,
3542 fn ? [ returned ] : arguments
3543 );
3544 } }
3545 }); } );
3546 }); } );
3547 fns = null; fns = null;
3548 }).promise(); } ).promise();
3549 }, },
3550
3551 // Get a promise for this deferred // Get a promise for this deferred
3552 // If obj is provided, the promise aspect is added to the object // If obj is provided, the promise aspect is added to the object
3553 promise: function( obj ) { promise: function( obj ) {
3554 return obj != null ? jQuery.extend( obj, promise ) : promise; return obj != null ? jQuery.extend( obj, promise ) : promise;
3555 } }
3556 }, },
3557 deferred = {}; deferred = {};
3558
3559 // Keep pipe for back-compat // Keep pipe for back-compat
3560 promise.pipe = promise.then; promise.pipe = promise.then;
3561
3562 // Add list-specific methods // Add list-specific methods
3563 jQuery.each( tuples, function( i, tuple ) { jQuery.each( tuples, function( i, tuple ) {
3564 var list = tuple[ 2 ], var list = tuple[ 2 ],
3565 stateString = tuple[ 3 ]; stateString = tuple[ 3 ];
3566
3567 // promise[ done | fail | progress ] = list.add // promise[ done | fail | progress ] = list.add
3568 promise[ tuple[1] ] = list.add; promise[ tuple[ 1 ] ] = list.add;
3569
3570 // Handle state // Handle state
3571 if ( stateString ) { if ( stateString ) {
3572 list.add(function() { list.add( function() {
3573 // state = [ resolved | rejected ] // state = [ resolved | rejected ]
3574 state = stateString; state = stateString;
3575
3576 // [ reject_list | resolve_list ].disable; progress_list.lock // [ reject_list | resolve_list ].disable; progress_list.lock
3577 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
3578 } }
3579
3580 // deferred[ resolve | reject | notify ] // deferred[ resolve | reject | notify ]
3581 deferred[ tuple[0] ] = function() { deferred[ tuple[ 0 ] ] = function() {
3582 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
3583 return this; return this;
3584 }; };
3585 deferred[ tuple[0] + "With" ] = list.fireWith; deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
3586 }); } );
3587
3588 // Make the deferred a promise // Make the deferred a promise
3589 promise.promise( deferred ); promise.promise( deferred );
3590
3591 // Call given func if any // Call given func if any
3592 if ( func ) { if ( func ) {
3593 func.call( deferred, deferred ); func.call( deferred, deferred );
3594 } }
3595
3596 // All done! // All done!
3597 return deferred; return deferred;
3598 }, },
3599
3600 // Deferred helper // Deferred helper
3601 when: function( subordinate /* , ..., subordinateN */ ) { when: function( subordinate /* , ..., subordinateN */ ) {
3602 var i = 0, var i = 0,
3603 resolveValues = slice.call( arguments ), resolveValues = slice.call( arguments ),
3604 length = resolveValues.length, length = resolveValues.length,
3605
3606 // the count of uncompleted subordinates // the count of uncompleted subordinates
3607 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, remaining = length !== 1 ||
3608 ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
3609
3610 // the master Deferred. If resolveValues consist of only a single Deferred, just use that. // the master Deferred.
3611 // If resolveValues consist of only a single Deferred, just use that.
3612 deferred = remaining === 1 ? subordinate : jQuery.Deferred(), deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
3613
3614 // Update function for both resolve and progress values // Update function for both resolve and progress values
3615 updateFunc = function( i, contexts, values ) { updateFunc = function( i, contexts, values ) {
3616 return function( value ) { return function( value ) {
3617 contexts[ i ] = this; contexts[ i ] = this;
3618 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
3619 if ( values === progressValues ) { if ( values === progressValues ) {
3620 deferred.notifyWith( contexts, values ); deferred.notifyWith( contexts, values );
3621
3622 } else if ( !(--remaining) ) { } else if ( !( --remaining ) ) {
3623 deferred.resolveWith( contexts, values ); deferred.resolveWith( contexts, values );
3624 } }
3625 }; };
3626 }, },
3627
3628 progressValues, progressContexts, resolveContexts; progressValues, progressContexts, resolveContexts;
3629
3630 // add listeners to Deferred subordinates; treat others as resolved // add listeners to Deferred subordinates; treat others as resolved
3631 if ( length > 1 ) { if ( length > 1 ) {
3632 progressValues = new Array( length ); progressValues = new Array( length );
3633 progressContexts = new Array( length ); progressContexts = new Array( length );
3634 resolveContexts = new Array( length ); resolveContexts = new Array( length );
3635 for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
3636 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
3637 resolveValues[ i ].promise() resolveValues[ i ].promise()
3638 .progress( updateFunc( i, progressContexts, progressValues ) )
3639 .done( updateFunc( i, resolveContexts, resolveValues ) ) .done( updateFunc( i, resolveContexts, resolveValues ) )
3640 .fail( deferred.reject ) .fail( deferred.reject );
3641 .progress( updateFunc( i, progressContexts, progressValues ) );
3642 } else { } else {
3643 --remaining; --remaining;
3644 } }
3645 } }
3646 } }
3647
3648 // if we're not waiting on anything, resolve the master // if we're not waiting on anything, resolve the master
3649 if ( !remaining ) { if ( !remaining ) {
3650 deferred.resolveWith( resolveContexts, resolveValues ); deferred.resolveWith( resolveContexts, resolveValues );
3651 } }
3652
3653 return deferred.promise(); return deferred.promise();
3654 } }
3655 }); } );
3656
3657
3658 // The deferred used on DOM ready // The deferred used on DOM ready
3659 var readyList; var readyList;
3660
3661 jQuery.fn.ready = function( fn ) { jQuery.fn.ready = function( fn ) {
3662
3663 // Add the callback // Add the callback
3664 jQuery.ready.promise().done( fn ); jQuery.ready.promise().done( fn );
3665
3666 return this; return this;
3667 }; };
3668
3669 jQuery.extend({ jQuery.extend( {
3670 // Is the DOM ready to be used? Set to true once it occurs. // Is the DOM ready to be used? Set to true once it occurs.
3671 isReady: false, isReady: false,
3672
3673 // A counter to track how many items to wait for before // A counter to track how many items to wait for before
3674 // the ready event fires. See #6781 // the ready event fires. See #6781
3675 readyWait: 1, readyWait: 1,
3676
3677 // Hold (or release) the ready event // Hold (or release) the ready event
3678 holdReady: function( hold ) { holdReady: function( hold ) {
3679 if ( hold ) { if ( hold ) {
3680 jQuery.readyWait++; jQuery.readyWait++;
3681 } else { } else {
3682 jQuery.ready( true ); jQuery.ready( true );
3683 } }
3684 }, },
3685
3686 // Handle when the DOM is ready // Handle when the DOM is ready
3687 ready: function( wait ) { ready: function( wait ) {
3688
3689 // Abort if there are pending holds or we're already ready // Abort if there are pending holds or we're already ready
3690 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
3691 return; return;
3692 } }
3693
3694 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
3695 if ( !document.body ) {
3696 return setTimeout( jQuery.ready );
3697 }
3698
3699 // Remember that the DOM is ready // Remember that the DOM is ready
3700 jQuery.isReady = true; jQuery.isReady = true;
3701
3702 // If a normal DOM Ready event fired, decrement, and wait if need be // If a normal DOM Ready event fired, decrement, and wait if need be
3703 if ( wait !== true && --jQuery.readyWait > 0 ) { if ( wait !== true && --jQuery.readyWait > 0 ) {
3704 return; return;
3705 } }
3706
3707 // If there are functions bound, to execute // If there are functions bound, to execute
3708 readyList.resolveWith( document, [ jQuery ] ); readyList.resolveWith( document, [ jQuery ] );
3709
3710 // Trigger any bound ready events // Trigger any bound ready events
3711 if ( jQuery.fn.triggerHandler ) { if ( jQuery.fn.triggerHandler ) {
3712 jQuery( document ).triggerHandler( "ready" ); jQuery( document ).triggerHandler( "ready" );
3713 jQuery( document ).off( "ready" ); jQuery( document ).off( "ready" );
3714 } }
3715 } }
3716 }); } );
3717
3718 /** /**
3719 * Clean-up method for dom ready events * Clean-up method for dom ready events
3720 */ */
3721 function detach() { function detach() {
3722 if ( document.addEventListener ) { if ( document.addEventListener ) {
3723 document.removeEventListener( "DOMContentLoaded", completed, false ); document.removeEventListener( "DOMContentLoaded", completed );
3724 window.removeEventListener( "load", completed, false ); window.removeEventListener( "load", completed );
3725
3726 } else { } else {
3727 document.detachEvent( "onreadystatechange", completed ); document.detachEvent( "onreadystatechange", completed );
3728 window.detachEvent( "onload", completed ); window.detachEvent( "onload", completed );
3729 } }
3730 } }
3731
3732 /** /**
3733 * The ready event handler and self cleanup method * The ready event handler and self cleanup method
3734 */ */
3735 function completed() { function completed() {
3736
3737 // readyState === "complete" is good enough for us to call the dom ready in oldIE // readyState === "complete" is good enough for us to call the dom ready in oldIE
3738 if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) { if ( document.addEventListener ||
3739 window.event.type === "load" ||
3740 document.readyState === "complete" ) {
3741 detach(); detach();
3742 jQuery.ready(); jQuery.ready();
3743 } }
3744 } }
3745
3746 jQuery.ready.promise = function( obj ) { jQuery.ready.promise = function( obj ) {
3747 if ( !readyList ) { if ( !readyList ) {
3748
3749 readyList = jQuery.Deferred(); readyList = jQuery.Deferred();
3750
3751 // Catch cases where $(document).ready() is called after the browser event has already occurred. // Catch cases where $(document).ready() is called
3752 // we once tried to use readyState "interactive" here, but it caused issues like the one // after the browser event has already occurred.
3753 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 // Support: IE6-10
3754 if ( document.readyState === "complete" ) { // Older IE sometimes signals "interactive" too soon
3755 if ( document.readyState === "complete" ||
3756 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
3757 // Handle it asynchronously to allow scripts the opportunity to delay ready // Handle it asynchronously to allow scripts the opportunity to delay ready
3758 setTimeout( jQuery.ready ); window.setTimeout( jQuery.ready );
3759
3760 // Standards-based browsers support DOMContentLoaded // Standards-based browsers support DOMContentLoaded
3761 } else if ( document.addEventListener ) { } else if ( document.addEventListener ) {
3762
3763 // Use the handy event callback // Use the handy event callback
3764 document.addEventListener( "DOMContentLoaded", completed, false ); document.addEventListener( "DOMContentLoaded", completed );
3765
3766 // A fallback to window.onload, that will always work // A fallback to window.onload, that will always work
3767 window.addEventListener( "load", completed, false ); window.addEventListener( "load", completed );
3768
3769 // If IE event model is used // If IE event model is used
3770 } else { } else {
3771
3772 // Ensure firing before onload, maybe late but safe also for iframes // Ensure firing before onload, maybe late but safe also for iframes
3773 document.attachEvent( "onreadystatechange", completed ); document.attachEvent( "onreadystatechange", completed );
3774
3775 // A fallback to window.onload, that will always work // A fallback to window.onload, that will always work
3776 window.attachEvent( "onload", completed ); window.attachEvent( "onload", completed );
3777
3778 // If IE and not a frame // If IE and not a frame
3779 // continually check to see if the document is ready // continually check to see if the document is ready
3780 var top = false; var top = false;
3781
3782 try { try {
3783 top = window.frameElement == null && document.documentElement; top = window.frameElement == null && document.documentElement;
3784 } catch(e) {} } catch ( e ) {}
3785
3786 if ( top && top.doScroll ) { if ( top && top.doScroll ) {
3787 (function doScrollCheck() { ( function doScrollCheck() {
3788 if ( !jQuery.isReady ) { if ( !jQuery.isReady ) {
3789
3790 try { try {
3791
3792 // Use the trick by Diego Perini // Use the trick by Diego Perini
3793 // http://javascript.nwbox.com/IEContentLoaded/ // http://javascript.nwbox.com/IEContentLoaded/
3794 top.doScroll("left"); top.doScroll( "left" );
3795 } catch(e) { } catch ( e ) {
3796 return setTimeout( doScrollCheck, 50 ); return window.setTimeout( doScrollCheck, 50 );
3797 } }
3798
3799 // detach all dom ready events // detach all dom ready events
3800 detach(); detach();
3801
3802 // and execute any waiting functions // and execute any waiting functions
3803 jQuery.ready(); jQuery.ready();
3804 } }
3805 })(); } )();
3806 } }
3807 } }
3808 } }
3809 return readyList.promise( obj ); return readyList.promise( obj );
3810 }; };
3811
3812 // Kick off the DOM ready check even if the user does not
3813 jQuery.ready.promise();
3814
3815 var strundefined = typeof undefined;
3816
3817
3818
3819 // Support: IE<9 // Support: IE<9
3820 // Iteration over object's inherited properties before its own // Iteration over object's inherited properties before its own
3821 var i; var i;
3822 for ( i in jQuery( support ) ) { for ( i in jQuery( support ) ) {
3823 break; break;
3824 } }
3825 support.ownLast = i !== "0"; support.ownFirst = i === "0";
3826
3827 // Note: most support tests are defined in their respective modules. // Note: most support tests are defined in their respective modules.
3828 // false until the test is run // false until the test is run
3829 support.inlineBlockNeedsLayout = false; support.inlineBlockNeedsLayout = false;
3830
3831 // Execute ASAP in case we need to set body.style.zoom // Execute ASAP in case we need to set body.style.zoom
3832 jQuery(function() { jQuery( function() {
3833 // Minified: var a,b,c,d // Minified: var a,b,c,d
3834 var val, div, body, container; var val, div, body, container;
3835
3836 body = document.getElementsByTagName( "body" )[ 0 ]; body = document.getElementsByTagName( "body" )[ 0 ];
3837 if ( !body || !body.style ) { if ( !body || !body.style ) {
3838
3839 // Return for frameset docs that don't have a body // Return for frameset docs that don't have a body
3840 return; return;
3841 } }
3842
3843 // Setup // Setup
3844 div = document.createElement( "div" ); div = document.createElement( "div" );
3845 container = document.createElement( "div" ); container = document.createElement( "div" );
3846 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px"; container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
3847 body.appendChild( container ).appendChild( div ); body.appendChild( container ).appendChild( div );
3848
3849 if ( typeof div.style.zoom !== strundefined ) { if ( typeof div.style.zoom !== "undefined" ) {
3850 // Support: IE<8 // Support: IE<8
3851 // Check if natively block-level elements act like inline-block // Check if natively block-level elements act like inline-block
3852 // elements when setting their display to 'inline' and giving // elements when setting their display to 'inline' and giving
3853 // them layout // them layout
3854 div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1"; div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
3855
3856 support.inlineBlockNeedsLayout = val = div.offsetWidth === 3; support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
3857 if ( val ) { if ( val ) {
3858
3859 // Prevent IE 6 from affecting layout for positioned elements #11048 // Prevent IE 6 from affecting layout for positioned elements #11048
3860 // Prevent IE from shrinking the body in IE 7 mode #12869 // Prevent IE from shrinking the body in IE 7 mode #12869
3861 // Support: IE<8 // Support: IE<8
3862 body.style.zoom = 1; body.style.zoom = 1;
3863 } }
3864 } }
3865
3866 body.removeChild( container ); body.removeChild( container );
3867 }); } );
3868
3869
3870 ( function() {
3871
3872 (function() {
3873 var div = document.createElement( "div" ); var div = document.createElement( "div" );
3874
3875 // Execute the test only if not already executed in another module. // Support: IE<9
3876 if (support.deleteExpando == null) { support.deleteExpando = true;
3877 // Support: IE<9 try {
3878 support.deleteExpando = true; delete div.test;
3879 try { } catch ( e ) {
3880 delete div.test; support.deleteExpando = false;
3881 } catch( e ) {
3882 support.deleteExpando = false;
3883 }
3884 } }
3885
3886 // Null elements to avoid leaks in IE. // Null elements to avoid leaks in IE.
3887 div = null; div = null;
3888 })(); } )();
3889 var acceptData = function( elem ) {
3890 var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ],
3891 /**
3892 * Determines whether an object can have data
3893 */
3894 jQuery.acceptData = function( elem ) {
3895 var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ],
3896 nodeType = +elem.nodeType || 1; nodeType = +elem.nodeType || 1;
3897
3898 // Do not set data on non-element DOM nodes because it will not be cleared (#8335). // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
3899 return nodeType !== 1 && nodeType !== 9 ? return nodeType !== 1 && nodeType !== 9 ?
3900 false : false :
3901
3902 // Nodes accept data unless otherwise specified; rejection can be conditional // Nodes accept data unless otherwise specified; rejection can be conditional
3903 !noData || noData !== true && elem.getAttribute("classid") === noData; !noData || noData !== true && elem.getAttribute( "classid" ) === noData;
3904 }; };
3905
3906
3907
3908
3909 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
3910 rmultiDash = /([A-Z])/g; rmultiDash = /([A-Z])/g;
3911
3912 function dataAttr( elem, key, data ) { function dataAttr( elem, key, data ) {
3913
3914 // If nothing was found internally, try to fetch any // If nothing was found internally, try to fetch any
3915 // data from the HTML5 data-* attribute // data from the HTML5 data-* attribute
3916 if ( data === undefined && elem.nodeType === 1 ) { if ( data === undefined && elem.nodeType === 1 ) {
3917
3918 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
3919
3920 data = elem.getAttribute( name ); data = elem.getAttribute( name );
3921
3922 if ( typeof data === "string" ) { if ( typeof data === "string" ) {
3923 try { try {
3924 data = data === "true" ? true : data = data === "true" ? true :
3925 data === "false" ? false : data === "false" ? false :
3926 data === "null" ? null : data === "null" ? null :
3927
3928 // Only convert to a number if it doesn't change the string // Only convert to a number if it doesn't change the string
3929 +data + "" === data ? +data : +data + "" === data ? +data :
3930 rbrace.test( data ) ? jQuery.parseJSON( data ) : rbrace.test( data ) ? jQuery.parseJSON( data ) :
3931 data; data;
3932 } catch( e ) {} } catch ( e ) {}
3933
3934 // Make sure we set the data so it isn't changed later // Make sure we set the data so it isn't changed later
3935 jQuery.data( elem, key, data ); jQuery.data( elem, key, data );
3936
3937 } else { } else {
3938 data = undefined; data = undefined;
3939 } }
3940 } }
3941
3942 return data; return data;
3943 } }
3944
3945 // checks a cache object for emptiness // checks a cache object for emptiness
3946 function isEmptyDataObject( obj ) { function isEmptyDataObject( obj ) {
3947 var name; var name;
3948 for ( name in obj ) { for ( name in obj ) {
3949
3950 // if the public data object is empty, the private is still empty // if the public data object is empty, the private is still empty
3951 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { if ( name === "data" && jQuery.isEmptyObject( obj[ name ] ) ) {
3952 continue; continue;
3953 } }
3954 if ( name !== "toJSON" ) { if ( name !== "toJSON" ) {
3955 return false; return false;
3956 } }
3957 } }
3958
3959 return true; return true;
3960 } }
3961
3962 function internalData( elem, name, data, pvt /* Internal Use Only */ ) { function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
3963 if ( !jQuery.acceptData( elem ) ) { if ( !acceptData( elem ) ) {
3964 return; return;
3965 } }
3966
3967 var ret, thisCache, var ret, thisCache,
3968 internalKey = jQuery.expando, internalKey = jQuery.expando,
3969
3970 // We have to handle DOM nodes and JS objects differently because IE6-7 // We have to handle DOM nodes and JS objects differently because IE6-7
3971 // can't GC object references properly across the DOM-JS boundary // can't GC object references properly across the DOM-JS boundary
3972 isNode = elem.nodeType, isNode = elem.nodeType,
3973
3974 // Only DOM nodes need the global jQuery cache; JS object data is // Only DOM nodes need the global jQuery cache; JS object data is
3975 // attached directly to the object so GC can occur automatically // attached directly to the object so GC can occur automatically
3976 cache = isNode ? jQuery.cache : elem, cache = isNode ? jQuery.cache : elem,
3977
3978 // Only defining an ID for JS objects if its cache already exists allows // Only defining an ID for JS objects if its cache already exists allows
3979 // the code to shortcut on the same path as a DOM node with no cache // the code to shortcut on the same path as a DOM node with no cache
3980 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
3981
3982 // Avoid doing any more work than we need to when trying to get data on an // Avoid doing any more work than we need to when trying to get data on an
3983 // object that has no data at all // object that has no data at all
3984 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) { if ( ( !id || !cache[ id ] || ( !pvt && !cache[ id ].data ) ) &&
3985 data === undefined && typeof name === "string" ) {
3986 return; return;
3987 } }
3988
3989 if ( !id ) { if ( !id ) {
3990
3991 // Only DOM nodes need a new unique ID for each element since their data // Only DOM nodes need a new unique ID for each element since their data
3992 // ends up in the global cache // ends up in the global cache
3993 if ( isNode ) { if ( isNode ) {
3994 id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++; id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
3995 } else { } else {
3996 id = internalKey; id = internalKey;
3997 } }
3998 } }
3999
4000 if ( !cache[ id ] ) { if ( !cache[ id ] ) {
4001
4002 // Avoid exposing jQuery metadata on plain JS objects when the object // Avoid exposing jQuery metadata on plain JS objects when the object
4003 // is serialized using JSON.stringify // is serialized using JSON.stringify
4004 cache[ id ] = isNode ? {} : { toJSON: jQuery.noop }; cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
4005 } }
4006
4007 // An object can be passed to jQuery.data instead of a key/value pair; this gets // An object can be passed to jQuery.data instead of a key/value pair; this gets
4008 // shallow copied over onto the existing cache // shallow copied over onto the existing cache
4009 if ( typeof name === "object" || typeof name === "function" ) { if ( typeof name === "object" || typeof name === "function" ) {
4010 if ( pvt ) { if ( pvt ) {
4011 cache[ id ] = jQuery.extend( cache[ id ], name ); cache[ id ] = jQuery.extend( cache[ id ], name );
4012 } else { } else {
4013 cache[ id ].data = jQuery.extend( cache[ id ].data, name ); cache[ id ].data = jQuery.extend( cache[ id ].data, name );
4014 } }
4015 } }
4016
4017 thisCache = cache[ id ]; thisCache = cache[ id ];
4018
4019 // jQuery data() is stored in a separate object inside the object's internal data // jQuery data() is stored in a separate object inside the object's internal data
4020 // cache in order to avoid key collisions between internal data and user-defined // cache in order to avoid key collisions between internal data and user-defined
4021 // data. // data.
4022 if ( !pvt ) { if ( !pvt ) {
4023 if ( !thisCache.data ) { if ( !thisCache.data ) {
4024 thisCache.data = {}; thisCache.data = {};
4025 } }
4026
4027 thisCache = thisCache.data; thisCache = thisCache.data;
4028 } }
4029
4030 if ( data !== undefined ) { if ( data !== undefined ) {
4031 thisCache[ jQuery.camelCase( name ) ] = data; thisCache[ jQuery.camelCase( name ) ] = data;
4032 } }
4033
4034 // Check for both converted-to-camel and non-converted data property names // Check for both converted-to-camel and non-converted data property names
4035 // If a data property was specified // If a data property was specified
4036 if ( typeof name === "string" ) { if ( typeof name === "string" ) {
4037
4038 // First Try to find as-is property data // First Try to find as-is property data
4039 ret = thisCache[ name ]; ret = thisCache[ name ];
4040
4041 // Test for null|undefined property data // Test for null|undefined property data
4042 if ( ret == null ) { if ( ret == null ) {
4043
4044 // Try to find the camelCased property // Try to find the camelCased property
4045 ret = thisCache[ jQuery.camelCase( name ) ]; ret = thisCache[ jQuery.camelCase( name ) ];
4046 } }
4047 } else { } else {
4048 ret = thisCache; ret = thisCache;
4049 } }
4050
4051 return ret; return ret;
4052 } }
4053
4054 function internalRemoveData( elem, name, pvt ) { function internalRemoveData( elem, name, pvt ) {
4055 if ( !jQuery.acceptData( elem ) ) { if ( !acceptData( elem ) ) {
4056 return; return;
4057 } }
4058
4059 var thisCache, i, var thisCache, i,
4060 isNode = elem.nodeType, isNode = elem.nodeType,
4061
4062 // See jQuery.data for more information // See jQuery.data for more information
4063 cache = isNode ? jQuery.cache : elem, cache = isNode ? jQuery.cache : elem,
4064 id = isNode ? elem[ jQuery.expando ] : jQuery.expando; id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
4065
4066 // If there is already no cache entry for this object, there is no // If there is already no cache entry for this object, there is no
4067 // purpose in continuing // purpose in continuing
4068 if ( !cache[ id ] ) { if ( !cache[ id ] ) {
4069 return; return;
4070 } }
4071
4072 if ( name ) { if ( name ) {
4073
4074 thisCache = pvt ? cache[ id ] : cache[ id ].data; thisCache = pvt ? cache[ id ] : cache[ id ].data;
4075
4076 if ( thisCache ) { if ( thisCache ) {
4077
4078 // Support array or space separated string names for data keys // Support array or space separated string names for data keys
4079 if ( !jQuery.isArray( name ) ) { if ( !jQuery.isArray( name ) ) {
4080
4081 // try the string as a key before any manipulation // try the string as a key before any manipulation
4082 if ( name in thisCache ) { if ( name in thisCache ) {
4083 name = [ name ]; name = [ name ];
4084 } else { } else {
4085
4086 // split the camel cased version by spaces unless a key with the spaces exists // split the camel cased version by spaces unless a key with the spaces exists
4087 name = jQuery.camelCase( name ); name = jQuery.camelCase( name );
4088 if ( name in thisCache ) { if ( name in thisCache ) {
4089 name = [ name ]; name = [ name ];
4090 } else { } else {
4091 name = name.split(" "); name = name.split( " " );
4092 } }
4093 } }
4094 } else { } else {
4095
4096 // If "name" is an array of keys... // If "name" is an array of keys...
4097 // When data is initially created, via ("key", "val") signature, // When data is initially created, via ("key", "val") signature,
4098 // keys will be converted to camelCase. // keys will be converted to camelCase.
4099 // Since there is no way to tell _how_ a key was added, remove // Since there is no way to tell _how_ a key was added, remove
4100 // both plain key and camelCase key. #12786 // both plain key and camelCase key. #12786
4101 // This will only penalize the array argument path. // This will only penalize the array argument path.
4102 name = name.concat( jQuery.map( name, jQuery.camelCase ) ); name = name.concat( jQuery.map( name, jQuery.camelCase ) );
4103 } }
4104
4105 i = name.length; i = name.length;
4106 while ( i-- ) { while ( i-- ) {
4107 delete thisCache[ name[i] ]; delete thisCache[ name[ i ] ];
4108 } }
4109
4110 // If there is no data left in the cache, we want to continue // If there is no data left in the cache, we want to continue
4111 // and let the cache object itself get destroyed // and let the cache object itself get destroyed
4112 if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) { if ( pvt ? !isEmptyDataObject( thisCache ) : !jQuery.isEmptyObject( thisCache ) ) {
4113 return; return;
4114 } }
4115 } }
4116 } }
4117
4118 // See jQuery.data for more information // See jQuery.data for more information
4119 if ( !pvt ) { if ( !pvt ) {
4120 delete cache[ id ].data; delete cache[ id ].data;
4121
4122 // Don't destroy the parent cache unless the internal data object // Don't destroy the parent cache unless the internal data object
4123 // had been the only thing left in it // had been the only thing left in it
4124 if ( !isEmptyDataObject( cache[ id ] ) ) { if ( !isEmptyDataObject( cache[ id ] ) ) {
4125 return; return;
4126 } }
4127 } }
4128
4129 // Destroy the cache // Destroy the cache
4130 if ( isNode ) { if ( isNode ) {
4131 jQuery.cleanData( [ elem ], true ); jQuery.cleanData( [ elem ], true );
4132
4133 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
4134 /* jshint eqeqeq: false */ /* jshint eqeqeq: false */
4135 } else if ( support.deleteExpando || cache != cache.window ) { } else if ( support.deleteExpando || cache != cache.window ) {
4136 /* jshint eqeqeq: true */ /* jshint eqeqeq: true */
4137 delete cache[ id ]; delete cache[ id ];
4138
4139 // When all else fails, null // When all else fails, undefined
4140 } else { } else {
4141 cache[ id ] = null; cache[ id ] = undefined;
4142 } }
4143 } }
4144
4145 jQuery.extend({ jQuery.extend( {
4146 cache: {}, cache: {},
4147
4148 // The following elements (space-suffixed to avoid Object.prototype collisions) // The following elements (space-suffixed to avoid Object.prototype collisions)
4149 // throw uncatchable exceptions if you attempt to set expando properties // throw uncatchable exceptions if you attempt to set expando properties
4150 noData: { noData: {
4151 "applet ": true, "applet ": true,
4152 "embed ": true, "embed ": true,
4153
4154 // ...but Flash objects (which have this classid) *can* handle expandos // ...but Flash objects (which have this classid) *can* handle expandos
4155 "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
4156 }, },
4157
4158 hasData: function( elem ) { hasData: function( elem ) {
4159 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; elem = elem.nodeType ? jQuery.cache[ elem[ jQuery.expando ] ] : elem[ jQuery.expando ];
4160 return !!elem && !isEmptyDataObject( elem ); return !!elem && !isEmptyDataObject( elem );
4161 }, },
4162
4163 data: function( elem, name, data ) { data: function( elem, name, data ) {
4164 return internalData( elem, name, data ); return internalData( elem, name, data );
4165 }, },
4166
4167 removeData: function( elem, name ) { removeData: function( elem, name ) {
4168 return internalRemoveData( elem, name ); return internalRemoveData( elem, name );
4169 }, },
4170
4171 // For internal use only. // For internal use only.
4172 _data: function( elem, name, data ) { _data: function( elem, name, data ) {
4173 return internalData( elem, name, data, true ); return internalData( elem, name, data, true );
4174 }, },
4175
4176 _removeData: function( elem, name ) { _removeData: function( elem, name ) {
4177 return internalRemoveData( elem, name, true ); return internalRemoveData( elem, name, true );
4178 } }
4179 }); } );
4180
4181 jQuery.fn.extend({ jQuery.fn.extend( {
4182 data: function( key, value ) { data: function( key, value ) {
4183 var i, name, data, var i, name, data,
4184 elem = this[0], elem = this[ 0 ],
4185 attrs = elem && elem.attributes; attrs = elem && elem.attributes;
4186
4187 // Special expections of .data basically thwart jQuery.access, // Special expections of .data basically thwart jQuery.access,
4188 // so implement the relevant behavior ourselves // so implement the relevant behavior ourselves
4189
4190 // Gets all values // Gets all values
4191 if ( key === undefined ) { if ( key === undefined ) {
4192 if ( this.length ) { if ( this.length ) {
4193 data = jQuery.data( elem ); data = jQuery.data( elem );
4194
4195 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
4196 i = attrs.length; i = attrs.length;
4197 while ( i-- ) { while ( i-- ) {
4198
4199 // Support: IE11+ // Support: IE11+
4200 // The attrs elements can be null (#14894) // The attrs elements can be null (#14894)
4201 if ( attrs[ i ] ) { if ( attrs[ i ] ) {
4202 name = attrs[ i ].name; name = attrs[ i ].name;
4203 if ( name.indexOf( "data-" ) === 0 ) { if ( name.indexOf( "data-" ) === 0 ) {
4204 name = jQuery.camelCase( name.slice(5) ); name = jQuery.camelCase( name.slice( 5 ) );
4205 dataAttr( elem, name, data[ name ] ); dataAttr( elem, name, data[ name ] );
4206 } }
4207 } }
4208 } }
4209 jQuery._data( elem, "parsedAttrs", true ); jQuery._data( elem, "parsedAttrs", true );
4210 } }
4211 } }
4212
4213 return data; return data;
4214 } }
4215
4216 // Sets multiple values // Sets multiple values
4217 if ( typeof key === "object" ) { if ( typeof key === "object" ) {
4218 return this.each(function() { return this.each( function() {
4219 jQuery.data( this, key ); jQuery.data( this, key );
4220 }); } );
4221 } }
4222
4223 return arguments.length > 1 ? return arguments.length > 1 ?
4224
4225 // Sets one value // Sets one value
4226 this.each(function() { this.each( function() {
4227 jQuery.data( this, key, value ); jQuery.data( this, key, value );
4228 }) : } ) :
4229
4230 // Gets one value // Gets one value
4231 // Try to fetch any internally stored data first // Try to fetch any internally stored data first
4232 elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined; elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
4233 }, },
4234
4235 removeData: function( key ) { removeData: function( key ) {
4236 return this.each(function() { return this.each( function() {
4237 jQuery.removeData( this, key ); jQuery.removeData( this, key );
4238 }); } );
4239 } }
4240 }); } );
4241
4242
4243 jQuery.extend({ jQuery.extend( {
4244 queue: function( elem, type, data ) { queue: function( elem, type, data ) {
4245 var queue; var queue;
4246
4247 if ( elem ) { if ( elem ) {
4248 type = ( type || "fx" ) + "queue"; type = ( type || "fx" ) + "queue";
4249 queue = jQuery._data( elem, type ); queue = jQuery._data( elem, type );
4250
4251 // Speed up dequeue by getting out quickly if this is just a lookup // Speed up dequeue by getting out quickly if this is just a lookup
4252 if ( data ) { if ( data ) {
4253 if ( !queue || jQuery.isArray(data) ) { if ( !queue || jQuery.isArray( data ) ) {
4254 queue = jQuery._data( elem, type, jQuery.makeArray(data) ); queue = jQuery._data( elem, type, jQuery.makeArray( data ) );
4255 } else { } else {
4256 queue.push( data ); queue.push( data );
4257 } }
4258 } }
4259 return queue || []; return queue || [];
4260 } }
4261 }, },
4262
4263 dequeue: function( elem, type ) { dequeue: function( elem, type ) {
4264 type = type || "fx"; type = type || "fx";
4265
4266 var queue = jQuery.queue( elem, type ), var queue = jQuery.queue( elem, type ),
4267 startLength = queue.length, startLength = queue.length,
4268 fn = queue.shift(), fn = queue.shift(),
4269 hooks = jQuery._queueHooks( elem, type ), hooks = jQuery._queueHooks( elem, type ),
4270 next = function() { next = function() {
4271 jQuery.dequeue( elem, type ); jQuery.dequeue( elem, type );
4272 }; };
4273
4274 // If the fx queue is dequeued, always remove the progress sentinel // If the fx queue is dequeued, always remove the progress sentinel
4275 if ( fn === "inprogress" ) { if ( fn === "inprogress" ) {
4276 fn = queue.shift(); fn = queue.shift();
4277 startLength--; startLength--;
4278 } }
4279
4280 if ( fn ) { if ( fn ) {
4281
4282 // Add a progress sentinel to prevent the fx queue from being // Add a progress sentinel to prevent the fx queue from being
4283 // automatically dequeued // automatically dequeued
4284 if ( type === "fx" ) { if ( type === "fx" ) {
4285 queue.unshift( "inprogress" ); queue.unshift( "inprogress" );
4286 } }
4287
4288 // clear up the last queue stop function // clear up the last queue stop function
4289 delete hooks.stop; delete hooks.stop;
4290 fn.call( elem, next, hooks ); fn.call( elem, next, hooks );
4291 } }
4292
4293 if ( !startLength && hooks ) { if ( !startLength && hooks ) {
4294 hooks.empty.fire(); hooks.empty.fire();
4295 } }
4296 }, },
4297
4298 // not intended for public consumption - generates a queueHooks object, or returns the current one // not intended for public consumption - generates a queueHooks object,
4299 // or returns the current one
4300 _queueHooks: function( elem, type ) { _queueHooks: function( elem, type ) {
4301 var key = type + "queueHooks"; var key = type + "queueHooks";
4302 return jQuery._data( elem, key ) || jQuery._data( elem, key, { return jQuery._data( elem, key ) || jQuery._data( elem, key, {
4303 empty: jQuery.Callbacks("once memory").add(function() { empty: jQuery.Callbacks( "once memory" ).add( function() {
4304 jQuery._removeData( elem, type + "queue" ); jQuery._removeData( elem, type + "queue" );
4305 jQuery._removeData( elem, key ); jQuery._removeData( elem, key );
4306 }) } )
4307 }); } );
4308 } }
4309 }); } );
4310
4311 jQuery.fn.extend({ jQuery.fn.extend( {
4312 queue: function( type, data ) { queue: function( type, data ) {
4313 var setter = 2; var setter = 2;
4314
4315 if ( typeof type !== "string" ) { if ( typeof type !== "string" ) {
4316 data = type; data = type;
4317 type = "fx"; type = "fx";
4318 setter--; setter--;
4319 } }
4320
4321 if ( arguments.length < setter ) { if ( arguments.length < setter ) {
4322 return jQuery.queue( this[0], type ); return jQuery.queue( this[ 0 ], type );
4323 } }
4324
4325 return data === undefined ? return data === undefined ?
4326 this : this :
4327 this.each(function() { this.each( function() {
4328 var queue = jQuery.queue( this, type, data ); var queue = jQuery.queue( this, type, data );
4329
4330 // ensure a hooks for this queue // ensure a hooks for this queue
4331 jQuery._queueHooks( this, type ); jQuery._queueHooks( this, type );
4332
4333 if ( type === "fx" && queue[0] !== "inprogress" ) { if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
4334 jQuery.dequeue( this, type ); jQuery.dequeue( this, type );
4335 } }
4336 }); } );
4337 }, },
4338 dequeue: function( type ) { dequeue: function( type ) {
4339 return this.each(function() { return this.each( function() {
4340 jQuery.dequeue( this, type ); jQuery.dequeue( this, type );
4341 }); } );
4342 }, },
4343 clearQueue: function( type ) { clearQueue: function( type ) {
4344 return this.queue( type || "fx", [] ); return this.queue( type || "fx", [] );
4345 }, },
4346
4347 // Get a promise resolved when queues of a certain type // Get a promise resolved when queues of a certain type
4348 // are emptied (fx is the type by default) // are emptied (fx is the type by default)
4349 promise: function( type, obj ) { promise: function( type, obj ) {
4350 var tmp, var tmp,
4351 count = 1, count = 1,
4352 defer = jQuery.Deferred(), defer = jQuery.Deferred(),
4353 elements = this, elements = this,
4354 i = this.length, i = this.length,
4355 resolve = function() { resolve = function() {
4356 if ( !( --count ) ) { if ( !( --count ) ) {
4357 defer.resolveWith( elements, [ elements ] ); defer.resolveWith( elements, [ elements ] );
4358 } }
4359 }; };
4360
4361 if ( typeof type !== "string" ) { if ( typeof type !== "string" ) {
4362 obj = type; obj = type;
4363 type = undefined; type = undefined;
4364 } }
4365 type = type || "fx"; type = type || "fx";
4366
4367 while ( i-- ) { while ( i-- ) {
4368 tmp = jQuery._data( elements[ i ], type + "queueHooks" ); tmp = jQuery._data( elements[ i ], type + "queueHooks" );
4369 if ( tmp && tmp.empty ) { if ( tmp && tmp.empty ) {
4370 count++; count++;
4371 tmp.empty.add( resolve ); tmp.empty.add( resolve );
4372 } }
4373 } }
4374 resolve(); resolve();
4375 return defer.promise( obj ); return defer.promise( obj );
4376 } }
4377 }); } );
4378 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
4379
4380
4381 ( function() {
4382 var shrinkWrapBlocksVal;
4383
4384 support.shrinkWrapBlocks = function() {
4385 if ( shrinkWrapBlocksVal != null ) {
4386 return shrinkWrapBlocksVal;
4387 }
4388
4389 // Will be changed later if needed.
4390 shrinkWrapBlocksVal = false;
4391
4392 // Minified: var b,c,d
4393 var div, body, container;
4394
4395 body = document.getElementsByTagName( "body" )[ 0 ];
4396 if ( !body || !body.style ) {
4397
4398 // Test fired too early or in an unsupported environment, exit.
4399 return;
4400 }
4401
4402 // Setup
4403 div = document.createElement( "div" );
4404 container = document.createElement( "div" );
4405 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
4406 body.appendChild( container ).appendChild( div );
4407
4408 // Support: IE6
4409 // Check if elements with layout shrink-wrap their children
4410 if ( typeof div.style.zoom !== "undefined" ) {
4411
4412 // Reset CSS: box-sizing; display; margin; border
4413 div.style.cssText =
4414
4415 // Support: Firefox<29, Android 2.3
4416 // Vendor-prefix box-sizing
4417 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
4418 "box-sizing:content-box;display:block;margin:0;border:0;" +
4419 "padding:1px;width:1px;zoom:1";
4420 div.appendChild( document.createElement( "div" ) ).style.width = "5px";
4421 shrinkWrapBlocksVal = div.offsetWidth !== 3;
4422 }
4423
4424 body.removeChild( container );
4425
4426 return shrinkWrapBlocksVal;
4427 };
4428
4429 } )();
4430 var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
4431
4432 var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
4433
4434
4435 var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4436
4437 var isHidden = function( elem, el ) { var isHidden = function( elem, el ) {
4438
4439 // isHidden might be called from jQuery#filter function; // isHidden might be called from jQuery#filter function;
4440 // in that case, element will be second argument // in that case, element will be second argument
4441 elem = el || elem; elem = el || elem;
4442 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); return jQuery.css( elem, "display" ) === "none" ||
4443 !jQuery.contains( elem.ownerDocument, elem );
4444 }; };
4445
4446
4447
4448 function adjustCSS( elem, prop, valueParts, tween ) {
4449 var adjusted,
4450 scale = 1,
4451 maxIterations = 20,
4452 currentValue = tween ?
4453 function() { return tween.cur(); } :
4454 function() { return jQuery.css( elem, prop, "" ); },
4455 initial = currentValue(),
4456 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
4457
4458 // Starting value computation is required for potential unit mismatches
4459 initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
4460 rcssNum.exec( jQuery.css( elem, prop ) );
4461
4462 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
4463
4464 // Trust units reported by jQuery.css
4465 unit = unit || initialInUnit[ 3 ];
4466
4467 // Make sure we update the tween properties later on
4468 valueParts = valueParts || [];
4469
4470 // Iteratively approximate from a nonzero starting point
4471 initialInUnit = +initial || 1;
4472
4473 do {
4474
4475 // If previous iteration zeroed out, double until we get *something*.
4476 // Use string for doubling so we don't accidentally see scale as unchanged below
4477 scale = scale || ".5";
4478
4479 // Adjust and apply
4480 initialInUnit = initialInUnit / scale;
4481 jQuery.style( elem, prop, initialInUnit + unit );
4482
4483 // Update scale, tolerating zero or NaN from tween.cur()
4484 // Break the loop if scale is unchanged or perfect, or if we've just had enough.
4485 } while (
4486 scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
4487 );
4488 }
4489
4490 if ( valueParts ) {
4491 initialInUnit = +initialInUnit || +initial || 0;
4492
4493 // Apply relative offset (+=/-=) if specified
4494 adjusted = valueParts[ 1 ] ?
4495 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
4496 +valueParts[ 2 ];
4497 if ( tween ) {
4498 tween.unit = unit;
4499 tween.start = initialInUnit;
4500 tween.end = adjusted;
4501 }
4502 }
4503 return adjusted;
4504 }
4505
4506
4507 // Multifunctional method to get and set values of a collection // Multifunctional method to get and set values of a collection
4508 // The value/s can optionally be executed if it's a function // The value/s can optionally be executed if it's a function
4509 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
4510 var i = 0, var i = 0,
4511 length = elems.length, length = elems.length,
4512 bulk = key == null; bulk = key == null;
4513
4514 // Sets many values // Sets many values
4515 if ( jQuery.type( key ) === "object" ) { if ( jQuery.type( key ) === "object" ) {
4516 chainable = true; chainable = true;
4517 for ( i in key ) { for ( i in key ) {
4518 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); access( elems, fn, i, key[ i ], true, emptyGet, raw );
4519 } }
4520
4521 // Sets one value // Sets one value
4522 } else if ( value !== undefined ) { } else if ( value !== undefined ) {
4523 chainable = true; chainable = true;
4524
4525 if ( !jQuery.isFunction( value ) ) { if ( !jQuery.isFunction( value ) ) {
4526 raw = true; raw = true;
4527 } }
4528
4529 if ( bulk ) { if ( bulk ) {
4530
4531 // Bulk operations run against the entire set // Bulk operations run against the entire set
4532 if ( raw ) { if ( raw ) {
4533 fn.call( elems, value ); fn.call( elems, value );
4534 fn = null; fn = null;
4535
4536 // ...except when executing function values // ...except when executing function values
4537 } else { } else {
4538 bulk = fn; bulk = fn;
4539 fn = function( elem, key, value ) { fn = function( elem, key, value ) {
4540 return bulk.call( jQuery( elem ), value ); return bulk.call( jQuery( elem ), value );
4541 }; };
4542 } }
4543 } }
4544
4545 if ( fn ) { if ( fn ) {
4546 for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
4547 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); fn(
4548 elems[ i ],
4549 key,
4550 raw ? value : value.call( elems[ i ], i, fn( elems[ i ], key ) )
4551 );
4552 } }
4553 } }
4554 } }
4555
4556 return chainable ? return chainable ?
4557 elems : elems :
4558
4559 // Gets // Gets
4560 bulk ? bulk ?
4561 fn.call( elems ) : fn.call( elems ) :
4562 length ? fn( elems[0], key ) : emptyGet; length ? fn( elems[ 0 ], key ) : emptyGet;
4563 }; };
4564 var rcheckableType = (/^(?:checkbox|radio)$/i); var rcheckableType = ( /^(?:checkbox|radio)$/i );
4565
4566 var rtagName = ( /<([\w:-]+)/ );
4567
4568 var rscriptType = ( /^$|\/(?:java|ecma)script/i );
4569
4570 (function() { var rleadingWhitespace = ( /^\s+/ );
4571 // Minified: var a,b,c
4572 var input = document.createElement( "input" ),
4573 div = document.createElement( "div" ),
4574 fragment = document.createDocumentFragment();
4575
4576 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|" +
4577 "details|dialog|figcaption|figure|footer|header|hgroup|main|" +
4578 "mark|meter|nav|output|picture|progress|section|summary|template|time|video";
4579
4580
4581
4582 function createSafeFragment( document ) {
4583 var list = nodeNames.split( "|" ),
4584 safeFrag = document.createDocumentFragment();
4585
4586 if ( safeFrag.createElement ) {
4587 while ( list.length ) {
4588 safeFrag.createElement(
4589 list.pop()
4590 );
4591 }
4592 }
4593 return safeFrag;
4594 }
4595
4596
4597 ( function() {
4598 var div = document.createElement( "div" ),
4599 fragment = document.createDocumentFragment(),
4600 input = document.createElement( "input" );
4601
4602 // Setup // Setup
4603 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
4604
4605 // IE strips leading whitespace when .innerHTML is used // IE strips leading whitespace when .innerHTML is used
4606 support.leadingWhitespace = div.firstChild.nodeType === 3; support.leadingWhitespace = div.firstChild.nodeType === 3;
4607
4608 // Make sure that tbody elements aren't automatically inserted // Make sure that tbody elements aren't automatically inserted
4609 // IE will insert them into empty tables // IE will insert them into empty tables
4610 support.tbody = !div.getElementsByTagName( "tbody" ).length; support.tbody = !div.getElementsByTagName( "tbody" ).length;
4611
4612 // Make sure that link elements get serialized correctly by innerHTML // Make sure that link elements get serialized correctly by innerHTML
4613 // This requires a wrapper element in IE // This requires a wrapper element in IE
4614 support.htmlSerialize = !!div.getElementsByTagName( "link" ).length; support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
4615
4616 // Makes sure cloning an html5 element does not cause problems // Makes sure cloning an html5 element does not cause problems
4617 // Where outerHTML is undefined, this still works // Where outerHTML is undefined, this still works
4618 support.html5Clone = support.html5Clone =
4619 document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>"; document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
4620
4621 // Check if a disconnected checkbox will retain its checked // Check if a disconnected checkbox will retain its checked
4622 // value of true after appended to the DOM (IE6/7) // value of true after appended to the DOM (IE6/7)
4623 input.type = "checkbox"; input.type = "checkbox";
4624 input.checked = true; input.checked = true;
4625 fragment.appendChild( input ); fragment.appendChild( input );
4626 support.appendChecked = input.checked; support.appendChecked = input.checked;
4627
4628 // Make sure textarea (and checkbox) defaultValue is properly cloned // Make sure textarea (and checkbox) defaultValue is properly cloned
4629 // Support: IE6-IE11+ // Support: IE6-IE11+
4630 div.innerHTML = "<textarea>x</textarea>"; div.innerHTML = "<textarea>x</textarea>";
4631 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
4632
4633 // #11217 - WebKit loses check when the name is after the checked attribute // #11217 - WebKit loses check when the name is after the checked attribute
4634 fragment.appendChild( div ); fragment.appendChild( div );
4635 div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
4636
4637 // Support: Windows Web Apps (WWA)
4638 // `name` and `type` must use .setAttribute for WWA (#14901)
4639 input = document.createElement( "input" );
4640 input.setAttribute( "type", "radio" );
4641 input.setAttribute( "checked", "checked" );
4642 input.setAttribute( "name", "t" );
4643
4644 div.appendChild( input );
4645
4646 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
4647 // old WebKit doesn't clone checked state correctly in fragments // old WebKit doesn't clone checked state correctly in fragments
4648 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
4649
4650 // Support: IE<9 // Support: IE<9
4651 // Opera does not clone events (and typeof div.attachEvent === undefined). // Cloned elements keep attachEvent handlers, we use addEventListener on IE9+
4652 // IE9-10 clones events bound via attachEvent, but they don't trigger with .click() support.noCloneEvent = !!div.addEventListener;
4653 support.noCloneEvent = true;
4654 if ( div.attachEvent ) {
4655 div.attachEvent( "onclick", function() {
4656 support.noCloneEvent = false;
4657 });
4658
4659 div.cloneNode( true ).click(); // Support: IE<9
4660 // Since attributes and properties are the same in IE,
4661 // cleanData must set properties to undefined rather than use removeAttribute
4662 div[ jQuery.expando ] = 1;
4663 support.attributes = !div.getAttribute( jQuery.expando );
4664 } )();
4665
4666
4667 // We have to close these tags to support XHTML (#13200)
4668 var wrapMap = {
4669 option: [ 1, "<select multiple='multiple'>", "</select>" ],
4670 legend: [ 1, "<fieldset>", "</fieldset>" ],
4671 area: [ 1, "<map>", "</map>" ],
4672
4673 // Support: IE8
4674 param: [ 1, "<object>", "</object>" ],
4675 thead: [ 1, "<table>", "</table>" ],
4676 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
4677 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
4678 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4679
4680 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
4681 // unless wrapped in a div with non-breaking characters in front of it.
4682 _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
4683 };
4684
4685 // Support: IE8-IE9
4686 wrapMap.optgroup = wrapMap.option;
4687
4688 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
4689 wrapMap.th = wrapMap.td;
4690
4691
4692 function getAll( context, tag ) {
4693 var elems, elem,
4694 i = 0,
4695 found = typeof context.getElementsByTagName !== "undefined" ?
4696 context.getElementsByTagName( tag || "*" ) :
4697 typeof context.querySelectorAll !== "undefined" ?
4698 context.querySelectorAll( tag || "*" ) :
4699 undefined;
4700
4701 if ( !found ) {
4702 for ( found = [], elems = context.childNodes || context;
4703 ( elem = elems[ i ] ) != null;
4704 i++
4705 ) {
4706 if ( !tag || jQuery.nodeName( elem, tag ) ) {
4707 found.push( elem );
4708 } else {
4709 jQuery.merge( found, getAll( elem, tag ) );
4710 }
4711 }
4712 } }
4713
4714 // Execute the test only if not already executed in another module. return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
4715 if (support.deleteExpando == null) { jQuery.merge( [ context ], found ) :
4716 // Support: IE<9 found;
4717 support.deleteExpando = true; }
4718 try {
4719 delete div.test;
4720 } catch( e ) { // Mark scripts as having already been evaluated
4721 support.deleteExpando = false; function setGlobalEval( elems, refElements ) {
4722 var elem,
4723 i = 0;
4724 for ( ; ( elem = elems[ i ] ) != null; i++ ) {
4725 jQuery._data(
4726 elem,
4727 "globalEval",
4728 !refElements || jQuery._data( refElements[ i ], "globalEval" )
4729 );
4730 }
4731 }
4732
4733
4734 var rhtml = /<|&#?\w+;/,
4735 rtbody = /<tbody/i;
4736
4737 function fixDefaultChecked( elem ) {
4738 if ( rcheckableType.test( elem.type ) ) {
4739 elem.defaultChecked = elem.checked;
4740 }
4741 }
4742
4743 function buildFragment( elems, context, scripts, selection, ignored ) {
4744 var j, elem, contains,
4745 tmp, tag, tbody, wrap,
4746 l = elems.length,
4747
4748 // Ensure a safe fragment
4749 safe = createSafeFragment( context ),
4750
4751 nodes = [],
4752 i = 0;
4753
4754 for ( ; i < l; i++ ) {
4755 elem = elems[ i ];
4756
4757 if ( elem || elem === 0 ) {
4758
4759 // Add nodes directly
4760 if ( jQuery.type( elem ) === "object" ) {
4761 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
4762
4763 // Convert non-html into a text node
4764 } else if ( !rhtml.test( elem ) ) {
4765 nodes.push( context.createTextNode( elem ) );
4766
4767 // Convert html into DOM nodes
4768 } else {
4769 tmp = tmp || safe.appendChild( context.createElement( "div" ) );
4770
4771 // Deserialize a standard representation
4772 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
4773 wrap = wrapMap[ tag ] || wrapMap._default;
4774
4775 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
4776
4777 // Descend through wrappers to the right content
4778 j = wrap[ 0 ];
4779 while ( j-- ) {
4780 tmp = tmp.lastChild;
4781 }
4782
4783 // Manually add leading whitespace removed by IE
4784 if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
4785 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[ 0 ] ) );
4786 }
4787
4788 // Remove IE's autoinserted <tbody> from table fragments
4789 if ( !support.tbody ) {
4790
4791 // String was a <table>, *may* have spurious <tbody>
4792 elem = tag === "table" && !rtbody.test( elem ) ?
4793 tmp.firstChild :
4794
4795 // String was a bare <thead> or <tfoot>
4796 wrap[ 1 ] === "<table>" && !rtbody.test( elem ) ?
4797 tmp :
4798 0;
4799
4800 j = elem && elem.childNodes.length;
4801 while ( j-- ) {
4802 if ( jQuery.nodeName( ( tbody = elem.childNodes[ j ] ), "tbody" ) &&
4803 !tbody.childNodes.length ) {
4804
4805 elem.removeChild( tbody );
4806 }
4807 }
4808 }
4809
4810 jQuery.merge( nodes, tmp.childNodes );
4811
4812 // Fix #12392 for WebKit and IE > 9
4813 tmp.textContent = "";
4814
4815 // Fix #12392 for oldIE
4816 while ( tmp.firstChild ) {
4817 tmp.removeChild( tmp.firstChild );
4818 }
4819
4820 // Remember the top-level container for proper cleanup
4821 tmp = safe.lastChild;
4822 }
4823 } }
4824 } }
4825 })();
4826
4827 // Fix #11356: Clear elements from fragment
4828 if ( tmp ) {
4829 safe.removeChild( tmp );
4830 }
4831
4832 (function() { // Reset defaultChecked for any radios and checkboxes
4833 // about to be appended to the DOM in IE 6/7 (#8060)
4834 if ( !support.appendChecked ) {
4835 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
4836 }
4837
4838 i = 0;
4839 while ( ( elem = nodes[ i++ ] ) ) {
4840
4841 // Skip elements already in the context collection (trac-4087)
4842 if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
4843 if ( ignored ) {
4844 ignored.push( elem );
4845 }
4846
4847 continue;
4848 }
4849
4850 contains = jQuery.contains( elem.ownerDocument, elem );
4851
4852 // Append to fragment
4853 tmp = getAll( safe.appendChild( elem ), "script" );
4854
4855 // Preserve script evaluation history
4856 if ( contains ) {
4857 setGlobalEval( tmp );
4858 }
4859
4860 // Capture executables
4861 if ( scripts ) {
4862 j = 0;
4863 while ( ( elem = tmp[ j++ ] ) ) {
4864 if ( rscriptType.test( elem.type || "" ) ) {
4865 scripts.push( elem );
4866 }
4867 }
4868 }
4869 }
4870
4871 tmp = null;
4872
4873 return safe;
4874 }
4875
4876
4877 ( function() {
4878 var i, eventName, var i, eventName,
4879 div = document.createElement( "div" ); div = document.createElement( "div" );
4880
4881 // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event) // Support: IE<9 (lack submit/change bubble), Firefox (lack focus(in | out) events)
4882 for ( i in { submit: true, change: true, focusin: true }) { for ( i in { submit: true, change: true, focusin: true } ) {
4883 eventName = "on" + i; eventName = "on" + i;
4884
4885 if ( !(support[ i + "Bubbles" ] = eventName in window) ) { if ( !( support[ i ] = eventName in window ) ) {
4886 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP) // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
4887 div.setAttribute( eventName, "t" ); div.setAttribute( eventName, "t" );
4888 support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false; support[ i ] = div.attributes[ eventName ].expando === false;
4889 } }
4890 } }
4891
4892 // Null elements to avoid leaks in IE. // Null elements to avoid leaks in IE.
4893 div = null; div = null;
4894 })(); } )();
4895
4896
4897 var rformElems = /^(?:input|select|textarea)$/i, var rformElems = /^(?:input|select|textarea)$/i,
4898 rkeyEvent = /^key/, rkeyEvent = /^key/,
4899 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/, rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
4900 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
4901 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
4902
4903 function returnTrue() { function returnTrue() {
4904 return true; return true;
4905 } }
4906
4907 function returnFalse() { function returnFalse() {
4908 return false; return false;
4909 } }
4910
4911 // Support: IE9
4912 // See #13393 for more info
4913 function safeActiveElement() { function safeActiveElement() {
4914 try { try {
4915 return document.activeElement; return document.activeElement;
4916 } catch ( err ) { } } catch ( err ) { }
4917 } }
4918
4919 function on( elem, types, selector, data, fn, one ) {
4920 var origFn, type;
4921
4922 // Types can be a map of types/handlers
4923 if ( typeof types === "object" ) {
4924
4925 // ( types-Object, selector, data )
4926 if ( typeof selector !== "string" ) {
4927
4928 // ( types-Object, data )
4929 data = data || selector;
4930 selector = undefined;
4931 }
4932 for ( type in types ) {
4933 on( elem, type, selector, data, types[ type ], one );
4934 }
4935 return elem;
4936 }
4937
4938 if ( data == null && fn == null ) {
4939
4940 // ( types, fn )
4941 fn = selector;
4942 data = selector = undefined;
4943 } else if ( fn == null ) {
4944 if ( typeof selector === "string" ) {
4945
4946 // ( types, selector, fn )
4947 fn = data;
4948 data = undefined;
4949 } else {
4950
4951 // ( types, data, fn )
4952 fn = data;
4953 data = selector;
4954 selector = undefined;
4955 }
4956 }
4957 if ( fn === false ) {
4958 fn = returnFalse;
4959 } else if ( !fn ) {
4960 return elem;
4961 }
4962
4963 if ( one === 1 ) {
4964 origFn = fn;
4965 fn = function( event ) {
4966
4967 // Can use an empty set, since event contains the info
4968 jQuery().off( event );
4969 return origFn.apply( this, arguments );
4970 };
4971
4972 // Use same guid so caller can remove using origFn
4973 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
4974 }
4975 return elem.each( function() {
4976 jQuery.event.add( this, types, fn, data, selector );
4977 } );
4978 }
4979
4980 /* /*
4981 * Helper functions for managing events -- not part of the public interface. * Helper functions for managing events -- not part of the public interface.
4982 * Props to Dean Edwards' addEvent library for many of the ideas. * Props to Dean Edwards' addEvent library for many of the ideas.
4983 */ */
4984 jQuery.event = { jQuery.event = {
4985
4986 global: {}, global: {},
4987
4988 add: function( elem, types, handler, data, selector ) { add: function( elem, types, handler, data, selector ) {
4989 var tmp, events, t, handleObjIn, var tmp, events, t, handleObjIn,
4990 special, eventHandle, handleObj, special, eventHandle, handleObj,
4991 handlers, type, namespaces, origType, handlers, type, namespaces, origType,
4992 elemData = jQuery._data( elem ); elemData = jQuery._data( elem );
4993
4994 // Don't attach events to noData or text/comment nodes (but allow plain objects) // Don't attach events to noData or text/comment nodes (but allow plain objects)
4995 if ( !elemData ) { if ( !elemData ) {
4996 return; return;
4997 } }
4998
4999 // Caller can pass in an object of custom data in lieu of the handler // Caller can pass in an object of custom data in lieu of the handler
5000 if ( handler.handler ) { if ( handler.handler ) {
5001 handleObjIn = handler; handleObjIn = handler;
5002 handler = handleObjIn.handler; handler = handleObjIn.handler;
5003 selector = handleObjIn.selector; selector = handleObjIn.selector;
5004 } }
5005
5006 // Make sure that the handler has a unique ID, used to find/remove it later // Make sure that the handler has a unique ID, used to find/remove it later
5007 if ( !handler.guid ) { if ( !handler.guid ) {
5008 handler.guid = jQuery.guid++; handler.guid = jQuery.guid++;
5009 } }
5010
5011 // Init the element's event structure and main handler, if this is the first // Init the element's event structure and main handler, if this is the first
5012 if ( !(events = elemData.events) ) { if ( !( events = elemData.events ) ) {
5013 events = elemData.events = {}; events = elemData.events = {};
5014 } }
5015 if ( !(eventHandle = elemData.handle) ) { if ( !( eventHandle = elemData.handle ) ) {
5016 eventHandle = elemData.handle = function( e ) { eventHandle = elemData.handle = function( e ) {
5017
5018 // Discard the second event of a jQuery.event.trigger() and // Discard the second event of a jQuery.event.trigger() and
5019 // when an event is called after a page has unloaded // when an event is called after a page has unloaded
5020 return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ? return typeof jQuery !== "undefined" &&
5021 ( !e || jQuery.event.triggered !== e.type ) ?
5022 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
5023 undefined; undefined;
5024 }; };
5025 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
5026 // Add elem as a property of the handle fn to prevent a memory leak
5027 // with IE non-native events
5028 eventHandle.elem = elem; eventHandle.elem = elem;
5029 } }
5030
5031 // Handle multiple events separated by a space // Handle multiple events separated by a space
5032 types = ( types || "" ).match( rnotwhite ) || [ "" ]; types = ( types || "" ).match( rnotwhite ) || [ "" ];
5033 t = types.length; t = types.length;
5034 while ( t-- ) { while ( t-- ) {
5035 tmp = rtypenamespace.exec( types[t] ) || []; tmp = rtypenamespace.exec( types[ t ] ) || [];
5036 type = origType = tmp[1]; type = origType = tmp[ 1 ];
5037 namespaces = ( tmp[2] || "" ).split( "." ).sort(); namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
5038
5039 // There *must* be a type, no attaching namespace-only handlers // There *must* be a type, no attaching namespace-only handlers
5040 if ( !type ) { if ( !type ) {
5041 continue; continue;
5042 } }
5043
5044 // If event changes its type, use the special event handlers for the changed type // If event changes its type, use the special event handlers for the changed type
5045 special = jQuery.event.special[ type ] || {}; special = jQuery.event.special[ type ] || {};
5046
5047 // If selector defined, determine special event api type, otherwise given type // If selector defined, determine special event api type, otherwise given type
5048 type = ( selector ? special.delegateType : special.bindType ) || type; type = ( selector ? special.delegateType : special.bindType ) || type;
5049
5050 // Update special based on newly reset type // Update special based on newly reset type
5051 special = jQuery.event.special[ type ] || {}; special = jQuery.event.special[ type ] || {};
5052
5053 // handleObj is passed to all event handlers // handleObj is passed to all event handlers
5054 handleObj = jQuery.extend({ handleObj = jQuery.extend( {
5055 type: type, type: type,
5056 origType: origType, origType: origType,
5057 data: data, data: data,
5058 handler: handler, handler: handler,
5059 guid: handler.guid, guid: handler.guid,
5060 selector: selector, selector: selector,
5061 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
5062 namespace: namespaces.join(".") namespace: namespaces.join( "." )
5063 }, handleObjIn ); }, handleObjIn );
5064
5065 // Init the event handler queue if we're the first // Init the event handler queue if we're the first
5066 if ( !(handlers = events[ type ]) ) { if ( !( handlers = events[ type ] ) ) {
5067 handlers = events[ type ] = []; handlers = events[ type ] = [];
5068 handlers.delegateCount = 0; handlers.delegateCount = 0;
5069
5070 // Only use addEventListener/attachEvent if the special events handler returns false // Only use addEventListener/attachEvent if the special events handler returns false
5071 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { if ( !special.setup ||
5072 special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
5073 // Bind the global event handler to the element // Bind the global event handler to the element
5074 if ( elem.addEventListener ) { if ( elem.addEventListener ) {
5075 elem.addEventListener( type, eventHandle, false ); elem.addEventListener( type, eventHandle, false );
5076
5077 } else if ( elem.attachEvent ) { } else if ( elem.attachEvent ) {
5078 elem.attachEvent( "on" + type, eventHandle ); elem.attachEvent( "on" + type, eventHandle );
5079 } }
5080 } }
5081 } }
5082
5083 if ( special.add ) { if ( special.add ) {
5084 special.add.call( elem, handleObj ); special.add.call( elem, handleObj );
5085
5086 if ( !handleObj.handler.guid ) { if ( !handleObj.handler.guid ) {
5087 handleObj.handler.guid = handler.guid; handleObj.handler.guid = handler.guid;
5088 } }
5089 } }
5090
5091 // Add to the element's handler list, delegates in front // Add to the element's handler list, delegates in front
5092 if ( selector ) { if ( selector ) {
5093 handlers.splice( handlers.delegateCount++, 0, handleObj ); handlers.splice( handlers.delegateCount++, 0, handleObj );
5094 } else { } else {
5095 handlers.push( handleObj ); handlers.push( handleObj );
5096 } }
5097
5098 // Keep track of which events have ever been used, for event optimization // Keep track of which events have ever been used, for event optimization
5099 jQuery.event.global[ type ] = true; jQuery.event.global[ type ] = true;
5100 } }
5101
5102 // Nullify elem to prevent memory leaks in IE // Nullify elem to prevent memory leaks in IE
5103 elem = null; elem = null;
5104 }, },
5105
5106 // Detach an event or set of events from an element // Detach an event or set of events from an element
5107 remove: function( elem, types, handler, selector, mappedTypes ) { remove: function( elem, types, handler, selector, mappedTypes ) {
5108 var j, handleObj, tmp, var j, handleObj, tmp,
5109 origCount, t, events, origCount, t, events,
5110 special, handlers, type, special, handlers, type,
5111 namespaces, origType, namespaces, origType,
5112 elemData = jQuery.hasData( elem ) && jQuery._data( elem ); elemData = jQuery.hasData( elem ) && jQuery._data( elem );
5113
5114 if ( !elemData || !(events = elemData.events) ) { if ( !elemData || !( events = elemData.events ) ) {
5115 return; return;
5116 } }
5117
5118 // Once for each type.namespace in types; type may be omitted // Once for each type.namespace in types; type may be omitted
5119 types = ( types || "" ).match( rnotwhite ) || [ "" ]; types = ( types || "" ).match( rnotwhite ) || [ "" ];
5120 t = types.length; t = types.length;
5121 while ( t-- ) { while ( t-- ) {
5122 tmp = rtypenamespace.exec( types[t] ) || []; tmp = rtypenamespace.exec( types[ t ] ) || [];
5123 type = origType = tmp[1]; type = origType = tmp[ 1 ];
5124 namespaces = ( tmp[2] || "" ).split( "." ).sort(); namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
5125
5126 // Unbind all events (on this namespace, if provided) for the element // Unbind all events (on this namespace, if provided) for the element
5127 if ( !type ) { if ( !type ) {
5128 for ( type in events ) { for ( type in events ) {
5129 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
5130 } }
5131 continue; continue;
5132 } }
5133
5134 special = jQuery.event.special[ type ] || {}; special = jQuery.event.special[ type ] || {};
5135 type = ( selector ? special.delegateType : special.bindType ) || type; type = ( selector ? special.delegateType : special.bindType ) || type;
5136 handlers = events[ type ] || []; handlers = events[ type ] || [];
5137 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); tmp = tmp[ 2 ] &&
5138 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
5139
5140 // Remove matching events // Remove matching events
5141 origCount = j = handlers.length; origCount = j = handlers.length;
5142 while ( j-- ) { while ( j-- ) {
5143 handleObj = handlers[ j ]; handleObj = handlers[ j ];
5144
5145 if ( ( mappedTypes || origType === handleObj.origType ) && if ( ( mappedTypes || origType === handleObj.origType ) &&
5146 ( !handler || handler.guid === handleObj.guid ) && ( !handler || handler.guid === handleObj.guid ) &&
5147 ( !tmp || tmp.test( handleObj.namespace ) ) && ( !tmp || tmp.test( handleObj.namespace ) ) &&
5148 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { ( !selector || selector === handleObj.selector ||
5149 selector === "**" && handleObj.selector ) ) {
5150 handlers.splice( j, 1 ); handlers.splice( j, 1 );
5151
5152 if ( handleObj.selector ) { if ( handleObj.selector ) {
5153 handlers.delegateCount--; handlers.delegateCount--;
5154 } }
5155 if ( special.remove ) { if ( special.remove ) {
5156 special.remove.call( elem, handleObj ); special.remove.call( elem, handleObj );
5157 } }
5158 } }
5159 } }
5160
5161 // Remove generic event handler if we removed something and no more handlers exist // Remove generic event handler if we removed something and no more handlers exist
5162 // (avoids potential for endless recursion during removal of special event handlers) // (avoids potential for endless recursion during removal of special event handlers)
5163 if ( origCount && !handlers.length ) { if ( origCount && !handlers.length ) {
5164 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { if ( !special.teardown ||
5165 special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
5166 jQuery.removeEvent( elem, type, elemData.handle ); jQuery.removeEvent( elem, type, elemData.handle );
5167 } }
5168
5169 delete events[ type ]; delete events[ type ];
5170 } }
5171 } }
5172
5173 // Remove the expando if it's no longer used // Remove the expando if it's no longer used
5174 if ( jQuery.isEmptyObject( events ) ) { if ( jQuery.isEmptyObject( events ) ) {
5175 delete elemData.handle; delete elemData.handle;
5176
5177 // removeData also checks for emptiness and clears the expando if empty // removeData also checks for emptiness and clears the expando if empty
5178 // so use it instead of delete // so use it instead of delete
5179 jQuery._removeData( elem, "events" ); jQuery._removeData( elem, "events" );
5180 } }
5181 }, },
5182
5183 trigger: function( event, data, elem, onlyHandlers ) { trigger: function( event, data, elem, onlyHandlers ) {
5184 var handle, ontype, cur, var handle, ontype, cur,
5185 bubbleType, special, tmp, i, bubbleType, special, tmp, i,
5186 eventPath = [ elem || document ], eventPath = [ elem || document ],
5187 type = hasOwn.call( event, "type" ) ? event.type : event, type = hasOwn.call( event, "type" ) ? event.type : event,
5188 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
5189
5190 cur = tmp = elem = elem || document; cur = tmp = elem = elem || document;
5191
5192 // Don't do events on text and comment nodes // Don't do events on text and comment nodes
5193 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
5194 return; return;
5195 } }
5196
5197 // focus/blur morphs to focusin/out; ensure we're not firing them right now // focus/blur morphs to focusin/out; ensure we're not firing them right now
5198 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
5199 return; return;
5200 } }
5201
5202 if ( type.indexOf(".") >= 0 ) { if ( type.indexOf( "." ) > -1 ) {
5203 // Namespaced trigger; create a regexp to match event type in handle() // Namespaced trigger; create a regexp to match event type in handle()
5204 namespaces = type.split("."); namespaces = type.split( "." );
5205 type = namespaces.shift(); type = namespaces.shift();
5206 namespaces.sort(); namespaces.sort();
5207 } }
5208 ontype = type.indexOf(":") < 0 && "on" + type; ontype = type.indexOf( ":" ) < 0 && "on" + type;
5209
5210 // Caller can pass in a jQuery.Event object, Object, or just an event type string // Caller can pass in a jQuery.Event object, Object, or just an event type string
5211 event = event[ jQuery.expando ] ? event = event[ jQuery.expando ] ?
5212 event : event :
5213 new jQuery.Event( type, typeof event === "object" && event ); new jQuery.Event( type, typeof event === "object" && event );
5214
5215 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
5216 event.isTrigger = onlyHandlers ? 2 : 3; event.isTrigger = onlyHandlers ? 2 : 3;
5217 event.namespace = namespaces.join("."); event.namespace = namespaces.join( "." );
5218 event.namespace_re = event.namespace ? event.rnamespace = event.namespace ?
5219 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
5220 null; null;
5221
5222 // Clean up the event in case it is being reused // Clean up the event in case it is being reused
5223 event.result = undefined; event.result = undefined;
5224 if ( !event.target ) { if ( !event.target ) {
5225 event.target = elem; event.target = elem;
5226 } }
5227
5228 // Clone any incoming data and prepend the event, creating the handler arg list // Clone any incoming data and prepend the event, creating the handler arg list
5229 data = data == null ? data = data == null ?
5230 [ event ] : [ event ] :
5231 jQuery.makeArray( data, [ event ] ); jQuery.makeArray( data, [ event ] );
5232
5233 // Allow special events to draw outside the lines // Allow special events to draw outside the lines
5234 special = jQuery.event.special[ type ] || {}; special = jQuery.event.special[ type ] || {};
5235 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
5236 return; return;
5237 } }
5238
5239 // Determine event propagation path in advance, per W3C events spec (#9951) // Determine event propagation path in advance, per W3C events spec (#9951)
5240 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
5241 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
5242
5243 bubbleType = special.delegateType || type; bubbleType = special.delegateType || type;
5244 if ( !rfocusMorph.test( bubbleType + type ) ) { if ( !rfocusMorph.test( bubbleType + type ) ) {
5245 cur = cur.parentNode; cur = cur.parentNode;
5246 } }
5247 for ( ; cur; cur = cur.parentNode ) { for ( ; cur; cur = cur.parentNode ) {
5248 eventPath.push( cur ); eventPath.push( cur );
5249 tmp = cur; tmp = cur;
5250 } }
5251
5252 // Only add window if we got to document (e.g., not plain obj or detached DOM) // Only add window if we got to document (e.g., not plain obj or detached DOM)
5253 if ( tmp === (elem.ownerDocument || document) ) { if ( tmp === ( elem.ownerDocument || document ) ) {
5254 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); eventPath.push( tmp.defaultView || tmp.parentWindow || window );
5255 } }
5256 } }
5257
5258 // Fire handlers on the event path // Fire handlers on the event path
5259 i = 0; i = 0;
5260 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
5261
5262 event.type = i > 1 ? event.type = i > 1 ?
5263 bubbleType : bubbleType :
5264 special.bindType || type; special.bindType || type;
5265
5266 // jQuery handler // jQuery handler
5267 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] &&
5268 jQuery._data( cur, "handle" );
5269 if ( handle ) { if ( handle ) {
5270 handle.apply( cur, data ); handle.apply( cur, data );
5271 } }
5272
5273 // Native handler // Native handler
5274 handle = ontype && cur[ ontype ]; handle = ontype && cur[ ontype ];
5275 if ( handle && handle.apply && jQuery.acceptData( cur ) ) { if ( handle && handle.apply && acceptData( cur ) ) {
5276 event.result = handle.apply( cur, data ); event.result = handle.apply( cur, data );
5277 if ( event.result === false ) { if ( event.result === false ) {
5278 event.preventDefault(); event.preventDefault();
5279 } }
5280 } }
5281 } }
5282 event.type = type; event.type = type;
5283
5284 // If nobody prevented the default action, do it now // If nobody prevented the default action, do it now
5285 if ( !onlyHandlers && !event.isDefaultPrevented() ) { if ( !onlyHandlers && !event.isDefaultPrevented() ) {
5286
5287 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && if (
5288 jQuery.acceptData( elem ) ) { ( !special._default ||
5289 special._default.apply( eventPath.pop(), data ) === false
5290 ) && acceptData( elem )
5291 ) {
5292
5293 // Call a native DOM method on the target with the same name name as the event. // Call a native DOM method on the target with the same name name as the event.
5294 // Can't use an .isFunction() check here because IE6/7 fails that test. // Can't use an .isFunction() check here because IE6/7 fails that test.
5295 // Don't do default actions on window, that's where global variables be (#6170) // Don't do default actions on window, that's where global variables be (#6170)
5296 if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
5297
5298 // Don't re-trigger an onFOO event when we call its FOO() method // Don't re-trigger an onFOO event when we call its FOO() method
5299 tmp = elem[ ontype ]; tmp = elem[ ontype ];
5300
5301 if ( tmp ) { if ( tmp ) {
5302 elem[ ontype ] = null; elem[ ontype ] = null;
5303 } }
5304
5305 // Prevent re-triggering of the same event, since we already bubbled it above // Prevent re-triggering of the same event, since we already bubbled it above
5306 jQuery.event.triggered = type; jQuery.event.triggered = type;
5307 try { try {
5308 elem[ type ](); elem[ type ]();
5309 } catch ( e ) { } catch ( e ) {
5310
5311 // IE<9 dies on focus/blur to hidden element (#1486,#12518) // IE<9 dies on focus/blur to hidden element (#1486,#12518)
5312 // only reproducible on winXP IE8 native, not IE9 in IE8 mode // only reproducible on winXP IE8 native, not IE9 in IE8 mode
5313 } }
5314 jQuery.event.triggered = undefined; jQuery.event.triggered = undefined;
5315
5316 if ( tmp ) { if ( tmp ) {
5317 elem[ ontype ] = tmp; elem[ ontype ] = tmp;
5318 } }
5319 } }
5320 } }
5321 } }
5322
5323 return event.result; return event.result;
5324 }, },
5325
5326 dispatch: function( event ) { dispatch: function( event ) {
5327
5328 // Make a writable jQuery.Event from the native event object // Make a writable jQuery.Event from the native event object
5329 event = jQuery.event.fix( event ); event = jQuery.event.fix( event );
5330
5331 var i, ret, handleObj, matched, j, var i, j, ret, matched, handleObj,
5332 handlerQueue = [], handlerQueue = [],
5333 args = slice.call( arguments ), args = slice.call( arguments ),
5334 handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [], handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
5335 special = jQuery.event.special[ event.type ] || {}; special = jQuery.event.special[ event.type ] || {};
5336
5337 // Use the fix-ed jQuery.Event rather than the (read-only) native event // Use the fix-ed jQuery.Event rather than the (read-only) native event
5338 args[0] = event; args[ 0 ] = event;
5339 event.delegateTarget = this; event.delegateTarget = this;
5340
5341 // Call the preDispatch hook for the mapped type, and let it bail if desired // Call the preDispatch hook for the mapped type, and let it bail if desired
5342 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
5343 return; return;
5344 } }
5345
5346 // Determine handlers // Determine handlers
5347 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); handlerQueue = jQuery.event.handlers.call( this, event, handlers );
5348
5349 // Run delegates first; they may want to stop propagation beneath us // Run delegates first; they may want to stop propagation beneath us
5350 i = 0; i = 0;
5351 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
5352 event.currentTarget = matched.elem; event.currentTarget = matched.elem;
5353
5354 j = 0; j = 0;
5355 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { while ( ( handleObj = matched.handlers[ j++ ] ) &&
5356 !event.isImmediatePropagationStopped() ) {
5357
5358 // Triggered event must either 1) have no namespace, or // Triggered event must either 1) have no namespace, or 2) have namespace(s)
5359 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). // a subset or equal to those in the bound event (both can have no namespace).
5360 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
5361
5362 event.handleObj = handleObj; event.handleObj = handleObj;
5363 event.data = handleObj.data; event.data = handleObj.data;
5364
5365 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
5366 .apply( matched.elem, args ); handleObj.handler ).apply( matched.elem, args );
5367
5368 if ( ret !== undefined ) { if ( ret !== undefined ) {
5369 if ( (event.result = ret) === false ) { if ( ( event.result = ret ) === false ) {
5370 event.preventDefault(); event.preventDefault();
5371 event.stopPropagation(); event.stopPropagation();
5372 } }
5373 } }
5374 } }
5375 } }
5376 } }
5377
5378 // Call the postDispatch hook for the mapped type // Call the postDispatch hook for the mapped type
5379 if ( special.postDispatch ) { if ( special.postDispatch ) {
5380 special.postDispatch.call( this, event ); special.postDispatch.call( this, event );
5381 } }
5382
5383 return event.result; return event.result;
5384 }, },
5385
5386 handlers: function( event, handlers ) { handlers: function( event, handlers ) {
5387 var sel, handleObj, matches, i, var i, matches, sel, handleObj,
5388 handlerQueue = [], handlerQueue = [],
5389 delegateCount = handlers.delegateCount, delegateCount = handlers.delegateCount,
5390 cur = event.target; cur = event.target;
5391
5392 // Support (at least): Chrome, IE9
5393 // Find delegate handlers // Find delegate handlers
5394 // Black-hole SVG <use> instance trees (#13180) // Black-hole SVG <use> instance trees (#13180)
5395 // Avoid non-left-click bubbling in Firefox (#3861) //
5396 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { // Support: Firefox<=42+
5397 // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)
5398 if ( delegateCount && cur.nodeType &&
5399 ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) {
5400
5401 /* jshint eqeqeq: false */ /* jshint eqeqeq: false */
5402 for ( ; cur != this; cur = cur.parentNode || this ) { for ( ; cur != this; cur = cur.parentNode || this ) {
5403 /* jshint eqeqeq: true */ /* jshint eqeqeq: true */
5404
5405 // Don't check non-elements (#13208) // Don't check non-elements (#13208)
5406 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
5407 if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) { if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) {
5408 matches = []; matches = [];
5409 for ( i = 0; i < delegateCount; i++ ) { for ( i = 0; i < delegateCount; i++ ) {
5410 handleObj = handlers[ i ]; handleObj = handlers[ i ];
5411
5412 // Don't conflict with Object.prototype properties (#13203) // Don't conflict with Object.prototype properties (#13203)
5413 sel = handleObj.selector + " "; sel = handleObj.selector + " ";
5414
5415 if ( matches[ sel ] === undefined ) { if ( matches[ sel ] === undefined ) {
5416 matches[ sel ] = handleObj.needsContext ? matches[ sel ] = handleObj.needsContext ?
5417 jQuery( sel, this ).index( cur ) >= 0 : jQuery( sel, this ).index( cur ) > -1 :
5418 jQuery.find( sel, this, null, [ cur ] ).length; jQuery.find( sel, this, null, [ cur ] ).length;
5419 } }
5420 if ( matches[ sel ] ) { if ( matches[ sel ] ) {
5421 matches.push( handleObj ); matches.push( handleObj );
5422 } }
5423 } }
5424 if ( matches.length ) { if ( matches.length ) {
5425 handlerQueue.push({ elem: cur, handlers: matches }); handlerQueue.push( { elem: cur, handlers: matches } );
5426 } }
5427 } }
5428 } }
5429 } }
5430
5431 // Add the remaining (directly-bound) handlers // Add the remaining (directly-bound) handlers
5432 if ( delegateCount < handlers.length ) { if ( delegateCount < handlers.length ) {
5433 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );
5434 } }
5435
5436 return handlerQueue; return handlerQueue;
5437 }, },
5438
5439 fix: function( event ) { fix: function( event ) {
5440 if ( event[ jQuery.expando ] ) { if ( event[ jQuery.expando ] ) {
5441 return event; return event;
5442 } }
5443
5444 // Create a writable copy of the event object and normalize some properties // Create a writable copy of the event object and normalize some properties
5445 var i, prop, copy, var i, prop, copy,
5446 type = event.type, type = event.type,
5447 originalEvent = event, originalEvent = event,
5448 fixHook = this.fixHooks[ type ]; fixHook = this.fixHooks[ type ];
5449
5450 if ( !fixHook ) { if ( !fixHook ) {
5451 this.fixHooks[ type ] = fixHook = this.fixHooks[ type ] = fixHook =
5452 rmouseEvent.test( type ) ? this.mouseHooks : rmouseEvent.test( type ) ? this.mouseHooks :
5453 rkeyEvent.test( type ) ? this.keyHooks : rkeyEvent.test( type ) ? this.keyHooks :
5454 {}; {};
5455 } }
5456 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
5457
5458 event = new jQuery.Event( originalEvent ); event = new jQuery.Event( originalEvent );
5459
5460 i = copy.length; i = copy.length;
5461 while ( i-- ) { while ( i-- ) {
5462 prop = copy[ i ]; prop = copy[ i ];
5463 event[ prop ] = originalEvent[ prop ]; event[ prop ] = originalEvent[ prop ];
5464 } }
5465
5466 // Support: IE<9 // Support: IE<9
5467 // Fix target property (#1925) // Fix target property (#1925)
5468 if ( !event.target ) { if ( !event.target ) {
5469 event.target = originalEvent.srcElement || document; event.target = originalEvent.srcElement || document;
5470 } }
5471
5472 // Support: Chrome 23+, Safari? // Support: Safari 6-8+
5473 // Target should not be a text node (#504, #13143) // Target should not be a text node (#504, #13143)
5474 if ( event.target.nodeType === 3 ) { if ( event.target.nodeType === 3 ) {
5475 event.target = event.target.parentNode; event.target = event.target.parentNode;
5476 } }
5477
5478 // Support: IE<9 // Support: IE<9
5479 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328) // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
5480 event.metaKey = !!event.metaKey; event.metaKey = !!event.metaKey;
5481
5482 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
5483 }, },
5484
5485 // Includes some event props shared by KeyEvent and MouseEvent // Includes some event props shared by KeyEvent and MouseEvent
5486 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
5487 "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),
5488
5489 fixHooks: {}, fixHooks: {},
5490
5491 keyHooks: { keyHooks: {
5492 props: "char charCode key keyCode".split(" "), props: "char charCode key keyCode".split( " " ),
5493 filter: function( event, original ) { filter: function( event, original ) {
5494
5495 // Add which for key events // Add which for key events
5496 if ( event.which == null ) { if ( event.which == null ) {
5497 event.which = original.charCode != null ? original.charCode : original.keyCode; event.which = original.charCode != null ? original.charCode : original.keyCode;
5498 } }
5499
5500 return event; return event;
5501 } }
5502 }, },
5503
5504 mouseHooks: { mouseHooks: {
5505 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), props: ( "button buttons clientX clientY fromElement offsetX offsetY " +
5506 "pageX pageY screenX screenY toElement" ).split( " " ),
5507 filter: function( event, original ) { filter: function( event, original ) {
5508 var body, eventDoc, doc, var body, eventDoc, doc,
5509 button = original.button, button = original.button,
5510 fromElement = original.fromElement; fromElement = original.fromElement;
5511
5512 // Calculate pageX/Y if missing and clientX/Y available // Calculate pageX/Y if missing and clientX/Y available
5513 if ( event.pageX == null && original.clientX != null ) { if ( event.pageX == null && original.clientX != null ) {
5514 eventDoc = event.target.ownerDocument || document; eventDoc = event.target.ownerDocument || document;
5515 doc = eventDoc.documentElement; doc = eventDoc.documentElement;
5516 body = eventDoc.body; body = eventDoc.body;
5517
5518 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); event.pageX = original.clientX +
5519 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -
5520 ( doc && doc.clientLeft || body && body.clientLeft || 0 );
5521 event.pageY = original.clientY +
5522 ( doc && doc.scrollTop || body && body.scrollTop || 0 ) -
5523 ( doc && doc.clientTop || body && body.clientTop || 0 );
5524 } }
5525
5526 // Add relatedTarget, if necessary // Add relatedTarget, if necessary
5527 if ( !event.relatedTarget && fromElement ) { if ( !event.relatedTarget && fromElement ) {
5528 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; event.relatedTarget = fromElement === event.target ?
5529 original.toElement :
5530 fromElement;
5531 } }
5532
5533 // Add which for click: 1 === left; 2 === middle; 3 === right // Add which for click: 1 === left; 2 === middle; 3 === right
5534 // Note: button is not normalized, so don't use it // Note: button is not normalized, so don't use it
5535 if ( !event.which && button !== undefined ) { if ( !event.which && button !== undefined ) {
5536 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
5537 } }
5538
5539 return event; return event;
5540 } }
5541 }, },
5542
5543 special: { special: {
5544 load: { load: {
5545
5546 // Prevent triggered image.load events from bubbling to window.load // Prevent triggered image.load events from bubbling to window.load
5547 noBubble: true noBubble: true
5548 }, },
5549 focus: { focus: {
5550
5551 // Fire native event if possible so blur/focus sequence is correct // Fire native event if possible so blur/focus sequence is correct
5552 trigger: function() { trigger: function() {
5553 if ( this !== safeActiveElement() && this.focus ) { if ( this !== safeActiveElement() && this.focus ) {
5554 try { try {
5555 this.focus(); this.focus();
5556 return false; return false;
5557 } catch ( e ) { } catch ( e ) {
5558
5559 // Support: IE<9 // Support: IE<9
5560 // If we error on focus to hidden element (#1486, #12518), // If we error on focus to hidden element (#1486, #12518),
5561 // let .trigger() run the handlers // let .trigger() run the handlers
5562 } }
5563 } }
5564 }, },
5565 delegateType: "focusin" delegateType: "focusin"
5566 }, },
5567 blur: { blur: {
5568 trigger: function() { trigger: function() {
5569 if ( this === safeActiveElement() && this.blur ) { if ( this === safeActiveElement() && this.blur ) {
5570 this.blur(); this.blur();
5571 return false; return false;
5572 } }
5573 }, },
5574 delegateType: "focusout" delegateType: "focusout"
5575 }, },
5576 click: { click: {
5577
5578 // For checkbox, fire native event so checked state will be right // For checkbox, fire native event so checked state will be right
5579 trigger: function() { trigger: function() {
5580 if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) { if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
5581 this.click(); this.click();
5582 return false; return false;
5583 } }
5584 }, },
5585
5586 // For cross-browser consistency, don't fire native .click() on links // For cross-browser consistency, don't fire native .click() on links
5587 _default: function( event ) { _default: function( event ) {
5588 return jQuery.nodeName( event.target, "a" ); return jQuery.nodeName( event.target, "a" );
5589 } }
5590 }, },
5591
5592 beforeunload: { beforeunload: {
5593 postDispatch: function( event ) { postDispatch: function( event ) {
5594
5595 // Support: Firefox 20+ // Support: Firefox 20+
5596 // Firefox doesn't alert if the returnValue field is not set. // Firefox doesn't alert if the returnValue field is not set.
5597 if ( event.result !== undefined && event.originalEvent ) { if ( event.result !== undefined && event.originalEvent ) {
5598 event.originalEvent.returnValue = event.result; event.originalEvent.returnValue = event.result;
5599 } }
5600 } }
5601 } }
5602 }, },
5603
5604 simulate: function( type, elem, event, bubble ) { // Piggyback on a donor event to simulate a different one
5605 // Piggyback on a donor event to simulate a different one. simulate: function( type, elem, event ) {
5606 // Fake originalEvent to avoid donor's stopPropagation, but if the
5607 // simulated event prevents default then we do the same on the donor.
5608 var e = jQuery.extend( var e = jQuery.extend(
5609 new jQuery.Event(), new jQuery.Event(),
5610 event, event,
5611 { {
5612 type: type, type: type,
5613 isSimulated: true, isSimulated: true
5614 originalEvent: {}
5615 // Previously, `originalEvent: {}` was set here, so stopPropagation call
5616 // would not be triggered on donor event, since in our own
5617 // jQuery.event.stopPropagation function we had a check for existence of
5618 // originalEvent.stopPropagation method, so, consequently it would be a noop.
5619 //
5620 // Guard for simulated events was moved to jQuery.event.stopPropagation function
5621 // since `originalEvent` should point to the original event for the
5622 // constancy with other events and for more focused logic
5623 } }
5624 ); );
5625 if ( bubble ) {
5626 jQuery.event.trigger( e, null, elem ); jQuery.event.trigger( e, null, elem );
5627 } else {
5628 jQuery.event.dispatch.call( elem, e );
5629 }
5630 if ( e.isDefaultPrevented() ) { if ( e.isDefaultPrevented() ) {
5631 event.preventDefault(); event.preventDefault();
5632 } }
5633 } }
5634 }; };
5635
5636 jQuery.removeEvent = document.removeEventListener ? jQuery.removeEvent = document.removeEventListener ?
5637 function( elem, type, handle ) { function( elem, type, handle ) {
5638
5639 // This "if" is needed for plain objects
5640 if ( elem.removeEventListener ) { if ( elem.removeEventListener ) {
5641 elem.removeEventListener( type, handle, false ); elem.removeEventListener( type, handle );
5642 } }
5643 } : } :
5644 function( elem, type, handle ) { function( elem, type, handle ) {
5645 var name = "on" + type; var name = "on" + type;
5646
5647 if ( elem.detachEvent ) { if ( elem.detachEvent ) {
5648
5649 // #8545, #7054, preventing memory leaks for custom events in IE6-8 // #8545, #7054, preventing memory leaks for custom events in IE6-8
5650 // detachEvent needed property on element, by name of that event, to properly expose it to GC // detachEvent needed property on element, by name of that event,
5651 if ( typeof elem[ name ] === strundefined ) { // to properly expose it to GC
5652 if ( typeof elem[ name ] === "undefined" ) {
5653 elem[ name ] = null; elem[ name ] = null;
5654 } }
5655
5656 elem.detachEvent( name, handle ); elem.detachEvent( name, handle );
5657 } }
5658 }; };
5659
5660 jQuery.Event = function( src, props ) { jQuery.Event = function( src, props ) {
5661
5662 // Allow instantiation without the 'new' keyword // Allow instantiation without the 'new' keyword
5663 if ( !(this instanceof jQuery.Event) ) { if ( !( this instanceof jQuery.Event ) ) {
5664 return new jQuery.Event( src, props ); return new jQuery.Event( src, props );
5665 } }
5666
5667 // Event object // Event object
5668 if ( src && src.type ) { if ( src && src.type ) {
5669 this.originalEvent = src; this.originalEvent = src;
5670 this.type = src.type; this.type = src.type;
5671
5672 // Events bubbling up the document may have been marked as prevented // Events bubbling up the document may have been marked as prevented
5673 // by a handler lower down the tree; reflect the correct value. // by a handler lower down the tree; reflect the correct value.
5674 this.isDefaultPrevented = src.defaultPrevented || this.isDefaultPrevented = src.defaultPrevented ||
5675 src.defaultPrevented === undefined && src.defaultPrevented === undefined &&
5676
5677 // Support: IE < 9, Android < 4.0 // Support: IE < 9, Android < 4.0
5678 src.returnValue === false ? src.returnValue === false ?
5679 returnTrue : returnTrue :
5680 returnFalse; returnFalse;
5681
5682 // Event type // Event type
5683 } else { } else {
5684 this.type = src; this.type = src;
5685 } }
5686
5687 // Put explicitly provided properties onto the event object // Put explicitly provided properties onto the event object
5688 if ( props ) { if ( props ) {
5689 jQuery.extend( this, props ); jQuery.extend( this, props );
5690 } }
5691
5692 // Create a timestamp if incoming event doesn't have one // Create a timestamp if incoming event doesn't have one
5693 this.timeStamp = src && src.timeStamp || jQuery.now(); this.timeStamp = src && src.timeStamp || jQuery.now();
5694
5695 // Mark it as fixed // Mark it as fixed
5696 this[ jQuery.expando ] = true; this[ jQuery.expando ] = true;
5697 }; };
5698
5699 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5700 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5701 jQuery.Event.prototype = { jQuery.Event.prototype = {
5702 constructor: jQuery.Event,
5703 isDefaultPrevented: returnFalse, isDefaultPrevented: returnFalse,
5704 isPropagationStopped: returnFalse, isPropagationStopped: returnFalse,
5705 isImmediatePropagationStopped: returnFalse, isImmediatePropagationStopped: returnFalse,
5706
5707 preventDefault: function() { preventDefault: function() {
5708 var e = this.originalEvent; var e = this.originalEvent;
5709
5710 this.isDefaultPrevented = returnTrue; this.isDefaultPrevented = returnTrue;
5711 if ( !e ) { if ( !e ) {
5712 return; return;
5713 } }
5714
5715 // If preventDefault exists, run it on the original event // If preventDefault exists, run it on the original event
5716 if ( e.preventDefault ) { if ( e.preventDefault ) {
5717 e.preventDefault(); e.preventDefault();
5718
5719 // Support: IE // Support: IE
5720 // Otherwise set the returnValue property of the original event to false // Otherwise set the returnValue property of the original event to false
5721 } else { } else {
5722 e.returnValue = false; e.returnValue = false;
5723 } }
5724 }, },
5725 stopPropagation: function() { stopPropagation: function() {
5726 var e = this.originalEvent; var e = this.originalEvent;
5727
5728 this.isPropagationStopped = returnTrue; this.isPropagationStopped = returnTrue;
5729 if ( !e ) {
5730 if ( !e || this.isSimulated ) {
5731 return; return;
5732 } }
5733
5734 // If stopPropagation exists, run it on the original event // If stopPropagation exists, run it on the original event
5735 if ( e.stopPropagation ) { if ( e.stopPropagation ) {
5736 e.stopPropagation(); e.stopPropagation();
5737 } }
5738
5739 // Support: IE // Support: IE
5740 // Set the cancelBubble property of the original event to true // Set the cancelBubble property of the original event to true
5741 e.cancelBubble = true; e.cancelBubble = true;
5742 }, },
5743 stopImmediatePropagation: function() { stopImmediatePropagation: function() {
5744 var e = this.originalEvent; var e = this.originalEvent;
5745
5746 this.isImmediatePropagationStopped = returnTrue; this.isImmediatePropagationStopped = returnTrue;
5747
5748 if ( e && e.stopImmediatePropagation ) { if ( e && e.stopImmediatePropagation ) {
5749 e.stopImmediatePropagation(); e.stopImmediatePropagation();
5750 } }
5751
5752 this.stopPropagation(); this.stopPropagation();
5753 } }
5754 }; };
5755
5756 // Create mouseenter/leave events using mouseover/out and event-time checks // Create mouseenter/leave events using mouseover/out and event-time checks
5757 jQuery.each({ // so that event delegation works in jQuery.
5758 // Do the same for pointerenter/pointerleave and pointerover/pointerout
5759 //
5760 // Support: Safari 7 only
5761 // Safari sends mouseenter too often; see:
5762 // https://code.google.com/p/chromium/issues/detail?id=470258
5763 // for the description of the bug (it existed in older Chrome versions as well).
5764 jQuery.each( {
5765 mouseenter: "mouseover", mouseenter: "mouseover",
5766 mouseleave: "mouseout", mouseleave: "mouseout",
5767 pointerenter: "pointerover", pointerenter: "pointerover",
5768 pointerleave: "pointerout" pointerleave: "pointerout"
5769 }, function( orig, fix ) { }, function( orig, fix ) {
5770 jQuery.event.special[ orig ] = { jQuery.event.special[ orig ] = {
5771 delegateType: fix, delegateType: fix,
5772 bindType: fix, bindType: fix,
5773
5774 handle: function( event ) { handle: function( event ) {
5775 var ret, var ret,
5776 target = this, target = this,
5777 related = event.relatedTarget, related = event.relatedTarget,
5778 handleObj = event.handleObj; handleObj = event.handleObj;
5779
5780 // For mousenter/leave call the handler if related is outside the target. // For mouseenter/leave call the handler if related is outside the target.
5781 // NB: No relatedTarget if the mouse left/entered the browser window // NB: No relatedTarget if the mouse left/entered the browser window
5782 if ( !related || (related !== target && !jQuery.contains( target, related )) ) { if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
5783 event.type = handleObj.origType; event.type = handleObj.origType;
5784 ret = handleObj.handler.apply( this, arguments ); ret = handleObj.handler.apply( this, arguments );
5785 event.type = fix; event.type = fix;
5786 } }
5787 return ret; return ret;
5788 } }
5789 }; };
5790 }); } );
5791
5792 // IE submit delegation // IE submit delegation
5793 if ( !support.submitBubbles ) { if ( !support.submit ) {
5794
5795 jQuery.event.special.submit = { jQuery.event.special.submit = {
5796 setup: function() { setup: function() {
5797
5798 // Only need this for delegated form submit events // Only need this for delegated form submit events
5799 if ( jQuery.nodeName( this, "form" ) ) { if ( jQuery.nodeName( this, "form" ) ) {
5800 return false; return false;
5801 } }
5802
5803 // Lazy-add a submit handler when a descendant form may potentially be submitted // Lazy-add a submit handler when a descendant form may potentially be submitted
5804 jQuery.event.add( this, "click._submit keypress._submit", function( e ) { jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
5805
5806 // Node name check avoids a VML-related crash in IE (#9807) // Node name check avoids a VML-related crash in IE (#9807)
5807 var elem = e.target, var elem = e.target,
5808 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ?
5809 if ( form && !jQuery._data( form, "submitBubbles" ) ) {
5810 // Support: IE <=8
5811 // We use jQuery.prop instead of elem.form
5812 // to allow fixing the IE8 delegated submit issue (gh-2332)
5813 // by 3rd party polyfills/workarounds.
5814 jQuery.prop( elem, "form" ) :
5815 undefined;
5816
5817 if ( form && !jQuery._data( form, "submit" ) ) {
5818 jQuery.event.add( form, "submit._submit", function( event ) { jQuery.event.add( form, "submit._submit", function( event ) {
5819 event._submit_bubble = true; event._submitBubble = true;
5820 }); } );
5821 jQuery._data( form, "submitBubbles", true ); jQuery._data( form, "submit", true );
5822 } }
5823 }); } );
5824 // return undefined since we don't need an event listener // return undefined since we don't need an event listener
5825 }, },
5826
5827 postDispatch: function( event ) { postDispatch: function( event ) {
5828
5829 // If form was submitted by the user, bubble the event up the tree // If form was submitted by the user, bubble the event up the tree
5830 if ( event._submit_bubble ) { if ( event._submitBubble ) {
5831 delete event._submit_bubble; delete event._submitBubble;
5832 if ( this.parentNode && !event.isTrigger ) { if ( this.parentNode && !event.isTrigger ) {
5833 jQuery.event.simulate( "submit", this.parentNode, event, true ); jQuery.event.simulate( "submit", this.parentNode, event );
5834 } }
5835 } }
5836 }, },
5837
5838 teardown: function() { teardown: function() {
5839
5840 // Only need this for delegated form submit events // Only need this for delegated form submit events
5841 if ( jQuery.nodeName( this, "form" ) ) { if ( jQuery.nodeName( this, "form" ) ) {
5842 return false; return false;
5843 } }
5844
5845 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
5846 jQuery.event.remove( this, "._submit" ); jQuery.event.remove( this, "._submit" );
5847 } }
5848 }; };
5849 } }
5850
5851 // IE change delegation and checkbox/radio fix // IE change delegation and checkbox/radio fix
5852 if ( !support.changeBubbles ) { if ( !support.change ) {
5853
5854 jQuery.event.special.change = { jQuery.event.special.change = {
5855
5856 setup: function() { setup: function() {
5857
5858 if ( rformElems.test( this.nodeName ) ) { if ( rformElems.test( this.nodeName ) ) {
5859
5860 // IE doesn't fire change on a check/radio until blur; trigger it on click // IE doesn't fire change on a check/radio until blur; trigger it on click
5861 // after a propertychange. Eat the blur-change in special.change.handle. // after a propertychange. Eat the blur-change in special.change.handle.
5862 // This still fires onchange a second time for check/radio after blur. // This still fires onchange a second time for check/radio after blur.
5863 if ( this.type === "checkbox" || this.type === "radio" ) { if ( this.type === "checkbox" || this.type === "radio" ) {
5864 jQuery.event.add( this, "propertychange._change", function( event ) { jQuery.event.add( this, "propertychange._change", function( event ) {
5865 if ( event.originalEvent.propertyName === "checked" ) { if ( event.originalEvent.propertyName === "checked" ) {
5866 this._just_changed = true; this._justChanged = true;
5867 } }
5868 }); } );
5869 jQuery.event.add( this, "click._change", function( event ) { jQuery.event.add( this, "click._change", function( event ) {
5870 if ( this._just_changed && !event.isTrigger ) { if ( this._justChanged && !event.isTrigger ) {
5871 this._just_changed = false; this._justChanged = false;
5872 } }
5873
5874 // Allow triggered, simulated change events (#11500) // Allow triggered, simulated change events (#11500)
5875 jQuery.event.simulate( "change", this, event, true ); jQuery.event.simulate( "change", this, event );
5876 }); } );
5877 } }
5878 return false; return false;
5879 } }
5880
5881 // Delegated event; lazy-add a change handler on descendant inputs // Delegated event; lazy-add a change handler on descendant inputs
5882 jQuery.event.add( this, "beforeactivate._change", function( e ) { jQuery.event.add( this, "beforeactivate._change", function( e ) {
5883 var elem = e.target; var elem = e.target;
5884
5885 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) { if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "change" ) ) {
5886 jQuery.event.add( elem, "change._change", function( event ) { jQuery.event.add( elem, "change._change", function( event ) {
5887 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
5888 jQuery.event.simulate( "change", this.parentNode, event, true ); jQuery.event.simulate( "change", this.parentNode, event );
5889 } }
5890 }); } );
5891 jQuery._data( elem, "changeBubbles", true ); jQuery._data( elem, "change", true );
5892 } }
5893 }); } );
5894 }, },
5895
5896 handle: function( event ) { handle: function( event ) {
5897 var elem = event.target; var elem = event.target;
5898
5899 // Swallow native change events from checkbox/radio, we already triggered them above // Swallow native change events from checkbox/radio, we already triggered them above
5900 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { if ( this !== elem || event.isSimulated || event.isTrigger ||
5901 ( elem.type !== "radio" && elem.type !== "checkbox" ) ) {
5902 return event.handleObj.handler.apply( this, arguments ); return event.handleObj.handler.apply( this, arguments );
5903 } }
5904 }, },
5905
5906 teardown: function() { teardown: function() {
5907 jQuery.event.remove( this, "._change" ); jQuery.event.remove( this, "._change" );
5908
5909 return !rformElems.test( this.nodeName ); return !rformElems.test( this.nodeName );
5910 } }
5911 }; };
5912 } }
5913
5914 // Create "bubbling" focus and blur events // Support: Firefox
5915 if ( !support.focusinBubbles ) { // Firefox doesn't have focus(in | out) events
5916 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
5917 //
5918 // Support: Chrome, Safari
5919 // focus(in | out) events fire after focus & blur events,
5920 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
5921 // Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
5922 if ( !support.focusin ) {
5923 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
5924
5925 // Attach a single capturing handler on the document while someone wants focusin/focusout // Attach a single capturing handler on the document while someone wants focusin/focusout
5926 var handler = function( event ) { var handler = function( event ) {
5927 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
5928 }; };
5929
5930 jQuery.event.special[ fix ] = { jQuery.event.special[ fix ] = {
5931 setup: function() { setup: function() {
5932 var doc = this.ownerDocument || this, var doc = this.ownerDocument || this,
5933 attaches = jQuery._data( doc, fix ); attaches = jQuery._data( doc, fix );
5934
5935 if ( !attaches ) { if ( !attaches ) {
5936 doc.addEventListener( orig, handler, true ); doc.addEventListener( orig, handler, true );
5937 } }
5938 jQuery._data( doc, fix, ( attaches || 0 ) + 1 ); jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
5939 }, },
5940 teardown: function() { teardown: function() {
5941 var doc = this.ownerDocument || this, var doc = this.ownerDocument || this,
5942 attaches = jQuery._data( doc, fix ) - 1; attaches = jQuery._data( doc, fix ) - 1;
5943
5944 if ( !attaches ) { if ( !attaches ) {
5945 doc.removeEventListener( orig, handler, true ); doc.removeEventListener( orig, handler, true );
5946 jQuery._removeData( doc, fix ); jQuery._removeData( doc, fix );
5947 } else { } else {
5948 jQuery._data( doc, fix, attaches ); jQuery._data( doc, fix, attaches );
5949 } }
5950 } }
5951 }; };
5952 }); } );
5953 } }
5954
5955 jQuery.fn.extend({ jQuery.fn.extend( {
5956
5957 on: function( types, selector, data, fn, /*INTERNAL*/ one ) { on: function( types, selector, data, fn ) {
5958 var type, origFn; return on( this, types, selector, data, fn );
5959
5960 // Types can be a map of types/handlers
5961 if ( typeof types === "object" ) {
5962 // ( types-Object, selector, data )
5963 if ( typeof selector !== "string" ) {
5964 // ( types-Object, data )
5965 data = data || selector;
5966 selector = undefined;
5967 }
5968 for ( type in types ) {
5969 this.on( type, selector, data, types[ type ], one );
5970 }
5971 return this;
5972 }
5973
5974 if ( data == null && fn == null ) {
5975 // ( types, fn )
5976 fn = selector;
5977 data = selector = undefined;
5978 } else if ( fn == null ) {
5979 if ( typeof selector === "string" ) {
5980 // ( types, selector, fn )
5981 fn = data;
5982 data = undefined;
5983 } else {
5984 // ( types, data, fn )
5985 fn = data;
5986 data = selector;
5987 selector = undefined;
5988 }
5989 }
5990 if ( fn === false ) {
5991 fn = returnFalse;
5992 } else if ( !fn ) {
5993 return this;
5994 }
5995
5996 if ( one === 1 ) {
5997 origFn = fn;
5998 fn = function( event ) {
5999 // Can use an empty set, since event contains the info
6000 jQuery().off( event );
6001 return origFn.apply( this, arguments );
6002 };
6003 // Use same guid so caller can remove using origFn
6004 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
6005 }
6006 return this.each( function() {
6007 jQuery.event.add( this, types, fn, data, selector );
6008 });
6009 }, },
6010 one: function( types, selector, data, fn ) { one: function( types, selector, data, fn ) {
6011 return this.on( types, selector, data, fn, 1 ); return on( this, types, selector, data, fn, 1 );
6012 }, },
6013 off: function( types, selector, fn ) { off: function( types, selector, fn ) {
6014 var handleObj, type; var handleObj, type;
6015 if ( types && types.preventDefault && types.handleObj ) { if ( types && types.preventDefault && types.handleObj ) {
6016
6017 // ( event ) dispatched jQuery.Event // ( event ) dispatched jQuery.Event
6018 handleObj = types.handleObj; handleObj = types.handleObj;
6019 jQuery( types.delegateTarget ).off( jQuery( types.delegateTarget ).off(
6020 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, handleObj.namespace ?
6021 handleObj.origType + "." + handleObj.namespace :
6022 handleObj.origType,
6023 handleObj.selector, handleObj.selector,
6024 handleObj.handler handleObj.handler
6025 ); );
6026 return this; return this;
6027 } }
6028 if ( typeof types === "object" ) { if ( typeof types === "object" ) {
6029
6030 // ( types-object [, selector] ) // ( types-object [, selector] )
6031 for ( type in types ) { for ( type in types ) {
6032 this.off( type, selector, types[ type ] ); this.off( type, selector, types[ type ] );
6033 } }
6034 return this; return this;
6035 } }
6036 if ( selector === false || typeof selector === "function" ) { if ( selector === false || typeof selector === "function" ) {
6037
6038 // ( types [, fn] ) // ( types [, fn] )
6039 fn = selector; fn = selector;
6040 selector = undefined; selector = undefined;
6041 } }
6042 if ( fn === false ) { if ( fn === false ) {
6043 fn = returnFalse; fn = returnFalse;
6044 } }
6045 return this.each(function() { return this.each( function() {
6046 jQuery.event.remove( this, types, fn, selector ); jQuery.event.remove( this, types, fn, selector );
6047 }); } );
6048 }, },
6049
6050 trigger: function( type, data ) { trigger: function( type, data ) {
6051 return this.each(function() { return this.each( function() {
6052 jQuery.event.trigger( type, data, this ); jQuery.event.trigger( type, data, this );
6053 }); } );
6054 }, },
6055 triggerHandler: function( type, data ) { triggerHandler: function( type, data ) {
6056 var elem = this[0]; var elem = this[ 0 ];
6057 if ( elem ) { if ( elem ) {
6058 return jQuery.event.trigger( type, data, elem, true ); return jQuery.event.trigger( type, data, elem, true );
6059 } }
6060 } }
6061 }); } );
6062
6063
6064 function createSafeFragment( document ) { var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
6065 var list = nodeNames.split( "|" ), rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ),
6066 safeFrag = document.createDocumentFragment(); rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
6067
6068 if ( safeFrag.createElement ) { // Support: IE 10-11, Edge 10240+
6069 while ( list.length ) { // In IE/Edge using regex groups here causes severe slowdowns.
6070 safeFrag.createElement( // See https://connect.microsoft.com/IE/feedback/details/1736512/
6071 list.pop() rnoInnerhtml = /<script|<style|<link/i,
6072 );
6073 }
6074 }
6075 return safeFrag;
6076 }
6077
6078 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
6079 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
6080 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
6081 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
6082 rleadingWhitespace = /^\s+/,
6083 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
6084 rtagName = /<([\w:]+)/,
6085 rtbody = /<tbody/i,
6086 rhtml = /<|&#?\w+;/,
6087 rnoInnerhtml = /<(?:script|style|link)/i,
6088 // checked="checked" or checked // checked="checked" or checked
6089 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
6090 rscriptType = /^$|\/(?:java|ecma)script/i,
6091 rscriptTypeMasked = /^true\/(.*)/, rscriptTypeMasked = /^true\/(.*)/,
6092 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
6093
6094 // We have to close these tags to support XHTML (#13200)
6095 wrapMap = {
6096 option: [ 1, "<select multiple='multiple'>", "</select>" ],
6097 legend: [ 1, "<fieldset>", "</fieldset>" ],
6098 area: [ 1, "<map>", "</map>" ],
6099 param: [ 1, "<object>", "</object>" ],
6100 thead: [ 1, "<table>", "</table>" ],
6101 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
6102 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
6103 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
6104
6105 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
6106 // unless wrapped in a div with non-breaking characters in front of it.
6107 _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
6108 },
6109 safeFragment = createSafeFragment( document ), safeFragment = createSafeFragment( document ),
6110 fragmentDiv = safeFragment.appendChild( document.createElement("div") ); fragmentDiv = safeFragment.appendChild( document.createElement( "div" ) );
6111
6112 wrapMap.optgroup = wrapMap.option;
6113 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
6114 wrapMap.th = wrapMap.td;
6115
6116 function getAll( context, tag ) {
6117 var elems, elem,
6118 i = 0,
6119 found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
6120 typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
6121 undefined;
6122
6123 if ( !found ) {
6124 for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
6125 if ( !tag || jQuery.nodeName( elem, tag ) ) {
6126 found.push( elem );
6127 } else {
6128 jQuery.merge( found, getAll( elem, tag ) );
6129 }
6130 }
6131 }
6132
6133 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
6134 jQuery.merge( [ context ], found ) :
6135 found;
6136 }
6137
6138 // Used in buildFragment, fixes the defaultChecked property
6139 function fixDefaultChecked( elem ) {
6140 if ( rcheckableType.test( elem.type ) ) {
6141 elem.defaultChecked = elem.checked;
6142 }
6143 }
6144
6145 // Support: IE<8 // Support: IE<8
6146 // Manipulating tables requires a tbody // Manipulating tables requires a tbody
6147 function manipulationTarget( elem, content ) { function manipulationTarget( elem, content ) {
6148 return jQuery.nodeName( elem, "table" ) && return jQuery.nodeName( elem, "table" ) &&
6149 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
6150
6151 elem.getElementsByTagName("tbody")[0] || elem.getElementsByTagName( "tbody" )[ 0 ] ||
6152 elem.appendChild( elem.ownerDocument.createElement("tbody") ) : elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) :
6153 elem; elem;
6154 } }
6155
6156 // Replace/restore the type attribute of script elements for safe DOM manipulation // Replace/restore the type attribute of script elements for safe DOM manipulation
6157 function disableScript( elem ) { function disableScript( elem ) {
6158 elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type; elem.type = ( jQuery.find.attr( elem, "type" ) !== null ) + "/" + elem.type;
6159 return elem; return elem;
6160 } }
6161 function restoreScript( elem ) { function restoreScript( elem ) {
6162 var match = rscriptTypeMasked.exec( elem.type ); var match = rscriptTypeMasked.exec( elem.type );
6163 if ( match ) { if ( match ) {
6164 elem.type = match[1]; elem.type = match[ 1 ];
6165 } else { } else {
6166 elem.removeAttribute("type"); elem.removeAttribute( "type" );
6167 } }
6168 return elem; return elem;
6169 } }
6170
6171 // Mark scripts as having already been evaluated
6172 function setGlobalEval( elems, refElements ) {
6173 var elem,
6174 i = 0;
6175 for ( ; (elem = elems[i]) != null; i++ ) {
6176 jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
6177 }
6178 }
6179
6180 function cloneCopyEvent( src, dest ) { function cloneCopyEvent( src, dest ) {
6181
6182 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
6183 return; return;
6184 } }
6185
6186 var type, i, l, var type, i, l,
6187 oldData = jQuery._data( src ), oldData = jQuery._data( src ),
6188 curData = jQuery._data( dest, oldData ), curData = jQuery._data( dest, oldData ),
6189 events = oldData.events; events = oldData.events;
6190
6191 if ( events ) { if ( events ) {
6192 delete curData.handle; delete curData.handle;
6193 curData.events = {}; curData.events = {};
6194
6195 for ( type in events ) { for ( type in events ) {
6196 for ( i = 0, l = events[ type ].length; i < l; i++ ) { for ( i = 0, l = events[ type ].length; i < l; i++ ) {
6197 jQuery.event.add( dest, type, events[ type ][ i ] ); jQuery.event.add( dest, type, events[ type ][ i ] );
6198 } }
6199 } }
6200 } }
6201
6202 // make the cloned public data object a copy from the original // make the cloned public data object a copy from the original
6203 if ( curData.data ) { if ( curData.data ) {
6204 curData.data = jQuery.extend( {}, curData.data ); curData.data = jQuery.extend( {}, curData.data );
6205 } }
6206 } }
6207
6208 function fixCloneNodeIssues( src, dest ) { function fixCloneNodeIssues( src, dest ) {
6209 var nodeName, e, data; var nodeName, e, data;
6210
6211 // We do not need to do anything for non-Elements // We do not need to do anything for non-Elements
6212 if ( dest.nodeType !== 1 ) { if ( dest.nodeType !== 1 ) {
6213 return; return;
6214 } }
6215
6216 nodeName = dest.nodeName.toLowerCase(); nodeName = dest.nodeName.toLowerCase();
6217
6218 // IE6-8 copies events bound via attachEvent when using cloneNode. // IE6-8 copies events bound via attachEvent when using cloneNode.
6219 if ( !support.noCloneEvent && dest[ jQuery.expando ] ) { if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
6220 data = jQuery._data( dest ); data = jQuery._data( dest );
6221
6222 for ( e in data.events ) { for ( e in data.events ) {
6223 jQuery.removeEvent( dest, e, data.handle ); jQuery.removeEvent( dest, e, data.handle );
6224 } }
6225
6226 // Event data gets referenced instead of copied if the expando gets copied too // Event data gets referenced instead of copied if the expando gets copied too
6227 dest.removeAttribute( jQuery.expando ); dest.removeAttribute( jQuery.expando );
6228 } }
6229
6230 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
6231 if ( nodeName === "script" && dest.text !== src.text ) { if ( nodeName === "script" && dest.text !== src.text ) {
6232 disableScript( dest ).text = src.text; disableScript( dest ).text = src.text;
6233 restoreScript( dest ); restoreScript( dest );
6234
6235 // IE6-10 improperly clones children of object elements using classid. // IE6-10 improperly clones children of object elements using classid.
6236 // IE10 throws NoModificationAllowedError if parent is null, #12132. // IE10 throws NoModificationAllowedError if parent is null, #12132.
6237 } else if ( nodeName === "object" ) { } else if ( nodeName === "object" ) {
6238 if ( dest.parentNode ) { if ( dest.parentNode ) {
6239 dest.outerHTML = src.outerHTML; dest.outerHTML = src.outerHTML;
6240 } }
6241
6242 // This path appears unavoidable for IE9. When cloning an object // This path appears unavoidable for IE9. When cloning an object
6243 // element in IE9, the outerHTML strategy above is not sufficient. // element in IE9, the outerHTML strategy above is not sufficient.
6244 // If the src has innerHTML and the destination does not, // If the src has innerHTML and the destination does not,
6245 // copy the src.innerHTML into the dest.innerHTML. #10324 // copy the src.innerHTML into the dest.innerHTML. #10324
6246 if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) { if ( support.html5Clone && ( src.innerHTML && !jQuery.trim( dest.innerHTML ) ) ) {
6247 dest.innerHTML = src.innerHTML; dest.innerHTML = src.innerHTML;
6248 } }
6249
6250 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) { } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
6251
6252 // IE6-8 fails to persist the checked state of a cloned checkbox // IE6-8 fails to persist the checked state of a cloned checkbox
6253 // or radio button. Worse, IE6-7 fail to give the cloned element // or radio button. Worse, IE6-7 fail to give the cloned element
6254 // a checked appearance if the defaultChecked value isn't also set // a checked appearance if the defaultChecked value isn't also set
6255
6256 dest.defaultChecked = dest.checked = src.checked; dest.defaultChecked = dest.checked = src.checked;
6257
6258 // IE6-7 get confused and end up setting the value of a cloned // IE6-7 get confused and end up setting the value of a cloned
6259 // checkbox/radio button to an empty string instead of "on" // checkbox/radio button to an empty string instead of "on"
6260 if ( dest.value !== src.value ) { if ( dest.value !== src.value ) {
6261 dest.value = src.value; dest.value = src.value;
6262 } }
6263
6264 // IE6-8 fails to return the selected option to the default selected // IE6-8 fails to return the selected option to the default selected
6265 // state when cloning options // state when cloning options
6266 } else if ( nodeName === "option" ) { } else if ( nodeName === "option" ) {
6267 dest.defaultSelected = dest.selected = src.defaultSelected; dest.defaultSelected = dest.selected = src.defaultSelected;
6268
6269 // IE6-8 fails to set the defaultValue to the correct value when // IE6-8 fails to set the defaultValue to the correct value when
6270 // cloning other types of input fields // cloning other types of input fields
6271 } else if ( nodeName === "input" || nodeName === "textarea" ) { } else if ( nodeName === "input" || nodeName === "textarea" ) {
6272 dest.defaultValue = src.defaultValue; dest.defaultValue = src.defaultValue;
6273 } }
6274 } }
6275
6276 jQuery.extend({ function domManip( collection, args, callback, ignored ) {
6277
6278 // Flatten any nested arrays
6279 args = concat.apply( [], args );
6280
6281 var first, node, hasScripts,
6282 scripts, doc, fragment,
6283 i = 0,
6284 l = collection.length,
6285 iNoClone = l - 1,
6286 value = args[ 0 ],
6287 isFunction = jQuery.isFunction( value );
6288
6289 // We can't cloneNode fragments that contain checked, in WebKit
6290 if ( isFunction ||
6291 ( l > 1 && typeof value === "string" &&
6292 !support.checkClone && rchecked.test( value ) ) ) {
6293 return collection.each( function( index ) {
6294 var self = collection.eq( index );
6295 if ( isFunction ) {
6296 args[ 0 ] = value.call( this, index, self.html() );
6297 }
6298 domManip( self, args, callback, ignored );
6299 } );
6300 }
6301
6302 if ( l ) {
6303 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
6304 first = fragment.firstChild;
6305
6306 if ( fragment.childNodes.length === 1 ) {
6307 fragment = first;
6308 }
6309
6310 // Require either new content or an interest in ignored elements to invoke the callback
6311 if ( first || ignored ) {
6312 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
6313 hasScripts = scripts.length;
6314
6315 // Use the original fragment for the last item
6316 // instead of the first because it can end up
6317 // being emptied incorrectly in certain situations (#8070).
6318 for ( ; i < l; i++ ) {
6319 node = fragment;
6320
6321 if ( i !== iNoClone ) {
6322 node = jQuery.clone( node, true, true );
6323
6324 // Keep references to cloned scripts for later restoration
6325 if ( hasScripts ) {
6326
6327 // Support: Android<4.1, PhantomJS<2
6328 // push.apply(_, arraylike) throws on ancient WebKit
6329 jQuery.merge( scripts, getAll( node, "script" ) );
6330 }
6331 }
6332
6333 callback.call( collection[ i ], node, i );
6334 }
6335
6336 if ( hasScripts ) {
6337 doc = scripts[ scripts.length - 1 ].ownerDocument;
6338
6339 // Reenable scripts
6340 jQuery.map( scripts, restoreScript );
6341
6342 // Evaluate executable scripts on first document insertion
6343 for ( i = 0; i < hasScripts; i++ ) {
6344 node = scripts[ i ];
6345 if ( rscriptType.test( node.type || "" ) &&
6346 !jQuery._data( node, "globalEval" ) &&
6347 jQuery.contains( doc, node ) ) {
6348
6349 if ( node.src ) {
6350
6351 // Optional AJAX dependency, but won't run scripts if not present
6352 if ( jQuery._evalUrl ) {
6353 jQuery._evalUrl( node.src );
6354 }
6355 } else {
6356 jQuery.globalEval(
6357 ( node.text || node.textContent || node.innerHTML || "" )
6358 .replace( rcleanScript, "" )
6359 );
6360 }
6361 }
6362 }
6363 }
6364
6365 // Fix #11809: Avoid leaking memory
6366 fragment = first = null;
6367 }
6368 }
6369
6370 return collection;
6371 }
6372
6373 function remove( elem, selector, keepData ) {
6374 var node,
6375 elems = selector ? jQuery.filter( selector, elem ) : elem,
6376 i = 0;
6377
6378 for ( ; ( node = elems[ i ] ) != null; i++ ) {
6379
6380 if ( !keepData && node.nodeType === 1 ) {
6381 jQuery.cleanData( getAll( node ) );
6382 }
6383
6384 if ( node.parentNode ) {
6385 if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
6386 setGlobalEval( getAll( node, "script" ) );
6387 }
6388 node.parentNode.removeChild( node );
6389 }
6390 }
6391
6392 return elem;
6393 }
6394
6395 jQuery.extend( {
6396 htmlPrefilter: function( html ) {
6397 return html.replace( rxhtmlTag, "<$1></$2>" );
6398 },
6399 clone: function( elem, dataAndEvents, deepDataAndEvents ) { clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6400 var destElements, node, clone, i, srcElements, var destElements, node, clone, i, srcElements,
6401 inPage = jQuery.contains( elem.ownerDocument, elem ); inPage = jQuery.contains( elem.ownerDocument, elem );
6402
6403 if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { if ( support.html5Clone || jQuery.isXMLDoc( elem ) ||
6404 !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
6405 clone = elem.cloneNode( true ); clone = elem.cloneNode( true );
6406
6407 // IE<=8 does not properly clone detached, unknown element nodes // IE<=8 does not properly clone detached, unknown element nodes
6408 } else { } else {
6409 fragmentDiv.innerHTML = elem.outerHTML; fragmentDiv.innerHTML = elem.outerHTML;
6410 fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
6411 } }
6412
6413 if ( (!support.noCloneEvent || !support.noCloneChecked) && if ( ( !support.noCloneEvent || !support.noCloneChecked ) &&
6414 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) {
6415
6416 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
6417 destElements = getAll( clone ); destElements = getAll( clone );
6418 srcElements = getAll( elem ); srcElements = getAll( elem );
6419
6420 // Fix all IE cloning issues // Fix all IE cloning issues
6421 for ( i = 0; (node = srcElements[i]) != null; ++i ) { for ( i = 0; ( node = srcElements[ i ] ) != null; ++i ) {
6422 // Ensure that the destination node is not null; Fixes #9587 // Ensure that the destination node is not null; Fixes #9587
6423 if ( destElements[i] ) { if ( destElements[ i ] ) {
6424 fixCloneNodeIssues( node, destElements[i] ); fixCloneNodeIssues( node, destElements[ i ] );
6425 } }
6426 } }
6427 } }
6428
6429 // Copy the events from the original to the clone // Copy the events from the original to the clone
6430 if ( dataAndEvents ) { if ( dataAndEvents ) {
6431 if ( deepDataAndEvents ) { if ( deepDataAndEvents ) {
6432 srcElements = srcElements || getAll( elem ); srcElements = srcElements || getAll( elem );
6433 destElements = destElements || getAll( clone ); destElements = destElements || getAll( clone );
6434
6435 for ( i = 0; (node = srcElements[i]) != null; i++ ) { for ( i = 0; ( node = srcElements[ i ] ) != null; i++ ) {
6436 cloneCopyEvent( node, destElements[i] ); cloneCopyEvent( node, destElements[ i ] );
6437 } }
6438 } else { } else {
6439 cloneCopyEvent( elem, clone ); cloneCopyEvent( elem, clone );
6440 } }
6441 } }
6442
6443 // Preserve script evaluation history // Preserve script evaluation history
6444 destElements = getAll( clone, "script" ); destElements = getAll( clone, "script" );
6445 if ( destElements.length > 0 ) { if ( destElements.length > 0 ) {
6446 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
6447 } }
6448
6449 destElements = srcElements = node = null; destElements = srcElements = node = null;
6450
6451 // Return the cloned set // Return the cloned set
6452 return clone; return clone;
6453 }, },
6454
6455 buildFragment: function( elems, context, scripts, selection ) { cleanData: function( elems, /* internal */ forceAcceptData ) {
6456 var j, elem, contains,
6457 tmp, tag, tbody, wrap,
6458 l = elems.length,
6459
6460 // Ensure a safe fragment
6461 safe = createSafeFragment( context ),
6462
6463 nodes = [],
6464 i = 0;
6465
6466 for ( ; i < l; i++ ) {
6467 elem = elems[ i ];
6468
6469 if ( elem || elem === 0 ) {
6470
6471 // Add nodes directly
6472 if ( jQuery.type( elem ) === "object" ) {
6473 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
6474
6475 // Convert non-html into a text node
6476 } else if ( !rhtml.test( elem ) ) {
6477 nodes.push( context.createTextNode( elem ) );
6478
6479 // Convert html into DOM nodes
6480 } else {
6481 tmp = tmp || safe.appendChild( context.createElement("div") );
6482
6483 // Deserialize a standard representation
6484 tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase();
6485 wrap = wrapMap[ tag ] || wrapMap._default;
6486
6487 tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
6488
6489 // Descend through wrappers to the right content
6490 j = wrap[0];
6491 while ( j-- ) {
6492 tmp = tmp.lastChild;
6493 }
6494
6495 // Manually add leading whitespace removed by IE
6496 if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6497 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
6498 }
6499
6500 // Remove IE's autoinserted <tbody> from table fragments
6501 if ( !support.tbody ) {
6502
6503 // String was a <table>, *may* have spurious <tbody>
6504 elem = tag === "table" && !rtbody.test( elem ) ?
6505 tmp.firstChild :
6506
6507 // String was a bare <thead> or <tfoot>
6508 wrap[1] === "<table>" && !rtbody.test( elem ) ?
6509 tmp :
6510 0;
6511
6512 j = elem && elem.childNodes.length;
6513 while ( j-- ) {
6514 if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
6515 elem.removeChild( tbody );
6516 }
6517 }
6518 }
6519
6520 jQuery.merge( nodes, tmp.childNodes );
6521
6522 // Fix #12392 for WebKit and IE > 9
6523 tmp.textContent = "";
6524
6525 // Fix #12392 for oldIE
6526 while ( tmp.firstChild ) {
6527 tmp.removeChild( tmp.firstChild );
6528 }
6529
6530 // Remember the top-level container for proper cleanup
6531 tmp = safe.lastChild;
6532 }
6533 }
6534 }
6535
6536 // Fix #11356: Clear elements from fragment
6537 if ( tmp ) {
6538 safe.removeChild( tmp );
6539 }
6540
6541 // Reset defaultChecked for any radios and checkboxes
6542 // about to be appended to the DOM in IE 6/7 (#8060)
6543 if ( !support.appendChecked ) {
6544 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
6545 }
6546
6547 i = 0;
6548 while ( (elem = nodes[ i++ ]) ) {
6549
6550 // #4087 - If origin and destination elements are the same, and this is
6551 // that element, do not do anything
6552 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
6553 continue;
6554 }
6555
6556 contains = jQuery.contains( elem.ownerDocument, elem );
6557
6558 // Append to fragment
6559 tmp = getAll( safe.appendChild( elem ), "script" );
6560
6561 // Preserve script evaluation history
6562 if ( contains ) {
6563 setGlobalEval( tmp );
6564 }
6565
6566 // Capture executables
6567 if ( scripts ) {
6568 j = 0;
6569 while ( (elem = tmp[ j++ ]) ) {
6570 if ( rscriptType.test( elem.type || "" ) ) {
6571 scripts.push( elem );
6572 }
6573 }
6574 }
6575 }
6576
6577 tmp = null;
6578
6579 return safe;
6580 },
6581
6582 cleanData: function( elems, /* internal */ acceptData ) {
6583 var elem, type, id, data, var elem, type, id, data,
6584 i = 0, i = 0,
6585 internalKey = jQuery.expando, internalKey = jQuery.expando,
6586 cache = jQuery.cache, cache = jQuery.cache,
6587 deleteExpando = support.deleteExpando, attributes = support.attributes,
6588 special = jQuery.event.special; special = jQuery.event.special;
6589
6590 for ( ; (elem = elems[i]) != null; i++ ) { for ( ; ( elem = elems[ i ] ) != null; i++ ) {
6591 if ( acceptData || jQuery.acceptData( elem ) ) { if ( forceAcceptData || acceptData( elem ) ) {
6592
6593 id = elem[ internalKey ]; id = elem[ internalKey ];
6594 data = id && cache[ id ]; data = id && cache[ id ];
6595
6596 if ( data ) { if ( data ) {
6597 if ( data.events ) { if ( data.events ) {
6598 for ( type in data.events ) { for ( type in data.events ) {
6599 if ( special[ type ] ) { if ( special[ type ] ) {
6600 jQuery.event.remove( elem, type ); jQuery.event.remove( elem, type );
6601
6602 // This is a shortcut to avoid jQuery.event.remove's overhead // This is a shortcut to avoid jQuery.event.remove's overhead
6603 } else { } else {
6604 jQuery.removeEvent( elem, type, data.handle ); jQuery.removeEvent( elem, type, data.handle );
6605 } }
6606 } }
6607 } }
6608
6609 // Remove cache only if it was not already removed by jQuery.event.remove // Remove cache only if it was not already removed by jQuery.event.remove
6610 if ( cache[ id ] ) { if ( cache[ id ] ) {
6611
6612 delete cache[ id ]; delete cache[ id ];
6613
6614 // IE does not allow us to delete expando properties from nodes, // Support: IE<9
6615 // nor does it have a removeAttribute function on Document nodes; // IE does not allow us to delete expando properties from nodes
6616 // we must handle all of these cases // IE creates expando attributes along with the property
6617 if ( deleteExpando ) { // IE does not have a removeAttribute function on Document nodes
6618 delete elem[ internalKey ]; if ( !attributes && typeof elem.removeAttribute !== "undefined" ) {
6619
6620 } else if ( typeof elem.removeAttribute !== strundefined ) {
6621 elem.removeAttribute( internalKey ); elem.removeAttribute( internalKey );
6622
6623 // Webkit & Blink performance suffers when deleting properties
6624 // from DOM nodes, so set to undefined instead
6625 // https://code.google.com/p/chromium/issues/detail?id=378607
6626 } else { } else {
6627 elem[ internalKey ] = null; elem[ internalKey ] = undefined;
6628 } }
6629
6630 deletedIds.push( id ); deletedIds.push( id );
6631 } }
6632 } }
6633 } }
6634 } }
6635 } }
6636 }); } );
6637
6638 jQuery.fn.extend({ jQuery.fn.extend( {
6639
6640 // Keep domManip exposed until 3.0 (gh-2225)
6641 domManip: domManip,
6642
6643 detach: function( selector ) {
6644 return remove( this, selector, true );
6645 },
6646
6647 remove: function( selector ) {
6648 return remove( this, selector );
6649 },
6650 text: function( value ) { text: function( value ) {
6651 return access( this, function( value ) { return access( this, function( value ) {
6652 return value === undefined ? return value === undefined ?
6653 jQuery.text( this ) : jQuery.text( this ) :
6654 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); this.empty().append(
6655 ( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value )
6656 );
6657 }, null, value, arguments.length ); }, null, value, arguments.length );
6658 }, },
6659
6660 append: function() { append: function() {
6661 return this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
6662 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6663 var target = manipulationTarget( this, elem ); var target = manipulationTarget( this, elem );
6664 target.appendChild( elem ); target.appendChild( elem );
6665 } }
6666 }); } );
6667 }, },
6668
6669 prepend: function() { prepend: function() {
6670 return this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
6671 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6672 var target = manipulationTarget( this, elem ); var target = manipulationTarget( this, elem );
6673 target.insertBefore( elem, target.firstChild ); target.insertBefore( elem, target.firstChild );
6674 } }
6675 }); } );
6676 }, },
6677
6678 before: function() { before: function() {
6679 return this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
6680 if ( this.parentNode ) { if ( this.parentNode ) {
6681 this.parentNode.insertBefore( elem, this ); this.parentNode.insertBefore( elem, this );
6682 } }
6683 }); } );
6684 }, },
6685
6686 after: function() { after: function() {
6687 return this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
6688 if ( this.parentNode ) { if ( this.parentNode ) {
6689 this.parentNode.insertBefore( elem, this.nextSibling ); this.parentNode.insertBefore( elem, this.nextSibling );
6690 } }
6691 }); } );
6692 }, },
6693
6694 remove: function( selector, keepData /* Internal Use Only */ ) {
6695 var elem,
6696 elems = selector ? jQuery.filter( selector, this ) : this,
6697 i = 0;
6698
6699 for ( ; (elem = elems[i]) != null; i++ ) {
6700
6701 if ( !keepData && elem.nodeType === 1 ) {
6702 jQuery.cleanData( getAll( elem ) );
6703 }
6704
6705 if ( elem.parentNode ) {
6706 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
6707 setGlobalEval( getAll( elem, "script" ) );
6708 }
6709 elem.parentNode.removeChild( elem );
6710 }
6711 }
6712
6713 return this;
6714 },
6715
6716 empty: function() { empty: function() {
6717 var elem, var elem,
6718 i = 0; i = 0;
6719
6720 for ( ; (elem = this[i]) != null; i++ ) { for ( ; ( elem = this[ i ] ) != null; i++ ) {
6721 // Remove element nodes and prevent memory leaks // Remove element nodes and prevent memory leaks
6722 if ( elem.nodeType === 1 ) { if ( elem.nodeType === 1 ) {
6723 jQuery.cleanData( getAll( elem, false ) ); jQuery.cleanData( getAll( elem, false ) );
6724 } }
6725
6726 // Remove any remaining nodes // Remove any remaining nodes
6727 while ( elem.firstChild ) { while ( elem.firstChild ) {
6728 elem.removeChild( elem.firstChild ); elem.removeChild( elem.firstChild );
6729 } }
6730
6731 // If this is a select, ensure that it displays empty (#12336) // If this is a select, ensure that it displays empty (#12336)
6732 // Support: IE<9 // Support: IE<9
6733 if ( elem.options && jQuery.nodeName( elem, "select" ) ) { if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
6734 elem.options.length = 0; elem.options.length = 0;
6735 } }
6736 } }
6737
6738 return this; return this;
6739 }, },
6740
6741 clone: function( dataAndEvents, deepDataAndEvents ) { clone: function( dataAndEvents, deepDataAndEvents ) {
6742 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
6743 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
6744
6745 return this.map(function() { return this.map( function() {
6746 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
6747 }); } );
6748 }, },
6749
6750 html: function( value ) { html: function( value ) {
6751 return access( this, function( value ) { return access( this, function( value ) {
6752 var elem = this[ 0 ] || {}, var elem = this[ 0 ] || {},
6753 i = 0, i = 0,
6754 l = this.length; l = this.length;
6755
6756 if ( value === undefined ) { if ( value === undefined ) {
6757 return elem.nodeType === 1 ? return elem.nodeType === 1 ?
6758 elem.innerHTML.replace( rinlinejQuery, "" ) : elem.innerHTML.replace( rinlinejQuery, "" ) :
6759 undefined; undefined;
6760 } }
6761
6762 // See if we can take a shortcut and just use innerHTML // See if we can take a shortcut and just use innerHTML
6763 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
6764 ( support.htmlSerialize || !rnoshimcache.test( value ) ) && ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
6765 ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
6766 !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) { !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
6767
6768 value = value.replace( rxhtmlTag, "<$1></$2>" ); value = jQuery.htmlPrefilter( value );
6769
6770 try { try {
6771 for (; i < l; i++ ) { for ( ; i < l; i++ ) {
6772 // Remove element nodes and prevent memory leaks // Remove element nodes and prevent memory leaks
6773 elem = this[i] || {}; elem = this[ i ] || {};
6774 if ( elem.nodeType === 1 ) { if ( elem.nodeType === 1 ) {
6775 jQuery.cleanData( getAll( elem, false ) ); jQuery.cleanData( getAll( elem, false ) );
6776 elem.innerHTML = value; elem.innerHTML = value;
6777 } }
6778 } }
6779
6780 elem = 0; elem = 0;
6781
6782 // If using innerHTML throws an exception, use the fallback method // If using innerHTML throws an exception, use the fallback method
6783 } catch(e) {} } catch ( e ) {}
6784 } }
6785
6786 if ( elem ) { if ( elem ) {
6787 this.empty().append( value ); this.empty().append( value );
6788 } }
6789 }, null, value, arguments.length ); }, null, value, arguments.length );
6790 }, },
6791
6792 replaceWith: function() { replaceWith: function() {
6793 var arg = arguments[ 0 ]; var ignored = [];
6794
6795 // Make the changes, replacing each context element with the new content // Make the changes, replacing each non-ignored context element with the new content
6796 this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
6797 arg = this.parentNode; var parent = this.parentNode;
6798
6799 jQuery.cleanData( getAll( this ) ); if ( jQuery.inArray( this, ignored ) < 0 ) {
6800 jQuery.cleanData( getAll( this ) );
6801 if ( arg ) { if ( parent ) {
6802 arg.replaceChild( elem, this ); parent.replaceChild( elem, this );
6803 }
6804 });
6805
6806 // Force removal if there was no new content (e.g., from empty arguments)
6807 return arg && (arg.length || arg.nodeType) ? this : this.remove();
6808 },
6809
6810 detach: function( selector ) {
6811 return this.remove( selector, true );
6812 },
6813
6814 domManip: function( args, callback ) {
6815
6816 // Flatten any nested arrays
6817 args = concat.apply( [], args );
6818
6819 var first, node, hasScripts,
6820 scripts, doc, fragment,
6821 i = 0,
6822 l = this.length,
6823 set = this,
6824 iNoClone = l - 1,
6825 value = args[0],
6826 isFunction = jQuery.isFunction( value );
6827
6828 // We can't cloneNode fragments that contain checked, in WebKit
6829 if ( isFunction ||
6830 ( l > 1 && typeof value === "string" &&
6831 !support.checkClone && rchecked.test( value ) ) ) {
6832 return this.each(function( index ) {
6833 var self = set.eq( index );
6834 if ( isFunction ) {
6835 args[0] = value.call( this, index, self.html() );
6836 } }
6837 self.domManip( args, callback );
6838 });
6839 }
6840
6841 if ( l ) {
6842 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
6843 first = fragment.firstChild;
6844
6845 if ( fragment.childNodes.length === 1 ) {
6846 fragment = first;
6847 } }
6848
6849 if ( first ) { // Force callback invocation
6850 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); }, ignored );
6851 hasScripts = scripts.length;
6852
6853 // Use the original fragment for the last item instead of the first because it can end up
6854 // being emptied incorrectly in certain situations (#8070).
6855 for ( ; i < l; i++ ) {
6856 node = fragment;
6857
6858 if ( i !== iNoClone ) {
6859 node = jQuery.clone( node, true, true );
6860
6861 // Keep references to cloned scripts for later restoration
6862 if ( hasScripts ) {
6863 jQuery.merge( scripts, getAll( node, "script" ) );
6864 }
6865 }
6866
6867 callback.call( this[i], node, i );
6868 }
6869
6870 if ( hasScripts ) {
6871 doc = scripts[ scripts.length - 1 ].ownerDocument;
6872
6873 // Reenable scripts
6874 jQuery.map( scripts, restoreScript );
6875
6876 // Evaluate executable scripts on first document insertion
6877 for ( i = 0; i < hasScripts; i++ ) {
6878 node = scripts[ i ];
6879 if ( rscriptType.test( node.type || "" ) &&
6880 !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
6881
6882 if ( node.src ) {
6883 // Optional AJAX dependency, but won't run scripts if not present
6884 if ( jQuery._evalUrl ) {
6885 jQuery._evalUrl( node.src );
6886 }
6887 } else {
6888 jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
6889 }
6890 }
6891 }
6892 }
6893
6894 // Fix #11809: Avoid leaking memory
6895 fragment = first = null;
6896 }
6897 }
6898
6899 return this;
6900 } }
6901 }); } );
6902
6903 jQuery.each({ jQuery.each( {
6904 appendTo: "append", appendTo: "append",
6905 prependTo: "prepend", prependTo: "prepend",
6906 insertBefore: "before", insertBefore: "before",
6907 insertAfter: "after", insertAfter: "after",
6908 replaceAll: "replaceWith" replaceAll: "replaceWith"
6909 }, function( name, original ) { }, function( name, original ) {
6910 jQuery.fn[ name ] = function( selector ) { jQuery.fn[ name ] = function( selector ) {
6911 var elems, var elems,
6912 i = 0, i = 0,
6913 ret = [], ret = [],
6914 insert = jQuery( selector ), insert = jQuery( selector ),
6915 last = insert.length - 1; last = insert.length - 1;
6916
6917 for ( ; i <= last; i++ ) { for ( ; i <= last; i++ ) {
6918 elems = i === last ? this : this.clone(true); elems = i === last ? this : this.clone( true );
6919 jQuery( insert[i] )[ original ]( elems ); jQuery( insert[ i ] )[ original ]( elems );
6920
6921 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get() // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
6922 push.apply( ret, elems.get() ); push.apply( ret, elems.get() );
6923 } }
6924
6925 return this.pushStack( ret ); return this.pushStack( ret );
6926 }; };
6927 }); } );
6928
6929
6930 var iframe, var iframe,
6931 elemdisplay = {}; elemdisplay = {
6932
6933 // Support: Firefox
6934 // We have to pre-define these values for FF (#10227)
6935 HTML: "block",
6936 BODY: "block"
6937 };
6938
6939 /** /**
6940 * Retrieve the actual display of a element * Retrieve the actual display of a element
6941 * @param {String} name nodeName of the element * @param {String} name nodeName of the element
6942 * @param {Object} doc Document object * @param {Object} doc Document object
6943 */ */
6944
6945 // Called only from within defaultDisplay // Called only from within defaultDisplay
6946 function actualDisplay( name, doc ) { function actualDisplay( name, doc ) {
6947 var style, var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
6948 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
6949
6950 // getDefaultComputedStyle might be reliably used only on attached element display = jQuery.css( elem[ 0 ], "display" );
6951 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
6952
6953 // Use of this method is a temporary fix (more like optmization) until something better comes along,
6954 // since it was removed from specification and supported only in FF
6955 style.display : jQuery.css( elem[ 0 ], "display" );
6956
6957 // We don't have any data stored on the element, // We don't have any data stored on the element,
6958 // so use "detach" method as fast way to get rid of the element // so use "detach" method as fast way to get rid of the element
6959 elem.detach(); elem.detach();
6960
6961 return display; return display;
6962 } }
6963
6964 /** /**
6965 * Try to determine the default display value of an element * Try to determine the default display value of an element
6966 * @param {String} nodeName * @param {String} nodeName
6967 */ */
6968 function defaultDisplay( nodeName ) { function defaultDisplay( nodeName ) {
6969 var doc = document, var doc = document,
6970 display = elemdisplay[ nodeName ]; display = elemdisplay[ nodeName ];
6971
6972 if ( !display ) { if ( !display ) {
6973 display = actualDisplay( nodeName, doc ); display = actualDisplay( nodeName, doc );
6974
6975 // If the simple way fails, read from inside an iframe // If the simple way fails, read from inside an iframe
6976 if ( display === "none" || !display ) { if ( display === "none" || !display ) {
6977
6978 // Use the already-created iframe if possible // Use the already-created iframe if possible
6979 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement ); iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) )
6980 .appendTo( doc.documentElement );
6981
6982 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
6983 doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document; doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
6984
6985 // Support: IE // Support: IE
6986 doc.write(); doc.write();
6987 doc.close(); doc.close();
6988
6989 display = actualDisplay( nodeName, doc ); display = actualDisplay( nodeName, doc );
6990 iframe.detach(); iframe.detach();
6991 } }
6992
6993 // Store the correct default display // Store the correct default display
6994 elemdisplay[ nodeName ] = display; elemdisplay[ nodeName ] = display;
6995 } }
6996
6997 return display; return display;
6998 } }
6999 var rmargin = ( /^margin/ );
7000
7001 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
7002
7003 (function() { var swap = function( elem, options, callback, args ) {
7004 var shrinkWrapBlocksVal; var ret, name,
7005 old = {};
7006
7007 support.shrinkWrapBlocks = function() { // Remember the old values, and insert the new ones
7008 if ( shrinkWrapBlocksVal != null ) { for ( name in options ) {
7009 return shrinkWrapBlocksVal; old[ name ] = elem.style[ name ];
7010 } elem.style[ name ] = options[ name ];
7011 }
7012
7013 // Will be changed later if needed. ret = callback.apply( elem, args || [] );
7014 shrinkWrapBlocksVal = false;
7015
7016 // Minified: var b,c,d // Revert the old values
7017 var div, body, container; for ( name in options ) {
7018 elem.style[ name ] = old[ name ];
7019 }
7020
7021 body = document.getElementsByTagName( "body" )[ 0 ]; return ret;
7022 if ( !body || !body.style ) { };
7023 // Test fired too early or in an unsupported environment, exit.
7024 return;
7025 var documentElement = document.documentElement;
7026
7027
7028
7029 ( function() {
7030 var pixelPositionVal, pixelMarginRightVal, boxSizingReliableVal,
7031 reliableHiddenOffsetsVal, reliableMarginRightVal, reliableMarginLeftVal,
7032 container = document.createElement( "div" ),
7033 div = document.createElement( "div" );
7034
7035 // Finish early in limited (non-browser) environments
7036 if ( !div.style ) {
7037 return;
7038 }
7039
7040 div.style.cssText = "float:left;opacity:.5";
7041
7042 // Support: IE<9
7043 // Make sure that element opacity exists (as opposed to filter)
7044 support.opacity = div.style.opacity === "0.5";
7045
7046 // Verify style float existence
7047 // (IE uses styleFloat instead of cssFloat)
7048 support.cssFloat = !!div.style.cssFloat;
7049
7050 div.style.backgroundClip = "content-box";
7051 div.cloneNode( true ).style.backgroundClip = "";
7052 support.clearCloneStyle = div.style.backgroundClip === "content-box";
7053
7054 container = document.createElement( "div" );
7055 container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
7056 "padding:0;margin-top:1px;position:absolute";
7057 div.innerHTML = "";
7058 container.appendChild( div );
7059
7060 // Support: Firefox<29, Android 2.3
7061 // Vendor-prefix box-sizing
7062 support.boxSizing = div.style.boxSizing === "" || div.style.MozBoxSizing === "" ||
7063 div.style.WebkitBoxSizing === "";
7064
7065 jQuery.extend( support, {
7066 reliableHiddenOffsets: function() {
7067 if ( pixelPositionVal == null ) {
7068 computeStyleTests();
7069 }
7070 return reliableHiddenOffsetsVal;
7071 },
7072
7073 boxSizingReliable: function() {
7074
7075 // We're checking for pixelPositionVal here instead of boxSizingReliableVal
7076 // since that compresses better and they're computed together anyway.
7077 if ( pixelPositionVal == null ) {
7078 computeStyleTests();
7079 }
7080 return boxSizingReliableVal;
7081 },
7082
7083 pixelMarginRight: function() {
7084
7085 // Support: Android 4.0-4.3
7086 if ( pixelPositionVal == null ) {
7087 computeStyleTests();
7088 }
7089 return pixelMarginRightVal;
7090 },
7091
7092 pixelPosition: function() {
7093 if ( pixelPositionVal == null ) {
7094 computeStyleTests();
7095 }
7096 return pixelPositionVal;
7097 },
7098
7099 reliableMarginRight: function() {
7100
7101 // Support: Android 2.3
7102 if ( pixelPositionVal == null ) {
7103 computeStyleTests();
7104 }
7105 return reliableMarginRightVal;
7106 },
7107
7108 reliableMarginLeft: function() {
7109
7110 // Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37
7111 if ( pixelPositionVal == null ) {
7112 computeStyleTests();
7113 }
7114 return reliableMarginLeftVal;
7115 } }
7116 } );
7117
7118 function computeStyleTests() {
7119 var contents, divStyle,
7120 documentElement = document.documentElement;
7121
7122 // Setup // Setup
7123 div = document.createElement( "div" ); documentElement.appendChild( container );
7124 container = document.createElement( "div" );
7125 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
7126 body.appendChild( container ).appendChild( div );
7127
7128 // Support: IE6 div.style.cssText =
7129 // Check if elements with layout shrink-wrap their children
7130 if ( typeof div.style.zoom !== strundefined ) { // Support: Android 2.3
7131 // Reset CSS: box-sizing; display; margin; border // Vendor-prefix box-sizing
7132 div.style.cssText = "-webkit-box-sizing:border-box;box-sizing:border-box;" +
7133 // Support: Firefox<29, Android 2.3 "position:relative;display:block;" +
7134 "margin:auto;border:1px;padding:1px;" +
7135 "top:1%;width:50%";
7136
7137 // Support: IE<9
7138 // Assume reasonable values in the absence of getComputedStyle
7139 pixelPositionVal = boxSizingReliableVal = reliableMarginLeftVal = false;
7140 pixelMarginRightVal = reliableMarginRightVal = true;
7141
7142 // Check for getComputedStyle so that this code is not run in IE<9.
7143 if ( window.getComputedStyle ) {
7144 divStyle = window.getComputedStyle( div );
7145 pixelPositionVal = ( divStyle || {} ).top !== "1%";
7146 reliableMarginLeftVal = ( divStyle || {} ).marginLeft === "2px";
7147 boxSizingReliableVal = ( divStyle || { width: "4px" } ).width === "4px";
7148
7149 // Support: Android 4.0 - 4.3 only
7150 // Some styles come back with percentage values, even though they shouldn't
7151 div.style.marginRight = "50%";
7152 pixelMarginRightVal = ( divStyle || { marginRight: "4px" } ).marginRight === "4px";
7153
7154 // Support: Android 2.3 only
7155 // Div with explicit width and no margin-right incorrectly
7156 // gets computed margin-right based on width of container (#3333)
7157 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
7158 contents = div.appendChild( document.createElement( "div" ) );
7159
7160 // Reset CSS: box-sizing; display; margin; border; padding
7161 contents.style.cssText = div.style.cssText =
7162
7163 // Support: Android 2.3
7164 // Vendor-prefix box-sizing // Vendor-prefix box-sizing
7165 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" + "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
7166 "box-sizing:content-box;display:block;margin:0;border:0;" + "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
7167 "padding:1px;width:1px;zoom:1"; contents.style.marginRight = contents.style.width = "0";
7168 div.appendChild( document.createElement( "div" ) ).style.width = "5px"; div.style.width = "1px";
7169 shrinkWrapBlocksVal = div.offsetWidth !== 3;
7170 }
7171
7172 body.removeChild( container ); reliableMarginRightVal =
7173 !parseFloat( ( window.getComputedStyle( contents ) || {} ).marginRight );
7174
7175 return shrinkWrapBlocksVal; div.removeChild( contents );
7176 }; }
7177
7178 })(); // Support: IE6-8
7179 var rmargin = (/^margin/); // First check that getClientRects works as expected
7180 // Check if table cells still have offsetWidth/Height when they are set
7181 // to display:none and there are still other visible table cells in a
7182 // table row; if so, offsetWidth/Height are not reliable for use when
7183 // determining if an element has been hidden directly using
7184 // display:none (it is still safe to use offsets if a parent element is
7185 // hidden; don safety goggles and see bug #4512 for more information).
7186 div.style.display = "none";
7187 reliableHiddenOffsetsVal = div.getClientRects().length === 0;
7188 if ( reliableHiddenOffsetsVal ) {
7189 div.style.display = "";
7190 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
7191 div.childNodes[ 0 ].style.borderCollapse = "separate";
7192 contents = div.getElementsByTagName( "td" );
7193 contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
7194 reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
7195 if ( reliableHiddenOffsetsVal ) {
7196 contents[ 0 ].style.display = "";
7197 contents[ 1 ].style.display = "none";
7198 reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
7199 }
7200 }
7201
7202 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); // Teardown
7203 documentElement.removeChild( container );
7204 }
7205
7206 } )();
7207
7208
7209 var getStyles, curCSS, var getStyles, curCSS,
7210 rposition = /^(top|right|bottom|left)$/; rposition = /^(top|right|bottom|left)$/;
7211
7212 if ( window.getComputedStyle ) { if ( window.getComputedStyle ) {
7213 getStyles = function( elem ) { getStyles = function( elem ) {
7214
7215 // Support: IE<=11+, Firefox<=30+ (#15098, #14150) // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
7216 // IE throws on elements created in popups // IE throws on elements created in popups
7217 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
7218 if ( elem.ownerDocument.defaultView.opener ) { var view = elem.ownerDocument.defaultView;
7219 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
7220 if ( !view || !view.opener ) {
7221 view = window;
7222 } }
7223
7224 return window.getComputedStyle( elem, null ); return view.getComputedStyle( elem );
7225 }; };
7226
7227 curCSS = function( elem, name, computed ) { curCSS = function( elem, name, computed ) {
7228 var width, minWidth, maxWidth, ret, var width, minWidth, maxWidth, ret,
7229 style = elem.style; style = elem.style;
7230
7231 computed = computed || getStyles( elem ); computed = computed || getStyles( elem );
7232
7233 // getPropertyValue is only needed for .css('filter') in IE9, see #12537 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
7234 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined; ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
7235
7236 // Support: Opera 12.1x only
7237 // Fall back to style even without computed
7238 // computed is undefined for elems on document fragments
7239 if ( ( ret === "" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) {
7240 ret = jQuery.style( elem, name );
7241 }
7242
7243 if ( computed ) { if ( computed ) {
7244
7245 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
7246 ret = jQuery.style( elem, name );
7247 }
7248
7249 // A tribute to the "awesome hack by Dean Edwards" // A tribute to the "awesome hack by Dean Edwards"
7250 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right // Chrome < 17 and Safari 5.0 uses "computed value"
7251 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels // instead of "used value" for margin-right
7252 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values // Safari 5.1.7 (at least) returns percentage for a larger set of values,
7253 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { // but width seems to be reliably pixels
7254 // this is against the CSSOM draft spec:
7255 // http://dev.w3.org/csswg/cssom/#resolved-values
7256 if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
7257
7258 // Remember the original values // Remember the original values
7259 width = style.width; width = style.width;
7260 minWidth = style.minWidth; minWidth = style.minWidth;
7261 maxWidth = style.maxWidth; maxWidth = style.maxWidth;
7262
7263 // Put in the new values to get a computed value out // Put in the new values to get a computed value out
7264 style.minWidth = style.maxWidth = style.width = ret; style.minWidth = style.maxWidth = style.width = ret;
7265 ret = computed.width; ret = computed.width;
7266
7267 // Revert the changed values // Revert the changed values
7268 style.width = width; style.width = width;
7269 style.minWidth = minWidth; style.minWidth = minWidth;
7270 style.maxWidth = maxWidth; style.maxWidth = maxWidth;
7271 } }
7272 } }
7273
7274 // Support: IE // Support: IE
7275 // IE returns zIndex value as an integer. // IE returns zIndex value as an integer.
7276 return ret === undefined ? return ret === undefined ?
7277 ret : ret :
7278 ret + ""; ret + "";
7279 }; };
7280 } else if ( document.documentElement.currentStyle ) { } else if ( documentElement.currentStyle ) {
7281 getStyles = function( elem ) { getStyles = function( elem ) {
7282 return elem.currentStyle; return elem.currentStyle;
7283 }; };
7284
7285 curCSS = function( elem, name, computed ) { curCSS = function( elem, name, computed ) {
7286 var left, rs, rsLeft, ret, var left, rs, rsLeft, ret,
7287 style = elem.style; style = elem.style;
7288
7289 computed = computed || getStyles( elem ); computed = computed || getStyles( elem );
7290 ret = computed ? computed[ name ] : undefined; ret = computed ? computed[ name ] : undefined;
7291
7292 // Avoid setting ret to empty string here // Avoid setting ret to empty string here
7293 // so we don't default to auto // so we don't default to auto
7294 if ( ret == null && style && style[ name ] ) { if ( ret == null && style && style[ name ] ) {
7295 ret = style[ name ]; ret = style[ name ];
7296 } }
7297
7298 // From the awesome hack by Dean Edwards // From the awesome hack by Dean Edwards
7299 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
7300
7301 // If we're not dealing with a regular pixel number // If we're not dealing with a regular pixel number
7302 // but a number that has a weird ending, we need to convert it to pixels // but a number that has a weird ending, we need to convert it to pixels
7303 // but not position css attributes, as those are proportional to the parent element instead // but not position css attributes, as those are
7304 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem // proportional to the parent element instead
7305 // and we can't measure the parent instead because it
7306 // might trigger a "stacking dolls" problem
7307 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
7308
7309 // Remember the original values // Remember the original values
7310 left = style.left; left = style.left;
7311 rs = elem.runtimeStyle; rs = elem.runtimeStyle;
7312 rsLeft = rs && rs.left; rsLeft = rs && rs.left;
7313
7314 // Put in the new values to get a computed value out // Put in the new values to get a computed value out
7315 if ( rsLeft ) { if ( rsLeft ) {
7316 rs.left = elem.currentStyle.left; rs.left = elem.currentStyle.left;
7317 } }
7318 style.left = name === "fontSize" ? "1em" : ret; style.left = name === "fontSize" ? "1em" : ret;
7319 ret = style.pixelLeft + "px"; ret = style.pixelLeft + "px";
7320
7321 // Revert the changed values // Revert the changed values
7322 style.left = left; style.left = left;
7323 if ( rsLeft ) { if ( rsLeft ) {
7324 rs.left = rsLeft; rs.left = rsLeft;
7325 } }
7326 } }
7327
7328 // Support: IE // Support: IE
7329 // IE returns zIndex value as an integer. // IE returns zIndex value as an integer.
7330 return ret === undefined ? return ret === undefined ?
7331 ret : ret :
7332 ret + "" || "auto"; ret + "" || "auto";
7333 }; };
7334 } }
7335
7336
7337
7338
7339 function addGetHookIf( conditionFn, hookFn ) { function addGetHookIf( conditionFn, hookFn ) {
7340
7341 // Define the hook, we'll check on the first run if it's really needed. // Define the hook, we'll check on the first run if it's really needed.
7342 return { return {
7343 get: function() { get: function() {
7344 var condition = conditionFn(); if ( conditionFn() ) {
7345
7346 if ( condition == null ) { // Hook not needed (or it's not possible to use it due
7347 // The test was not ready at this point; screw the hook this time // to missing dependency), remove it.
7348 // but check again when needed next time.
7349 return;
7350 }
7351
7352 if ( condition ) {
7353 // Hook not needed (or it's not possible to use it due to missing dependency),
7354 // remove it.
7355 // Since there are no other hooks for marginRight, remove the whole object.
7356 delete this.get; delete this.get;
7357 return; return;
7358 } }
7359
7360 // Hook needed; redefine it so that the support test is not executed again. // Hook needed; redefine it so that the support test is not executed again.
7361 return ( this.get = hookFn ).apply( this, arguments );
7362 return (this.get = hookFn).apply( this, arguments );
7363 } }
7364 }; };
7365 } }
7366
7367
7368 (function() {
7369 // Minified: var b,c,d,e,f,g, h,i
7370 var div, style, a, pixelPositionVal, boxSizingReliableVal,
7371 reliableHiddenOffsetsVal, reliableMarginRightVal;
7372
7373 // Setup
7374 div = document.createElement( "div" );
7375 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
7376 a = div.getElementsByTagName( "a" )[ 0 ];
7377 style = a && a.style;
7378
7379 // Finish early in limited (non-browser) environments
7380 if ( !style ) {
7381 return;
7382 }
7383
7384 style.cssText = "float:left;opacity:.5";
7385
7386 // Support: IE<9
7387 // Make sure that element opacity exists (as opposed to filter)
7388 support.opacity = style.opacity === "0.5";
7389
7390 // Verify style float existence
7391 // (IE uses styleFloat instead of cssFloat)
7392 support.cssFloat = !!style.cssFloat;
7393
7394 div.style.backgroundClip = "content-box";
7395 div.cloneNode( true ).style.backgroundClip = "";
7396 support.clearCloneStyle = div.style.backgroundClip === "content-box";
7397
7398 // Support: Firefox<29, Android 2.3
7399 // Vendor-prefix box-sizing
7400 support.boxSizing = style.boxSizing === "" || style.MozBoxSizing === "" ||
7401 style.WebkitBoxSizing === "";
7402
7403 jQuery.extend(support, {
7404 reliableHiddenOffsets: function() {
7405 if ( reliableHiddenOffsetsVal == null ) {
7406 computeStyleTests();
7407 }
7408 return reliableHiddenOffsetsVal;
7409 },
7410
7411 boxSizingReliable: function() {
7412 if ( boxSizingReliableVal == null ) {
7413 computeStyleTests();
7414 }
7415 return boxSizingReliableVal;
7416 },
7417
7418 pixelPosition: function() {
7419 if ( pixelPositionVal == null ) {
7420 computeStyleTests();
7421 }
7422 return pixelPositionVal;
7423 },
7424
7425 // Support: Android 2.3
7426 reliableMarginRight: function() {
7427 if ( reliableMarginRightVal == null ) {
7428 computeStyleTests();
7429 }
7430 return reliableMarginRightVal;
7431 }
7432 });
7433
7434 function computeStyleTests() {
7435 // Minified: var b,c,d,j
7436 var div, body, container, contents;
7437
7438 body = document.getElementsByTagName( "body" )[ 0 ];
7439 if ( !body || !body.style ) {
7440 // Test fired too early or in an unsupported environment, exit.
7441 return;
7442 }
7443
7444 // Setup
7445 div = document.createElement( "div" );
7446 container = document.createElement( "div" );
7447 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
7448 body.appendChild( container ).appendChild( div );
7449
7450 div.style.cssText =
7451 // Support: Firefox<29, Android 2.3
7452 // Vendor-prefix box-sizing
7453 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
7454 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
7455 "border:1px;padding:1px;width:4px;position:absolute";
7456
7457 // Support: IE<9
7458 // Assume reasonable values in the absence of getComputedStyle
7459 pixelPositionVal = boxSizingReliableVal = false;
7460 reliableMarginRightVal = true;
7461
7462 // Check for getComputedStyle so that this code is not run in IE<9.
7463 if ( window.getComputedStyle ) {
7464 pixelPositionVal = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
7465 boxSizingReliableVal =
7466 ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
7467
7468 // Support: Android 2.3
7469 // Div with explicit width and no margin-right incorrectly
7470 // gets computed margin-right based on width of container (#3333)
7471 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
7472 contents = div.appendChild( document.createElement( "div" ) );
7473
7474 // Reset CSS: box-sizing; display; margin; border; padding
7475 contents.style.cssText = div.style.cssText =
7476 // Support: Firefox<29, Android 2.3
7477 // Vendor-prefix box-sizing
7478 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
7479 "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
7480 contents.style.marginRight = contents.style.width = "0";
7481 div.style.width = "1px";
7482
7483 reliableMarginRightVal =
7484 !parseFloat( ( window.getComputedStyle( contents, null ) || {} ).marginRight );
7485
7486 div.removeChild( contents );
7487 }
7488
7489 // Support: IE8
7490 // Check if table cells still have offsetWidth/Height when they are set
7491 // to display:none and there are still other visible table cells in a
7492 // table row; if so, offsetWidth/Height are not reliable for use when
7493 // determining if an element has been hidden directly using
7494 // display:none (it is still safe to use offsets if a parent element is
7495 // hidden; don safety goggles and see bug #4512 for more information).
7496 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
7497 contents = div.getElementsByTagName( "td" );
7498 contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
7499 reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
7500 if ( reliableHiddenOffsetsVal ) {
7501 contents[ 0 ].style.display = "";
7502 contents[ 1 ].style.display = "none";
7503 reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
7504 }
7505
7506 body.removeChild( container );
7507 }
7508
7509 })();
7510
7511
7512 // A method for quickly swapping in/out CSS properties to get correct calculations.
7513 jQuery.swap = function( elem, options, callback, args ) {
7514 var ret, name,
7515 old = {};
7516
7517 // Remember the old values, and insert the new ones
7518 for ( name in options ) {
7519 old[ name ] = elem.style[ name ];
7520 elem.style[ name ] = options[ name ];
7521 }
7522
7523 ret = callback.apply( elem, args || [] );
7524
7525 // Revert the old values
7526 for ( name in options ) {
7527 elem.style[ name ] = old[ name ];
7528 }
7529
7530 return ret;
7531 };
7532
7533
7534 var var
7535
7536 ralpha = /alpha\([^)]*\)/i, ralpha = /alpha\([^)]*\)/i,
7537 ropacity = /opacity\s*=\s*([^)]*)/, ropacity = /opacity\s*=\s*([^)]*)/i,
7538
7539 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" // swappable if display is none or starts with table except
7540 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display // "table", "table-cell", or "table-caption"
7541 // see here for display values:
7542 // https://developer.mozilla.org/en-US/docs/CSS/display
7543 rdisplayswap = /^(none|table(?!-c[ea]).+)/, rdisplayswap = /^(none|table(?!-c[ea]).+)/,
7544 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ), rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
7545 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
7546
7547 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, cssShow = { position: "absolute", visibility: "hidden", display: "block" },
7548 cssNormalTransform = { cssNormalTransform = {
7549 letterSpacing: "0", letterSpacing: "0",
7550 fontWeight: "400" fontWeight: "400"
7551 }, },
7552
7553 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
7554 emptyStyle = document.createElement( "div" ).style;
7555
7556
7557 // return a css property mapped to a potentially vendor prefixed property // return a css property mapped to a potentially vendor prefixed property
7558 function vendorPropName( style, name ) { function vendorPropName( name ) {
7559
7560 // shortcut for names that are not vendor prefixed // shortcut for names that are not vendor prefixed
7561 if ( name in style ) { if ( name in emptyStyle ) {
7562 return name; return name;
7563 } }
7564
7565 // check for vendor prefixed names // check for vendor prefixed names
7566 var capName = name.charAt(0).toUpperCase() + name.slice(1), var capName = name.charAt( 0 ).toUpperCase() + name.slice( 1 ),
7567 origName = name,
7568 i = cssPrefixes.length; i = cssPrefixes.length;
7569
7570 while ( i-- ) { while ( i-- ) {
7571 name = cssPrefixes[ i ] + capName; name = cssPrefixes[ i ] + capName;
7572 if ( name in style ) { if ( name in emptyStyle ) {
7573 return name; return name;
7574 } }
7575 } }
7576
7577 return origName;
7578 } }
7579
7580 function showHide( elements, show ) { function showHide( elements, show ) {
7581 var display, elem, hidden, var display, elem, hidden,
7582 values = [], values = [],
7583 index = 0, index = 0,
7584 length = elements.length; length = elements.length;
7585
7586 for ( ; index < length; index++ ) { for ( ; index < length; index++ ) {
7587 elem = elements[ index ]; elem = elements[ index ];
7588 if ( !elem.style ) { if ( !elem.style ) {
7589 continue; continue;
7590 } }
7591
7592 values[ index ] = jQuery._data( elem, "olddisplay" ); values[ index ] = jQuery._data( elem, "olddisplay" );
7593 display = elem.style.display; display = elem.style.display;
7594 if ( show ) { if ( show ) {
7595
7596 // Reset the inline display of this element to learn if it is // Reset the inline display of this element to learn if it is
7597 // being hidden by cascaded rules or not // being hidden by cascaded rules or not
7598 if ( !values[ index ] && display === "none" ) { if ( !values[ index ] && display === "none" ) {
7599 elem.style.display = ""; elem.style.display = "";
7600 } }
7601
7602 // Set elements which have been overridden with display: none // Set elements which have been overridden with display: none
7603 // in a stylesheet to whatever the default browser style is // in a stylesheet to whatever the default browser style is
7604 // for such an element // for such an element
7605 if ( elem.style.display === "" && isHidden( elem ) ) { if ( elem.style.display === "" && isHidden( elem ) ) {
7606 values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) ); values[ index ] =
7607 jQuery._data( elem, "olddisplay", defaultDisplay( elem.nodeName ) );
7608 } }
7609 } else { } else {
7610 hidden = isHidden( elem ); hidden = isHidden( elem );
7611
7612 if ( display && display !== "none" || !hidden ) { if ( display && display !== "none" || !hidden ) {
7613 jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); jQuery._data(
7614 elem,
7615 "olddisplay",
7616 hidden ? display : jQuery.css( elem, "display" )
7617 );
7618 } }
7619 } }
7620 } }
7621
7622 // Set the display of most of the elements in a second loop // Set the display of most of the elements in a second loop
7623 // to avoid the constant reflow // to avoid the constant reflow
7624 for ( index = 0; index < length; index++ ) { for ( index = 0; index < length; index++ ) {
7625 elem = elements[ index ]; elem = elements[ index ];
7626 if ( !elem.style ) { if ( !elem.style ) {
7627 continue; continue;
7628 } }
7629 if ( !show || elem.style.display === "none" || elem.style.display === "" ) { if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
7630 elem.style.display = show ? values[ index ] || "" : "none"; elem.style.display = show ? values[ index ] || "" : "none";
7631 } }
7632 } }
7633
7634 return elements; return elements;
7635 } }
7636
7637 function setPositiveNumber( elem, value, subtract ) { function setPositiveNumber( elem, value, subtract ) {
7638 var matches = rnumsplit.exec( value ); var matches = rnumsplit.exec( value );
7639 return matches ? return matches ?
7640
7641 // Guard against undefined "subtract", e.g., when used as in cssHooks // Guard against undefined "subtract", e.g., when used as in cssHooks
7642 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
7643 value; value;
7644 } }
7645
7646 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
7647 var i = extra === ( isBorderBox ? "border" : "content" ) ? var i = extra === ( isBorderBox ? "border" : "content" ) ?
7648
7649 // If we already have the right measurement, avoid augmentation // If we already have the right measurement, avoid augmentation
7650 4 : 4 :
7651
7652 // Otherwise initialize for horizontal or vertical properties // Otherwise initialize for horizontal or vertical properties
7653 name === "width" ? 1 : 0, name === "width" ? 1 : 0,
7654
7655 val = 0; val = 0;
7656
7657 for ( ; i < 4; i += 2 ) { for ( ; i < 4; i += 2 ) {
7658
7659 // both box models exclude margin, so add it if we want it // both box models exclude margin, so add it if we want it
7660 if ( extra === "margin" ) { if ( extra === "margin" ) {
7661 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
7662 } }
7663
7664 if ( isBorderBox ) { if ( isBorderBox ) {
7665
7666 // border-box includes padding, so remove it if we want content // border-box includes padding, so remove it if we want content
7667 if ( extra === "content" ) { if ( extra === "content" ) {
7668 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
7669 } }
7670
7671 // at this point, extra isn't border nor margin, so remove border // at this point, extra isn't border nor margin, so remove border
7672 if ( extra !== "margin" ) { if ( extra !== "margin" ) {
7673 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
7674 } }
7675 } else { } else {
7676
7677 // at this point, extra isn't content, so add padding // at this point, extra isn't content, so add padding
7678 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
7679
7680 // at this point, extra isn't content nor padding, so add border // at this point, extra isn't content nor padding, so add border
7681 if ( extra !== "padding" ) { if ( extra !== "padding" ) {
7682 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
7683 } }
7684 } }
7685 } }
7686
7687 return val; return val;
7688 } }
7689
7690 function getWidthOrHeight( elem, name, extra ) { function getWidthOrHeight( elem, name, extra ) {
7691
7692 // Start with offset property, which is equivalent to the border-box value // Start with offset property, which is equivalent to the border-box value
7693 var valueIsBorderBox = true, var valueIsBorderBox = true,
7694 val = name === "width" ? elem.offsetWidth : elem.offsetHeight, val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
7695 styles = getStyles( elem ), styles = getStyles( elem ),
7696 isBorderBox = support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; isBorderBox = support.boxSizing &&
7697 jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
7698
7699 // some non-html elements return undefined for offsetWidth, so check for null/undefined // some non-html elements return undefined for offsetWidth, so check for null/undefined
7700 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
7701 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
7702 if ( val <= 0 || val == null ) { if ( val <= 0 || val == null ) {
7703
7704 // Fall back to computed then uncomputed css if necessary // Fall back to computed then uncomputed css if necessary
7705 val = curCSS( elem, name, styles ); val = curCSS( elem, name, styles );
7706 if ( val < 0 || val == null ) { if ( val < 0 || val == null ) {
7707 val = elem.style[ name ]; val = elem.style[ name ];
7708 } }
7709
7710 // Computed unit is not pixels. Stop here and return. // Computed unit is not pixels. Stop here and return.
7711 if ( rnumnonpx.test(val) ) { if ( rnumnonpx.test( val ) ) {
7712 return val; return val;
7713 } }
7714
7715 // we need the check for style in case a browser which returns unreliable values // we need the check for style in case a browser which returns unreliable values
7716 // for getComputedStyle silently falls back to the reliable elem.style // for getComputedStyle silently falls back to the reliable elem.style
7717 valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] ); valueIsBorderBox = isBorderBox &&
7718 ( support.boxSizingReliable() || val === elem.style[ name ] );
7719
7720 // Normalize "", auto, and prepare for extra // Normalize "", auto, and prepare for extra
7721 val = parseFloat( val ) || 0; val = parseFloat( val ) || 0;
7722 } }
7723
7724 // use the active box-sizing model to add/subtract irrelevant styles // use the active box-sizing model to add/subtract irrelevant styles
7725 return ( val + return ( val +
7726 augmentWidthOrHeight( augmentWidthOrHeight(
7727 elem, elem,
7728 name, name,
7729 extra || ( isBorderBox ? "border" : "content" ), extra || ( isBorderBox ? "border" : "content" ),
7730 valueIsBorderBox, valueIsBorderBox,
7731 styles styles
7732 ) )
7733 ) + "px"; ) + "px";
7734 } }
7735
7736 jQuery.extend({ jQuery.extend( {
7737 // Add in style property hooks for overriding the default // Add in style property hooks for overriding the default
7738 // behavior of getting and setting a style property // behavior of getting and setting a style property
7739 cssHooks: { cssHooks: {
7740 opacity: { opacity: {
7741 get: function( elem, computed ) { get: function( elem, computed ) {
7742 if ( computed ) { if ( computed ) {
7743
7744 // We should always get a number back from opacity // We should always get a number back from opacity
7745 var ret = curCSS( elem, "opacity" ); var ret = curCSS( elem, "opacity" );
7746 return ret === "" ? "1" : ret; return ret === "" ? "1" : ret;
7747 } }
7748 } }
7749 } }
7750 }, },
7751
7752 // Don't automatically add "px" to these possibly-unitless properties // Don't automatically add "px" to these possibly-unitless properties
7753 cssNumber: { cssNumber: {
7754 "animationIterationCount": true,
7755 "columnCount": true, "columnCount": true,
7756 "fillOpacity": true, "fillOpacity": true,
7757 "flexGrow": true, "flexGrow": true,
7758 "flexShrink": true, "flexShrink": true,
7759 "fontWeight": true, "fontWeight": true,
7760 "lineHeight": true, "lineHeight": true,
7761 "opacity": true, "opacity": true,
7762 "order": true, "order": true,
7763 "orphans": true, "orphans": true,
7764 "widows": true, "widows": true,
7765 "zIndex": true, "zIndex": true,
7766 "zoom": true "zoom": true
7767 }, },
7768
7769 // Add in properties whose names you wish to fix before // Add in properties whose names you wish to fix before
7770 // setting or getting the value // setting or getting the value
7771 cssProps: { cssProps: {
7772
7773 // normalize float css property // normalize float css property
7774 "float": support.cssFloat ? "cssFloat" : "styleFloat" "float": support.cssFloat ? "cssFloat" : "styleFloat"
7775 }, },
7776
7777 // Get and set the style property on a DOM Node // Get and set the style property on a DOM Node
7778 style: function( elem, name, value, extra ) { style: function( elem, name, value, extra ) {
7779
7780 // Don't set styles on text and comment nodes // Don't set styles on text and comment nodes
7781 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
7782 return; return;
7783 } }
7784
7785 // Make sure that we're working with the right name // Make sure that we're working with the right name
7786 var ret, type, hooks, var ret, type, hooks,
7787 origName = jQuery.camelCase( name ), origName = jQuery.camelCase( name ),
7788 style = elem.style; style = elem.style;
7789
7790 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); name = jQuery.cssProps[ origName ] ||
7791 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
7792
7793 // gets hook for the prefixed version // gets hook for the prefixed version
7794 // followed by the unprefixed version // followed by the unprefixed version
7795 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
7796
7797 // Check if we're setting a value // Check if we're setting a value
7798 if ( value !== undefined ) { if ( value !== undefined ) {
7799 type = typeof value; type = typeof value;
7800
7801 // convert relative number strings (+= or -=) to relative numbers. #7345 // Convert "+=" or "-=" to relative numbers (#7345)
7802 if ( type === "string" && (ret = rrelNum.exec( value )) ) { if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
7803 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); value = adjustCSS( elem, name, ret );
7804 // Fixes bug #9237 // Fixes bug #9237
7805 type = "number"; type = "number";
7806 } }
7807
7808 // Make sure that null and NaN values aren't set. See: #7116 // Make sure that null and NaN values aren't set. See: #7116
7809 if ( value == null || value !== value ) { if ( value == null || value !== value ) {
7810 return; return;
7811 } }
7812
7813 // If a number was passed in, add 'px' to the (except for certain CSS properties) // If a number was passed in, add the unit (except for certain CSS properties)
7814 if ( type === "number" && !jQuery.cssNumber[ origName ] ) { if ( type === "number" ) {
7815 value += "px"; value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
7816 } }
7817
7818 // Fixes #8908, it can be done more correctly by specifing setters in cssHooks, // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
7819 // but it would mean to define eight (for every problematic property) identical functions // but it would mean to define eight
7820 if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) { // (for every problematic property) identical functions
7821 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
7822 style[ name ] = "inherit"; style[ name ] = "inherit";
7823 } }
7824
7825 // If a hook was provided, use that value, otherwise just set the specified value // If a hook was provided, use that value, otherwise just set the specified value
7826 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { if ( !hooks || !( "set" in hooks ) ||
7827 ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
7828
7829 // Support: IE // Support: IE
7830 // Swallow errors from 'invalid' CSS values (#5509) // Swallow errors from 'invalid' CSS values (#5509)
7831 try { try {
7832 style[ name ] = value; style[ name ] = value;
7833 } catch(e) {} } catch ( e ) {}
7834 } }
7835
7836 } else { } else {
7837
7838 // If a hook was provided get the non-computed value from there // If a hook was provided get the non-computed value from there
7839 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { if ( hooks && "get" in hooks &&
7840 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
7841 return ret; return ret;
7842 } }
7843
7844 // Otherwise just get the value from the style object // Otherwise just get the value from the style object
7845 return style[ name ]; return style[ name ];
7846 } }
7847 }, },
7848
7849 css: function( elem, name, extra, styles ) { css: function( elem, name, extra, styles ) {
7850 var num, val, hooks, var num, val, hooks,
7851 origName = jQuery.camelCase( name ); origName = jQuery.camelCase( name );
7852
7853 // Make sure that we're working with the right name // Make sure that we're working with the right name
7854 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); name = jQuery.cssProps[ origName ] ||
7855 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
7856
7857 // gets hook for the prefixed version // gets hook for the prefixed version
7858 // followed by the unprefixed version // followed by the unprefixed version
7859 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
7860
7861 // If a hook was provided get the computed value from there // If a hook was provided get the computed value from there
7862 if ( hooks && "get" in hooks ) { if ( hooks && "get" in hooks ) {
7863 val = hooks.get( elem, true, extra ); val = hooks.get( elem, true, extra );
7864 } }
7865
7866 // Otherwise, if a way to get the computed value exists, use that // Otherwise, if a way to get the computed value exists, use that
7867 if ( val === undefined ) { if ( val === undefined ) {
7868 val = curCSS( elem, name, styles ); val = curCSS( elem, name, styles );
7869 } }
7870
7871 //convert "normal" to computed value //convert "normal" to computed value
7872 if ( val === "normal" && name in cssNormalTransform ) { if ( val === "normal" && name in cssNormalTransform ) {
7873 val = cssNormalTransform[ name ]; val = cssNormalTransform[ name ];
7874 } }
7875
7876 // Return, converting to number if forced or a qualifier was provided and val looks numeric // Return, converting to number if forced or a qualifier was provided and val looks numeric
7877 if ( extra === "" || extra ) { if ( extra === "" || extra ) {
7878 num = parseFloat( val ); num = parseFloat( val );
7879 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; return extra === true || isFinite( num ) ? num || 0 : val;
7880 } }
7881 return val; return val;
7882 } }
7883 }); } );
7884
7885 jQuery.each([ "height", "width" ], function( i, name ) { jQuery.each( [ "height", "width" ], function( i, name ) {
7886 jQuery.cssHooks[ name ] = { jQuery.cssHooks[ name ] = {
7887 get: function( elem, computed, extra ) { get: function( elem, computed, extra ) {
7888 if ( computed ) { if ( computed ) {
7889
7890 // certain elements can have dimension info if we invisibly show them // certain elements can have dimension info if we invisibly show them
7891 // however, it must have a current display style that would benefit from this // however, it must have a current display style that would benefit from this
7892 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ? return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
7893 jQuery.swap( elem, cssShow, function() { elem.offsetWidth === 0 ?
7894 return getWidthOrHeight( elem, name, extra ); swap( elem, cssShow, function() {
7895 }) : return getWidthOrHeight( elem, name, extra );
7896 getWidthOrHeight( elem, name, extra ); } ) :
7897 getWidthOrHeight( elem, name, extra );
7898 } }
7899 }, },
7900
7901 set: function( elem, value, extra ) { set: function( elem, value, extra ) {
7902 var styles = extra && getStyles( elem ); var styles = extra && getStyles( elem );
7903 return setPositiveNumber( elem, value, extra ? return setPositiveNumber( elem, value, extra ?
7904 augmentWidthOrHeight( augmentWidthOrHeight(
7905 elem, elem,
7906 name, name,
7907 extra, extra,
7908 support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box", support.boxSizing &&
7909 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
7910 styles styles
7911 ) : 0 ) : 0
7912 ); );
7913 } }
7914 }; };
7915 }); } );
7916
7917 if ( !support.opacity ) { if ( !support.opacity ) {
7918 jQuery.cssHooks.opacity = { jQuery.cssHooks.opacity = {
7919 get: function( elem, computed ) { get: function( elem, computed ) {
7920
7921 // IE uses filters for opacity // IE uses filters for opacity
7922 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? return ropacity.test( ( computed && elem.currentStyle ?
7923 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" : elem.currentStyle.filter :
7924 computed ? "1" : ""; elem.style.filter ) || "" ) ?
7925 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
7926 computed ? "1" : "";
7927 }, },
7928
7929 set: function( elem, value ) { set: function( elem, value ) {
7930 var style = elem.style, var style = elem.style,
7931 currentStyle = elem.currentStyle, currentStyle = elem.currentStyle,
7932 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "", opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
7933 filter = currentStyle && currentStyle.filter || style.filter || ""; filter = currentStyle && currentStyle.filter || style.filter || "";
7934
7935 // IE has trouble with opacity if it does not have layout // IE has trouble with opacity if it does not have layout
7936 // Force it by setting the zoom level // Force it by setting the zoom level
7937 style.zoom = 1; style.zoom = 1;
7938
7939 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 // if setting opacity to 1, and no other filters exist -
7940 // attempt to remove filter attribute #6652
7941 // if value === "", then remove inline opacity #12685 // if value === "", then remove inline opacity #12685
7942 if ( ( value >= 1 || value === "" ) && if ( ( value >= 1 || value === "" ) &&
7943 jQuery.trim( filter.replace( ralpha, "" ) ) === "" && jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
7944 style.removeAttribute ) { style.removeAttribute ) {
7945
7946 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
7947 // if "filter:" is present at all, clearType is disabled, we want to avoid this // if "filter:" is present at all, clearType is disabled, we want to avoid this
7948 // style.removeAttribute is IE Only, but so apparently is this code path... // style.removeAttribute is IE Only, but so apparently is this code path...
7949 style.removeAttribute( "filter" ); style.removeAttribute( "filter" );
7950
7951 // if there is no filter style applied in a css rule or unset inline opacity, we are done // if there is no filter style applied in a css rule
7952 // or unset inline opacity, we are done
7953 if ( value === "" || currentStyle && !currentStyle.filter ) { if ( value === "" || currentStyle && !currentStyle.filter ) {
7954 return; return;
7955 } }
7956 } }
7957
7958 // otherwise, set new filter values // otherwise, set new filter values
7959 style.filter = ralpha.test( filter ) ? style.filter = ralpha.test( filter ) ?
7960 filter.replace( ralpha, opacity ) : filter.replace( ralpha, opacity ) :
7961 filter + " " + opacity; filter + " " + opacity;
7962 } }
7963 }; };
7964 } }
7965
7966 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
7967 function( elem, computed ) { function( elem, computed ) {
7968 if ( computed ) { if ( computed ) {
7969 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right return swap( elem, { "display": "inline-block" },
7970 // Work around by temporarily setting element display to inline-block
7971 return jQuery.swap( elem, { "display": "inline-block" },
7972 curCSS, [ elem, "marginRight" ] ); curCSS, [ elem, "marginRight" ] );
7973 } }
7974 } }
7975 ); );
7976
7977 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
7978 function( elem, computed ) {
7979 if ( computed ) {
7980 return (
7981 parseFloat( curCSS( elem, "marginLeft" ) ) ||
7982
7983 // Support: IE<=11+
7984 // Running getBoundingClientRect on a disconnected node in IE throws an error
7985 // Support: IE8 only
7986 // getClientRects() errors on disconnected elems
7987 ( jQuery.contains( elem.ownerDocument, elem ) ?
7988 elem.getBoundingClientRect().left -
7989 swap( elem, { marginLeft: 0 }, function() {
7990 return elem.getBoundingClientRect().left;
7991 } ) :
7992 0
7993 )
7994 ) + "px";
7995 }
7996 }
7997 );
7998
7999 // These hooks are used by animate to expand properties // These hooks are used by animate to expand properties
8000 jQuery.each({ jQuery.each( {
8001 margin: "", margin: "",
8002 padding: "", padding: "",
8003 border: "Width" border: "Width"
8004 }, function( prefix, suffix ) { }, function( prefix, suffix ) {
8005 jQuery.cssHooks[ prefix + suffix ] = { jQuery.cssHooks[ prefix + suffix ] = {
8006 expand: function( value ) { expand: function( value ) {
8007 var i = 0, var i = 0,
8008 expanded = {}, expanded = {},
8009
8010 // assumes a single number if not a string // assumes a single number if not a string
8011 parts = typeof value === "string" ? value.split(" ") : [ value ]; parts = typeof value === "string" ? value.split( " " ) : [ value ];
8012
8013 for ( ; i < 4; i++ ) { for ( ; i < 4; i++ ) {
8014 expanded[ prefix + cssExpand[ i ] + suffix ] = expanded[ prefix + cssExpand[ i ] + suffix ] =
8015 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
8016 } }
8017
8018 return expanded; return expanded;
8019 } }
8020 }; };
8021
8022 if ( !rmargin.test( prefix ) ) { if ( !rmargin.test( prefix ) ) {
8023 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
8024 } }
8025 }); } );
8026
8027 jQuery.fn.extend({ jQuery.fn.extend( {
8028 css: function( name, value ) { css: function( name, value ) {
8029 return access( this, function( elem, name, value ) { return access( this, function( elem, name, value ) {
8030 var styles, len, var styles, len,
8031 map = {}, map = {},
8032 i = 0; i = 0;
8033
8034 if ( jQuery.isArray( name ) ) { if ( jQuery.isArray( name ) ) {
8035 styles = getStyles( elem ); styles = getStyles( elem );
8036 len = name.length; len = name.length;
8037
8038 for ( ; i < len; i++ ) { for ( ; i < len; i++ ) {
8039 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
8040 } }
8041
8042 return map; return map;
8043 } }
8044
8045 return value !== undefined ? return value !== undefined ?
8046 jQuery.style( elem, name, value ) : jQuery.style( elem, name, value ) :
8047 jQuery.css( elem, name ); jQuery.css( elem, name );
8048 }, name, value, arguments.length > 1 ); }, name, value, arguments.length > 1 );
8049 }, },
8050 show: function() { show: function() {
8051 return showHide( this, true ); return showHide( this, true );
8052 }, },
8053 hide: function() { hide: function() {
8054 return showHide( this ); return showHide( this );
8055 }, },
8056 toggle: function( state ) { toggle: function( state ) {
8057 if ( typeof state === "boolean" ) { if ( typeof state === "boolean" ) {
8058 return state ? this.show() : this.hide(); return state ? this.show() : this.hide();
8059 } }
8060
8061 return this.each(function() { return this.each( function() {
8062 if ( isHidden( this ) ) { if ( isHidden( this ) ) {
8063 jQuery( this ).show(); jQuery( this ).show();
8064 } else { } else {
8065 jQuery( this ).hide(); jQuery( this ).hide();
8066 } }
8067 }); } );
8068 } }
8069 }); } );
8070
8071
8072 function Tween( elem, options, prop, end, easing ) { function Tween( elem, options, prop, end, easing ) {
8073 return new Tween.prototype.init( elem, options, prop, end, easing ); return new Tween.prototype.init( elem, options, prop, end, easing );
8074 } }
8075 jQuery.Tween = Tween; jQuery.Tween = Tween;
8076
8077 Tween.prototype = { Tween.prototype = {
8078 constructor: Tween, constructor: Tween,
8079 init: function( elem, options, prop, end, easing, unit ) { init: function( elem, options, prop, end, easing, unit ) {
8080 this.elem = elem; this.elem = elem;
8081 this.prop = prop; this.prop = prop;
8082 this.easing = easing || "swing"; this.easing = easing || jQuery.easing._default;
8083 this.options = options; this.options = options;
8084 this.start = this.now = this.cur(); this.start = this.now = this.cur();
8085 this.end = end; this.end = end;
8086 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
8087 }, },
8088 cur: function() { cur: function() {
8089 var hooks = Tween.propHooks[ this.prop ]; var hooks = Tween.propHooks[ this.prop ];
8090
8091 return hooks && hooks.get ? return hooks && hooks.get ?
8092 hooks.get( this ) : hooks.get( this ) :
8093 Tween.propHooks._default.get( this ); Tween.propHooks._default.get( this );
8094 }, },
8095 run: function( percent ) { run: function( percent ) {
8096 var eased, var eased,
8097 hooks = Tween.propHooks[ this.prop ]; hooks = Tween.propHooks[ this.prop ];
8098
8099 if ( this.options.duration ) { if ( this.options.duration ) {
8100 this.pos = eased = jQuery.easing[ this.easing ]( this.pos = eased = jQuery.easing[ this.easing ](
8101 percent, this.options.duration * percent, 0, 1, this.options.duration percent, this.options.duration * percent, 0, 1, this.options.duration
8102 ); );
8103 } else { } else {
8104 this.pos = eased = percent; this.pos = eased = percent;
8105 } }
8106 this.now = ( this.end - this.start ) * eased + this.start; this.now = ( this.end - this.start ) * eased + this.start;
8107
8108 if ( this.options.step ) { if ( this.options.step ) {
8109 this.options.step.call( this.elem, this.now, this ); this.options.step.call( this.elem, this.now, this );
8110 } }
8111
8112 if ( hooks && hooks.set ) { if ( hooks && hooks.set ) {
8113 hooks.set( this ); hooks.set( this );
8114 } else { } else {
8115 Tween.propHooks._default.set( this ); Tween.propHooks._default.set( this );
8116 } }
8117 return this; return this;
8118 } }
8119 }; };
8120
8121 Tween.prototype.init.prototype = Tween.prototype; Tween.prototype.init.prototype = Tween.prototype;
8122
8123 Tween.propHooks = { Tween.propHooks = {
8124 _default: { _default: {
8125 get: function( tween ) { get: function( tween ) {
8126 var result; var result;
8127
8128 if ( tween.elem[ tween.prop ] != null && // Use a property on the element directly when it is not a DOM element,
8129 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { // or when there is no matching style property that exists.
8130 if ( tween.elem.nodeType !== 1 ||
8131 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
8132 return tween.elem[ tween.prop ]; return tween.elem[ tween.prop ];
8133 } }
8134
8135 // passing an empty string as a 3rd parameter to .css will automatically // passing an empty string as a 3rd parameter to .css will automatically
8136 // attempt a parseFloat and fallback to a string if the parse fails // attempt a parseFloat and fallback to a string if the parse fails
8137 // so, simple values such as "10px" are parsed to Float. // so, simple values such as "10px" are parsed to Float.
8138 // complex values such as "rotate(1rad)" are returned as is. // complex values such as "rotate(1rad)" are returned as is.
8139 result = jQuery.css( tween.elem, tween.prop, "" ); result = jQuery.css( tween.elem, tween.prop, "" );
8140
8141 // Empty strings, null, undefined and "auto" are converted to 0. // Empty strings, null, undefined and "auto" are converted to 0.
8142 return !result || result === "auto" ? 0 : result; return !result || result === "auto" ? 0 : result;
8143 }, },
8144 set: function( tween ) { set: function( tween ) {
8145
8146 // use step hook for back compat - use cssHook if its there - use .style if its // use step hook for back compat - use cssHook if its there - use .style if its
8147 // available and use plain properties where available // available and use plain properties where available
8148 if ( jQuery.fx.step[ tween.prop ] ) { if ( jQuery.fx.step[ tween.prop ] ) {
8149 jQuery.fx.step[ tween.prop ]( tween ); jQuery.fx.step[ tween.prop ]( tween );
8150 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { } else if ( tween.elem.nodeType === 1 &&
8151 ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
8152 jQuery.cssHooks[ tween.prop ] ) ) {
8153 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
8154 } else { } else {
8155 tween.elem[ tween.prop ] = tween.now; tween.elem[ tween.prop ] = tween.now;
8156 } }
8157 } }
8158 } }
8159 }; };
8160
8161 // Support: IE <=9 // Support: IE <=9
8162 // Panic based approach to setting things on disconnected nodes // Panic based approach to setting things on disconnected nodes
8163
8164 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
8165 set: function( tween ) { set: function( tween ) {
8166 if ( tween.elem.nodeType && tween.elem.parentNode ) { if ( tween.elem.nodeType && tween.elem.parentNode ) {
8167 tween.elem[ tween.prop ] = tween.now; tween.elem[ tween.prop ] = tween.now;
8168 } }
8169 } }
8170 }; };
8171
8172 jQuery.easing = { jQuery.easing = {
8173 linear: function( p ) { linear: function( p ) {
8174 return p; return p;
8175 }, },
8176 swing: function( p ) { swing: function( p ) {
8177 return 0.5 - Math.cos( p * Math.PI ) / 2; return 0.5 - Math.cos( p * Math.PI ) / 2;
8178 } },
8179 _default: "swing"
8180 }; };
8181
8182 jQuery.fx = Tween.prototype.init; jQuery.fx = Tween.prototype.init;
8183
8184 // Back Compat <1.8 extension point // Back Compat <1.8 extension point
8185 jQuery.fx.step = {}; jQuery.fx.step = {};
8186
8187
8188
8189
8190 var var
8191 fxNow, timerId, fxNow, timerId,
8192 rfxtypes = /^(?:toggle|show|hide)$/, rfxtypes = /^(?:toggle|show|hide)$/,
8193 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ), rrun = /queueHooks$/;
8194 rrun = /queueHooks$/,
8195 animationPrefilters = [ defaultPrefilter ],
8196 tweeners = {
8197 "*": [ function( prop, value ) {
8198 var tween = this.createTween( prop, value ),
8199 target = tween.cur(),
8200 parts = rfxnum.exec( value ),
8201 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
8202
8203 // Starting value computation is required for potential unit mismatches
8204 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
8205 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
8206 scale = 1,
8207 maxIterations = 20;
8208
8209 if ( start && start[ 3 ] !== unit ) {
8210 // Trust units reported by jQuery.css
8211 unit = unit || start[ 3 ];
8212
8213 // Make sure we update the tween properties later on
8214 parts = parts || [];
8215
8216 // Iteratively approximate from a nonzero starting point
8217 start = +target || 1;
8218
8219 do {
8220 // If previous iteration zeroed out, double until we get *something*
8221 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
8222 scale = scale || ".5";
8223
8224 // Adjust and apply
8225 start = start / scale;
8226 jQuery.style( tween.elem, prop, start + unit );
8227
8228 // Update scale, tolerating zero or NaN from tween.cur()
8229 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
8230 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
8231 }
8232
8233 // Update tween properties
8234 if ( parts ) {
8235 start = tween.start = +start || +target || 0;
8236 tween.unit = unit;
8237 // If a +=/-= token was provided, we're doing a relative animation
8238 tween.end = parts[ 1 ] ?
8239 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
8240 +parts[ 2 ];
8241 }
8242
8243 return tween;
8244 } ]
8245 };
8246
8247 // Animations created synchronously will run synchronously // Animations created synchronously will run synchronously
8248 function createFxNow() { function createFxNow() {
8249 setTimeout(function() { window.setTimeout( function() {
8250 fxNow = undefined; fxNow = undefined;
8251 }); } );
8252 return ( fxNow = jQuery.now() ); return ( fxNow = jQuery.now() );
8253 } }
8254
8255 // Generate parameters to create a standard animation // Generate parameters to create a standard animation
8256 function genFx( type, includeWidth ) { function genFx( type, includeWidth ) {
8257 var which, var which,
8258 attrs = { height: type }, attrs = { height: type },
8259 i = 0; i = 0;
8260
8261 // if we include width, step value is 1 to do all cssExpand values, // if we include width, step value is 1 to do all cssExpand values,
8262 // if we don't include width, step value is 2 to skip over Left and Right // if we don't include width, step value is 2 to skip over Left and Right
8263 includeWidth = includeWidth ? 1 : 0; includeWidth = includeWidth ? 1 : 0;
8264 for ( ; i < 4 ; i += 2 - includeWidth ) { for ( ; i < 4 ; i += 2 - includeWidth ) {
8265 which = cssExpand[ i ]; which = cssExpand[ i ];
8266 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
8267 } }
8268
8269 if ( includeWidth ) { if ( includeWidth ) {
8270 attrs.opacity = attrs.width = type; attrs.opacity = attrs.width = type;
8271 } }
8272
8273 return attrs; return attrs;
8274 } }
8275
8276 function createTween( value, prop, animation ) { function createTween( value, prop, animation ) {
8277 var tween, var tween,
8278 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
8279 index = 0, index = 0,
8280 length = collection.length; length = collection.length;
8281 for ( ; index < length; index++ ) { for ( ; index < length; index++ ) {
8282 if ( (tween = collection[ index ].call( animation, prop, value )) ) { if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
8283
8284 // we're done with this property // we're done with this property
8285 return tween; return tween;
8286 } }
8287 } }
8288 } }
8289
8290 function defaultPrefilter( elem, props, opts ) { function defaultPrefilter( elem, props, opts ) {
8291 /* jshint validthis: true */ /* jshint validthis: true */
8292 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay, var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
8293 anim = this, anim = this,
8294 orig = {}, orig = {},
8295 style = elem.style, style = elem.style,
8296 hidden = elem.nodeType && isHidden( elem ), hidden = elem.nodeType && isHidden( elem ),
8297 dataShow = jQuery._data( elem, "fxshow" ); dataShow = jQuery._data( elem, "fxshow" );
8298
8299 // handle queue: false promises // handle queue: false promises
8300 if ( !opts.queue ) { if ( !opts.queue ) {
8301 hooks = jQuery._queueHooks( elem, "fx" ); hooks = jQuery._queueHooks( elem, "fx" );
8302 if ( hooks.unqueued == null ) { if ( hooks.unqueued == null ) {
8303 hooks.unqueued = 0; hooks.unqueued = 0;
8304 oldfire = hooks.empty.fire; oldfire = hooks.empty.fire;
8305 hooks.empty.fire = function() { hooks.empty.fire = function() {
8306 if ( !hooks.unqueued ) { if ( !hooks.unqueued ) {
8307 oldfire(); oldfire();
8308 } }
8309 }; };
8310 } }
8311 hooks.unqueued++; hooks.unqueued++;
8312
8313 anim.always(function() { anim.always( function() {
8314 // doing this makes sure that the complete handler will be called // doing this makes sure that the complete handler will be called
8315 // before this completes // before this completes
8316 anim.always(function() { anim.always( function() {
8317 hooks.unqueued--; hooks.unqueued--;
8318 if ( !jQuery.queue( elem, "fx" ).length ) { if ( !jQuery.queue( elem, "fx" ).length ) {
8319 hooks.empty.fire(); hooks.empty.fire();
8320 } }
8321 }); } );
8322 }); } );
8323 } }
8324
8325 // height/width overflow pass // height/width overflow pass
8326 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
8327
8328 // Make sure that nothing sneaks out // Make sure that nothing sneaks out
8329 // Record all 3 overflow attributes because IE does not // Record all 3 overflow attributes because IE does not
8330 // change the overflow attribute when overflowX and // change the overflow attribute when overflowX and
8331 // overflowY are set to the same value // overflowY are set to the same value
8332 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
8333
8334 // Set display property to inline-block for height/width // Set display property to inline-block for height/width
8335 // animations on inline elements that are having width/height animated // animations on inline elements that are having width/height animated
8336 display = jQuery.css( elem, "display" ); display = jQuery.css( elem, "display" );
8337
8338 // Test default display if display is currently "none" // Test default display if display is currently "none"
8339 checkDisplay = display === "none" ? checkDisplay = display === "none" ?
8340 jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
8341
8342 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
8343
8344 // inline-level elements accept inline-block; // inline-level elements accept inline-block;
8345 // block-level elements need to be inline with layout // block-level elements need to be inline with layout
8346 if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) { if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
8347 style.display = "inline-block"; style.display = "inline-block";
8348 } else { } else {
8349 style.zoom = 1; style.zoom = 1;
8350 } }
8351 } }
8352 } }
8353
8354 if ( opts.overflow ) { if ( opts.overflow ) {
8355 style.overflow = "hidden"; style.overflow = "hidden";
8356 if ( !support.shrinkWrapBlocks() ) { if ( !support.shrinkWrapBlocks() ) {
8357 anim.always(function() { anim.always( function() {
8358 style.overflow = opts.overflow[ 0 ]; style.overflow = opts.overflow[ 0 ];
8359 style.overflowX = opts.overflow[ 1 ]; style.overflowX = opts.overflow[ 1 ];
8360 style.overflowY = opts.overflow[ 2 ]; style.overflowY = opts.overflow[ 2 ];
8361 }); } );
8362 } }
8363 } }
8364
8365 // show/hide pass // show/hide pass
8366 for ( prop in props ) { for ( prop in props ) {
8367 value = props[ prop ]; value = props[ prop ];
8368 if ( rfxtypes.exec( value ) ) { if ( rfxtypes.exec( value ) ) {
8369 delete props[ prop ]; delete props[ prop ];
8370 toggle = toggle || value === "toggle"; toggle = toggle || value === "toggle";
8371 if ( value === ( hidden ? "hide" : "show" ) ) { if ( value === ( hidden ? "hide" : "show" ) ) {
8372
8373 // 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 // If there is dataShow left over from a stopped hide or show
8374 // and we are going to proceed with show, we should pretend to be hidden
8375 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
8376 hidden = true; hidden = true;
8377 } else { } else {
8378 continue; continue;
8379 } }
8380 } }
8381 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
8382
8383 // Any non-fx value stops us from restoring the original display value // Any non-fx value stops us from restoring the original display value
8384 } else { } else {
8385 display = undefined; display = undefined;
8386 } }
8387 } }
8388
8389 if ( !jQuery.isEmptyObject( orig ) ) { if ( !jQuery.isEmptyObject( orig ) ) {
8390 if ( dataShow ) { if ( dataShow ) {
8391 if ( "hidden" in dataShow ) { if ( "hidden" in dataShow ) {
8392 hidden = dataShow.hidden; hidden = dataShow.hidden;
8393 } }
8394 } else { } else {
8395 dataShow = jQuery._data( elem, "fxshow", {} ); dataShow = jQuery._data( elem, "fxshow", {} );
8396 } }
8397
8398 // store state if its toggle - enables .stop().toggle() to "reverse" // store state if its toggle - enables .stop().toggle() to "reverse"
8399 if ( toggle ) { if ( toggle ) {
8400 dataShow.hidden = !hidden; dataShow.hidden = !hidden;
8401 } }
8402 if ( hidden ) { if ( hidden ) {
8403 jQuery( elem ).show(); jQuery( elem ).show();
8404 } else { } else {
8405 anim.done(function() { anim.done( function() {
8406 jQuery( elem ).hide(); jQuery( elem ).hide();
8407 }); } );
8408 } }
8409 anim.done(function() { anim.done( function() {
8410 var prop; var prop;
8411 jQuery._removeData( elem, "fxshow" ); jQuery._removeData( elem, "fxshow" );
8412 for ( prop in orig ) { for ( prop in orig ) {
8413 jQuery.style( elem, prop, orig[ prop ] ); jQuery.style( elem, prop, orig[ prop ] );
8414 } }
8415 }); } );
8416 for ( prop in orig ) { for ( prop in orig ) {
8417 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
8418
8419 if ( !( prop in dataShow ) ) { if ( !( prop in dataShow ) ) {
8420 dataShow[ prop ] = tween.start; dataShow[ prop ] = tween.start;
8421 if ( hidden ) { if ( hidden ) {
8422 tween.end = tween.start; tween.end = tween.start;
8423 tween.start = prop === "width" || prop === "height" ? 1 : 0; tween.start = prop === "width" || prop === "height" ? 1 : 0;
8424 } }
8425 } }
8426 } }
8427
8428 // If this is a noop like .hide().hide(), restore an overwritten display value // If this is a noop like .hide().hide(), restore an overwritten display value
8429 } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) { } else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) {
8430 style.display = display; style.display = display;
8431 } }
8432 } }
8433
8434 function propFilter( props, specialEasing ) { function propFilter( props, specialEasing ) {
8435 var index, name, easing, value, hooks; var index, name, easing, value, hooks;
8436
8437 // camelCase, specialEasing and expand cssHook pass // camelCase, specialEasing and expand cssHook pass
8438 for ( index in props ) { for ( index in props ) {
8439 name = jQuery.camelCase( index ); name = jQuery.camelCase( index );
8440 easing = specialEasing[ name ]; easing = specialEasing[ name ];
8441 value = props[ index ]; value = props[ index ];
8442 if ( jQuery.isArray( value ) ) { if ( jQuery.isArray( value ) ) {
8443 easing = value[ 1 ]; easing = value[ 1 ];
8444 value = props[ index ] = value[ 0 ]; value = props[ index ] = value[ 0 ];
8445 } }
8446
8447 if ( index !== name ) { if ( index !== name ) {
8448 props[ name ] = value; props[ name ] = value;
8449 delete props[ index ]; delete props[ index ];
8450 } }
8451
8452 hooks = jQuery.cssHooks[ name ]; hooks = jQuery.cssHooks[ name ];
8453 if ( hooks && "expand" in hooks ) { if ( hooks && "expand" in hooks ) {
8454 value = hooks.expand( value ); value = hooks.expand( value );
8455 delete props[ name ]; delete props[ name ];
8456
8457 // not quite $.extend, this wont overwrite keys already present. // not quite $.extend, this wont overwrite keys already present.
8458 // also - reusing 'index' from above because we have the correct "name" // also - reusing 'index' from above because we have the correct "name"
8459 for ( index in value ) { for ( index in value ) {
8460 if ( !( index in props ) ) { if ( !( index in props ) ) {
8461 props[ index ] = value[ index ]; props[ index ] = value[ index ];
8462 specialEasing[ index ] = easing; specialEasing[ index ] = easing;
8463 } }
8464 } }
8465 } else { } else {
8466 specialEasing[ name ] = easing; specialEasing[ name ] = easing;
8467 } }
8468 } }
8469 } }
8470
8471 function Animation( elem, properties, options ) { function Animation( elem, properties, options ) {
8472 var result, var result,
8473 stopped, stopped,
8474 index = 0, index = 0,
8475 length = animationPrefilters.length, length = Animation.prefilters.length,
8476 deferred = jQuery.Deferred().always( function() { deferred = jQuery.Deferred().always( function() {
8477
8478 // don't match elem in the :animated selector // don't match elem in the :animated selector
8479 delete tick.elem; delete tick.elem;
8480 }), } ),
8481 tick = function() { tick = function() {
8482 if ( stopped ) { if ( stopped ) {
8483 return false; return false;
8484 } }
8485 var currentTime = fxNow || createFxNow(), var currentTime = fxNow || createFxNow(),
8486 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
8487 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
8488 // Support: Android 2.3
8489 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
8490 temp = remaining / animation.duration || 0, temp = remaining / animation.duration || 0,
8491 percent = 1 - temp, percent = 1 - temp,
8492 index = 0, index = 0,
8493 length = animation.tweens.length; length = animation.tweens.length;
8494
8495 for ( ; index < length ; index++ ) { for ( ; index < length ; index++ ) {
8496 animation.tweens[ index ].run( percent ); animation.tweens[ index ].run( percent );
8497 } }
8498
8499 deferred.notifyWith( elem, [ animation, percent, remaining ]); deferred.notifyWith( elem, [ animation, percent, remaining ] );
8500
8501 if ( percent < 1 && length ) { if ( percent < 1 && length ) {
8502 return remaining; return remaining;
8503 } else { } else {
8504 deferred.resolveWith( elem, [ animation ] ); deferred.resolveWith( elem, [ animation ] );
8505 return false; return false;
8506 } }
8507 }, },
8508 animation = deferred.promise({ animation = deferred.promise( {
8509 elem: elem, elem: elem,
8510 props: jQuery.extend( {}, properties ), props: jQuery.extend( {}, properties ),
8511 opts: jQuery.extend( true, { specialEasing: {} }, options ), opts: jQuery.extend( true, {
8512 specialEasing: {},
8513 easing: jQuery.easing._default
8514 }, options ),
8515 originalProperties: properties, originalProperties: properties,
8516 originalOptions: options, originalOptions: options,
8517 startTime: fxNow || createFxNow(), startTime: fxNow || createFxNow(),
8518 duration: options.duration, duration: options.duration,
8519 tweens: [], tweens: [],
8520 createTween: function( prop, end ) { createTween: function( prop, end ) {
8521 var tween = jQuery.Tween( elem, animation.opts, prop, end, var tween = jQuery.Tween( elem, animation.opts, prop, end,
8522 animation.opts.specialEasing[ prop ] || animation.opts.easing ); animation.opts.specialEasing[ prop ] || animation.opts.easing );
8523 animation.tweens.push( tween ); animation.tweens.push( tween );
8524 return tween; return tween;
8525 }, },
8526 stop: function( gotoEnd ) { stop: function( gotoEnd ) {
8527 var index = 0, var index = 0,
8528
8529 // if we are going to the end, we want to run all the tweens // if we are going to the end, we want to run all the tweens
8530 // otherwise we skip this part // otherwise we skip this part
8531 length = gotoEnd ? animation.tweens.length : 0; length = gotoEnd ? animation.tweens.length : 0;
8532 if ( stopped ) { if ( stopped ) {
8533 return this; return this;
8534 } }
8535 stopped = true; stopped = true;
8536 for ( ; index < length ; index++ ) { for ( ; index < length ; index++ ) {
8537 animation.tweens[ index ].run( 1 ); animation.tweens[ index ].run( 1 );
8538 } }
8539
8540 // resolve when we played the last frame // resolve when we played the last frame
8541 // otherwise, reject // otherwise, reject
8542 if ( gotoEnd ) { if ( gotoEnd ) {
8543 deferred.notifyWith( elem, [ animation, 1, 0 ] );
8544 deferred.resolveWith( elem, [ animation, gotoEnd ] ); deferred.resolveWith( elem, [ animation, gotoEnd ] );
8545 } else { } else {
8546 deferred.rejectWith( elem, [ animation, gotoEnd ] ); deferred.rejectWith( elem, [ animation, gotoEnd ] );
8547 } }
8548 return this; return this;
8549 } }
8550 }), } ),
8551 props = animation.props; props = animation.props;
8552
8553 propFilter( props, animation.opts.specialEasing ); propFilter( props, animation.opts.specialEasing );
8554
8555 for ( ; index < length ; index++ ) { for ( ; index < length ; index++ ) {
8556 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
8557 if ( result ) { if ( result ) {
8558 if ( jQuery.isFunction( result.stop ) ) {
8559 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
8560 jQuery.proxy( result.stop, result );
8561 }
8562 return result; return result;
8563 } }
8564 } }
8565
8566 jQuery.map( props, createTween, animation ); jQuery.map( props, createTween, animation );
8567
8568 if ( jQuery.isFunction( animation.opts.start ) ) { if ( jQuery.isFunction( animation.opts.start ) ) {
8569 animation.opts.start.call( elem, animation ); animation.opts.start.call( elem, animation );
8570 } }
8571
8572 jQuery.fx.timer( jQuery.fx.timer(
8573 jQuery.extend( tick, { jQuery.extend( tick, {
8574 elem: elem, elem: elem,
8575 anim: animation, anim: animation,
8576 queue: animation.opts.queue queue: animation.opts.queue
8577 }) } )
8578 ); );
8579
8580 // attach callbacks from options // attach callbacks from options
8581 return animation.progress( animation.opts.progress ) return animation.progress( animation.opts.progress )
8582 .done( animation.opts.done, animation.opts.complete ) .done( animation.opts.done, animation.opts.complete )
8583 .fail( animation.opts.fail ) .fail( animation.opts.fail )
8584 .always( animation.opts.always ); .always( animation.opts.always );
8585 } }
8586
8587 jQuery.Animation = jQuery.extend( Animation, { jQuery.Animation = jQuery.extend( Animation, {
8588
8589 tweeners: {
8590 "*": [ function( prop, value ) {
8591 var tween = this.createTween( prop, value );
8592 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
8593 return tween;
8594 } ]
8595 },
8596
8597 tweener: function( props, callback ) { tweener: function( props, callback ) {
8598 if ( jQuery.isFunction( props ) ) { if ( jQuery.isFunction( props ) ) {
8599 callback = props; callback = props;
8600 props = [ "*" ]; props = [ "*" ];
8601 } else { } else {
8602 props = props.split(" "); props = props.match( rnotwhite );
8603 } }
8604
8605 var prop, var prop,
8606 index = 0, index = 0,
8607 length = props.length; length = props.length;
8608
8609 for ( ; index < length ; index++ ) { for ( ; index < length ; index++ ) {
8610 prop = props[ index ]; prop = props[ index ];
8611 tweeners[ prop ] = tweeners[ prop ] || []; Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
8612 tweeners[ prop ].unshift( callback ); Animation.tweeners[ prop ].unshift( callback );
8613 } }
8614 }, },
8615
8616 prefilters: [ defaultPrefilter ],
8617
8618 prefilter: function( callback, prepend ) { prefilter: function( callback, prepend ) {
8619 if ( prepend ) { if ( prepend ) {
8620 animationPrefilters.unshift( callback ); Animation.prefilters.unshift( callback );
8621 } else { } else {
8622 animationPrefilters.push( callback ); Animation.prefilters.push( callback );
8623 } }
8624 } }
8625 }); } );
8626
8627 jQuery.speed = function( speed, easing, fn ) { jQuery.speed = function( speed, easing, fn ) {
8628 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
8629 complete: fn || !fn && easing || complete: fn || !fn && easing ||
8630 jQuery.isFunction( speed ) && speed, jQuery.isFunction( speed ) && speed,
8631 duration: speed, duration: speed,
8632 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
8633 }; };
8634
8635 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
8636 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; opt.duration in jQuery.fx.speeds ?
8637 jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
8638
8639 // normalize opt.queue - true/undefined/null -> "fx" // normalize opt.queue - true/undefined/null -> "fx"
8640 if ( opt.queue == null || opt.queue === true ) { if ( opt.queue == null || opt.queue === true ) {
8641 opt.queue = "fx"; opt.queue = "fx";
8642 } }
8643
8644 // Queueing // Queueing
8645 opt.old = opt.complete; opt.old = opt.complete;
8646
8647 opt.complete = function() { opt.complete = function() {
8648 if ( jQuery.isFunction( opt.old ) ) { if ( jQuery.isFunction( opt.old ) ) {
8649 opt.old.call( this ); opt.old.call( this );
8650 } }
8651
8652 if ( opt.queue ) { if ( opt.queue ) {
8653 jQuery.dequeue( this, opt.queue ); jQuery.dequeue( this, opt.queue );
8654 } }
8655 }; };
8656
8657 return opt; return opt;
8658 }; };
8659
8660 jQuery.fn.extend({ jQuery.fn.extend( {
8661 fadeTo: function( speed, to, easing, callback ) { fadeTo: function( speed, to, easing, callback ) {
8662
8663 // show any hidden elements after setting opacity to 0 // show any hidden elements after setting opacity to 0
8664 return this.filter( isHidden ).css( "opacity", 0 ).show() return this.filter( isHidden ).css( "opacity", 0 ).show()
8665
8666 // animate to the value specified // animate to the value specified
8667 .end().animate({ opacity: to }, speed, easing, callback ); .end().animate( { opacity: to }, speed, easing, callback );
8668 }, },
8669 animate: function( prop, speed, easing, callback ) { animate: function( prop, speed, easing, callback ) {
8670 var empty = jQuery.isEmptyObject( prop ), var empty = jQuery.isEmptyObject( prop ),
8671 optall = jQuery.speed( speed, easing, callback ), optall = jQuery.speed( speed, easing, callback ),
8672 doAnimation = function() { doAnimation = function() {
8673
8674 // Operate on a copy of prop so per-property easing won't be lost // Operate on a copy of prop so per-property easing won't be lost
8675 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); var anim = Animation( this, jQuery.extend( {}, prop ), optall );
8676
8677 // Empty animations, or finishing resolves immediately // Empty animations, or finishing resolves immediately
8678 if ( empty || jQuery._data( this, "finish" ) ) { if ( empty || jQuery._data( this, "finish" ) ) {
8679 anim.stop( true ); anim.stop( true );
8680 } }
8681 }; };
8682 doAnimation.finish = doAnimation; doAnimation.finish = doAnimation;
8683
8684 return empty || optall.queue === false ? return empty || optall.queue === false ?
8685 this.each( doAnimation ) : this.each( doAnimation ) :
8686 this.queue( optall.queue, doAnimation ); this.queue( optall.queue, doAnimation );
8687 }, },
8688 stop: function( type, clearQueue, gotoEnd ) { stop: function( type, clearQueue, gotoEnd ) {
8689 var stopQueue = function( hooks ) { var stopQueue = function( hooks ) {
8690 var stop = hooks.stop; var stop = hooks.stop;
8691 delete hooks.stop; delete hooks.stop;
8692 stop( gotoEnd ); stop( gotoEnd );
8693 }; };
8694
8695 if ( typeof type !== "string" ) { if ( typeof type !== "string" ) {
8696 gotoEnd = clearQueue; gotoEnd = clearQueue;
8697 clearQueue = type; clearQueue = type;
8698 type = undefined; type = undefined;
8699 } }
8700 if ( clearQueue && type !== false ) { if ( clearQueue && type !== false ) {
8701 this.queue( type || "fx", [] ); this.queue( type || "fx", [] );
8702 } }
8703
8704 return this.each(function() { return this.each( function() {
8705 var dequeue = true, var dequeue = true,
8706 index = type != null && type + "queueHooks", index = type != null && type + "queueHooks",
8707 timers = jQuery.timers, timers = jQuery.timers,
8708 data = jQuery._data( this ); data = jQuery._data( this );
8709
8710 if ( index ) { if ( index ) {
8711 if ( data[ index ] && data[ index ].stop ) { if ( data[ index ] && data[ index ].stop ) {
8712 stopQueue( data[ index ] ); stopQueue( data[ index ] );
8713 } }
8714 } else { } else {
8715 for ( index in data ) { for ( index in data ) {
8716 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
8717 stopQueue( data[ index ] ); stopQueue( data[ index ] );
8718 } }
8719 } }
8720 } }
8721
8722 for ( index = timers.length; index--; ) { for ( index = timers.length; index--; ) {
8723 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { if ( timers[ index ].elem === this &&
8724 ( type == null || timers[ index ].queue === type ) ) {
8725 timers[ index ].anim.stop( gotoEnd ); timers[ index ].anim.stop( gotoEnd );
8726 dequeue = false; dequeue = false;
8727 timers.splice( index, 1 ); timers.splice( index, 1 );
8728 } }
8729 } }
8730
8731 // start the next in the queue if the last step wasn't forced // start the next in the queue if the last step wasn't forced
8732 // timers currently will call their complete callbacks, which will dequeue // timers currently will call their complete callbacks, which will dequeue
8733 // but only if they were gotoEnd // but only if they were gotoEnd
8734 if ( dequeue || !gotoEnd ) { if ( dequeue || !gotoEnd ) {
8735 jQuery.dequeue( this, type ); jQuery.dequeue( this, type );
8736 } }
8737 }); } );
8738 }, },
8739 finish: function( type ) { finish: function( type ) {
8740 if ( type !== false ) { if ( type !== false ) {
8741 type = type || "fx"; type = type || "fx";
8742 } }
8743 return this.each(function() { return this.each( function() {
8744 var index, var index,
8745 data = jQuery._data( this ), data = jQuery._data( this ),
8746 queue = data[ type + "queue" ], queue = data[ type + "queue" ],
8747 hooks = data[ type + "queueHooks" ], hooks = data[ type + "queueHooks" ],
8748 timers = jQuery.timers, timers = jQuery.timers,
8749 length = queue ? queue.length : 0; length = queue ? queue.length : 0;
8750
8751 // enable finishing flag on private data // enable finishing flag on private data
8752 data.finish = true; data.finish = true;
8753
8754 // empty the queue first // empty the queue first
8755 jQuery.queue( this, type, [] ); jQuery.queue( this, type, [] );
8756
8757 if ( hooks && hooks.stop ) { if ( hooks && hooks.stop ) {
8758 hooks.stop.call( this, true ); hooks.stop.call( this, true );
8759 } }
8760
8761 // look for any active animations, and finish them // look for any active animations, and finish them
8762 for ( index = timers.length; index--; ) { for ( index = timers.length; index--; ) {
8763 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
8764 timers[ index ].anim.stop( true ); timers[ index ].anim.stop( true );
8765 timers.splice( index, 1 ); timers.splice( index, 1 );
8766 } }
8767 } }
8768
8769 // look for any animations in the old queue and finish them // look for any animations in the old queue and finish them
8770 for ( index = 0; index < length; index++ ) { for ( index = 0; index < length; index++ ) {
8771 if ( queue[ index ] && queue[ index ].finish ) { if ( queue[ index ] && queue[ index ].finish ) {
8772 queue[ index ].finish.call( this ); queue[ index ].finish.call( this );
8773 } }
8774 } }
8775
8776 // turn off finishing flag // turn off finishing flag
8777 delete data.finish; delete data.finish;
8778 }); } );
8779 } }
8780 }); } );
8781
8782 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
8783 var cssFn = jQuery.fn[ name ]; var cssFn = jQuery.fn[ name ];
8784 jQuery.fn[ name ] = function( speed, easing, callback ) { jQuery.fn[ name ] = function( speed, easing, callback ) {
8785 return speed == null || typeof speed === "boolean" ? return speed == null || typeof speed === "boolean" ?
8786 cssFn.apply( this, arguments ) : cssFn.apply( this, arguments ) :
8787 this.animate( genFx( name, true ), speed, easing, callback ); this.animate( genFx( name, true ), speed, easing, callback );
8788 }; };
8789 }); } );
8790
8791 // Generate shortcuts for custom animations // Generate shortcuts for custom animations
8792 jQuery.each({ jQuery.each( {
8793 slideDown: genFx("show"), slideDown: genFx( "show" ),
8794 slideUp: genFx("hide"), slideUp: genFx( "hide" ),
8795 slideToggle: genFx("toggle"), slideToggle: genFx( "toggle" ),
8796 fadeIn: { opacity: "show" }, fadeIn: { opacity: "show" },
8797 fadeOut: { opacity: "hide" }, fadeOut: { opacity: "hide" },
8798 fadeToggle: { opacity: "toggle" } fadeToggle: { opacity: "toggle" }
8799 }, function( name, props ) { }, function( name, props ) {
8800 jQuery.fn[ name ] = function( speed, easing, callback ) { jQuery.fn[ name ] = function( speed, easing, callback ) {
8801 return this.animate( props, speed, easing, callback ); return this.animate( props, speed, easing, callback );
8802 }; };
8803 }); } );
8804
8805 jQuery.timers = []; jQuery.timers = [];
8806 jQuery.fx.tick = function() { jQuery.fx.tick = function() {
8807 var timer, var timer,
8808 timers = jQuery.timers, timers = jQuery.timers,
8809 i = 0; i = 0;
8810
8811 fxNow = jQuery.now(); fxNow = jQuery.now();
8812
8813 for ( ; i < timers.length; i++ ) { for ( ; i < timers.length; i++ ) {
8814 timer = timers[ i ]; timer = timers[ i ];
8815
8816 // Checks the timer has not already been removed // Checks the timer has not already been removed
8817 if ( !timer() && timers[ i ] === timer ) { if ( !timer() && timers[ i ] === timer ) {
8818 timers.splice( i--, 1 ); timers.splice( i--, 1 );
8819 } }
8820 } }
8821
8822 if ( !timers.length ) { if ( !timers.length ) {
8823 jQuery.fx.stop(); jQuery.fx.stop();
8824 } }
8825 fxNow = undefined; fxNow = undefined;
8826 }; };
8827
8828 jQuery.fx.timer = function( timer ) { jQuery.fx.timer = function( timer ) {
8829 jQuery.timers.push( timer ); jQuery.timers.push( timer );
8830 if ( timer() ) { if ( timer() ) {
8831 jQuery.fx.start(); jQuery.fx.start();
8832 } else { } else {
8833 jQuery.timers.pop(); jQuery.timers.pop();
8834 } }
8835 }; };
8836
8837 jQuery.fx.interval = 13; jQuery.fx.interval = 13;
8838
8839 jQuery.fx.start = function() { jQuery.fx.start = function() {
8840 if ( !timerId ) { if ( !timerId ) {
8841 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
8842 } }
8843 }; };
8844
8845 jQuery.fx.stop = function() { jQuery.fx.stop = function() {
8846 clearInterval( timerId ); window.clearInterval( timerId );
8847 timerId = null; timerId = null;
8848 }; };
8849
8850 jQuery.fx.speeds = { jQuery.fx.speeds = {
8851 slow: 600, slow: 600,
8852 fast: 200, fast: 200,
8853
8854 // Default speed // Default speed
8855 _default: 400 _default: 400
8856 }; };
8857
8858
8859 // Based off of the plugin by Clint Helfers, with permission. // Based off of the plugin by Clint Helfers, with permission.
8860 // http://blindsignals.com/index.php/2009/07/jquery-delay/ // http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
8861 jQuery.fn.delay = function( time, type ) { jQuery.fn.delay = function( time, type ) {
8862 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
8863 type = type || "fx"; type = type || "fx";
8864
8865 return this.queue( type, function( next, hooks ) { return this.queue( type, function( next, hooks ) {
8866 var timeout = setTimeout( next, time ); var timeout = window.setTimeout( next, time );
8867 hooks.stop = function() { hooks.stop = function() {
8868 clearTimeout( timeout ); window.clearTimeout( timeout );
8869 }; };
8870 }); } );
8871 }; };
8872
8873
8874 (function() { ( function() {
8875 // Minified: var a,b,c,d,e var a,
8876 var input, div, select, a, opt; input = document.createElement( "input" ),
8877 div = document.createElement( "div" ),
8878 select = document.createElement( "select" ),
8879 opt = select.appendChild( document.createElement( "option" ) );
8880
8881 // Setup // Setup
8882 div = document.createElement( "div" ); div = document.createElement( "div" );
8883 div.setAttribute( "className", "t" ); div.setAttribute( "className", "t" );
8884 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
8885 a = div.getElementsByTagName("a")[ 0 ]; a = div.getElementsByTagName( "a" )[ 0 ];
8886
8887 // First batch of tests. // Support: Windows Web Apps (WWA)
8888 select = document.createElement("select"); // `type` must use .setAttribute for WWA (#14901)
8889 opt = select.appendChild( document.createElement("option") ); input.setAttribute( "type", "checkbox" );
8890 input = div.getElementsByTagName("input")[ 0 ]; div.appendChild( input );
8891
8892 a = div.getElementsByTagName( "a" )[ 0 ];
8893
8894 // First batch of tests.
8895 a.style.cssText = "top:1px"; a.style.cssText = "top:1px";
8896
8897 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) // Test setAttribute on camelCase class.
8898 // If it works, we need attrFixes when doing get/setAttribute (ie6/7)
8899 support.getSetAttribute = div.className !== "t"; support.getSetAttribute = div.className !== "t";
8900
8901 // Get the style information from getAttribute // Get the style information from getAttribute
8902 // (IE uses .cssText instead) // (IE uses .cssText instead)
8903 support.style = /top/.test( a.getAttribute("style") ); support.style = /top/.test( a.getAttribute( "style" ) );
8904
8905 // Make sure that URLs aren't manipulated // Make sure that URLs aren't manipulated
8906 // (IE normalizes it by default) // (IE normalizes it by default)
8907 support.hrefNormalized = a.getAttribute("href") === "/a"; support.hrefNormalized = a.getAttribute( "href" ) === "/a";
8908
8909 // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere) // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
8910 support.checkOn = !!input.value; support.checkOn = !!input.value;
8911
8912 // Make sure that a selected-by-default option has a working selected property. // Make sure that a selected-by-default option has a working selected property.
8913 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
8914 support.optSelected = opt.selected; support.optSelected = opt.selected;
8915
8916 // Tests for enctype support on a form (#6743) // Tests for enctype support on a form (#6743)
8917 support.enctype = !!document.createElement("form").enctype; support.enctype = !!document.createElement( "form" ).enctype;
8918
8919 // Make sure that the options inside disabled selects aren't marked as disabled // Make sure that the options inside disabled selects aren't marked as disabled
8920 // (WebKit marks them as disabled) // (WebKit marks them as disabled)
8921 select.disabled = true; select.disabled = true;
8922 support.optDisabled = !opt.disabled; support.optDisabled = !opt.disabled;
8923
8924 // Support: IE8 only // Support: IE8 only
8925 // Check if we can trust getAttribute("value") // Check if we can trust getAttribute("value")
8926 input = document.createElement( "input" ); input = document.createElement( "input" );
8927 input.setAttribute( "value", "" ); input.setAttribute( "value", "" );
8928 support.input = input.getAttribute( "value" ) === ""; support.input = input.getAttribute( "value" ) === "";
8929
8930 // Check if an input maintains its value after becoming a radio // Check if an input maintains its value after becoming a radio
8931 input.value = "t"; input.value = "t";
8932 input.setAttribute( "type", "radio" ); input.setAttribute( "type", "radio" );
8933 support.radioValue = input.value === "t"; support.radioValue = input.value === "t";
8934 })(); } )();
8935
8936
8937 var rreturn = /\r/g; var rreturn = /\r/g,
8938 rspaces = /[\x20\t\r\n\f]+/g;
8939
8940 jQuery.fn.extend({ jQuery.fn.extend( {
8941 val: function( value ) { val: function( value ) {
8942 var hooks, ret, isFunction, var hooks, ret, isFunction,
8943 elem = this[0]; elem = this[ 0 ];
8944
8945 if ( !arguments.length ) { if ( !arguments.length ) {
8946 if ( elem ) { if ( elem ) {
8947 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; hooks = jQuery.valHooks[ elem.type ] ||
8948 jQuery.valHooks[ elem.nodeName.toLowerCase() ];
8949
8950 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { if (
8951 hooks &&
8952 "get" in hooks &&
8953 ( ret = hooks.get( elem, "value" ) ) !== undefined
8954 ) {
8955 return ret; return ret;
8956 } }
8957
8958 ret = elem.value; ret = elem.value;
8959
8960 return typeof ret === "string" ? return typeof ret === "string" ?
8961
8962 // handle most common string cases // handle most common string cases
8963 ret.replace(rreturn, "") : ret.replace( rreturn, "" ) :
8964 // handle cases where value is null/undef or number // handle cases where value is null/undef or number
8965 ret == null ? "" : ret; ret == null ? "" : ret;
8966 } }
8967
8968 return; return;
8969 } }
8970
8971 isFunction = jQuery.isFunction( value ); isFunction = jQuery.isFunction( value );
8972
8973 return this.each(function( i ) { return this.each( function( i ) {
8974 var val; var val;
8975
8976 if ( this.nodeType !== 1 ) { if ( this.nodeType !== 1 ) {
8977 return; return;
8978 } }
8979
8980 if ( isFunction ) { if ( isFunction ) {
8981 val = value.call( this, i, jQuery( this ).val() ); val = value.call( this, i, jQuery( this ).val() );
8982 } else { } else {
8983 val = value; val = value;
8984 } }
8985
8986 // Treat null/undefined as ""; convert numbers to string // Treat null/undefined as ""; convert numbers to string
8987 if ( val == null ) { if ( val == null ) {
8988 val = ""; val = "";
8989 } else if ( typeof val === "number" ) { } else if ( typeof val === "number" ) {
8990 val += ""; val += "";
8991 } else if ( jQuery.isArray( val ) ) { } else if ( jQuery.isArray( val ) ) {
8992 val = jQuery.map( val, function( value ) { val = jQuery.map( val, function( value ) {
8993 return value == null ? "" : value + ""; return value == null ? "" : value + "";
8994 }); } );
8995 } }
8996
8997 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
8998
8999 // If set returns undefined, fall back to normal setting // If set returns undefined, fall back to normal setting
9000 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
9001 this.value = val; this.value = val;
9002 } }
9003 }); } );
9004 } }
9005 }); } );
9006
9007 jQuery.extend({ jQuery.extend( {
9008 valHooks: { valHooks: {
9009 option: { option: {
9010 get: function( elem ) { get: function( elem ) {
9011 var val = jQuery.find.attr( elem, "value" ); var val = jQuery.find.attr( elem, "value" );
9012 return val != null ? return val != null ?
9013 val : val :
9014
9015 // Support: IE10-11+ // Support: IE10-11+
9016 // option.text throws exceptions (#14686, #14858) // option.text throws exceptions (#14686, #14858)
9017 jQuery.trim( jQuery.text( elem ) ); // Strip and collapse whitespace
9018 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
9019 jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " );
9020 } }
9021 }, },
9022 select: { select: {
9023 get: function( elem ) { get: function( elem ) {
9024 var value, option, var value, option,
9025 options = elem.options, options = elem.options,
9026 index = elem.selectedIndex, index = elem.selectedIndex,
9027 one = elem.type === "select-one" || index < 0, one = elem.type === "select-one" || index < 0,
9028 values = one ? null : [], values = one ? null : [],
9029 max = one ? index + 1 : options.length, max = one ? index + 1 : options.length,
9030 i = index < 0 ? i = index < 0 ?
9031 max : max :
9032 one ? index : 0; one ? index : 0;
9033
9034 // Loop through all the selected options // Loop through all the selected options
9035 for ( ; i < max; i++ ) { for ( ; i < max; i++ ) {
9036 option = options[ i ]; option = options[ i ];
9037
9038 // oldIE doesn't update selected after form reset (#2551) // oldIE doesn't update selected after form reset (#2551)
9039 if ( ( option.selected || i === index ) && if ( ( option.selected || i === index ) &&
9040
9041 // Don't return options that are disabled or in a disabled optgroup // Don't return options that are disabled or in a disabled optgroup
9042 ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) && ( support.optDisabled ?
9043 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { !option.disabled :
9044 option.getAttribute( "disabled" ) === null ) &&
9045 ( !option.parentNode.disabled ||
9046 !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
9047
9048 // Get the specific value for the option // Get the specific value for the option
9049 value = jQuery( option ).val(); value = jQuery( option ).val();
9050
9051 // We don't need an array for one selects // We don't need an array for one selects
9052 if ( one ) { if ( one ) {
9053 return value; return value;
9054 } }
9055
9056 // Multi-Selects return an array // Multi-Selects return an array
9057 values.push( value ); values.push( value );
9058 } }
9059 } }
9060
9061 return values; return values;
9062 }, },
9063
9064 set: function( elem, value ) { set: function( elem, value ) {
9065 var optionSet, option, var optionSet, option,
9066 options = elem.options, options = elem.options,
9067 values = jQuery.makeArray( value ), values = jQuery.makeArray( value ),
9068 i = options.length; i = options.length;
9069
9070 while ( i-- ) { while ( i-- ) {
9071 option = options[ i ]; option = options[ i ];
9072
9073 if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) { if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 ) {
9074
9075 // Support: IE6 // Support: IE6
9076 // When new option element is added to select box we need to // When new option element is added to select box we need to
9077 // force reflow of newly added node in order to workaround delay // force reflow of newly added node in order to workaround delay
9078 // of initialization properties // of initialization properties
9079 try { try {
9080 option.selected = optionSet = true; option.selected = optionSet = true;
9081
9082 } catch ( _ ) { } catch ( _ ) {
9083
9084 // Will be executed only in IE6 // Will be executed only in IE6
9085 option.scrollHeight; option.scrollHeight;
9086 } }
9087
9088 } else { } else {
9089 option.selected = false; option.selected = false;
9090 } }
9091 } }
9092
9093 // Force browsers to behave consistently when non-matching value is set // Force browsers to behave consistently when non-matching value is set
9094 if ( !optionSet ) { if ( !optionSet ) {
9095 elem.selectedIndex = -1; elem.selectedIndex = -1;
9096 } }
9097
9098 return options; return options;
9099 } }
9100 } }
9101 } }
9102 }); } );
9103
9104 // Radios and checkboxes getter/setter // Radios and checkboxes getter/setter
9105 jQuery.each([ "radio", "checkbox" ], function() { jQuery.each( [ "radio", "checkbox" ], function() {
9106 jQuery.valHooks[ this ] = { jQuery.valHooks[ this ] = {
9107 set: function( elem, value ) { set: function( elem, value ) {
9108 if ( jQuery.isArray( value ) ) { if ( jQuery.isArray( value ) ) {
9109 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
9110 } }
9111 } }
9112 }; };
9113 if ( !support.checkOn ) { if ( !support.checkOn ) {
9114 jQuery.valHooks[ this ].get = function( elem ) { jQuery.valHooks[ this ].get = function( elem ) {
9115 // Support: Webkit return elem.getAttribute( "value" ) === null ? "on" : elem.value;
9116 // "" is returned instead of "on" if a value isn't specified
9117 return elem.getAttribute("value") === null ? "on" : elem.value;
9118 }; };
9119 } }
9120 }); } );
9121
9122
9123
9124
9125 var nodeHook, boolHook, var nodeHook, boolHook,
9126 attrHandle = jQuery.expr.attrHandle, attrHandle = jQuery.expr.attrHandle,
9127 ruseDefault = /^(?:checked|selected)$/i, ruseDefault = /^(?:checked|selected)$/i,
9128 getSetAttribute = support.getSetAttribute, getSetAttribute = support.getSetAttribute,
9129 getSetInput = support.input; getSetInput = support.input;
9130
9131 jQuery.fn.extend({ jQuery.fn.extend( {
9132 attr: function( name, value ) { attr: function( name, value ) {
9133 return access( this, jQuery.attr, name, value, arguments.length > 1 ); return access( this, jQuery.attr, name, value, arguments.length > 1 );
9134 }, },
9135
9136 removeAttr: function( name ) { removeAttr: function( name ) {
9137 return this.each(function() { return this.each( function() {
9138 jQuery.removeAttr( this, name ); jQuery.removeAttr( this, name );
9139 }); } );
9140 } }
9141 }); } );
9142
9143 jQuery.extend({ jQuery.extend( {
9144 attr: function( elem, name, value ) { attr: function( elem, name, value ) {
9145 var hooks, ret, var ret, hooks,
9146 nType = elem.nodeType; nType = elem.nodeType;
9147
9148 // don't get/set attributes on text, comment and attribute nodes // Don't get/set attributes on text, comment and attribute nodes
9149 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( nType === 3 || nType === 8 || nType === 2 ) {
9150 return; return;
9151 } }
9152
9153 // Fallback to prop when attributes are not supported // Fallback to prop when attributes are not supported
9154 if ( typeof elem.getAttribute === strundefined ) { if ( typeof elem.getAttribute === "undefined" ) {
9155 return jQuery.prop( elem, name, value ); return jQuery.prop( elem, name, value );
9156 } }
9157
9158 // All attributes are lowercase // All attributes are lowercase
9159 // Grab necessary hook if one is defined // Grab necessary hook if one is defined
9160 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
9161 name = name.toLowerCase(); name = name.toLowerCase();
9162 hooks = jQuery.attrHooks[ name ] || hooks = jQuery.attrHooks[ name ] ||
9163 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook ); ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
9164 } }
9165
9166 if ( value !== undefined ) { if ( value !== undefined ) {
9167
9168 if ( value === null ) { if ( value === null ) {
9169 jQuery.removeAttr( elem, name ); jQuery.removeAttr( elem, name );
9170 return;
9171 }
9172
9173 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { if ( hooks && "set" in hooks &&
9174 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
9175 return ret; return ret;
9176
9177 } else {
9178 elem.setAttribute( name, value + "" );
9179 return value;
9180 } }
9181
9182 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { elem.setAttribute( name, value + "" );
9183 return value;
9184 }
9185
9186 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
9187 return ret; return ret;
9188 }
9189
9190 } else { ret = jQuery.find.attr( elem, name );
9191 ret = jQuery.find.attr( elem, name );
9192
9193 // Non-existent attributes return null, we normalize to undefined // Non-existent attributes return null, we normalize to undefined
9194 return ret == null ? return ret == null ? undefined : ret;
9195 undefined : },
9196 ret;
9197 attrHooks: {
9198 type: {
9199 set: function( elem, value ) {
9200 if ( !support.radioValue && value === "radio" &&
9201 jQuery.nodeName( elem, "input" ) ) {
9202
9203 // Setting the type on a radio button after the value resets the value in IE8-9
9204 // Reset value to default in case type is set after value during creation
9205 var val = elem.value;
9206 elem.setAttribute( "type", value );
9207 if ( val ) {
9208 elem.value = val;
9209 }
9210 return value;
9211 }
9212 }
9213 } }
9214 }, },
9215
9216 removeAttr: function( elem, value ) { removeAttr: function( elem, value ) {
9217 var name, propName, var name, propName,
9218 i = 0, i = 0,
9219 attrNames = value && value.match( rnotwhite ); attrNames = value && value.match( rnotwhite );
9220
9221 if ( attrNames && elem.nodeType === 1 ) { if ( attrNames && elem.nodeType === 1 ) {
9222 while ( (name = attrNames[i++]) ) { while ( ( name = attrNames[ i++ ] ) ) {
9223 propName = jQuery.propFix[ name ] || name; propName = jQuery.propFix[ name ] || name;
9224
9225 // Boolean attributes get special treatment (#10870) // Boolean attributes get special treatment (#10870)
9226 if ( jQuery.expr.match.bool.test( name ) ) { if ( jQuery.expr.match.bool.test( name ) ) {
9227
9228 // Set corresponding property to false // Set corresponding property to false
9229 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
9230 elem[ propName ] = false; elem[ propName ] = false;
9231
9232 // Support: IE<9 // Support: IE<9
9233 // Also clear defaultChecked/defaultSelected (if appropriate) // Also clear defaultChecked/defaultSelected (if appropriate)
9234 } else { } else {
9235 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ jQuery.camelCase( "default-" + name ) ] =
9236 elem[ propName ] = false; elem[ propName ] = false;
9237 } }
9238
9239 // See #9699 for explanation of this approach (setting first, then removal) // See #9699 for explanation of this approach (setting first, then removal)
9240 } else { } else {
9241 jQuery.attr( elem, name, "" ); jQuery.attr( elem, name, "" );
9242 } }
9243
9244 elem.removeAttribute( getSetAttribute ? name : propName ); elem.removeAttribute( getSetAttribute ? name : propName );
9245 } }
9246 } }
9247 },
9248
9249 attrHooks: {
9250 type: {
9251 set: function( elem, value ) {
9252 if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
9253 // Setting the type on a radio button after the value resets the value in IE6-9
9254 // Reset value to default in case type is set after value during creation
9255 var val = elem.value;
9256 elem.setAttribute( "type", value );
9257 if ( val ) {
9258 elem.value = val;
9259 }
9260 return value;
9261 }
9262 }
9263 }
9264 } }
9265 }); } );
9266
9267 // Hook for boolean attributes // Hooks for boolean attributes
9268 boolHook = { boolHook = {
9269 set: function( elem, value, name ) { set: function( elem, value, name ) {
9270 if ( value === false ) { if ( value === false ) {
9271
9272 // Remove boolean attributes when set to false // Remove boolean attributes when set to false
9273 jQuery.removeAttr( elem, name ); jQuery.removeAttr( elem, name );
9274 } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
9275
9276 // IE<8 needs the *property* name // IE<8 needs the *property* name
9277 elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name ); elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
9278
9279 // Use defaultChecked and defaultSelected for oldIE
9280 } else { } else {
9281
9282 // Support: IE<9
9283 // Use defaultChecked and defaultSelected for oldIE
9284 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true; elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
9285 } }
9286
9287 return name; return name;
9288 } }
9289 }; };
9290
9291 // Retrieve booleans specially
9292 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
9293
9294 var getter = attrHandle[ name ] || jQuery.find.attr; var getter = attrHandle[ name ] || jQuery.find.attr;
9295
9296 attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ? if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
9297 function( elem, name, isXML ) { attrHandle[ name ] = function( elem, name, isXML ) {
9298 var ret, handle; var ret, handle;
9299 if ( !isXML ) { if ( !isXML ) {
9300
9301 // Avoid an infinite loop by temporarily removing this function from the getter // Avoid an infinite loop by temporarily removing this function from the getter
9302 handle = attrHandle[ name ]; handle = attrHandle[ name ];
9303 attrHandle[ name ] = ret; attrHandle[ name ] = ret;
9304 ret = getter( elem, name, isXML ) != null ? ret = getter( elem, name, isXML ) != null ?
9305 name.toLowerCase() : name.toLowerCase() :
9306 null; null;
9307 attrHandle[ name ] = handle; attrHandle[ name ] = handle;
9308 } }
9309 return ret; return ret;
9310 } : };
9311 function( elem, name, isXML ) { } else {
9312 attrHandle[ name ] = function( elem, name, isXML ) {
9313 if ( !isXML ) { if ( !isXML ) {
9314 return elem[ jQuery.camelCase( "default-" + name ) ] ? return elem[ jQuery.camelCase( "default-" + name ) ] ?
9315 name.toLowerCase() : name.toLowerCase() :
9316 null; null;
9317 } }
9318 }; };
9319 }); }
9320 } );
9321
9322 // fix oldIE attroperties // fix oldIE attroperties
9323 if ( !getSetInput || !getSetAttribute ) { if ( !getSetInput || !getSetAttribute ) {
9324 jQuery.attrHooks.value = { jQuery.attrHooks.value = {
9325 set: function( elem, value, name ) { set: function( elem, value, name ) {
9326 if ( jQuery.nodeName( elem, "input" ) ) { if ( jQuery.nodeName( elem, "input" ) ) {
9327
9328 // Does not return so that setAttribute is also used // Does not return so that setAttribute is also used
9329 elem.defaultValue = value; elem.defaultValue = value;
9330 } else { } else {
9331
9332 // Use nodeHook if defined (#1954); otherwise setAttribute is fine // Use nodeHook if defined (#1954); otherwise setAttribute is fine
9333 return nodeHook && nodeHook.set( elem, value, name ); return nodeHook && nodeHook.set( elem, value, name );
9334 } }
9335 } }
9336 }; };
9337 } }
9338
9339 // IE6/7 do not support getting/setting some attributes with get/setAttribute // IE6/7 do not support getting/setting some attributes with get/setAttribute
9340 if ( !getSetAttribute ) { if ( !getSetAttribute ) {
9341
9342 // Use this for any attribute in IE6/7 // Use this for any attribute in IE6/7
9343 // This fixes almost every IE6/7 issue // This fixes almost every IE6/7 issue
9344 nodeHook = { nodeHook = {
9345 set: function( elem, value, name ) { set: function( elem, value, name ) {
9346
9347 // Set the existing or create a new attribute node // Set the existing or create a new attribute node
9348 var ret = elem.getAttributeNode( name ); var ret = elem.getAttributeNode( name );
9349 if ( !ret ) { if ( !ret ) {
9350 elem.setAttributeNode( elem.setAttributeNode(
9351 (ret = elem.ownerDocument.createAttribute( name )) ( ret = elem.ownerDocument.createAttribute( name ) )
9352 ); );
9353 } }
9354
9355 ret.value = value += ""; ret.value = value += "";
9356
9357 // Break association with cloned elements by also using setAttribute (#9646) // Break association with cloned elements by also using setAttribute (#9646)
9358 if ( name === "value" || value === elem.getAttribute( name ) ) { if ( name === "value" || value === elem.getAttribute( name ) ) {
9359 return value; return value;
9360 } }
9361 } }
9362 }; };
9363
9364 // Some attributes are constructed with empty-string values when not defined // Some attributes are constructed with empty-string values when not defined
9365 attrHandle.id = attrHandle.name = attrHandle.coords = attrHandle.id = attrHandle.name = attrHandle.coords =
9366 function( elem, name, isXML ) { function( elem, name, isXML ) {
9367 var ret; var ret;
9368 if ( !isXML ) { if ( !isXML ) {
9369 return (ret = elem.getAttributeNode( name )) && ret.value !== "" ? return ( ret = elem.getAttributeNode( name ) ) && ret.value !== "" ?
9370 ret.value : ret.value :
9371 null; null;
9372 } }
9373 }; };
9374
9375 // Fixing value retrieval on a button requires this module // Fixing value retrieval on a button requires this module
9376 jQuery.valHooks.button = { jQuery.valHooks.button = {
9377 get: function( elem, name ) { get: function( elem, name ) {
9378 var ret = elem.getAttributeNode( name ); var ret = elem.getAttributeNode( name );
9379 if ( ret && ret.specified ) { if ( ret && ret.specified ) {
9380 return ret.value; return ret.value;
9381 } }
9382 }, },
9383 set: nodeHook.set set: nodeHook.set
9384 }; };
9385
9386 // Set contenteditable to false on removals(#10429) // Set contenteditable to false on removals(#10429)
9387 // Setting to empty string throws an error as an invalid value // Setting to empty string throws an error as an invalid value
9388 jQuery.attrHooks.contenteditable = { jQuery.attrHooks.contenteditable = {
9389 set: function( elem, value, name ) { set: function( elem, value, name ) {
9390 nodeHook.set( elem, value === "" ? false : value, name ); nodeHook.set( elem, value === "" ? false : value, name );
9391 } }
9392 }; };
9393
9394 // Set width and height to auto instead of 0 on empty string( Bug #8150 ) // Set width and height to auto instead of 0 on empty string( Bug #8150 )
9395 // This is for removals // This is for removals
9396 jQuery.each([ "width", "height" ], function( i, name ) { jQuery.each( [ "width", "height" ], function( i, name ) {
9397 jQuery.attrHooks[ name ] = { jQuery.attrHooks[ name ] = {
9398 set: function( elem, value ) { set: function( elem, value ) {
9399 if ( value === "" ) { if ( value === "" ) {
9400 elem.setAttribute( name, "auto" ); elem.setAttribute( name, "auto" );
9401 return value; return value;
9402 } }
9403 } }
9404 }; };
9405 }); } );
9406 } }
9407
9408 if ( !support.style ) { if ( !support.style ) {
9409 jQuery.attrHooks.style = { jQuery.attrHooks.style = {
9410 get: function( elem ) { get: function( elem ) {
9411
9412 // Return undefined in the case of empty string // Return undefined in the case of empty string
9413 // Note: IE uppercases css property names, but if we were to .toLowerCase() // Note: IE uppercases css property names, but if we were to .toLowerCase()
9414 // .cssText, that would destroy case senstitivity in URL's, like in "background" // .cssText, that would destroy case sensitivity in URL's, like in "background"
9415 return elem.style.cssText || undefined; return elem.style.cssText || undefined;
9416 }, },
9417 set: function( elem, value ) { set: function( elem, value ) {
9418 return ( elem.style.cssText = value + "" ); return ( elem.style.cssText = value + "" );
9419 } }
9420 }; };
9421 } }
9422
9423
9424
9425
9426 var rfocusable = /^(?:input|select|textarea|button|object)$/i, var rfocusable = /^(?:input|select|textarea|button|object)$/i,
9427 rclickable = /^(?:a|area)$/i; rclickable = /^(?:a|area)$/i;
9428
9429 jQuery.fn.extend({ jQuery.fn.extend( {
9430 prop: function( name, value ) { prop: function( name, value ) {
9431 return access( this, jQuery.prop, name, value, arguments.length > 1 ); return access( this, jQuery.prop, name, value, arguments.length > 1 );
9432 }, },
9433
9434 removeProp: function( name ) { removeProp: function( name ) {
9435 name = jQuery.propFix[ name ] || name; name = jQuery.propFix[ name ] || name;
9436 return this.each(function() { return this.each( function() {
9437 // try/catch handles cases where IE balks (such as removing a property on window) // try/catch handles cases where IE balks (such as removing a property on window)
9438 try { try {
9439 this[ name ] = undefined; this[ name ] = undefined;
9440 delete this[ name ]; delete this[ name ];
9441 } catch( e ) {} } catch ( e ) {}
9442 }); } );
9443 } }
9444 }); } );
9445
9446 jQuery.extend({ jQuery.extend( {
9447 propFix: {
9448 "for": "htmlFor",
9449 "class": "className"
9450 },
9451 prop: function( elem, name, value ) { prop: function( elem, name, value ) {
9452 var ret, hooks, notxml, var ret, hooks,
9453 nType = elem.nodeType; nType = elem.nodeType;
9454
9455 // don't get/set properties on text, comment and attribute nodes // Don't get/set properties on text, comment and attribute nodes
9456 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( nType === 3 || nType === 8 || nType === 2 ) {
9457 return; return;
9458 } }
9459
9460 notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
9461
9462 if ( notxml ) {
9463 // Fix name and attach hooks // Fix name and attach hooks
9464 name = jQuery.propFix[ name ] || name; name = jQuery.propFix[ name ] || name;
9465 hooks = jQuery.propHooks[ name ]; hooks = jQuery.propHooks[ name ];
9466 } }
9467
9468 if ( value !== undefined ) { if ( value !== undefined ) {
9469 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? if ( hooks && "set" in hooks &&
9470 ret : ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
9471 ( elem[ name ] = value ); return ret;
9472 }
9473
9474 } else { return ( elem[ name ] = value );
9475 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
9476 ret :
9477 elem[ name ];
9478 } }
9479
9480 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
9481 return ret;
9482 }
9483
9484 return elem[ name ];
9485 }, },
9486
9487 propHooks: { propHooks: {
9488 tabIndex: { tabIndex: {
9489 get: function( elem ) { get: function( elem ) {
9490 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
9491 // elem.tabIndex doesn't always return the
9492 // correct value when it hasn't been explicitly set
9493 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
9494 // Use proper attribute retrieval(#12072) // Use proper attribute retrieval(#12072)
9495 var tabindex = jQuery.find.attr( elem, "tabindex" ); var tabindex = jQuery.find.attr( elem, "tabindex" );
9496
9497 return tabindex ? return tabindex ?
9498 parseInt( tabindex, 10 ) : parseInt( tabindex, 10 ) :
9499 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? rfocusable.test( elem.nodeName ) ||
9500 0 : rclickable.test( elem.nodeName ) && elem.href ?
9501 -1; 0 :
9502 -1;
9503 } }
9504 } }
9505 },
9506
9507 propFix: {
9508 "for": "htmlFor",
9509 "class": "className"
9510 } }
9511 }); } );
9512
9513 // Some attributes require a special call on IE // Some attributes require a special call on IE
9514 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
9515 if ( !support.hrefNormalized ) { if ( !support.hrefNormalized ) {
9516
9517 // href/src property should get the full normalized URL (#10299/#12915) // href/src property should get the full normalized URL (#10299/#12915)
9518 jQuery.each([ "href", "src" ], function( i, name ) { jQuery.each( [ "href", "src" ], function( i, name ) {
9519 jQuery.propHooks[ name ] = { jQuery.propHooks[ name ] = {
9520 get: function( elem ) { get: function( elem ) {
9521 return elem.getAttribute( name, 4 ); return elem.getAttribute( name, 4 );
9522 } }
9523 }; };
9524 }); } );
9525 } }
9526
9527 // Support: Safari, IE9+ // Support: Safari, IE9+
9528 // mis-reports the default selected property of an option // Accessing the selectedIndex property
9529 // Accessing the parent's selectedIndex property fixes it // forces the browser to respect setting selected
9530 // on the option
9531 // The getter ensures a default option is selected
9532 // when in an optgroup
9533 if ( !support.optSelected ) { if ( !support.optSelected ) {
9534 jQuery.propHooks.selected = { jQuery.propHooks.selected = {
9535 get: function( elem ) { get: function( elem ) {
9536 var parent = elem.parentNode; var parent = elem.parentNode;
9537
9538 if ( parent ) { if ( parent ) {
9539 parent.selectedIndex; parent.selectedIndex;
9540
9541 // Make sure that it also works with optgroups, see #5701 // Make sure that it also works with optgroups, see #5701
9542 if ( parent.parentNode ) { if ( parent.parentNode ) {
9543 parent.parentNode.selectedIndex; parent.parentNode.selectedIndex;
9544 } }
9545 } }
9546 return null; return null;
9547 },
9548 set: function( elem ) {
9549 var parent = elem.parentNode;
9550 if ( parent ) {
9551 parent.selectedIndex;
9552
9553 if ( parent.parentNode ) {
9554 parent.parentNode.selectedIndex;
9555 }
9556 }
9557 } }
9558 }; };
9559 } }
9560
9561 jQuery.each([ jQuery.each( [
9562 "tabIndex", "tabIndex",
9563 "readOnly", "readOnly",
9564 "maxLength", "maxLength",
9565 "cellSpacing", "cellSpacing",
9566 "cellPadding", "cellPadding",
9567 "rowSpan", "rowSpan",
9568 "colSpan", "colSpan",
9569 "useMap", "useMap",
9570 "frameBorder", "frameBorder",
9571 "contentEditable" "contentEditable"
9572 ], function() { ], function() {
9573 jQuery.propFix[ this.toLowerCase() ] = this; jQuery.propFix[ this.toLowerCase() ] = this;
9574 }); } );
9575
9576 // IE6/7 call enctype encoding // IE6/7 call enctype encoding
9577 if ( !support.enctype ) { if ( !support.enctype ) {
9578 jQuery.propFix.enctype = "encoding"; jQuery.propFix.enctype = "encoding";
9579 } }
9580
9581
9582
9583
9584 var rclass = /[\t\r\n\f]/g; var rclass = /[\t\r\n\f]/g;
9585
9586 jQuery.fn.extend({ function getClass( elem ) {
9587 return jQuery.attr( elem, "class" ) || "";
9588 }
9589
9590 jQuery.fn.extend( {
9591 addClass: function( value ) { addClass: function( value ) {
9592 var classes, elem, cur, clazz, j, finalValue, var classes, elem, cur, curValue, clazz, j, finalValue,
9593 i = 0, i = 0;
9594 len = this.length,
9595 proceed = typeof value === "string" && value;
9596
9597 if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
9598 return this.each(function( j ) { return this.each( function( j ) {
9599 jQuery( this ).addClass( value.call( this, j, this.className ) ); jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
9600 }); } );
9601 } }
9602
9603 if ( proceed ) { if ( typeof value === "string" && value ) {
9604 // The disjunction here is for better compressibility (see removeClass) classes = value.match( rnotwhite ) || [];
9605 classes = ( value || "" ).match( rnotwhite ) || [];
9606
9607 for ( ; i < len; i++ ) { while ( ( elem = this[ i++ ] ) ) {
9608 elem = this[ i ]; curValue = getClass( elem );
9609 cur = elem.nodeType === 1 && ( elem.className ? cur = elem.nodeType === 1 &&
9610 ( " " + elem.className + " " ).replace( rclass, " " ) : ( " " + curValue + " " ).replace( rclass, " " );
9611 " "
9612 );
9613
9614 if ( cur ) { if ( cur ) {
9615 j = 0; j = 0;
9616 while ( (clazz = classes[j++]) ) { while ( ( clazz = classes[ j++ ] ) ) {
9617 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
9618 cur += clazz + " "; cur += clazz + " ";
9619 } }
9620 } }
9621
9622 // only assign if different to avoid unneeded rendering. // only assign if different to avoid unneeded rendering.
9623 finalValue = jQuery.trim( cur ); finalValue = jQuery.trim( cur );
9624 if ( elem.className !== finalValue ) { if ( curValue !== finalValue ) {
9625 elem.className = finalValue; jQuery.attr( elem, "class", finalValue );
9626 } }
9627 } }
9628 } }
9629 } }
9630
9631 return this; return this;
9632 }, },
9633
9634 removeClass: function( value ) { removeClass: function( value ) {
9635 var classes, elem, cur, clazz, j, finalValue, var classes, elem, cur, curValue, clazz, j, finalValue,
9636 i = 0, i = 0;
9637 len = this.length,
9638 proceed = arguments.length === 0 || typeof value === "string" && value;
9639
9640 if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
9641 return this.each(function( j ) { return this.each( function( j ) {
9642 jQuery( this ).removeClass( value.call( this, j, this.className ) ); jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
9643 }); } );
9644 } }
9645 if ( proceed ) {
9646 classes = ( value || "" ).match( rnotwhite ) || [];
9647
9648 for ( ; i < len; i++ ) { if ( !arguments.length ) {
9649 elem = this[ i ]; return this.attr( "class", "" );
9650 }
9651
9652 if ( typeof value === "string" && value ) {
9653 classes = value.match( rnotwhite ) || [];
9654
9655 while ( ( elem = this[ i++ ] ) ) {
9656 curValue = getClass( elem );
9657 // This expression is here for better compressibility (see addClass) // This expression is here for better compressibility (see addClass)
9658 cur = elem.nodeType === 1 && ( elem.className ? cur = elem.nodeType === 1 &&
9659 ( " " + elem.className + " " ).replace( rclass, " " ) : ( " " + curValue + " " ).replace( rclass, " " );
9660 ""
9661 );
9662
9663 if ( cur ) { if ( cur ) {
9664 j = 0; j = 0;
9665 while ( (clazz = classes[j++]) ) { while ( ( clazz = classes[ j++ ] ) ) {
9666 // Remove *all* instances // Remove *all* instances
9667 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
9668 cur = cur.replace( " " + clazz + " ", " " ); cur = cur.replace( " " + clazz + " ", " " );
9669 } }
9670 } }
9671
9672 // only assign if different to avoid unneeded rendering. // Only assign if different to avoid unneeded rendering.
9673 finalValue = value ? jQuery.trim( cur ) : ""; finalValue = jQuery.trim( cur );
9674 if ( elem.className !== finalValue ) { if ( curValue !== finalValue ) {
9675 elem.className = finalValue; jQuery.attr( elem, "class", finalValue );
9676 } }
9677 } }
9678 } }
9679 } }
9680
9681 return this; return this;
9682 }, },
9683
9684 toggleClass: function( value, stateVal ) { toggleClass: function( value, stateVal ) {
9685 var type = typeof value; var type = typeof value;
9686
9687 if ( typeof stateVal === "boolean" && type === "string" ) { if ( typeof stateVal === "boolean" && type === "string" ) {
9688 return stateVal ? this.addClass( value ) : this.removeClass( value ); return stateVal ? this.addClass( value ) : this.removeClass( value );
9689 } }
9690
9691 if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
9692 return this.each(function( i ) { return this.each( function( i ) {
9693 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); jQuery( this ).toggleClass(
9694 }); value.call( this, i, getClass( this ), stateVal ),
9695 stateVal
9696 );
9697 } );
9698 } }
9699
9700 return this.each(function() { return this.each( function() {
9701 var className, i, self, classNames;
9702 if ( type === "string" ) { if ( type === "string" ) {
9703 // toggle individual class names
9704 var className,
9705 i = 0,
9706 self = jQuery( this ),
9707 classNames = value.match( rnotwhite ) || [];
9708
9709 while ( (className = classNames[ i++ ]) ) { // Toggle individual class names
9710 // check each className given, space separated list i = 0;
9711 self = jQuery( this );
9712 classNames = value.match( rnotwhite ) || [];
9713
9714 while ( ( className = classNames[ i++ ] ) ) {
9715
9716 // Check each className given, space separated list
9717 if ( self.hasClass( className ) ) { if ( self.hasClass( className ) ) {
9718 self.removeClass( className ); self.removeClass( className );
9719 } else { } else {
9720 self.addClass( className ); self.addClass( className );
9721 } }
9722 } }
9723
9724 // Toggle whole class name // Toggle whole class name
9725 } else if ( type === strundefined || type === "boolean" ) { } else if ( value === undefined || type === "boolean" ) {
9726 if ( this.className ) { className = getClass( this );
9727 if ( className ) {
9728 // store className if set // store className if set
9729 jQuery._data( this, "__className__", this.className ); jQuery._data( this, "__className__", className );
9730 } }
9731
9732 // If the element has a class name or if we're passed "false", // If the element has a class name or if we're passed "false",
9733 // then remove the whole classname (if there was one, the above saved it). // then remove the whole classname (if there was one, the above saved it).
9734 // Otherwise bring back whatever was previously saved (if anything), // Otherwise bring back whatever was previously saved (if anything),
9735 // falling back to the empty string if nothing was stored. // falling back to the empty string if nothing was stored.
9736 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; jQuery.attr( this, "class",
9737 className || value === false ?
9738 "" :
9739 jQuery._data( this, "__className__" ) || ""
9740 );
9741 } }
9742 }); } );
9743 }, },
9744
9745 hasClass: function( selector ) { hasClass: function( selector ) {
9746 var className = " " + selector + " ", var className, elem,
9747 i = 0, i = 0;
9748 l = this.length;
9749 for ( ; i < l; i++ ) { className = " " + selector + " ";
9750 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { while ( ( elem = this[ i++ ] ) ) {
9751 if ( elem.nodeType === 1 &&
9752 ( " " + getClass( elem ) + " " ).replace( rclass, " " )
9753 .indexOf( className ) > -1
9754 ) {
9755 return true; return true;
9756 } }
9757 } }
9758
9759 return false; return false;
9760 } }
9761 }); } );
9762
9763
9764
9765
9766 // Return jQuery for attributes-only inclusion // Return jQuery for attributes-only inclusion
9767
9768
9769 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " +
9770 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
9771 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { "change select submit keydown keypress keyup error contextmenu" ).split( " " ),
9772 function( i, name ) {
9773
9774 // Handle event binding // Handle event binding
9775 jQuery.fn[ name ] = function( data, fn ) { jQuery.fn[ name ] = function( data, fn ) {
9776 return arguments.length > 0 ? return arguments.length > 0 ?
9777 this.on( name, null, data, fn ) : this.on( name, null, data, fn ) :
9778 this.trigger( name ); this.trigger( name );
9779 }; };
9780 }); } );
9781
9782 jQuery.fn.extend({ jQuery.fn.extend( {
9783 hover: function( fnOver, fnOut ) { hover: function( fnOver, fnOut ) {
9784 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
9785 },
9786
9787 bind: function( types, data, fn ) {
9788 return this.on( types, null, data, fn );
9789 },
9790 unbind: function( types, fn ) {
9791 return this.off( types, null, fn );
9792 },
9793
9794 delegate: function( selector, types, data, fn ) {
9795 return this.on( types, selector, data, fn );
9796 },
9797 undelegate: function( selector, types, fn ) {
9798 // ( namespace ) or ( selector, types [, fn] )
9799 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
9800 } }
9801 }); } );
9802
9803
9804 var location = window.location;
9805
9806 var nonce = jQuery.now(); var nonce = jQuery.now();
9807
9808 var rquery = (/\?/); var rquery = ( /\?/ );
9809
9810
9811
9812 var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g; var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
9813
9814 jQuery.parseJSON = function( data ) { jQuery.parseJSON = function( data ) {
9815
9816 // Attempt to parse using the native JSON parser first // Attempt to parse using the native JSON parser first
9817 if ( window.JSON && window.JSON.parse ) { if ( window.JSON && window.JSON.parse ) {
9818
9819 // Support: Android 2.3 // Support: Android 2.3
9820 // Workaround failure to string-cast null input // Workaround failure to string-cast null input
9821 return window.JSON.parse( data + "" ); return window.JSON.parse( data + "" );
9822 } }
9823
9824 var requireNonComma, var requireNonComma,
9825 depth = null, depth = null,
9826 str = jQuery.trim( data + "" ); str = jQuery.trim( data + "" );
9827
9828 // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
9829 // after removing valid tokens // after removing valid tokens
9830 return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) { return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
9831
9832 // Force termination if we see a misplaced comma // Force termination if we see a misplaced comma
9833 if ( requireNonComma && comma ) { if ( requireNonComma && comma ) {
9834 depth = 0; depth = 0;
9835 } }
9836
9837 // Perform no more replacements after returning to outermost depth // Perform no more replacements after returning to outermost depth
9838 if ( depth === 0 ) { if ( depth === 0 ) {
9839 return token; return token;
9840 } }
9841
9842 // Commas must not follow "[", "{", or "," // Commas must not follow "[", "{", or ","
9843 requireNonComma = open || comma; requireNonComma = open || comma;
9844
9845 // Determine new depth // Determine new depth
9846 // array/object open ("[" or "{"): depth += true - false (increment) // array/object open ("[" or "{"): depth += true - false (increment)
9847 // array/object close ("]" or "}"): depth += false - true (decrement) // array/object close ("]" or "}"): depth += false - true (decrement)
9848 // other cases ("," or primitive): depth += true - true (numeric cast) // other cases ("," or primitive): depth += true - true (numeric cast)
9849 depth += !close - !open; depth += !close - !open;
9850
9851 // Remove this token // Remove this token
9852 return ""; return "";
9853 }) ) ? } ) ) ?
9854 ( Function( "return " + str ) )() : ( Function( "return " + str ) )() :
9855 jQuery.error( "Invalid JSON: " + data ); jQuery.error( "Invalid JSON: " + data );
9856 }; };
9857
9858
9859 // Cross-browser xml parsing // Cross-browser xml parsing
9860 jQuery.parseXML = function( data ) { jQuery.parseXML = function( data ) {
9861 var xml, tmp; var xml, tmp;
9862 if ( !data || typeof data !== "string" ) { if ( !data || typeof data !== "string" ) {
9863 return null; return null;
9864 } }
9865 try { try {
9866 if ( window.DOMParser ) { // Standard if ( window.DOMParser ) { // Standard
9867 tmp = new DOMParser(); tmp = new window.DOMParser();
9868 xml = tmp.parseFromString( data, "text/xml" ); xml = tmp.parseFromString( data, "text/xml" );
9869 } else { // IE } else { // IE
9870 xml = new ActiveXObject( "Microsoft.XMLDOM" ); xml = new window.ActiveXObject( "Microsoft.XMLDOM" );
9871 xml.async = "false"; xml.async = "false";
9872 xml.loadXML( data ); xml.loadXML( data );
9873 } }
9874 } catch( e ) { } catch ( e ) {
9875 xml = undefined; xml = undefined;
9876 } }
9877 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
9878 jQuery.error( "Invalid XML: " + data ); jQuery.error( "Invalid XML: " + data );
9879 } }
9880 return xml; return xml;
9881 }; };
9882
9883
9884 var var
9885 // Document location
9886 ajaxLocParts,
9887 ajaxLocation,
9888
9889 rhash = /#.*$/, rhash = /#.*$/,
9890 rts = /([?&])_=[^&]*/, rts = /([?&])_=[^&]*/,
9891 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
9892 // IE leaves an \r character at EOL
9893 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg,
9894 // #7653, #8125, #8152: local protocol detection // #7653, #8125, #8152: local protocol detection
9895 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
9896 rnoContent = /^(?:GET|HEAD)$/, rnoContent = /^(?:GET|HEAD)$/,
9897 rprotocol = /^\/\//, rprotocol = /^\/\//,
9898 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/, rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
9899
9900 /* Prefilters /* Prefilters
9901 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
9902 * 2) These are called: * 2) These are called:
9903 * - BEFORE asking for a transport * - BEFORE asking for a transport
9904 * - AFTER param serialization (s.data is a string if s.processData is true) * - AFTER param serialization (s.data is a string if s.processData is true)
9905 * 3) key is the dataType * 3) key is the dataType
9906 * 4) the catchall symbol "*" can be used * 4) the catchall symbol "*" can be used
9907 * 5) execution will start with transport dataType and THEN continue down to "*" if needed * 5) execution will start with transport dataType and THEN continue down to "*" if needed
9908 */ */
9909 prefilters = {}, prefilters = {},
9910
9911 /* Transports bindings /* Transports bindings
9912 * 1) key is the dataType * 1) key is the dataType
9913 * 2) the catchall symbol "*" can be used * 2) the catchall symbol "*" can be used
9914 * 3) selection will start with transport dataType and THEN go to "*" if needed * 3) selection will start with transport dataType and THEN go to "*" if needed
9915 */ */
9916 transports = {}, transports = {},
9917
9918 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
9919 allTypes = "*/".concat("*"); allTypes = "*/".concat( "*" ),
9920
9921 // #8138, IE may throw an exception when accessing // Document location
9922 // a field from window.location if document.domain has been set ajaxLocation = location.href,
9923 try {
9924 ajaxLocation = location.href;
9925 } catch( e ) {
9926 // Use the href attribute of an A element
9927 // since IE will modify it given document.location
9928 ajaxLocation = document.createElement( "a" );
9929 ajaxLocation.href = "";
9930 ajaxLocation = ajaxLocation.href;
9931 }
9932
9933 // Segment location into parts // Segment location into parts
9934 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
9935
9936 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
9937 function addToPrefiltersOrTransports( structure ) { function addToPrefiltersOrTransports( structure ) {
9938
9939 // dataTypeExpression is optional and defaults to "*" // dataTypeExpression is optional and defaults to "*"
9940 return function( dataTypeExpression, func ) { return function( dataTypeExpression, func ) {
9941
9942 if ( typeof dataTypeExpression !== "string" ) { if ( typeof dataTypeExpression !== "string" ) {
9943 func = dataTypeExpression; func = dataTypeExpression;
9944 dataTypeExpression = "*"; dataTypeExpression = "*";
9945 } }
9946
9947 var dataType, var dataType,
9948 i = 0, i = 0,
9949 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || []; dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
9950
9951 if ( jQuery.isFunction( func ) ) { if ( jQuery.isFunction( func ) ) {
9952
9953 // For each dataType in the dataTypeExpression // For each dataType in the dataTypeExpression
9954 while ( (dataType = dataTypes[i++]) ) { while ( ( dataType = dataTypes[ i++ ] ) ) {
9955 // Prepend if requested // Prepend if requested
9956 if ( dataType.charAt( 0 ) === "+" ) { if ( dataType.charAt( 0 ) === "+" ) {
9957 dataType = dataType.slice( 1 ) || "*"; dataType = dataType.slice( 1 ) || "*";
9958 (structure[ dataType ] = structure[ dataType ] || []).unshift( func ); ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
9959
9960 // Otherwise append // Otherwise append
9961 } else { } else {
9962 (structure[ dataType ] = structure[ dataType ] || []).push( func ); ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
9963 } }
9964 } }
9965 } }
9966 }; };
9967 } }
9968
9969 // Base inspection function for prefilters and transports // Base inspection function for prefilters and transports
9970 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
9971
9972 var inspected = {}, var inspected = {},
9973 seekingTransport = ( structure === transports ); seekingTransport = ( structure === transports );
9974
9975 function inspect( dataType ) { function inspect( dataType ) {
9976 var selected; var selected;
9977 inspected[ dataType ] = true; inspected[ dataType ] = true;
9978 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
9979 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
9980 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) { if ( typeof dataTypeOrTransport === "string" &&
9981 !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
9982 options.dataTypes.unshift( dataTypeOrTransport ); options.dataTypes.unshift( dataTypeOrTransport );
9983 inspect( dataTypeOrTransport ); inspect( dataTypeOrTransport );
9984 return false; return false;
9985 } else if ( seekingTransport ) { } else if ( seekingTransport ) {
9986 return !( selected = dataTypeOrTransport ); return !( selected = dataTypeOrTransport );
9987 } }
9988 }); } );
9989 return selected; return selected;
9990 } }
9991
9992 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
9993 } }
9994
9995 // A special extend for ajax options // A special extend for ajax options
9996 // that takes "flat" options (not to be deep extended) // that takes "flat" options (not to be deep extended)
9997 // Fixes #9887 // Fixes #9887
9998 function ajaxExtend( target, src ) { function ajaxExtend( target, src ) {
9999 var deep, key, var deep, key,
10000 flatOptions = jQuery.ajaxSettings.flatOptions || {}; flatOptions = jQuery.ajaxSettings.flatOptions || {};
10001
10002 for ( key in src ) { for ( key in src ) {
10003 if ( src[ key ] !== undefined ) { if ( src[ key ] !== undefined ) {
10004 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ]; ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
10005 } }
10006 } }
10007 if ( deep ) { if ( deep ) {
10008 jQuery.extend( true, target, deep ); jQuery.extend( true, target, deep );
10009 } }
10010
10011 return target; return target;
10012 } }
10013
10014 /* Handles responses to an ajax request: /* Handles responses to an ajax request:
10015 * - finds the right dataType (mediates between content-type and expected dataType) * - finds the right dataType (mediates between content-type and expected dataType)
10016 * - returns the corresponding response * - returns the corresponding response
10017 */ */
10018 function ajaxHandleResponses( s, jqXHR, responses ) { function ajaxHandleResponses( s, jqXHR, responses ) {
10019 var firstDataType, ct, finalDataType, type, var firstDataType, ct, finalDataType, type,
10020 contents = s.contents, contents = s.contents,
10021 dataTypes = s.dataTypes; dataTypes = s.dataTypes;
10022
10023 // Remove auto dataType and get content-type in the process // Remove auto dataType and get content-type in the process
10024 while ( dataTypes[ 0 ] === "*" ) { while ( dataTypes[ 0 ] === "*" ) {
10025 dataTypes.shift(); dataTypes.shift();
10026 if ( ct === undefined ) { if ( ct === undefined ) {
10027 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type"); ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
10028 } }
10029 } }
10030
10031 // Check if we're dealing with a known content-type // Check if we're dealing with a known content-type
10032 if ( ct ) { if ( ct ) {
10033 for ( type in contents ) { for ( type in contents ) {
10034 if ( contents[ type ] && contents[ type ].test( ct ) ) { if ( contents[ type ] && contents[ type ].test( ct ) ) {
10035 dataTypes.unshift( type ); dataTypes.unshift( type );
10036 break; break;
10037 } }
10038 } }
10039 } }
10040
10041 // Check to see if we have a response for the expected dataType // Check to see if we have a response for the expected dataType
10042 if ( dataTypes[ 0 ] in responses ) { if ( dataTypes[ 0 ] in responses ) {
10043 finalDataType = dataTypes[ 0 ]; finalDataType = dataTypes[ 0 ];
10044 } else { } else {
10045
10046 // Try convertible dataTypes // Try convertible dataTypes
10047 for ( type in responses ) { for ( type in responses ) {
10048 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
10049 finalDataType = type; finalDataType = type;
10050 break; break;
10051 } }
10052 if ( !firstDataType ) { if ( !firstDataType ) {
10053 firstDataType = type; firstDataType = type;
10054 } }
10055 } }
10056
10057 // Or just use first one // Or just use first one
10058 finalDataType = finalDataType || firstDataType; finalDataType = finalDataType || firstDataType;
10059 } }
10060
10061 // If we found a dataType // If we found a dataType
10062 // We add the dataType to the list if needed // We add the dataType to the list if needed
10063 // and return the corresponding response // and return the corresponding response
10064 if ( finalDataType ) { if ( finalDataType ) {
10065 if ( finalDataType !== dataTypes[ 0 ] ) { if ( finalDataType !== dataTypes[ 0 ] ) {
10066 dataTypes.unshift( finalDataType ); dataTypes.unshift( finalDataType );
10067 } }
10068 return responses[ finalDataType ]; return responses[ finalDataType ];
10069 } }
10070 } }
10071
10072 /* Chain conversions given the request and the original response /* Chain conversions given the request and the original response
10073 * Also sets the responseXXX fields on the jqXHR instance * Also sets the responseXXX fields on the jqXHR instance
10074 */ */
10075 function ajaxConvert( s, response, jqXHR, isSuccess ) { function ajaxConvert( s, response, jqXHR, isSuccess ) {
10076 var conv2, current, conv, tmp, prev, var conv2, current, conv, tmp, prev,
10077 converters = {}, converters = {},
10078
10079 // Work with a copy of dataTypes in case we need to modify it for conversion // Work with a copy of dataTypes in case we need to modify it for conversion
10080 dataTypes = s.dataTypes.slice(); dataTypes = s.dataTypes.slice();
10081
10082 // Create converters map with lowercased keys // Create converters map with lowercased keys
10083 if ( dataTypes[ 1 ] ) { if ( dataTypes[ 1 ] ) {
10084 for ( conv in s.converters ) { for ( conv in s.converters ) {
10085 converters[ conv.toLowerCase() ] = s.converters[ conv ]; converters[ conv.toLowerCase() ] = s.converters[ conv ];
10086 } }
10087 } }
10088
10089 current = dataTypes.shift(); current = dataTypes.shift();
10090
10091 // Convert to each sequential dataType // Convert to each sequential dataType
10092 while ( current ) { while ( current ) {
10093
10094 if ( s.responseFields[ current ] ) { if ( s.responseFields[ current ] ) {
10095 jqXHR[ s.responseFields[ current ] ] = response; jqXHR[ s.responseFields[ current ] ] = response;
10096 } }
10097
10098 // Apply the dataFilter if provided // Apply the dataFilter if provided
10099 if ( !prev && isSuccess && s.dataFilter ) { if ( !prev && isSuccess && s.dataFilter ) {
10100 response = s.dataFilter( response, s.dataType ); response = s.dataFilter( response, s.dataType );
10101 } }
10102
10103 prev = current; prev = current;
10104 current = dataTypes.shift(); current = dataTypes.shift();
10105
10106 if ( current ) { if ( current ) {
10107
10108 // There's only work to do if current dataType is non-auto // There's only work to do if current dataType is non-auto
10109 if ( current === "*" ) { if ( current === "*" ) {
10110
10111 current = prev; current = prev;
10112
10113 // Convert response if prev dataType is non-auto and differs from current // Convert response if prev dataType is non-auto and differs from current
10114 } else if ( prev !== "*" && prev !== current ) { } else if ( prev !== "*" && prev !== current ) {
10115
10116 // Seek a direct converter // Seek a direct converter
10117 conv = converters[ prev + " " + current ] || converters[ "* " + current ]; conv = converters[ prev + " " + current ] || converters[ "* " + current ];
10118
10119 // If none found, seek a pair // If none found, seek a pair
10120 if ( !conv ) { if ( !conv ) {
10121 for ( conv2 in converters ) { for ( conv2 in converters ) {
10122
10123 // If conv2 outputs current // If conv2 outputs current
10124 tmp = conv2.split( " " ); tmp = conv2.split( " " );
10125 if ( tmp[ 1 ] === current ) { if ( tmp[ 1 ] === current ) {
10126
10127 // If prev can be converted to accepted input // If prev can be converted to accepted input
10128 conv = converters[ prev + " " + tmp[ 0 ] ] || conv = converters[ prev + " " + tmp[ 0 ] ] ||
10129 converters[ "* " + tmp[ 0 ] ]; converters[ "* " + tmp[ 0 ] ];
10130 if ( conv ) { if ( conv ) {
10131
10132 // Condense equivalence converters // Condense equivalence converters
10133 if ( conv === true ) { if ( conv === true ) {
10134 conv = converters[ conv2 ]; conv = converters[ conv2 ];
10135
10136 // Otherwise, insert the intermediate dataType // Otherwise, insert the intermediate dataType
10137 } else if ( converters[ conv2 ] !== true ) { } else if ( converters[ conv2 ] !== true ) {
10138 current = tmp[ 0 ]; current = tmp[ 0 ];
10139 dataTypes.unshift( tmp[ 1 ] ); dataTypes.unshift( tmp[ 1 ] );
10140 } }
10141 break; break;
10142 } }
10143 } }
10144 } }
10145 } }
10146
10147 // Apply converter (if not an equivalence) // Apply converter (if not an equivalence)
10148 if ( conv !== true ) { if ( conv !== true ) {
10149
10150 // Unless errors are allowed to bubble, catch and return them // Unless errors are allowed to bubble, catch and return them
10151 if ( conv && s[ "throws" ] ) { if ( conv && s[ "throws" ] ) { // jscs:ignore requireDotNotation
10152 response = conv( response ); response = conv( response );
10153 } else { } else {
10154 try { try {
10155 response = conv( response ); response = conv( response );
10156 } catch ( e ) { } catch ( e ) {
10157 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current }; return {
10158 state: "parsererror",
10159 error: conv ? e : "No conversion from " + prev + " to " + current
10160 };
10161 } }
10162 } }
10163 } }
10164 } }
10165 } }
10166 } }
10167
10168 return { state: "success", data: response }; return { state: "success", data: response };
10169 } }
10170
10171 jQuery.extend({ jQuery.extend( {
10172
10173 // Counter for holding the number of active queries // Counter for holding the number of active queries
10174 active: 0, active: 0,
10175
10176 // Last-Modified header cache for next request // Last-Modified header cache for next request
10177 lastModified: {}, lastModified: {},
10178 etag: {}, etag: {},
10179
10180 ajaxSettings: { ajaxSettings: {
10181 url: ajaxLocation, url: ajaxLocation,
10182 type: "GET", type: "GET",
10183 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
10184 global: true, global: true,
10185 processData: true, processData: true,
10186 async: true, async: true,
10187 contentType: "application/x-www-form-urlencoded; charset=UTF-8", contentType: "application/x-www-form-urlencoded; charset=UTF-8",
10188 /* /*
10189 timeout: 0, timeout: 0,
10190 data: null, data: null,
10191 dataType: null, dataType: null,
10192 username: null, username: null,
10193 password: null, password: null,
10194 cache: null, cache: null,
10195 throws: false, throws: false,
10196 traditional: false, traditional: false,
10197 headers: {}, headers: {},
10198 */ */
10199
10200 accepts: { accepts: {
10201 "*": allTypes, "*": allTypes,
10202 text: "text/plain", text: "text/plain",
10203 html: "text/html", html: "text/html",
10204 xml: "application/xml, text/xml", xml: "application/xml, text/xml",
10205 json: "application/json, text/javascript" json: "application/json, text/javascript"
10206 }, },
10207
10208 contents: { contents: {
10209 xml: /xml/, xml: /\bxml\b/,
10210 html: /html/, html: /\bhtml/,
10211 json: /json/ json: /\bjson\b/
10212 }, },
10213
10214 responseFields: { responseFields: {
10215 xml: "responseXML", xml: "responseXML",
10216 text: "responseText", text: "responseText",
10217 json: "responseJSON" json: "responseJSON"
10218 }, },
10219
10220 // Data converters // Data converters
10221 // Keys separate source (or catchall "*") and destination types with a single space // Keys separate source (or catchall "*") and destination types with a single space
10222 converters: { converters: {
10223
10224 // Convert anything to text // Convert anything to text
10225 "* text": String, "* text": String,
10226
10227 // Text to html (true = no transformation) // Text to html (true = no transformation)
10228 "text html": true, "text html": true,
10229
10230 // Evaluate text as a json expression // Evaluate text as a json expression
10231 "text json": jQuery.parseJSON, "text json": jQuery.parseJSON,
10232
10233 // Parse text as xml // Parse text as xml
10234 "text xml": jQuery.parseXML "text xml": jQuery.parseXML
10235 }, },
10236
10237 // For options that shouldn't be deep extended: // For options that shouldn't be deep extended:
10238 // you can add your own custom options here if // you can add your own custom options here if
10239 // and when you create one that shouldn't be // and when you create one that shouldn't be
10240 // deep extended (see ajaxExtend) // deep extended (see ajaxExtend)
10241 flatOptions: { flatOptions: {
10242 url: true, url: true,
10243 context: true context: true
10244 } }
10245 }, },
10246
10247 // Creates a full fledged settings object into target // Creates a full fledged settings object into target
10248 // with both ajaxSettings and settings fields. // with both ajaxSettings and settings fields.
10249 // If target is omitted, writes into ajaxSettings. // If target is omitted, writes into ajaxSettings.
10250 ajaxSetup: function( target, settings ) { ajaxSetup: function( target, settings ) {
10251 return settings ? return settings ?
10252
10253 // Building a settings object // Building a settings object
10254 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
10255
10256 // Extending ajaxSettings // Extending ajaxSettings
10257 ajaxExtend( jQuery.ajaxSettings, target ); ajaxExtend( jQuery.ajaxSettings, target );
10258 }, },
10259
10260 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
10261 ajaxTransport: addToPrefiltersOrTransports( transports ), ajaxTransport: addToPrefiltersOrTransports( transports ),
10262
10263 // Main method // Main method
10264 ajax: function( url, options ) { ajax: function( url, options ) {
10265
10266 // If url is an object, simulate pre-1.5 signature // If url is an object, simulate pre-1.5 signature
10267 if ( typeof url === "object" ) { if ( typeof url === "object" ) {
10268 options = url; options = url;
10269 url = undefined; url = undefined;
10270 } }
10271
10272 // Force options to be an object // Force options to be an object
10273 options = options || {}; options = options || {};
10274
10275 var // Cross-domain detection vars var
10276
10277 // Cross-domain detection vars
10278 parts, parts,
10279
10280 // Loop variable // Loop variable
10281 i, i,
10282
10283 // URL without anti-cache param // URL without anti-cache param
10284 cacheURL, cacheURL,
10285
10286 // Response headers as string // Response headers as string
10287 responseHeadersString, responseHeadersString,
10288
10289 // timeout handle // timeout handle
10290 timeoutTimer, timeoutTimer,
10291
10292 // To know if global events are to be dispatched // To know if global events are to be dispatched
10293 fireGlobals, fireGlobals,
10294
10295 transport, transport,
10296
10297 // Response headers // Response headers
10298 responseHeaders, responseHeaders,
10299
10300 // Create the final options object // Create the final options object
10301 s = jQuery.ajaxSetup( {}, options ), s = jQuery.ajaxSetup( {}, options ),
10302
10303 // Callbacks context // Callbacks context
10304 callbackContext = s.context || s, callbackContext = s.context || s,
10305
10306 // Context for global events is callbackContext if it is a DOM node or jQuery collection // Context for global events is callbackContext if it is a DOM node or jQuery collection
10307 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ? globalEventContext = s.context &&
10308 jQuery( callbackContext ) : ( callbackContext.nodeType || callbackContext.jquery ) ?
10309 jQuery.event, jQuery( callbackContext ) :
10310 jQuery.event,
10311 // Deferreds // Deferreds
10312 deferred = jQuery.Deferred(), deferred = jQuery.Deferred(),
10313 completeDeferred = jQuery.Callbacks("once memory"), completeDeferred = jQuery.Callbacks( "once memory" ),
10314 // Status-dependent callbacks // Status-dependent callbacks
10315 statusCode = s.statusCode || {}, statusCode = s.statusCode || {},
10316
10317 // Headers (they are sent all at once) // Headers (they are sent all at once)
10318 requestHeaders = {}, requestHeaders = {},
10319 requestHeadersNames = {}, requestHeadersNames = {},
10320
10321 // The jqXHR state // The jqXHR state
10322 state = 0, state = 0,
10323
10324 // Default abort message // Default abort message
10325 strAbort = "canceled", strAbort = "canceled",
10326
10327 // Fake xhr // Fake xhr
10328 jqXHR = { jqXHR = {
10329 readyState: 0, readyState: 0,
10330
10331 // Builds headers hashtable if needed // Builds headers hashtable if needed
10332 getResponseHeader: function( key ) { getResponseHeader: function( key ) {
10333 var match; var match;
10334 if ( state === 2 ) { if ( state === 2 ) {
10335 if ( !responseHeaders ) { if ( !responseHeaders ) {
10336 responseHeaders = {}; responseHeaders = {};
10337 while ( (match = rheaders.exec( responseHeadersString )) ) { while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
10338 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
10339 } }
10340 } }
10341 match = responseHeaders[ key.toLowerCase() ]; match = responseHeaders[ key.toLowerCase() ];
10342 } }
10343 return match == null ? null : match; return match == null ? null : match;
10344 }, },
10345
10346 // Raw string // Raw string
10347 getAllResponseHeaders: function() { getAllResponseHeaders: function() {
10348 return state === 2 ? responseHeadersString : null; return state === 2 ? responseHeadersString : null;
10349 }, },
10350
10351 // Caches the header // Caches the header
10352 setRequestHeader: function( name, value ) { setRequestHeader: function( name, value ) {
10353 var lname = name.toLowerCase(); var lname = name.toLowerCase();
10354 if ( !state ) { if ( !state ) {
10355 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
10356 requestHeaders[ name ] = value; requestHeaders[ name ] = value;
10357 } }
10358 return this; return this;
10359 }, },
10360
10361 // Overrides response content-type header // Overrides response content-type header
10362 overrideMimeType: function( type ) { overrideMimeType: function( type ) {
10363 if ( !state ) { if ( !state ) {
10364 s.mimeType = type; s.mimeType = type;
10365 } }
10366 return this; return this;
10367 }, },
10368
10369 // Status-dependent callbacks // Status-dependent callbacks
10370 statusCode: function( map ) { statusCode: function( map ) {
10371 var code; var code;
10372 if ( map ) { if ( map ) {
10373 if ( state < 2 ) { if ( state < 2 ) {
10374 for ( code in map ) { for ( code in map ) {
10375
10376 // Lazy-add the new callback in a way that preserves old ones // Lazy-add the new callback in a way that preserves old ones
10377 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
10378 } }
10379 } else { } else {
10380
10381 // Execute the appropriate callbacks // Execute the appropriate callbacks
10382 jqXHR.always( map[ jqXHR.status ] ); jqXHR.always( map[ jqXHR.status ] );
10383 } }
10384 } }
10385 return this; return this;
10386 }, },
10387
10388 // Cancel the request // Cancel the request
10389 abort: function( statusText ) { abort: function( statusText ) {
10390 var finalText = statusText || strAbort; var finalText = statusText || strAbort;
10391 if ( transport ) { if ( transport ) {
10392 transport.abort( finalText ); transport.abort( finalText );
10393 } }
10394 done( 0, finalText ); done( 0, finalText );
10395 return this; return this;
10396 } }
10397 }; };
10398
10399 // Attach deferreds // Attach deferreds
10400 deferred.promise( jqXHR ).complete = completeDeferred.add; deferred.promise( jqXHR ).complete = completeDeferred.add;
10401 jqXHR.success = jqXHR.done; jqXHR.success = jqXHR.done;
10402 jqXHR.error = jqXHR.fail; jqXHR.error = jqXHR.fail;
10403
10404 // Remove hash character (#7531: and string promotion) // Remove hash character (#7531: and string promotion)
10405 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
10406 // Handle falsy url in the settings object (#10093: consistency with old signature) // Handle falsy url in the settings object (#10093: consistency with old signature)
10407 // We also use the url parameter if available // We also use the url parameter if available
10408 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); s.url = ( ( url || s.url || ajaxLocation ) + "" )
10409 .replace( rhash, "" )
10410 .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
10411
10412 // Alias method option to type as per ticket #12004 // Alias method option to type as per ticket #12004
10413 s.type = options.method || options.type || s.method || s.type; s.type = options.method || options.type || s.method || s.type;
10414
10415 // Extract dataTypes list // Extract dataTypes list
10416 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ]; s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
10417
10418 // A cross-domain request is in order when we have a protocol:host:port mismatch // A cross-domain request is in order when we have a protocol:host:port mismatch
10419 if ( s.crossDomain == null ) { if ( s.crossDomain == null ) {
10420 parts = rurl.exec( s.url.toLowerCase() ); parts = rurl.exec( s.url.toLowerCase() );
10421 s.crossDomain = !!( parts && s.crossDomain = !!( parts &&
10422 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] || ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
10423 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !== ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
10424 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) ) ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
10425 ); );
10426 } }
10427
10428 // Convert data if not already a string // Convert data if not already a string
10429 if ( s.data && s.processData && typeof s.data !== "string" ) { if ( s.data && s.processData && typeof s.data !== "string" ) {
10430 s.data = jQuery.param( s.data, s.traditional ); s.data = jQuery.param( s.data, s.traditional );
10431 } }
10432
10433 // Apply prefilters // Apply prefilters
10434 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
10435
10436 // If request was aborted inside a prefilter, stop there // If request was aborted inside a prefilter, stop there
10437 if ( state === 2 ) { if ( state === 2 ) {
10438 return jqXHR; return jqXHR;
10439 } }
10440
10441 // We can fire global events as of now if asked to // We can fire global events as of now if asked to
10442 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
10443 fireGlobals = jQuery.event && s.global; fireGlobals = jQuery.event && s.global;
10444
10445 // Watch for a new set of requests // Watch for a new set of requests
10446 if ( fireGlobals && jQuery.active++ === 0 ) { if ( fireGlobals && jQuery.active++ === 0 ) {
10447 jQuery.event.trigger("ajaxStart"); jQuery.event.trigger( "ajaxStart" );
10448 } }
10449
10450 // Uppercase the type // Uppercase the type
10451 s.type = s.type.toUpperCase(); s.type = s.type.toUpperCase();
10452
10453 // Determine if request has content // Determine if request has content
10454 s.hasContent = !rnoContent.test( s.type ); s.hasContent = !rnoContent.test( s.type );
10455
10456 // Save the URL in case we're toying with the If-Modified-Since // Save the URL in case we're toying with the If-Modified-Since
10457 // and/or If-None-Match header later on // and/or If-None-Match header later on
10458 cacheURL = s.url; cacheURL = s.url;
10459
10460 // More options handling for requests with no content // More options handling for requests with no content
10461 if ( !s.hasContent ) { if ( !s.hasContent ) {
10462
10463 // If data is available, append data to url // If data is available, append data to url
10464 if ( s.data ) { if ( s.data ) {
10465 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data ); cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
10466
10467 // #9682: remove data so that it's not used in an eventual retry // #9682: remove data so that it's not used in an eventual retry
10468 delete s.data; delete s.data;
10469 } }
10470
10471 // Add anti-cache in url if needed // Add anti-cache in url if needed
10472 if ( s.cache === false ) { if ( s.cache === false ) {
10473 s.url = rts.test( cacheURL ) ? s.url = rts.test( cacheURL ) ?
10474
10475 // If there is already a '_' parameter, set its value // If there is already a '_' parameter, set its value
10476 cacheURL.replace( rts, "$1_=" + nonce++ ) : cacheURL.replace( rts, "$1_=" + nonce++ ) :
10477
10478 // Otherwise add one to the end // Otherwise add one to the end
10479 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++; cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
10480 } }
10481 } }
10482
10483 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
10484 if ( s.ifModified ) { if ( s.ifModified ) {
10485 if ( jQuery.lastModified[ cacheURL ] ) { if ( jQuery.lastModified[ cacheURL ] ) {
10486 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
10487 } }
10488 if ( jQuery.etag[ cacheURL ] ) { if ( jQuery.etag[ cacheURL ] ) {
10489 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
10490 } }
10491 } }
10492
10493 // Set the correct header, if data is being sent // Set the correct header, if data is being sent
10494 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
10495 jqXHR.setRequestHeader( "Content-Type", s.contentType ); jqXHR.setRequestHeader( "Content-Type", s.contentType );
10496 } }
10497
10498 // Set the Accepts header for the server, depending on the dataType // Set the Accepts header for the server, depending on the dataType
10499 jqXHR.setRequestHeader( jqXHR.setRequestHeader(
10500 "Accept", "Accept",
10501 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
10502 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : s.accepts[ s.dataTypes[ 0 ] ] +
10503 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
10504 s.accepts[ "*" ] s.accepts[ "*" ]
10505 ); );
10506
10507 // Check for headers option // Check for headers option
10508 for ( i in s.headers ) { for ( i in s.headers ) {
10509 jqXHR.setRequestHeader( i, s.headers[ i ] ); jqXHR.setRequestHeader( i, s.headers[ i ] );
10510 } }
10511
10512 // Allow custom headers/mimetypes and early abort // Allow custom headers/mimetypes and early abort
10513 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { if ( s.beforeSend &&
10514 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
10515 // Abort if not done already and return // Abort if not done already and return
10516 return jqXHR.abort(); return jqXHR.abort();
10517 } }
10518
10519 // aborting is no longer a cancellation // aborting is no longer a cancellation
10520 strAbort = "abort"; strAbort = "abort";
10521
10522 // Install callbacks on deferreds // Install callbacks on deferreds
10523 for ( i in { success: 1, error: 1, complete: 1 } ) { for ( i in { success: 1, error: 1, complete: 1 } ) {
10524 jqXHR[ i ]( s[ i ] ); jqXHR[ i ]( s[ i ] );
10525 } }
10526
10527 // Get transport // Get transport
10528 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
10529
10530 // If no transport, we auto-abort // If no transport, we auto-abort
10531 if ( !transport ) { if ( !transport ) {
10532 done( -1, "No Transport" ); done( -1, "No Transport" );
10533 } else { } else {
10534 jqXHR.readyState = 1; jqXHR.readyState = 1;
10535
10536 // Send global event // Send global event
10537 if ( fireGlobals ) { if ( fireGlobals ) {
10538 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
10539 } }
10540
10541 // If request was aborted inside ajaxSend, stop there
10542 if ( state === 2 ) {
10543 return jqXHR;
10544 }
10545
10546 // Timeout // Timeout
10547 if ( s.async && s.timeout > 0 ) { if ( s.async && s.timeout > 0 ) {
10548 timeoutTimer = setTimeout(function() { timeoutTimer = window.setTimeout( function() {
10549 jqXHR.abort("timeout"); jqXHR.abort( "timeout" );
10550 }, s.timeout ); }, s.timeout );
10551 } }
10552
10553 try { try {
10554 state = 1; state = 1;
10555 transport.send( requestHeaders, done ); transport.send( requestHeaders, done );
10556 } catch ( e ) { } catch ( e ) {
10557
10558 // Propagate exception as error if not done // Propagate exception as error if not done
10559 if ( state < 2 ) { if ( state < 2 ) {
10560 done( -1, e ); done( -1, e );
10561
10562 // Simply rethrow otherwise // Simply rethrow otherwise
10563 } else { } else {
10564 throw e; throw e;
10565 } }
10566 } }
10567 } }
10568
10569 // Callback for when everything is done // Callback for when everything is done
10570 function done( status, nativeStatusText, responses, headers ) { function done( status, nativeStatusText, responses, headers ) {
10571 var isSuccess, success, error, response, modified, var isSuccess, success, error, response, modified,
10572 statusText = nativeStatusText; statusText = nativeStatusText;
10573
10574 // Called once // Called once
10575 if ( state === 2 ) { if ( state === 2 ) {
10576 return; return;
10577 } }
10578
10579 // State is "done" now // State is "done" now
10580 state = 2; state = 2;
10581
10582 // Clear timeout if it exists // Clear timeout if it exists
10583 if ( timeoutTimer ) { if ( timeoutTimer ) {
10584 clearTimeout( timeoutTimer ); window.clearTimeout( timeoutTimer );
10585 } }
10586
10587 // Dereference transport for early garbage collection // Dereference transport for early garbage collection
10588 // (no matter how long the jqXHR object will be used) // (no matter how long the jqXHR object will be used)
10589 transport = undefined; transport = undefined;
10590
10591 // Cache response headers // Cache response headers
10592 responseHeadersString = headers || ""; responseHeadersString = headers || "";
10593
10594 // Set readyState // Set readyState
10595 jqXHR.readyState = status > 0 ? 4 : 0; jqXHR.readyState = status > 0 ? 4 : 0;
10596
10597 // Determine if successful // Determine if successful
10598 isSuccess = status >= 200 && status < 300 || status === 304; isSuccess = status >= 200 && status < 300 || status === 304;
10599
10600 // Get response data // Get response data
10601 if ( responses ) { if ( responses ) {
10602 response = ajaxHandleResponses( s, jqXHR, responses ); response = ajaxHandleResponses( s, jqXHR, responses );
10603 } }
10604
10605 // Convert no matter what (that way responseXXX fields are always set) // Convert no matter what (that way responseXXX fields are always set)
10606 response = ajaxConvert( s, response, jqXHR, isSuccess ); response = ajaxConvert( s, response, jqXHR, isSuccess );
10607
10608 // If successful, handle type chaining // If successful, handle type chaining
10609 if ( isSuccess ) { if ( isSuccess ) {
10610
10611 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
10612 if ( s.ifModified ) { if ( s.ifModified ) {
10613 modified = jqXHR.getResponseHeader("Last-Modified"); modified = jqXHR.getResponseHeader( "Last-Modified" );
10614 if ( modified ) { if ( modified ) {
10615 jQuery.lastModified[ cacheURL ] = modified; jQuery.lastModified[ cacheURL ] = modified;
10616 } }
10617 modified = jqXHR.getResponseHeader("etag"); modified = jqXHR.getResponseHeader( "etag" );
10618 if ( modified ) { if ( modified ) {
10619 jQuery.etag[ cacheURL ] = modified; jQuery.etag[ cacheURL ] = modified;
10620 } }
10621 } }
10622
10623 // if no content // if no content
10624 if ( status === 204 || s.type === "HEAD" ) { if ( status === 204 || s.type === "HEAD" ) {
10625 statusText = "nocontent"; statusText = "nocontent";
10626
10627 // if not modified // if not modified
10628 } else if ( status === 304 ) { } else if ( status === 304 ) {
10629 statusText = "notmodified"; statusText = "notmodified";
10630
10631 // If we have data, let's convert it // If we have data, let's convert it
10632 } else { } else {
10633 statusText = response.state; statusText = response.state;
10634 success = response.data; success = response.data;
10635 error = response.error; error = response.error;
10636 isSuccess = !error; isSuccess = !error;
10637 } }
10638 } else { } else {
10639
10640 // We extract error from statusText // We extract error from statusText
10641 // then normalize statusText and status for non-aborts // then normalize statusText and status for non-aborts
10642 error = statusText; error = statusText;
10643 if ( status || !statusText ) { if ( status || !statusText ) {
10644 statusText = "error"; statusText = "error";
10645 if ( status < 0 ) { if ( status < 0 ) {
10646 status = 0; status = 0;
10647 } }
10648 } }
10649 } }
10650
10651 // Set data for the fake xhr object // Set data for the fake xhr object
10652 jqXHR.status = status; jqXHR.status = status;
10653 jqXHR.statusText = ( nativeStatusText || statusText ) + ""; jqXHR.statusText = ( nativeStatusText || statusText ) + "";
10654
10655 // Success/Error // Success/Error
10656 if ( isSuccess ) { if ( isSuccess ) {
10657 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
10658 } else { } else {
10659 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
10660 } }
10661
10662 // Status-dependent callbacks // Status-dependent callbacks
10663 jqXHR.statusCode( statusCode ); jqXHR.statusCode( statusCode );
10664 statusCode = undefined; statusCode = undefined;
10665
10666 if ( fireGlobals ) { if ( fireGlobals ) {
10667 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
10668 [ jqXHR, s, isSuccess ? success : error ] ); [ jqXHR, s, isSuccess ? success : error ] );
10669 } }
10670
10671 // Complete // Complete
10672 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
10673
10674 if ( fireGlobals ) { if ( fireGlobals ) {
10675 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
10676
10677 // Handle the global AJAX counter // Handle the global AJAX counter
10678 if ( !( --jQuery.active ) ) { if ( !( --jQuery.active ) ) {
10679 jQuery.event.trigger("ajaxStop"); jQuery.event.trigger( "ajaxStop" );
10680 } }
10681 } }
10682 } }
10683
10684 return jqXHR; return jqXHR;
10685 }, },
10686
10687 getJSON: function( url, data, callback ) { getJSON: function( url, data, callback ) {
10688 return jQuery.get( url, data, callback, "json" ); return jQuery.get( url, data, callback, "json" );
10689 }, },
10690
10691 getScript: function( url, callback ) { getScript: function( url, callback ) {
10692 return jQuery.get( url, undefined, callback, "script" ); return jQuery.get( url, undefined, callback, "script" );
10693 } }
10694 }); } );
10695
10696 jQuery.each( [ "get", "post" ], function( i, method ) { jQuery.each( [ "get", "post" ], function( i, method ) {
10697 jQuery[ method ] = function( url, data, callback, type ) { jQuery[ method ] = function( url, data, callback, type ) {
10698
10699 // shift arguments if data argument was omitted // shift arguments if data argument was omitted
10700 if ( jQuery.isFunction( data ) ) { if ( jQuery.isFunction( data ) ) {
10701 type = type || callback; type = type || callback;
10702 callback = data; callback = data;
10703 data = undefined; data = undefined;
10704 } }
10705
10706 return jQuery.ajax({ // The url can be an options object (which then must have .url)
10707 return jQuery.ajax( jQuery.extend( {
10708 url: url, url: url,
10709 type: method, type: method,
10710 dataType: type, dataType: type,
10711 data: data, data: data,
10712 success: callback success: callback
10713 }); }, jQuery.isPlainObject( url ) && url ) );
10714 }; };
10715 }); } );
10716
10717
10718 jQuery._evalUrl = function( url ) { jQuery._evalUrl = function( url ) {
10719 return jQuery.ajax({ return jQuery.ajax( {
10720 url: url, url: url,
10721
10722 // Make this explicit, since user can override this through ajaxSetup (#11264)
10723 type: "GET", type: "GET",
10724 dataType: "script", dataType: "script",
10725 cache: true,
10726 async: false, async: false,
10727 global: false, global: false,
10728 "throws": true "throws": true
10729 }); } );
10730 }; };
10731
10732
10733 jQuery.fn.extend({ jQuery.fn.extend( {
10734 wrapAll: function( html ) { wrapAll: function( html ) {
10735 if ( jQuery.isFunction( html ) ) { if ( jQuery.isFunction( html ) ) {
10736 return this.each(function(i) { return this.each( function( i ) {
10737 jQuery(this).wrapAll( html.call(this, i) ); jQuery( this ).wrapAll( html.call( this, i ) );
10738 }); } );
10739 } }
10740
10741 if ( this[0] ) { if ( this[ 0 ] ) {
10742 // The elements to wrap the target around // The elements to wrap the target around
10743 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); var wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
10744
10745 if ( this[0].parentNode ) { if ( this[ 0 ].parentNode ) {
10746 wrap.insertBefore( this[0] ); wrap.insertBefore( this[ 0 ] );
10747 } }
10748
10749 wrap.map(function() { wrap.map( function() {
10750 var elem = this; var elem = this;
10751
10752 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
10753 elem = elem.firstChild; elem = elem.firstChild;
10754 } }
10755
10756 return elem; return elem;
10757 }).append( this ); } ).append( this );
10758 } }
10759
10760 return this; return this;
10761 }, },
10762
10763 wrapInner: function( html ) { wrapInner: function( html ) {
10764 if ( jQuery.isFunction( html ) ) { if ( jQuery.isFunction( html ) ) {
10765 return this.each(function(i) { return this.each( function( i ) {
10766 jQuery(this).wrapInner( html.call(this, i) ); jQuery( this ).wrapInner( html.call( this, i ) );
10767 }); } );
10768 } }
10769
10770 return this.each(function() { return this.each( function() {
10771 var self = jQuery( this ), var self = jQuery( this ),
10772 contents = self.contents(); contents = self.contents();
10773
10774 if ( contents.length ) { if ( contents.length ) {
10775 contents.wrapAll( html ); contents.wrapAll( html );
10776
10777 } else { } else {
10778 self.append( html ); self.append( html );
10779 } }
10780 }); } );
10781 }, },
10782
10783 wrap: function( html ) { wrap: function( html ) {
10784 var isFunction = jQuery.isFunction( html ); var isFunction = jQuery.isFunction( html );
10785
10786 return this.each(function(i) { return this.each( function( i ) {
10787 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
10788 }); } );
10789 }, },
10790
10791 unwrap: function() { unwrap: function() {
10792 return this.parent().each(function() { return this.parent().each( function() {
10793 if ( !jQuery.nodeName( this, "body" ) ) { if ( !jQuery.nodeName( this, "body" ) ) {
10794 jQuery( this ).replaceWith( this.childNodes ); jQuery( this ).replaceWith( this.childNodes );
10795 } }
10796 }).end(); } ).end();
10797 } }
10798 }); } );
10799
10800
10801 function getDisplay( elem ) {
10802 return elem.style && elem.style.display || jQuery.css( elem, "display" );
10803 }
10804
10805 function filterHidden( elem ) {
10806
10807 // Disconnected elements are considered hidden
10808 if ( !jQuery.contains( elem.ownerDocument || document, elem ) ) {
10809 return true;
10810 }
10811 while ( elem && elem.nodeType === 1 ) {
10812 if ( getDisplay( elem ) === "none" || elem.type === "hidden" ) {
10813 return true;
10814 }
10815 elem = elem.parentNode;
10816 }
10817 return false;
10818 }
10819
10820 jQuery.expr.filters.hidden = function( elem ) { jQuery.expr.filters.hidden = function( elem ) {
10821
10822 // Support: Opera <= 12.12 // Support: Opera <= 12.12
10823 // Opera reports offsetWidths and offsetHeights less than zero on some elements // Opera reports offsetWidths and offsetHeights less than zero on some elements
10824 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 || return support.reliableHiddenOffsets() ?
10825 (!support.reliableHiddenOffsets() && ( elem.offsetWidth <= 0 && elem.offsetHeight <= 0 &&
10826 ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none"); !elem.getClientRects().length ) :
10827 filterHidden( elem );
10828 }; };
10829
10830 jQuery.expr.filters.visible = function( elem ) { jQuery.expr.filters.visible = function( elem ) {
10831 return !jQuery.expr.filters.hidden( elem ); return !jQuery.expr.filters.hidden( elem );
10832 }; };
10833
10834
10835
10836
10837 var r20 = /%20/g, var r20 = /%20/g,
10838 rbracket = /\[\]$/, rbracket = /\[\]$/,
10839 rCRLF = /\r?\n/g, rCRLF = /\r?\n/g,
10840 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
10841 rsubmittable = /^(?:input|select|textarea|keygen)/i; rsubmittable = /^(?:input|select|textarea|keygen)/i;
10842
10843 function buildParams( prefix, obj, traditional, add ) { function buildParams( prefix, obj, traditional, add ) {
10844 var name; var name;
10845
10846 if ( jQuery.isArray( obj ) ) { if ( jQuery.isArray( obj ) ) {
10847
10848 // Serialize array item. // Serialize array item.
10849 jQuery.each( obj, function( i, v ) { jQuery.each( obj, function( i, v ) {
10850 if ( traditional || rbracket.test( prefix ) ) { if ( traditional || rbracket.test( prefix ) ) {
10851
10852 // Treat each array item as a scalar. // Treat each array item as a scalar.
10853 add( prefix, v ); add( prefix, v );
10854
10855 } else { } else {
10856
10857 // Item is non-scalar (array or object), encode its numeric index. // Item is non-scalar (array or object), encode its numeric index.
10858 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); buildParams(
10859 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
10860 v,
10861 traditional,
10862 add
10863 );
10864 } }
10865 }); } );
10866
10867 } else if ( !traditional && jQuery.type( obj ) === "object" ) { } else if ( !traditional && jQuery.type( obj ) === "object" ) {
10868
10869 // Serialize object item. // Serialize object item.
10870 for ( name in obj ) { for ( name in obj ) {
10871 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
10872 } }
10873
10874 } else { } else {
10875
10876 // Serialize scalar item. // Serialize scalar item.
10877 add( prefix, obj ); add( prefix, obj );
10878 } }
10879 } }
10880
10881 // Serialize an array of form elements or a set of // Serialize an array of form elements or a set of
10882 // key/values into a query string // key/values into a query string
10883 jQuery.param = function( a, traditional ) { jQuery.param = function( a, traditional ) {
10884 var prefix, var prefix,
10885 s = [], s = [],
10886 add = function( key, value ) { add = function( key, value ) {
10887
10888 // If value is a function, invoke it and return its value // If value is a function, invoke it and return its value
10889 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
10890 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
10891 }; };
10892
10893 // Set traditional to true for jQuery <= 1.3.2 behavior. // Set traditional to true for jQuery <= 1.3.2 behavior.
10894 if ( traditional === undefined ) { if ( traditional === undefined ) {
10895 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
10896 } }
10897
10898 // If an array was passed in, assume that it is an array of form elements. // If an array was passed in, assume that it is an array of form elements.
10899 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
10900
10901 // Serialize the form elements // Serialize the form elements
10902 jQuery.each( a, function() { jQuery.each( a, function() {
10903 add( this.name, this.value ); add( this.name, this.value );
10904 }); } );
10905
10906 } else { } else {
10907
10908 // If traditional, encode the "old" way (the way 1.3.2 or older // If traditional, encode the "old" way (the way 1.3.2 or older
10909 // did it), otherwise encode params recursively. // did it), otherwise encode params recursively.
10910 for ( prefix in a ) { for ( prefix in a ) {
10911 buildParams( prefix, a[ prefix ], traditional, add ); buildParams( prefix, a[ prefix ], traditional, add );
10912 } }
10913 } }
10914
10915 // Return the resulting serialization // Return the resulting serialization
10916 return s.join( "&" ).replace( r20, "+" ); return s.join( "&" ).replace( r20, "+" );
10917 }; };
10918
10919 jQuery.fn.extend({ jQuery.fn.extend( {
10920 serialize: function() { serialize: function() {
10921 return jQuery.param( this.serializeArray() ); return jQuery.param( this.serializeArray() );
10922 }, },
10923 serializeArray: function() { serializeArray: function() {
10924 return this.map(function() { return this.map( function() {
10925 // Can add propHook for "elements" to filter or add form elements // Can add propHook for "elements" to filter or add form elements
10926 var elements = jQuery.prop( this, "elements" ); var elements = jQuery.prop( this, "elements" );
10927 return elements ? jQuery.makeArray( elements ) : this; return elements ? jQuery.makeArray( elements ) : this;
10928 }) } )
10929 .filter(function() { .filter( function() {
10930 var type = this.type; var type = this.type;
10931
10932 // Use .is(":disabled") so that fieldset[disabled] works // Use .is(":disabled") so that fieldset[disabled] works
10933 return this.name && !jQuery( this ).is( ":disabled" ) && return this.name && !jQuery( this ).is( ":disabled" ) &&
10934 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
10935 ( this.checked || !rcheckableType.test( type ) ); ( this.checked || !rcheckableType.test( type ) );
10936 }) } )
10937 .map(function( i, elem ) { .map( function( i, elem ) {
10938 var val = jQuery( this ).val(); var val = jQuery( this ).val();
10939
10940 return val == null ? return val == null ?
10941 null : null :
10942 jQuery.isArray( val ) ? jQuery.isArray( val ) ?
10943 jQuery.map( val, function( val ) { jQuery.map( val, function( val ) {
10944 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
10945 }) : } ) :
10946 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
10947 }).get(); } ).get();
10948 } }
10949 }); } );
10950
10951
10952 // Create the request object // Create the request object
10953 // (This is still attached to ajaxSettings for backward compatibility) // (This is still attached to ajaxSettings for backward compatibility)
10954 jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ? jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
10955 // Support: IE6+
10956 // Support: IE6-IE8
10957 function() { function() {
10958
10959 // XHR cannot access local files, always use ActiveX for that case // XHR cannot access local files, always use ActiveX for that case
10960 return !this.isLocal && if ( this.isLocal ) {
10961 return createActiveXHR();
10962 }
10963
10964 // Support: IE7-8 // Support: IE 9-11
10965 // oldIE XHR does not support non-RFC2616 methods (#13240) // IE seems to error on cross-domain PATCH requests when ActiveX XHR
10966 // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx // is used. In IE 9+ always use the native XHR.
10967 // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9 // Note: this condition won't catch Edge as it doesn't define
10968 // Although this check for six methods instead of eight // document.documentMode but it also doesn't support ActiveX so it won't
10969 // since IE also does not support "trace" and "connect" // reach this code.
10970 /^(get|post|head|put|delete|options)$/i.test( this.type ) && if ( document.documentMode > 8 ) {
10971 return createStandardXHR();
10972 }
10973
10974 // Support: IE<9
10975 // oldIE XHR does not support non-RFC2616 methods (#13240)
10976 // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
10977 // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
10978 // Although this check for six methods instead of eight
10979 // since IE also does not support "trace" and "connect"
10980 return /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
10981 createStandardXHR() || createActiveXHR(); createStandardXHR() || createActiveXHR();
10982 } : } :
10983
10984 // For all other browsers, use the standard XMLHttpRequest object // For all other browsers, use the standard XMLHttpRequest object
10985 createStandardXHR; createStandardXHR;
10986
10987 var xhrId = 0, var xhrId = 0,
10988 xhrCallbacks = {}, xhrCallbacks = {},
10989 xhrSupported = jQuery.ajaxSettings.xhr(); xhrSupported = jQuery.ajaxSettings.xhr();
10990
10991 // Support: IE<10 // Support: IE<10
10992 // Open requests must be manually aborted on unload (#5280) // Open requests must be manually aborted on unload (#5280)
10993 // See https://support.microsoft.com/kb/2856746 for more info // See https://support.microsoft.com/kb/2856746 for more info
10994 if ( window.attachEvent ) { if ( window.attachEvent ) {
10995 window.attachEvent( "onunload", function() { window.attachEvent( "onunload", function() {
10996 for ( var key in xhrCallbacks ) { for ( var key in xhrCallbacks ) {
10997 xhrCallbacks[ key ]( undefined, true ); xhrCallbacks[ key ]( undefined, true );
10998 } }
10999 }); } );
11000 } }
11001
11002 // Determine support properties // Determine support properties
11003 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
11004 xhrSupported = support.ajax = !!xhrSupported; xhrSupported = support.ajax = !!xhrSupported;
11005
11006 // Create transport if the browser can provide an xhr // Create transport if the browser can provide an xhr
11007 if ( xhrSupported ) { if ( xhrSupported ) {
11008
11009 jQuery.ajaxTransport(function( options ) { jQuery.ajaxTransport( function( options ) {
11010 // Cross domain only allowed if supported through XMLHttpRequest // Cross domain only allowed if supported through XMLHttpRequest
11011 if ( !options.crossDomain || support.cors ) { if ( !options.crossDomain || support.cors ) {
11012
11013 var callback; var callback;
11014
11015 return { return {
11016 send: function( headers, complete ) { send: function( headers, complete ) {
11017 var i, var i,
11018 xhr = options.xhr(), xhr = options.xhr(),
11019 id = ++xhrId; id = ++xhrId;
11020
11021 // Open the socket // Open the socket
11022 xhr.open( options.type, options.url, options.async, options.username, options.password ); xhr.open(
11023 options.type,
11024 options.url,
11025 options.async,
11026 options.username,
11027 options.password
11028 );
11029
11030 // Apply custom fields if provided // Apply custom fields if provided
11031 if ( options.xhrFields ) { if ( options.xhrFields ) {
11032 for ( i in options.xhrFields ) { for ( i in options.xhrFields ) {
11033 xhr[ i ] = options.xhrFields[ i ]; xhr[ i ] = options.xhrFields[ i ];
11034 } }
11035 } }
11036
11037 // Override mime type if needed // Override mime type if needed
11038 if ( options.mimeType && xhr.overrideMimeType ) { if ( options.mimeType && xhr.overrideMimeType ) {
11039 xhr.overrideMimeType( options.mimeType ); xhr.overrideMimeType( options.mimeType );
11040 } }
11041
11042 // X-Requested-With header // X-Requested-With header
11043 // For cross-domain requests, seeing as conditions for a preflight are // For cross-domain requests, seeing as conditions for a preflight are
11044 // akin to a jigsaw puzzle, we simply never set it to be sure. // akin to a jigsaw puzzle, we simply never set it to be sure.
11045 // (it can always be set on a per-request basis or even using ajaxSetup) // (it can always be set on a per-request basis or even using ajaxSetup)
11046 // For same-domain requests, won't change header if already provided. // For same-domain requests, won't change header if already provided.
11047 if ( !options.crossDomain && !headers["X-Requested-With"] ) { if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
11048 headers["X-Requested-With"] = "XMLHttpRequest"; headers[ "X-Requested-With" ] = "XMLHttpRequest";
11049 } }
11050
11051 // Set headers // Set headers
11052 for ( i in headers ) { for ( i in headers ) {
11053
11054 // Support: IE<9 // Support: IE<9
11055 // IE's ActiveXObject throws a 'Type Mismatch' exception when setting // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
11056 // request header to a null-value. // request header to a null-value.
11057 // //
11058 // To keep consistent with other XHR implementations, cast the value // To keep consistent with other XHR implementations, cast the value
11059 // to string and ignore `undefined`. // to string and ignore `undefined`.
11060 if ( headers[ i ] !== undefined ) { if ( headers[ i ] !== undefined ) {
11061 xhr.setRequestHeader( i, headers[ i ] + "" ); xhr.setRequestHeader( i, headers[ i ] + "" );
11062 } }
11063 } }
11064
11065 // Do send the request // Do send the request
11066 // This may raise an exception which is actually // This may raise an exception which is actually
11067 // handled in jQuery.ajax (so no try/catch here) // handled in jQuery.ajax (so no try/catch here)
11068 xhr.send( ( options.hasContent && options.data ) || null ); xhr.send( ( options.hasContent && options.data ) || null );
11069
11070 // Listener // Listener
11071 callback = function( _, isAbort ) { callback = function( _, isAbort ) {
11072 var status, statusText, responses; var status, statusText, responses;
11073
11074 // Was never called and is aborted or complete // Was never called and is aborted or complete
11075 if ( callback && ( isAbort || xhr.readyState === 4 ) ) { if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
11076
11077 // Clean up // Clean up
11078 delete xhrCallbacks[ id ]; delete xhrCallbacks[ id ];
11079 callback = undefined; callback = undefined;
11080 xhr.onreadystatechange = jQuery.noop; xhr.onreadystatechange = jQuery.noop;
11081
11082 // Abort manually if needed // Abort manually if needed
11083 if ( isAbort ) { if ( isAbort ) {
11084 if ( xhr.readyState !== 4 ) { if ( xhr.readyState !== 4 ) {
11085 xhr.abort(); xhr.abort();
11086 } }
11087 } else { } else {
11088 responses = {}; responses = {};
11089 status = xhr.status; status = xhr.status;
11090
11091 // Support: IE<10 // Support: IE<10
11092 // Accessing binary-data responseText throws an exception // Accessing binary-data responseText throws an exception
11093 // (#11426) // (#11426)
11094 if ( typeof xhr.responseText === "string" ) { if ( typeof xhr.responseText === "string" ) {
11095 responses.text = xhr.responseText; responses.text = xhr.responseText;
11096 } }
11097
11098 // Firefox throws an exception when accessing // Firefox throws an exception when accessing
11099 // statusText for faulty cross-domain requests // statusText for faulty cross-domain requests
11100 try { try {
11101 statusText = xhr.statusText; statusText = xhr.statusText;
11102 } catch( e ) { } catch ( e ) {
11103 // We normalize with Webkit giving an empty statusText // We normalize with Webkit giving an empty statusText
11104 statusText = ""; statusText = "";
11105 } }
11106
11107 // Filter status for non standard behaviors // Filter status for non standard behaviors
11108
11109 // If the request is local and we have data: assume a success // If the request is local and we have data: assume a success
11110 // (success with no data won't get notified, that's the best we // (success with no data won't get notified, that's the best we
11111 // can do given current implementations) // can do given current implementations)
11112 if ( !status && options.isLocal && !options.crossDomain ) { if ( !status && options.isLocal && !options.crossDomain ) {
11113 status = responses.text ? 200 : 404; status = responses.text ? 200 : 404;
11114
11115 // IE - #1450: sometimes returns 1223 when it should be 204 // IE - #1450: sometimes returns 1223 when it should be 204
11116 } else if ( status === 1223 ) { } else if ( status === 1223 ) {
11117 status = 204; status = 204;
11118 } }
11119 } }
11120 } }
11121
11122 // Call complete if needed // Call complete if needed
11123 if ( responses ) { if ( responses ) {
11124 complete( status, statusText, responses, xhr.getAllResponseHeaders() ); complete( status, statusText, responses, xhr.getAllResponseHeaders() );
11125 } }
11126 }; };
11127
11128 // Do send the request
11129 // `xhr.send` may raise an exception, but it will be
11130 // handled in jQuery.ajax (so no try/catch here)
11131 if ( !options.async ) { if ( !options.async ) {
11132 // if we're in sync mode we fire the callback
11133 // If we're in sync mode we fire the callback
11134 callback(); callback();
11135 } else if ( xhr.readyState === 4 ) { } else if ( xhr.readyState === 4 ) {
11136
11137 // (IE6 & IE7) if it's in cache and has been // (IE6 & IE7) if it's in cache and has been
11138 // retrieved directly we need to fire the callback // retrieved directly we need to fire the callback
11139 setTimeout( callback ); window.setTimeout( callback );
11140 } else { } else {
11141
11142 // Register the callback, but delay it in case `xhr.send` throws
11143 // Add to the list of active xhr callbacks // Add to the list of active xhr callbacks
11144 xhr.onreadystatechange = xhrCallbacks[ id ] = callback; xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
11145 } }
11146 }, },
11147
11148 abort: function() { abort: function() {
11149 if ( callback ) { if ( callback ) {
11150 callback( undefined, true ); callback( undefined, true );
11151 } }
11152 } }
11153 }; };
11154 } }
11155 }); } );
11156 } }
11157
11158 // Functions to create xhrs // Functions to create xhrs
11159 function createStandardXHR() { function createStandardXHR() {
11160 try { try {
11161 return new window.XMLHttpRequest(); return new window.XMLHttpRequest();
11162 } catch( e ) {} } catch ( e ) {}
11163 } }
11164
11165 function createActiveXHR() { function createActiveXHR() {
11166 try { try {
11167 return new window.ActiveXObject( "Microsoft.XMLHTTP" ); return new window.ActiveXObject( "Microsoft.XMLHTTP" );
11168 } catch( e ) {} } catch ( e ) {}
11169 } }
11170
11171
11172
11173
11174 // Install script dataType // Install script dataType
11175 jQuery.ajaxSetup({ jQuery.ajaxSetup( {
11176 accepts: { accepts: {
11177 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" script: "text/javascript, application/javascript, " +
11178 "application/ecmascript, application/x-ecmascript"
11179 }, },
11180 contents: { contents: {
11181 script: /(?:java|ecma)script/ script: /\b(?:java|ecma)script\b/
11182 }, },
11183 converters: { converters: {
11184 "text script": function( text ) { "text script": function( text ) {
11185 jQuery.globalEval( text ); jQuery.globalEval( text );
11186 return text; return text;
11187 } }
11188 } }
11189 }); } );
11190
11191 // Handle cache's special case and global // Handle cache's special case and global
11192 jQuery.ajaxPrefilter( "script", function( s ) { jQuery.ajaxPrefilter( "script", function( s ) {
11193 if ( s.cache === undefined ) { if ( s.cache === undefined ) {
11194 s.cache = false; s.cache = false;
11195 } }
11196 if ( s.crossDomain ) { if ( s.crossDomain ) {
11197 s.type = "GET"; s.type = "GET";
11198 s.global = false; s.global = false;
11199 } }
11200 }); } );
11201
11202 // Bind script tag hack transport // Bind script tag hack transport
11203 jQuery.ajaxTransport( "script", function(s) { jQuery.ajaxTransport( "script", function( s ) {
11204
11205 // This transport only deals with cross domain requests // This transport only deals with cross domain requests
11206 if ( s.crossDomain ) { if ( s.crossDomain ) {
11207
11208 var script, var script,
11209 head = document.head || jQuery("head")[0] || document.documentElement; head = document.head || jQuery( "head" )[ 0 ] || document.documentElement;
11210
11211 return { return {
11212
11213 send: function( _, callback ) { send: function( _, callback ) {
11214
11215 script = document.createElement("script"); script = document.createElement( "script" );
11216
11217 script.async = true; script.async = true;
11218
11219 if ( s.scriptCharset ) { if ( s.scriptCharset ) {
11220 script.charset = s.scriptCharset; script.charset = s.scriptCharset;
11221 } }
11222
11223 script.src = s.url; script.src = s.url;
11224
11225 // Attach handlers for all browsers // Attach handlers for all browsers
11226 script.onload = script.onreadystatechange = function( _, isAbort ) { script.onload = script.onreadystatechange = function( _, isAbort ) {
11227
11228 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
11229
11230 // Handle memory leak in IE // Handle memory leak in IE
11231 script.onload = script.onreadystatechange = null; script.onload = script.onreadystatechange = null;
11232
11233 // Remove the script // Remove the script
11234 if ( script.parentNode ) { if ( script.parentNode ) {
11235 script.parentNode.removeChild( script ); script.parentNode.removeChild( script );
11236 } }
11237
11238 // Dereference the script // Dereference the script
11239 script = null; script = null;
11240
11241 // Callback if not abort // Callback if not abort
11242 if ( !isAbort ) { if ( !isAbort ) {
11243 callback( 200, "success" ); callback( 200, "success" );
11244 } }
11245 } }
11246 }; };
11247
11248 // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
11249 // Use native DOM manipulation to avoid our domManip AJAX trickery // Use native DOM manipulation to avoid our domManip AJAX trickery
11250 head.insertBefore( script, head.firstChild ); head.insertBefore( script, head.firstChild );
11251 }, },
11252
11253 abort: function() { abort: function() {
11254 if ( script ) { if ( script ) {
11255 script.onload( undefined, true ); script.onload( undefined, true );
11256 } }
11257 } }
11258 }; };
11259 } }
11260 }); } );
11261
11262
11263
11264
11265 var oldCallbacks = [], var oldCallbacks = [],
11266 rjsonp = /(=)\?(?=&|$)|\?\?/; rjsonp = /(=)\?(?=&|$)|\?\?/;
11267
11268 // Default jsonp settings // Default jsonp settings
11269 jQuery.ajaxSetup({ jQuery.ajaxSetup( {
11270 jsonp: "callback", jsonp: "callback",
11271 jsonpCallback: function() { jsonpCallback: function() {
11272 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
11273 this[ callback ] = true; this[ callback ] = true;
11274 return callback; return callback;
11275 } }
11276 }); } );
11277
11278 // Detect, normalize options and install callbacks for jsonp requests // Detect, normalize options and install callbacks for jsonp requests
11279 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
11280
11281 var callbackName, overwritten, responseContainer, var callbackName, overwritten, responseContainer,
11282 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
11283 "url" : "url" :
11284 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" typeof s.data === "string" &&
11285 ( s.contentType || "" )
11286 .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
11287 rjsonp.test( s.data ) && "data"
11288 ); );
11289
11290 // Handle iff the expected data type is "jsonp" or we have a parameter to set // Handle iff the expected data type is "jsonp" or we have a parameter to set
11291 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
11292
11293 // Get callback name, remembering preexisting value associated with it // Get callback name, remembering preexisting value associated with it
11294 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
11295 s.jsonpCallback() : s.jsonpCallback() :
11296 s.jsonpCallback; s.jsonpCallback;
11297
11298 // Insert callback into url or form data // Insert callback into url or form data
11299 if ( jsonProp ) { if ( jsonProp ) {
11300 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
11301 } else if ( s.jsonp !== false ) { } else if ( s.jsonp !== false ) {
11302 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
11303 } }
11304
11305 // Use data converter to retrieve json after script execution // Use data converter to retrieve json after script execution
11306 s.converters["script json"] = function() { s.converters[ "script json" ] = function() {
11307 if ( !responseContainer ) { if ( !responseContainer ) {
11308 jQuery.error( callbackName + " was not called" ); jQuery.error( callbackName + " was not called" );
11309 } }
11310 return responseContainer[ 0 ]; return responseContainer[ 0 ];
11311 }; };
11312
11313 // force json dataType // force json dataType
11314 s.dataTypes[ 0 ] = "json"; s.dataTypes[ 0 ] = "json";
11315
11316 // Install callback // Install callback
11317 overwritten = window[ callbackName ]; overwritten = window[ callbackName ];
11318 window[ callbackName ] = function() { window[ callbackName ] = function() {
11319 responseContainer = arguments; responseContainer = arguments;
11320 }; };
11321
11322 // Clean-up function (fires after converters) // Clean-up function (fires after converters)
11323 jqXHR.always(function() { jqXHR.always( function() {
11324 // Restore preexisting value
11325 window[ callbackName ] = overwritten;
11326
11327 // If previous value didn't exist - remove it
11328 if ( overwritten === undefined ) {
11329 jQuery( window ).removeProp( callbackName );
11330
11331 // Otherwise restore preexisting value
11332 } else {
11333 window[ callbackName ] = overwritten;
11334 }
11335
11336 // Save back as free // Save back as free
11337 if ( s[ callbackName ] ) { if ( s[ callbackName ] ) {
11338
11339 // make sure that re-using the options doesn't screw things around // make sure that re-using the options doesn't screw things around
11340 s.jsonpCallback = originalSettings.jsonpCallback; s.jsonpCallback = originalSettings.jsonpCallback;
11341
11342 // save the callback name for future use // save the callback name for future use
11343 oldCallbacks.push( callbackName ); oldCallbacks.push( callbackName );
11344 } }
11345
11346 // Call if it was a function and we have a response // Call if it was a function and we have a response
11347 if ( responseContainer && jQuery.isFunction( overwritten ) ) { if ( responseContainer && jQuery.isFunction( overwritten ) ) {
11348 overwritten( responseContainer[ 0 ] ); overwritten( responseContainer[ 0 ] );
11349 } }
11350
11351 responseContainer = overwritten = undefined; responseContainer = overwritten = undefined;
11352 }); } );
11353
11354 // Delegate to script // Delegate to script
11355 return "script"; return "script";
11356 } }
11357 }); } );
11358
11359
11360
11361
11362 // data: string of html // data: string of html
11363 // context (optional): If specified, the fragment will be created in this context, defaults to document // context (optional): If specified, the fragment will be created in this context,
11364 // defaults to document
11365 // keepScripts (optional): If true, will include scripts passed in the html string // keepScripts (optional): If true, will include scripts passed in the html string
11366 jQuery.parseHTML = function( data, context, keepScripts ) { jQuery.parseHTML = function( data, context, keepScripts ) {
11367 if ( !data || typeof data !== "string" ) { if ( !data || typeof data !== "string" ) {
11368 return null; return null;
11369 } }
11370 if ( typeof context === "boolean" ) { if ( typeof context === "boolean" ) {
11371 keepScripts = context; keepScripts = context;
11372 context = false; context = false;
11373 } }
11374 context = context || document; context = context || document;
11375
11376 var parsed = rsingleTag.exec( data ), var parsed = rsingleTag.exec( data ),
11377 scripts = !keepScripts && []; scripts = !keepScripts && [];
11378
11379 // Single tag // Single tag
11380 if ( parsed ) { if ( parsed ) {
11381 return [ context.createElement( parsed[1] ) ]; return [ context.createElement( parsed[ 1 ] ) ];
11382 } }
11383
11384 parsed = jQuery.buildFragment( [ data ], context, scripts ); parsed = buildFragment( [ data ], context, scripts );
11385
11386 if ( scripts && scripts.length ) { if ( scripts && scripts.length ) {
11387 jQuery( scripts ).remove(); jQuery( scripts ).remove();
11388 } }
11389
11390 return jQuery.merge( [], parsed.childNodes ); return jQuery.merge( [], parsed.childNodes );
11391 }; };
11392
11393
11394 // Keep a copy of the old load method // Keep a copy of the old load method
11395 var _load = jQuery.fn.load; var _load = jQuery.fn.load;
11396
11397 /** /**
11398 * Load a url into a page * Load a url into a page
11399 */ */
11400 jQuery.fn.load = function( url, params, callback ) { jQuery.fn.load = function( url, params, callback ) {
11401 if ( typeof url !== "string" && _load ) { if ( typeof url !== "string" && _load ) {
11402 return _load.apply( this, arguments ); return _load.apply( this, arguments );
11403 } }
11404
11405 var selector, response, type, var selector, type, response,
11406 self = this, self = this,
11407 off = url.indexOf(" "); off = url.indexOf( " " );
11408
11409 if ( off >= 0 ) { if ( off > -1 ) {
11410 selector = jQuery.trim( url.slice( off, url.length ) ); selector = jQuery.trim( url.slice( off, url.length ) );
11411 url = url.slice( 0, off ); url = url.slice( 0, off );
11412 } }
11413
11414 // If it's a function // If it's a function
11415 if ( jQuery.isFunction( params ) ) { if ( jQuery.isFunction( params ) ) {
11416
11417 // We assume that it's the callback // We assume that it's the callback
11418 callback = params; callback = params;
11419 params = undefined; params = undefined;
11420
11421 // Otherwise, build a param string // Otherwise, build a param string
11422 } else if ( params && typeof params === "object" ) { } else if ( params && typeof params === "object" ) {
11423 type = "POST"; type = "POST";
11424 } }
11425
11426 // If we have elements to modify, make the request // If we have elements to modify, make the request
11427 if ( self.length > 0 ) { if ( self.length > 0 ) {
11428 jQuery.ajax({ jQuery.ajax( {
11429 url: url, url: url,
11430
11431 // if "type" variable is undefined, then "GET" method will be used // If "type" variable is undefined, then "GET" method will be used.
11432 type: type, // Make value of this field explicit since
11433 // user can override it through ajaxSetup method
11434 type: type || "GET",
11435 dataType: "html", dataType: "html",
11436 data: params data: params
11437 }).done(function( responseText ) { } ).done( function( responseText ) {
11438
11439 // Save response for use in complete callback // Save response for use in complete callback
11440 response = arguments; response = arguments;
11441
11442 self.html( selector ? self.html( selector ?
11443
11444 // If a selector was specified, locate the right elements in a dummy div // If a selector was specified, locate the right elements in a dummy div
11445 // Exclude scripts to avoid IE 'Permission Denied' errors // Exclude scripts to avoid IE 'Permission Denied' errors
11446 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) : jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
11447
11448 // Otherwise use the full result // Otherwise use the full result
11449 responseText ); responseText );
11450
11451 }).complete( callback && function( jqXHR, status ) { // If the request succeeds, this function gets "data", "status", "jqXHR"
11452 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); // but they are ignored because response was set above.
11453 }); // If it fails, this function gets "jqXHR", "status", "error"
11454 } ).always( callback && function( jqXHR, status ) {
11455 self.each( function() {
11456 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
11457 } );
11458 } );
11459 } }
11460
11461 return this; return this;
11462 }; };
11463
11464
11465
11466
11467 // Attach a bunch of functions for handling common AJAX events // Attach a bunch of functions for handling common AJAX events
11468 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) { jQuery.each( [
11469 "ajaxStart",
11470 "ajaxStop",
11471 "ajaxComplete",
11472 "ajaxError",
11473 "ajaxSuccess",
11474 "ajaxSend"
11475 ], function( i, type ) {
11476 jQuery.fn[ type ] = function( fn ) { jQuery.fn[ type ] = function( fn ) {
11477 return this.on( type, fn ); return this.on( type, fn );
11478 }; };
11479 }); } );
11480
11481
11482
11483
11484 jQuery.expr.filters.animated = function( elem ) { jQuery.expr.filters.animated = function( elem ) {
11485 return jQuery.grep(jQuery.timers, function( fn ) { return jQuery.grep( jQuery.timers, function( fn ) {
11486 return elem === fn.elem; return elem === fn.elem;
11487 }).length; } ).length;
11488 }; };
11489
11490
11491
11492
11493
11494 var docElem = window.document.documentElement;
11495
11496 /** /**
11497 * Gets a window from an element * Gets a window from an element
11498 */ */
11499 function getWindow( elem ) { function getWindow( elem ) {
11500 return jQuery.isWindow( elem ) ? return jQuery.isWindow( elem ) ?
11501 elem : elem :
11502 elem.nodeType === 9 ? elem.nodeType === 9 ?
11503 elem.defaultView || elem.parentWindow : elem.defaultView || elem.parentWindow :
11504 false; false;
11505 } }
11506
11507 jQuery.offset = { jQuery.offset = {
11508 setOffset: function( elem, options, i ) { setOffset: function( elem, options, i ) {
11509 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
11510 position = jQuery.css( elem, "position" ), position = jQuery.css( elem, "position" ),
11511 curElem = jQuery( elem ), curElem = jQuery( elem ),
11512 props = {}; props = {};
11513
11514 // set position first, in-case top/left are set even on static elem // set position first, in-case top/left are set even on static elem
11515 if ( position === "static" ) { if ( position === "static" ) {
11516 elem.style.position = "relative"; elem.style.position = "relative";
11517 } }
11518
11519 curOffset = curElem.offset(); curOffset = curElem.offset();
11520 curCSSTop = jQuery.css( elem, "top" ); curCSSTop = jQuery.css( elem, "top" );
11521 curCSSLeft = jQuery.css( elem, "left" ); curCSSLeft = jQuery.css( elem, "left" );
11522 calculatePosition = ( position === "absolute" || position === "fixed" ) && calculatePosition = ( position === "absolute" || position === "fixed" ) &&
11523 jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1; jQuery.inArray( "auto", [ curCSSTop, curCSSLeft ] ) > -1;
11524
11525 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed // need to be able to calculate position if either top or left
11526 // is auto and position is either absolute or fixed
11527 if ( calculatePosition ) { if ( calculatePosition ) {
11528 curPosition = curElem.position(); curPosition = curElem.position();
11529 curTop = curPosition.top; curTop = curPosition.top;
11530 curLeft = curPosition.left; curLeft = curPosition.left;
11531 } else { } else {
11532 curTop = parseFloat( curCSSTop ) || 0; curTop = parseFloat( curCSSTop ) || 0;
11533 curLeft = parseFloat( curCSSLeft ) || 0; curLeft = parseFloat( curCSSLeft ) || 0;
11534 } }
11535
11536 if ( jQuery.isFunction( options ) ) { if ( jQuery.isFunction( options ) ) {
11537 options = options.call( elem, i, curOffset );
11538 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
11539 options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
11540 } }
11541
11542 if ( options.top != null ) { if ( options.top != null ) {
11543 props.top = ( options.top - curOffset.top ) + curTop; props.top = ( options.top - curOffset.top ) + curTop;
11544 } }
11545 if ( options.left != null ) { if ( options.left != null ) {
11546 props.left = ( options.left - curOffset.left ) + curLeft; props.left = ( options.left - curOffset.left ) + curLeft;
11547 } }
11548
11549 if ( "using" in options ) { if ( "using" in options ) {
11550 options.using.call( elem, props ); options.using.call( elem, props );
11551 } else { } else {
11552 curElem.css( props ); curElem.css( props );
11553 } }
11554 } }
11555 }; };
11556
11557 jQuery.fn.extend({ jQuery.fn.extend( {
11558 offset: function( options ) { offset: function( options ) {
11559 if ( arguments.length ) { if ( arguments.length ) {
11560 return options === undefined ? return options === undefined ?
11561 this : this :
11562 this.each(function( i ) { this.each( function( i ) {
11563 jQuery.offset.setOffset( this, options, i ); jQuery.offset.setOffset( this, options, i );
11564 }); } );
11565 } }
11566
11567 var docElem, win, var docElem, win,
11568 box = { top: 0, left: 0 }, box = { top: 0, left: 0 },
11569 elem = this[ 0 ], elem = this[ 0 ],
11570 doc = elem && elem.ownerDocument; doc = elem && elem.ownerDocument;
11571
11572 if ( !doc ) { if ( !doc ) {
11573 return; return;
11574 } }
11575
11576 docElem = doc.documentElement; docElem = doc.documentElement;
11577
11578 // Make sure it's not a disconnected DOM node // Make sure it's not a disconnected DOM node
11579 if ( !jQuery.contains( docElem, elem ) ) { if ( !jQuery.contains( docElem, elem ) ) {
11580 return box; return box;
11581 } }
11582
11583 // If we don't have gBCR, just use 0,0 rather than error // If we don't have gBCR, just use 0,0 rather than error
11584 // BlackBerry 5, iOS 3 (original iPhone) // BlackBerry 5, iOS 3 (original iPhone)
11585 if ( typeof elem.getBoundingClientRect !== strundefined ) { if ( typeof elem.getBoundingClientRect !== "undefined" ) {
11586 box = elem.getBoundingClientRect(); box = elem.getBoundingClientRect();
11587 } }
11588 win = getWindow( doc ); win = getWindow( doc );
11589 return { return {
11590 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ), top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
11591 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 ) left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
11592 }; };
11593 }, },
11594
11595 position: function() { position: function() {
11596 if ( !this[ 0 ] ) { if ( !this[ 0 ] ) {
11597 return; return;
11598 } }
11599
11600 var offsetParent, offset, var offsetParent, offset,
11601 parentOffset = { top: 0, left: 0 }, parentOffset = { top: 0, left: 0 },
11602 elem = this[ 0 ]; elem = this[ 0 ];
11603
11604 // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
11605 // because it is its only offset parent
11606 if ( jQuery.css( elem, "position" ) === "fixed" ) { if ( jQuery.css( elem, "position" ) === "fixed" ) {
11607
11608 // we assume that getBoundingClientRect is available when computed position is fixed // we assume that getBoundingClientRect is available when computed position is fixed
11609 offset = elem.getBoundingClientRect(); offset = elem.getBoundingClientRect();
11610 } else { } else {
11611
11612 // Get *real* offsetParent // Get *real* offsetParent
11613 offsetParent = this.offsetParent(); offsetParent = this.offsetParent();
11614
11615 // Get correct offsets // Get correct offsets
11616 offset = this.offset(); offset = this.offset();
11617 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
11618 parentOffset = offsetParent.offset(); parentOffset = offsetParent.offset();
11619 } }
11620
11621 // Add offsetParent borders // Add offsetParent borders
11622 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ); parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
11623 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ); parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
11624 } }
11625
11626 // Subtract parent offsets and element margins // Subtract parent offsets and element margins
11627 // note: when an element has margin: auto the offsetLeft and marginLeft // note: when an element has margin: auto the offsetLeft and marginLeft
11628 // are the same in Safari causing offset.left to incorrectly be 0 // are the same in Safari causing offset.left to incorrectly be 0
11629 return { return {
11630 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
11631 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true) left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
11632 }; };
11633 }, },
11634
11635 offsetParent: function() { offsetParent: function() {
11636 return this.map(function() { return this.map( function() {
11637 var offsetParent = this.offsetParent || docElem; var offsetParent = this.offsetParent;
11638
11639 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) { while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) &&
11640 jQuery.css( offsetParent, "position" ) === "static" ) ) {
11641 offsetParent = offsetParent.offsetParent; offsetParent = offsetParent.offsetParent;
11642 } }
11643 return offsetParent || docElem; return offsetParent || documentElement;
11644 }); } );
11645 } }
11646 }); } );
11647
11648 // Create scrollLeft and scrollTop methods // Create scrollLeft and scrollTop methods
11649 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
11650 var top = /Y/.test( prop ); var top = /Y/.test( prop );
11651
11652 jQuery.fn[ method ] = function( val ) { jQuery.fn[ method ] = function( val ) {
11653 return access( this, function( elem, method, val ) { return access( this, function( elem, method, val ) {
11654 var win = getWindow( elem ); var win = getWindow( elem );
11655
11656 if ( val === undefined ) { if ( val === undefined ) {
11657 return win ? (prop in win) ? win[ prop ] : return win ? ( prop in win ) ? win[ prop ] :
11658 win.document.documentElement[ method ] : win.document.documentElement[ method ] :
11659 elem[ method ]; elem[ method ];
11660 } }
11661
11662 if ( win ) { if ( win ) {
11663 win.scrollTo( win.scrollTo(
11664 !top ? val : jQuery( win ).scrollLeft(), !top ? val : jQuery( win ).scrollLeft(),
11665 top ? val : jQuery( win ).scrollTop() top ? val : jQuery( win ).scrollTop()
11666 ); );
11667
11668 } else { } else {
11669 elem[ method ] = val; elem[ method ] = val;
11670 } }
11671 }, method, val, arguments.length, null ); }, method, val, arguments.length, null );
11672 }; };
11673 }); } );
11674
11675 // Support: Safari<7-8+, Chrome<37-44+
11676 // Add the top/left cssHooks using jQuery.fn.position // Add the top/left cssHooks using jQuery.fn.position
11677 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
11678 // getComputedStyle returns percent when specified for top/left/bottom/right // getComputedStyle returns percent when specified for top/left/bottom/right
11679 // rather than make the css module depend on the offset module, we just check for it here // rather than make the css module depend on the offset module, we just check for it here
11680 jQuery.each( [ "top", "left" ], function( i, prop ) { jQuery.each( [ "top", "left" ], function( i, prop ) {
11681 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
11682 function( elem, computed ) { function( elem, computed ) {
11683 if ( computed ) { if ( computed ) {
11684 computed = curCSS( elem, prop ); computed = curCSS( elem, prop );
11685
11686 // if curCSS returns percentage, fallback to offset // if curCSS returns percentage, fallback to offset
11687 return rnumnonpx.test( computed ) ? return rnumnonpx.test( computed ) ?
11688 jQuery( elem ).position()[ prop ] + "px" : jQuery( elem ).position()[ prop ] + "px" :
11689 computed; computed;
11690 } }
11691 } }
11692 ); );
11693 }); } );
11694
11695
11696 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
11697 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
11698 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
11699 function( defaultExtra, funcName ) {
11700 // margin is only for outerHeight, outerWidth // margin is only for outerHeight, outerWidth
11701 jQuery.fn[ funcName ] = function( margin, value ) { jQuery.fn[ funcName ] = function( margin, value ) {
11702 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
11703 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
11704
11705 return access( this, function( elem, type, value ) { return access( this, function( elem, type, value ) {
11706 var doc; var doc;
11707
11708 if ( jQuery.isWindow( elem ) ) { if ( jQuery.isWindow( elem ) ) {
11709
11710 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
11711 // isn't a whole lot we can do. See pull request at this URL for discussion: // isn't a whole lot we can do. See pull request at this URL for discussion:
11712 // https://github.com/jquery/jquery/pull/764 // https://github.com/jquery/jquery/pull/764
11713 return elem.document.documentElement[ "client" + name ]; return elem.document.documentElement[ "client" + name ];
11714 } }
11715
11716 // Get document width or height // Get document width or height
11717 if ( elem.nodeType === 9 ) { if ( elem.nodeType === 9 ) {
11718 doc = elem.documentElement; doc = elem.documentElement;
11719
11720 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
11721 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it. // whichever is greatest
11722 // unfortunately, this causes bug #3838 in IE6/8 only,
11723 // but there is currently no good, small way to fix it.
11724 return Math.max( return Math.max(
11725 elem.body[ "scroll" + name ], doc[ "scroll" + name ], elem.body[ "scroll" + name ], doc[ "scroll" + name ],
11726 elem.body[ "offset" + name ], doc[ "offset" + name ], elem.body[ "offset" + name ], doc[ "offset" + name ],
11727 doc[ "client" + name ] doc[ "client" + name ]
11728 ); );
11729 } }
11730
11731 return value === undefined ? return value === undefined ?
11732
11733 // Get width or height on the element, requesting but not forcing parseFloat // Get width or height on the element, requesting but not forcing parseFloat
11734 jQuery.css( elem, type, extra ) : jQuery.css( elem, type, extra ) :
11735
11736 // Set width or height on the element // Set width or height on the element
11737 jQuery.style( elem, type, value, extra ); jQuery.style( elem, type, value, extra );
11738 }, type, chainable ? margin : undefined, chainable, null ); }, type, chainable ? margin : undefined, chainable, null );
11739 }; };
11740 }); } );
11741 }); } );
11742
11743
11744 jQuery.fn.extend( {
11745
11746 bind: function( types, data, fn ) {
11747 return this.on( types, null, data, fn );
11748 },
11749 unbind: function( types, fn ) {
11750 return this.off( types, null, fn );
11751 },
11752
11753 delegate: function( selector, types, data, fn ) {
11754 return this.on( types, selector, data, fn );
11755 },
11756 undelegate: function( selector, types, fn ) {
11757
11758 // ( namespace ) or ( selector, types [, fn] )
11759 return arguments.length === 1 ?
11760 this.off( selector, "**" ) :
11761 this.off( types, selector || "**", fn );
11762 }
11763 } );
11764
11765 // The number of elements contained in the matched element set // The number of elements contained in the matched element set
11766 jQuery.fn.size = function() { jQuery.fn.size = function() {
11767 return this.length; return this.length;
11768 }; };
11769
11770 jQuery.fn.andSelf = jQuery.fn.addBack; jQuery.fn.andSelf = jQuery.fn.addBack;
11771
11772
11773
11774
11775 // Register as a named AMD module, since jQuery can be concatenated with other // Register as a named AMD module, since jQuery can be concatenated with other
11776 // files that may use define, but not via a proper concatenation script that // files that may use define, but not via a proper concatenation script that
11777 // understands anonymous AMD modules. A named AMD is safest and most robust // understands anonymous AMD modules. A named AMD is safest and most robust
11778 // way to register. Lowercase jquery is used because AMD module names are // way to register. Lowercase jquery is used because AMD module names are
11779 // derived from file names, and jQuery is normally delivered in a lowercase // derived from file names, and jQuery is normally delivered in a lowercase
11780 // file name. Do this after creating the global so that if an AMD module wants // file name. Do this after creating the global so that if an AMD module wants
11781 // to call noConflict to hide this version of jQuery, it will work. // to call noConflict to hide this version of jQuery, it will work.
11782
11783 // Note that for maximum portability, libraries that are not jQuery should // Note that for maximum portability, libraries that are not jQuery should
11784 // declare themselves as anonymous modules, and avoid setting a global if an // declare themselves as anonymous modules, and avoid setting a global if an
11785 // AMD loader is present. jQuery is a special case. For more information, see // AMD loader is present. jQuery is a special case. For more information, see
11786 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
11787
11788 if ( typeof define === "function" && define.amd ) { if ( typeof define === "function" && define.amd ) {
11789 define( "jquery", [], function() { define( "jquery", [], function() {
11790 return jQuery; return jQuery;
11791 }); } );
11792 } }
11793
11794
11795
11796
11797 var var
11798
11799 // Map over jQuery in case of overwrite // Map over jQuery in case of overwrite
11800 _jQuery = window.jQuery, _jQuery = window.jQuery,
11801
11802 // Map over the $ in case of overwrite // Map over the $ in case of overwrite
11803 _$ = window.$; _$ = window.$;
11804
11805 jQuery.noConflict = function( deep ) { jQuery.noConflict = function( deep ) {
11806 if ( window.$ === jQuery ) { if ( window.$ === jQuery ) {
11807 window.$ = _$; window.$ = _$;
11808 } }
11809
11810 if ( deep && window.jQuery === jQuery ) { if ( deep && window.jQuery === jQuery ) {
11811 window.jQuery = _jQuery; window.jQuery = _jQuery;
11812 } }
11813
11814 return jQuery; return jQuery;
11815 }; };
11816
11817 // Expose jQuery and $ identifiers, even in // Expose jQuery and $ identifiers, even in
11818 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557) // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
11819 // and CommonJS for browser emulators (#13566) // and CommonJS for browser emulators (#13566)
11820 if ( typeof noGlobal === strundefined ) { if ( !noGlobal ) {
11821 window.jQuery = window.$ = jQuery; window.jQuery = window.$ = jQuery;
11822 } }
11823
11824
11825
11826
11827 return jQuery; return jQuery;
11828
11829 })); }));