7
|
1 /*!
|
|
2 * jQuery JavaScript Library v1.10.0
|
|
3 * http://jquery.com/
|
|
4 *
|
|
5 * Includes Sizzle.js
|
|
6 * http://sizzlejs.com/
|
|
7 *
|
|
8 * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors
|
|
9 * Released under the MIT license
|
|
10 * http://jquery.org/license
|
|
11 *
|
|
12 * Date: 2013-05-24T18:39Z
|
|
13 */
|
|
14 (function( window, undefined ) {
|
|
15
|
|
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+
|
|
20 //"use strict";
|
|
21 var
|
|
22 // The deferred used on DOM ready
|
|
23 readyList,
|
|
24
|
|
25 // A central reference to the root jQuery(document)
|
|
26 rootjQuery,
|
|
27
|
|
28 // Support: IE<10
|
|
29 // For `typeof xmlNode.method` instead of `xmlNode.method !== undefined`
|
|
30 core_strundefined = typeof undefined,
|
|
31
|
|
32 // Use the correct document accordingly with window argument (sandbox)
|
|
33 location = window.location,
|
|
34 document = window.document,
|
|
35 docElem = document.documentElement,
|
|
36
|
|
37 // Map over jQuery in case of overwrite
|
|
38 _jQuery = window.jQuery,
|
|
39
|
|
40 // Map over the $ in case of overwrite
|
|
41 _$ = window.$,
|
|
42
|
|
43 // [[Class]] -> type pairs
|
|
44 class2type = {},
|
|
45
|
|
46 // List of deleted data cache ids, so we can reuse them
|
|
47 core_deletedIds = [],
|
|
48
|
|
49 core_version = "1.10.0",
|
|
50
|
|
51 // Save a reference to some core methods
|
|
52 core_concat = core_deletedIds.concat,
|
|
53 core_push = core_deletedIds.push,
|
|
54 core_slice = core_deletedIds.slice,
|
|
55 core_indexOf = core_deletedIds.indexOf,
|
|
56 core_toString = class2type.toString,
|
|
57 core_hasOwn = class2type.hasOwnProperty,
|
|
58 core_trim = core_version.trim,
|
|
59
|
|
60 // Define a local copy of jQuery
|
|
61 jQuery = function( selector, context ) {
|
|
62 // The jQuery object is actually just the init constructor 'enhanced'
|
|
63 return new jQuery.fn.init( selector, context, rootjQuery );
|
|
64 },
|
|
65
|
|
66 // Used for matching numbers
|
|
67 core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,
|
|
68
|
|
69 // Used for splitting on whitespace
|
|
70 core_rnotwhite = /\S+/g,
|
|
71
|
|
72 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
|
|
73 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
|
|
74
|
|
75 // A simple way to check for HTML strings
|
|
76 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
|
|
77 // Strict HTML recognition (#11290: must start with <)
|
|
78 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
|
|
79
|
|
80 // Match a standalone tag
|
|
81 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
|
|
82
|
|
83 // JSON RegExp
|
|
84 rvalidchars = /^[\],:{}\s]*$/,
|
|
85 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
|
|
86 rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
|
|
87 rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,
|
|
88
|
|
89 // Matches dashed string for camelizing
|
|
90 rmsPrefix = /^-ms-/,
|
|
91 rdashAlpha = /-([\da-z])/gi,
|
|
92
|
|
93 // Used by jQuery.camelCase as callback to replace()
|
|
94 fcamelCase = function( all, letter ) {
|
|
95 return letter.toUpperCase();
|
|
96 },
|
|
97
|
|
98 // The ready event handler
|
|
99 completed = function( event ) {
|
|
100
|
|
101 // readyState === "complete" is good enough for us to call the dom ready in oldIE
|
|
102 if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
|
|
103 detach();
|
|
104 jQuery.ready();
|
|
105 }
|
|
106 },
|
|
107 // Clean-up method for dom ready events
|
|
108 detach = function() {
|
|
109 if ( document.addEventListener ) {
|
|
110 document.removeEventListener( "DOMContentLoaded", completed, false );
|
|
111 window.removeEventListener( "load", completed, false );
|
|
112
|
|
113 } else {
|
|
114 document.detachEvent( "onreadystatechange", completed );
|
|
115 window.detachEvent( "onload", completed );
|
|
116 }
|
|
117 };
|
|
118
|
|
119 jQuery.fn = jQuery.prototype = {
|
|
120 // The current version of jQuery being used
|
|
121 jquery: core_version,
|
|
122
|
|
123 constructor: jQuery,
|
|
124 init: function( selector, context, rootjQuery ) {
|
|
125 var match, elem;
|
|
126
|
|
127 // HANDLE: $(""), $(null), $(undefined), $(false)
|
|
128 if ( !selector ) {
|
|
129 return this;
|
|
130 }
|
|
131
|
|
132 // Handle HTML strings
|
|
133 if ( typeof selector === "string" ) {
|
|
134 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
|
|
135 // Assume that strings that start and end with <> are HTML and skip the regex check
|
|
136 match = [ null, selector, null ];
|
|
137
|
|
138 } else {
|
|
139 match = rquickExpr.exec( selector );
|
|
140 }
|
|
141
|
|
142 // Match html or make sure no context is specified for #id
|
|
143 if ( match && (match[1] || !context) ) {
|
|
144
|
|
145 // HANDLE: $(html) -> $(array)
|
|
146 if ( match[1] ) {
|
|
147 context = context instanceof jQuery ? context[0] : context;
|
|
148
|
|
149 // scripts is true for back-compat
|
|
150 jQuery.merge( this, jQuery.parseHTML(
|
|
151 match[1],
|
|
152 context && context.nodeType ? context.ownerDocument || context : document,
|
|
153 true
|
|
154 ) );
|
|
155
|
|
156 // HANDLE: $(html, props)
|
|
157 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
|
|
158 for ( match in context ) {
|
|
159 // Properties of context are called as methods if possible
|
|
160 if ( jQuery.isFunction( this[ match ] ) ) {
|
|
161 this[ match ]( context[ match ] );
|
|
162
|
|
163 // ...and otherwise set as attributes
|
|
164 } else {
|
|
165 this.attr( match, context[ match ] );
|
|
166 }
|
|
167 }
|
|
168 }
|
|
169
|
|
170 return this;
|
|
171
|
|
172 // HANDLE: $(#id)
|
|
173 } else {
|
|
174 elem = document.getElementById( match[2] );
|
|
175
|
|
176 // Check parentNode to catch when Blackberry 4.6 returns
|
|
177 // nodes that are no longer in the document #6963
|
|
178 if ( elem && elem.parentNode ) {
|
|
179 // Handle the case where IE and Opera return items
|
|
180 // by name instead of ID
|
|
181 if ( elem.id !== match[2] ) {
|
|
182 return rootjQuery.find( selector );
|
|
183 }
|
|
184
|
|
185 // Otherwise, we inject the element directly into the jQuery object
|
|
186 this.length = 1;
|
|
187 this[0] = elem;
|
|
188 }
|
|
189
|
|
190 this.context = document;
|
|
191 this.selector = selector;
|
|
192 return this;
|
|
193 }
|
|
194
|
|
195 // HANDLE: $(expr, $(...))
|
|
196 } else if ( !context || context.jquery ) {
|
|
197 return ( context || rootjQuery ).find( selector );
|
|
198
|
|
199 // HANDLE: $(expr, context)
|
|
200 // (which is just equivalent to: $(context).find(expr)
|
|
201 } else {
|
|
202 return this.constructor( context ).find( selector );
|
|
203 }
|
|
204
|
|
205 // HANDLE: $(DOMElement)
|
|
206 } else if ( selector.nodeType ) {
|
|
207 this.context = this[0] = selector;
|
|
208 this.length = 1;
|
|
209 return this;
|
|
210
|
|
211 // HANDLE: $(function)
|
|
212 // Shortcut for document ready
|
|
213 } else if ( jQuery.isFunction( selector ) ) {
|
|
214 return rootjQuery.ready( selector );
|
|
215 }
|
|
216
|
|
217 if ( selector.selector !== undefined ) {
|
|
218 this.selector = selector.selector;
|
|
219 this.context = selector.context;
|
|
220 }
|
|
221
|
|
222 return jQuery.makeArray( selector, this );
|
|
223 },
|
|
224
|
|
225 // Start with an empty selector
|
|
226 selector: "",
|
|
227
|
|
228 // The default length of a jQuery object is 0
|
|
229 length: 0,
|
|
230
|
|
231 toArray: function() {
|
|
232 return core_slice.call( this );
|
|
233 },
|
|
234
|
|
235 // Get the Nth element in the matched element set OR
|
|
236 // Get the whole matched element set as a clean array
|
|
237 get: function( num ) {
|
|
238 return num == null ?
|
|
239
|
|
240 // Return a 'clean' array
|
|
241 this.toArray() :
|
|
242
|
|
243 // Return just the object
|
|
244 ( num < 0 ? this[ this.length + num ] : this[ num ] );
|
|
245 },
|
|
246
|
|
247 // Take an array of elements and push it onto the stack
|
|
248 // (returning the new matched element set)
|
|
249 pushStack: function( elems ) {
|
|
250
|
|
251 // Build a new jQuery matched element set
|
|
252 var ret = jQuery.merge( this.constructor(), elems );
|
|
253
|
|
254 // Add the old object onto the stack (as a reference)
|
|
255 ret.prevObject = this;
|
|
256 ret.context = this.context;
|
|
257
|
|
258 // Return the newly-formed element set
|
|
259 return ret;
|
|
260 },
|
|
261
|
|
262 // Execute a callback for every element in the matched set.
|
|
263 // (You can seed the arguments with an array of args, but this is
|
|
264 // only used internally.)
|
|
265 each: function( callback, args ) {
|
|
266 return jQuery.each( this, callback, args );
|
|
267 },
|
|
268
|
|
269 ready: function( fn ) {
|
|
270 // Add the callback
|
|
271 jQuery.ready.promise().done( fn );
|
|
272
|
|
273 return this;
|
|
274 },
|
|
275
|
|
276 slice: function() {
|
|
277 return this.pushStack( core_slice.apply( this, arguments ) );
|
|
278 },
|
|
279
|
|
280 first: function() {
|
|
281 return this.eq( 0 );
|
|
282 },
|
|
283
|
|
284 last: function() {
|
|
285 return this.eq( -1 );
|
|
286 },
|
|
287
|
|
288 eq: function( i ) {
|
|
289 var len = this.length,
|
|
290 j = +i + ( i < 0 ? len : 0 );
|
|
291 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
|
|
292 },
|
|
293
|
|
294 map: function( callback ) {
|
|
295 return this.pushStack( jQuery.map(this, function( elem, i ) {
|
|
296 return callback.call( elem, i, elem );
|
|
297 }));
|
|
298 },
|
|
299
|
|
300 end: function() {
|
|
301 return this.prevObject || this.constructor(null);
|
|
302 },
|
|
303
|
|
304 // For internal use only.
|
|
305 // Behaves like an Array's method, not like a jQuery method.
|
|
306 push: core_push,
|
|
307 sort: [].sort,
|
|
308 splice: [].splice
|
|
309 };
|
|
310
|
|
311 // Give the init function the jQuery prototype for later instantiation
|
|
312 jQuery.fn.init.prototype = jQuery.fn;
|
|
313
|
|
314 jQuery.extend = jQuery.fn.extend = function() {
|
|
315 var src, copyIsArray, copy, name, options, clone,
|
|
316 target = arguments[0] || {},
|
|
317 i = 1,
|
|
318 length = arguments.length,
|
|
319 deep = false;
|
|
320
|
|
321 // Handle a deep copy situation
|
|
322 if ( typeof target === "boolean" ) {
|
|
323 deep = target;
|
|
324 target = arguments[1] || {};
|
|
325 // skip the boolean and the target
|
|
326 i = 2;
|
|
327 }
|
|
328
|
|
329 // Handle case when target is a string or something (possible in deep copy)
|
|
330 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
|
|
331 target = {};
|
|
332 }
|
|
333
|
|
334 // extend jQuery itself if only one argument is passed
|
|
335 if ( length === i ) {
|
|
336 target = this;
|
|
337 --i;
|
|
338 }
|
|
339
|
|
340 for ( ; i < length; i++ ) {
|
|
341 // Only deal with non-null/undefined values
|
|
342 if ( (options = arguments[ i ]) != null ) {
|
|
343 // Extend the base object
|
|
344 for ( name in options ) {
|
|
345 src = target[ name ];
|
|
346 copy = options[ name ];
|
|
347
|
|
348 // Prevent never-ending loop
|
|
349 if ( target === copy ) {
|
|
350 continue;
|
|
351 }
|
|
352
|
|
353 // Recurse if we're merging plain objects or arrays
|
|
354 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
|
|
355 if ( copyIsArray ) {
|
|
356 copyIsArray = false;
|
|
357 clone = src && jQuery.isArray(src) ? src : [];
|
|
358
|
|
359 } else {
|
|
360 clone = src && jQuery.isPlainObject(src) ? src : {};
|
|
361 }
|
|
362
|
|
363 // Never move original objects, clone them
|
|
364 target[ name ] = jQuery.extend( deep, clone, copy );
|
|
365
|
|
366 // Don't bring in undefined values
|
|
367 } else if ( copy !== undefined ) {
|
|
368 target[ name ] = copy;
|
|
369 }
|
|
370 }
|
|
371 }
|
|
372 }
|
|
373
|
|
374 // Return the modified object
|
|
375 return target;
|
|
376 };
|
|
377
|
|
378 jQuery.extend({
|
|
379 // Unique for each copy of jQuery on the page
|
|
380 // Non-digits removed to match rinlinejQuery
|
|
381 expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ),
|
|
382
|
|
383 noConflict: function( deep ) {
|
|
384 if ( window.$ === jQuery ) {
|
|
385 window.$ = _$;
|
|
386 }
|
|
387
|
|
388 if ( deep && window.jQuery === jQuery ) {
|
|
389 window.jQuery = _jQuery;
|
|
390 }
|
|
391
|
|
392 return jQuery;
|
|
393 },
|
|
394
|
|
395 // Is the DOM ready to be used? Set to true once it occurs.
|
|
396 isReady: false,
|
|
397
|
|
398 // A counter to track how many items to wait for before
|
|
399 // the ready event fires. See #6781
|
|
400 readyWait: 1,
|
|
401
|
|
402 // Hold (or release) the ready event
|
|
403 holdReady: function( hold ) {
|
|
404 if ( hold ) {
|
|
405 jQuery.readyWait++;
|
|
406 } else {
|
|
407 jQuery.ready( true );
|
|
408 }
|
|
409 },
|
|
410
|
|
411 // Handle when the DOM is ready
|
|
412 ready: function( wait ) {
|
|
413
|
|
414 // Abort if there are pending holds or we're already ready
|
|
415 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
|
|
416 return;
|
|
417 }
|
|
418
|
|
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 );
|
|
422 }
|
|
423
|
|
424 // Remember that the DOM is ready
|
|
425 jQuery.isReady = true;
|
|
426
|
|
427 // If a normal DOM Ready event fired, decrement, and wait if need be
|
|
428 if ( wait !== true && --jQuery.readyWait > 0 ) {
|
|
429 return;
|
|
430 }
|
|
431
|
|
432 // If there are functions bound, to execute
|
|
433 readyList.resolveWith( document, [ jQuery ] );
|
|
434
|
|
435 // Trigger any bound ready events
|
|
436 if ( jQuery.fn.trigger ) {
|
|
437 jQuery( document ).trigger("ready").off("ready");
|
|
438 }
|
|
439 },
|
|
440
|
|
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";
|
|
446 },
|
|
447
|
|
448 isArray: Array.isArray || function( obj ) {
|
|
449 return jQuery.type(obj) === "array";
|
|
450 },
|
|
451
|
|
452 isWindow: function( obj ) {
|
|
453 /* jshint eqeqeq: false */
|
|
454 return obj != null && obj == obj.window;
|
|
455 },
|
|
456
|
|
457 isNumeric: function( obj ) {
|
|
458 return !isNaN( parseFloat(obj) ) && isFinite( obj );
|
|
459 },
|
|
460
|
|
461 type: function( obj ) {
|
|
462 if ( obj == null ) {
|
|
463 return String( obj );
|
|
464 }
|
|
465 return typeof obj === "object" || typeof obj === "function" ?
|
|
466 class2type[ core_toString.call(obj) ] || "object" :
|
|
467 typeof obj;
|
|
468 },
|
|
469
|
|
470 isPlainObject: function( obj ) {
|
|
471 var key;
|
|
472
|
|
473 // Must be an Object.
|
|
474 // Because of IE, we also have to check the presence of the constructor property.
|
|
475 // Make sure that DOM nodes and window objects don't pass through, as well
|
|
476 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
|
|
477 return false;
|
|
478 }
|
|
479
|
|
480 try {
|
|
481 // Not own constructor property must be Object
|
|
482 if ( obj.constructor &&
|
|
483 !core_hasOwn.call(obj, "constructor") &&
|
|
484 !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
|
|
485 return false;
|
|
486 }
|
|
487 } catch ( e ) {
|
|
488 // IE8,9 Will throw exceptions on certain host objects #9897
|
|
489 return false;
|
|
490 }
|
|
491
|
|
492 // Support: IE<9
|
|
493 // Handle iteration over inherited properties before own properties.
|
|
494 if ( jQuery.support.ownLast ) {
|
|
495 for ( key in obj ) {
|
|
496 return core_hasOwn.call( obj, key );
|
|
497 }
|
|
498 }
|
|
499
|
|
500 // Own properties are enumerated firstly, so to speed up,
|
|
501 // if last one is own, then all properties are own.
|
|
502 for ( key in obj ) {}
|
|
503
|
|
504 return key === undefined || core_hasOwn.call( obj, key );
|
|
505 },
|
|
506
|
|
507 isEmptyObject: function( obj ) {
|
|
508 var name;
|
|
509 for ( name in obj ) {
|
|
510 return false;
|
|
511 }
|
|
512 return true;
|
|
513 },
|
|
514
|
|
515 error: function( msg ) {
|
|
516 throw new Error( msg );
|
|
517 },
|
|
518
|
|
519 // data: string of html
|
|
520 // context (optional): If specified, the fragment will be created in this context, defaults to document
|
|
521 // keepScripts (optional): If true, will include scripts passed in the html string
|
|
522 parseHTML: function( data, context, keepScripts ) {
|
|
523 if ( !data || typeof data !== "string" ) {
|
|
524 return null;
|
|
525 }
|
|
526 if ( typeof context === "boolean" ) {
|
|
527 keepScripts = context;
|
|
528 context = false;
|
|
529 }
|
|
530 context = context || document;
|
|
531
|
|
532 var parsed = rsingleTag.exec( data ),
|
|
533 scripts = !keepScripts && [];
|
|
534
|
|
535 // Single tag
|
|
536 if ( parsed ) {
|
|
537 return [ context.createElement( parsed[1] ) ];
|
|
538 }
|
|
539
|
|
540 parsed = jQuery.buildFragment( [ data ], context, scripts );
|
|
541 if ( scripts ) {
|
|
542 jQuery( scripts ).remove();
|
|
543 }
|
|
544 return jQuery.merge( [], parsed.childNodes );
|
|
545 },
|
|
546
|
|
547 parseJSON: function( data ) {
|
|
548 // Attempt to parse using the native JSON parser first
|
|
549 if ( window.JSON && window.JSON.parse ) {
|
|
550 return window.JSON.parse( data );
|
|
551 }
|
|
552
|
|
553 if ( data === null ) {
|
|
554 return data;
|
|
555 }
|
|
556
|
|
557 if ( typeof data === "string" ) {
|
|
558
|
|
559 // Make sure leading/trailing whitespace is removed (IE can't handle it)
|
|
560 data = jQuery.trim( data );
|
|
561
|
|
562 if ( data ) {
|
|
563 // Make sure the incoming data is actual JSON
|
|
564 // Logic borrowed from http://json.org/json2.js
|
|
565 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
|
|
566 .replace( rvalidtokens, "]" )
|
|
567 .replace( rvalidbraces, "")) ) {
|
|
568
|
|
569 return ( new Function( "return " + data ) )();
|
|
570 }
|
|
571 }
|
|
572 }
|
|
573
|
|
574 jQuery.error( "Invalid JSON: " + data );
|
|
575 },
|
|
576
|
|
577 // Cross-browser xml parsing
|
|
578 parseXML: function( data ) {
|
|
579 var xml, tmp;
|
|
580 if ( !data || typeof data !== "string" ) {
|
|
581 return null;
|
|
582 }
|
|
583 try {
|
|
584 if ( window.DOMParser ) { // Standard
|
|
585 tmp = new DOMParser();
|
|
586 xml = tmp.parseFromString( data , "text/xml" );
|
|
587 } else { // IE
|
|
588 xml = new ActiveXObject( "Microsoft.XMLDOM" );
|
|
589 xml.async = "false";
|
|
590 xml.loadXML( data );
|
|
591 }
|
|
592 } catch( e ) {
|
|
593 xml = undefined;
|
|
594 }
|
|
595 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
|
|
596 jQuery.error( "Invalid XML: " + data );
|
|
597 }
|
|
598 return xml;
|
|
599 },
|
|
600
|
|
601 noop: function() {},
|
|
602
|
|
603 // Evaluates a script in a global context
|
|
604 // Workarounds based on findings by Jim Driscoll
|
|
605 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
|
|
606 globalEval: function( data ) {
|
|
607 if ( data && jQuery.trim( data ) ) {
|
|
608 // We use execScript on Internet Explorer
|
|
609 // We use an anonymous function so that context is window
|
|
610 // rather than jQuery in Firefox
|
|
611 ( window.execScript || function( data ) {
|
|
612 window[ "eval" ].call( window, data );
|
|
613 } )( data );
|
|
614 }
|
|
615 },
|
|
616
|
|
617 // Convert dashed to camelCase; used by the css and data modules
|
|
618 // Microsoft forgot to hump their vendor prefix (#9572)
|
|
619 camelCase: function( string ) {
|
|
620 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
|
|
621 },
|
|
622
|
|
623 nodeName: function( elem, name ) {
|
|
624 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
|
|
625 },
|
|
626
|
|
627 // args is for internal usage only
|
|
628 each: function( obj, callback, args ) {
|
|
629 var value,
|
|
630 i = 0,
|
|
631 length = obj.length,
|
|
632 isArray = isArraylike( obj );
|
|
633
|
|
634 if ( args ) {
|
|
635 if ( isArray ) {
|
|
636 for ( ; i < length; i++ ) {
|
|
637 value = callback.apply( obj[ i ], args );
|
|
638
|
|
639 if ( value === false ) {
|
|
640 break;
|
|
641 }
|
|
642 }
|
|
643 } else {
|
|
644 for ( i in obj ) {
|
|
645 value = callback.apply( obj[ i ], args );
|
|
646
|
|
647 if ( value === false ) {
|
|
648 break;
|
|
649 }
|
|
650 }
|
|
651 }
|
|
652
|
|
653 // A special, fast, case for the most common use of each
|
|
654 } else {
|
|
655 if ( isArray ) {
|
|
656 for ( ; i < length; i++ ) {
|
|
657 value = callback.call( obj[ i ], i, obj[ i ] );
|
|
658
|
|
659 if ( value === false ) {
|
|
660 break;
|
|
661 }
|
|
662 }
|
|
663 } else {
|
|
664 for ( i in obj ) {
|
|
665 value = callback.call( obj[ i ], i, obj[ i ] );
|
|
666
|
|
667 if ( value === false ) {
|
|
668 break;
|
|
669 }
|
|
670 }
|
|
671 }
|
|
672 }
|
|
673
|
|
674 return obj;
|
|
675 },
|
|
676
|
|
677 // Use native String.trim function wherever possible
|
|
678 trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
|
|
679 function( text ) {
|
|
680 return text == null ?
|
|
681 "" :
|
|
682 core_trim.call( text );
|
|
683 } :
|
|
684
|
|
685 // Otherwise use our own trimming functionality
|
|
686 function( text ) {
|
|
687 return text == null ?
|
|
688 "" :
|
|
689 ( text + "" ).replace( rtrim, "" );
|
|
690 },
|
|
691
|
|
692 // results is for internal usage only
|
|
693 makeArray: function( arr, results ) {
|
|
694 var ret = results || [];
|
|
695
|
|
696 if ( arr != null ) {
|
|
697 if ( isArraylike( Object(arr) ) ) {
|
|
698 jQuery.merge( ret,
|
|
699 typeof arr === "string" ?
|
|
700 [ arr ] : arr
|
|
701 );
|
|
702 } else {
|
|
703 core_push.call( ret, arr );
|
|
704 }
|
|
705 }
|
|
706
|
|
707 return ret;
|
|
708 },
|
|
709
|
|
710 inArray: function( elem, arr, i ) {
|
|
711 var len;
|
|
712
|
|
713 if ( arr ) {
|
|
714 if ( core_indexOf ) {
|
|
715 return core_indexOf.call( arr, elem, i );
|
|
716 }
|
|
717
|
|
718 len = arr.length;
|
|
719 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
|
|
720
|
|
721 for ( ; i < len; i++ ) {
|
|
722 // Skip accessing in sparse arrays
|
|
723 if ( i in arr && arr[ i ] === elem ) {
|
|
724 return i;
|
|
725 }
|
|
726 }
|
|
727 }
|
|
728
|
|
729 return -1;
|
|
730 },
|
|
731
|
|
732 merge: function( first, second ) {
|
|
733 var l = second.length,
|
|
734 i = first.length,
|
|
735 j = 0;
|
|
736
|
|
737 if ( typeof l === "number" ) {
|
|
738 for ( ; j < l; j++ ) {
|
|
739 first[ i++ ] = second[ j ];
|
|
740 }
|
|
741 } else {
|
|
742 while ( second[j] !== undefined ) {
|
|
743 first[ i++ ] = second[ j++ ];
|
|
744 }
|
|
745 }
|
|
746
|
|
747 first.length = i;
|
|
748
|
|
749 return first;
|
|
750 },
|
|
751
|
|
752 grep: function( elems, callback, inv ) {
|
|
753 var retVal,
|
|
754 ret = [],
|
|
755 i = 0,
|
|
756 length = elems.length;
|
|
757 inv = !!inv;
|
|
758
|
|
759 // Go through the array, only saving the items
|
|
760 // that pass the validator function
|
|
761 for ( ; i < length; i++ ) {
|
|
762 retVal = !!callback( elems[ i ], i );
|
|
763 if ( inv !== retVal ) {
|
|
764 ret.push( elems[ i ] );
|
|
765 }
|
|
766 }
|
|
767
|
|
768 return ret;
|
|
769 },
|
|
770
|
|
771 // arg is for internal usage only
|
|
772 map: function( elems, callback, arg ) {
|
|
773 var value,
|
|
774 i = 0,
|
|
775 length = elems.length,
|
|
776 isArray = isArraylike( elems ),
|
|
777 ret = [];
|
|
778
|
|
779 // Go through the array, translating each of the items to their
|
|
780 if ( isArray ) {
|
|
781 for ( ; i < length; i++ ) {
|
|
782 value = callback( elems[ i ], i, arg );
|
|
783
|
|
784 if ( value != null ) {
|
|
785 ret[ ret.length ] = value;
|
|
786 }
|
|
787 }
|
|
788
|
|
789 // Go through every key on the object,
|
|
790 } else {
|
|
791 for ( i in elems ) {
|
|
792 value = callback( elems[ i ], i, arg );
|
|
793
|
|
794 if ( value != null ) {
|
|
795 ret[ ret.length ] = value;
|
|
796 }
|
|
797 }
|
|
798 }
|
|
799
|
|
800 // Flatten any nested arrays
|
|
801 return core_concat.apply( [], ret );
|
|
802 },
|
|
803
|
|
804 // A global GUID counter for objects
|
|
805 guid: 1,
|
|
806
|
|
807 // Bind a function to a context, optionally partially applying any
|
|
808 // arguments.
|
|
809 proxy: function( fn, context ) {
|
|
810 var args, proxy, tmp;
|
|
811
|
|
812 if ( typeof context === "string" ) {
|
|
813 tmp = fn[ context ];
|
|
814 context = fn;
|
|
815 fn = tmp;
|
|
816 }
|
|
817
|
|
818 // Quick check to determine if target is callable, in the spec
|
|
819 // this throws a TypeError, but we will just return undefined.
|
|
820 if ( !jQuery.isFunction( fn ) ) {
|
|
821 return undefined;
|
|
822 }
|
|
823
|
|
824 // Simulated bind
|
|
825 args = core_slice.call( arguments, 2 );
|
|
826 proxy = function() {
|
|
827 return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) );
|
|
828 };
|
|
829
|
|
830 // Set the guid of unique handler to the same of original handler, so it can be removed
|
|
831 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
|
|
832
|
|
833 return proxy;
|
|
834 },
|
|
835
|
|
836 // Multifunctional method to get and set values of a collection
|
|
837 // The value/s can optionally be executed if it's a function
|
|
838 access: function( elems, fn, key, value, chainable, emptyGet, raw ) {
|
|
839 var i = 0,
|
|
840 length = elems.length,
|
|
841 bulk = key == null;
|
|
842
|
|
843 // Sets many values
|
|
844 if ( jQuery.type( key ) === "object" ) {
|
|
845 chainable = true;
|
|
846 for ( i in key ) {
|
|
847 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
|
|
848 }
|
|
849
|
|
850 // Sets one value
|
|
851 } else if ( value !== undefined ) {
|
|
852 chainable = true;
|
|
853
|
|
854 if ( !jQuery.isFunction( value ) ) {
|
|
855 raw = true;
|
|
856 }
|
|
857
|
|
858 if ( bulk ) {
|
|
859 // Bulk operations run against the entire set
|
|
860 if ( raw ) {
|
|
861 fn.call( elems, value );
|
|
862 fn = null;
|
|
863
|
|
864 // ...except when executing function values
|
|
865 } else {
|
|
866 bulk = fn;
|
|
867 fn = function( elem, key, value ) {
|
|
868 return bulk.call( jQuery( elem ), value );
|
|
869 };
|
|
870 }
|
|
871 }
|
|
872
|
|
873 if ( fn ) {
|
|
874 for ( ; i < length; i++ ) {
|
|
875 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
|
|
876 }
|
|
877 }
|
|
878 }
|
|
879
|
|
880 return chainable ?
|
|
881 elems :
|
|
882
|
|
883 // Gets
|
|
884 bulk ?
|
|
885 fn.call( elems ) :
|
|
886 length ? fn( elems[0], key ) : emptyGet;
|
|
887 },
|
|
888
|
|
889 now: function() {
|
|
890 return ( new Date() ).getTime();
|
|
891 },
|
|
892
|
|
893 // A method for quickly swapping in/out CSS properties to get correct calculations.
|
|
894 // Note: this method belongs to the css module but it's needed here for the support module.
|
|
895 // If support gets modularized, this method should be moved back to the css module.
|
|
896 swap: function( elem, options, callback, args ) {
|
|
897 var ret, name,
|
|
898 old = {};
|
|
899
|
|
900 // Remember the old values, and insert the new ones
|
|
901 for ( name in options ) {
|
|
902 old[ name ] = elem.style[ name ];
|
|
903 elem.style[ name ] = options[ name ];
|
|
904 }
|
|
905
|
|
906 ret = callback.apply( elem, args || [] );
|
|
907
|
|
908 // Revert the old values
|
|
909 for ( name in options ) {
|
|
910 elem.style[ name ] = old[ name ];
|
|
911 }
|
|
912
|
|
913 return ret;
|
|
914 }
|
|
915 });
|
|
916
|
|
917 jQuery.ready.promise = function( obj ) {
|
|
918 if ( !readyList ) {
|
|
919
|
|
920 readyList = jQuery.Deferred();
|
|
921
|
|
922 // Catch cases where $(document).ready() is called after the browser event has already occurred.
|
|
923 // we once tried to use readyState "interactive" here, but it caused issues like the one
|
|
924 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
|
|
925 if ( document.readyState === "complete" ) {
|
|
926 // Handle it asynchronously to allow scripts the opportunity to delay ready
|
|
927 setTimeout( jQuery.ready );
|
|
928
|
|
929 // Standards-based browsers support DOMContentLoaded
|
|
930 } else if ( document.addEventListener ) {
|
|
931 // Use the handy event callback
|
|
932 document.addEventListener( "DOMContentLoaded", completed, false );
|
|
933
|
|
934 // A fallback to window.onload, that will always work
|
|
935 window.addEventListener( "load", completed, false );
|
|
936
|
|
937 // If IE event model is used
|
|
938 } else {
|
|
939 // Ensure firing before onload, maybe late but safe also for iframes
|
|
940 document.attachEvent( "onreadystatechange", completed );
|
|
941
|
|
942 // A fallback to window.onload, that will always work
|
|
943 window.attachEvent( "onload", completed );
|
|
944
|
|
945 // If IE and not a frame
|
|
946 // continually check to see if the document is ready
|
|
947 var top = false;
|
|
948
|
|
949 try {
|
|
950 top = window.frameElement == null && document.documentElement;
|
|
951 } catch(e) {}
|
|
952
|
|
953 if ( top && top.doScroll ) {
|
|
954 (function doScrollCheck() {
|
|
955 if ( !jQuery.isReady ) {
|
|
956
|
|
957 try {
|
|
958 // Use the trick by Diego Perini
|
|
959 // http://javascript.nwbox.com/IEContentLoaded/
|
|
960 top.doScroll("left");
|
|
961 } catch(e) {
|
|
962 return setTimeout( doScrollCheck, 50 );
|
|
963 }
|
|
964
|
|
965 // detach all dom ready events
|
|
966 detach();
|
|
967
|
|
968 // and execute any waiting functions
|
|
969 jQuery.ready();
|
|
970 }
|
|
971 })();
|
|
972 }
|
|
973 }
|
|
974 }
|
|
975 return readyList.promise( obj );
|
|
976 };
|
|
977
|
|
978 // Populate the class2type map
|
|
979 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
|
|
980 class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
|
981 });
|
|
982
|
|
983 function isArraylike( obj ) {
|
|
984 var length = obj.length,
|
|
985 type = jQuery.type( obj );
|
|
986
|
|
987 if ( jQuery.isWindow( obj ) ) {
|
|
988 return false;
|
|
989 }
|
|
990
|
|
991 if ( obj.nodeType === 1 && length ) {
|
|
992 return true;
|
|
993 }
|
|
994
|
|
995 return type === "array" || type !== "function" &&
|
|
996 ( length === 0 ||
|
|
997 typeof length === "number" && length > 0 && ( length - 1 ) in obj );
|
|
998 }
|
|
999
|
|
1000 // All jQuery objects should point back to these
|
|
1001 rootjQuery = jQuery(document);
|
|
1002 /*!
|
|
1003 * Sizzle CSS Selector Engine v1.9.4-pre
|
|
1004 * http://sizzlejs.com/
|
|
1005 *
|
|
1006 * Copyright 2013 jQuery Foundation, Inc. and other contributors
|
|
1007 * Released under the MIT license
|
|
1008 * http://jquery.org/license
|
|
1009 *
|
|
1010 * Date: 2013-05-15
|
|
1011 */
|
|
1012 (function( window, undefined ) {
|
|
1013
|
|
1014 var i,
|
|
1015 support,
|
|
1016 cachedruns,
|
|
1017 Expr,
|
|
1018 getText,
|
|
1019 isXML,
|
|
1020 compile,
|
|
1021 outermostContext,
|
|
1022 sortInput,
|
|
1023
|
|
1024 // Local document vars
|
|
1025 setDocument,
|
|
1026 document,
|
|
1027 docElem,
|
|
1028 documentIsHTML,
|
|
1029 rbuggyQSA,
|
|
1030 rbuggyMatches,
|
|
1031 matches,
|
|
1032 contains,
|
|
1033
|
|
1034 // Instance-specific data
|
|
1035 expando = "sizzle" + -(new Date()),
|
|
1036 preferredDoc = window.document,
|
|
1037 dirruns = 0,
|
|
1038 done = 0,
|
|
1039 classCache = createCache(),
|
|
1040 tokenCache = createCache(),
|
|
1041 compilerCache = createCache(),
|
|
1042 hasDuplicate = false,
|
|
1043 sortOrder = function() { return 0; },
|
|
1044
|
|
1045 // General-purpose constants
|
|
1046 strundefined = typeof undefined,
|
|
1047 MAX_NEGATIVE = 1 << 31,
|
|
1048
|
|
1049 // Instance methods
|
|
1050 hasOwn = ({}).hasOwnProperty,
|
|
1051 arr = [],
|
|
1052 pop = arr.pop,
|
|
1053 push_native = arr.push,
|
|
1054 push = arr.push,
|
|
1055 slice = arr.slice,
|
|
1056 // Use a stripped-down indexOf if we can't use a native one
|
|
1057 indexOf = arr.indexOf || function( elem ) {
|
|
1058 var i = 0,
|
|
1059 len = this.length;
|
|
1060 for ( ; i < len; i++ ) {
|
|
1061 if ( this[i] === elem ) {
|
|
1062 return i;
|
|
1063 }
|
|
1064 }
|
|
1065 return -1;
|
|
1066 },
|
|
1067
|
|
1068 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
|
|
1069
|
|
1070 // Regular expressions
|
|
1071
|
|
1072 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
|
|
1073 whitespace = "[\\x20\\t\\r\\n\\f]",
|
|
1074 // http://www.w3.org/TR/css3-syntax/#characters
|
|
1075 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
|
|
1076
|
|
1077 // Loosely modeled on CSS identifier characters
|
|
1078 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
|
|
1079 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
|
|
1080 identifier = characterEncoding.replace( "w", "w#" ),
|
|
1081
|
|
1082 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
|
|
1083 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
|
|
1084 "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
|
|
1085
|
|
1086 // Prefer arguments quoted,
|
|
1087 // then not containing pseudos/brackets,
|
|
1088 // then attribute selectors/non-parenthetical expressions,
|
|
1089 // then anything else
|
|
1090 // These preferences are here to reduce the number of selectors
|
|
1091 // needing tokenize in the PSEUDO preFilter
|
|
1092 pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
|
|
1093
|
|
1094 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
|
|
1095 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
|
|
1096
|
|
1097 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
|
|
1098 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
|
|
1099
|
|
1100 rsibling = new RegExp( whitespace + "*[+~]" ),
|
|
1101 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*)" + whitespace + "*\\]", "g" ),
|
|
1102
|
|
1103 rpseudo = new RegExp( pseudos ),
|
|
1104 ridentifier = new RegExp( "^" + identifier + "$" ),
|
|
1105
|
|
1106 matchExpr = {
|
|
1107 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
|
|
1108 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
|
|
1109 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
|
|
1110 "ATTR": new RegExp( "^" + attributes ),
|
|
1111 "PSEUDO": new RegExp( "^" + pseudos ),
|
|
1112 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
|
|
1113 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
|
|
1114 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
|
|
1115 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
|
|
1116 // For use in libraries implementing .is()
|
|
1117 // We use this for POS matching in `select`
|
|
1118 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
|
|
1119 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
|
|
1120 },
|
|
1121
|
|
1122 rnative = /^[^{]+\{\s*\[native \w/,
|
|
1123
|
|
1124 // Easily-parseable/retrievable ID or TAG or CLASS selectors
|
|
1125 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
|
|
1126
|
|
1127 rinputs = /^(?:input|select|textarea|button)$/i,
|
|
1128 rheader = /^h\d$/i,
|
|
1129
|
|
1130 rescape = /'|\\/g,
|
|
1131
|
|
1132 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
|
|
1133 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
|
|
1134 funescape = function( _, escaped, escapedWhitespace ) {
|
|
1135 var high = "0x" + escaped - 0x10000;
|
|
1136 // NaN means non-codepoint
|
|
1137 // Support: Firefox
|
|
1138 // Workaround erroneous numeric interpretation of +"0x"
|
|
1139 return high !== high || escapedWhitespace ?
|
|
1140 escaped :
|
|
1141 // BMP codepoint
|
|
1142 high < 0 ?
|
|
1143 String.fromCharCode( high + 0x10000 ) :
|
|
1144 // Supplemental Plane codepoint (surrogate pair)
|
|
1145 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
|
|
1146 };
|
|
1147
|
|
1148 // Optimize for push.apply( _, NodeList )
|
|
1149 try {
|
|
1150 push.apply(
|
|
1151 (arr = slice.call( preferredDoc.childNodes )),
|
|
1152 preferredDoc.childNodes
|
|
1153 );
|
|
1154 // Support: Android<4.0
|
|
1155 // Detect silently failing push.apply
|
|
1156 arr[ preferredDoc.childNodes.length ].nodeType;
|
|
1157 } catch ( e ) {
|
|
1158 push = { apply: arr.length ?
|
|
1159
|
|
1160 // Leverage slice if possible
|
|
1161 function( target, els ) {
|
|
1162 push_native.apply( target, slice.call(els) );
|
|
1163 } :
|
|
1164
|
|
1165 // Support: IE<9
|
|
1166 // Otherwise append directly
|
|
1167 function( target, els ) {
|
|
1168 var j = target.length,
|
|
1169 i = 0;
|
|
1170 // Can't trust NodeList.length
|
|
1171 while ( (target[j++] = els[i++]) ) {}
|
|
1172 target.length = j - 1;
|
|
1173 }
|
|
1174 };
|
|
1175 }
|
|
1176
|
|
1177 function Sizzle( selector, context, results, seed ) {
|
|
1178 var match, elem, m, nodeType,
|
|
1179 // QSA vars
|
|
1180 i, groups, old, nid, newContext, newSelector;
|
|
1181
|
|
1182 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
|
|
1183 setDocument( context );
|
|
1184 }
|
|
1185
|
|
1186 context = context || document;
|
|
1187 results = results || [];
|
|
1188
|
|
1189 if ( !selector || typeof selector !== "string" ) {
|
|
1190 return results;
|
|
1191 }
|
|
1192
|
|
1193 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
|
|
1194 return [];
|
|
1195 }
|
|
1196
|
|
1197 if ( documentIsHTML && !seed ) {
|
|
1198
|
|
1199 // Shortcuts
|
|
1200 if ( (match = rquickExpr.exec( selector )) ) {
|
|
1201 // Speed-up: Sizzle("#ID")
|
|
1202 if ( (m = match[1]) ) {
|
|
1203 if ( nodeType === 9 ) {
|
|
1204 elem = context.getElementById( m );
|
|
1205 // Check parentNode to catch when Blackberry 4.6 returns
|
|
1206 // nodes that are no longer in the document #6963
|
|
1207 if ( elem && elem.parentNode ) {
|
|
1208 // Handle the case where IE, Opera, and Webkit return items
|
|
1209 // by name instead of ID
|
|
1210 if ( elem.id === m ) {
|
|
1211 results.push( elem );
|
|
1212 return results;
|
|
1213 }
|
|
1214 } else {
|
|
1215 return results;
|
|
1216 }
|
|
1217 } else {
|
|
1218 // Context is not a document
|
|
1219 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
|
|
1220 contains( context, elem ) && elem.id === m ) {
|
|
1221 results.push( elem );
|
|
1222 return results;
|
|
1223 }
|
|
1224 }
|
|
1225
|
|
1226 // Speed-up: Sizzle("TAG")
|
|
1227 } else if ( match[2] ) {
|
|
1228 push.apply( results, context.getElementsByTagName( selector ) );
|
|
1229 return results;
|
|
1230
|
|
1231 // Speed-up: Sizzle(".CLASS")
|
|
1232 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
|
|
1233 push.apply( results, context.getElementsByClassName( m ) );
|
|
1234 return results;
|
|
1235 }
|
|
1236 }
|
|
1237
|
|
1238 // QSA path
|
|
1239 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
|
|
1240 nid = old = expando;
|
|
1241 newContext = context;
|
|
1242 newSelector = nodeType === 9 && selector;
|
|
1243
|
|
1244 // qSA works strangely on Element-rooted queries
|
|
1245 // We can work around this by specifying an extra ID on the root
|
|
1246 // and working up from there (Thanks to Andrew Dupont for the technique)
|
|
1247 // IE 8 doesn't work on object elements
|
|
1248 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
|
|
1249 groups = tokenize( selector );
|
|
1250
|
|
1251 if ( (old = context.getAttribute("id")) ) {
|
|
1252 nid = old.replace( rescape, "\\$&" );
|
|
1253 } else {
|
|
1254 context.setAttribute( "id", nid );
|
|
1255 }
|
|
1256 nid = "[id='" + nid + "'] ";
|
|
1257
|
|
1258 i = groups.length;
|
|
1259 while ( i-- ) {
|
|
1260 groups[i] = nid + toSelector( groups[i] );
|
|
1261 }
|
|
1262 newContext = rsibling.test( selector ) && context.parentNode || context;
|
|
1263 newSelector = groups.join(",");
|
|
1264 }
|
|
1265
|
|
1266 if ( newSelector ) {
|
|
1267 try {
|
|
1268 push.apply( results,
|
|
1269 newContext.querySelectorAll( newSelector )
|
|
1270 );
|
|
1271 return results;
|
|
1272 } catch(qsaError) {
|
|
1273 } finally {
|
|
1274 if ( !old ) {
|
|
1275 context.removeAttribute("id");
|
|
1276 }
|
|
1277 }
|
|
1278 }
|
|
1279 }
|
|
1280 }
|
|
1281
|
|
1282 // All others
|
|
1283 return select( selector.replace( rtrim, "$1" ), context, results, seed );
|
|
1284 }
|
|
1285
|
|
1286 /**
|
|
1287 * For feature detection
|
|
1288 * @param {Function} fn The function to test for native support
|
|
1289 */
|
|
1290 function isNative( fn ) {
|
|
1291 return rnative.test( fn + "" );
|
|
1292 }
|
|
1293
|
|
1294 /**
|
|
1295 * Create key-value caches of limited size
|
|
1296 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
|
|
1297 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
|
|
1298 * deleting the oldest entry
|
|
1299 */
|
|
1300 function createCache() {
|
|
1301 var keys = [];
|
|
1302
|
|
1303 function cache( key, value ) {
|
|
1304 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
|
|
1305 if ( keys.push( key += " " ) > Expr.cacheLength ) {
|
|
1306 // Only keep the most recent entries
|
|
1307 delete cache[ keys.shift() ];
|
|
1308 }
|
|
1309 return (cache[ key ] = value);
|
|
1310 }
|
|
1311 return cache;
|
|
1312 }
|
|
1313
|
|
1314 /**
|
|
1315 * Mark a function for special use by Sizzle
|
|
1316 * @param {Function} fn The function to mark
|
|
1317 */
|
|
1318 function markFunction( fn ) {
|
|
1319 fn[ expando ] = true;
|
|
1320 return fn;
|
|
1321 }
|
|
1322
|
|
1323 /**
|
|
1324 * Support testing using an element
|
|
1325 * @param {Function} fn Passed the created div and expects a boolean result
|
|
1326 */
|
|
1327 function assert( fn ) {
|
|
1328 var div = document.createElement("div");
|
|
1329
|
|
1330 try {
|
|
1331 return !!fn( div );
|
|
1332 } catch (e) {
|
|
1333 return false;
|
|
1334 } finally {
|
|
1335 // Remove from its parent by default
|
|
1336 if ( div.parentNode ) {
|
|
1337 div.parentNode.removeChild( div );
|
|
1338 }
|
|
1339 // release memory in IE
|
|
1340 div = null;
|
|
1341 }
|
|
1342 }
|
|
1343
|
|
1344 /**
|
|
1345 * Adds the same handler for all of the specified attrs
|
|
1346 * @param {String} attrs Pipe-separated list of attributes
|
|
1347 * @param {Function} handler The method that will be applied if the test fails
|
|
1348 * @param {Boolean} test The result of a test. If true, null will be set as the handler in leiu of the specified handler
|
|
1349 */
|
|
1350 function addHandle( attrs, handler, test ) {
|
|
1351 attrs = attrs.split("|");
|
|
1352 var current,
|
|
1353 i = attrs.length,
|
|
1354 setHandle = test ? null : handler;
|
|
1355
|
|
1356 while ( i-- ) {
|
|
1357 // Don't override a user's handler
|
|
1358 if ( !(current = Expr.attrHandle[ attrs[i] ]) || current === handler ) {
|
|
1359 Expr.attrHandle[ attrs[i] ] = setHandle;
|
|
1360 }
|
|
1361 }
|
|
1362 }
|
|
1363
|
|
1364 /**
|
|
1365 * Fetches boolean attributes by node
|
|
1366 * @param {Element} elem
|
|
1367 * @param {String} name
|
|
1368 */
|
|
1369 function boolHandler( elem, name ) {
|
|
1370 // XML does not need to be checked as this will not be assigned for XML documents
|
|
1371 var val = elem.getAttributeNode( name );
|
|
1372 return val && val.specified ?
|
|
1373 val.value :
|
|
1374 elem[ name ] === true ? name.toLowerCase() : null;
|
|
1375 }
|
|
1376
|
|
1377 /**
|
|
1378 * Fetches attributes without interpolation
|
|
1379 * http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
|
|
1380 * @param {Element} elem
|
|
1381 * @param {String} name
|
|
1382 */
|
|
1383 function interpolationHandler( elem, name ) {
|
|
1384 // XML does not need to be checked as this will not be assigned for XML documents
|
|
1385 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
|
|
1386 }
|
|
1387
|
|
1388 /**
|
|
1389 * Uses defaultValue to retrieve value in IE6/7
|
|
1390 * @param {Element} elem
|
|
1391 * @param {String} name
|
|
1392 */
|
|
1393 function valueHandler( elem ) {
|
|
1394 // Ignore the value *property* on inputs by using defaultValue
|
|
1395 // Fallback to Sizzle.attr by returning undefined where appropriate
|
|
1396 // XML does not need to be checked as this will not be assigned for XML documents
|
|
1397 if ( elem.nodeName.toLowerCase() === "input" ) {
|
|
1398 return elem.defaultValue;
|
|
1399 }
|
|
1400 }
|
|
1401
|
|
1402 /**
|
|
1403 * Checks document order of two siblings
|
|
1404 * @param {Element} a
|
|
1405 * @param {Element} b
|
|
1406 * @returns Returns -1 if a precedes b, 1 if a follows b
|
|
1407 */
|
|
1408 function siblingCheck( a, b ) {
|
|
1409 var cur = b && a,
|
|
1410 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
|
|
1411 ( ~b.sourceIndex || MAX_NEGATIVE ) -
|
|
1412 ( ~a.sourceIndex || MAX_NEGATIVE );
|
|
1413
|
|
1414 // Use IE sourceIndex if available on both nodes
|
|
1415 if ( diff ) {
|
|
1416 return diff;
|
|
1417 }
|
|
1418
|
|
1419 // Check if b follows a
|
|
1420 if ( cur ) {
|
|
1421 while ( (cur = cur.nextSibling) ) {
|
|
1422 if ( cur === b ) {
|
|
1423 return -1;
|
|
1424 }
|
|
1425 }
|
|
1426 }
|
|
1427
|
|
1428 return a ? 1 : -1;
|
|
1429 }
|
|
1430
|
|
1431 /**
|
|
1432 * Returns a function to use in pseudos for input types
|
|
1433 * @param {String} type
|
|
1434 */
|
|
1435 function createInputPseudo( type ) {
|
|
1436 return function( elem ) {
|
|
1437 var name = elem.nodeName.toLowerCase();
|
|
1438 return name === "input" && elem.type === type;
|
|
1439 };
|
|
1440 }
|
|
1441
|
|
1442 /**
|
|
1443 * Returns a function to use in pseudos for buttons
|
|
1444 * @param {String} type
|
|
1445 */
|
|
1446 function createButtonPseudo( type ) {
|
|
1447 return function( elem ) {
|
|
1448 var name = elem.nodeName.toLowerCase();
|
|
1449 return (name === "input" || name === "button") && elem.type === type;
|
|
1450 };
|
|
1451 }
|
|
1452
|
|
1453 /**
|
|
1454 * Returns a function to use in pseudos for positionals
|
|
1455 * @param {Function} fn
|
|
1456 */
|
|
1457 function createPositionalPseudo( fn ) {
|
|
1458 return markFunction(function( argument ) {
|
|
1459 argument = +argument;
|
|
1460 return markFunction(function( seed, matches ) {
|
|
1461 var j,
|
|
1462 matchIndexes = fn( [], seed.length, argument ),
|
|
1463 i = matchIndexes.length;
|
|
1464
|
|
1465 // Match elements found at the specified indexes
|
|
1466 while ( i-- ) {
|
|
1467 if ( seed[ (j = matchIndexes[i]) ] ) {
|
|
1468 seed[j] = !(matches[j] = seed[j]);
|
|
1469 }
|
|
1470 }
|
|
1471 });
|
|
1472 });
|
|
1473 }
|
|
1474
|
|
1475 /**
|
|
1476 * Detect xml
|
|
1477 * @param {Element|Object} elem An element or a document
|
|
1478 */
|
|
1479 isXML = Sizzle.isXML = function( elem ) {
|
|
1480 // documentElement is verified for cases where it doesn't yet exist
|
|
1481 // (such as loading iframes in IE - #4833)
|
|
1482 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
|
|
1483 return documentElement ? documentElement.nodeName !== "HTML" : false;
|
|
1484 };
|
|
1485
|
|
1486 // Expose support vars for convenience
|
|
1487 support = Sizzle.support = {};
|
|
1488
|
|
1489 /**
|
|
1490 * Sets document-related variables once based on the current document
|
|
1491 * @param {Element|Object} [doc] An element or document object to use to set the document
|
|
1492 * @returns {Object} Returns the current document
|
|
1493 */
|
|
1494 setDocument = Sizzle.setDocument = function( node ) {
|
|
1495 var doc = node ? node.ownerDocument || node : preferredDoc;
|
|
1496
|
|
1497 // If no document and documentElement is available, return
|
|
1498 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
|
|
1499 return document;
|
|
1500 }
|
|
1501
|
|
1502 // Set our document
|
|
1503 document = doc;
|
|
1504 docElem = doc.documentElement;
|
|
1505
|
|
1506 // Support tests
|
|
1507 documentIsHTML = !isXML( doc );
|
|
1508
|
|
1509 /* Attributes
|
|
1510 ---------------------------------------------------------------------- */
|
|
1511
|
|
1512 // Support: IE<8
|
|
1513 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
|
|
1514 support.attributes = assert(function( div ) {
|
|
1515
|
|
1516 // Support: IE<8
|
|
1517 // Prevent attribute/property "interpolation"
|
|
1518 div.innerHTML = "<a href='#'></a>";
|
|
1519 addHandle( "type|href|height|width", interpolationHandler, div.firstChild.getAttribute("href") === "#" );
|
|
1520
|
|
1521 // Support: IE<9
|
|
1522 // Use getAttributeNode to fetch booleans when getAttribute lies
|
|
1523 addHandle( booleans, boolHandler, div.getAttribute("disabled") == null );
|
|
1524
|
|
1525 div.className = "i";
|
|
1526 return !div.getAttribute("className");
|
|
1527 });
|
|
1528
|
|
1529 // Support: IE<9
|
|
1530 // Retrieving value should defer to defaultValue
|
|
1531 support.input = assert(function( div ) {
|
|
1532 div.innerHTML = "<input>";
|
|
1533 div.firstChild.setAttribute( "value", "" );
|
|
1534 return div.firstChild.getAttribute( "value" ) === "";
|
|
1535 });
|
|
1536
|
|
1537 // IE6/7 still return empty string for value,
|
|
1538 // but are actually retrieving the property
|
|
1539 addHandle( "value", valueHandler, support.attributes && support.input );
|
|
1540
|
|
1541 /* getElement(s)By*
|
|
1542 ---------------------------------------------------------------------- */
|
|
1543
|
|
1544 // Check if getElementsByTagName("*") returns only elements
|
|
1545 support.getElementsByTagName = assert(function( div ) {
|
|
1546 div.appendChild( doc.createComment("") );
|
|
1547 return !div.getElementsByTagName("*").length;
|
|
1548 });
|
|
1549
|
|
1550 // Check if getElementsByClassName can be trusted
|
|
1551 support.getElementsByClassName = assert(function( div ) {
|
|
1552 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
|
|
1553
|
|
1554 // Support: Safari<4
|
|
1555 // Catch class over-caching
|
|
1556 div.firstChild.className = "i";
|
|
1557 // Support: Opera<10
|
|
1558 // Catch gEBCN failure to find non-leading classes
|
|
1559 return div.getElementsByClassName("i").length === 2;
|
|
1560 });
|
|
1561
|
|
1562 // Support: IE<10
|
|
1563 // Check if getElementById returns elements by name
|
|
1564 // The broken getElementById methods don't pick up programatically-set names,
|
|
1565 // so use a roundabout getElementsByName test
|
|
1566 support.getById = assert(function( div ) {
|
|
1567 docElem.appendChild( div ).id = expando;
|
|
1568 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
|
|
1569 });
|
|
1570
|
|
1571 // ID find and filter
|
|
1572 if ( support.getById ) {
|
|
1573 Expr.find["ID"] = function( id, context ) {
|
|
1574 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
|
|
1575 var m = context.getElementById( id );
|
|
1576 // Check parentNode to catch when Blackberry 4.6 returns
|
|
1577 // nodes that are no longer in the document #6963
|
|
1578 return m && m.parentNode ? [m] : [];
|
|
1579 }
|
|
1580 };
|
|
1581 Expr.filter["ID"] = function( id ) {
|
|
1582 var attrId = id.replace( runescape, funescape );
|
|
1583 return function( elem ) {
|
|
1584 return elem.getAttribute("id") === attrId;
|
|
1585 };
|
|
1586 };
|
|
1587 } else {
|
|
1588 // Support: IE6/7
|
|
1589 // getElementById is not reliable as a find shortcut
|
|
1590 delete Expr.find["ID"];
|
|
1591
|
|
1592 Expr.filter["ID"] = function( id ) {
|
|
1593 var attrId = id.replace( runescape, funescape );
|
|
1594 return function( elem ) {
|
|
1595 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
|
|
1596 return node && node.value === attrId;
|
|
1597 };
|
|
1598 };
|
|
1599 }
|
|
1600
|
|
1601 // Tag
|
|
1602 Expr.find["TAG"] = support.getElementsByTagName ?
|
|
1603 function( tag, context ) {
|
|
1604 if ( typeof context.getElementsByTagName !== strundefined ) {
|
|
1605 return context.getElementsByTagName( tag );
|
|
1606 }
|
|
1607 } :
|
|
1608 function( tag, context ) {
|
|
1609 var elem,
|
|
1610 tmp = [],
|
|
1611 i = 0,
|
|
1612 results = context.getElementsByTagName( tag );
|
|
1613
|
|
1614 // Filter out possible comments
|
|
1615 if ( tag === "*" ) {
|
|
1616 while ( (elem = results[i++]) ) {
|
|
1617 if ( elem.nodeType === 1 ) {
|
|
1618 tmp.push( elem );
|
|
1619 }
|
|
1620 }
|
|
1621
|
|
1622 return tmp;
|
|
1623 }
|
|
1624 return results;
|
|
1625 };
|
|
1626
|
|
1627 // Class
|
|
1628 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
|
|
1629 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
|
|
1630 return context.getElementsByClassName( className );
|
|
1631 }
|
|
1632 };
|
|
1633
|
|
1634 /* QSA/matchesSelector
|
|
1635 ---------------------------------------------------------------------- */
|
|
1636
|
|
1637 // QSA and matchesSelector support
|
|
1638
|
|
1639 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
|
|
1640 rbuggyMatches = [];
|
|
1641
|
|
1642 // qSa(:focus) reports false when true (Chrome 21)
|
|
1643 // We allow this because of a bug in IE8/9 that throws an error
|
|
1644 // whenever `document.activeElement` is accessed on an iframe
|
|
1645 // So, we allow :focus to pass through QSA all the time to avoid the IE error
|
|
1646 // See http://bugs.jquery.com/ticket/13378
|
|
1647 rbuggyQSA = [];
|
|
1648
|
|
1649 if ( (support.qsa = isNative(doc.querySelectorAll)) ) {
|
|
1650 // Build QSA regex
|
|
1651 // Regex strategy adopted from Diego Perini
|
|
1652 assert(function( div ) {
|
|
1653 // Select is set to empty string on purpose
|
|
1654 // This is to test IE's treatment of not explicitly
|
|
1655 // setting a boolean content attribute,
|
|
1656 // since its presence should be enough
|
|
1657 // http://bugs.jquery.com/ticket/12359
|
|
1658 div.innerHTML = "<select><option selected=''></option></select>";
|
|
1659
|
|
1660 // Support: IE8
|
|
1661 // Boolean attributes and "value" are not treated correctly
|
|
1662 if ( !div.querySelectorAll("[selected]").length ) {
|
|
1663 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
|
|
1664 }
|
|
1665
|
|
1666 // Webkit/Opera - :checked should return selected option elements
|
|
1667 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
|
|
1668 // IE8 throws error here and will not see later tests
|
|
1669 if ( !div.querySelectorAll(":checked").length ) {
|
|
1670 rbuggyQSA.push(":checked");
|
|
1671 }
|
|
1672 });
|
|
1673
|
|
1674 assert(function( div ) {
|
|
1675
|
|
1676 // Support: Opera 10-12/IE8
|
|
1677 // ^= $= *= and empty values
|
|
1678 // Should not select anything
|
|
1679 // Support: Windows 8 Native Apps
|
|
1680 // The type attribute is restricted during .innerHTML assignment
|
|
1681 var input = doc.createElement("input");
|
|
1682 input.setAttribute( "type", "hidden" );
|
|
1683 div.appendChild( input ).setAttribute( "t", "" );
|
|
1684
|
|
1685 if ( div.querySelectorAll("[t^='']").length ) {
|
|
1686 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
|
|
1687 }
|
|
1688
|
|
1689 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
|
|
1690 // IE8 throws error here and will not see later tests
|
|
1691 if ( !div.querySelectorAll(":enabled").length ) {
|
|
1692 rbuggyQSA.push( ":enabled", ":disabled" );
|
|
1693 }
|
|
1694
|
|
1695 // Opera 10-11 does not throw on post-comma invalid pseudos
|
|
1696 div.querySelectorAll("*,:x");
|
|
1697 rbuggyQSA.push(",.*:");
|
|
1698 });
|
|
1699 }
|
|
1700
|
|
1701 if ( (support.matchesSelector = isNative( (matches = docElem.webkitMatchesSelector ||
|
|
1702 docElem.mozMatchesSelector ||
|
|
1703 docElem.oMatchesSelector ||
|
|
1704 docElem.msMatchesSelector) )) ) {
|
|
1705
|
|
1706 assert(function( div ) {
|
|
1707 // Check to see if it's possible to do matchesSelector
|
|
1708 // on a disconnected node (IE 9)
|
|
1709 support.disconnectedMatch = matches.call( div, "div" );
|
|
1710
|
|
1711 // This should fail with an exception
|
|
1712 // Gecko does not error, returns false instead
|
|
1713 matches.call( div, "[s!='']:x" );
|
|
1714 rbuggyMatches.push( "!=", pseudos );
|
|
1715 });
|
|
1716 }
|
|
1717
|
|
1718 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
|
|
1719 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
|
|
1720
|
|
1721 /* Contains
|
|
1722 ---------------------------------------------------------------------- */
|
|
1723
|
|
1724 // Element contains another
|
|
1725 // Purposefully does not implement inclusive descendent
|
|
1726 // As in, an element does not contain itself
|
|
1727 contains = isNative(docElem.contains) || docElem.compareDocumentPosition ?
|
|
1728 function( a, b ) {
|
|
1729 var adown = a.nodeType === 9 ? a.documentElement : a,
|
|
1730 bup = b && b.parentNode;
|
|
1731 return a === bup || !!( bup && bup.nodeType === 1 && (
|
|
1732 adown.contains ?
|
|
1733 adown.contains( bup ) :
|
|
1734 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
|
|
1735 ));
|
|
1736 } :
|
|
1737 function( a, b ) {
|
|
1738 if ( b ) {
|
|
1739 while ( (b = b.parentNode) ) {
|
|
1740 if ( b === a ) {
|
|
1741 return true;
|
|
1742 }
|
|
1743 }
|
|
1744 }
|
|
1745 return false;
|
|
1746 };
|
|
1747
|
|
1748 /* Sorting
|
|
1749 ---------------------------------------------------------------------- */
|
|
1750
|
|
1751 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
|
|
1752 // Detached nodes confoundingly follow *each other*
|
|
1753 support.sortDetached = assert(function( div1 ) {
|
|
1754 // Should return 1, but returns 4 (following)
|
|
1755 return div1.compareDocumentPosition( doc.createElement("div") ) & 1;
|
|
1756 });
|
|
1757
|
|
1758 // Document order sorting
|
|
1759 sortOrder = docElem.compareDocumentPosition ?
|
|
1760 function( a, b ) {
|
|
1761
|
|
1762 // Flag for duplicate removal
|
|
1763 if ( a === b ) {
|
|
1764 hasDuplicate = true;
|
|
1765 return 0;
|
|
1766 }
|
|
1767
|
|
1768 var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b );
|
|
1769
|
|
1770 if ( compare ) {
|
|
1771 // Disconnected nodes
|
|
1772 if ( compare & 1 ||
|
|
1773 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
|
|
1774
|
|
1775 // Choose the first element that is related to our preferred document
|
|
1776 if ( a === doc || contains(preferredDoc, a) ) {
|
|
1777 return -1;
|
|
1778 }
|
|
1779 if ( b === doc || contains(preferredDoc, b) ) {
|
|
1780 return 1;
|
|
1781 }
|
|
1782
|
|
1783 // Maintain original order
|
|
1784 return sortInput ?
|
|
1785 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
|
|
1786 0;
|
|
1787 }
|
|
1788
|
|
1789 return compare & 4 ? -1 : 1;
|
|
1790 }
|
|
1791
|
|
1792 // Not directly comparable, sort on existence of method
|
|
1793 return a.compareDocumentPosition ? -1 : 1;
|
|
1794 } :
|
|
1795 function( a, b ) {
|
|
1796 var cur,
|
|
1797 i = 0,
|
|
1798 aup = a.parentNode,
|
|
1799 bup = b.parentNode,
|
|
1800 ap = [ a ],
|
|
1801 bp = [ b ];
|
|
1802
|
|
1803 // Exit early if the nodes are identical
|
|
1804 if ( a === b ) {
|
|
1805 hasDuplicate = true;
|
|
1806 return 0;
|
|
1807
|
|
1808 // Parentless nodes are either documents or disconnected
|
|
1809 } else if ( !aup || !bup ) {
|
|
1810 return a === doc ? -1 :
|
|
1811 b === doc ? 1 :
|
|
1812 aup ? -1 :
|
|
1813 bup ? 1 :
|
|
1814 sortInput ?
|
|
1815 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
|
|
1816 0;
|
|
1817
|
|
1818 // If the nodes are siblings, we can do a quick check
|
|
1819 } else if ( aup === bup ) {
|
|
1820 return siblingCheck( a, b );
|
|
1821 }
|
|
1822
|
|
1823 // Otherwise we need full lists of their ancestors for comparison
|
|
1824 cur = a;
|
|
1825 while ( (cur = cur.parentNode) ) {
|
|
1826 ap.unshift( cur );
|
|
1827 }
|
|
1828 cur = b;
|
|
1829 while ( (cur = cur.parentNode) ) {
|
|
1830 bp.unshift( cur );
|
|
1831 }
|
|
1832
|
|
1833 // Walk down the tree looking for a discrepancy
|
|
1834 while ( ap[i] === bp[i] ) {
|
|
1835 i++;
|
|
1836 }
|
|
1837
|
|
1838 return i ?
|
|
1839 // Do a sibling check if the nodes have a common ancestor
|
|
1840 siblingCheck( ap[i], bp[i] ) :
|
|
1841
|
|
1842 // Otherwise nodes in our document sort first
|
|
1843 ap[i] === preferredDoc ? -1 :
|
|
1844 bp[i] === preferredDoc ? 1 :
|
|
1845 0;
|
|
1846 };
|
|
1847
|
|
1848 return doc;
|
|
1849 };
|
|
1850
|
|
1851 Sizzle.matches = function( expr, elements ) {
|
|
1852 return Sizzle( expr, null, null, elements );
|
|
1853 };
|
|
1854
|
|
1855 Sizzle.matchesSelector = function( elem, expr ) {
|
|
1856 // Set document vars if needed
|
|
1857 if ( ( elem.ownerDocument || elem ) !== document ) {
|
|
1858 setDocument( elem );
|
|
1859 }
|
|
1860
|
|
1861 // Make sure that attribute selectors are quoted
|
|
1862 expr = expr.replace( rattributeQuotes, "='$1']" );
|
|
1863
|
|
1864 if ( support.matchesSelector && documentIsHTML &&
|
|
1865 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
|
|
1866 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
|
|
1867
|
|
1868 try {
|
|
1869 var ret = matches.call( elem, expr );
|
|
1870
|
|
1871 // IE 9's matchesSelector returns false on disconnected nodes
|
|
1872 if ( ret || support.disconnectedMatch ||
|
|
1873 // As well, disconnected nodes are said to be in a document
|
|
1874 // fragment in IE 9
|
|
1875 elem.document && elem.document.nodeType !== 11 ) {
|
|
1876 return ret;
|
|
1877 }
|
|
1878 } catch(e) {}
|
|
1879 }
|
|
1880
|
|
1881 return Sizzle( expr, document, null, [elem] ).length > 0;
|
|
1882 };
|
|
1883
|
|
1884 Sizzle.contains = function( context, elem ) {
|
|
1885 // Set document vars if needed
|
|
1886 if ( ( context.ownerDocument || context ) !== document ) {
|
|
1887 setDocument( context );
|
|
1888 }
|
|
1889 return contains( context, elem );
|
|
1890 };
|
|
1891
|
|
1892 Sizzle.attr = function( elem, name ) {
|
|
1893 // Set document vars if needed
|
|
1894 if ( ( elem.ownerDocument || elem ) !== document ) {
|
|
1895 setDocument( elem );
|
|
1896 }
|
|
1897
|
|
1898 var fn = Expr.attrHandle[ name.toLowerCase() ],
|
|
1899 // Don't get fooled by Object.prototype properties (jQuery #13807)
|
|
1900 val = ( fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
|
|
1901 fn( elem, name, !documentIsHTML ) :
|
|
1902 undefined );
|
|
1903
|
|
1904 return val === undefined ?
|
|
1905 support.attributes || !documentIsHTML ?
|
|
1906 elem.getAttribute( name ) :
|
|
1907 (val = elem.getAttributeNode(name)) && val.specified ?
|
|
1908 val.value :
|
|
1909 null :
|
|
1910 val;
|
|
1911 };
|
|
1912
|
|
1913 Sizzle.error = function( msg ) {
|
|
1914 throw new Error( "Syntax error, unrecognized expression: " + msg );
|
|
1915 };
|
|
1916
|
|
1917 /**
|
|
1918 * Document sorting and removing duplicates
|
|
1919 * @param {ArrayLike} results
|
|
1920 */
|
|
1921 Sizzle.uniqueSort = function( results ) {
|
|
1922 var elem,
|
|
1923 duplicates = [],
|
|
1924 j = 0,
|
|
1925 i = 0;
|
|
1926
|
|
1927 // Unless we *know* we can detect duplicates, assume their presence
|
|
1928 hasDuplicate = !support.detectDuplicates;
|
|
1929 sortInput = !support.sortStable && results.slice( 0 );
|
|
1930 results.sort( sortOrder );
|
|
1931
|
|
1932 if ( hasDuplicate ) {
|
|
1933 while ( (elem = results[i++]) ) {
|
|
1934 if ( elem === results[ i ] ) {
|
|
1935 j = duplicates.push( i );
|
|
1936 }
|
|
1937 }
|
|
1938 while ( j-- ) {
|
|
1939 results.splice( duplicates[ j ], 1 );
|
|
1940 }
|
|
1941 }
|
|
1942
|
|
1943 return results;
|
|
1944 };
|
|
1945
|
|
1946 /**
|
|
1947 * Utility function for retrieving the text value of an array of DOM nodes
|
|
1948 * @param {Array|Element} elem
|
|
1949 */
|
|
1950 getText = Sizzle.getText = function( elem ) {
|
|
1951 var node,
|
|
1952 ret = "",
|
|
1953 i = 0,
|
|
1954 nodeType = elem.nodeType;
|
|
1955
|
|
1956 if ( !nodeType ) {
|
|
1957 // If no nodeType, this is expected to be an array
|
|
1958 for ( ; (node = elem[i]); i++ ) {
|
|
1959 // Do not traverse comment nodes
|
|
1960 ret += getText( node );
|
|
1961 }
|
|
1962 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
|
|
1963 // Use textContent for elements
|
|
1964 // innerText usage removed for consistency of new lines (see #11153)
|
|
1965 if ( typeof elem.textContent === "string" ) {
|
|
1966 return elem.textContent;
|
|
1967 } else {
|
|
1968 // Traverse its children
|
|
1969 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
|
|
1970 ret += getText( elem );
|
|
1971 }
|
|
1972 }
|
|
1973 } else if ( nodeType === 3 || nodeType === 4 ) {
|
|
1974 return elem.nodeValue;
|
|
1975 }
|
|
1976 // Do not include comment or processing instruction nodes
|
|
1977
|
|
1978 return ret;
|
|
1979 };
|
|
1980
|
|
1981 Expr = Sizzle.selectors = {
|
|
1982
|
|
1983 // Can be adjusted by the user
|
|
1984 cacheLength: 50,
|
|
1985
|
|
1986 createPseudo: markFunction,
|
|
1987
|
|
1988 match: matchExpr,
|
|
1989
|
|
1990 attrHandle: {},
|
|
1991
|
|
1992 find: {},
|
|
1993
|
|
1994 relative: {
|
|
1995 ">": { dir: "parentNode", first: true },
|
|
1996 " ": { dir: "parentNode" },
|
|
1997 "+": { dir: "previousSibling", first: true },
|
|
1998 "~": { dir: "previousSibling" }
|
|
1999 },
|
|
2000
|
|
2001 preFilter: {
|
|
2002 "ATTR": function( match ) {
|
|
2003 match[1] = match[1].replace( runescape, funescape );
|
|
2004
|
|
2005 // Move the given value to match[3] whether quoted or unquoted
|
|
2006 match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
|
|
2007
|
|
2008 if ( match[2] === "~=" ) {
|
|
2009 match[3] = " " + match[3] + " ";
|
|
2010 }
|
|
2011
|
|
2012 return match.slice( 0, 4 );
|
|
2013 },
|
|
2014
|
|
2015 "CHILD": function( match ) {
|
|
2016 /* matches from matchExpr["CHILD"]
|
|
2017 1 type (only|nth|...)
|
|
2018 2 what (child|of-type)
|
|
2019 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
|
|
2020 4 xn-component of xn+y argument ([+-]?\d*n|)
|
|
2021 5 sign of xn-component
|
|
2022 6 x of xn-component
|
|
2023 7 sign of y-component
|
|
2024 8 y of y-component
|
|
2025 */
|
|
2026 match[1] = match[1].toLowerCase();
|
|
2027
|
|
2028 if ( match[1].slice( 0, 3 ) === "nth" ) {
|
|
2029 // nth-* requires argument
|
|
2030 if ( !match[3] ) {
|
|
2031 Sizzle.error( match[0] );
|
|
2032 }
|
|
2033
|
|
2034 // numeric x and y parameters for Expr.filter.CHILD
|
|
2035 // remember that false/true cast respectively to 0/1
|
|
2036 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
|
|
2037 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
|
|
2038
|
|
2039 // other types prohibit arguments
|
|
2040 } else if ( match[3] ) {
|
|
2041 Sizzle.error( match[0] );
|
|
2042 }
|
|
2043
|
|
2044 return match;
|
|
2045 },
|
|
2046
|
|
2047 "PSEUDO": function( match ) {
|
|
2048 var excess,
|
|
2049 unquoted = !match[5] && match[2];
|
|
2050
|
|
2051 if ( matchExpr["CHILD"].test( match[0] ) ) {
|
|
2052 return null;
|
|
2053 }
|
|
2054
|
|
2055 // Accept quoted arguments as-is
|
|
2056 if ( match[3] && match[4] !== undefined ) {
|
|
2057 match[2] = match[4];
|
|
2058
|
|
2059 // Strip excess characters from unquoted arguments
|
|
2060 } else if ( unquoted && rpseudo.test( unquoted ) &&
|
|
2061 // Get excess from tokenize (recursively)
|
|
2062 (excess = tokenize( unquoted, true )) &&
|
|
2063 // advance to the next closing parenthesis
|
|
2064 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
|
|
2065
|
|
2066 // excess is a negative index
|
|
2067 match[0] = match[0].slice( 0, excess );
|
|
2068 match[2] = unquoted.slice( 0, excess );
|
|
2069 }
|
|
2070
|
|
2071 // Return only captures needed by the pseudo filter method (type and argument)
|
|
2072 return match.slice( 0, 3 );
|
|
2073 }
|
|
2074 },
|
|
2075
|
|
2076 filter: {
|
|
2077
|
|
2078 "TAG": function( nodeNameSelector ) {
|
|
2079 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
|
|
2080 return nodeNameSelector === "*" ?
|
|
2081 function() { return true; } :
|
|
2082 function( elem ) {
|
|
2083 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
|
|
2084 };
|
|
2085 },
|
|
2086
|
|
2087 "CLASS": function( className ) {
|
|
2088 var pattern = classCache[ className + " " ];
|
|
2089
|
|
2090 return pattern ||
|
|
2091 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
|
|
2092 classCache( className, function( elem ) {
|
|
2093 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
|
|
2094 });
|
|
2095 },
|
|
2096
|
|
2097 "ATTR": function( name, operator, check ) {
|
|
2098 return function( elem ) {
|
|
2099 var result = Sizzle.attr( elem, name );
|
|
2100
|
|
2101 if ( result == null ) {
|
|
2102 return operator === "!=";
|
|
2103 }
|
|
2104 if ( !operator ) {
|
|
2105 return true;
|
|
2106 }
|
|
2107
|
|
2108 result += "";
|
|
2109
|
|
2110 return operator === "=" ? result === check :
|
|
2111 operator === "!=" ? result !== check :
|
|
2112 operator === "^=" ? check && result.indexOf( check ) === 0 :
|
|
2113 operator === "*=" ? check && result.indexOf( check ) > -1 :
|
|
2114 operator === "$=" ? check && result.slice( -check.length ) === check :
|
|
2115 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
|
|
2116 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
|
|
2117 false;
|
|
2118 };
|
|
2119 },
|
|
2120
|
|
2121 "CHILD": function( type, what, argument, first, last ) {
|
|
2122 var simple = type.slice( 0, 3 ) !== "nth",
|
|
2123 forward = type.slice( -4 ) !== "last",
|
|
2124 ofType = what === "of-type";
|
|
2125
|
|
2126 return first === 1 && last === 0 ?
|
|
2127
|
|
2128 // Shortcut for :nth-*(n)
|
|
2129 function( elem ) {
|
|
2130 return !!elem.parentNode;
|
|
2131 } :
|
|
2132
|
|
2133 function( elem, context, xml ) {
|
|
2134 var cache, outerCache, node, diff, nodeIndex, start,
|
|
2135 dir = simple !== forward ? "nextSibling" : "previousSibling",
|
|
2136 parent = elem.parentNode,
|
|
2137 name = ofType && elem.nodeName.toLowerCase(),
|
|
2138 useCache = !xml && !ofType;
|
|
2139
|
|
2140 if ( parent ) {
|
|
2141
|
|
2142 // :(first|last|only)-(child|of-type)
|
|
2143 if ( simple ) {
|
|
2144 while ( dir ) {
|
|
2145 node = elem;
|
|
2146 while ( (node = node[ dir ]) ) {
|
|
2147 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
|
|
2148 return false;
|
|
2149 }
|
|
2150 }
|
|
2151 // Reverse direction for :only-* (if we haven't yet done so)
|
|
2152 start = dir = type === "only" && !start && "nextSibling";
|
|
2153 }
|
|
2154 return true;
|
|
2155 }
|
|
2156
|
|
2157 start = [ forward ? parent.firstChild : parent.lastChild ];
|
|
2158
|
|
2159 // non-xml :nth-child(...) stores cache data on `parent`
|
|
2160 if ( forward && useCache ) {
|
|
2161 // Seek `elem` from a previously-cached index
|
|
2162 outerCache = parent[ expando ] || (parent[ expando ] = {});
|
|
2163 cache = outerCache[ type ] || [];
|
|
2164 nodeIndex = cache[0] === dirruns && cache[1];
|
|
2165 diff = cache[0] === dirruns && cache[2];
|
|
2166 node = nodeIndex && parent.childNodes[ nodeIndex ];
|
|
2167
|
|
2168 while ( (node = ++nodeIndex && node && node[ dir ] ||
|
|
2169
|
|
2170 // Fallback to seeking `elem` from the start
|
|
2171 (diff = nodeIndex = 0) || start.pop()) ) {
|
|
2172
|
|
2173 // When found, cache indexes on `parent` and break
|
|
2174 if ( node.nodeType === 1 && ++diff && node === elem ) {
|
|
2175 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
|
|
2176 break;
|
|
2177 }
|
|
2178 }
|
|
2179
|
|
2180 // Use previously-cached element index if available
|
|
2181 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
|
|
2182 diff = cache[1];
|
|
2183
|
|
2184 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
|
|
2185 } else {
|
|
2186 // Use the same loop as above to seek `elem` from the start
|
|
2187 while ( (node = ++nodeIndex && node && node[ dir ] ||
|
|
2188 (diff = nodeIndex = 0) || start.pop()) ) {
|
|
2189
|
|
2190 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
|
|
2191 // Cache the index of each encountered element
|
|
2192 if ( useCache ) {
|
|
2193 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
|
|
2194 }
|
|
2195
|
|
2196 if ( node === elem ) {
|
|
2197 break;
|
|
2198 }
|
|
2199 }
|
|
2200 }
|
|
2201 }
|
|
2202
|
|
2203 // Incorporate the offset, then check against cycle size
|
|
2204 diff -= last;
|
|
2205 return diff === first || ( diff % first === 0 && diff / first >= 0 );
|
|
2206 }
|
|
2207 };
|
|
2208 },
|
|
2209
|
|
2210 "PSEUDO": function( pseudo, argument ) {
|
|
2211 // pseudo-class names are case-insensitive
|
|
2212 // http://www.w3.org/TR/selectors/#pseudo-classes
|
|
2213 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
|
|
2214 // Remember that setFilters inherits from pseudos
|
|
2215 var args,
|
|
2216 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
|
|
2217 Sizzle.error( "unsupported pseudo: " + pseudo );
|
|
2218
|
|
2219 // The user may use createPseudo to indicate that
|
|
2220 // arguments are needed to create the filter function
|
|
2221 // just as Sizzle does
|
|
2222 if ( fn[ expando ] ) {
|
|
2223 return fn( argument );
|
|
2224 }
|
|
2225
|
|
2226 // But maintain support for old signatures
|
|
2227 if ( fn.length > 1 ) {
|
|
2228 args = [ pseudo, pseudo, "", argument ];
|
|
2229 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
|
|
2230 markFunction(function( seed, matches ) {
|
|
2231 var idx,
|
|
2232 matched = fn( seed, argument ),
|
|
2233 i = matched.length;
|
|
2234 while ( i-- ) {
|
|
2235 idx = indexOf.call( seed, matched[i] );
|
|
2236 seed[ idx ] = !( matches[ idx ] = matched[i] );
|
|
2237 }
|
|
2238 }) :
|
|
2239 function( elem ) {
|
|
2240 return fn( elem, 0, args );
|
|
2241 };
|
|
2242 }
|
|
2243
|
|
2244 return fn;
|
|
2245 }
|
|
2246 },
|
|
2247
|
|
2248 pseudos: {
|
|
2249 // Potentially complex pseudos
|
|
2250 "not": markFunction(function( selector ) {
|
|
2251 // Trim the selector passed to compile
|
|
2252 // to avoid treating leading and trailing
|
|
2253 // spaces as combinators
|
|
2254 var input = [],
|
|
2255 results = [],
|
|
2256 matcher = compile( selector.replace( rtrim, "$1" ) );
|
|
2257
|
|
2258 return matcher[ expando ] ?
|
|
2259 markFunction(function( seed, matches, context, xml ) {
|
|
2260 var elem,
|
|
2261 unmatched = matcher( seed, null, xml, [] ),
|
|
2262 i = seed.length;
|
|
2263
|
|
2264 // Match elements unmatched by `matcher`
|
|
2265 while ( i-- ) {
|
|
2266 if ( (elem = unmatched[i]) ) {
|
|
2267 seed[i] = !(matches[i] = elem);
|
|
2268 }
|
|
2269 }
|
|
2270 }) :
|
|
2271 function( elem, context, xml ) {
|
|
2272 input[0] = elem;
|
|
2273 matcher( input, null, xml, results );
|
|
2274 return !results.pop();
|
|
2275 };
|
|
2276 }),
|
|
2277
|
|
2278 "has": markFunction(function( selector ) {
|
|
2279 return function( elem ) {
|
|
2280 return Sizzle( selector, elem ).length > 0;
|
|
2281 };
|
|
2282 }),
|
|
2283
|
|
2284 "contains": markFunction(function( text ) {
|
|
2285 return function( elem ) {
|
|
2286 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
|
|
2287 };
|
|
2288 }),
|
|
2289
|
|
2290 // "Whether an element is represented by a :lang() selector
|
|
2291 // is based solely on the element's language value
|
|
2292 // being equal to the identifier C,
|
|
2293 // or beginning with the identifier C immediately followed by "-".
|
|
2294 // The matching of C against the element's language value is performed case-insensitively.
|
|
2295 // The identifier C does not have to be a valid language name."
|
|
2296 // http://www.w3.org/TR/selectors/#lang-pseudo
|
|
2297 "lang": markFunction( function( lang ) {
|
|
2298 // lang value must be a valid identifier
|
|
2299 if ( !ridentifier.test(lang || "") ) {
|
|
2300 Sizzle.error( "unsupported lang: " + lang );
|
|
2301 }
|
|
2302 lang = lang.replace( runescape, funescape ).toLowerCase();
|
|
2303 return function( elem ) {
|
|
2304 var elemLang;
|
|
2305 do {
|
|
2306 if ( (elemLang = documentIsHTML ?
|
|
2307 elem.lang :
|
|
2308 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
|
|
2309
|
|
2310 elemLang = elemLang.toLowerCase();
|
|
2311 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
|
|
2312 }
|
|
2313 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
|
|
2314 return false;
|
|
2315 };
|
|
2316 }),
|
|
2317
|
|
2318 // Miscellaneous
|
|
2319 "target": function( elem ) {
|
|
2320 var hash = window.location && window.location.hash;
|
|
2321 return hash && hash.slice( 1 ) === elem.id;
|
|
2322 },
|
|
2323
|
|
2324 "root": function( elem ) {
|
|
2325 return elem === docElem;
|
|
2326 },
|
|
2327
|
|
2328 "focus": function( elem ) {
|
|
2329 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
|
|
2330 },
|
|
2331
|
|
2332 // Boolean properties
|
|
2333 "enabled": function( elem ) {
|
|
2334 return elem.disabled === false;
|
|
2335 },
|
|
2336
|
|
2337 "disabled": function( elem ) {
|
|
2338 return elem.disabled === true;
|
|
2339 },
|
|
2340
|
|
2341 "checked": function( elem ) {
|
|
2342 // In CSS3, :checked should return both checked and selected elements
|
|
2343 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
|
|
2344 var nodeName = elem.nodeName.toLowerCase();
|
|
2345 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
|
|
2346 },
|
|
2347
|
|
2348 "selected": function( elem ) {
|
|
2349 // Accessing this property makes selected-by-default
|
|
2350 // options in Safari work properly
|
|
2351 if ( elem.parentNode ) {
|
|
2352 elem.parentNode.selectedIndex;
|
|
2353 }
|
|
2354
|
|
2355 return elem.selected === true;
|
|
2356 },
|
|
2357
|
|
2358 // Contents
|
|
2359 "empty": function( elem ) {
|
|
2360 // http://www.w3.org/TR/selectors/#empty-pseudo
|
|
2361 // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
|
|
2362 // not comment, processing instructions, or others
|
|
2363 // Thanks to Diego Perini for the nodeName shortcut
|
|
2364 // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
|
|
2365 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
|
|
2366 if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) {
|
|
2367 return false;
|
|
2368 }
|
|
2369 }
|
|
2370 return true;
|
|
2371 },
|
|
2372
|
|
2373 "parent": function( elem ) {
|
|
2374 return !Expr.pseudos["empty"]( elem );
|
|
2375 },
|
|
2376
|
|
2377 // Element/input types
|
|
2378 "header": function( elem ) {
|
|
2379 return rheader.test( elem.nodeName );
|
|
2380 },
|
|
2381
|
|
2382 "input": function( elem ) {
|
|
2383 return rinputs.test( elem.nodeName );
|
|
2384 },
|
|
2385
|
|
2386 "button": function( elem ) {
|
|
2387 var name = elem.nodeName.toLowerCase();
|
|
2388 return name === "input" && elem.type === "button" || name === "button";
|
|
2389 },
|
|
2390
|
|
2391 "text": function( elem ) {
|
|
2392 var attr;
|
|
2393 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
|
|
2394 // use getAttribute instead to test this case
|
|
2395 return elem.nodeName.toLowerCase() === "input" &&
|
|
2396 elem.type === "text" &&
|
|
2397 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type );
|
|
2398 },
|
|
2399
|
|
2400 // Position-in-collection
|
|
2401 "first": createPositionalPseudo(function() {
|
|
2402 return [ 0 ];
|
|
2403 }),
|
|
2404
|
|
2405 "last": createPositionalPseudo(function( matchIndexes, length ) {
|
|
2406 return [ length - 1 ];
|
|
2407 }),
|
|
2408
|
|
2409 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
|
|
2410 return [ argument < 0 ? argument + length : argument ];
|
|
2411 }),
|
|
2412
|
|
2413 "even": createPositionalPseudo(function( matchIndexes, length ) {
|
|
2414 var i = 0;
|
|
2415 for ( ; i < length; i += 2 ) {
|
|
2416 matchIndexes.push( i );
|
|
2417 }
|
|
2418 return matchIndexes;
|
|
2419 }),
|
|
2420
|
|
2421 "odd": createPositionalPseudo(function( matchIndexes, length ) {
|
|
2422 var i = 1;
|
|
2423 for ( ; i < length; i += 2 ) {
|
|
2424 matchIndexes.push( i );
|
|
2425 }
|
|
2426 return matchIndexes;
|
|
2427 }),
|
|
2428
|
|
2429 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
|
|
2430 var i = argument < 0 ? argument + length : argument;
|
|
2431 for ( ; --i >= 0; ) {
|
|
2432 matchIndexes.push( i );
|
|
2433 }
|
|
2434 return matchIndexes;
|
|
2435 }),
|
|
2436
|
|
2437 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
|
|
2438 var i = argument < 0 ? argument + length : argument;
|
|
2439 for ( ; ++i < length; ) {
|
|
2440 matchIndexes.push( i );
|
|
2441 }
|
|
2442 return matchIndexes;
|
|
2443 })
|
|
2444 }
|
|
2445 };
|
|
2446
|
|
2447 // Add button/input type pseudos
|
|
2448 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
|
|
2449 Expr.pseudos[ i ] = createInputPseudo( i );
|
|
2450 }
|
|
2451 for ( i in { submit: true, reset: true } ) {
|
|
2452 Expr.pseudos[ i ] = createButtonPseudo( i );
|
|
2453 }
|
|
2454
|
|
2455 function tokenize( selector, parseOnly ) {
|
|
2456 var matched, match, tokens, type,
|
|
2457 soFar, groups, preFilters,
|
|
2458 cached = tokenCache[ selector + " " ];
|
|
2459
|
|
2460 if ( cached ) {
|
|
2461 return parseOnly ? 0 : cached.slice( 0 );
|
|
2462 }
|
|
2463
|
|
2464 soFar = selector;
|
|
2465 groups = [];
|
|
2466 preFilters = Expr.preFilter;
|
|
2467
|
|
2468 while ( soFar ) {
|
|
2469
|
|
2470 // Comma and first run
|
|
2471 if ( !matched || (match = rcomma.exec( soFar )) ) {
|
|
2472 if ( match ) {
|
|
2473 // Don't consume trailing commas as valid
|
|
2474 soFar = soFar.slice( match[0].length ) || soFar;
|
|
2475 }
|
|
2476 groups.push( tokens = [] );
|
|
2477 }
|
|
2478
|
|
2479 matched = false;
|
|
2480
|
|
2481 // Combinators
|
|
2482 if ( (match = rcombinators.exec( soFar )) ) {
|
|
2483 matched = match.shift();
|
|
2484 tokens.push({
|
|
2485 value: matched,
|
|
2486 // Cast descendant combinators to space
|
|
2487 type: match[0].replace( rtrim, " " )
|
|
2488 });
|
|
2489 soFar = soFar.slice( matched.length );
|
|
2490 }
|
|
2491
|
|
2492 // Filters
|
|
2493 for ( type in Expr.filter ) {
|
|
2494 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
|
|
2495 (match = preFilters[ type ]( match ))) ) {
|
|
2496 matched = match.shift();
|
|
2497 tokens.push({
|
|
2498 value: matched,
|
|
2499 type: type,
|
|
2500 matches: match
|
|
2501 });
|
|
2502 soFar = soFar.slice( matched.length );
|
|
2503 }
|
|
2504 }
|
|
2505
|
|
2506 if ( !matched ) {
|
|
2507 break;
|
|
2508 }
|
|
2509 }
|
|
2510
|
|
2511 // Return the length of the invalid excess
|
|
2512 // if we're just parsing
|
|
2513 // Otherwise, throw an error or return tokens
|
|
2514 return parseOnly ?
|
|
2515 soFar.length :
|
|
2516 soFar ?
|
|
2517 Sizzle.error( selector ) :
|
|
2518 // Cache the tokens
|
|
2519 tokenCache( selector, groups ).slice( 0 );
|
|
2520 }
|
|
2521
|
|
2522 function toSelector( tokens ) {
|
|
2523 var i = 0,
|
|
2524 len = tokens.length,
|
|
2525 selector = "";
|
|
2526 for ( ; i < len; i++ ) {
|
|
2527 selector += tokens[i].value;
|
|
2528 }
|
|
2529 return selector;
|
|
2530 }
|
|
2531
|
|
2532 function addCombinator( matcher, combinator, base ) {
|
|
2533 var dir = combinator.dir,
|
|
2534 checkNonElements = base && dir === "parentNode",
|
|
2535 doneName = done++;
|
|
2536
|
|
2537 return combinator.first ?
|
|
2538 // Check against closest ancestor/preceding element
|
|
2539 function( elem, context, xml ) {
|
|
2540 while ( (elem = elem[ dir ]) ) {
|
|
2541 if ( elem.nodeType === 1 || checkNonElements ) {
|
|
2542 return matcher( elem, context, xml );
|
|
2543 }
|
|
2544 }
|
|
2545 } :
|
|
2546
|
|
2547 // Check against all ancestor/preceding elements
|
|
2548 function( elem, context, xml ) {
|
|
2549 var data, cache, outerCache,
|
|
2550 dirkey = dirruns + " " + doneName;
|
|
2551
|
|
2552 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
|
|
2553 if ( xml ) {
|
|
2554 while ( (elem = elem[ dir ]) ) {
|
|
2555 if ( elem.nodeType === 1 || checkNonElements ) {
|
|
2556 if ( matcher( elem, context, xml ) ) {
|
|
2557 return true;
|
|
2558 }
|
|
2559 }
|
|
2560 }
|
|
2561 } else {
|
|
2562 while ( (elem = elem[ dir ]) ) {
|
|
2563 if ( elem.nodeType === 1 || checkNonElements ) {
|
|
2564 outerCache = elem[ expando ] || (elem[ expando ] = {});
|
|
2565 if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) {
|
|
2566 if ( (data = cache[1]) === true || data === cachedruns ) {
|
|
2567 return data === true;
|
|
2568 }
|
|
2569 } else {
|
|
2570 cache = outerCache[ dir ] = [ dirkey ];
|
|
2571 cache[1] = matcher( elem, context, xml ) || cachedruns;
|
|
2572 if ( cache[1] === true ) {
|
|
2573 return true;
|
|
2574 }
|
|
2575 }
|
|
2576 }
|
|
2577 }
|
|
2578 }
|
|
2579 };
|
|
2580 }
|
|
2581
|
|
2582 function elementMatcher( matchers ) {
|
|
2583 return matchers.length > 1 ?
|
|
2584 function( elem, context, xml ) {
|
|
2585 var i = matchers.length;
|
|
2586 while ( i-- ) {
|
|
2587 if ( !matchers[i]( elem, context, xml ) ) {
|
|
2588 return false;
|
|
2589 }
|
|
2590 }
|
|
2591 return true;
|
|
2592 } :
|
|
2593 matchers[0];
|
|
2594 }
|
|
2595
|
|
2596 function condense( unmatched, map, filter, context, xml ) {
|
|
2597 var elem,
|
|
2598 newUnmatched = [],
|
|
2599 i = 0,
|
|
2600 len = unmatched.length,
|
|
2601 mapped = map != null;
|
|
2602
|
|
2603 for ( ; i < len; i++ ) {
|
|
2604 if ( (elem = unmatched[i]) ) {
|
|
2605 if ( !filter || filter( elem, context, xml ) ) {
|
|
2606 newUnmatched.push( elem );
|
|
2607 if ( mapped ) {
|
|
2608 map.push( i );
|
|
2609 }
|
|
2610 }
|
|
2611 }
|
|
2612 }
|
|
2613
|
|
2614 return newUnmatched;
|
|
2615 }
|
|
2616
|
|
2617 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
|
|
2618 if ( postFilter && !postFilter[ expando ] ) {
|
|
2619 postFilter = setMatcher( postFilter );
|
|
2620 }
|
|
2621 if ( postFinder && !postFinder[ expando ] ) {
|
|
2622 postFinder = setMatcher( postFinder, postSelector );
|
|
2623 }
|
|
2624 return markFunction(function( seed, results, context, xml ) {
|
|
2625 var temp, i, elem,
|
|
2626 preMap = [],
|
|
2627 postMap = [],
|
|
2628 preexisting = results.length,
|
|
2629
|
|
2630 // Get initial elements from seed or context
|
|
2631 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
|
|
2632
|
|
2633 // Prefilter to get matcher input, preserving a map for seed-results synchronization
|
|
2634 matcherIn = preFilter && ( seed || !selector ) ?
|
|
2635 condense( elems, preMap, preFilter, context, xml ) :
|
|
2636 elems,
|
|
2637
|
|
2638 matcherOut = matcher ?
|
|
2639 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
|
|
2640 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
|
|
2641
|
|
2642 // ...intermediate processing is necessary
|
|
2643 [] :
|
|
2644
|
|
2645 // ...otherwise use results directly
|
|
2646 results :
|
|
2647 matcherIn;
|
|
2648
|
|
2649 // Find primary matches
|
|
2650 if ( matcher ) {
|
|
2651 matcher( matcherIn, matcherOut, context, xml );
|
|
2652 }
|
|
2653
|
|
2654 // Apply postFilter
|
|
2655 if ( postFilter ) {
|
|
2656 temp = condense( matcherOut, postMap );
|
|
2657 postFilter( temp, [], context, xml );
|
|
2658
|
|
2659 // Un-match failing elements by moving them back to matcherIn
|
|
2660 i = temp.length;
|
|
2661 while ( i-- ) {
|
|
2662 if ( (elem = temp[i]) ) {
|
|
2663 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
|
|
2664 }
|
|
2665 }
|
|
2666 }
|
|
2667
|
|
2668 if ( seed ) {
|
|
2669 if ( postFinder || preFilter ) {
|
|
2670 if ( postFinder ) {
|
|
2671 // Get the final matcherOut by condensing this intermediate into postFinder contexts
|
|
2672 temp = [];
|
|
2673 i = matcherOut.length;
|
|
2674 while ( i-- ) {
|
|
2675 if ( (elem = matcherOut[i]) ) {
|
|
2676 // Restore matcherIn since elem is not yet a final match
|
|
2677 temp.push( (matcherIn[i] = elem) );
|
|
2678 }
|
|
2679 }
|
|
2680 postFinder( null, (matcherOut = []), temp, xml );
|
|
2681 }
|
|
2682
|
|
2683 // Move matched elements from seed to results to keep them synchronized
|
|
2684 i = matcherOut.length;
|
|
2685 while ( i-- ) {
|
|
2686 if ( (elem = matcherOut[i]) &&
|
|
2687 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
|
|
2688
|
|
2689 seed[temp] = !(results[temp] = elem);
|
|
2690 }
|
|
2691 }
|
|
2692 }
|
|
2693
|
|
2694 // Add elements to results, through postFinder if defined
|
|
2695 } else {
|
|
2696 matcherOut = condense(
|
|
2697 matcherOut === results ?
|
|
2698 matcherOut.splice( preexisting, matcherOut.length ) :
|
|
2699 matcherOut
|
|
2700 );
|
|
2701 if ( postFinder ) {
|
|
2702 postFinder( null, results, matcherOut, xml );
|
|
2703 } else {
|
|
2704 push.apply( results, matcherOut );
|
|
2705 }
|
|
2706 }
|
|
2707 });
|
|
2708 }
|
|
2709
|
|
2710 function matcherFromTokens( tokens ) {
|
|
2711 var checkContext, matcher, j,
|
|
2712 len = tokens.length,
|
|
2713 leadingRelative = Expr.relative[ tokens[0].type ],
|
|
2714 implicitRelative = leadingRelative || Expr.relative[" "],
|
|
2715 i = leadingRelative ? 1 : 0,
|
|
2716
|
|
2717 // The foundational matcher ensures that elements are reachable from top-level context(s)
|
|
2718 matchContext = addCombinator( function( elem ) {
|
|
2719 return elem === checkContext;
|
|
2720 }, implicitRelative, true ),
|
|
2721 matchAnyContext = addCombinator( function( elem ) {
|
|
2722 return indexOf.call( checkContext, elem ) > -1;
|
|
2723 }, implicitRelative, true ),
|
|
2724 matchers = [ function( elem, context, xml ) {
|
|
2725 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
|
|
2726 (checkContext = context).nodeType ?
|
|
2727 matchContext( elem, context, xml ) :
|
|
2728 matchAnyContext( elem, context, xml ) );
|
|
2729 } ];
|
|
2730
|
|
2731 for ( ; i < len; i++ ) {
|
|
2732 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
|
|
2733 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
|
|
2734 } else {
|
|
2735 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
|
|
2736
|
|
2737 // Return special upon seeing a positional matcher
|
|
2738 if ( matcher[ expando ] ) {
|
|
2739 // Find the next relative operator (if any) for proper handling
|
|
2740 j = ++i;
|
|
2741 for ( ; j < len; j++ ) {
|
|
2742 if ( Expr.relative[ tokens[j].type ] ) {
|
|
2743 break;
|
|
2744 }
|
|
2745 }
|
|
2746 return setMatcher(
|
|
2747 i > 1 && elementMatcher( matchers ),
|
|
2748 i > 1 && toSelector(
|
|
2749 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
|
|
2750 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
|
|
2751 ).replace( rtrim, "$1" ),
|
|
2752 matcher,
|
|
2753 i < j && matcherFromTokens( tokens.slice( i, j ) ),
|
|
2754 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
|
|
2755 j < len && toSelector( tokens )
|
|
2756 );
|
|
2757 }
|
|
2758 matchers.push( matcher );
|
|
2759 }
|
|
2760 }
|
|
2761
|
|
2762 return elementMatcher( matchers );
|
|
2763 }
|
|
2764
|
|
2765 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
|
|
2766 // A counter to specify which element is currently being matched
|
|
2767 var matcherCachedRuns = 0,
|
|
2768 bySet = setMatchers.length > 0,
|
|
2769 byElement = elementMatchers.length > 0,
|
|
2770 superMatcher = function( seed, context, xml, results, expandContext ) {
|
|
2771 var elem, j, matcher,
|
|
2772 setMatched = [],
|
|
2773 matchedCount = 0,
|
|
2774 i = "0",
|
|
2775 unmatched = seed && [],
|
|
2776 outermost = expandContext != null,
|
|
2777 contextBackup = outermostContext,
|
|
2778 // We must always have either seed elements or context
|
|
2779 elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
|
|
2780 // Use integer dirruns iff this is the outermost matcher
|
|
2781 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1);
|
|
2782
|
|
2783 if ( outermost ) {
|
|
2784 outermostContext = context !== document && context;
|
|
2785 cachedruns = matcherCachedRuns;
|
|
2786 }
|
|
2787
|
|
2788 // Add elements passing elementMatchers directly to results
|
|
2789 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
|
|
2790 for ( ; (elem = elems[i]) != null; i++ ) {
|
|
2791 if ( byElement && elem ) {
|
|
2792 j = 0;
|
|
2793 while ( (matcher = elementMatchers[j++]) ) {
|
|
2794 if ( matcher( elem, context, xml ) ) {
|
|
2795 results.push( elem );
|
|
2796 break;
|
|
2797 }
|
|
2798 }
|
|
2799 if ( outermost ) {
|
|
2800 dirruns = dirrunsUnique;
|
|
2801 cachedruns = ++matcherCachedRuns;
|
|
2802 }
|
|
2803 }
|
|
2804
|
|
2805 // Track unmatched elements for set filters
|
|
2806 if ( bySet ) {
|
|
2807 // They will have gone through all possible matchers
|
|
2808 if ( (elem = !matcher && elem) ) {
|
|
2809 matchedCount--;
|
|
2810 }
|
|
2811
|
|
2812 // Lengthen the array for every element, matched or not
|
|
2813 if ( seed ) {
|
|
2814 unmatched.push( elem );
|
|
2815 }
|
|
2816 }
|
|
2817 }
|
|
2818
|
|
2819 // Apply set filters to unmatched elements
|
|
2820 matchedCount += i;
|
|
2821 if ( bySet && i !== matchedCount ) {
|
|
2822 j = 0;
|
|
2823 while ( (matcher = setMatchers[j++]) ) {
|
|
2824 matcher( unmatched, setMatched, context, xml );
|
|
2825 }
|
|
2826
|
|
2827 if ( seed ) {
|
|
2828 // Reintegrate element matches to eliminate the need for sorting
|
|
2829 if ( matchedCount > 0 ) {
|
|
2830 while ( i-- ) {
|
|
2831 if ( !(unmatched[i] || setMatched[i]) ) {
|
|
2832 setMatched[i] = pop.call( results );
|
|
2833 }
|
|
2834 }
|
|
2835 }
|
|
2836
|
|
2837 // Discard index placeholder values to get only actual matches
|
|
2838 setMatched = condense( setMatched );
|
|
2839 }
|
|
2840
|
|
2841 // Add matches to results
|
|
2842 push.apply( results, setMatched );
|
|
2843
|
|
2844 // Seedless set matches succeeding multiple successful matchers stipulate sorting
|
|
2845 if ( outermost && !seed && setMatched.length > 0 &&
|
|
2846 ( matchedCount + setMatchers.length ) > 1 ) {
|
|
2847
|
|
2848 Sizzle.uniqueSort( results );
|
|
2849 }
|
|
2850 }
|
|
2851
|
|
2852 // Override manipulation of globals by nested matchers
|
|
2853 if ( outermost ) {
|
|
2854 dirruns = dirrunsUnique;
|
|
2855 outermostContext = contextBackup;
|
|
2856 }
|
|
2857
|
|
2858 return unmatched;
|
|
2859 };
|
|
2860
|
|
2861 return bySet ?
|
|
2862 markFunction( superMatcher ) :
|
|
2863 superMatcher;
|
|
2864 }
|
|
2865
|
|
2866 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
|
|
2867 var i,
|
|
2868 setMatchers = [],
|
|
2869 elementMatchers = [],
|
|
2870 cached = compilerCache[ selector + " " ];
|
|
2871
|
|
2872 if ( !cached ) {
|
|
2873 // Generate a function of recursive functions that can be used to check each element
|
|
2874 if ( !group ) {
|
|
2875 group = tokenize( selector );
|
|
2876 }
|
|
2877 i = group.length;
|
|
2878 while ( i-- ) {
|
|
2879 cached = matcherFromTokens( group[i] );
|
|
2880 if ( cached[ expando ] ) {
|
|
2881 setMatchers.push( cached );
|
|
2882 } else {
|
|
2883 elementMatchers.push( cached );
|
|
2884 }
|
|
2885 }
|
|
2886
|
|
2887 // Cache the compiled function
|
|
2888 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
|
|
2889 }
|
|
2890 return cached;
|
|
2891 };
|
|
2892
|
|
2893 function multipleContexts( selector, contexts, results ) {
|
|
2894 var i = 0,
|
|
2895 len = contexts.length;
|
|
2896 for ( ; i < len; i++ ) {
|
|
2897 Sizzle( selector, contexts[i], results );
|
|
2898 }
|
|
2899 return results;
|
|
2900 }
|
|
2901
|
|
2902 function select( selector, context, results, seed ) {
|
|
2903 var i, tokens, token, type, find,
|
|
2904 match = tokenize( selector );
|
|
2905
|
|
2906 if ( !seed ) {
|
|
2907 // Try to minimize operations if there is only one group
|
|
2908 if ( match.length === 1 ) {
|
|
2909
|
|
2910 // Take a shortcut and set the context if the root selector is an ID
|
|
2911 tokens = match[0] = match[0].slice( 0 );
|
|
2912 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
|
|
2913 support.getById && context.nodeType === 9 && documentIsHTML &&
|
|
2914 Expr.relative[ tokens[1].type ] ) {
|
|
2915
|
|
2916 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
|
|
2917 if ( !context ) {
|
|
2918 return results;
|
|
2919 }
|
|
2920 selector = selector.slice( tokens.shift().value.length );
|
|
2921 }
|
|
2922
|
|
2923 // Fetch a seed set for right-to-left matching
|
|
2924 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
|
|
2925 while ( i-- ) {
|
|
2926 token = tokens[i];
|
|
2927
|
|
2928 // Abort if we hit a combinator
|
|
2929 if ( Expr.relative[ (type = token.type) ] ) {
|
|
2930 break;
|
|
2931 }
|
|
2932 if ( (find = Expr.find[ type ]) ) {
|
|
2933 // Search, expanding context for leading sibling combinators
|
|
2934 if ( (seed = find(
|
|
2935 token.matches[0].replace( runescape, funescape ),
|
|
2936 rsibling.test( tokens[0].type ) && context.parentNode || context
|
|
2937 )) ) {
|
|
2938
|
|
2939 // If seed is empty or no tokens remain, we can return early
|
|
2940 tokens.splice( i, 1 );
|
|
2941 selector = seed.length && toSelector( tokens );
|
|
2942 if ( !selector ) {
|
|
2943 push.apply( results, seed );
|
|
2944 return results;
|
|
2945 }
|
|
2946
|
|
2947 break;
|
|
2948 }
|
|
2949 }
|
|
2950 }
|
|
2951 }
|
|
2952 }
|
|
2953
|
|
2954 // Compile and execute a filtering function
|
|
2955 // Provide `match` to avoid retokenization if we modified the selector above
|
|
2956 compile( selector, match )(
|
|
2957 seed,
|
|
2958 context,
|
|
2959 !documentIsHTML,
|
|
2960 results,
|
|
2961 rsibling.test( selector )
|
|
2962 );
|
|
2963 return results;
|
|
2964 }
|
|
2965
|
|
2966 // Deprecated
|
|
2967 Expr.pseudos["nth"] = Expr.pseudos["eq"];
|
|
2968
|
|
2969 // Easy API for creating new setFilters
|
|
2970 function setFilters() {}
|
|
2971 setFilters.prototype = Expr.filters = Expr.pseudos;
|
|
2972 Expr.setFilters = new setFilters();
|
|
2973
|
|
2974 // One-time assignments
|
|
2975
|
|
2976 // Sort stability
|
|
2977 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
|
|
2978
|
|
2979 // Initialize against the default document
|
|
2980 setDocument();
|
|
2981
|
|
2982 // Support: Chrome<<14
|
|
2983 // Always assume duplicates if they aren't passed to the comparison function
|
|
2984 [0, 0].sort( sortOrder );
|
|
2985 support.detectDuplicates = hasDuplicate;
|
|
2986
|
|
2987 jQuery.find = Sizzle;
|
|
2988 jQuery.expr = Sizzle.selectors;
|
|
2989 jQuery.expr[":"] = jQuery.expr.pseudos;
|
|
2990 jQuery.unique = Sizzle.uniqueSort;
|
|
2991 jQuery.text = Sizzle.getText;
|
|
2992 jQuery.isXMLDoc = Sizzle.isXML;
|
|
2993 jQuery.contains = Sizzle.contains;
|
|
2994
|
|
2995
|
|
2996 })( window );
|
|
2997 // String to Object options format cache
|
|
2998 var optionsCache = {};
|
|
2999
|
|
3000 // Convert String-formatted options into Object-formatted ones and store in cache
|
|
3001 function createOptions( options ) {
|
|
3002 var object = optionsCache[ options ] = {};
|
|
3003 jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) {
|
|
3004 object[ flag ] = true;
|
|
3005 });
|
|
3006 return object;
|
|
3007 }
|
|
3008
|
|
3009 /*
|
|
3010 * Create a callback list using the following parameters:
|
|
3011 *
|
|
3012 * options: an optional list of space-separated options that will change how
|
|
3013 * the callback list behaves or a more traditional option object
|
|
3014 *
|
|
3015 * By default a callback list will act like an event callback list and can be
|
|
3016 * "fired" multiple times.
|
|
3017 *
|
|
3018 * Possible options:
|
|
3019 *
|
|
3020 * once: will ensure the callback list can only be fired once (like a Deferred)
|
|
3021 *
|
|
3022 * memory: will keep track of previous values and will call any callback added
|
|
3023 * after the list has been fired right away with the latest "memorized"
|
|
3024 * values (like a Deferred)
|
|
3025 *
|
|
3026 * unique: will ensure a callback can only be added once (no duplicate in the list)
|
|
3027 *
|
|
3028 * stopOnFalse: interrupt callings when a callback returns false
|
|
3029 *
|
|
3030 */
|
|
3031 jQuery.Callbacks = function( options ) {
|
|
3032
|
|
3033 // Convert options from String-formatted to Object-formatted if needed
|
|
3034 // (we check in cache first)
|
|
3035 options = typeof options === "string" ?
|
|
3036 ( optionsCache[ options ] || createOptions( options ) ) :
|
|
3037 jQuery.extend( {}, options );
|
|
3038
|
|
3039 var // Flag to know if list is currently firing
|
|
3040 firing,
|
|
3041 // Last fire value (for non-forgettable lists)
|
|
3042 memory,
|
|
3043 // Flag to know if list was already fired
|
|
3044 fired,
|
|
3045 // End of the loop when firing
|
|
3046 firingLength,
|
|
3047 // Index of currently firing callback (modified by remove if needed)
|
|
3048 firingIndex,
|
|
3049 // First callback to fire (used internally by add and fireWith)
|
|
3050 firingStart,
|
|
3051 // Actual callback list
|
|
3052 list = [],
|
|
3053 // Stack of fire calls for repeatable lists
|
|
3054 stack = !options.once && [],
|
|
3055 // Fire callbacks
|
|
3056 fire = function( data ) {
|
|
3057 memory = options.memory && data;
|
|
3058 fired = true;
|
|
3059 firingIndex = firingStart || 0;
|
|
3060 firingStart = 0;
|
|
3061 firingLength = list.length;
|
|
3062 firing = true;
|
|
3063 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
|
|
3064 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
|
|
3065 memory = false; // To prevent further calls using add
|
|
3066 break;
|
|
3067 }
|
|
3068 }
|
|
3069 firing = false;
|
|
3070 if ( list ) {
|
|
3071 if ( stack ) {
|
|
3072 if ( stack.length ) {
|
|
3073 fire( stack.shift() );
|
|
3074 }
|
|
3075 } else if ( memory ) {
|
|
3076 list = [];
|
|
3077 } else {
|
|
3078 self.disable();
|
|
3079 }
|
|
3080 }
|
|
3081 },
|
|
3082 // Actual Callbacks object
|
|
3083 self = {
|
|
3084 // Add a callback or a collection of callbacks to the list
|
|
3085 add: function() {
|
|
3086 if ( list ) {
|
|
3087 // First, we save the current length
|
|
3088 var start = list.length;
|
|
3089 (function add( args ) {
|
|
3090 jQuery.each( args, function( _, arg ) {
|
|
3091 var type = jQuery.type( arg );
|
|
3092 if ( type === "function" ) {
|
|
3093 if ( !options.unique || !self.has( arg ) ) {
|
|
3094 list.push( arg );
|
|
3095 }
|
|
3096 } else if ( arg && arg.length && type !== "string" ) {
|
|
3097 // Inspect recursively
|
|
3098 add( arg );
|
|
3099 }
|
|
3100 });
|
|
3101 })( arguments );
|
|
3102 // Do we need to add the callbacks to the
|
|
3103 // current firing batch?
|
|
3104 if ( firing ) {
|
|
3105 firingLength = list.length;
|
|
3106 // With memory, if we're not firing then
|
|
3107 // we should call right away
|
|
3108 } else if ( memory ) {
|
|
3109 firingStart = start;
|
|
3110 fire( memory );
|
|
3111 }
|
|
3112 }
|
|
3113 return this;
|
|
3114 },
|
|
3115 // Remove a callback from the list
|
|
3116 remove: function() {
|
|
3117 if ( list ) {
|
|
3118 jQuery.each( arguments, function( _, arg ) {
|
|
3119 var index;
|
|
3120 while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
|
|
3121 list.splice( index, 1 );
|
|
3122 // Handle firing indexes
|
|
3123 if ( firing ) {
|
|
3124 if ( index <= firingLength ) {
|
|
3125 firingLength--;
|
|
3126 }
|
|
3127 if ( index <= firingIndex ) {
|
|
3128 firingIndex--;
|
|
3129 }
|
|
3130 }
|
|
3131 }
|
|
3132 });
|
|
3133 }
|
|
3134 return this;
|
|
3135 },
|
|
3136 // Check if a given callback is in the list.
|
|
3137 // If no argument is given, return whether or not list has callbacks attached.
|
|
3138 has: function( fn ) {
|
|
3139 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
|
|
3140 },
|
|
3141 // Remove all callbacks from the list
|
|
3142 empty: function() {
|
|
3143 list = [];
|
|
3144 firingLength = 0;
|
|
3145 return this;
|
|
3146 },
|
|
3147 // Have the list do nothing anymore
|
|
3148 disable: function() {
|
|
3149 list = stack = memory = undefined;
|
|
3150 return this;
|
|
3151 },
|
|
3152 // Is it disabled?
|
|
3153 disabled: function() {
|
|
3154 return !list;
|
|
3155 },
|
|
3156 // Lock the list in its current state
|
|
3157 lock: function() {
|
|
3158 stack = undefined;
|
|
3159 if ( !memory ) {
|
|
3160 self.disable();
|
|
3161 }
|
|
3162 return this;
|
|
3163 },
|
|
3164 // Is it locked?
|
|
3165 locked: function() {
|
|
3166 return !stack;
|
|
3167 },
|
|
3168 // Call all callbacks with the given context and arguments
|
|
3169 fireWith: function( context, args ) {
|
|
3170 args = args || [];
|
|
3171 args = [ context, args.slice ? args.slice() : args ];
|
|
3172 if ( list && ( !fired || stack ) ) {
|
|
3173 if ( firing ) {
|
|
3174 stack.push( args );
|
|
3175 } else {
|
|
3176 fire( args );
|
|
3177 }
|
|
3178 }
|
|
3179 return this;
|
|
3180 },
|
|
3181 // Call all the callbacks with the given arguments
|
|
3182 fire: function() {
|
|
3183 self.fireWith( this, arguments );
|
|
3184 return this;
|
|
3185 },
|
|
3186 // To know if the callbacks have already been called at least once
|
|
3187 fired: function() {
|
|
3188 return !!fired;
|
|
3189 }
|
|
3190 };
|
|
3191
|
|
3192 return self;
|
|
3193 };
|
|
3194 jQuery.extend({
|
|
3195
|
|
3196 Deferred: function( func ) {
|
|
3197 var tuples = [
|
|
3198 // action, add listener, listener list, final state
|
|
3199 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
|
|
3200 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
|
|
3201 [ "notify", "progress", jQuery.Callbacks("memory") ]
|
|
3202 ],
|
|
3203 state = "pending",
|
|
3204 promise = {
|
|
3205 state: function() {
|
|
3206 return state;
|
|
3207 },
|
|
3208 always: function() {
|
|
3209 deferred.done( arguments ).fail( arguments );
|
|
3210 return this;
|
|
3211 },
|
|
3212 then: function( /* fnDone, fnFail, fnProgress */ ) {
|
|
3213 var fns = arguments;
|
|
3214 return jQuery.Deferred(function( newDefer ) {
|
|
3215 jQuery.each( tuples, function( i, tuple ) {
|
|
3216 var action = tuple[ 0 ],
|
|
3217 fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
|
|
3218 // deferred[ done | fail | progress ] for forwarding actions to newDefer
|
|
3219 deferred[ tuple[1] ](function() {
|
|
3220 var returned = fn && fn.apply( this, arguments );
|
|
3221 if ( returned && jQuery.isFunction( returned.promise ) ) {
|
|
3222 returned.promise()
|
|
3223 .done( newDefer.resolve )
|
|
3224 .fail( newDefer.reject )
|
|
3225 .progress( newDefer.notify );
|
|
3226 } else {
|
|
3227 newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
|
|
3228 }
|
|
3229 });
|
|
3230 });
|
|
3231 fns = null;
|
|
3232 }).promise();
|
|
3233 },
|
|
3234 // Get a promise for this deferred
|
|
3235 // If obj is provided, the promise aspect is added to the object
|
|
3236 promise: function( obj ) {
|
|
3237 return obj != null ? jQuery.extend( obj, promise ) : promise;
|
|
3238 }
|
|
3239 },
|
|
3240 deferred = {};
|
|
3241
|
|
3242 // Keep pipe for back-compat
|
|
3243 promise.pipe = promise.then;
|
|
3244
|
|
3245 // Add list-specific methods
|
|
3246 jQuery.each( tuples, function( i, tuple ) {
|
|
3247 var list = tuple[ 2 ],
|
|
3248 stateString = tuple[ 3 ];
|
|
3249
|
|
3250 // promise[ done | fail | progress ] = list.add
|
|
3251 promise[ tuple[1] ] = list.add;
|
|
3252
|
|
3253 // Handle state
|
|
3254 if ( stateString ) {
|
|
3255 list.add(function() {
|
|
3256 // state = [ resolved | rejected ]
|
|
3257 state = stateString;
|
|
3258
|
|
3259 // [ reject_list | resolve_list ].disable; progress_list.lock
|
|
3260 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
|
|
3261 }
|
|
3262
|
|
3263 // deferred[ resolve | reject | notify ]
|
|
3264 deferred[ tuple[0] ] = function() {
|
|
3265 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
|
|
3266 return this;
|
|
3267 };
|
|
3268 deferred[ tuple[0] + "With" ] = list.fireWith;
|
|
3269 });
|
|
3270
|
|
3271 // Make the deferred a promise
|
|
3272 promise.promise( deferred );
|
|
3273
|
|
3274 // Call given func if any
|
|
3275 if ( func ) {
|
|
3276 func.call( deferred, deferred );
|
|
3277 }
|
|
3278
|
|
3279 // All done!
|
|
3280 return deferred;
|
|
3281 },
|
|
3282
|
|
3283 // Deferred helper
|
|
3284 when: function( subordinate /* , ..., subordinateN */ ) {
|
|
3285 var i = 0,
|
|
3286 resolveValues = core_slice.call( arguments ),
|
|
3287 length = resolveValues.length,
|
|
3288
|
|
3289 // the count of uncompleted subordinates
|
|
3290 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
|
|
3291
|
|
3292 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
|
|
3293 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
|
|
3294
|
|
3295 // Update function for both resolve and progress values
|
|
3296 updateFunc = function( i, contexts, values ) {
|
|
3297 return function( value ) {
|
|
3298 contexts[ i ] = this;
|
|
3299 values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
|
|
3300 if( values === progressValues ) {
|
|
3301 deferred.notifyWith( contexts, values );
|
|
3302 } else if ( !( --remaining ) ) {
|
|
3303 deferred.resolveWith( contexts, values );
|
|
3304 }
|
|
3305 };
|
|
3306 },
|
|
3307
|
|
3308 progressValues, progressContexts, resolveContexts;
|
|
3309
|
|
3310 // add listeners to Deferred subordinates; treat others as resolved
|
|
3311 if ( length > 1 ) {
|
|
3312 progressValues = new Array( length );
|
|
3313 progressContexts = new Array( length );
|
|
3314 resolveContexts = new Array( length );
|
|
3315 for ( ; i < length; i++ ) {
|
|
3316 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
|
|
3317 resolveValues[ i ].promise()
|
|
3318 .done( updateFunc( i, resolveContexts, resolveValues ) )
|
|
3319 .fail( deferred.reject )
|
|
3320 .progress( updateFunc( i, progressContexts, progressValues ) );
|
|
3321 } else {
|
|
3322 --remaining;
|
|
3323 }
|
|
3324 }
|
|
3325 }
|
|
3326
|
|
3327 // if we're not waiting on anything, resolve the master
|
|
3328 if ( !remaining ) {
|
|
3329 deferred.resolveWith( resolveContexts, resolveValues );
|
|
3330 }
|
|
3331
|
|
3332 return deferred.promise();
|
|
3333 }
|
|
3334 });
|
|
3335 jQuery.support = (function( support ) {
|
|
3336
|
|
3337 var all, a, input, select, fragment, opt, eventName, isSupported, i,
|
|
3338 div = document.createElement("div");
|
|
3339
|
|
3340 // Setup
|
|
3341 div.setAttribute( "className", "t" );
|
|
3342 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
|
|
3343
|
|
3344 // Finish early in limited (non-browser) environments
|
|
3345 all = div.getElementsByTagName("*") || [];
|
|
3346 a = div.getElementsByTagName("a")[ 0 ];
|
|
3347 if ( !a || !a.style || !all.length ) {
|
|
3348 return support;
|
|
3349 }
|
|
3350
|
|
3351 // First batch of tests
|
|
3352 select = document.createElement("select");
|
|
3353 opt = select.appendChild( document.createElement("option") );
|
|
3354 input = div.getElementsByTagName("input")[ 0 ];
|
|
3355
|
|
3356 a.style.cssText = "top:1px;float:left;opacity:.5";
|
|
3357
|
|
3358 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
|
|
3359 support.getSetAttribute = div.className !== "t";
|
|
3360
|
|
3361 // IE strips leading whitespace when .innerHTML is used
|
|
3362 support.leadingWhitespace = div.firstChild.nodeType === 3;
|
|
3363
|
|
3364 // Make sure that tbody elements aren't automatically inserted
|
|
3365 // IE will insert them into empty tables
|
|
3366 support.tbody = !div.getElementsByTagName("tbody").length;
|
|
3367
|
|
3368 // Make sure that link elements get serialized correctly by innerHTML
|
|
3369 // This requires a wrapper element in IE
|
|
3370 support.htmlSerialize = !!div.getElementsByTagName("link").length;
|
|
3371
|
|
3372 // Get the style information from getAttribute
|
|
3373 // (IE uses .cssText instead)
|
|
3374 support.style = /top/.test( a.getAttribute("style") );
|
|
3375
|
|
3376 // Make sure that URLs aren't manipulated
|
|
3377 // (IE normalizes it by default)
|
|
3378 support.hrefNormalized = a.getAttribute("href") === "/a";
|
|
3379
|
|
3380 // Make sure that element opacity exists
|
|
3381 // (IE uses filter instead)
|
|
3382 // Use a regex to work around a WebKit issue. See #5145
|
|
3383 support.opacity = /^0.5/.test( a.style.opacity );
|
|
3384
|
|
3385 // Verify style float existence
|
|
3386 // (IE uses styleFloat instead of cssFloat)
|
|
3387 support.cssFloat = !!a.style.cssFloat;
|
|
3388
|
|
3389 // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
|
|
3390 support.checkOn = !!input.value;
|
|
3391
|
|
3392 // Make sure that a selected-by-default option has a working selected property.
|
|
3393 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
|
|
3394 support.optSelected = opt.selected;
|
|
3395
|
|
3396 // Tests for enctype support on a form (#6743)
|
|
3397 support.enctype = !!document.createElement("form").enctype;
|
|
3398
|
|
3399 // Makes sure cloning an html5 element does not cause problems
|
|
3400 // Where outerHTML is undefined, this still works
|
|
3401 support.html5Clone = document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>";
|
|
3402
|
|
3403 // Will be defined later
|
|
3404 support.inlineBlockNeedsLayout = false;
|
|
3405 support.shrinkWrapBlocks = false;
|
|
3406 support.pixelPosition = false;
|
|
3407 support.deleteExpando = true;
|
|
3408 support.noCloneEvent = true;
|
|
3409 support.reliableMarginRight = true;
|
|
3410 support.boxSizingReliable = true;
|
|
3411
|
|
3412 // Make sure checked status is properly cloned
|
|
3413 input.checked = true;
|
|
3414 support.noCloneChecked = input.cloneNode( true ).checked;
|
|
3415
|
|
3416 // Make sure that the options inside disabled selects aren't marked as disabled
|
|
3417 // (WebKit marks them as disabled)
|
|
3418 select.disabled = true;
|
|
3419 support.optDisabled = !opt.disabled;
|
|
3420
|
|
3421 // Support: IE<9
|
|
3422 try {
|
|
3423 delete div.test;
|
|
3424 } catch( e ) {
|
|
3425 support.deleteExpando = false;
|
|
3426 }
|
|
3427
|
|
3428 // Check if we can trust getAttribute("value")
|
|
3429 input = document.createElement("input");
|
|
3430 input.setAttribute( "value", "" );
|
|
3431 support.input = input.getAttribute( "value" ) === "";
|
|
3432
|
|
3433 // Check if an input maintains its value after becoming a radio
|
|
3434 input.value = "t";
|
|
3435 input.setAttribute( "type", "radio" );
|
|
3436 support.radioValue = input.value === "t";
|
|
3437
|
|
3438 // #11217 - WebKit loses check when the name is after the checked attribute
|
|
3439 input.setAttribute( "checked", "t" );
|
|
3440 input.setAttribute( "name", "t" );
|
|
3441
|
|
3442 fragment = document.createDocumentFragment();
|
|
3443 fragment.appendChild( input );
|
|
3444
|
|
3445 // Check if a disconnected checkbox will retain its checked
|
|
3446 // value of true after appended to the DOM (IE6/7)
|
|
3447 support.appendChecked = input.checked;
|
|
3448
|
|
3449 // WebKit doesn't clone checked state correctly in fragments
|
|
3450 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
|
|
3451
|
|
3452 // Support: IE<9
|
|
3453 // Opera does not clone events (and typeof div.attachEvent === undefined).
|
|
3454 // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
|
|
3455 if ( div.attachEvent ) {
|
|
3456 div.attachEvent( "onclick", function() {
|
|
3457 support.noCloneEvent = false;
|
|
3458 });
|
|
3459
|
|
3460 div.cloneNode( true ).click();
|
|
3461 }
|
|
3462
|
|
3463 // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
|
|
3464 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
|
|
3465 for ( i in { submit: true, change: true, focusin: true }) {
|
|
3466 div.setAttribute( eventName = "on" + i, "t" );
|
|
3467
|
|
3468 support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false;
|
|
3469 }
|
|
3470
|
|
3471 div.style.backgroundClip = "content-box";
|
|
3472 div.cloneNode( true ).style.backgroundClip = "";
|
|
3473 support.clearCloneStyle = div.style.backgroundClip === "content-box";
|
|
3474
|
|
3475 // Support: IE<9
|
|
3476 // Iteration over object's inherited properties before its own.
|
|
3477 for ( i in jQuery( support ) ) {
|
|
3478 break;
|
|
3479 }
|
|
3480 support.ownLast = i !== "0";
|
|
3481
|
|
3482 // Run tests that need a body at doc ready
|
|
3483 jQuery(function() {
|
|
3484 var container, marginDiv, tds,
|
|
3485 divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",
|
|
3486 body = document.getElementsByTagName("body")[0];
|
|
3487
|
|
3488 if ( !body ) {
|
|
3489 // Return for frameset docs that don't have a body
|
|
3490 return;
|
|
3491 }
|
|
3492
|
|
3493 container = document.createElement("div");
|
|
3494 container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
|
|
3495
|
|
3496 body.appendChild( container ).appendChild( div );
|
|
3497
|
|
3498 // Support: IE8
|
|
3499 // Check if table cells still have offsetWidth/Height when they are set
|
|
3500 // to display:none and there are still other visible table cells in a
|
|
3501 // table row; if so, offsetWidth/Height are not reliable for use when
|
|
3502 // determining if an element has been hidden directly using
|
|
3503 // display:none (it is still safe to use offsets if a parent element is
|
|
3504 // hidden; don safety goggles and see bug #4512 for more information).
|
|
3505 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
|
|
3506 tds = div.getElementsByTagName("td");
|
|
3507 tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
|
|
3508 isSupported = ( tds[ 0 ].offsetHeight === 0 );
|
|
3509
|
|
3510 tds[ 0 ].style.display = "";
|
|
3511 tds[ 1 ].style.display = "none";
|
|
3512
|
|
3513 // Support: IE8
|
|
3514 // Check if empty table cells still have offsetWidth/Height
|
|
3515 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
|
|
3516
|
|
3517 // Check box-sizing and margin behavior.
|
|
3518 div.innerHTML = "";
|
|
3519 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%;";
|
|
3520
|
|
3521 // Workaround failing boxSizing test due to offsetWidth returning wrong value
|
|
3522 // with some non-1 values of body zoom, ticket #13543
|
|
3523 jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() {
|
|
3524 support.boxSizing = div.offsetWidth === 4;
|
|
3525 });
|
|
3526
|
|
3527 // Use window.getComputedStyle because jsdom on node.js will break without it.
|
|
3528 if ( window.getComputedStyle ) {
|
|
3529 support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
|
|
3530 support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
|
|
3531
|
|
3532 // Check if div with explicit width and no margin-right incorrectly
|
|
3533 // gets computed margin-right based on width of container. (#3333)
|
|
3534 // Fails in WebKit before Feb 2011 nightlies
|
|
3535 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
|
3536 marginDiv = div.appendChild( document.createElement("div") );
|
|
3537 marginDiv.style.cssText = div.style.cssText = divReset;
|
|
3538 marginDiv.style.marginRight = marginDiv.style.width = "0";
|
|
3539 div.style.width = "1px";
|
|
3540
|
|
3541 support.reliableMarginRight =
|
|
3542 !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
|
|
3543 }
|
|
3544
|
|
3545 if ( typeof div.style.zoom !== core_strundefined ) {
|
|
3546 // Support: IE<8
|
|
3547 // Check if natively block-level elements act like inline-block
|
|
3548 // elements when setting their display to 'inline' and giving
|
|
3549 // them layout
|
|
3550 div.innerHTML = "";
|
|
3551 div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
|
|
3552 support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
|
|
3553
|
|
3554 // Support: IE6
|
|
3555 // Check if elements with layout shrink-wrap their children
|
|
3556 div.style.display = "block";
|
|
3557 div.innerHTML = "<div></div>";
|
|
3558 div.firstChild.style.width = "5px";
|
|
3559 support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
|
|
3560
|
|
3561 if ( support.inlineBlockNeedsLayout ) {
|
|
3562 // Prevent IE 6 from affecting layout for positioned elements #11048
|
|
3563 // Prevent IE from shrinking the body in IE 7 mode #12869
|
|
3564 // Support: IE<8
|
|
3565 body.style.zoom = 1;
|
|
3566 }
|
|
3567 }
|
|
3568
|
|
3569 body.removeChild( container );
|
|
3570
|
|
3571 // Null elements to avoid leaks in IE
|
|
3572 container = div = tds = marginDiv = null;
|
|
3573 });
|
|
3574
|
|
3575 // Null elements to avoid leaks in IE
|
|
3576 all = select = fragment = opt = a = input = null;
|
|
3577
|
|
3578 return support;
|
|
3579 })({});
|
|
3580
|
|
3581 var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
|
|
3582 rmultiDash = /([A-Z])/g;
|
|
3583
|
|
3584 function internalData( elem, name, data, pvt /* Internal Use Only */ ){
|
|
3585 if ( !jQuery.acceptData( elem ) ) {
|
|
3586 return;
|
|
3587 }
|
|
3588
|
|
3589 var ret, thisCache,
|
|
3590 internalKey = jQuery.expando,
|
|
3591
|
|
3592 // We have to handle DOM nodes and JS objects differently because IE6-7
|
|
3593 // can't GC object references properly across the DOM-JS boundary
|
|
3594 isNode = elem.nodeType,
|
|
3595
|
|
3596 // Only DOM nodes need the global jQuery cache; JS object data is
|
|
3597 // attached directly to the object so GC can occur automatically
|
|
3598 cache = isNode ? jQuery.cache : elem,
|
|
3599
|
|
3600 // Only defining an ID for JS objects if its cache already exists allows
|
|
3601 // the code to shortcut on the same path as a DOM node with no cache
|
|
3602 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
|
|
3603
|
|
3604 // Avoid doing any more work than we need to when trying to get data on an
|
|
3605 // object that has no data at all
|
|
3606 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
|
|
3607 return;
|
|
3608 }
|
|
3609
|
|
3610 if ( !id ) {
|
|
3611 // Only DOM nodes need a new unique ID for each element since their data
|
|
3612 // ends up in the global cache
|
|
3613 if ( isNode ) {
|
|
3614 id = elem[ internalKey ] = core_deletedIds.pop() || jQuery.guid++;
|
|
3615 } else {
|
|
3616 id = internalKey;
|
|
3617 }
|
|
3618 }
|
|
3619
|
|
3620 if ( !cache[ id ] ) {
|
|
3621 // Avoid exposing jQuery metadata on plain JS objects when the object
|
|
3622 // is serialized using JSON.stringify
|
|
3623 cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
|
|
3624 }
|
|
3625
|
|
3626 // An object can be passed to jQuery.data instead of a key/value pair; this gets
|
|
3627 // shallow copied over onto the existing cache
|
|
3628 if ( typeof name === "object" || typeof name === "function" ) {
|
|
3629 if ( pvt ) {
|
|
3630 cache[ id ] = jQuery.extend( cache[ id ], name );
|
|
3631 } else {
|
|
3632 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
|
|
3633 }
|
|
3634 }
|
|
3635
|
|
3636 thisCache = cache[ id ];
|
|
3637
|
|
3638 // jQuery data() is stored in a separate object inside the object's internal data
|
|
3639 // cache in order to avoid key collisions between internal data and user-defined
|
|
3640 // data.
|
|
3641 if ( !pvt ) {
|
|
3642 if ( !thisCache.data ) {
|
|
3643 thisCache.data = {};
|
|
3644 }
|
|
3645
|
|
3646 thisCache = thisCache.data;
|
|
3647 }
|
|
3648
|
|
3649 if ( data !== undefined ) {
|
|
3650 thisCache[ jQuery.camelCase( name ) ] = data;
|
|
3651 }
|
|
3652
|
|
3653 // Check for both converted-to-camel and non-converted data property names
|
|
3654 // If a data property was specified
|
|
3655 if ( typeof name === "string" ) {
|
|
3656
|
|
3657 // First Try to find as-is property data
|
|
3658 ret = thisCache[ name ];
|
|
3659
|
|
3660 // Test for null|undefined property data
|
|
3661 if ( ret == null ) {
|
|
3662
|
|
3663 // Try to find the camelCased property
|
|
3664 ret = thisCache[ jQuery.camelCase( name ) ];
|
|
3665 }
|
|
3666 } else {
|
|
3667 ret = thisCache;
|
|
3668 }
|
|
3669
|
|
3670 return ret;
|
|
3671 }
|
|
3672
|
|
3673 function internalRemoveData( elem, name, pvt ) {
|
|
3674 if ( !jQuery.acceptData( elem ) ) {
|
|
3675 return;
|
|
3676 }
|
|
3677
|
|
3678 var thisCache, i,
|
|
3679 isNode = elem.nodeType,
|
|
3680
|
|
3681 // See jQuery.data for more information
|
|
3682 cache = isNode ? jQuery.cache : elem,
|
|
3683 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
|
|
3684
|
|
3685 // If there is already no cache entry for this object, there is no
|
|
3686 // purpose in continuing
|
|
3687 if ( !cache[ id ] ) {
|
|
3688 return;
|
|
3689 }
|
|
3690
|
|
3691 if ( name ) {
|
|
3692
|
|
3693 thisCache = pvt ? cache[ id ] : cache[ id ].data;
|
|
3694
|
|
3695 if ( thisCache ) {
|
|
3696
|
|
3697 // Support array or space separated string names for data keys
|
|
3698 if ( !jQuery.isArray( name ) ) {
|
|
3699
|
|
3700 // try the string as a key before any manipulation
|
|
3701 if ( name in thisCache ) {
|
|
3702 name = [ name ];
|
|
3703 } else {
|
|
3704
|
|
3705 // split the camel cased version by spaces unless a key with the spaces exists
|
|
3706 name = jQuery.camelCase( name );
|
|
3707 if ( name in thisCache ) {
|
|
3708 name = [ name ];
|
|
3709 } else {
|
|
3710 name = name.split(" ");
|
|
3711 }
|
|
3712 }
|
|
3713 } else {
|
|
3714 // If "name" is an array of keys...
|
|
3715 // When data is initially created, via ("key", "val") signature,
|
|
3716 // keys will be converted to camelCase.
|
|
3717 // Since there is no way to tell _how_ a key was added, remove
|
|
3718 // both plain key and camelCase key. #12786
|
|
3719 // This will only penalize the array argument path.
|
|
3720 name = name.concat( jQuery.map( name, jQuery.camelCase ) );
|
|
3721 }
|
|
3722
|
|
3723 i = name.length;
|
|
3724 while ( i-- ) {
|
|
3725 delete thisCache[ name[i] ];
|
|
3726 }
|
|
3727
|
|
3728 // If there is no data left in the cache, we want to continue
|
|
3729 // and let the cache object itself get destroyed
|
|
3730 if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
|
|
3731 return;
|
|
3732 }
|
|
3733 }
|
|
3734 }
|
|
3735
|
|
3736 // See jQuery.data for more information
|
|
3737 if ( !pvt ) {
|
|
3738 delete cache[ id ].data;
|
|
3739
|
|
3740 // Don't destroy the parent cache unless the internal data object
|
|
3741 // had been the only thing left in it
|
|
3742 if ( !isEmptyDataObject( cache[ id ] ) ) {
|
|
3743 return;
|
|
3744 }
|
|
3745 }
|
|
3746
|
|
3747 // Destroy the cache
|
|
3748 if ( isNode ) {
|
|
3749 jQuery.cleanData( [ elem ], true );
|
|
3750
|
|
3751 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
|
|
3752 /* jshint eqeqeq: false */
|
|
3753 } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
|
|
3754 /* jshint eqeqeq: true */
|
|
3755 delete cache[ id ];
|
|
3756
|
|
3757 // When all else fails, null
|
|
3758 } else {
|
|
3759 cache[ id ] = null;
|
|
3760 }
|
|
3761 }
|
|
3762
|
|
3763 jQuery.extend({
|
|
3764 cache: {},
|
|
3765
|
|
3766 // The following elements throw uncatchable exceptions if you
|
|
3767 // attempt to add expando properties to them.
|
|
3768 noData: {
|
|
3769 "applet": true,
|
|
3770 "embed": true,
|
|
3771 // Ban all objects except for Flash (which handle expandos)
|
|
3772 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
|
|
3773 },
|
|
3774
|
|
3775 hasData: function( elem ) {
|
|
3776 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
|
|
3777 return !!elem && !isEmptyDataObject( elem );
|
|
3778 },
|
|
3779
|
|
3780 data: function( elem, name, data ) {
|
|
3781 return internalData( elem, name, data );
|
|
3782 },
|
|
3783
|
|
3784 removeData: function( elem, name ) {
|
|
3785 return internalRemoveData( elem, name );
|
|
3786 },
|
|
3787
|
|
3788 // For internal use only.
|
|
3789 _data: function( elem, name, data ) {
|
|
3790 return internalData( elem, name, data, true );
|
|
3791 },
|
|
3792
|
|
3793 _removeData: function( elem, name ) {
|
|
3794 return internalRemoveData( elem, name, true );
|
|
3795 },
|
|
3796
|
|
3797 // A method for determining if a DOM node can handle the data expando
|
|
3798 acceptData: function( elem ) {
|
|
3799 // Do not set data on non-element because it will not be cleared (#8335).
|
|
3800 if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) {
|
|
3801 return false;
|
|
3802 }
|
|
3803
|
|
3804 var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
|
|
3805
|
|
3806 // nodes accept data unless otherwise specified; rejection can be conditional
|
|
3807 return !noData || noData !== true && elem.getAttribute("classid") === noData;
|
|
3808 }
|
|
3809 });
|
|
3810
|
|
3811 jQuery.fn.extend({
|
|
3812 data: function( key, value ) {
|
|
3813 var attrs, name,
|
|
3814 data = null,
|
|
3815 i = 0,
|
|
3816 elem = this[0];
|
|
3817
|
|
3818 // Special expections of .data basically thwart jQuery.access,
|
|
3819 // so implement the relevant behavior ourselves
|
|
3820
|
|
3821 // Gets all values
|
|
3822 if ( key === undefined ) {
|
|
3823 if ( this.length ) {
|
|
3824 data = jQuery.data( elem );
|
|
3825
|
|
3826 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
|
|
3827 attrs = elem.attributes;
|
|
3828 for ( ; i < attrs.length; i++ ) {
|
|
3829 name = attrs[i].name;
|
|
3830
|
|
3831 if ( name.indexOf("data-") === 0 ) {
|
|
3832 name = jQuery.camelCase( name.slice(5) );
|
|
3833
|
|
3834 dataAttr( elem, name, data[ name ] );
|
|
3835 }
|
|
3836 }
|
|
3837 jQuery._data( elem, "parsedAttrs", true );
|
|
3838 }
|
|
3839 }
|
|
3840
|
|
3841 return data;
|
|
3842 }
|
|
3843
|
|
3844 // Sets multiple values
|
|
3845 if ( typeof key === "object" ) {
|
|
3846 return this.each(function() {
|
|
3847 jQuery.data( this, key );
|
|
3848 });
|
|
3849 }
|
|
3850
|
|
3851 return arguments.length > 1 ?
|
|
3852
|
|
3853 // Sets one value
|
|
3854 this.each(function() {
|
|
3855 jQuery.data( this, key, value );
|
|
3856 }) :
|
|
3857
|
|
3858 // Gets one value
|
|
3859 // Try to fetch any internally stored data first
|
|
3860 elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null;
|
|
3861 },
|
|
3862
|
|
3863 removeData: function( key ) {
|
|
3864 return this.each(function() {
|
|
3865 jQuery.removeData( this, key );
|
|
3866 });
|
|
3867 }
|
|
3868 });
|
|
3869
|
|
3870 function dataAttr( elem, key, data ) {
|
|
3871 // If nothing was found internally, try to fetch any
|
|
3872 // data from the HTML5 data-* attribute
|
|
3873 if ( data === undefined && elem.nodeType === 1 ) {
|
|
3874
|
|
3875 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
|
|
3876
|
|
3877 data = elem.getAttribute( name );
|
|
3878
|
|
3879 if ( typeof data === "string" ) {
|
|
3880 try {
|
|
3881 data = data === "true" ? true :
|
|
3882 data === "false" ? false :
|
|
3883 data === "null" ? null :
|
|
3884 // Only convert to a number if it doesn't change the string
|
|
3885 +data + "" === data ? +data :
|
|
3886 rbrace.test( data ) ? jQuery.parseJSON( data ) :
|
|
3887 data;
|
|
3888 } catch( e ) {}
|
|
3889
|
|
3890 // Make sure we set the data so it isn't changed later
|
|
3891 jQuery.data( elem, key, data );
|
|
3892
|
|
3893 } else {
|
|
3894 data = undefined;
|
|
3895 }
|
|
3896 }
|
|
3897
|
|
3898 return data;
|
|
3899 }
|
|
3900
|
|
3901 // checks a cache object for emptiness
|
|
3902 function isEmptyDataObject( obj ) {
|
|
3903 var name;
|
|
3904 for ( name in obj ) {
|
|
3905
|
|
3906 // if the public data object is empty, the private is still empty
|
|
3907 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
|
|
3908 continue;
|
|
3909 }
|
|
3910 if ( name !== "toJSON" ) {
|
|
3911 return false;
|
|
3912 }
|
|
3913 }
|
|
3914
|
|
3915 return true;
|
|
3916 }
|
|
3917 jQuery.extend({
|
|
3918 queue: function( elem, type, data ) {
|
|
3919 var queue;
|
|
3920
|
|
3921 if ( elem ) {
|
|
3922 type = ( type || "fx" ) + "queue";
|
|
3923 queue = jQuery._data( elem, type );
|
|
3924
|
|
3925 // Speed up dequeue by getting out quickly if this is just a lookup
|
|
3926 if ( data ) {
|
|
3927 if ( !queue || jQuery.isArray(data) ) {
|
|
3928 queue = jQuery._data( elem, type, jQuery.makeArray(data) );
|
|
3929 } else {
|
|
3930 queue.push( data );
|
|
3931 }
|
|
3932 }
|
|
3933 return queue || [];
|
|
3934 }
|
|
3935 },
|
|
3936
|
|
3937 dequeue: function( elem, type ) {
|
|
3938 type = type || "fx";
|
|
3939
|
|
3940 var queue = jQuery.queue( elem, type ),
|
|
3941 startLength = queue.length,
|
|
3942 fn = queue.shift(),
|
|
3943 hooks = jQuery._queueHooks( elem, type ),
|
|
3944 next = function() {
|
|
3945 jQuery.dequeue( elem, type );
|
|
3946 };
|
|
3947
|
|
3948 // If the fx queue is dequeued, always remove the progress sentinel
|
|
3949 if ( fn === "inprogress" ) {
|
|
3950 fn = queue.shift();
|
|
3951 startLength--;
|
|
3952 }
|
|
3953
|
|
3954 hooks.cur = fn;
|
|
3955 if ( fn ) {
|
|
3956
|
|
3957 // Add a progress sentinel to prevent the fx queue from being
|
|
3958 // automatically dequeued
|
|
3959 if ( type === "fx" ) {
|
|
3960 queue.unshift( "inprogress" );
|
|
3961 }
|
|
3962
|
|
3963 // clear up the last queue stop function
|
|
3964 delete hooks.stop;
|
|
3965 fn.call( elem, next, hooks );
|
|
3966 }
|
|
3967
|
|
3968 if ( !startLength && hooks ) {
|
|
3969 hooks.empty.fire();
|
|
3970 }
|
|
3971 },
|
|
3972
|
|
3973 // not intended for public consumption - generates a queueHooks object, or returns the current one
|
|
3974 _queueHooks: function( elem, type ) {
|
|
3975 var key = type + "queueHooks";
|
|
3976 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
|
|
3977 empty: jQuery.Callbacks("once memory").add(function() {
|
|
3978 jQuery._removeData( elem, type + "queue" );
|
|
3979 jQuery._removeData( elem, key );
|
|
3980 })
|
|
3981 });
|
|
3982 }
|
|
3983 });
|
|
3984
|
|
3985 jQuery.fn.extend({
|
|
3986 queue: function( type, data ) {
|
|
3987 var setter = 2;
|
|
3988
|
|
3989 if ( typeof type !== "string" ) {
|
|
3990 data = type;
|
|
3991 type = "fx";
|
|
3992 setter--;
|
|
3993 }
|
|
3994
|
|
3995 if ( arguments.length < setter ) {
|
|
3996 return jQuery.queue( this[0], type );
|
|
3997 }
|
|
3998
|
|
3999 return data === undefined ?
|
|
4000 this :
|
|
4001 this.each(function() {
|
|
4002 var queue = jQuery.queue( this, type, data );
|
|
4003
|
|
4004 // ensure a hooks for this queue
|
|
4005 jQuery._queueHooks( this, type );
|
|
4006
|
|
4007 if ( type === "fx" && queue[0] !== "inprogress" ) {
|
|
4008 jQuery.dequeue( this, type );
|
|
4009 }
|
|
4010 });
|
|
4011 },
|
|
4012 dequeue: function( type ) {
|
|
4013 return this.each(function() {
|
|
4014 jQuery.dequeue( this, type );
|
|
4015 });
|
|
4016 },
|
|
4017 // Based off of the plugin by Clint Helfers, with permission.
|
|
4018 // http://blindsignals.com/index.php/2009/07/jquery-delay/
|
|
4019 delay: function( time, type ) {
|
|
4020 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
|
|
4021 type = type || "fx";
|
|
4022
|
|
4023 return this.queue( type, function( next, hooks ) {
|
|
4024 var timeout = setTimeout( next, time );
|
|
4025 hooks.stop = function() {
|
|
4026 clearTimeout( timeout );
|
|
4027 };
|
|
4028 });
|
|
4029 },
|
|
4030 clearQueue: function( type ) {
|
|
4031 return this.queue( type || "fx", [] );
|
|
4032 },
|
|
4033 // Get a promise resolved when queues of a certain type
|
|
4034 // are emptied (fx is the type by default)
|
|
4035 promise: function( type, obj ) {
|
|
4036 var tmp,
|
|
4037 count = 1,
|
|
4038 defer = jQuery.Deferred(),
|
|
4039 elements = this,
|
|
4040 i = this.length,
|
|
4041 resolve = function() {
|
|
4042 if ( !( --count ) ) {
|
|
4043 defer.resolveWith( elements, [ elements ] );
|
|
4044 }
|
|
4045 };
|
|
4046
|
|
4047 if ( typeof type !== "string" ) {
|
|
4048 obj = type;
|
|
4049 type = undefined;
|
|
4050 }
|
|
4051 type = type || "fx";
|
|
4052
|
|
4053 while( i-- ) {
|
|
4054 tmp = jQuery._data( elements[ i ], type + "queueHooks" );
|
|
4055 if ( tmp && tmp.empty ) {
|
|
4056 count++;
|
|
4057 tmp.empty.add( resolve );
|
|
4058 }
|
|
4059 }
|
|
4060 resolve();
|
|
4061 return defer.promise( obj );
|
|
4062 }
|
|
4063 });
|
|
4064 var nodeHook, boolHook,
|
|
4065 rclass = /[\t\r\n\f]/g,
|
|
4066 rreturn = /\r/g,
|
|
4067 rfocusable = /^(?:input|select|textarea|button|object)$/i,
|
|
4068 rclickable = /^(?:a|area)$/i,
|
|
4069 ruseDefault = /^(?:checked|selected)$/i,
|
|
4070 getSetAttribute = jQuery.support.getSetAttribute,
|
|
4071 getSetInput = jQuery.support.input;
|
|
4072
|
|
4073 jQuery.fn.extend({
|
|
4074 attr: function( name, value ) {
|
|
4075 return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
|
|
4076 },
|
|
4077
|
|
4078 removeAttr: function( name ) {
|
|
4079 return this.each(function() {
|
|
4080 jQuery.removeAttr( this, name );
|
|
4081 });
|
|
4082 },
|
|
4083
|
|
4084 prop: function( name, value ) {
|
|
4085 return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
|
|
4086 },
|
|
4087
|
|
4088 removeProp: function( name ) {
|
|
4089 name = jQuery.propFix[ name ] || name;
|
|
4090 return this.each(function() {
|
|
4091 // try/catch handles cases where IE balks (such as removing a property on window)
|
|
4092 try {
|
|
4093 this[ name ] = undefined;
|
|
4094 delete this[ name ];
|
|
4095 } catch( e ) {}
|
|
4096 });
|
|
4097 },
|
|
4098
|
|
4099 addClass: function( value ) {
|
|
4100 var classes, elem, cur, clazz, j,
|
|
4101 i = 0,
|
|
4102 len = this.length,
|
|
4103 proceed = typeof value === "string" && value;
|
|
4104
|
|
4105 if ( jQuery.isFunction( value ) ) {
|
|
4106 return this.each(function( j ) {
|
|
4107 jQuery( this ).addClass( value.call( this, j, this.className ) );
|
|
4108 });
|
|
4109 }
|
|
4110
|
|
4111 if ( proceed ) {
|
|
4112 // The disjunction here is for better compressibility (see removeClass)
|
|
4113 classes = ( value || "" ).match( core_rnotwhite ) || [];
|
|
4114
|
|
4115 for ( ; i < len; i++ ) {
|
|
4116 elem = this[ i ];
|
|
4117 cur = elem.nodeType === 1 && ( elem.className ?
|
|
4118 ( " " + elem.className + " " ).replace( rclass, " " ) :
|
|
4119 " "
|
|
4120 );
|
|
4121
|
|
4122 if ( cur ) {
|
|
4123 j = 0;
|
|
4124 while ( (clazz = classes[j++]) ) {
|
|
4125 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
|
|
4126 cur += clazz + " ";
|
|
4127 }
|
|
4128 }
|
|
4129 elem.className = jQuery.trim( cur );
|
|
4130
|
|
4131 }
|
|
4132 }
|
|
4133 }
|
|
4134
|
|
4135 return this;
|
|
4136 },
|
|
4137
|
|
4138 removeClass: function( value ) {
|
|
4139 var classes, elem, cur, clazz, j,
|
|
4140 i = 0,
|
|
4141 len = this.length,
|
|
4142 proceed = arguments.length === 0 || typeof value === "string" && value;
|
|
4143
|
|
4144 if ( jQuery.isFunction( value ) ) {
|
|
4145 return this.each(function( j ) {
|
|
4146 jQuery( this ).removeClass( value.call( this, j, this.className ) );
|
|
4147 });
|
|
4148 }
|
|
4149 if ( proceed ) {
|
|
4150 classes = ( value || "" ).match( core_rnotwhite ) || [];
|
|
4151
|
|
4152 for ( ; i < len; i++ ) {
|
|
4153 elem = this[ i ];
|
|
4154 // This expression is here for better compressibility (see addClass)
|
|
4155 cur = elem.nodeType === 1 && ( elem.className ?
|
|
4156 ( " " + elem.className + " " ).replace( rclass, " " ) :
|
|
4157 ""
|
|
4158 );
|
|
4159
|
|
4160 if ( cur ) {
|
|
4161 j = 0;
|
|
4162 while ( (clazz = classes[j++]) ) {
|
|
4163 // Remove *all* instances
|
|
4164 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
|
|
4165 cur = cur.replace( " " + clazz + " ", " " );
|
|
4166 }
|
|
4167 }
|
|
4168 elem.className = value ? jQuery.trim( cur ) : "";
|
|
4169 }
|
|
4170 }
|
|
4171 }
|
|
4172
|
|
4173 return this;
|
|
4174 },
|
|
4175
|
|
4176 toggleClass: function( value, stateVal ) {
|
|
4177 var type = typeof value,
|
|
4178 isBool = typeof stateVal === "boolean";
|
|
4179
|
|
4180 if ( jQuery.isFunction( value ) ) {
|
|
4181 return this.each(function( i ) {
|
|
4182 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
|
|
4183 });
|
|
4184 }
|
|
4185
|
|
4186 return this.each(function() {
|
|
4187 if ( type === "string" ) {
|
|
4188 // toggle individual class names
|
|
4189 var className,
|
|
4190 i = 0,
|
|
4191 self = jQuery( this ),
|
|
4192 state = stateVal,
|
|
4193 classNames = value.match( core_rnotwhite ) || [];
|
|
4194
|
|
4195 while ( (className = classNames[ i++ ]) ) {
|
|
4196 // check each className given, space separated list
|
|
4197 state = isBool ? state : !self.hasClass( className );
|
|
4198 self[ state ? "addClass" : "removeClass" ]( className );
|
|
4199 }
|
|
4200
|
|
4201 // Toggle whole class name
|
|
4202 } else if ( type === core_strundefined || type === "boolean" ) {
|
|
4203 if ( this.className ) {
|
|
4204 // store className if set
|
|
4205 jQuery._data( this, "__className__", this.className );
|
|
4206 }
|
|
4207
|
|
4208 // If the element has a class name or if we're passed "false",
|
|
4209 // then remove the whole classname (if there was one, the above saved it).
|
|
4210 // Otherwise bring back whatever was previously saved (if anything),
|
|
4211 // falling back to the empty string if nothing was stored.
|
|
4212 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
|
|
4213 }
|
|
4214 });
|
|
4215 },
|
|
4216
|
|
4217 hasClass: function( selector ) {
|
|
4218 var className = " " + selector + " ",
|
|
4219 i = 0,
|
|
4220 l = this.length;
|
|
4221 for ( ; i < l; i++ ) {
|
|
4222 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
|
|
4223 return true;
|
|
4224 }
|
|
4225 }
|
|
4226
|
|
4227 return false;
|
|
4228 },
|
|
4229
|
|
4230 val: function( value ) {
|
|
4231 var ret, hooks, isFunction,
|
|
4232 elem = this[0];
|
|
4233
|
|
4234 if ( !arguments.length ) {
|
|
4235 if ( elem ) {
|
|
4236 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
|
|
4237
|
|
4238 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
|
|
4239 return ret;
|
|
4240 }
|
|
4241
|
|
4242 ret = elem.value;
|
|
4243
|
|
4244 return typeof ret === "string" ?
|
|
4245 // handle most common string cases
|
|
4246 ret.replace(rreturn, "") :
|
|
4247 // handle cases where value is null/undef or number
|
|
4248 ret == null ? "" : ret;
|
|
4249 }
|
|
4250
|
|
4251 return;
|
|
4252 }
|
|
4253
|
|
4254 isFunction = jQuery.isFunction( value );
|
|
4255
|
|
4256 return this.each(function( i ) {
|
|
4257 var val;
|
|
4258
|
|
4259 if ( this.nodeType !== 1 ) {
|
|
4260 return;
|
|
4261 }
|
|
4262
|
|
4263 if ( isFunction ) {
|
|
4264 val = value.call( this, i, jQuery( this ).val() );
|
|
4265 } else {
|
|
4266 val = value;
|
|
4267 }
|
|
4268
|
|
4269 // Treat null/undefined as ""; convert numbers to string
|
|
4270 if ( val == null ) {
|
|
4271 val = "";
|
|
4272 } else if ( typeof val === "number" ) {
|
|
4273 val += "";
|
|
4274 } else if ( jQuery.isArray( val ) ) {
|
|
4275 val = jQuery.map(val, function ( value ) {
|
|
4276 return value == null ? "" : value + "";
|
|
4277 });
|
|
4278 }
|
|
4279
|
|
4280 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
|
|
4281
|
|
4282 // If set returns undefined, fall back to normal setting
|
|
4283 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
|
|
4284 this.value = val;
|
|
4285 }
|
|
4286 });
|
|
4287 }
|
|
4288 });
|
|
4289
|
|
4290 jQuery.extend({
|
|
4291 valHooks: {
|
|
4292 option: {
|
|
4293 get: function( elem ) {
|
|
4294 // Use proper attribute retrieval(#6932, #12072)
|
|
4295 var val = jQuery.find.attr( elem, "value" );
|
|
4296 return val != null ?
|
|
4297 val :
|
|
4298 elem.text;
|
|
4299 }
|
|
4300 },
|
|
4301 select: {
|
|
4302 get: function( elem ) {
|
|
4303 var value, option,
|
|
4304 options = elem.options,
|
|
4305 index = elem.selectedIndex,
|
|
4306 one = elem.type === "select-one" || index < 0,
|
|
4307 values = one ? null : [],
|
|
4308 max = one ? index + 1 : options.length,
|
|
4309 i = index < 0 ?
|
|
4310 max :
|
|
4311 one ? index : 0;
|
|
4312
|
|
4313 // Loop through all the selected options
|
|
4314 for ( ; i < max; i++ ) {
|
|
4315 option = options[ i ];
|
|
4316
|
|
4317 // oldIE doesn't update selected after form reset (#2551)
|
|
4318 if ( ( option.selected || i === index ) &&
|
|
4319 // Don't return options that are disabled or in a disabled optgroup
|
|
4320 ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
|
|
4321 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
|
|
4322
|
|
4323 // Get the specific value for the option
|
|
4324 value = jQuery( option ).val();
|
|
4325
|
|
4326 // We don't need an array for one selects
|
|
4327 if ( one ) {
|
|
4328 return value;
|
|
4329 }
|
|
4330
|
|
4331 // Multi-Selects return an array
|
|
4332 values.push( value );
|
|
4333 }
|
|
4334 }
|
|
4335
|
|
4336 return values;
|
|
4337 },
|
|
4338
|
|
4339 set: function( elem, value ) {
|
|
4340 var optionSet, option,
|
|
4341 options = elem.options,
|
|
4342 values = jQuery.makeArray( value ),
|
|
4343 i = options.length;
|
|
4344
|
|
4345 while ( i-- ) {
|
|
4346 option = options[ i ];
|
|
4347 if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) {
|
|
4348 optionSet = true;
|
|
4349 }
|
|
4350 }
|
|
4351
|
|
4352 // force browsers to behave consistently when non-matching value is set
|
|
4353 if ( !optionSet ) {
|
|
4354 elem.selectedIndex = -1;
|
|
4355 }
|
|
4356 return values;
|
|
4357 }
|
|
4358 }
|
|
4359 },
|
|
4360
|
|
4361 attr: function( elem, name, value ) {
|
|
4362 var hooks, ret,
|
|
4363 nType = elem.nodeType;
|
|
4364
|
|
4365 // don't get/set attributes on text, comment and attribute nodes
|
|
4366 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
|
4367 return;
|
|
4368 }
|
|
4369
|
|
4370 // Fallback to prop when attributes are not supported
|
|
4371 if ( typeof elem.getAttribute === core_strundefined ) {
|
|
4372 return jQuery.prop( elem, name, value );
|
|
4373 }
|
|
4374
|
|
4375 // All attributes are lowercase
|
|
4376 // Grab necessary hook if one is defined
|
|
4377 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
|
|
4378 name = name.toLowerCase();
|
|
4379 hooks = jQuery.attrHooks[ name ] ||
|
|
4380 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
|
|
4381 }
|
|
4382
|
|
4383 if ( value !== undefined ) {
|
|
4384
|
|
4385 if ( value === null ) {
|
|
4386 jQuery.removeAttr( elem, name );
|
|
4387
|
|
4388 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
|
|
4389 return ret;
|
|
4390
|
|
4391 } else {
|
|
4392 elem.setAttribute( name, value + "" );
|
|
4393 return value;
|
|
4394 }
|
|
4395
|
|
4396 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
|
|
4397 return ret;
|
|
4398
|
|
4399 } else {
|
|
4400 ret = jQuery.find.attr( elem, name );
|
|
4401
|
|
4402 // Non-existent attributes return null, we normalize to undefined
|
|
4403 return ret == null ?
|
|
4404 undefined :
|
|
4405 ret;
|
|
4406 }
|
|
4407 },
|
|
4408
|
|
4409 removeAttr: function( elem, value ) {
|
|
4410 var name, propName,
|
|
4411 i = 0,
|
|
4412 attrNames = value && value.match( core_rnotwhite );
|
|
4413
|
|
4414 if ( attrNames && elem.nodeType === 1 ) {
|
|
4415 while ( (name = attrNames[i++]) ) {
|
|
4416 propName = jQuery.propFix[ name ] || name;
|
|
4417
|
|
4418 // Boolean attributes get special treatment (#10870)
|
|
4419 if ( jQuery.expr.match.bool.test( name ) ) {
|
|
4420 // Set corresponding property to false
|
|
4421 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
|
|
4422 elem[ propName ] = false;
|
|
4423 // Support: IE<9
|
|
4424 // Also clear defaultChecked/defaultSelected (if appropriate)
|
|
4425 } else {
|
|
4426 elem[ jQuery.camelCase( "default-" + name ) ] =
|
|
4427 elem[ propName ] = false;
|
|
4428 }
|
|
4429
|
|
4430 // See #9699 for explanation of this approach (setting first, then removal)
|
|
4431 } else {
|
|
4432 jQuery.attr( elem, name, "" );
|
|
4433 }
|
|
4434
|
|
4435 elem.removeAttribute( getSetAttribute ? name : propName );
|
|
4436 }
|
|
4437 }
|
|
4438 },
|
|
4439
|
|
4440 attrHooks: {
|
|
4441 type: {
|
|
4442 set: function( elem, value ) {
|
|
4443 if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
|
|
4444 // Setting the type on a radio button after the value resets the value in IE6-9
|
|
4445 // Reset value to default in case type is set after value during creation
|
|
4446 var val = elem.value;
|
|
4447 elem.setAttribute( "type", value );
|
|
4448 if ( val ) {
|
|
4449 elem.value = val;
|
|
4450 }
|
|
4451 return value;
|
|
4452 }
|
|
4453 }
|
|
4454 }
|
|
4455 },
|
|
4456
|
|
4457 propFix: {
|
|
4458 "for": "htmlFor",
|
|
4459 "class": "className"
|
|
4460 },
|
|
4461
|
|
4462 prop: function( elem, name, value ) {
|
|
4463 var ret, hooks, notxml,
|
|
4464 nType = elem.nodeType;
|
|
4465
|
|
4466 // don't get/set properties on text, comment and attribute nodes
|
|
4467 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
|
4468 return;
|
|
4469 }
|
|
4470
|
|
4471 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
|
4472
|
|
4473 if ( notxml ) {
|
|
4474 // Fix name and attach hooks
|
|
4475 name = jQuery.propFix[ name ] || name;
|
|
4476 hooks = jQuery.propHooks[ name ];
|
|
4477 }
|
|
4478
|
|
4479 if ( value !== undefined ) {
|
|
4480 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
|
|
4481 ret :
|
|
4482 ( elem[ name ] = value );
|
|
4483
|
|
4484 } else {
|
|
4485 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
|
|
4486 ret :
|
|
4487 elem[ name ];
|
|
4488 }
|
|
4489 },
|
|
4490
|
|
4491 propHooks: {
|
|
4492 tabIndex: {
|
|
4493 get: function( elem ) {
|
|
4494 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
|
4495 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
|
4496 // Use proper attribute retrieval(#12072)
|
|
4497 var tabindex = jQuery.find.attr( elem, "tabindex" );
|
|
4498
|
|
4499 return tabindex ?
|
|
4500 parseInt( tabindex, 10 ) :
|
|
4501 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
|
|
4502 0 :
|
|
4503 -1;
|
|
4504 }
|
|
4505 }
|
|
4506 }
|
|
4507 });
|
|
4508
|
|
4509 // Hooks for boolean attributes
|
|
4510 boolHook = {
|
|
4511 set: function( elem, value, name ) {
|
|
4512 if ( value === false ) {
|
|
4513 // Remove boolean attributes when set to false
|
|
4514 jQuery.removeAttr( elem, name );
|
|
4515 } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
|
|
4516 // IE<8 needs the *property* name
|
|
4517 elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
|
|
4518
|
|
4519 // Use defaultChecked and defaultSelected for oldIE
|
|
4520 } else {
|
|
4521 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
|
|
4522 }
|
|
4523
|
|
4524 return name;
|
|
4525 }
|
|
4526 };
|
|
4527 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
|
|
4528 var getter = jQuery.expr.attrHandle[ name ] || jQuery.find.attr;
|
|
4529
|
|
4530 jQuery.expr.attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
|
|
4531 function( elem, name, isXML ) {
|
|
4532 var fn = jQuery.expr.attrHandle[ name ],
|
|
4533 ret = isXML ?
|
|
4534 undefined :
|
|
4535 /* jshint eqeqeq: false */
|
|
4536 (jQuery.expr.attrHandle[ name ] = undefined) !=
|
|
4537 getter( elem, name, isXML ) ?
|
|
4538
|
|
4539 name.toLowerCase() :
|
|
4540 null;
|
|
4541 jQuery.expr.attrHandle[ name ] = fn;
|
|
4542 return ret;
|
|
4543 } :
|
|
4544 function( elem, name, isXML ) {
|
|
4545 return isXML ?
|
|
4546 undefined :
|
|
4547 elem[ jQuery.camelCase( "default-" + name ) ] ?
|
|
4548 name.toLowerCase() :
|
|
4549 null;
|
|
4550 };
|
|
4551 });
|
|
4552
|
|
4553 // fix oldIE attroperties
|
|
4554 if ( !getSetInput || !getSetAttribute ) {
|
|
4555 jQuery.attrHooks.value = {
|
|
4556 set: function( elem, value, name ) {
|
|
4557 if ( jQuery.nodeName( elem, "input" ) ) {
|
|
4558 // Does not return so that setAttribute is also used
|
|
4559 elem.defaultValue = value;
|
|
4560 } else {
|
|
4561 // Use nodeHook if defined (#1954); otherwise setAttribute is fine
|
|
4562 return nodeHook && nodeHook.set( elem, value, name );
|
|
4563 }
|
|
4564 }
|
|
4565 };
|
|
4566 }
|
|
4567
|
|
4568 // IE6/7 do not support getting/setting some attributes with get/setAttribute
|
|
4569 if ( !getSetAttribute ) {
|
|
4570
|
|
4571 // Use this for any attribute in IE6/7
|
|
4572 // This fixes almost every IE6/7 issue
|
|
4573 nodeHook = {
|
|
4574 set: function( elem, value, name ) {
|
|
4575 // Set the existing or create a new attribute node
|
|
4576 var ret = elem.getAttributeNode( name );
|
|
4577 if ( !ret ) {
|
|
4578 elem.setAttributeNode(
|
|
4579 (ret = elem.ownerDocument.createAttribute( name ))
|
|
4580 );
|
|
4581 }
|
|
4582
|
|
4583 ret.value = value += "";
|
|
4584
|
|
4585 // Break association with cloned elements by also using setAttribute (#9646)
|
|
4586 return name === "value" || value === elem.getAttribute( name ) ?
|
|
4587 value :
|
|
4588 undefined;
|
|
4589 }
|
|
4590 };
|
|
4591 jQuery.expr.attrHandle.id = jQuery.expr.attrHandle.name = jQuery.expr.attrHandle.coords =
|
|
4592 // Some attributes are constructed with empty-string values when not defined
|
|
4593 function( elem, name, isXML ) {
|
|
4594 var ret;
|
|
4595 return isXML ?
|
|
4596 undefined :
|
|
4597 (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
|
|
4598 ret.value :
|
|
4599 null;
|
|
4600 };
|
|
4601 jQuery.valHooks.button = {
|
|
4602 get: function( elem, name ) {
|
|
4603 var ret = elem.getAttributeNode( name );
|
|
4604 return ret && ret.specified ?
|
|
4605 ret.value :
|
|
4606 undefined;
|
|
4607 },
|
|
4608 set: nodeHook.set
|
|
4609 };
|
|
4610
|
|
4611 // Set contenteditable to false on removals(#10429)
|
|
4612 // Setting to empty string throws an error as an invalid value
|
|
4613 jQuery.attrHooks.contenteditable = {
|
|
4614 set: function( elem, value, name ) {
|
|
4615 nodeHook.set( elem, value === "" ? false : value, name );
|
|
4616 }
|
|
4617 };
|
|
4618
|
|
4619 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
|
|
4620 // This is for removals
|
|
4621 jQuery.each([ "width", "height" ], function( i, name ) {
|
|
4622 jQuery.attrHooks[ name ] = {
|
|
4623 set: function( elem, value ) {
|
|
4624 if ( value === "" ) {
|
|
4625 elem.setAttribute( name, "auto" );
|
|
4626 return value;
|
|
4627 }
|
|
4628 }
|
|
4629 };
|
|
4630 });
|
|
4631 }
|
|
4632
|
|
4633
|
|
4634 // Some attributes require a special call on IE
|
|
4635 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
|
|
4636 if ( !jQuery.support.hrefNormalized ) {
|
|
4637 // href/src property should get the full normalized URL (#10299/#12915)
|
|
4638 jQuery.each([ "href", "src" ], function( i, name ) {
|
|
4639 jQuery.propHooks[ name ] = {
|
|
4640 get: function( elem ) {
|
|
4641 return elem.getAttribute( name, 4 );
|
|
4642 }
|
|
4643 };
|
|
4644 });
|
|
4645 }
|
|
4646
|
|
4647 if ( !jQuery.support.style ) {
|
|
4648 jQuery.attrHooks.style = {
|
|
4649 get: function( elem ) {
|
|
4650 // Return undefined in the case of empty string
|
|
4651 // Note: IE uppercases css property names, but if we were to .toLowerCase()
|
|
4652 // .cssText, that would destroy case senstitivity in URL's, like in "background"
|
|
4653 return elem.style.cssText || undefined;
|
|
4654 },
|
|
4655 set: function( elem, value ) {
|
|
4656 return ( elem.style.cssText = value + "" );
|
|
4657 }
|
|
4658 };
|
|
4659 }
|
|
4660
|
|
4661 // Safari mis-reports the default selected property of an option
|
|
4662 // Accessing the parent's selectedIndex property fixes it
|
|
4663 if ( !jQuery.support.optSelected ) {
|
|
4664 jQuery.propHooks.selected = {
|
|
4665 get: function( elem ) {
|
|
4666 var parent = elem.parentNode;
|
|
4667
|
|
4668 if ( parent ) {
|
|
4669 parent.selectedIndex;
|
|
4670
|
|
4671 // Make sure that it also works with optgroups, see #5701
|
|
4672 if ( parent.parentNode ) {
|
|
4673 parent.parentNode.selectedIndex;
|
|
4674 }
|
|
4675 }
|
|
4676 return null;
|
|
4677 }
|
|
4678 };
|
|
4679 }
|
|
4680
|
|
4681 jQuery.each([
|
|
4682 "tabIndex",
|
|
4683 "readOnly",
|
|
4684 "maxLength",
|
|
4685 "cellSpacing",
|
|
4686 "cellPadding",
|
|
4687 "rowSpan",
|
|
4688 "colSpan",
|
|
4689 "useMap",
|
|
4690 "frameBorder",
|
|
4691 "contentEditable"
|
|
4692 ], function() {
|
|
4693 jQuery.propFix[ this.toLowerCase() ] = this;
|
|
4694 });
|
|
4695
|
|
4696 // IE6/7 call enctype encoding
|
|
4697 if ( !jQuery.support.enctype ) {
|
|
4698 jQuery.propFix.enctype = "encoding";
|
|
4699 }
|
|
4700
|
|
4701 // Radios and checkboxes getter/setter
|
|
4702 jQuery.each([ "radio", "checkbox" ], function() {
|
|
4703 jQuery.valHooks[ this ] = {
|
|
4704 set: function( elem, value ) {
|
|
4705 if ( jQuery.isArray( value ) ) {
|
|
4706 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
|
|
4707 }
|
|
4708 }
|
|
4709 };
|
|
4710 if ( !jQuery.support.checkOn ) {
|
|
4711 jQuery.valHooks[ this ].get = function( elem ) {
|
|
4712 // Support: Webkit
|
|
4713 // "" is returned instead of "on" if a value isn't specified
|
|
4714 return elem.getAttribute("value") === null ? "on" : elem.value;
|
|
4715 };
|
|
4716 }
|
|
4717 });
|
|
4718 var rformElems = /^(?:input|select|textarea)$/i,
|
|
4719 rkeyEvent = /^key/,
|
|
4720 rmouseEvent = /^(?:mouse|contextmenu)|click/,
|
|
4721 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
|
|
4722 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
|
|
4723
|
|
4724 function returnTrue() {
|
|
4725 return true;
|
|
4726 }
|
|
4727
|
|
4728 function returnFalse() {
|
|
4729 return false;
|
|
4730 }
|
|
4731
|
|
4732 function safeActiveElement() {
|
|
4733 try {
|
|
4734 return document.activeElement;
|
|
4735 } catch ( err ) { }
|
|
4736 }
|
|
4737
|
|
4738 /*
|
|
4739 * Helper functions for managing events -- not part of the public interface.
|
|
4740 * Props to Dean Edwards' addEvent library for many of the ideas.
|
|
4741 */
|
|
4742 jQuery.event = {
|
|
4743
|
|
4744 global: {},
|
|
4745
|
|
4746 add: function( elem, types, handler, data, selector ) {
|
|
4747 var tmp, events, t, handleObjIn,
|
|
4748 special, eventHandle, handleObj,
|
|
4749 handlers, type, namespaces, origType,
|
|
4750 elemData = jQuery._data( elem );
|
|
4751
|
|
4752 // Don't attach events to noData or text/comment nodes (but allow plain objects)
|
|
4753 if ( !elemData ) {
|
|
4754 return;
|
|
4755 }
|
|
4756
|
|
4757 // Caller can pass in an object of custom data in lieu of the handler
|
|
4758 if ( handler.handler ) {
|
|
4759 handleObjIn = handler;
|
|
4760 handler = handleObjIn.handler;
|
|
4761 selector = handleObjIn.selector;
|
|
4762 }
|
|
4763
|
|
4764 // Make sure that the handler has a unique ID, used to find/remove it later
|
|
4765 if ( !handler.guid ) {
|
|
4766 handler.guid = jQuery.guid++;
|
|
4767 }
|
|
4768
|
|
4769 // Init the element's event structure and main handler, if this is the first
|
|
4770 if ( !(events = elemData.events) ) {
|
|
4771 events = elemData.events = {};
|
|
4772 }
|
|
4773 if ( !(eventHandle = elemData.handle) ) {
|
|
4774 eventHandle = elemData.handle = function( e ) {
|
|
4775 // Discard the second event of a jQuery.event.trigger() and
|
|
4776 // when an event is called after a page has unloaded
|
|
4777 return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?
|
|
4778 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
|
|
4779 undefined;
|
|
4780 };
|
|
4781 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
|
|
4782 eventHandle.elem = elem;
|
|
4783 }
|
|
4784
|
|
4785 // Handle multiple events separated by a space
|
|
4786 types = ( types || "" ).match( core_rnotwhite ) || [""];
|
|
4787 t = types.length;
|
|
4788 while ( t-- ) {
|
|
4789 tmp = rtypenamespace.exec( types[t] ) || [];
|
|
4790 type = origType = tmp[1];
|
|
4791 namespaces = ( tmp[2] || "" ).split( "." ).sort();
|
|
4792
|
|
4793 // There *must* be a type, no attaching namespace-only handlers
|
|
4794 if ( !type ) {
|
|
4795 continue;
|
|
4796 }
|
|
4797
|
|
4798 // If event changes its type, use the special event handlers for the changed type
|
|
4799 special = jQuery.event.special[ type ] || {};
|
|
4800
|
|
4801 // If selector defined, determine special event api type, otherwise given type
|
|
4802 type = ( selector ? special.delegateType : special.bindType ) || type;
|
|
4803
|
|
4804 // Update special based on newly reset type
|
|
4805 special = jQuery.event.special[ type ] || {};
|
|
4806
|
|
4807 // handleObj is passed to all event handlers
|
|
4808 handleObj = jQuery.extend({
|
|
4809 type: type,
|
|
4810 origType: origType,
|
|
4811 data: data,
|
|
4812 handler: handler,
|
|
4813 guid: handler.guid,
|
|
4814 selector: selector,
|
|
4815 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
|
|
4816 namespace: namespaces.join(".")
|
|
4817 }, handleObjIn );
|
|
4818
|
|
4819 // Init the event handler queue if we're the first
|
|
4820 if ( !(handlers = events[ type ]) ) {
|
|
4821 handlers = events[ type ] = [];
|
|
4822 handlers.delegateCount = 0;
|
|
4823
|
|
4824 // Only use addEventListener/attachEvent if the special events handler returns false
|
|
4825 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
|
|
4826 // Bind the global event handler to the element
|
|
4827 if ( elem.addEventListener ) {
|
|
4828 elem.addEventListener( type, eventHandle, false );
|
|
4829
|
|
4830 } else if ( elem.attachEvent ) {
|
|
4831 elem.attachEvent( "on" + type, eventHandle );
|
|
4832 }
|
|
4833 }
|
|
4834 }
|
|
4835
|
|
4836 if ( special.add ) {
|
|
4837 special.add.call( elem, handleObj );
|
|
4838
|
|
4839 if ( !handleObj.handler.guid ) {
|
|
4840 handleObj.handler.guid = handler.guid;
|
|
4841 }
|
|
4842 }
|
|
4843
|
|
4844 // Add to the element's handler list, delegates in front
|
|
4845 if ( selector ) {
|
|
4846 handlers.splice( handlers.delegateCount++, 0, handleObj );
|
|
4847 } else {
|
|
4848 handlers.push( handleObj );
|
|
4849 }
|
|
4850
|
|
4851 // Keep track of which events have ever been used, for event optimization
|
|
4852 jQuery.event.global[ type ] = true;
|
|
4853 }
|
|
4854
|
|
4855 // Nullify elem to prevent memory leaks in IE
|
|
4856 elem = null;
|
|
4857 },
|
|
4858
|
|
4859 // Detach an event or set of events from an element
|
|
4860 remove: function( elem, types, handler, selector, mappedTypes ) {
|
|
4861 var j, handleObj, tmp,
|
|
4862 origCount, t, events,
|
|
4863 special, handlers, type,
|
|
4864 namespaces, origType,
|
|
4865 elemData = jQuery.hasData( elem ) && jQuery._data( elem );
|
|
4866
|
|
4867 if ( !elemData || !(events = elemData.events) ) {
|
|
4868 return;
|
|
4869 }
|
|
4870
|
|
4871 // Once for each type.namespace in types; type may be omitted
|
|
4872 types = ( types || "" ).match( core_rnotwhite ) || [""];
|
|
4873 t = types.length;
|
|
4874 while ( t-- ) {
|
|
4875 tmp = rtypenamespace.exec( types[t] ) || [];
|
|
4876 type = origType = tmp[1];
|
|
4877 namespaces = ( tmp[2] || "" ).split( "." ).sort();
|
|
4878
|
|
4879 // Unbind all events (on this namespace, if provided) for the element
|
|
4880 if ( !type ) {
|
|
4881 for ( type in events ) {
|
|
4882 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
|
|
4883 }
|
|
4884 continue;
|
|
4885 }
|
|
4886
|
|
4887 special = jQuery.event.special[ type ] || {};
|
|
4888 type = ( selector ? special.delegateType : special.bindType ) || type;
|
|
4889 handlers = events[ type ] || [];
|
|
4890 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
|
|
4891
|
|
4892 // Remove matching events
|
|
4893 origCount = j = handlers.length;
|
|
4894 while ( j-- ) {
|
|
4895 handleObj = handlers[ j ];
|
|
4896
|
|
4897 if ( ( mappedTypes || origType === handleObj.origType ) &&
|
|
4898 ( !handler || handler.guid === handleObj.guid ) &&
|
|
4899 ( !tmp || tmp.test( handleObj.namespace ) ) &&
|
|
4900 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
|
|
4901 handlers.splice( j, 1 );
|
|
4902
|
|
4903 if ( handleObj.selector ) {
|
|
4904 handlers.delegateCount--;
|
|
4905 }
|
|
4906 if ( special.remove ) {
|
|
4907 special.remove.call( elem, handleObj );
|
|
4908 }
|
|
4909 }
|
|
4910 }
|
|
4911
|
|
4912 // Remove generic event handler if we removed something and no more handlers exist
|
|
4913 // (avoids potential for endless recursion during removal of special event handlers)
|
|
4914 if ( origCount && !handlers.length ) {
|
|
4915 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
|
|
4916 jQuery.removeEvent( elem, type, elemData.handle );
|
|
4917 }
|
|
4918
|
|
4919 delete events[ type ];
|
|
4920 }
|
|
4921 }
|
|
4922
|
|
4923 // Remove the expando if it's no longer used
|
|
4924 if ( jQuery.isEmptyObject( events ) ) {
|
|
4925 delete elemData.handle;
|
|
4926
|
|
4927 // removeData also checks for emptiness and clears the expando if empty
|
|
4928 // so use it instead of delete
|
|
4929 jQuery._removeData( elem, "events" );
|
|
4930 }
|
|
4931 },
|
|
4932
|
|
4933 trigger: function( event, data, elem, onlyHandlers ) {
|
|
4934 var handle, ontype, cur,
|
|
4935 bubbleType, special, tmp, i,
|
|
4936 eventPath = [ elem || document ],
|
|
4937 type = core_hasOwn.call( event, "type" ) ? event.type : event,
|
|
4938 namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
|
|
4939
|
|
4940 cur = tmp = elem = elem || document;
|
|
4941
|
|
4942 // Don't do events on text and comment nodes
|
|
4943 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
|
|
4944 return;
|
|
4945 }
|
|
4946
|
|
4947 // focus/blur morphs to focusin/out; ensure we're not firing them right now
|
|
4948 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
|
|
4949 return;
|
|
4950 }
|
|
4951
|
|
4952 if ( type.indexOf(".") >= 0 ) {
|
|
4953 // Namespaced trigger; create a regexp to match event type in handle()
|
|
4954 namespaces = type.split(".");
|
|
4955 type = namespaces.shift();
|
|
4956 namespaces.sort();
|
|
4957 }
|
|
4958 ontype = type.indexOf(":") < 0 && "on" + type;
|
|
4959
|
|
4960 // Caller can pass in a jQuery.Event object, Object, or just an event type string
|
|
4961 event = event[ jQuery.expando ] ?
|
|
4962 event :
|
|
4963 new jQuery.Event( type, typeof event === "object" && event );
|
|
4964
|
|
4965 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
|
|
4966 event.isTrigger = onlyHandlers ? 2 : 3;
|
|
4967 event.namespace = namespaces.join(".");
|
|
4968 event.namespace_re = event.namespace ?
|
|
4969 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
|
|
4970 null;
|
|
4971
|
|
4972 // Clean up the event in case it is being reused
|
|
4973 event.result = undefined;
|
|
4974 if ( !event.target ) {
|
|
4975 event.target = elem;
|
|
4976 }
|
|
4977
|
|
4978 // Clone any incoming data and prepend the event, creating the handler arg list
|
|
4979 data = data == null ?
|
|
4980 [ event ] :
|
|
4981 jQuery.makeArray( data, [ event ] );
|
|
4982
|
|
4983 // Allow special events to draw outside the lines
|
|
4984 special = jQuery.event.special[ type ] || {};
|
|
4985 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
|
|
4986 return;
|
|
4987 }
|
|
4988
|
|
4989 // Determine event propagation path in advance, per W3C events spec (#9951)
|
|
4990 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
|
|
4991 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
|
|
4992
|
|
4993 bubbleType = special.delegateType || type;
|
|
4994 if ( !rfocusMorph.test( bubbleType + type ) ) {
|
|
4995 cur = cur.parentNode;
|
|
4996 }
|
|
4997 for ( ; cur; cur = cur.parentNode ) {
|
|
4998 eventPath.push( cur );
|
|
4999 tmp = cur;
|
|
5000 }
|
|
5001
|
|
5002 // Only add window if we got to document (e.g., not plain obj or detached DOM)
|
|
5003 if ( tmp === (elem.ownerDocument || document) ) {
|
|
5004 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
|
|
5005 }
|
|
5006 }
|
|
5007
|
|
5008 // Fire handlers on the event path
|
|
5009 i = 0;
|
|
5010 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
|
|
5011
|
|
5012 event.type = i > 1 ?
|
|
5013 bubbleType :
|
|
5014 special.bindType || type;
|
|
5015
|
|
5016 // jQuery handler
|
|
5017 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
|
|
5018 if ( handle ) {
|
|
5019 handle.apply( cur, data );
|
|
5020 }
|
|
5021
|
|
5022 // Native handler
|
|
5023 handle = ontype && cur[ ontype ];
|
|
5024 if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
|
|
5025 event.preventDefault();
|
|
5026 }
|
|
5027 }
|
|
5028 event.type = type;
|
|
5029
|
|
5030 // If nobody prevented the default action, do it now
|
|
5031 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
|
|
5032
|
|
5033 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
|
|
5034 jQuery.acceptData( elem ) ) {
|
|
5035
|
|
5036 // Call a native DOM method on the target with the same name name as the event.
|
|
5037 // Can't use an .isFunction() check here because IE6/7 fails that test.
|
|
5038 // Don't do default actions on window, that's where global variables be (#6170)
|
|
5039 if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
|
|
5040
|
|
5041 // Don't re-trigger an onFOO event when we call its FOO() method
|
|
5042 tmp = elem[ ontype ];
|
|
5043
|
|
5044 if ( tmp ) {
|
|
5045 elem[ ontype ] = null;
|
|
5046 }
|
|
5047
|
|
5048 // Prevent re-triggering of the same event, since we already bubbled it above
|
|
5049 jQuery.event.triggered = type;
|
|
5050 try {
|
|
5051 elem[ type ]();
|
|
5052 } catch ( e ) {
|
|
5053 // IE<9 dies on focus/blur to hidden element (#1486,#12518)
|
|
5054 // only reproducible on winXP IE8 native, not IE9 in IE8 mode
|
|
5055 }
|
|
5056 jQuery.event.triggered = undefined;
|
|
5057
|
|
5058 if ( tmp ) {
|
|
5059 elem[ ontype ] = tmp;
|
|
5060 }
|
|
5061 }
|
|
5062 }
|
|
5063 }
|
|
5064
|
|
5065 return event.result;
|
|
5066 },
|
|
5067
|
|
5068 dispatch: function( event ) {
|
|
5069
|
|
5070 // Make a writable jQuery.Event from the native event object
|
|
5071 event = jQuery.event.fix( event );
|
|
5072
|
|
5073 var i, ret, handleObj, matched, j,
|
|
5074 handlerQueue = [],
|
|
5075 args = core_slice.call( arguments ),
|
|
5076 handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
|
|
5077 special = jQuery.event.special[ event.type ] || {};
|
|
5078
|
|
5079 // Use the fix-ed jQuery.Event rather than the (read-only) native event
|
|
5080 args[0] = event;
|
|
5081 event.delegateTarget = this;
|
|
5082
|
|
5083 // Call the preDispatch hook for the mapped type, and let it bail if desired
|
|
5084 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
|
|
5085 return;
|
|
5086 }
|
|
5087
|
|
5088 // Determine handlers
|
|
5089 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
|
|
5090
|
|
5091 // Run delegates first; they may want to stop propagation beneath us
|
|
5092 i = 0;
|
|
5093 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
|
|
5094 event.currentTarget = matched.elem;
|
|
5095
|
|
5096 j = 0;
|
|
5097 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
|
|
5098
|
|
5099 // Triggered event must either 1) have no namespace, or
|
|
5100 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
|
|
5101 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
|
|
5102
|
|
5103 event.handleObj = handleObj;
|
|
5104 event.data = handleObj.data;
|
|
5105
|
|
5106 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
|
|
5107 .apply( matched.elem, args );
|
|
5108
|
|
5109 if ( ret !== undefined ) {
|
|
5110 if ( (event.result = ret) === false ) {
|
|
5111 event.preventDefault();
|
|
5112 event.stopPropagation();
|
|
5113 }
|
|
5114 }
|
|
5115 }
|
|
5116 }
|
|
5117 }
|
|
5118
|
|
5119 // Call the postDispatch hook for the mapped type
|
|
5120 if ( special.postDispatch ) {
|
|
5121 special.postDispatch.call( this, event );
|
|
5122 }
|
|
5123
|
|
5124 return event.result;
|
|
5125 },
|
|
5126
|
|
5127 handlers: function( event, handlers ) {
|
|
5128 var sel, handleObj, matches, i,
|
|
5129 handlerQueue = [],
|
|
5130 delegateCount = handlers.delegateCount,
|
|
5131 cur = event.target;
|
|
5132
|
|
5133 // Find delegate handlers
|
|
5134 // Black-hole SVG <use> instance trees (#13180)
|
|
5135 // Avoid non-left-click bubbling in Firefox (#3861)
|
|
5136 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
|
|
5137
|
|
5138 /* jshint eqeqeq: false */
|
|
5139 for ( ; cur != this; cur = cur.parentNode || this ) {
|
|
5140 /* jshint eqeqeq: true */
|
|
5141
|
|
5142 // Don't check non-elements (#13208)
|
|
5143 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
|
|
5144 if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
|
|
5145 matches = [];
|
|
5146 for ( i = 0; i < delegateCount; i++ ) {
|
|
5147 handleObj = handlers[ i ];
|
|
5148
|
|
5149 // Don't conflict with Object.prototype properties (#13203)
|
|
5150 sel = handleObj.selector + " ";
|
|
5151
|
|
5152 if ( matches[ sel ] === undefined ) {
|
|
5153 matches[ sel ] = handleObj.needsContext ?
|
|
5154 jQuery( sel, this ).index( cur ) >= 0 :
|
|
5155 jQuery.find( sel, this, null, [ cur ] ).length;
|
|
5156 }
|
|
5157 if ( matches[ sel ] ) {
|
|
5158 matches.push( handleObj );
|
|
5159 }
|
|
5160 }
|
|
5161 if ( matches.length ) {
|
|
5162 handlerQueue.push({ elem: cur, handlers: matches });
|
|
5163 }
|
|
5164 }
|
|
5165 }
|
|
5166 }
|
|
5167
|
|
5168 // Add the remaining (directly-bound) handlers
|
|
5169 if ( delegateCount < handlers.length ) {
|
|
5170 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
|
|
5171 }
|
|
5172
|
|
5173 return handlerQueue;
|
|
5174 },
|
|
5175
|
|
5176 fix: function( event ) {
|
|
5177 if ( event[ jQuery.expando ] ) {
|
|
5178 return event;
|
|
5179 }
|
|
5180
|
|
5181 // Create a writable copy of the event object and normalize some properties
|
|
5182 var i, prop, copy,
|
|
5183 type = event.type,
|
|
5184 originalEvent = event,
|
|
5185 fixHook = this.fixHooks[ type ];
|
|
5186
|
|
5187 if ( !fixHook ) {
|
|
5188 this.fixHooks[ type ] = fixHook =
|
|
5189 rmouseEvent.test( type ) ? this.mouseHooks :
|
|
5190 rkeyEvent.test( type ) ? this.keyHooks :
|
|
5191 {};
|
|
5192 }
|
|
5193 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
|
|
5194
|
|
5195 event = new jQuery.Event( originalEvent );
|
|
5196
|
|
5197 i = copy.length;
|
|
5198 while ( i-- ) {
|
|
5199 prop = copy[ i ];
|
|
5200 event[ prop ] = originalEvent[ prop ];
|
|
5201 }
|
|
5202
|
|
5203 // Support: IE<9
|
|
5204 // Fix target property (#1925)
|
|
5205 if ( !event.target ) {
|
|
5206 event.target = originalEvent.srcElement || document;
|
|
5207 }
|
|
5208
|
|
5209 // Support: Chrome 23+, Safari?
|
|
5210 // Target should not be a text node (#504, #13143)
|
|
5211 if ( event.target.nodeType === 3 ) {
|
|
5212 event.target = event.target.parentNode;
|
|
5213 }
|
|
5214
|
|
5215 // Support: IE<9
|
|
5216 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
|
|
5217 event.metaKey = !!event.metaKey;
|
|
5218
|
|
5219 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
|
|
5220 },
|
|
5221
|
|
5222 // Includes some event props shared by KeyEvent and MouseEvent
|
|
5223 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
|
|
5224
|
|
5225 fixHooks: {},
|
|
5226
|
|
5227 keyHooks: {
|
|
5228 props: "char charCode key keyCode".split(" "),
|
|
5229 filter: function( event, original ) {
|
|
5230
|
|
5231 // Add which for key events
|
|
5232 if ( event.which == null ) {
|
|
5233 event.which = original.charCode != null ? original.charCode : original.keyCode;
|
|
5234 }
|
|
5235
|
|
5236 return event;
|
|
5237 }
|
|
5238 },
|
|
5239
|
|
5240 mouseHooks: {
|
|
5241 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
|
|
5242 filter: function( event, original ) {
|
|
5243 var body, eventDoc, doc,
|
|
5244 button = original.button,
|
|
5245 fromElement = original.fromElement;
|
|
5246
|
|
5247 // Calculate pageX/Y if missing and clientX/Y available
|
|
5248 if ( event.pageX == null && original.clientX != null ) {
|
|
5249 eventDoc = event.target.ownerDocument || document;
|
|
5250 doc = eventDoc.documentElement;
|
|
5251 body = eventDoc.body;
|
|
5252
|
|
5253 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
|
|
5254 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
|
|
5255 }
|
|
5256
|
|
5257 // Add relatedTarget, if necessary
|
|
5258 if ( !event.relatedTarget && fromElement ) {
|
|
5259 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
|
|
5260 }
|
|
5261
|
|
5262 // Add which for click: 1 === left; 2 === middle; 3 === right
|
|
5263 // Note: button is not normalized, so don't use it
|
|
5264 if ( !event.which && button !== undefined ) {
|
|
5265 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
|
|
5266 }
|
|
5267
|
|
5268 return event;
|
|
5269 }
|
|
5270 },
|
|
5271
|
|
5272 special: {
|
|
5273 load: {
|
|
5274 // Prevent triggered image.load events from bubbling to window.load
|
|
5275 noBubble: true
|
|
5276 },
|
|
5277 focus: {
|
|
5278 // Fire native event if possible so blur/focus sequence is correct
|
|
5279 trigger: function() {
|
|
5280 if ( this !== safeActiveElement() && this.focus ) {
|
|
5281 try {
|
|
5282 this.focus();
|
|
5283 return false;
|
|
5284 } catch ( e ) {
|
|
5285 // Support: IE<9
|
|
5286 // If we error on focus to hidden element (#1486, #12518),
|
|
5287 // let .trigger() run the handlers
|
|
5288 }
|
|
5289 }
|
|
5290 },
|
|
5291 delegateType: "focusin"
|
|
5292 },
|
|
5293 blur: {
|
|
5294 trigger: function() {
|
|
5295 if ( this === safeActiveElement() && this.blur ) {
|
|
5296 this.blur();
|
|
5297 return false;
|
|
5298 }
|
|
5299 },
|
|
5300 delegateType: "focusout"
|
|
5301 },
|
|
5302 click: {
|
|
5303 // For checkbox, fire native event so checked state will be right
|
|
5304 trigger: function() {
|
|
5305 if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
|
|
5306 this.click();
|
|
5307 return false;
|
|
5308 }
|
|
5309 },
|
|
5310
|
|
5311 // For cross-browser consistency, don't fire native .click() on links
|
|
5312 _default: function( event ) {
|
|
5313 return jQuery.nodeName( event.target, "a" );
|
|
5314 }
|
|
5315 },
|
|
5316
|
|
5317 beforeunload: {
|
|
5318 postDispatch: function( event ) {
|
|
5319
|
|
5320 // Even when returnValue equals to undefined Firefox will still show alert
|
|
5321 if ( event.result !== undefined ) {
|
|
5322 event.originalEvent.returnValue = event.result;
|
|
5323 }
|
|
5324 }
|
|
5325 }
|
|
5326 },
|
|
5327
|
|
5328 simulate: function( type, elem, event, bubble ) {
|
|
5329 // Piggyback on a donor event to simulate a different one.
|
|
5330 // Fake originalEvent to avoid donor's stopPropagation, but if the
|
|
5331 // simulated event prevents default then we do the same on the donor.
|
|
5332 var e = jQuery.extend(
|
|
5333 new jQuery.Event(),
|
|
5334 event,
|
|
5335 {
|
|
5336 type: type,
|
|
5337 isSimulated: true,
|
|
5338 originalEvent: {}
|
|
5339 }
|
|
5340 );
|
|
5341 if ( bubble ) {
|
|
5342 jQuery.event.trigger( e, null, elem );
|
|
5343 } else {
|
|
5344 jQuery.event.dispatch.call( elem, e );
|
|
5345 }
|
|
5346 if ( e.isDefaultPrevented() ) {
|
|
5347 event.preventDefault();
|
|
5348 }
|
|
5349 }
|
|
5350 };
|
|
5351
|
|
5352 jQuery.removeEvent = document.removeEventListener ?
|
|
5353 function( elem, type, handle ) {
|
|
5354 if ( elem.removeEventListener ) {
|
|
5355 elem.removeEventListener( type, handle, false );
|
|
5356 }
|
|
5357 } :
|
|
5358 function( elem, type, handle ) {
|
|
5359 var name = "on" + type;
|
|
5360
|
|
5361 if ( elem.detachEvent ) {
|
|
5362
|
|
5363 // #8545, #7054, preventing memory leaks for custom events in IE6-8
|
|
5364 // detachEvent needed property on element, by name of that event, to properly expose it to GC
|
|
5365 if ( typeof elem[ name ] === core_strundefined ) {
|
|
5366 elem[ name ] = null;
|
|
5367 }
|
|
5368
|
|
5369 elem.detachEvent( name, handle );
|
|
5370 }
|
|
5371 };
|
|
5372
|
|
5373 jQuery.Event = function( src, props ) {
|
|
5374 // Allow instantiation without the 'new' keyword
|
|
5375 if ( !(this instanceof jQuery.Event) ) {
|
|
5376 return new jQuery.Event( src, props );
|
|
5377 }
|
|
5378
|
|
5379 // Event object
|
|
5380 if ( src && src.type ) {
|
|
5381 this.originalEvent = src;
|
|
5382 this.type = src.type;
|
|
5383
|
|
5384 // Events bubbling up the document may have been marked as prevented
|
|
5385 // by a handler lower down the tree; reflect the correct value.
|
|
5386 this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
|
|
5387 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
|
|
5388
|
|
5389 // Event type
|
|
5390 } else {
|
|
5391 this.type = src;
|
|
5392 }
|
|
5393
|
|
5394 // Put explicitly provided properties onto the event object
|
|
5395 if ( props ) {
|
|
5396 jQuery.extend( this, props );
|
|
5397 }
|
|
5398
|
|
5399 // Create a timestamp if incoming event doesn't have one
|
|
5400 this.timeStamp = src && src.timeStamp || jQuery.now();
|
|
5401
|
|
5402 // Mark it as fixed
|
|
5403 this[ jQuery.expando ] = true;
|
|
5404 };
|
|
5405
|
|
5406 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
|
5407 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
|
5408 jQuery.Event.prototype = {
|
|
5409 isDefaultPrevented: returnFalse,
|
|
5410 isPropagationStopped: returnFalse,
|
|
5411 isImmediatePropagationStopped: returnFalse,
|
|
5412
|
|
5413 preventDefault: function() {
|
|
5414 var e = this.originalEvent;
|
|
5415
|
|
5416 this.isDefaultPrevented = returnTrue;
|
|
5417 if ( !e ) {
|
|
5418 return;
|
|
5419 }
|
|
5420
|
|
5421 // If preventDefault exists, run it on the original event
|
|
5422 if ( e.preventDefault ) {
|
|
5423 e.preventDefault();
|
|
5424
|
|
5425 // Support: IE
|
|
5426 // Otherwise set the returnValue property of the original event to false
|
|
5427 } else {
|
|
5428 e.returnValue = false;
|
|
5429 }
|
|
5430 },
|
|
5431 stopPropagation: function() {
|
|
5432 var e = this.originalEvent;
|
|
5433
|
|
5434 this.isPropagationStopped = returnTrue;
|
|
5435 if ( !e ) {
|
|
5436 return;
|
|
5437 }
|
|
5438 // If stopPropagation exists, run it on the original event
|
|
5439 if ( e.stopPropagation ) {
|
|
5440 e.stopPropagation();
|
|
5441 }
|
|
5442
|
|
5443 // Support: IE
|
|
5444 // Set the cancelBubble property of the original event to true
|
|
5445 e.cancelBubble = true;
|
|
5446 },
|
|
5447 stopImmediatePropagation: function() {
|
|
5448 this.isImmediatePropagationStopped = returnTrue;
|
|
5449 this.stopPropagation();
|
|
5450 }
|
|
5451 };
|
|
5452
|
|
5453 // Create mouseenter/leave events using mouseover/out and event-time checks
|
|
5454 jQuery.each({
|
|
5455 mouseenter: "mouseover",
|
|
5456 mouseleave: "mouseout"
|
|
5457 }, function( orig, fix ) {
|
|
5458 jQuery.event.special[ orig ] = {
|
|
5459 delegateType: fix,
|
|
5460 bindType: fix,
|
|
5461
|
|
5462 handle: function( event ) {
|
|
5463 var ret,
|
|
5464 target = this,
|
|
5465 related = event.relatedTarget,
|
|
5466 handleObj = event.handleObj;
|
|
5467
|
|
5468 // For mousenter/leave call the handler if related is outside the target.
|
|
5469 // NB: No relatedTarget if the mouse left/entered the browser window
|
|
5470 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
|
|
5471 event.type = handleObj.origType;
|
|
5472 ret = handleObj.handler.apply( this, arguments );
|
|
5473 event.type = fix;
|
|
5474 }
|
|
5475 return ret;
|
|
5476 }
|
|
5477 };
|
|
5478 });
|
|
5479
|
|
5480 // IE submit delegation
|
|
5481 if ( !jQuery.support.submitBubbles ) {
|
|
5482
|
|
5483 jQuery.event.special.submit = {
|
|
5484 setup: function() {
|
|
5485 // Only need this for delegated form submit events
|
|
5486 if ( jQuery.nodeName( this, "form" ) ) {
|
|
5487 return false;
|
|
5488 }
|
|
5489
|
|
5490 // Lazy-add a submit handler when a descendant form may potentially be submitted
|
|
5491 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
|
|
5492 // Node name check avoids a VML-related crash in IE (#9807)
|
|
5493 var elem = e.target,
|
|
5494 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
|
|
5495 if ( form && !jQuery._data( form, "submitBubbles" ) ) {
|
|
5496 jQuery.event.add( form, "submit._submit", function( event ) {
|
|
5497 event._submit_bubble = true;
|
|
5498 });
|
|
5499 jQuery._data( form, "submitBubbles", true );
|
|
5500 }
|
|
5501 });
|
|
5502 // return undefined since we don't need an event listener
|
|
5503 },
|
|
5504
|
|
5505 postDispatch: function( event ) {
|
|
5506 // If form was submitted by the user, bubble the event up the tree
|
|
5507 if ( event._submit_bubble ) {
|
|
5508 delete event._submit_bubble;
|
|
5509 if ( this.parentNode && !event.isTrigger ) {
|
|
5510 jQuery.event.simulate( "submit", this.parentNode, event, true );
|
|
5511 }
|
|
5512 }
|
|
5513 },
|
|
5514
|
|
5515 teardown: function() {
|
|
5516 // Only need this for delegated form submit events
|
|
5517 if ( jQuery.nodeName( this, "form" ) ) {
|
|
5518 return false;
|
|
5519 }
|
|
5520
|
|
5521 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
|
|
5522 jQuery.event.remove( this, "._submit" );
|
|
5523 }
|
|
5524 };
|
|
5525 }
|
|
5526
|
|
5527 // IE change delegation and checkbox/radio fix
|
|
5528 if ( !jQuery.support.changeBubbles ) {
|
|
5529
|
|
5530 jQuery.event.special.change = {
|
|
5531
|
|
5532 setup: function() {
|
|
5533
|
|
5534 if ( rformElems.test( this.nodeName ) ) {
|
|
5535 // IE doesn't fire change on a check/radio until blur; trigger it on click
|
|
5536 // after a propertychange. Eat the blur-change in special.change.handle.
|
|
5537 // This still fires onchange a second time for check/radio after blur.
|
|
5538 if ( this.type === "checkbox" || this.type === "radio" ) {
|
|
5539 jQuery.event.add( this, "propertychange._change", function( event ) {
|
|
5540 if ( event.originalEvent.propertyName === "checked" ) {
|
|
5541 this._just_changed = true;
|
|
5542 }
|
|
5543 });
|
|
5544 jQuery.event.add( this, "click._change", function( event ) {
|
|
5545 if ( this._just_changed && !event.isTrigger ) {
|
|
5546 this._just_changed = false;
|
|
5547 }
|
|
5548 // Allow triggered, simulated change events (#11500)
|
|
5549 jQuery.event.simulate( "change", this, event, true );
|
|
5550 });
|
|
5551 }
|
|
5552 return false;
|
|
5553 }
|
|
5554 // Delegated event; lazy-add a change handler on descendant inputs
|
|
5555 jQuery.event.add( this, "beforeactivate._change", function( e ) {
|
|
5556 var elem = e.target;
|
|
5557
|
|
5558 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
|
|
5559 jQuery.event.add( elem, "change._change", function( event ) {
|
|
5560 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
|
|
5561 jQuery.event.simulate( "change", this.parentNode, event, true );
|
|
5562 }
|
|
5563 });
|
|
5564 jQuery._data( elem, "changeBubbles", true );
|
|
5565 }
|
|
5566 });
|
|
5567 },
|
|
5568
|
|
5569 handle: function( event ) {
|
|
5570 var elem = event.target;
|
|
5571
|
|
5572 // Swallow native change events from checkbox/radio, we already triggered them above
|
|
5573 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
|
|
5574 return event.handleObj.handler.apply( this, arguments );
|
|
5575 }
|
|
5576 },
|
|
5577
|
|
5578 teardown: function() {
|
|
5579 jQuery.event.remove( this, "._change" );
|
|
5580
|
|
5581 return !rformElems.test( this.nodeName );
|
|
5582 }
|
|
5583 };
|
|
5584 }
|
|
5585
|
|
5586 // Create "bubbling" focus and blur events
|
|
5587 if ( !jQuery.support.focusinBubbles ) {
|
|
5588 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
|
|
5589
|
|
5590 // Attach a single capturing handler while someone wants focusin/focusout
|
|
5591 var attaches = 0,
|
|
5592 handler = function( event ) {
|
|
5593 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
|
|
5594 };
|
|
5595
|
|
5596 jQuery.event.special[ fix ] = {
|
|
5597 setup: function() {
|
|
5598 if ( attaches++ === 0 ) {
|
|
5599 document.addEventListener( orig, handler, true );
|
|
5600 }
|
|
5601 },
|
|
5602 teardown: function() {
|
|
5603 if ( --attaches === 0 ) {
|
|
5604 document.removeEventListener( orig, handler, true );
|
|
5605 }
|
|
5606 }
|
|
5607 };
|
|
5608 });
|
|
5609 }
|
|
5610
|
|
5611 jQuery.fn.extend({
|
|
5612
|
|
5613 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
|
|
5614 var type, origFn;
|
|
5615
|
|
5616 // Types can be a map of types/handlers
|
|
5617 if ( typeof types === "object" ) {
|
|
5618 // ( types-Object, selector, data )
|
|
5619 if ( typeof selector !== "string" ) {
|
|
5620 // ( types-Object, data )
|
|
5621 data = data || selector;
|
|
5622 selector = undefined;
|
|
5623 }
|
|
5624 for ( type in types ) {
|
|
5625 this.on( type, selector, data, types[ type ], one );
|
|
5626 }
|
|
5627 return this;
|
|
5628 }
|
|
5629
|
|
5630 if ( data == null && fn == null ) {
|
|
5631 // ( types, fn )
|
|
5632 fn = selector;
|
|
5633 data = selector = undefined;
|
|
5634 } else if ( fn == null ) {
|
|
5635 if ( typeof selector === "string" ) {
|
|
5636 // ( types, selector, fn )
|
|
5637 fn = data;
|
|
5638 data = undefined;
|
|
5639 } else {
|
|
5640 // ( types, data, fn )
|
|
5641 fn = data;
|
|
5642 data = selector;
|
|
5643 selector = undefined;
|
|
5644 }
|
|
5645 }
|
|
5646 if ( fn === false ) {
|
|
5647 fn = returnFalse;
|
|
5648 } else if ( !fn ) {
|
|
5649 return this;
|
|
5650 }
|
|
5651
|
|
5652 if ( one === 1 ) {
|
|
5653 origFn = fn;
|
|
5654 fn = function( event ) {
|
|
5655 // Can use an empty set, since event contains the info
|
|
5656 jQuery().off( event );
|
|
5657 return origFn.apply( this, arguments );
|
|
5658 };
|
|
5659 // Use same guid so caller can remove using origFn
|
|
5660 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
|
|
5661 }
|
|
5662 return this.each( function() {
|
|
5663 jQuery.event.add( this, types, fn, data, selector );
|
|
5664 });
|
|
5665 },
|
|
5666 one: function( types, selector, data, fn ) {
|
|
5667 return this.on( types, selector, data, fn, 1 );
|
|
5668 },
|
|
5669 off: function( types, selector, fn ) {
|
|
5670 var handleObj, type;
|
|
5671 if ( types && types.preventDefault && types.handleObj ) {
|
|
5672 // ( event ) dispatched jQuery.Event
|
|
5673 handleObj = types.handleObj;
|
|
5674 jQuery( types.delegateTarget ).off(
|
|
5675 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
|
|
5676 handleObj.selector,
|
|
5677 handleObj.handler
|
|
5678 );
|
|
5679 return this;
|
|
5680 }
|
|
5681 if ( typeof types === "object" ) {
|
|
5682 // ( types-object [, selector] )
|
|
5683 for ( type in types ) {
|
|
5684 this.off( type, selector, types[ type ] );
|
|
5685 }
|
|
5686 return this;
|
|
5687 }
|
|
5688 if ( selector === false || typeof selector === "function" ) {
|
|
5689 // ( types [, fn] )
|
|
5690 fn = selector;
|
|
5691 selector = undefined;
|
|
5692 }
|
|
5693 if ( fn === false ) {
|
|
5694 fn = returnFalse;
|
|
5695 }
|
|
5696 return this.each(function() {
|
|
5697 jQuery.event.remove( this, types, fn, selector );
|
|
5698 });
|
|
5699 },
|
|
5700
|
|
5701 trigger: function( type, data ) {
|
|
5702 return this.each(function() {
|
|
5703 jQuery.event.trigger( type, data, this );
|
|
5704 });
|
|
5705 },
|
|
5706 triggerHandler: function( type, data ) {
|
|
5707 var elem = this[0];
|
|
5708 if ( elem ) {
|
|
5709 return jQuery.event.trigger( type, data, elem, true );
|
|
5710 }
|
|
5711 }
|
|
5712 });
|
|
5713 var isSimple = /^.[^:#\[\.,]*$/,
|
|
5714 rparentsprev = /^(?:parents|prev(?:Until|All))/,
|
|
5715 rneedsContext = jQuery.expr.match.needsContext,
|
|
5716 // methods guaranteed to produce a unique set when starting from a unique set
|
|
5717 guaranteedUnique = {
|
|
5718 children: true,
|
|
5719 contents: true,
|
|
5720 next: true,
|
|
5721 prev: true
|
|
5722 };
|
|
5723
|
|
5724 jQuery.fn.extend({
|
|
5725 find: function( selector ) {
|
|
5726 var i,
|
|
5727 ret = [],
|
|
5728 self = this,
|
|
5729 len = self.length;
|
|
5730
|
|
5731 if ( typeof selector !== "string" ) {
|
|
5732 return this.pushStack( jQuery( selector ).filter(function() {
|
|
5733 for ( i = 0; i < len; i++ ) {
|
|
5734 if ( jQuery.contains( self[ i ], this ) ) {
|
|
5735 return true;
|
|
5736 }
|
|
5737 }
|
|
5738 }) );
|
|
5739 }
|
|
5740
|
|
5741 for ( i = 0; i < len; i++ ) {
|
|
5742 jQuery.find( selector, self[ i ], ret );
|
|
5743 }
|
|
5744
|
|
5745 // Needed because $( selector, context ) becomes $( context ).find( selector )
|
|
5746 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
|
|
5747 ret.selector = this.selector ? this.selector + " " + selector : selector;
|
|
5748 return ret;
|
|
5749 },
|
|
5750
|
|
5751 has: function( target ) {
|
|
5752 var i,
|
|
5753 targets = jQuery( target, this ),
|
|
5754 len = targets.length;
|
|
5755
|
|
5756 return this.filter(function() {
|
|
5757 for ( i = 0; i < len; i++ ) {
|
|
5758 if ( jQuery.contains( this, targets[i] ) ) {
|
|
5759 return true;
|
|
5760 }
|
|
5761 }
|
|
5762 });
|
|
5763 },
|
|
5764
|
|
5765 not: function( selector ) {
|
|
5766 return this.pushStack( winnow(this, selector || [], true) );
|
|
5767 },
|
|
5768
|
|
5769 filter: function( selector ) {
|
|
5770 return this.pushStack( winnow(this, selector || [], false) );
|
|
5771 },
|
|
5772
|
|
5773 is: function( selector ) {
|
|
5774 return !!winnow(
|
|
5775 this,
|
|
5776
|
|
5777 // If this is a positional/relative selector, check membership in the returned set
|
|
5778 // so $("p:first").is("p:last") won't return true for a doc with two "p".
|
|
5779 typeof selector === "string" && rneedsContext.test( selector ) ?
|
|
5780 jQuery( selector ) :
|
|
5781 selector || [],
|
|
5782 false
|
|
5783 ).length;
|
|
5784 },
|
|
5785
|
|
5786 closest: function( selectors, context ) {
|
|
5787 var cur,
|
|
5788 i = 0,
|
|
5789 l = this.length,
|
|
5790 ret = [],
|
|
5791 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
|
|
5792 jQuery( selectors, context || this.context ) :
|
|
5793 0;
|
|
5794
|
|
5795 for ( ; i < l; i++ ) {
|
|
5796 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
|
|
5797 // Always skip document fragments
|
|
5798 if ( cur.nodeType < 11 && (pos ?
|
|
5799 pos.index(cur) > -1 :
|
|
5800
|
|
5801 // Don't pass non-elements to Sizzle
|
|
5802 cur.nodeType === 1 &&
|
|
5803 jQuery.find.matchesSelector(cur, selectors)) ) {
|
|
5804
|
|
5805 cur = ret.push( cur );
|
|
5806 break;
|
|
5807 }
|
|
5808 }
|
|
5809 }
|
|
5810
|
|
5811 return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret );
|
|
5812 },
|
|
5813
|
|
5814 // Determine the position of an element within
|
|
5815 // the matched set of elements
|
|
5816 index: function( elem ) {
|
|
5817
|
|
5818 // No argument, return index in parent
|
|
5819 if ( !elem ) {
|
|
5820 return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
|
|
5821 }
|
|
5822
|
|
5823 // index in selector
|
|
5824 if ( typeof elem === "string" ) {
|
|
5825 return jQuery.inArray( this[0], jQuery( elem ) );
|
|
5826 }
|
|
5827
|
|
5828 // Locate the position of the desired element
|
|
5829 return jQuery.inArray(
|
|
5830 // If it receives a jQuery object, the first element is used
|
|
5831 elem.jquery ? elem[0] : elem, this );
|
|
5832 },
|
|
5833
|
|
5834 add: function( selector, context ) {
|
|
5835 var set = typeof selector === "string" ?
|
|
5836 jQuery( selector, context ) :
|
|
5837 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
|
|
5838 all = jQuery.merge( this.get(), set );
|
|
5839
|
|
5840 return this.pushStack( jQuery.unique(all) );
|
|
5841 },
|
|
5842
|
|
5843 addBack: function( selector ) {
|
|
5844 return this.add( selector == null ?
|
|
5845 this.prevObject : this.prevObject.filter(selector)
|
|
5846 );
|
|
5847 }
|
|
5848 });
|
|
5849
|
|
5850 function sibling( cur, dir ) {
|
|
5851 do {
|
|
5852 cur = cur[ dir ];
|
|
5853 } while ( cur && cur.nodeType !== 1 );
|
|
5854
|
|
5855 return cur;
|
|
5856 }
|
|
5857
|
|
5858 jQuery.each({
|
|
5859 parent: function( elem ) {
|
|
5860 var parent = elem.parentNode;
|
|
5861 return parent && parent.nodeType !== 11 ? parent : null;
|
|
5862 },
|
|
5863 parents: function( elem ) {
|
|
5864 return jQuery.dir( elem, "parentNode" );
|
|
5865 },
|
|
5866 parentsUntil: function( elem, i, until ) {
|
|
5867 return jQuery.dir( elem, "parentNode", until );
|
|
5868 },
|
|
5869 next: function( elem ) {
|
|
5870 return sibling( elem, "nextSibling" );
|
|
5871 },
|
|
5872 prev: function( elem ) {
|
|
5873 return sibling( elem, "previousSibling" );
|
|
5874 },
|
|
5875 nextAll: function( elem ) {
|
|
5876 return jQuery.dir( elem, "nextSibling" );
|
|
5877 },
|
|
5878 prevAll: function( elem ) {
|
|
5879 return jQuery.dir( elem, "previousSibling" );
|
|
5880 },
|
|
5881 nextUntil: function( elem, i, until ) {
|
|
5882 return jQuery.dir( elem, "nextSibling", until );
|
|
5883 },
|
|
5884 prevUntil: function( elem, i, until ) {
|
|
5885 return jQuery.dir( elem, "previousSibling", until );
|
|
5886 },
|
|
5887 siblings: function( elem ) {
|
|
5888 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
|
|
5889 },
|
|
5890 children: function( elem ) {
|
|
5891 return jQuery.sibling( elem.firstChild );
|
|
5892 },
|
|
5893 contents: function( elem ) {
|
|
5894 return jQuery.nodeName( elem, "iframe" ) ?
|
|
5895 elem.contentDocument || elem.contentWindow.document :
|
|
5896 jQuery.merge( [], elem.childNodes );
|
|
5897 }
|
|
5898 }, function( name, fn ) {
|
|
5899 jQuery.fn[ name ] = function( until, selector ) {
|
|
5900 var ret = jQuery.map( this, fn, until );
|
|
5901
|
|
5902 if ( name.slice( -5 ) !== "Until" ) {
|
|
5903 selector = until;
|
|
5904 }
|
|
5905
|
|
5906 if ( selector && typeof selector === "string" ) {
|
|
5907 ret = jQuery.filter( selector, ret );
|
|
5908 }
|
|
5909
|
|
5910 if ( this.length > 1 ) {
|
|
5911 // Remove duplicates
|
|
5912 if ( !guaranteedUnique[ name ] ) {
|
|
5913 ret = jQuery.unique( ret );
|
|
5914 }
|
|
5915
|
|
5916 // Reverse order for parents* and prev-derivatives
|
|
5917 if ( rparentsprev.test( name ) ) {
|
|
5918 ret = ret.reverse();
|
|
5919 }
|
|
5920 }
|
|
5921
|
|
5922 return this.pushStack( ret );
|
|
5923 };
|
|
5924 });
|
|
5925
|
|
5926 jQuery.extend({
|
|
5927 filter: function( expr, elems, not ) {
|
|
5928 var elem = elems[ 0 ];
|
|
5929
|
|
5930 if ( not ) {
|
|
5931 expr = ":not(" + expr + ")";
|
|
5932 }
|
|
5933
|
|
5934 return elems.length === 1 && elem.nodeType === 1 ?
|
|
5935 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
|
|
5936 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
|
|
5937 return elem.nodeType === 1;
|
|
5938 }));
|
|
5939 },
|
|
5940
|
|
5941 dir: function( elem, dir, until ) {
|
|
5942 var matched = [],
|
|
5943 cur = elem[ dir ];
|
|
5944
|
|
5945 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
|
|
5946 if ( cur.nodeType === 1 ) {
|
|
5947 matched.push( cur );
|
|
5948 }
|
|
5949 cur = cur[dir];
|
|
5950 }
|
|
5951 return matched;
|
|
5952 },
|
|
5953
|
|
5954 sibling: function( n, elem ) {
|
|
5955 var r = [];
|
|
5956
|
|
5957 for ( ; n; n = n.nextSibling ) {
|
|
5958 if ( n.nodeType === 1 && n !== elem ) {
|
|
5959 r.push( n );
|
|
5960 }
|
|
5961 }
|
|
5962
|
|
5963 return r;
|
|
5964 }
|
|
5965 });
|
|
5966
|
|
5967 // Implement the identical functionality for filter and not
|
|
5968 function winnow( elements, qualifier, not ) {
|
|
5969 if ( jQuery.isFunction( qualifier ) ) {
|
|
5970 return jQuery.grep( elements, function( elem, i ) {
|
|
5971 /* jshint -W018 */
|
|
5972 return !!qualifier.call( elem, i, elem ) !== not;
|
|
5973 });
|
|
5974
|
|
5975 }
|
|
5976
|
|
5977 if ( qualifier.nodeType ) {
|
|
5978 return jQuery.grep( elements, function( elem ) {
|
|
5979 return ( elem === qualifier ) !== not;
|
|
5980 });
|
|
5981
|
|
5982 }
|
|
5983
|
|
5984 if ( typeof qualifier === "string" ) {
|
|
5985 if ( isSimple.test( qualifier ) ) {
|
|
5986 return jQuery.filter( qualifier, elements, not );
|
|
5987 }
|
|
5988
|
|
5989 qualifier = jQuery.filter( qualifier, elements );
|
|
5990 }
|
|
5991
|
|
5992 return jQuery.grep( elements, function( elem ) {
|
|
5993 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
|
|
5994 });
|
|
5995 }
|
|
5996 function createSafeFragment( document ) {
|
|
5997 var list = nodeNames.split( "|" ),
|
|
5998 safeFrag = document.createDocumentFragment();
|
|
5999
|
|
6000 if ( safeFrag.createElement ) {
|
|
6001 while ( list.length ) {
|
|
6002 safeFrag.createElement(
|
|
6003 list.pop()
|
|
6004 );
|
|
6005 }
|
|
6006 }
|
|
6007 return safeFrag;
|
|
6008 }
|
|
6009
|
|
6010 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
|
|
6011 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
|
|
6012 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
|
|
6013 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
|
|
6014 rleadingWhitespace = /^\s+/,
|
|
6015 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
|
|
6016 rtagName = /<([\w:]+)/,
|
|
6017 rtbody = /<tbody/i,
|
|
6018 rhtml = /<|&#?\w+;/,
|
|
6019 rnoInnerhtml = /<(?:script|style|link)/i,
|
|
6020 manipulation_rcheckableType = /^(?:checkbox|radio)$/i,
|
|
6021 // checked="checked" or checked
|
|
6022 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
|
|
6023 rscriptType = /^$|\/(?:java|ecma)script/i,
|
|
6024 rscriptTypeMasked = /^true\/(.*)/,
|
|
6025 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
|
|
6026
|
|
6027 // We have to close these tags to support XHTML (#13200)
|
|
6028 wrapMap = {
|
|
6029 option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
|
6030 legend: [ 1, "<fieldset>", "</fieldset>" ],
|
|
6031 area: [ 1, "<map>", "</map>" ],
|
|
6032 param: [ 1, "<object>", "</object>" ],
|
|
6033 thead: [ 1, "<table>", "</table>" ],
|
|
6034 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
|
|
6035 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
|
|
6036 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
|
|
6037
|
|
6038 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
|
|
6039 // unless wrapped in a div with non-breaking characters in front of it.
|
|
6040 _default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
|
|
6041 },
|
|
6042 safeFragment = createSafeFragment( document ),
|
|
6043 fragmentDiv = safeFragment.appendChild( document.createElement("div") );
|
|
6044
|
|
6045 wrapMap.optgroup = wrapMap.option;
|
|
6046 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
|
6047 wrapMap.th = wrapMap.td;
|
|
6048
|
|
6049 jQuery.fn.extend({
|
|
6050 text: function( value ) {
|
|
6051 return jQuery.access( this, function( value ) {
|
|
6052 return value === undefined ?
|
|
6053 jQuery.text( this ) :
|
|
6054 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
|
|
6055 }, null, value, arguments.length );
|
|
6056 },
|
|
6057
|
|
6058 append: function() {
|
|
6059 return this.domManip( arguments, function( elem ) {
|
|
6060 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
|
6061 var target = manipulationTarget( this, elem );
|
|
6062 target.appendChild( elem );
|
|
6063 }
|
|
6064 });
|
|
6065 },
|
|
6066
|
|
6067 prepend: function() {
|
|
6068 return this.domManip( arguments, function( elem ) {
|
|
6069 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
|
6070 var target = manipulationTarget( this, elem );
|
|
6071 target.insertBefore( elem, target.firstChild );
|
|
6072 }
|
|
6073 });
|
|
6074 },
|
|
6075
|
|
6076 before: function() {
|
|
6077 return this.domManip( arguments, function( elem ) {
|
|
6078 if ( this.parentNode ) {
|
|
6079 this.parentNode.insertBefore( elem, this );
|
|
6080 }
|
|
6081 });
|
|
6082 },
|
|
6083
|
|
6084 after: function() {
|
|
6085 return this.domManip( arguments, function( elem ) {
|
|
6086 if ( this.parentNode ) {
|
|
6087 this.parentNode.insertBefore( elem, this.nextSibling );
|
|
6088 }
|
|
6089 });
|
|
6090 },
|
|
6091
|
|
6092 // keepData is for internal use only--do not document
|
|
6093 remove: function( selector, keepData ) {
|
|
6094 var elem,
|
|
6095 elems = selector ? jQuery.filter( selector, this ) : this,
|
|
6096 i = 0;
|
|
6097
|
|
6098 for ( ; (elem = elems[i]) != null; i++ ) {
|
|
6099
|
|
6100 if ( !keepData && elem.nodeType === 1 ) {
|
|
6101 jQuery.cleanData( getAll( elem ) );
|
|
6102 }
|
|
6103
|
|
6104 if ( elem.parentNode ) {
|
|
6105 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
|
|
6106 setGlobalEval( getAll( elem, "script" ) );
|
|
6107 }
|
|
6108 elem.parentNode.removeChild( elem );
|
|
6109 }
|
|
6110 }
|
|
6111
|
|
6112 return this;
|
|
6113 },
|
|
6114
|
|
6115 empty: function() {
|
|
6116 var elem,
|
|
6117 i = 0;
|
|
6118
|
|
6119 for ( ; (elem = this[i]) != null; i++ ) {
|
|
6120 // Remove element nodes and prevent memory leaks
|
|
6121 if ( elem.nodeType === 1 ) {
|
|
6122 jQuery.cleanData( getAll( elem, false ) );
|
|
6123 }
|
|
6124
|
|
6125 // Remove any remaining nodes
|
|
6126 while ( elem.firstChild ) {
|
|
6127 elem.removeChild( elem.firstChild );
|
|
6128 }
|
|
6129
|
|
6130 // If this is a select, ensure that it displays empty (#12336)
|
|
6131 // Support: IE<9
|
|
6132 if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
|
|
6133 elem.options.length = 0;
|
|
6134 }
|
|
6135 }
|
|
6136
|
|
6137 return this;
|
|
6138 },
|
|
6139
|
|
6140 clone: function( dataAndEvents, deepDataAndEvents ) {
|
|
6141 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
|
|
6142 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
|
|
6143
|
|
6144 return this.map( function () {
|
|
6145 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
|
|
6146 });
|
|
6147 },
|
|
6148
|
|
6149 html: function( value ) {
|
|
6150 return jQuery.access( this, function( value ) {
|
|
6151 var elem = this[0] || {},
|
|
6152 i = 0,
|
|
6153 l = this.length;
|
|
6154
|
|
6155 if ( value === undefined ) {
|
|
6156 return elem.nodeType === 1 ?
|
|
6157 elem.innerHTML.replace( rinlinejQuery, "" ) :
|
|
6158 undefined;
|
|
6159 }
|
|
6160
|
|
6161 // See if we can take a shortcut and just use innerHTML
|
|
6162 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
|
|
6163 ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
|
|
6164 ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
|
|
6165 !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
|
|
6166
|
|
6167 value = value.replace( rxhtmlTag, "<$1></$2>" );
|
|
6168
|
|
6169 try {
|
|
6170 for (; i < l; i++ ) {
|
|
6171 // Remove element nodes and prevent memory leaks
|
|
6172 elem = this[i] || {};
|
|
6173 if ( elem.nodeType === 1 ) {
|
|
6174 jQuery.cleanData( getAll( elem, false ) );
|
|
6175 elem.innerHTML = value;
|
|
6176 }
|
|
6177 }
|
|
6178
|
|
6179 elem = 0;
|
|
6180
|
|
6181 // If using innerHTML throws an exception, use the fallback method
|
|
6182 } catch(e) {}
|
|
6183 }
|
|
6184
|
|
6185 if ( elem ) {
|
|
6186 this.empty().append( value );
|
|
6187 }
|
|
6188 }, null, value, arguments.length );
|
|
6189 },
|
|
6190
|
|
6191 replaceWith: function() {
|
|
6192 var
|
|
6193 // Snapshot the DOM in case .domManip sweeps something relevant into its fragment
|
|
6194 args = jQuery.map( this, function( elem ) {
|
|
6195 return [ elem.nextSibling, elem.parentNode ];
|
|
6196 }),
|
|
6197 i = 0;
|
|
6198
|
|
6199 // Make the changes, replacing each context element with the new content
|
|
6200 this.domManip( arguments, function( elem ) {
|
|
6201 var next = args[ i++ ],
|
|
6202 parent = args[ i++ ];
|
|
6203
|
|
6204 if ( parent ) {
|
|
6205 // Don't use the snapshot next if it has moved (#13810)
|
|
6206 if ( next && next.parentNode !== parent ) {
|
|
6207 next = this.nextSibling;
|
|
6208 }
|
|
6209 jQuery( this ).remove();
|
|
6210 parent.insertBefore( elem, next );
|
|
6211 }
|
|
6212 // Allow new content to include elements from the context set
|
|
6213 }, true );
|
|
6214
|
|
6215 // Force removal if there was no new content (e.g., from empty arguments)
|
|
6216 return i ? this : this.remove();
|
|
6217 },
|
|
6218
|
|
6219 detach: function( selector ) {
|
|
6220 return this.remove( selector, true );
|
|
6221 },
|
|
6222
|
|
6223 domManip: function( args, callback, allowIntersection ) {
|
|
6224
|
|
6225 // Flatten any nested arrays
|
|
6226 args = core_concat.apply( [], args );
|
|
6227
|
|
6228 var first, node, hasScripts,
|
|
6229 scripts, doc, fragment,
|
|
6230 i = 0,
|
|
6231 l = this.length,
|
|
6232 set = this,
|
|
6233 iNoClone = l - 1,
|
|
6234 value = args[0],
|
|
6235 isFunction = jQuery.isFunction( value );
|
|
6236
|
|
6237 // We can't cloneNode fragments that contain checked, in WebKit
|
|
6238 if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) {
|
|
6239 return this.each(function( index ) {
|
|
6240 var self = set.eq( index );
|
|
6241 if ( isFunction ) {
|
|
6242 args[0] = value.call( this, index, self.html() );
|
|
6243 }
|
|
6244 self.domManip( args, callback, allowIntersection );
|
|
6245 });
|
|
6246 }
|
|
6247
|
|
6248 if ( l ) {
|
|
6249 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this );
|
|
6250 first = fragment.firstChild;
|
|
6251
|
|
6252 if ( fragment.childNodes.length === 1 ) {
|
|
6253 fragment = first;
|
|
6254 }
|
|
6255
|
|
6256 if ( first ) {
|
|
6257 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
|
|
6258 hasScripts = scripts.length;
|
|
6259
|
|
6260 // Use the original fragment for the last item instead of the first because it can end up
|
|
6261 // being emptied incorrectly in certain situations (#8070).
|
|
6262 for ( ; i < l; i++ ) {
|
|
6263 node = fragment;
|
|
6264
|
|
6265 if ( i !== iNoClone ) {
|
|
6266 node = jQuery.clone( node, true, true );
|
|
6267
|
|
6268 // Keep references to cloned scripts for later restoration
|
|
6269 if ( hasScripts ) {
|
|
6270 jQuery.merge( scripts, getAll( node, "script" ) );
|
|
6271 }
|
|
6272 }
|
|
6273
|
|
6274 callback.call( this[i], node, i );
|
|
6275 }
|
|
6276
|
|
6277 if ( hasScripts ) {
|
|
6278 doc = scripts[ scripts.length - 1 ].ownerDocument;
|
|
6279
|
|
6280 // Reenable scripts
|
|
6281 jQuery.map( scripts, restoreScript );
|
|
6282
|
|
6283 // Evaluate executable scripts on first document insertion
|
|
6284 for ( i = 0; i < hasScripts; i++ ) {
|
|
6285 node = scripts[ i ];
|
|
6286 if ( rscriptType.test( node.type || "" ) &&
|
|
6287 !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
|
|
6288
|
|
6289 if ( node.src ) {
|
|
6290 // Hope ajax is available...
|
|
6291 jQuery._evalUrl( node.src );
|
|
6292 } else {
|
|
6293 jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
|
|
6294 }
|
|
6295 }
|
|
6296 }
|
|
6297 }
|
|
6298
|
|
6299 // Fix #11809: Avoid leaking memory
|
|
6300 fragment = first = null;
|
|
6301 }
|
|
6302 }
|
|
6303
|
|
6304 return this;
|
|
6305 }
|
|
6306 });
|
|
6307
|
|
6308 // Support: IE<8
|
|
6309 // Manipulating tables requires a tbody
|
|
6310 function manipulationTarget( elem, content ) {
|
|
6311 return jQuery.nodeName( elem, "table" ) &&
|
|
6312 jQuery.nodeName( content.nodeType === 1 ? content : content.firstChild, "tr" ) ?
|
|
6313
|
|
6314 elem.getElementsByTagName("tbody")[0] ||
|
|
6315 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
|
|
6316 elem;
|
|
6317 }
|
|
6318
|
|
6319 // Replace/restore the type attribute of script elements for safe DOM manipulation
|
|
6320 function disableScript( elem ) {
|
|
6321 elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
|
|
6322 return elem;
|
|
6323 }
|
|
6324 function restoreScript( elem ) {
|
|
6325 var match = rscriptTypeMasked.exec( elem.type );
|
|
6326 if ( match ) {
|
|
6327 elem.type = match[1];
|
|
6328 } else {
|
|
6329 elem.removeAttribute("type");
|
|
6330 }
|
|
6331 return elem;
|
|
6332 }
|
|
6333
|
|
6334 // Mark scripts as having already been evaluated
|
|
6335 function setGlobalEval( elems, refElements ) {
|
|
6336 var elem,
|
|
6337 i = 0;
|
|
6338 for ( ; (elem = elems[i]) != null; i++ ) {
|
|
6339 jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
|
|
6340 }
|
|
6341 }
|
|
6342
|
|
6343 function cloneCopyEvent( src, dest ) {
|
|
6344
|
|
6345 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
|
|
6346 return;
|
|
6347 }
|
|
6348
|
|
6349 var type, i, l,
|
|
6350 oldData = jQuery._data( src ),
|
|
6351 curData = jQuery._data( dest, oldData ),
|
|
6352 events = oldData.events;
|
|
6353
|
|
6354 if ( events ) {
|
|
6355 delete curData.handle;
|
|
6356 curData.events = {};
|
|
6357
|
|
6358 for ( type in events ) {
|
|
6359 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
|
|
6360 jQuery.event.add( dest, type, events[ type ][ i ] );
|
|
6361 }
|
|
6362 }
|
|
6363 }
|
|
6364
|
|
6365 // make the cloned public data object a copy from the original
|
|
6366 if ( curData.data ) {
|
|
6367 curData.data = jQuery.extend( {}, curData.data );
|
|
6368 }
|
|
6369 }
|
|
6370
|
|
6371 function fixCloneNodeIssues( src, dest ) {
|
|
6372 var nodeName, e, data;
|
|
6373
|
|
6374 // We do not need to do anything for non-Elements
|
|
6375 if ( dest.nodeType !== 1 ) {
|
|
6376 return;
|
|
6377 }
|
|
6378
|
|
6379 nodeName = dest.nodeName.toLowerCase();
|
|
6380
|
|
6381 // IE6-8 copies events bound via attachEvent when using cloneNode.
|
|
6382 if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) {
|
|
6383 data = jQuery._data( dest );
|
|
6384
|
|
6385 for ( e in data.events ) {
|
|
6386 jQuery.removeEvent( dest, e, data.handle );
|
|
6387 }
|
|
6388
|
|
6389 // Event data gets referenced instead of copied if the expando gets copied too
|
|
6390 dest.removeAttribute( jQuery.expando );
|
|
6391 }
|
|
6392
|
|
6393 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
|
|
6394 if ( nodeName === "script" && dest.text !== src.text ) {
|
|
6395 disableScript( dest ).text = src.text;
|
|
6396 restoreScript( dest );
|
|
6397
|
|
6398 // IE6-10 improperly clones children of object elements using classid.
|
|
6399 // IE10 throws NoModificationAllowedError if parent is null, #12132.
|
|
6400 } else if ( nodeName === "object" ) {
|
|
6401 if ( dest.parentNode ) {
|
|
6402 dest.outerHTML = src.outerHTML;
|
|
6403 }
|
|
6404
|
|
6405 // This path appears unavoidable for IE9. When cloning an object
|
|
6406 // element in IE9, the outerHTML strategy above is not sufficient.
|
|
6407 // If the src has innerHTML and the destination does not,
|
|
6408 // copy the src.innerHTML into the dest.innerHTML. #10324
|
|
6409 if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
|
|
6410 dest.innerHTML = src.innerHTML;
|
|
6411 }
|
|
6412
|
|
6413 } else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) {
|
|
6414 // IE6-8 fails to persist the checked state of a cloned checkbox
|
|
6415 // or radio button. Worse, IE6-7 fail to give the cloned element
|
|
6416 // a checked appearance if the defaultChecked value isn't also set
|
|
6417
|
|
6418 dest.defaultChecked = dest.checked = src.checked;
|
|
6419
|
|
6420 // IE6-7 get confused and end up setting the value of a cloned
|
|
6421 // checkbox/radio button to an empty string instead of "on"
|
|
6422 if ( dest.value !== src.value ) {
|
|
6423 dest.value = src.value;
|
|
6424 }
|
|
6425
|
|
6426 // IE6-8 fails to return the selected option to the default selected
|
|
6427 // state when cloning options
|
|
6428 } else if ( nodeName === "option" ) {
|
|
6429 dest.defaultSelected = dest.selected = src.defaultSelected;
|
|
6430
|
|
6431 // IE6-8 fails to set the defaultValue to the correct value when
|
|
6432 // cloning other types of input fields
|
|
6433 } else if ( nodeName === "input" || nodeName === "textarea" ) {
|
|
6434 dest.defaultValue = src.defaultValue;
|
|
6435 }
|
|
6436 }
|
|
6437
|
|
6438 jQuery.each({
|
|
6439 appendTo: "append",
|
|
6440 prependTo: "prepend",
|
|
6441 insertBefore: "before",
|
|
6442 insertAfter: "after",
|
|
6443 replaceAll: "replaceWith"
|
|
6444 }, function( name, original ) {
|
|
6445 jQuery.fn[ name ] = function( selector ) {
|
|
6446 var elems,
|
|
6447 i = 0,
|
|
6448 ret = [],
|
|
6449 insert = jQuery( selector ),
|
|
6450 last = insert.length - 1;
|
|
6451
|
|
6452 for ( ; i <= last; i++ ) {
|
|
6453 elems = i === last ? this : this.clone(true);
|
|
6454 jQuery( insert[i] )[ original ]( elems );
|
|
6455
|
|
6456 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
|
|
6457 core_push.apply( ret, elems.get() );
|
|
6458 }
|
|
6459
|
|
6460 return this.pushStack( ret );
|
|
6461 };
|
|
6462 });
|
|
6463
|
|
6464 function getAll( context, tag ) {
|
|
6465 var elems, elem,
|
|
6466 i = 0,
|
|
6467 found = typeof context.getElementsByTagName !== core_strundefined ? context.getElementsByTagName( tag || "*" ) :
|
|
6468 typeof context.querySelectorAll !== core_strundefined ? context.querySelectorAll( tag || "*" ) :
|
|
6469 undefined;
|
|
6470
|
|
6471 if ( !found ) {
|
|
6472 for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
|
|
6473 if ( !tag || jQuery.nodeName( elem, tag ) ) {
|
|
6474 found.push( elem );
|
|
6475 } else {
|
|
6476 jQuery.merge( found, getAll( elem, tag ) );
|
|
6477 }
|
|
6478 }
|
|
6479 }
|
|
6480
|
|
6481 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
|
|
6482 jQuery.merge( [ context ], found ) :
|
|
6483 found;
|
|
6484 }
|
|
6485
|
|
6486 // Used in buildFragment, fixes the defaultChecked property
|
|
6487 function fixDefaultChecked( elem ) {
|
|
6488 if ( manipulation_rcheckableType.test( elem.type ) ) {
|
|
6489 elem.defaultChecked = elem.checked;
|
|
6490 }
|
|
6491 }
|
|
6492
|
|
6493 jQuery.extend({
|
|
6494 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
|
6495 var destElements, node, clone, i, srcElements,
|
|
6496 inPage = jQuery.contains( elem.ownerDocument, elem );
|
|
6497
|
|
6498 if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
|
|
6499 clone = elem.cloneNode( true );
|
|
6500
|
|
6501 // IE<=8 does not properly clone detached, unknown element nodes
|
|
6502 } else {
|
|
6503 fragmentDiv.innerHTML = elem.outerHTML;
|
|
6504 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
|
|
6505 }
|
|
6506
|
|
6507 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
|
|
6508 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
|
|
6509
|
|
6510 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
|
|
6511 destElements = getAll( clone );
|
|
6512 srcElements = getAll( elem );
|
|
6513
|
|
6514 // Fix all IE cloning issues
|
|
6515 for ( i = 0; (node = srcElements[i]) != null; ++i ) {
|
|
6516 // Ensure that the destination node is not null; Fixes #9587
|
|
6517 if ( destElements[i] ) {
|
|
6518 fixCloneNodeIssues( node, destElements[i] );
|
|
6519 }
|
|
6520 }
|
|
6521 }
|
|
6522
|
|
6523 // Copy the events from the original to the clone
|
|
6524 if ( dataAndEvents ) {
|
|
6525 if ( deepDataAndEvents ) {
|
|
6526 srcElements = srcElements || getAll( elem );
|
|
6527 destElements = destElements || getAll( clone );
|
|
6528
|
|
6529 for ( i = 0; (node = srcElements[i]) != null; i++ ) {
|
|
6530 cloneCopyEvent( node, destElements[i] );
|
|
6531 }
|
|
6532 } else {
|
|
6533 cloneCopyEvent( elem, clone );
|
|
6534 }
|
|
6535 }
|
|
6536
|
|
6537 // Preserve script evaluation history
|
|
6538 destElements = getAll( clone, "script" );
|
|
6539 if ( destElements.length > 0 ) {
|
|
6540 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
|
|
6541 }
|
|
6542
|
|
6543 destElements = srcElements = node = null;
|
|
6544
|
|
6545 // Return the cloned set
|
|
6546 return clone;
|
|
6547 },
|
|
6548
|
|
6549 buildFragment: function( elems, context, scripts, selection ) {
|
|
6550 var j, elem, contains,
|
|
6551 tmp, tag, tbody, wrap,
|
|
6552 l = elems.length,
|
|
6553
|
|
6554 // Ensure a safe fragment
|
|
6555 safe = createSafeFragment( context ),
|
|
6556
|
|
6557 nodes = [],
|
|
6558 i = 0;
|
|
6559
|
|
6560 for ( ; i < l; i++ ) {
|
|
6561 elem = elems[ i ];
|
|
6562
|
|
6563 if ( elem || elem === 0 ) {
|
|
6564
|
|
6565 // Add nodes directly
|
|
6566 if ( jQuery.type( elem ) === "object" ) {
|
|
6567 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
|
|
6568
|
|
6569 // Convert non-html into a text node
|
|
6570 } else if ( !rhtml.test( elem ) ) {
|
|
6571 nodes.push( context.createTextNode( elem ) );
|
|
6572
|
|
6573 // Convert html into DOM nodes
|
|
6574 } else {
|
|
6575 tmp = tmp || safe.appendChild( context.createElement("div") );
|
|
6576
|
|
6577 // Deserialize a standard representation
|
|
6578 tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
|
|
6579 wrap = wrapMap[ tag ] || wrapMap._default;
|
|
6580
|
|
6581 tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
|
|
6582
|
|
6583 // Descend through wrappers to the right content
|
|
6584 j = wrap[0];
|
|
6585 while ( j-- ) {
|
|
6586 tmp = tmp.lastChild;
|
|
6587 }
|
|
6588
|
|
6589 // Manually add leading whitespace removed by IE
|
|
6590 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
|
|
6591 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
|
|
6592 }
|
|
6593
|
|
6594 // Remove IE's autoinserted <tbody> from table fragments
|
|
6595 if ( !jQuery.support.tbody ) {
|
|
6596
|
|
6597 // String was a <table>, *may* have spurious <tbody>
|
|
6598 elem = tag === "table" && !rtbody.test( elem ) ?
|
|
6599 tmp.firstChild :
|
|
6600
|
|
6601 // String was a bare <thead> or <tfoot>
|
|
6602 wrap[1] === "<table>" && !rtbody.test( elem ) ?
|
|
6603 tmp :
|
|
6604 0;
|
|
6605
|
|
6606 j = elem && elem.childNodes.length;
|
|
6607 while ( j-- ) {
|
|
6608 if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
|
|
6609 elem.removeChild( tbody );
|
|
6610 }
|
|
6611 }
|
|
6612 }
|
|
6613
|
|
6614 jQuery.merge( nodes, tmp.childNodes );
|
|
6615
|
|
6616 // Fix #12392 for WebKit and IE > 9
|
|
6617 tmp.textContent = "";
|
|
6618
|
|
6619 // Fix #12392 for oldIE
|
|
6620 while ( tmp.firstChild ) {
|
|
6621 tmp.removeChild( tmp.firstChild );
|
|
6622 }
|
|
6623
|
|
6624 // Remember the top-level container for proper cleanup
|
|
6625 tmp = safe.lastChild;
|
|
6626 }
|
|
6627 }
|
|
6628 }
|
|
6629
|
|
6630 // Fix #11356: Clear elements from fragment
|
|
6631 if ( tmp ) {
|
|
6632 safe.removeChild( tmp );
|
|
6633 }
|
|
6634
|
|
6635 // Reset defaultChecked for any radios and checkboxes
|
|
6636 // about to be appended to the DOM in IE 6/7 (#8060)
|
|
6637 if ( !jQuery.support.appendChecked ) {
|
|
6638 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
|
|
6639 }
|
|
6640
|
|
6641 i = 0;
|
|
6642 while ( (elem = nodes[ i++ ]) ) {
|
|
6643
|
|
6644 // #4087 - If origin and destination elements are the same, and this is
|
|
6645 // that element, do not do anything
|
|
6646 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
|
|
6647 continue;
|
|
6648 }
|
|
6649
|
|
6650 contains = jQuery.contains( elem.ownerDocument, elem );
|
|
6651
|
|
6652 // Append to fragment
|
|
6653 tmp = getAll( safe.appendChild( elem ), "script" );
|
|
6654
|
|
6655 // Preserve script evaluation history
|
|
6656 if ( contains ) {
|
|
6657 setGlobalEval( tmp );
|
|
6658 }
|
|
6659
|
|
6660 // Capture executables
|
|
6661 if ( scripts ) {
|
|
6662 j = 0;
|
|
6663 while ( (elem = tmp[ j++ ]) ) {
|
|
6664 if ( rscriptType.test( elem.type || "" ) ) {
|
|
6665 scripts.push( elem );
|
|
6666 }
|
|
6667 }
|
|
6668 }
|
|
6669 }
|
|
6670
|
|
6671 tmp = null;
|
|
6672
|
|
6673 return safe;
|
|
6674 },
|
|
6675
|
|
6676 cleanData: function( elems, /* internal */ acceptData ) {
|
|
6677 var elem, type, id, data,
|
|
6678 i = 0,
|
|
6679 internalKey = jQuery.expando,
|
|
6680 cache = jQuery.cache,
|
|
6681 deleteExpando = jQuery.support.deleteExpando,
|
|
6682 special = jQuery.event.special;
|
|
6683
|
|
6684 for ( ; (elem = elems[i]) != null; i++ ) {
|
|
6685
|
|
6686 if ( acceptData || jQuery.acceptData( elem ) ) {
|
|
6687
|
|
6688 id = elem[ internalKey ];
|
|
6689 data = id && cache[ id ];
|
|
6690
|
|
6691 if ( data ) {
|
|
6692 if ( data.events ) {
|
|
6693 for ( type in data.events ) {
|
|
6694 if ( special[ type ] ) {
|
|
6695 jQuery.event.remove( elem, type );
|
|
6696
|
|
6697 // This is a shortcut to avoid jQuery.event.remove's overhead
|
|
6698 } else {
|
|
6699 jQuery.removeEvent( elem, type, data.handle );
|
|
6700 }
|
|
6701 }
|
|
6702 }
|
|
6703
|
|
6704 // Remove cache only if it was not already removed by jQuery.event.remove
|
|
6705 if ( cache[ id ] ) {
|
|
6706
|
|
6707 delete cache[ id ];
|
|
6708
|
|
6709 // IE does not allow us to delete expando properties from nodes,
|
|
6710 // nor does it have a removeAttribute function on Document nodes;
|
|
6711 // we must handle all of these cases
|
|
6712 if ( deleteExpando ) {
|
|
6713 delete elem[ internalKey ];
|
|
6714
|
|
6715 } else if ( typeof elem.removeAttribute !== core_strundefined ) {
|
|
6716 elem.removeAttribute( internalKey );
|
|
6717
|
|
6718 } else {
|
|
6719 elem[ internalKey ] = null;
|
|
6720 }
|
|
6721
|
|
6722 core_deletedIds.push( id );
|
|
6723 }
|
|
6724 }
|
|
6725 }
|
|
6726 }
|
|
6727 },
|
|
6728
|
|
6729 _evalUrl: function( url ) {
|
|
6730 return jQuery.ajax({
|
|
6731 url: url,
|
|
6732 type: "GET",
|
|
6733 dataType: "script",
|
|
6734 async: false,
|
|
6735 global: false,
|
|
6736 "throws": true
|
|
6737 });
|
|
6738 }
|
|
6739 });
|
|
6740 jQuery.fn.extend({
|
|
6741 wrapAll: function( html ) {
|
|
6742 if ( jQuery.isFunction( html ) ) {
|
|
6743 return this.each(function(i) {
|
|
6744 jQuery(this).wrapAll( html.call(this, i) );
|
|
6745 });
|
|
6746 }
|
|
6747
|
|
6748 if ( this[0] ) {
|
|
6749 // The elements to wrap the target around
|
|
6750 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
|
|
6751
|
|
6752 if ( this[0].parentNode ) {
|
|
6753 wrap.insertBefore( this[0] );
|
|
6754 }
|
|
6755
|
|
6756 wrap.map(function() {
|
|
6757 var elem = this;
|
|
6758
|
|
6759 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
|
|
6760 elem = elem.firstChild;
|
|
6761 }
|
|
6762
|
|
6763 return elem;
|
|
6764 }).append( this );
|
|
6765 }
|
|
6766
|
|
6767 return this;
|
|
6768 },
|
|
6769
|
|
6770 wrapInner: function( html ) {
|
|
6771 if ( jQuery.isFunction( html ) ) {
|
|
6772 return this.each(function(i) {
|
|
6773 jQuery(this).wrapInner( html.call(this, i) );
|
|
6774 });
|
|
6775 }
|
|
6776
|
|
6777 return this.each(function() {
|
|
6778 var self = jQuery( this ),
|
|
6779 contents = self.contents();
|
|
6780
|
|
6781 if ( contents.length ) {
|
|
6782 contents.wrapAll( html );
|
|
6783
|
|
6784 } else {
|
|
6785 self.append( html );
|
|
6786 }
|
|
6787 });
|
|
6788 },
|
|
6789
|
|
6790 wrap: function( html ) {
|
|
6791 var isFunction = jQuery.isFunction( html );
|
|
6792
|
|
6793 return this.each(function(i) {
|
|
6794 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
|
|
6795 });
|
|
6796 },
|
|
6797
|
|
6798 unwrap: function() {
|
|
6799 return this.parent().each(function() {
|
|
6800 if ( !jQuery.nodeName( this, "body" ) ) {
|
|
6801 jQuery( this ).replaceWith( this.childNodes );
|
|
6802 }
|
|
6803 }).end();
|
|
6804 }
|
|
6805 });
|
|
6806 var iframe, getStyles, curCSS,
|
|
6807 ralpha = /alpha\([^)]*\)/i,
|
|
6808 ropacity = /opacity\s*=\s*([^)]*)/,
|
|
6809 rposition = /^(top|right|bottom|left)$/,
|
|
6810 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
|
|
6811 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
|
|
6812 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
|
|
6813 rmargin = /^margin/,
|
|
6814 rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
|
|
6815 rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
|
|
6816 rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ),
|
|
6817 elemdisplay = { BODY: "block" },
|
|
6818
|
|
6819 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
|
|
6820 cssNormalTransform = {
|
|
6821 letterSpacing: 0,
|
|
6822 fontWeight: 400
|
|
6823 },
|
|
6824
|
|
6825 cssExpand = [ "Top", "Right", "Bottom", "Left" ],
|
|
6826 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
|
|
6827
|
|
6828 // return a css property mapped to a potentially vendor prefixed property
|
|
6829 function vendorPropName( style, name ) {
|
|
6830
|
|
6831 // shortcut for names that are not vendor prefixed
|
|
6832 if ( name in style ) {
|
|
6833 return name;
|
|
6834 }
|
|
6835
|
|
6836 // check for vendor prefixed names
|
|
6837 var capName = name.charAt(0).toUpperCase() + name.slice(1),
|
|
6838 origName = name,
|
|
6839 i = cssPrefixes.length;
|
|
6840
|
|
6841 while ( i-- ) {
|
|
6842 name = cssPrefixes[ i ] + capName;
|
|
6843 if ( name in style ) {
|
|
6844 return name;
|
|
6845 }
|
|
6846 }
|
|
6847
|
|
6848 return origName;
|
|
6849 }
|
|
6850
|
|
6851 function isHidden( elem, el ) {
|
|
6852 // isHidden might be called from jQuery#filter function;
|
|
6853 // in that case, element will be second argument
|
|
6854 elem = el || elem;
|
|
6855 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
|
|
6856 }
|
|
6857
|
|
6858 function showHide( elements, show ) {
|
|
6859 var display, elem, hidden,
|
|
6860 values = [],
|
|
6861 index = 0,
|
|
6862 length = elements.length;
|
|
6863
|
|
6864 for ( ; index < length; index++ ) {
|
|
6865 elem = elements[ index ];
|
|
6866 if ( !elem.style ) {
|
|
6867 continue;
|
|
6868 }
|
|
6869
|
|
6870 values[ index ] = jQuery._data( elem, "olddisplay" );
|
|
6871 display = elem.style.display;
|
|
6872 if ( show ) {
|
|
6873 // Reset the inline display of this element to learn if it is
|
|
6874 // being hidden by cascaded rules or not
|
|
6875 if ( !values[ index ] && display === "none" ) {
|
|
6876 elem.style.display = "";
|
|
6877 }
|
|
6878
|
|
6879 // Set elements which have been overridden with display: none
|
|
6880 // in a stylesheet to whatever the default browser style is
|
|
6881 // for such an element
|
|
6882 if ( elem.style.display === "" && isHidden( elem ) ) {
|
|
6883 values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
|
|
6884 }
|
|
6885 } else {
|
|
6886
|
|
6887 if ( !values[ index ] ) {
|
|
6888 hidden = isHidden( elem );
|
|
6889
|
|
6890 if ( display && display !== "none" || !hidden ) {
|
|
6891 jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
|
|
6892 }
|
|
6893 }
|
|
6894 }
|
|
6895 }
|
|
6896
|
|
6897 // Set the display of most of the elements in a second loop
|
|
6898 // to avoid the constant reflow
|
|
6899 for ( index = 0; index < length; index++ ) {
|
|
6900 elem = elements[ index ];
|
|
6901 if ( !elem.style ) {
|
|
6902 continue;
|
|
6903 }
|
|
6904 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
|
|
6905 elem.style.display = show ? values[ index ] || "" : "none";
|
|
6906 }
|
|
6907 }
|
|
6908
|
|
6909 return elements;
|
|
6910 }
|
|
6911
|
|
6912 jQuery.fn.extend({
|
|
6913 css: function( name, value ) {
|
|
6914 return jQuery.access( this, function( elem, name, value ) {
|
|
6915 var len, styles,
|
|
6916 map = {},
|
|
6917 i = 0;
|
|
6918
|
|
6919 if ( jQuery.isArray( name ) ) {
|
|
6920 styles = getStyles( elem );
|
|
6921 len = name.length;
|
|
6922
|
|
6923 for ( ; i < len; i++ ) {
|
|
6924 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
|
|
6925 }
|
|
6926
|
|
6927 return map;
|
|
6928 }
|
|
6929
|
|
6930 return value !== undefined ?
|
|
6931 jQuery.style( elem, name, value ) :
|
|
6932 jQuery.css( elem, name );
|
|
6933 }, name, value, arguments.length > 1 );
|
|
6934 },
|
|
6935 show: function() {
|
|
6936 return showHide( this, true );
|
|
6937 },
|
|
6938 hide: function() {
|
|
6939 return showHide( this );
|
|
6940 },
|
|
6941 toggle: function( state ) {
|
|
6942 var bool = typeof state === "boolean";
|
|
6943
|
|
6944 return this.each(function() {
|
|
6945 if ( bool ? state : isHidden( this ) ) {
|
|
6946 jQuery( this ).show();
|
|
6947 } else {
|
|
6948 jQuery( this ).hide();
|
|
6949 }
|
|
6950 });
|
|
6951 }
|
|
6952 });
|
|
6953
|
|
6954 jQuery.extend({
|
|
6955 // Add in style property hooks for overriding the default
|
|
6956 // behavior of getting and setting a style property
|
|
6957 cssHooks: {
|
|
6958 opacity: {
|
|
6959 get: function( elem, computed ) {
|
|
6960 if ( computed ) {
|
|
6961 // We should always get a number back from opacity
|
|
6962 var ret = curCSS( elem, "opacity" );
|
|
6963 return ret === "" ? "1" : ret;
|
|
6964 }
|
|
6965 }
|
|
6966 }
|
|
6967 },
|
|
6968
|
|
6969 // Don't automatically add "px" to these possibly-unitless properties
|
|
6970 cssNumber: {
|
|
6971 "columnCount": true,
|
|
6972 "fillOpacity": true,
|
|
6973 "fontWeight": true,
|
|
6974 "lineHeight": true,
|
|
6975 "opacity": true,
|
|
6976 "orphans": true,
|
|
6977 "widows": true,
|
|
6978 "zIndex": true,
|
|
6979 "zoom": true
|
|
6980 },
|
|
6981
|
|
6982 // Add in properties whose names you wish to fix before
|
|
6983 // setting or getting the value
|
|
6984 cssProps: {
|
|
6985 // normalize float css property
|
|
6986 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
|
|
6987 },
|
|
6988
|
|
6989 // Get and set the style property on a DOM Node
|
|
6990 style: function( elem, name, value, extra ) {
|
|
6991 // Don't set styles on text and comment nodes
|
|
6992 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
|
|
6993 return;
|
|
6994 }
|
|
6995
|
|
6996 // Make sure that we're working with the right name
|
|
6997 var ret, type, hooks,
|
|
6998 origName = jQuery.camelCase( name ),
|
|
6999 style = elem.style;
|
|
7000
|
|
7001 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
|
|
7002
|
|
7003 // gets hook for the prefixed version
|
|
7004 // followed by the unprefixed version
|
|
7005 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
|
7006
|
|
7007 // Check if we're setting a value
|
|
7008 if ( value !== undefined ) {
|
|
7009 type = typeof value;
|
|
7010
|
|
7011 // convert relative number strings (+= or -=) to relative numbers. #7345
|
|
7012 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
|
|
7013 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
|
|
7014 // Fixes bug #9237
|
|
7015 type = "number";
|
|
7016 }
|
|
7017
|
|
7018 // Make sure that NaN and null values aren't set. See: #7116
|
|
7019 if ( value == null || type === "number" && isNaN( value ) ) {
|
|
7020 return;
|
|
7021 }
|
|
7022
|
|
7023 // If a number was passed in, add 'px' to the (except for certain CSS properties)
|
|
7024 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
|
|
7025 value += "px";
|
|
7026 }
|
|
7027
|
|
7028 // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
|
|
7029 // but it would mean to define eight (for every problematic property) identical functions
|
|
7030 if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
|
|
7031 style[ name ] = "inherit";
|
|
7032 }
|
|
7033
|
|
7034 // If a hook was provided, use that value, otherwise just set the specified value
|
|
7035 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
|
|
7036
|
|
7037 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
|
|
7038 // Fixes bug #5509
|
|
7039 try {
|
|
7040 style[ name ] = value;
|
|
7041 } catch(e) {}
|
|
7042 }
|
|
7043
|
|
7044 } else {
|
|
7045 // If a hook was provided get the non-computed value from there
|
|
7046 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
|
|
7047 return ret;
|
|
7048 }
|
|
7049
|
|
7050 // Otherwise just get the value from the style object
|
|
7051 return style[ name ];
|
|
7052 }
|
|
7053 },
|
|
7054
|
|
7055 css: function( elem, name, extra, styles ) {
|
|
7056 var num, val, hooks,
|
|
7057 origName = jQuery.camelCase( name );
|
|
7058
|
|
7059 // Make sure that we're working with the right name
|
|
7060 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
|
|
7061
|
|
7062 // gets hook for the prefixed version
|
|
7063 // followed by the unprefixed version
|
|
7064 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
|
7065
|
|
7066 // If a hook was provided get the computed value from there
|
|
7067 if ( hooks && "get" in hooks ) {
|
|
7068 val = hooks.get( elem, true, extra );
|
|
7069 }
|
|
7070
|
|
7071 // Otherwise, if a way to get the computed value exists, use that
|
|
7072 if ( val === undefined ) {
|
|
7073 val = curCSS( elem, name, styles );
|
|
7074 }
|
|
7075
|
|
7076 //convert "normal" to computed value
|
|
7077 if ( val === "normal" && name in cssNormalTransform ) {
|
|
7078 val = cssNormalTransform[ name ];
|
|
7079 }
|
|
7080
|
|
7081 // Return, converting to number if forced or a qualifier was provided and val looks numeric
|
|
7082 if ( extra === "" || extra ) {
|
|
7083 num = parseFloat( val );
|
|
7084 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
|
|
7085 }
|
|
7086 return val;
|
|
7087 }
|
|
7088 });
|
|
7089
|
|
7090 // NOTE: we've included the "window" in window.getComputedStyle
|
|
7091 // because jsdom on node.js will break without it.
|
|
7092 if ( window.getComputedStyle ) {
|
|
7093 getStyles = function( elem ) {
|
|
7094 return window.getComputedStyle( elem, null );
|
|
7095 };
|
|
7096
|
|
7097 curCSS = function( elem, name, _computed ) {
|
|
7098 var width, minWidth, maxWidth,
|
|
7099 computed = _computed || getStyles( elem ),
|
|
7100
|
|
7101 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
|
|
7102 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined,
|
|
7103 style = elem.style;
|
|
7104
|
|
7105 if ( computed ) {
|
|
7106
|
|
7107 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
|
|
7108 ret = jQuery.style( elem, name );
|
|
7109 }
|
|
7110
|
|
7111 // A tribute to the "awesome hack by Dean Edwards"
|
|
7112 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
|
|
7113 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
|
|
7114 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
|
|
7115 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
|
|
7116
|
|
7117 // Remember the original values
|
|
7118 width = style.width;
|
|
7119 minWidth = style.minWidth;
|
|
7120 maxWidth = style.maxWidth;
|
|
7121
|
|
7122 // Put in the new values to get a computed value out
|
|
7123 style.minWidth = style.maxWidth = style.width = ret;
|
|
7124 ret = computed.width;
|
|
7125
|
|
7126 // Revert the changed values
|
|
7127 style.width = width;
|
|
7128 style.minWidth = minWidth;
|
|
7129 style.maxWidth = maxWidth;
|
|
7130 }
|
|
7131 }
|
|
7132
|
|
7133 return ret;
|
|
7134 };
|
|
7135 } else if ( document.documentElement.currentStyle ) {
|
|
7136 getStyles = function( elem ) {
|
|
7137 return elem.currentStyle;
|
|
7138 };
|
|
7139
|
|
7140 curCSS = function( elem, name, _computed ) {
|
|
7141 var left, rs, rsLeft,
|
|
7142 computed = _computed || getStyles( elem ),
|
|
7143 ret = computed ? computed[ name ] : undefined,
|
|
7144 style = elem.style;
|
|
7145
|
|
7146 // Avoid setting ret to empty string here
|
|
7147 // so we don't default to auto
|
|
7148 if ( ret == null && style && style[ name ] ) {
|
|
7149 ret = style[ name ];
|
|
7150 }
|
|
7151
|
|
7152 // From the awesome hack by Dean Edwards
|
|
7153 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
|
7154
|
|
7155 // If we're not dealing with a regular pixel number
|
|
7156 // but a number that has a weird ending, we need to convert it to pixels
|
|
7157 // but not position css attributes, as those are proportional to the parent element instead
|
|
7158 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
|
|
7159 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
|
|
7160
|
|
7161 // Remember the original values
|
|
7162 left = style.left;
|
|
7163 rs = elem.runtimeStyle;
|
|
7164 rsLeft = rs && rs.left;
|
|
7165
|
|
7166 // Put in the new values to get a computed value out
|
|
7167 if ( rsLeft ) {
|
|
7168 rs.left = elem.currentStyle.left;
|
|
7169 }
|
|
7170 style.left = name === "fontSize" ? "1em" : ret;
|
|
7171 ret = style.pixelLeft + "px";
|
|
7172
|
|
7173 // Revert the changed values
|
|
7174 style.left = left;
|
|
7175 if ( rsLeft ) {
|
|
7176 rs.left = rsLeft;
|
|
7177 }
|
|
7178 }
|
|
7179
|
|
7180 return ret === "" ? "auto" : ret;
|
|
7181 };
|
|
7182 }
|
|
7183
|
|
7184 function setPositiveNumber( elem, value, subtract ) {
|
|
7185 var matches = rnumsplit.exec( value );
|
|
7186 return matches ?
|
|
7187 // Guard against undefined "subtract", e.g., when used as in cssHooks
|
|
7188 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
|
|
7189 value;
|
|
7190 }
|
|
7191
|
|
7192 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
|
|
7193 var i = extra === ( isBorderBox ? "border" : "content" ) ?
|
|
7194 // If we already have the right measurement, avoid augmentation
|
|
7195 4 :
|
|
7196 // Otherwise initialize for horizontal or vertical properties
|
|
7197 name === "width" ? 1 : 0,
|
|
7198
|
|
7199 val = 0;
|
|
7200
|
|
7201 for ( ; i < 4; i += 2 ) {
|
|
7202 // both box models exclude margin, so add it if we want it
|
|
7203 if ( extra === "margin" ) {
|
|
7204 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
|
|
7205 }
|
|
7206
|
|
7207 if ( isBorderBox ) {
|
|
7208 // border-box includes padding, so remove it if we want content
|
|
7209 if ( extra === "content" ) {
|
|
7210 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
|
7211 }
|
|
7212
|
|
7213 // at this point, extra isn't border nor margin, so remove border
|
|
7214 if ( extra !== "margin" ) {
|
|
7215 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
|
7216 }
|
|
7217 } else {
|
|
7218 // at this point, extra isn't content, so add padding
|
|
7219 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
|
7220
|
|
7221 // at this point, extra isn't content nor padding, so add border
|
|
7222 if ( extra !== "padding" ) {
|
|
7223 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
|
7224 }
|
|
7225 }
|
|
7226 }
|
|
7227
|
|
7228 return val;
|
|
7229 }
|
|
7230
|
|
7231 function getWidthOrHeight( elem, name, extra ) {
|
|
7232
|
|
7233 // Start with offset property, which is equivalent to the border-box value
|
|
7234 var valueIsBorderBox = true,
|
|
7235 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
|
|
7236 styles = getStyles( elem ),
|
|
7237 isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
|
|
7238
|
|
7239 // some non-html elements return undefined for offsetWidth, so check for null/undefined
|
|
7240 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
|
|
7241 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
|
|
7242 if ( val <= 0 || val == null ) {
|
|
7243 // Fall back to computed then uncomputed css if necessary
|
|
7244 val = curCSS( elem, name, styles );
|
|
7245 if ( val < 0 || val == null ) {
|
|
7246 val = elem.style[ name ];
|
|
7247 }
|
|
7248
|
|
7249 // Computed unit is not pixels. Stop here and return.
|
|
7250 if ( rnumnonpx.test(val) ) {
|
|
7251 return val;
|
|
7252 }
|
|
7253
|
|
7254 // we need the check for style in case a browser which returns unreliable values
|
|
7255 // for getComputedStyle silently falls back to the reliable elem.style
|
|
7256 valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
|
|
7257
|
|
7258 // Normalize "", auto, and prepare for extra
|
|
7259 val = parseFloat( val ) || 0;
|
|
7260 }
|
|
7261
|
|
7262 // use the active box-sizing model to add/subtract irrelevant styles
|
|
7263 return ( val +
|
|
7264 augmentWidthOrHeight(
|
|
7265 elem,
|
|
7266 name,
|
|
7267 extra || ( isBorderBox ? "border" : "content" ),
|
|
7268 valueIsBorderBox,
|
|
7269 styles
|
|
7270 )
|
|
7271 ) + "px";
|
|
7272 }
|
|
7273
|
|
7274 // Try to determine the default display value of an element
|
|
7275 function css_defaultDisplay( nodeName ) {
|
|
7276 var doc = document,
|
|
7277 display = elemdisplay[ nodeName ];
|
|
7278
|
|
7279 if ( !display ) {
|
|
7280 display = actualDisplay( nodeName, doc );
|
|
7281
|
|
7282 // If the simple way fails, read from inside an iframe
|
|
7283 if ( display === "none" || !display ) {
|
|
7284 // Use the already-created iframe if possible
|
|
7285 iframe = ( iframe ||
|
|
7286 jQuery("<iframe frameborder='0' width='0' height='0'/>")
|
|
7287 .css( "cssText", "display:block !important" )
|
|
7288 ).appendTo( doc.documentElement );
|
|
7289
|
|
7290 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
|
|
7291 doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document;
|
|
7292 doc.write("<!doctype html><html><body>");
|
|
7293 doc.close();
|
|
7294
|
|
7295 display = actualDisplay( nodeName, doc );
|
|
7296 iframe.detach();
|
|
7297 }
|
|
7298
|
|
7299 // Store the correct default display
|
|
7300 elemdisplay[ nodeName ] = display;
|
|
7301 }
|
|
7302
|
|
7303 return display;
|
|
7304 }
|
|
7305
|
|
7306 // Called ONLY from within css_defaultDisplay
|
|
7307 function actualDisplay( name, doc ) {
|
|
7308 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
|
|
7309 display = jQuery.css( elem[0], "display" );
|
|
7310 elem.remove();
|
|
7311 return display;
|
|
7312 }
|
|
7313
|
|
7314 jQuery.each([ "height", "width" ], function( i, name ) {
|
|
7315 jQuery.cssHooks[ name ] = {
|
|
7316 get: function( elem, computed, extra ) {
|
|
7317 if ( computed ) {
|
|
7318 // certain elements can have dimension info if we invisibly show them
|
|
7319 // however, it must have a current display style that would benefit from this
|
|
7320 return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
|
|
7321 jQuery.swap( elem, cssShow, function() {
|
|
7322 return getWidthOrHeight( elem, name, extra );
|
|
7323 }) :
|
|
7324 getWidthOrHeight( elem, name, extra );
|
|
7325 }
|
|
7326 },
|
|
7327
|
|
7328 set: function( elem, value, extra ) {
|
|
7329 var styles = extra && getStyles( elem );
|
|
7330 return setPositiveNumber( elem, value, extra ?
|
|
7331 augmentWidthOrHeight(
|
|
7332 elem,
|
|
7333 name,
|
|
7334 extra,
|
|
7335 jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
|
|
7336 styles
|
|
7337 ) : 0
|
|
7338 );
|
|
7339 }
|
|
7340 };
|
|
7341 });
|
|
7342
|
|
7343 if ( !jQuery.support.opacity ) {
|
|
7344 jQuery.cssHooks.opacity = {
|
|
7345 get: function( elem, computed ) {
|
|
7346 // IE uses filters for opacity
|
|
7347 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
|
|
7348 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
|
|
7349 computed ? "1" : "";
|
|
7350 },
|
|
7351
|
|
7352 set: function( elem, value ) {
|
|
7353 var style = elem.style,
|
|
7354 currentStyle = elem.currentStyle,
|
|
7355 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
|
|
7356 filter = currentStyle && currentStyle.filter || style.filter || "";
|
|
7357
|
|
7358 // IE has trouble with opacity if it does not have layout
|
|
7359 // Force it by setting the zoom level
|
|
7360 style.zoom = 1;
|
|
7361
|
|
7362 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
|
|
7363 // if value === "", then remove inline opacity #12685
|
|
7364 if ( ( value >= 1 || value === "" ) &&
|
|
7365 jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
|
|
7366 style.removeAttribute ) {
|
|
7367
|
|
7368 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
|
|
7369 // if "filter:" is present at all, clearType is disabled, we want to avoid this
|
|
7370 // style.removeAttribute is IE Only, but so apparently is this code path...
|
|
7371 style.removeAttribute( "filter" );
|
|
7372
|
|
7373 // if there is no filter style applied in a css rule or unset inline opacity, we are done
|
|
7374 if ( value === "" || currentStyle && !currentStyle.filter ) {
|
|
7375 return;
|
|
7376 }
|
|
7377 }
|
|
7378
|
|
7379 // otherwise, set new filter values
|
|
7380 style.filter = ralpha.test( filter ) ?
|
|
7381 filter.replace( ralpha, opacity ) :
|
|
7382 filter + " " + opacity;
|
|
7383 }
|
|
7384 };
|
|
7385 }
|
|
7386
|
|
7387 // These hooks cannot be added until DOM ready because the support test
|
|
7388 // for it is not run until after DOM ready
|
|
7389 jQuery(function() {
|
|
7390 if ( !jQuery.support.reliableMarginRight ) {
|
|
7391 jQuery.cssHooks.marginRight = {
|
|
7392 get: function( elem, computed ) {
|
|
7393 if ( computed ) {
|
|
7394 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
|
7395 // Work around by temporarily setting element display to inline-block
|
|
7396 return jQuery.swap( elem, { "display": "inline-block" },
|
|
7397 curCSS, [ elem, "marginRight" ] );
|
|
7398 }
|
|
7399 }
|
|
7400 };
|
|
7401 }
|
|
7402
|
|
7403 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
|
|
7404 // getComputedStyle returns percent when specified for top/left/bottom/right
|
|
7405 // rather than make the css module depend on the offset module, we just check for it here
|
|
7406 if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
|
|
7407 jQuery.each( [ "top", "left" ], function( i, prop ) {
|
|
7408 jQuery.cssHooks[ prop ] = {
|
|
7409 get: function( elem, computed ) {
|
|
7410 if ( computed ) {
|
|
7411 computed = curCSS( elem, prop );
|
|
7412 // if curCSS returns percentage, fallback to offset
|
|
7413 return rnumnonpx.test( computed ) ?
|
|
7414 jQuery( elem ).position()[ prop ] + "px" :
|
|
7415 computed;
|
|
7416 }
|
|
7417 }
|
|
7418 };
|
|
7419 });
|
|
7420 }
|
|
7421
|
|
7422 });
|
|
7423
|
|
7424 if ( jQuery.expr && jQuery.expr.filters ) {
|
|
7425 jQuery.expr.filters.hidden = function( elem ) {
|
|
7426 // Support: Opera <= 12.12
|
|
7427 // Opera reports offsetWidths and offsetHeights less than zero on some elements
|
|
7428 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
|
|
7429 (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
|
|
7430 };
|
|
7431
|
|
7432 jQuery.expr.filters.visible = function( elem ) {
|
|
7433 return !jQuery.expr.filters.hidden( elem );
|
|
7434 };
|
|
7435 }
|
|
7436
|
|
7437 // These hooks are used by animate to expand properties
|
|
7438 jQuery.each({
|
|
7439 margin: "",
|
|
7440 padding: "",
|
|
7441 border: "Width"
|
|
7442 }, function( prefix, suffix ) {
|
|
7443 jQuery.cssHooks[ prefix + suffix ] = {
|
|
7444 expand: function( value ) {
|
|
7445 var i = 0,
|
|
7446 expanded = {},
|
|
7447
|
|
7448 // assumes a single number if not a string
|
|
7449 parts = typeof value === "string" ? value.split(" ") : [ value ];
|
|
7450
|
|
7451 for ( ; i < 4; i++ ) {
|
|
7452 expanded[ prefix + cssExpand[ i ] + suffix ] =
|
|
7453 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
|
|
7454 }
|
|
7455
|
|
7456 return expanded;
|
|
7457 }
|
|
7458 };
|
|
7459
|
|
7460 if ( !rmargin.test( prefix ) ) {
|
|
7461 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
|
|
7462 }
|
|
7463 });
|
|
7464 var r20 = /%20/g,
|
|
7465 rbracket = /\[\]$/,
|
|
7466 rCRLF = /\r?\n/g,
|
|
7467 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
|
|
7468 rsubmittable = /^(?:input|select|textarea|keygen)/i;
|
|
7469
|
|
7470 jQuery.fn.extend({
|
|
7471 serialize: function() {
|
|
7472 return jQuery.param( this.serializeArray() );
|
|
7473 },
|
|
7474 serializeArray: function() {
|
|
7475 return this.map(function(){
|
|
7476 // Can add propHook for "elements" to filter or add form elements
|
|
7477 var elements = jQuery.prop( this, "elements" );
|
|
7478 return elements ? jQuery.makeArray( elements ) : this;
|
|
7479 })
|
|
7480 .filter(function(){
|
|
7481 var type = this.type;
|
|
7482 // Use .is(":disabled") so that fieldset[disabled] works
|
|
7483 return this.name && !jQuery( this ).is( ":disabled" ) &&
|
|
7484 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
|
|
7485 ( this.checked || !manipulation_rcheckableType.test( type ) );
|
|
7486 })
|
|
7487 .map(function( i, elem ){
|
|
7488 var val = jQuery( this ).val();
|
|
7489
|
|
7490 return val == null ?
|
|
7491 null :
|
|
7492 jQuery.isArray( val ) ?
|
|
7493 jQuery.map( val, function( val ){
|
|
7494 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
|
|
7495 }) :
|
|
7496 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
|
|
7497 }).get();
|
|
7498 }
|
|
7499 });
|
|
7500
|
|
7501 //Serialize an array of form elements or a set of
|
|
7502 //key/values into a query string
|
|
7503 jQuery.param = function( a, traditional ) {
|
|
7504 var prefix,
|
|
7505 s = [],
|
|
7506 add = function( key, value ) {
|
|
7507 // If value is a function, invoke it and return its value
|
|
7508 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
|
|
7509 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
|
|
7510 };
|
|
7511
|
|
7512 // Set traditional to true for jQuery <= 1.3.2 behavior.
|
|
7513 if ( traditional === undefined ) {
|
|
7514 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
|
|
7515 }
|
|
7516
|
|
7517 // If an array was passed in, assume that it is an array of form elements.
|
|
7518 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
|
|
7519 // Serialize the form elements
|
|
7520 jQuery.each( a, function() {
|
|
7521 add( this.name, this.value );
|
|
7522 });
|
|
7523
|
|
7524 } else {
|
|
7525 // If traditional, encode the "old" way (the way 1.3.2 or older
|
|
7526 // did it), otherwise encode params recursively.
|
|
7527 for ( prefix in a ) {
|
|
7528 buildParams( prefix, a[ prefix ], traditional, add );
|
|
7529 }
|
|
7530 }
|
|
7531
|
|
7532 // Return the resulting serialization
|
|
7533 return s.join( "&" ).replace( r20, "+" );
|
|
7534 };
|
|
7535
|
|
7536 function buildParams( prefix, obj, traditional, add ) {
|
|
7537 var name;
|
|
7538
|
|
7539 if ( jQuery.isArray( obj ) ) {
|
|
7540 // Serialize array item.
|
|
7541 jQuery.each( obj, function( i, v ) {
|
|
7542 if ( traditional || rbracket.test( prefix ) ) {
|
|
7543 // Treat each array item as a scalar.
|
|
7544 add( prefix, v );
|
|
7545
|
|
7546 } else {
|
|
7547 // Item is non-scalar (array or object), encode its numeric index.
|
|
7548 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
|
|
7549 }
|
|
7550 });
|
|
7551
|
|
7552 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
|
|
7553 // Serialize object item.
|
|
7554 for ( name in obj ) {
|
|
7555 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
|
|
7556 }
|
|
7557
|
|
7558 } else {
|
|
7559 // Serialize scalar item.
|
|
7560 add( prefix, obj );
|
|
7561 }
|
|
7562 }
|
|
7563 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
|
|
7564 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
|
7565 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
|
|
7566
|
|
7567 // Handle event binding
|
|
7568 jQuery.fn[ name ] = function( data, fn ) {
|
|
7569 return arguments.length > 0 ?
|
|
7570 this.on( name, null, data, fn ) :
|
|
7571 this.trigger( name );
|
|
7572 };
|
|
7573 });
|
|
7574
|
|
7575 jQuery.fn.extend({
|
|
7576 hover: function( fnOver, fnOut ) {
|
|
7577 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
|
|
7578 },
|
|
7579
|
|
7580 bind: function( types, data, fn ) {
|
|
7581 return this.on( types, null, data, fn );
|
|
7582 },
|
|
7583 unbind: function( types, fn ) {
|
|
7584 return this.off( types, null, fn );
|
|
7585 },
|
|
7586
|
|
7587 delegate: function( selector, types, data, fn ) {
|
|
7588 return this.on( types, selector, data, fn );
|
|
7589 },
|
|
7590 undelegate: function( selector, types, fn ) {
|
|
7591 // ( namespace ) or ( selector, types [, fn] )
|
|
7592 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
|
|
7593 }
|
|
7594 });
|
|
7595 var
|
|
7596 // Document location
|
|
7597 ajaxLocParts,
|
|
7598 ajaxLocation,
|
|
7599 ajax_nonce = jQuery.now(),
|
|
7600
|
|
7601 ajax_rquery = /\?/,
|
|
7602 rhash = /#.*$/,
|
|
7603 rts = /([?&])_=[^&]*/,
|
|
7604 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
|
|
7605 // #7653, #8125, #8152: local protocol detection
|
|
7606 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
|
|
7607 rnoContent = /^(?:GET|HEAD)$/,
|
|
7608 rprotocol = /^\/\//,
|
|
7609 rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
|
|
7610
|
|
7611 // Keep a copy of the old load method
|
|
7612 _load = jQuery.fn.load,
|
|
7613
|
|
7614 /* Prefilters
|
|
7615 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
|
|
7616 * 2) These are called:
|
|
7617 * - BEFORE asking for a transport
|
|
7618 * - AFTER param serialization (s.data is a string if s.processData is true)
|
|
7619 * 3) key is the dataType
|
|
7620 * 4) the catchall symbol "*" can be used
|
|
7621 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
|
|
7622 */
|
|
7623 prefilters = {},
|
|
7624
|
|
7625 /* Transports bindings
|
|
7626 * 1) key is the dataType
|
|
7627 * 2) the catchall symbol "*" can be used
|
|
7628 * 3) selection will start with transport dataType and THEN go to "*" if needed
|
|
7629 */
|
|
7630 transports = {},
|
|
7631
|
|
7632 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
|
|
7633 allTypes = "*/".concat("*");
|
|
7634
|
|
7635 // #8138, IE may throw an exception when accessing
|
|
7636 // a field from window.location if document.domain has been set
|
|
7637 try {
|
|
7638 ajaxLocation = location.href;
|
|
7639 } catch( e ) {
|
|
7640 // Use the href attribute of an A element
|
|
7641 // since IE will modify it given document.location
|
|
7642 ajaxLocation = document.createElement( "a" );
|
|
7643 ajaxLocation.href = "";
|
|
7644 ajaxLocation = ajaxLocation.href;
|
|
7645 }
|
|
7646
|
|
7647 // Segment location into parts
|
|
7648 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
|
|
7649
|
|
7650 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
|
|
7651 function addToPrefiltersOrTransports( structure ) {
|
|
7652
|
|
7653 // dataTypeExpression is optional and defaults to "*"
|
|
7654 return function( dataTypeExpression, func ) {
|
|
7655
|
|
7656 if ( typeof dataTypeExpression !== "string" ) {
|
|
7657 func = dataTypeExpression;
|
|
7658 dataTypeExpression = "*";
|
|
7659 }
|
|
7660
|
|
7661 var dataType,
|
|
7662 i = 0,
|
|
7663 dataTypes = dataTypeExpression.toLowerCase().match( core_rnotwhite ) || [];
|
|
7664
|
|
7665 if ( jQuery.isFunction( func ) ) {
|
|
7666 // For each dataType in the dataTypeExpression
|
|
7667 while ( (dataType = dataTypes[i++]) ) {
|
|
7668 // Prepend if requested
|
|
7669 if ( dataType[0] === "+" ) {
|
|
7670 dataType = dataType.slice( 1 ) || "*";
|
|
7671 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
|
|
7672
|
|
7673 // Otherwise append
|
|
7674 } else {
|
|
7675 (structure[ dataType ] = structure[ dataType ] || []).push( func );
|
|
7676 }
|
|
7677 }
|
|
7678 }
|
|
7679 };
|
|
7680 }
|
|
7681
|
|
7682 // Base inspection function for prefilters and transports
|
|
7683 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
|
|
7684
|
|
7685 var inspected = {},
|
|
7686 seekingTransport = ( structure === transports );
|
|
7687
|
|
7688 function inspect( dataType ) {
|
|
7689 var selected;
|
|
7690 inspected[ dataType ] = true;
|
|
7691 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
|
|
7692 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
|
|
7693 if( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
|
|
7694 options.dataTypes.unshift( dataTypeOrTransport );
|
|
7695 inspect( dataTypeOrTransport );
|
|
7696 return false;
|
|
7697 } else if ( seekingTransport ) {
|
|
7698 return !( selected = dataTypeOrTransport );
|
|
7699 }
|
|
7700 });
|
|
7701 return selected;
|
|
7702 }
|
|
7703
|
|
7704 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
|
|
7705 }
|
|
7706
|
|
7707 // A special extend for ajax options
|
|
7708 // that takes "flat" options (not to be deep extended)
|
|
7709 // Fixes #9887
|
|
7710 function ajaxExtend( target, src ) {
|
|
7711 var deep, key,
|
|
7712 flatOptions = jQuery.ajaxSettings.flatOptions || {};
|
|
7713
|
|
7714 for ( key in src ) {
|
|
7715 if ( src[ key ] !== undefined ) {
|
|
7716 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
|
|
7717 }
|
|
7718 }
|
|
7719 if ( deep ) {
|
|
7720 jQuery.extend( true, target, deep );
|
|
7721 }
|
|
7722
|
|
7723 return target;
|
|
7724 }
|
|
7725
|
|
7726 jQuery.fn.load = function( url, params, callback ) {
|
|
7727 if ( typeof url !== "string" && _load ) {
|
|
7728 return _load.apply( this, arguments );
|
|
7729 }
|
|
7730
|
|
7731 var selector, response, type,
|
|
7732 self = this,
|
|
7733 off = url.indexOf(" ");
|
|
7734
|
|
7735 if ( off >= 0 ) {
|
|
7736 selector = url.slice( off, url.length );
|
|
7737 url = url.slice( 0, off );
|
|
7738 }
|
|
7739
|
|
7740 // If it's a function
|
|
7741 if ( jQuery.isFunction( params ) ) {
|
|
7742
|
|
7743 // We assume that it's the callback
|
|
7744 callback = params;
|
|
7745 params = undefined;
|
|
7746
|
|
7747 // Otherwise, build a param string
|
|
7748 } else if ( params && typeof params === "object" ) {
|
|
7749 type = "POST";
|
|
7750 }
|
|
7751
|
|
7752 // If we have elements to modify, make the request
|
|
7753 if ( self.length > 0 ) {
|
|
7754 jQuery.ajax({
|
|
7755 url: url,
|
|
7756
|
|
7757 // if "type" variable is undefined, then "GET" method will be used
|
|
7758 type: type,
|
|
7759 dataType: "html",
|
|
7760 data: params
|
|
7761 }).done(function( responseText ) {
|
|
7762
|
|
7763 // Save response for use in complete callback
|
|
7764 response = arguments;
|
|
7765
|
|
7766 self.html( selector ?
|
|
7767
|
|
7768 // If a selector was specified, locate the right elements in a dummy div
|
|
7769 // Exclude scripts to avoid IE 'Permission Denied' errors
|
|
7770 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
|
|
7771
|
|
7772 // Otherwise use the full result
|
|
7773 responseText );
|
|
7774
|
|
7775 }).complete( callback && function( jqXHR, status ) {
|
|
7776 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
|
|
7777 });
|
|
7778 }
|
|
7779
|
|
7780 return this;
|
|
7781 };
|
|
7782
|
|
7783 // Attach a bunch of functions for handling common AJAX events
|
|
7784 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){
|
|
7785 jQuery.fn[ type ] = function( fn ){
|
|
7786 return this.on( type, fn );
|
|
7787 };
|
|
7788 });
|
|
7789
|
|
7790 jQuery.extend({
|
|
7791
|
|
7792 // Counter for holding the number of active queries
|
|
7793 active: 0,
|
|
7794
|
|
7795 // Last-Modified header cache for next request
|
|
7796 lastModified: {},
|
|
7797 etag: {},
|
|
7798
|
|
7799 ajaxSettings: {
|
|
7800 url: ajaxLocation,
|
|
7801 type: "GET",
|
|
7802 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
|
|
7803 global: true,
|
|
7804 processData: true,
|
|
7805 async: true,
|
|
7806 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
|
|
7807 /*
|
|
7808 timeout: 0,
|
|
7809 data: null,
|
|
7810 dataType: null,
|
|
7811 username: null,
|
|
7812 password: null,
|
|
7813 cache: null,
|
|
7814 throws: false,
|
|
7815 traditional: false,
|
|
7816 headers: {},
|
|
7817 */
|
|
7818
|
|
7819 accepts: {
|
|
7820 "*": allTypes,
|
|
7821 text: "text/plain",
|
|
7822 html: "text/html",
|
|
7823 xml: "application/xml, text/xml",
|
|
7824 json: "application/json, text/javascript"
|
|
7825 },
|
|
7826
|
|
7827 contents: {
|
|
7828 xml: /xml/,
|
|
7829 html: /html/,
|
|
7830 json: /json/
|
|
7831 },
|
|
7832
|
|
7833 responseFields: {
|
|
7834 xml: "responseXML",
|
|
7835 text: "responseText",
|
|
7836 json: "responseJSON"
|
|
7837 },
|
|
7838
|
|
7839 // Data converters
|
|
7840 // Keys separate source (or catchall "*") and destination types with a single space
|
|
7841 converters: {
|
|
7842
|
|
7843 // Convert anything to text
|
|
7844 "* text": String,
|
|
7845
|
|
7846 // Text to html (true = no transformation)
|
|
7847 "text html": true,
|
|
7848
|
|
7849 // Evaluate text as a json expression
|
|
7850 "text json": jQuery.parseJSON,
|
|
7851
|
|
7852 // Parse text as xml
|
|
7853 "text xml": jQuery.parseXML
|
|
7854 },
|
|
7855
|
|
7856 // For options that shouldn't be deep extended:
|
|
7857 // you can add your own custom options here if
|
|
7858 // and when you create one that shouldn't be
|
|
7859 // deep extended (see ajaxExtend)
|
|
7860 flatOptions: {
|
|
7861 url: true,
|
|
7862 context: true
|
|
7863 }
|
|
7864 },
|
|
7865
|
|
7866 // Creates a full fledged settings object into target
|
|
7867 // with both ajaxSettings and settings fields.
|
|
7868 // If target is omitted, writes into ajaxSettings.
|
|
7869 ajaxSetup: function( target, settings ) {
|
|
7870 return settings ?
|
|
7871
|
|
7872 // Building a settings object
|
|
7873 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
|
|
7874
|
|
7875 // Extending ajaxSettings
|
|
7876 ajaxExtend( jQuery.ajaxSettings, target );
|
|
7877 },
|
|
7878
|
|
7879 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
|
|
7880 ajaxTransport: addToPrefiltersOrTransports( transports ),
|
|
7881
|
|
7882 // Main method
|
|
7883 ajax: function( url, options ) {
|
|
7884
|
|
7885 // If url is an object, simulate pre-1.5 signature
|
|
7886 if ( typeof url === "object" ) {
|
|
7887 options = url;
|
|
7888 url = undefined;
|
|
7889 }
|
|
7890
|
|
7891 // Force options to be an object
|
|
7892 options = options || {};
|
|
7893
|
|
7894 var // Cross-domain detection vars
|
|
7895 parts,
|
|
7896 // Loop variable
|
|
7897 i,
|
|
7898 // URL without anti-cache param
|
|
7899 cacheURL,
|
|
7900 // Response headers as string
|
|
7901 responseHeadersString,
|
|
7902 // timeout handle
|
|
7903 timeoutTimer,
|
|
7904
|
|
7905 // To know if global events are to be dispatched
|
|
7906 fireGlobals,
|
|
7907
|
|
7908 transport,
|
|
7909 // Response headers
|
|
7910 responseHeaders,
|
|
7911 // Create the final options object
|
|
7912 s = jQuery.ajaxSetup( {}, options ),
|
|
7913 // Callbacks context
|
|
7914 callbackContext = s.context || s,
|
|
7915 // Context for global events is callbackContext if it is a DOM node or jQuery collection
|
|
7916 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
|
|
7917 jQuery( callbackContext ) :
|
|
7918 jQuery.event,
|
|
7919 // Deferreds
|
|
7920 deferred = jQuery.Deferred(),
|
|
7921 completeDeferred = jQuery.Callbacks("once memory"),
|
|
7922 // Status-dependent callbacks
|
|
7923 statusCode = s.statusCode || {},
|
|
7924 // Headers (they are sent all at once)
|
|
7925 requestHeaders = {},
|
|
7926 requestHeadersNames = {},
|
|
7927 // The jqXHR state
|
|
7928 state = 0,
|
|
7929 // Default abort message
|
|
7930 strAbort = "canceled",
|
|
7931 // Fake xhr
|
|
7932 jqXHR = {
|
|
7933 readyState: 0,
|
|
7934
|
|
7935 // Builds headers hashtable if needed
|
|
7936 getResponseHeader: function( key ) {
|
|
7937 var match;
|
|
7938 if ( state === 2 ) {
|
|
7939 if ( !responseHeaders ) {
|
|
7940 responseHeaders = {};
|
|
7941 while ( (match = rheaders.exec( responseHeadersString )) ) {
|
|
7942 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
|
|
7943 }
|
|
7944 }
|
|
7945 match = responseHeaders[ key.toLowerCase() ];
|
|
7946 }
|
|
7947 return match == null ? null : match;
|
|
7948 },
|
|
7949
|
|
7950 // Raw string
|
|
7951 getAllResponseHeaders: function() {
|
|
7952 return state === 2 ? responseHeadersString : null;
|
|
7953 },
|
|
7954
|
|
7955 // Caches the header
|
|
7956 setRequestHeader: function( name, value ) {
|
|
7957 var lname = name.toLowerCase();
|
|
7958 if ( !state ) {
|
|
7959 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
|
|
7960 requestHeaders[ name ] = value;
|
|
7961 }
|
|
7962 return this;
|
|
7963 },
|
|
7964
|
|
7965 // Overrides response content-type header
|
|
7966 overrideMimeType: function( type ) {
|
|
7967 if ( !state ) {
|
|
7968 s.mimeType = type;
|
|
7969 }
|
|
7970 return this;
|
|
7971 },
|
|
7972
|
|
7973 // Status-dependent callbacks
|
|
7974 statusCode: function( map ) {
|
|
7975 var code;
|
|
7976 if ( map ) {
|
|
7977 if ( state < 2 ) {
|
|
7978 for ( code in map ) {
|
|
7979 // Lazy-add the new callback in a way that preserves old ones
|
|
7980 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
|
|
7981 }
|
|
7982 } else {
|
|
7983 // Execute the appropriate callbacks
|
|
7984 jqXHR.always( map[ jqXHR.status ] );
|
|
7985 }
|
|
7986 }
|
|
7987 return this;
|
|
7988 },
|
|
7989
|
|
7990 // Cancel the request
|
|
7991 abort: function( statusText ) {
|
|
7992 var finalText = statusText || strAbort;
|
|
7993 if ( transport ) {
|
|
7994 transport.abort( finalText );
|
|
7995 }
|
|
7996 done( 0, finalText );
|
|
7997 return this;
|
|
7998 }
|
|
7999 };
|
|
8000
|
|
8001 // Attach deferreds
|
|
8002 deferred.promise( jqXHR ).complete = completeDeferred.add;
|
|
8003 jqXHR.success = jqXHR.done;
|
|
8004 jqXHR.error = jqXHR.fail;
|
|
8005
|
|
8006 // Remove hash character (#7531: and string promotion)
|
|
8007 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
|
|
8008 // Handle falsy url in the settings object (#10093: consistency with old signature)
|
|
8009 // We also use the url parameter if available
|
|
8010 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
|
|
8011
|
|
8012 // Alias method option to type as per ticket #12004
|
|
8013 s.type = options.method || options.type || s.method || s.type;
|
|
8014
|
|
8015 // Extract dataTypes list
|
|
8016 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( core_rnotwhite ) || [""];
|
|
8017
|
|
8018 // A cross-domain request is in order when we have a protocol:host:port mismatch
|
|
8019 if ( s.crossDomain == null ) {
|
|
8020 parts = rurl.exec( s.url.toLowerCase() );
|
|
8021 s.crossDomain = !!( parts &&
|
|
8022 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
|
|
8023 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
|
|
8024 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
|
|
8025 );
|
|
8026 }
|
|
8027
|
|
8028 // Convert data if not already a string
|
|
8029 if ( s.data && s.processData && typeof s.data !== "string" ) {
|
|
8030 s.data = jQuery.param( s.data, s.traditional );
|
|
8031 }
|
|
8032
|
|
8033 // Apply prefilters
|
|
8034 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
|
|
8035
|
|
8036 // If request was aborted inside a prefilter, stop there
|
|
8037 if ( state === 2 ) {
|
|
8038 return jqXHR;
|
|
8039 }
|
|
8040
|
|
8041 // We can fire global events as of now if asked to
|
|
8042 fireGlobals = s.global;
|
|
8043
|
|
8044 // Watch for a new set of requests
|
|
8045 if ( fireGlobals && jQuery.active++ === 0 ) {
|
|
8046 jQuery.event.trigger("ajaxStart");
|
|
8047 }
|
|
8048
|
|
8049 // Uppercase the type
|
|
8050 s.type = s.type.toUpperCase();
|
|
8051
|
|
8052 // Determine if request has content
|
|
8053 s.hasContent = !rnoContent.test( s.type );
|
|
8054
|
|
8055 // Save the URL in case we're toying with the If-Modified-Since
|
|
8056 // and/or If-None-Match header later on
|
|
8057 cacheURL = s.url;
|
|
8058
|
|
8059 // More options handling for requests with no content
|
|
8060 if ( !s.hasContent ) {
|
|
8061
|
|
8062 // If data is available, append data to url
|
|
8063 if ( s.data ) {
|
|
8064 cacheURL = ( s.url += ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
|
|
8065 // #9682: remove data so that it's not used in an eventual retry
|
|
8066 delete s.data;
|
|
8067 }
|
|
8068
|
|
8069 // Add anti-cache in url if needed
|
|
8070 if ( s.cache === false ) {
|
|
8071 s.url = rts.test( cacheURL ) ?
|
|
8072
|
|
8073 // If there is already a '_' parameter, set its value
|
|
8074 cacheURL.replace( rts, "$1_=" + ajax_nonce++ ) :
|
|
8075
|
|
8076 // Otherwise add one to the end
|
|
8077 cacheURL + ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ajax_nonce++;
|
|
8078 }
|
|
8079 }
|
|
8080
|
|
8081 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
|
8082 if ( s.ifModified ) {
|
|
8083 if ( jQuery.lastModified[ cacheURL ] ) {
|
|
8084 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
|
|
8085 }
|
|
8086 if ( jQuery.etag[ cacheURL ] ) {
|
|
8087 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
|
|
8088 }
|
|
8089 }
|
|
8090
|
|
8091 // Set the correct header, if data is being sent
|
|
8092 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
|
|
8093 jqXHR.setRequestHeader( "Content-Type", s.contentType );
|
|
8094 }
|
|
8095
|
|
8096 // Set the Accepts header for the server, depending on the dataType
|
|
8097 jqXHR.setRequestHeader(
|
|
8098 "Accept",
|
|
8099 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
|
|
8100 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
|
|
8101 s.accepts[ "*" ]
|
|
8102 );
|
|
8103
|
|
8104 // Check for headers option
|
|
8105 for ( i in s.headers ) {
|
|
8106 jqXHR.setRequestHeader( i, s.headers[ i ] );
|
|
8107 }
|
|
8108
|
|
8109 // Allow custom headers/mimetypes and early abort
|
|
8110 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
|
|
8111 // Abort if not done already and return
|
|
8112 return jqXHR.abort();
|
|
8113 }
|
|
8114
|
|
8115 // aborting is no longer a cancellation
|
|
8116 strAbort = "abort";
|
|
8117
|
|
8118 // Install callbacks on deferreds
|
|
8119 for ( i in { success: 1, error: 1, complete: 1 } ) {
|
|
8120 jqXHR[ i ]( s[ i ] );
|
|
8121 }
|
|
8122
|
|
8123 // Get transport
|
|
8124 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
|
|
8125
|
|
8126 // If no transport, we auto-abort
|
|
8127 if ( !transport ) {
|
|
8128 done( -1, "No Transport" );
|
|
8129 } else {
|
|
8130 jqXHR.readyState = 1;
|
|
8131
|
|
8132 // Send global event
|
|
8133 if ( fireGlobals ) {
|
|
8134 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
|
|
8135 }
|
|
8136 // Timeout
|
|
8137 if ( s.async && s.timeout > 0 ) {
|
|
8138 timeoutTimer = setTimeout(function() {
|
|
8139 jqXHR.abort("timeout");
|
|
8140 }, s.timeout );
|
|
8141 }
|
|
8142
|
|
8143 try {
|
|
8144 state = 1;
|
|
8145 transport.send( requestHeaders, done );
|
|
8146 } catch ( e ) {
|
|
8147 // Propagate exception as error if not done
|
|
8148 if ( state < 2 ) {
|
|
8149 done( -1, e );
|
|
8150 // Simply rethrow otherwise
|
|
8151 } else {
|
|
8152 throw e;
|
|
8153 }
|
|
8154 }
|
|
8155 }
|
|
8156
|
|
8157 // Callback for when everything is done
|
|
8158 function done( status, nativeStatusText, responses, headers ) {
|
|
8159 var isSuccess, success, error, response, modified,
|
|
8160 statusText = nativeStatusText;
|
|
8161
|
|
8162 // Called once
|
|
8163 if ( state === 2 ) {
|
|
8164 return;
|
|
8165 }
|
|
8166
|
|
8167 // State is "done" now
|
|
8168 state = 2;
|
|
8169
|
|
8170 // Clear timeout if it exists
|
|
8171 if ( timeoutTimer ) {
|
|
8172 clearTimeout( timeoutTimer );
|
|
8173 }
|
|
8174
|
|
8175 // Dereference transport for early garbage collection
|
|
8176 // (no matter how long the jqXHR object will be used)
|
|
8177 transport = undefined;
|
|
8178
|
|
8179 // Cache response headers
|
|
8180 responseHeadersString = headers || "";
|
|
8181
|
|
8182 // Set readyState
|
|
8183 jqXHR.readyState = status > 0 ? 4 : 0;
|
|
8184
|
|
8185 // Determine if successful
|
|
8186 isSuccess = status >= 200 && status < 300 || status === 304;
|
|
8187
|
|
8188 // Get response data
|
|
8189 if ( responses ) {
|
|
8190 response = ajaxHandleResponses( s, jqXHR, responses );
|
|
8191 }
|
|
8192
|
|
8193 // Convert no matter what (that way responseXXX fields are always set)
|
|
8194 response = ajaxConvert( s, response, jqXHR, isSuccess );
|
|
8195
|
|
8196 // If successful, handle type chaining
|
|
8197 if ( isSuccess ) {
|
|
8198
|
|
8199 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
|
8200 if ( s.ifModified ) {
|
|
8201 modified = jqXHR.getResponseHeader("Last-Modified");
|
|
8202 if ( modified ) {
|
|
8203 jQuery.lastModified[ cacheURL ] = modified;
|
|
8204 }
|
|
8205 modified = jqXHR.getResponseHeader("etag");
|
|
8206 if ( modified ) {
|
|
8207 jQuery.etag[ cacheURL ] = modified;
|
|
8208 }
|
|
8209 }
|
|
8210
|
|
8211 // if no content
|
|
8212 if ( status === 204 || s.type === "HEAD" ) {
|
|
8213 statusText = "nocontent";
|
|
8214
|
|
8215 // if not modified
|
|
8216 } else if ( status === 304 ) {
|
|
8217 statusText = "notmodified";
|
|
8218
|
|
8219 // If we have data, let's convert it
|
|
8220 } else {
|
|
8221 statusText = response.state;
|
|
8222 success = response.data;
|
|
8223 error = response.error;
|
|
8224 isSuccess = !error;
|
|
8225 }
|
|
8226 } else {
|
|
8227 // We extract error from statusText
|
|
8228 // then normalize statusText and status for non-aborts
|
|
8229 error = statusText;
|
|
8230 if ( status || !statusText ) {
|
|
8231 statusText = "error";
|
|
8232 if ( status < 0 ) {
|
|
8233 status = 0;
|
|
8234 }
|
|
8235 }
|
|
8236 }
|
|
8237
|
|
8238 // Set data for the fake xhr object
|
|
8239 jqXHR.status = status;
|
|
8240 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
|
|
8241
|
|
8242 // Success/Error
|
|
8243 if ( isSuccess ) {
|
|
8244 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
|
|
8245 } else {
|
|
8246 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
|
|
8247 }
|
|
8248
|
|
8249 // Status-dependent callbacks
|
|
8250 jqXHR.statusCode( statusCode );
|
|
8251 statusCode = undefined;
|
|
8252
|
|
8253 if ( fireGlobals ) {
|
|
8254 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
|
|
8255 [ jqXHR, s, isSuccess ? success : error ] );
|
|
8256 }
|
|
8257
|
|
8258 // Complete
|
|
8259 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
|
|
8260
|
|
8261 if ( fireGlobals ) {
|
|
8262 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
|
|
8263 // Handle the global AJAX counter
|
|
8264 if ( !( --jQuery.active ) ) {
|
|
8265 jQuery.event.trigger("ajaxStop");
|
|
8266 }
|
|
8267 }
|
|
8268 }
|
|
8269
|
|
8270 return jqXHR;
|
|
8271 },
|
|
8272
|
|
8273 getJSON: function( url, data, callback ) {
|
|
8274 return jQuery.get( url, data, callback, "json" );
|
|
8275 },
|
|
8276
|
|
8277 getScript: function( url, callback ) {
|
|
8278 return jQuery.get( url, undefined, callback, "script" );
|
|
8279 }
|
|
8280 });
|
|
8281
|
|
8282 jQuery.each( [ "get", "post" ], function( i, method ) {
|
|
8283 jQuery[ method ] = function( url, data, callback, type ) {
|
|
8284 // shift arguments if data argument was omitted
|
|
8285 if ( jQuery.isFunction( data ) ) {
|
|
8286 type = type || callback;
|
|
8287 callback = data;
|
|
8288 data = undefined;
|
|
8289 }
|
|
8290
|
|
8291 return jQuery.ajax({
|
|
8292 url: url,
|
|
8293 type: method,
|
|
8294 dataType: type,
|
|
8295 data: data,
|
|
8296 success: callback
|
|
8297 });
|
|
8298 };
|
|
8299 });
|
|
8300
|
|
8301 /* Handles responses to an ajax request:
|
|
8302 * - finds the right dataType (mediates between content-type and expected dataType)
|
|
8303 * - returns the corresponding response
|
|
8304 */
|
|
8305 function ajaxHandleResponses( s, jqXHR, responses ) {
|
|
8306 var firstDataType, ct, finalDataType, type,
|
|
8307 contents = s.contents,
|
|
8308 dataTypes = s.dataTypes;
|
|
8309
|
|
8310 // Remove auto dataType and get content-type in the process
|
|
8311 while( dataTypes[ 0 ] === "*" ) {
|
|
8312 dataTypes.shift();
|
|
8313 if ( ct === undefined ) {
|
|
8314 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
|
|
8315 }
|
|
8316 }
|
|
8317
|
|
8318 // Check if we're dealing with a known content-type
|
|
8319 if ( ct ) {
|
|
8320 for ( type in contents ) {
|
|
8321 if ( contents[ type ] && contents[ type ].test( ct ) ) {
|
|
8322 dataTypes.unshift( type );
|
|
8323 break;
|
|
8324 }
|
|
8325 }
|
|
8326 }
|
|
8327
|
|
8328 // Check to see if we have a response for the expected dataType
|
|
8329 if ( dataTypes[ 0 ] in responses ) {
|
|
8330 finalDataType = dataTypes[ 0 ];
|
|
8331 } else {
|
|
8332 // Try convertible dataTypes
|
|
8333 for ( type in responses ) {
|
|
8334 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
|
|
8335 finalDataType = type;
|
|
8336 break;
|
|
8337 }
|
|
8338 if ( !firstDataType ) {
|
|
8339 firstDataType = type;
|
|
8340 }
|
|
8341 }
|
|
8342 // Or just use first one
|
|
8343 finalDataType = finalDataType || firstDataType;
|
|
8344 }
|
|
8345
|
|
8346 // If we found a dataType
|
|
8347 // We add the dataType to the list if needed
|
|
8348 // and return the corresponding response
|
|
8349 if ( finalDataType ) {
|
|
8350 if ( finalDataType !== dataTypes[ 0 ] ) {
|
|
8351 dataTypes.unshift( finalDataType );
|
|
8352 }
|
|
8353 return responses[ finalDataType ];
|
|
8354 }
|
|
8355 }
|
|
8356
|
|
8357 /* Chain conversions given the request and the original response
|
|
8358 * Also sets the responseXXX fields on the jqXHR instance
|
|
8359 */
|
|
8360 function ajaxConvert( s, response, jqXHR, isSuccess ) {
|
|
8361 var conv2, current, conv, tmp, prev,
|
|
8362 converters = {},
|
|
8363 // Work with a copy of dataTypes in case we need to modify it for conversion
|
|
8364 dataTypes = s.dataTypes.slice();
|
|
8365
|
|
8366 // Create converters map with lowercased keys
|
|
8367 if ( dataTypes[ 1 ] ) {
|
|
8368 for ( conv in s.converters ) {
|
|
8369 converters[ conv.toLowerCase() ] = s.converters[ conv ];
|
|
8370 }
|
|
8371 }
|
|
8372
|
|
8373 current = dataTypes.shift();
|
|
8374
|
|
8375 // Convert to each sequential dataType
|
|
8376 while ( current ) {
|
|
8377
|
|
8378 if ( s.responseFields[ current ] ) {
|
|
8379 jqXHR[ s.responseFields[ current ] ] = response;
|
|
8380 }
|
|
8381
|
|
8382 // Apply the dataFilter if provided
|
|
8383 if ( !prev && isSuccess && s.dataFilter ) {
|
|
8384 response = s.dataFilter( response, s.dataType );
|
|
8385 }
|
|
8386
|
|
8387 prev = current;
|
|
8388 current = dataTypes.shift();
|
|
8389
|
|
8390 if ( current ) {
|
|
8391
|
|
8392 // There's only work to do if current dataType is non-auto
|
|
8393 if ( current === "*" ) {
|
|
8394
|
|
8395 current = prev;
|
|
8396
|
|
8397 // Convert response if prev dataType is non-auto and differs from current
|
|
8398 } else if ( prev !== "*" && prev !== current ) {
|
|
8399
|
|
8400 // Seek a direct converter
|
|
8401 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
|
|
8402
|
|
8403 // If none found, seek a pair
|
|
8404 if ( !conv ) {
|
|
8405 for ( conv2 in converters ) {
|
|
8406
|
|
8407 // If conv2 outputs current
|
|
8408 tmp = conv2.split( " " );
|
|
8409 if ( tmp[ 1 ] === current ) {
|
|
8410
|
|
8411 // If prev can be converted to accepted input
|
|
8412 conv = converters[ prev + " " + tmp[ 0 ] ] ||
|
|
8413 converters[ "* " + tmp[ 0 ] ];
|
|
8414 if ( conv ) {
|
|
8415 // Condense equivalence converters
|
|
8416 if ( conv === true ) {
|
|
8417 conv = converters[ conv2 ];
|
|
8418
|
|
8419 // Otherwise, insert the intermediate dataType
|
|
8420 } else if ( converters[ conv2 ] !== true ) {
|
|
8421 current = tmp[ 0 ];
|
|
8422 dataTypes.unshift( tmp[ 1 ] );
|
|
8423 }
|
|
8424 break;
|
|
8425 }
|
|
8426 }
|
|
8427 }
|
|
8428 }
|
|
8429
|
|
8430 // Apply converter (if not an equivalence)
|
|
8431 if ( conv !== true ) {
|
|
8432
|
|
8433 // Unless errors are allowed to bubble, catch and return them
|
|
8434 if ( conv && s[ "throws" ] ) {
|
|
8435 response = conv( response );
|
|
8436 } else {
|
|
8437 try {
|
|
8438 response = conv( response );
|
|
8439 } catch ( e ) {
|
|
8440 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
|
|
8441 }
|
|
8442 }
|
|
8443 }
|
|
8444 }
|
|
8445 }
|
|
8446 }
|
|
8447
|
|
8448 return { state: "success", data: response };
|
|
8449 }
|
|
8450 // Install script dataType
|
|
8451 jQuery.ajaxSetup({
|
|
8452 accepts: {
|
|
8453 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
|
|
8454 },
|
|
8455 contents: {
|
|
8456 script: /(?:java|ecma)script/
|
|
8457 },
|
|
8458 converters: {
|
|
8459 "text script": function( text ) {
|
|
8460 jQuery.globalEval( text );
|
|
8461 return text;
|
|
8462 }
|
|
8463 }
|
|
8464 });
|
|
8465
|
|
8466 // Handle cache's special case and global
|
|
8467 jQuery.ajaxPrefilter( "script", function( s ) {
|
|
8468 if ( s.cache === undefined ) {
|
|
8469 s.cache = false;
|
|
8470 }
|
|
8471 if ( s.crossDomain ) {
|
|
8472 s.type = "GET";
|
|
8473 s.global = false;
|
|
8474 }
|
|
8475 });
|
|
8476
|
|
8477 // Bind script tag hack transport
|
|
8478 jQuery.ajaxTransport( "script", function(s) {
|
|
8479
|
|
8480 // This transport only deals with cross domain requests
|
|
8481 if ( s.crossDomain ) {
|
|
8482
|
|
8483 var script,
|
|
8484 head = document.head || jQuery("head")[0] || document.documentElement;
|
|
8485
|
|
8486 return {
|
|
8487
|
|
8488 send: function( _, callback ) {
|
|
8489
|
|
8490 script = document.createElement("script");
|
|
8491
|
|
8492 script.async = true;
|
|
8493
|
|
8494 if ( s.scriptCharset ) {
|
|
8495 script.charset = s.scriptCharset;
|
|
8496 }
|
|
8497
|
|
8498 script.src = s.url;
|
|
8499
|
|
8500 // Attach handlers for all browsers
|
|
8501 script.onload = script.onreadystatechange = function( _, isAbort ) {
|
|
8502
|
|
8503 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
|
|
8504
|
|
8505 // Handle memory leak in IE
|
|
8506 script.onload = script.onreadystatechange = null;
|
|
8507
|
|
8508 // Remove the script
|
|
8509 if ( script.parentNode ) {
|
|
8510 script.parentNode.removeChild( script );
|
|
8511 }
|
|
8512
|
|
8513 // Dereference the script
|
|
8514 script = null;
|
|
8515
|
|
8516 // Callback if not abort
|
|
8517 if ( !isAbort ) {
|
|
8518 callback( 200, "success" );
|
|
8519 }
|
|
8520 }
|
|
8521 };
|
|
8522
|
|
8523 // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
|
|
8524 // Use native DOM manipulation to avoid our domManip AJAX trickery
|
|
8525 head.insertBefore( script, head.firstChild );
|
|
8526 },
|
|
8527
|
|
8528 abort: function() {
|
|
8529 if ( script ) {
|
|
8530 script.onload( undefined, true );
|
|
8531 }
|
|
8532 }
|
|
8533 };
|
|
8534 }
|
|
8535 });
|
|
8536 var oldCallbacks = [],
|
|
8537 rjsonp = /(=)\?(?=&|$)|\?\?/;
|
|
8538
|
|
8539 // Default jsonp settings
|
|
8540 jQuery.ajaxSetup({
|
|
8541 jsonp: "callback",
|
|
8542 jsonpCallback: function() {
|
|
8543 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) );
|
|
8544 this[ callback ] = true;
|
|
8545 return callback;
|
|
8546 }
|
|
8547 });
|
|
8548
|
|
8549 // Detect, normalize options and install callbacks for jsonp requests
|
|
8550 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
|
8551
|
|
8552 var callbackName, overwritten, responseContainer,
|
|
8553 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
|
|
8554 "url" :
|
|
8555 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
|
|
8556 );
|
|
8557
|
|
8558 // Handle iff the expected data type is "jsonp" or we have a parameter to set
|
|
8559 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
|
|
8560
|
|
8561 // Get callback name, remembering preexisting value associated with it
|
|
8562 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
|
|
8563 s.jsonpCallback() :
|
|
8564 s.jsonpCallback;
|
|
8565
|
|
8566 // Insert callback into url or form data
|
|
8567 if ( jsonProp ) {
|
|
8568 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
|
|
8569 } else if ( s.jsonp !== false ) {
|
|
8570 s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
|
|
8571 }
|
|
8572
|
|
8573 // Use data converter to retrieve json after script execution
|
|
8574 s.converters["script json"] = function() {
|
|
8575 if ( !responseContainer ) {
|
|
8576 jQuery.error( callbackName + " was not called" );
|
|
8577 }
|
|
8578 return responseContainer[ 0 ];
|
|
8579 };
|
|
8580
|
|
8581 // force json dataType
|
|
8582 s.dataTypes[ 0 ] = "json";
|
|
8583
|
|
8584 // Install callback
|
|
8585 overwritten = window[ callbackName ];
|
|
8586 window[ callbackName ] = function() {
|
|
8587 responseContainer = arguments;
|
|
8588 };
|
|
8589
|
|
8590 // Clean-up function (fires after converters)
|
|
8591 jqXHR.always(function() {
|
|
8592 // Restore preexisting value
|
|
8593 window[ callbackName ] = overwritten;
|
|
8594
|
|
8595 // Save back as free
|
|
8596 if ( s[ callbackName ] ) {
|
|
8597 // make sure that re-using the options doesn't screw things around
|
|
8598 s.jsonpCallback = originalSettings.jsonpCallback;
|
|
8599
|
|
8600 // save the callback name for future use
|
|
8601 oldCallbacks.push( callbackName );
|
|
8602 }
|
|
8603
|
|
8604 // Call if it was a function and we have a response
|
|
8605 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
|
|
8606 overwritten( responseContainer[ 0 ] );
|
|
8607 }
|
|
8608
|
|
8609 responseContainer = overwritten = undefined;
|
|
8610 });
|
|
8611
|
|
8612 // Delegate to script
|
|
8613 return "script";
|
|
8614 }
|
|
8615 });
|
|
8616 var xhrCallbacks, xhrSupported,
|
|
8617 xhrId = 0,
|
|
8618 // #5280: Internet Explorer will keep connections alive if we don't abort on unload
|
|
8619 xhrOnUnloadAbort = window.ActiveXObject && function() {
|
|
8620 // Abort all pending requests
|
|
8621 var key;
|
|
8622 for ( key in xhrCallbacks ) {
|
|
8623 xhrCallbacks[ key ]( undefined, true );
|
|
8624 }
|
|
8625 };
|
|
8626
|
|
8627 // Functions to create xhrs
|
|
8628 function createStandardXHR() {
|
|
8629 try {
|
|
8630 return new window.XMLHttpRequest();
|
|
8631 } catch( e ) {}
|
|
8632 }
|
|
8633
|
|
8634 function createActiveXHR() {
|
|
8635 try {
|
|
8636 return new window.ActiveXObject("Microsoft.XMLHTTP");
|
|
8637 } catch( e ) {}
|
|
8638 }
|
|
8639
|
|
8640 // Create the request object
|
|
8641 // (This is still attached to ajaxSettings for backward compatibility)
|
|
8642 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
|
|
8643 /* Microsoft failed to properly
|
|
8644 * implement the XMLHttpRequest in IE7 (can't request local files),
|
|
8645 * so we use the ActiveXObject when it is available
|
|
8646 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
|
|
8647 * we need a fallback.
|
|
8648 */
|
|
8649 function() {
|
|
8650 return !this.isLocal && createStandardXHR() || createActiveXHR();
|
|
8651 } :
|
|
8652 // For all other browsers, use the standard XMLHttpRequest object
|
|
8653 createStandardXHR;
|
|
8654
|
|
8655 // Determine support properties
|
|
8656 xhrSupported = jQuery.ajaxSettings.xhr();
|
|
8657 jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
|
|
8658 xhrSupported = jQuery.support.ajax = !!xhrSupported;
|
|
8659
|
|
8660 // Create transport if the browser can provide an xhr
|
|
8661 if ( xhrSupported ) {
|
|
8662
|
|
8663 jQuery.ajaxTransport(function( s ) {
|
|
8664 // Cross domain only allowed if supported through XMLHttpRequest
|
|
8665 if ( !s.crossDomain || jQuery.support.cors ) {
|
|
8666
|
|
8667 var callback;
|
|
8668
|
|
8669 return {
|
|
8670 send: function( headers, complete ) {
|
|
8671
|
|
8672 // Get a new xhr
|
|
8673 var handle, i,
|
|
8674 xhr = s.xhr();
|
|
8675
|
|
8676 // Open the socket
|
|
8677 // Passing null username, generates a login popup on Opera (#2865)
|
|
8678 if ( s.username ) {
|
|
8679 xhr.open( s.type, s.url, s.async, s.username, s.password );
|
|
8680 } else {
|
|
8681 xhr.open( s.type, s.url, s.async );
|
|
8682 }
|
|
8683
|
|
8684 // Apply custom fields if provided
|
|
8685 if ( s.xhrFields ) {
|
|
8686 for ( i in s.xhrFields ) {
|
|
8687 xhr[ i ] = s.xhrFields[ i ];
|
|
8688 }
|
|
8689 }
|
|
8690
|
|
8691 // Override mime type if needed
|
|
8692 if ( s.mimeType && xhr.overrideMimeType ) {
|
|
8693 xhr.overrideMimeType( s.mimeType );
|
|
8694 }
|
|
8695
|
|
8696 // X-Requested-With header
|
|
8697 // For cross-domain requests, seeing as conditions for a preflight are
|
|
8698 // akin to a jigsaw puzzle, we simply never set it to be sure.
|
|
8699 // (it can always be set on a per-request basis or even using ajaxSetup)
|
|
8700 // For same-domain requests, won't change header if already provided.
|
|
8701 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
|
|
8702 headers["X-Requested-With"] = "XMLHttpRequest";
|
|
8703 }
|
|
8704
|
|
8705 // Need an extra try/catch for cross domain requests in Firefox 3
|
|
8706 try {
|
|
8707 for ( i in headers ) {
|
|
8708 xhr.setRequestHeader( i, headers[ i ] );
|
|
8709 }
|
|
8710 } catch( err ) {}
|
|
8711
|
|
8712 // Do send the request
|
|
8713 // This may raise an exception which is actually
|
|
8714 // handled in jQuery.ajax (so no try/catch here)
|
|
8715 xhr.send( ( s.hasContent && s.data ) || null );
|
|
8716
|
|
8717 // Listener
|
|
8718 callback = function( _, isAbort ) {
|
|
8719 var status, responseHeaders, statusText, responses;
|
|
8720
|
|
8721 // Firefox throws exceptions when accessing properties
|
|
8722 // of an xhr when a network error occurred
|
|
8723 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
|
|
8724 try {
|
|
8725
|
|
8726 // Was never called and is aborted or complete
|
|
8727 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
|
|
8728
|
|
8729 // Only called once
|
|
8730 callback = undefined;
|
|
8731
|
|
8732 // Do not keep as active anymore
|
|
8733 if ( handle ) {
|
|
8734 xhr.onreadystatechange = jQuery.noop;
|
|
8735 if ( xhrOnUnloadAbort ) {
|
|
8736 delete xhrCallbacks[ handle ];
|
|
8737 }
|
|
8738 }
|
|
8739
|
|
8740 // If it's an abort
|
|
8741 if ( isAbort ) {
|
|
8742 // Abort it manually if needed
|
|
8743 if ( xhr.readyState !== 4 ) {
|
|
8744 xhr.abort();
|
|
8745 }
|
|
8746 } else {
|
|
8747 responses = {};
|
|
8748 status = xhr.status;
|
|
8749 responseHeaders = xhr.getAllResponseHeaders();
|
|
8750
|
|
8751 // When requesting binary data, IE6-9 will throw an exception
|
|
8752 // on any attempt to access responseText (#11426)
|
|
8753 if ( typeof xhr.responseText === "string" ) {
|
|
8754 responses.text = xhr.responseText;
|
|
8755 }
|
|
8756
|
|
8757 // Firefox throws an exception when accessing
|
|
8758 // statusText for faulty cross-domain requests
|
|
8759 try {
|
|
8760 statusText = xhr.statusText;
|
|
8761 } catch( e ) {
|
|
8762 // We normalize with Webkit giving an empty statusText
|
|
8763 statusText = "";
|
|
8764 }
|
|
8765
|
|
8766 // Filter status for non standard behaviors
|
|
8767
|
|
8768 // If the request is local and we have data: assume a success
|
|
8769 // (success with no data won't get notified, that's the best we
|
|
8770 // can do given current implementations)
|
|
8771 if ( !status && s.isLocal && !s.crossDomain ) {
|
|
8772 status = responses.text ? 200 : 404;
|
|
8773 // IE - #1450: sometimes returns 1223 when it should be 204
|
|
8774 } else if ( status === 1223 ) {
|
|
8775 status = 204;
|
|
8776 }
|
|
8777 }
|
|
8778 }
|
|
8779 } catch( firefoxAccessException ) {
|
|
8780 if ( !isAbort ) {
|
|
8781 complete( -1, firefoxAccessException );
|
|
8782 }
|
|
8783 }
|
|
8784
|
|
8785 // Call complete if needed
|
|
8786 if ( responses ) {
|
|
8787 complete( status, statusText, responses, responseHeaders );
|
|
8788 }
|
|
8789 };
|
|
8790
|
|
8791 if ( !s.async ) {
|
|
8792 // if we're in sync mode we fire the callback
|
|
8793 callback();
|
|
8794 } else if ( xhr.readyState === 4 ) {
|
|
8795 // (IE6 & IE7) if it's in cache and has been
|
|
8796 // retrieved directly we need to fire the callback
|
|
8797 setTimeout( callback );
|
|
8798 } else {
|
|
8799 handle = ++xhrId;
|
|
8800 if ( xhrOnUnloadAbort ) {
|
|
8801 // Create the active xhrs callbacks list if needed
|
|
8802 // and attach the unload handler
|
|
8803 if ( !xhrCallbacks ) {
|
|
8804 xhrCallbacks = {};
|
|
8805 jQuery( window ).unload( xhrOnUnloadAbort );
|
|
8806 }
|
|
8807 // Add to list of active xhrs callbacks
|
|
8808 xhrCallbacks[ handle ] = callback;
|
|
8809 }
|
|
8810 xhr.onreadystatechange = callback;
|
|
8811 }
|
|
8812 },
|
|
8813
|
|
8814 abort: function() {
|
|
8815 if ( callback ) {
|
|
8816 callback( undefined, true );
|
|
8817 }
|
|
8818 }
|
|
8819 };
|
|
8820 }
|
|
8821 });
|
|
8822 }
|
|
8823 var fxNow, timerId,
|
|
8824 rfxtypes = /^(?:toggle|show|hide)$/,
|
|
8825 rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
|
|
8826 rrun = /queueHooks$/,
|
|
8827 animationPrefilters = [ defaultPrefilter ],
|
|
8828 tweeners = {
|
|
8829 "*": [function( prop, value ) {
|
|
8830 var tween = this.createTween( prop, value ),
|
|
8831 target = tween.cur(),
|
|
8832 parts = rfxnum.exec( value ),
|
|
8833 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
|
|
8834
|
|
8835 // Starting value computation is required for potential unit mismatches
|
|
8836 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
|
|
8837 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
|
|
8838 scale = 1,
|
|
8839 maxIterations = 20;
|
|
8840
|
|
8841 if ( start && start[ 3 ] !== unit ) {
|
|
8842 // Trust units reported by jQuery.css
|
|
8843 unit = unit || start[ 3 ];
|
|
8844
|
|
8845 // Make sure we update the tween properties later on
|
|
8846 parts = parts || [];
|
|
8847
|
|
8848 // Iteratively approximate from a nonzero starting point
|
|
8849 start = +target || 1;
|
|
8850
|
|
8851 do {
|
|
8852 // If previous iteration zeroed out, double until we get *something*
|
|
8853 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
|
|
8854 scale = scale || ".5";
|
|
8855
|
|
8856 // Adjust and apply
|
|
8857 start = start / scale;
|
|
8858 jQuery.style( tween.elem, prop, start + unit );
|
|
8859
|
|
8860 // Update scale, tolerating zero or NaN from tween.cur()
|
|
8861 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
|
|
8862 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
|
|
8863 }
|
|
8864
|
|
8865 // Update tween properties
|
|
8866 if ( parts ) {
|
|
8867 tween.unit = unit;
|
|
8868 tween.start = +start || +target || 0;
|
|
8869 // If a +=/-= token was provided, we're doing a relative animation
|
|
8870 tween.end = parts[ 1 ] ?
|
|
8871 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
|
|
8872 +parts[ 2 ];
|
|
8873 }
|
|
8874
|
|
8875 return tween;
|
|
8876 }]
|
|
8877 };
|
|
8878
|
|
8879 // Animations created synchronously will run synchronously
|
|
8880 function createFxNow() {
|
|
8881 setTimeout(function() {
|
|
8882 fxNow = undefined;
|
|
8883 });
|
|
8884 return ( fxNow = jQuery.now() );
|
|
8885 }
|
|
8886
|
|
8887 function createTween( value, prop, animation ) {
|
|
8888 var tween,
|
|
8889 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
|
|
8890 index = 0,
|
|
8891 length = collection.length;
|
|
8892 for ( ; index < length; index++ ) {
|
|
8893 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
|
|
8894
|
|
8895 // we're done with this property
|
|
8896 return tween;
|
|
8897 }
|
|
8898 }
|
|
8899 }
|
|
8900
|
|
8901 function Animation( elem, properties, options ) {
|
|
8902 var result,
|
|
8903 stopped,
|
|
8904 index = 0,
|
|
8905 length = animationPrefilters.length,
|
|
8906 deferred = jQuery.Deferred().always( function() {
|
|
8907 // don't match elem in the :animated selector
|
|
8908 delete tick.elem;
|
|
8909 }),
|
|
8910 tick = function() {
|
|
8911 if ( stopped ) {
|
|
8912 return false;
|
|
8913 }
|
|
8914 var currentTime = fxNow || createFxNow(),
|
|
8915 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
|
|
8916 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
|
|
8917 temp = remaining / animation.duration || 0,
|
|
8918 percent = 1 - temp,
|
|
8919 index = 0,
|
|
8920 length = animation.tweens.length;
|
|
8921
|
|
8922 for ( ; index < length ; index++ ) {
|
|
8923 animation.tweens[ index ].run( percent );
|
|
8924 }
|
|
8925
|
|
8926 deferred.notifyWith( elem, [ animation, percent, remaining ]);
|
|
8927
|
|
8928 if ( percent < 1 && length ) {
|
|
8929 return remaining;
|
|
8930 } else {
|
|
8931 deferred.resolveWith( elem, [ animation ] );
|
|
8932 return false;
|
|
8933 }
|
|
8934 },
|
|
8935 animation = deferred.promise({
|
|
8936 elem: elem,
|
|
8937 props: jQuery.extend( {}, properties ),
|
|
8938 opts: jQuery.extend( true, { specialEasing: {} }, options ),
|
|
8939 originalProperties: properties,
|
|
8940 originalOptions: options,
|
|
8941 startTime: fxNow || createFxNow(),
|
|
8942 duration: options.duration,
|
|
8943 tweens: [],
|
|
8944 createTween: function( prop, end ) {
|
|
8945 var tween = jQuery.Tween( elem, animation.opts, prop, end,
|
|
8946 animation.opts.specialEasing[ prop ] || animation.opts.easing );
|
|
8947 animation.tweens.push( tween );
|
|
8948 return tween;
|
|
8949 },
|
|
8950 stop: function( gotoEnd ) {
|
|
8951 var index = 0,
|
|
8952 // if we are going to the end, we want to run all the tweens
|
|
8953 // otherwise we skip this part
|
|
8954 length = gotoEnd ? animation.tweens.length : 0;
|
|
8955 if ( stopped ) {
|
|
8956 return this;
|
|
8957 }
|
|
8958 stopped = true;
|
|
8959 for ( ; index < length ; index++ ) {
|
|
8960 animation.tweens[ index ].run( 1 );
|
|
8961 }
|
|
8962
|
|
8963 // resolve when we played the last frame
|
|
8964 // otherwise, reject
|
|
8965 if ( gotoEnd ) {
|
|
8966 deferred.resolveWith( elem, [ animation, gotoEnd ] );
|
|
8967 } else {
|
|
8968 deferred.rejectWith( elem, [ animation, gotoEnd ] );
|
|
8969 }
|
|
8970 return this;
|
|
8971 }
|
|
8972 }),
|
|
8973 props = animation.props;
|
|
8974
|
|
8975 propFilter( props, animation.opts.specialEasing );
|
|
8976
|
|
8977 for ( ; index < length ; index++ ) {
|
|
8978 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
|
|
8979 if ( result ) {
|
|
8980 return result;
|
|
8981 }
|
|
8982 }
|
|
8983
|
|
8984 jQuery.map( props, createTween, animation );
|
|
8985
|
|
8986 if ( jQuery.isFunction( animation.opts.start ) ) {
|
|
8987 animation.opts.start.call( elem, animation );
|
|
8988 }
|
|
8989
|
|
8990 jQuery.fx.timer(
|
|
8991 jQuery.extend( tick, {
|
|
8992 elem: elem,
|
|
8993 anim: animation,
|
|
8994 queue: animation.opts.queue
|
|
8995 })
|
|
8996 );
|
|
8997
|
|
8998 // attach callbacks from options
|
|
8999 return animation.progress( animation.opts.progress )
|
|
9000 .done( animation.opts.done, animation.opts.complete )
|
|
9001 .fail( animation.opts.fail )
|
|
9002 .always( animation.opts.always );
|
|
9003 }
|
|
9004
|
|
9005 function propFilter( props, specialEasing ) {
|
|
9006 var index, name, easing, value, hooks;
|
|
9007
|
|
9008 // camelCase, specialEasing and expand cssHook pass
|
|
9009 for ( index in props ) {
|
|
9010 name = jQuery.camelCase( index );
|
|
9011 easing = specialEasing[ name ];
|
|
9012 value = props[ index ];
|
|
9013 if ( jQuery.isArray( value ) ) {
|
|
9014 easing = value[ 1 ];
|
|
9015 value = props[ index ] = value[ 0 ];
|
|
9016 }
|
|
9017
|
|
9018 if ( index !== name ) {
|
|
9019 props[ name ] = value;
|
|
9020 delete props[ index ];
|
|
9021 }
|
|
9022
|
|
9023 hooks = jQuery.cssHooks[ name ];
|
|
9024 if ( hooks && "expand" in hooks ) {
|
|
9025 value = hooks.expand( value );
|
|
9026 delete props[ name ];
|
|
9027
|
|
9028 // not quite $.extend, this wont overwrite keys already present.
|
|
9029 // also - reusing 'index' from above because we have the correct "name"
|
|
9030 for ( index in value ) {
|
|
9031 if ( !( index in props ) ) {
|
|
9032 props[ index ] = value[ index ];
|
|
9033 specialEasing[ index ] = easing;
|
|
9034 }
|
|
9035 }
|
|
9036 } else {
|
|
9037 specialEasing[ name ] = easing;
|
|
9038 }
|
|
9039 }
|
|
9040 }
|
|
9041
|
|
9042 jQuery.Animation = jQuery.extend( Animation, {
|
|
9043
|
|
9044 tweener: function( props, callback ) {
|
|
9045 if ( jQuery.isFunction( props ) ) {
|
|
9046 callback = props;
|
|
9047 props = [ "*" ];
|
|
9048 } else {
|
|
9049 props = props.split(" ");
|
|
9050 }
|
|
9051
|
|
9052 var prop,
|
|
9053 index = 0,
|
|
9054 length = props.length;
|
|
9055
|
|
9056 for ( ; index < length ; index++ ) {
|
|
9057 prop = props[ index ];
|
|
9058 tweeners[ prop ] = tweeners[ prop ] || [];
|
|
9059 tweeners[ prop ].unshift( callback );
|
|
9060 }
|
|
9061 },
|
|
9062
|
|
9063 prefilter: function( callback, prepend ) {
|
|
9064 if ( prepend ) {
|
|
9065 animationPrefilters.unshift( callback );
|
|
9066 } else {
|
|
9067 animationPrefilters.push( callback );
|
|
9068 }
|
|
9069 }
|
|
9070 });
|
|
9071
|
|
9072 function defaultPrefilter( elem, props, opts ) {
|
|
9073 /* jshint validthis: true */
|
|
9074 var prop, value, toggle, tween, hooks, oldfire,
|
|
9075 anim = this,
|
|
9076 orig = {},
|
|
9077 style = elem.style,
|
|
9078 hidden = elem.nodeType && isHidden( elem ),
|
|
9079 dataShow = jQuery._data( elem, "fxshow" );
|
|
9080
|
|
9081 // handle queue: false promises
|
|
9082 if ( !opts.queue ) {
|
|
9083 hooks = jQuery._queueHooks( elem, "fx" );
|
|
9084 if ( hooks.unqueued == null ) {
|
|
9085 hooks.unqueued = 0;
|
|
9086 oldfire = hooks.empty.fire;
|
|
9087 hooks.empty.fire = function() {
|
|
9088 if ( !hooks.unqueued ) {
|
|
9089 oldfire();
|
|
9090 }
|
|
9091 };
|
|
9092 }
|
|
9093 hooks.unqueued++;
|
|
9094
|
|
9095 anim.always(function() {
|
|
9096 // doing this makes sure that the complete handler will be called
|
|
9097 // before this completes
|
|
9098 anim.always(function() {
|
|
9099 hooks.unqueued--;
|
|
9100 if ( !jQuery.queue( elem, "fx" ).length ) {
|
|
9101 hooks.empty.fire();
|
|
9102 }
|
|
9103 });
|
|
9104 });
|
|
9105 }
|
|
9106
|
|
9107 // height/width overflow pass
|
|
9108 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
|
|
9109 // Make sure that nothing sneaks out
|
|
9110 // Record all 3 overflow attributes because IE does not
|
|
9111 // change the overflow attribute when overflowX and
|
|
9112 // overflowY are set to the same value
|
|
9113 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
|
|
9114
|
|
9115 // Set display property to inline-block for height/width
|
|
9116 // animations on inline elements that are having width/height animated
|
|
9117 if ( jQuery.css( elem, "display" ) === "inline" &&
|
|
9118 jQuery.css( elem, "float" ) === "none" ) {
|
|
9119
|
|
9120 // inline-level elements accept inline-block;
|
|
9121 // block-level elements need to be inline with layout
|
|
9122 if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
|
|
9123 style.display = "inline-block";
|
|
9124
|
|
9125 } else {
|
|
9126 style.zoom = 1;
|
|
9127 }
|
|
9128 }
|
|
9129 }
|
|
9130
|
|
9131 if ( opts.overflow ) {
|
|
9132 style.overflow = "hidden";
|
|
9133 if ( !jQuery.support.shrinkWrapBlocks ) {
|
|
9134 anim.always(function() {
|
|
9135 style.overflow = opts.overflow[ 0 ];
|
|
9136 style.overflowX = opts.overflow[ 1 ];
|
|
9137 style.overflowY = opts.overflow[ 2 ];
|
|
9138 });
|
|
9139 }
|
|
9140 }
|
|
9141
|
|
9142
|
|
9143 // show/hide pass
|
|
9144 for ( prop in props ) {
|
|
9145 value = props[ prop ];
|
|
9146 if ( rfxtypes.exec( value ) ) {
|
|
9147 delete props[ prop ];
|
|
9148 toggle = toggle || value === "toggle";
|
|
9149 if ( value === ( hidden ? "hide" : "show" ) ) {
|
|
9150 continue;
|
|
9151 }
|
|
9152 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
|
|
9153 }
|
|
9154 }
|
|
9155
|
|
9156 if ( !jQuery.isEmptyObject( orig ) ) {
|
|
9157 if ( dataShow ) {
|
|
9158 if ( "hidden" in dataShow ) {
|
|
9159 hidden = dataShow.hidden;
|
|
9160 }
|
|
9161 } else {
|
|
9162 dataShow = jQuery._data( elem, "fxshow", {} );
|
|
9163 }
|
|
9164
|
|
9165 // store state if its toggle - enables .stop().toggle() to "reverse"
|
|
9166 if ( toggle ) {
|
|
9167 dataShow.hidden = !hidden;
|
|
9168 }
|
|
9169 if ( hidden ) {
|
|
9170 jQuery( elem ).show();
|
|
9171 } else {
|
|
9172 anim.done(function() {
|
|
9173 jQuery( elem ).hide();
|
|
9174 });
|
|
9175 }
|
|
9176 anim.done(function() {
|
|
9177 var prop;
|
|
9178 jQuery._removeData( elem, "fxshow" );
|
|
9179 for ( prop in orig ) {
|
|
9180 jQuery.style( elem, prop, orig[ prop ] );
|
|
9181 }
|
|
9182 });
|
|
9183 for ( prop in orig ) {
|
|
9184 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
|
|
9185
|
|
9186 if ( !( prop in dataShow ) ) {
|
|
9187 dataShow[ prop ] = tween.start;
|
|
9188 if ( hidden ) {
|
|
9189 tween.end = tween.start;
|
|
9190 tween.start = prop === "width" || prop === "height" ? 1 : 0;
|
|
9191 }
|
|
9192 }
|
|
9193 }
|
|
9194 }
|
|
9195 }
|
|
9196
|
|
9197 function Tween( elem, options, prop, end, easing ) {
|
|
9198 return new Tween.prototype.init( elem, options, prop, end, easing );
|
|
9199 }
|
|
9200 jQuery.Tween = Tween;
|
|
9201
|
|
9202 Tween.prototype = {
|
|
9203 constructor: Tween,
|
|
9204 init: function( elem, options, prop, end, easing, unit ) {
|
|
9205 this.elem = elem;
|
|
9206 this.prop = prop;
|
|
9207 this.easing = easing || "swing";
|
|
9208 this.options = options;
|
|
9209 this.start = this.now = this.cur();
|
|
9210 this.end = end;
|
|
9211 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
|
|
9212 },
|
|
9213 cur: function() {
|
|
9214 var hooks = Tween.propHooks[ this.prop ];
|
|
9215
|
|
9216 return hooks && hooks.get ?
|
|
9217 hooks.get( this ) :
|
|
9218 Tween.propHooks._default.get( this );
|
|
9219 },
|
|
9220 run: function( percent ) {
|
|
9221 var eased,
|
|
9222 hooks = Tween.propHooks[ this.prop ];
|
|
9223
|
|
9224 if ( this.options.duration ) {
|
|
9225 this.pos = eased = jQuery.easing[ this.easing ](
|
|
9226 percent, this.options.duration * percent, 0, 1, this.options.duration
|
|
9227 );
|
|
9228 } else {
|
|
9229 this.pos = eased = percent;
|
|
9230 }
|
|
9231 this.now = ( this.end - this.start ) * eased + this.start;
|
|
9232
|
|
9233 if ( this.options.step ) {
|
|
9234 this.options.step.call( this.elem, this.now, this );
|
|
9235 }
|
|
9236
|
|
9237 if ( hooks && hooks.set ) {
|
|
9238 hooks.set( this );
|
|
9239 } else {
|
|
9240 Tween.propHooks._default.set( this );
|
|
9241 }
|
|
9242 return this;
|
|
9243 }
|
|
9244 };
|
|
9245
|
|
9246 Tween.prototype.init.prototype = Tween.prototype;
|
|
9247
|
|
9248 Tween.propHooks = {
|
|
9249 _default: {
|
|
9250 get: function( tween ) {
|
|
9251 var result;
|
|
9252
|
|
9253 if ( tween.elem[ tween.prop ] != null &&
|
|
9254 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
|
|
9255 return tween.elem[ tween.prop ];
|
|
9256 }
|
|
9257
|
|
9258 // passing an empty string as a 3rd parameter to .css will automatically
|
|
9259 // attempt a parseFloat and fallback to a string if the parse fails
|
|
9260 // so, simple values such as "10px" are parsed to Float.
|
|
9261 // complex values such as "rotate(1rad)" are returned as is.
|
|
9262 result = jQuery.css( tween.elem, tween.prop, "" );
|
|
9263 // Empty strings, null, undefined and "auto" are converted to 0.
|
|
9264 return !result || result === "auto" ? 0 : result;
|
|
9265 },
|
|
9266 set: function( tween ) {
|
|
9267 // use step hook for back compat - use cssHook if its there - use .style if its
|
|
9268 // available and use plain properties where available
|
|
9269 if ( jQuery.fx.step[ tween.prop ] ) {
|
|
9270 jQuery.fx.step[ tween.prop ]( tween );
|
|
9271 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
|
|
9272 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
|
|
9273 } else {
|
|
9274 tween.elem[ tween.prop ] = tween.now;
|
|
9275 }
|
|
9276 }
|
|
9277 }
|
|
9278 };
|
|
9279
|
|
9280 // Support: IE <=9
|
|
9281 // Panic based approach to setting things on disconnected nodes
|
|
9282
|
|
9283 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
|
|
9284 set: function( tween ) {
|
|
9285 if ( tween.elem.nodeType && tween.elem.parentNode ) {
|
|
9286 tween.elem[ tween.prop ] = tween.now;
|
|
9287 }
|
|
9288 }
|
|
9289 };
|
|
9290
|
|
9291 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
|
|
9292 var cssFn = jQuery.fn[ name ];
|
|
9293 jQuery.fn[ name ] = function( speed, easing, callback ) {
|
|
9294 return speed == null || typeof speed === "boolean" ?
|
|
9295 cssFn.apply( this, arguments ) :
|
|
9296 this.animate( genFx( name, true ), speed, easing, callback );
|
|
9297 };
|
|
9298 });
|
|
9299
|
|
9300 jQuery.fn.extend({
|
|
9301 fadeTo: function( speed, to, easing, callback ) {
|
|
9302
|
|
9303 // show any hidden elements after setting opacity to 0
|
|
9304 return this.filter( isHidden ).css( "opacity", 0 ).show()
|
|
9305
|
|
9306 // animate to the value specified
|
|
9307 .end().animate({ opacity: to }, speed, easing, callback );
|
|
9308 },
|
|
9309 animate: function( prop, speed, easing, callback ) {
|
|
9310 var empty = jQuery.isEmptyObject( prop ),
|
|
9311 optall = jQuery.speed( speed, easing, callback ),
|
|
9312 doAnimation = function() {
|
|
9313 // Operate on a copy of prop so per-property easing won't be lost
|
|
9314 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
|
|
9315 doAnimation.finish = function() {
|
|
9316 anim.stop( true );
|
|
9317 };
|
|
9318 // Empty animations, or finishing resolves immediately
|
|
9319 if ( empty || jQuery._data( this, "finish" ) ) {
|
|
9320 anim.stop( true );
|
|
9321 }
|
|
9322 };
|
|
9323 doAnimation.finish = doAnimation;
|
|
9324
|
|
9325 return empty || optall.queue === false ?
|
|
9326 this.each( doAnimation ) :
|
|
9327 this.queue( optall.queue, doAnimation );
|
|
9328 },
|
|
9329 stop: function( type, clearQueue, gotoEnd ) {
|
|
9330 var stopQueue = function( hooks ) {
|
|
9331 var stop = hooks.stop;
|
|
9332 delete hooks.stop;
|
|
9333 stop( gotoEnd );
|
|
9334 };
|
|
9335
|
|
9336 if ( typeof type !== "string" ) {
|
|
9337 gotoEnd = clearQueue;
|
|
9338 clearQueue = type;
|
|
9339 type = undefined;
|
|
9340 }
|
|
9341 if ( clearQueue && type !== false ) {
|
|
9342 this.queue( type || "fx", [] );
|
|
9343 }
|
|
9344
|
|
9345 return this.each(function() {
|
|
9346 var dequeue = true,
|
|
9347 index = type != null && type + "queueHooks",
|
|
9348 timers = jQuery.timers,
|
|
9349 data = jQuery._data( this );
|
|
9350
|
|
9351 if ( index ) {
|
|
9352 if ( data[ index ] && data[ index ].stop ) {
|
|
9353 stopQueue( data[ index ] );
|
|
9354 }
|
|
9355 } else {
|
|
9356 for ( index in data ) {
|
|
9357 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
|
|
9358 stopQueue( data[ index ] );
|
|
9359 }
|
|
9360 }
|
|
9361 }
|
|
9362
|
|
9363 for ( index = timers.length; index--; ) {
|
|
9364 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
|
|
9365 timers[ index ].anim.stop( gotoEnd );
|
|
9366 dequeue = false;
|
|
9367 timers.splice( index, 1 );
|
|
9368 }
|
|
9369 }
|
|
9370
|
|
9371 // start the next in the queue if the last step wasn't forced
|
|
9372 // timers currently will call their complete callbacks, which will dequeue
|
|
9373 // but only if they were gotoEnd
|
|
9374 if ( dequeue || !gotoEnd ) {
|
|
9375 jQuery.dequeue( this, type );
|
|
9376 }
|
|
9377 });
|
|
9378 },
|
|
9379 finish: function( type ) {
|
|
9380 if ( type !== false ) {
|
|
9381 type = type || "fx";
|
|
9382 }
|
|
9383 return this.each(function() {
|
|
9384 var index,
|
|
9385 data = jQuery._data( this ),
|
|
9386 queue = data[ type + "queue" ],
|
|
9387 hooks = data[ type + "queueHooks" ],
|
|
9388 timers = jQuery.timers,
|
|
9389 length = queue ? queue.length : 0;
|
|
9390
|
|
9391 // enable finishing flag on private data
|
|
9392 data.finish = true;
|
|
9393
|
|
9394 // empty the queue first
|
|
9395 jQuery.queue( this, type, [] );
|
|
9396
|
|
9397 if ( hooks && hooks.cur && hooks.cur.finish ) {
|
|
9398 hooks.cur.finish.call( this );
|
|
9399 }
|
|
9400
|
|
9401 // look for any active animations, and finish them
|
|
9402 for ( index = timers.length; index--; ) {
|
|
9403 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
|
|
9404 timers[ index ].anim.stop( true );
|
|
9405 timers.splice( index, 1 );
|
|
9406 }
|
|
9407 }
|
|
9408
|
|
9409 // look for any animations in the old queue and finish them
|
|
9410 for ( index = 0; index < length; index++ ) {
|
|
9411 if ( queue[ index ] && queue[ index ].finish ) {
|
|
9412 queue[ index ].finish.call( this );
|
|
9413 }
|
|
9414 }
|
|
9415
|
|
9416 // turn off finishing flag
|
|
9417 delete data.finish;
|
|
9418 });
|
|
9419 }
|
|
9420 });
|
|
9421
|
|
9422 // Generate parameters to create a standard animation
|
|
9423 function genFx( type, includeWidth ) {
|
|
9424 var which,
|
|
9425 attrs = { height: type },
|
|
9426 i = 0;
|
|
9427
|
|
9428 // if we include width, step value is 1 to do all cssExpand values,
|
|
9429 // if we don't include width, step value is 2 to skip over Left and Right
|
|
9430 includeWidth = includeWidth? 1 : 0;
|
|
9431 for( ; i < 4 ; i += 2 - includeWidth ) {
|
|
9432 which = cssExpand[ i ];
|
|
9433 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
|
|
9434 }
|
|
9435
|
|
9436 if ( includeWidth ) {
|
|
9437 attrs.opacity = attrs.width = type;
|
|
9438 }
|
|
9439
|
|
9440 return attrs;
|
|
9441 }
|
|
9442
|
|
9443 // Generate shortcuts for custom animations
|
|
9444 jQuery.each({
|
|
9445 slideDown: genFx("show"),
|
|
9446 slideUp: genFx("hide"),
|
|
9447 slideToggle: genFx("toggle"),
|
|
9448 fadeIn: { opacity: "show" },
|
|
9449 fadeOut: { opacity: "hide" },
|
|
9450 fadeToggle: { opacity: "toggle" }
|
|
9451 }, function( name, props ) {
|
|
9452 jQuery.fn[ name ] = function( speed, easing, callback ) {
|
|
9453 return this.animate( props, speed, easing, callback );
|
|
9454 };
|
|
9455 });
|
|
9456
|
|
9457 jQuery.speed = function( speed, easing, fn ) {
|
|
9458 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
|
|
9459 complete: fn || !fn && easing ||
|
|
9460 jQuery.isFunction( speed ) && speed,
|
|
9461 duration: speed,
|
|
9462 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
|
|
9463 };
|
|
9464
|
|
9465 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
|
|
9466 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
|
|
9467
|
|
9468 // normalize opt.queue - true/undefined/null -> "fx"
|
|
9469 if ( opt.queue == null || opt.queue === true ) {
|
|
9470 opt.queue = "fx";
|
|
9471 }
|
|
9472
|
|
9473 // Queueing
|
|
9474 opt.old = opt.complete;
|
|
9475
|
|
9476 opt.complete = function() {
|
|
9477 if ( jQuery.isFunction( opt.old ) ) {
|
|
9478 opt.old.call( this );
|
|
9479 }
|
|
9480
|
|
9481 if ( opt.queue ) {
|
|
9482 jQuery.dequeue( this, opt.queue );
|
|
9483 }
|
|
9484 };
|
|
9485
|
|
9486 return opt;
|
|
9487 };
|
|
9488
|
|
9489 jQuery.easing = {
|
|
9490 linear: function( p ) {
|
|
9491 return p;
|
|
9492 },
|
|
9493 swing: function( p ) {
|
|
9494 return 0.5 - Math.cos( p*Math.PI ) / 2;
|
|
9495 }
|
|
9496 };
|
|
9497
|
|
9498 jQuery.timers = [];
|
|
9499 jQuery.fx = Tween.prototype.init;
|
|
9500 jQuery.fx.tick = function() {
|
|
9501 var timer,
|
|
9502 timers = jQuery.timers,
|
|
9503 i = 0;
|
|
9504
|
|
9505 fxNow = jQuery.now();
|
|
9506
|
|
9507 for ( ; i < timers.length; i++ ) {
|
|
9508 timer = timers[ i ];
|
|
9509 // Checks the timer has not already been removed
|
|
9510 if ( !timer() && timers[ i ] === timer ) {
|
|
9511 timers.splice( i--, 1 );
|
|
9512 }
|
|
9513 }
|
|
9514
|
|
9515 if ( !timers.length ) {
|
|
9516 jQuery.fx.stop();
|
|
9517 }
|
|
9518 fxNow = undefined;
|
|
9519 };
|
|
9520
|
|
9521 jQuery.fx.timer = function( timer ) {
|
|
9522 if ( timer() && jQuery.timers.push( timer ) ) {
|
|
9523 jQuery.fx.start();
|
|
9524 }
|
|
9525 };
|
|
9526
|
|
9527 jQuery.fx.interval = 13;
|
|
9528
|
|
9529 jQuery.fx.start = function() {
|
|
9530 if ( !timerId ) {
|
|
9531 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
|
|
9532 }
|
|
9533 };
|
|
9534
|
|
9535 jQuery.fx.stop = function() {
|
|
9536 clearInterval( timerId );
|
|
9537 timerId = null;
|
|
9538 };
|
|
9539
|
|
9540 jQuery.fx.speeds = {
|
|
9541 slow: 600,
|
|
9542 fast: 200,
|
|
9543 // Default speed
|
|
9544 _default: 400
|
|
9545 };
|
|
9546
|
|
9547 // Back Compat <1.8 extension point
|
|
9548 jQuery.fx.step = {};
|
|
9549
|
|
9550 if ( jQuery.expr && jQuery.expr.filters ) {
|
|
9551 jQuery.expr.filters.animated = function( elem ) {
|
|
9552 return jQuery.grep(jQuery.timers, function( fn ) {
|
|
9553 return elem === fn.elem;
|
|
9554 }).length;
|
|
9555 };
|
|
9556 }
|
|
9557 jQuery.fn.offset = function( options ) {
|
|
9558 if ( arguments.length ) {
|
|
9559 return options === undefined ?
|
|
9560 this :
|
|
9561 this.each(function( i ) {
|
|
9562 jQuery.offset.setOffset( this, options, i );
|
|
9563 });
|
|
9564 }
|
|
9565
|
|
9566 var docElem, win,
|
|
9567 box = { top: 0, left: 0 },
|
|
9568 elem = this[ 0 ],
|
|
9569 doc = elem && elem.ownerDocument;
|
|
9570
|
|
9571 if ( !doc ) {
|
|
9572 return;
|
|
9573 }
|
|
9574
|
|
9575 docElem = doc.documentElement;
|
|
9576
|
|
9577 // Make sure it's not a disconnected DOM node
|
|
9578 if ( !jQuery.contains( docElem, elem ) ) {
|
|
9579 return box;
|
|
9580 }
|
|
9581
|
|
9582 // If we don't have gBCR, just use 0,0 rather than error
|
|
9583 // BlackBerry 5, iOS 3 (original iPhone)
|
|
9584 if ( typeof elem.getBoundingClientRect !== core_strundefined ) {
|
|
9585 box = elem.getBoundingClientRect();
|
|
9586 }
|
|
9587 win = getWindow( doc );
|
|
9588 return {
|
|
9589 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
|
|
9590 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
|
|
9591 };
|
|
9592 };
|
|
9593
|
|
9594 jQuery.offset = {
|
|
9595
|
|
9596 setOffset: function( elem, options, i ) {
|
|
9597 var position = jQuery.css( elem, "position" );
|
|
9598
|
|
9599 // set position first, in-case top/left are set even on static elem
|
|
9600 if ( position === "static" ) {
|
|
9601 elem.style.position = "relative";
|
|
9602 }
|
|
9603
|
|
9604 var curElem = jQuery( elem ),
|
|
9605 curOffset = curElem.offset(),
|
|
9606 curCSSTop = jQuery.css( elem, "top" ),
|
|
9607 curCSSLeft = jQuery.css( elem, "left" ),
|
|
9608 calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
|
|
9609 props = {}, curPosition = {}, curTop, curLeft;
|
|
9610
|
|
9611 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
|
|
9612 if ( calculatePosition ) {
|
|
9613 curPosition = curElem.position();
|
|
9614 curTop = curPosition.top;
|
|
9615 curLeft = curPosition.left;
|
|
9616 } else {
|
|
9617 curTop = parseFloat( curCSSTop ) || 0;
|
|
9618 curLeft = parseFloat( curCSSLeft ) || 0;
|
|
9619 }
|
|
9620
|
|
9621 if ( jQuery.isFunction( options ) ) {
|
|
9622 options = options.call( elem, i, curOffset );
|
|
9623 }
|
|
9624
|
|
9625 if ( options.top != null ) {
|
|
9626 props.top = ( options.top - curOffset.top ) + curTop;
|
|
9627 }
|
|
9628 if ( options.left != null ) {
|
|
9629 props.left = ( options.left - curOffset.left ) + curLeft;
|
|
9630 }
|
|
9631
|
|
9632 if ( "using" in options ) {
|
|
9633 options.using.call( elem, props );
|
|
9634 } else {
|
|
9635 curElem.css( props );
|
|
9636 }
|
|
9637 }
|
|
9638 };
|
|
9639
|
|
9640
|
|
9641 jQuery.fn.extend({
|
|
9642
|
|
9643 position: function() {
|
|
9644 if ( !this[ 0 ] ) {
|
|
9645 return;
|
|
9646 }
|
|
9647
|
|
9648 var offsetParent, offset,
|
|
9649 parentOffset = { top: 0, left: 0 },
|
|
9650 elem = this[ 0 ];
|
|
9651
|
|
9652 // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is it's only offset parent
|
|
9653 if ( jQuery.css( elem, "position" ) === "fixed" ) {
|
|
9654 // we assume that getBoundingClientRect is available when computed position is fixed
|
|
9655 offset = elem.getBoundingClientRect();
|
|
9656 } else {
|
|
9657 // Get *real* offsetParent
|
|
9658 offsetParent = this.offsetParent();
|
|
9659
|
|
9660 // Get correct offsets
|
|
9661 offset = this.offset();
|
|
9662 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
|
|
9663 parentOffset = offsetParent.offset();
|
|
9664 }
|
|
9665
|
|
9666 // Add offsetParent borders
|
|
9667 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
|
|
9668 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
|
|
9669 }
|
|
9670
|
|
9671 // Subtract parent offsets and element margins
|
|
9672 // note: when an element has margin: auto the offsetLeft and marginLeft
|
|
9673 // are the same in Safari causing offset.left to incorrectly be 0
|
|
9674 return {
|
|
9675 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
|
|
9676 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
|
|
9677 };
|
|
9678 },
|
|
9679
|
|
9680 offsetParent: function() {
|
|
9681 return this.map(function() {
|
|
9682 var offsetParent = this.offsetParent || docElem;
|
|
9683 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position") === "static" ) ) {
|
|
9684 offsetParent = offsetParent.offsetParent;
|
|
9685 }
|
|
9686 return offsetParent || docElem;
|
|
9687 });
|
|
9688 }
|
|
9689 });
|
|
9690
|
|
9691
|
|
9692 // Create scrollLeft and scrollTop methods
|
|
9693 jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
|
|
9694 var top = /Y/.test( prop );
|
|
9695
|
|
9696 jQuery.fn[ method ] = function( val ) {
|
|
9697 return jQuery.access( this, function( elem, method, val ) {
|
|
9698 var win = getWindow( elem );
|
|
9699
|
|
9700 if ( val === undefined ) {
|
|
9701 return win ? (prop in win) ? win[ prop ] :
|
|
9702 win.document.documentElement[ method ] :
|
|
9703 elem[ method ];
|
|
9704 }
|
|
9705
|
|
9706 if ( win ) {
|
|
9707 win.scrollTo(
|
|
9708 !top ? val : jQuery( win ).scrollLeft(),
|
|
9709 top ? val : jQuery( win ).scrollTop()
|
|
9710 );
|
|
9711
|
|
9712 } else {
|
|
9713 elem[ method ] = val;
|
|
9714 }
|
|
9715 }, method, val, arguments.length, null );
|
|
9716 };
|
|
9717 });
|
|
9718
|
|
9719 function getWindow( elem ) {
|
|
9720 return jQuery.isWindow( elem ) ?
|
|
9721 elem :
|
|
9722 elem.nodeType === 9 ?
|
|
9723 elem.defaultView || elem.parentWindow :
|
|
9724 false;
|
|
9725 }
|
|
9726 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
|
|
9727 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
|
9728 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
|
|
9729 // margin is only for outerHeight, outerWidth
|
|
9730 jQuery.fn[ funcName ] = function( margin, value ) {
|
|
9731 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
|
|
9732 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
|
|
9733
|
|
9734 return jQuery.access( this, function( elem, type, value ) {
|
|
9735 var doc;
|
|
9736
|
|
9737 if ( jQuery.isWindow( elem ) ) {
|
|
9738 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
|
|
9739 // isn't a whole lot we can do. See pull request at this URL for discussion:
|
|
9740 // https://github.com/jquery/jquery/pull/764
|
|
9741 return elem.document.documentElement[ "client" + name ];
|
|
9742 }
|
|
9743
|
|
9744 // Get document width or height
|
|
9745 if ( elem.nodeType === 9 ) {
|
|
9746 doc = elem.documentElement;
|
|
9747
|
|
9748 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
|
|
9749 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
|
|
9750 return Math.max(
|
|
9751 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
|
|
9752 elem.body[ "offset" + name ], doc[ "offset" + name ],
|
|
9753 doc[ "client" + name ]
|
|
9754 );
|
|
9755 }
|
|
9756
|
|
9757 return value === undefined ?
|
|
9758 // Get width or height on the element, requesting but not forcing parseFloat
|
|
9759 jQuery.css( elem, type, extra ) :
|
|
9760
|
|
9761 // Set width or height on the element
|
|
9762 jQuery.style( elem, type, value, extra );
|
|
9763 }, type, chainable ? margin : undefined, chainable, null );
|
|
9764 };
|
|
9765 });
|
|
9766 });
|
|
9767 // Limit scope pollution from any deprecated API
|
|
9768 // (function() {
|
|
9769
|
|
9770 // The number of elements contained in the matched element set
|
|
9771 jQuery.fn.size = function() {
|
|
9772 return this.length;
|
|
9773 };
|
|
9774
|
|
9775 jQuery.fn.andSelf = jQuery.fn.addBack;
|
|
9776
|
|
9777 // })();
|
|
9778 if ( typeof module === "object" && typeof module.exports === "object" ) {
|
|
9779 // Expose jQuery as module.exports in loaders that implement the Node
|
|
9780 // module pattern (including browserify). Do not create the global, since
|
|
9781 // the user will be storing it themselves locally, and globals are frowned
|
|
9782 // upon in the Node module world.
|
|
9783 module.exports = jQuery;
|
|
9784 } else {
|
|
9785 // Otherwise expose jQuery to the global object as usual
|
|
9786 window.jQuery = window.$ = jQuery;
|
|
9787
|
|
9788 // Register as a named AMD module, since jQuery can be concatenated with other
|
|
9789 // files that may use define, but not via a proper concatenation script that
|
|
9790 // understands anonymous AMD modules. A named AMD is safest and most robust
|
|
9791 // way to register. Lowercase jquery is used because AMD module names are
|
|
9792 // derived from file names, and jQuery is normally delivered in a lowercase
|
|
9793 // file name. Do this after creating the global so that if an AMD module wants
|
|
9794 // to call noConflict to hide this version of jQuery, it will work.
|
|
9795 if ( typeof define === "function" && define.amd ) {
|
|
9796 define( "jquery", [], function () { return jQuery; } );
|
|
9797 }
|
|
9798 }
|
|
9799
|
|
9800 })( window );
|