2
* jQuery JavaScript Library v1.8.3
2
* jQuery JavaScript Library v1.9.1
6
6
* http://sizzlejs.com/
8
* Copyright 2012 jQuery Foundation and other contributors
8
* Copyright 2005, 2012 jQuery Foundation, Inc. and other contributors
9
9
* Released under the MIT license
10
10
* http://jquery.org/license
12
* Date: Tue Nov 13 2012 08:20:33 GMT-0500 (Eastern Standard Time)
14
14
(function( window, undefined ) {
16
// Can't do this because several apps including ASP.NET trace
17
// the stack via arguments.caller.callee and Firefox dies if
18
// you try to trace through "use strict" call chains. (#13335)
19
// Support: Firefox 18+
16
// A central reference to the root jQuery(document)
19
// The deferred used on DOM ready
22
// Use the correct document accordingly with window argument (sandbox)
23
document = window.document,
24
location = window.location,
25
navigator = window.navigator,
27
// Map over jQuery in case of overwrite
28
_jQuery = window.jQuery,
30
// Map over the $ in case of overwrite
33
// Save a reference to some core methods
34
core_push = Array.prototype.push,
35
core_slice = Array.prototype.slice,
36
core_indexOf = Array.prototype.indexOf,
37
core_toString = Object.prototype.toString,
38
core_hasOwn = Object.prototype.hasOwnProperty,
39
core_trim = String.prototype.trim,
41
// Define a local copy of jQuery
42
jQuery = function( selector, context ) {
43
// The jQuery object is actually just the init constructor 'enhanced'
44
return new jQuery.fn.init( selector, context, rootjQuery );
47
// Used for matching numbers
48
core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,
50
// Used for detecting and trimming whitespace
51
core_rnotwhite = /\S/,
54
// Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
55
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
57
// A simple way to check for HTML strings
58
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
59
rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
61
// Match a standalone tag
62
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
65
rvalidchars = /^[\],:{}\s]*$/,
66
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
67
rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
68
rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,
70
// Matches dashed string for camelizing
72
rdashAlpha = /-([\da-z])/gi,
74
// Used by jQuery.camelCase as callback to replace()
75
fcamelCase = function( all, letter ) {
76
return ( letter + "" ).toUpperCase();
79
// The ready event handler and self cleanup method
80
DOMContentLoaded = function() {
81
if ( document.addEventListener ) {
82
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
84
} else if ( document.readyState === "complete" ) {
85
// we're here because readyState === "complete" in oldIE
86
// which is good enough for us to call the dom ready!
87
document.detachEvent( "onreadystatechange", DOMContentLoaded );
92
// [[Class]] -> type pairs
22
// The deferred used on DOM ready
25
// A central reference to the root jQuery(document)
29
// For `typeof node.method` instead of `node.method !== undefined`
30
core_strundefined = typeof undefined,
32
// Use the correct document accordingly with window argument (sandbox)
33
document = window.document,
34
location = window.location,
36
// Map over jQuery in case of overwrite
37
_jQuery = window.jQuery,
39
// Map over the $ in case of overwrite
42
// [[Class]] -> type pairs
45
// List of deleted data cache ids, so we can reuse them
48
core_version = "1.9.1",
50
// Save a reference to some core methods
51
core_concat = core_deletedIds.concat,
52
core_push = core_deletedIds.push,
53
core_slice = core_deletedIds.slice,
54
core_indexOf = core_deletedIds.indexOf,
55
core_toString = class2type.toString,
56
core_hasOwn = class2type.hasOwnProperty,
57
core_trim = core_version.trim,
59
// Define a local copy of jQuery
60
jQuery = function( selector, context ) {
61
// The jQuery object is actually just the init constructor 'enhanced'
62
return new jQuery.fn.init( selector, context, rootjQuery );
65
// Used for matching numbers
66
core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,
68
// Used for splitting on whitespace
69
core_rnotwhite = /\S+/g,
71
// Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
72
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
74
// A simple way to check for HTML strings
75
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
76
// Strict HTML recognition (#11290: must start with <)
77
rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,
79
// Match a standalone tag
80
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
83
rvalidchars = /^[\],:{}\s]*$/,
84
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
85
rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
86
rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,
88
// Matches dashed string for camelizing
90
rdashAlpha = /-([\da-z])/gi,
92
// Used by jQuery.camelCase as callback to replace()
93
fcamelCase = function( all, letter ) {
94
return letter.toUpperCase();
97
// The ready event handler
98
completed = function( event ) {
100
// readyState === "complete" is good enough for us to call the dom ready in oldIE
101
if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
106
// Clean-up method for dom ready events
107
detach = function() {
108
if ( document.addEventListener ) {
109
document.removeEventListener( "DOMContentLoaded", completed, false );
110
window.removeEventListener( "load", completed, false );
113
document.detachEvent( "onreadystatechange", completed );
114
window.detachEvent( "onload", completed );
95
118
jQuery.fn = jQuery.prototype = {
97
init: function( selector, context, rootjQuery ) {
98
var match, elem, ret, doc;
100
// Handle $(""), $(null), $(undefined), $(false)
105
// Handle $(DOMElement)
106
if ( selector.nodeType ) {
107
this.context = this[0] = selector;
112
// Handle HTML strings
113
if ( typeof selector === "string" ) {
114
if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
115
// Assume that strings that start and end with <> are HTML and skip the regex check
116
match = [ null, selector, null ];
119
match = rquickExpr.exec( selector );
122
// Match html or make sure no context is specified for #id
123
if ( match && (match[1] || !context) ) {
125
// HANDLE: $(html) -> $(array)
127
context = context instanceof jQuery ? context[0] : context;
128
doc = ( context && context.nodeType ? context.ownerDocument || context : document );
130
// scripts is true for back-compat
131
selector = jQuery.parseHTML( match[1], doc, true );
132
if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
133
this.attr.call( selector, context, true );
136
return jQuery.merge( this, selector );
140
elem = document.getElementById( match[2] );
142
// Check parentNode to catch when Blackberry 4.6 returns
143
// nodes that are no longer in the document #6963
144
if ( elem && elem.parentNode ) {
145
// Handle the case where IE and Opera return items
146
// by name instead of ID
147
if ( elem.id !== match[2] ) {
148
return rootjQuery.find( selector );
151
// Otherwise, we inject the element directly into the jQuery object
156
this.context = document;
157
this.selector = selector;
161
// HANDLE: $(expr, $(...))
162
} else if ( !context || context.jquery ) {
163
return ( context || rootjQuery ).find( selector );
165
// HANDLE: $(expr, context)
166
// (which is just equivalent to: $(context).find(expr)
168
return this.constructor( context ).find( selector );
171
// HANDLE: $(function)
172
// Shortcut for document ready
173
} else if ( jQuery.isFunction( selector ) ) {
174
return rootjQuery.ready( selector );
177
if ( selector.selector !== undefined ) {
178
this.selector = selector.selector;
179
this.context = selector.context;
182
return jQuery.makeArray( selector, this );
185
// Start with an empty selector
188
// The current version of jQuery being used
191
// The default length of a jQuery object is 0
194
// The number of elements contained in the matched element set
199
toArray: function() {
200
return core_slice.call( this );
203
// Get the Nth element in the matched element set OR
204
// Get the whole matched element set as a clean array
205
get: function( num ) {
208
// Return a 'clean' array
211
// Return just the object
212
( num < 0 ? this[ this.length + num ] : this[ num ] );
215
// Take an array of elements and push it onto the stack
216
// (returning the new matched element set)
217
pushStack: function( elems, name, selector ) {
219
// Build a new jQuery matched element set
220
var ret = jQuery.merge( this.constructor(), elems );
222
// Add the old object onto the stack (as a reference)
223
ret.prevObject = this;
225
ret.context = this.context;
227
if ( name === "find" ) {
228
ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
230
ret.selector = this.selector + "." + name + "(" + selector + ")";
233
// Return the newly-formed element set
237
// Execute a callback for every element in the matched set.
238
// (You can seed the arguments with an array of args, but this is
239
// only used internally.)
240
each: function( callback, args ) {
241
return jQuery.each( this, callback, args );
244
ready: function( fn ) {
246
jQuery.ready.promise().done( fn );
255
this.slice( i, i + 1 );
263
return this.eq( -1 );
267
return this.pushStack( core_slice.apply( this, arguments ),
268
"slice", core_slice.call(arguments).join(",") );
271
map: function( callback ) {
272
return this.pushStack( jQuery.map(this, function( elem, i ) {
273
return callback.call( elem, i, elem );
278
return this.prevObject || this.constructor(null);
281
// For internal use only.
282
// Behaves like an Array's method, not like a jQuery method.
119
// The current version of jQuery being used
120
jquery: core_version,
123
init: function( selector, context, rootjQuery ) {
126
// HANDLE: $(""), $(null), $(undefined), $(false)
131
// Handle HTML strings
132
if ( typeof selector === "string" ) {
133
if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
134
// Assume that strings that start and end with <> are HTML and skip the regex check
135
match = [ null, selector, null ];
138
match = rquickExpr.exec( selector );
141
// Match html or make sure no context is specified for #id
142
if ( match && (match[1] || !context) ) {
144
// HANDLE: $(html) -> $(array)
146
context = context instanceof jQuery ? context[0] : context;
148
// scripts is true for back-compat
149
jQuery.merge( this, jQuery.parseHTML(
151
context && context.nodeType ? context.ownerDocument || context : document,
155
// HANDLE: $(html, props)
156
if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
157
for ( match in context ) {
158
// Properties of context are called as methods if possible
159
if ( jQuery.isFunction( this[ match ] ) ) {
160
this[ match ]( context[ match ] );
162
// ...and otherwise set as attributes
164
this.attr( match, context[ match ] );
173
elem = document.getElementById( match[2] );
175
// Check parentNode to catch when Blackberry 4.6 returns
176
// nodes that are no longer in the document #6963
177
if ( elem && elem.parentNode ) {
178
// Handle the case where IE and Opera return items
179
// by name instead of ID
180
if ( elem.id !== match[2] ) {
181
return rootjQuery.find( selector );
184
// Otherwise, we inject the element directly into the jQuery object
189
this.context = document;
190
this.selector = selector;
194
// HANDLE: $(expr, $(...))
195
} else if ( !context || context.jquery ) {
196
return ( context || rootjQuery ).find( selector );
198
// HANDLE: $(expr, context)
199
// (which is just equivalent to: $(context).find(expr)
201
return this.constructor( context ).find( selector );
204
// HANDLE: $(DOMElement)
205
} else if ( selector.nodeType ) {
206
this.context = this[0] = selector;
210
// HANDLE: $(function)
211
// Shortcut for document ready
212
} else if ( jQuery.isFunction( selector ) ) {
213
return rootjQuery.ready( selector );
216
if ( selector.selector !== undefined ) {
217
this.selector = selector.selector;
218
this.context = selector.context;
221
return jQuery.makeArray( selector, this );
224
// Start with an empty selector
227
// The default length of a jQuery object is 0
230
// The number of elements contained in the matched element set
235
toArray: function() {
236
return core_slice.call( this );
239
// Get the Nth element in the matched element set OR
240
// Get the whole matched element set as a clean array
241
get: function( num ) {
244
// Return a 'clean' array
247
// Return just the object
248
( num < 0 ? this[ this.length + num ] : this[ num ] );
251
// Take an array of elements and push it onto the stack
252
// (returning the new matched element set)
253
pushStack: function( elems ) {
255
// Build a new jQuery matched element set
256
var ret = jQuery.merge( this.constructor(), elems );
258
// Add the old object onto the stack (as a reference)
259
ret.prevObject = this;
260
ret.context = this.context;
262
// Return the newly-formed element set
266
// Execute a callback for every element in the matched set.
267
// (You can seed the arguments with an array of args, but this is
268
// only used internally.)
269
each: function( callback, args ) {
270
return jQuery.each( this, callback, args );
273
ready: function( fn ) {
275
jQuery.ready.promise().done( fn );
281
return this.pushStack( core_slice.apply( this, arguments ) );
289
return this.eq( -1 );
293
var len = this.length,
294
j = +i + ( i < 0 ? len : 0 );
295
return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
298
map: function( callback ) {
299
return this.pushStack( jQuery.map(this, function( elem, i ) {
300
return callback.call( elem, i, elem );
305
return this.prevObject || this.constructor(null);
308
// For internal use only.
309
// Behaves like an Array's method, not like a jQuery method.
288
315
// Give the init function the jQuery prototype for later instantiation
289
316
jQuery.fn.init.prototype = jQuery.fn;
291
318
jQuery.extend = jQuery.fn.extend = function() {
292
var options, name, src, copy, copyIsArray, clone,
293
target = arguments[0] || {},
295
length = arguments.length,
298
// Handle a deep copy situation
299
if ( typeof target === "boolean" ) {
301
target = arguments[1] || {};
302
// skip the boolean and the target
306
// Handle case when target is a string or something (possible in deep copy)
307
if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
311
// extend jQuery itself if only one argument is passed
312
if ( length === i ) {
317
for ( ; i < length; i++ ) {
318
// Only deal with non-null/undefined values
319
if ( (options = arguments[ i ]) != null ) {
320
// Extend the base object
321
for ( name in options ) {
322
src = target[ name ];
323
copy = options[ name ];
325
// Prevent never-ending loop
326
if ( target === copy ) {
330
// Recurse if we're merging plain objects or arrays
331
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
334
clone = src && jQuery.isArray(src) ? src : [];
337
clone = src && jQuery.isPlainObject(src) ? src : {};
340
// Never move original objects, clone them
341
target[ name ] = jQuery.extend( deep, clone, copy );
343
// Don't bring in undefined values
344
} else if ( copy !== undefined ) {
345
target[ name ] = copy;
351
// Return the modified object
319
var src, copyIsArray, copy, name, options, clone,
320
target = arguments[0] || {},
322
length = arguments.length,
325
// Handle a deep copy situation
326
if ( typeof target === "boolean" ) {
328
target = arguments[1] || {};
329
// skip the boolean and the target
333
// Handle case when target is a string or something (possible in deep copy)
334
if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
338
// extend jQuery itself if only one argument is passed
339
if ( length === i ) {
344
for ( ; i < length; i++ ) {
345
// Only deal with non-null/undefined values
346
if ( (options = arguments[ i ]) != null ) {
347
// Extend the base object
348
for ( name in options ) {
349
src = target[ name ];
350
copy = options[ name ];
352
// Prevent never-ending loop
353
if ( target === copy ) {
357
// Recurse if we're merging plain objects or arrays
358
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
361
clone = src && jQuery.isArray(src) ? src : [];
364
clone = src && jQuery.isPlainObject(src) ? src : {};
367
// Never move original objects, clone them
368
target[ name ] = jQuery.extend( deep, clone, copy );
370
// Don't bring in undefined values
371
} else if ( copy !== undefined ) {
372
target[ name ] = copy;
378
// Return the modified object
356
noConflict: function( deep ) {
357
if ( window.$ === jQuery ) {
361
if ( deep && window.jQuery === jQuery ) {
362
window.jQuery = _jQuery;
368
// Is the DOM ready to be used? Set to true once it occurs.
371
// A counter to track how many items to wait for before
372
// the ready event fires. See #6781
375
// Hold (or release) the ready event
376
holdReady: function( hold ) {
380
jQuery.ready( true );
384
// Handle when the DOM is ready
385
ready: function( wait ) {
387
// Abort if there are pending holds or we're already ready
388
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
392
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
393
if ( !document.body ) {
394
return setTimeout( jQuery.ready, 1 );
397
// Remember that the DOM is ready
398
jQuery.isReady = true;
400
// If a normal DOM Ready event fired, decrement, and wait if need be
401
if ( wait !== true && --jQuery.readyWait > 0 ) {
405
// If there are functions bound, to execute
406
readyList.resolveWith( document, [ jQuery ] );
408
// Trigger any bound ready events
409
if ( jQuery.fn.trigger ) {
410
jQuery( document ).trigger("ready").off("ready");
414
// See test/unit/core.js for details concerning isFunction.
415
// Since version 1.3, DOM methods and functions like alert
416
// aren't supported. They return false on IE (#2968).
417
isFunction: function( obj ) {
418
return jQuery.type(obj) === "function";
421
isArray: Array.isArray || function( obj ) {
422
return jQuery.type(obj) === "array";
425
isWindow: function( obj ) {
426
return obj != null && obj == obj.window;
429
isNumeric: function( obj ) {
430
return !isNaN( parseFloat(obj) ) && isFinite( obj );
433
type: function( obj ) {
436
class2type[ core_toString.call(obj) ] || "object";
439
isPlainObject: function( obj ) {
440
// Must be an Object.
441
// Because of IE, we also have to check the presence of the constructor property.
442
// Make sure that DOM nodes and window objects don't pass through, as well
443
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
448
// Not own constructor property must be Object
449
if ( obj.constructor &&
450
!core_hasOwn.call(obj, "constructor") &&
451
!core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
455
// IE8,9 Will throw exceptions on certain host objects #9897
459
// Own properties are enumerated firstly, so to speed up,
460
// if last one is own, then all properties are own.
463
for ( key in obj ) {}
465
return key === undefined || core_hasOwn.call( obj, key );
468
isEmptyObject: function( obj ) {
470
for ( name in obj ) {
476
error: function( msg ) {
477
throw new Error( msg );
480
// data: string of html
481
// context (optional): If specified, the fragment will be created in this context, defaults to document
482
// scripts (optional): If true, will include scripts passed in the html string
483
parseHTML: function( data, context, scripts ) {
485
if ( !data || typeof data !== "string" ) {
488
if ( typeof context === "boolean" ) {
492
context = context || document;
495
if ( (parsed = rsingleTag.exec( data )) ) {
496
return [ context.createElement( parsed[1] ) ];
499
parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] );
500
return jQuery.merge( [],
501
(parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes );
504
parseJSON: function( data ) {
505
if ( !data || typeof data !== "string") {
509
// Make sure leading/trailing whitespace is removed (IE can't handle it)
510
data = jQuery.trim( data );
512
// Attempt to parse using the native JSON parser first
513
if ( window.JSON && window.JSON.parse ) {
514
return window.JSON.parse( data );
517
// Make sure the incoming data is actual JSON
518
// Logic borrowed from http://json.org/json2.js
519
if ( rvalidchars.test( data.replace( rvalidescape, "@" )
520
.replace( rvalidtokens, "]" )
521
.replace( rvalidbraces, "")) ) {
523
return ( new Function( "return " + data ) )();
526
jQuery.error( "Invalid JSON: " + data );
529
// Cross-browser xml parsing
530
parseXML: function( data ) {
532
if ( !data || typeof data !== "string" ) {
536
if ( window.DOMParser ) { // Standard
537
tmp = new DOMParser();
538
xml = tmp.parseFromString( data , "text/xml" );
540
xml = new ActiveXObject( "Microsoft.XMLDOM" );
547
if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
548
jQuery.error( "Invalid XML: " + data );
555
// Evaluates a script in a global context
556
// Workarounds based on findings by Jim Driscoll
557
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
558
globalEval: function( data ) {
559
if ( data && core_rnotwhite.test( data ) ) {
560
// We use execScript on Internet Explorer
561
// We use an anonymous function so that context is window
562
// rather than jQuery in Firefox
563
( window.execScript || function( data ) {
564
window[ "eval" ].call( window, data );
569
// Convert dashed to camelCase; used by the css and data modules
570
// Microsoft forgot to hump their vendor prefix (#9572)
571
camelCase: function( string ) {
572
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
575
nodeName: function( elem, name ) {
576
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
579
// args is for internal usage only
580
each: function( obj, callback, args ) {
584
isObj = length === undefined || jQuery.isFunction( obj );
588
for ( name in obj ) {
589
if ( callback.apply( obj[ name ], args ) === false ) {
594
for ( ; i < length; ) {
595
if ( callback.apply( obj[ i++ ], args ) === false ) {
601
// A special, fast, case for the most common use of each
604
for ( name in obj ) {
605
if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) {
610
for ( ; i < length; ) {
611
if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) {
621
// Use native String.trim function wherever possible
622
trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
624
return text == null ?
626
core_trim.call( text );
629
// Otherwise use our own trimming functionality
631
return text == null ?
633
( text + "" ).replace( rtrim, "" );
636
// results is for internal usage only
637
makeArray: function( arr, results ) {
642
// The window, strings (and functions) also have 'length'
643
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
644
type = jQuery.type( arr );
646
if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) {
647
core_push.call( ret, arr );
649
jQuery.merge( ret, arr );
656
inArray: function( elem, arr, i ) {
660
if ( core_indexOf ) {
661
return core_indexOf.call( arr, elem, i );
665
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
667
for ( ; i < len; i++ ) {
668
// Skip accessing in sparse arrays
669
if ( i in arr && arr[ i ] === elem ) {
678
merge: function( first, second ) {
679
var l = second.length,
683
if ( typeof l === "number" ) {
684
for ( ; j < l; j++ ) {
685
first[ i++ ] = second[ j ];
689
while ( second[j] !== undefined ) {
690
first[ i++ ] = second[ j++ ];
699
grep: function( elems, callback, inv ) {
703
length = elems.length;
706
// Go through the array, only saving the items
707
// that pass the validator function
708
for ( ; i < length; i++ ) {
709
retVal = !!callback( elems[ i ], i );
710
if ( inv !== retVal ) {
711
ret.push( elems[ i ] );
718
// arg is for internal usage only
719
map: function( elems, callback, arg ) {
723
length = elems.length,
724
// jquery objects are treated as arrays
725
isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
727
// Go through the array, translating each of the items to their
729
for ( ; i < length; i++ ) {
730
value = callback( elems[ i ], i, arg );
732
if ( value != null ) {
733
ret[ ret.length ] = value;
737
// Go through every key on the object,
739
for ( key in elems ) {
740
value = callback( elems[ key ], key, arg );
742
if ( value != null ) {
743
ret[ ret.length ] = value;
748
// Flatten any nested arrays
749
return ret.concat.apply( [], ret );
752
// A global GUID counter for objects
755
// Bind a function to a context, optionally partially applying any
757
proxy: function( fn, context ) {
758
var tmp, args, proxy;
760
if ( typeof context === "string" ) {
766
// Quick check to determine if target is callable, in the spec
767
// this throws a TypeError, but we will just return undefined.
768
if ( !jQuery.isFunction( fn ) ) {
773
args = core_slice.call( arguments, 2 );
775
return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
778
// Set the guid of unique handler to the same of original handler, so it can be removed
779
proxy.guid = fn.guid = fn.guid || jQuery.guid++;
784
// Multifunctional method to get and set values of a collection
785
// The value/s can optionally be executed if it's a function
786
access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
790
length = elems.length;
793
if ( key && typeof key === "object" ) {
795
jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
800
} else if ( value !== undefined ) {
801
// Optionally, function values get executed if exec is true
802
exec = pass === undefined && jQuery.isFunction( value );
805
// Bulk operations only iterate when executing function values
808
fn = function( elem, key, value ) {
809
return exec.call( jQuery( elem ), value );
812
// Otherwise they run against the entire set
814
fn.call( elems, value );
820
for (; i < length; i++ ) {
821
fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
834
length ? fn( elems[0], key ) : emptyGet;
838
return ( new Date() ).getTime();
383
noConflict: function( deep ) {
384
if ( window.$ === jQuery ) {
388
if ( deep && window.jQuery === jQuery ) {
389
window.jQuery = _jQuery;
395
// Is the DOM ready to be used? Set to true once it occurs.
398
// A counter to track how many items to wait for before
399
// the ready event fires. See #6781
402
// Hold (or release) the ready event
403
holdReady: function( hold ) {
407
jQuery.ready( true );
411
// Handle when the DOM is ready
412
ready: function( wait ) {
414
// Abort if there are pending holds or we're already ready
415
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
419
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
420
if ( !document.body ) {
421
return setTimeout( jQuery.ready );
424
// Remember that the DOM is ready
425
jQuery.isReady = true;
427
// If a normal DOM Ready event fired, decrement, and wait if need be
428
if ( wait !== true && --jQuery.readyWait > 0 ) {
432
// If there are functions bound, to execute
433
readyList.resolveWith( document, [ jQuery ] );
435
// Trigger any bound ready events
436
if ( jQuery.fn.trigger ) {
437
jQuery( document ).trigger("ready").off("ready");
441
// See test/unit/core.js for details concerning isFunction.
442
// Since version 1.3, DOM methods and functions like alert
443
// aren't supported. They return false on IE (#2968).
444
isFunction: function( obj ) {
445
return jQuery.type(obj) === "function";
448
isArray: Array.isArray || function( obj ) {
449
return jQuery.type(obj) === "array";
452
isWindow: function( obj ) {
453
return obj != null && obj == obj.window;
456
isNumeric: function( obj ) {
457
return !isNaN( parseFloat(obj) ) && isFinite( obj );
460
type: function( obj ) {
462
return String( obj );
464
return typeof obj === "object" || typeof obj === "function" ?
465
class2type[ core_toString.call(obj) ] || "object" :
469
isPlainObject: function( obj ) {
470
// Must be an Object.
471
// Because of IE, we also have to check the presence of the constructor property.
472
// Make sure that DOM nodes and window objects don't pass through, as well
473
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
478
// Not own constructor property must be Object
479
if ( obj.constructor &&
480
!core_hasOwn.call(obj, "constructor") &&
481
!core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
485
// IE8,9 Will throw exceptions on certain host objects #9897
489
// Own properties are enumerated firstly, so to speed up,
490
// if last one is own, then all properties are own.
493
for ( key in obj ) {}
495
return key === undefined || core_hasOwn.call( obj, key );
498
isEmptyObject: function( obj ) {
500
for ( name in obj ) {
506
error: function( msg ) {
507
throw new Error( msg );
510
// data: string of html
511
// context (optional): If specified, the fragment will be created in this context, defaults to document
512
// keepScripts (optional): If true, will include scripts passed in the html string
513
parseHTML: function( data, context, keepScripts ) {
514
if ( !data || typeof data !== "string" ) {
517
if ( typeof context === "boolean" ) {
518
keepScripts = context;
521
context = context || document;
523
var parsed = rsingleTag.exec( data ),
524
scripts = !keepScripts && [];
528
return [ context.createElement( parsed[1] ) ];
531
parsed = jQuery.buildFragment( [ data ], context, scripts );
533
jQuery( scripts ).remove();
535
return jQuery.merge( [], parsed.childNodes );
538
parseJSON: function( data ) {
539
// Attempt to parse using the native JSON parser first
540
if ( window.JSON && window.JSON.parse ) {
541
return window.JSON.parse( data );
544
if ( data === null ) {
548
if ( typeof data === "string" ) {
550
// Make sure leading/trailing whitespace is removed (IE can't handle it)
551
data = jQuery.trim( data );
554
// Make sure the incoming data is actual JSON
555
// Logic borrowed from http://json.org/json2.js
556
if ( rvalidchars.test( data.replace( rvalidescape, "@" )
557
.replace( rvalidtokens, "]" )
558
.replace( rvalidbraces, "")) ) {
560
return ( new Function( "return " + data ) )();
565
jQuery.error( "Invalid JSON: " + data );
568
// Cross-browser xml parsing
569
parseXML: function( data ) {
571
if ( !data || typeof data !== "string" ) {
575
if ( window.DOMParser ) { // Standard
576
tmp = new DOMParser();
577
xml = tmp.parseFromString( data , "text/xml" );
579
xml = new ActiveXObject( "Microsoft.XMLDOM" );
586
if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
587
jQuery.error( "Invalid XML: " + data );
594
// Evaluates a script in a global context
595
// Workarounds based on findings by Jim Driscoll
596
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
597
globalEval: function( data ) {
598
if ( data && jQuery.trim( data ) ) {
599
// We use execScript on Internet Explorer
600
// We use an anonymous function so that context is window
601
// rather than jQuery in Firefox
602
( window.execScript || function( data ) {
603
window[ "eval" ].call( window, data );
608
// Convert dashed to camelCase; used by the css and data modules
609
// Microsoft forgot to hump their vendor prefix (#9572)
610
camelCase: function( string ) {
611
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
614
nodeName: function( elem, name ) {
615
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
618
// args is for internal usage only
619
each: function( obj, callback, args ) {
623
isArray = isArraylike( obj );
627
for ( ; i < length; i++ ) {
628
value = callback.apply( obj[ i ], args );
630
if ( value === false ) {
636
value = callback.apply( obj[ i ], args );
638
if ( value === false ) {
644
// A special, fast, case for the most common use of each
647
for ( ; i < length; i++ ) {
648
value = callback.call( obj[ i ], i, obj[ i ] );
650
if ( value === false ) {
656
value = callback.call( obj[ i ], i, obj[ i ] );
658
if ( value === false ) {
668
// Use native String.trim function wherever possible
669
trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
671
return text == null ?
673
core_trim.call( text );
676
// Otherwise use our own trimming functionality
678
return text == null ?
680
( text + "" ).replace( rtrim, "" );
683
// results is for internal usage only
684
makeArray: function( arr, results ) {
685
var ret = results || [];
688
if ( isArraylike( Object(arr) ) ) {
690
typeof arr === "string" ?
694
core_push.call( ret, arr );
701
inArray: function( elem, arr, i ) {
705
if ( core_indexOf ) {
706
return core_indexOf.call( arr, elem, i );
710
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
712
for ( ; i < len; i++ ) {
713
// Skip accessing in sparse arrays
714
if ( i in arr && arr[ i ] === elem ) {
723
merge: function( first, second ) {
724
var l = second.length,
728
if ( typeof l === "number" ) {
729
for ( ; j < l; j++ ) {
730
first[ i++ ] = second[ j ];
733
while ( second[j] !== undefined ) {
734
first[ i++ ] = second[ j++ ];
743
grep: function( elems, callback, inv ) {
747
length = elems.length;
750
// Go through the array, only saving the items
751
// that pass the validator function
752
for ( ; i < length; i++ ) {
753
retVal = !!callback( elems[ i ], i );
754
if ( inv !== retVal ) {
755
ret.push( elems[ i ] );
762
// arg is for internal usage only
763
map: function( elems, callback, arg ) {
766
length = elems.length,
767
isArray = isArraylike( elems ),
770
// Go through the array, translating each of the items to their
772
for ( ; i < length; i++ ) {
773
value = callback( elems[ i ], i, arg );
775
if ( value != null ) {
776
ret[ ret.length ] = value;
780
// Go through every key on the object,
783
value = callback( elems[ i ], i, arg );
785
if ( value != null ) {
786
ret[ ret.length ] = value;
791
// Flatten any nested arrays
792
return core_concat.apply( [], ret );
795
// A global GUID counter for objects
798
// Bind a function to a context, optionally partially applying any
800
proxy: function( fn, context ) {
801
var args, proxy, tmp;
803
if ( typeof context === "string" ) {
809
// Quick check to determine if target is callable, in the spec
810
// this throws a TypeError, but we will just return undefined.
811
if ( !jQuery.isFunction( fn ) ) {
816
args = core_slice.call( arguments, 2 );
818
return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) );
821
// Set the guid of unique handler to the same of original handler, so it can be removed
822
proxy.guid = fn.guid = fn.guid || jQuery.guid++;
827
// Multifunctional method to get and set values of a collection
828
// The value/s can optionally be executed if it's a function
829
access: function( elems, fn, key, value, chainable, emptyGet, raw ) {
831
length = elems.length,
835
if ( jQuery.type( key ) === "object" ) {
838
jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
842
} else if ( value !== undefined ) {
845
if ( !jQuery.isFunction( value ) ) {
850
// Bulk operations run against the entire set
852
fn.call( elems, value );
855
// ...except when executing function values
858
fn = function( elem, key, value ) {
859
return bulk.call( jQuery( elem ), value );
865
for ( ; i < length; i++ ) {
866
fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
877
length ? fn( elems[0], key ) : emptyGet;
881
return ( new Date() ).getTime();
842
885
jQuery.ready.promise = function( obj ) {
845
readyList = jQuery.Deferred();
847
// Catch cases where $(document).ready() is called after the browser event has already occurred.
848
// we once tried to use readyState "interactive" here, but it caused issues like the one
849
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
850
if ( document.readyState === "complete" ) {
851
// Handle it asynchronously to allow scripts the opportunity to delay ready
852
setTimeout( jQuery.ready, 1 );
854
// Standards-based browsers support DOMContentLoaded
855
} else if ( document.addEventListener ) {
856
// Use the handy event callback
857
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
859
// A fallback to window.onload, that will always work
860
window.addEventListener( "load", jQuery.ready, false );
862
// If IE event model is used
864
// Ensure firing before onload, maybe late but safe also for iframes
865
document.attachEvent( "onreadystatechange", DOMContentLoaded );
867
// A fallback to window.onload, that will always work
868
window.attachEvent( "onload", jQuery.ready );
870
// If IE and not a frame
871
// continually check to see if the document is ready
875
top = window.frameElement == null && document.documentElement;
878
if ( top && top.doScroll ) {
879
(function doScrollCheck() {
880
if ( !jQuery.isReady ) {
883
// Use the trick by Diego Perini
884
// http://javascript.nwbox.com/IEContentLoaded/
885
top.doScroll("left");
887
return setTimeout( doScrollCheck, 50 );
890
// and execute any waiting functions
897
return readyList.promise( obj );
888
readyList = jQuery.Deferred();
890
// Catch cases where $(document).ready() is called after the browser event has already occurred.
891
// we once tried to use readyState "interactive" here, but it caused issues like the one
892
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
893
if ( document.readyState === "complete" ) {
894
// Handle it asynchronously to allow scripts the opportunity to delay ready
895
setTimeout( jQuery.ready );
897
// Standards-based browsers support DOMContentLoaded
898
} else if ( document.addEventListener ) {
899
// Use the handy event callback
900
document.addEventListener( "DOMContentLoaded", completed, false );
902
// A fallback to window.onload, that will always work
903
window.addEventListener( "load", completed, false );
905
// If IE event model is used
907
// Ensure firing before onload, maybe late but safe also for iframes
908
document.attachEvent( "onreadystatechange", completed );
910
// A fallback to window.onload, that will always work
911
window.attachEvent( "onload", completed );
913
// If IE and not a frame
914
// continually check to see if the document is ready
918
top = window.frameElement == null && document.documentElement;
921
if ( top && top.doScroll ) {
922
(function doScrollCheck() {
923
if ( !jQuery.isReady ) {
926
// Use the trick by Diego Perini
927
// http://javascript.nwbox.com/IEContentLoaded/
928
top.doScroll("left");
930
return setTimeout( doScrollCheck, 50 );
933
// detach all dom ready events
936
// and execute any waiting functions
943
return readyList.promise( obj );
900
946
// Populate the class2type map
901
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
902
class2type[ "[object " + name + "]" ] = name.toLowerCase();
947
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
948
class2type[ "[object " + name + "]" ] = name.toLowerCase();
951
function isArraylike( obj ) {
952
var length = obj.length,
953
type = jQuery.type( obj );
955
if ( jQuery.isWindow( obj ) ) {
959
if ( obj.nodeType === 1 && length ) {
963
return type === "array" || type !== "function" &&
965
typeof length === "number" && length > 0 && ( length - 1 ) in obj );
905
968
// All jQuery objects should point back to these
906
969
rootjQuery = jQuery(document);
907
970
// String to Object options format cache
910
973
// Convert String-formatted options into Object-formatted ones and store in cache
911
974
function createOptions( options ) {
912
var object = optionsCache[ options ] = {};
913
jQuery.each( options.split( core_rspace ), function( _, flag ) {
914
object[ flag ] = true;
975
var object = optionsCache[ options ] = {};
976
jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) {
977
object[ flag ] = true;
920
983
* Create a callback list using the following parameters:
922
* options: an optional list of space-separated options that will change how
923
* the callback list behaves or a more traditional option object
985
* options: an optional list of space-separated options that will change how
986
* the callback list behaves or a more traditional option object
925
988
* By default a callback list will act like an event callback list and can be
926
989
* "fired" multiple times.
928
991
* Possible options:
930
* once: will ensure the callback list can only be fired once (like a Deferred)
932
* memory: will keep track of previous values and will call any callback added
933
* after the list has been fired right away with the latest "memorized"
934
* values (like a Deferred)
936
* unique: will ensure a callback can only be added once (no duplicate in the list)
938
* stopOnFalse: interrupt callings when a callback returns false
993
* once: will ensure the callback list can only be fired once (like a Deferred)
995
* memory: will keep track of previous values and will call any callback added
996
* after the list has been fired right away with the latest "memorized"
997
* values (like a Deferred)
999
* unique: will ensure a callback can only be added once (no duplicate in the list)
1001
* stopOnFalse: interrupt callings when a callback returns false
941
1004
jQuery.Callbacks = function( options ) {
943
// Convert options from String-formatted to Object-formatted if needed
944
// (we check in cache first)
945
options = typeof options === "string" ?
946
( optionsCache[ options ] || createOptions( options ) ) :
947
jQuery.extend( {}, options );
949
var // Last fire value (for non-forgettable lists)
951
// Flag to know if list was already fired
953
// Flag to know if list is currently firing
955
// First callback to fire (used internally by add and fireWith)
957
// End of the loop when firing
959
// Index of currently firing callback (modified by remove if needed)
961
// Actual callback list
963
// Stack of fire calls for repeatable lists
964
stack = !options.once && [],
966
fire = function( data ) {
967
memory = options.memory && data;
969
firingIndex = firingStart || 0;
971
firingLength = list.length;
973
for ( ; list && firingIndex < firingLength; firingIndex++ ) {
974
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
975
memory = false; // To prevent further calls using add
982
if ( stack.length ) {
983
fire( stack.shift() );
985
} else if ( memory ) {
992
// Actual Callbacks object
994
// Add a callback or a collection of callbacks to the list
997
// First, we save the current length
998
var start = list.length;
999
(function add( args ) {
1000
jQuery.each( args, function( _, arg ) {
1001
var type = jQuery.type( arg );
1002
if ( type === "function" ) {
1003
if ( !options.unique || !self.has( arg ) ) {
1006
} else if ( arg && arg.length && type !== "string" ) {
1007
// Inspect recursively
1012
// Do we need to add the callbacks to the
1013
// current firing batch?
1015
firingLength = list.length;
1016
// With memory, if we're not firing then
1017
// we should call right away
1018
} else if ( memory ) {
1019
firingStart = start;
1025
// Remove a callback from the list
1026
remove: function() {
1028
jQuery.each( arguments, function( _, arg ) {
1030
while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
1031
list.splice( index, 1 );
1032
// Handle firing indexes
1034
if ( index <= firingLength ) {
1037
if ( index <= firingIndex ) {
1046
// Control if a given callback is in the list
1047
has: function( fn ) {
1048
return jQuery.inArray( fn, list ) > -1;
1050
// Remove all callbacks from the list
1055
// Have the list do nothing anymore
1056
disable: function() {
1057
list = stack = memory = undefined;
1061
disabled: function() {
1064
// Lock the list in its current state
1073
locked: function() {
1076
// Call all callbacks with the given context and arguments
1077
fireWith: function( context, args ) {
1079
args = [ context, args.slice ? args.slice() : args ];
1080
if ( list && ( !fired || stack ) ) {
1089
// Call all the callbacks with the given arguments
1091
self.fireWith( this, arguments );
1094
// To know if the callbacks have already been called at least once
1006
// Convert options from String-formatted to Object-formatted if needed
1007
// (we check in cache first)
1008
options = typeof options === "string" ?
1009
( optionsCache[ options ] || createOptions( options ) ) :
1010
jQuery.extend( {}, options );
1012
var // Flag to know if list is currently firing
1014
// Last fire value (for non-forgettable lists)
1016
// Flag to know if list was already fired
1018
// End of the loop when firing
1020
// Index of currently firing callback (modified by remove if needed)
1022
// First callback to fire (used internally by add and fireWith)
1024
// Actual callback list
1026
// Stack of fire calls for repeatable lists
1027
stack = !options.once && [],
1029
fire = function( data ) {
1030
memory = options.memory && data;
1032
firingIndex = firingStart || 0;
1034
firingLength = list.length;
1036
for ( ; list && firingIndex < firingLength; firingIndex++ ) {
1037
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
1038
memory = false; // To prevent further calls using add
1045
if ( stack.length ) {
1046
fire( stack.shift() );
1048
} else if ( memory ) {
1055
// Actual Callbacks object
1057
// Add a callback or a collection of callbacks to the list
1060
// First, we save the current length
1061
var start = list.length;
1062
(function add( args ) {
1063
jQuery.each( args, function( _, arg ) {
1064
var type = jQuery.type( arg );
1065
if ( type === "function" ) {
1066
if ( !options.unique || !self.has( arg ) ) {
1069
} else if ( arg && arg.length && type !== "string" ) {
1070
// Inspect recursively
1075
// Do we need to add the callbacks to the
1076
// current firing batch?
1078
firingLength = list.length;
1079
// With memory, if we're not firing then
1080
// we should call right away
1081
} else if ( memory ) {
1082
firingStart = start;
1088
// Remove a callback from the list
1089
remove: function() {
1091
jQuery.each( arguments, function( _, arg ) {
1093
while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
1094
list.splice( index, 1 );
1095
// Handle firing indexes
1097
if ( index <= firingLength ) {
1100
if ( index <= firingIndex ) {
1109
// Check if a given callback is in the list.
1110
// If no argument is given, return whether or not list has callbacks attached.
1111
has: function( fn ) {
1112
return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
1114
// Remove all callbacks from the list
1119
// Have the list do nothing anymore
1120
disable: function() {
1121
list = stack = memory = undefined;
1125
disabled: function() {
1128
// Lock the list in its current state
1137
locked: function() {
1140
// Call all callbacks with the given context and arguments
1141
fireWith: function( context, args ) {
1143
args = [ context, args.slice ? args.slice() : args ];
1144
if ( list && ( !fired || stack ) ) {
1153
// Call all the callbacks with the given arguments
1155
self.fireWith( this, arguments );
1158
// To know if the callbacks have already been called at least once
1102
1166
jQuery.extend({
1104
Deferred: function( func ) {
1106
// action, add listener, listener list, final state
1107
[ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
1108
[ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
1109
[ "notify", "progress", jQuery.Callbacks("memory") ]
1116
always: function() {
1117
deferred.done( arguments ).fail( arguments );
1120
then: function( /* fnDone, fnFail, fnProgress */ ) {
1121
var fns = arguments;
1122
return jQuery.Deferred(function( newDefer ) {
1123
jQuery.each( tuples, function( i, tuple ) {
1124
var action = tuple[ 0 ],
1126
// deferred[ done | fail | progress ] for forwarding actions to newDefer
1127
deferred[ tuple[1] ]( jQuery.isFunction( fn ) ?
1129
var returned = fn.apply( this, arguments );
1130
if ( returned && jQuery.isFunction( returned.promise ) ) {
1132
.done( newDefer.resolve )
1133
.fail( newDefer.reject )
1134
.progress( newDefer.notify );
1136
newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1145
// Get a promise for this deferred
1146
// If obj is provided, the promise aspect is added to the object
1147
promise: function( obj ) {
1148
return obj != null ? jQuery.extend( obj, promise ) : promise;
1153
// Keep pipe for back-compat
1154
promise.pipe = promise.then;
1156
// Add list-specific methods
1157
jQuery.each( tuples, function( i, tuple ) {
1158
var list = tuple[ 2 ],
1159
stateString = tuple[ 3 ];
1161
// promise[ done | fail | progress ] = list.add
1162
promise[ tuple[1] ] = list.add;
1165
if ( stateString ) {
1166
list.add(function() {
1167
// state = [ resolved | rejected ]
1168
state = stateString;
1170
// [ reject_list | resolve_list ].disable; progress_list.lock
1171
}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
1174
// deferred[ resolve | reject | notify ] = list.fire
1175
deferred[ tuple[0] ] = list.fire;
1176
deferred[ tuple[0] + "With" ] = list.fireWith;
1179
// Make the deferred a promise
1180
promise.promise( deferred );
1182
// Call given func if any
1184
func.call( deferred, deferred );
1192
when: function( subordinate /* , ..., subordinateN */ ) {
1194
resolveValues = core_slice.call( arguments ),
1195
length = resolveValues.length,
1197
// the count of uncompleted subordinates
1198
remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
1200
// the master Deferred. If resolveValues consist of only a single Deferred, just use that.
1201
deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
1203
// Update function for both resolve and progress values
1204
updateFunc = function( i, contexts, values ) {
1205
return function( value ) {
1206
contexts[ i ] = this;
1207
values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
1208
if( values === progressValues ) {
1209
deferred.notifyWith( contexts, values );
1210
} else if ( !( --remaining ) ) {
1211
deferred.resolveWith( contexts, values );
1216
progressValues, progressContexts, resolveContexts;
1218
// add listeners to Deferred subordinates; treat others as resolved
1220
progressValues = new Array( length );
1221
progressContexts = new Array( length );
1222
resolveContexts = new Array( length );
1223
for ( ; i < length; i++ ) {
1224
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
1225
resolveValues[ i ].promise()
1226
.done( updateFunc( i, resolveContexts, resolveValues ) )
1227
.fail( deferred.reject )
1228
.progress( updateFunc( i, progressContexts, progressValues ) );
1235
// if we're not waiting on anything, resolve the master
1237
deferred.resolveWith( resolveContexts, resolveValues );
1240
return deferred.promise();
1168
Deferred: function( func ) {
1170
// action, add listener, listener list, final state
1171
[ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
1172
[ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
1173
[ "notify", "progress", jQuery.Callbacks("memory") ]
1180
always: function() {
1181
deferred.done( arguments ).fail( arguments );
1184
then: function( /* fnDone, fnFail, fnProgress */ ) {
1185
var fns = arguments;
1186
return jQuery.Deferred(function( newDefer ) {
1187
jQuery.each( tuples, function( i, tuple ) {
1188
var action = tuple[ 0 ],
1189
fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
1190
// deferred[ done | fail | progress ] for forwarding actions to newDefer
1191
deferred[ tuple[1] ](function() {
1192
var returned = fn && fn.apply( this, arguments );
1193
if ( returned && jQuery.isFunction( returned.promise ) ) {
1195
.done( newDefer.resolve )
1196
.fail( newDefer.reject )
1197
.progress( newDefer.notify );
1199
newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
1206
// Get a promise for this deferred
1207
// If obj is provided, the promise aspect is added to the object
1208
promise: function( obj ) {
1209
return obj != null ? jQuery.extend( obj, promise ) : promise;
1214
// Keep pipe for back-compat
1215
promise.pipe = promise.then;
1217
// Add list-specific methods
1218
jQuery.each( tuples, function( i, tuple ) {
1219
var list = tuple[ 2 ],
1220
stateString = tuple[ 3 ];
1222
// promise[ done | fail | progress ] = list.add
1223
promise[ tuple[1] ] = list.add;
1226
if ( stateString ) {
1227
list.add(function() {
1228
// state = [ resolved | rejected ]
1229
state = stateString;
1231
// [ reject_list | resolve_list ].disable; progress_list.lock
1232
}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
1235
// deferred[ resolve | reject | notify ]
1236
deferred[ tuple[0] ] = function() {
1237
deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
1240
deferred[ tuple[0] + "With" ] = list.fireWith;
1243
// Make the deferred a promise
1244
promise.promise( deferred );
1246
// Call given func if any
1248
func.call( deferred, deferred );
1256
when: function( subordinate /* , ..., subordinateN */ ) {
1258
resolveValues = core_slice.call( arguments ),
1259
length = resolveValues.length,
1261
// the count of uncompleted subordinates
1262
remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
1264
// the master Deferred. If resolveValues consist of only a single Deferred, just use that.
1265
deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
1267
// Update function for both resolve and progress values
1268
updateFunc = function( i, contexts, values ) {
1269
return function( value ) {
1270
contexts[ i ] = this;
1271
values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
1272
if( values === progressValues ) {
1273
deferred.notifyWith( contexts, values );
1274
} else if ( !( --remaining ) ) {
1275
deferred.resolveWith( contexts, values );
1280
progressValues, progressContexts, resolveContexts;
1282
// add listeners to Deferred subordinates; treat others as resolved
1284
progressValues = new Array( length );
1285
progressContexts = new Array( length );
1286
resolveContexts = new Array( length );
1287
for ( ; i < length; i++ ) {
1288
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
1289
resolveValues[ i ].promise()
1290
.done( updateFunc( i, resolveContexts, resolveValues ) )
1291
.fail( deferred.reject )
1292
.progress( updateFunc( i, progressContexts, progressValues ) );
1299
// if we're not waiting on anything, resolve the master
1301
deferred.resolveWith( resolveContexts, resolveValues );
1304
return deferred.promise();
1243
1307
jQuery.support = (function() {
1256
div = document.createElement("div");
1259
div.setAttribute( "className", "t" );
1260
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
1262
// Support tests won't run in some limited or non-browser environments
1263
all = div.getElementsByTagName("*");
1264
a = div.getElementsByTagName("a")[ 0 ];
1265
if ( !all || !a || !all.length ) {
1269
// First batch of tests
1270
select = document.createElement("select");
1271
opt = select.appendChild( document.createElement("option") );
1272
input = div.getElementsByTagName("input")[ 0 ];
1274
a.style.cssText = "top:1px;float:left;opacity:.5";
1276
// IE strips leading whitespace when .innerHTML is used
1277
leadingWhitespace: ( div.firstChild.nodeType === 3 ),
1279
// Make sure that tbody elements aren't automatically inserted
1280
// IE will insert them into empty tables
1281
tbody: !div.getElementsByTagName("tbody").length,
1283
// Make sure that link elements get serialized correctly by innerHTML
1284
// This requires a wrapper element in IE
1285
htmlSerialize: !!div.getElementsByTagName("link").length,
1287
// Get the style information from getAttribute
1288
// (IE uses .cssText instead)
1289
style: /top/.test( a.getAttribute("style") ),
1291
// Make sure that URLs aren't manipulated
1292
// (IE normalizes it by default)
1293
hrefNormalized: ( a.getAttribute("href") === "/a" ),
1295
// Make sure that element opacity exists
1296
// (IE uses filter instead)
1297
// Use a regex to work around a WebKit issue. See #5145
1298
opacity: /^0.5/.test( a.style.opacity ),
1300
// Verify style float existence
1301
// (IE uses styleFloat instead of cssFloat)
1302
cssFloat: !!a.style.cssFloat,
1304
// Make sure that if no value is specified for a checkbox
1305
// that it defaults to "on".
1306
// (WebKit defaults to "" instead)
1307
checkOn: ( input.value === "on" ),
1309
// Make sure that a selected-by-default option has a working selected property.
1310
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1311
optSelected: opt.selected,
1313
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1314
getSetAttribute: div.className !== "t",
1316
// Tests for enctype support on a form (#6743)
1317
enctype: !!document.createElement("form").enctype,
1319
// Makes sure cloning an html5 element does not cause problems
1320
// Where outerHTML is undefined, this still works
1321
html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
1323
// jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
1324
boxModel: ( document.compatMode === "CSS1Compat" ),
1326
// Will be defined later
1327
submitBubbles: true,
1328
changeBubbles: true,
1329
focusinBubbles: false,
1330
deleteExpando: true,
1332
inlineBlockNeedsLayout: false,
1333
shrinkWrapBlocks: false,
1334
reliableMarginRight: true,
1335
boxSizingReliable: true,
1336
pixelPosition: false
1339
// Make sure checked status is properly cloned
1340
input.checked = true;
1341
support.noCloneChecked = input.cloneNode( true ).checked;
1343
// Make sure that the options inside disabled selects aren't marked as disabled
1344
// (WebKit marks them as disabled)
1345
select.disabled = true;
1346
support.optDisabled = !opt.disabled;
1348
// Test to see if it's possible to delete an expando from an element
1349
// Fails in Internet Explorer
1353
support.deleteExpando = false;
1356
if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1357
div.attachEvent( "onclick", clickFn = function() {
1358
// Cloning a node shouldn't copy over any
1359
// bound event handlers (IE does this)
1360
support.noCloneEvent = false;
1362
div.cloneNode( true ).fireEvent("onclick");
1363
div.detachEvent( "onclick", clickFn );
1366
// Check if a radio maintains its value
1367
// after being appended to the DOM
1368
input = document.createElement("input");
1370
input.setAttribute( "type", "radio" );
1371
support.radioValue = input.value === "t";
1373
input.setAttribute( "checked", "checked" );
1375
// #11217 - WebKit loses check when the name is after the checked attribute
1376
input.setAttribute( "name", "t" );
1378
div.appendChild( input );
1379
fragment = document.createDocumentFragment();
1380
fragment.appendChild( div.lastChild );
1382
// WebKit doesn't clone checked state correctly in fragments
1383
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1385
// Check if a disconnected checkbox will retain its checked
1386
// value of true after appended to the DOM (IE6/7)
1387
support.appendChecked = input.checked;
1389
fragment.removeChild( input );
1390
fragment.appendChild( div );
1392
// Technique from Juriy Zaytsev
1393
// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
1394
// We only care about the case where non-standard event systems
1395
// are used, namely in IE. Short-circuiting here helps us to
1396
// avoid an eval call (in setAttribute) which can cause CSP
1397
// to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1398
if ( div.attachEvent ) {
1404
eventName = "on" + i;
1405
isSupported = ( eventName in div );
1406
if ( !isSupported ) {
1407
div.setAttribute( eventName, "return;" );
1408
isSupported = ( typeof div[ eventName ] === "function" );
1410
support[ i + "Bubbles" ] = isSupported;
1414
// Run tests that need a body at doc ready
1416
var container, div, tds, marginDiv,
1417
divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;",
1418
body = document.getElementsByTagName("body")[0];
1421
// Return for frameset docs that don't have a body
1425
container = document.createElement("div");
1426
container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";
1427
body.insertBefore( container, body.firstChild );
1429
// Construct the test element
1430
div = document.createElement("div");
1431
container.appendChild( div );
1433
// Check if table cells still have offsetWidth/Height when they are set
1434
// to display:none and there are still other visible table cells in a
1435
// table row; if so, offsetWidth/Height are not reliable for use when
1436
// determining if an element has been hidden directly using
1437
// display:none (it is still safe to use offsets if a parent element is
1438
// hidden; don safety goggles and see bug #4512 for more information).
1439
// (only IE 8 fails this test)
1440
div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
1441
tds = div.getElementsByTagName("td");
1442
tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
1443
isSupported = ( tds[ 0 ].offsetHeight === 0 );
1445
tds[ 0 ].style.display = "";
1446
tds[ 1 ].style.display = "none";
1448
// Check if empty table cells still have offsetWidth/Height
1449
// (IE <= 8 fail this test)
1450
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1452
// Check box-sizing and margin behavior
1454
div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
1455
support.boxSizing = ( div.offsetWidth === 4 );
1456
support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
1458
// NOTE: To any future maintainer, we've window.getComputedStyle
1459
// because jsdom on node.js will break without it.
1460
if ( window.getComputedStyle ) {
1461
support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
1462
support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
1464
// Check if div with explicit width and no margin-right incorrectly
1465
// gets computed margin-right based on width of container. For more
1466
// info see bug #3333
1467
// Fails in WebKit before Feb 2011 nightlies
1468
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1469
marginDiv = document.createElement("div");
1470
marginDiv.style.cssText = div.style.cssText = divReset;
1471
marginDiv.style.marginRight = marginDiv.style.width = "0";
1472
div.style.width = "1px";
1473
div.appendChild( marginDiv );
1474
support.reliableMarginRight =
1475
!parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
1478
if ( typeof div.style.zoom !== "undefined" ) {
1479
// Check if natively block-level elements act like inline-block
1480
// elements when setting their display to 'inline' and giving
1482
// (IE < 8 does this)
1484
div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
1485
support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
1487
// Check if elements with layout shrink-wrap their children
1489
div.style.display = "block";
1490
div.style.overflow = "visible";
1491
div.innerHTML = "<div></div>";
1492
div.firstChild.style.width = "5px";
1493
support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
1495
container.style.zoom = 1;
1498
// Null elements to avoid leaks in IE
1499
body.removeChild( container );
1500
container = div = tds = marginDiv = null;
1503
// Null elements to avoid leaks in IE
1504
fragment.removeChild( div );
1505
all = a = select = opt = input = fragment = div = null;
1309
var support, all, a,
1310
input, select, fragment,
1311
opt, eventName, isSupported, i,
1312
div = document.createElement("div");
1315
div.setAttribute( "className", "t" );
1316
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
1318
// Support tests won't run in some limited or non-browser environments
1319
all = div.getElementsByTagName("*");
1320
a = div.getElementsByTagName("a")[ 0 ];
1321
if ( !all || !a || !all.length ) {
1325
// First batch of tests
1326
select = document.createElement("select");
1327
opt = select.appendChild( document.createElement("option") );
1328
input = div.getElementsByTagName("input")[ 0 ];
1330
a.style.cssText = "top:1px;float:left;opacity:.5";
1332
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1333
getSetAttribute: div.className !== "t",
1335
// IE strips leading whitespace when .innerHTML is used
1336
leadingWhitespace: div.firstChild.nodeType === 3,
1338
// Make sure that tbody elements aren't automatically inserted
1339
// IE will insert them into empty tables
1340
tbody: !div.getElementsByTagName("tbody").length,
1342
// Make sure that link elements get serialized correctly by innerHTML
1343
// This requires a wrapper element in IE
1344
htmlSerialize: !!div.getElementsByTagName("link").length,
1346
// Get the style information from getAttribute
1347
// (IE uses .cssText instead)
1348
style: /top/.test( a.getAttribute("style") ),
1350
// Make sure that URLs aren't manipulated
1351
// (IE normalizes it by default)
1352
hrefNormalized: a.getAttribute("href") === "/a",
1354
// Make sure that element opacity exists
1355
// (IE uses filter instead)
1356
// Use a regex to work around a WebKit issue. See #5145
1357
opacity: /^0.5/.test( a.style.opacity ),
1359
// Verify style float existence
1360
// (IE uses styleFloat instead of cssFloat)
1361
cssFloat: !!a.style.cssFloat,
1363
// Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
1364
checkOn: !!input.value,
1366
// Make sure that a selected-by-default option has a working selected property.
1367
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1368
optSelected: opt.selected,
1370
// Tests for enctype support on a form (#6743)
1371
enctype: !!document.createElement("form").enctype,
1373
// Makes sure cloning an html5 element does not cause problems
1374
// Where outerHTML is undefined, this still works
1375
html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
1377
// jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
1378
boxModel: document.compatMode === "CSS1Compat",
1380
// Will be defined later
1381
deleteExpando: true,
1383
inlineBlockNeedsLayout: false,
1384
shrinkWrapBlocks: false,
1385
reliableMarginRight: true,
1386
boxSizingReliable: true,
1387
pixelPosition: false
1390
// Make sure checked status is properly cloned
1391
input.checked = true;
1392
support.noCloneChecked = input.cloneNode( true ).checked;
1394
// Make sure that the options inside disabled selects aren't marked as disabled
1395
// (WebKit marks them as disabled)
1396
select.disabled = true;
1397
support.optDisabled = !opt.disabled;
1403
support.deleteExpando = false;
1406
// Check if we can trust getAttribute("value")
1407
input = document.createElement("input");
1408
input.setAttribute( "value", "" );
1409
support.input = input.getAttribute( "value" ) === "";
1411
// Check if an input maintains its value after becoming a radio
1413
input.setAttribute( "type", "radio" );
1414
support.radioValue = input.value === "t";
1416
// #11217 - WebKit loses check when the name is after the checked attribute
1417
input.setAttribute( "checked", "t" );
1418
input.setAttribute( "name", "t" );
1420
fragment = document.createDocumentFragment();
1421
fragment.appendChild( input );
1423
// Check if a disconnected checkbox will retain its checked
1424
// value of true after appended to the DOM (IE6/7)
1425
support.appendChecked = input.checked;
1427
// WebKit doesn't clone checked state correctly in fragments
1428
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1431
// Opera does not clone events (and typeof div.attachEvent === undefined).
1432
// IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
1433
if ( div.attachEvent ) {
1434
div.attachEvent( "onclick", function() {
1435
support.noCloneEvent = false;
1438
div.cloneNode( true ).click();
1441
// Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
1442
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP), test/csp.php
1443
for ( i in { submit: true, change: true, focusin: true }) {
1444
div.setAttribute( eventName = "on" + i, "t" );
1446
support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false;
1449
div.style.backgroundClip = "content-box";
1450
div.cloneNode( true ).style.backgroundClip = "";
1451
support.clearCloneStyle = div.style.backgroundClip === "content-box";
1453
// Run tests that need a body at doc ready
1455
var container, marginDiv, tds,
1456
divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",
1457
body = document.getElementsByTagName("body")[0];
1460
// Return for frameset docs that don't have a body
1464
container = document.createElement("div");
1465
container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
1467
body.appendChild( container ).appendChild( div );
1470
// Check if table cells still have offsetWidth/Height when they are set
1471
// to display:none and there are still other visible table cells in a
1472
// table row; if so, offsetWidth/Height are not reliable for use when
1473
// determining if an element has been hidden directly using
1474
// display:none (it is still safe to use offsets if a parent element is
1475
// hidden; don safety goggles and see bug #4512 for more information).
1476
div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
1477
tds = div.getElementsByTagName("td");
1478
tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
1479
isSupported = ( tds[ 0 ].offsetHeight === 0 );
1481
tds[ 0 ].style.display = "";
1482
tds[ 1 ].style.display = "none";
1485
// Check if empty table cells still have offsetWidth/Height
1486
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1488
// Check box-sizing and margin behavior
1490
div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
1491
support.boxSizing = ( div.offsetWidth === 4 );
1492
support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
1494
// Use window.getComputedStyle because jsdom on node.js will break without it.
1495
if ( window.getComputedStyle ) {
1496
support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
1497
support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
1499
// Check if div with explicit width and no margin-right incorrectly
1500
// gets computed margin-right based on width of container. (#3333)
1501
// Fails in WebKit before Feb 2011 nightlies
1502
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1503
marginDiv = div.appendChild( document.createElement("div") );
1504
marginDiv.style.cssText = div.style.cssText = divReset;
1505
marginDiv.style.marginRight = marginDiv.style.width = "0";
1506
div.style.width = "1px";
1508
support.reliableMarginRight =
1509
!parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
1512
if ( typeof div.style.zoom !== core_strundefined ) {
1514
// Check if natively block-level elements act like inline-block
1515
// elements when setting their display to 'inline' and giving
1518
div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
1519
support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
1522
// Check if elements with layout shrink-wrap their children
1523
div.style.display = "block";
1524
div.innerHTML = "<div></div>";
1525
div.firstChild.style.width = "5px";
1526
support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
1528
if ( support.inlineBlockNeedsLayout ) {
1529
// Prevent IE 6 from affecting layout for positioned elements #11048
1530
// Prevent IE from shrinking the body in IE 7 mode #12869
1532
body.style.zoom = 1;
1536
body.removeChild( container );
1538
// Null elements to avoid leaks in IE
1539
container = div = tds = marginDiv = null;
1542
// Null elements to avoid leaks in IE
1543
all = select = fragment = opt = a = input = null;
1509
1548
var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
1510
rmultiDash = /([A-Z])/g;
1549
rmultiDash = /([A-Z])/g;
1551
function internalData( elem, name, data, pvt /* Internal Use Only */ ){
1552
if ( !jQuery.acceptData( elem ) ) {
1557
internalKey = jQuery.expando,
1558
getByName = typeof name === "string",
1560
// We have to handle DOM nodes and JS objects differently because IE6-7
1561
// can't GC object references properly across the DOM-JS boundary
1562
isNode = elem.nodeType,
1564
// Only DOM nodes need the global jQuery cache; JS object data is
1565
// attached directly to the object so GC can occur automatically
1566
cache = isNode ? jQuery.cache : elem,
1568
// Only defining an ID for JS objects if its cache already exists allows
1569
// the code to shortcut on the same path as a DOM node with no cache
1570
id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
1572
// Avoid doing any more work than we need to when trying to get data on an
1573
// object that has no data at all
1574
if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
1579
// Only DOM nodes need a new unique ID for each element since their data
1580
// ends up in the global cache
1582
elem[ internalKey ] = id = core_deletedIds.pop() || jQuery.guid++;
1588
if ( !cache[ id ] ) {
1591
// Avoids exposing jQuery metadata on plain JS objects when the object
1592
// is serialized using JSON.stringify
1594
cache[ id ].toJSON = jQuery.noop;
1598
// An object can be passed to jQuery.data instead of a key/value pair; this gets
1599
// shallow copied over onto the existing cache
1600
if ( typeof name === "object" || typeof name === "function" ) {
1602
cache[ id ] = jQuery.extend( cache[ id ], name );
1604
cache[ id ].data = jQuery.extend( cache[ id ].data, name );
1608
thisCache = cache[ id ];
1610
// jQuery data() is stored in a separate object inside the object's internal data
1611
// cache in order to avoid key collisions between internal data and user-defined
1614
if ( !thisCache.data ) {
1615
thisCache.data = {};
1618
thisCache = thisCache.data;
1621
if ( data !== undefined ) {
1622
thisCache[ jQuery.camelCase( name ) ] = data;
1625
// Check for both converted-to-camel and non-converted data property names
1626
// If a data property was specified
1629
// First Try to find as-is property data
1630
ret = thisCache[ name ];
1632
// Test for null|undefined property data
1633
if ( ret == null ) {
1635
// Try to find the camelCased property
1636
ret = thisCache[ jQuery.camelCase( name ) ];
1645
function internalRemoveData( elem, name, pvt ) {
1646
if ( !jQuery.acceptData( elem ) ) {
1650
var i, l, thisCache,
1651
isNode = elem.nodeType,
1653
// See jQuery.data for more information
1654
cache = isNode ? jQuery.cache : elem,
1655
id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
1657
// If there is already no cache entry for this object, there is no
1658
// purpose in continuing
1659
if ( !cache[ id ] ) {
1665
thisCache = pvt ? cache[ id ] : cache[ id ].data;
1669
// Support array or space separated string names for data keys
1670
if ( !jQuery.isArray( name ) ) {
1672
// try the string as a key before any manipulation
1673
if ( name in thisCache ) {
1677
// split the camel cased version by spaces unless a key with the spaces exists
1678
name = jQuery.camelCase( name );
1679
if ( name in thisCache ) {
1682
name = name.split(" ");
1686
// If "name" is an array of keys...
1687
// When data is initially created, via ("key", "val") signature,
1688
// keys will be converted to camelCase.
1689
// Since there is no way to tell _how_ a key was added, remove
1690
// both plain key and camelCase key. #12786
1691
// This will only penalize the array argument path.
1692
name = name.concat( jQuery.map( name, jQuery.camelCase ) );
1695
for ( i = 0, l = name.length; i < l; i++ ) {
1696
delete thisCache[ name[i] ];
1699
// If there is no data left in the cache, we want to continue
1700
// and let the cache object itself get destroyed
1701
if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
1707
// See jQuery.data for more information
1709
delete cache[ id ].data;
1711
// Don't destroy the parent cache unless the internal data object
1712
// had been the only thing left in it
1713
if ( !isEmptyDataObject( cache[ id ] ) ) {
1718
// Destroy the cache
1720
jQuery.cleanData( [ elem ], true );
1722
// Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
1723
} else if ( jQuery.support.deleteExpando || cache != cache.window ) {
1726
// When all else fails, null
1512
1732
jQuery.extend({
1517
// Remove at next major release (1.9/2.0)
1520
// Unique for each copy of jQuery on the page
1521
// Non-digits removed to match rinlinejQuery
1522
expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
1524
// The following elements throw uncatchable exceptions if you
1525
// attempt to add expando properties to them.
1528
// Ban all objects except for Flash (which handle expandos)
1529
"object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1533
hasData: function( elem ) {
1534
elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1535
return !!elem && !isEmptyDataObject( elem );
1538
data: function( elem, name, data, pvt /* Internal Use Only */ ) {
1539
if ( !jQuery.acceptData( elem ) ) {
1544
internalKey = jQuery.expando,
1545
getByName = typeof name === "string",
1547
// We have to handle DOM nodes and JS objects differently because IE6-7
1548
// can't GC object references properly across the DOM-JS boundary
1549
isNode = elem.nodeType,
1551
// Only DOM nodes need the global jQuery cache; JS object data is
1552
// attached directly to the object so GC can occur automatically
1553
cache = isNode ? jQuery.cache : elem,
1555
// Only defining an ID for JS objects if its cache already exists allows
1556
// the code to shortcut on the same path as a DOM node with no cache
1557
id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
1559
// Avoid doing any more work than we need to when trying to get data on an
1560
// object that has no data at all
1561
if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
1566
// Only DOM nodes need a new unique ID for each element since their data
1567
// ends up in the global cache
1569
elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++;
1575
if ( !cache[ id ] ) {
1578
// Avoids exposing jQuery metadata on plain JS objects when the object
1579
// is serialized using JSON.stringify
1581
cache[ id ].toJSON = jQuery.noop;
1585
// An object can be passed to jQuery.data instead of a key/value pair; this gets
1586
// shallow copied over onto the existing cache
1587
if ( typeof name === "object" || typeof name === "function" ) {
1589
cache[ id ] = jQuery.extend( cache[ id ], name );
1591
cache[ id ].data = jQuery.extend( cache[ id ].data, name );
1595
thisCache = cache[ id ];
1597
// jQuery data() is stored in a separate object inside the object's internal data
1598
// cache in order to avoid key collisions between internal data and user-defined
1601
if ( !thisCache.data ) {
1602
thisCache.data = {};
1605
thisCache = thisCache.data;
1608
if ( data !== undefined ) {
1609
thisCache[ jQuery.camelCase( name ) ] = data;
1612
// Check for both converted-to-camel and non-converted data property names
1613
// If a data property was specified
1616
// First Try to find as-is property data
1617
ret = thisCache[ name ];
1619
// Test for null|undefined property data
1620
if ( ret == null ) {
1622
// Try to find the camelCased property
1623
ret = thisCache[ jQuery.camelCase( name ) ];
1632
removeData: function( elem, name, pvt /* Internal Use Only */ ) {
1633
if ( !jQuery.acceptData( elem ) ) {
1637
var thisCache, i, l,
1639
isNode = elem.nodeType,
1641
// See jQuery.data for more information
1642
cache = isNode ? jQuery.cache : elem,
1643
id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
1645
// If there is already no cache entry for this object, there is no
1646
// purpose in continuing
1647
if ( !cache[ id ] ) {
1653
thisCache = pvt ? cache[ id ] : cache[ id ].data;
1657
// Support array or space separated string names for data keys
1658
if ( !jQuery.isArray( name ) ) {
1660
// try the string as a key before any manipulation
1661
if ( name in thisCache ) {
1665
// split the camel cased version by spaces unless a key with the spaces exists
1666
name = jQuery.camelCase( name );
1667
if ( name in thisCache ) {
1670
name = name.split(" ");
1675
for ( i = 0, l = name.length; i < l; i++ ) {
1676
delete thisCache[ name[i] ];
1679
// If there is no data left in the cache, we want to continue
1680
// and let the cache object itself get destroyed
1681
if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
1687
// See jQuery.data for more information
1689
delete cache[ id ].data;
1691
// Don't destroy the parent cache unless the internal data object
1692
// had been the only thing left in it
1693
if ( !isEmptyDataObject( cache[ id ] ) ) {
1698
// Destroy the cache
1700
jQuery.cleanData( [ elem ], true );
1702
// Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
1703
} else if ( jQuery.support.deleteExpando || cache != cache.window ) {
1706
// When all else fails, null
1712
// For internal use only.
1713
_data: function( elem, name, data ) {
1714
return jQuery.data( elem, name, data, true );
1717
// A method for determining if a DOM node can handle the data expando
1718
acceptData: function( elem ) {
1719
var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
1721
// nodes accept data unless otherwise specified; rejection can be conditional
1722
return !noData || noData !== true && elem.getAttribute("classid") === noData;
1735
// Unique for each copy of jQuery on the page
1736
// Non-digits removed to match rinlinejQuery
1737
expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ),
1739
// The following elements throw uncatchable exceptions if you
1740
// attempt to add expando properties to them.
1743
// Ban all objects except for Flash (which handle expandos)
1744
"object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1748
hasData: function( elem ) {
1749
elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1750
return !!elem && !isEmptyDataObject( elem );
1753
data: function( elem, name, data ) {
1754
return internalData( elem, name, data );
1757
removeData: function( elem, name ) {
1758
return internalRemoveData( elem, name );
1761
// For internal use only.
1762
_data: function( elem, name, data ) {
1763
return internalData( elem, name, data, true );
1766
_removeData: function( elem, name ) {
1767
return internalRemoveData( elem, name, true );
1770
// A method for determining if a DOM node can handle the data expando
1771
acceptData: function( elem ) {
1772
// Do not set data on non-element because it will not be cleared (#8335).
1773
if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) {
1777
var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
1779
// nodes accept data unless otherwise specified; rejection can be conditional
1780
return !noData || noData !== true && elem.getAttribute("classid") === noData;
1726
1784
jQuery.fn.extend({
1727
data: function( key, value ) {
1728
var parts, part, attr, name, l,
1734
if ( key === undefined ) {
1735
if ( this.length ) {
1736
data = jQuery.data( elem );
1738
if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
1739
attr = elem.attributes;
1740
for ( l = attr.length; i < l; i++ ) {
1741
name = attr[i].name;
1743
if ( !name.indexOf( "data-" ) ) {
1744
name = jQuery.camelCase( name.substring(5) );
1746
dataAttr( elem, name, data[ name ] );
1749
jQuery._data( elem, "parsedAttrs", true );
1756
// Sets multiple values
1757
if ( typeof key === "object" ) {
1758
return this.each(function() {
1759
jQuery.data( this, key );
1763
parts = key.split( ".", 2 );
1764
parts[1] = parts[1] ? "." + parts[1] : "";
1765
part = parts[1] + "!";
1767
return jQuery.access( this, function( value ) {
1769
if ( value === undefined ) {
1770
data = this.triggerHandler( "getData" + part, [ parts[0] ] );
1772
// Try to fetch any internally stored data first
1773
if ( data === undefined && elem ) {
1774
data = jQuery.data( elem, key );
1775
data = dataAttr( elem, key, data );
1778
return data === undefined && parts[1] ?
1779
this.data( parts[0] ) :
1784
this.each(function() {
1785
var self = jQuery( this );
1787
self.triggerHandler( "setData" + part, parts );
1788
jQuery.data( this, key, value );
1789
self.triggerHandler( "changeData" + part, parts );
1791
}, null, value, arguments.length > 1, null, false );
1794
removeData: function( key ) {
1795
return this.each(function() {
1796
jQuery.removeData( this, key );
1785
data: function( key, value ) {
1792
if ( key === undefined ) {
1793
if ( this.length ) {
1794
data = jQuery.data( elem );
1796
if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
1797
attrs = elem.attributes;
1798
for ( ; i < attrs.length; i++ ) {
1799
name = attrs[i].name;
1801
if ( !name.indexOf( "data-" ) ) {
1802
name = jQuery.camelCase( name.slice(5) );
1804
dataAttr( elem, name, data[ name ] );
1807
jQuery._data( elem, "parsedAttrs", true );
1814
// Sets multiple values
1815
if ( typeof key === "object" ) {
1816
return this.each(function() {
1817
jQuery.data( this, key );
1821
return jQuery.access( this, function( value ) {
1823
if ( value === undefined ) {
1824
// Try to fetch any internally stored data first
1825
return elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null;
1828
this.each(function() {
1829
jQuery.data( this, key, value );
1831
}, null, value, arguments.length > 1, null, true );
1834
removeData: function( key ) {
1835
return this.each(function() {
1836
jQuery.removeData( this, key );
1801
1841
function dataAttr( elem, key, data ) {
1802
// If nothing was found internally, try to fetch any
1803
// data from the HTML5 data-* attribute
1804
if ( data === undefined && elem.nodeType === 1 ) {
1806
var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1808
data = elem.getAttribute( name );
1810
if ( typeof data === "string" ) {
1812
data = data === "true" ? true :
1813
data === "false" ? false :
1814
data === "null" ? null :
1815
// Only convert to a number if it doesn't change the string
1816
+data + "" === data ? +data :
1817
rbrace.test( data ) ? jQuery.parseJSON( data ) :
1821
// Make sure we set the data so it isn't changed later
1822
jQuery.data( elem, key, data );
1842
// If nothing was found internally, try to fetch any
1843
// data from the HTML5 data-* attribute
1844
if ( data === undefined && elem.nodeType === 1 ) {
1846
var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1848
data = elem.getAttribute( name );
1850
if ( typeof data === "string" ) {
1852
data = data === "true" ? true :
1853
data === "false" ? false :
1854
data === "null" ? null :
1855
// Only convert to a number if it doesn't change the string
1856
+data + "" === data ? +data :
1857
rbrace.test( data ) ? jQuery.parseJSON( data ) :
1861
// Make sure we set the data so it isn't changed later
1862
jQuery.data( elem, key, data );
1832
1872
// checks a cache object for emptiness
1833
1873
function isEmptyDataObject( obj ) {
1835
for ( name in obj ) {
1837
// if the public data object is empty, the private is still empty
1838
if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
1841
if ( name !== "toJSON" ) {
1875
for ( name in obj ) {
1877
// if the public data object is empty, the private is still empty
1878
if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
1881
if ( name !== "toJSON" ) {
1848
1888
jQuery.extend({
1849
queue: function( elem, type, data ) {
1853
type = ( type || "fx" ) + "queue";
1854
queue = jQuery._data( elem, type );
1856
// Speed up dequeue by getting out quickly if this is just a lookup
1858
if ( !queue || jQuery.isArray(data) ) {
1859
queue = jQuery._data( elem, type, jQuery.makeArray(data) );
1868
dequeue: function( elem, type ) {
1869
type = type || "fx";
1871
var queue = jQuery.queue( elem, type ),
1872
startLength = queue.length,
1874
hooks = jQuery._queueHooks( elem, type ),
1876
jQuery.dequeue( elem, type );
1879
// If the fx queue is dequeued, always remove the progress sentinel
1880
if ( fn === "inprogress" ) {
1887
// Add a progress sentinel to prevent the fx queue from being
1888
// automatically dequeued
1889
if ( type === "fx" ) {
1890
queue.unshift( "inprogress" );
1893
// clear up the last queue stop function
1895
fn.call( elem, next, hooks );
1898
if ( !startLength && hooks ) {
1903
// not intended for public consumption - generates a queueHooks object, or returns the current one
1904
_queueHooks: function( elem, type ) {
1905
var key = type + "queueHooks";
1906
return jQuery._data( elem, key ) || jQuery._data( elem, key, {
1907
empty: jQuery.Callbacks("once memory").add(function() {
1908
jQuery.removeData( elem, type + "queue", true );
1909
jQuery.removeData( elem, key, true );
1916
queue: function( type, data ) {
1919
if ( typeof type !== "string" ) {
1925
if ( arguments.length < setter ) {
1926
return jQuery.queue( this[0], type );
1929
return data === undefined ?
1931
this.each(function() {
1932
var queue = jQuery.queue( this, type, data );
1934
// ensure a hooks for this queue
1935
jQuery._queueHooks( this, type );
1937
if ( type === "fx" && queue[0] !== "inprogress" ) {
1938
jQuery.dequeue( this, type );
1942
dequeue: function( type ) {
1943
return this.each(function() {
1944
jQuery.dequeue( this, type );
1947
// Based off of the plugin by Clint Helfers, with permission.
1948
// http://blindsignals.com/index.php/2009/07/jquery-delay/
1949
delay: function( time, type ) {
1950
time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
1951
type = type || "fx";
1953
return this.queue( type, function( next, hooks ) {
1954
var timeout = setTimeout( next, time );
1955
hooks.stop = function() {
1956
clearTimeout( timeout );
1960
clearQueue: function( type ) {
1961
return this.queue( type || "fx", [] );
1963
// Get a promise resolved when queues of a certain type
1964
// are emptied (fx is the type by default)
1965
promise: function( type, obj ) {
1968
defer = jQuery.Deferred(),
1971
resolve = function() {
1972
if ( !( --count ) ) {
1973
defer.resolveWith( elements, [ elements ] );
1977
if ( typeof type !== "string" ) {
1981
type = type || "fx";
1984
tmp = jQuery._data( elements[ i ], type + "queueHooks" );
1985
if ( tmp && tmp.empty ) {
1987
tmp.empty.add( resolve );
1991
return defer.promise( obj );
1994
var nodeHook, boolHook, fixSpecified,
1995
rclass = /[\t\r\n]/g,
1997
rtype = /^(?:button|input)$/i,
1998
rfocusable = /^(?:button|input|object|select|textarea)$/i,
1999
rclickable = /^a(?:rea|)$/i,
2000
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
2001
getSetAttribute = jQuery.support.getSetAttribute;
2004
attr: function( name, value ) {
2005
return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
2008
removeAttr: function( name ) {
2009
return this.each(function() {
2010
jQuery.removeAttr( this, name );
2014
prop: function( name, value ) {
2015
return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
2018
removeProp: function( name ) {
2019
name = jQuery.propFix[ name ] || name;
2020
return this.each(function() {
2021
// try/catch handles cases where IE balks (such as removing a property on window)
2023
this[ name ] = undefined;
2024
delete this[ name ];
2029
addClass: function( value ) {
2030
var classNames, i, l, elem,
2033
if ( jQuery.isFunction( value ) ) {
2034
return this.each(function( j ) {
2035
jQuery( this ).addClass( value.call(this, j, this.className) );
2039
if ( value && typeof value === "string" ) {
2040
classNames = value.split( core_rspace );
2042
for ( i = 0, l = this.length; i < l; i++ ) {
2045
if ( elem.nodeType === 1 ) {
2046
if ( !elem.className && classNames.length === 1 ) {
2047
elem.className = value;
2050
setClass = " " + elem.className + " ";
2052
for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2053
if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
2054
setClass += classNames[ c ] + " ";
2057
elem.className = jQuery.trim( setClass );
2066
removeClass: function( value ) {
2067
var removes, className, elem, c, cl, i, l;
2069
if ( jQuery.isFunction( value ) ) {
2070
return this.each(function( j ) {
2071
jQuery( this ).removeClass( value.call(this, j, this.className) );
2074
if ( (value && typeof value === "string") || value === undefined ) {
2075
removes = ( value || "" ).split( core_rspace );
2077
for ( i = 0, l = this.length; i < l; i++ ) {
2079
if ( elem.nodeType === 1 && elem.className ) {
2081
className = (" " + elem.className + " ").replace( rclass, " " );
2083
// loop over each item in the removal list
2084
for ( c = 0, cl = removes.length; c < cl; c++ ) {
2085
// Remove until there is nothing to remove,
2086
while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
2087
className = className.replace( " " + removes[ c ] + " " , " " );
2090
elem.className = value ? jQuery.trim( className ) : "";
2098
toggleClass: function( value, stateVal ) {
2099
var type = typeof value,
2100
isBool = typeof stateVal === "boolean";
2102
if ( jQuery.isFunction( value ) ) {
2103
return this.each(function( i ) {
2104
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2108
return this.each(function() {
2109
if ( type === "string" ) {
2110
// toggle individual class names
2113
self = jQuery( this ),
2115
classNames = value.split( core_rspace );
2117
while ( (className = classNames[ i++ ]) ) {
2118
// check each className given, space separated list
2119
state = isBool ? state : !self.hasClass( className );
2120
self[ state ? "addClass" : "removeClass" ]( className );
2123
} else if ( type === "undefined" || type === "boolean" ) {
2124
if ( this.className ) {
2125
// store className if set
2126
jQuery._data( this, "__className__", this.className );
2129
// toggle whole className
2130
this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2135
hasClass: function( selector ) {
2136
var className = " " + selector + " ",
2139
for ( ; i < l; i++ ) {
2140
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
2148
val: function( value ) {
2149
var hooks, ret, isFunction,
2152
if ( !arguments.length ) {
2154
hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
2156
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2162
return typeof ret === "string" ?
2163
// handle most common string cases
2164
ret.replace(rreturn, "") :
2165
// handle cases where value is null/undef or number
2166
ret == null ? "" : ret;
2172
isFunction = jQuery.isFunction( value );
2174
return this.each(function( i ) {
2176
self = jQuery(this);
2178
if ( this.nodeType !== 1 ) {
2183
val = value.call( this, i, self.val() );
2188
// Treat null/undefined as ""; convert numbers to string
2189
if ( val == null ) {
2191
} else if ( typeof val === "number" ) {
2193
} else if ( jQuery.isArray( val ) ) {
2194
val = jQuery.map(val, function ( value ) {
2195
return value == null ? "" : value + "";
2199
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
2201
// If set returns undefined, fall back to normal setting
2202
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
1889
queue: function( elem, type, data ) {
1893
type = ( type || "fx" ) + "queue";
1894
queue = jQuery._data( elem, type );
1896
// Speed up dequeue by getting out quickly if this is just a lookup
1898
if ( !queue || jQuery.isArray(data) ) {
1899
queue = jQuery._data( elem, type, jQuery.makeArray(data) );
1908
dequeue: function( elem, type ) {
1909
type = type || "fx";
1911
var queue = jQuery.queue( elem, type ),
1912
startLength = queue.length,
1914
hooks = jQuery._queueHooks( elem, type ),
1916
jQuery.dequeue( elem, type );
1919
// If the fx queue is dequeued, always remove the progress sentinel
1920
if ( fn === "inprogress" ) {
1928
// Add a progress sentinel to prevent the fx queue from being
1929
// automatically dequeued
1930
if ( type === "fx" ) {
1931
queue.unshift( "inprogress" );
1934
// clear up the last queue stop function
1936
fn.call( elem, next, hooks );
1939
if ( !startLength && hooks ) {
1944
// not intended for public consumption - generates a queueHooks object, or returns the current one
1945
_queueHooks: function( elem, type ) {
1946
var key = type + "queueHooks";
1947
return jQuery._data( elem, key ) || jQuery._data( elem, key, {
1948
empty: jQuery.Callbacks("once memory").add(function() {
1949
jQuery._removeData( elem, type + "queue" );
1950
jQuery._removeData( elem, key );
1957
queue: function( type, data ) {
1960
if ( typeof type !== "string" ) {
1966
if ( arguments.length < setter ) {
1967
return jQuery.queue( this[0], type );
1970
return data === undefined ?
1972
this.each(function() {
1973
var queue = jQuery.queue( this, type, data );
1975
// ensure a hooks for this queue
1976
jQuery._queueHooks( this, type );
1978
if ( type === "fx" && queue[0] !== "inprogress" ) {
1979
jQuery.dequeue( this, type );
1983
dequeue: function( type ) {
1984
return this.each(function() {
1985
jQuery.dequeue( this, type );
1988
// Based off of the plugin by Clint Helfers, with permission.
1989
// http://blindsignals.com/index.php/2009/07/jquery-delay/
1990
delay: function( time, type ) {
1991
time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
1992
type = type || "fx";
1994
return this.queue( type, function( next, hooks ) {
1995
var timeout = setTimeout( next, time );
1996
hooks.stop = function() {
1997
clearTimeout( timeout );
2001
clearQueue: function( type ) {
2002
return this.queue( type || "fx", [] );
2004
// Get a promise resolved when queues of a certain type
2005
// are emptied (fx is the type by default)
2006
promise: function( type, obj ) {
2009
defer = jQuery.Deferred(),
2012
resolve = function() {
2013
if ( !( --count ) ) {
2014
defer.resolveWith( elements, [ elements ] );
2018
if ( typeof type !== "string" ) {
2022
type = type || "fx";
2025
tmp = jQuery._data( elements[ i ], type + "queueHooks" );
2026
if ( tmp && tmp.empty ) {
2028
tmp.empty.add( resolve );
2032
return defer.promise( obj );
2035
var nodeHook, boolHook,
2036
rclass = /[\t\r\n]/g,
2038
rfocusable = /^(?:input|select|textarea|button|object)$/i,
2039
rclickable = /^(?:a|area)$/i,
2040
rboolean = /^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,
2041
ruseDefault = /^(?:checked|selected)$/i,
2042
getSetAttribute = jQuery.support.getSetAttribute,
2043
getSetInput = jQuery.support.input;
2046
attr: function( name, value ) {
2047
return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
2050
removeAttr: function( name ) {
2051
return this.each(function() {
2052
jQuery.removeAttr( this, name );
2056
prop: function( name, value ) {
2057
return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
2060
removeProp: function( name ) {
2061
name = jQuery.propFix[ name ] || name;
2062
return this.each(function() {
2063
// try/catch handles cases where IE balks (such as removing a property on window)
2065
this[ name ] = undefined;
2066
delete this[ name ];
2071
addClass: function( value ) {
2072
var classes, elem, cur, clazz, j,
2075
proceed = typeof value === "string" && value;
2077
if ( jQuery.isFunction( value ) ) {
2078
return this.each(function( j ) {
2079
jQuery( this ).addClass( value.call( this, j, this.className ) );
2084
// The disjunction here is for better compressibility (see removeClass)
2085
classes = ( value || "" ).match( core_rnotwhite ) || [];
2087
for ( ; i < len; i++ ) {
2089
cur = elem.nodeType === 1 && ( elem.className ?
2090
( " " + elem.className + " " ).replace( rclass, " " ) :
2096
while ( (clazz = classes[j++]) ) {
2097
if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
2101
elem.className = jQuery.trim( cur );
2110
removeClass: function( value ) {
2111
var classes, elem, cur, clazz, j,
2114
proceed = arguments.length === 0 || typeof value === "string" && value;
2116
if ( jQuery.isFunction( value ) ) {
2117
return this.each(function( j ) {
2118
jQuery( this ).removeClass( value.call( this, j, this.className ) );
2122
classes = ( value || "" ).match( core_rnotwhite ) || [];
2124
for ( ; i < len; i++ ) {
2126
// This expression is here for better compressibility (see addClass)
2127
cur = elem.nodeType === 1 && ( elem.className ?
2128
( " " + elem.className + " " ).replace( rclass, " " ) :
2134
while ( (clazz = classes[j++]) ) {
2135
// Remove *all* instances
2136
while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
2137
cur = cur.replace( " " + clazz + " ", " " );
2140
elem.className = value ? jQuery.trim( cur ) : "";
2148
toggleClass: function( value, stateVal ) {
2149
var type = typeof value,
2150
isBool = typeof stateVal === "boolean";
2152
if ( jQuery.isFunction( value ) ) {
2153
return this.each(function( i ) {
2154
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2158
return this.each(function() {
2159
if ( type === "string" ) {
2160
// toggle individual class names
2163
self = jQuery( this ),
2165
classNames = value.match( core_rnotwhite ) || [];
2167
while ( (className = classNames[ i++ ]) ) {
2168
// check each className given, space separated list
2169
state = isBool ? state : !self.hasClass( className );
2170
self[ state ? "addClass" : "removeClass" ]( className );
2173
// Toggle whole class name
2174
} else if ( type === core_strundefined || type === "boolean" ) {
2175
if ( this.className ) {
2176
// store className if set
2177
jQuery._data( this, "__className__", this.className );
2180
// If the element has a class name or if we're passed "false",
2181
// then remove the whole classname (if there was one, the above saved it).
2182
// Otherwise bring back whatever was previously saved (if anything),
2183
// falling back to the empty string if nothing was stored.
2184
this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2189
hasClass: function( selector ) {
2190
var className = " " + selector + " ",
2193
for ( ; i < l; i++ ) {
2194
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
2202
val: function( value ) {
2203
var ret, hooks, isFunction,
2206
if ( !arguments.length ) {
2208
hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
2210
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2216
return typeof ret === "string" ?
2217
// handle most common string cases
2218
ret.replace(rreturn, "") :
2219
// handle cases where value is null/undef or number
2220
ret == null ? "" : ret;
2226
isFunction = jQuery.isFunction( value );
2228
return this.each(function( i ) {
2230
self = jQuery(this);
2232
if ( this.nodeType !== 1 ) {
2237
val = value.call( this, i, self.val() );
2242
// Treat null/undefined as ""; convert numbers to string
2243
if ( val == null ) {
2245
} else if ( typeof val === "number" ) {
2247
} else if ( jQuery.isArray( val ) ) {
2248
val = jQuery.map(val, function ( value ) {
2249
return value == null ? "" : value + "";
2253
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
2255
// If set returns undefined, fall back to normal setting
2256
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
2209
2263
jQuery.extend({
2212
get: function( elem ) {
2213
// attributes.value is undefined in Blackberry 4.7 but
2214
// uses .value. See #6932
2215
var val = elem.attributes.value;
2216
return !val || val.specified ? elem.value : elem.text;
2220
get: function( elem ) {
2222
options = elem.options,
2223
index = elem.selectedIndex,
2224
one = elem.type === "select-one" || index < 0,
2225
values = one ? null : [],
2226
max = one ? index + 1 : options.length,
2231
// Loop through all the selected options
2232
for ( ; i < max; i++ ) {
2233
option = options[ i ];
2235
// oldIE doesn't update selected after form reset (#2551)
2236
if ( ( option.selected || i === index ) &&
2237
// Don't return options that are disabled or in a disabled optgroup
2238
( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
2239
( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
2241
// Get the specific value for the option
2242
value = jQuery( option ).val();
2244
// We don't need an array for one selects
2249
// Multi-Selects return an array
2250
values.push( value );
2257
set: function( elem, value ) {
2258
var values = jQuery.makeArray( value );
2260
jQuery(elem).find("option").each(function() {
2261
this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2264
if ( !values.length ) {
2265
elem.selectedIndex = -1;
2272
// Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9
2275
attr: function( elem, name, value, pass ) {
2276
var ret, hooks, notxml,
2277
nType = elem.nodeType;
2279
// don't get/set attributes on text, comment and attribute nodes
2280
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2284
if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) {
2285
return jQuery( elem )[ name ]( value );
2288
// Fallback to prop when attributes are not supported
2289
if ( typeof elem.getAttribute === "undefined" ) {
2290
return jQuery.prop( elem, name, value );
2293
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2295
// All attributes are lowercase
2296
// Grab necessary hook if one is defined
2298
name = name.toLowerCase();
2299
hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
2302
if ( value !== undefined ) {
2304
if ( value === null ) {
2305
jQuery.removeAttr( elem, name );
2308
} else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
2312
elem.setAttribute( name, value + "" );
2316
} else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
2321
ret = elem.getAttribute( name );
2323
// Non-existent attributes return null, we normalize to undefined
2324
return ret === null ?
2330
removeAttr: function( elem, value ) {
2331
var propName, attrNames, name, isBool,
2334
if ( value && elem.nodeType === 1 ) {
2336
attrNames = value.split( core_rspace );
2338
for ( ; i < attrNames.length; i++ ) {
2339
name = attrNames[ i ];
2342
propName = jQuery.propFix[ name ] || name;
2343
isBool = rboolean.test( name );
2345
// See #9699 for explanation of this approach (setting first, then removal)
2346
// Do not do this for boolean attributes (see #10870)
2348
jQuery.attr( elem, name, "" );
2350
elem.removeAttribute( getSetAttribute ? name : propName );
2352
// Set corresponding property to false for boolean attributes
2353
if ( isBool && propName in elem ) {
2354
elem[ propName ] = false;
2363
set: function( elem, value ) {
2364
// We can't allow the type property to be changed (since it causes problems in IE)
2365
if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
2366
jQuery.error( "type property can't be changed" );
2367
} else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2368
// Setting the type on a radio button after the value resets the value in IE6-9
2369
// Reset value to it's default in case type is set after value
2370
// This is for element creation
2371
var val = elem.value;
2372
elem.setAttribute( "type", value );
2380
// Use the value property for back compat
2381
// Use the nodeHook for button elements in IE6/7 (#1954)
2383
get: function( elem, name ) {
2384
if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2385
return nodeHook.get( elem, name );
2387
return name in elem ?
2391
set: function( elem, value, name ) {
2392
if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2393
return nodeHook.set( elem, value, name );
2395
// Does not return so that setAttribute is also used
2402
tabindex: "tabIndex",
2403
readonly: "readOnly",
2405
"class": "className",
2406
maxlength: "maxLength",
2407
cellspacing: "cellSpacing",
2408
cellpadding: "cellPadding",
2412
frameborder: "frameBorder",
2413
contenteditable: "contentEditable"
2416
prop: function( elem, name, value ) {
2417
var ret, hooks, notxml,
2418
nType = elem.nodeType;
2420
// don't get/set properties on text, comment and attribute nodes
2421
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2425
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2428
// Fix name and attach hooks
2429
name = jQuery.propFix[ name ] || name;
2430
hooks = jQuery.propHooks[ name ];
2433
if ( value !== undefined ) {
2434
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2438
return ( elem[ name ] = value );
2442
if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2446
return elem[ name ];
2453
get: function( elem ) {
2454
// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2455
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2456
var attributeNode = elem.getAttributeNode("tabindex");
2458
return attributeNode && attributeNode.specified ?
2459
parseInt( attributeNode.value, 10 ) :
2460
rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2266
get: function( elem ) {
2267
// attributes.value is undefined in Blackberry 4.7 but
2268
// uses .value. See #6932
2269
var val = elem.attributes.value;
2270
return !val || val.specified ? elem.value : elem.text;
2274
get: function( elem ) {
2276
options = elem.options,
2277
index = elem.selectedIndex,
2278
one = elem.type === "select-one" || index < 0,
2279
values = one ? null : [],
2280
max = one ? index + 1 : options.length,
2285
// Loop through all the selected options
2286
for ( ; i < max; i++ ) {
2287
option = options[ i ];
2289
// oldIE doesn't update selected after form reset (#2551)
2290
if ( ( option.selected || i === index ) &&
2291
// Don't return options that are disabled or in a disabled optgroup
2292
( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
2293
( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
2295
// Get the specific value for the option
2296
value = jQuery( option ).val();
2298
// We don't need an array for one selects
2303
// Multi-Selects return an array
2304
values.push( value );
2311
set: function( elem, value ) {
2312
var values = jQuery.makeArray( value );
2314
jQuery(elem).find("option").each(function() {
2315
this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2318
if ( !values.length ) {
2319
elem.selectedIndex = -1;
2326
attr: function( elem, name, value ) {
2327
var hooks, notxml, ret,
2328
nType = elem.nodeType;
2330
// don't get/set attributes on text, comment and attribute nodes
2331
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2335
// Fallback to prop when attributes are not supported
2336
if ( typeof elem.getAttribute === core_strundefined ) {
2337
return jQuery.prop( elem, name, value );
2340
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2342
// All attributes are lowercase
2343
// Grab necessary hook if one is defined
2345
name = name.toLowerCase();
2346
hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
2349
if ( value !== undefined ) {
2351
if ( value === null ) {
2352
jQuery.removeAttr( elem, name );
2354
} else if ( hooks && notxml && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2358
elem.setAttribute( name, value + "" );
2362
} else if ( hooks && notxml && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2367
// In IE9+, Flash objects don't have .getAttribute (#12945)
2369
if ( typeof elem.getAttribute !== core_strundefined ) {
2370
ret = elem.getAttribute( name );
2373
// Non-existent attributes return null, we normalize to undefined
2374
return ret == null ?
2380
removeAttr: function( elem, value ) {
2383
attrNames = value && value.match( core_rnotwhite );
2385
if ( attrNames && elem.nodeType === 1 ) {
2386
while ( (name = attrNames[i++]) ) {
2387
propName = jQuery.propFix[ name ] || name;
2389
// Boolean attributes get special treatment (#10870)
2390
if ( rboolean.test( name ) ) {
2391
// Set corresponding property to false for boolean attributes
2392
// Also clear defaultChecked/defaultSelected (if appropriate) for IE<8
2393
if ( !getSetAttribute && ruseDefault.test( name ) ) {
2394
elem[ jQuery.camelCase( "default-" + name ) ] =
2395
elem[ propName ] = false;
2397
elem[ propName ] = false;
2400
// See #9699 for explanation of this approach (setting first, then removal)
2402
jQuery.attr( elem, name, "" );
2405
elem.removeAttribute( getSetAttribute ? name : propName );
2412
set: function( elem, value ) {
2413
if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2414
// Setting the type on a radio button after the value resets the value in IE6-9
2415
// Reset value to default in case type is set after value during creation
2416
var val = elem.value;
2417
elem.setAttribute( "type", value );
2428
tabindex: "tabIndex",
2429
readonly: "readOnly",
2431
"class": "className",
2432
maxlength: "maxLength",
2433
cellspacing: "cellSpacing",
2434
cellpadding: "cellPadding",
2438
frameborder: "frameBorder",
2439
contenteditable: "contentEditable"
2442
prop: function( elem, name, value ) {
2443
var ret, hooks, notxml,
2444
nType = elem.nodeType;
2446
// don't get/set properties on text, comment and attribute nodes
2447
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2451
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2454
// Fix name and attach hooks
2455
name = jQuery.propFix[ name ] || name;
2456
hooks = jQuery.propHooks[ name ];
2459
if ( value !== undefined ) {
2460
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2464
return ( elem[ name ] = value );
2468
if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2472
return elem[ name ];
2479
get: function( elem ) {
2480
// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2481
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2482
var attributeNode = elem.getAttributeNode("tabindex");
2484
return attributeNode && attributeNode.specified ?
2485
parseInt( attributeNode.value, 10 ) :
2486
rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2468
2494
// Hook for boolean attributes
2470
get: function( elem, name ) {
2471
// Align boolean attributes with corresponding properties
2472
// Fall back to attribute presence where some booleans are not supported
2474
property = jQuery.prop( elem, name );
2475
return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
2476
name.toLowerCase() :
2479
set: function( elem, value, name ) {
2481
if ( value === false ) {
2482
// Remove boolean attributes when set to false
2483
jQuery.removeAttr( elem, name );
2485
// value is true since we know at this point it's type boolean and not false
2486
// Set boolean attributes to the same name and set the DOM property
2487
propName = jQuery.propFix[ name ] || name;
2488
if ( propName in elem ) {
2489
// Only set the IDL specifically if it already exists on the element
2490
elem[ propName ] = true;
2493
elem.setAttribute( name, name.toLowerCase() );
2496
get: function( elem, name ) {
2498
// Use .prop to determine if this attribute is understood as boolean
2499
prop = jQuery.prop( elem, name ),
2501
// Fetch it accordingly
2502
attr = typeof prop === "boolean" && elem.getAttribute( name ),
2503
detail = typeof prop === "boolean" ?
2505
getSetInput && getSetAttribute ?
2507
// oldIE fabricates an empty string for missing boolean attributes
2508
// and conflates checked/selected into attroperties
2509
ruseDefault.test( name ) ?
2510
elem[ jQuery.camelCase( "default-" + name ) ] :
2513
// fetch an attribute node for properties not recognized as boolean
2514
elem.getAttributeNode( name );
2516
return detail && detail.value !== false ?
2517
name.toLowerCase() :
2520
set: function( elem, value, name ) {
2521
if ( value === false ) {
2522
// Remove boolean attributes when set to false
2523
jQuery.removeAttr( elem, name );
2524
} else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
2525
// IE<8 needs the *property* name
2526
elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
2528
// Use defaultChecked and defaultSelected for oldIE
2530
elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
2537
// fix oldIE value attroperty
2538
if ( !getSetInput || !getSetAttribute ) {
2539
jQuery.attrHooks.value = {
2540
get: function( elem, name ) {
2541
var ret = elem.getAttributeNode( name );
2542
return jQuery.nodeName( elem, "input" ) ?
2544
// Ignore the value *property* by using defaultValue
2547
ret && ret.specified ? ret.value : undefined;
2549
set: function( elem, value, name ) {
2550
if ( jQuery.nodeName( elem, "input" ) ) {
2551
// Does not return so that setAttribute is also used
2552
elem.defaultValue = value;
2554
// Use nodeHook if defined (#1954); otherwise setAttribute is fine
2555
return nodeHook && nodeHook.set( elem, value, name );
2499
2561
// IE6/7 do not support getting/setting some attributes with get/setAttribute
2500
2562
if ( !getSetAttribute ) {
2508
// Use this for any attribute in IE6/7
2509
// This fixes almost every IE6/7 issue
2510
nodeHook = jQuery.valHooks.button = {
2511
get: function( elem, name ) {
2513
ret = elem.getAttributeNode( name );
2514
return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ?
2518
set: function( elem, value, name ) {
2519
// Set the existing or create a new attribute node
2520
var ret = elem.getAttributeNode( name );
2522
ret = document.createAttribute( name );
2523
elem.setAttributeNode( ret );
2525
return ( ret.value = value + "" );
2529
// Set width and height to auto instead of 0 on empty string( Bug #8150 )
2530
// This is for removals
2531
jQuery.each([ "width", "height" ], function( i, name ) {
2532
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2533
set: function( elem, value ) {
2534
if ( value === "" ) {
2535
elem.setAttribute( name, "auto" );
2542
// Set contenteditable to false on removals(#10429)
2543
// Setting to empty string throws an error as an invalid value
2544
jQuery.attrHooks.contenteditable = {
2546
set: function( elem, value, name ) {
2547
if ( value === "" ) {
2550
nodeHook.set( elem, value, name );
2564
// Use this for any attribute in IE6/7
2565
// This fixes almost every IE6/7 issue
2566
nodeHook = jQuery.valHooks.button = {
2567
get: function( elem, name ) {
2568
var ret = elem.getAttributeNode( name );
2569
return ret && ( name === "id" || name === "name" || name === "coords" ? ret.value !== "" : ret.specified ) ?
2573
set: function( elem, value, name ) {
2574
// Set the existing or create a new attribute node
2575
var ret = elem.getAttributeNode( name );
2577
elem.setAttributeNode(
2578
(ret = elem.ownerDocument.createAttribute( name ))
2582
ret.value = value += "";
2584
// Break association with cloned elements by also using setAttribute (#9646)
2585
return name === "value" || value === elem.getAttribute( name ) ?
2591
// Set contenteditable to false on removals(#10429)
2592
// Setting to empty string throws an error as an invalid value
2593
jQuery.attrHooks.contenteditable = {
2595
set: function( elem, value, name ) {
2596
nodeHook.set( elem, value === "" ? false : value, name );
2600
// Set width and height to auto instead of 0 on empty string( Bug #8150 )
2601
// This is for removals
2602
jQuery.each([ "width", "height" ], function( i, name ) {
2603
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2604
set: function( elem, value ) {
2605
if ( value === "" ) {
2606
elem.setAttribute( name, "auto" );
2556
2615
// Some attributes require a special call on IE
2616
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2557
2617
if ( !jQuery.support.hrefNormalized ) {
2558
jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2559
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2560
get: function( elem ) {
2561
var ret = elem.getAttribute( name, 2 );
2562
return ret === null ? undefined : ret;
2618
jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2619
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2620
get: function( elem ) {
2621
var ret = elem.getAttribute( name, 2 );
2622
return ret == null ? undefined : ret;
2627
// href/src property should get the full normalized URL (#10299/#12915)
2628
jQuery.each([ "href", "src" ], function( i, name ) {
2629
jQuery.propHooks[ name ] = {
2630
get: function( elem ) {
2631
return elem.getAttribute( name, 4 );
2568
2637
if ( !jQuery.support.style ) {
2569
jQuery.attrHooks.style = {
2570
get: function( elem ) {
2571
// Return undefined in the case of empty string
2572
// Normalize to lowercase since IE uppercases css property names
2573
return elem.style.cssText.toLowerCase() || undefined;
2575
set: function( elem, value ) {
2576
return ( elem.style.cssText = value + "" );
2638
jQuery.attrHooks.style = {
2639
get: function( elem ) {
2640
// Return undefined in the case of empty string
2641
// Note: IE uppercases css property names, but if we were to .toLowerCase()
2642
// .cssText, that would destroy case senstitivity in URL's, like in "background"
2643
return elem.style.cssText || undefined;
2645
set: function( elem, value ) {
2646
return ( elem.style.cssText = value + "" );
2581
2651
// Safari mis-reports the default selected property of an option
2582
2652
// Accessing the parent's selectedIndex property fixes it
2583
2653
if ( !jQuery.support.optSelected ) {
2584
jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2585
get: function( elem ) {
2586
var parent = elem.parentNode;
2589
parent.selectedIndex;
2591
// Make sure that it also works with optgroups, see #5701
2592
if ( parent.parentNode ) {
2593
parent.parentNode.selectedIndex;
2654
jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2655
get: function( elem ) {
2656
var parent = elem.parentNode;
2659
parent.selectedIndex;
2661
// Make sure that it also works with optgroups, see #5701
2662
if ( parent.parentNode ) {
2663
parent.parentNode.selectedIndex;
2601
2671
// IE6/7 call enctype encoding
2602
2672
if ( !jQuery.support.enctype ) {
2603
jQuery.propFix.enctype = "encoding";
2673
jQuery.propFix.enctype = "encoding";
2606
2676
// Radios and checkboxes getter/setter
2607
2677
if ( !jQuery.support.checkOn ) {
2608
jQuery.each([ "radio", "checkbox" ], function() {
2609
jQuery.valHooks[ this ] = {
2610
get: function( elem ) {
2611
// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2612
return elem.getAttribute("value") === null ? "on" : elem.value;
2678
jQuery.each([ "radio", "checkbox" ], function() {
2679
jQuery.valHooks[ this ] = {
2680
get: function( elem ) {
2681
// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2682
return elem.getAttribute("value") === null ? "on" : elem.value;
2617
2687
jQuery.each([ "radio", "checkbox" ], function() {
2618
jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2619
set: function( elem, value ) {
2620
if ( jQuery.isArray( value ) ) {
2621
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
2688
jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2689
set: function( elem, value ) {
2690
if ( jQuery.isArray( value ) ) {
2691
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
2626
var rformElems = /^(?:textarea|input|select)$/i,
2627
rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/,
2628
rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
2630
rmouseEvent = /^(?:mouse|contextmenu)|click/,
2631
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
2632
hoverHack = function( events ) {
2633
return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
2696
var rformElems = /^(?:input|select|textarea)$/i,
2698
rmouseEvent = /^(?:mouse|contextmenu)|click/,
2699
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
2700
rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
2702
function returnTrue() {
2706
function returnFalse() {
2637
2711
* Helper functions for managing events -- not part of the public interface.
2640
2714
jQuery.event = {
2642
add: function( elem, types, handler, data, selector ) {
2644
var elemData, eventHandle, events,
2645
t, tns, type, namespaces, handleObj,
2646
handleObjIn, handlers, special;
2648
// Don't attach events to noData or text/comment nodes (allow plain objects tho)
2649
if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
2653
// Caller can pass in an object of custom data in lieu of the handler
2654
if ( handler.handler ) {
2655
handleObjIn = handler;
2656
handler = handleObjIn.handler;
2657
selector = handleObjIn.selector;
2660
// Make sure that the handler has a unique ID, used to find/remove it later
2661
if ( !handler.guid ) {
2662
handler.guid = jQuery.guid++;
2665
// Init the element's event structure and main handler, if this is the first
2666
events = elemData.events;
2668
elemData.events = events = {};
2670
eventHandle = elemData.handle;
2671
if ( !eventHandle ) {
2672
elemData.handle = eventHandle = function( e ) {
2673
// Discard the second event of a jQuery.event.trigger() and
2674
// when an event is called after a page has unloaded
2675
return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2676
jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
2679
// Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2680
eventHandle.elem = elem;
2683
// Handle multiple events separated by a space
2684
// jQuery(...).bind("mouseover mouseout", fn);
2685
types = jQuery.trim( hoverHack(types) ).split( " " );
2686
for ( t = 0; t < types.length; t++ ) {
2688
tns = rtypenamespace.exec( types[t] ) || [];
2690
namespaces = ( tns[2] || "" ).split( "." ).sort();
2692
// If event changes its type, use the special event handlers for the changed type
2693
special = jQuery.event.special[ type ] || {};
2695
// If selector defined, determine special event api type, otherwise given type
2696
type = ( selector ? special.delegateType : special.bindType ) || type;
2698
// Update special based on newly reset type
2699
special = jQuery.event.special[ type ] || {};
2701
// handleObj is passed to all event handlers
2702
handleObj = jQuery.extend({
2709
needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
2710
namespace: namespaces.join(".")
2713
// Init the event handler queue if we're the first
2714
handlers = events[ type ];
2716
handlers = events[ type ] = [];
2717
handlers.delegateCount = 0;
2719
// Only use addEventListener/attachEvent if the special events handler returns false
2720
if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2721
// Bind the global event handler to the element
2722
if ( elem.addEventListener ) {
2723
elem.addEventListener( type, eventHandle, false );
2725
} else if ( elem.attachEvent ) {
2726
elem.attachEvent( "on" + type, eventHandle );
2731
if ( special.add ) {
2732
special.add.call( elem, handleObj );
2734
if ( !handleObj.handler.guid ) {
2735
handleObj.handler.guid = handler.guid;
2739
// Add to the element's handler list, delegates in front
2741
handlers.splice( handlers.delegateCount++, 0, handleObj );
2743
handlers.push( handleObj );
2746
// Keep track of which events have ever been used, for event optimization
2747
jQuery.event.global[ type ] = true;
2750
// Nullify elem to prevent memory leaks in IE
2756
// Detach an event or set of events from an element
2757
remove: function( elem, types, handler, selector, mappedTypes ) {
2759
var t, tns, type, origType, namespaces, origCount,
2760
j, events, special, eventType, handleObj,
2761
elemData = jQuery.hasData( elem ) && jQuery._data( elem );
2763
if ( !elemData || !(events = elemData.events) ) {
2767
// Once for each type.namespace in types; type may be omitted
2768
types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
2769
for ( t = 0; t < types.length; t++ ) {
2770
tns = rtypenamespace.exec( types[t] ) || [];
2771
type = origType = tns[1];
2772
namespaces = tns[2];
2774
// Unbind all events (on this namespace, if provided) for the element
2776
for ( type in events ) {
2777
jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
2782
special = jQuery.event.special[ type ] || {};
2783
type = ( selector? special.delegateType : special.bindType ) || type;
2784
eventType = events[ type ] || [];
2785
origCount = eventType.length;
2786
namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
2788
// Remove matching events
2789
for ( j = 0; j < eventType.length; j++ ) {
2790
handleObj = eventType[ j ];
2792
if ( ( mappedTypes || origType === handleObj.origType ) &&
2793
( !handler || handler.guid === handleObj.guid ) &&
2794
( !namespaces || namespaces.test( handleObj.namespace ) ) &&
2795
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
2796
eventType.splice( j--, 1 );
2798
if ( handleObj.selector ) {
2799
eventType.delegateCount--;
2801
if ( special.remove ) {
2802
special.remove.call( elem, handleObj );
2807
// Remove generic event handler if we removed something and no more handlers exist
2808
// (avoids potential for endless recursion during removal of special event handlers)
2809
if ( eventType.length === 0 && origCount !== eventType.length ) {
2810
if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
2811
jQuery.removeEvent( elem, type, elemData.handle );
2814
delete events[ type ];
2818
// Remove the expando if it's no longer used
2819
if ( jQuery.isEmptyObject( events ) ) {
2820
delete elemData.handle;
2822
// removeData also checks for emptiness and clears the expando if empty
2823
// so use it instead of delete
2824
jQuery.removeData( elem, "events", true );
2828
// Events that are safe to short-circuit if no handlers are attached.
2829
// Native DOM events should not be added, they may have inline handlers.
2836
trigger: function( event, data, elem, onlyHandlers ) {
2837
// Don't do events on text and comment nodes
2838
if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
2842
// Event object or event type
2843
var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType,
2844
type = event.type || event,
2847
// focus/blur morphs to focusin/out; ensure we're not firing them right now
2848
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
2852
if ( type.indexOf( "!" ) >= 0 ) {
2853
// Exclusive events trigger only for the exact event (no namespaces)
2854
type = type.slice(0, -1);
2858
if ( type.indexOf( "." ) >= 0 ) {
2859
// Namespaced trigger; create a regexp to match event type in handle()
2860
namespaces = type.split(".");
2861
type = namespaces.shift();
2865
if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
2866
// No jQuery handlers for this event type, and it can't have inline handlers
2870
// Caller can pass in an Event, Object, or just an event type string
2871
event = typeof event === "object" ?
2872
// jQuery.Event object
2873
event[ jQuery.expando ] ? event :
2875
new jQuery.Event( type, event ) :
2876
// Just the event type (string)
2877
new jQuery.Event( type );
2880
event.isTrigger = true;
2881
event.exclusive = exclusive;
2882
event.namespace = namespaces.join( "." );
2883
event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
2884
ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
2886
// Handle a global trigger
2889
// TODO: Stop taunting the data cache; remove global events and always attach to document
2890
cache = jQuery.cache;
2891
for ( i in cache ) {
2892
if ( cache[ i ].events && cache[ i ].events[ type ] ) {
2893
jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
2899
// Clean up the event in case it is being reused
2900
event.result = undefined;
2901
if ( !event.target ) {
2902
event.target = elem;
2905
// Clone any incoming data and prepend the event, creating the handler arg list
2906
data = data != null ? jQuery.makeArray( data ) : [];
2907
data.unshift( event );
2909
// Allow special events to draw outside the lines
2910
special = jQuery.event.special[ type ] || {};
2911
if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
2915
// Determine event propagation path in advance, per W3C events spec (#9951)
2916
// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
2917
eventPath = [[ elem, special.bindType || type ]];
2918
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
2920
bubbleType = special.delegateType || type;
2921
cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
2922
for ( old = elem; cur; cur = cur.parentNode ) {
2923
eventPath.push([ cur, bubbleType ]);
2927
// Only add window if we got to document (e.g., not plain obj or detached DOM)
2928
if ( old === (elem.ownerDocument || document) ) {
2929
eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
2933
// Fire handlers on the event path
2934
for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
2936
cur = eventPath[i][0];
2937
event.type = eventPath[i][1];
2939
handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
2941
handle.apply( cur, data );
2943
// Note that this is a bare JS function and not a jQuery handler
2944
handle = ontype && cur[ ontype ];
2945
if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
2946
event.preventDefault();
2951
// If nobody prevented the default action, do it now
2952
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
2954
if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
2955
!(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
2957
// Call a native DOM method on the target with the same name name as the event.
2958
// Can't use an .isFunction() check here because IE6/7 fails that test.
2959
// Don't do default actions on window, that's where global variables be (#6170)
2960
// IE<9 dies on focus/blur to hidden element (#1486)
2961
if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
2963
// Don't re-trigger an onFOO event when we call its FOO() method
2964
old = elem[ ontype ];
2967
elem[ ontype ] = null;
2970
// Prevent re-triggering of the same event, since we already bubbled it above
2971
jQuery.event.triggered = type;
2973
jQuery.event.triggered = undefined;
2976
elem[ ontype ] = old;
2982
return event.result;
2985
dispatch: function( event ) {
2987
// Make a writable jQuery.Event from the native event object
2988
event = jQuery.event.fix( event || window.event );
2990
var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
2991
handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
2992
delegateCount = handlers.delegateCount,
2993
args = core_slice.call( arguments ),
2994
run_all = !event.exclusive && !event.namespace,
2995
special = jQuery.event.special[ event.type ] || {},
2998
// Use the fix-ed jQuery.Event rather than the (read-only) native event
3000
event.delegateTarget = this;
3002
// Call the preDispatch hook for the mapped type, and let it bail if desired
3003
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
3007
// Determine handlers that should run if there are delegated events
3008
// Avoid non-left-click bubbling in Firefox (#3861)
3009
if ( delegateCount && !(event.button && event.type === "click") ) {
3011
for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
3013
// Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764)
3014
if ( cur.disabled !== true || event.type !== "click" ) {
3017
for ( i = 0; i < delegateCount; i++ ) {
3018
handleObj = handlers[ i ];
3019
sel = handleObj.selector;
3021
if ( selMatch[ sel ] === undefined ) {
3022
selMatch[ sel ] = handleObj.needsContext ?
3023
jQuery( sel, this ).index( cur ) >= 0 :
3024
jQuery.find( sel, this, null, [ cur ] ).length;
3026
if ( selMatch[ sel ] ) {
3027
matches.push( handleObj );
3030
if ( matches.length ) {
3031
handlerQueue.push({ elem: cur, matches: matches });
3037
// Add the remaining (directly-bound) handlers
3038
if ( handlers.length > delegateCount ) {
3039
handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
3042
// Run delegates first; they may want to stop propagation beneath us
3043
for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
3044
matched = handlerQueue[ i ];
3045
event.currentTarget = matched.elem;
3047
for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
3048
handleObj = matched.matches[ j ];
3050
// Triggered event must either 1) be non-exclusive and have no namespace, or
3051
// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3052
if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
3054
event.data = handleObj.data;
3055
event.handleObj = handleObj;
3057
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
3058
.apply( matched.elem, args );
3060
if ( ret !== undefined ) {
3062
if ( ret === false ) {
3063
event.preventDefault();
3064
event.stopPropagation();
3071
// Call the postDispatch hook for the mapped type
3072
if ( special.postDispatch ) {
3073
special.postDispatch.call( this, event );
3076
return event.result;
3079
// Includes some event props shared by KeyEvent and MouseEvent
3080
// *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
3081
props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3086
props: "char charCode key keyCode".split(" "),
3087
filter: function( event, original ) {
3089
// Add which for key events
3090
if ( event.which == null ) {
3091
event.which = original.charCode != null ? original.charCode : original.keyCode;
3099
props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3100
filter: function( event, original ) {
3101
var eventDoc, doc, body,
3102
button = original.button,
3103
fromElement = original.fromElement;
3105
// Calculate pageX/Y if missing and clientX/Y available
3106
if ( event.pageX == null && original.clientX != null ) {
3107
eventDoc = event.target.ownerDocument || document;
3108
doc = eventDoc.documentElement;
3109
body = eventDoc.body;
3111
event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
3112
event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
3115
// Add relatedTarget, if necessary
3116
if ( !event.relatedTarget && fromElement ) {
3117
event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
3120
// Add which for click: 1 === left; 2 === middle; 3 === right
3121
// Note: button is not normalized, so don't use it
3122
if ( !event.which && button !== undefined ) {
3123
event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
3130
fix: function( event ) {
3131
if ( event[ jQuery.expando ] ) {
3135
// Create a writable copy of the event object and normalize some properties
3137
originalEvent = event,
3138
fixHook = jQuery.event.fixHooks[ event.type ] || {},
3139
copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
3141
event = jQuery.Event( originalEvent );
3143
for ( i = copy.length; i; ) {
3145
event[ prop ] = originalEvent[ prop ];
3148
// Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
3149
if ( !event.target ) {
3150
event.target = originalEvent.srcElement || document;
3153
// Target should not be a text node (#504, Safari)
3154
if ( event.target.nodeType === 3 ) {
3155
event.target = event.target.parentNode;
3158
// For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8)
3159
event.metaKey = !!event.metaKey;
3161
return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
3166
// Prevent triggered image.load events from bubbling to window.load
3171
delegateType: "focusin"
3174
delegateType: "focusout"
3178
setup: function( data, namespaces, eventHandle ) {
3179
// We only want to do this special case on windows
3180
if ( jQuery.isWindow( this ) ) {
3181
this.onbeforeunload = eventHandle;
3185
teardown: function( namespaces, eventHandle ) {
3186
if ( this.onbeforeunload === eventHandle ) {
3187
this.onbeforeunload = null;
3193
simulate: function( type, elem, event, bubble ) {
3194
// Piggyback on a donor event to simulate a different one.
3195
// Fake originalEvent to avoid donor's stopPropagation, but if the
3196
// simulated event prevents default then we do the same on the donor.
3197
var e = jQuery.extend(
3206
jQuery.event.trigger( e, null, elem );
3208
jQuery.event.dispatch.call( elem, e );
3210
if ( e.isDefaultPrevented() ) {
3211
event.preventDefault();
2718
add: function( elem, types, handler, data, selector ) {
2719
var tmp, events, t, handleObjIn,
2720
special, eventHandle, handleObj,
2721
handlers, type, namespaces, origType,
2722
elemData = jQuery._data( elem );
2724
// Don't attach events to noData or text/comment nodes (but allow plain objects)
2729
// Caller can pass in an object of custom data in lieu of the handler
2730
if ( handler.handler ) {
2731
handleObjIn = handler;
2732
handler = handleObjIn.handler;
2733
selector = handleObjIn.selector;
2736
// Make sure that the handler has a unique ID, used to find/remove it later
2737
if ( !handler.guid ) {
2738
handler.guid = jQuery.guid++;
2741
// Init the element's event structure and main handler, if this is the first
2742
if ( !(events = elemData.events) ) {
2743
events = elemData.events = {};
2745
if ( !(eventHandle = elemData.handle) ) {
2746
eventHandle = elemData.handle = function( e ) {
2747
// Discard the second event of a jQuery.event.trigger() and
2748
// when an event is called after a page has unloaded
2749
return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?
2750
jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
2753
// Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2754
eventHandle.elem = elem;
2757
// Handle multiple events separated by a space
2758
// jQuery(...).bind("mouseover mouseout", fn);
2759
types = ( types || "" ).match( core_rnotwhite ) || [""];
2762
tmp = rtypenamespace.exec( types[t] ) || [];
2763
type = origType = tmp[1];
2764
namespaces = ( tmp[2] || "" ).split( "." ).sort();
2766
// If event changes its type, use the special event handlers for the changed type
2767
special = jQuery.event.special[ type ] || {};
2769
// If selector defined, determine special event api type, otherwise given type
2770
type = ( selector ? special.delegateType : special.bindType ) || type;
2772
// Update special based on newly reset type
2773
special = jQuery.event.special[ type ] || {};
2775
// handleObj is passed to all event handlers
2776
handleObj = jQuery.extend({
2783
needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
2784
namespace: namespaces.join(".")
2787
// Init the event handler queue if we're the first
2788
if ( !(handlers = events[ type ]) ) {
2789
handlers = events[ type ] = [];
2790
handlers.delegateCount = 0;
2792
// Only use addEventListener/attachEvent if the special events handler returns false
2793
if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2794
// Bind the global event handler to the element
2795
if ( elem.addEventListener ) {
2796
elem.addEventListener( type, eventHandle, false );
2798
} else if ( elem.attachEvent ) {
2799
elem.attachEvent( "on" + type, eventHandle );
2804
if ( special.add ) {
2805
special.add.call( elem, handleObj );
2807
if ( !handleObj.handler.guid ) {
2808
handleObj.handler.guid = handler.guid;
2812
// Add to the element's handler list, delegates in front
2814
handlers.splice( handlers.delegateCount++, 0, handleObj );
2816
handlers.push( handleObj );
2819
// Keep track of which events have ever been used, for event optimization
2820
jQuery.event.global[ type ] = true;
2823
// Nullify elem to prevent memory leaks in IE
2827
// Detach an event or set of events from an element
2828
remove: function( elem, types, handler, selector, mappedTypes ) {
2829
var j, handleObj, tmp,
2830
origCount, t, events,
2831
special, handlers, type,
2832
namespaces, origType,
2833
elemData = jQuery.hasData( elem ) && jQuery._data( elem );
2835
if ( !elemData || !(events = elemData.events) ) {
2839
// Once for each type.namespace in types; type may be omitted
2840
types = ( types || "" ).match( core_rnotwhite ) || [""];
2843
tmp = rtypenamespace.exec( types[t] ) || [];
2844
type = origType = tmp[1];
2845
namespaces = ( tmp[2] || "" ).split( "." ).sort();
2847
// Unbind all events (on this namespace, if provided) for the element
2849
for ( type in events ) {
2850
jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
2855
special = jQuery.event.special[ type ] || {};
2856
type = ( selector ? special.delegateType : special.bindType ) || type;
2857
handlers = events[ type ] || [];
2858
tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
2860
// Remove matching events
2861
origCount = j = handlers.length;
2863
handleObj = handlers[ j ];
2865
if ( ( mappedTypes || origType === handleObj.origType ) &&
2866
( !handler || handler.guid === handleObj.guid ) &&
2867
( !tmp || tmp.test( handleObj.namespace ) ) &&
2868
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
2869
handlers.splice( j, 1 );
2871
if ( handleObj.selector ) {
2872
handlers.delegateCount--;
2874
if ( special.remove ) {
2875
special.remove.call( elem, handleObj );
2880
// Remove generic event handler if we removed something and no more handlers exist
2881
// (avoids potential for endless recursion during removal of special event handlers)
2882
if ( origCount && !handlers.length ) {
2883
if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
2884
jQuery.removeEvent( elem, type, elemData.handle );
2887
delete events[ type ];
2891
// Remove the expando if it's no longer used
2892
if ( jQuery.isEmptyObject( events ) ) {
2893
delete elemData.handle;
2895
// removeData also checks for emptiness and clears the expando if empty
2896
// so use it instead of delete
2897
jQuery._removeData( elem, "events" );
2901
trigger: function( event, data, elem, onlyHandlers ) {
2902
var handle, ontype, cur,
2903
bubbleType, special, tmp, i,
2904
eventPath = [ elem || document ],
2905
type = core_hasOwn.call( event, "type" ) ? event.type : event,
2906
namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
2908
cur = tmp = elem = elem || document;
2910
// Don't do events on text and comment nodes
2911
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2915
// focus/blur morphs to focusin/out; ensure we're not firing them right now
2916
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
2920
if ( type.indexOf(".") >= 0 ) {
2921
// Namespaced trigger; create a regexp to match event type in handle()
2922
namespaces = type.split(".");
2923
type = namespaces.shift();
2926
ontype = type.indexOf(":") < 0 && "on" + type;
2928
// Caller can pass in a jQuery.Event object, Object, or just an event type string
2929
event = event[ jQuery.expando ] ?
2931
new jQuery.Event( type, typeof event === "object" && event );
2933
event.isTrigger = true;
2934
event.namespace = namespaces.join(".");
2935
event.namespace_re = event.namespace ?
2936
new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
2939
// Clean up the event in case it is being reused
2940
event.result = undefined;
2941
if ( !event.target ) {
2942
event.target = elem;
2945
// Clone any incoming data and prepend the event, creating the handler arg list
2946
data = data == null ?
2948
jQuery.makeArray( data, [ event ] );
2950
// Allow special events to draw outside the lines
2951
special = jQuery.event.special[ type ] || {};
2952
if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
2956
// Determine event propagation path in advance, per W3C events spec (#9951)
2957
// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
2958
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
2960
bubbleType = special.delegateType || type;
2961
if ( !rfocusMorph.test( bubbleType + type ) ) {
2962
cur = cur.parentNode;
2964
for ( ; cur; cur = cur.parentNode ) {
2965
eventPath.push( cur );
2969
// Only add window if we got to document (e.g., not plain obj or detached DOM)
2970
if ( tmp === (elem.ownerDocument || document) ) {
2971
eventPath.push( tmp.defaultView || tmp.parentWindow || window );
2975
// Fire handlers on the event path
2977
while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
2979
event.type = i > 1 ?
2981
special.bindType || type;
2984
handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
2986
handle.apply( cur, data );
2990
handle = ontype && cur[ ontype ];
2991
if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
2992
event.preventDefault();
2997
// If nobody prevented the default action, do it now
2998
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
3000
if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
3001
!(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
3003
// Call a native DOM method on the target with the same name name as the event.
3004
// Can't use an .isFunction() check here because IE6/7 fails that test.
3005
// Don't do default actions on window, that's where global variables be (#6170)
3006
if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
3008
// Don't re-trigger an onFOO event when we call its FOO() method
3009
tmp = elem[ ontype ];
3012
elem[ ontype ] = null;
3015
// Prevent re-triggering of the same event, since we already bubbled it above
3016
jQuery.event.triggered = type;
3020
// IE<9 dies on focus/blur to hidden element (#1486,#12518)
3021
// only reproducible on winXP IE8 native, not IE9 in IE8 mode
3023
jQuery.event.triggered = undefined;
3026
elem[ ontype ] = tmp;
3032
return event.result;
3035
dispatch: function( event ) {
3037
// Make a writable jQuery.Event from the native event object
3038
event = jQuery.event.fix( event );
3040
var i, ret, handleObj, matched, j,
3042
args = core_slice.call( arguments ),
3043
handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
3044
special = jQuery.event.special[ event.type ] || {};
3046
// Use the fix-ed jQuery.Event rather than the (read-only) native event
3048
event.delegateTarget = this;
3050
// Call the preDispatch hook for the mapped type, and let it bail if desired
3051
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
3055
// Determine handlers
3056
handlerQueue = jQuery.event.handlers.call( this, event, handlers );
3058
// Run delegates first; they may want to stop propagation beneath us
3060
while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
3061
event.currentTarget = matched.elem;
3064
while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
3066
// Triggered event must either 1) have no namespace, or
3067
// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3068
if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
3070
event.handleObj = handleObj;
3071
event.data = handleObj.data;
3073
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
3074
.apply( matched.elem, args );
3076
if ( ret !== undefined ) {
3077
if ( (event.result = ret) === false ) {
3078
event.preventDefault();
3079
event.stopPropagation();
3086
// Call the postDispatch hook for the mapped type
3087
if ( special.postDispatch ) {
3088
special.postDispatch.call( this, event );
3091
return event.result;
3094
handlers: function( event, handlers ) {
3095
var sel, handleObj, matches, i,
3097
delegateCount = handlers.delegateCount,
3100
// Find delegate handlers
3101
// Black-hole SVG <use> instance trees (#13180)
3102
// Avoid non-left-click bubbling in Firefox (#3861)
3103
if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
3105
for ( ; cur != this; cur = cur.parentNode || this ) {
3107
// Don't check non-elements (#13208)
3108
// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
3109
if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
3111
for ( i = 0; i < delegateCount; i++ ) {
3112
handleObj = handlers[ i ];
3114
// Don't conflict with Object.prototype properties (#13203)
3115
sel = handleObj.selector + " ";
3117
if ( matches[ sel ] === undefined ) {
3118
matches[ sel ] = handleObj.needsContext ?
3119
jQuery( sel, this ).index( cur ) >= 0 :
3120
jQuery.find( sel, this, null, [ cur ] ).length;
3122
if ( matches[ sel ] ) {
3123
matches.push( handleObj );
3126
if ( matches.length ) {
3127
handlerQueue.push({ elem: cur, handlers: matches });
3133
// Add the remaining (directly-bound) handlers
3134
if ( delegateCount < handlers.length ) {
3135
handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
3138
return handlerQueue;
3141
fix: function( event ) {
3142
if ( event[ jQuery.expando ] ) {
3146
// Create a writable copy of the event object and normalize some properties
3149
originalEvent = event,
3150
fixHook = this.fixHooks[ type ];
3153
this.fixHooks[ type ] = fixHook =
3154
rmouseEvent.test( type ) ? this.mouseHooks :
3155
rkeyEvent.test( type ) ? this.keyHooks :
3158
copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
3160
event = new jQuery.Event( originalEvent );
3165
event[ prop ] = originalEvent[ prop ];
3169
// Fix target property (#1925)
3170
if ( !event.target ) {
3171
event.target = originalEvent.srcElement || document;
3174
// Support: Chrome 23+, Safari?
3175
// Target should not be a text node (#504, #13143)
3176
if ( event.target.nodeType === 3 ) {
3177
event.target = event.target.parentNode;
3181
// For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
3182
event.metaKey = !!event.metaKey;
3184
return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
3187
// Includes some event props shared by KeyEvent and MouseEvent
3188
props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3193
props: "char charCode key keyCode".split(" "),
3194
filter: function( event, original ) {
3196
// Add which for key events
3197
if ( event.which == null ) {
3198
event.which = original.charCode != null ? original.charCode : original.keyCode;
3206
props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3207
filter: function( event, original ) {
3208
var body, eventDoc, doc,
3209
button = original.button,
3210
fromElement = original.fromElement;
3212
// Calculate pageX/Y if missing and clientX/Y available
3213
if ( event.pageX == null && original.clientX != null ) {
3214
eventDoc = event.target.ownerDocument || document;
3215
doc = eventDoc.documentElement;
3216
body = eventDoc.body;
3218
event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
3219
event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
3222
// Add relatedTarget, if necessary
3223
if ( !event.relatedTarget && fromElement ) {
3224
event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
3227
// Add which for click: 1 === left; 2 === middle; 3 === right
3228
// Note: button is not normalized, so don't use it
3229
if ( !event.which && button !== undefined ) {
3230
event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
3239
// Prevent triggered image.load events from bubbling to window.load
3243
// For checkbox, fire native event so checked state will be right
3244
trigger: function() {
3245
if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
3252
// Fire native event if possible so blur/focus sequence is correct
3253
trigger: function() {
3254
if ( this !== document.activeElement && this.focus ) {
3260
// If we error on focus to hidden element (#1486, #12518),
3261
// let .trigger() run the handlers
3265
delegateType: "focusin"
3268
trigger: function() {
3269
if ( this === document.activeElement && this.blur ) {
3274
delegateType: "focusout"
3278
postDispatch: function( event ) {
3280
// Even when returnValue equals to undefined Firefox will still show alert
3281
if ( event.result !== undefined ) {
3282
event.originalEvent.returnValue = event.result;
3288
simulate: function( type, elem, event, bubble ) {
3289
// Piggyback on a donor event to simulate a different one.
3290
// Fake originalEvent to avoid donor's stopPropagation, but if the
3291
// simulated event prevents default then we do the same on the donor.
3292
var e = jQuery.extend(
3301
jQuery.event.trigger( e, null, elem );
3303
jQuery.event.dispatch.call( elem, e );
3305
if ( e.isDefaultPrevented() ) {
3306
event.preventDefault();
3216
// Some plugins are using, but it's undocumented/deprecated and will be removed.
3217
// The 1.7 special event interface should provide all the hooks needed now.
3218
jQuery.event.handle = jQuery.event.dispatch;
3220
3311
jQuery.removeEvent = document.removeEventListener ?
3221
function( elem, type, handle ) {
3222
if ( elem.removeEventListener ) {
3223
elem.removeEventListener( type, handle, false );
3226
function( elem, type, handle ) {
3227
var name = "on" + type;
3229
if ( elem.detachEvent ) {
3231
// #8545, #7054, preventing memory leaks for custom events in IE6-8
3232
// detachEvent needed property on element, by name of that event, to properly expose it to GC
3233
if ( typeof elem[ name ] === "undefined" ) {
3234
elem[ name ] = null;
3237
elem.detachEvent( name, handle );
3312
function( elem, type, handle ) {
3313
if ( elem.removeEventListener ) {
3314
elem.removeEventListener( type, handle, false );
3317
function( elem, type, handle ) {
3318
var name = "on" + type;
3320
if ( elem.detachEvent ) {
3322
// #8545, #7054, preventing memory leaks for custom events in IE6-8
3323
// detachEvent needed property on element, by name of that event, to properly expose it to GC
3324
if ( typeof elem[ name ] === core_strundefined ) {
3325
elem[ name ] = null;
3328
elem.detachEvent( name, handle );
3241
3332
jQuery.Event = function( src, props ) {
3242
// Allow instantiation without the 'new' keyword
3243
if ( !(this instanceof jQuery.Event) ) {
3244
return new jQuery.Event( src, props );
3248
if ( src && src.type ) {
3249
this.originalEvent = src;
3250
this.type = src.type;
3252
// Events bubbling up the document may have been marked as prevented
3253
// by a handler lower down the tree; reflect the correct value.
3254
this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
3255
src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
3262
// Put explicitly provided properties onto the event object
3264
jQuery.extend( this, props );
3267
// Create a timestamp if incoming event doesn't have one
3268
this.timeStamp = src && src.timeStamp || jQuery.now();
3271
this[ jQuery.expando ] = true;
3333
// Allow instantiation without the 'new' keyword
3334
if ( !(this instanceof jQuery.Event) ) {
3335
return new jQuery.Event( src, props );
3339
if ( src && src.type ) {
3340
this.originalEvent = src;
3341
this.type = src.type;
3343
// Events bubbling up the document may have been marked as prevented
3344
// by a handler lower down the tree; reflect the correct value.
3345
this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
3346
src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
3353
// Put explicitly provided properties onto the event object
3355
jQuery.extend( this, props );
3358
// Create a timestamp if incoming event doesn't have one
3359
this.timeStamp = src && src.timeStamp || jQuery.now();
3362
this[ jQuery.expando ] = true;
3274
function returnFalse() {
3277
function returnTrue() {
3281
3365
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3282
3366
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3283
3367
jQuery.Event.prototype = {
3284
preventDefault: function() {
3285
this.isDefaultPrevented = returnTrue;
3287
var e = this.originalEvent;
3292
// if preventDefault exists run it on the original event
3293
if ( e.preventDefault ) {
3296
// otherwise set the returnValue property of the original event to false (IE)
3298
e.returnValue = false;
3301
stopPropagation: function() {
3302
this.isPropagationStopped = returnTrue;
3304
var e = this.originalEvent;
3308
// if stopPropagation exists run it on the original event
3309
if ( e.stopPropagation ) {
3310
e.stopPropagation();
3312
// otherwise set the cancelBubble property of the original event to true (IE)
3313
e.cancelBubble = true;
3315
stopImmediatePropagation: function() {
3316
this.isImmediatePropagationStopped = returnTrue;
3317
this.stopPropagation();
3319
isDefaultPrevented: returnFalse,
3320
isPropagationStopped: returnFalse,
3321
isImmediatePropagationStopped: returnFalse
3368
isDefaultPrevented: returnFalse,
3369
isPropagationStopped: returnFalse,
3370
isImmediatePropagationStopped: returnFalse,
3372
preventDefault: function() {
3373
var e = this.originalEvent;
3375
this.isDefaultPrevented = returnTrue;
3380
// If preventDefault exists, run it on the original event
3381
if ( e.preventDefault ) {
3385
// Otherwise set the returnValue property of the original event to false
3387
e.returnValue = false;
3390
stopPropagation: function() {
3391
var e = this.originalEvent;
3393
this.isPropagationStopped = returnTrue;
3397
// If stopPropagation exists, run it on the original event
3398
if ( e.stopPropagation ) {
3399
e.stopPropagation();
3403
// Set the cancelBubble property of the original event to true
3404
e.cancelBubble = true;
3406
stopImmediatePropagation: function() {
3407
this.isImmediatePropagationStopped = returnTrue;
3408
this.stopPropagation();
3324
3412
// Create mouseenter/leave events using mouseover/out and event-time checks
3326
mouseenter: "mouseover",
3327
mouseleave: "mouseout"
3414
mouseenter: "mouseover",
3415
mouseleave: "mouseout"
3328
3416
}, function( orig, fix ) {
3329
jQuery.event.special[ orig ] = {
3333
handle: function( event ) {
3336
related = event.relatedTarget,
3337
handleObj = event.handleObj,
3338
selector = handleObj.selector;
3340
// For mousenter/leave call the handler if related is outside the target.
3341
// NB: No relatedTarget if the mouse left/entered the browser window
3342
if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
3343
event.type = handleObj.origType;
3344
ret = handleObj.handler.apply( this, arguments );
3417
jQuery.event.special[ orig ] = {
3421
handle: function( event ) {
3424
related = event.relatedTarget,
3425
handleObj = event.handleObj;
3427
// For mousenter/leave call the handler if related is outside the target.
3428
// NB: No relatedTarget if the mouse left/entered the browser window
3429
if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
3430
event.type = handleObj.origType;
3431
ret = handleObj.handler.apply( this, arguments );
3352
3439
// IE submit delegation
3353
3440
if ( !jQuery.support.submitBubbles ) {
3355
jQuery.event.special.submit = {
3357
// Only need this for delegated form submit events
3358
if ( jQuery.nodeName( this, "form" ) ) {
3362
// Lazy-add a submit handler when a descendant form may potentially be submitted
3363
jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
3364
// Node name check avoids a VML-related crash in IE (#9807)
3365
var elem = e.target,
3366
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
3367
if ( form && !jQuery._data( form, "_submit_attached" ) ) {
3368
jQuery.event.add( form, "submit._submit", function( event ) {
3369
event._submit_bubble = true;
3371
jQuery._data( form, "_submit_attached", true );
3374
// return undefined since we don't need an event listener
3377
postDispatch: function( event ) {
3378
// If form was submitted by the user, bubble the event up the tree
3379
if ( event._submit_bubble ) {
3380
delete event._submit_bubble;
3381
if ( this.parentNode && !event.isTrigger ) {
3382
jQuery.event.simulate( "submit", this.parentNode, event, true );
3387
teardown: function() {
3388
// Only need this for delegated form submit events
3389
if ( jQuery.nodeName( this, "form" ) ) {
3393
// Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3394
jQuery.event.remove( this, "._submit" );
3442
jQuery.event.special.submit = {
3444
// Only need this for delegated form submit events
3445
if ( jQuery.nodeName( this, "form" ) ) {
3449
// Lazy-add a submit handler when a descendant form may potentially be submitted
3450
jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
3451
// Node name check avoids a VML-related crash in IE (#9807)
3452
var elem = e.target,
3453
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
3454
if ( form && !jQuery._data( form, "submitBubbles" ) ) {
3455
jQuery.event.add( form, "submit._submit", function( event ) {
3456
event._submit_bubble = true;
3458
jQuery._data( form, "submitBubbles", true );
3461
// return undefined since we don't need an event listener
3464
postDispatch: function( event ) {
3465
// If form was submitted by the user, bubble the event up the tree
3466
if ( event._submit_bubble ) {
3467
delete event._submit_bubble;
3468
if ( this.parentNode && !event.isTrigger ) {
3469
jQuery.event.simulate( "submit", this.parentNode, event, true );
3474
teardown: function() {
3475
// Only need this for delegated form submit events
3476
if ( jQuery.nodeName( this, "form" ) ) {
3480
// Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3481
jQuery.event.remove( this, "._submit" );
3399
3486
// IE change delegation and checkbox/radio fix
3400
3487
if ( !jQuery.support.changeBubbles ) {
3402
jQuery.event.special.change = {
3406
if ( rformElems.test( this.nodeName ) ) {
3407
// IE doesn't fire change on a check/radio until blur; trigger it on click
3408
// after a propertychange. Eat the blur-change in special.change.handle.
3409
// This still fires onchange a second time for check/radio after blur.
3410
if ( this.type === "checkbox" || this.type === "radio" ) {
3411
jQuery.event.add( this, "propertychange._change", function( event ) {
3412
if ( event.originalEvent.propertyName === "checked" ) {
3413
this._just_changed = true;
3416
jQuery.event.add( this, "click._change", function( event ) {
3417
if ( this._just_changed && !event.isTrigger ) {
3418
this._just_changed = false;
3420
// Allow triggered, simulated change events (#11500)
3421
jQuery.event.simulate( "change", this, event, true );
3426
// Delegated event; lazy-add a change handler on descendant inputs
3427
jQuery.event.add( this, "beforeactivate._change", function( e ) {
3428
var elem = e.target;
3430
if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) {
3431
jQuery.event.add( elem, "change._change", function( event ) {
3432
if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
3433
jQuery.event.simulate( "change", this.parentNode, event, true );
3436
jQuery._data( elem, "_change_attached", true );
3441
handle: function( event ) {
3442
var elem = event.target;
3444
// Swallow native change events from checkbox/radio, we already triggered them above
3445
if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
3446
return event.handleObj.handler.apply( this, arguments );
3450
teardown: function() {
3451
jQuery.event.remove( this, "._change" );
3453
return !rformElems.test( this.nodeName );
3489
jQuery.event.special.change = {
3493
if ( rformElems.test( this.nodeName ) ) {
3494
// IE doesn't fire change on a check/radio until blur; trigger it on click
3495
// after a propertychange. Eat the blur-change in special.change.handle.
3496
// This still fires onchange a second time for check/radio after blur.
3497
if ( this.type === "checkbox" || this.type === "radio" ) {
3498
jQuery.event.add( this, "propertychange._change", function( event ) {
3499
if ( event.originalEvent.propertyName === "checked" ) {
3500
this._just_changed = true;
3503
jQuery.event.add( this, "click._change", function( event ) {
3504
if ( this._just_changed && !event.isTrigger ) {
3505
this._just_changed = false;
3507
// Allow triggered, simulated change events (#11500)
3508
jQuery.event.simulate( "change", this, event, true );
3513
// Delegated event; lazy-add a change handler on descendant inputs
3514
jQuery.event.add( this, "beforeactivate._change", function( e ) {
3515
var elem = e.target;
3517
if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
3518
jQuery.event.add( elem, "change._change", function( event ) {
3519
if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
3520
jQuery.event.simulate( "change", this.parentNode, event, true );
3523
jQuery._data( elem, "changeBubbles", true );
3528
handle: function( event ) {
3529
var elem = event.target;
3531
// Swallow native change events from checkbox/radio, we already triggered them above
3532
if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
3533
return event.handleObj.handler.apply( this, arguments );
3537
teardown: function() {
3538
jQuery.event.remove( this, "._change" );
3540
return !rformElems.test( this.nodeName );
3458
3545
// Create "bubbling" focus and blur events
3459
3546
if ( !jQuery.support.focusinBubbles ) {
3460
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3462
// Attach a single capturing handler while someone wants focusin/focusout
3464
handler = function( event ) {
3465
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
3468
jQuery.event.special[ fix ] = {
3470
if ( attaches++ === 0 ) {
3471
document.addEventListener( orig, handler, true );
3474
teardown: function() {
3475
if ( --attaches === 0 ) {
3476
document.removeEventListener( orig, handler, true );
3547
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3549
// Attach a single capturing handler while someone wants focusin/focusout
3551
handler = function( event ) {
3552
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
3555
jQuery.event.special[ fix ] = {
3557
if ( attaches++ === 0 ) {
3558
document.addEventListener( orig, handler, true );
3561
teardown: function() {
3562
if ( --attaches === 0 ) {
3563
document.removeEventListener( orig, handler, true );
3483
3570
jQuery.fn.extend({
3485
on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
3488
// Types can be a map of types/handlers
3489
if ( typeof types === "object" ) {
3490
// ( types-Object, selector, data )
3491
if ( typeof selector !== "string" ) { // && selector != null
3492
// ( types-Object, data )
3493
data = data || selector;
3494
selector = undefined;
3496
for ( type in types ) {
3497
this.on( type, selector, data, types[ type ], one );
3502
if ( data == null && fn == null ) {
3505
data = selector = undefined;
3506
} else if ( fn == null ) {
3507
if ( typeof selector === "string" ) {
3508
// ( types, selector, fn )
3512
// ( types, data, fn )
3515
selector = undefined;
3518
if ( fn === false ) {
3526
fn = function( event ) {
3527
// Can use an empty set, since event contains the info
3528
jQuery().off( event );
3529
return origFn.apply( this, arguments );
3531
// Use same guid so caller can remove using origFn
3532
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
3534
return this.each( function() {
3535
jQuery.event.add( this, types, fn, data, selector );
3538
one: function( types, selector, data, fn ) {
3539
return this.on( types, selector, data, fn, 1 );
3541
off: function( types, selector, fn ) {
3542
var handleObj, type;
3543
if ( types && types.preventDefault && types.handleObj ) {
3544
// ( event ) dispatched jQuery.Event
3545
handleObj = types.handleObj;
3546
jQuery( types.delegateTarget ).off(
3547
handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
3553
if ( typeof types === "object" ) {
3554
// ( types-object [, selector] )
3555
for ( type in types ) {
3556
this.off( type, selector, types[ type ] );
3560
if ( selector === false || typeof selector === "function" ) {
3563
selector = undefined;
3565
if ( fn === false ) {
3568
return this.each(function() {
3569
jQuery.event.remove( this, types, fn, selector );
3573
bind: function( types, data, fn ) {
3574
return this.on( types, null, data, fn );
3576
unbind: function( types, fn ) {
3577
return this.off( types, null, fn );
3580
live: function( types, data, fn ) {
3581
jQuery( this.context ).on( types, this.selector, data, fn );
3584
die: function( types, fn ) {
3585
jQuery( this.context ).off( types, this.selector || "**", fn );
3589
delegate: function( selector, types, data, fn ) {
3590
return this.on( types, selector, data, fn );
3592
undelegate: function( selector, types, fn ) {
3593
// ( namespace ) or ( selector, types [, fn] )
3594
return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
3597
trigger: function( type, data ) {
3598
return this.each(function() {
3599
jQuery.event.trigger( type, data, this );
3602
triggerHandler: function( type, data ) {
3604
return jQuery.event.trigger( type, data, this[0], true );
3608
toggle: function( fn ) {
3609
// Save reference to arguments for access in closure
3610
var args = arguments,
3611
guid = fn.guid || jQuery.guid++,
3613
toggler = function( event ) {
3614
// Figure out which function to execute
3615
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
3616
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
3618
// Make sure that clicks stop
3619
event.preventDefault();
3621
// and execute the function
3622
return args[ lastToggle ].apply( this, arguments ) || false;
3625
// link all the functions, so any of them can unbind this click handler
3626
toggler.guid = guid;
3627
while ( i < args.length ) {
3628
args[ i++ ].guid = guid;
3631
return this.click( toggler );
3634
hover: function( fnOver, fnOut ) {
3635
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
3639
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3640
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3641
"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
3643
// Handle event binding
3644
jQuery.fn[ name ] = function( data, fn ) {
3650
return arguments.length > 0 ?
3651
this.on( name, null, data, fn ) :
3652
this.trigger( name );
3655
if ( rkeyEvent.test( name ) ) {
3656
jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
3659
if ( rmouseEvent.test( name ) ) {
3660
jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
3572
on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
3575
// Types can be a map of types/handlers
3576
if ( typeof types === "object" ) {
3577
// ( types-Object, selector, data )
3578
if ( typeof selector !== "string" ) {
3579
// ( types-Object, data )
3580
data = data || selector;
3581
selector = undefined;
3583
for ( type in types ) {
3584
this.on( type, selector, data, types[ type ], one );
3589
if ( data == null && fn == null ) {
3592
data = selector = undefined;
3593
} else if ( fn == null ) {
3594
if ( typeof selector === "string" ) {
3595
// ( types, selector, fn )
3599
// ( types, data, fn )
3602
selector = undefined;
3605
if ( fn === false ) {
3613
fn = function( event ) {
3614
// Can use an empty set, since event contains the info
3615
jQuery().off( event );
3616
return origFn.apply( this, arguments );
3618
// Use same guid so caller can remove using origFn
3619
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
3621
return this.each( function() {
3622
jQuery.event.add( this, types, fn, data, selector );
3625
one: function( types, selector, data, fn ) {
3626
return this.on( types, selector, data, fn, 1 );
3628
off: function( types, selector, fn ) {
3629
var handleObj, type;
3630
if ( types && types.preventDefault && types.handleObj ) {
3631
// ( event ) dispatched jQuery.Event
3632
handleObj = types.handleObj;
3633
jQuery( types.delegateTarget ).off(
3634
handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
3640
if ( typeof types === "object" ) {
3641
// ( types-object [, selector] )
3642
for ( type in types ) {
3643
this.off( type, selector, types[ type ] );
3647
if ( selector === false || typeof selector === "function" ) {
3650
selector = undefined;
3652
if ( fn === false ) {
3655
return this.each(function() {
3656
jQuery.event.remove( this, types, fn, selector );
3660
bind: function( types, data, fn ) {
3661
return this.on( types, null, data, fn );
3663
unbind: function( types, fn ) {
3664
return this.off( types, null, fn );
3667
delegate: function( selector, types, data, fn ) {
3668
return this.on( types, selector, data, fn );
3670
undelegate: function( selector, types, fn ) {
3671
// ( namespace ) or ( selector, types [, fn] )
3672
return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
3675
trigger: function( type, data ) {
3676
return this.each(function() {
3677
jQuery.event.trigger( type, data, this );
3680
triggerHandler: function( type, data ) {
3683
return jQuery.event.trigger( type, data, elem, true );
3664
3688
* Sizzle CSS Selector Engine
3669
3693
(function( window, undefined ) {
3682
baseHasDuplicate = true,
3683
strundefined = "undefined",
3685
expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
3688
document = window.document,
3689
docElem = document.documentElement,
3695
// Use a stripped-down indexOf if a native one is unavailable
3696
indexOf = [].indexOf || function( elem ) {
3699
for ( ; i < len; i++ ) {
3700
if ( this[i] === elem ) {
3707
// Augment a function for special use by Sizzle
3708
markFunction = function( fn, value ) {
3709
fn[ expando ] = value == null || value;
3713
createCache = function() {
3717
return markFunction(function( key, value ) {
3718
// Only keep the most recent entries
3719
if ( keys.push( key ) > Expr.cacheLength ) {
3720
delete cache[ keys.shift() ];
3723
// Retrieve with (key + " ") to avoid collision with native Object.prototype properties (see Issue #157)
3724
return (cache[ key + " " ] = value);
3728
classCache = createCache(),
3729
tokenCache = createCache(),
3730
compilerCache = createCache(),
3734
// Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
3735
whitespace = "[\\x20\\t\\r\\n\\f]",
3736
// http://www.w3.org/TR/css3-syntax/#characters
3737
characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",
3739
// Loosely modeled on CSS identifier characters
3740
// An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors)
3741
// Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
3742
identifier = characterEncoding.replace( "w", "w#" ),
3744
// Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
3745
operators = "([*^$|!~]?=)",
3746
attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
3747
"*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
3749
// Prefer arguments not in parens/brackets,
3750
// then attribute selectors and non-pseudos (denoted by :),
3751
// then anything else
3752
// These preferences are here to reduce the number of selectors
3753
// needing tokenize in the PSEUDO preFilter
3754
pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",
3756
// For matchExpr.POS and matchExpr.needsContext
3757
pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
3758
"*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",
3760
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
3761
rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
3763
rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
3764
rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),
3765
rpseudo = new RegExp( pseudos ),
3767
// Easily-parseable/retrievable ID or TAG or CLASS selectors
3768
rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,
3771
rsibling = /[\x20\t\r\n\f]*[+~]/,
3772
rendsWithNot = /:not\($/,
3775
rinputs = /input|select|textarea|button/i,
3777
rbackslash = /\\(?!\\)/g,
3780
"ID": new RegExp( "^#(" + characterEncoding + ")" ),
3781
"CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
3782
"NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
3783
"TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
3784
"ATTR": new RegExp( "^" + attributes ),
3785
"PSEUDO": new RegExp( "^" + pseudos ),
3786
"POS": new RegExp( pos, "i" ),
3787
"CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace +
3788
"*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
3789
"*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
3790
// For use in libraries implementing .is()
3791
"needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
3796
// Used for testing something on an element
3797
assert = function( fn ) {
3798
var div = document.createElement("div");
3805
// release memory in IE
3810
// Check if getElementsByTagName("*") returns only elements
3811
assertTagNameNoComments = assert(function( div ) {
3812
div.appendChild( document.createComment("") );
3813
return !div.getElementsByTagName("*").length;
3816
// Check if getAttribute returns normalized href attributes
3817
assertHrefNotNormalized = assert(function( div ) {
3818
div.innerHTML = "<a href='#'></a>";
3819
return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
3820
div.firstChild.getAttribute("href") === "#";
3823
// Check if attributes should be retrieved by attribute nodes
3824
assertAttributes = assert(function( div ) {
3825
div.innerHTML = "<select></select>";
3826
var type = typeof div.lastChild.getAttribute("multiple");
3827
// IE8 returns a string for some attributes even when not present
3828
return type !== "boolean" && type !== "string";
3831
// Check if getElementsByClassName can be trusted
3832
assertUsableClassName = assert(function( div ) {
3833
// Opera can't find a second classname (in 9.6)
3834
div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
3835
if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {
3839
// Safari 3.2 caches class attributes and doesn't catch changes
3840
div.lastChild.className = "e";
3841
return div.getElementsByClassName("e").length === 2;
3844
// Check if getElementById returns elements by name
3845
// Check if getElementsByName privileges form controls or returns elements by ID
3846
assertUsableName = assert(function( div ) {
3848
div.id = expando + 0;
3849
div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>";
3850
docElem.insertBefore( div, docElem.firstChild );
3853
var pass = document.getElementsByName &&
3854
// buggy browsers will return fewer than the correct 2
3855
document.getElementsByName( expando ).length === 2 +
3856
// buggy browsers will return more than the correct 0
3857
document.getElementsByName( expando + 0 ).length;
3858
assertGetIdNotName = !document.getElementById( expando );
3861
docElem.removeChild( div );
3866
// If slice is not available, provide a backup
3704
// Local document vars
3715
// Instance-specific data
3716
expando = "sizzle" + -(new Date()),
3717
preferredDoc = window.document,
3721
classCache = createCache(),
3722
tokenCache = createCache(),
3723
compilerCache = createCache(),
3725
// General-purpose constants
3726
strundefined = typeof undefined,
3727
MAX_NEGATIVE = 1 << 31,
3734
// Use a stripped-down indexOf if we can't use a native one
3735
indexOf = arr.indexOf || function( elem ) {
3738
for ( ; i < len; i++ ) {
3739
if ( this[i] === elem ) {
3747
// Regular expressions
3749
// Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
3750
whitespace = "[\\x20\\t\\r\\n\\f]",
3751
// http://www.w3.org/TR/css3-syntax/#characters
3752
characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
3754
// Loosely modeled on CSS identifier characters
3755
// An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
3756
// Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
3757
identifier = characterEncoding.replace( "w", "w#" ),
3759
// Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
3760
operators = "([*^$|!~]?=)",
3761
attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
3762
"*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
3764
// Prefer arguments quoted,
3765
// then not containing pseudos/brackets,
3766
// then attribute selectors/non-parenthetical expressions,
3767
// then anything else
3768
// These preferences are here to reduce the number of selectors
3769
// needing tokenize in the PSEUDO preFilter
3770
pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
3772
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
3773
rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
3775
rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
3776
rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),
3777
rpseudo = new RegExp( pseudos ),
3778
ridentifier = new RegExp( "^" + identifier + "$" ),
3781
"ID": new RegExp( "^#(" + characterEncoding + ")" ),
3782
"CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
3783
"NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
3784
"TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
3785
"ATTR": new RegExp( "^" + attributes ),
3786
"PSEUDO": new RegExp( "^" + pseudos ),
3787
"CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
3788
"*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
3789
"*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
3790
// For use in libraries implementing .is()
3791
// We use this for POS matching in `select`
3792
"needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
3793
whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
3796
rsibling = /[\x20\t\r\n\f]*[+~]/,
3798
rnative = /^[^{]+\{\s*\[native code/,
3800
// Easily-parseable/retrievable ID or TAG or CLASS selectors
3801
rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
3803
rinputs = /^(?:input|select|textarea|button)$/i,
3807
rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
3809
// CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
3810
runescape = /\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,
3811
funescape = function( _, escaped ) {
3812
var high = "0x" + escaped - 0x10000;
3813
// NaN means non-codepoint
3814
return high !== high ?
3818
String.fromCharCode( high + 0x10000 ) :
3819
// Supplemental Plane codepoint (surrogate pair)
3820
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
3823
// Use a stripped-down slice if we can't use a native one
3868
slice.call( docElem.childNodes, 0 )[0].nodeType;
3825
slice.call( preferredDoc.documentElement.childNodes, 0 )[0].nodeType;
3869
3826
} catch ( e ) {
3870
slice = function( i ) {
3873
for ( ; (elem = this[i]); i++ ) {
3874
results.push( elem );
3827
slice = function( i ) {
3830
while ( (elem = this[i++]) ) {
3831
results.push( elem );
3838
* For feature detection
3839
* @param {Function} fn The function to test for native support
3841
function isNative( fn ) {
3842
return rnative.test( fn + "" );
3846
* Create key-value caches of limited size
3847
* @returns {Function(string, Object)} Returns the Object data after storing it on itself with
3848
* property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
3849
* deleting the oldest entry
3851
function createCache() {
3855
return (cache = function( key, value ) {
3856
// Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
3857
if ( keys.push( key += " " ) > Expr.cacheLength ) {
3858
// Only keep the most recent entries
3859
delete cache[ keys.shift() ];
3861
return (cache[ key ] = value);
3866
* Mark a function for special use by Sizzle
3867
* @param {Function} fn The function to mark
3869
function markFunction( fn ) {
3870
fn[ expando ] = true;
3875
* Support testing using an element
3876
* @param {Function} fn Passed the created div and expects a boolean result
3878
function assert( fn ) {
3879
var div = document.createElement("div");
3886
// release memory in IE
3880
3891
function Sizzle( selector, context, results, seed ) {
3881
results = results || [];
3882
context = context || document;
3883
var match, elem, xml, m,
3884
nodeType = context.nodeType;
3886
if ( !selector || typeof selector !== "string" ) {
3890
if ( nodeType !== 1 && nodeType !== 9 ) {
3894
xml = isXML( context );
3896
if ( !xml && !seed ) {
3897
if ( (match = rquickExpr.exec( selector )) ) {
3898
// Speed-up: Sizzle("#ID")
3899
if ( (m = match[1]) ) {
3900
if ( nodeType === 9 ) {
3901
elem = context.getElementById( m );
3902
// Check parentNode to catch when Blackberry 4.6 returns
3903
// nodes that are no longer in the document #6963
3904
if ( elem && elem.parentNode ) {
3905
// Handle the case where IE, Opera, and Webkit return items
3906
// by name instead of ID
3907
if ( elem.id === m ) {
3908
results.push( elem );
3915
// Context is not a document
3916
if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
3917
contains( context, elem ) && elem.id === m ) {
3918
results.push( elem );
3923
// Speed-up: Sizzle("TAG")
3924
} else if ( match[2] ) {
3925
push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );
3928
// Speed-up: Sizzle(".CLASS")
3929
} else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) {
3930
push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );
3937
return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );
3892
var match, elem, m, nodeType,
3894
i, groups, old, nid, newContext, newSelector;
3896
if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
3897
setDocument( context );
3900
context = context || document;
3901
results = results || [];
3903
if ( !selector || typeof selector !== "string" ) {
3907
if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
3911
if ( !documentIsXML && !seed ) {
3914
if ( (match = rquickExpr.exec( selector )) ) {
3915
// Speed-up: Sizzle("#ID")
3916
if ( (m = match[1]) ) {
3917
if ( nodeType === 9 ) {
3918
elem = context.getElementById( m );
3919
// Check parentNode to catch when Blackberry 4.6 returns
3920
// nodes that are no longer in the document #6963
3921
if ( elem && elem.parentNode ) {
3922
// Handle the case where IE, Opera, and Webkit return items
3923
// by name instead of ID
3924
if ( elem.id === m ) {
3925
results.push( elem );
3932
// Context is not a document
3933
if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
3934
contains( context, elem ) && elem.id === m ) {
3935
results.push( elem );
3940
// Speed-up: Sizzle("TAG")
3941
} else if ( match[2] ) {
3942
push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );
3945
// Speed-up: Sizzle(".CLASS")
3946
} else if ( (m = match[3]) && support.getByClassName && context.getElementsByClassName ) {
3947
push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );
3953
if ( support.qsa && !rbuggyQSA.test(selector) ) {
3956
newContext = context;
3957
newSelector = nodeType === 9 && selector;
3959
// qSA works strangely on Element-rooted queries
3960
// We can work around this by specifying an extra ID on the root
3961
// and working up from there (Thanks to Andrew Dupont for the technique)
3962
// IE 8 doesn't work on object elements
3963
if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
3964
groups = tokenize( selector );
3966
if ( (old = context.getAttribute("id")) ) {
3967
nid = old.replace( rescape, "\\$&" );
3969
context.setAttribute( "id", nid );
3971
nid = "[id='" + nid + "'] ";
3975
groups[i] = nid + toSelector( groups[i] );
3977
newContext = rsibling.test( selector ) && context.parentNode || context;
3978
newSelector = groups.join(",");
3981
if ( newSelector ) {
3983
push.apply( results, slice.call( newContext.querySelectorAll(
3990
context.removeAttribute("id");
3998
return select( selector.replace( rtrim, "$1" ), context, results, seed );
4003
* @param {Element|Object} elem An element or a document
4005
isXML = Sizzle.isXML = function( elem ) {
4006
// documentElement is verified for cases where it doesn't yet exist
4007
// (such as loading iframes in IE - #4833)
4008
var documentElement = elem && (elem.ownerDocument || elem).documentElement;
4009
return documentElement ? documentElement.nodeName !== "HTML" : false;
4013
* Sets document-related variables once based on the current document
4014
* @param {Element|Object} [doc] An element or document object to use to set the document
4015
* @returns {Object} Returns the current document
4017
setDocument = Sizzle.setDocument = function( node ) {
4018
var doc = node ? node.ownerDocument || node : preferredDoc;
4020
// If no document and documentElement is available, return
4021
if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
4027
docElem = doc.documentElement;
4030
documentIsXML = isXML( doc );
4032
// Check if getElementsByTagName("*") returns only elements
4033
support.tagNameNoComments = assert(function( div ) {
4034
div.appendChild( doc.createComment("") );
4035
return !div.getElementsByTagName("*").length;
4038
// Check if attributes should be retrieved by attribute nodes
4039
support.attributes = assert(function( div ) {
4040
div.innerHTML = "<select></select>";
4041
var type = typeof div.lastChild.getAttribute("multiple");
4042
// IE8 returns a string for some attributes even when not present
4043
return type !== "boolean" && type !== "string";
4046
// Check if getElementsByClassName can be trusted
4047
support.getByClassName = assert(function( div ) {
4048
// Opera can't find a second classname (in 9.6)
4049
div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
4050
if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {
4054
// Safari 3.2 caches class attributes and doesn't catch changes
4055
div.lastChild.className = "e";
4056
return div.getElementsByClassName("e").length === 2;
4059
// Check if getElementById returns elements by name
4060
// Check if getElementsByName privileges form controls or returns elements by ID
4061
support.getByName = assert(function( div ) {
4063
div.id = expando + 0;
4064
div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>";
4065
docElem.insertBefore( div, docElem.firstChild );
4068
var pass = doc.getElementsByName &&
4069
// buggy browsers will return fewer than the correct 2
4070
doc.getElementsByName( expando ).length === 2 +
4071
// buggy browsers will return more than the correct 0
4072
doc.getElementsByName( expando + 0 ).length;
4073
support.getIdNotName = !doc.getElementById( expando );
4076
docElem.removeChild( div );
4081
// IE6/7 return modified attributes
4082
Expr.attrHandle = assert(function( div ) {
4083
div.innerHTML = "<a href='#'></a>";
4084
return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
4085
div.firstChild.getAttribute("href") === "#";
4089
"href": function( elem ) {
4090
return elem.getAttribute( "href", 2 );
4092
"type": function( elem ) {
4093
return elem.getAttribute("type");
4097
// ID find and filter
4098
if ( support.getIdNotName ) {
4099
Expr.find["ID"] = function( id, context ) {
4100
if ( typeof context.getElementById !== strundefined && !documentIsXML ) {
4101
var m = context.getElementById( id );
4102
// Check parentNode to catch when Blackberry 4.6 returns
4103
// nodes that are no longer in the document #6963
4104
return m && m.parentNode ? [m] : [];
4107
Expr.filter["ID"] = function( id ) {
4108
var attrId = id.replace( runescape, funescape );
4109
return function( elem ) {
4110
return elem.getAttribute("id") === attrId;
4114
Expr.find["ID"] = function( id, context ) {
4115
if ( typeof context.getElementById !== strundefined && !documentIsXML ) {
4116
var m = context.getElementById( id );
4119
m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?
4125
Expr.filter["ID"] = function( id ) {
4126
var attrId = id.replace( runescape, funescape );
4127
return function( elem ) {
4128
var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
4129
return node && node.value === attrId;
4135
Expr.find["TAG"] = support.tagNameNoComments ?
4136
function( tag, context ) {
4137
if ( typeof context.getElementsByTagName !== strundefined ) {
4138
return context.getElementsByTagName( tag );
4141
function( tag, context ) {
4145
results = context.getElementsByTagName( tag );
4147
// Filter out possible comments
4148
if ( tag === "*" ) {
4149
while ( (elem = results[i++]) ) {
4150
if ( elem.nodeType === 1 ) {
4161
Expr.find["NAME"] = support.getByName && function( tag, context ) {
4162
if ( typeof context.getElementsByName !== strundefined ) {
4163
return context.getElementsByName( name );
4168
Expr.find["CLASS"] = support.getByClassName && function( className, context ) {
4169
if ( typeof context.getElementsByClassName !== strundefined && !documentIsXML ) {
4170
return context.getElementsByClassName( className );
4174
// QSA and matchesSelector support
4176
// matchesSelector(:active) reports false when true (IE9/Opera 11.5)
4179
// qSa(:focus) reports false when true (Chrome 21),
4180
// no need to also add to buggyMatches since matches checks buggyQSA
4181
// A support test would require too much code (would include document ready)
4182
rbuggyQSA = [ ":focus" ];
4184
if ( (support.qsa = isNative(doc.querySelectorAll)) ) {
4186
// Regex strategy adopted from Diego Perini
4187
assert(function( div ) {
4188
// Select is set to empty string on purpose
4189
// This is to test IE's treatment of not explictly
4190
// setting a boolean content attribute,
4191
// since its presence should be enough
4192
// http://bugs.jquery.com/ticket/12359
4193
div.innerHTML = "<select><option selected=''></option></select>";
4195
// IE8 - Some boolean attributes are not treated correctly
4196
if ( !div.querySelectorAll("[selected]").length ) {
4197
rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );
4200
// Webkit/Opera - :checked should return selected option elements
4201
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
4202
// IE8 throws error here and will not see later tests
4203
if ( !div.querySelectorAll(":checked").length ) {
4204
rbuggyQSA.push(":checked");
4208
assert(function( div ) {
4210
// Opera 10-12/IE8 - ^= $= *= and empty values
4211
// Should not select anything
4212
div.innerHTML = "<input type='hidden' i=''/>";
4213
if ( div.querySelectorAll("[i^='']").length ) {
4214
rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
4217
// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
4218
// IE8 throws error here and will not see later tests
4219
if ( !div.querySelectorAll(":enabled").length ) {
4220
rbuggyQSA.push( ":enabled", ":disabled" );
4223
// Opera 10-11 does not throw on post-comma invalid pseudos
4224
div.querySelectorAll("*,:x");
4225
rbuggyQSA.push(",.*:");
4229
if ( (support.matchesSelector = isNative( (matches = docElem.matchesSelector ||
4230
docElem.mozMatchesSelector ||
4231
docElem.webkitMatchesSelector ||
4232
docElem.oMatchesSelector ||
4233
docElem.msMatchesSelector) )) ) {
4235
assert(function( div ) {
4236
// Check to see if it's possible to do matchesSelector
4237
// on a disconnected node (IE 9)
4238
support.disconnectedMatch = matches.call( div, "div" );
4240
// This should fail with an exception
4241
// Gecko does not error, returns false instead
4242
matches.call( div, "[s!='']:x" );
4243
rbuggyMatches.push( "!=", pseudos );
4247
rbuggyQSA = new RegExp( rbuggyQSA.join("|") );
4248
rbuggyMatches = new RegExp( rbuggyMatches.join("|") );
4250
// Element contains another
4251
// Purposefully does not implement inclusive descendent
4252
// As in, an element does not contain itself
4253
contains = isNative(docElem.contains) || docElem.compareDocumentPosition ?
4255
var adown = a.nodeType === 9 ? a.documentElement : a,
4256
bup = b && b.parentNode;
4257
return a === bup || !!( bup && bup.nodeType === 1 && (
4259
adown.contains( bup ) :
4260
a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
4265
while ( (b = b.parentNode) ) {
4274
// Document order sorting
4275
sortOrder = docElem.compareDocumentPosition ?
4280
hasDuplicate = true;
4284
if ( (compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b )) ) {
4285
if ( compare & 1 || a.parentNode && a.parentNode.nodeType === 11 ) {
4286
if ( a === doc || contains( preferredDoc, a ) ) {
4289
if ( b === doc || contains( preferredDoc, b ) ) {
4294
return compare & 4 ? -1 : 1;
4297
return a.compareDocumentPosition ? -1 : 1;
4307
// Exit early if the nodes are identical
4309
hasDuplicate = true;
4312
// Parentless nodes are either documents or disconnected
4313
} else if ( !aup || !bup ) {
4314
return a === doc ? -1 :
4320
// If the nodes are siblings, we can do a quick check
4321
} else if ( aup === bup ) {
4322
return siblingCheck( a, b );
4325
// Otherwise we need full lists of their ancestors for comparison
4327
while ( (cur = cur.parentNode) ) {
4331
while ( (cur = cur.parentNode) ) {
4335
// Walk down the tree looking for a discrepancy
4336
while ( ap[i] === bp[i] ) {
4341
// Do a sibling check if the nodes have a common ancestor
4342
siblingCheck( ap[i], bp[i] ) :
4344
// Otherwise nodes in our document sort first
4345
ap[i] === preferredDoc ? -1 :
4346
bp[i] === preferredDoc ? 1 :
4350
// Always assume the presence of duplicates if sort doesn't
4351
// pass them to our comparison function (as in Google Chrome).
4352
hasDuplicate = false;
4353
[0, 0].sort( sortOrder );
4354
support.detectDuplicates = hasDuplicate;
3940
4359
Sizzle.matches = function( expr, elements ) {
3941
return Sizzle( expr, null, null, elements );
4360
return Sizzle( expr, null, null, elements );
3944
4363
Sizzle.matchesSelector = function( elem, expr ) {
3945
return Sizzle( expr, null, null, [ elem ] ).length > 0;
4364
// Set document vars if needed
4365
if ( ( elem.ownerDocument || elem ) !== document ) {
4366
setDocument( elem );
4369
// Make sure that attribute selectors are quoted
4370
expr = expr.replace( rattributeQuotes, "='$1']" );
4372
// rbuggyQSA always contains :focus, so no need for an existence check
4373
if ( support.matchesSelector && !documentIsXML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && !rbuggyQSA.test(expr) ) {
4375
var ret = matches.call( elem, expr );
4377
// IE 9's matchesSelector returns false on disconnected nodes
4378
if ( ret || support.disconnectedMatch ||
4379
// As well, disconnected nodes are said to be in a document
4381
elem.document && elem.document.nodeType !== 11 ) {
4387
return Sizzle( expr, document, null, [elem] ).length > 0;
4390
Sizzle.contains = function( context, elem ) {
4391
// Set document vars if needed
4392
if ( ( context.ownerDocument || context ) !== document ) {
4393
setDocument( context );
4395
return contains( context, elem );
4398
Sizzle.attr = function( elem, name ) {
4401
// Set document vars if needed
4402
if ( ( elem.ownerDocument || elem ) !== document ) {
4403
setDocument( elem );
4406
if ( !documentIsXML ) {
4407
name = name.toLowerCase();
4409
if ( (val = Expr.attrHandle[ name ]) ) {
4412
if ( documentIsXML || support.attributes ) {
4413
return elem.getAttribute( name );
4415
return ( (val = elem.getAttributeNode( name )) || elem.getAttribute( name ) ) && elem[ name ] === true ?
4417
val && val.specified ? val.value : null;
4420
Sizzle.error = function( msg ) {
4421
throw new Error( "Syntax error, unrecognized expression: " + msg );
4424
// Document sorting and removing duplicates
4425
Sizzle.uniqueSort = function( results ) {
4431
// Unless we *know* we can detect duplicates, assume their presence
4432
hasDuplicate = !support.detectDuplicates;
4433
results.sort( sortOrder );
4435
if ( hasDuplicate ) {
4436
for ( ; (elem = results[i]); i++ ) {
4437
if ( elem === results[ i - 1 ] ) {
4438
j = duplicates.push( i );
4442
results.splice( duplicates[ j ], 1 );
4449
function siblingCheck( a, b ) {
4451
diff = cur && ( ~b.sourceIndex || MAX_NEGATIVE ) - ( ~a.sourceIndex || MAX_NEGATIVE );
4453
// Use IE sourceIndex if available on both nodes
4458
// Check if b follows a
4460
while ( (cur = cur.nextSibling) ) {
3948
4470
// Returns a function to use in pseudos for input types
3949
4471
function createInputPseudo( type ) {
3950
return function( elem ) {
3951
var name = elem.nodeName.toLowerCase();
3952
return name === "input" && elem.type === type;
4472
return function( elem ) {
4473
var name = elem.nodeName.toLowerCase();
4474
return name === "input" && elem.type === type;
3956
4478
// Returns a function to use in pseudos for buttons
3957
4479
function createButtonPseudo( type ) {
3958
return function( elem ) {
3959
var name = elem.nodeName.toLowerCase();
3960
return (name === "input" || name === "button") && elem.type === type;
4480
return function( elem ) {
4481
var name = elem.nodeName.toLowerCase();
4482
return (name === "input" || name === "button") && elem.type === type;
3964
4486
// Returns a function to use in pseudos for positionals
3965
4487
function createPositionalPseudo( fn ) {
3966
return markFunction(function( argument ) {
3967
argument = +argument;
3968
return markFunction(function( seed, matches ) {
3970
matchIndexes = fn( [], seed.length, argument ),
3971
i = matchIndexes.length;
4488
return markFunction(function( argument ) {
4489
argument = +argument;
4490
return markFunction(function( seed, matches ) {
4492
matchIndexes = fn( [], seed.length, argument ),
4493
i = matchIndexes.length;
3973
// Match elements found at the specified indexes
3975
if ( seed[ (j = matchIndexes[i]) ] ) {
3976
seed[j] = !(matches[j] = seed[j]);
4495
// Match elements found at the specified indexes
4497
if ( seed[ (j = matchIndexes[i]) ] ) {
4498
seed[j] = !(matches[j] = seed[j]);
3985
4507
* @param {Array|Element} elem
3987
4509
getText = Sizzle.getText = function( elem ) {
3991
nodeType = elem.nodeType;
3994
if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
3995
// Use textContent for elements
3996
// innerText usage removed for consistency of new lines (see #11153)
3997
if ( typeof elem.textContent === "string" ) {
3998
return elem.textContent;
4000
// Traverse its children
4001
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
4002
ret += getText( elem );
4005
} else if ( nodeType === 3 || nodeType === 4 ) {
4006
return elem.nodeValue;
4008
// Do not include comment or processing instruction nodes
4011
// If no nodeType, this is expected to be an array
4012
for ( ; (node = elem[i]); i++ ) {
4013
// Do not traverse comment nodes
4014
ret += getText( node );
4020
isXML = Sizzle.isXML = function( elem ) {
4021
// documentElement is verified for cases where it doesn't yet exist
4022
// (such as loading iframes in IE - #4833)
4023
var documentElement = elem && (elem.ownerDocument || elem).documentElement;
4024
return documentElement ? documentElement.nodeName !== "HTML" : false;
4027
// Element contains another
4028
contains = Sizzle.contains = docElem.contains ?
4030
var adown = a.nodeType === 9 ? a.documentElement : a,
4031
bup = b && b.parentNode;
4032
return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) );
4034
docElem.compareDocumentPosition ?
4036
return b && !!( a.compareDocumentPosition( b ) & 16 );
4039
while ( (b = b.parentNode) ) {
4047
Sizzle.attr = function( elem, name ) {
4049
xml = isXML( elem );
4052
name = name.toLowerCase();
4054
if ( (val = Expr.attrHandle[ name ]) ) {
4057
if ( xml || assertAttributes ) {
4058
return elem.getAttribute( name );
4060
val = elem.getAttributeNode( name );
4062
typeof elem[ name ] === "boolean" ?
4063
elem[ name ] ? name : null :
4064
val.specified ? val.value : null :
4513
nodeType = elem.nodeType;
4516
// If no nodeType, this is expected to be an array
4517
for ( ; (node = elem[i]); i++ ) {
4518
// Do not traverse comment nodes
4519
ret += getText( node );
4521
} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
4522
// Use textContent for elements
4523
// innerText usage removed for consistency of new lines (see #11153)
4524
if ( typeof elem.textContent === "string" ) {
4525
return elem.textContent;
4527
// Traverse its children
4528
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
4529
ret += getText( elem );
4532
} else if ( nodeType === 3 || nodeType === 4 ) {
4533
return elem.nodeValue;
4535
// Do not include comment or processing instruction nodes
4068
4540
Expr = Sizzle.selectors = {
4070
// Can be adjusted by the user
4073
createPseudo: markFunction,
4077
// IE6/7 return a modified href
4078
attrHandle: assertHrefNotNormalized ?
4081
"href": function( elem ) {
4082
return elem.getAttribute( "href", 2 );
4084
"type": function( elem ) {
4085
return elem.getAttribute("type");
4090
"ID": assertGetIdNotName ?
4091
function( id, context, xml ) {
4092
if ( typeof context.getElementById !== strundefined && !xml ) {
4093
var m = context.getElementById( id );
4094
// Check parentNode to catch when Blackberry 4.6 returns
4095
// nodes that are no longer in the document #6963
4096
return m && m.parentNode ? [m] : [];
4099
function( id, context, xml ) {
4100
if ( typeof context.getElementById !== strundefined && !xml ) {
4101
var m = context.getElementById( id );
4104
m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?
4111
"TAG": assertTagNameNoComments ?
4112
function( tag, context ) {
4113
if ( typeof context.getElementsByTagName !== strundefined ) {
4114
return context.getElementsByTagName( tag );
4117
function( tag, context ) {
4118
var results = context.getElementsByTagName( tag );
4120
// Filter out possible comments
4121
if ( tag === "*" ) {
4126
for ( ; (elem = results[i]); i++ ) {
4127
if ( elem.nodeType === 1 ) {
4137
"NAME": assertUsableName && function( tag, context ) {
4138
if ( typeof context.getElementsByName !== strundefined ) {
4139
return context.getElementsByName( name );
4143
"CLASS": assertUsableClassName && function( className, context, xml ) {
4144
if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
4145
return context.getElementsByClassName( className );
4151
">": { dir: "parentNode", first: true },
4152
" ": { dir: "parentNode" },
4153
"+": { dir: "previousSibling", first: true },
4154
"~": { dir: "previousSibling" }
4158
"ATTR": function( match ) {
4159
match[1] = match[1].replace( rbackslash, "" );
4161
// Move the given value to match[3] whether quoted or unquoted
4162
match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" );
4164
if ( match[2] === "~=" ) {
4165
match[3] = " " + match[3] + " ";
4168
return match.slice( 0, 4 );
4171
"CHILD": function( match ) {
4172
/* matches from matchExpr["CHILD"]
4173
1 type (only|nth|...)
4174
2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
4175
3 xn-component of xn+y argument ([+-]?\d*n|)
4176
4 sign of xn-component
4178
6 sign of y-component
4181
match[1] = match[1].toLowerCase();
4183
if ( match[1] === "nth" ) {
4184
// nth-child requires argument
4186
Sizzle.error( match[0] );
4189
// numeric x and y parameters for Expr.filter.CHILD
4190
// remember that false/true cast respectively to 0/1
4191
match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) );
4192
match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" );
4194
// other types prohibit arguments
4195
} else if ( match[2] ) {
4196
Sizzle.error( match[0] );
4202
"PSEUDO": function( match ) {
4203
var unquoted, excess;
4204
if ( matchExpr["CHILD"].test( match[0] ) ) {
4209
match[2] = match[3];
4210
} else if ( (unquoted = match[4]) ) {
4211
// Only check arguments that contain a pseudo
4212
if ( rpseudo.test(unquoted) &&
4213
// Get excess from tokenize (recursively)
4214
(excess = tokenize( unquoted, true )) &&
4215
// advance to the next closing parenthesis
4216
(excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
4218
// excess is a negative index
4219
unquoted = unquoted.slice( 0, excess );
4220
match[0] = match[0].slice( 0, excess );
4222
match[2] = unquoted;
4225
// Return only captures needed by the pseudo filter method (type and argument)
4226
return match.slice( 0, 3 );
4231
"ID": assertGetIdNotName ?
4233
id = id.replace( rbackslash, "" );
4234
return function( elem ) {
4235
return elem.getAttribute("id") === id;
4239
id = id.replace( rbackslash, "" );
4240
return function( elem ) {
4241
var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
4242
return node && node.value === id;
4246
"TAG": function( nodeName ) {
4247
if ( nodeName === "*" ) {
4248
return function() { return true; };
4250
nodeName = nodeName.replace( rbackslash, "" ).toLowerCase();
4252
return function( elem ) {
4253
return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
4257
"CLASS": function( className ) {
4258
var pattern = classCache[ expando ][ className + " " ];
4261
(pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
4262
classCache( className, function( elem ) {
4263
return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
4267
"ATTR": function( name, operator, check ) {
4268
return function( elem, context ) {
4269
var result = Sizzle.attr( elem, name );
4271
if ( result == null ) {
4272
return operator === "!=";
4280
return operator === "=" ? result === check :
4281
operator === "!=" ? result !== check :
4282
operator === "^=" ? check && result.indexOf( check ) === 0 :
4283
operator === "*=" ? check && result.indexOf( check ) > -1 :
4284
operator === "$=" ? check && result.substr( result.length - check.length ) === check :
4285
operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
4286
operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :
4291
"CHILD": function( type, argument, first, last ) {
4293
if ( type === "nth" ) {
4294
return function( elem ) {
4296
parent = elem.parentNode;
4298
if ( first === 1 && last === 0 ) {
4304
for ( node = parent.firstChild; node; node = node.nextSibling ) {
4305
if ( node.nodeType === 1 ) {
4307
if ( elem === node ) {
4314
// Incorporate the offset (or cast to NaN), then check against cycle size
4316
return diff === first || ( diff % first === 0 && diff / first >= 0 );
4320
return function( elem ) {
4326
while ( (node = node.previousSibling) ) {
4327
if ( node.nodeType === 1 ) {
4332
if ( type === "first" ) {
4340
while ( (node = node.nextSibling) ) {
4341
if ( node.nodeType === 1 ) {
4351
"PSEUDO": function( pseudo, argument ) {
4352
// pseudo-class names are case-insensitive
4353
// http://www.w3.org/TR/selectors/#pseudo-classes
4354
// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
4355
// Remember that setFilters inherits from pseudos
4357
fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
4358
Sizzle.error( "unsupported pseudo: " + pseudo );
4360
// The user may use createPseudo to indicate that
4361
// arguments are needed to create the filter function
4362
// just as Sizzle does
4363
if ( fn[ expando ] ) {
4364
return fn( argument );
4367
// But maintain support for old signatures
4368
if ( fn.length > 1 ) {
4369
args = [ pseudo, pseudo, "", argument ];
4370
return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
4371
markFunction(function( seed, matches ) {
4373
matched = fn( seed, argument ),
4376
idx = indexOf.call( seed, matched[i] );
4377
seed[ idx ] = !( matches[ idx ] = matched[i] );
4381
return fn( elem, 0, args );
4390
"not": markFunction(function( selector ) {
4391
// Trim the selector passed to compile
4392
// to avoid treating leading and trailing
4393
// spaces as combinators
4396
matcher = compile( selector.replace( rtrim, "$1" ) );
4398
return matcher[ expando ] ?
4399
markFunction(function( seed, matches, context, xml ) {
4401
unmatched = matcher( seed, null, xml, [] ),
4404
// Match elements unmatched by `matcher`
4406
if ( (elem = unmatched[i]) ) {
4407
seed[i] = !(matches[i] = elem);
4411
function( elem, context, xml ) {
4413
matcher( input, null, xml, results );
4414
return !results.pop();
4418
"has": markFunction(function( selector ) {
4419
return function( elem ) {
4420
return Sizzle( selector, elem ).length > 0;
4424
"contains": markFunction(function( text ) {
4425
return function( elem ) {
4426
return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
4430
"enabled": function( elem ) {
4431
return elem.disabled === false;
4434
"disabled": function( elem ) {
4435
return elem.disabled === true;
4438
"checked": function( elem ) {
4439
// In CSS3, :checked should return both checked and selected elements
4440
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
4441
var nodeName = elem.nodeName.toLowerCase();
4442
return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
4445
"selected": function( elem ) {
4446
// Accessing this property makes selected-by-default
4447
// options in Safari work properly
4448
if ( elem.parentNode ) {
4449
elem.parentNode.selectedIndex;
4452
return elem.selected === true;
4455
"parent": function( elem ) {
4456
return !Expr.pseudos["empty"]( elem );
4459
"empty": function( elem ) {
4460
// http://www.w3.org/TR/selectors/#empty-pseudo
4461
// :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
4462
// not comment, processing instructions, or others
4463
// Thanks to Diego Perini for the nodeName shortcut
4464
// Greater than "@" means alpha characters (specifically not starting with "#" or "?")
4466
elem = elem.firstChild;
4468
if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) {
4471
elem = elem.nextSibling;
4476
"header": function( elem ) {
4477
return rheader.test( elem.nodeName );
4480
"text": function( elem ) {
4482
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
4483
// use getAttribute instead to test this case
4484
return elem.nodeName.toLowerCase() === "input" &&
4485
(type = elem.type) === "text" &&
4486
( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type );
4490
"radio": createInputPseudo("radio"),
4491
"checkbox": createInputPseudo("checkbox"),
4492
"file": createInputPseudo("file"),
4493
"password": createInputPseudo("password"),
4494
"image": createInputPseudo("image"),
4496
"submit": createButtonPseudo("submit"),
4497
"reset": createButtonPseudo("reset"),
4499
"button": function( elem ) {
4500
var name = elem.nodeName.toLowerCase();
4501
return name === "input" && elem.type === "button" || name === "button";
4504
"input": function( elem ) {
4505
return rinputs.test( elem.nodeName );
4508
"focus": function( elem ) {
4509
var doc = elem.ownerDocument;
4510
return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
4513
"active": function( elem ) {
4514
return elem === elem.ownerDocument.activeElement;
4518
"first": createPositionalPseudo(function() {
4522
"last": createPositionalPseudo(function( matchIndexes, length ) {
4523
return [ length - 1 ];
4526
"eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
4527
return [ argument < 0 ? argument + length : argument ];
4530
"even": createPositionalPseudo(function( matchIndexes, length ) {
4531
for ( var i = 0; i < length; i += 2 ) {
4532
matchIndexes.push( i );
4534
return matchIndexes;
4537
"odd": createPositionalPseudo(function( matchIndexes, length ) {
4538
for ( var i = 1; i < length; i += 2 ) {
4539
matchIndexes.push( i );
4541
return matchIndexes;
4544
"lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
4545
for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) {
4546
matchIndexes.push( i );
4548
return matchIndexes;
4551
"gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
4552
for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) {
4553
matchIndexes.push( i );
4555
return matchIndexes;
4560
function siblingCheck( a, b, ret ) {
4565
var cur = a.nextSibling;
4572
cur = cur.nextSibling;
4578
sortOrder = docElem.compareDocumentPosition ?
4581
hasDuplicate = true;
4585
return ( !a.compareDocumentPosition || !b.compareDocumentPosition ?
4586
a.compareDocumentPosition :
4587
a.compareDocumentPosition(b) & 4
4591
// The nodes are identical, we can exit early
4593
hasDuplicate = true;
4596
// Fallback to using sourceIndex (in IE) if it's available on both nodes
4597
} else if ( a.sourceIndex && b.sourceIndex ) {
4598
return a.sourceIndex - b.sourceIndex;
4608
// If the nodes are siblings (or identical) we can do a quick check
4609
if ( aup === bup ) {
4610
return siblingCheck( a, b );
4612
// If no parents were found then the nodes are disconnected
4613
} else if ( !aup ) {
4616
} else if ( !bup ) {
4620
// Otherwise they're somewhere else in the tree so we need
4621
// to build up a full list of the parentNodes for comparison
4624
cur = cur.parentNode;
4631
cur = cur.parentNode;
4637
// Start walking down the tree looking for a discrepancy
4638
for ( var i = 0; i < al && i < bl; i++ ) {
4639
if ( ap[i] !== bp[i] ) {
4640
return siblingCheck( ap[i], bp[i] );
4644
// We ended someplace up the tree so do a sibling check
4646
siblingCheck( a, bp[i], -1 ) :
4647
siblingCheck( ap[i], b, 1 );
4650
// Always assume the presence of duplicates if sort doesn't
4651
// pass them to our comparison function (as in Google Chrome).
4652
[0, 0].sort( sortOrder );
4653
baseHasDuplicate = !hasDuplicate;
4655
// Document sorting and removing duplicates
4656
Sizzle.uniqueSort = function( results ) {
4662
hasDuplicate = baseHasDuplicate;
4663
results.sort( sortOrder );
4665
if ( hasDuplicate ) {
4666
for ( ; (elem = results[i]); i++ ) {
4667
if ( elem === results[ i - 1 ] ) {
4668
j = duplicates.push( i );
4672
results.splice( duplicates[ j ], 1 );
4679
Sizzle.error = function( msg ) {
4680
throw new Error( "Syntax error, unrecognized expression: " + msg );
4542
// Can be adjusted by the user
4545
createPseudo: markFunction,
4552
">": { dir: "parentNode", first: true },
4553
" ": { dir: "parentNode" },
4554
"+": { dir: "previousSibling", first: true },
4555
"~": { dir: "previousSibling" }
4559
"ATTR": function( match ) {
4560
match[1] = match[1].replace( runescape, funescape );
4562
// Move the given value to match[3] whether quoted or unquoted
4563
match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
4565
if ( match[2] === "~=" ) {
4566
match[3] = " " + match[3] + " ";
4569
return match.slice( 0, 4 );
4572
"CHILD": function( match ) {
4573
/* matches from matchExpr["CHILD"]
4574
1 type (only|nth|...)
4575
2 what (child|of-type)
4576
3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
4577
4 xn-component of xn+y argument ([+-]?\d*n|)
4578
5 sign of xn-component
4580
7 sign of y-component
4583
match[1] = match[1].toLowerCase();
4585
if ( match[1].slice( 0, 3 ) === "nth" ) {
4586
// nth-* requires argument
4588
Sizzle.error( match[0] );
4591
// numeric x and y parameters for Expr.filter.CHILD
4592
// remember that false/true cast respectively to 0/1
4593
match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
4594
match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
4596
// other types prohibit arguments
4597
} else if ( match[3] ) {
4598
Sizzle.error( match[0] );
4604
"PSEUDO": function( match ) {
4606
unquoted = !match[5] && match[2];
4608
if ( matchExpr["CHILD"].test( match[0] ) ) {
4612
// Accept quoted arguments as-is
4614
match[2] = match[4];
4616
// Strip excess characters from unquoted arguments
4617
} else if ( unquoted && rpseudo.test( unquoted ) &&
4618
// Get excess from tokenize (recursively)
4619
(excess = tokenize( unquoted, true )) &&
4620
// advance to the next closing parenthesis
4621
(excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
4623
// excess is a negative index
4624
match[0] = match[0].slice( 0, excess );
4625
match[2] = unquoted.slice( 0, excess );
4628
// Return only captures needed by the pseudo filter method (type and argument)
4629
return match.slice( 0, 3 );
4635
"TAG": function( nodeName ) {
4636
if ( nodeName === "*" ) {
4637
return function() { return true; };
4640
nodeName = nodeName.replace( runescape, funescape ).toLowerCase();
4641
return function( elem ) {
4642
return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
4646
"CLASS": function( className ) {
4647
var pattern = classCache[ className + " " ];
4650
(pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
4651
classCache( className, function( elem ) {
4652
return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
4656
"ATTR": function( name, operator, check ) {
4657
return function( elem ) {
4658
var result = Sizzle.attr( elem, name );
4660
if ( result == null ) {
4661
return operator === "!=";
4669
return operator === "=" ? result === check :
4670
operator === "!=" ? result !== check :
4671
operator === "^=" ? check && result.indexOf( check ) === 0 :
4672
operator === "*=" ? check && result.indexOf( check ) > -1 :
4673
operator === "$=" ? check && result.slice( -check.length ) === check :
4674
operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
4675
operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
4680
"CHILD": function( type, what, argument, first, last ) {
4681
var simple = type.slice( 0, 3 ) !== "nth",
4682
forward = type.slice( -4 ) !== "last",
4683
ofType = what === "of-type";
4685
return first === 1 && last === 0 ?
4687
// Shortcut for :nth-*(n)
4689
return !!elem.parentNode;
4692
function( elem, context, xml ) {
4693
var cache, outerCache, node, diff, nodeIndex, start,
4694
dir = simple !== forward ? "nextSibling" : "previousSibling",
4695
parent = elem.parentNode,
4696
name = ofType && elem.nodeName.toLowerCase(),
4697
useCache = !xml && !ofType;
4701
// :(first|last|only)-(child|of-type)
4705
while ( (node = node[ dir ]) ) {
4706
if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
4710
// Reverse direction for :only-* (if we haven't yet done so)
4711
start = dir = type === "only" && !start && "nextSibling";
4716
start = [ forward ? parent.firstChild : parent.lastChild ];
4718
// non-xml :nth-child(...) stores cache data on `parent`
4719
if ( forward && useCache ) {
4720
// Seek `elem` from a previously-cached index
4721
outerCache = parent[ expando ] || (parent[ expando ] = {});
4722
cache = outerCache[ type ] || [];
4723
nodeIndex = cache[0] === dirruns && cache[1];
4724
diff = cache[0] === dirruns && cache[2];
4725
node = nodeIndex && parent.childNodes[ nodeIndex ];
4727
while ( (node = ++nodeIndex && node && node[ dir ] ||
4729
// Fallback to seeking `elem` from the start
4730
(diff = nodeIndex = 0) || start.pop()) ) {
4732
// When found, cache indexes on `parent` and break
4733
if ( node.nodeType === 1 && ++diff && node === elem ) {
4734
outerCache[ type ] = [ dirruns, nodeIndex, diff ];
4739
// Use previously-cached element index if available
4740
} else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
4743
// xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
4745
// Use the same loop as above to seek `elem` from the start
4746
while ( (node = ++nodeIndex && node && node[ dir ] ||
4747
(diff = nodeIndex = 0) || start.pop()) ) {
4749
if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
4750
// Cache the index of each encountered element
4752
(node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
4755
if ( node === elem ) {
4762
// Incorporate the offset, then check against cycle size
4764
return diff === first || ( diff % first === 0 && diff / first >= 0 );
4769
"PSEUDO": function( pseudo, argument ) {
4770
// pseudo-class names are case-insensitive
4771
// http://www.w3.org/TR/selectors/#pseudo-classes
4772
// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
4773
// Remember that setFilters inherits from pseudos
4775
fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
4776
Sizzle.error( "unsupported pseudo: " + pseudo );
4778
// The user may use createPseudo to indicate that
4779
// arguments are needed to create the filter function
4780
// just as Sizzle does
4781
if ( fn[ expando ] ) {
4782
return fn( argument );
4785
// But maintain support for old signatures
4786
if ( fn.length > 1 ) {
4787
args = [ pseudo, pseudo, "", argument ];
4788
return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
4789
markFunction(function( seed, matches ) {
4791
matched = fn( seed, argument ),
4794
idx = indexOf.call( seed, matched[i] );
4795
seed[ idx ] = !( matches[ idx ] = matched[i] );
4799
return fn( elem, 0, args );
4808
// Potentially complex pseudos
4809
"not": markFunction(function( selector ) {
4810
// Trim the selector passed to compile
4811
// to avoid treating leading and trailing
4812
// spaces as combinators
4815
matcher = compile( selector.replace( rtrim, "$1" ) );
4817
return matcher[ expando ] ?
4818
markFunction(function( seed, matches, context, xml ) {
4820
unmatched = matcher( seed, null, xml, [] ),
4823
// Match elements unmatched by `matcher`
4825
if ( (elem = unmatched[i]) ) {
4826
seed[i] = !(matches[i] = elem);
4830
function( elem, context, xml ) {
4832
matcher( input, null, xml, results );
4833
return !results.pop();
4837
"has": markFunction(function( selector ) {
4838
return function( elem ) {
4839
return Sizzle( selector, elem ).length > 0;
4843
"contains": markFunction(function( text ) {
4844
return function( elem ) {
4845
return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
4849
// "Whether an element is represented by a :lang() selector
4850
// is based solely on the element's language value
4851
// being equal to the identifier C,
4852
// or beginning with the identifier C immediately followed by "-".
4853
// The matching of C against the element's language value is performed case-insensitively.
4854
// The identifier C does not have to be a valid language name."
4855
// http://www.w3.org/TR/selectors/#lang-pseudo
4856
"lang": markFunction( function( lang ) {
4857
// lang value must be a valid identifider
4858
if ( !ridentifier.test(lang || "") ) {
4859
Sizzle.error( "unsupported lang: " + lang );
4861
lang = lang.replace( runescape, funescape ).toLowerCase();
4862
return function( elem ) {
4865
if ( (elemLang = documentIsXML ?
4866
elem.getAttribute("xml:lang") || elem.getAttribute("lang") :
4869
elemLang = elemLang.toLowerCase();
4870
return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
4872
} while ( (elem = elem.parentNode) && elem.nodeType === 1 );
4878
"target": function( elem ) {
4879
var hash = window.location && window.location.hash;
4880
return hash && hash.slice( 1 ) === elem.id;
4883
"root": function( elem ) {
4884
return elem === docElem;
4887
"focus": function( elem ) {
4888
return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
4891
// Boolean properties
4892
"enabled": function( elem ) {
4893
return elem.disabled === false;
4896
"disabled": function( elem ) {
4897
return elem.disabled === true;
4900
"checked": function( elem ) {
4901
// In CSS3, :checked should return both checked and selected elements
4902
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
4903
var nodeName = elem.nodeName.toLowerCase();
4904
return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
4907
"selected": function( elem ) {
4908
// Accessing this property makes selected-by-default
4909
// options in Safari work properly
4910
if ( elem.parentNode ) {
4911
elem.parentNode.selectedIndex;
4914
return elem.selected === true;
4918
"empty": function( elem ) {
4919
// http://www.w3.org/TR/selectors/#empty-pseudo
4920
// :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
4921
// not comment, processing instructions, or others
4922
// Thanks to Diego Perini for the nodeName shortcut
4923
// Greater than "@" means alpha characters (specifically not starting with "#" or "?")
4924
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
4925
if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) {
4932
"parent": function( elem ) {
4933
return !Expr.pseudos["empty"]( elem );
4936
// Element/input types
4937
"header": function( elem ) {
4938
return rheader.test( elem.nodeName );
4941
"input": function( elem ) {
4942
return rinputs.test( elem.nodeName );
4945
"button": function( elem ) {
4946
var name = elem.nodeName.toLowerCase();
4947
return name === "input" && elem.type === "button" || name === "button";
4950
"text": function( elem ) {
4952
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
4953
// use getAttribute instead to test this case
4954
return elem.nodeName.toLowerCase() === "input" &&
4955
elem.type === "text" &&
4956
( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type );
4959
// Position-in-collection
4960
"first": createPositionalPseudo(function() {
4964
"last": createPositionalPseudo(function( matchIndexes, length ) {
4965
return [ length - 1 ];
4968
"eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
4969
return [ argument < 0 ? argument + length : argument ];
4972
"even": createPositionalPseudo(function( matchIndexes, length ) {
4974
for ( ; i < length; i += 2 ) {
4975
matchIndexes.push( i );
4977
return matchIndexes;
4980
"odd": createPositionalPseudo(function( matchIndexes, length ) {
4982
for ( ; i < length; i += 2 ) {
4983
matchIndexes.push( i );
4985
return matchIndexes;
4988
"lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
4989
var i = argument < 0 ? argument + length : argument;
4990
for ( ; --i >= 0; ) {
4991
matchIndexes.push( i );
4993
return matchIndexes;
4996
"gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
4997
var i = argument < 0 ? argument + length : argument;
4998
for ( ; ++i < length; ) {
4999
matchIndexes.push( i );
5001
return matchIndexes;
5006
// Add button/input type pseudos
5007
for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
5008
Expr.pseudos[ i ] = createInputPseudo( i );
5010
for ( i in { submit: true, reset: true } ) {
5011
Expr.pseudos[ i ] = createButtonPseudo( i );
4683
5014
function tokenize( selector, parseOnly ) {
4684
var matched, match, tokens, type,
4685
soFar, groups, preFilters,
4686
cached = tokenCache[ expando ][ selector + " " ];
4689
return parseOnly ? 0 : cached.slice( 0 );
4694
preFilters = Expr.preFilter;
4698
// Comma and first run
4699
if ( !matched || (match = rcomma.exec( soFar )) ) {
4701
// Don't consume trailing commas as valid
4702
soFar = soFar.slice( match[0].length ) || soFar;
4704
groups.push( tokens = [] );
4710
if ( (match = rcombinators.exec( soFar )) ) {
4711
tokens.push( matched = new Token( match.shift() ) );
4712
soFar = soFar.slice( matched.length );
4714
// Cast descendant combinators to space
4715
matched.type = match[0].replace( rtrim, " " );
4719
for ( type in Expr.filter ) {
4720
if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
4721
(match = preFilters[ type ]( match ))) ) {
4723
tokens.push( matched = new Token( match.shift() ) );
4724
soFar = soFar.slice( matched.length );
4725
matched.type = type;
4726
matched.matches = match;
4735
// Return the length of the invalid excess
4736
// if we're just parsing
4737
// Otherwise, throw an error or return tokens
4741
Sizzle.error( selector ) :
4743
tokenCache( selector, groups ).slice( 0 );
5015
var matched, match, tokens, type,
5016
soFar, groups, preFilters,
5017
cached = tokenCache[ selector + " " ];
5020
return parseOnly ? 0 : cached.slice( 0 );
5025
preFilters = Expr.preFilter;
5029
// Comma and first run
5030
if ( !matched || (match = rcomma.exec( soFar )) ) {
5032
// Don't consume trailing commas as valid
5033
soFar = soFar.slice( match[0].length ) || soFar;
5035
groups.push( tokens = [] );
5041
if ( (match = rcombinators.exec( soFar )) ) {
5042
matched = match.shift();
5045
// Cast descendant combinators to space
5046
type: match[0].replace( rtrim, " " )
5048
soFar = soFar.slice( matched.length );
5052
for ( type in Expr.filter ) {
5053
if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
5054
(match = preFilters[ type ]( match ))) ) {
5055
matched = match.shift();
5061
soFar = soFar.slice( matched.length );
5070
// Return the length of the invalid excess
5071
// if we're just parsing
5072
// Otherwise, throw an error or return tokens
5076
Sizzle.error( selector ) :
5078
tokenCache( selector, groups ).slice( 0 );
5081
function toSelector( tokens ) {
5083
len = tokens.length,
5085
for ( ; i < len; i++ ) {
5086
selector += tokens[i].value;
4746
5091
function addCombinator( matcher, combinator, base ) {
4747
var dir = combinator.dir,
4748
checkNonElements = base && combinator.dir === "parentNode",
4751
return combinator.first ?
4752
// Check against closest ancestor/preceding element
4753
function( elem, context, xml ) {
4754
while ( (elem = elem[ dir ]) ) {
4755
if ( checkNonElements || elem.nodeType === 1 ) {
4756
return matcher( elem, context, xml );
4761
// Check against all ancestor/preceding elements
4762
function( elem, context, xml ) {
4763
// We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
4766
dirkey = dirruns + " " + doneName + " ",
4767
cachedkey = dirkey + cachedruns;
4768
while ( (elem = elem[ dir ]) ) {
4769
if ( checkNonElements || elem.nodeType === 1 ) {
4770
if ( (cache = elem[ expando ]) === cachedkey ) {
4772
} else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
4773
if ( elem.sizset ) {
4777
elem[ expando ] = cachedkey;
4778
if ( matcher( elem, context, xml ) ) {
4782
elem.sizset = false;
4787
while ( (elem = elem[ dir ]) ) {
4788
if ( checkNonElements || elem.nodeType === 1 ) {
4789
if ( matcher( elem, context, xml ) ) {
5092
var dir = combinator.dir,
5093
checkNonElements = base && dir === "parentNode",
5096
return combinator.first ?
5097
// Check against closest ancestor/preceding element
5098
function( elem, context, xml ) {
5099
while ( (elem = elem[ dir ]) ) {
5100
if ( elem.nodeType === 1 || checkNonElements ) {
5101
return matcher( elem, context, xml );
5106
// Check against all ancestor/preceding elements
5107
function( elem, context, xml ) {
5108
var data, cache, outerCache,
5109
dirkey = dirruns + " " + doneName;
5111
// We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
5113
while ( (elem = elem[ dir ]) ) {
5114
if ( elem.nodeType === 1 || checkNonElements ) {
5115
if ( matcher( elem, context, xml ) ) {
5121
while ( (elem = elem[ dir ]) ) {
5122
if ( elem.nodeType === 1 || checkNonElements ) {
5123
outerCache = elem[ expando ] || (elem[ expando ] = {});
5124
if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) {
5125
if ( (data = cache[1]) === true || data === cachedruns ) {
5126
return data === true;
5129
cache = outerCache[ dir ] = [ dirkey ];
5130
cache[1] = matcher( elem, context, xml ) || cachedruns;
5131
if ( cache[1] === true ) {
4798
5141
function elementMatcher( matchers ) {
4799
return matchers.length > 1 ?
4800
function( elem, context, xml ) {
4801
var i = matchers.length;
4803
if ( !matchers[i]( elem, context, xml ) ) {
5142
return matchers.length > 1 ?
5143
function( elem, context, xml ) {
5144
var i = matchers.length;
5146
if ( !matchers[i]( elem, context, xml ) ) {
4812
5155
function condense( unmatched, map, filter, context, xml ) {
4816
len = unmatched.length,
4817
mapped = map != null;
4819
for ( ; i < len; i++ ) {
4820
if ( (elem = unmatched[i]) ) {
4821
if ( !filter || filter( elem, context, xml ) ) {
4822
newUnmatched.push( elem );
4830
return newUnmatched;
5159
len = unmatched.length,
5160
mapped = map != null;
5162
for ( ; i < len; i++ ) {
5163
if ( (elem = unmatched[i]) ) {
5164
if ( !filter || filter( elem, context, xml ) ) {
5165
newUnmatched.push( elem );
5173
return newUnmatched;
4833
5176
function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
4834
if ( postFilter && !postFilter[ expando ] ) {
4835
postFilter = setMatcher( postFilter );
4837
if ( postFinder && !postFinder[ expando ] ) {
4838
postFinder = setMatcher( postFinder, postSelector );
4840
return markFunction(function( seed, results, context, xml ) {
4844
preexisting = results.length,
4846
// Get initial elements from seed or context
4847
elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
4849
// Prefilter to get matcher input, preserving a map for seed-results synchronization
4850
matcherIn = preFilter && ( seed || !selector ) ?
4851
condense( elems, preMap, preFilter, context, xml ) :
4854
matcherOut = matcher ?
4855
// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
4856
postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
4858
// ...intermediate processing is necessary
4861
// ...otherwise use results directly
4865
// Find primary matches
4867
matcher( matcherIn, matcherOut, context, xml );
4872
temp = condense( matcherOut, postMap );
4873
postFilter( temp, [], context, xml );
4875
// Un-match failing elements by moving them back to matcherIn
4878
if ( (elem = temp[i]) ) {
4879
matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
4885
if ( postFinder || preFilter ) {
4887
// Get the final matcherOut by condensing this intermediate into postFinder contexts
4889
i = matcherOut.length;
4891
if ( (elem = matcherOut[i]) ) {
4892
// Restore matcherIn since elem is not yet a final match
4893
temp.push( (matcherIn[i] = elem) );
4896
postFinder( null, (matcherOut = []), temp, xml );
4899
// Move matched elements from seed to results to keep them synchronized
4900
i = matcherOut.length;
4902
if ( (elem = matcherOut[i]) &&
4903
(temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
4905
seed[temp] = !(results[temp] = elem);
4910
// Add elements to results, through postFinder if defined
4912
matcherOut = condense(
4913
matcherOut === results ?
4914
matcherOut.splice( preexisting, matcherOut.length ) :
4918
postFinder( null, results, matcherOut, xml );
4920
push.apply( results, matcherOut );
5177
if ( postFilter && !postFilter[ expando ] ) {
5178
postFilter = setMatcher( postFilter );
5180
if ( postFinder && !postFinder[ expando ] ) {
5181
postFinder = setMatcher( postFinder, postSelector );
5183
return markFunction(function( seed, results, context, xml ) {
5187
preexisting = results.length,
5189
// Get initial elements from seed or context
5190
elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
5192
// Prefilter to get matcher input, preserving a map for seed-results synchronization
5193
matcherIn = preFilter && ( seed || !selector ) ?
5194
condense( elems, preMap, preFilter, context, xml ) :
5197
matcherOut = matcher ?
5198
// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
5199
postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
5201
// ...intermediate processing is necessary
5204
// ...otherwise use results directly
5208
// Find primary matches
5210
matcher( matcherIn, matcherOut, context, xml );
5215
temp = condense( matcherOut, postMap );
5216
postFilter( temp, [], context, xml );
5218
// Un-match failing elements by moving them back to matcherIn
5221
if ( (elem = temp[i]) ) {
5222
matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
5228
if ( postFinder || preFilter ) {
5230
// Get the final matcherOut by condensing this intermediate into postFinder contexts
5232
i = matcherOut.length;
5234
if ( (elem = matcherOut[i]) ) {
5235
// Restore matcherIn since elem is not yet a final match
5236
temp.push( (matcherIn[i] = elem) );
5239
postFinder( null, (matcherOut = []), temp, xml );
5242
// Move matched elements from seed to results to keep them synchronized
5243
i = matcherOut.length;
5245
if ( (elem = matcherOut[i]) &&
5246
(temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
5248
seed[temp] = !(results[temp] = elem);
5253
// Add elements to results, through postFinder if defined
5255
matcherOut = condense(
5256
matcherOut === results ?
5257
matcherOut.splice( preexisting, matcherOut.length ) :
5261
postFinder( null, results, matcherOut, xml );
5263
push.apply( results, matcherOut );
4926
5269
function matcherFromTokens( tokens ) {
4927
var checkContext, matcher, j,
4928
len = tokens.length,
4929
leadingRelative = Expr.relative[ tokens[0].type ],
4930
implicitRelative = leadingRelative || Expr.relative[" "],
4931
i = leadingRelative ? 1 : 0,
4933
// The foundational matcher ensures that elements are reachable from top-level context(s)
4934
matchContext = addCombinator( function( elem ) {
4935
return elem === checkContext;
4936
}, implicitRelative, true ),
4937
matchAnyContext = addCombinator( function( elem ) {
4938
return indexOf.call( checkContext, elem ) > -1;
4939
}, implicitRelative, true ),
4940
matchers = [ function( elem, context, xml ) {
4941
return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
4942
(checkContext = context).nodeType ?
4943
matchContext( elem, context, xml ) :
4944
matchAnyContext( elem, context, xml ) );
4947
for ( ; i < len; i++ ) {
4948
if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
4949
matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
4951
matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
4953
// Return special upon seeing a positional matcher
4954
if ( matcher[ expando ] ) {
4955
// Find the next relative operator (if any) for proper handling
4957
for ( ; j < len; j++ ) {
4958
if ( Expr.relative[ tokens[j].type ] ) {
4963
i > 1 && elementMatcher( matchers ),
4964
i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ),
4966
i < j && matcherFromTokens( tokens.slice( i, j ) ),
4967
j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
4968
j < len && tokens.join("")
4971
matchers.push( matcher );
4975
return elementMatcher( matchers );
5270
var checkContext, matcher, j,
5271
len = tokens.length,
5272
leadingRelative = Expr.relative[ tokens[0].type ],
5273
implicitRelative = leadingRelative || Expr.relative[" "],
5274
i = leadingRelative ? 1 : 0,
5276
// The foundational matcher ensures that elements are reachable from top-level context(s)
5277
matchContext = addCombinator( function( elem ) {
5278
return elem === checkContext;
5279
}, implicitRelative, true ),
5280
matchAnyContext = addCombinator( function( elem ) {
5281
return indexOf.call( checkContext, elem ) > -1;
5282
}, implicitRelative, true ),
5283
matchers = [ function( elem, context, xml ) {
5284
return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
5285
(checkContext = context).nodeType ?
5286
matchContext( elem, context, xml ) :
5287
matchAnyContext( elem, context, xml ) );
5290
for ( ; i < len; i++ ) {
5291
if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
5292
matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
5294
matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
5296
// Return special upon seeing a positional matcher
5297
if ( matcher[ expando ] ) {
5298
// Find the next relative operator (if any) for proper handling
5300
for ( ; j < len; j++ ) {
5301
if ( Expr.relative[ tokens[j].type ] ) {
5306
i > 1 && elementMatcher( matchers ),
5307
i > 1 && toSelector( tokens.slice( 0, i - 1 ) ).replace( rtrim, "$1" ),
5309
i < j && matcherFromTokens( tokens.slice( i, j ) ),
5310
j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
5311
j < len && toSelector( tokens )
5314
matchers.push( matcher );
5318
return elementMatcher( matchers );
4978
5321
function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
4979
var bySet = setMatchers.length > 0,
4980
byElement = elementMatchers.length > 0,
4981
superMatcher = function( seed, context, xml, results, expandContext ) {
4982
var elem, j, matcher,
4986
unmatched = seed && [],
4987
outermost = expandContext != null,
4988
contextBackup = outermostContext,
4989
// We must always have either seed elements or context
4990
elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
4991
// Nested matchers should use non-integer dirruns
4992
dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);
4995
outermostContext = context !== document && context;
4996
cachedruns = superMatcher.el;
4999
// Add elements passing elementMatchers directly to results
5000
for ( ; (elem = elems[i]) != null; i++ ) {
5001
if ( byElement && elem ) {
5002
for ( j = 0; (matcher = elementMatchers[j]); j++ ) {
5003
if ( matcher( elem, context, xml ) ) {
5004
results.push( elem );
5009
dirruns = dirrunsUnique;
5010
cachedruns = ++superMatcher.el;
5014
// Track unmatched elements for set filters
5016
// They will have gone through all possible matchers
5017
if ( (elem = !matcher && elem) ) {
5021
// Lengthen the array for every element, matched or not
5023
unmatched.push( elem );
5028
// Apply set filters to unmatched elements
5030
if ( bySet && i !== matchedCount ) {
5031
for ( j = 0; (matcher = setMatchers[j]); j++ ) {
5032
matcher( unmatched, setMatched, context, xml );
5036
// Reintegrate element matches to eliminate the need for sorting
5037
if ( matchedCount > 0 ) {
5039
if ( !(unmatched[i] || setMatched[i]) ) {
5040
setMatched[i] = pop.call( results );
5045
// Discard index placeholder values to get only actual matches
5046
setMatched = condense( setMatched );
5049
// Add matches to results
5050
push.apply( results, setMatched );
5052
// Seedless set matches succeeding multiple successful matchers stipulate sorting
5053
if ( outermost && !seed && setMatched.length > 0 &&
5054
( matchedCount + setMatchers.length ) > 1 ) {
5056
Sizzle.uniqueSort( results );
5060
// Override manipulation of globals by nested matchers
5062
dirruns = dirrunsUnique;
5063
outermostContext = contextBackup;
5069
superMatcher.el = 0;
5071
markFunction( superMatcher ) :
5322
// A counter to specify which element is currently being matched
5323
var matcherCachedRuns = 0,
5324
bySet = setMatchers.length > 0,
5325
byElement = elementMatchers.length > 0,
5326
superMatcher = function( seed, context, xml, results, expandContext ) {
5327
var elem, j, matcher,
5331
unmatched = seed && [],
5332
outermost = expandContext != null,
5333
contextBackup = outermostContext,
5334
// We must always have either seed elements or context
5335
elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
5336
// Use integer dirruns iff this is the outermost matcher
5337
dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1);
5340
outermostContext = context !== document && context;
5341
cachedruns = matcherCachedRuns;
5344
// Add elements passing elementMatchers directly to results
5345
// Keep `i` a string if there are no elements so `matchedCount` will be "00" below
5346
for ( ; (elem = elems[i]) != null; i++ ) {
5347
if ( byElement && elem ) {
5349
while ( (matcher = elementMatchers[j++]) ) {
5350
if ( matcher( elem, context, xml ) ) {
5351
results.push( elem );
5356
dirruns = dirrunsUnique;
5357
cachedruns = ++matcherCachedRuns;
5361
// Track unmatched elements for set filters
5363
// They will have gone through all possible matchers
5364
if ( (elem = !matcher && elem) ) {
5368
// Lengthen the array for every element, matched or not
5370
unmatched.push( elem );
5375
// Apply set filters to unmatched elements
5377
if ( bySet && i !== matchedCount ) {
5379
while ( (matcher = setMatchers[j++]) ) {
5380
matcher( unmatched, setMatched, context, xml );
5384
// Reintegrate element matches to eliminate the need for sorting
5385
if ( matchedCount > 0 ) {
5387
if ( !(unmatched[i] || setMatched[i]) ) {
5388
setMatched[i] = pop.call( results );
5393
// Discard index placeholder values to get only actual matches
5394
setMatched = condense( setMatched );
5397
// Add matches to results
5398
push.apply( results, setMatched );
5400
// Seedless set matches succeeding multiple successful matchers stipulate sorting
5401
if ( outermost && !seed && setMatched.length > 0 &&
5402
( matchedCount + setMatchers.length ) > 1 ) {
5404
Sizzle.uniqueSort( results );
5408
// Override manipulation of globals by nested matchers
5410
dirruns = dirrunsUnique;
5411
outermostContext = contextBackup;
5418
markFunction( superMatcher ) :
5075
5422
compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
5078
elementMatchers = [],
5079
cached = compilerCache[ expando ][ selector + " " ];
5082
// Generate a function of recursive functions that can be used to check each element
5084
group = tokenize( selector );
5088
cached = matcherFromTokens( group[i] );
5089
if ( cached[ expando ] ) {
5090
setMatchers.push( cached );
5092
elementMatchers.push( cached );
5096
// Cache the compiled function
5097
cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
5425
elementMatchers = [],
5426
cached = compilerCache[ selector + " " ];
5429
// Generate a function of recursive functions that can be used to check each element
5431
group = tokenize( selector );
5435
cached = matcherFromTokens( group[i] );
5436
if ( cached[ expando ] ) {
5437
setMatchers.push( cached );
5439
elementMatchers.push( cached );
5443
// Cache the compiled function
5444
cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
5102
5449
function multipleContexts( selector, contexts, results ) {
5104
len = contexts.length;
5105
for ( ; i < len; i++ ) {
5106
Sizzle( selector, contexts[i], results );
5111
function select( selector, context, results, seed, xml ) {
5112
var i, tokens, token, type, find,
5113
match = tokenize( selector ),
5117
// Try to minimize operations if there is only one group
5118
if ( match.length === 1 ) {
5120
// Take a shortcut and set the context if the root selector is an ID
5121
tokens = match[0] = match[0].slice( 0 );
5122
if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
5123
context.nodeType === 9 && !xml &&
5124
Expr.relative[ tokens[1].type ] ) {
5126
context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0];
5131
selector = selector.slice( tokens.shift().length );
5134
// Fetch a seed set for right-to-left matching
5135
for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {
5138
// Abort if we hit a combinator
5139
if ( Expr.relative[ (type = token.type) ] ) {
5142
if ( (find = Expr.find[ type ]) ) {
5143
// Search, expanding context for leading sibling combinators
5145
token.matches[0].replace( rbackslash, "" ),
5146
rsibling.test( tokens[0].type ) && context.parentNode || context,
5150
// If seed is empty or no tokens remain, we can return early
5151
tokens.splice( i, 1 );
5152
selector = seed.length && tokens.join("");
5154
push.apply( results, slice.call( seed, 0 ) );
5165
// Compile and execute a filtering function
5166
// Provide `match` to avoid retokenization if we modified the selector above
5167
compile( selector, match )(
5172
rsibling.test( selector )
5177
if ( document.querySelectorAll ) {
5179
var disconnectedMatch,
5182
rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
5184
// qSa(:focus) reports false when true (Chrome 21), no need to also add to buggyMatches since matches checks buggyQSA
5185
// A support test would require too much code (would include document ready)
5186
rbuggyQSA = [ ":focus" ],
5188
// matchesSelector(:active) reports false when true (IE9/Opera 11.5)
5189
// A support test would require too much code (would include document ready)
5190
// just skip matchesSelector for :active
5191
rbuggyMatches = [ ":active" ],
5192
matches = docElem.matchesSelector ||
5193
docElem.mozMatchesSelector ||
5194
docElem.webkitMatchesSelector ||
5195
docElem.oMatchesSelector ||
5196
docElem.msMatchesSelector;
5199
// Regex strategy adopted from Diego Perini
5200
assert(function( div ) {
5201
// Select is set to empty string on purpose
5202
// This is to test IE's treatment of not explictly
5203
// setting a boolean content attribute,
5204
// since its presence should be enough
5205
// http://bugs.jquery.com/ticket/12359
5206
div.innerHTML = "<select><option selected=''></option></select>";
5208
// IE8 - Some boolean attributes are not treated correctly
5209
if ( !div.querySelectorAll("[selected]").length ) {
5210
rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );
5213
// Webkit/Opera - :checked should return selected option elements
5214
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
5215
// IE8 throws error here (do not put tests after this one)
5216
if ( !div.querySelectorAll(":checked").length ) {
5217
rbuggyQSA.push(":checked");
5221
assert(function( div ) {
5223
// Opera 10-12/IE9 - ^= $= *= and empty values
5224
// Should not select anything
5225
div.innerHTML = "<p test=''></p>";
5226
if ( div.querySelectorAll("[test^='']").length ) {
5227
rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
5230
// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
5231
// IE8 throws error here (do not put tests after this one)
5232
div.innerHTML = "<input type='hidden'/>";
5233
if ( !div.querySelectorAll(":enabled").length ) {
5234
rbuggyQSA.push(":enabled", ":disabled");
5238
// rbuggyQSA always contains :focus, so no need for a length check
5239
rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") );
5241
select = function( selector, context, results, seed, xml ) {
5242
// Only use querySelectorAll when not filtering,
5243
// when this is not xml,
5244
// and when no QSA bugs apply
5245
if ( !seed && !xml && !rbuggyQSA.test( selector ) ) {
5249
newContext = context,
5250
newSelector = context.nodeType === 9 && selector;
5252
// qSA works strangely on Element-rooted queries
5253
// We can work around this by specifying an extra ID on the root
5254
// and working up from there (Thanks to Andrew Dupont for the technique)
5255
// IE 8 doesn't work on object elements
5256
if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
5257
groups = tokenize( selector );
5259
if ( (old = context.getAttribute("id")) ) {
5260
nid = old.replace( rescape, "\\$&" );
5262
context.setAttribute( "id", nid );
5264
nid = "[id='" + nid + "'] ";
5268
groups[i] = nid + groups[i].join("");
5270
newContext = rsibling.test( selector ) && context.parentNode || context;
5271
newSelector = groups.join(",");
5274
if ( newSelector ) {
5276
push.apply( results, slice.call( newContext.querySelectorAll(
5283
context.removeAttribute("id");
5289
return oldSelect( selector, context, results, seed, xml );
5293
assert(function( div ) {
5294
// Check to see if it's possible to do matchesSelector
5295
// on a disconnected node (IE 9)
5296
disconnectedMatch = matches.call( div, "div" );
5298
// This should fail with an exception
5299
// Gecko does not error, returns false instead
5301
matches.call( div, "[test!='']:sizzle" );
5302
rbuggyMatches.push( "!=", pseudos );
5306
// rbuggyMatches always contains :active and :focus, so no need for a length check
5307
rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
5309
Sizzle.matchesSelector = function( elem, expr ) {
5310
// Make sure that attribute selectors are quoted
5311
expr = expr.replace( rattributeQuotes, "='$1']" );
5313
// rbuggyMatches always contains :active, so no need for an existence check
5314
if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && !rbuggyQSA.test( expr ) ) {
5316
var ret = matches.call( elem, expr );
5318
// IE 9's matchesSelector returns false on disconnected nodes
5319
if ( ret || disconnectedMatch ||
5320
// As well, disconnected nodes are said to be in a document
5322
elem.document && elem.document.nodeType !== 11 ) {
5328
return Sizzle( expr, null, null, [ elem ] ).length > 0;
5451
len = contexts.length;
5452
for ( ; i < len; i++ ) {
5453
Sizzle( selector, contexts[i], results );
5458
function select( selector, context, results, seed ) {
5459
var i, tokens, token, type, find,
5460
match = tokenize( selector );
5463
// Try to minimize operations if there is only one group
5464
if ( match.length === 1 ) {
5466
// Take a shortcut and set the context if the root selector is an ID
5467
tokens = match[0] = match[0].slice( 0 );
5468
if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
5469
context.nodeType === 9 && !documentIsXML &&
5470
Expr.relative[ tokens[1].type ] ) {
5472
context = Expr.find["ID"]( token.matches[0].replace( runescape, funescape ), context )[0];
5477
selector = selector.slice( tokens.shift().value.length );
5480
// Fetch a seed set for right-to-left matching
5481
i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
5485
// Abort if we hit a combinator
5486
if ( Expr.relative[ (type = token.type) ] ) {
5489
if ( (find = Expr.find[ type ]) ) {
5490
// Search, expanding context for leading sibling combinators
5492
token.matches[0].replace( runescape, funescape ),
5493
rsibling.test( tokens[0].type ) && context.parentNode || context
5496
// If seed is empty or no tokens remain, we can return early
5497
tokens.splice( i, 1 );
5498
selector = seed.length && toSelector( tokens );
5500
push.apply( results, slice.call( seed, 0 ) );
5511
// Compile and execute a filtering function
5512
// Provide `match` to avoid retokenization if we modified the selector above
5513
compile( selector, match )(
5518
rsibling.test( selector )
5335
5524
Expr.pseudos["nth"] = Expr.pseudos["eq"];
5526
// Easy API for creating new setFilters
5338
5527
function setFilters() {}
5339
5528
Expr.filters = setFilters.prototype = Expr.pseudos;
5340
5529
Expr.setFilters = new setFilters();
5531
// Initialize with the default document
5342
5534
// Override sizzle attribute retrieval
5343
5535
Sizzle.attr = jQuery.attr;
5344
5536
jQuery.find = Sizzle;
5354
5546
var runtil = /Until$/,
5355
rparentsprev = /^(?:parents|prev(?:Until|All))/,
5356
isSimple = /^.[^:#\[\.,]*$/,
5357
rneedsContext = jQuery.expr.match.needsContext,
5358
// methods guaranteed to produce a unique set when starting from a unique set
5359
guaranteedUnique = {
5547
rparentsprev = /^(?:parents|prev(?:Until|All))/,
5548
isSimple = /^.[^:#\[\.,]*$/,
5549
rneedsContext = jQuery.expr.match.needsContext,
5550
// methods guaranteed to produce a unique set when starting from a unique set
5551
guaranteedUnique = {
5366
5558
jQuery.fn.extend({
5367
find: function( selector ) {
5368
var i, l, length, n, r, ret,
5371
if ( typeof selector !== "string" ) {
5372
return jQuery( selector ).filter(function() {
5373
for ( i = 0, l = self.length; i < l; i++ ) {
5374
if ( jQuery.contains( self[ i ], this ) ) {
5381
ret = this.pushStack( "", "find", selector );
5383
for ( i = 0, l = this.length; i < l; i++ ) {
5384
length = ret.length;
5385
jQuery.find( selector, this[i], ret );
5388
// Make sure that the results are unique
5389
for ( n = length; n < ret.length; n++ ) {
5390
for ( r = 0; r < length; r++ ) {
5391
if ( ret[r] === ret[n] ) {
5403
has: function( target ) {
5405
targets = jQuery( target, this ),
5406
len = targets.length;
5408
return this.filter(function() {
5409
for ( i = 0; i < len; i++ ) {
5410
if ( jQuery.contains( this, targets[i] ) ) {
5417
not: function( selector ) {
5418
return this.pushStack( winnow(this, selector, false), "not", selector);
5421
filter: function( selector ) {
5422
return this.pushStack( winnow(this, selector, true), "filter", selector );
5425
is: function( selector ) {
5426
return !!selector && (
5427
typeof selector === "string" ?
5428
// If this is a positional/relative selector, check membership in the returned set
5429
// so $("p:first").is("p:last") won't return true for a doc with two "p".
5430
rneedsContext.test( selector ) ?
5431
jQuery( selector, this.context ).index( this[0] ) >= 0 :
5432
jQuery.filter( selector, this ).length > 0 :
5433
this.filter( selector ).length > 0 );
5436
closest: function( selectors, context ) {
5441
pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
5442
jQuery( selectors, context || this.context ) :
5445
for ( ; i < l; i++ ) {
5448
while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
5449
if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
5453
cur = cur.parentNode;
5457
ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
5459
return this.pushStack( ret, "closest", selectors );
5462
// Determine the position of an element within
5463
// the matched set of elements
5464
index: function( elem ) {
5466
// No argument, return index in parent
5468
return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
5471
// index in selector
5472
if ( typeof elem === "string" ) {
5473
return jQuery.inArray( this[0], jQuery( elem ) );
5476
// Locate the position of the desired element
5477
return jQuery.inArray(
5478
// If it receives a jQuery object, the first element is used
5479
elem.jquery ? elem[0] : elem, this );
5482
add: function( selector, context ) {
5483
var set = typeof selector === "string" ?
5484
jQuery( selector, context ) :
5485
jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5486
all = jQuery.merge( this.get(), set );
5488
return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
5490
jQuery.unique( all ) );
5493
addBack: function( selector ) {
5494
return this.add( selector == null ?
5495
this.prevObject : this.prevObject.filter(selector)
5559
find: function( selector ) {
5563
if ( typeof selector !== "string" ) {
5565
return this.pushStack( jQuery( selector ).filter(function() {
5566
for ( i = 0; i < len; i++ ) {
5567
if ( jQuery.contains( self[ i ], this ) ) {
5575
for ( i = 0; i < len; i++ ) {
5576
jQuery.find( selector, this[ i ], ret );
5579
// Needed because $( selector, context ) becomes $( context ).find( selector )
5580
ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
5581
ret.selector = ( this.selector ? this.selector + " " : "" ) + selector;
5585
has: function( target ) {
5587
targets = jQuery( target, this ),
5588
len = targets.length;
5590
return this.filter(function() {
5591
for ( i = 0; i < len; i++ ) {
5592
if ( jQuery.contains( this, targets[i] ) ) {
5599
not: function( selector ) {
5600
return this.pushStack( winnow(this, selector, false) );
5603
filter: function( selector ) {
5604
return this.pushStack( winnow(this, selector, true) );
5607
is: function( selector ) {
5608
return !!selector && (
5609
typeof selector === "string" ?
5610
// If this is a positional/relative selector, check membership in the returned set
5611
// so $("p:first").is("p:last") won't return true for a doc with two "p".
5612
rneedsContext.test( selector ) ?
5613
jQuery( selector, this.context ).index( this[0] ) >= 0 :
5614
jQuery.filter( selector, this ).length > 0 :
5615
this.filter( selector ).length > 0 );
5618
closest: function( selectors, context ) {
5623
pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
5624
jQuery( selectors, context || this.context ) :
5627
for ( ; i < l; i++ ) {
5630
while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
5631
if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
5635
cur = cur.parentNode;
5639
return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret );
5642
// Determine the position of an element within
5643
// the matched set of elements
5644
index: function( elem ) {
5646
// No argument, return index in parent
5648
return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
5651
// index in selector
5652
if ( typeof elem === "string" ) {
5653
return jQuery.inArray( this[0], jQuery( elem ) );
5656
// Locate the position of the desired element
5657
return jQuery.inArray(
5658
// If it receives a jQuery object, the first element is used
5659
elem.jquery ? elem[0] : elem, this );
5662
add: function( selector, context ) {
5663
var set = typeof selector === "string" ?
5664
jQuery( selector, context ) :
5665
jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5666
all = jQuery.merge( this.get(), set );
5668
return this.pushStack( jQuery.unique(all) );
5671
addBack: function( selector ) {
5672
return this.add( selector == null ?
5673
this.prevObject : this.prevObject.filter(selector)
5500
5678
jQuery.fn.andSelf = jQuery.fn.addBack;
5502
// A painfully simple check to see if an element is disconnected
5503
// from a document (should be improved, where feasible).
5504
function isDisconnected( node ) {
5505
return !node || !node.parentNode || node.parentNode.nodeType === 11;
5508
5680
function sibling( cur, dir ) {
5511
} while ( cur && cur.nodeType !== 1 );
5683
} while ( cur && cur.nodeType !== 1 );
5517
parent: function( elem ) {
5518
var parent = elem.parentNode;
5519
return parent && parent.nodeType !== 11 ? parent : null;
5521
parents: function( elem ) {
5522
return jQuery.dir( elem, "parentNode" );
5524
parentsUntil: function( elem, i, until ) {
5525
return jQuery.dir( elem, "parentNode", until );
5527
next: function( elem ) {
5528
return sibling( elem, "nextSibling" );
5530
prev: function( elem ) {
5531
return sibling( elem, "previousSibling" );
5533
nextAll: function( elem ) {
5534
return jQuery.dir( elem, "nextSibling" );
5536
prevAll: function( elem ) {
5537
return jQuery.dir( elem, "previousSibling" );
5539
nextUntil: function( elem, i, until ) {
5540
return jQuery.dir( elem, "nextSibling", until );
5542
prevUntil: function( elem, i, until ) {
5543
return jQuery.dir( elem, "previousSibling", until );
5545
siblings: function( elem ) {
5546
return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
5548
children: function( elem ) {
5549
return jQuery.sibling( elem.firstChild );
5551
contents: function( elem ) {
5552
return jQuery.nodeName( elem, "iframe" ) ?
5553
elem.contentDocument || elem.contentWindow.document :
5554
jQuery.merge( [], elem.childNodes );
5689
parent: function( elem ) {
5690
var parent = elem.parentNode;
5691
return parent && parent.nodeType !== 11 ? parent : null;
5693
parents: function( elem ) {
5694
return jQuery.dir( elem, "parentNode" );
5696
parentsUntil: function( elem, i, until ) {
5697
return jQuery.dir( elem, "parentNode", until );
5699
next: function( elem ) {
5700
return sibling( elem, "nextSibling" );
5702
prev: function( elem ) {
5703
return sibling( elem, "previousSibling" );
5705
nextAll: function( elem ) {
5706
return jQuery.dir( elem, "nextSibling" );
5708
prevAll: function( elem ) {
5709
return jQuery.dir( elem, "previousSibling" );
5711
nextUntil: function( elem, i, until ) {
5712
return jQuery.dir( elem, "nextSibling", until );
5714
prevUntil: function( elem, i, until ) {
5715
return jQuery.dir( elem, "previousSibling", until );
5717
siblings: function( elem ) {
5718
return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
5720
children: function( elem ) {
5721
return jQuery.sibling( elem.firstChild );
5723
contents: function( elem ) {
5724
return jQuery.nodeName( elem, "iframe" ) ?
5725
elem.contentDocument || elem.contentWindow.document :
5726
jQuery.merge( [], elem.childNodes );
5556
5728
}, function( name, fn ) {
5557
jQuery.fn[ name ] = function( until, selector ) {
5558
var ret = jQuery.map( this, fn, until );
5560
if ( !runtil.test( name ) ) {
5564
if ( selector && typeof selector === "string" ) {
5565
ret = jQuery.filter( selector, ret );
5568
ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
5570
if ( this.length > 1 && rparentsprev.test( name ) ) {
5571
ret = ret.reverse();
5574
return this.pushStack( ret, name, core_slice.call( arguments ).join(",") );
5729
jQuery.fn[ name ] = function( until, selector ) {
5730
var ret = jQuery.map( this, fn, until );
5732
if ( !runtil.test( name ) ) {
5736
if ( selector && typeof selector === "string" ) {
5737
ret = jQuery.filter( selector, ret );
5740
ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
5742
if ( this.length > 1 && rparentsprev.test( name ) ) {
5743
ret = ret.reverse();
5746
return this.pushStack( ret );
5578
5750
jQuery.extend({
5579
filter: function( expr, elems, not ) {
5581
expr = ":not(" + expr + ")";
5584
return elems.length === 1 ?
5585
jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
5586
jQuery.find.matches(expr, elems);
5589
dir: function( elem, dir, until ) {
5593
while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5594
if ( cur.nodeType === 1 ) {
5595
matched.push( cur );
5602
sibling: function( n, elem ) {
5605
for ( ; n; n = n.nextSibling ) {
5606
if ( n.nodeType === 1 && n !== elem ) {
5751
filter: function( expr, elems, not ) {
5753
expr = ":not(" + expr + ")";
5756
return elems.length === 1 ?
5757
jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
5758
jQuery.find.matches(expr, elems);
5761
dir: function( elem, dir, until ) {
5765
while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5766
if ( cur.nodeType === 1 ) {
5767
matched.push( cur );
5774
sibling: function( n, elem ) {
5777
for ( ; n; n = n.nextSibling ) {
5778
if ( n.nodeType === 1 && n !== elem ) {
5615
5787
// Implement the identical functionality for filter and not
5616
5788
function winnow( elements, qualifier, keep ) {
5618
// Can't pass null or undefined to indexOf in Firefox 4
5619
// Set to 0 to skip string check
5620
qualifier = qualifier || 0;
5622
if ( jQuery.isFunction( qualifier ) ) {
5623
return jQuery.grep(elements, function( elem, i ) {
5624
var retVal = !!qualifier.call( elem, i, elem );
5625
return retVal === keep;
5628
} else if ( qualifier.nodeType ) {
5629
return jQuery.grep(elements, function( elem, i ) {
5630
return ( elem === qualifier ) === keep;
5633
} else if ( typeof qualifier === "string" ) {
5634
var filtered = jQuery.grep(elements, function( elem ) {
5635
return elem.nodeType === 1;
5638
if ( isSimple.test( qualifier ) ) {
5639
return jQuery.filter(qualifier, filtered, !keep);
5641
qualifier = jQuery.filter( qualifier, filtered );
5645
return jQuery.grep(elements, function( elem, i ) {
5646
return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
5790
// Can't pass null or undefined to indexOf in Firefox 4
5791
// Set to 0 to skip string check
5792
qualifier = qualifier || 0;
5794
if ( jQuery.isFunction( qualifier ) ) {
5795
return jQuery.grep(elements, function( elem, i ) {
5796
var retVal = !!qualifier.call( elem, i, elem );
5797
return retVal === keep;
5800
} else if ( qualifier.nodeType ) {
5801
return jQuery.grep(elements, function( elem ) {
5802
return ( elem === qualifier ) === keep;
5805
} else if ( typeof qualifier === "string" ) {
5806
var filtered = jQuery.grep(elements, function( elem ) {
5807
return elem.nodeType === 1;
5810
if ( isSimple.test( qualifier ) ) {
5811
return jQuery.filter(qualifier, filtered, !keep);
5813
qualifier = jQuery.filter( qualifier, filtered );
5817
return jQuery.grep(elements, function( elem ) {
5818
return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
5649
5821
function createSafeFragment( document ) {
5650
var list = nodeNames.split( "|" ),
5651
safeFrag = document.createDocumentFragment();
5822
var list = nodeNames.split( "|" ),
5823
safeFrag = document.createDocumentFragment();
5653
if ( safeFrag.createElement ) {
5654
while ( list.length ) {
5655
safeFrag.createElement(
5825
if ( safeFrag.createElement ) {
5826
while ( list.length ) {
5827
safeFrag.createElement(
5663
5835
var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
5664
"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
5665
rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
5666
rleadingWhitespace = /^\s+/,
5667
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
5668
rtagName = /<([\w:]+)/,
5670
rhtml = /<|&#?\w+;/,
5671
rnoInnerhtml = /<(?:script|style|link)/i,
5672
rnocache = /<(?:script|object|embed|option|style)/i,
5673
rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
5674
rcheckableType = /^(?:checkbox|radio)$/,
5675
// checked="checked" or checked
5676
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5677
rscriptType = /\/(java|ecma)script/i,
5678
rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,
5680
option: [ 1, "<select multiple='multiple'>", "</select>" ],
5681
legend: [ 1, "<fieldset>", "</fieldset>" ],
5682
thead: [ 1, "<table>", "</table>" ],
5683
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5684
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5685
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5686
area: [ 1, "<map>", "</map>" ],
5687
_default: [ 0, "", "" ]
5689
safeFragment = createSafeFragment( document ),
5690
fragmentDiv = safeFragment.appendChild( document.createElement("div") );
5836
"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
5837
rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
5838
rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
5839
rleadingWhitespace = /^\s+/,
5840
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
5841
rtagName = /<([\w:]+)/,
5843
rhtml = /<|&#?\w+;/,
5844
rnoInnerhtml = /<(?:script|style|link)/i,
5845
manipulation_rcheckableType = /^(?:checkbox|radio)$/i,
5846
// checked="checked" or checked
5847
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5848
rscriptType = /^$|\/(?:java|ecma)script/i,
5849
rscriptTypeMasked = /^true\/(.*)/,
5850
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
5852
// We have to close these tags to support XHTML (#13200)
5854
option: [ 1, "<select multiple='multiple'>", "</select>" ],
5855
legend: [ 1, "<fieldset>", "</fieldset>" ],
5856
area: [ 1, "<map>", "</map>" ],
5857
param: [ 1, "<object>", "</object>" ],
5858
thead: [ 1, "<table>", "</table>" ],
5859
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5860
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5861
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5863
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
5864
// unless wrapped in a div with non-breaking characters in front of it.
5865
_default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
5867
safeFragment = createSafeFragment( document ),
5868
fragmentDiv = safeFragment.appendChild( document.createElement("div") );
5692
5870
wrapMap.optgroup = wrapMap.option;
5693
5871
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5694
5872
wrapMap.th = wrapMap.td;
5696
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
5697
// unless wrapped in a div with non-breaking characters in front of it.
5698
if ( !jQuery.support.htmlSerialize ) {
5699
wrapMap._default = [ 1, "X<div>", "</div>" ];
5702
5874
jQuery.fn.extend({
5703
text: function( value ) {
5704
return jQuery.access( this, function( value ) {
5705
return value === undefined ?
5706
jQuery.text( this ) :
5707
this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
5708
}, null, value, arguments.length );
5711
wrapAll: function( html ) {
5712
if ( jQuery.isFunction( html ) ) {
5713
return this.each(function(i) {
5714
jQuery(this).wrapAll( html.call(this, i) );
5719
// The elements to wrap the target around
5720
var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5722
if ( this[0].parentNode ) {
5723
wrap.insertBefore( this[0] );
5726
wrap.map(function() {
5729
while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5730
elem = elem.firstChild;
5740
wrapInner: function( html ) {
5741
if ( jQuery.isFunction( html ) ) {
5742
return this.each(function(i) {
5743
jQuery(this).wrapInner( html.call(this, i) );
5747
return this.each(function() {
5748
var self = jQuery( this ),
5749
contents = self.contents();
5751
if ( contents.length ) {
5752
contents.wrapAll( html );
5755
self.append( html );
5760
wrap: function( html ) {
5761
var isFunction = jQuery.isFunction( html );
5763
return this.each(function(i) {
5764
jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
5768
unwrap: function() {
5769
return this.parent().each(function() {
5770
if ( !jQuery.nodeName( this, "body" ) ) {
5771
jQuery( this ).replaceWith( this.childNodes );
5776
append: function() {
5777
return this.domManip(arguments, true, function( elem ) {
5778
if ( this.nodeType === 1 || this.nodeType === 11 ) {
5779
this.appendChild( elem );
5784
prepend: function() {
5785
return this.domManip(arguments, true, function( elem ) {
5786
if ( this.nodeType === 1 || this.nodeType === 11 ) {
5787
this.insertBefore( elem, this.firstChild );
5792
before: function() {
5793
if ( !isDisconnected( this[0] ) ) {
5794
return this.domManip(arguments, false, function( elem ) {
5795
this.parentNode.insertBefore( elem, this );
5799
if ( arguments.length ) {
5800
var set = jQuery.clean( arguments );
5801
return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
5806
if ( !isDisconnected( this[0] ) ) {
5807
return this.domManip(arguments, false, function( elem ) {
5808
this.parentNode.insertBefore( elem, this.nextSibling );
5812
if ( arguments.length ) {
5813
var set = jQuery.clean( arguments );
5814
return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
5818
// keepData is for internal use only--do not document
5819
remove: function( selector, keepData ) {
5823
for ( ; (elem = this[i]) != null; i++ ) {
5824
if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
5825
if ( !keepData && elem.nodeType === 1 ) {
5826
jQuery.cleanData( elem.getElementsByTagName("*") );
5827
jQuery.cleanData( [ elem ] );
5830
if ( elem.parentNode ) {
5831
elem.parentNode.removeChild( elem );
5843
for ( ; (elem = this[i]) != null; i++ ) {
5844
// Remove element nodes and prevent memory leaks
5845
if ( elem.nodeType === 1 ) {
5846
jQuery.cleanData( elem.getElementsByTagName("*") );
5849
// Remove any remaining nodes
5850
while ( elem.firstChild ) {
5851
elem.removeChild( elem.firstChild );
5858
clone: function( dataAndEvents, deepDataAndEvents ) {
5859
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5860
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5862
return this.map( function () {
5863
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5867
html: function( value ) {
5868
return jQuery.access( this, function( value ) {
5869
var elem = this[0] || {},
5873
if ( value === undefined ) {
5874
return elem.nodeType === 1 ?
5875
elem.innerHTML.replace( rinlinejQuery, "" ) :
5879
// See if we can take a shortcut and just use innerHTML
5880
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5881
( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
5882
( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
5883
!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
5885
value = value.replace( rxhtmlTag, "<$1></$2>" );
5888
for (; i < l; i++ ) {
5889
// Remove element nodes and prevent memory leaks
5890
elem = this[i] || {};
5891
if ( elem.nodeType === 1 ) {
5892
jQuery.cleanData( elem.getElementsByTagName( "*" ) );
5893
elem.innerHTML = value;
5899
// If using innerHTML throws an exception, use the fallback method
5904
this.empty().append( value );
5906
}, null, value, arguments.length );
5909
replaceWith: function( value ) {
5910
if ( !isDisconnected( this[0] ) ) {
5911
// Make sure that the elements are removed from the DOM before they are inserted
5912
// this can help fix replacing a parent with child elements
5913
if ( jQuery.isFunction( value ) ) {
5914
return this.each(function(i) {
5915
var self = jQuery(this), old = self.html();
5916
self.replaceWith( value.call( this, i, old ) );
5920
if ( typeof value !== "string" ) {
5921
value = jQuery( value ).detach();
5924
return this.each(function() {
5925
var next = this.nextSibling,
5926
parent = this.parentNode;
5928
jQuery( this ).remove();
5931
jQuery(next).before( value );
5933
jQuery(parent).append( value );
5938
return this.length ?
5939
this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
5943
detach: function( selector ) {
5944
return this.remove( selector, true );
5947
domManip: function( args, table, callback ) {
5949
// Flatten any nested arrays
5950
args = [].concat.apply( [], args );
5952
var results, first, fragment, iNoClone,
5958
// We can't cloneNode fragments that contain checked, in WebKit
5959
if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) {
5960
return this.each(function() {
5961
jQuery(this).domManip( args, table, callback );
5965
if ( jQuery.isFunction(value) ) {
5966
return this.each(function(i) {
5967
var self = jQuery(this);
5968
args[0] = value.call( this, i, table ? self.html() : undefined );
5969
self.domManip( args, table, callback );
5974
results = jQuery.buildFragment( args, this, scripts );
5975
fragment = results.fragment;
5976
first = fragment.firstChild;
5978
if ( fragment.childNodes.length === 1 ) {
5983
table = table && jQuery.nodeName( first, "tr" );
5985
// Use the original fragment for the last item instead of the first because it can end up
5986
// being emptied incorrectly in certain situations (#8070).
5987
// Fragments from the fragment cache must always be cloned and never used in place.
5988
for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) {
5990
table && jQuery.nodeName( this[i], "table" ) ?
5991
findOrAppend( this[i], "tbody" ) :
5995
jQuery.clone( fragment, true, true )
6000
// Fix #11809: Avoid leaking memory
6001
fragment = first = null;
6003
if ( scripts.length ) {
6004
jQuery.each( scripts, function( i, elem ) {
6006
if ( jQuery.ajax ) {
6016
jQuery.error("no ajax");
6019
jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) );
6022
if ( elem.parentNode ) {
6023
elem.parentNode.removeChild( elem );
5875
text: function( value ) {
5876
return jQuery.access( this, function( value ) {
5877
return value === undefined ?
5878
jQuery.text( this ) :
5879
this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
5880
}, null, value, arguments.length );
5883
wrapAll: function( html ) {
5884
if ( jQuery.isFunction( html ) ) {
5885
return this.each(function(i) {
5886
jQuery(this).wrapAll( html.call(this, i) );
5891
// The elements to wrap the target around
5892
var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5894
if ( this[0].parentNode ) {
5895
wrap.insertBefore( this[0] );
5898
wrap.map(function() {
5901
while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5902
elem = elem.firstChild;
5912
wrapInner: function( html ) {
5913
if ( jQuery.isFunction( html ) ) {
5914
return this.each(function(i) {
5915
jQuery(this).wrapInner( html.call(this, i) );
5919
return this.each(function() {
5920
var self = jQuery( this ),
5921
contents = self.contents();
5923
if ( contents.length ) {
5924
contents.wrapAll( html );
5927
self.append( html );
5932
wrap: function( html ) {
5933
var isFunction = jQuery.isFunction( html );
5935
return this.each(function(i) {
5936
jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
5940
unwrap: function() {
5941
return this.parent().each(function() {
5942
if ( !jQuery.nodeName( this, "body" ) ) {
5943
jQuery( this ).replaceWith( this.childNodes );
5948
append: function() {
5949
return this.domManip(arguments, true, function( elem ) {
5950
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5951
this.appendChild( elem );
5956
prepend: function() {
5957
return this.domManip(arguments, true, function( elem ) {
5958
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5959
this.insertBefore( elem, this.firstChild );
5964
before: function() {
5965
return this.domManip( arguments, false, function( elem ) {
5966
if ( this.parentNode ) {
5967
this.parentNode.insertBefore( elem, this );
5973
return this.domManip( arguments, false, function( elem ) {
5974
if ( this.parentNode ) {
5975
this.parentNode.insertBefore( elem, this.nextSibling );
5980
// keepData is for internal use only--do not document
5981
remove: function( selector, keepData ) {
5985
for ( ; (elem = this[i]) != null; i++ ) {
5986
if ( !selector || jQuery.filter( selector, [ elem ] ).length > 0 ) {
5987
if ( !keepData && elem.nodeType === 1 ) {
5988
jQuery.cleanData( getAll( elem ) );
5991
if ( elem.parentNode ) {
5992
if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
5993
setGlobalEval( getAll( elem, "script" ) );
5995
elem.parentNode.removeChild( elem );
6007
for ( ; (elem = this[i]) != null; i++ ) {
6008
// Remove element nodes and prevent memory leaks
6009
if ( elem.nodeType === 1 ) {
6010
jQuery.cleanData( getAll( elem, false ) );
6013
// Remove any remaining nodes
6014
while ( elem.firstChild ) {
6015
elem.removeChild( elem.firstChild );
6018
// If this is a select, ensure that it displays empty (#12336)
6020
if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
6021
elem.options.length = 0;
6028
clone: function( dataAndEvents, deepDataAndEvents ) {
6029
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
6030
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
6032
return this.map( function () {
6033
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
6037
html: function( value ) {
6038
return jQuery.access( this, function( value ) {
6039
var elem = this[0] || {},
6043
if ( value === undefined ) {
6044
return elem.nodeType === 1 ?
6045
elem.innerHTML.replace( rinlinejQuery, "" ) :
6049
// See if we can take a shortcut and just use innerHTML
6050
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
6051
( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
6052
( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
6053
!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
6055
value = value.replace( rxhtmlTag, "<$1></$2>" );
6058
for (; i < l; i++ ) {
6059
// Remove element nodes and prevent memory leaks
6060
elem = this[i] || {};
6061
if ( elem.nodeType === 1 ) {
6062
jQuery.cleanData( getAll( elem, false ) );
6063
elem.innerHTML = value;
6069
// If using innerHTML throws an exception, use the fallback method
6074
this.empty().append( value );
6076
}, null, value, arguments.length );
6079
replaceWith: function( value ) {
6080
var isFunc = jQuery.isFunction( value );
6082
// Make sure that the elements are removed from the DOM before they are inserted
6083
// this can help fix replacing a parent with child elements
6084
if ( !isFunc && typeof value !== "string" ) {
6085
value = jQuery( value ).not( this ).detach();
6088
return this.domManip( [ value ], true, function( elem ) {
6089
var next = this.nextSibling,
6090
parent = this.parentNode;
6093
jQuery( this ).remove();
6094
parent.insertBefore( elem, next );
6099
detach: function( selector ) {
6100
return this.remove( selector, true );
6103
domManip: function( args, table, callback ) {
6105
// Flatten any nested arrays
6106
args = core_concat.apply( [], args );
6108
var first, node, hasScripts,
6109
scripts, doc, fragment,
6115
isFunction = jQuery.isFunction( value );
6117
// We can't cloneNode fragments that contain checked, in WebKit
6118
if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) {
6119
return this.each(function( index ) {
6120
var self = set.eq( index );
6122
args[0] = value.call( this, index, table ? self.html() : undefined );
6124
self.domManip( args, table, callback );
6129
fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
6130
first = fragment.firstChild;
6132
if ( fragment.childNodes.length === 1 ) {
6137
table = table && jQuery.nodeName( first, "tr" );
6138
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
6139
hasScripts = scripts.length;
6141
// Use the original fragment for the last item instead of the first because it can end up
6142
// being emptied incorrectly in certain situations (#8070).
6143
for ( ; i < l; i++ ) {
6146
if ( i !== iNoClone ) {
6147
node = jQuery.clone( node, true, true );
6149
// Keep references to cloned scripts for later restoration
6151
jQuery.merge( scripts, getAll( node, "script" ) );
6156
table && jQuery.nodeName( this[i], "table" ) ?
6157
findOrAppend( this[i], "tbody" ) :
6165
doc = scripts[ scripts.length - 1 ].ownerDocument;
6168
jQuery.map( scripts, restoreScript );
6170
// Evaluate executable scripts on first document insertion
6171
for ( i = 0; i < hasScripts; i++ ) {
6172
node = scripts[ i ];
6173
if ( rscriptType.test( node.type || "" ) &&
6174
!jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
6177
// Hope ajax is available...
6187
jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
6193
// Fix #11809: Avoid leaking memory
6194
fragment = first = null;
6033
6202
function findOrAppend( elem, tag ) {
6034
return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
6203
return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
6206
// Replace/restore the type attribute of script elements for safe DOM manipulation
6207
function disableScript( elem ) {
6208
var attr = elem.getAttributeNode("type");
6209
elem.type = ( attr && attr.specified ) + "/" + elem.type;
6212
function restoreScript( elem ) {
6213
var match = rscriptTypeMasked.exec( elem.type );
6215
elem.type = match[1];
6217
elem.removeAttribute("type");
6222
// Mark scripts as having already been evaluated
6223
function setGlobalEval( elems, refElements ) {
6226
for ( ; (elem = elems[i]) != null; i++ ) {
6227
jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
6037
6231
function cloneCopyEvent( src, dest ) {
6039
if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
6044
oldData = jQuery._data( src ),
6045
curData = jQuery._data( dest, oldData ),
6046
events = oldData.events;
6049
delete curData.handle;
6050
curData.events = {};
6052
for ( type in events ) {
6053
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
6054
jQuery.event.add( dest, type, events[ type ][ i ] );
6059
// make the cloned public data object a copy from the original
6060
if ( curData.data ) {
6061
curData.data = jQuery.extend( {}, curData.data );
6065
function cloneFixAttributes( src, dest ) {
6068
// We do not need to do anything for non-Elements
6069
if ( dest.nodeType !== 1 ) {
6073
// clearAttributes removes the attributes, which we don't want,
6074
// but also removes the attachEvent events, which we *do* want
6075
if ( dest.clearAttributes ) {
6076
dest.clearAttributes();
6079
// mergeAttributes, in contrast, only merges back on the
6080
// original attributes, not the events
6081
if ( dest.mergeAttributes ) {
6082
dest.mergeAttributes( src );
6085
nodeName = dest.nodeName.toLowerCase();
6087
if ( nodeName === "object" ) {
6088
// IE6-10 improperly clones children of object elements using classid.
6089
// IE10 throws NoModificationAllowedError if parent is null, #12132.
6090
if ( dest.parentNode ) {
6091
dest.outerHTML = src.outerHTML;
6094
// This path appears unavoidable for IE9. When cloning an object
6095
// element in IE9, the outerHTML strategy above is not sufficient.
6096
// If the src has innerHTML and the destination does not,
6097
// copy the src.innerHTML into the dest.innerHTML. #10324
6098
if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
6099
dest.innerHTML = src.innerHTML;
6102
} else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
6103
// IE6-8 fails to persist the checked state of a cloned checkbox
6104
// or radio button. Worse, IE6-7 fail to give the cloned element
6105
// a checked appearance if the defaultChecked value isn't also set
6107
dest.defaultChecked = dest.checked = src.checked;
6109
// IE6-7 get confused and end up setting the value of a cloned
6110
// checkbox/radio button to an empty string instead of "on"
6111
if ( dest.value !== src.value ) {
6112
dest.value = src.value;
6115
// IE6-8 fails to return the selected option to the default selected
6116
// state when cloning options
6117
} else if ( nodeName === "option" ) {
6118
dest.selected = src.defaultSelected;
6120
// IE6-8 fails to set the defaultValue to the correct value when
6121
// cloning other types of input fields
6122
} else if ( nodeName === "input" || nodeName === "textarea" ) {
6123
dest.defaultValue = src.defaultValue;
6125
// IE blanks contents when cloning scripts
6126
} else if ( nodeName === "script" && dest.text !== src.text ) {
6127
dest.text = src.text;
6130
// Event data gets referenced instead of copied if the expando
6132
dest.removeAttribute( jQuery.expando );
6135
jQuery.buildFragment = function( args, context, scripts ) {
6136
var fragment, cacheable, cachehit,
6139
// Set context from what may come in as undefined or a jQuery collection or a node
6140
// Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 &
6141
// also doubles as fix for #8950 where plain objects caused createDocumentFragment exception
6142
context = context || document;
6143
context = !context.nodeType && context[0] || context;
6144
context = context.ownerDocument || context;
6146
// Only cache "small" (1/2 KB) HTML strings that are associated with the main document
6147
// Cloning options loses the selected state, so don't cache them
6148
// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
6149
// Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
6150
// Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
6151
if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document &&
6152
first.charAt(0) === "<" && !rnocache.test( first ) &&
6153
(jQuery.support.checkClone || !rchecked.test( first )) &&
6154
(jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
6156
// Mark cacheable and look for a hit
6158
fragment = jQuery.fragments[ first ];
6159
cachehit = fragment !== undefined;
6163
fragment = context.createDocumentFragment();
6164
jQuery.clean( args, context, fragment, scripts );
6166
// Update the cache, but only store false
6167
// unless this is a second parsing of the same content
6169
jQuery.fragments[ first ] = cachehit && fragment;
6173
return { fragment: fragment, cacheable: cacheable };
6176
jQuery.fragments = {};
6233
if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
6238
oldData = jQuery._data( src ),
6239
curData = jQuery._data( dest, oldData ),
6240
events = oldData.events;
6243
delete curData.handle;
6244
curData.events = {};
6246
for ( type in events ) {
6247
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
6248
jQuery.event.add( dest, type, events[ type ][ i ] );
6253
// make the cloned public data object a copy from the original
6254
if ( curData.data ) {
6255
curData.data = jQuery.extend( {}, curData.data );
6259
function fixCloneNodeIssues( src, dest ) {
6260
var nodeName, e, data;
6262
// We do not need to do anything for non-Elements
6263
if ( dest.nodeType !== 1 ) {
6267
nodeName = dest.nodeName.toLowerCase();
6269
// IE6-8 copies events bound via attachEvent when using cloneNode.
6270
if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) {
6271
data = jQuery._data( dest );
6273
for ( e in data.events ) {
6274
jQuery.removeEvent( dest, e, data.handle );
6277
// Event data gets referenced instead of copied if the expando gets copied too
6278
dest.removeAttribute( jQuery.expando );
6281
// IE blanks contents when cloning scripts, and tries to evaluate newly-set text
6282
if ( nodeName === "script" && dest.text !== src.text ) {
6283
disableScript( dest ).text = src.text;
6284
restoreScript( dest );
6286
// IE6-10 improperly clones children of object elements using classid.
6287
// IE10 throws NoModificationAllowedError if parent is null, #12132.
6288
} else if ( nodeName === "object" ) {
6289
if ( dest.parentNode ) {
6290
dest.outerHTML = src.outerHTML;
6293
// This path appears unavoidable for IE9. When cloning an object
6294
// element in IE9, the outerHTML strategy above is not sufficient.
6295
// If the src has innerHTML and the destination does not,
6296
// copy the src.innerHTML into the dest.innerHTML. #10324
6297
if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
6298
dest.innerHTML = src.innerHTML;
6301
} else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) {
6302
// IE6-8 fails to persist the checked state of a cloned checkbox
6303
// or radio button. Worse, IE6-7 fail to give the cloned element
6304
// a checked appearance if the defaultChecked value isn't also set
6306
dest.defaultChecked = dest.checked = src.checked;
6308
// IE6-7 get confused and end up setting the value of a cloned
6309
// checkbox/radio button to an empty string instead of "on"
6310
if ( dest.value !== src.value ) {
6311
dest.value = src.value;
6314
// IE6-8 fails to return the selected option to the default selected
6315
// state when cloning options
6316
} else if ( nodeName === "option" ) {
6317
dest.defaultSelected = dest.selected = src.defaultSelected;
6319
// IE6-8 fails to set the defaultValue to the correct value when
6320
// cloning other types of input fields
6321
} else if ( nodeName === "input" || nodeName === "textarea" ) {
6322
dest.defaultValue = src.defaultValue;
6180
prependTo: "prepend",
6181
insertBefore: "before",
6182
insertAfter: "after",
6183
replaceAll: "replaceWith"
6328
prependTo: "prepend",
6329
insertBefore: "before",
6330
insertAfter: "after",
6331
replaceAll: "replaceWith"
6184
6332
}, function( name, original ) {
6185
jQuery.fn[ name ] = function( selector ) {
6189
insert = jQuery( selector ),
6191
parent = this.length === 1 && this[0].parentNode;
6193
if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) {
6194
insert[ original ]( this[0] );
6197
for ( ; i < l; i++ ) {
6198
elems = ( i > 0 ? this.clone(true) : this ).get();
6199
jQuery( insert[i] )[ original ]( elems );
6200
ret = ret.concat( elems );
6203
return this.pushStack( ret, name, insert.selector );
6333
jQuery.fn[ name ] = function( selector ) {
6337
insert = jQuery( selector ),
6338
last = insert.length - 1;
6340
for ( ; i <= last; i++ ) {
6341
elems = i === last ? this : this.clone(true);
6342
jQuery( insert[i] )[ original ]( elems );
6344
// Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
6345
core_push.apply( ret, elems.get() );
6348
return this.pushStack( ret );
6208
function getAll( elem ) {
6209
if ( typeof elem.getElementsByTagName !== "undefined" ) {
6210
return elem.getElementsByTagName( "*" );
6212
} else if ( typeof elem.querySelectorAll !== "undefined" ) {
6213
return elem.querySelectorAll( "*" );
6352
function getAll( context, tag ) {
6355
found = typeof context.getElementsByTagName !== core_strundefined ? context.getElementsByTagName( tag || "*" ) :
6356
typeof context.querySelectorAll !== core_strundefined ? context.querySelectorAll( tag || "*" ) :
6360
for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
6361
if ( !tag || jQuery.nodeName( elem, tag ) ) {
6364
jQuery.merge( found, getAll( elem, tag ) );
6369
return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
6370
jQuery.merge( [ context ], found ) :
6220
// Used in clean, fixes the defaultChecked property
6374
// Used in buildFragment, fixes the defaultChecked property
6221
6375
function fixDefaultChecked( elem ) {
6222
if ( rcheckableType.test( elem.type ) ) {
6223
elem.defaultChecked = elem.checked;
6376
if ( manipulation_rcheckableType.test( elem.type ) ) {
6377
elem.defaultChecked = elem.checked;
6227
6381
jQuery.extend({
6228
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6234
if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
6235
clone = elem.cloneNode( true );
6237
// IE<=8 does not properly clone detached, unknown element nodes
6239
fragmentDiv.innerHTML = elem.outerHTML;
6240
fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
6243
if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6244
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6245
// IE copies events bound via attachEvent when using cloneNode.
6246
// Calling detachEvent on the clone will also remove the events
6247
// from the original. In order to get around this, we use some
6248
// proprietary methods to clear the events. Thanks to MooTools
6249
// guys for this hotness.
6251
cloneFixAttributes( elem, clone );
6253
// Using Sizzle here is crazy slow, so we use getElementsByTagName instead
6254
srcElements = getAll( elem );
6255
destElements = getAll( clone );
6257
// Weird iteration because IE will replace the length property
6258
// with an element if you are cloning the body and one of the
6259
// elements on the page has a name or id of "length"
6260
for ( i = 0; srcElements[i]; ++i ) {
6261
// Ensure that the destination node is not null; Fixes #9587
6262
if ( destElements[i] ) {
6263
cloneFixAttributes( srcElements[i], destElements[i] );
6268
// Copy the events from the original to the clone
6269
if ( dataAndEvents ) {
6270
cloneCopyEvent( elem, clone );
6272
if ( deepDataAndEvents ) {
6273
srcElements = getAll( elem );
6274
destElements = getAll( clone );
6276
for ( i = 0; srcElements[i]; ++i ) {
6277
cloneCopyEvent( srcElements[i], destElements[i] );
6282
srcElements = destElements = null;
6284
// Return the cloned set
6288
clean: function( elems, context, fragment, scripts ) {
6289
var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags,
6290
safe = context === document && safeFragment,
6293
// Ensure that context is a document
6294
if ( !context || typeof context.createDocumentFragment === "undefined" ) {
6298
// Use the already-created safe fragment if context permits
6299
for ( i = 0; (elem = elems[i]) != null; i++ ) {
6300
if ( typeof elem === "number" ) {
6308
// Convert html string into DOM nodes
6309
if ( typeof elem === "string" ) {
6310
if ( !rhtml.test( elem ) ) {
6311
elem = context.createTextNode( elem );
6313
// Ensure a safe container in which to render the html
6314
safe = safe || createSafeFragment( context );
6315
div = context.createElement("div");
6316
safe.appendChild( div );
6318
// Fix "XHTML"-style tags in all browsers
6319
elem = elem.replace(rxhtmlTag, "<$1></$2>");
6321
// Go to html and back, then peel off extra wrappers
6322
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
6323
wrap = wrapMap[ tag ] || wrapMap._default;
6325
div.innerHTML = wrap[1] + elem + wrap[2];
6327
// Move to the right depth
6329
div = div.lastChild;
6332
// Remove IE's autoinserted <tbody> from table fragments
6333
if ( !jQuery.support.tbody ) {
6335
// String was a <table>, *may* have spurious <tbody>
6336
hasBody = rtbody.test(elem);
6337
tbody = tag === "table" && !hasBody ?
6338
div.firstChild && div.firstChild.childNodes :
6340
// String was a bare <thead> or <tfoot>
6341
wrap[1] === "<table>" && !hasBody ?
6345
for ( j = tbody.length - 1; j >= 0 ; --j ) {
6346
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
6347
tbody[ j ].parentNode.removeChild( tbody[ j ] );
6352
// IE completely kills leading whitespace when innerHTML is used
6353
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6354
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
6357
elem = div.childNodes;
6359
// Take out of fragment container (we need a fresh div each time)
6360
div.parentNode.removeChild( div );
6364
if ( elem.nodeType ) {
6367
jQuery.merge( ret, elem );
6371
// Fix #11356: Clear elements from safeFragment
6373
elem = div = safe = null;
6376
// Reset defaultChecked for any radios and checkboxes
6377
// about to be appended to the DOM in IE 6/7 (#8060)
6378
if ( !jQuery.support.appendChecked ) {
6379
for ( i = 0; (elem = ret[i]) != null; i++ ) {
6380
if ( jQuery.nodeName( elem, "input" ) ) {
6381
fixDefaultChecked( elem );
6382
} else if ( typeof elem.getElementsByTagName !== "undefined" ) {
6383
jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
6388
// Append elements to a provided document fragment
6390
// Special handling of each script element
6391
handleScript = function( elem ) {
6392
// Check if we consider it executable
6393
if ( !elem.type || rscriptType.test( elem.type ) ) {
6394
// Detach the script and store it in the scripts array (if provided) or the fragment
6395
// Return truthy to indicate that it has been handled
6397
scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
6398
fragment.appendChild( elem );
6402
for ( i = 0; (elem = ret[i]) != null; i++ ) {
6403
// Check if we're done after handling an executable script
6404
if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
6405
// Append to fragment and handle embedded scripts
6406
fragment.appendChild( elem );
6407
if ( typeof elem.getElementsByTagName !== "undefined" ) {
6408
// handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
6409
jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
6411
// Splice the scripts into ret after their former ancestor and advance our index beyond them
6412
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
6422
cleanData: function( elems, /* internal */ acceptData ) {
6423
var data, id, elem, type,
6425
internalKey = jQuery.expando,
6426
cache = jQuery.cache,
6427
deleteExpando = jQuery.support.deleteExpando,
6428
special = jQuery.event.special;
6430
for ( ; (elem = elems[i]) != null; i++ ) {
6432
if ( acceptData || jQuery.acceptData( elem ) ) {
6434
id = elem[ internalKey ];
6435
data = id && cache[ id ];
6438
if ( data.events ) {
6439
for ( type in data.events ) {
6440
if ( special[ type ] ) {
6441
jQuery.event.remove( elem, type );
6443
// This is a shortcut to avoid jQuery.event.remove's overhead
6445
jQuery.removeEvent( elem, type, data.handle );
6450
// Remove cache only if it was not already removed by jQuery.event.remove
6451
if ( cache[ id ] ) {
6455
// IE does not allow us to delete expando properties from nodes,
6456
// nor does it have a removeAttribute function on Document nodes;
6457
// we must handle all of these cases
6458
if ( deleteExpando ) {
6459
delete elem[ internalKey ];
6461
} else if ( elem.removeAttribute ) {
6462
elem.removeAttribute( internalKey );
6465
elem[ internalKey ] = null;
6468
jQuery.deletedIds.push( id );
6382
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6383
var destElements, node, clone, i, srcElements,
6384
inPage = jQuery.contains( elem.ownerDocument, elem );
6386
if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
6387
clone = elem.cloneNode( true );
6389
// IE<=8 does not properly clone detached, unknown element nodes
6391
fragmentDiv.innerHTML = elem.outerHTML;
6392
fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
6395
if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6396
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6398
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
6399
destElements = getAll( clone );
6400
srcElements = getAll( elem );
6402
// Fix all IE cloning issues
6403
for ( i = 0; (node = srcElements[i]) != null; ++i ) {
6404
// Ensure that the destination node is not null; Fixes #9587
6405
if ( destElements[i] ) {
6406
fixCloneNodeIssues( node, destElements[i] );
6411
// Copy the events from the original to the clone
6412
if ( dataAndEvents ) {
6413
if ( deepDataAndEvents ) {
6414
srcElements = srcElements || getAll( elem );
6415
destElements = destElements || getAll( clone );
6417
for ( i = 0; (node = srcElements[i]) != null; i++ ) {
6418
cloneCopyEvent( node, destElements[i] );
6421
cloneCopyEvent( elem, clone );
6425
// Preserve script evaluation history
6426
destElements = getAll( clone, "script" );
6427
if ( destElements.length > 0 ) {
6428
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
6431
destElements = srcElements = node = null;
6433
// Return the cloned set
6437
buildFragment: function( elems, context, scripts, selection ) {
6438
var j, elem, contains,
6439
tmp, tag, tbody, wrap,
6442
// Ensure a safe fragment
6443
safe = createSafeFragment( context ),
6448
for ( ; i < l; i++ ) {
6451
if ( elem || elem === 0 ) {
6453
// Add nodes directly
6454
if ( jQuery.type( elem ) === "object" ) {
6455
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
6457
// Convert non-html into a text node
6458
} else if ( !rhtml.test( elem ) ) {
6459
nodes.push( context.createTextNode( elem ) );
6461
// Convert html into DOM nodes
6463
tmp = tmp || safe.appendChild( context.createElement("div") );
6465
// Deserialize a standard representation
6466
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
6467
wrap = wrapMap[ tag ] || wrapMap._default;
6469
tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
6471
// Descend through wrappers to the right content
6474
tmp = tmp.lastChild;
6477
// Manually add leading whitespace removed by IE
6478
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6479
nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
6482
// Remove IE's autoinserted <tbody> from table fragments
6483
if ( !jQuery.support.tbody ) {
6485
// String was a <table>, *may* have spurious <tbody>
6486
elem = tag === "table" && !rtbody.test( elem ) ?
6489
// String was a bare <thead> or <tfoot>
6490
wrap[1] === "<table>" && !rtbody.test( elem ) ?
6494
j = elem && elem.childNodes.length;
6496
if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
6497
elem.removeChild( tbody );
6502
jQuery.merge( nodes, tmp.childNodes );
6504
// Fix #12392 for WebKit and IE > 9
6505
tmp.textContent = "";
6507
// Fix #12392 for oldIE
6508
while ( tmp.firstChild ) {
6509
tmp.removeChild( tmp.firstChild );
6512
// Remember the top-level container for proper cleanup
6513
tmp = safe.lastChild;
6518
// Fix #11356: Clear elements from fragment
6520
safe.removeChild( tmp );
6523
// Reset defaultChecked for any radios and checkboxes
6524
// about to be appended to the DOM in IE 6/7 (#8060)
6525
if ( !jQuery.support.appendChecked ) {
6526
jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
6530
while ( (elem = nodes[ i++ ]) ) {
6532
// #4087 - If origin and destination elements are the same, and this is
6533
// that element, do not do anything
6534
if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
6538
contains = jQuery.contains( elem.ownerDocument, elem );
6540
// Append to fragment
6541
tmp = getAll( safe.appendChild( elem ), "script" );
6543
// Preserve script evaluation history
6545
setGlobalEval( tmp );
6548
// Capture executables
6551
while ( (elem = tmp[ j++ ]) ) {
6552
if ( rscriptType.test( elem.type || "" ) ) {
6553
scripts.push( elem );
6564
cleanData: function( elems, /* internal */ acceptData ) {
6565
var elem, type, id, data,
6567
internalKey = jQuery.expando,
6568
cache = jQuery.cache,
6569
deleteExpando = jQuery.support.deleteExpando,
6570
special = jQuery.event.special;
6572
for ( ; (elem = elems[i]) != null; i++ ) {
6574
if ( acceptData || jQuery.acceptData( elem ) ) {
6576
id = elem[ internalKey ];
6577
data = id && cache[ id ];
6580
if ( data.events ) {
6581
for ( type in data.events ) {
6582
if ( special[ type ] ) {
6583
jQuery.event.remove( elem, type );
6585
// This is a shortcut to avoid jQuery.event.remove's overhead
6587
jQuery.removeEvent( elem, type, data.handle );
6592
// Remove cache only if it was not already removed by jQuery.event.remove
6593
if ( cache[ id ] ) {
6597
// IE does not allow us to delete expando properties from nodes,
6598
// nor does it have a removeAttribute function on Document nodes;
6599
// we must handle all of these cases
6600
if ( deleteExpando ) {
6601
delete elem[ internalKey ];
6603
} else if ( typeof elem.removeAttribute !== core_strundefined ) {
6604
elem.removeAttribute( internalKey );
6607
elem[ internalKey ] = null;
6610
core_deletedIds.push( id );
6475
// Limit scope pollution from any deprecated API
6478
var matched, browser;
6480
// Use of jQuery.browser is frowned upon.
6481
// More details: http://api.jquery.com/jQuery.browser
6482
// jQuery.uaMatch maintained for back-compat
6483
jQuery.uaMatch = function( ua ) {
6484
ua = ua.toLowerCase();
6486
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
6487
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
6488
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
6489
/(msie) ([\w.]+)/.exec( ua ) ||
6490
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
6494
browser: match[ 1 ] || "",
6495
version: match[ 2 ] || "0"
6499
matched = jQuery.uaMatch( navigator.userAgent );
6502
if ( matched.browser ) {
6503
browser[ matched.browser ] = true;
6504
browser.version = matched.version;
6507
// Chrome is Webkit, but Webkit is also Safari.
6508
if ( browser.chrome ) {
6509
browser.webkit = true;
6510
} else if ( browser.webkit ) {
6511
browser.safari = true;
6514
jQuery.browser = browser;
6516
jQuery.sub = function() {
6517
function jQuerySub( selector, context ) {
6518
return new jQuerySub.fn.init( selector, context );
6520
jQuery.extend( true, jQuerySub, this );
6521
jQuerySub.superclass = this;
6522
jQuerySub.fn = jQuerySub.prototype = this();
6523
jQuerySub.fn.constructor = jQuerySub;
6524
jQuerySub.sub = this.sub;
6525
jQuerySub.fn.init = function init( selector, context ) {
6526
if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
6527
context = jQuerySub( context );
6530
return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
6532
jQuerySub.fn.init.prototype = jQuerySub.fn;
6533
var rootjQuerySub = jQuerySub(document);
6538
var curCSS, iframe, iframeDoc,
6539
ralpha = /alpha\([^)]*\)/i,
6540
ropacity = /opacity=([^)]*)/,
6541
rposition = /^(top|right|bottom|left)$/,
6542
// swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
6543
// see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6544
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6545
rmargin = /^margin/,
6546
rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
6547
rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
6548
rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ),
6549
elemdisplay = { BODY: "block" },
6551
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6552
cssNormalTransform = {
6557
cssExpand = [ "Top", "Right", "Bottom", "Left" ],
6558
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
6560
eventsToggle = jQuery.fn.toggle;
6617
var iframe, getStyles, curCSS,
6618
ralpha = /alpha\([^)]*\)/i,
6619
ropacity = /opacity\s*=\s*([^)]*)/,
6620
rposition = /^(top|right|bottom|left)$/,
6621
// swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
6622
// see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6623
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6624
rmargin = /^margin/,
6625
rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
6626
rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
6627
rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ),
6628
elemdisplay = { BODY: "block" },
6630
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6631
cssNormalTransform = {
6636
cssExpand = [ "Top", "Right", "Bottom", "Left" ],
6637
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
6562
6639
// return a css property mapped to a potentially vendor prefixed property
6563
6640
function vendorPropName( style, name ) {
6565
// shortcut for names that are not vendor prefixed
6566
if ( name in style ) {
6570
// check for vendor prefixed names
6571
var capName = name.charAt(0).toUpperCase() + name.slice(1),
6573
i = cssPrefixes.length;
6576
name = cssPrefixes[ i ] + capName;
6577
if ( name in style ) {
6642
// shortcut for names that are not vendor prefixed
6643
if ( name in style ) {
6647
// check for vendor prefixed names
6648
var capName = name.charAt(0).toUpperCase() + name.slice(1),
6650
i = cssPrefixes.length;
6653
name = cssPrefixes[ i ] + capName;
6654
if ( name in style ) {
6585
6662
function isHidden( elem, el ) {
6587
return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
6663
// isHidden might be called from jQuery#filter function;
6664
// in that case, element will be second argument
6666
return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
6590
6669
function showHide( elements, show ) {
6594
length = elements.length;
6596
for ( ; index < length; index++ ) {
6597
elem = elements[ index ];
6598
if ( !elem.style ) {
6601
values[ index ] = jQuery._data( elem, "olddisplay" );
6603
// Reset the inline display of this element to learn if it is
6604
// being hidden by cascaded rules or not
6605
if ( !values[ index ] && elem.style.display === "none" ) {
6606
elem.style.display = "";
6609
// Set elements which have been overridden with display: none
6610
// in a stylesheet to whatever the default browser style is
6611
// for such an element
6612
if ( elem.style.display === "" && isHidden( elem ) ) {
6613
values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
6616
display = curCSS( elem, "display" );
6618
if ( !values[ index ] && display !== "none" ) {
6619
jQuery._data( elem, "olddisplay", display );
6624
// Set the display of most of the elements in a second loop
6625
// to avoid the constant reflow
6626
for ( index = 0; index < length; index++ ) {
6627
elem = elements[ index ];
6628
if ( !elem.style ) {
6631
if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
6632
elem.style.display = show ? values[ index ] || "" : "none";
6670
var display, elem, hidden,
6673
length = elements.length;
6675
for ( ; index < length; index++ ) {
6676
elem = elements[ index ];
6677
if ( !elem.style ) {
6681
values[ index ] = jQuery._data( elem, "olddisplay" );
6682
display = elem.style.display;
6684
// Reset the inline display of this element to learn if it is
6685
// being hidden by cascaded rules or not
6686
if ( !values[ index ] && display === "none" ) {
6687
elem.style.display = "";
6690
// Set elements which have been overridden with display: none
6691
// in a stylesheet to whatever the default browser style is
6692
// for such an element
6693
if ( elem.style.display === "" && isHidden( elem ) ) {
6694
values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
6698
if ( !values[ index ] ) {
6699
hidden = isHidden( elem );
6701
if ( display && display !== "none" || !hidden ) {
6702
jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
6708
// Set the display of most of the elements in a second loop
6709
// to avoid the constant reflow
6710
for ( index = 0; index < length; index++ ) {
6711
elem = elements[ index ];
6712
if ( !elem.style ) {
6715
if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
6716
elem.style.display = show ? values[ index ] || "" : "none";
6639
6723
jQuery.fn.extend({
6640
css: function( name, value ) {
6641
return jQuery.access( this, function( elem, name, value ) {
6642
return value !== undefined ?
6643
jQuery.style( elem, name, value ) :
6644
jQuery.css( elem, name );
6645
}, name, value, arguments.length > 1 );
6648
return showHide( this, true );
6651
return showHide( this );
6653
toggle: function( state, fn2 ) {
6654
var bool = typeof state === "boolean";
6656
if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) {
6657
return eventsToggle.apply( this, arguments );
6660
return this.each(function() {
6661
if ( bool ? state : isHidden( this ) ) {
6662
jQuery( this ).show();
6664
jQuery( this ).hide();
6724
css: function( name, value ) {
6725
return jQuery.access( this, function( elem, name, value ) {
6730
if ( jQuery.isArray( name ) ) {
6731
styles = getStyles( elem );
6734
for ( ; i < len; i++ ) {
6735
map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
6741
return value !== undefined ?
6742
jQuery.style( elem, name, value ) :
6743
jQuery.css( elem, name );
6744
}, name, value, arguments.length > 1 );
6747
return showHide( this, true );
6750
return showHide( this );
6752
toggle: function( state ) {
6753
var bool = typeof state === "boolean";
6755
return this.each(function() {
6756
if ( bool ? state : isHidden( this ) ) {
6757
jQuery( this ).show();
6759
jQuery( this ).hide();
6670
6765
jQuery.extend({
6671
// Add in style property hooks for overriding the default
6672
// behavior of getting and setting a style property
6675
get: function( elem, computed ) {
6677
// We should always get a number back from opacity
6678
var ret = curCSS( elem, "opacity" );
6679
return ret === "" ? "1" : ret;
6686
// Exclude the following css properties to add px
6688
"fillOpacity": true,
6698
// Add in properties whose names you wish to fix before
6699
// setting or getting the value
6701
// normalize float css property
6702
"float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
6705
// Get and set the style property on a DOM Node
6706
style: function( elem, name, value, extra ) {
6707
// Don't set styles on text and comment nodes
6708
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6712
// Make sure that we're working with the right name
6713
var ret, type, hooks,
6714
origName = jQuery.camelCase( name ),
6717
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
6719
// gets hook for the prefixed version
6720
// followed by the unprefixed version
6721
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6723
// Check if we're setting a value
6724
if ( value !== undefined ) {
6725
type = typeof value;
6727
// convert relative number strings (+= or -=) to relative numbers. #7345
6728
if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6729
value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
6734
// Make sure that NaN and null values aren't set. See: #7116
6735
if ( value == null || type === "number" && isNaN( value ) ) {
6739
// If a number was passed in, add 'px' to the (except for certain CSS properties)
6740
if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6744
// If a hook was provided, use that value, otherwise just set the specified value
6745
if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
6746
// Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6749
style[ name ] = value;
6754
// If a hook was provided get the non-computed value from there
6755
if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6759
// Otherwise just get the value from the style object
6760
return style[ name ];
6764
css: function( elem, name, numeric, extra ) {
6765
var val, num, hooks,
6766
origName = jQuery.camelCase( name );
6768
// Make sure that we're working with the right name
6769
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
6771
// gets hook for the prefixed version
6772
// followed by the unprefixed version
6773
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6775
// If a hook was provided get the computed value from there
6776
if ( hooks && "get" in hooks ) {
6777
val = hooks.get( elem, true, extra );
6780
// Otherwise, if a way to get the computed value exists, use that
6781
if ( val === undefined ) {
6782
val = curCSS( elem, name );
6785
//convert "normal" to computed value
6786
if ( val === "normal" && name in cssNormalTransform ) {
6787
val = cssNormalTransform[ name ];
6790
// Return, converting to number if forced or a qualifier was provided and val looks numeric
6791
if ( numeric || extra !== undefined ) {
6792
num = parseFloat( val );
6793
return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
6798
// A method for quickly swapping in/out CSS properties to get correct calculations
6799
swap: function( elem, options, callback ) {
6803
// Remember the old values, and insert the new ones
6804
for ( name in options ) {
6805
old[ name ] = elem.style[ name ];
6806
elem.style[ name ] = options[ name ];
6809
ret = callback.call( elem );
6811
// Revert the old values
6812
for ( name in options ) {
6813
elem.style[ name ] = old[ name ];
6766
// Add in style property hooks for overriding the default
6767
// behavior of getting and setting a style property
6770
get: function( elem, computed ) {
6772
// We should always get a number back from opacity
6773
var ret = curCSS( elem, "opacity" );
6774
return ret === "" ? "1" : ret;
6780
// Exclude the following css properties to add px
6782
"columnCount": true,
6783
"fillOpacity": true,
6793
// Add in properties whose names you wish to fix before
6794
// setting or getting the value
6796
// normalize float css property
6797
"float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
6800
// Get and set the style property on a DOM Node
6801
style: function( elem, name, value, extra ) {
6802
// Don't set styles on text and comment nodes
6803
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6807
// Make sure that we're working with the right name
6808
var ret, type, hooks,
6809
origName = jQuery.camelCase( name ),
6812
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
6814
// gets hook for the prefixed version
6815
// followed by the unprefixed version
6816
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6818
// Check if we're setting a value
6819
if ( value !== undefined ) {
6820
type = typeof value;
6822
// convert relative number strings (+= or -=) to relative numbers. #7345
6823
if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6824
value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
6829
// Make sure that NaN and null values aren't set. See: #7116
6830
if ( value == null || type === "number" && isNaN( value ) ) {
6834
// If a number was passed in, add 'px' to the (except for certain CSS properties)
6835
if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6839
// Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
6840
// but it would mean to define eight (for every problematic property) identical functions
6841
if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
6842
style[ name ] = "inherit";
6845
// If a hook was provided, use that value, otherwise just set the specified value
6846
if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
6848
// Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6851
style[ name ] = value;
6856
// If a hook was provided get the non-computed value from there
6857
if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6861
// Otherwise just get the value from the style object
6862
return style[ name ];
6866
css: function( elem, name, extra, styles ) {
6867
var num, val, hooks,
6868
origName = jQuery.camelCase( name );
6870
// Make sure that we're working with the right name
6871
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
6873
// gets hook for the prefixed version
6874
// followed by the unprefixed version
6875
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6877
// If a hook was provided get the computed value from there
6878
if ( hooks && "get" in hooks ) {
6879
val = hooks.get( elem, true, extra );
6882
// Otherwise, if a way to get the computed value exists, use that
6883
if ( val === undefined ) {
6884
val = curCSS( elem, name, styles );
6887
//convert "normal" to computed value
6888
if ( val === "normal" && name in cssNormalTransform ) {
6889
val = cssNormalTransform[ name ];
6892
// Return, converting to number if forced or a qualifier was provided and val looks numeric
6893
if ( extra === "" || extra ) {
6894
num = parseFloat( val );
6895
return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
6900
// A method for quickly swapping in/out CSS properties to get correct calculations
6901
swap: function( elem, options, callback, args ) {
6905
// Remember the old values, and insert the new ones
6906
for ( name in options ) {
6907
old[ name ] = elem.style[ name ];
6908
elem.style[ name ] = options[ name ];
6911
ret = callback.apply( elem, args || [] );
6913
// Revert the old values
6914
for ( name in options ) {
6915
elem.style[ name ] = old[ name ];
6820
// NOTE: To any future maintainer, we've window.getComputedStyle
6922
// NOTE: we've included the "window" in window.getComputedStyle
6821
6923
// because jsdom on node.js will break without it.
6822
6924
if ( window.getComputedStyle ) {
6823
curCSS = function( elem, name ) {
6824
var ret, width, minWidth, maxWidth,
6825
computed = window.getComputedStyle( elem, null ),
6830
// getPropertyValue is only needed for .css('filter') in IE9, see #12537
6831
ret = computed.getPropertyValue( name ) || computed[ name ];
6833
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
6834
ret = jQuery.style( elem, name );
6837
// A tribute to the "awesome hack by Dean Edwards"
6838
// Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
6839
// Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
6840
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
6841
if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
6842
width = style.width;
6843
minWidth = style.minWidth;
6844
maxWidth = style.maxWidth;
6846
style.minWidth = style.maxWidth = style.width = ret;
6847
ret = computed.width;
6849
style.width = width;
6850
style.minWidth = minWidth;
6851
style.maxWidth = maxWidth;
6925
getStyles = function( elem ) {
6926
return window.getComputedStyle( elem, null );
6929
curCSS = function( elem, name, _computed ) {
6930
var width, minWidth, maxWidth,
6931
computed = _computed || getStyles( elem ),
6933
// getPropertyValue is only needed for .css('filter') in IE9, see #12537
6934
ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined,
6939
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
6940
ret = jQuery.style( elem, name );
6943
// A tribute to the "awesome hack by Dean Edwards"
6944
// Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
6945
// Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
6946
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
6947
if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
6949
// Remember the original values
6950
width = style.width;
6951
minWidth = style.minWidth;
6952
maxWidth = style.maxWidth;
6954
// Put in the new values to get a computed value out
6955
style.minWidth = style.maxWidth = style.width = ret;
6956
ret = computed.width;
6958
// Revert the changed values
6959
style.width = width;
6960
style.minWidth = minWidth;
6961
style.maxWidth = maxWidth;
6857
6967
} else if ( document.documentElement.currentStyle ) {
6858
curCSS = function( elem, name ) {
6860
ret = elem.currentStyle && elem.currentStyle[ name ],
6863
// Avoid setting ret to empty string here
6864
// so we don't default to auto
6865
if ( ret == null && style && style[ name ] ) {
6866
ret = style[ name ];
6869
// From the awesome hack by Dean Edwards
6870
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6872
// If we're not dealing with a regular pixel number
6873
// but a number that has a weird ending, we need to convert it to pixels
6874
// but not position css attributes, as those are proportional to the parent element instead
6875
// and we can't measure the parent instead because it might trigger a "stacking dolls" problem
6876
if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
6878
// Remember the original values
6880
rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
6882
// Put in the new values to get a computed value out
6884
elem.runtimeStyle.left = elem.currentStyle.left;
6886
style.left = name === "fontSize" ? "1em" : ret;
6887
ret = style.pixelLeft + "px";
6889
// Revert the changed values
6892
elem.runtimeStyle.left = rsLeft;
6896
return ret === "" ? "auto" : ret;
6968
getStyles = function( elem ) {
6969
return elem.currentStyle;
6972
curCSS = function( elem, name, _computed ) {
6973
var left, rs, rsLeft,
6974
computed = _computed || getStyles( elem ),
6975
ret = computed ? computed[ name ] : undefined,
6978
// Avoid setting ret to empty string here
6979
// so we don't default to auto
6980
if ( ret == null && style && style[ name ] ) {
6981
ret = style[ name ];
6984
// From the awesome hack by Dean Edwards
6985
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6987
// If we're not dealing with a regular pixel number
6988
// but a number that has a weird ending, we need to convert it to pixels
6989
// but not position css attributes, as those are proportional to the parent element instead
6990
// and we can't measure the parent instead because it might trigger a "stacking dolls" problem
6991
if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
6993
// Remember the original values
6995
rs = elem.runtimeStyle;
6996
rsLeft = rs && rs.left;
6998
// Put in the new values to get a computed value out
7000
rs.left = elem.currentStyle.left;
7002
style.left = name === "fontSize" ? "1em" : ret;
7003
ret = style.pixelLeft + "px";
7005
// Revert the changed values
7012
return ret === "" ? "auto" : ret;
6900
7016
function setPositiveNumber( elem, value, subtract ) {
6901
var matches = rnumsplit.exec( value );
6903
Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
7017
var matches = rnumsplit.exec( value );
7019
// Guard against undefined "subtract", e.g., when used as in cssHooks
7020
Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
6907
function augmentWidthOrHeight( elem, name, extra, isBorderBox ) {
6908
var i = extra === ( isBorderBox ? "border" : "content" ) ?
6909
// If we already have the right measurement, avoid augmentation
6911
// Otherwise initialize for horizontal or vertical properties
6912
name === "width" ? 1 : 0,
6916
for ( ; i < 4; i += 2 ) {
6917
// both box models exclude margin, so add it if we want it
6918
if ( extra === "margin" ) {
6919
// we use jQuery.css instead of curCSS here
6920
// because of the reliableMarginRight CSS hook!
6921
val += jQuery.css( elem, extra + cssExpand[ i ], true );
6924
// From this point on we use curCSS for maximum performance (relevant in animations)
6925
if ( isBorderBox ) {
6926
// border-box includes padding, so remove it if we want content
6927
if ( extra === "content" ) {
6928
val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
6931
// at this point, extra isn't border nor margin, so remove border
6932
if ( extra !== "margin" ) {
6933
val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
6936
// at this point, extra isn't content, so add padding
6937
val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
6939
// at this point, extra isn't content nor padding, so add border
6940
if ( extra !== "padding" ) {
6941
val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
7024
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
7025
var i = extra === ( isBorderBox ? "border" : "content" ) ?
7026
// If we already have the right measurement, avoid augmentation
7028
// Otherwise initialize for horizontal or vertical properties
7029
name === "width" ? 1 : 0,
7033
for ( ; i < 4; i += 2 ) {
7034
// both box models exclude margin, so add it if we want it
7035
if ( extra === "margin" ) {
7036
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
7039
if ( isBorderBox ) {
7040
// border-box includes padding, so remove it if we want content
7041
if ( extra === "content" ) {
7042
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
7045
// at this point, extra isn't border nor margin, so remove border
7046
if ( extra !== "margin" ) {
7047
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
7050
// at this point, extra isn't content, so add padding
7051
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
7053
// at this point, extra isn't content nor padding, so add border
7054
if ( extra !== "padding" ) {
7055
val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6949
7063
function getWidthOrHeight( elem, name, extra ) {
6951
// Start with offset property, which is equivalent to the border-box value
6952
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6953
valueIsBorderBox = true,
6954
isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";
6956
// some non-html elements return undefined for offsetWidth, so check for null/undefined
6957
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
6958
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
6959
if ( val <= 0 || val == null ) {
6960
// Fall back to computed then uncomputed css if necessary
6961
val = curCSS( elem, name );
6962
if ( val < 0 || val == null ) {
6963
val = elem.style[ name ];
6966
// Computed unit is not pixels. Stop here and return.
6967
if ( rnumnonpx.test(val) ) {
6971
// we need the check for style in case a browser which returns unreliable values
6972
// for getComputedStyle silently falls back to the reliable elem.style
6973
valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
6975
// Normalize "", auto, and prepare for extra
6976
val = parseFloat( val ) || 0;
6979
// use the active box-sizing model to add/subtract irrelevant styles
6981
augmentWidthOrHeight(
6984
extra || ( isBorderBox ? "border" : "content" ),
7065
// Start with offset property, which is equivalent to the border-box value
7066
var valueIsBorderBox = true,
7067
val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
7068
styles = getStyles( elem ),
7069
isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
7071
// some non-html elements return undefined for offsetWidth, so check for null/undefined
7072
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
7073
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
7074
if ( val <= 0 || val == null ) {
7075
// Fall back to computed then uncomputed css if necessary
7076
val = curCSS( elem, name, styles );
7077
if ( val < 0 || val == null ) {
7078
val = elem.style[ name ];
7081
// Computed unit is not pixels. Stop here and return.
7082
if ( rnumnonpx.test(val) ) {
7086
// we need the check for style in case a browser which returns unreliable values
7087
// for getComputedStyle silently falls back to the reliable elem.style
7088
valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
7090
// Normalize "", auto, and prepare for extra
7091
val = parseFloat( val ) || 0;
7094
// use the active box-sizing model to add/subtract irrelevant styles
7096
augmentWidthOrHeight(
7099
extra || ( isBorderBox ? "border" : "content" ),
6991
7106
// Try to determine the default display value of an element
6992
7107
function css_defaultDisplay( nodeName ) {
6993
if ( elemdisplay[ nodeName ] ) {
6994
return elemdisplay[ nodeName ];
6997
var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ),
6998
display = elem.css("display");
7001
// If the simple way fails,
7002
// get element's real default display by attaching it to a temp iframe
7003
if ( display === "none" || display === "" ) {
7004
// Use the already-created iframe if possible
7005
iframe = document.body.appendChild(
7006
iframe || jQuery.extend( document.createElement("iframe"), {
7013
// Create a cacheable copy of the iframe document on first call.
7014
// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
7015
// document to it; WebKit & Firefox won't allow reusing the iframe document.
7016
if ( !iframeDoc || !iframe.createElement ) {
7017
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
7018
iframeDoc.write("<!doctype html><html><body>");
7022
elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) );
7024
display = curCSS( elem, "display" );
7025
document.body.removeChild( iframe );
7028
// Store the correct default display
7029
elemdisplay[ nodeName ] = display;
7109
display = elemdisplay[ nodeName ];
7112
display = actualDisplay( nodeName, doc );
7114
// If the simple way fails, read from inside an iframe
7115
if ( display === "none" || !display ) {
7116
// Use the already-created iframe if possible
7117
iframe = ( iframe ||
7118
jQuery("<iframe frameborder='0' width='0' height='0'/>")
7119
.css( "cssText", "display:block !important" )
7120
).appendTo( doc.documentElement );
7122
// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
7123
doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document;
7124
doc.write("<!doctype html><html><body>");
7127
display = actualDisplay( nodeName, doc );
7131
// Store the correct default display
7132
elemdisplay[ nodeName ] = display;
7138
// Called ONLY from within css_defaultDisplay
7139
function actualDisplay( name, doc ) {
7140
var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
7141
display = jQuery.css( elem[0], "display" );
7034
7146
jQuery.each([ "height", "width" ], function( i, name ) {
7035
jQuery.cssHooks[ name ] = {
7036
get: function( elem, computed, extra ) {
7038
// certain elements can have dimension info if we invisibly show them
7039
// however, it must have a current display style that would benefit from this
7040
if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) {
7041
return jQuery.swap( elem, cssShow, function() {
7042
return getWidthOrHeight( elem, name, extra );
7045
return getWidthOrHeight( elem, name, extra );
7147
jQuery.cssHooks[ name ] = {
7148
get: function( elem, computed, extra ) {
7150
// certain elements can have dimension info if we invisibly show them
7151
// however, it must have a current display style that would benefit from this
7152
return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
7153
jQuery.swap( elem, cssShow, function() {
7154
return getWidthOrHeight( elem, name, extra );
7156
getWidthOrHeight( elem, name, extra );
7050
set: function( elem, value, extra ) {
7051
return setPositiveNumber( elem, value, extra ?
7052
augmentWidthOrHeight(
7056
jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"
7160
set: function( elem, value, extra ) {
7161
var styles = extra && getStyles( elem );
7162
return setPositiveNumber( elem, value, extra ?
7163
augmentWidthOrHeight(
7167
jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
7063
7175
if ( !jQuery.support.opacity ) {
7064
jQuery.cssHooks.opacity = {
7065
get: function( elem, computed ) {
7066
// IE uses filters for opacity
7067
return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
7068
( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
7069
computed ? "1" : "";
7072
set: function( elem, value ) {
7073
var style = elem.style,
7074
currentStyle = elem.currentStyle,
7075
opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
7076
filter = currentStyle && currentStyle.filter || style.filter || "";
7078
// IE has trouble with opacity if it does not have layout
7079
// Force it by setting the zoom level
7082
// if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
7083
if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
7084
style.removeAttribute ) {
7086
// Setting style.filter to null, "" & " " still leave "filter:" in the cssText
7087
// if "filter:" is present at all, clearType is disabled, we want to avoid this
7088
// style.removeAttribute is IE Only, but so apparently is this code path...
7089
style.removeAttribute( "filter" );
7091
// if there there is no filter style applied in a css rule, we are done
7092
if ( currentStyle && !currentStyle.filter ) {
7097
// otherwise, set new filter values
7098
style.filter = ralpha.test( filter ) ?
7099
filter.replace( ralpha, opacity ) :
7100
filter + " " + opacity;
7176
jQuery.cssHooks.opacity = {
7177
get: function( elem, computed ) {
7178
// IE uses filters for opacity
7179
return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
7180
( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
7181
computed ? "1" : "";
7184
set: function( elem, value ) {
7185
var style = elem.style,
7186
currentStyle = elem.currentStyle,
7187
opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
7188
filter = currentStyle && currentStyle.filter || style.filter || "";
7190
// IE has trouble with opacity if it does not have layout
7191
// Force it by setting the zoom level
7194
// if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
7195
// if value === "", then remove inline opacity #12685
7196
if ( ( value >= 1 || value === "" ) &&
7197
jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
7198
style.removeAttribute ) {
7200
// Setting style.filter to null, "" & " " still leave "filter:" in the cssText
7201
// if "filter:" is present at all, clearType is disabled, we want to avoid this
7202
// style.removeAttribute is IE Only, but so apparently is this code path...
7203
style.removeAttribute( "filter" );
7205
// if there is no filter style applied in a css rule or unset inline opacity, we are done
7206
if ( value === "" || currentStyle && !currentStyle.filter ) {
7211
// otherwise, set new filter values
7212
style.filter = ralpha.test( filter ) ?
7213
filter.replace( ralpha, opacity ) :
7214
filter + " " + opacity;
7105
7219
// These hooks cannot be added until DOM ready because the support test
7106
7220
// for it is not run until after DOM ready
7107
7221
jQuery(function() {
7108
if ( !jQuery.support.reliableMarginRight ) {
7109
jQuery.cssHooks.marginRight = {
7110
get: function( elem, computed ) {
7111
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
7112
// Work around by temporarily setting element display to inline-block
7113
return jQuery.swap( elem, { "display": "inline-block" }, function() {
7115
return curCSS( elem, "marginRight" );
7222
if ( !jQuery.support.reliableMarginRight ) {
7223
jQuery.cssHooks.marginRight = {
7224
get: function( elem, computed ) {
7226
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
7227
// Work around by temporarily setting element display to inline-block
7228
return jQuery.swap( elem, { "display": "inline-block" },
7229
curCSS, [ elem, "marginRight" ] );
7122
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
7123
// getComputedStyle returns percent when specified for top/left/bottom/right
7124
// rather than make the css module depend on the offset module, we just check for it here
7125
if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
7126
jQuery.each( [ "top", "left" ], function( i, prop ) {
7127
jQuery.cssHooks[ prop ] = {
7128
get: function( elem, computed ) {
7130
var ret = curCSS( elem, prop );
7131
// if curCSS returns percentage, fallback to offset
7132
return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret;
7235
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
7236
// getComputedStyle returns percent when specified for top/left/bottom/right
7237
// rather than make the css module depend on the offset module, we just check for it here
7238
if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
7239
jQuery.each( [ "top", "left" ], function( i, prop ) {
7240
jQuery.cssHooks[ prop ] = {
7241
get: function( elem, computed ) {
7243
computed = curCSS( elem, prop );
7244
// if curCSS returns percentage, fallback to offset
7245
return rnumnonpx.test( computed ) ?
7246
jQuery( elem ).position()[ prop ] + "px" :
7141
7256
if ( jQuery.expr && jQuery.expr.filters ) {
7142
jQuery.expr.filters.hidden = function( elem ) {
7143
return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none");
7257
jQuery.expr.filters.hidden = function( elem ) {
7258
// Support: Opera <= 12.12
7259
// Opera reports offsetWidths and offsetHeights less than zero on some elements
7260
return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
7261
(!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
7146
jQuery.expr.filters.visible = function( elem ) {
7147
return !jQuery.expr.filters.hidden( elem );
7264
jQuery.expr.filters.visible = function( elem ) {
7265
return !jQuery.expr.filters.hidden( elem );
7151
7269
// These hooks are used by animate to expand properties
7156
7274
}, function( prefix, suffix ) {
7157
jQuery.cssHooks[ prefix + suffix ] = {
7158
expand: function( value ) {
7161
// assumes a single number if not a string
7162
parts = typeof value === "string" ? value.split(" ") : [ value ],
7165
for ( i = 0; i < 4; i++ ) {
7166
expanded[ prefix + cssExpand[ i ] + suffix ] =
7167
parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
7174
if ( !rmargin.test( prefix ) ) {
7175
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
7275
jQuery.cssHooks[ prefix + suffix ] = {
7276
expand: function( value ) {
7280
// assumes a single number if not a string
7281
parts = typeof value === "string" ? value.split(" ") : [ value ];
7283
for ( ; i < 4; i++ ) {
7284
expanded[ prefix + cssExpand[ i ] + suffix ] =
7285
parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
7292
if ( !rmargin.test( prefix ) ) {
7293
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
7178
7296
var r20 = /%20/g,
7181
rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
7182
rselectTextarea = /^(?:select|textarea)/i;
7299
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
7300
rsubmittable = /^(?:input|select|textarea|keygen)/i;
7184
7302
jQuery.fn.extend({
7185
serialize: function() {
7186
return jQuery.param( this.serializeArray() );
7188
serializeArray: function() {
7189
return this.map(function(){
7190
return this.elements ? jQuery.makeArray( this.elements ) : this;
7193
return this.name && !this.disabled &&
7194
( this.checked || rselectTextarea.test( this.nodeName ) ||
7195
rinput.test( this.type ) );
7197
.map(function( i, elem ){
7198
var val = jQuery( this ).val();
7303
serialize: function() {
7304
return jQuery.param( this.serializeArray() );
7306
serializeArray: function() {
7307
return this.map(function(){
7308
// Can add propHook for "elements" to filter or add form elements
7309
var elements = jQuery.prop( this, "elements" );
7310
return elements ? jQuery.makeArray( elements ) : this;
7313
var type = this.type;
7314
// Use .is(":disabled") so that fieldset[disabled] works
7315
return this.name && !jQuery( this ).is( ":disabled" ) &&
7316
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
7317
( this.checked || !manipulation_rcheckableType.test( type ) );
7319
.map(function( i, elem ){
7320
var val = jQuery( this ).val();
7200
return val == null ?
7202
jQuery.isArray( val ) ?
7203
jQuery.map( val, function( val, i ){
7204
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7206
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7322
return val == null ?
7324
jQuery.isArray( val ) ?
7325
jQuery.map( val, function( val ){
7326
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7328
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7211
7333
//Serialize an array of form elements or a set of
7212
7334
//key/values into a query string
7213
7335
jQuery.param = function( a, traditional ) {
7216
add = function( key, value ) {
7217
// If value is a function, invoke it and return its value
7218
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
7219
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7222
// Set traditional to true for jQuery <= 1.3.2 behavior.
7223
if ( traditional === undefined ) {
7224
traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
7227
// If an array was passed in, assume that it is an array of form elements.
7228
if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7229
// Serialize the form elements
7230
jQuery.each( a, function() {
7231
add( this.name, this.value );
7235
// If traditional, encode the "old" way (the way 1.3.2 or older
7236
// did it), otherwise encode params recursively.
7237
for ( prefix in a ) {
7238
buildParams( prefix, a[ prefix ], traditional, add );
7242
// Return the resulting serialization
7243
return s.join( "&" ).replace( r20, "+" );
7338
add = function( key, value ) {
7339
// If value is a function, invoke it and return its value
7340
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
7341
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7344
// Set traditional to true for jQuery <= 1.3.2 behavior.
7345
if ( traditional === undefined ) {
7346
traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
7349
// If an array was passed in, assume that it is an array of form elements.
7350
if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7351
// Serialize the form elements
7352
jQuery.each( a, function() {
7353
add( this.name, this.value );
7357
// If traditional, encode the "old" way (the way 1.3.2 or older
7358
// did it), otherwise encode params recursively.
7359
for ( prefix in a ) {
7360
buildParams( prefix, a[ prefix ], traditional, add );
7364
// Return the resulting serialization
7365
return s.join( "&" ).replace( r20, "+" );
7246
7368
function buildParams( prefix, obj, traditional, add ) {
7249
if ( jQuery.isArray( obj ) ) {
7250
// Serialize array item.
7251
jQuery.each( obj, function( i, v ) {
7252
if ( traditional || rbracket.test( prefix ) ) {
7253
// Treat each array item as a scalar.
7257
// If array item is non-scalar (array or object), encode its
7258
// numeric index to resolve deserialization ambiguity issues.
7259
// Note that rack (as of 1.0.0) can't currently deserialize
7260
// nested arrays properly, and attempting to do so may cause
7261
// a server error. Possible fixes are to modify rack's
7262
// deserialization algorithm or to provide an option or flag
7263
// to force array serialization to be shallow.
7264
buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
7268
} else if ( !traditional && jQuery.type( obj ) === "object" ) {
7269
// Serialize object item.
7270
for ( name in obj ) {
7271
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7275
// Serialize scalar item.
7371
if ( jQuery.isArray( obj ) ) {
7372
// Serialize array item.
7373
jQuery.each( obj, function( i, v ) {
7374
if ( traditional || rbracket.test( prefix ) ) {
7375
// Treat each array item as a scalar.
7379
// Item is non-scalar (array or object), encode its numeric index.
7380
buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
7384
} else if ( !traditional && jQuery.type( obj ) === "object" ) {
7385
// Serialize object item.
7386
for ( name in obj ) {
7387
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7391
// Serialize scalar item.
7395
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
7396
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
7397
"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
7399
// Handle event binding
7400
jQuery.fn[ name ] = function( data, fn ) {
7401
return arguments.length > 0 ?
7402
this.on( name, null, data, fn ) :
7403
this.trigger( name );
7407
jQuery.fn.hover = function( fnOver, fnOut ) {
7408
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
7280
// Document location
7285
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
7286
// #7653, #8125, #8152: local protocol detection
7287
rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
7288
rnoContent = /^(?:GET|HEAD)$/,
7289
rprotocol = /^\/\//,
7291
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
7292
rts = /([?&])_=[^&]*/,
7293
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
7295
// Keep a copy of the old load method
7296
_load = jQuery.fn.load,
7299
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
7300
* 2) These are called:
7301
* - BEFORE asking for a transport
7302
* - AFTER param serialization (s.data is a string if s.processData is true)
7303
* 3) key is the dataType
7304
* 4) the catchall symbol "*" can be used
7305
* 5) execution will start with transport dataType and THEN continue down to "*" if needed
7309
/* Transports bindings
7310
* 1) key is the dataType
7311
* 2) the catchall symbol "*" can be used
7312
* 3) selection will start with transport dataType and THEN go to "*" if needed
7316
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
7317
allTypes = ["*/"] + ["*"];
7411
// Document location
7414
ajax_nonce = jQuery.now(),
7418
rts = /([?&])_=[^&]*/,
7419
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
7420
// #7653, #8125, #8152: local protocol detection
7421
rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
7422
rnoContent = /^(?:GET|HEAD)$/,
7423
rprotocol = /^\/\//,
7424
rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
7426
// Keep a copy of the old load method
7427
_load = jQuery.fn.load,
7430
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
7431
* 2) These are called:
7432
* - BEFORE asking for a transport
7433
* - AFTER param serialization (s.data is a string if s.processData is true)
7434
* 3) key is the dataType
7435
* 4) the catchall symbol "*" can be used
7436
* 5) execution will start with transport dataType and THEN continue down to "*" if needed
7440
/* Transports bindings
7441
* 1) key is the dataType
7442
* 2) the catchall symbol "*" can be used
7443
* 3) selection will start with transport dataType and THEN go to "*" if needed
7447
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
7448
allTypes = "*/".concat("*");
7319
7450
// #8138, IE may throw an exception when accessing
7320
7451
// a field from window.location if document.domain has been set
7322
ajaxLocation = location.href;
7453
ajaxLocation = location.href;
7324
// Use the href attribute of an A element
7325
// since IE will modify it given document.location
7326
ajaxLocation = document.createElement( "a" );
7327
ajaxLocation.href = "";
7328
ajaxLocation = ajaxLocation.href;
7455
// Use the href attribute of an A element
7456
// since IE will modify it given document.location
7457
ajaxLocation = document.createElement( "a" );
7458
ajaxLocation.href = "";
7459
ajaxLocation = ajaxLocation.href;
7331
7462
// Segment location into parts
7334
7465
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
7335
7466
function addToPrefiltersOrTransports( structure ) {
7337
// dataTypeExpression is optional and defaults to "*"
7338
return function( dataTypeExpression, func ) {
7340
if ( typeof dataTypeExpression !== "string" ) {
7341
func = dataTypeExpression;
7342
dataTypeExpression = "*";
7345
var dataType, list, placeBefore,
7346
dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
7348
length = dataTypes.length;
7350
if ( jQuery.isFunction( func ) ) {
7351
// For each dataType in the dataTypeExpression
7352
for ( ; i < length; i++ ) {
7353
dataType = dataTypes[ i ];
7354
// We control if we're asked to add before
7355
// any existing element
7356
placeBefore = /^\+/.test( dataType );
7357
if ( placeBefore ) {
7358
dataType = dataType.substr( 1 ) || "*";
7360
list = structure[ dataType ] = structure[ dataType ] || [];
7361
// then we add to the structure accordingly
7362
list[ placeBefore ? "unshift" : "push" ]( func );
7468
// dataTypeExpression is optional and defaults to "*"
7469
return function( dataTypeExpression, func ) {
7471
if ( typeof dataTypeExpression !== "string" ) {
7472
func = dataTypeExpression;
7473
dataTypeExpression = "*";
7478
dataTypes = dataTypeExpression.toLowerCase().match( core_rnotwhite ) || [];
7480
if ( jQuery.isFunction( func ) ) {
7481
// For each dataType in the dataTypeExpression
7482
while ( (dataType = dataTypes[i++]) ) {
7483
// Prepend if requested
7484
if ( dataType[0] === "+" ) {
7485
dataType = dataType.slice( 1 ) || "*";
7486
(structure[ dataType ] = structure[ dataType ] || []).unshift( func );
7490
(structure[ dataType ] = structure[ dataType ] || []).push( func );
7368
7497
// Base inspection function for prefilters and transports
7369
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
7370
dataType /* internal */, inspected /* internal */ ) {
7372
dataType = dataType || options.dataTypes[ 0 ];
7373
inspected = inspected || {};
7375
inspected[ dataType ] = true;
7378
list = structure[ dataType ],
7380
length = list ? list.length : 0,
7381
executeOnly = ( structure === prefilters );
7383
for ( ; i < length && ( executeOnly || !selection ); i++ ) {
7384
selection = list[ i ]( options, originalOptions, jqXHR );
7385
// If we got redirected to another dataType
7386
// we try there if executing only and not done already
7387
if ( typeof selection === "string" ) {
7388
if ( !executeOnly || inspected[ selection ] ) {
7389
selection = undefined;
7391
options.dataTypes.unshift( selection );
7392
selection = inspectPrefiltersOrTransports(
7393
structure, options, originalOptions, jqXHR, selection, inspected );
7397
// If we're only executing or nothing was selected
7398
// we try the catchall dataType if not done already
7399
if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
7400
selection = inspectPrefiltersOrTransports(
7401
structure, options, originalOptions, jqXHR, "*", inspected );
7403
// unnecessary when only executing (prefilters)
7404
// but it'll be ignored by the caller in that case
7498
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
7501
seekingTransport = ( structure === transports );
7503
function inspect( dataType ) {
7505
inspected[ dataType ] = true;
7506
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
7507
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
7508
if( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
7509
options.dataTypes.unshift( dataTypeOrTransport );
7510
inspect( dataTypeOrTransport );
7512
} else if ( seekingTransport ) {
7513
return !( selected = dataTypeOrTransport );
7519
return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
7408
7522
// A special extend for ajax options
7409
7523
// that takes "flat" options (not to be deep extended)
7411
7525
function ajaxExtend( target, src ) {
7413
flatOptions = jQuery.ajaxSettings.flatOptions || {};
7414
for ( key in src ) {
7415
if ( src[ key ] !== undefined ) {
7416
( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
7420
jQuery.extend( true, target, deep );
7527
flatOptions = jQuery.ajaxSettings.flatOptions || {};
7529
for ( key in src ) {
7530
if ( src[ key ] !== undefined ) {
7531
( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
7535
jQuery.extend( true, target, deep );
7424
7541
jQuery.fn.load = function( url, params, callback ) {
7425
if ( typeof url !== "string" && _load ) {
7426
return _load.apply( this, arguments );
7429
// Don't do a request if no elements are being requested
7430
if ( !this.length ) {
7434
var selector, type, response,
7436
off = url.indexOf(" ");
7439
selector = url.slice( off, url.length );
7440
url = url.slice( 0, off );
7443
// If it's a function
7444
if ( jQuery.isFunction( params ) ) {
7446
// We assume that it's the callback
7450
// Otherwise, build a param string
7451
} else if ( params && typeof params === "object" ) {
7455
// Request the remote document
7459
// if "type" variable is undefined, then "GET" method will be used
7463
complete: function( jqXHR, status ) {
7465
self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
7468
}).done(function( responseText ) {
7470
// Save response for use in complete callback
7471
response = arguments;
7473
// See if a selector was specified
7474
self.html( selector ?
7476
// Create a dummy div to hold the results
7479
// inject the contents of the document in, removing the scripts
7480
// to avoid any 'Permission Denied' errors in IE
7481
.append( responseText.replace( rscript, "" ) )
7483
// Locate the specified elements
7486
// If not, just inject the full result
7542
if ( typeof url !== "string" && _load ) {
7543
return _load.apply( this, arguments );
7546
var selector, response, type,
7548
off = url.indexOf(" ");
7551
selector = url.slice( off, url.length );
7552
url = url.slice( 0, off );
7555
// If it's a function
7556
if ( jQuery.isFunction( params ) ) {
7558
// We assume that it's the callback
7562
// Otherwise, build a param string
7563
} else if ( params && typeof params === "object" ) {
7567
// If we have elements to modify, make the request
7568
if ( self.length > 0 ) {
7572
// if "type" variable is undefined, then "GET" method will be used
7576
}).done(function( responseText ) {
7578
// Save response for use in complete callback
7579
response = arguments;
7581
self.html( selector ?
7583
// If a selector was specified, locate the right elements in a dummy div
7584
// Exclude scripts to avoid IE 'Permission Denied' errors
7585
jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
7587
// Otherwise use the full result
7590
}).complete( callback && function( jqXHR, status ) {
7591
self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
7494
7598
// Attach a bunch of functions for handling common AJAX events
7495
jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
7496
jQuery.fn[ o ] = function( f ){
7497
return this.on( o, f );
7599
jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){
7600
jQuery.fn[ type ] = function( fn ){
7601
return this.on( type, fn );
7501
7605
jQuery.each( [ "get", "post" ], function( i, method ) {
7502
jQuery[ method ] = function( url, data, callback, type ) {
7503
// shift arguments if data argument was omitted
7504
if ( jQuery.isFunction( data ) ) {
7505
type = type || callback;
7606
jQuery[ method ] = function( url, data, callback, type ) {
7607
// shift arguments if data argument was omitted
7608
if ( jQuery.isFunction( data ) ) {
7609
type = type || callback;
7510
return jQuery.ajax({
7614
return jQuery.ajax({
7520
7624
jQuery.extend({
7522
getScript: function( url, callback ) {
7523
return jQuery.get( url, undefined, callback, "script" );
7526
getJSON: function( url, data, callback ) {
7527
return jQuery.get( url, data, callback, "json" );
7530
// Creates a full fledged settings object into target
7531
// with both ajaxSettings and settings fields.
7532
// If target is omitted, writes into ajaxSettings.
7533
ajaxSetup: function( target, settings ) {
7535
// Building a settings object
7536
ajaxExtend( target, jQuery.ajaxSettings );
7538
// Extending ajaxSettings
7540
target = jQuery.ajaxSettings;
7542
ajaxExtend( target, settings );
7548
isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
7551
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
7567
xml: "application/xml, text/xml",
7570
json: "application/json, text/javascript",
7582
text: "responseText"
7585
// List of data converters
7586
// 1) key format is "source_type destination_type" (a single space in-between)
7587
// 2) the catchall symbol "*" can be used for source_type
7590
// Convert anything to text
7591
"* text": window.String,
7593
// Text to html (true = no transformation)
7596
// Evaluate text as a json expression
7597
"text json": jQuery.parseJSON,
7599
// Parse text as xml
7600
"text xml": jQuery.parseXML
7603
// For options that shouldn't be deep extended:
7604
// you can add your own custom options here if
7605
// and when you create one that shouldn't be
7606
// deep extended (see ajaxExtend)
7613
ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7614
ajaxTransport: addToPrefiltersOrTransports( transports ),
7617
ajax: function( url, options ) {
7619
// If url is an object, simulate pre-1.5 signature
7620
if ( typeof url === "object" ) {
7625
// Force options to be an object
7626
options = options || {};
7628
var // ifModified key
7631
responseHeadersString,
7637
// Cross-domain detection vars
7639
// To know if global events are to be dispatched
7643
// Create the final options object
7644
s = jQuery.ajaxSetup( {}, options ),
7645
// Callbacks context
7646
callbackContext = s.context || s,
7647
// Context for global events
7648
// It's the callbackContext if one was provided in the options
7649
// and if it's a DOM node or a jQuery collection
7650
globalEventContext = callbackContext !== s &&
7651
( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
7652
jQuery( callbackContext ) : jQuery.event,
7654
deferred = jQuery.Deferred(),
7655
completeDeferred = jQuery.Callbacks( "once memory" ),
7656
// Status-dependent callbacks
7657
statusCode = s.statusCode || {},
7658
// Headers (they are sent all at once)
7659
requestHeaders = {},
7660
requestHeadersNames = {},
7663
// Default abort message
7664
strAbort = "canceled",
7670
// Caches the header
7671
setRequestHeader: function( name, value ) {
7673
var lname = name.toLowerCase();
7674
name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7675
requestHeaders[ name ] = value;
7681
getAllResponseHeaders: function() {
7682
return state === 2 ? responseHeadersString : null;
7685
// Builds headers hashtable if needed
7686
getResponseHeader: function( key ) {
7688
if ( state === 2 ) {
7689
if ( !responseHeaders ) {
7690
responseHeaders = {};
7691
while( ( match = rheaders.exec( responseHeadersString ) ) ) {
7692
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7695
match = responseHeaders[ key.toLowerCase() ];
7697
return match === undefined ? null : match;
7700
// Overrides response content-type header
7701
overrideMimeType: function( type ) {
7708
// Cancel the request
7709
abort: function( statusText ) {
7710
statusText = statusText || strAbort;
7712
transport.abort( statusText );
7714
done( 0, statusText );
7719
// Callback for when everything is done
7720
// It is defined here because jslint complains if it is declared
7721
// at the end of the function (which would be more logical and readable)
7722
function done( status, nativeStatusText, responses, headers ) {
7723
var isSuccess, success, error, response, modified,
7724
statusText = nativeStatusText;
7727
if ( state === 2 ) {
7731
// State is "done" now
7734
// Clear timeout if it exists
7735
if ( timeoutTimer ) {
7736
clearTimeout( timeoutTimer );
7739
// Dereference transport for early garbage collection
7740
// (no matter how long the jqXHR object will be used)
7741
transport = undefined;
7743
// Cache response headers
7744
responseHeadersString = headers || "";
7747
jqXHR.readyState = status > 0 ? 4 : 0;
7749
// Get response data
7751
response = ajaxHandleResponses( s, jqXHR, responses );
7754
// If successful, handle type chaining
7755
if ( status >= 200 && status < 300 || status === 304 ) {
7757
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7758
if ( s.ifModified ) {
7760
modified = jqXHR.getResponseHeader("Last-Modified");
7762
jQuery.lastModified[ ifModifiedKey ] = modified;
7764
modified = jqXHR.getResponseHeader("Etag");
7766
jQuery.etag[ ifModifiedKey ] = modified;
7771
if ( status === 304 ) {
7773
statusText = "notmodified";
7779
isSuccess = ajaxConvert( s, response );
7780
statusText = isSuccess.state;
7781
success = isSuccess.data;
7782
error = isSuccess.error;
7786
// We extract error from statusText
7787
// then normalize statusText and status for non-aborts
7789
if ( !statusText || status ) {
7790
statusText = "error";
7797
// Set data for the fake xhr object
7798
jqXHR.status = status;
7799
jqXHR.statusText = ( nativeStatusText || statusText ) + "";
7803
deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
7805
deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
7808
// Status-dependent callbacks
7809
jqXHR.statusCode( statusCode );
7810
statusCode = undefined;
7812
if ( fireGlobals ) {
7813
globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
7814
[ jqXHR, s, isSuccess ? success : error ] );
7818
completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
7820
if ( fireGlobals ) {
7821
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
7822
// Handle the global AJAX counter
7823
if ( !( --jQuery.active ) ) {
7824
jQuery.event.trigger( "ajaxStop" );
7830
deferred.promise( jqXHR );
7831
jqXHR.success = jqXHR.done;
7832
jqXHR.error = jqXHR.fail;
7833
jqXHR.complete = completeDeferred.add;
7835
// Status-dependent callbacks
7836
jqXHR.statusCode = function( map ) {
7840
for ( tmp in map ) {
7841
statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
7844
tmp = map[ jqXHR.status ];
7845
jqXHR.always( tmp );
7851
// Remove hash character (#7531: and string promotion)
7852
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7853
// We also use the url parameter if available
7854
s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
7856
// Extract dataTypes list
7857
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
7859
// A cross-domain request is in order when we have a protocol:host:port mismatch
7860
if ( s.crossDomain == null ) {
7861
parts = rurl.exec( s.url.toLowerCase() );
7862
s.crossDomain = !!( parts &&
7863
( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
7864
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
7865
( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
7869
// Convert data if not already a string
7870
if ( s.data && s.processData && typeof s.data !== "string" ) {
7871
s.data = jQuery.param( s.data, s.traditional );
7875
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
7877
// If request was aborted inside a prefilter, stop there
7878
if ( state === 2 ) {
7882
// We can fire global events as of now if asked to
7883
fireGlobals = s.global;
7885
// Uppercase the type
7886
s.type = s.type.toUpperCase();
7888
// Determine if request has content
7889
s.hasContent = !rnoContent.test( s.type );
7891
// Watch for a new set of requests
7892
if ( fireGlobals && jQuery.active++ === 0 ) {
7893
jQuery.event.trigger( "ajaxStart" );
7896
// More options handling for requests with no content
7897
if ( !s.hasContent ) {
7899
// If data is available, append data to url
7901
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
7902
// #9682: remove data so that it's not used in an eventual retry
7906
// Get ifModifiedKey before adding the anti-cache parameter
7907
ifModifiedKey = s.url;
7909
// Add anti-cache in url if needed
7910
if ( s.cache === false ) {
7912
var ts = jQuery.now(),
7913
// try replacing _= if it is there
7914
ret = s.url.replace( rts, "$1_=" + ts );
7916
// if nothing was replaced, add timestamp to the end
7917
s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
7921
// Set the correct header, if data is being sent
7922
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
7923
jqXHR.setRequestHeader( "Content-Type", s.contentType );
7926
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7927
if ( s.ifModified ) {
7928
ifModifiedKey = ifModifiedKey || s.url;
7929
if ( jQuery.lastModified[ ifModifiedKey ] ) {
7930
jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
7932
if ( jQuery.etag[ ifModifiedKey ] ) {
7933
jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
7937
// Set the Accepts header for the server, depending on the dataType
7938
jqXHR.setRequestHeader(
7940
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
7941
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
7945
// Check for headers option
7946
for ( i in s.headers ) {
7947
jqXHR.setRequestHeader( i, s.headers[ i ] );
7950
// Allow custom headers/mimetypes and early abort
7951
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
7952
// Abort if not done already and return
7953
return jqXHR.abort();
7957
// aborting is no longer a cancellation
7960
// Install callbacks on deferreds
7961
for ( i in { success: 1, error: 1, complete: 1 } ) {
7962
jqXHR[ i ]( s[ i ] );
7966
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
7968
// If no transport, we auto-abort
7970
done( -1, "No Transport" );
7972
jqXHR.readyState = 1;
7973
// Send global event
7974
if ( fireGlobals ) {
7975
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
7978
if ( s.async && s.timeout > 0 ) {
7979
timeoutTimer = setTimeout( function(){
7980
jqXHR.abort( "timeout" );
7986
transport.send( requestHeaders, done );
7988
// Propagate exception as error if not done
7991
// Simply rethrow otherwise
8001
// Counter for holding the number of active queries
8004
// Last-Modified header cache for next request
7626
// Counter for holding the number of active queries
7629
// Last-Modified header cache for next request
7636
isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
7640
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
7657
xml: "application/xml, text/xml",
7658
json: "application/json, text/javascript"
7669
text: "responseText"
7673
// Keys separate source (or catchall "*") and destination types with a single space
7676
// Convert anything to text
7677
"* text": window.String,
7679
// Text to html (true = no transformation)
7682
// Evaluate text as a json expression
7683
"text json": jQuery.parseJSON,
7685
// Parse text as xml
7686
"text xml": jQuery.parseXML
7689
// For options that shouldn't be deep extended:
7690
// you can add your own custom options here if
7691
// and when you create one that shouldn't be
7692
// deep extended (see ajaxExtend)
7699
// Creates a full fledged settings object into target
7700
// with both ajaxSettings and settings fields.
7701
// If target is omitted, writes into ajaxSettings.
7702
ajaxSetup: function( target, settings ) {
7705
// Building a settings object
7706
ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
7708
// Extending ajaxSettings
7709
ajaxExtend( jQuery.ajaxSettings, target );
7712
ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7713
ajaxTransport: addToPrefiltersOrTransports( transports ),
7716
ajax: function( url, options ) {
7718
// If url is an object, simulate pre-1.5 signature
7719
if ( typeof url === "object" ) {
7724
// Force options to be an object
7725
options = options || {};
7727
var // Cross-domain detection vars
7731
// URL without anti-cache param
7733
// Response headers as string
7734
responseHeadersString,
7738
// To know if global events are to be dispatched
7744
// Create the final options object
7745
s = jQuery.ajaxSetup( {}, options ),
7746
// Callbacks context
7747
callbackContext = s.context || s,
7748
// Context for global events is callbackContext if it is a DOM node or jQuery collection
7749
globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
7750
jQuery( callbackContext ) :
7753
deferred = jQuery.Deferred(),
7754
completeDeferred = jQuery.Callbacks("once memory"),
7755
// Status-dependent callbacks
7756
statusCode = s.statusCode || {},
7757
// Headers (they are sent all at once)
7758
requestHeaders = {},
7759
requestHeadersNames = {},
7762
// Default abort message
7763
strAbort = "canceled",
7768
// Builds headers hashtable if needed
7769
getResponseHeader: function( key ) {
7771
if ( state === 2 ) {
7772
if ( !responseHeaders ) {
7773
responseHeaders = {};
7774
while ( (match = rheaders.exec( responseHeadersString )) ) {
7775
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7778
match = responseHeaders[ key.toLowerCase() ];
7780
return match == null ? null : match;
7784
getAllResponseHeaders: function() {
7785
return state === 2 ? responseHeadersString : null;
7788
// Caches the header
7789
setRequestHeader: function( name, value ) {
7790
var lname = name.toLowerCase();
7792
name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7793
requestHeaders[ name ] = value;
7798
// Overrides response content-type header
7799
overrideMimeType: function( type ) {
7806
// Status-dependent callbacks
7807
statusCode: function( map ) {
7811
for ( code in map ) {
7812
// Lazy-add the new callback in a way that preserves old ones
7813
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
7816
// Execute the appropriate callbacks
7817
jqXHR.always( map[ jqXHR.status ] );
7823
// Cancel the request
7824
abort: function( statusText ) {
7825
var finalText = statusText || strAbort;
7827
transport.abort( finalText );
7829
done( 0, finalText );
7835
deferred.promise( jqXHR ).complete = completeDeferred.add;
7836
jqXHR.success = jqXHR.done;
7837
jqXHR.error = jqXHR.fail;
7839
// Remove hash character (#7531: and string promotion)
7840
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7841
// Handle falsy url in the settings object (#10093: consistency with old signature)
7842
// We also use the url parameter if available
7843
s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
7845
// Alias method option to type as per ticket #12004
7846
s.type = options.method || options.type || s.method || s.type;
7848
// Extract dataTypes list
7849
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( core_rnotwhite ) || [""];
7851
// A cross-domain request is in order when we have a protocol:host:port mismatch
7852
if ( s.crossDomain == null ) {
7853
parts = rurl.exec( s.url.toLowerCase() );
7854
s.crossDomain = !!( parts &&
7855
( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
7856
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
7857
( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
7861
// Convert data if not already a string
7862
if ( s.data && s.processData && typeof s.data !== "string" ) {
7863
s.data = jQuery.param( s.data, s.traditional );
7867
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
7869
// If request was aborted inside a prefilter, stop there
7870
if ( state === 2 ) {
7874
// We can fire global events as of now if asked to
7875
fireGlobals = s.global;
7877
// Watch for a new set of requests
7878
if ( fireGlobals && jQuery.active++ === 0 ) {
7879
jQuery.event.trigger("ajaxStart");
7882
// Uppercase the type
7883
s.type = s.type.toUpperCase();
7885
// Determine if request has content
7886
s.hasContent = !rnoContent.test( s.type );
7888
// Save the URL in case we're toying with the If-Modified-Since
7889
// and/or If-None-Match header later on
7892
// More options handling for requests with no content
7893
if ( !s.hasContent ) {
7895
// If data is available, append data to url
7897
cacheURL = ( s.url += ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
7898
// #9682: remove data so that it's not used in an eventual retry
7902
// Add anti-cache in url if needed
7903
if ( s.cache === false ) {
7904
s.url = rts.test( cacheURL ) ?
7906
// If there is already a '_' parameter, set its value
7907
cacheURL.replace( rts, "$1_=" + ajax_nonce++ ) :
7909
// Otherwise add one to the end
7910
cacheURL + ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ajax_nonce++;
7914
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7915
if ( s.ifModified ) {
7916
if ( jQuery.lastModified[ cacheURL ] ) {
7917
jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
7919
if ( jQuery.etag[ cacheURL ] ) {
7920
jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
7924
// Set the correct header, if data is being sent
7925
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
7926
jqXHR.setRequestHeader( "Content-Type", s.contentType );
7929
// Set the Accepts header for the server, depending on the dataType
7930
jqXHR.setRequestHeader(
7932
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
7933
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
7937
// Check for headers option
7938
for ( i in s.headers ) {
7939
jqXHR.setRequestHeader( i, s.headers[ i ] );
7942
// Allow custom headers/mimetypes and early abort
7943
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
7944
// Abort if not done already and return
7945
return jqXHR.abort();
7948
// aborting is no longer a cancellation
7951
// Install callbacks on deferreds
7952
for ( i in { success: 1, error: 1, complete: 1 } ) {
7953
jqXHR[ i ]( s[ i ] );
7957
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
7959
// If no transport, we auto-abort
7961
done( -1, "No Transport" );
7963
jqXHR.readyState = 1;
7965
// Send global event
7966
if ( fireGlobals ) {
7967
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
7970
if ( s.async && s.timeout > 0 ) {
7971
timeoutTimer = setTimeout(function() {
7972
jqXHR.abort("timeout");
7978
transport.send( requestHeaders, done );
7980
// Propagate exception as error if not done
7983
// Simply rethrow otherwise
7990
// Callback for when everything is done
7991
function done( status, nativeStatusText, responses, headers ) {
7992
var isSuccess, success, error, response, modified,
7993
statusText = nativeStatusText;
7996
if ( state === 2 ) {
8000
// State is "done" now
8003
// Clear timeout if it exists
8004
if ( timeoutTimer ) {
8005
clearTimeout( timeoutTimer );
8008
// Dereference transport for early garbage collection
8009
// (no matter how long the jqXHR object will be used)
8010
transport = undefined;
8012
// Cache response headers
8013
responseHeadersString = headers || "";
8016
jqXHR.readyState = status > 0 ? 4 : 0;
8018
// Get response data
8020
response = ajaxHandleResponses( s, jqXHR, responses );
8023
// If successful, handle type chaining
8024
if ( status >= 200 && status < 300 || status === 304 ) {
8026
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
8027
if ( s.ifModified ) {
8028
modified = jqXHR.getResponseHeader("Last-Modified");
8030
jQuery.lastModified[ cacheURL ] = modified;
8032
modified = jqXHR.getResponseHeader("etag");
8034
jQuery.etag[ cacheURL ] = modified;
8039
if ( status === 204 ) {
8041
statusText = "nocontent";
8044
} else if ( status === 304 ) {
8046
statusText = "notmodified";
8048
// If we have data, let's convert it
8050
isSuccess = ajaxConvert( s, response );
8051
statusText = isSuccess.state;
8052
success = isSuccess.data;
8053
error = isSuccess.error;
8057
// We extract error from statusText
8058
// then normalize statusText and status for non-aborts
8060
if ( status || !statusText ) {
8061
statusText = "error";
8068
// Set data for the fake xhr object
8069
jqXHR.status = status;
8070
jqXHR.statusText = ( nativeStatusText || statusText ) + "";
8074
deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
8076
deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
8079
// Status-dependent callbacks
8080
jqXHR.statusCode( statusCode );
8081
statusCode = undefined;
8083
if ( fireGlobals ) {
8084
globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
8085
[ jqXHR, s, isSuccess ? success : error ] );
8089
completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
8091
if ( fireGlobals ) {
8092
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
8093
// Handle the global AJAX counter
8094
if ( !( --jQuery.active ) ) {
8095
jQuery.event.trigger("ajaxStop");
8103
getScript: function( url, callback ) {
8104
return jQuery.get( url, undefined, callback, "script" );
8107
getJSON: function( url, data, callback ) {
8108
return jQuery.get( url, data, callback, "json" );
8010
8112
/* Handles responses to an ajax request:
8013
8115
* - returns the corresponding response
8015
8117
function ajaxHandleResponses( s, jqXHR, responses ) {
8017
var ct, type, finalDataType, firstDataType,
8018
contents = s.contents,
8019
dataTypes = s.dataTypes,
8020
responseFields = s.responseFields;
8022
// Fill responseXXX fields
8023
for ( type in responseFields ) {
8024
if ( type in responses ) {
8025
jqXHR[ responseFields[type] ] = responses[ type ];
8029
// Remove auto dataType and get content-type in the process
8030
while( dataTypes[ 0 ] === "*" ) {
8032
if ( ct === undefined ) {
8033
ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
8037
// Check if we're dealing with a known content-type
8039
for ( type in contents ) {
8040
if ( contents[ type ] && contents[ type ].test( ct ) ) {
8041
dataTypes.unshift( type );
8047
// Check to see if we have a response for the expected dataType
8048
if ( dataTypes[ 0 ] in responses ) {
8049
finalDataType = dataTypes[ 0 ];
8051
// Try convertible dataTypes
8052
for ( type in responses ) {
8053
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
8054
finalDataType = type;
8057
if ( !firstDataType ) {
8058
firstDataType = type;
8061
// Or just use first one
8062
finalDataType = finalDataType || firstDataType;
8065
// If we found a dataType
8066
// We add the dataType to the list if needed
8067
// and return the corresponding response
8068
if ( finalDataType ) {
8069
if ( finalDataType !== dataTypes[ 0 ] ) {
8070
dataTypes.unshift( finalDataType );
8072
return responses[ finalDataType ];
8118
var firstDataType, ct, finalDataType, type,
8119
contents = s.contents,
8120
dataTypes = s.dataTypes,
8121
responseFields = s.responseFields;
8123
// Fill responseXXX fields
8124
for ( type in responseFields ) {
8125
if ( type in responses ) {
8126
jqXHR[ responseFields[type] ] = responses[ type ];
8130
// Remove auto dataType and get content-type in the process
8131
while( dataTypes[ 0 ] === "*" ) {
8133
if ( ct === undefined ) {
8134
ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
8138
// Check if we're dealing with a known content-type
8140
for ( type in contents ) {
8141
if ( contents[ type ] && contents[ type ].test( ct ) ) {
8142
dataTypes.unshift( type );
8148
// Check to see if we have a response for the expected dataType
8149
if ( dataTypes[ 0 ] in responses ) {
8150
finalDataType = dataTypes[ 0 ];
8152
// Try convertible dataTypes
8153
for ( type in responses ) {
8154
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
8155
finalDataType = type;
8158
if ( !firstDataType ) {
8159
firstDataType = type;
8162
// Or just use first one
8163
finalDataType = finalDataType || firstDataType;
8166
// If we found a dataType
8167
// We add the dataType to the list if needed
8168
// and return the corresponding response
8169
if ( finalDataType ) {
8170
if ( finalDataType !== dataTypes[ 0 ] ) {
8171
dataTypes.unshift( finalDataType );
8173
return responses[ finalDataType ];
8076
8177
// Chain conversions given the request and the original response
8077
8178
function ajaxConvert( s, response ) {
8079
var conv, conv2, current, tmp,
8080
// Work with a copy of dataTypes in case we need to modify it for conversion
8081
dataTypes = s.dataTypes.slice(),
8082
prev = dataTypes[ 0 ],
8086
// Apply the dataFilter if provided
8087
if ( s.dataFilter ) {
8088
response = s.dataFilter( response, s.dataType );
8091
// Create converters map with lowercased keys
8092
if ( dataTypes[ 1 ] ) {
8093
for ( conv in s.converters ) {
8094
converters[ conv.toLowerCase() ] = s.converters[ conv ];
8098
// Convert to each sequential dataType, tolerating list modification
8099
for ( ; (current = dataTypes[++i]); ) {
8101
// There's only work to do if current dataType is non-auto
8102
if ( current !== "*" ) {
8104
// Convert response if prev dataType is non-auto and differs from current
8105
if ( prev !== "*" && prev !== current ) {
8107
// Seek a direct converter
8108
conv = converters[ prev + " " + current ] || converters[ "* " + current ];
8110
// If none found, seek a pair
8112
for ( conv2 in converters ) {
8114
// If conv2 outputs current
8115
tmp = conv2.split(" ");
8116
if ( tmp[ 1 ] === current ) {
8118
// If prev can be converted to accepted input
8119
conv = converters[ prev + " " + tmp[ 0 ] ] ||
8120
converters[ "* " + tmp[ 0 ] ];
8122
// Condense equivalence converters
8123
if ( conv === true ) {
8124
conv = converters[ conv2 ];
8126
// Otherwise, insert the intermediate dataType
8127
} else if ( converters[ conv2 ] !== true ) {
8129
dataTypes.splice( i--, 0, current );
8138
// Apply converter (if not an equivalence)
8139
if ( conv !== true ) {
8141
// Unless errors are allowed to bubble, catch and return them
8142
if ( conv && s["throws"] ) {
8143
response = conv( response );
8146
response = conv( response );
8148
return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
8154
// Update prev for next iteration
8159
return { state: "success", data: response };
8179
var conv2, current, conv, tmp,
8182
// Work with a copy of dataTypes in case we need to modify it for conversion
8183
dataTypes = s.dataTypes.slice(),
8184
prev = dataTypes[ 0 ];
8186
// Apply the dataFilter if provided
8187
if ( s.dataFilter ) {
8188
response = s.dataFilter( response, s.dataType );
8191
// Create converters map with lowercased keys
8192
if ( dataTypes[ 1 ] ) {
8193
for ( conv in s.converters ) {
8194
converters[ conv.toLowerCase() ] = s.converters[ conv ];
8198
// Convert to each sequential dataType, tolerating list modification
8199
for ( ; (current = dataTypes[++i]); ) {
8201
// There's only work to do if current dataType is non-auto
8202
if ( current !== "*" ) {
8204
// Convert response if prev dataType is non-auto and differs from current
8205
if ( prev !== "*" && prev !== current ) {
8207
// Seek a direct converter
8208
conv = converters[ prev + " " + current ] || converters[ "* " + current ];
8210
// If none found, seek a pair
8212
for ( conv2 in converters ) {
8214
// If conv2 outputs current
8215
tmp = conv2.split(" ");
8216
if ( tmp[ 1 ] === current ) {
8218
// If prev can be converted to accepted input
8219
conv = converters[ prev + " " + tmp[ 0 ] ] ||
8220
converters[ "* " + tmp[ 0 ] ];
8222
// Condense equivalence converters
8223
if ( conv === true ) {
8224
conv = converters[ conv2 ];
8226
// Otherwise, insert the intermediate dataType
8227
} else if ( converters[ conv2 ] !== true ) {
8229
dataTypes.splice( i--, 0, current );
8238
// Apply converter (if not an equivalence)
8239
if ( conv !== true ) {
8241
// Unless errors are allowed to bubble, catch and return them
8242
if ( conv && s["throws"] ) {
8243
response = conv( response );
8246
response = conv( response );
8248
return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
8254
// Update prev for next iteration
8259
return { state: "success", data: response };
8161
var oldCallbacks = [],
8163
rjsonp = /(=)\?(?=&|$)|\?\?/,
8164
nonce = jQuery.now();
8166
// Default jsonp settings
8169
jsonpCallback: function() {
8170
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
8171
this[ callback ] = true;
8176
// Detect, normalize options and install callbacks for jsonp requests
8177
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
8179
var callbackName, overwritten, responseContainer,
8182
hasCallback = s.jsonp !== false,
8183
replaceInUrl = hasCallback && rjsonp.test( url ),
8184
replaceInData = hasCallback && !replaceInUrl && typeof data === "string" &&
8185
!( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") &&
8186
rjsonp.test( data );
8188
// Handle iff the expected data type is "jsonp" or we have a parameter to set
8189
if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) {
8191
// Get callback name, remembering preexisting value associated with it
8192
callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
8195
overwritten = window[ callbackName ];
8197
// Insert callback into url or form data
8198
if ( replaceInUrl ) {
8199
s.url = url.replace( rjsonp, "$1" + callbackName );
8200
} else if ( replaceInData ) {
8201
s.data = data.replace( rjsonp, "$1" + callbackName );
8202
} else if ( hasCallback ) {
8203
s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
8206
// Use data converter to retrieve json after script execution
8207
s.converters["script json"] = function() {
8208
if ( !responseContainer ) {
8209
jQuery.error( callbackName + " was not called" );
8211
return responseContainer[ 0 ];
8214
// force json dataType
8215
s.dataTypes[ 0 ] = "json";
8218
window[ callbackName ] = function() {
8219
responseContainer = arguments;
8222
// Clean-up function (fires after converters)
8223
jqXHR.always(function() {
8224
// Restore preexisting value
8225
window[ callbackName ] = overwritten;
8227
// Save back as free
8228
if ( s[ callbackName ] ) {
8229
// make sure that re-using the options doesn't screw things around
8230
s.jsonpCallback = originalSettings.jsonpCallback;
8232
// save the callback name for future use
8233
oldCallbacks.push( callbackName );
8236
// Call if it was a function and we have a response
8237
if ( responseContainer && jQuery.isFunction( overwritten ) ) {
8238
overwritten( responseContainer[ 0 ] );
8241
responseContainer = overwritten = undefined;
8244
// Delegate to script
8248
8261
// Install script dataType
8249
8262
jQuery.ajaxSetup({
8251
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
8254
script: /javascript|ecmascript/
8257
"text script": function( text ) {
8258
jQuery.globalEval( text );
8264
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
8267
script: /(?:java|ecma)script/
8270
"text script": function( text ) {
8271
jQuery.globalEval( text );
8264
8277
// Handle cache's special case and global
8265
8278
jQuery.ajaxPrefilter( "script", function( s ) {
8266
if ( s.cache === undefined ) {
8269
if ( s.crossDomain ) {
8279
if ( s.cache === undefined ) {
8282
if ( s.crossDomain ) {
8275
8288
// Bind script tag hack transport
8276
8289
jQuery.ajaxTransport( "script", function(s) {
8278
// This transport only deals with cross domain requests
8279
if ( s.crossDomain ) {
8282
head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
8286
send: function( _, callback ) {
8288
script = document.createElement( "script" );
8290
script.async = "async";
8292
if ( s.scriptCharset ) {
8293
script.charset = s.scriptCharset;
8298
// Attach handlers for all browsers
8299
script.onload = script.onreadystatechange = function( _, isAbort ) {
8301
if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
8303
// Handle memory leak in IE
8304
script.onload = script.onreadystatechange = null;
8306
// Remove the script
8307
if ( head && script.parentNode ) {
8308
head.removeChild( script );
8311
// Dereference the script
8314
// Callback if not abort
8316
callback( 200, "success" );
8320
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
8321
// This arises when a base node is used (#2709 and #4378).
8322
head.insertBefore( script, head.firstChild );
8327
script.onload( 0, 1 );
8334
// #5280: Internet Explorer will keep connections alive if we don't abort on unload
8335
xhrOnUnloadAbort = window.ActiveXObject ? function() {
8336
// Abort all pending requests
8337
for ( var key in xhrCallbacks ) {
8338
xhrCallbacks[ key ]( 0, 1 );
8291
// This transport only deals with cross domain requests
8292
if ( s.crossDomain ) {
8295
head = document.head || jQuery("head")[0] || document.documentElement;
8299
send: function( _, callback ) {
8301
script = document.createElement("script");
8303
script.async = true;
8305
if ( s.scriptCharset ) {
8306
script.charset = s.scriptCharset;
8311
// Attach handlers for all browsers
8312
script.onload = script.onreadystatechange = function( _, isAbort ) {
8314
if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
8316
// Handle memory leak in IE
8317
script.onload = script.onreadystatechange = null;
8319
// Remove the script
8320
if ( script.parentNode ) {
8321
script.parentNode.removeChild( script );
8324
// Dereference the script
8327
// Callback if not abort
8329
callback( 200, "success" );
8334
// Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
8335
// Use native DOM manipulation to avoid our domManip AJAX trickery
8336
head.insertBefore( script, head.firstChild );
8341
script.onload( undefined, true );
8347
var oldCallbacks = [],
8348
rjsonp = /(=)\?(?=&|$)|\?\?/;
8350
// Default jsonp settings
8353
jsonpCallback: function() {
8354
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) );
8355
this[ callback ] = true;
8360
// Detect, normalize options and install callbacks for jsonp requests
8361
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
8363
var callbackName, overwritten, responseContainer,
8364
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
8366
typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
8369
// Handle iff the expected data type is "jsonp" or we have a parameter to set
8370
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
8372
// Get callback name, remembering preexisting value associated with it
8373
callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
8377
// Insert callback into url or form data
8379
s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
8380
} else if ( s.jsonp !== false ) {
8381
s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
8384
// Use data converter to retrieve json after script execution
8385
s.converters["script json"] = function() {
8386
if ( !responseContainer ) {
8387
jQuery.error( callbackName + " was not called" );
8389
return responseContainer[ 0 ];
8392
// force json dataType
8393
s.dataTypes[ 0 ] = "json";
8396
overwritten = window[ callbackName ];
8397
window[ callbackName ] = function() {
8398
responseContainer = arguments;
8401
// Clean-up function (fires after converters)
8402
jqXHR.always(function() {
8403
// Restore preexisting value
8404
window[ callbackName ] = overwritten;
8406
// Save back as free
8407
if ( s[ callbackName ] ) {
8408
// make sure that re-using the options doesn't screw things around
8409
s.jsonpCallback = originalSettings.jsonpCallback;
8411
// save the callback name for future use
8412
oldCallbacks.push( callbackName );
8415
// Call if it was a function and we have a response
8416
if ( responseContainer && jQuery.isFunction( overwritten ) ) {
8417
overwritten( responseContainer[ 0 ] );
8420
responseContainer = overwritten = undefined;
8423
// Delegate to script
8427
var xhrCallbacks, xhrSupported,
8429
// #5280: Internet Explorer will keep connections alive if we don't abort on unload
8430
xhrOnUnloadAbort = window.ActiveXObject && function() {
8431
// Abort all pending requests
8433
for ( key in xhrCallbacks ) {
8434
xhrCallbacks[ key ]( undefined, true );
8343
8438
// Functions to create xhrs
8344
8439
function createStandardXHR() {
8346
return new window.XMLHttpRequest();
8441
return new window.XMLHttpRequest();
8350
8445
function createActiveXHR() {
8352
return new window.ActiveXObject( "Microsoft.XMLHTTP" );
8447
return new window.ActiveXObject("Microsoft.XMLHTTP");
8356
8451
// Create the request object
8357
8452
// (This is still attached to ajaxSettings for backward compatibility)
8358
8453
jQuery.ajaxSettings.xhr = window.ActiveXObject ?
8359
/* Microsoft failed to properly
8360
* implement the XMLHttpRequest in IE7 (can't request local files),
8361
* so we use the ActiveXObject when it is available
8362
* Additionally XMLHttpRequest can be disabled in IE7/IE8 so
8363
* we need a fallback.
8366
return !this.isLocal && createStandardXHR() || createActiveXHR();
8368
// For all other browsers, use the standard XMLHttpRequest object
8454
/* Microsoft failed to properly
8455
* implement the XMLHttpRequest in IE7 (can't request local files),
8456
* so we use the ActiveXObject when it is available
8457
* Additionally XMLHttpRequest can be disabled in IE7/IE8 so
8458
* we need a fallback.
8461
return !this.isLocal && createStandardXHR() || createActiveXHR();
8463
// For all other browsers, use the standard XMLHttpRequest object
8371
8466
// Determine support properties
8373
jQuery.extend( jQuery.support, {
8375
cors: !!xhr && ( "withCredentials" in xhr )
8377
})( jQuery.ajaxSettings.xhr() );
8467
xhrSupported = jQuery.ajaxSettings.xhr();
8468
jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
8469
xhrSupported = jQuery.support.ajax = !!xhrSupported;
8379
8471
// Create transport if the browser can provide an xhr
8380
if ( jQuery.support.ajax ) {
8382
jQuery.ajaxTransport(function( s ) {
8383
// Cross domain only allowed if supported through XMLHttpRequest
8384
if ( !s.crossDomain || jQuery.support.cors ) {
8389
send: function( headers, complete ) {
8396
// Passing null username, generates a login popup on Opera (#2865)
8398
xhr.open( s.type, s.url, s.async, s.username, s.password );
8400
xhr.open( s.type, s.url, s.async );
8403
// Apply custom fields if provided
8404
if ( s.xhrFields ) {
8405
for ( i in s.xhrFields ) {
8406
xhr[ i ] = s.xhrFields[ i ];
8410
// Override mime type if needed
8411
if ( s.mimeType && xhr.overrideMimeType ) {
8412
xhr.overrideMimeType( s.mimeType );
8415
// X-Requested-With header
8416
// For cross-domain requests, seeing as conditions for a preflight are
8417
// akin to a jigsaw puzzle, we simply never set it to be sure.
8418
// (it can always be set on a per-request basis or even using ajaxSetup)
8419
// For same-domain requests, won't change header if already provided.
8420
if ( !s.crossDomain && !headers["X-Requested-With"] ) {
8421
headers[ "X-Requested-With" ] = "XMLHttpRequest";
8424
// Need an extra try/catch for cross domain requests in Firefox 3
8426
for ( i in headers ) {
8427
xhr.setRequestHeader( i, headers[ i ] );
8431
// Do send the request
8432
// This may raise an exception which is actually
8433
// handled in jQuery.ajax (so no try/catch here)
8434
xhr.send( ( s.hasContent && s.data ) || null );
8437
callback = function( _, isAbort ) {
8445
// Firefox throws exceptions when accessing properties
8446
// of an xhr when a network error occurred
8447
// http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
8450
// Was never called and is aborted or complete
8451
if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
8454
callback = undefined;
8456
// Do not keep as active anymore
8458
xhr.onreadystatechange = jQuery.noop;
8459
if ( xhrOnUnloadAbort ) {
8460
delete xhrCallbacks[ handle ];
8466
// Abort it manually if needed
8467
if ( xhr.readyState !== 4 ) {
8471
status = xhr.status;
8472
responseHeaders = xhr.getAllResponseHeaders();
8474
xml = xhr.responseXML;
8476
// Construct response list
8477
if ( xml && xml.documentElement /* #4958 */ ) {
8478
responses.xml = xml;
8481
// When requesting binary data, IE6-9 will throw an exception
8482
// on any attempt to access responseText (#11426)
8484
responses.text = xhr.responseText;
8488
// Firefox throws an exception when accessing
8489
// statusText for faulty cross-domain requests
8491
statusText = xhr.statusText;
8493
// We normalize with Webkit giving an empty statusText
8497
// Filter status for non standard behaviors
8499
// If the request is local and we have data: assume a success
8500
// (success with no data won't get notified, that's the best we
8501
// can do given current implementations)
8502
if ( !status && s.isLocal && !s.crossDomain ) {
8503
status = responses.text ? 200 : 404;
8504
// IE - #1450: sometimes returns 1223 when it should be 204
8505
} else if ( status === 1223 ) {
8510
} catch( firefoxAccessException ) {
8512
complete( -1, firefoxAccessException );
8516
// Call complete if needed
8518
complete( status, statusText, responses, responseHeaders );
8523
// if we're in sync mode we fire the callback
8525
} else if ( xhr.readyState === 4 ) {
8526
// (IE6 & IE7) if it's in cache and has been
8527
// retrieved directly we need to fire the callback
8528
setTimeout( callback, 0 );
8531
if ( xhrOnUnloadAbort ) {
8532
// Create the active xhrs callbacks list if needed
8533
// and attach the unload handler
8534
if ( !xhrCallbacks ) {
8536
jQuery( window ).unload( xhrOnUnloadAbort );
8538
// Add to list of active xhrs callbacks
8539
xhrCallbacks[ handle ] = callback;
8541
xhr.onreadystatechange = callback;
8472
if ( xhrSupported ) {
8474
jQuery.ajaxTransport(function( s ) {
8475
// Cross domain only allowed if supported through XMLHttpRequest
8476
if ( !s.crossDomain || jQuery.support.cors ) {
8481
send: function( headers, complete ) {
8488
// Passing null username, generates a login popup on Opera (#2865)
8490
xhr.open( s.type, s.url, s.async, s.username, s.password );
8492
xhr.open( s.type, s.url, s.async );
8495
// Apply custom fields if provided
8496
if ( s.xhrFields ) {
8497
for ( i in s.xhrFields ) {
8498
xhr[ i ] = s.xhrFields[ i ];
8502
// Override mime type if needed
8503
if ( s.mimeType && xhr.overrideMimeType ) {
8504
xhr.overrideMimeType( s.mimeType );
8507
// X-Requested-With header
8508
// For cross-domain requests, seeing as conditions for a preflight are
8509
// akin to a jigsaw puzzle, we simply never set it to be sure.
8510
// (it can always be set on a per-request basis or even using ajaxSetup)
8511
// For same-domain requests, won't change header if already provided.
8512
if ( !s.crossDomain && !headers["X-Requested-With"] ) {
8513
headers["X-Requested-With"] = "XMLHttpRequest";
8516
// Need an extra try/catch for cross domain requests in Firefox 3
8518
for ( i in headers ) {
8519
xhr.setRequestHeader( i, headers[ i ] );
8523
// Do send the request
8524
// This may raise an exception which is actually
8525
// handled in jQuery.ajax (so no try/catch here)
8526
xhr.send( ( s.hasContent && s.data ) || null );
8529
callback = function( _, isAbort ) {
8530
var status, responseHeaders, statusText, responses;
8532
// Firefox throws exceptions when accessing properties
8533
// of an xhr when a network error occurred
8534
// http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
8537
// Was never called and is aborted or complete
8538
if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
8541
callback = undefined;
8543
// Do not keep as active anymore
8545
xhr.onreadystatechange = jQuery.noop;
8546
if ( xhrOnUnloadAbort ) {
8547
delete xhrCallbacks[ handle ];
8553
// Abort it manually if needed
8554
if ( xhr.readyState !== 4 ) {
8559
status = xhr.status;
8560
responseHeaders = xhr.getAllResponseHeaders();
8562
// When requesting binary data, IE6-9 will throw an exception
8563
// on any attempt to access responseText (#11426)
8564
if ( typeof xhr.responseText === "string" ) {
8565
responses.text = xhr.responseText;
8568
// Firefox throws an exception when accessing
8569
// statusText for faulty cross-domain requests
8571
statusText = xhr.statusText;
8573
// We normalize with Webkit giving an empty statusText
8577
// Filter status for non standard behaviors
8579
// If the request is local and we have data: assume a success
8580
// (success with no data won't get notified, that's the best we
8581
// can do given current implementations)
8582
if ( !status && s.isLocal && !s.crossDomain ) {
8583
status = responses.text ? 200 : 404;
8584
// IE - #1450: sometimes returns 1223 when it should be 204
8585
} else if ( status === 1223 ) {
8590
} catch( firefoxAccessException ) {
8592
complete( -1, firefoxAccessException );
8596
// Call complete if needed
8598
complete( status, statusText, responses, responseHeaders );
8603
// if we're in sync mode we fire the callback
8605
} else if ( xhr.readyState === 4 ) {
8606
// (IE6 & IE7) if it's in cache and has been
8607
// retrieved directly we need to fire the callback
8608
setTimeout( callback );
8611
if ( xhrOnUnloadAbort ) {
8612
// Create the active xhrs callbacks list if needed
8613
// and attach the unload handler
8614
if ( !xhrCallbacks ) {
8616
jQuery( window ).unload( xhrOnUnloadAbort );
8618
// Add to list of active xhrs callbacks
8619
xhrCallbacks[ handle ] = callback;
8621
xhr.onreadystatechange = callback;
8627
callback( undefined, true );
8554
8634
var fxNow, timerId,
8555
rfxtypes = /^(?:toggle|show|hide)$/,
8556
rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
8557
rrun = /queueHooks$/,
8558
animationPrefilters = [ defaultPrefilter ],
8560
"*": [function( prop, value ) {
8562
tween = this.createTween( prop, value ),
8563
parts = rfxnum.exec( value ),
8564
target = tween.cur(),
8565
start = +target || 0,
8571
unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
8573
// We need to compute starting value
8574
if ( unit !== "px" && start ) {
8575
// Iteratively approximate from a nonzero starting point
8576
// Prefer the current property, because this process will be trivial if it uses the same units
8577
// Fallback to end or a simple constant
8578
start = jQuery.css( tween.elem, prop, true ) || end || 1;
8581
// If previous iteration zeroed out, double until we get *something*
8582
// Use a string for doubling factor so we don't accidentally see scale as unchanged below
8583
scale = scale || ".5";
8586
start = start / scale;
8587
jQuery.style( tween.elem, prop, start + unit );
8589
// Update scale, tolerating zero or NaN from tween.cur()
8590
// And breaking the loop if scale is unchanged or perfect, or if we've just had enough
8591
} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
8595
tween.start = start;
8596
// If a +=/-= token was provided, we're doing a relative animation
8597
tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
8635
rfxtypes = /^(?:toggle|show|hide)$/,
8636
rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
8637
rrun = /queueHooks$/,
8638
animationPrefilters = [ defaultPrefilter ],
8640
"*": [function( prop, value ) {
8642
tween = this.createTween( prop, value ),
8643
parts = rfxnum.exec( value ),
8644
target = tween.cur(),
8645
start = +target || 0,
8651
unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
8653
// We need to compute starting value
8654
if ( unit !== "px" && start ) {
8655
// Iteratively approximate from a nonzero starting point
8656
// Prefer the current property, because this process will be trivial if it uses the same units
8657
// Fallback to end or a simple constant
8658
start = jQuery.css( tween.elem, prop, true ) || end || 1;
8661
// If previous iteration zeroed out, double until we get *something*
8662
// Use a string for doubling factor so we don't accidentally see scale as unchanged below
8663
scale = scale || ".5";
8666
start = start / scale;
8667
jQuery.style( tween.elem, prop, start + unit );
8669
// Update scale, tolerating zero or NaN from tween.cur()
8670
// And breaking the loop if scale is unchanged or perfect, or if we've just had enough
8671
} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
8675
tween.start = start;
8676
// If a +=/-= token was provided, we're doing a relative animation
8677
tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
8603
8683
// Animations created synchronously will run synchronously
8604
8684
function createFxNow() {
8605
setTimeout(function() {
8608
return ( fxNow = jQuery.now() );
8685
setTimeout(function() {
8688
return ( fxNow = jQuery.now() );
8611
8691
function createTweens( animation, props ) {
8612
jQuery.each( props, function( prop, value ) {
8613
var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
8615
length = collection.length;
8616
for ( ; index < length; index++ ) {
8617
if ( collection[ index ].call( animation, prop, value ) ) {
8692
jQuery.each( props, function( prop, value ) {
8693
var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
8695
length = collection.length;
8696
for ( ; index < length; index++ ) {
8697
if ( collection[ index ].call( animation, prop, value ) ) {
8619
// we're done with this property
8699
// we're done with this property
8626
8706
function Animation( elem, properties, options ) {
8630
length = animationPrefilters.length,
8631
deferred = jQuery.Deferred().always( function() {
8632
// don't match elem in the :animated selector
8636
var currentTime = fxNow || createFxNow(),
8637
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
8638
// archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
8639
temp = remaining / animation.duration || 0,
8642
length = animation.tweens.length;
8644
for ( ; index < length ; index++ ) {
8645
animation.tweens[ index ].run( percent );
8648
deferred.notifyWith( elem, [ animation, percent, remaining ]);
8650
if ( percent < 1 && length ) {
8653
deferred.resolveWith( elem, [ animation ] );
8657
animation = deferred.promise({
8659
props: jQuery.extend( {}, properties ),
8660
opts: jQuery.extend( true, { specialEasing: {} }, options ),
8661
originalProperties: properties,
8662
originalOptions: options,
8663
startTime: fxNow || createFxNow(),
8664
duration: options.duration,
8666
createTween: function( prop, end, easing ) {
8667
var tween = jQuery.Tween( elem, animation.opts, prop, end,
8668
animation.opts.specialEasing[ prop ] || animation.opts.easing );
8669
animation.tweens.push( tween );
8672
stop: function( gotoEnd ) {
8674
// if we are going to the end, we want to run all the tweens
8675
// otherwise we skip this part
8676
length = gotoEnd ? animation.tweens.length : 0;
8678
for ( ; index < length ; index++ ) {
8679
animation.tweens[ index ].run( 1 );
8682
// resolve when we played the last frame
8683
// otherwise, reject
8685
deferred.resolveWith( elem, [ animation, gotoEnd ] );
8687
deferred.rejectWith( elem, [ animation, gotoEnd ] );
8692
props = animation.props;
8694
propFilter( props, animation.opts.specialEasing );
8696
for ( ; index < length ; index++ ) {
8697
result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
8703
createTweens( animation, props );
8705
if ( jQuery.isFunction( animation.opts.start ) ) {
8706
animation.opts.start.call( elem, animation );
8710
jQuery.extend( tick, {
8712
queue: animation.opts.queue,
8717
// attach callbacks from options
8718
return animation.progress( animation.opts.progress )
8719
.done( animation.opts.done, animation.opts.complete )
8720
.fail( animation.opts.fail )
8721
.always( animation.opts.always );
8710
length = animationPrefilters.length,
8711
deferred = jQuery.Deferred().always( function() {
8712
// don't match elem in the :animated selector
8719
var currentTime = fxNow || createFxNow(),
8720
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
8721
// archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
8722
temp = remaining / animation.duration || 0,
8725
length = animation.tweens.length;
8727
for ( ; index < length ; index++ ) {
8728
animation.tweens[ index ].run( percent );
8731
deferred.notifyWith( elem, [ animation, percent, remaining ]);
8733
if ( percent < 1 && length ) {
8736
deferred.resolveWith( elem, [ animation ] );
8740
animation = deferred.promise({
8742
props: jQuery.extend( {}, properties ),
8743
opts: jQuery.extend( true, { specialEasing: {} }, options ),
8744
originalProperties: properties,
8745
originalOptions: options,
8746
startTime: fxNow || createFxNow(),
8747
duration: options.duration,
8749
createTween: function( prop, end ) {
8750
var tween = jQuery.Tween( elem, animation.opts, prop, end,
8751
animation.opts.specialEasing[ prop ] || animation.opts.easing );
8752
animation.tweens.push( tween );
8755
stop: function( gotoEnd ) {
8757
// if we are going to the end, we want to run all the tweens
8758
// otherwise we skip this part
8759
length = gotoEnd ? animation.tweens.length : 0;
8764
for ( ; index < length ; index++ ) {
8765
animation.tweens[ index ].run( 1 );
8768
// resolve when we played the last frame
8769
// otherwise, reject
8771
deferred.resolveWith( elem, [ animation, gotoEnd ] );
8773
deferred.rejectWith( elem, [ animation, gotoEnd ] );
8778
props = animation.props;
8780
propFilter( props, animation.opts.specialEasing );
8782
for ( ; index < length ; index++ ) {
8783
result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
8789
createTweens( animation, props );
8791
if ( jQuery.isFunction( animation.opts.start ) ) {
8792
animation.opts.start.call( elem, animation );
8796
jQuery.extend( tick, {
8799
queue: animation.opts.queue
8803
// attach callbacks from options
8804
return animation.progress( animation.opts.progress )
8805
.done( animation.opts.done, animation.opts.complete )
8806
.fail( animation.opts.fail )
8807
.always( animation.opts.always );
8724
8810
function propFilter( props, specialEasing ) {
8725
var index, name, easing, value, hooks;
8727
// camelCase, specialEasing and expand cssHook pass
8728
for ( index in props ) {
8729
name = jQuery.camelCase( index );
8730
easing = specialEasing[ name ];
8731
value = props[ index ];
8732
if ( jQuery.isArray( value ) ) {
8733
easing = value[ 1 ];
8734
value = props[ index ] = value[ 0 ];
8737
if ( index !== name ) {
8738
props[ name ] = value;
8739
delete props[ index ];
8742
hooks = jQuery.cssHooks[ name ];
8743
if ( hooks && "expand" in hooks ) {
8744
value = hooks.expand( value );
8745
delete props[ name ];
8747
// not quite $.extend, this wont overwrite keys already present.
8748
// also - reusing 'index' from above because we have the correct "name"
8749
for ( index in value ) {
8750
if ( !( index in props ) ) {
8751
props[ index ] = value[ index ];
8752
specialEasing[ index ] = easing;
8756
specialEasing[ name ] = easing;
8811
var value, name, index, easing, hooks;
8813
// camelCase, specialEasing and expand cssHook pass
8814
for ( index in props ) {
8815
name = jQuery.camelCase( index );
8816
easing = specialEasing[ name ];
8817
value = props[ index ];
8818
if ( jQuery.isArray( value ) ) {
8819
easing = value[ 1 ];
8820
value = props[ index ] = value[ 0 ];
8823
if ( index !== name ) {
8824
props[ name ] = value;
8825
delete props[ index ];
8828
hooks = jQuery.cssHooks[ name ];
8829
if ( hooks && "expand" in hooks ) {
8830
value = hooks.expand( value );
8831
delete props[ name ];
8833
// not quite $.extend, this wont overwrite keys already present.
8834
// also - reusing 'index' from above because we have the correct "name"
8835
for ( index in value ) {
8836
if ( !( index in props ) ) {
8837
props[ index ] = value[ index ];
8838
specialEasing[ index ] = easing;
8842
specialEasing[ name ] = easing;
8761
8847
jQuery.Animation = jQuery.extend( Animation, {
8763
tweener: function( props, callback ) {
8764
if ( jQuery.isFunction( props ) ) {
8768
props = props.split(" ");
8773
length = props.length;
8775
for ( ; index < length ; index++ ) {
8776
prop = props[ index ];
8777
tweeners[ prop ] = tweeners[ prop ] || [];
8778
tweeners[ prop ].unshift( callback );
8782
prefilter: function( callback, prepend ) {
8784
animationPrefilters.unshift( callback );
8786
animationPrefilters.push( callback );
8849
tweener: function( props, callback ) {
8850
if ( jQuery.isFunction( props ) ) {
8854
props = props.split(" ");
8859
length = props.length;
8861
for ( ; index < length ; index++ ) {
8862
prop = props[ index ];
8863
tweeners[ prop ] = tweeners[ prop ] || [];
8864
tweeners[ prop ].unshift( callback );
8868
prefilter: function( callback, prepend ) {
8870
animationPrefilters.unshift( callback );
8872
animationPrefilters.push( callback );
8791
8877
function defaultPrefilter( elem, props, opts ) {
8792
var index, prop, value, length, dataShow, toggle, tween, hooks, oldfire,
8797
hidden = elem.nodeType && isHidden( elem );
8799
// handle queue: false promises
8800
if ( !opts.queue ) {
8801
hooks = jQuery._queueHooks( elem, "fx" );
8802
if ( hooks.unqueued == null ) {
8804
oldfire = hooks.empty.fire;
8805
hooks.empty.fire = function() {
8806
if ( !hooks.unqueued ) {
8813
anim.always(function() {
8814
// doing this makes sure that the complete handler will be called
8815
// before this completes
8816
anim.always(function() {
8818
if ( !jQuery.queue( elem, "fx" ).length ) {
8825
// height/width overflow pass
8826
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
8827
// Make sure that nothing sneaks out
8828
// Record all 3 overflow attributes because IE does not
8829
// change the overflow attribute when overflowX and
8830
// overflowY are set to the same value
8831
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
8833
// Set display property to inline-block for height/width
8834
// animations on inline elements that are having width/height animated
8835
if ( jQuery.css( elem, "display" ) === "inline" &&
8836
jQuery.css( elem, "float" ) === "none" ) {
8838
// inline-level elements accept inline-block;
8839
// block-level elements need to be inline with layout
8840
if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
8841
style.display = "inline-block";
8849
if ( opts.overflow ) {
8850
style.overflow = "hidden";
8851
if ( !jQuery.support.shrinkWrapBlocks ) {
8852
anim.done(function() {
8853
style.overflow = opts.overflow[ 0 ];
8854
style.overflowX = opts.overflow[ 1 ];
8855
style.overflowY = opts.overflow[ 2 ];
8862
for ( index in props ) {
8863
value = props[ index ];
8864
if ( rfxtypes.exec( value ) ) {
8865
delete props[ index ];
8866
toggle = toggle || value === "toggle";
8867
if ( value === ( hidden ? "hide" : "show" ) ) {
8870
handled.push( index );
8874
length = handled.length;
8876
dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
8877
if ( "hidden" in dataShow ) {
8878
hidden = dataShow.hidden;
8881
// store state if its toggle - enables .stop().toggle() to "reverse"
8883
dataShow.hidden = !hidden;
8886
jQuery( elem ).show();
8888
anim.done(function() {
8889
jQuery( elem ).hide();
8892
anim.done(function() {
8894
jQuery.removeData( elem, "fxshow", true );
8895
for ( prop in orig ) {
8896
jQuery.style( elem, prop, orig[ prop ] );
8899
for ( index = 0 ; index < length ; index++ ) {
8900
prop = handled[ index ];
8901
tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
8902
orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
8904
if ( !( prop in dataShow ) ) {
8905
dataShow[ prop ] = tween.start;
8907
tween.end = tween.start;
8908
tween.start = prop === "width" || prop === "height" ? 1 : 0;
8878
/*jshint validthis:true */
8879
var prop, index, length,
8880
value, dataShow, toggle,
8881
tween, hooks, oldfire,
8886
hidden = elem.nodeType && isHidden( elem );
8888
// handle queue: false promises
8889
if ( !opts.queue ) {
8890
hooks = jQuery._queueHooks( elem, "fx" );
8891
if ( hooks.unqueued == null ) {
8893
oldfire = hooks.empty.fire;
8894
hooks.empty.fire = function() {
8895
if ( !hooks.unqueued ) {
8902
anim.always(function() {
8903
// doing this makes sure that the complete handler will be called
8904
// before this completes
8905
anim.always(function() {
8907
if ( !jQuery.queue( elem, "fx" ).length ) {
8914
// height/width overflow pass
8915
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
8916
// Make sure that nothing sneaks out
8917
// Record all 3 overflow attributes because IE does not
8918
// change the overflow attribute when overflowX and
8919
// overflowY are set to the same value
8920
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
8922
// Set display property to inline-block for height/width
8923
// animations on inline elements that are having width/height animated
8924
if ( jQuery.css( elem, "display" ) === "inline" &&
8925
jQuery.css( elem, "float" ) === "none" ) {
8927
// inline-level elements accept inline-block;
8928
// block-level elements need to be inline with layout
8929
if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
8930
style.display = "inline-block";
8938
if ( opts.overflow ) {
8939
style.overflow = "hidden";
8940
if ( !jQuery.support.shrinkWrapBlocks ) {
8941
anim.always(function() {
8942
style.overflow = opts.overflow[ 0 ];
8943
style.overflowX = opts.overflow[ 1 ];
8944
style.overflowY = opts.overflow[ 2 ];
8951
for ( index in props ) {
8952
value = props[ index ];
8953
if ( rfxtypes.exec( value ) ) {
8954
delete props[ index ];
8955
toggle = toggle || value === "toggle";
8956
if ( value === ( hidden ? "hide" : "show" ) ) {
8959
handled.push( index );
8963
length = handled.length;
8965
dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
8966
if ( "hidden" in dataShow ) {
8967
hidden = dataShow.hidden;
8970
// store state if its toggle - enables .stop().toggle() to "reverse"
8972
dataShow.hidden = !hidden;
8975
jQuery( elem ).show();
8977
anim.done(function() {
8978
jQuery( elem ).hide();
8981
anim.done(function() {
8983
jQuery._removeData( elem, "fxshow" );
8984
for ( prop in orig ) {
8985
jQuery.style( elem, prop, orig[ prop ] );
8988
for ( index = 0 ; index < length ; index++ ) {
8989
prop = handled[ index ];
8990
tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
8991
orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
8993
if ( !( prop in dataShow ) ) {
8994
dataShow[ prop ] = tween.start;
8996
tween.end = tween.start;
8997
tween.start = prop === "width" || prop === "height" ? 1 : 0;
8915
9004
function Tween( elem, options, prop, end, easing ) {
8916
return new Tween.prototype.init( elem, options, prop, end, easing );
9005
return new Tween.prototype.init( elem, options, prop, end, easing );
8918
9007
jQuery.Tween = Tween;
8920
9009
Tween.prototype = {
8922
init: function( elem, options, prop, end, easing, unit ) {
8925
this.easing = easing || "swing";
8926
this.options = options;
8927
this.start = this.now = this.cur();
8929
this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
8932
var hooks = Tween.propHooks[ this.prop ];
8934
return hooks && hooks.get ?
8936
Tween.propHooks._default.get( this );
8938
run: function( percent ) {
8940
hooks = Tween.propHooks[ this.prop ];
8942
if ( this.options.duration ) {
8943
this.pos = eased = jQuery.easing[ this.easing ](
8944
percent, this.options.duration * percent, 0, 1, this.options.duration
8947
this.pos = eased = percent;
8949
this.now = ( this.end - this.start ) * eased + this.start;
8951
if ( this.options.step ) {
8952
this.options.step.call( this.elem, this.now, this );
8955
if ( hooks && hooks.set ) {
8958
Tween.propHooks._default.set( this );
9011
init: function( elem, options, prop, end, easing, unit ) {
9014
this.easing = easing || "swing";
9015
this.options = options;
9016
this.start = this.now = this.cur();
9018
this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
9021
var hooks = Tween.propHooks[ this.prop ];
9023
return hooks && hooks.get ?
9025
Tween.propHooks._default.get( this );
9027
run: function( percent ) {
9029
hooks = Tween.propHooks[ this.prop ];
9031
if ( this.options.duration ) {
9032
this.pos = eased = jQuery.easing[ this.easing ](
9033
percent, this.options.duration * percent, 0, 1, this.options.duration
9036
this.pos = eased = percent;
9038
this.now = ( this.end - this.start ) * eased + this.start;
9040
if ( this.options.step ) {
9041
this.options.step.call( this.elem, this.now, this );
9044
if ( hooks && hooks.set ) {
9047
Tween.propHooks._default.set( this );
8964
9053
Tween.prototype.init.prototype = Tween.prototype;
8966
9055
Tween.propHooks = {
8968
get: function( tween ) {
8971
if ( tween.elem[ tween.prop ] != null &&
8972
(!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
8973
return tween.elem[ tween.prop ];
8976
// passing any value as a 4th parameter to .css will automatically
8977
// attempt a parseFloat and fallback to a string if the parse fails
8978
// so, simple values such as "10px" are parsed to Float.
8979
// complex values such as "rotate(1rad)" are returned as is.
8980
result = jQuery.css( tween.elem, tween.prop, false, "" );
8981
// Empty strings, null, undefined and "auto" are converted to 0.
8982
return !result || result === "auto" ? 0 : result;
8984
set: function( tween ) {
8985
// use step hook for back compat - use cssHook if its there - use .style if its
8986
// available and use plain properties where available
8987
if ( jQuery.fx.step[ tween.prop ] ) {
8988
jQuery.fx.step[ tween.prop ]( tween );
8989
} else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
8990
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
8992
tween.elem[ tween.prop ] = tween.now;
9057
get: function( tween ) {
9060
if ( tween.elem[ tween.prop ] != null &&
9061
(!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
9062
return tween.elem[ tween.prop ];
9065
// passing an empty string as a 3rd parameter to .css will automatically
9066
// attempt a parseFloat and fallback to a string if the parse fails
9067
// so, simple values such as "10px" are parsed to Float.
9068
// complex values such as "rotate(1rad)" are returned as is.
9069
result = jQuery.css( tween.elem, tween.prop, "" );
9070
// Empty strings, null, undefined and "auto" are converted to 0.
9071
return !result || result === "auto" ? 0 : result;
9073
set: function( tween ) {
9074
// use step hook for back compat - use cssHook if its there - use .style if its
9075
// available and use plain properties where available
9076
if ( jQuery.fx.step[ tween.prop ] ) {
9077
jQuery.fx.step[ tween.prop ]( tween );
9078
} else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
9079
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
9081
tween.elem[ tween.prop ] = tween.now;
8998
9087
// Remove in 2.0 - this supports IE8's panic based approach
8999
9088
// to setting things on disconnected nodes
9001
9090
Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
9002
set: function( tween ) {
9003
if ( tween.elem.nodeType && tween.elem.parentNode ) {
9004
tween.elem[ tween.prop ] = tween.now;
9091
set: function( tween ) {
9092
if ( tween.elem.nodeType && tween.elem.parentNode ) {
9093
tween.elem[ tween.prop ] = tween.now;
9009
9098
jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
9010
var cssFn = jQuery.fn[ name ];
9011
jQuery.fn[ name ] = function( speed, easing, callback ) {
9012
return speed == null || typeof speed === "boolean" ||
9013
// special check for .toggle( handler, handler, ... )
9014
( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ?
9015
cssFn.apply( this, arguments ) :
9016
this.animate( genFx( name, true ), speed, easing, callback );
9099
var cssFn = jQuery.fn[ name ];
9100
jQuery.fn[ name ] = function( speed, easing, callback ) {
9101
return speed == null || typeof speed === "boolean" ?
9102
cssFn.apply( this, arguments ) :
9103
this.animate( genFx( name, true ), speed, easing, callback );
9020
9107
jQuery.fn.extend({
9021
fadeTo: function( speed, to, easing, callback ) {
9023
// show any hidden elements after setting opacity to 0
9024
return this.filter( isHidden ).css( "opacity", 0 ).show()
9026
// animate to the value specified
9027
.end().animate({ opacity: to }, speed, easing, callback );
9029
animate: function( prop, speed, easing, callback ) {
9030
var empty = jQuery.isEmptyObject( prop ),
9031
optall = jQuery.speed( speed, easing, callback ),
9032
doAnimation = function() {
9033
// Operate on a copy of prop so per-property easing won't be lost
9034
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
9036
// Empty animations resolve immediately
9042
return empty || optall.queue === false ?
9043
this.each( doAnimation ) :
9044
this.queue( optall.queue, doAnimation );
9046
stop: function( type, clearQueue, gotoEnd ) {
9047
var stopQueue = function( hooks ) {
9048
var stop = hooks.stop;
9053
if ( typeof type !== "string" ) {
9054
gotoEnd = clearQueue;
9058
if ( clearQueue && type !== false ) {
9059
this.queue( type || "fx", [] );
9062
return this.each(function() {
9064
index = type != null && type + "queueHooks",
9065
timers = jQuery.timers,
9066
data = jQuery._data( this );
9069
if ( data[ index ] && data[ index ].stop ) {
9070
stopQueue( data[ index ] );
9073
for ( index in data ) {
9074
if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
9075
stopQueue( data[ index ] );
9080
for ( index = timers.length; index--; ) {
9081
if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
9082
timers[ index ].anim.stop( gotoEnd );
9084
timers.splice( index, 1 );
9088
// start the next in the queue if the last step wasn't forced
9089
// timers currently will call their complete callbacks, which will dequeue
9090
// but only if they were gotoEnd
9091
if ( dequeue || !gotoEnd ) {
9092
jQuery.dequeue( this, type );
9108
fadeTo: function( speed, to, easing, callback ) {
9110
// show any hidden elements after setting opacity to 0
9111
return this.filter( isHidden ).css( "opacity", 0 ).show()
9113
// animate to the value specified
9114
.end().animate({ opacity: to }, speed, easing, callback );
9116
animate: function( prop, speed, easing, callback ) {
9117
var empty = jQuery.isEmptyObject( prop ),
9118
optall = jQuery.speed( speed, easing, callback ),
9119
doAnimation = function() {
9120
// Operate on a copy of prop so per-property easing won't be lost
9121
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
9122
doAnimation.finish = function() {
9125
// Empty animations, or finishing resolves immediately
9126
if ( empty || jQuery._data( this, "finish" ) ) {
9130
doAnimation.finish = doAnimation;
9132
return empty || optall.queue === false ?
9133
this.each( doAnimation ) :
9134
this.queue( optall.queue, doAnimation );
9136
stop: function( type, clearQueue, gotoEnd ) {
9137
var stopQueue = function( hooks ) {
9138
var stop = hooks.stop;
9143
if ( typeof type !== "string" ) {
9144
gotoEnd = clearQueue;
9148
if ( clearQueue && type !== false ) {
9149
this.queue( type || "fx", [] );
9152
return this.each(function() {
9154
index = type != null && type + "queueHooks",
9155
timers = jQuery.timers,
9156
data = jQuery._data( this );
9159
if ( data[ index ] && data[ index ].stop ) {
9160
stopQueue( data[ index ] );
9163
for ( index in data ) {
9164
if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
9165
stopQueue( data[ index ] );
9170
for ( index = timers.length; index--; ) {
9171
if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
9172
timers[ index ].anim.stop( gotoEnd );
9174
timers.splice( index, 1 );
9178
// start the next in the queue if the last step wasn't forced
9179
// timers currently will call their complete callbacks, which will dequeue
9180
// but only if they were gotoEnd
9181
if ( dequeue || !gotoEnd ) {
9182
jQuery.dequeue( this, type );
9186
finish: function( type ) {
9187
if ( type !== false ) {
9188
type = type || "fx";
9190
return this.each(function() {
9192
data = jQuery._data( this ),
9193
queue = data[ type + "queue" ],
9194
hooks = data[ type + "queueHooks" ],
9195
timers = jQuery.timers,
9196
length = queue ? queue.length : 0;
9198
// enable finishing flag on private data
9201
// empty the queue first
9202
jQuery.queue( this, type, [] );
9204
if ( hooks && hooks.cur && hooks.cur.finish ) {
9205
hooks.cur.finish.call( this );
9208
// look for any active animations, and finish them
9209
for ( index = timers.length; index--; ) {
9210
if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
9211
timers[ index ].anim.stop( true );
9212
timers.splice( index, 1 );
9216
// look for any animations in the old queue and finish them
9217
for ( index = 0; index < length; index++ ) {
9218
if ( queue[ index ] && queue[ index ].finish ) {
9219
queue[ index ].finish.call( this );
9223
// turn off finishing flag
9098
9229
// Generate parameters to create a standard animation
9099
9230
function genFx( type, includeWidth ) {
9101
attrs = { height: type },
9104
// if we include width, step value is 1 to do all cssExpand values,
9105
// if we don't include width, step value is 2 to skip over Left and Right
9106
includeWidth = includeWidth? 1 : 0;
9107
for( ; i < 4 ; i += 2 - includeWidth ) {
9108
which = cssExpand[ i ];
9109
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
9112
if ( includeWidth ) {
9113
attrs.opacity = attrs.width = type;
9232
attrs = { height: type },
9235
// if we include width, step value is 1 to do all cssExpand values,
9236
// if we don't include width, step value is 2 to skip over Left and Right
9237
includeWidth = includeWidth? 1 : 0;
9238
for( ; i < 4 ; i += 2 - includeWidth ) {
9239
which = cssExpand[ i ];
9240
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
9243
if ( includeWidth ) {
9244
attrs.opacity = attrs.width = type;
9119
9250
// Generate shortcuts for custom animations
9121
slideDown: genFx("show"),
9122
slideUp: genFx("hide"),
9123
slideToggle: genFx("toggle"),
9124
fadeIn: { opacity: "show" },
9125
fadeOut: { opacity: "hide" },
9126
fadeToggle: { opacity: "toggle" }
9252
slideDown: genFx("show"),
9253
slideUp: genFx("hide"),
9254
slideToggle: genFx("toggle"),
9255
fadeIn: { opacity: "show" },
9256
fadeOut: { opacity: "hide" },
9257
fadeToggle: { opacity: "toggle" }
9127
9258
}, function( name, props ) {
9128
jQuery.fn[ name ] = function( speed, easing, callback ) {
9129
return this.animate( props, speed, easing, callback );
9259
jQuery.fn[ name ] = function( speed, easing, callback ) {
9260
return this.animate( props, speed, easing, callback );
9133
9264
jQuery.speed = function( speed, easing, fn ) {
9134
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
9135
complete: fn || !fn && easing ||
9136
jQuery.isFunction( speed ) && speed,
9138
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
9141
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
9142
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
9144
// normalize opt.queue - true/undefined/null -> "fx"
9145
if ( opt.queue == null || opt.queue === true ) {
9150
opt.old = opt.complete;
9152
opt.complete = function() {
9153
if ( jQuery.isFunction( opt.old ) ) {
9154
opt.old.call( this );
9158
jQuery.dequeue( this, opt.queue );
9265
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
9266
complete: fn || !fn && easing ||
9267
jQuery.isFunction( speed ) && speed,
9269
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
9272
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
9273
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
9275
// normalize opt.queue - true/undefined/null -> "fx"
9276
if ( opt.queue == null || opt.queue === true ) {
9281
opt.old = opt.complete;
9283
opt.complete = function() {
9284
if ( jQuery.isFunction( opt.old ) ) {
9285
opt.old.call( this );
9289
jQuery.dequeue( this, opt.queue );
9165
9296
jQuery.easing = {
9166
linear: function( p ) {
9169
swing: function( p ) {
9170
return 0.5 - Math.cos( p*Math.PI ) / 2;
9297
linear: function( p ) {
9300
swing: function( p ) {
9301
return 0.5 - Math.cos( p*Math.PI ) / 2;
9174
9305
jQuery.timers = [];
9175
9306
jQuery.fx = Tween.prototype.init;
9176
9307
jQuery.fx.tick = function() {
9178
timers = jQuery.timers,
9181
fxNow = jQuery.now();
9183
for ( ; i < timers.length; i++ ) {
9184
timer = timers[ i ];
9185
// Checks the timer has not already been removed
9186
if ( !timer() && timers[ i ] === timer ) {
9187
timers.splice( i--, 1 );
9191
if ( !timers.length ) {
9309
timers = jQuery.timers,
9312
fxNow = jQuery.now();
9314
for ( ; i < timers.length; i++ ) {
9315
timer = timers[ i ];
9316
// Checks the timer has not already been removed
9317
if ( !timer() && timers[ i ] === timer ) {
9318
timers.splice( i--, 1 );
9322
if ( !timers.length ) {
9197
9328
jQuery.fx.timer = function( timer ) {
9198
if ( timer() && jQuery.timers.push( timer ) && !timerId ) {
9199
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
9329
if ( timer() && jQuery.timers.push( timer ) ) {
9203
9334
jQuery.fx.interval = 13;
9336
jQuery.fx.start = function() {
9338
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
9205
9342
jQuery.fx.stop = function() {
9206
clearInterval( timerId );
9343
clearInterval( timerId );
9210
9347
jQuery.fx.speeds = {
9217
9354
// Back Compat <1.8 extension point
9218
9355
jQuery.fx.step = {};
9220
9357
if ( jQuery.expr && jQuery.expr.filters ) {
9221
jQuery.expr.filters.animated = function( elem ) {
9222
return jQuery.grep(jQuery.timers, function( fn ) {
9223
return elem === fn.elem;
9358
jQuery.expr.filters.animated = function( elem ) {
9359
return jQuery.grep(jQuery.timers, function( fn ) {
9360
return elem === fn.elem;
9227
var rroot = /^(?:body|html)$/i;
9229
9364
jQuery.fn.offset = function( options ) {
9230
if ( arguments.length ) {
9231
return options === undefined ?
9233
this.each(function( i ) {
9234
jQuery.offset.setOffset( this, options, i );
9238
var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft,
9239
box = { top: 0, left: 0 },
9241
doc = elem && elem.ownerDocument;
9247
if ( (body = doc.body) === elem ) {
9248
return jQuery.offset.bodyOffset( elem );
9251
docElem = doc.documentElement;
9253
// Make sure it's not a disconnected DOM node
9254
if ( !jQuery.contains( docElem, elem ) ) {
9258
// If we don't have gBCR, just use 0,0 rather than error
9259
// BlackBerry 5, iOS 3 (original iPhone)
9260
if ( typeof elem.getBoundingClientRect !== "undefined" ) {
9261
box = elem.getBoundingClientRect();
9263
win = getWindow( doc );
9264
clientTop = docElem.clientTop || body.clientTop || 0;
9265
clientLeft = docElem.clientLeft || body.clientLeft || 0;
9266
scrollTop = win.pageYOffset || docElem.scrollTop;
9267
scrollLeft = win.pageXOffset || docElem.scrollLeft;
9269
top: box.top + scrollTop - clientTop,
9270
left: box.left + scrollLeft - clientLeft
9365
if ( arguments.length ) {
9366
return options === undefined ?
9368
this.each(function( i ) {
9369
jQuery.offset.setOffset( this, options, i );
9374
box = { top: 0, left: 0 },
9376
doc = elem && elem.ownerDocument;
9382
docElem = doc.documentElement;
9384
// Make sure it's not a disconnected DOM node
9385
if ( !jQuery.contains( docElem, elem ) ) {
9389
// If we don't have gBCR, just use 0,0 rather than error
9390
// BlackBerry 5, iOS 3 (original iPhone)
9391
if ( typeof elem.getBoundingClientRect !== core_strundefined ) {
9392
box = elem.getBoundingClientRect();
9394
win = getWindow( doc );
9396
top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
9397
left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
9274
9401
jQuery.offset = {
9276
bodyOffset: function( body ) {
9277
var top = body.offsetTop,
9278
left = body.offsetLeft;
9280
if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
9281
top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
9282
left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
9285
return { top: top, left: left };
9288
setOffset: function( elem, options, i ) {
9289
var position = jQuery.css( elem, "position" );
9291
// set position first, in-case top/left are set even on static elem
9292
if ( position === "static" ) {
9293
elem.style.position = "relative";
9296
var curElem = jQuery( elem ),
9297
curOffset = curElem.offset(),
9298
curCSSTop = jQuery.css( elem, "top" ),
9299
curCSSLeft = jQuery.css( elem, "left" ),
9300
calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
9301
props = {}, curPosition = {}, curTop, curLeft;
9303
// need to be able to calculate position if either top or left is auto and position is either absolute or fixed
9304
if ( calculatePosition ) {
9305
curPosition = curElem.position();
9306
curTop = curPosition.top;
9307
curLeft = curPosition.left;
9309
curTop = parseFloat( curCSSTop ) || 0;
9310
curLeft = parseFloat( curCSSLeft ) || 0;
9313
if ( jQuery.isFunction( options ) ) {
9314
options = options.call( elem, i, curOffset );
9317
if ( options.top != null ) {
9318
props.top = ( options.top - curOffset.top ) + curTop;
9320
if ( options.left != null ) {
9321
props.left = ( options.left - curOffset.left ) + curLeft;
9324
if ( "using" in options ) {
9325
options.using.call( elem, props );
9327
curElem.css( props );
9403
setOffset: function( elem, options, i ) {
9404
var position = jQuery.css( elem, "position" );
9406
// set position first, in-case top/left are set even on static elem
9407
if ( position === "static" ) {
9408
elem.style.position = "relative";
9411
var curElem = jQuery( elem ),
9412
curOffset = curElem.offset(),
9413
curCSSTop = jQuery.css( elem, "top" ),
9414
curCSSLeft = jQuery.css( elem, "left" ),
9415
calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
9416
props = {}, curPosition = {}, curTop, curLeft;
9418
// need to be able to calculate position if either top or left is auto and position is either absolute or fixed
9419
if ( calculatePosition ) {
9420
curPosition = curElem.position();
9421
curTop = curPosition.top;
9422
curLeft = curPosition.left;
9424
curTop = parseFloat( curCSSTop ) || 0;
9425
curLeft = parseFloat( curCSSLeft ) || 0;
9428
if ( jQuery.isFunction( options ) ) {
9429
options = options.call( elem, i, curOffset );
9432
if ( options.top != null ) {
9433
props.top = ( options.top - curOffset.top ) + curTop;
9435
if ( options.left != null ) {
9436
props.left = ( options.left - curOffset.left ) + curLeft;
9439
if ( "using" in options ) {
9440
options.using.call( elem, props );
9442
curElem.css( props );
9333
9448
jQuery.fn.extend({
9335
position: function() {
9342
// Get *real* offsetParent
9343
offsetParent = this.offsetParent(),
9345
// Get correct offsets
9346
offset = this.offset(),
9347
parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
9349
// Subtract element margins
9350
// note: when an element has margin: auto the offsetLeft and marginLeft
9351
// are the same in Safari causing offset.left to incorrectly be 0
9352
offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
9353
offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
9355
// Add offsetParent borders
9356
parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
9357
parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
9359
// Subtract the two offsets
9361
top: offset.top - parentOffset.top,
9362
left: offset.left - parentOffset.left
9366
offsetParent: function() {
9367
return this.map(function() {
9368
var offsetParent = this.offsetParent || document.body;
9369
while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
9370
offsetParent = offsetParent.offsetParent;
9372
return offsetParent || document.body;
9450
position: function() {
9455
var offsetParent, offset,
9456
parentOffset = { top: 0, left: 0 },
9459
// fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is it's only offset parent
9460
if ( jQuery.css( elem, "position" ) === "fixed" ) {
9461
// we assume that getBoundingClientRect is available when computed position is fixed
9462
offset = elem.getBoundingClientRect();
9464
// Get *real* offsetParent
9465
offsetParent = this.offsetParent();
9467
// Get correct offsets
9468
offset = this.offset();
9469
if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
9470
parentOffset = offsetParent.offset();
9473
// Add offsetParent borders
9474
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
9475
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
9478
// Subtract parent offsets and element margins
9479
// note: when an element has margin: auto the offsetLeft and marginLeft
9480
// are the same in Safari causing offset.left to incorrectly be 0
9482
top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
9483
left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
9487
offsetParent: function() {
9488
return this.map(function() {
9489
var offsetParent = this.offsetParent || document.documentElement;
9490
while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position") === "static" ) ) {
9491
offsetParent = offsetParent.offsetParent;
9493
return offsetParent || document.documentElement;
9378
9499
// Create scrollLeft and scrollTop methods
9379
9500
jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
9380
var top = /Y/.test( prop );
9382
jQuery.fn[ method ] = function( val ) {
9383
return jQuery.access( this, function( elem, method, val ) {
9384
var win = getWindow( elem );
9386
if ( val === undefined ) {
9387
return win ? (prop in win) ? win[ prop ] :
9388
win.document.documentElement[ method ] :
9394
!top ? val : jQuery( win ).scrollLeft(),
9395
top ? val : jQuery( win ).scrollTop()
9399
elem[ method ] = val;
9401
}, method, val, arguments.length, null );
9501
var top = /Y/.test( prop );
9503
jQuery.fn[ method ] = function( val ) {
9504
return jQuery.access( this, function( elem, method, val ) {
9505
var win = getWindow( elem );
9507
if ( val === undefined ) {
9508
return win ? (prop in win) ? win[ prop ] :
9509
win.document.documentElement[ method ] :
9515
!top ? val : jQuery( win ).scrollLeft(),
9516
top ? val : jQuery( win ).scrollTop()
9520
elem[ method ] = val;
9522
}, method, val, arguments.length, null );
9405
9526
function getWindow( elem ) {
9406
return jQuery.isWindow( elem ) ?
9408
elem.nodeType === 9 ?
9409
elem.defaultView || elem.parentWindow :
9527
return jQuery.isWindow( elem ) ?
9529
elem.nodeType === 9 ?
9530
elem.defaultView || elem.parentWindow :
9412
9533
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
9413
9534
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
9414
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
9415
// margin is only for outerHeight, outerWidth
9416
jQuery.fn[ funcName ] = function( margin, value ) {
9417
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
9418
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
9420
return jQuery.access( this, function( elem, type, value ) {
9423
if ( jQuery.isWindow( elem ) ) {
9424
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
9425
// isn't a whole lot we can do. See pull request at this URL for discussion:
9426
// https://github.com/jquery/jquery/pull/764
9427
return elem.document.documentElement[ "client" + name ];
9430
// Get document width or height
9431
if ( elem.nodeType === 9 ) {
9432
doc = elem.documentElement;
9434
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
9435
// unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
9437
elem.body[ "scroll" + name ], doc[ "scroll" + name ],
9438
elem.body[ "offset" + name ], doc[ "offset" + name ],
9439
doc[ "client" + name ]
9443
return value === undefined ?
9444
// Get width or height on the element, requesting but not forcing parseFloat
9445
jQuery.css( elem, type, value, extra ) :
9447
// Set width or height on the element
9448
jQuery.style( elem, type, value, extra );
9449
}, type, chainable ? margin : undefined, chainable, null );
9535
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
9536
// margin is only for outerHeight, outerWidth
9537
jQuery.fn[ funcName ] = function( margin, value ) {
9538
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
9539
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
9541
return jQuery.access( this, function( elem, type, value ) {
9544
if ( jQuery.isWindow( elem ) ) {
9545
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
9546
// isn't a whole lot we can do. See pull request at this URL for discussion:
9547
// https://github.com/jquery/jquery/pull/764
9548
return elem.document.documentElement[ "client" + name ];
9551
// Get document width or height
9552
if ( elem.nodeType === 9 ) {
9553
doc = elem.documentElement;
9555
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
9556
// unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
9558
elem.body[ "scroll" + name ], doc[ "scroll" + name ],
9559
elem.body[ "offset" + name ], doc[ "offset" + name ],
9560
doc[ "client" + name ]
9564
return value === undefined ?
9565
// Get width or height on the element, requesting but not forcing parseFloat
9566
jQuery.css( elem, type, extra ) :
9568
// Set width or height on the element
9569
jQuery.style( elem, type, value, extra );
9570
}, type, chainable ? margin : undefined, chainable, null );
9574
// Limit scope pollution from any deprecated API
9453
9578
// Expose jQuery to the global object
9454
9579
window.jQuery = window.$ = jQuery;