7
|
1 /*!
|
|
2 * jQuery JavaScript Library v1.10.1
|
|
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-30T21:49Z
|
|
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.1",
|
|
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-27
|
|
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 parent = doc.parentWindow;
|
|
1497
|
|
1498 // If no document and documentElement is available, return
|
|
1499 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
|
|
1500 return document;
|
|
1501 }
|
|
1502
|
|
1503 // Set our document
|
|
1504 document = doc;
|
|
1505 docElem = doc.documentElement;
|
|
1506
|
|
1507 // Support tests
|
|
1508 documentIsHTML = !isXML( doc );
|
|
1509
|
|
1510 // Support: IE>8
|
|
1511 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
|
|
1512 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
|
|
1513 if ( parent && parent.frameElement ) {
|
|
1514 parent.attachEvent( "onbeforeunload", function() {
|
|
1515 setDocument();
|
|
1516 });
|
|
1517 }
|
|
1518
|
|
1519 /* Attributes
|
|
1520 ---------------------------------------------------------------------- */
|
|
1521
|
|
1522 // Support: IE<8
|
|
1523 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
|
|
1524 support.attributes = assert(function( div ) {
|
|
1525
|
|
1526 // Support: IE<8
|
|
1527 // Prevent attribute/property "interpolation"
|
|
1528 div.innerHTML = "<a href='#'></a>";
|
|
1529 addHandle( "type|href|height|width", interpolationHandler, div.firstChild.getAttribute("href") === "#" );
|
|
1530
|
|
1531 // Support: IE<9
|
|
1532 // Use getAttributeNode to fetch booleans when getAttribute lies
|
|
1533 addHandle( booleans, boolHandler, div.getAttribute("disabled") == null );
|
|
1534
|
|
1535 div.className = "i";
|
|
1536 return !div.getAttribute("className");
|
|
1537 });
|
|
1538
|
|
1539 // Support: IE<9
|
|
1540 // Retrieving value should defer to defaultValue
|
|
1541 support.input = assert(function( div ) {
|
|
1542 div.innerHTML = "<input>";
|
|
1543 div.firstChild.setAttribute( "value", "" );
|
|
1544 return div.firstChild.getAttribute( "value" ) === "";
|
|
1545 });
|
|
1546
|
|
1547 // IE6/7 still return empty string for value,
|
|
1548 // but are actually retrieving the property
|
|
1549 addHandle( "value", valueHandler, support.attributes && support.input );
|
|
1550
|
|
1551 /* getElement(s)By*
|
|
1552 ---------------------------------------------------------------------- */
|
|
1553
|
|
1554 // Check if getElementsByTagName("*") returns only elements
|
|
1555 support.getElementsByTagName = assert(function( div ) {
|
|
1556 div.appendChild( doc.createComment("") );
|
|
1557 return !div.getElementsByTagName("*").length;
|
|
1558 });
|
|
1559
|
|
1560 // Check if getElementsByClassName can be trusted
|
|
1561 support.getElementsByClassName = assert(function( div ) {
|
|
1562 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
|
|
1563
|
|
1564 // Support: Safari<4
|
|
1565 // Catch class over-caching
|
|
1566 div.firstChild.className = "i";
|
|
1567 // Support: Opera<10
|
|
1568 // Catch gEBCN failure to find non-leading classes
|
|
1569 return div.getElementsByClassName("i").length === 2;
|
|
1570 });
|
|
1571
|
|
1572 // Support: IE<10
|
|
1573 // Check if getElementById returns elements by name
|
|
1574 // The broken getElementById methods don't pick up programatically-set names,
|
|
1575 // so use a roundabout getElementsByName test
|
|
1576 support.getById = assert(function( div ) {
|
|
1577 docElem.appendChild( div ).id = expando;
|
|
1578 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
|
|
1579 });
|
|
1580
|
|
1581 // ID find and filter
|
|
1582 if ( support.getById ) {
|
|
1583 Expr.find["ID"] = function( id, context ) {
|
|
1584 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
|
|
1585 var m = context.getElementById( id );
|
|
1586 // Check parentNode to catch when Blackberry 4.6 returns
|
|
1587 // nodes that are no longer in the document #6963
|
|
1588 return m && m.parentNode ? [m] : [];
|
|
1589 }
|
|
1590 };
|
|
1591 Expr.filter["ID"] = function( id ) {
|
|
1592 var attrId = id.replace( runescape, funescape );
|
|
1593 return function( elem ) {
|
|
1594 return elem.getAttribute("id") === attrId;
|
|
1595 };
|
|
1596 };
|
|
1597 } else {
|
|
1598 // Support: IE6/7
|
|
1599 // getElementById is not reliable as a find shortcut
|
|
1600 delete Expr.find["ID"];
|
|
1601
|
|
1602 Expr.filter["ID"] = function( id ) {
|
|
1603 var attrId = id.replace( runescape, funescape );
|
|
1604 return function( elem ) {
|
|
1605 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
|
|
1606 return node && node.value === attrId;
|
|
1607 };
|
|
1608 };
|
|
1609 }
|
|
1610
|
|
1611 // Tag
|
|
1612 Expr.find["TAG"] = support.getElementsByTagName ?
|
|
1613 function( tag, context ) {
|
|
1614 if ( typeof context.getElementsByTagName !== strundefined ) {
|
|
1615 return context.getElementsByTagName( tag );
|
|
1616 }
|
|
1617 } :
|
|
1618 function( tag, context ) {
|
|
1619 var elem,
|
|
1620 tmp = [],
|
|
1621 i = 0,
|
|
1622 results = context.getElementsByTagName( tag );
|
|
1623
|
|
1624 // Filter out possible comments
|
|
1625 if ( tag === "*" ) {
|
|
1626 while ( (elem = results[i++]) ) {
|
|
1627 if ( elem.nodeType === 1 ) {
|
|
1628 tmp.push( elem );
|
|
1629 }
|
|
1630 }
|
|
1631
|
|
1632 return tmp;
|
|
1633 }
|
|
1634 return results;
|
|
1635 };
|
|
1636
|
|
1637 // Class
|
|
1638 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
|
|
1639 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
|
|
1640 return context.getElementsByClassName( className );
|
|
1641 }
|
|
1642 };
|
|
1643
|
|
1644 /* QSA/matchesSelector
|
|
1645 ---------------------------------------------------------------------- */
|
|
1646
|
|
1647 // QSA and matchesSelector support
|
|
1648
|
|
1649 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
|
|
1650 rbuggyMatches = [];
|
|
1651
|
|
1652 // qSa(:focus) reports false when true (Chrome 21)
|
|
1653 // We allow this because of a bug in IE8/9 that throws an error
|
|
1654 // whenever `document.activeElement` is accessed on an iframe
|
|
1655 // So, we allow :focus to pass through QSA all the time to avoid the IE error
|
|
1656 // See http://bugs.jquery.com/ticket/13378
|
|
1657 rbuggyQSA = [];
|
|
1658
|
|
1659 if ( (support.qsa = isNative(doc.querySelectorAll)) ) {
|
|
1660 // Build QSA regex
|
|
1661 // Regex strategy adopted from Diego Perini
|
|
1662 assert(function( div ) {
|
|
1663 // Select is set to empty string on purpose
|
|
1664 // This is to test IE's treatment of not explicitly
|
|
1665 // setting a boolean content attribute,
|
|
1666 // since its presence should be enough
|
|
1667 // http://bugs.jquery.com/ticket/12359
|
|
1668 div.innerHTML = "<select><option selected=''></option></select>";
|
|
1669
|
|
1670 // Support: IE8
|
|
1671 // Boolean attributes and "value" are not treated correctly
|
|
1672 if ( !div.querySelectorAll("[selected]").length ) {
|
|
1673 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
|
|
1674 }
|
|
1675
|
|
1676 // Webkit/Opera - :checked should return selected option elements
|
|
1677 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
|
|
1678 // IE8 throws error here and will not see later tests
|
|
1679 if ( !div.querySelectorAll(":checked").length ) {
|
|
1680 rbuggyQSA.push(":checked");
|
|
1681 }
|
|
1682 });
|
|
1683
|
|
1684 assert(function( div ) {
|
|
1685
|
|
1686 // Support: Opera 10-12/IE8
|
|
1687 // ^= $= *= and empty values
|
|
1688 // Should not select anything
|
|
1689 // Support: Windows 8 Native Apps
|
|
1690 // The type attribute is restricted during .innerHTML assignment
|
|
1691 var input = doc.createElement("input");
|
|
1692 input.setAttribute( "type", "hidden" );
|
|
1693 div.appendChild( input ).setAttribute( "t", "" );
|
|
1694
|
|
1695 if ( div.querySelectorAll("[t^='']").length ) {
|
|
1696 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
|
|
1697 }
|
|
1698
|
|
1699 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
|
|
1700 // IE8 throws error here and will not see later tests
|
|
1701 if ( !div.querySelectorAll(":enabled").length ) {
|
|
1702 rbuggyQSA.push( ":enabled", ":disabled" );
|
|
1703 }
|
|
1704
|
|
1705 // Opera 10-11 does not throw on post-comma invalid pseudos
|
|
1706 div.querySelectorAll("*,:x");
|
|
1707 rbuggyQSA.push(",.*:");
|
|
1708 });
|
|
1709 }
|
|
1710
|
|
1711 if ( (support.matchesSelector = isNative( (matches = docElem.webkitMatchesSelector ||
|
|
1712 docElem.mozMatchesSelector ||
|
|
1713 docElem.oMatchesSelector ||
|
|
1714 docElem.msMatchesSelector) )) ) {
|
|
1715
|
|
1716 assert(function( div ) {
|
|
1717 // Check to see if it's possible to do matchesSelector
|
|
1718 // on a disconnected node (IE 9)
|
|
1719 support.disconnectedMatch = matches.call( div, "div" );
|
|
1720
|
|
1721 // This should fail with an exception
|
|
1722 // Gecko does not error, returns false instead
|
|
1723 matches.call( div, "[s!='']:x" );
|
|
1724 rbuggyMatches.push( "!=", pseudos );
|
|
1725 });
|
|
1726 }
|
|
1727
|
|
1728 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
|
|
1729 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
|
|
1730
|
|
1731 /* Contains
|
|
1732 ---------------------------------------------------------------------- */
|
|
1733
|
|
1734 // Element contains another
|
|
1735 // Purposefully does not implement inclusive descendent
|
|
1736 // As in, an element does not contain itself
|
|
1737 contains = isNative(docElem.contains) || docElem.compareDocumentPosition ?
|
|
1738 function( a, b ) {
|
|
1739 var adown = a.nodeType === 9 ? a.documentElement : a,
|
|
1740 bup = b && b.parentNode;
|
|
1741 return a === bup || !!( bup && bup.nodeType === 1 && (
|
|
1742 adown.contains ?
|
|
1743 adown.contains( bup ) :
|
|
1744 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
|
|
1745 ));
|
|
1746 } :
|
|
1747 function( a, b ) {
|
|
1748 if ( b ) {
|
|
1749 while ( (b = b.parentNode) ) {
|
|
1750 if ( b === a ) {
|
|
1751 return true;
|
|
1752 }
|
|
1753 }
|
|
1754 }
|
|
1755 return false;
|
|
1756 };
|
|
1757
|
|
1758 /* Sorting
|
|
1759 ---------------------------------------------------------------------- */
|
|
1760
|
|
1761 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
|
|
1762 // Detached nodes confoundingly follow *each other*
|
|
1763 support.sortDetached = assert(function( div1 ) {
|
|
1764 // Should return 1, but returns 4 (following)
|
|
1765 return div1.compareDocumentPosition( doc.createElement("div") ) & 1;
|
|
1766 });
|
|
1767
|
|
1768 // Document order sorting
|
|
1769 sortOrder = docElem.compareDocumentPosition ?
|
|
1770 function( a, b ) {
|
|
1771
|
|
1772 // Flag for duplicate removal
|
|
1773 if ( a === b ) {
|
|
1774 hasDuplicate = true;
|
|
1775 return 0;
|
|
1776 }
|
|
1777
|
|
1778 var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b );
|
|
1779
|
|
1780 if ( compare ) {
|
|
1781 // Disconnected nodes
|
|
1782 if ( compare & 1 ||
|
|
1783 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
|
|
1784
|
|
1785 // Choose the first element that is related to our preferred document
|
|
1786 if ( a === doc || contains(preferredDoc, a) ) {
|
|
1787 return -1;
|
|
1788 }
|
|
1789 if ( b === doc || contains(preferredDoc, b) ) {
|
|
1790 return 1;
|
|
1791 }
|
|
1792
|
|
1793 // Maintain original order
|
|
1794 return sortInput ?
|
|
1795 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
|
|
1796 0;
|
|
1797 }
|
|
1798
|
|
1799 return compare & 4 ? -1 : 1;
|
|
1800 }
|
|
1801
|
|
1802 // Not directly comparable, sort on existence of method
|
|
1803 return a.compareDocumentPosition ? -1 : 1;
|
|
1804 } :
|
|
1805 function( a, b ) {
|
|
1806 var cur,
|
|
1807 i = 0,
|
|
1808 aup = a.parentNode,
|
|
1809 bup = b.parentNode,
|
|
1810 ap = [ a ],
|
|
1811 bp = [ b ];
|
|
1812
|
|
1813 // Exit early if the nodes are identical
|
|
1814 if ( a === b ) {
|
|
1815 hasDuplicate = true;
|
|
1816 return 0;
|
|
1817
|
|
1818 // Parentless nodes are either documents or disconnected
|
|
1819 } else if ( !aup || !bup ) {
|
|
1820 return a === doc ? -1 :
|
|
1821 b === doc ? 1 :
|
|
1822 aup ? -1 :
|
|
1823 bup ? 1 :
|
|
1824 sortInput ?
|
|
1825 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
|
|
1826 0;
|
|
1827
|
|
1828 // If the nodes are siblings, we can do a quick check
|
|
1829 } else if ( aup === bup ) {
|
|
1830 return siblingCheck( a, b );
|
|
1831 }
|
|
1832
|
|
1833 // Otherwise we need full lists of their ancestors for comparison
|
|
1834 cur = a;
|
|
1835 while ( (cur = cur.parentNode) ) {
|
|
1836 ap.unshift( cur );
|
|
1837 }
|
|
1838 cur = b;
|
|
1839 while ( (cur = cur.parentNode) ) {
|
|
1840 bp.unshift( cur );
|
|
1841 }
|
|
1842
|
|
1843 // Walk down the tree looking for a discrepancy
|
|
1844 while ( ap[i] === bp[i] ) {
|
|
1845 i++;
|
|
1846 }
|
|
1847
|
|
1848 return i ?
|
|
1849 // Do a sibling check if the nodes have a common ancestor
|
|
1850 siblingCheck( ap[i], bp[i] ) :
|
|
1851
|
|
1852 // Otherwise nodes in our document sort first
|
|
1853 ap[i] === preferredDoc ? -1 :
|
|
1854 bp[i] === preferredDoc ? 1 :
|
|
1855 0;
|
|
1856 };
|
|
1857
|
|
1858 return doc;
|
|
1859 };
|
|
1860
|
|
1861 Sizzle.matches = function( expr, elements ) {
|
|
1862 return Sizzle( expr, null, null, elements );
|
|
1863 };
|
|
1864
|
|
1865 Sizzle.matchesSelector = function( elem, expr ) {
|
|
1866 // Set document vars if needed
|
|
1867 if ( ( elem.ownerDocument || elem ) !== document ) {
|
|
1868 setDocument( elem );
|
|
1869 }
|
|
1870
|
|
1871 // Make sure that attribute selectors are quoted
|
|
1872 expr = expr.replace( rattributeQuotes, "='$1']" );
|
|
1873
|
|
1874 if ( support.matchesSelector && documentIsHTML &&
|
|
1875 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
|
|
1876 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
|
|
1877
|
|
1878 try {
|
|
1879 var ret = matches.call( elem, expr );
|
|
1880
|
|
1881 // IE 9's matchesSelector returns false on disconnected nodes
|
|
1882 if ( ret || support.disconnectedMatch ||
|
|
1883 // As well, disconnected nodes are said to be in a document
|
|
1884 // fragment in IE 9
|
|
1885 elem.document && elem.document.nodeType !== 11 ) {
|
|
1886 return ret;
|
|
1887 }
|
|
1888 } catch(e) {}
|
|
1889 }
|
|
1890
|
|
1891 return Sizzle( expr, document, null, [elem] ).length > 0;
|
|
1892 };
|
|
1893
|
|
1894 Sizzle.contains = function( context, elem ) {
|
|
1895 // Set document vars if needed
|
|
1896 if ( ( context.ownerDocument || context ) !== document ) {
|
|
1897 setDocument( context );
|
|
1898 }
|
|
1899 return contains( context, elem );
|
|
1900 };
|
|
1901
|
|
1902 Sizzle.attr = function( elem, name ) {
|
|
1903 // Set document vars if needed
|
|
1904 if ( ( elem.ownerDocument || elem ) !== document ) {
|
|
1905 setDocument( elem );
|
|
1906 }
|
|
1907
|
|
1908 var fn = Expr.attrHandle[ name.toLowerCase() ],
|
|
1909 // Don't get fooled by Object.prototype properties (jQuery #13807)
|
|
1910 val = ( fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
|
|
1911 fn( elem, name, !documentIsHTML ) :
|
|
1912 undefined );
|
|
1913
|
|
1914 return val === undefined ?
|
|
1915 support.attributes || !documentIsHTML ?
|
|
1916 elem.getAttribute( name ) :
|
|
1917 (val = elem.getAttributeNode(name)) && val.specified ?
|
|
1918 val.value :
|
|
1919 null :
|
|
1920 val;
|
|
1921 };
|
|
1922
|
|
1923 Sizzle.error = function( msg ) {
|
|
1924 throw new Error( "Syntax error, unrecognized expression: " + msg );
|
|
1925 };
|
|
1926
|
|
1927 /**
|
|
1928 * Document sorting and removing duplicates
|
|
1929 * @param {ArrayLike} results
|
|
1930 */
|
|
1931 Sizzle.uniqueSort = function( results ) {
|
|
1932 var elem,
|
|
1933 duplicates = [],
|
|
1934 j = 0,
|
|
1935 i = 0;
|
|
1936
|
|
1937 // Unless we *know* we can detect duplicates, assume their presence
|
|
1938 hasDuplicate = !support.detectDuplicates;
|
|
1939 sortInput = !support.sortStable && results.slice( 0 );
|
|
1940 results.sort( sortOrder );
|
|
1941
|
|
1942 if ( hasDuplicate ) {
|
|
1943 while ( (elem = results[i++]) ) {
|
|
1944 if ( elem === results[ i ] ) {
|
|
1945 j = duplicates.push( i );
|
|
1946 }
|
|
1947 }
|
|
1948 while ( j-- ) {
|
|
1949 results.splice( duplicates[ j ], 1 );
|
|
1950 }
|
|
1951 }
|
|
1952
|
|
1953 return results;
|
|
1954 };
|
|
1955
|
|
1956 /**
|
|
1957 * Utility function for retrieving the text value of an array of DOM nodes
|
|
1958 * @param {Array|Element} elem
|
|
1959 */
|
|
1960 getText = Sizzle.getText = function( elem ) {
|
|
1961 var node,
|
|
1962 ret = "",
|
|
1963 i = 0,
|
|
1964 nodeType = elem.nodeType;
|
|
1965
|
|
1966 if ( !nodeType ) {
|
|
1967 // If no nodeType, this is expected to be an array
|
|
1968 for ( ; (node = elem[i]); i++ ) {
|
|
1969 // Do not traverse comment nodes
|
|
1970 ret += getText( node );
|
|
1971 }
|
|
1972 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
|
|
1973 // Use textContent for elements
|
|
1974 // innerText usage removed for consistency of new lines (see #11153)
|
|
1975 if ( typeof elem.textContent === "string" ) {
|
|
1976 return elem.textContent;
|
|
1977 } else {
|
|
1978 // Traverse its children
|
|
1979 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
|
|
1980 ret += getText( elem );
|
|
1981 }
|
|
1982 }
|
|
1983 } else if ( nodeType === 3 || nodeType === 4 ) {
|
|
1984 return elem.nodeValue;
|
|
1985 }
|
|
1986 // Do not include comment or processing instruction nodes
|
|
1987
|
|
1988 return ret;
|
|
1989 };
|
|
1990
|
|
1991 Expr = Sizzle.selectors = {
|
|
1992
|
|
1993 // Can be adjusted by the user
|
|
1994 cacheLength: 50,
|
|
1995
|
|
1996 createPseudo: markFunction,
|
|
1997
|
|
1998 match: matchExpr,
|
|
1999
|
|
2000 attrHandle: {},
|
|
2001
|
|
2002 find: {},
|
|
2003
|
|
2004 relative: {
|
|
2005 ">": { dir: "parentNode", first: true },
|
|
2006 " ": { dir: "parentNode" },
|
|
2007 "+": { dir: "previousSibling", first: true },
|
|
2008 "~": { dir: "previousSibling" }
|
|
2009 },
|
|
2010
|
|
2011 preFilter: {
|
|
2012 "ATTR": function( match ) {
|
|
2013 match[1] = match[1].replace( runescape, funescape );
|
|
2014
|
|
2015 // Move the given value to match[3] whether quoted or unquoted
|
|
2016 match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
|
|
2017
|
|
2018 if ( match[2] === "~=" ) {
|
|
2019 match[3] = " " + match[3] + " ";
|
|
2020 }
|
|
2021
|
|
2022 return match.slice( 0, 4 );
|
|
2023 },
|
|
2024
|
|
2025 "CHILD": function( match ) {
|
|
2026 /* matches from matchExpr["CHILD"]
|
|
2027 1 type (only|nth|...)
|
|
2028 2 what (child|of-type)
|
|
2029 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
|
|
2030 4 xn-component of xn+y argument ([+-]?\d*n|)
|
|
2031 5 sign of xn-component
|
|
2032 6 x of xn-component
|
|
2033 7 sign of y-component
|
|
2034 8 y of y-component
|
|
2035 */
|
|
2036 match[1] = match[1].toLowerCase();
|
|
2037
|
|
2038 if ( match[1].slice( 0, 3 ) === "nth" ) {
|
|
2039 // nth-* requires argument
|
|
2040 if ( !match[3] ) {
|
|
2041 Sizzle.error( match[0] );
|
|
2042 }
|
|
2043
|
|
2044 // numeric x and y parameters for Expr.filter.CHILD
|
|
2045 // remember that false/true cast respectively to 0/1
|
|
2046 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
|
|
2047 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
|
|
2048
|
|
2049 // other types prohibit arguments
|
|
2050 } else if ( match[3] ) {
|
|
2051 Sizzle.error( match[0] );
|
|
2052 }
|
|
2053
|
|
2054 return match;
|
|
2055 },
|
|
2056
|
|
2057 "PSEUDO": function( match ) {
|
|
2058 var excess,
|
|
2059 unquoted = !match[5] && match[2];
|
|
2060
|
|
2061 if ( matchExpr["CHILD"].test( match[0] ) ) {
|
|
2062 return null;
|
|
2063 }
|
|
2064
|
|
2065 // Accept quoted arguments as-is
|
|
2066 if ( match[3] && match[4] !== undefined ) {
|
|
2067 match[2] = match[4];
|
|
2068
|
|
2069 // Strip excess characters from unquoted arguments
|
|
2070 } else if ( unquoted && rpseudo.test( unquoted ) &&
|
|
2071 // Get excess from tokenize (recursively)
|
|
2072 (excess = tokenize( unquoted, true )) &&
|
|
2073 // advance to the next closing parenthesis
|
|
2074 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
|
|
2075
|
|
2076 // excess is a negative index
|
|
2077 match[0] = match[0].slice( 0, excess );
|
|
2078 match[2] = unquoted.slice( 0, excess );
|
|
2079 }
|
|
2080
|
|
2081 // Return only captures needed by the pseudo filter method (type and argument)
|
|
2082 return match.slice( 0, 3 );
|
|
2083 }
|
|
2084 },
|
|
2085
|
|
2086 filter: {
|
|
2087
|
|
2088 "TAG": function( nodeNameSelector ) {
|
|
2089 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
|
|
2090 return nodeNameSelector === "*" ?
|
|
2091 function() { return true; } :
|
|
2092 function( elem ) {
|
|
2093 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
|
|
2094 };
|
|
2095 },
|
|
2096
|
|
2097 "CLASS": function( className ) {
|
|
2098 var pattern = classCache[ className + " " ];
|
|
2099
|
|
2100 return pattern ||
|
|
2101 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
|
|
2102 classCache( className, function( elem ) {
|
|
2103 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
|
|
2104 });
|
|
2105 },
|
|
2106
|
|
2107 "ATTR": function( name, operator, check ) {
|
|
2108 return function( elem ) {
|
|
2109 var result = Sizzle.attr( elem, name );
|
|
2110
|
|
2111 if ( result == null ) {
|
|
2112 return operator === "!=";
|
|
2113 }
|
|
2114 if ( !operator ) {
|
|
2115 return true;
|
|
2116 }
|
|
2117
|
|
2118 result += "";
|
|
2119
|
|
2120 return operator === "=" ? result === check :
|
|
2121 operator === "!=" ? result !== check :
|
|
2122 operator === "^=" ? check && result.indexOf( check ) === 0 :
|
|
2123 operator === "*=" ? check && result.indexOf( check ) > -1 :
|
|
2124 operator === "$=" ? check && result.slice( -check.length ) === check :
|
|
2125 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
|
|
2126 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
|
|
2127 false;
|
|
2128 };
|
|
2129 },
|
|
2130
|
|
2131 "CHILD": function( type, what, argument, first, last ) {
|
|
2132 var simple = type.slice( 0, 3 ) !== "nth",
|
|
2133 forward = type.slice( -4 ) !== "last",
|
|
2134 ofType = what === "of-type";
|
|
2135
|
|
2136 return first === 1 && last === 0 ?
|
|
2137
|
|
2138 // Shortcut for :nth-*(n)
|
|
2139 function( elem ) {
|
|
2140 return !!elem.parentNode;
|
|
2141 } :
|
|
2142
|
|
2143 function( elem, context, xml ) {
|
|
2144 var cache, outerCache, node, diff, nodeIndex, start,
|
|
2145 dir = simple !== forward ? "nextSibling" : "previousSibling",
|
|
2146 parent = elem.parentNode,
|
|
2147 name = ofType && elem.nodeName.toLowerCase(),
|
|
2148 useCache = !xml && !ofType;
|
|
2149
|
|
2150 if ( parent ) {
|
|
2151
|
|
2152 // :(first|last|only)-(child|of-type)
|
|
2153 if ( simple ) {
|
|
2154 while ( dir ) {
|
|
2155 node = elem;
|
|
2156 while ( (node = node[ dir ]) ) {
|
|
2157 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
|
|
2158 return false;
|
|
2159 }
|
|
2160 }
|
|
2161 // Reverse direction for :only-* (if we haven't yet done so)
|
|
2162 start = dir = type === "only" && !start && "nextSibling";
|
|
2163 }
|
|
2164 return true;
|
|
2165 }
|
|
2166
|
|
2167 start = [ forward ? parent.firstChild : parent.lastChild ];
|
|
2168
|
|
2169 // non-xml :nth-child(...) stores cache data on `parent`
|
|
2170 if ( forward && useCache ) {
|
|
2171 // Seek `elem` from a previously-cached index
|
|
2172 outerCache = parent[ expando ] || (parent[ expando ] = {});
|
|
2173 cache = outerCache[ type ] || [];
|
|
2174 nodeIndex = cache[0] === dirruns && cache[1];
|
|
2175 diff = cache[0] === dirruns && cache[2];
|
|
2176 node = nodeIndex && parent.childNodes[ nodeIndex ];
|
|
2177
|
|
2178 while ( (node = ++nodeIndex && node && node[ dir ] ||
|
|
2179
|
|
2180 // Fallback to seeking `elem` from the start
|
|
2181 (diff = nodeIndex = 0) || start.pop()) ) {
|
|
2182
|
|
2183 // When found, cache indexes on `parent` and break
|
|
2184 if ( node.nodeType === 1 && ++diff && node === elem ) {
|
|
2185 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
|
|
2186 break;
|
|
2187 }
|
|
2188 }
|
|
2189
|
|
2190 // Use previously-cached element index if available
|
|
2191 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
|
|
2192 diff = cache[1];
|
|
2193
|
|
2194 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
|
|
2195 } else {
|
|
2196 // Use the same loop as above to seek `elem` from the start
|
|
2197 while ( (node = ++nodeIndex && node && node[ dir ] ||
|
|
2198 (diff = nodeIndex = 0) || start.pop()) ) {
|
|
2199
|
|
2200 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
|
|
2201 // Cache the index of each encountered element
|
|
2202 if ( useCache ) {
|
|
2203 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
|
|
2204 }
|
|
2205
|
|
2206 if ( node === elem ) {
|
|
2207 break;
|
|
2208 }
|
|
2209 }
|
|
2210 }
|
|
2211 }
|
|
2212
|
|
2213 // Incorporate the offset, then check against cycle size
|
|
2214 diff -= last;
|
|
2215 return diff === first || ( diff % first === 0 && diff / first >= 0 );
|
|
2216 }
|
|
2217 };
|
|
2218 },
|
|
2219
|
|
2220 "PSEUDO": function( pseudo, argument ) {
|
|
2221 // pseudo-class names are case-insensitive
|
|
2222 // http://www.w3.org/TR/selectors/#pseudo-classes
|
|
2223 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
|
|
2224 // Remember that setFilters inherits from pseudos
|
|
2225 var args,
|
|
2226 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
|
|
2227 Sizzle.error( "unsupported pseudo: " + pseudo );
|
|
2228
|
|
2229 // The user may use createPseudo to indicate that
|
|
2230 // arguments are needed to create the filter function
|
|
2231 // just as Sizzle does
|
|
2232 if ( fn[ expando ] ) {
|
|
2233 return fn( argument );
|
|
2234 }
|
|
2235
|
|
2236 // But maintain support for old signatures
|
|
2237 if ( fn.length > 1 ) {
|
|
2238 args = [ pseudo, pseudo, "", argument ];
|
|
2239 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
|
|
2240 markFunction(function( seed, matches ) {
|
|
2241 var idx,
|
|
2242 matched = fn( seed, argument ),
|
|
2243 i = matched.length;
|
|
2244 while ( i-- ) {
|
|
2245 idx = indexOf.call( seed, matched[i] );
|
|
2246 seed[ idx ] = !( matches[ idx ] = matched[i] );
|
|
2247 }
|
|
2248 }) :
|
|
2249 function( elem ) {
|
|
2250 return fn( elem, 0, args );
|
|
2251 };
|
|
2252 }
|
|
2253
|
|
2254 return fn;
|
|
2255 }
|
|
2256 },
|
|
2257
|
|
2258 pseudos: {
|
|
2259 // Potentially complex pseudos
|
|
2260 "not": markFunction(function( selector ) {
|
|
2261 // Trim the selector passed to compile
|
|
2262 // to avoid treating leading and trailing
|
|
2263 // spaces as combinators
|
|
2264 var input = [],
|
|
2265 results = [],
|
|
2266 matcher = compile( selector.replace( rtrim, "$1" ) );
|
|
2267
|
|
2268 return matcher[ expando ] ?
|
|
2269 markFunction(function( seed, matches, context, xml ) {
|
|
2270 var elem,
|
|
2271 unmatched = matcher( seed, null, xml, [] ),
|
|
2272 i = seed.length;
|
|
2273
|
|
2274 // Match elements unmatched by `matcher`
|
|
2275 while ( i-- ) {
|
|
2276 if ( (elem = unmatched[i]) ) {
|
|
2277 seed[i] = !(matches[i] = elem);
|
|
2278 }
|
|
2279 }
|
|
2280 }) :
|
|
2281 function( elem, context, xml ) {
|
|
2282 input[0] = elem;
|
|
2283 matcher( input, null, xml, results );
|
|
2284 return !results.pop();
|
|
2285 };
|
|
2286 }),
|
|
2287
|
|
2288 "has": markFunction(function( selector ) {
|
|
2289 return function( elem ) {
|
|
2290 return Sizzle( selector, elem ).length > 0;
|
|
2291 };
|
|
2292 }),
|
|
2293
|
|
2294 "contains": markFunction(function( text ) {
|
|
2295 return function( elem ) {
|
|
2296 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
|
|
2297 };
|
|
2298 }),
|
|
2299
|
|
2300 // "Whether an element is represented by a :lang() selector
|
|
2301 // is based solely on the element's language value
|
|
2302 // being equal to the identifier C,
|
|
2303 // or beginning with the identifier C immediately followed by "-".
|
|
2304 // The matching of C against the element's language value is performed case-insensitively.
|
|
2305 // The identifier C does not have to be a valid language name."
|
|
2306 // http://www.w3.org/TR/selectors/#lang-pseudo
|
|
2307 "lang": markFunction( function( lang ) {
|
|
2308 // lang value must be a valid identifier
|
|
2309 if ( !ridentifier.test(lang || "") ) {
|
|
2310 Sizzle.error( "unsupported lang: " + lang );
|
|
2311 }
|
|
2312 lang = lang.replace( runescape, funescape ).toLowerCase();
|
|
2313 return function( elem ) {
|
|
2314 var elemLang;
|
|
2315 do {
|
|
2316 if ( (elemLang = documentIsHTML ?
|
|
2317 elem.lang :
|
|
2318 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
|
|
2319
|
|
2320 elemLang = elemLang.toLowerCase();
|
|
2321 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
|
|
2322 }
|
|
2323 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
|
|
2324 return false;
|
|
2325 };
|
|
2326 }),
|
|
2327
|
|
2328 // Miscellaneous
|
|
2329 "target": function( elem ) {
|
|
2330 var hash = window.location && window.location.hash;
|
|
2331 return hash && hash.slice( 1 ) === elem.id;
|
|
2332 },
|
|
2333
|
|
2334 "root": function( elem ) {
|
|
2335 return elem === docElem;
|
|
2336 },
|
|
2337
|
|
2338 "focus": function( elem ) {
|
|
2339 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
|
|
2340 },
|
|
2341
|
|
2342 // Boolean properties
|
|
2343 "enabled": function( elem ) {
|
|
2344 return elem.disabled === false;
|
|
2345 },
|
|
2346
|
|
2347 "disabled": function( elem ) {
|
|
2348 return elem.disabled === true;
|
|
2349 },
|
|
2350
|
|
2351 "checked": function( elem ) {
|
|
2352 // In CSS3, :checked should return both checked and selected elements
|
|
2353 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
|
|
2354 var nodeName = elem.nodeName.toLowerCase();
|
|
2355 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
|
|
2356 },
|
|
2357
|
|
2358 "selected": function( elem ) {
|
|
2359 // Accessing this property makes selected-by-default
|
|
2360 // options in Safari work properly
|
|
2361 if ( elem.parentNode ) {
|
|
2362 elem.parentNode.selectedIndex;
|
|
2363 }
|
|
2364
|
|
2365 return elem.selected === true;
|
|
2366 },
|
|
2367
|
|
2368 // Contents
|
|
2369 "empty": function( elem ) {
|
|
2370 // http://www.w3.org/TR/selectors/#empty-pseudo
|
|
2371 // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
|
|
2372 // not comment, processing instructions, or others
|
|
2373 // Thanks to Diego Perini for the nodeName shortcut
|
|
2374 // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
|
|
2375 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
|
|
2376 if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) {
|
|
2377 return false;
|
|
2378 }
|
|
2379 }
|
|
2380 return true;
|
|
2381 },
|
|
2382
|
|
2383 "parent": function( elem ) {
|
|
2384 return !Expr.pseudos["empty"]( elem );
|
|
2385 },
|
|
2386
|
|
2387 // Element/input types
|
|
2388 "header": function( elem ) {
|
|
2389 return rheader.test( elem.nodeName );
|
|
2390 },
|
|
2391
|
|
2392 "input": function( elem ) {
|
|
2393 return rinputs.test( elem.nodeName );
|
|
2394 },
|
|
2395
|
|
2396 "button": function( elem ) {
|
|
2397 var name = elem.nodeName.toLowerCase();
|
|
2398 return name === "input" && elem.type === "button" || name === "button";
|
|
2399 },
|
|
2400
|
|
2401 "text": function( elem ) {
|
|
2402 var attr;
|
|
2403 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
|
|
2404 // use getAttribute instead to test this case
|
|
2405 return elem.nodeName.toLowerCase() === "input" &&
|
|
2406 elem.type === "text" &&
|
|
2407 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type );
|
|
2408 },
|
|
2409
|
|
2410 // Position-in-collection
|
|
2411 "first": createPositionalPseudo(function() {
|
|
2412 return [ 0 ];
|
|
2413 }),
|
|
2414
|
|
2415 "last": createPositionalPseudo(function( matchIndexes, length ) {
|
|
2416 return [ length - 1 ];
|
|
2417 }),
|
|
2418
|
|
2419 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
|
|
2420 return [ argument < 0 ? argument + length : argument ];
|
|
2421 }),
|
|
2422
|
|
2423 "even": createPositionalPseudo(function( matchIndexes, length ) {
|
|
2424 var i = 0;
|
|
2425 for ( ; i < length; i += 2 ) {
|
|
2426 matchIndexes.push( i );
|
|
2427 }
|
|
2428 return matchIndexes;
|
|
2429 }),
|
|
2430
|
|
2431 "odd": createPositionalPseudo(function( matchIndexes, length ) {
|
|
2432 var i = 1;
|
|
2433 for ( ; i < length; i += 2 ) {
|
|
2434 matchIndexes.push( i );
|
|
2435 }
|
|
2436 return matchIndexes;
|
|
2437 }),
|
|
2438
|
|
2439 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
|
|
2440 var i = argument < 0 ? argument + length : argument;
|
|
2441 for ( ; --i >= 0; ) {
|
|
2442 matchIndexes.push( i );
|
|
2443 }
|
|
2444 return matchIndexes;
|
|
2445 }),
|
|
2446
|
|
2447 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
|
|
2448 var i = argument < 0 ? argument + length : argument;
|
|
2449 for ( ; ++i < length; ) {
|
|
2450 matchIndexes.push( i );
|
|
2451 }
|
|
2452 return matchIndexes;
|
|
2453 })
|
|
2454 }
|
|
2455 };
|
|
2456
|
|
2457 // Add button/input type pseudos
|
|
2458 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
|
|
2459 Expr.pseudos[ i ] = createInputPseudo( i );
|
|
2460 }
|
|
2461 for ( i in { submit: true, reset: true } ) {
|
|
2462 Expr.pseudos[ i ] = createButtonPseudo( i );
|
|
2463 }
|
|
2464
|
|
2465 function tokenize( selector, parseOnly ) {
|
|
2466 var matched, match, tokens, type,
|
|
2467 soFar, groups, preFilters,
|
|
2468 cached = tokenCache[ selector + " " ];
|
|
2469
|
|
2470 if ( cached ) {
|
|
2471 return parseOnly ? 0 : cached.slice( 0 );
|
|
2472 }
|
|
2473
|
|
2474 soFar = selector;
|
|
2475 groups = [];
|
|
2476 preFilters = Expr.preFilter;
|
|
2477
|
|
2478 while ( soFar ) {
|
|
2479
|
|
2480 // Comma and first run
|
|
2481 if ( !matched || (match = rcomma.exec( soFar )) ) {
|
|
2482 if ( match ) {
|
|
2483 // Don't consume trailing commas as valid
|
|
2484 soFar = soFar.slice( match[0].length ) || soFar;
|
|
2485 }
|
|
2486 groups.push( tokens = [] );
|
|
2487 }
|
|
2488
|
|
2489 matched = false;
|
|
2490
|
|
2491 // Combinators
|
|
2492 if ( (match = rcombinators.exec( soFar )) ) {
|
|
2493 matched = match.shift();
|
|
2494 tokens.push({
|
|
2495 value: matched,
|
|
2496 // Cast descendant combinators to space
|
|
2497 type: match[0].replace( rtrim, " " )
|
|
2498 });
|
|
2499 soFar = soFar.slice( matched.length );
|
|
2500 }
|
|
2501
|
|
2502 // Filters
|
|
2503 for ( type in Expr.filter ) {
|
|
2504 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
|
|
2505 (match = preFilters[ type ]( match ))) ) {
|
|
2506 matched = match.shift();
|
|
2507 tokens.push({
|
|
2508 value: matched,
|
|
2509 type: type,
|
|
2510 matches: match
|
|
2511 });
|
|
2512 soFar = soFar.slice( matched.length );
|
|
2513 }
|
|
2514 }
|
|
2515
|
|
2516 if ( !matched ) {
|
|
2517 break;
|
|
2518 }
|
|
2519 }
|
|
2520
|
|
2521 // Return the length of the invalid excess
|
|
2522 // if we're just parsing
|
|
2523 // Otherwise, throw an error or return tokens
|
|
2524 return parseOnly ?
|
|
2525 soFar.length :
|
|
2526 soFar ?
|
|
2527 Sizzle.error( selector ) :
|
|
2528 // Cache the tokens
|
|
2529 tokenCache( selector, groups ).slice( 0 );
|
|
2530 }
|
|
2531
|
|
2532 function toSelector( tokens ) {
|
|
2533 var i = 0,
|
|
2534 len = tokens.length,
|
|
2535 selector = "";
|
|
2536 for ( ; i < len; i++ ) {
|
|
2537 selector += tokens[i].value;
|
|
2538 }
|
|
2539 return selector;
|
|
2540 }
|
|
2541
|
|
2542 function addCombinator( matcher, combinator, base ) {
|
|
2543 var dir = combinator.dir,
|
|
2544 checkNonElements = base && dir === "parentNode",
|
|
2545 doneName = done++;
|
|
2546
|
|
2547 return combinator.first ?
|
|
2548 // Check against closest ancestor/preceding element
|
|
2549 function( elem, context, xml ) {
|
|
2550 while ( (elem = elem[ dir ]) ) {
|
|
2551 if ( elem.nodeType === 1 || checkNonElements ) {
|
|
2552 return matcher( elem, context, xml );
|
|
2553 }
|
|
2554 }
|
|
2555 } :
|
|
2556
|
|
2557 // Check against all ancestor/preceding elements
|
|
2558 function( elem, context, xml ) {
|
|
2559 var data, cache, outerCache,
|
|
2560 dirkey = dirruns + " " + doneName;
|
|
2561
|
|
2562 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
|
|
2563 if ( xml ) {
|
|
2564 while ( (elem = elem[ dir ]) ) {
|
|
2565 if ( elem.nodeType === 1 || checkNonElements ) {
|
|
2566 if ( matcher( elem, context, xml ) ) {
|
|
2567 return true;
|
|
2568 }
|
|
2569 }
|
|
2570 }
|
|
2571 } else {
|
|
2572 while ( (elem = elem[ dir ]) ) {
|
|
2573 if ( elem.nodeType === 1 || checkNonElements ) {
|
|
2574 outerCache = elem[ expando ] || (elem[ expando ] = {});
|
|
2575 if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) {
|
|
2576 if ( (data = cache[1]) === true || data === cachedruns ) {
|
|
2577 return data === true;
|
|
2578 }
|
|
2579 } else {
|
|
2580 cache = outerCache[ dir ] = [ dirkey ];
|
|
2581 cache[1] = matcher( elem, context, xml ) || cachedruns;
|
|
2582 if ( cache[1] === true ) {
|
|
2583 return true;
|
|
2584 }
|
|
2585 }
|
|
2586 }
|
|
2587 }
|
|
2588 }
|
|
2589 };
|
|
2590 }
|
|
2591
|
|
2592 function elementMatcher( matchers ) {
|
|
2593 return matchers.length > 1 ?
|
|
2594 function( elem, context, xml ) {
|
|
2595 var i = matchers.length;
|
|
2596 while ( i-- ) {
|
|
2597 if ( !matchers[i]( elem, context, xml ) ) {
|
|
2598 return false;
|
|
2599 }
|
|
2600 }
|
|
2601 return true;
|
|
2602 } :
|
|
2603 matchers[0];
|
|
2604 }
|
|
2605
|
|
2606 function condense( unmatched, map, filter, context, xml ) {
|
|
2607 var elem,
|
|
2608 newUnmatched = [],
|
|
2609 i = 0,
|
|
2610 len = unmatched.length,
|
|
2611 mapped = map != null;
|
|
2612
|
|
2613 for ( ; i < len; i++ ) {
|
|
2614 if ( (elem = unmatched[i]) ) {
|
|
2615 if ( !filter || filter( elem, context, xml ) ) {
|
|
2616 newUnmatched.push( elem );
|
|
2617 if ( mapped ) {
|
|
2618 map.push( i );
|
|
2619 }
|
|
2620 }
|
|
2621 }
|
|
2622 }
|
|
2623
|
|
2624 return newUnmatched;
|
|
2625 }
|
|
2626
|
|
2627 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
|
|
2628 if ( postFilter && !postFilter[ expando ] ) {
|
|
2629 postFilter = setMatcher( postFilter );
|
|
2630 }
|
|
2631 if ( postFinder && !postFinder[ expando ] ) {
|
|
2632 postFinder = setMatcher( postFinder, postSelector );
|
|
2633 }
|
|
2634 return markFunction(function( seed, results, context, xml ) {
|
|
2635 var temp, i, elem,
|
|
2636 preMap = [],
|
|
2637 postMap = [],
|
|
2638 preexisting = results.length,
|
|
2639
|
|
2640 // Get initial elements from seed or context
|
|
2641 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
|
|
2642
|
|
2643 // Prefilter to get matcher input, preserving a map for seed-results synchronization
|
|
2644 matcherIn = preFilter && ( seed || !selector ) ?
|
|
2645 condense( elems, preMap, preFilter, context, xml ) :
|
|
2646 elems,
|
|
2647
|
|
2648 matcherOut = matcher ?
|
|
2649 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
|
|
2650 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
|
|
2651
|
|
2652 // ...intermediate processing is necessary
|
|
2653 [] :
|
|
2654
|
|
2655 // ...otherwise use results directly
|
|
2656 results :
|
|
2657 matcherIn;
|
|
2658
|
|
2659 // Find primary matches
|
|
2660 if ( matcher ) {
|
|
2661 matcher( matcherIn, matcherOut, context, xml );
|
|
2662 }
|
|
2663
|
|
2664 // Apply postFilter
|
|
2665 if ( postFilter ) {
|
|
2666 temp = condense( matcherOut, postMap );
|
|
2667 postFilter( temp, [], context, xml );
|
|
2668
|
|
2669 // Un-match failing elements by moving them back to matcherIn
|
|
2670 i = temp.length;
|
|
2671 while ( i-- ) {
|
|
2672 if ( (elem = temp[i]) ) {
|
|
2673 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
|
|
2674 }
|
|
2675 }
|
|
2676 }
|
|
2677
|
|
2678 if ( seed ) {
|
|
2679 if ( postFinder || preFilter ) {
|
|
2680 if ( postFinder ) {
|
|
2681 // Get the final matcherOut by condensing this intermediate into postFinder contexts
|
|
2682 temp = [];
|
|
2683 i = matcherOut.length;
|
|
2684 while ( i-- ) {
|
|
2685 if ( (elem = matcherOut[i]) ) {
|
|
2686 // Restore matcherIn since elem is not yet a final match
|
|
2687 temp.push( (matcherIn[i] = elem) );
|
|
2688 }
|
|
2689 }
|
|
2690 postFinder( null, (matcherOut = []), temp, xml );
|
|
2691 }
|
|
2692
|
|
2693 // Move matched elements from seed to results to keep them synchronized
|
|
2694 i = matcherOut.length;
|
|
2695 while ( i-- ) {
|
|
2696 if ( (elem = matcherOut[i]) &&
|
|
2697 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
|
|
2698
|
|
2699 seed[temp] = !(results[temp] = elem);
|
|
2700 }
|
|
2701 }
|
|
2702 }
|
|
2703
|
|
2704 // Add elements to results, through postFinder if defined
|
|
2705 } else {
|
|
2706 matcherOut = condense(
|
|
2707 matcherOut === results ?
|
|
2708 matcherOut.splice( preexisting, matcherOut.length ) :
|
|
2709 matcherOut
|
|
2710 );
|
|
2711 if ( postFinder ) {
|
|
2712 postFinder( null, results, matcherOut, xml );
|
|
2713 } else {
|
|
2714 push.apply( results, matcherOut );
|
|
2715 }
|
|
2716 }
|
|
2717 });
|
|
2718 }
|
|
2719
|
|
2720 function matcherFromTokens( tokens ) {
|
|
2721 var checkContext, matcher, j,
|
|
2722 len = tokens.length,
|
|
2723 leadingRelative = Expr.relative[ tokens[0].type ],
|
|
2724 implicitRelative = leadingRelative || Expr.relative[" "],
|
|
2725 i = leadingRelative ? 1 : 0,
|
|
2726
|
|
2727 // The foundational matcher ensures that elements are reachable from top-level context(s)
|
|
2728 matchContext = addCombinator( function( elem ) {
|
|
2729 return elem === checkContext;
|
|
2730 }, implicitRelative, true ),
|
|
2731 matchAnyContext = addCombinator( function( elem ) {
|
|
2732 return indexOf.call( checkContext, elem ) > -1;
|
|
2733 }, implicitRelative, true ),
|
|
2734 matchers = [ function( elem, context, xml ) {
|
|
2735 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
|
|
2736 (checkContext = context).nodeType ?
|
|
2737 matchContext( elem, context, xml ) :
|
|
2738 matchAnyContext( elem, context, xml ) );
|
|
2739 } ];
|
|
2740
|
|
2741 for ( ; i < len; i++ ) {
|
|
2742 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
|
|
2743 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
|
|
2744 } else {
|
|
2745 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
|
|
2746
|
|
2747 // Return special upon seeing a positional matcher
|
|
2748 if ( matcher[ expando ] ) {
|
|
2749 // Find the next relative operator (if any) for proper handling
|
|
2750 j = ++i;
|
|
2751 for ( ; j < len; j++ ) {
|
|
2752 if ( Expr.relative[ tokens[j].type ] ) {
|
|
2753 break;
|
|
2754 }
|
|
2755 }
|
|
2756 return setMatcher(
|
|
2757 i > 1 && elementMatcher( matchers ),
|
|
2758 i > 1 && toSelector(
|
|
2759 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
|
|
2760 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
|
|
2761 ).replace( rtrim, "$1" ),
|
|
2762 matcher,
|
|
2763 i < j && matcherFromTokens( tokens.slice( i, j ) ),
|
|
2764 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
|
|
2765 j < len && toSelector( tokens )
|
|
2766 );
|
|
2767 }
|
|
2768 matchers.push( matcher );
|
|
2769 }
|
|
2770 }
|
|
2771
|
|
2772 return elementMatcher( matchers );
|
|
2773 }
|
|
2774
|
|
2775 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
|
|
2776 // A counter to specify which element is currently being matched
|
|
2777 var matcherCachedRuns = 0,
|
|
2778 bySet = setMatchers.length > 0,
|
|
2779 byElement = elementMatchers.length > 0,
|
|
2780 superMatcher = function( seed, context, xml, results, expandContext ) {
|
|
2781 var elem, j, matcher,
|
|
2782 setMatched = [],
|
|
2783 matchedCount = 0,
|
|
2784 i = "0",
|
|
2785 unmatched = seed && [],
|
|
2786 outermost = expandContext != null,
|
|
2787 contextBackup = outermostContext,
|
|
2788 // We must always have either seed elements or context
|
|
2789 elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
|
|
2790 // Use integer dirruns iff this is the outermost matcher
|
|
2791 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1);
|
|
2792
|
|
2793 if ( outermost ) {
|
|
2794 outermostContext = context !== document && context;
|
|
2795 cachedruns = matcherCachedRuns;
|
|
2796 }
|
|
2797
|
|
2798 // Add elements passing elementMatchers directly to results
|
|
2799 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
|
|
2800 for ( ; (elem = elems[i]) != null; i++ ) {
|
|
2801 if ( byElement && elem ) {
|
|
2802 j = 0;
|
|
2803 while ( (matcher = elementMatchers[j++]) ) {
|
|
2804 if ( matcher( elem, context, xml ) ) {
|
|
2805 results.push( elem );
|
|
2806 break;
|
|
2807 }
|
|
2808 }
|
|
2809 if ( outermost ) {
|
|
2810 dirruns = dirrunsUnique;
|
|
2811 cachedruns = ++matcherCachedRuns;
|
|
2812 }
|
|
2813 }
|
|
2814
|
|
2815 // Track unmatched elements for set filters
|
|
2816 if ( bySet ) {
|
|
2817 // They will have gone through all possible matchers
|
|
2818 if ( (elem = !matcher && elem) ) {
|
|
2819 matchedCount--;
|
|
2820 }
|
|
2821
|
|
2822 // Lengthen the array for every element, matched or not
|
|
2823 if ( seed ) {
|
|
2824 unmatched.push( elem );
|
|
2825 }
|
|
2826 }
|
|
2827 }
|
|
2828
|
|
2829 // Apply set filters to unmatched elements
|
|
2830 matchedCount += i;
|
|
2831 if ( bySet && i !== matchedCount ) {
|
|
2832 j = 0;
|
|
2833 while ( (matcher = setMatchers[j++]) ) {
|
|
2834 matcher( unmatched, setMatched, context, xml );
|
|
2835 }
|
|
2836
|
|
2837 if ( seed ) {
|
|
2838 // Reintegrate element matches to eliminate the need for sorting
|
|
2839 if ( matchedCount > 0 ) {
|
|
2840 while ( i-- ) {
|
|
2841 if ( !(unmatched[i] || setMatched[i]) ) {
|
|
2842 setMatched[i] = pop.call( results );
|
|
2843 }
|
|
2844 }
|
|
2845 }
|
|
2846
|
|
2847 // Discard index placeholder values to get only actual matches
|
|
2848 setMatched = condense( setMatched );
|
|
2849 }
|
|
2850
|
|
2851 // Add matches to results
|
|
2852 push.apply( results, setMatched );
|
|
2853
|
|
2854 // Seedless set matches succeeding multiple successful matchers stipulate sorting
|
|
2855 if ( outermost && !seed && setMatched.length > 0 &&
|
|
2856 ( matchedCount + setMatchers.length ) > 1 ) {
|
|
2857
|
|
2858 Sizzle.uniqueSort( results );
|
|
2859 }
|
|
2860 }
|
|
2861
|
|
2862 // Override manipulation of globals by nested matchers
|
|
2863 if ( outermost ) {
|
|
2864 dirruns = dirrunsUnique;
|
|
2865 outermostContext = contextBackup;
|
|
2866 }
|
|
2867
|
|
2868 return unmatched;
|
|
2869 };
|
|
2870
|
|
2871 return bySet ?
|
|
2872 markFunction( superMatcher ) :
|
|
2873 superMatcher;
|
|
2874 }
|
|
2875
|
|
2876 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
|
|
2877 var i,
|
|
2878 setMatchers = [],
|
|
2879 elementMatchers = [],
|
|
2880 cached = compilerCache[ selector + " " ];
|
|
2881
|
|
2882 if ( !cached ) {
|
|
2883 // Generate a function of recursive functions that can be used to check each element
|
|
2884 if ( !group ) {
|
|
2885 group = tokenize( selector );
|
|
2886 }
|
|
2887 i = group.length;
|
|
2888 while ( i-- ) {
|
|
2889 cached = matcherFromTokens( group[i] );
|
|
2890 if ( cached[ expando ] ) {
|
|
2891 setMatchers.push( cached );
|
|
2892 } else {
|
|
2893 elementMatchers.push( cached );
|
|
2894 }
|
|
2895 }
|
|
2896
|
|
2897 // Cache the compiled function
|
|
2898 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
|
|
2899 }
|
|
2900 return cached;
|
|
2901 };
|
|
2902
|
|
2903 function multipleContexts( selector, contexts, results ) {
|
|
2904 var i = 0,
|
|
2905 len = contexts.length;
|
|
2906 for ( ; i < len; i++ ) {
|
|
2907 Sizzle( selector, contexts[i], results );
|
|
2908 }
|
|
2909 return results;
|
|
2910 }
|
|
2911
|
|
2912 function select( selector, context, results, seed ) {
|
|
2913 var i, tokens, token, type, find,
|
|
2914 match = tokenize( selector );
|
|
2915
|
|
2916 if ( !seed ) {
|
|
2917 // Try to minimize operations if there is only one group
|
|
2918 if ( match.length === 1 ) {
|
|
2919
|
|
2920 // Take a shortcut and set the context if the root selector is an ID
|
|
2921 tokens = match[0] = match[0].slice( 0 );
|
|
2922 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
|
|
2923 support.getById && context.nodeType === 9 && documentIsHTML &&
|
|
2924 Expr.relative[ tokens[1].type ] ) {
|
|
2925
|
|
2926 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
|
|
2927 if ( !context ) {
|
|
2928 return results;
|
|
2929 }
|
|
2930 selector = selector.slice( tokens.shift().value.length );
|
|
2931 }
|
|
2932
|
|
2933 // Fetch a seed set for right-to-left matching
|
|
2934 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
|
|
2935 while ( i-- ) {
|
|
2936 token = tokens[i];
|
|
2937
|
|
2938 // Abort if we hit a combinator
|
|
2939 if ( Expr.relative[ (type = token.type) ] ) {
|
|
2940 break;
|
|
2941 }
|
|
2942 if ( (find = Expr.find[ type ]) ) {
|
|
2943 // Search, expanding context for leading sibling combinators
|
|
2944 if ( (seed = find(
|
|
2945 token.matches[0].replace( runescape, funescape ),
|
|
2946 rsibling.test( tokens[0].type ) && context.parentNode || context
|
|
2947 )) ) {
|
|
2948
|
|
2949 // If seed is empty or no tokens remain, we can return early
|
|
2950 tokens.splice( i, 1 );
|
|
2951 selector = seed.length && toSelector( tokens );
|
|
2952 if ( !selector ) {
|
|
2953 push.apply( results, seed );
|
|
2954 return results;
|
|
2955 }
|
|
2956
|
|
2957 break;
|
|
2958 }
|
|
2959 }
|
|
2960 }
|
|
2961 }
|
|
2962 }
|
|
2963
|
|
2964 // Compile and execute a filtering function
|
|
2965 // Provide `match` to avoid retokenization if we modified the selector above
|
|
2966 compile( selector, match )(
|
|
2967 seed,
|
|
2968 context,
|
|
2969 !documentIsHTML,
|
|
2970 results,
|
|
2971 rsibling.test( selector )
|
|
2972 );
|
|
2973 return results;
|
|
2974 }
|
|
2975
|
|
2976 // Deprecated
|
|
2977 Expr.pseudos["nth"] = Expr.pseudos["eq"];
|
|
2978
|
|
2979 // Easy API for creating new setFilters
|
|
2980 function setFilters() {}
|
|
2981 setFilters.prototype = Expr.filters = Expr.pseudos;
|
|
2982 Expr.setFilters = new setFilters();
|
|
2983
|
|
2984 // One-time assignments
|
|
2985
|
|
2986 // Sort stability
|
|
2987 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
|
|
2988
|
|
2989 // Initialize against the default document
|
|
2990 setDocument();
|
|
2991
|
|
2992 // Support: Chrome<<14
|
|
2993 // Always assume duplicates if they aren't passed to the comparison function
|
|
2994 [0, 0].sort( sortOrder );
|
|
2995 support.detectDuplicates = hasDuplicate;
|
|
2996
|
|
2997 jQuery.find = Sizzle;
|
|
2998 jQuery.expr = Sizzle.selectors;
|
|
2999 jQuery.expr[":"] = jQuery.expr.pseudos;
|
|
3000 jQuery.unique = Sizzle.uniqueSort;
|
|
3001 jQuery.text = Sizzle.getText;
|
|
3002 jQuery.isXMLDoc = Sizzle.isXML;
|
|
3003 jQuery.contains = Sizzle.contains;
|
|
3004
|
|
3005
|
|
3006 })( window );
|
|
3007 // String to Object options format cache
|
|
3008 var optionsCache = {};
|
|
3009
|
|
3010 // Convert String-formatted options into Object-formatted ones and store in cache
|
|
3011 function createOptions( options ) {
|
|
3012 var object = optionsCache[ options ] = {};
|
|
3013 jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) {
|
|
3014 object[ flag ] = true;
|
|
3015 });
|
|
3016 return object;
|
|
3017 }
|
|
3018
|
|
3019 /*
|
|
3020 * Create a callback list using the following parameters:
|
|
3021 *
|
|
3022 * options: an optional list of space-separated options that will change how
|
|
3023 * the callback list behaves or a more traditional option object
|
|
3024 *
|
|
3025 * By default a callback list will act like an event callback list and can be
|
|
3026 * "fired" multiple times.
|
|
3027 *
|
|
3028 * Possible options:
|
|
3029 *
|
|
3030 * once: will ensure the callback list can only be fired once (like a Deferred)
|
|
3031 *
|
|
3032 * memory: will keep track of previous values and will call any callback added
|
|
3033 * after the list has been fired right away with the latest "memorized"
|
|
3034 * values (like a Deferred)
|
|
3035 *
|
|
3036 * unique: will ensure a callback can only be added once (no duplicate in the list)
|
|
3037 *
|
|
3038 * stopOnFalse: interrupt callings when a callback returns false
|
|
3039 *
|
|
3040 */
|
|
3041 jQuery.Callbacks = function( options ) {
|
|
3042
|
|
3043 // Convert options from String-formatted to Object-formatted if needed
|
|
3044 // (we check in cache first)
|
|
3045 options = typeof options === "string" ?
|
|
3046 ( optionsCache[ options ] || createOptions( options ) ) :
|
|
3047 jQuery.extend( {}, options );
|
|
3048
|
|
3049 var // Flag to know if list is currently firing
|
|
3050 firing,
|
|
3051 // Last fire value (for non-forgettable lists)
|
|
3052 memory,
|
|
3053 // Flag to know if list was already fired
|
|
3054 fired,
|
|
3055 // End of the loop when firing
|
|
3056 firingLength,
|
|
3057 // Index of currently firing callback (modified by remove if needed)
|
|
3058 firingIndex,
|
|
3059 // First callback to fire (used internally by add and fireWith)
|
|
3060 firingStart,
|
|
3061 // Actual callback list
|
|
3062 list = [],
|
|
3063 // Stack of fire calls for repeatable lists
|
|
3064 stack = !options.once && [],
|
|
3065 // Fire callbacks
|
|
3066 fire = function( data ) {
|
|
3067 memory = options.memory && data;
|
|
3068 fired = true;
|
|
3069 firingIndex = firingStart || 0;
|
|
3070 firingStart = 0;
|
|
3071 firingLength = list.length;
|
|
3072 firing = true;
|
|
3073 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
|
|
3074 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
|
|
3075 memory = false; // To prevent further calls using add
|
|
3076 break;
|
|
3077 }
|
|
3078 }
|
|
3079 firing = false;
|
|
3080 if ( list ) {
|
|
3081 if ( stack ) {
|
|
3082 if ( stack.length ) {
|
|
3083 fire( stack.shift() );
|
|
3084 }
|
|
3085 } else if ( memory ) {
|
|
3086 list = [];
|
|
3087 } else {
|
|
3088 self.disable();
|
|
3089 }
|
|
3090 }
|
|
3091 },
|
|
3092 // Actual Callbacks object
|
|
3093 self = {
|
|
3094 // Add a callback or a collection of callbacks to the list
|
|
3095 add: function() {
|
|
3096 if ( list ) {
|
|
3097 // First, we save the current length
|
|
3098 var start = list.length;
|
|
3099 (function add( args ) {
|
|
3100 jQuery.each( args, function( _, arg ) {
|
|
3101 var type = jQuery.type( arg );
|
|
3102 if ( type === "function" ) {
|
|
3103 if ( !options.unique || !self.has( arg ) ) {
|
|
3104 list.push( arg );
|
|
3105 }
|
|
3106 } else if ( arg && arg.length && type !== "string" ) {
|
|
3107 // Inspect recursively
|
|
3108 add( arg );
|
|
3109 }
|
|
3110 });
|
|
3111 })( arguments );
|
|
3112 // Do we need to add the callbacks to the
|
|
3113 // current firing batch?
|
|
3114 if ( firing ) {
|
|
3115 firingLength = list.length;
|
|
3116 // With memory, if we're not firing then
|
|
3117 // we should call right away
|
|
3118 } else if ( memory ) {
|
|
3119 firingStart = start;
|
|
3120 fire( memory );
|
|
3121 }
|
|
3122 }
|
|
3123 return this;
|
|
3124 },
|
|
3125 // Remove a callback from the list
|
|
3126 remove: function() {
|
|
3127 if ( list ) {
|
|
3128 jQuery.each( arguments, function( _, arg ) {
|
|
3129 var index;
|
|
3130 while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
|
|
3131 list.splice( index, 1 );
|
|
3132 // Handle firing indexes
|
|
3133 if ( firing ) {
|
|
3134 if ( index <= firingLength ) {
|
|
3135 firingLength--;
|
|
3136 }
|
|
3137 if ( index <= firingIndex ) {
|
|
3138 firingIndex--;
|
|
3139 }
|
|
3140 }
|
|
3141 }
|
|
3142 });
|
|
3143 }
|
|
3144 return this;
|
|
3145 },
|
|
3146 // Check if a given callback is in the list.
|
|
3147 // If no argument is given, return whether or not list has callbacks attached.
|
|
3148 has: function( fn ) {
|
|
3149 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
|
|
3150 },
|
|
3151 // Remove all callbacks from the list
|
|
3152 empty: function() {
|
|
3153 list = [];
|
|
3154 firingLength = 0;
|
|
3155 return this;
|
|
3156 },
|
|
3157 // Have the list do nothing anymore
|
|
3158 disable: function() {
|
|
3159 list = stack = memory = undefined;
|
|
3160 return this;
|
|
3161 },
|
|
3162 // Is it disabled?
|
|
3163 disabled: function() {
|
|
3164 return !list;
|
|
3165 },
|
|
3166 // Lock the list in its current state
|
|
3167 lock: function() {
|
|
3168 stack = undefined;
|
|
3169 if ( !memory ) {
|
|
3170 self.disable();
|
|
3171 }
|
|
3172 return this;
|
|
3173 },
|
|
3174 // Is it locked?
|
|
3175 locked: function() {
|
|
3176 return !stack;
|
|
3177 },
|
|
3178 // Call all callbacks with the given context and arguments
|
|
3179 fireWith: function( context, args ) {
|
|
3180 args = args || [];
|
|
3181 args = [ context, args.slice ? args.slice() : args ];
|
|
3182 if ( list && ( !fired || stack ) ) {
|
|
3183 if ( firing ) {
|
|
3184 stack.push( args );
|
|
3185 } else {
|
|
3186 fire( args );
|
|
3187 }
|
|
3188 }
|
|
3189 return this;
|
|
3190 },
|
|
3191 // Call all the callbacks with the given arguments
|
|
3192 fire: function() {
|
|
3193 self.fireWith( this, arguments );
|
|
3194 return this;
|
|
3195 },
|
|
3196 // To know if the callbacks have already been called at least once
|
|
3197 fired: function() {
|
|
3198 return !!fired;
|
|
3199 }
|
|
3200 };
|
|
3201
|
|
3202 return self;
|
|
3203 };
|
|
3204 jQuery.extend({
|
|
3205
|
|
3206 Deferred: function( func ) {
|
|
3207 var tuples = [
|
|
3208 // action, add listener, listener list, final state
|
|
3209 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
|
|
3210 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
|
|
3211 [ "notify", "progress", jQuery.Callbacks("memory") ]
|
|
3212 ],
|
|
3213 state = "pending",
|
|
3214 promise = {
|
|
3215 state: function() {
|
|
3216 return state;
|
|
3217 },
|
|
3218 always: function() {
|
|
3219 deferred.done( arguments ).fail( arguments );
|
|
3220 return this;
|
|
3221 },
|
|
3222 then: function( /* fnDone, fnFail, fnProgress */ ) {
|
|
3223 var fns = arguments;
|
|
3224 return jQuery.Deferred(function( newDefer ) {
|
|
3225 jQuery.each( tuples, function( i, tuple ) {
|
|
3226 var action = tuple[ 0 ],
|
|
3227 fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
|
|
3228 // deferred[ done | fail | progress ] for forwarding actions to newDefer
|
|
3229 deferred[ tuple[1] ](function() {
|
|
3230 var returned = fn && fn.apply( this, arguments );
|
|
3231 if ( returned && jQuery.isFunction( returned.promise ) ) {
|
|
3232 returned.promise()
|
|
3233 .done( newDefer.resolve )
|
|
3234 .fail( newDefer.reject )
|
|
3235 .progress( newDefer.notify );
|
|
3236 } else {
|
|
3237 newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
|
|
3238 }
|
|
3239 });
|
|
3240 });
|
|
3241 fns = null;
|
|
3242 }).promise();
|
|
3243 },
|
|
3244 // Get a promise for this deferred
|
|
3245 // If obj is provided, the promise aspect is added to the object
|
|
3246 promise: function( obj ) {
|
|
3247 return obj != null ? jQuery.extend( obj, promise ) : promise;
|
|
3248 }
|
|
3249 },
|
|
3250 deferred = {};
|
|
3251
|
|
3252 // Keep pipe for back-compat
|
|
3253 promise.pipe = promise.then;
|
|
3254
|
|
3255 // Add list-specific methods
|
|
3256 jQuery.each( tuples, function( i, tuple ) {
|
|
3257 var list = tuple[ 2 ],
|
|
3258 stateString = tuple[ 3 ];
|
|
3259
|
|
3260 // promise[ done | fail | progress ] = list.add
|
|
3261 promise[ tuple[1] ] = list.add;
|
|
3262
|
|
3263 // Handle state
|
|
3264 if ( stateString ) {
|
|
3265 list.add(function() {
|
|
3266 // state = [ resolved | rejected ]
|
|
3267 state = stateString;
|
|
3268
|
|
3269 // [ reject_list | resolve_list ].disable; progress_list.lock
|
|
3270 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
|
|
3271 }
|
|
3272
|
|
3273 // deferred[ resolve | reject | notify ]
|
|
3274 deferred[ tuple[0] ] = function() {
|
|
3275 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
|
|
3276 return this;
|
|
3277 };
|
|
3278 deferred[ tuple[0] + "With" ] = list.fireWith;
|
|
3279 });
|
|
3280
|
|
3281 // Make the deferred a promise
|
|
3282 promise.promise( deferred );
|
|
3283
|
|
3284 // Call given func if any
|
|
3285 if ( func ) {
|
|
3286 func.call( deferred, deferred );
|
|
3287 }
|
|
3288
|
|
3289 // All done!
|
|
3290 return deferred;
|
|
3291 },
|
|
3292
|
|
3293 // Deferred helper
|
|
3294 when: function( subordinate /* , ..., subordinateN */ ) {
|
|
3295 var i = 0,
|
|
3296 resolveValues = core_slice.call( arguments ),
|
|
3297 length = resolveValues.length,
|
|
3298
|
|
3299 // the count of uncompleted subordinates
|
|
3300 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
|
|
3301
|
|
3302 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
|
|
3303 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
|
|
3304
|
|
3305 // Update function for both resolve and progress values
|
|
3306 updateFunc = function( i, contexts, values ) {
|
|
3307 return function( value ) {
|
|
3308 contexts[ i ] = this;
|
|
3309 values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
|
|
3310 if( values === progressValues ) {
|
|
3311 deferred.notifyWith( contexts, values );
|
|
3312 } else if ( !( --remaining ) ) {
|
|
3313 deferred.resolveWith( contexts, values );
|
|
3314 }
|
|
3315 };
|
|
3316 },
|
|
3317
|
|
3318 progressValues, progressContexts, resolveContexts;
|
|
3319
|
|
3320 // add listeners to Deferred subordinates; treat others as resolved
|
|
3321 if ( length > 1 ) {
|
|
3322 progressValues = new Array( length );
|
|
3323 progressContexts = new Array( length );
|
|
3324 resolveContexts = new Array( length );
|
|
3325 for ( ; i < length; i++ ) {
|
|
3326 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
|
|
3327 resolveValues[ i ].promise()
|
|
3328 .done( updateFunc( i, resolveContexts, resolveValues ) )
|
|
3329 .fail( deferred.reject )
|
|
3330 .progress( updateFunc( i, progressContexts, progressValues ) );
|
|
3331 } else {
|
|
3332 --remaining;
|
|
3333 }
|
|
3334 }
|
|
3335 }
|
|
3336
|
|
3337 // if we're not waiting on anything, resolve the master
|
|
3338 if ( !remaining ) {
|
|
3339 deferred.resolveWith( resolveContexts, resolveValues );
|
|
3340 }
|
|
3341
|
|
3342 return deferred.promise();
|
|
3343 }
|
|
3344 });
|
|
3345 jQuery.support = (function( support ) {
|
|
3346
|
|
3347 var all, a, input, select, fragment, opt, eventName, isSupported, i,
|
|
3348 div = document.createElement("div");
|
|
3349
|
|
3350 // Setup
|
|
3351 div.setAttribute( "className", "t" );
|
|
3352 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
|
|
3353
|
|
3354 // Finish early in limited (non-browser) environments
|
|
3355 all = div.getElementsByTagName("*") || [];
|
|
3356 a = div.getElementsByTagName("a")[ 0 ];
|
|
3357 if ( !a || !a.style || !all.length ) {
|
|
3358 return support;
|
|
3359 }
|
|
3360
|
|
3361 // First batch of tests
|
|
3362 select = document.createElement("select");
|
|
3363 opt = select.appendChild( document.createElement("option") );
|
|
3364 input = div.getElementsByTagName("input")[ 0 ];
|
|
3365
|
|
3366 a.style.cssText = "top:1px;float:left;opacity:.5";
|
|
3367
|
|
3368 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
|
|
3369 support.getSetAttribute = div.className !== "t";
|
|
3370
|
|
3371 // IE strips leading whitespace when .innerHTML is used
|
|
3372 support.leadingWhitespace = div.firstChild.nodeType === 3;
|
|
3373
|
|
3374 // Make sure that tbody elements aren't automatically inserted
|
|
3375 // IE will insert them into empty tables
|
|
3376 support.tbody = !div.getElementsByTagName("tbody").length;
|
|
3377
|
|
3378 // Make sure that link elements get serialized correctly by innerHTML
|
|
3379 // This requires a wrapper element in IE
|
|
3380 support.htmlSerialize = !!div.getElementsByTagName("link").length;
|
|
3381
|
|
3382 // Get the style information from getAttribute
|
|
3383 // (IE uses .cssText instead)
|
|
3384 support.style = /top/.test( a.getAttribute("style") );
|
|
3385
|
|
3386 // Make sure that URLs aren't manipulated
|
|
3387 // (IE normalizes it by default)
|
|
3388 support.hrefNormalized = a.getAttribute("href") === "/a";
|
|
3389
|
|
3390 // Make sure that element opacity exists
|
|
3391 // (IE uses filter instead)
|
|
3392 // Use a regex to work around a WebKit issue. See #5145
|
|
3393 support.opacity = /^0.5/.test( a.style.opacity );
|
|
3394
|
|
3395 // Verify style float existence
|
|
3396 // (IE uses styleFloat instead of cssFloat)
|
|
3397 support.cssFloat = !!a.style.cssFloat;
|
|
3398
|
|
3399 // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
|
|
3400 support.checkOn = !!input.value;
|
|
3401
|
|
3402 // Make sure that a selected-by-default option has a working selected property.
|
|
3403 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
|
|
3404 support.optSelected = opt.selected;
|
|
3405
|
|
3406 // Tests for enctype support on a form (#6743)
|
|
3407 support.enctype = !!document.createElement("form").enctype;
|
|
3408
|
|
3409 // Makes sure cloning an html5 element does not cause problems
|
|
3410 // Where outerHTML is undefined, this still works
|
|
3411 support.html5Clone = document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>";
|
|
3412
|
|
3413 // Will be defined later
|
|
3414 support.inlineBlockNeedsLayout = false;
|
|
3415 support.shrinkWrapBlocks = false;
|
|
3416 support.pixelPosition = false;
|
|
3417 support.deleteExpando = true;
|
|
3418 support.noCloneEvent = true;
|
|
3419 support.reliableMarginRight = true;
|
|
3420 support.boxSizingReliable = true;
|
|
3421
|
|
3422 // Make sure checked status is properly cloned
|
|
3423 input.checked = true;
|
|
3424 support.noCloneChecked = input.cloneNode( true ).checked;
|
|
3425
|
|
3426 // Make sure that the options inside disabled selects aren't marked as disabled
|
|
3427 // (WebKit marks them as disabled)
|
|
3428 select.disabled = true;
|
|
3429 support.optDisabled = !opt.disabled;
|
|
3430
|
|
3431 // Support: IE<9
|
|
3432 try {
|
|
3433 delete div.test;
|
|
3434 } catch( e ) {
|
|
3435 support.deleteExpando = false;
|
|
3436 }
|
|
3437
|
|
3438 // Check if we can trust getAttribute("value")
|
|
3439 input = document.createElement("input");
|
|
3440 input.setAttribute( "value", "" );
|
|
3441 support.input = input.getAttribute( "value" ) === "";
|
|
3442
|
|
3443 // Check if an input maintains its value after becoming a radio
|
|
3444 input.value = "t";
|
|
3445 input.setAttribute( "type", "radio" );
|
|
3446 support.radioValue = input.value === "t";
|
|
3447
|
|
3448 // #11217 - WebKit loses check when the name is after the checked attribute
|
|
3449 input.setAttribute( "checked", "t" );
|
|
3450 input.setAttribute( "name", "t" );
|
|
3451
|
|
3452 fragment = document.createDocumentFragment();
|
|
3453 fragment.appendChild( input );
|
|
3454
|
|
3455 // Check if a disconnected checkbox will retain its checked
|
|
3456 // value of true after appended to the DOM (IE6/7)
|
|
3457 support.appendChecked = input.checked;
|
|
3458
|
|
3459 // WebKit doesn't clone checked state correctly in fragments
|
|
3460 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
|
|
3461
|
|
3462 // Support: IE<9
|
|
3463 // Opera does not clone events (and typeof div.attachEvent === undefined).
|
|
3464 // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
|
|
3465 if ( div.attachEvent ) {
|
|
3466 div.attachEvent( "onclick", function() {
|
|
3467 support.noCloneEvent = false;
|
|
3468 });
|
|
3469
|
|
3470 div.cloneNode( true ).click();
|
|
3471 }
|
|
3472
|
|
3473 // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
|
|
3474 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
|
|
3475 for ( i in { submit: true, change: true, focusin: true }) {
|
|
3476 div.setAttribute( eventName = "on" + i, "t" );
|
|
3477
|
|
3478 support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false;
|
|
3479 }
|
|
3480
|
|
3481 div.style.backgroundClip = "content-box";
|
|
3482 div.cloneNode( true ).style.backgroundClip = "";
|
|
3483 support.clearCloneStyle = div.style.backgroundClip === "content-box";
|
|
3484
|
|
3485 // Support: IE<9
|
|
3486 // Iteration over object's inherited properties before its own.
|
|
3487 for ( i in jQuery( support ) ) {
|
|
3488 break;
|
|
3489 }
|
|
3490 support.ownLast = i !== "0";
|
|
3491
|
|
3492 // Run tests that need a body at doc ready
|
|
3493 jQuery(function() {
|
|
3494 var container, marginDiv, tds,
|
|
3495 divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",
|
|
3496 body = document.getElementsByTagName("body")[0];
|
|
3497
|
|
3498 if ( !body ) {
|
|
3499 // Return for frameset docs that don't have a body
|
|
3500 return;
|
|
3501 }
|
|
3502
|
|
3503 container = document.createElement("div");
|
|
3504 container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
|
|
3505
|
|
3506 body.appendChild( container ).appendChild( div );
|
|
3507
|
|
3508 // Support: IE8
|
|
3509 // Check if table cells still have offsetWidth/Height when they are set
|
|
3510 // to display:none and there are still other visible table cells in a
|
|
3511 // table row; if so, offsetWidth/Height are not reliable for use when
|
|
3512 // determining if an element has been hidden directly using
|
|
3513 // display:none (it is still safe to use offsets if a parent element is
|
|
3514 // hidden; don safety goggles and see bug #4512 for more information).
|
|
3515 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
|
|
3516 tds = div.getElementsByTagName("td");
|
|
3517 tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
|
|
3518 isSupported = ( tds[ 0 ].offsetHeight === 0 );
|
|
3519
|
|
3520 tds[ 0 ].style.display = "";
|
|
3521 tds[ 1 ].style.display = "none";
|
|
3522
|
|
3523 // Support: IE8
|
|
3524 // Check if empty table cells still have offsetWidth/Height
|
|
3525 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
|
|
3526
|
|
3527 // Check box-sizing and margin behavior.
|
|
3528 div.innerHTML = "";
|
|
3529 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%;";
|
|
3530
|
|
3531 // Workaround failing boxSizing test due to offsetWidth returning wrong value
|
|
3532 // with some non-1 values of body zoom, ticket #13543
|
|
3533 jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() {
|
|
3534 support.boxSizing = div.offsetWidth === 4;
|
|
3535 });
|
|
3536
|
|
3537 // Use window.getComputedStyle because jsdom on node.js will break without it.
|
|
3538 if ( window.getComputedStyle ) {
|
|
3539 support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
|
|
3540 support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
|
|
3541
|
|
3542 // Check if div with explicit width and no margin-right incorrectly
|
|
3543 // gets computed margin-right based on width of container. (#3333)
|
|
3544 // Fails in WebKit before Feb 2011 nightlies
|
|
3545 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
|
3546 marginDiv = div.appendChild( document.createElement("div") );
|
|
3547 marginDiv.style.cssText = div.style.cssText = divReset;
|
|
3548 marginDiv.style.marginRight = marginDiv.style.width = "0";
|
|
3549 div.style.width = "1px";
|
|
3550
|
|
3551 support.reliableMarginRight =
|
|
3552 !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
|
|
3553 }
|
|
3554
|
|
3555 if ( typeof div.style.zoom !== core_strundefined ) {
|
|
3556 // Support: IE<8
|
|
3557 // Check if natively block-level elements act like inline-block
|
|
3558 // elements when setting their display to 'inline' and giving
|
|
3559 // them layout
|
|
3560 div.innerHTML = "";
|
|
3561 div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
|
|
3562 support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
|
|
3563
|
|
3564 // Support: IE6
|
|
3565 // Check if elements with layout shrink-wrap their children
|
|
3566 div.style.display = "block";
|
|
3567 div.innerHTML = "<div></div>";
|
|
3568 div.firstChild.style.width = "5px";
|
|
3569 support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
|
|
3570
|
|
3571 if ( support.inlineBlockNeedsLayout ) {
|
|
3572 // Prevent IE 6 from affecting layout for positioned elements #11048
|
|
3573 // Prevent IE from shrinking the body in IE 7 mode #12869
|
|
3574 // Support: IE<8
|
|
3575 body.style.zoom = 1;
|
|
3576 }
|
|
3577 }
|
|
3578
|
|
3579 body.removeChild( container );
|
|
3580
|
|
3581 // Null elements to avoid leaks in IE
|
|
3582 container = div = tds = marginDiv = null;
|
|
3583 });
|
|
3584
|
|
3585 // Null elements to avoid leaks in IE
|
|
3586 all = select = fragment = opt = a = input = null;
|
|
3587
|
|
3588 return support;
|
|
3589 })({});
|
|
3590
|
|
3591 var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
|
|
3592 rmultiDash = /([A-Z])/g;
|
|
3593
|
|
3594 function internalData( elem, name, data, pvt /* Internal Use Only */ ){
|
|
3595 if ( !jQuery.acceptData( elem ) ) {
|
|
3596 return;
|
|
3597 }
|
|
3598
|
|
3599 var ret, thisCache,
|
|
3600 internalKey = jQuery.expando,
|
|
3601
|
|
3602 // We have to handle DOM nodes and JS objects differently because IE6-7
|
|
3603 // can't GC object references properly across the DOM-JS boundary
|
|
3604 isNode = elem.nodeType,
|
|
3605
|
|
3606 // Only DOM nodes need the global jQuery cache; JS object data is
|
|
3607 // attached directly to the object so GC can occur automatically
|
|
3608 cache = isNode ? jQuery.cache : elem,
|
|
3609
|
|
3610 // Only defining an ID for JS objects if its cache already exists allows
|
|
3611 // the code to shortcut on the same path as a DOM node with no cache
|
|
3612 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
|
|
3613
|
|
3614 // Avoid doing any more work than we need to when trying to get data on an
|
|
3615 // object that has no data at all
|
|
3616 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
|
|
3617 return;
|
|
3618 }
|
|
3619
|
|
3620 if ( !id ) {
|
|
3621 // Only DOM nodes need a new unique ID for each element since their data
|
|
3622 // ends up in the global cache
|
|
3623 if ( isNode ) {
|
|
3624 id = elem[ internalKey ] = core_deletedIds.pop() || jQuery.guid++;
|
|
3625 } else {
|
|
3626 id = internalKey;
|
|
3627 }
|
|
3628 }
|
|
3629
|
|
3630 if ( !cache[ id ] ) {
|
|
3631 // Avoid exposing jQuery metadata on plain JS objects when the object
|
|
3632 // is serialized using JSON.stringify
|
|
3633 cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
|
|
3634 }
|
|
3635
|
|
3636 // An object can be passed to jQuery.data instead of a key/value pair; this gets
|
|
3637 // shallow copied over onto the existing cache
|
|
3638 if ( typeof name === "object" || typeof name === "function" ) {
|
|
3639 if ( pvt ) {
|
|
3640 cache[ id ] = jQuery.extend( cache[ id ], name );
|
|
3641 } else {
|
|
3642 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
|
|
3643 }
|
|
3644 }
|
|
3645
|
|
3646 thisCache = cache[ id ];
|
|
3647
|
|
3648 // jQuery data() is stored in a separate object inside the object's internal data
|
|
3649 // cache in order to avoid key collisions between internal data and user-defined
|
|
3650 // data.
|
|
3651 if ( !pvt ) {
|
|
3652 if ( !thisCache.data ) {
|
|
3653 thisCache.data = {};
|
|
3654 }
|
|
3655
|
|
3656 thisCache = thisCache.data;
|
|
3657 }
|
|
3658
|
|
3659 if ( data !== undefined ) {
|
|
3660 thisCache[ jQuery.camelCase( name ) ] = data;
|
|
3661 }
|
|
3662
|
|
3663 // Check for both converted-to-camel and non-converted data property names
|
|
3664 // If a data property was specified
|
|
3665 if ( typeof name === "string" ) {
|
|
3666
|
|
3667 // First Try to find as-is property data
|
|
3668 ret = thisCache[ name ];
|
|
3669
|
|
3670 // Test for null|undefined property data
|
|
3671 if ( ret == null ) {
|
|
3672
|
|
3673 // Try to find the camelCased property
|
|
3674 ret = thisCache[ jQuery.camelCase( name ) ];
|
|
3675 }
|
|
3676 } else {
|
|
3677 ret = thisCache;
|
|
3678 }
|
|
3679
|
|
3680 return ret;
|
|
3681 }
|
|
3682
|
|
3683 function internalRemoveData( elem, name, pvt ) {
|
|
3684 if ( !jQuery.acceptData( elem ) ) {
|
|
3685 return;
|
|
3686 }
|
|
3687
|
|
3688 var thisCache, i,
|
|
3689 isNode = elem.nodeType,
|
|
3690
|
|
3691 // See jQuery.data for more information
|
|
3692 cache = isNode ? jQuery.cache : elem,
|
|
3693 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
|
|
3694
|
|
3695 // If there is already no cache entry for this object, there is no
|
|
3696 // purpose in continuing
|
|
3697 if ( !cache[ id ] ) {
|
|
3698 return;
|
|
3699 }
|
|
3700
|
|
3701 if ( name ) {
|
|
3702
|
|
3703 thisCache = pvt ? cache[ id ] : cache[ id ].data;
|
|
3704
|
|
3705 if ( thisCache ) {
|
|
3706
|
|
3707 // Support array or space separated string names for data keys
|
|
3708 if ( !jQuery.isArray( name ) ) {
|
|
3709
|
|
3710 // try the string as a key before any manipulation
|
|
3711 if ( name in thisCache ) {
|
|
3712 name = [ name ];
|
|
3713 } else {
|
|
3714
|
|
3715 // split the camel cased version by spaces unless a key with the spaces exists
|
|
3716 name = jQuery.camelCase( name );
|
|
3717 if ( name in thisCache ) {
|
|
3718 name = [ name ];
|
|
3719 } else {
|
|
3720 name = name.split(" ");
|
|
3721 }
|
|
3722 }
|
|
3723 } else {
|
|
3724 // If "name" is an array of keys...
|
|
3725 // When data is initially created, via ("key", "val") signature,
|
|
3726 // keys will be converted to camelCase.
|
|
3727 // Since there is no way to tell _how_ a key was added, remove
|
|
3728 // both plain key and camelCase key. #12786
|
|
3729 // This will only penalize the array argument path.
|
|
3730 name = name.concat( jQuery.map( name, jQuery.camelCase ) );
|
|
3731 }
|
|
3732
|
|
3733 i = name.length;
|
|
3734 while ( i-- ) {
|
|
3735 delete thisCache[ name[i] ];
|
|
3736 }
|
|
3737
|
|
3738 // If there is no data left in the cache, we want to continue
|
|
3739 // and let the cache object itself get destroyed
|
|
3740 if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
|
|
3741 return;
|
|
3742 }
|
|
3743 }
|
|
3744 }
|
|
3745
|
|
3746 // See jQuery.data for more information
|
|
3747 if ( !pvt ) {
|
|
3748 delete cache[ id ].data;
|
|
3749
|
|
3750 // Don't destroy the parent cache unless the internal data object
|
|
3751 // had been the only thing left in it
|
|
3752 if ( !isEmptyDataObject( cache[ id ] ) ) {
|
|
3753 return;
|
|
3754 }
|
|
3755 }
|
|
3756
|
|
3757 // Destroy the cache
|
|
3758 if ( isNode ) {
|
|
3759 jQuery.cleanData( [ elem ], true );
|
|
3760
|
|
3761 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
|
|
3762 /* jshint eqeqeq: false */
|
|
3763 } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
|
|
3764 /* jshint eqeqeq: true */
|
|
3765 delete cache[ id ];
|
|
3766
|
|
3767 // When all else fails, null
|
|
3768 } else {
|
|
3769 cache[ id ] = null;
|
|
3770 }
|
|
3771 }
|
|
3772
|
|
3773 jQuery.extend({
|
|
3774 cache: {},
|
|
3775
|
|
3776 // The following elements throw uncatchable exceptions if you
|
|
3777 // attempt to add expando properties to them.
|
|
3778 noData: {
|
|
3779 "applet": true,
|
|
3780 "embed": true,
|
|
3781 // Ban all objects except for Flash (which handle expandos)
|
|
3782 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
|
|
3783 },
|
|
3784
|
|
3785 hasData: function( elem ) {
|
|
3786 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
|
|
3787 return !!elem && !isEmptyDataObject( elem );
|
|
3788 },
|
|
3789
|
|
3790 data: function( elem, name, data ) {
|
|
3791 return internalData( elem, name, data );
|
|
3792 },
|
|
3793
|
|
3794 removeData: function( elem, name ) {
|
|
3795 return internalRemoveData( elem, name );
|
|
3796 },
|
|
3797
|
|
3798 // For internal use only.
|
|
3799 _data: function( elem, name, data ) {
|
|
3800 return internalData( elem, name, data, true );
|
|
3801 },
|
|
3802
|
|
3803 _removeData: function( elem, name ) {
|
|
3804 return internalRemoveData( elem, name, true );
|
|
3805 },
|
|
3806
|
|
3807 // A method for determining if a DOM node can handle the data expando
|
|
3808 acceptData: function( elem ) {
|
|
3809 // Do not set data on non-element because it will not be cleared (#8335).
|
|
3810 if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) {
|
|
3811 return false;
|
|
3812 }
|
|
3813
|
|
3814 var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
|
|
3815
|
|
3816 // nodes accept data unless otherwise specified; rejection can be conditional
|
|
3817 return !noData || noData !== true && elem.getAttribute("classid") === noData;
|
|
3818 }
|
|
3819 });
|
|
3820
|
|
3821 jQuery.fn.extend({
|
|
3822 data: function( key, value ) {
|
|
3823 var attrs, name,
|
|
3824 data = null,
|
|
3825 i = 0,
|
|
3826 elem = this[0];
|
|
3827
|
|
3828 // Special expections of .data basically thwart jQuery.access,
|
|
3829 // so implement the relevant behavior ourselves
|
|
3830
|
|
3831 // Gets all values
|
|
3832 if ( key === undefined ) {
|
|
3833 if ( this.length ) {
|
|
3834 data = jQuery.data( elem );
|
|
3835
|
|
3836 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
|
|
3837 attrs = elem.attributes;
|
|
3838 for ( ; i < attrs.length; i++ ) {
|
|
3839 name = attrs[i].name;
|
|
3840
|
|
3841 if ( name.indexOf("data-") === 0 ) {
|
|
3842 name = jQuery.camelCase( name.slice(5) );
|
|
3843
|
|
3844 dataAttr( elem, name, data[ name ] );
|
|
3845 }
|
|
3846 }
|
|
3847 jQuery._data( elem, "parsedAttrs", true );
|
|
3848 }
|
|
3849 }
|
|
3850
|
|
3851 return data;
|
|
3852 }
|
|
3853
|
|
3854 // Sets multiple values
|
|
3855 if ( typeof key === "object" ) {
|
|
3856 return this.each(function() {
|
|
3857 jQuery.data( this, key );
|
|
3858 });
|
|
3859 }
|
|
3860
|
|
3861 return arguments.length > 1 ?
|
|
3862
|
|
3863 // Sets one value
|
|
3864 this.each(function() {
|
|
3865 jQuery.data( this, key, value );
|
|
3866 }) :
|
|
3867
|
|
3868 // Gets one value
|
|
3869 // Try to fetch any internally stored data first
|
|
3870 elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null;
|
|
3871 },
|
|
3872
|
|
3873 removeData: function( key ) {
|
|
3874 return this.each(function() {
|
|
3875 jQuery.removeData( this, key );
|
|
3876 });
|
|
3877 }
|
|
3878 });
|
|
3879
|
|
3880 function dataAttr( elem, key, data ) {
|
|
3881 // If nothing was found internally, try to fetch any
|
|
3882 // data from the HTML5 data-* attribute
|
|
3883 if ( data === undefined && elem.nodeType === 1 ) {
|
|
3884
|
|
3885 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
|
|
3886
|
|
3887 data = elem.getAttribute( name );
|
|
3888
|
|
3889 if ( typeof data === "string" ) {
|
|
3890 try {
|
|
3891 data = data === "true" ? true :
|
|
3892 data === "false" ? false :
|
|
3893 data === "null" ? null :
|
|
3894 // Only convert to a number if it doesn't change the string
|
|
3895 +data + "" === data ? +data :
|
|
3896 rbrace.test( data ) ? jQuery.parseJSON( data ) :
|
|
3897 data;
|
|
3898 } catch( e ) {}
|
|
3899
|
|
3900 // Make sure we set the data so it isn't changed later
|
|
3901 jQuery.data( elem, key, data );
|
|
3902
|
|
3903 } else {
|
|
3904 data = undefined;
|
|
3905 }
|
|
3906 }
|
|
3907
|
|
3908 return data;
|
|
3909 }
|
|
3910
|
|
3911 // checks a cache object for emptiness
|
|
3912 function isEmptyDataObject( obj ) {
|
|
3913 var name;
|
|
3914 for ( name in obj ) {
|
|
3915
|
|
3916 // if the public data object is empty, the private is still empty
|
|
3917 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
|
|
3918 continue;
|
|
3919 }
|
|
3920 if ( name !== "toJSON" ) {
|
|
3921 return false;
|
|
3922 }
|
|
3923 }
|
|
3924
|
|
3925 return true;
|
|
3926 }
|
|
3927 jQuery.extend({
|
|
3928 queue: function( elem, type, data ) {
|
|
3929 var queue;
|
|
3930
|
|
3931 if ( elem ) {
|
|
3932 type = ( type || "fx" ) + "queue";
|
|
3933 queue = jQuery._data( elem, type );
|
|
3934
|
|
3935 // Speed up dequeue by getting out quickly if this is just a lookup
|
|
3936 if ( data ) {
|
|
3937 if ( !queue || jQuery.isArray(data) ) {
|
|
3938 queue = jQuery._data( elem, type, jQuery.makeArray(data) );
|
|
3939 } else {
|
|
3940 queue.push( data );
|
|
3941 }
|
|
3942 }
|
|
3943 return queue || [];
|
|
3944 }
|
|
3945 },
|
|
3946
|
|
3947 dequeue: function( elem, type ) {
|
|
3948 type = type || "fx";
|
|
3949
|
|
3950 var queue = jQuery.queue( elem, type ),
|
|
3951 startLength = queue.length,
|
|
3952 fn = queue.shift(),
|
|
3953 hooks = jQuery._queueHooks( elem, type ),
|
|
3954 next = function() {
|
|
3955 jQuery.dequeue( elem, type );
|
|
3956 };
|
|
3957
|
|
3958 // If the fx queue is dequeued, always remove the progress sentinel
|
|
3959 if ( fn === "inprogress" ) {
|
|
3960 fn = queue.shift();
|
|
3961 startLength--;
|
|
3962 }
|
|
3963
|
|
3964 if ( fn ) {
|
|
3965
|
|
3966 // Add a progress sentinel to prevent the fx queue from being
|
|
3967 // automatically dequeued
|
|
3968 if ( type === "fx" ) {
|
|
3969 queue.unshift( "inprogress" );
|
|
3970 }
|
|
3971
|
|
3972 // clear up the last queue stop function
|
|
3973 delete hooks.stop;
|
|
3974 fn.call( elem, next, hooks );
|
|
3975 }
|
|
3976
|
|
3977 if ( !startLength && hooks ) {
|
|
3978 hooks.empty.fire();
|
|
3979 }
|
|
3980 },
|
|
3981
|
|
3982 // not intended for public consumption - generates a queueHooks object, or returns the current one
|
|
3983 _queueHooks: function( elem, type ) {
|
|
3984 var key = type + "queueHooks";
|
|
3985 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
|
|
3986 empty: jQuery.Callbacks("once memory").add(function() {
|
|
3987 jQuery._removeData( elem, type + "queue" );
|
|
3988 jQuery._removeData( elem, key );
|
|
3989 })
|
|
3990 });
|
|
3991 }
|
|
3992 });
|
|
3993
|
|
3994 jQuery.fn.extend({
|
|
3995 queue: function( type, data ) {
|
|
3996 var setter = 2;
|
|
3997
|
|
3998 if ( typeof type !== "string" ) {
|
|
3999 data = type;
|
|
4000 type = "fx";
|
|
4001 setter--;
|
|
4002 }
|
|
4003
|
|
4004 if ( arguments.length < setter ) {
|
|
4005 return jQuery.queue( this[0], type );
|
|
4006 }
|
|
4007
|
|
4008 return data === undefined ?
|
|
4009 this :
|
|
4010 this.each(function() {
|
|
4011 var queue = jQuery.queue( this, type, data );
|
|
4012
|
|
4013 // ensure a hooks for this queue
|
|
4014 jQuery._queueHooks( this, type );
|
|
4015
|
|
4016 if ( type === "fx" && queue[0] !== "inprogress" ) {
|
|
4017 jQuery.dequeue( this, type );
|
|
4018 }
|
|
4019 });
|
|
4020 },
|
|
4021 dequeue: function( type ) {
|
|
4022 return this.each(function() {
|
|
4023 jQuery.dequeue( this, type );
|
|
4024 });
|
|
4025 },
|
|
4026 // Based off of the plugin by Clint Helfers, with permission.
|
|
4027 // http://blindsignals.com/index.php/2009/07/jquery-delay/
|
|
4028 delay: function( time, type ) {
|
|
4029 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
|
|
4030 type = type || "fx";
|
|
4031
|
|
4032 return this.queue( type, function( next, hooks ) {
|
|
4033 var timeout = setTimeout( next, time );
|
|
4034 hooks.stop = function() {
|
|
4035 clearTimeout( timeout );
|
|
4036 };
|
|
4037 });
|
|
4038 },
|
|
4039 clearQueue: function( type ) {
|
|
4040 return this.queue( type || "fx", [] );
|
|
4041 },
|
|
4042 // Get a promise resolved when queues of a certain type
|
|
4043 // are emptied (fx is the type by default)
|
|
4044 promise: function( type, obj ) {
|
|
4045 var tmp,
|
|
4046 count = 1,
|
|
4047 defer = jQuery.Deferred(),
|
|
4048 elements = this,
|
|
4049 i = this.length,
|
|
4050 resolve = function() {
|
|
4051 if ( !( --count ) ) {
|
|
4052 defer.resolveWith( elements, [ elements ] );
|
|
4053 }
|
|
4054 };
|
|
4055
|
|
4056 if ( typeof type !== "string" ) {
|
|
4057 obj = type;
|
|
4058 type = undefined;
|
|
4059 }
|
|
4060 type = type || "fx";
|
|
4061
|
|
4062 while( i-- ) {
|
|
4063 tmp = jQuery._data( elements[ i ], type + "queueHooks" );
|
|
4064 if ( tmp && tmp.empty ) {
|
|
4065 count++;
|
|
4066 tmp.empty.add( resolve );
|
|
4067 }
|
|
4068 }
|
|
4069 resolve();
|
|
4070 return defer.promise( obj );
|
|
4071 }
|
|
4072 });
|
|
4073 var nodeHook, boolHook,
|
|
4074 rclass = /[\t\r\n\f]/g,
|
|
4075 rreturn = /\r/g,
|
|
4076 rfocusable = /^(?:input|select|textarea|button|object)$/i,
|
|
4077 rclickable = /^(?:a|area)$/i,
|
|
4078 ruseDefault = /^(?:checked|selected)$/i,
|
|
4079 getSetAttribute = jQuery.support.getSetAttribute,
|
|
4080 getSetInput = jQuery.support.input;
|
|
4081
|
|
4082 jQuery.fn.extend({
|
|
4083 attr: function( name, value ) {
|
|
4084 return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
|
|
4085 },
|
|
4086
|
|
4087 removeAttr: function( name ) {
|
|
4088 return this.each(function() {
|
|
4089 jQuery.removeAttr( this, name );
|
|
4090 });
|
|
4091 },
|
|
4092
|
|
4093 prop: function( name, value ) {
|
|
4094 return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
|
|
4095 },
|
|
4096
|
|
4097 removeProp: function( name ) {
|
|
4098 name = jQuery.propFix[ name ] || name;
|
|
4099 return this.each(function() {
|
|
4100 // try/catch handles cases where IE balks (such as removing a property on window)
|
|
4101 try {
|
|
4102 this[ name ] = undefined;
|
|
4103 delete this[ name ];
|
|
4104 } catch( e ) {}
|
|
4105 });
|
|
4106 },
|
|
4107
|
|
4108 addClass: function( value ) {
|
|
4109 var classes, elem, cur, clazz, j,
|
|
4110 i = 0,
|
|
4111 len = this.length,
|
|
4112 proceed = typeof value === "string" && value;
|
|
4113
|
|
4114 if ( jQuery.isFunction( value ) ) {
|
|
4115 return this.each(function( j ) {
|
|
4116 jQuery( this ).addClass( value.call( this, j, this.className ) );
|
|
4117 });
|
|
4118 }
|
|
4119
|
|
4120 if ( proceed ) {
|
|
4121 // The disjunction here is for better compressibility (see removeClass)
|
|
4122 classes = ( value || "" ).match( core_rnotwhite ) || [];
|
|
4123
|
|
4124 for ( ; i < len; i++ ) {
|
|
4125 elem = this[ i ];
|
|
4126 cur = elem.nodeType === 1 && ( elem.className ?
|
|
4127 ( " " + elem.className + " " ).replace( rclass, " " ) :
|
|
4128 " "
|
|
4129 );
|
|
4130
|
|
4131 if ( cur ) {
|
|
4132 j = 0;
|
|
4133 while ( (clazz = classes[j++]) ) {
|
|
4134 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
|
|
4135 cur += clazz + " ";
|
|
4136 }
|
|
4137 }
|
|
4138 elem.className = jQuery.trim( cur );
|
|
4139
|
|
4140 }
|
|
4141 }
|
|
4142 }
|
|
4143
|
|
4144 return this;
|
|
4145 },
|
|
4146
|
|
4147 removeClass: function( value ) {
|
|
4148 var classes, elem, cur, clazz, j,
|
|
4149 i = 0,
|
|
4150 len = this.length,
|
|
4151 proceed = arguments.length === 0 || typeof value === "string" && value;
|
|
4152
|
|
4153 if ( jQuery.isFunction( value ) ) {
|
|
4154 return this.each(function( j ) {
|
|
4155 jQuery( this ).removeClass( value.call( this, j, this.className ) );
|
|
4156 });
|
|
4157 }
|
|
4158 if ( proceed ) {
|
|
4159 classes = ( value || "" ).match( core_rnotwhite ) || [];
|
|
4160
|
|
4161 for ( ; i < len; i++ ) {
|
|
4162 elem = this[ i ];
|
|
4163 // This expression is here for better compressibility (see addClass)
|
|
4164 cur = elem.nodeType === 1 && ( elem.className ?
|
|
4165 ( " " + elem.className + " " ).replace( rclass, " " ) :
|
|
4166 ""
|
|
4167 );
|
|
4168
|
|
4169 if ( cur ) {
|
|
4170 j = 0;
|
|
4171 while ( (clazz = classes[j++]) ) {
|
|
4172 // Remove *all* instances
|
|
4173 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
|
|
4174 cur = cur.replace( " " + clazz + " ", " " );
|
|
4175 }
|
|
4176 }
|
|
4177 elem.className = value ? jQuery.trim( cur ) : "";
|
|
4178 }
|
|
4179 }
|
|
4180 }
|
|
4181
|
|
4182 return this;
|
|
4183 },
|
|
4184
|
|
4185 toggleClass: function( value, stateVal ) {
|
|
4186 var type = typeof value,
|
|
4187 isBool = typeof stateVal === "boolean";
|
|
4188
|
|
4189 if ( jQuery.isFunction( value ) ) {
|
|
4190 return this.each(function( i ) {
|
|
4191 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
|
|
4192 });
|
|
4193 }
|
|
4194
|
|
4195 return this.each(function() {
|
|
4196 if ( type === "string" ) {
|
|
4197 // toggle individual class names
|
|
4198 var className,
|
|
4199 i = 0,
|
|
4200 self = jQuery( this ),
|
|
4201 state = stateVal,
|
|
4202 classNames = value.match( core_rnotwhite ) || [];
|
|
4203
|
|
4204 while ( (className = classNames[ i++ ]) ) {
|
|
4205 // check each className given, space separated list
|
|
4206 state = isBool ? state : !self.hasClass( className );
|
|
4207 self[ state ? "addClass" : "removeClass" ]( className );
|
|
4208 }
|
|
4209
|
|
4210 // Toggle whole class name
|
|
4211 } else if ( type === core_strundefined || type === "boolean" ) {
|
|
4212 if ( this.className ) {
|
|
4213 // store className if set
|
|
4214 jQuery._data( this, "__className__", this.className );
|
|
4215 }
|
|
4216
|
|
4217 // If the element has a class name or if we're passed "false",
|
|
4218 // then remove the whole classname (if there was one, the above saved it).
|
|
4219 // Otherwise bring back whatever was previously saved (if anything),
|
|
4220 // falling back to the empty string if nothing was stored.
|
|
4221 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
|
|
4222 }
|
|
4223 });
|
|
4224 },
|
|
4225
|
|
4226 hasClass: function( selector ) {
|
|
4227 var className = " " + selector + " ",
|
|
4228 i = 0,
|
|
4229 l = this.length;
|
|
4230 for ( ; i < l; i++ ) {
|
|
4231 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
|
|
4232 return true;
|
|
4233 }
|
|
4234 }
|
|
4235
|
|
4236 return false;
|
|
4237 },
|
|
4238
|
|
4239 val: function( value ) {
|
|
4240 var ret, hooks, isFunction,
|
|
4241 elem = this[0];
|
|
4242
|
|
4243 if ( !arguments.length ) {
|
|
4244 if ( elem ) {
|
|
4245 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
|
|
4246
|
|
4247 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
|
|
4248 return ret;
|
|
4249 }
|
|
4250
|
|
4251 ret = elem.value;
|
|
4252
|
|
4253 return typeof ret === "string" ?
|
|
4254 // handle most common string cases
|
|
4255 ret.replace(rreturn, "") :
|
|
4256 // handle cases where value is null/undef or number
|
|
4257 ret == null ? "" : ret;
|
|
4258 }
|
|
4259
|
|
4260 return;
|
|
4261 }
|
|
4262
|
|
4263 isFunction = jQuery.isFunction( value );
|
|
4264
|
|
4265 return this.each(function( i ) {
|
|
4266 var val;
|
|
4267
|
|
4268 if ( this.nodeType !== 1 ) {
|
|
4269 return;
|
|
4270 }
|
|
4271
|
|
4272 if ( isFunction ) {
|
|
4273 val = value.call( this, i, jQuery( this ).val() );
|
|
4274 } else {
|
|
4275 val = value;
|
|
4276 }
|
|
4277
|
|
4278 // Treat null/undefined as ""; convert numbers to string
|
|
4279 if ( val == null ) {
|
|
4280 val = "";
|
|
4281 } else if ( typeof val === "number" ) {
|
|
4282 val += "";
|
|
4283 } else if ( jQuery.isArray( val ) ) {
|
|
4284 val = jQuery.map(val, function ( value ) {
|
|
4285 return value == null ? "" : value + "";
|
|
4286 });
|
|
4287 }
|
|
4288
|
|
4289 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
|
|
4290
|
|
4291 // If set returns undefined, fall back to normal setting
|
|
4292 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
|
|
4293 this.value = val;
|
|
4294 }
|
|
4295 });
|
|
4296 }
|
|
4297 });
|
|
4298
|
|
4299 jQuery.extend({
|
|
4300 valHooks: {
|
|
4301 option: {
|
|
4302 get: function( elem ) {
|
|
4303 // Use proper attribute retrieval(#6932, #12072)
|
|
4304 var val = jQuery.find.attr( elem, "value" );
|
|
4305 return val != null ?
|
|
4306 val :
|
|
4307 elem.text;
|
|
4308 }
|
|
4309 },
|
|
4310 select: {
|
|
4311 get: function( elem ) {
|
|
4312 var value, option,
|
|
4313 options = elem.options,
|
|
4314 index = elem.selectedIndex,
|
|
4315 one = elem.type === "select-one" || index < 0,
|
|
4316 values = one ? null : [],
|
|
4317 max = one ? index + 1 : options.length,
|
|
4318 i = index < 0 ?
|
|
4319 max :
|
|
4320 one ? index : 0;
|
|
4321
|
|
4322 // Loop through all the selected options
|
|
4323 for ( ; i < max; i++ ) {
|
|
4324 option = options[ i ];
|
|
4325
|
|
4326 // oldIE doesn't update selected after form reset (#2551)
|
|
4327 if ( ( option.selected || i === index ) &&
|
|
4328 // Don't return options that are disabled or in a disabled optgroup
|
|
4329 ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
|
|
4330 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
|
|
4331
|
|
4332 // Get the specific value for the option
|
|
4333 value = jQuery( option ).val();
|
|
4334
|
|
4335 // We don't need an array for one selects
|
|
4336 if ( one ) {
|
|
4337 return value;
|
|
4338 }
|
|
4339
|
|
4340 // Multi-Selects return an array
|
|
4341 values.push( value );
|
|
4342 }
|
|
4343 }
|
|
4344
|
|
4345 return values;
|
|
4346 },
|
|
4347
|
|
4348 set: function( elem, value ) {
|
|
4349 var optionSet, option,
|
|
4350 options = elem.options,
|
|
4351 values = jQuery.makeArray( value ),
|
|
4352 i = options.length;
|
|
4353
|
|
4354 while ( i-- ) {
|
|
4355 option = options[ i ];
|
|
4356 if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) {
|
|
4357 optionSet = true;
|
|
4358 }
|
|
4359 }
|
|
4360
|
|
4361 // force browsers to behave consistently when non-matching value is set
|
|
4362 if ( !optionSet ) {
|
|
4363 elem.selectedIndex = -1;
|
|
4364 }
|
|
4365 return values;
|
|
4366 }
|
|
4367 }
|
|
4368 },
|
|
4369
|
|
4370 attr: function( elem, name, value ) {
|
|
4371 var hooks, ret,
|
|
4372 nType = elem.nodeType;
|
|
4373
|
|
4374 // don't get/set attributes on text, comment and attribute nodes
|
|
4375 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
|
4376 return;
|
|
4377 }
|
|
4378
|
|
4379 // Fallback to prop when attributes are not supported
|
|
4380 if ( typeof elem.getAttribute === core_strundefined ) {
|
|
4381 return jQuery.prop( elem, name, value );
|
|
4382 }
|
|
4383
|
|
4384 // All attributes are lowercase
|
|
4385 // Grab necessary hook if one is defined
|
|
4386 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
|
|
4387 name = name.toLowerCase();
|
|
4388 hooks = jQuery.attrHooks[ name ] ||
|
|
4389 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
|
|
4390 }
|
|
4391
|
|
4392 if ( value !== undefined ) {
|
|
4393
|
|
4394 if ( value === null ) {
|
|
4395 jQuery.removeAttr( elem, name );
|
|
4396
|
|
4397 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
|
|
4398 return ret;
|
|
4399
|
|
4400 } else {
|
|
4401 elem.setAttribute( name, value + "" );
|
|
4402 return value;
|
|
4403 }
|
|
4404
|
|
4405 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
|
|
4406 return ret;
|
|
4407
|
|
4408 } else {
|
|
4409 ret = jQuery.find.attr( elem, name );
|
|
4410
|
|
4411 // Non-existent attributes return null, we normalize to undefined
|
|
4412 return ret == null ?
|
|
4413 undefined :
|
|
4414 ret;
|
|
4415 }
|
|
4416 },
|
|
4417
|
|
4418 removeAttr: function( elem, value ) {
|
|
4419 var name, propName,
|
|
4420 i = 0,
|
|
4421 attrNames = value && value.match( core_rnotwhite );
|
|
4422
|
|
4423 if ( attrNames && elem.nodeType === 1 ) {
|
|
4424 while ( (name = attrNames[i++]) ) {
|
|
4425 propName = jQuery.propFix[ name ] || name;
|
|
4426
|
|
4427 // Boolean attributes get special treatment (#10870)
|
|
4428 if ( jQuery.expr.match.bool.test( name ) ) {
|
|
4429 // Set corresponding property to false
|
|
4430 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
|
|
4431 elem[ propName ] = false;
|
|
4432 // Support: IE<9
|
|
4433 // Also clear defaultChecked/defaultSelected (if appropriate)
|
|
4434 } else {
|
|
4435 elem[ jQuery.camelCase( "default-" + name ) ] =
|
|
4436 elem[ propName ] = false;
|
|
4437 }
|
|
4438
|
|
4439 // See #9699 for explanation of this approach (setting first, then removal)
|
|
4440 } else {
|
|
4441 jQuery.attr( elem, name, "" );
|
|
4442 }
|
|
4443
|
|
4444 elem.removeAttribute( getSetAttribute ? name : propName );
|
|
4445 }
|
|
4446 }
|
|
4447 },
|
|
4448
|
|
4449 attrHooks: {
|
|
4450 type: {
|
|
4451 set: function( elem, value ) {
|
|
4452 if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
|
|
4453 // Setting the type on a radio button after the value resets the value in IE6-9
|
|
4454 // Reset value to default in case type is set after value during creation
|
|
4455 var val = elem.value;
|
|
4456 elem.setAttribute( "type", value );
|
|
4457 if ( val ) {
|
|
4458 elem.value = val;
|
|
4459 }
|
|
4460 return value;
|
|
4461 }
|
|
4462 }
|
|
4463 }
|
|
4464 },
|
|
4465
|
|
4466 propFix: {
|
|
4467 "for": "htmlFor",
|
|
4468 "class": "className"
|
|
4469 },
|
|
4470
|
|
4471 prop: function( elem, name, value ) {
|
|
4472 var ret, hooks, notxml,
|
|
4473 nType = elem.nodeType;
|
|
4474
|
|
4475 // don't get/set properties on text, comment and attribute nodes
|
|
4476 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
|
4477 return;
|
|
4478 }
|
|
4479
|
|
4480 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
|
4481
|
|
4482 if ( notxml ) {
|
|
4483 // Fix name and attach hooks
|
|
4484 name = jQuery.propFix[ name ] || name;
|
|
4485 hooks = jQuery.propHooks[ name ];
|
|
4486 }
|
|
4487
|
|
4488 if ( value !== undefined ) {
|
|
4489 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
|
|
4490 ret :
|
|
4491 ( elem[ name ] = value );
|
|
4492
|
|
4493 } else {
|
|
4494 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
|
|
4495 ret :
|
|
4496 elem[ name ];
|
|
4497 }
|
|
4498 },
|
|
4499
|
|
4500 propHooks: {
|
|
4501 tabIndex: {
|
|
4502 get: function( elem ) {
|
|
4503 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
|
4504 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
|
4505 // Use proper attribute retrieval(#12072)
|
|
4506 var tabindex = jQuery.find.attr( elem, "tabindex" );
|
|
4507
|
|
4508 return tabindex ?
|
|
4509 parseInt( tabindex, 10 ) :
|
|
4510 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
|
|
4511 0 :
|
|
4512 -1;
|
|
4513 }
|
|
4514 }
|
|
4515 }
|
|
4516 });
|
|
4517
|
|
4518 // Hooks for boolean attributes
|
|
4519 boolHook = {
|
|
4520 set: function( elem, value, name ) {
|
|
4521 if ( value === false ) {
|
|
4522 // Remove boolean attributes when set to false
|
|
4523 jQuery.removeAttr( elem, name );
|
|
4524 } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
|
|
4525 // IE<8 needs the *property* name
|
|
4526 elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
|
|
4527
|
|
4528 // Use defaultChecked and defaultSelected for oldIE
|
|
4529 } else {
|
|
4530 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
|
|
4531 }
|
|
4532
|
|
4533 return name;
|
|
4534 }
|
|
4535 };
|
|
4536 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
|
|
4537 var getter = jQuery.expr.attrHandle[ name ] || jQuery.find.attr;
|
|
4538
|
|
4539 jQuery.expr.attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
|
|
4540 function( elem, name, isXML ) {
|
|
4541 var fn = jQuery.expr.attrHandle[ name ],
|
|
4542 ret = isXML ?
|
|
4543 undefined :
|
|
4544 /* jshint eqeqeq: false */
|
|
4545 (jQuery.expr.attrHandle[ name ] = undefined) !=
|
|
4546 getter( elem, name, isXML ) ?
|
|
4547
|
|
4548 name.toLowerCase() :
|
|
4549 null;
|
|
4550 jQuery.expr.attrHandle[ name ] = fn;
|
|
4551 return ret;
|
|
4552 } :
|
|
4553 function( elem, name, isXML ) {
|
|
4554 return isXML ?
|
|
4555 undefined :
|
|
4556 elem[ jQuery.camelCase( "default-" + name ) ] ?
|
|
4557 name.toLowerCase() :
|
|
4558 null;
|
|
4559 };
|
|
4560 });
|
|
4561
|
|
4562 // fix oldIE attroperties
|
|
4563 if ( !getSetInput || !getSetAttribute ) {
|
|
4564 jQuery.attrHooks.value = {
|
|
4565 set: function( elem, value, name ) {
|
|
4566 if ( jQuery.nodeName( elem, "input" ) ) {
|
|
4567 // Does not return so that setAttribute is also used
|
|
4568 elem.defaultValue = value;
|
|
4569 } else {
|
|
4570 // Use nodeHook if defined (#1954); otherwise setAttribute is fine
|
|
4571 return nodeHook && nodeHook.set( elem, value, name );
|
|
4572 }
|
|
4573 }
|
|
4574 };
|
|
4575 }
|
|
4576
|
|
4577 // IE6/7 do not support getting/setting some attributes with get/setAttribute
|
|
4578 if ( !getSetAttribute ) {
|
|
4579
|
|
4580 // Use this for any attribute in IE6/7
|
|
4581 // This fixes almost every IE6/7 issue
|
|
4582 nodeHook = {
|
|
4583 set: function( elem, value, name ) {
|
|
4584 // Set the existing or create a new attribute node
|
|
4585 var ret = elem.getAttributeNode( name );
|
|
4586 if ( !ret ) {
|
|
4587 elem.setAttributeNode(
|
|
4588 (ret = elem.ownerDocument.createAttribute( name ))
|
|
4589 );
|
|
4590 }
|
|
4591
|
|
4592 ret.value = value += "";
|
|
4593
|
|
4594 // Break association with cloned elements by also using setAttribute (#9646)
|
|
4595 return name === "value" || value === elem.getAttribute( name ) ?
|
|
4596 value :
|
|
4597 undefined;
|
|
4598 }
|
|
4599 };
|
|
4600 jQuery.expr.attrHandle.id = jQuery.expr.attrHandle.name = jQuery.expr.attrHandle.coords =
|
|
4601 // Some attributes are constructed with empty-string values when not defined
|
|
4602 function( elem, name, isXML ) {
|
|
4603 var ret;
|
|
4604 return isXML ?
|
|
4605 undefined :
|
|
4606 (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
|
|
4607 ret.value :
|
|
4608 null;
|
|
4609 };
|
|
4610 jQuery.valHooks.button = {
|
|
4611 get: function( elem, name ) {
|
|
4612 var ret = elem.getAttributeNode( name );
|
|
4613 return ret && ret.specified ?
|
|
4614 ret.value :
|
|
4615 undefined;
|
|
4616 },
|
|
4617 set: nodeHook.set
|
|
4618 };
|
|
4619
|
|
4620 // Set contenteditable to false on removals(#10429)
|
|
4621 // Setting to empty string throws an error as an invalid value
|
|
4622 jQuery.attrHooks.contenteditable = {
|
|
4623 set: function( elem, value, name ) {
|
|
4624 nodeHook.set( elem, value === "" ? false : value, name );
|
|
4625 }
|
|
4626 };
|
|
4627
|
|
4628 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
|
|
4629 // This is for removals
|
|
4630 jQuery.each([ "width", "height" ], function( i, name ) {
|
|
4631 jQuery.attrHooks[ name ] = {
|
|
4632 set: function( elem, value ) {
|
|
4633 if ( value === "" ) {
|
|
4634 elem.setAttribute( name, "auto" );
|
|
4635 return value;
|
|
4636 }
|
|
4637 }
|
|
4638 };
|
|
4639 });
|
|
4640 }
|
|
4641
|
|
4642
|
|
4643 // Some attributes require a special call on IE
|
|
4644 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
|
|
4645 if ( !jQuery.support.hrefNormalized ) {
|
|
4646 // href/src property should get the full normalized URL (#10299/#12915)
|
|
4647 jQuery.each([ "href", "src" ], function( i, name ) {
|
|
4648 jQuery.propHooks[ name ] = {
|
|
4649 get: function( elem ) {
|
|
4650 return elem.getAttribute( name, 4 );
|
|
4651 }
|
|
4652 };
|
|
4653 });
|
|
4654 }
|
|
4655
|
|
4656 if ( !jQuery.support.style ) {
|
|
4657 jQuery.attrHooks.style = {
|
|
4658 get: function( elem ) {
|
|
4659 // Return undefined in the case of empty string
|
|
4660 // Note: IE uppercases css property names, but if we were to .toLowerCase()
|
|
4661 // .cssText, that would destroy case senstitivity in URL's, like in "background"
|
|
4662 return elem.style.cssText || undefined;
|
|
4663 },
|
|
4664 set: function( elem, value ) {
|
|
4665 return ( elem.style.cssText = value + "" );
|
|
4666 }
|
|
4667 };
|
|
4668 }
|
|
4669
|
|
4670 // Safari mis-reports the default selected property of an option
|
|
4671 // Accessing the parent's selectedIndex property fixes it
|
|
4672 if ( !jQuery.support.optSelected ) {
|
|
4673 jQuery.propHooks.selected = {
|
|
4674 get: function( elem ) {
|
|
4675 var parent = elem.parentNode;
|
|
4676
|
|
4677 if ( parent ) {
|
|
4678 parent.selectedIndex;
|
|
4679
|
|
4680 // Make sure that it also works with optgroups, see #5701
|
|
4681 if ( parent.parentNode ) {
|
|
4682 parent.parentNode.selectedIndex;
|
|
4683 }
|
|
4684 }
|
|
4685 return null;
|
|
4686 }
|
|
4687 };
|
|
4688 }
|
|
4689
|
|
4690 jQuery.each([
|
|
4691 "tabIndex",
|
|
4692 "readOnly",
|
|
4693 "maxLength",
|
|
4694 "cellSpacing",
|
|
4695 "cellPadding",
|
|
4696 "rowSpan",
|
|
4697 "colSpan",
|
|
4698 "useMap",
|
|
4699 "frameBorder",
|
|
4700 "contentEditable"
|
|
4701 ], function() {
|
|
4702 jQuery.propFix[ this.toLowerCase() ] = this;
|
|
4703 });
|
|
4704
|
|
4705 // IE6/7 call enctype encoding
|
|
4706 if ( !jQuery.support.enctype ) {
|
|
4707 jQuery.propFix.enctype = "encoding";
|
|
4708 }
|
|
4709
|
|
4710 // Radios and checkboxes getter/setter
|
|
4711 jQuery.each([ "radio", "checkbox" ], function() {
|
|
4712 jQuery.valHooks[ this ] = {
|
|
4713 set: function( elem, value ) {
|
|
4714 if ( jQuery.isArray( value ) ) {
|
|
4715 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
|
|
4716 }
|
|
4717 }
|
|
4718 };
|
|
4719 if ( !jQuery.support.checkOn ) {
|
|
4720 jQuery.valHooks[ this ].get = function( elem ) {
|
|
4721 // Support: Webkit
|
|
4722 // "" is returned instead of "on" if a value isn't specified
|
|
4723 return elem.getAttribute("value") === null ? "on" : elem.value;
|
|
4724 };
|
|
4725 }
|
|
4726 });
|
|
4727 var rformElems = /^(?:input|select|textarea)$/i,
|
|
4728 rkeyEvent = /^key/,
|
|
4729 rmouseEvent = /^(?:mouse|contextmenu)|click/,
|
|
4730 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
|
|
4731 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
|
|
4732
|
|
4733 function returnTrue() {
|
|
4734 return true;
|
|
4735 }
|
|
4736
|
|
4737 function returnFalse() {
|
|
4738 return false;
|
|
4739 }
|
|
4740
|
|
4741 function safeActiveElement() {
|
|
4742 try {
|
|
4743 return document.activeElement;
|
|
4744 } catch ( err ) { }
|
|
4745 }
|
|
4746
|
|
4747 /*
|
|
4748 * Helper functions for managing events -- not part of the public interface.
|
|
4749 * Props to Dean Edwards' addEvent library for many of the ideas.
|
|
4750 */
|
|
4751 jQuery.event = {
|
|
4752
|
|
4753 global: {},
|
|
4754
|
|
4755 add: function( elem, types, handler, data, selector ) {
|
|
4756 var tmp, events, t, handleObjIn,
|
|
4757 special, eventHandle, handleObj,
|
|
4758 handlers, type, namespaces, origType,
|
|
4759 elemData = jQuery._data( elem );
|
|
4760
|
|
4761 // Don't attach events to noData or text/comment nodes (but allow plain objects)
|
|
4762 if ( !elemData ) {
|
|
4763 return;
|
|
4764 }
|
|
4765
|
|
4766 // Caller can pass in an object of custom data in lieu of the handler
|
|
4767 if ( handler.handler ) {
|
|
4768 handleObjIn = handler;
|
|
4769 handler = handleObjIn.handler;
|
|
4770 selector = handleObjIn.selector;
|
|
4771 }
|
|
4772
|
|
4773 // Make sure that the handler has a unique ID, used to find/remove it later
|
|
4774 if ( !handler.guid ) {
|
|
4775 handler.guid = jQuery.guid++;
|
|
4776 }
|
|
4777
|
|
4778 // Init the element's event structure and main handler, if this is the first
|
|
4779 if ( !(events = elemData.events) ) {
|
|
4780 events = elemData.events = {};
|
|
4781 }
|
|
4782 if ( !(eventHandle = elemData.handle) ) {
|
|
4783 eventHandle = elemData.handle = function( e ) {
|
|
4784 // Discard the second event of a jQuery.event.trigger() and
|
|
4785 // when an event is called after a page has unloaded
|
|
4786 return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?
|
|
4787 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
|
|
4788 undefined;
|
|
4789 };
|
|
4790 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
|
|
4791 eventHandle.elem = elem;
|
|
4792 }
|
|
4793
|
|
4794 // Handle multiple events separated by a space
|
|
4795 types = ( types || "" ).match( core_rnotwhite ) || [""];
|
|
4796 t = types.length;
|
|
4797 while ( t-- ) {
|
|
4798 tmp = rtypenamespace.exec( types[t] ) || [];
|
|
4799 type = origType = tmp[1];
|
|
4800 namespaces = ( tmp[2] || "" ).split( "." ).sort();
|
|
4801
|
|
4802 // There *must* be a type, no attaching namespace-only handlers
|
|
4803 if ( !type ) {
|
|
4804 continue;
|
|
4805 }
|
|
4806
|
|
4807 // If event changes its type, use the special event handlers for the changed type
|
|
4808 special = jQuery.event.special[ type ] || {};
|
|
4809
|
|
4810 // If selector defined, determine special event api type, otherwise given type
|
|
4811 type = ( selector ? special.delegateType : special.bindType ) || type;
|
|
4812
|
|
4813 // Update special based on newly reset type
|
|
4814 special = jQuery.event.special[ type ] || {};
|
|
4815
|
|
4816 // handleObj is passed to all event handlers
|
|
4817 handleObj = jQuery.extend({
|
|
4818 type: type,
|
|
4819 origType: origType,
|
|
4820 data: data,
|
|
4821 handler: handler,
|
|
4822 guid: handler.guid,
|
|
4823 selector: selector,
|
|
4824 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
|
|
4825 namespace: namespaces.join(".")
|
|
4826 }, handleObjIn );
|
|
4827
|
|
4828 // Init the event handler queue if we're the first
|
|
4829 if ( !(handlers = events[ type ]) ) {
|
|
4830 handlers = events[ type ] = [];
|
|
4831 handlers.delegateCount = 0;
|
|
4832
|
|
4833 // Only use addEventListener/attachEvent if the special events handler returns false
|
|
4834 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
|
|
4835 // Bind the global event handler to the element
|
|
4836 if ( elem.addEventListener ) {
|
|
4837 elem.addEventListener( type, eventHandle, false );
|
|
4838
|
|
4839 } else if ( elem.attachEvent ) {
|
|
4840 elem.attachEvent( "on" + type, eventHandle );
|
|
4841 }
|
|
4842 }
|
|
4843 }
|
|
4844
|
|
4845 if ( special.add ) {
|
|
4846 special.add.call( elem, handleObj );
|
|
4847
|
|
4848 if ( !handleObj.handler.guid ) {
|
|
4849 handleObj.handler.guid = handler.guid;
|
|
4850 }
|
|
4851 }
|
|
4852
|
|
4853 // Add to the element's handler list, delegates in front
|
|
4854 if ( selector ) {
|
|
4855 handlers.splice( handlers.delegateCount++, 0, handleObj );
|
|
4856 } else {
|
|
4857 handlers.push( handleObj );
|
|
4858 }
|
|
4859
|
|
4860 // Keep track of which events have ever been used, for event optimization
|
|
4861 jQuery.event.global[ type ] = true;
|
|
4862 }
|
|
4863
|
|
4864 // Nullify elem to prevent memory leaks in IE
|
|
4865 elem = null;
|
|
4866 },
|
|
4867
|
|
4868 // Detach an event or set of events from an element
|
|
4869 remove: function( elem, types, handler, selector, mappedTypes ) {
|
|
4870 var j, handleObj, tmp,
|
|
4871 origCount, t, events,
|
|
4872 special, handlers, type,
|
|
4873 namespaces, origType,
|
|
4874 elemData = jQuery.hasData( elem ) && jQuery._data( elem );
|
|
4875
|
|
4876 if ( !elemData || !(events = elemData.events) ) {
|
|
4877 return;
|
|
4878 }
|
|
4879
|
|
4880 // Once for each type.namespace in types; type may be omitted
|
|
4881 types = ( types || "" ).match( core_rnotwhite ) || [""];
|
|
4882 t = types.length;
|
|
4883 while ( t-- ) {
|
|
4884 tmp = rtypenamespace.exec( types[t] ) || [];
|
|
4885 type = origType = tmp[1];
|
|
4886 namespaces = ( tmp[2] || "" ).split( "." ).sort();
|
|
4887
|
|
4888 // Unbind all events (on this namespace, if provided) for the element
|
|
4889 if ( !type ) {
|
|
4890 for ( type in events ) {
|
|
4891 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
|
|
4892 }
|
|
4893 continue;
|
|
4894 }
|
|
4895
|
|
4896 special = jQuery.event.special[ type ] || {};
|
|
4897 type = ( selector ? special.delegateType : special.bindType ) || type;
|
|
4898 handlers = events[ type ] || [];
|
|
4899 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
|
|
4900
|
|
4901 // Remove matching events
|
|
4902 origCount = j = handlers.length;
|
|
4903 while ( j-- ) {
|
|
4904 handleObj = handlers[ j ];
|
|
4905
|
|
4906 if ( ( mappedTypes || origType === handleObj.origType ) &&
|
|
4907 ( !handler || handler.guid === handleObj.guid ) &&
|
|
4908 ( !tmp || tmp.test( handleObj.namespace ) ) &&
|
|
4909 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
|
|
4910 handlers.splice( j, 1 );
|
|
4911
|
|
4912 if ( handleObj.selector ) {
|
|
4913 handlers.delegateCount--;
|
|
4914 }
|
|
4915 if ( special.remove ) {
|
|
4916 special.remove.call( elem, handleObj );
|
|
4917 }
|
|
4918 }
|
|
4919 }
|
|
4920
|
|
4921 // Remove generic event handler if we removed something and no more handlers exist
|
|
4922 // (avoids potential for endless recursion during removal of special event handlers)
|
|
4923 if ( origCount && !handlers.length ) {
|
|
4924 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
|
|
4925 jQuery.removeEvent( elem, type, elemData.handle );
|
|
4926 }
|
|
4927
|
|
4928 delete events[ type ];
|
|
4929 }
|
|
4930 }
|
|
4931
|
|
4932 // Remove the expando if it's no longer used
|
|
4933 if ( jQuery.isEmptyObject( events ) ) {
|
|
4934 delete elemData.handle;
|
|
4935
|
|
4936 // removeData also checks for emptiness and clears the expando if empty
|
|
4937 // so use it instead of delete
|
|
4938 jQuery._removeData( elem, "events" );
|
|
4939 }
|
|
4940 },
|
|
4941
|
|
4942 trigger: function( event, data, elem, onlyHandlers ) {
|
|
4943 var handle, ontype, cur,
|
|
4944 bubbleType, special, tmp, i,
|
|
4945 eventPath = [ elem || document ],
|
|
4946 type = core_hasOwn.call( event, "type" ) ? event.type : event,
|
|
4947 namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
|
|
4948
|
|
4949 cur = tmp = elem = elem || document;
|
|
4950
|
|
4951 // Don't do events on text and comment nodes
|
|
4952 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
|
|
4953 return;
|
|
4954 }
|
|
4955
|
|
4956 // focus/blur morphs to focusin/out; ensure we're not firing them right now
|
|
4957 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
|
|
4958 return;
|
|
4959 }
|
|
4960
|
|
4961 if ( type.indexOf(".") >= 0 ) {
|
|
4962 // Namespaced trigger; create a regexp to match event type in handle()
|
|
4963 namespaces = type.split(".");
|
|
4964 type = namespaces.shift();
|
|
4965 namespaces.sort();
|
|
4966 }
|
|
4967 ontype = type.indexOf(":") < 0 && "on" + type;
|
|
4968
|
|
4969 // Caller can pass in a jQuery.Event object, Object, or just an event type string
|
|
4970 event = event[ jQuery.expando ] ?
|
|
4971 event :
|
|
4972 new jQuery.Event( type, typeof event === "object" && event );
|
|
4973
|
|
4974 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
|
|
4975 event.isTrigger = onlyHandlers ? 2 : 3;
|
|
4976 event.namespace = namespaces.join(".");
|
|
4977 event.namespace_re = event.namespace ?
|
|
4978 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
|
|
4979 null;
|
|
4980
|
|
4981 // Clean up the event in case it is being reused
|
|
4982 event.result = undefined;
|
|
4983 if ( !event.target ) {
|
|
4984 event.target = elem;
|
|
4985 }
|
|
4986
|
|
4987 // Clone any incoming data and prepend the event, creating the handler arg list
|
|
4988 data = data == null ?
|
|
4989 [ event ] :
|
|
4990 jQuery.makeArray( data, [ event ] );
|
|
4991
|
|
4992 // Allow special events to draw outside the lines
|
|
4993 special = jQuery.event.special[ type ] || {};
|
|
4994 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
|
|
4995 return;
|
|
4996 }
|
|
4997
|
|
4998 // Determine event propagation path in advance, per W3C events spec (#9951)
|
|
4999 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
|
|
5000 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
|
|
5001
|
|
5002 bubbleType = special.delegateType || type;
|
|
5003 if ( !rfocusMorph.test( bubbleType + type ) ) {
|
|
5004 cur = cur.parentNode;
|
|
5005 }
|
|
5006 for ( ; cur; cur = cur.parentNode ) {
|
|
5007 eventPath.push( cur );
|
|
5008 tmp = cur;
|
|
5009 }
|
|
5010
|
|
5011 // Only add window if we got to document (e.g., not plain obj or detached DOM)
|
|
5012 if ( tmp === (elem.ownerDocument || document) ) {
|
|
5013 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
|
|
5014 }
|
|
5015 }
|
|
5016
|
|
5017 // Fire handlers on the event path
|
|
5018 i = 0;
|
|
5019 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
|
|
5020
|
|
5021 event.type = i > 1 ?
|
|
5022 bubbleType :
|
|
5023 special.bindType || type;
|
|
5024
|
|
5025 // jQuery handler
|
|
5026 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
|
|
5027 if ( handle ) {
|
|
5028 handle.apply( cur, data );
|
|
5029 }
|
|
5030
|
|
5031 // Native handler
|
|
5032 handle = ontype && cur[ ontype ];
|
|
5033 if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
|
|
5034 event.preventDefault();
|
|
5035 }
|
|
5036 }
|
|
5037 event.type = type;
|
|
5038
|
|
5039 // If nobody prevented the default action, do it now
|
|
5040 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
|
|
5041
|
|
5042 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
|
|
5043 jQuery.acceptData( elem ) ) {
|
|
5044
|
|
5045 // Call a native DOM method on the target with the same name name as the event.
|
|
5046 // Can't use an .isFunction() check here because IE6/7 fails that test.
|
|
5047 // Don't do default actions on window, that's where global variables be (#6170)
|
|
5048 if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
|
|
5049
|
|
5050 // Don't re-trigger an onFOO event when we call its FOO() method
|
|
5051 tmp = elem[ ontype ];
|
|
5052
|
|
5053 if ( tmp ) {
|
|
5054 elem[ ontype ] = null;
|
|
5055 }
|
|
5056
|
|
5057 // Prevent re-triggering of the same event, since we already bubbled it above
|
|
5058 jQuery.event.triggered = type;
|
|
5059 try {
|
|
5060 elem[ type ]();
|
|
5061 } catch ( e ) {
|
|
5062 // IE<9 dies on focus/blur to hidden element (#1486,#12518)
|
|
5063 // only reproducible on winXP IE8 native, not IE9 in IE8 mode
|
|
5064 }
|
|
5065 jQuery.event.triggered = undefined;
|
|
5066
|
|
5067 if ( tmp ) {
|
|
5068 elem[ ontype ] = tmp;
|
|
5069 }
|
|
5070 }
|
|
5071 }
|
|
5072 }
|
|
5073
|
|
5074 return event.result;
|
|
5075 },
|
|
5076
|
|
5077 dispatch: function( event ) {
|
|
5078
|
|
5079 // Make a writable jQuery.Event from the native event object
|
|
5080 event = jQuery.event.fix( event );
|
|
5081
|
|
5082 var i, ret, handleObj, matched, j,
|
|
5083 handlerQueue = [],
|
|
5084 args = core_slice.call( arguments ),
|
|
5085 handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
|
|
5086 special = jQuery.event.special[ event.type ] || {};
|
|
5087
|
|
5088 // Use the fix-ed jQuery.Event rather than the (read-only) native event
|
|
5089 args[0] = event;
|
|
5090 event.delegateTarget = this;
|
|
5091
|
|
5092 // Call the preDispatch hook for the mapped type, and let it bail if desired
|
|
5093 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
|
|
5094 return;
|
|
5095 }
|
|
5096
|
|
5097 // Determine handlers
|
|
5098 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
|
|
5099
|
|
5100 // Run delegates first; they may want to stop propagation beneath us
|
|
5101 i = 0;
|
|
5102 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
|
|
5103 event.currentTarget = matched.elem;
|
|
5104
|
|
5105 j = 0;
|
|
5106 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
|
|
5107
|
|
5108 // Triggered event must either 1) have no namespace, or
|
|
5109 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
|
|
5110 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
|
|
5111
|
|
5112 event.handleObj = handleObj;
|
|
5113 event.data = handleObj.data;
|
|
5114
|
|
5115 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
|
|
5116 .apply( matched.elem, args );
|
|
5117
|
|
5118 if ( ret !== undefined ) {
|
|
5119 if ( (event.result = ret) === false ) {
|
|
5120 event.preventDefault();
|
|
5121 event.stopPropagation();
|
|
5122 }
|
|
5123 }
|
|
5124 }
|
|
5125 }
|
|
5126 }
|
|
5127
|
|
5128 // Call the postDispatch hook for the mapped type
|
|
5129 if ( special.postDispatch ) {
|
|
5130 special.postDispatch.call( this, event );
|
|
5131 }
|
|
5132
|
|
5133 return event.result;
|
|
5134 },
|
|
5135
|
|
5136 handlers: function( event, handlers ) {
|
|
5137 var sel, handleObj, matches, i,
|
|
5138 handlerQueue = [],
|
|
5139 delegateCount = handlers.delegateCount,
|
|
5140 cur = event.target;
|
|
5141
|
|
5142 // Find delegate handlers
|
|
5143 // Black-hole SVG <use> instance trees (#13180)
|
|
5144 // Avoid non-left-click bubbling in Firefox (#3861)
|
|
5145 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
|
|
5146
|
|
5147 /* jshint eqeqeq: false */
|
|
5148 for ( ; cur != this; cur = cur.parentNode || this ) {
|
|
5149 /* jshint eqeqeq: true */
|
|
5150
|
|
5151 // Don't check non-elements (#13208)
|
|
5152 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
|
|
5153 if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
|
|
5154 matches = [];
|
|
5155 for ( i = 0; i < delegateCount; i++ ) {
|
|
5156 handleObj = handlers[ i ];
|
|
5157
|
|
5158 // Don't conflict with Object.prototype properties (#13203)
|
|
5159 sel = handleObj.selector + " ";
|
|
5160
|
|
5161 if ( matches[ sel ] === undefined ) {
|
|
5162 matches[ sel ] = handleObj.needsContext ?
|
|
5163 jQuery( sel, this ).index( cur ) >= 0 :
|
|
5164 jQuery.find( sel, this, null, [ cur ] ).length;
|
|
5165 }
|
|
5166 if ( matches[ sel ] ) {
|
|
5167 matches.push( handleObj );
|
|
5168 }
|
|
5169 }
|
|
5170 if ( matches.length ) {
|
|
5171 handlerQueue.push({ elem: cur, handlers: matches });
|
|
5172 }
|
|
5173 }
|
|
5174 }
|
|
5175 }
|
|
5176
|
|
5177 // Add the remaining (directly-bound) handlers
|
|
5178 if ( delegateCount < handlers.length ) {
|
|
5179 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
|
|
5180 }
|
|
5181
|
|
5182 return handlerQueue;
|
|
5183 },
|
|
5184
|
|
5185 fix: function( event ) {
|
|
5186 if ( event[ jQuery.expando ] ) {
|
|
5187 return event;
|
|
5188 }
|
|
5189
|
|
5190 // Create a writable copy of the event object and normalize some properties
|
|
5191 var i, prop, copy,
|
|
5192 type = event.type,
|
|
5193 originalEvent = event,
|
|
5194 fixHook = this.fixHooks[ type ];
|
|
5195
|
|
5196 if ( !fixHook ) {
|
|
5197 this.fixHooks[ type ] = fixHook =
|
|
5198 rmouseEvent.test( type ) ? this.mouseHooks :
|
|
5199 rkeyEvent.test( type ) ? this.keyHooks :
|
|
5200 {};
|
|
5201 }
|
|
5202 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
|
|
5203
|
|
5204 event = new jQuery.Event( originalEvent );
|
|
5205
|
|
5206 i = copy.length;
|
|
5207 while ( i-- ) {
|
|
5208 prop = copy[ i ];
|
|
5209 event[ prop ] = originalEvent[ prop ];
|
|
5210 }
|
|
5211
|
|
5212 // Support: IE<9
|
|
5213 // Fix target property (#1925)
|
|
5214 if ( !event.target ) {
|
|
5215 event.target = originalEvent.srcElement || document;
|
|
5216 }
|
|
5217
|
|
5218 // Support: Chrome 23+, Safari?
|
|
5219 // Target should not be a text node (#504, #13143)
|
|
5220 if ( event.target.nodeType === 3 ) {
|
|
5221 event.target = event.target.parentNode;
|
|
5222 }
|
|
5223
|
|
5224 // Support: IE<9
|
|
5225 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
|
|
5226 event.metaKey = !!event.metaKey;
|
|
5227
|
|
5228 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
|
|
5229 },
|
|
5230
|
|
5231 // Includes some event props shared by KeyEvent and MouseEvent
|
|
5232 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
|
|
5233
|
|
5234 fixHooks: {},
|
|
5235
|
|
5236 keyHooks: {
|
|
5237 props: "char charCode key keyCode".split(" "),
|
|
5238 filter: function( event, original ) {
|
|
5239
|
|
5240 // Add which for key events
|
|
5241 if ( event.which == null ) {
|
|
5242 event.which = original.charCode != null ? original.charCode : original.keyCode;
|
|
5243 }
|
|
5244
|
|
5245 return event;
|
|
5246 }
|
|
5247 },
|
|
5248
|
|
5249 mouseHooks: {
|
|
5250 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
|
|
5251 filter: function( event, original ) {
|
|
5252 var body, eventDoc, doc,
|
|
5253 button = original.button,
|
|
5254 fromElement = original.fromElement;
|
|
5255
|
|
5256 // Calculate pageX/Y if missing and clientX/Y available
|
|
5257 if ( event.pageX == null && original.clientX != null ) {
|
|
5258 eventDoc = event.target.ownerDocument || document;
|
|
5259 doc = eventDoc.documentElement;
|
|
5260 body = eventDoc.body;
|
|
5261
|
|
5262 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
|
|
5263 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
|
|
5264 }
|
|
5265
|
|
5266 // Add relatedTarget, if necessary
|
|
5267 if ( !event.relatedTarget && fromElement ) {
|
|
5268 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
|
|
5269 }
|
|
5270
|
|
5271 // Add which for click: 1 === left; 2 === middle; 3 === right
|
|
5272 // Note: button is not normalized, so don't use it
|
|
5273 if ( !event.which && button !== undefined ) {
|
|
5274 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
|
|
5275 }
|
|
5276
|
|
5277 return event;
|
|
5278 }
|
|
5279 },
|
|
5280
|
|
5281 special: {
|
|
5282 load: {
|
|
5283 // Prevent triggered image.load events from bubbling to window.load
|
|
5284 noBubble: true
|
|
5285 },
|
|
5286 focus: {
|
|
5287 // Fire native event if possible so blur/focus sequence is correct
|
|
5288 trigger: function() {
|
|
5289 if ( this !== safeActiveElement() && this.focus ) {
|
|
5290 try {
|
|
5291 this.focus();
|
|
5292 return false;
|
|
5293 } catch ( e ) {
|
|
5294 // Support: IE<9
|
|
5295 // If we error on focus to hidden element (#1486, #12518),
|
|
5296 // let .trigger() run the handlers
|
|
5297 }
|
|
5298 }
|
|
5299 },
|
|
5300 delegateType: "focusin"
|
|
5301 },
|
|
5302 blur: {
|
|
5303 trigger: function() {
|
|
5304 if ( this === safeActiveElement() && this.blur ) {
|
|
5305 this.blur();
|
|
5306 return false;
|
|
5307 }
|
|
5308 },
|
|
5309 delegateType: "focusout"
|
|
5310 },
|
|
5311 click: {
|
|
5312 // For checkbox, fire native event so checked state will be right
|
|
5313 trigger: function() {
|
|
5314 if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
|
|
5315 this.click();
|
|
5316 return false;
|
|
5317 }
|
|
5318 },
|
|
5319
|
|
5320 // For cross-browser consistency, don't fire native .click() on links
|
|
5321 _default: function( event ) {
|
|
5322 return jQuery.nodeName( event.target, "a" );
|
|
5323 }
|
|
5324 },
|
|
5325
|
|
5326 beforeunload: {
|
|
5327 postDispatch: function( event ) {
|
|
5328
|
|
5329 // Even when returnValue equals to undefined Firefox will still show alert
|
|
5330 if ( event.result !== undefined ) {
|
|
5331 event.originalEvent.returnValue = event.result;
|
|
5332 }
|
|
5333 }
|
|
5334 }
|
|
5335 },
|
|
5336
|
|
5337 simulate: function( type, elem, event, bubble ) {
|
|
5338 // Piggyback on a donor event to simulate a different one.
|
|
5339 // Fake originalEvent to avoid donor's stopPropagation, but if the
|
|
5340 // simulated event prevents default then we do the same on the donor.
|
|
5341 var e = jQuery.extend(
|
|
5342 new jQuery.Event(),
|
|
5343 event,
|
|
5344 {
|
|
5345 type: type,
|
|
5346 isSimulated: true,
|
|
5347 originalEvent: {}
|
|
5348 }
|
|
5349 );
|
|
5350 if ( bubble ) {
|
|
5351 jQuery.event.trigger( e, null, elem );
|
|
5352 } else {
|
|
5353 jQuery.event.dispatch.call( elem, e );
|
|
5354 }
|
|
5355 if ( e.isDefaultPrevented() ) {
|
|
5356 event.preventDefault();
|
|
5357 }
|
|
5358 }
|
|
5359 };
|
|
5360
|
|
5361 jQuery.removeEvent = document.removeEventListener ?
|
|
5362 function( elem, type, handle ) {
|
|
5363 if ( elem.removeEventListener ) {
|
|
5364 elem.removeEventListener( type, handle, false );
|
|
5365 }
|
|
5366 } :
|
|
5367 function( elem, type, handle ) {
|
|
5368 var name = "on" + type;
|
|
5369
|
|
5370 if ( elem.detachEvent ) {
|
|
5371
|
|
5372 // #8545, #7054, preventing memory leaks for custom events in IE6-8
|
|
5373 // detachEvent needed property on element, by name of that event, to properly expose it to GC
|
|
5374 if ( typeof elem[ name ] === core_strundefined ) {
|
|
5375 elem[ name ] = null;
|
|
5376 }
|
|
5377
|
|
5378 elem.detachEvent( name, handle );
|
|
5379 }
|
|
5380 };
|
|
5381
|
|
5382 jQuery.Event = function( src, props ) {
|
|
5383 // Allow instantiation without the 'new' keyword
|
|
5384 if ( !(this instanceof jQuery.Event) ) {
|
|
5385 return new jQuery.Event( src, props );
|
|
5386 }
|
|
5387
|
|
5388 // Event object
|
|
5389 if ( src && src.type ) {
|
|
5390 this.originalEvent = src;
|
|
5391 this.type = src.type;
|
|
5392
|
|
5393 // Events bubbling up the document may have been marked as prevented
|
|
5394 // by a handler lower down the tree; reflect the correct value.
|
|
5395 this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
|
|
5396 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
|
|
5397
|
|
5398 // Event type
|
|
5399 } else {
|
|
5400 this.type = src;
|
|
5401 }
|
|
5402
|
|
5403 // Put explicitly provided properties onto the event object
|
|
5404 if ( props ) {
|
|
5405 jQuery.extend( this, props );
|
|
5406 }
|
|
5407
|
|
5408 // Create a timestamp if incoming event doesn't have one
|
|
5409 this.timeStamp = src && src.timeStamp || jQuery.now();
|
|
5410
|
|
5411 // Mark it as fixed
|
|
5412 this[ jQuery.expando ] = true;
|
|
5413 };
|
|
5414
|
|
5415 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
|
5416 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
|
5417 jQuery.Event.prototype = {
|
|
5418 isDefaultPrevented: returnFalse,
|
|
5419 isPropagationStopped: returnFalse,
|
|
5420 isImmediatePropagationStopped: returnFalse,
|
|
5421
|
|
5422 preventDefault: function() {
|
|
5423 var e = this.originalEvent;
|
|
5424
|
|
5425 this.isDefaultPrevented = returnTrue;
|
|
5426 if ( !e ) {
|
|
5427 return;
|
|
5428 }
|
|
5429
|
|
5430 // If preventDefault exists, run it on the original event
|
|
5431 if ( e.preventDefault ) {
|
|
5432 e.preventDefault();
|
|
5433
|
|
5434 // Support: IE
|
|
5435 // Otherwise set the returnValue property of the original event to false
|
|
5436 } else {
|
|
5437 e.returnValue = false;
|
|
5438 }
|
|
5439 },
|
|
5440 stopPropagation: function() {
|
|
5441 var e = this.originalEvent;
|
|
5442
|
|
5443 this.isPropagationStopped = returnTrue;
|
|
5444 if ( !e ) {
|
|
5445 return;
|
|
5446 }
|
|
5447 // If stopPropagation exists, run it on the original event
|
|
5448 if ( e.stopPropagation ) {
|
|
5449 e.stopPropagation();
|
|
5450 }
|
|
5451
|
|
5452 // Support: IE
|
|
5453 // Set the cancelBubble property of the original event to true
|
|
5454 e.cancelBubble = true;
|
|
5455 },
|
|
5456 stopImmediatePropagation: function() {
|
|
5457 this.isImmediatePropagationStopped = returnTrue;
|
|
5458 this.stopPropagation();
|
|
5459 }
|
|
5460 };
|
|
5461
|
|
5462 // Create mouseenter/leave events using mouseover/out and event-time checks
|
|
5463 jQuery.each({
|
|
5464 mouseenter: "mouseover",
|
|
5465 mouseleave: "mouseout"
|
|
5466 }, function( orig, fix ) {
|
|
5467 jQuery.event.special[ orig ] = {
|
|
5468 delegateType: fix,
|
|
5469 bindType: fix,
|
|
5470
|
|
5471 handle: function( event ) {
|
|
5472 var ret,
|
|
5473 target = this,
|
|
5474 related = event.relatedTarget,
|
|
5475 handleObj = event.handleObj;
|
|
5476
|
|
5477 // For mousenter/leave call the handler if related is outside the target.
|
|
5478 // NB: No relatedTarget if the mouse left/entered the browser window
|
|
5479 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
|
|
5480 event.type = handleObj.origType;
|
|
5481 ret = handleObj.handler.apply( this, arguments );
|
|
5482 event.type = fix;
|
|
5483 }
|
|
5484 return ret;
|
|
5485 }
|
|
5486 };
|
|
5487 });
|
|
5488
|
|
5489 // IE submit delegation
|
|
5490 if ( !jQuery.support.submitBubbles ) {
|
|
5491
|
|
5492 jQuery.event.special.submit = {
|
|
5493 setup: function() {
|
|
5494 // Only need this for delegated form submit events
|
|
5495 if ( jQuery.nodeName( this, "form" ) ) {
|
|
5496 return false;
|
|
5497 }
|
|
5498
|
|
5499 // Lazy-add a submit handler when a descendant form may potentially be submitted
|
|
5500 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
|
|
5501 // Node name check avoids a VML-related crash in IE (#9807)
|
|
5502 var elem = e.target,
|
|
5503 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
|
|
5504 if ( form && !jQuery._data( form, "submitBubbles" ) ) {
|
|
5505 jQuery.event.add( form, "submit._submit", function( event ) {
|
|
5506 event._submit_bubble = true;
|
|
5507 });
|
|
5508 jQuery._data( form, "submitBubbles", true );
|
|
5509 }
|
|
5510 });
|
|
5511 // return undefined since we don't need an event listener
|
|
5512 },
|
|
5513
|
|
5514 postDispatch: function( event ) {
|
|
5515 // If form was submitted by the user, bubble the event up the tree
|
|
5516 if ( event._submit_bubble ) {
|
|
5517 delete event._submit_bubble;
|
|
5518 if ( this.parentNode && !event.isTrigger ) {
|
|
5519 jQuery.event.simulate( "submit", this.parentNode, event, true );
|
|
5520 }
|
|
5521 }
|
|
5522 },
|
|
5523
|
|
5524 teardown: function() {
|
|
5525 // Only need this for delegated form submit events
|
|
5526 if ( jQuery.nodeName( this, "form" ) ) {
|
|
5527 return false;
|
|
5528 }
|
|
5529
|
|
5530 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
|
|
5531 jQuery.event.remove( this, "._submit" );
|
|
5532 }
|
|
5533 };
|
|
5534 }
|
|
5535
|
|
5536 // IE change delegation and checkbox/radio fix
|
|
5537 if ( !jQuery.support.changeBubbles ) {
|
|
5538
|
|
5539 jQuery.event.special.change = {
|
|
5540
|
|
5541 setup: function() {
|
|
5542
|
|
5543 if ( rformElems.test( this.nodeName ) ) {
|
|
5544 // IE doesn't fire change on a check/radio until blur; trigger it on click
|
|
5545 // after a propertychange. Eat the blur-change in special.change.handle.
|
|
5546 // This still fires onchange a second time for check/radio after blur.
|
|
5547 if ( this.type === "checkbox" || this.type === "radio" ) {
|
|
5548 jQuery.event.add( this, "propertychange._change", function( event ) {
|
|
5549 if ( event.originalEvent.propertyName === "checked" ) {
|
|
5550 this._just_changed = true;
|
|
5551 }
|
|
5552 });
|
|
5553 jQuery.event.add( this, "click._change", function( event ) {
|
|
5554 if ( this._just_changed && !event.isTrigger ) {
|
|
5555 this._just_changed = false;
|
|
5556 }
|
|
5557 // Allow triggered, simulated change events (#11500)
|
|
5558 jQuery.event.simulate( "change", this, event, true );
|
|
5559 });
|
|
5560 }
|
|
5561 return false;
|
|
5562 }
|
|
5563 // Delegated event; lazy-add a change handler on descendant inputs
|
|
5564 jQuery.event.add( this, "beforeactivate._change", function( e ) {
|
|
5565 var elem = e.target;
|
|
5566
|
|
5567 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
|
|
5568 jQuery.event.add( elem, "change._change", function( event ) {
|
|
5569 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
|
|
5570 jQuery.event.simulate( "change", this.parentNode, event, true );
|
|
5571 }
|
|
5572 });
|
|
5573 jQuery._data( elem, "changeBubbles", true );
|
|
5574 }
|
|
5575 });
|
|
5576 },
|
|
5577
|
|
5578 handle: function( event ) {
|
|
5579 var elem = event.target;
|
|
5580
|
|
5581 // Swallow native change events from checkbox/radio, we already triggered them above
|
|
5582 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
|
|
5583 return event.handleObj.handler.apply( this, arguments );
|
|
5584 }
|
|
5585 },
|
|
5586
|
|
5587 teardown: function() {
|
|
5588 jQuery.event.remove( this, "._change" );
|
|
5589
|
|
5590 return !rformElems.test( this.nodeName );
|
|
5591 }
|
|
5592 };
|
|
5593 }
|
|
5594
|
|
5595 // Create "bubbling" focus and blur events
|
|
5596 if ( !jQuery.support.focusinBubbles ) {
|
|
5597 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
|
|
5598
|
|
5599 // Attach a single capturing handler while someone wants focusin/focusout
|
|
5600 var attaches = 0,
|
|
5601 handler = function( event ) {
|
|
5602 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
|
|
5603 };
|
|
5604
|
|
5605 jQuery.event.special[ fix ] = {
|
|
5606 setup: function() {
|
|
5607 if ( attaches++ === 0 ) {
|
|
5608 document.addEventListener( orig, handler, true );
|
|
5609 }
|
|
5610 },
|
|
5611 teardown: function() {
|
|
5612 if ( --attaches === 0 ) {
|
|
5613 document.removeEventListener( orig, handler, true );
|
|
5614 }
|
|
5615 }
|
|
5616 };
|
|
5617 });
|
|
5618 }
|
|
5619
|
|
5620 jQuery.fn.extend({
|
|
5621
|
|
5622 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
|
|
5623 var type, origFn;
|
|
5624
|
|
5625 // Types can be a map of types/handlers
|
|
5626 if ( typeof types === "object" ) {
|
|
5627 // ( types-Object, selector, data )
|
|
5628 if ( typeof selector !== "string" ) {
|
|
5629 // ( types-Object, data )
|
|
5630 data = data || selector;
|
|
5631 selector = undefined;
|
|
5632 }
|
|
5633 for ( type in types ) {
|
|
5634 this.on( type, selector, data, types[ type ], one );
|
|
5635 }
|
|
5636 return this;
|
|
5637 }
|
|
5638
|
|
5639 if ( data == null && fn == null ) {
|
|
5640 // ( types, fn )
|
|
5641 fn = selector;
|
|
5642 data = selector = undefined;
|
|
5643 } else if ( fn == null ) {
|
|
5644 if ( typeof selector === "string" ) {
|
|
5645 // ( types, selector, fn )
|
|
5646 fn = data;
|
|
5647 data = undefined;
|
|
5648 } else {
|
|
5649 // ( types, data, fn )
|
|
5650 fn = data;
|
|
5651 data = selector;
|
|
5652 selector = undefined;
|
|
5653 }
|
|
5654 }
|
|
5655 if ( fn === false ) {
|
|
5656 fn = returnFalse;
|
|
5657 } else if ( !fn ) {
|
|
5658 return this;
|
|
5659 }
|
|
5660
|
|
5661 if ( one === 1 ) {
|
|
5662 origFn = fn;
|
|
5663 fn = function( event ) {
|
|
5664 // Can use an empty set, since event contains the info
|
|
5665 jQuery().off( event );
|
|
5666 return origFn.apply( this, arguments );
|
|
5667 };
|
|
5668 // Use same guid so caller can remove using origFn
|
|
5669 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
|
|
5670 }
|
|
5671 return this.each( function() {
|
|
5672 jQuery.event.add( this, types, fn, data, selector );
|
|
5673 });
|
|
5674 },
|
|
5675 one: function( types, selector, data, fn ) {
|
|
5676 return this.on( types, selector, data, fn, 1 );
|
|
5677 },
|
|
5678 off: function( types, selector, fn ) {
|
|
5679 var handleObj, type;
|
|
5680 if ( types && types.preventDefault && types.handleObj ) {
|
|
5681 // ( event ) dispatched jQuery.Event
|
|
5682 handleObj = types.handleObj;
|
|
5683 jQuery( types.delegateTarget ).off(
|
|
5684 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
|
|
5685 handleObj.selector,
|
|
5686 handleObj.handler
|
|
5687 );
|
|
5688 return this;
|
|
5689 }
|
|
5690 if ( typeof types === "object" ) {
|
|
5691 // ( types-object [, selector] )
|
|
5692 for ( type in types ) {
|
|
5693 this.off( type, selector, types[ type ] );
|
|
5694 }
|
|
5695 return this;
|
|
5696 }
|
|
5697 if ( selector === false || typeof selector === "function" ) {
|
|
5698 // ( types [, fn] )
|
|
5699 fn = selector;
|
|
5700 selector = undefined;
|
|
5701 }
|
|
5702 if ( fn === false ) {
|
|
5703 fn = returnFalse;
|
|
5704 }
|
|
5705 return this.each(function() {
|
|
5706 jQuery.event.remove( this, types, fn, selector );
|
|
5707 });
|
|
5708 },
|
|
5709
|
|
5710 trigger: function( type, data ) {
|
|
5711 return this.each(function() {
|
|
5712 jQuery.event.trigger( type, data, this );
|
|
5713 });
|
|
5714 },
|
|
5715 triggerHandler: function( type, data ) {
|
|
5716 var elem = this[0];
|
|
5717 if ( elem ) {
|
|
5718 return jQuery.event.trigger( type, data, elem, true );
|
|
5719 }
|
|
5720 }
|
|
5721 });
|
|
5722 var isSimple = /^.[^:#\[\.,]*$/,
|
|
5723 rparentsprev = /^(?:parents|prev(?:Until|All))/,
|
|
5724 rneedsContext = jQuery.expr.match.needsContext,
|
|
5725 // methods guaranteed to produce a unique set when starting from a unique set
|
|
5726 guaranteedUnique = {
|
|
5727 children: true,
|
|
5728 contents: true,
|
|
5729 next: true,
|
|
5730 prev: true
|
|
5731 };
|
|
5732
|
|
5733 jQuery.fn.extend({
|
|
5734 find: function( selector ) {
|
|
5735 var i,
|
|
5736 ret = [],
|
|
5737 self = this,
|
|
5738 len = self.length;
|
|
5739
|
|
5740 if ( typeof selector !== "string" ) {
|
|
5741 return this.pushStack( jQuery( selector ).filter(function() {
|
|
5742 for ( i = 0; i < len; i++ ) {
|
|
5743 if ( jQuery.contains( self[ i ], this ) ) {
|
|
5744 return true;
|
|
5745 }
|
|
5746 }
|
|
5747 }) );
|
|
5748 }
|
|
5749
|
|
5750 for ( i = 0; i < len; i++ ) {
|
|
5751 jQuery.find( selector, self[ i ], ret );
|
|
5752 }
|
|
5753
|
|
5754 // Needed because $( selector, context ) becomes $( context ).find( selector )
|
|
5755 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
|
|
5756 ret.selector = this.selector ? this.selector + " " + selector : selector;
|
|
5757 return ret;
|
|
5758 },
|
|
5759
|
|
5760 has: function( target ) {
|
|
5761 var i,
|
|
5762 targets = jQuery( target, this ),
|
|
5763 len = targets.length;
|
|
5764
|
|
5765 return this.filter(function() {
|
|
5766 for ( i = 0; i < len; i++ ) {
|
|
5767 if ( jQuery.contains( this, targets[i] ) ) {
|
|
5768 return true;
|
|
5769 }
|
|
5770 }
|
|
5771 });
|
|
5772 },
|
|
5773
|
|
5774 not: function( selector ) {
|
|
5775 return this.pushStack( winnow(this, selector || [], true) );
|
|
5776 },
|
|
5777
|
|
5778 filter: function( selector ) {
|
|
5779 return this.pushStack( winnow(this, selector || [], false) );
|
|
5780 },
|
|
5781
|
|
5782 is: function( selector ) {
|
|
5783 return !!winnow(
|
|
5784 this,
|
|
5785
|
|
5786 // If this is a positional/relative selector, check membership in the returned set
|
|
5787 // so $("p:first").is("p:last") won't return true for a doc with two "p".
|
|
5788 typeof selector === "string" && rneedsContext.test( selector ) ?
|
|
5789 jQuery( selector ) :
|
|
5790 selector || [],
|
|
5791 false
|
|
5792 ).length;
|
|
5793 },
|
|
5794
|
|
5795 closest: function( selectors, context ) {
|
|
5796 var cur,
|
|
5797 i = 0,
|
|
5798 l = this.length,
|
|
5799 ret = [],
|
|
5800 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
|
|
5801 jQuery( selectors, context || this.context ) :
|
|
5802 0;
|
|
5803
|
|
5804 for ( ; i < l; i++ ) {
|
|
5805 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
|
|
5806 // Always skip document fragments
|
|
5807 if ( cur.nodeType < 11 && (pos ?
|
|
5808 pos.index(cur) > -1 :
|
|
5809
|
|
5810 // Don't pass non-elements to Sizzle
|
|
5811 cur.nodeType === 1 &&
|
|
5812 jQuery.find.matchesSelector(cur, selectors)) ) {
|
|
5813
|
|
5814 cur = ret.push( cur );
|
|
5815 break;
|
|
5816 }
|
|
5817 }
|
|
5818 }
|
|
5819
|
|
5820 return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret );
|
|
5821 },
|
|
5822
|
|
5823 // Determine the position of an element within
|
|
5824 // the matched set of elements
|
|
5825 index: function( elem ) {
|
|
5826
|
|
5827 // No argument, return index in parent
|
|
5828 if ( !elem ) {
|
|
5829 return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
|
|
5830 }
|
|
5831
|
|
5832 // index in selector
|
|
5833 if ( typeof elem === "string" ) {
|
|
5834 return jQuery.inArray( this[0], jQuery( elem ) );
|
|
5835 }
|
|
5836
|
|
5837 // Locate the position of the desired element
|
|
5838 return jQuery.inArray(
|
|
5839 // If it receives a jQuery object, the first element is used
|
|
5840 elem.jquery ? elem[0] : elem, this );
|
|
5841 },
|
|
5842
|
|
5843 add: function( selector, context ) {
|
|
5844 var set = typeof selector === "string" ?
|
|
5845 jQuery( selector, context ) :
|
|
5846 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
|
|
5847 all = jQuery.merge( this.get(), set );
|
|
5848
|
|
5849 return this.pushStack( jQuery.unique(all) );
|
|
5850 },
|
|
5851
|
|
5852 addBack: function( selector ) {
|
|
5853 return this.add( selector == null ?
|
|
5854 this.prevObject : this.prevObject.filter(selector)
|
|
5855 );
|
|
5856 }
|
|
5857 });
|
|
5858
|
|
5859 function sibling( cur, dir ) {
|
|
5860 do {
|
|
5861 cur = cur[ dir ];
|
|
5862 } while ( cur && cur.nodeType !== 1 );
|
|
5863
|
|
5864 return cur;
|
|
5865 }
|
|
5866
|
|
5867 jQuery.each({
|
|
5868 parent: function( elem ) {
|
|
5869 var parent = elem.parentNode;
|
|
5870 return parent && parent.nodeType !== 11 ? parent : null;
|
|
5871 },
|
|
5872 parents: function( elem ) {
|
|
5873 return jQuery.dir( elem, "parentNode" );
|
|
5874 },
|
|
5875 parentsUntil: function( elem, i, until ) {
|
|
5876 return jQuery.dir( elem, "parentNode", until );
|
|
5877 },
|
|
5878 next: function( elem ) {
|
|
5879 return sibling( elem, "nextSibling" );
|
|
5880 },
|
|
5881 prev: function( elem ) {
|
|
5882 return sibling( elem, "previousSibling" );
|
|
5883 },
|
|
5884 nextAll: function( elem ) {
|
|
5885 return jQuery.dir( elem, "nextSibling" );
|
|
5886 },
|
|
5887 prevAll: function( elem ) {
|
|
5888 return jQuery.dir( elem, "previousSibling" );
|
|
5889 },
|
|
5890 nextUntil: function( elem, i, until ) {
|
|
5891 return jQuery.dir( elem, "nextSibling", until );
|
|
5892 },
|
|
5893 prevUntil: function( elem, i, until ) {
|
|
5894 return jQuery.dir( elem, "previousSibling", until );
|
|
5895 },
|
|
5896 siblings: function( elem ) {
|
|
5897 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
|
|
5898 },
|
|
5899 children: function( elem ) {
|
|
5900 return jQuery.sibling( elem.firstChild );
|
|
5901 },
|
|
5902 contents: function( elem ) {
|
|
5903 return jQuery.nodeName( elem, "iframe" ) ?
|
|
5904 elem.contentDocument || elem.contentWindow.document :
|
|
5905 jQuery.merge( [], elem.childNodes );
|
|
5906 }
|
|
5907 }, function( name, fn ) {
|
|
5908 jQuery.fn[ name ] = function( until, selector ) {
|
|
5909 var ret = jQuery.map( this, fn, until );
|
|
5910
|
|
5911 if ( name.slice( -5 ) !== "Until" ) {
|
|
5912 selector = until;
|
|
5913 }
|
|
5914
|
|
5915 if ( selector && typeof selector === "string" ) {
|
|
5916 ret = jQuery.filter( selector, ret );
|
|
5917 }
|
|
5918
|
|
5919 if ( this.length > 1 ) {
|
|
5920 // Remove duplicates
|
|
5921 if ( !guaranteedUnique[ name ] ) {
|
|
5922 ret = jQuery.unique( ret );
|
|
5923 }
|
|
5924
|
|
5925 // Reverse order for parents* and prev-derivatives
|
|
5926 if ( rparentsprev.test( name ) ) {
|
|
5927 ret = ret.reverse();
|
|
5928 }
|
|
5929 }
|
|
5930
|
|
5931 return this.pushStack( ret );
|
|
5932 };
|
|
5933 });
|
|
5934
|
|
5935 jQuery.extend({
|
|
5936 filter: function( expr, elems, not ) {
|
|
5937 var elem = elems[ 0 ];
|
|
5938
|
|
5939 if ( not ) {
|
|
5940 expr = ":not(" + expr + ")";
|
|
5941 }
|
|
5942
|
|
5943 return elems.length === 1 && elem.nodeType === 1 ?
|
|
5944 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
|
|
5945 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
|
|
5946 return elem.nodeType === 1;
|
|
5947 }));
|
|
5948 },
|
|
5949
|
|
5950 dir: function( elem, dir, until ) {
|
|
5951 var matched = [],
|
|
5952 cur = elem[ dir ];
|
|
5953
|
|
5954 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
|
|
5955 if ( cur.nodeType === 1 ) {
|
|
5956 matched.push( cur );
|
|
5957 }
|
|
5958 cur = cur[dir];
|
|
5959 }
|
|
5960 return matched;
|
|
5961 },
|
|
5962
|
|
5963 sibling: function( n, elem ) {
|
|
5964 var r = [];
|
|
5965
|
|
5966 for ( ; n; n = n.nextSibling ) {
|
|
5967 if ( n.nodeType === 1 && n !== elem ) {
|
|
5968 r.push( n );
|
|
5969 }
|
|
5970 }
|
|
5971
|
|
5972 return r;
|
|
5973 }
|
|
5974 });
|
|
5975
|
|
5976 // Implement the identical functionality for filter and not
|
|
5977 function winnow( elements, qualifier, not ) {
|
|
5978 if ( jQuery.isFunction( qualifier ) ) {
|
|
5979 return jQuery.grep( elements, function( elem, i ) {
|
|
5980 /* jshint -W018 */
|
|
5981 return !!qualifier.call( elem, i, elem ) !== not;
|
|
5982 });
|
|
5983
|
|
5984 }
|
|
5985
|
|
5986 if ( qualifier.nodeType ) {
|
|
5987 return jQuery.grep( elements, function( elem ) {
|
|
5988 return ( elem === qualifier ) !== not;
|
|
5989 });
|
|
5990
|
|
5991 }
|
|
5992
|
|
5993 if ( typeof qualifier === "string" ) {
|
|
5994 if ( isSimple.test( qualifier ) ) {
|
|
5995 return jQuery.filter( qualifier, elements, not );
|
|
5996 }
|
|
5997
|
|
5998 qualifier = jQuery.filter( qualifier, elements );
|
|
5999 }
|
|
6000
|
|
6001 return jQuery.grep( elements, function( elem ) {
|
|
6002 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
|
|
6003 });
|
|
6004 }
|
|
6005 function createSafeFragment( document ) {
|
|
6006 var list = nodeNames.split( "|" ),
|
|
6007 safeFrag = document.createDocumentFragment();
|
|
6008
|
|
6009 if ( safeFrag.createElement ) {
|
|
6010 while ( list.length ) {
|
|
6011 safeFrag.createElement(
|
|
6012 list.pop()
|
|
6013 );
|
|
6014 }
|
|
6015 }
|
|
6016 return safeFrag;
|
|
6017 }
|
|
6018
|
|
6019 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
|
|
6020 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
|
|
6021 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
|
|
6022 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
|
|
6023 rleadingWhitespace = /^\s+/,
|
|
6024 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
|
|
6025 rtagName = /<([\w:]+)/,
|
|
6026 rtbody = /<tbody/i,
|
|
6027 rhtml = /<|&#?\w+;/,
|
|
6028 rnoInnerhtml = /<(?:script|style|link)/i,
|
|
6029 manipulation_rcheckableType = /^(?:checkbox|radio)$/i,
|
|
6030 // checked="checked" or checked
|
|
6031 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
|
|
6032 rscriptType = /^$|\/(?:java|ecma)script/i,
|
|
6033 rscriptTypeMasked = /^true\/(.*)/,
|
|
6034 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
|
|
6035
|
|
6036 // We have to close these tags to support XHTML (#13200)
|
|
6037 wrapMap = {
|
|
6038 option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
|
6039 legend: [ 1, "<fieldset>", "</fieldset>" ],
|
|
6040 area: [ 1, "<map>", "</map>" ],
|
|
6041 param: [ 1, "<object>", "</object>" ],
|
|
6042 thead: [ 1, "<table>", "</table>" ],
|
|
6043 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
|
|
6044 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
|
|
6045 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
|
|
6046
|
|
6047 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
|
|
6048 // unless wrapped in a div with non-breaking characters in front of it.
|
|
6049 _default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
|
|
6050 },
|
|
6051 safeFragment = createSafeFragment( document ),
|
|
6052 fragmentDiv = safeFragment.appendChild( document.createElement("div") );
|
|
6053
|
|
6054 wrapMap.optgroup = wrapMap.option;
|
|
6055 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
|
6056 wrapMap.th = wrapMap.td;
|
|
6057
|
|
6058 jQuery.fn.extend({
|
|
6059 text: function( value ) {
|
|
6060 return jQuery.access( this, function( value ) {
|
|
6061 return value === undefined ?
|
|
6062 jQuery.text( this ) :
|
|
6063 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
|
|
6064 }, null, value, arguments.length );
|
|
6065 },
|
|
6066
|
|
6067 append: 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.appendChild( elem );
|
|
6072 }
|
|
6073 });
|
|
6074 },
|
|
6075
|
|
6076 prepend: function() {
|
|
6077 return this.domManip( arguments, function( elem ) {
|
|
6078 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
|
6079 var target = manipulationTarget( this, elem );
|
|
6080 target.insertBefore( elem, target.firstChild );
|
|
6081 }
|
|
6082 });
|
|
6083 },
|
|
6084
|
|
6085 before: function() {
|
|
6086 return this.domManip( arguments, function( elem ) {
|
|
6087 if ( this.parentNode ) {
|
|
6088 this.parentNode.insertBefore( elem, this );
|
|
6089 }
|
|
6090 });
|
|
6091 },
|
|
6092
|
|
6093 after: function() {
|
|
6094 return this.domManip( arguments, function( elem ) {
|
|
6095 if ( this.parentNode ) {
|
|
6096 this.parentNode.insertBefore( elem, this.nextSibling );
|
|
6097 }
|
|
6098 });
|
|
6099 },
|
|
6100
|
|
6101 // keepData is for internal use only--do not document
|
|
6102 remove: function( selector, keepData ) {
|
|
6103 var elem,
|
|
6104 elems = selector ? jQuery.filter( selector, this ) : this,
|
|
6105 i = 0;
|
|
6106
|
|
6107 for ( ; (elem = elems[i]) != null; i++ ) {
|
|
6108
|
|
6109 if ( !keepData && elem.nodeType === 1 ) {
|
|
6110 jQuery.cleanData( getAll( elem ) );
|
|
6111 }
|
|
6112
|
|
6113 if ( elem.parentNode ) {
|
|
6114 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
|
|
6115 setGlobalEval( getAll( elem, "script" ) );
|
|
6116 }
|
|
6117 elem.parentNode.removeChild( elem );
|
|
6118 }
|
|
6119 }
|
|
6120
|
|
6121 return this;
|
|
6122 },
|
|
6123
|
|
6124 empty: function() {
|
|
6125 var elem,
|
|
6126 i = 0;
|
|
6127
|
|
6128 for ( ; (elem = this[i]) != null; i++ ) {
|
|
6129 // Remove element nodes and prevent memory leaks
|
|
6130 if ( elem.nodeType === 1 ) {
|
|
6131 jQuery.cleanData( getAll( elem, false ) );
|
|
6132 }
|
|
6133
|
|
6134 // Remove any remaining nodes
|
|
6135 while ( elem.firstChild ) {
|
|
6136 elem.removeChild( elem.firstChild );
|
|
6137 }
|
|
6138
|
|
6139 // If this is a select, ensure that it displays empty (#12336)
|
|
6140 // Support: IE<9
|
|
6141 if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
|
|
6142 elem.options.length = 0;
|
|
6143 }
|
|
6144 }
|
|
6145
|
|
6146 return this;
|
|
6147 },
|
|
6148
|
|
6149 clone: function( dataAndEvents, deepDataAndEvents ) {
|
|
6150 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
|
|
6151 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
|
|
6152
|
|
6153 return this.map( function () {
|
|
6154 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
|
|
6155 });
|
|
6156 },
|
|
6157
|
|
6158 html: function( value ) {
|
|
6159 return jQuery.access( this, function( value ) {
|
|
6160 var elem = this[0] || {},
|
|
6161 i = 0,
|
|
6162 l = this.length;
|
|
6163
|
|
6164 if ( value === undefined ) {
|
|
6165 return elem.nodeType === 1 ?
|
|
6166 elem.innerHTML.replace( rinlinejQuery, "" ) :
|
|
6167 undefined;
|
|
6168 }
|
|
6169
|
|
6170 // See if we can take a shortcut and just use innerHTML
|
|
6171 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
|
|
6172 ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
|
|
6173 ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
|
|
6174 !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
|
|
6175
|
|
6176 value = value.replace( rxhtmlTag, "<$1></$2>" );
|
|
6177
|
|
6178 try {
|
|
6179 for (; i < l; i++ ) {
|
|
6180 // Remove element nodes and prevent memory leaks
|
|
6181 elem = this[i] || {};
|
|
6182 if ( elem.nodeType === 1 ) {
|
|
6183 jQuery.cleanData( getAll( elem, false ) );
|
|
6184 elem.innerHTML = value;
|
|
6185 }
|
|
6186 }
|
|
6187
|
|
6188 elem = 0;
|
|
6189
|
|
6190 // If using innerHTML throws an exception, use the fallback method
|
|
6191 } catch(e) {}
|
|
6192 }
|
|
6193
|
|
6194 if ( elem ) {
|
|
6195 this.empty().append( value );
|
|
6196 }
|
|
6197 }, null, value, arguments.length );
|
|
6198 },
|
|
6199
|
|
6200 replaceWith: function() {
|
|
6201 var
|
|
6202 // Snapshot the DOM in case .domManip sweeps something relevant into its fragment
|
|
6203 args = jQuery.map( this, function( elem ) {
|
|
6204 return [ elem.nextSibling, elem.parentNode ];
|
|
6205 }),
|
|
6206 i = 0;
|
|
6207
|
|
6208 // Make the changes, replacing each context element with the new content
|
|
6209 this.domManip( arguments, function( elem ) {
|
|
6210 var next = args[ i++ ],
|
|
6211 parent = args[ i++ ];
|
|
6212
|
|
6213 if ( parent ) {
|
|
6214 // Don't use the snapshot next if it has moved (#13810)
|
|
6215 if ( next && next.parentNode !== parent ) {
|
|
6216 next = this.nextSibling;
|
|
6217 }
|
|
6218 jQuery( this ).remove();
|
|
6219 parent.insertBefore( elem, next );
|
|
6220 }
|
|
6221 // Allow new content to include elements from the context set
|
|
6222 }, true );
|
|
6223
|
|
6224 // Force removal if there was no new content (e.g., from empty arguments)
|
|
6225 return i ? this : this.remove();
|
|
6226 },
|
|
6227
|
|
6228 detach: function( selector ) {
|
|
6229 return this.remove( selector, true );
|
|
6230 },
|
|
6231
|
|
6232 domManip: function( args, callback, allowIntersection ) {
|
|
6233
|
|
6234 // Flatten any nested arrays
|
|
6235 args = core_concat.apply( [], args );
|
|
6236
|
|
6237 var first, node, hasScripts,
|
|
6238 scripts, doc, fragment,
|
|
6239 i = 0,
|
|
6240 l = this.length,
|
|
6241 set = this,
|
|
6242 iNoClone = l - 1,
|
|
6243 value = args[0],
|
|
6244 isFunction = jQuery.isFunction( value );
|
|
6245
|
|
6246 // We can't cloneNode fragments that contain checked, in WebKit
|
|
6247 if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) {
|
|
6248 return this.each(function( index ) {
|
|
6249 var self = set.eq( index );
|
|
6250 if ( isFunction ) {
|
|
6251 args[0] = value.call( this, index, self.html() );
|
|
6252 }
|
|
6253 self.domManip( args, callback, allowIntersection );
|
|
6254 });
|
|
6255 }
|
|
6256
|
|
6257 if ( l ) {
|
|
6258 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this );
|
|
6259 first = fragment.firstChild;
|
|
6260
|
|
6261 if ( fragment.childNodes.length === 1 ) {
|
|
6262 fragment = first;
|
|
6263 }
|
|
6264
|
|
6265 if ( first ) {
|
|
6266 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
|
|
6267 hasScripts = scripts.length;
|
|
6268
|
|
6269 // Use the original fragment for the last item instead of the first because it can end up
|
|
6270 // being emptied incorrectly in certain situations (#8070).
|
|
6271 for ( ; i < l; i++ ) {
|
|
6272 node = fragment;
|
|
6273
|
|
6274 if ( i !== iNoClone ) {
|
|
6275 node = jQuery.clone( node, true, true );
|
|
6276
|
|
6277 // Keep references to cloned scripts for later restoration
|
|
6278 if ( hasScripts ) {
|
|
6279 jQuery.merge( scripts, getAll( node, "script" ) );
|
|
6280 }
|
|
6281 }
|
|
6282
|
|
6283 callback.call( this[i], node, i );
|
|
6284 }
|
|
6285
|
|
6286 if ( hasScripts ) {
|
|
6287 doc = scripts[ scripts.length - 1 ].ownerDocument;
|
|
6288
|
|
6289 // Reenable scripts
|
|
6290 jQuery.map( scripts, restoreScript );
|
|
6291
|
|
6292 // Evaluate executable scripts on first document insertion
|
|
6293 for ( i = 0; i < hasScripts; i++ ) {
|
|
6294 node = scripts[ i ];
|
|
6295 if ( rscriptType.test( node.type || "" ) &&
|
|
6296 !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
|
|
6297
|
|
6298 if ( node.src ) {
|
|
6299 // Hope ajax is available...
|
|
6300 jQuery._evalUrl( node.src );
|
|
6301 } else {
|
|
6302 jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
|
|
6303 }
|
|
6304 }
|
|
6305 }
|
|
6306 }
|
|
6307
|
|
6308 // Fix #11809: Avoid leaking memory
|
|
6309 fragment = first = null;
|
|
6310 }
|
|
6311 }
|
|
6312
|
|
6313 return this;
|
|
6314 }
|
|
6315 });
|
|
6316
|
|
6317 // Support: IE<8
|
|
6318 // Manipulating tables requires a tbody
|
|
6319 function manipulationTarget( elem, content ) {
|
|
6320 return jQuery.nodeName( elem, "table" ) &&
|
|
6321 jQuery.nodeName( content.nodeType === 1 ? content : content.firstChild, "tr" ) ?
|
|
6322
|
|
6323 elem.getElementsByTagName("tbody")[0] ||
|
|
6324 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
|
|
6325 elem;
|
|
6326 }
|
|
6327
|
|
6328 // Replace/restore the type attribute of script elements for safe DOM manipulation
|
|
6329 function disableScript( elem ) {
|
|
6330 elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
|
|
6331 return elem;
|
|
6332 }
|
|
6333 function restoreScript( elem ) {
|
|
6334 var match = rscriptTypeMasked.exec( elem.type );
|
|
6335 if ( match ) {
|
|
6336 elem.type = match[1];
|
|
6337 } else {
|
|
6338 elem.removeAttribute("type");
|
|
6339 }
|
|
6340 return elem;
|
|
6341 }
|
|
6342
|
|
6343 // Mark scripts as having already been evaluated
|
|
6344 function setGlobalEval( elems, refElements ) {
|
|
6345 var elem,
|
|
6346 i = 0;
|
|
6347 for ( ; (elem = elems[i]) != null; i++ ) {
|
|
6348 jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
|
|
6349 }
|
|
6350 }
|
|
6351
|
|
6352 function cloneCopyEvent( src, dest ) {
|
|
6353
|
|
6354 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
|
|
6355 return;
|
|
6356 }
|
|
6357
|
|
6358 var type, i, l,
|
|
6359 oldData = jQuery._data( src ),
|
|
6360 curData = jQuery._data( dest, oldData ),
|
|
6361 events = oldData.events;
|
|
6362
|
|
6363 if ( events ) {
|
|
6364 delete curData.handle;
|
|
6365 curData.events = {};
|
|
6366
|
|
6367 for ( type in events ) {
|
|
6368 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
|
|
6369 jQuery.event.add( dest, type, events[ type ][ i ] );
|
|
6370 }
|
|
6371 }
|
|
6372 }
|
|
6373
|
|
6374 // make the cloned public data object a copy from the original
|
|
6375 if ( curData.data ) {
|
|
6376 curData.data = jQuery.extend( {}, curData.data );
|
|
6377 }
|
|
6378 }
|
|
6379
|
|
6380 function fixCloneNodeIssues( src, dest ) {
|
|
6381 var nodeName, e, data;
|
|
6382
|
|
6383 // We do not need to do anything for non-Elements
|
|
6384 if ( dest.nodeType !== 1 ) {
|
|
6385 return;
|
|
6386 }
|
|
6387
|
|
6388 nodeName = dest.nodeName.toLowerCase();
|
|
6389
|
|
6390 // IE6-8 copies events bound via attachEvent when using cloneNode.
|
|
6391 if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) {
|
|
6392 data = jQuery._data( dest );
|
|
6393
|
|
6394 for ( e in data.events ) {
|
|
6395 jQuery.removeEvent( dest, e, data.handle );
|
|
6396 }
|
|
6397
|
|
6398 // Event data gets referenced instead of copied if the expando gets copied too
|
|
6399 dest.removeAttribute( jQuery.expando );
|
|
6400 }
|
|
6401
|
|
6402 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
|
|
6403 if ( nodeName === "script" && dest.text !== src.text ) {
|
|
6404 disableScript( dest ).text = src.text;
|
|
6405 restoreScript( dest );
|
|
6406
|
|
6407 // IE6-10 improperly clones children of object elements using classid.
|
|
6408 // IE10 throws NoModificationAllowedError if parent is null, #12132.
|
|
6409 } else if ( nodeName === "object" ) {
|
|
6410 if ( dest.parentNode ) {
|
|
6411 dest.outerHTML = src.outerHTML;
|
|
6412 }
|
|
6413
|
|
6414 // This path appears unavoidable for IE9. When cloning an object
|
|
6415 // element in IE9, the outerHTML strategy above is not sufficient.
|
|
6416 // If the src has innerHTML and the destination does not,
|
|
6417 // copy the src.innerHTML into the dest.innerHTML. #10324
|
|
6418 if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
|
|
6419 dest.innerHTML = src.innerHTML;
|
|
6420 }
|
|
6421
|
|
6422 } else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) {
|
|
6423 // IE6-8 fails to persist the checked state of a cloned checkbox
|
|
6424 // or radio button. Worse, IE6-7 fail to give the cloned element
|
|
6425 // a checked appearance if the defaultChecked value isn't also set
|
|
6426
|
|
6427 dest.defaultChecked = dest.checked = src.checked;
|
|
6428
|
|
6429 // IE6-7 get confused and end up setting the value of a cloned
|
|
6430 // checkbox/radio button to an empty string instead of "on"
|
|
6431 if ( dest.value !== src.value ) {
|
|
6432 dest.value = src.value;
|
|
6433 }
|
|
6434
|
|
6435 // IE6-8 fails to return the selected option to the default selected
|
|
6436 // state when cloning options
|
|
6437 } else if ( nodeName === "option" ) {
|
|
6438 dest.defaultSelected = dest.selected = src.defaultSelected;
|
|
6439
|
|
6440 // IE6-8 fails to set the defaultValue to the correct value when
|
|
6441 // cloning other types of input fields
|
|
6442 } else if ( nodeName === "input" || nodeName === "textarea" ) {
|
|
6443 dest.defaultValue = src.defaultValue;
|
|
6444 }
|
|
6445 }
|
|
6446
|
|
6447 jQuery.each({
|
|
6448 appendTo: "append",
|
|
6449 prependTo: "prepend",
|
|
6450 insertBefore: "before",
|
|
6451 insertAfter: "after",
|
|
6452 replaceAll: "replaceWith"
|
|
6453 }, function( name, original ) {
|
|
6454 jQuery.fn[ name ] = function( selector ) {
|
|
6455 var elems,
|
|
6456 i = 0,
|
|
6457 ret = [],
|
|
6458 insert = jQuery( selector ),
|
|
6459 last = insert.length - 1;
|
|
6460
|
|
6461 for ( ; i <= last; i++ ) {
|
|
6462 elems = i === last ? this : this.clone(true);
|
|
6463 jQuery( insert[i] )[ original ]( elems );
|
|
6464
|
|
6465 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
|
|
6466 core_push.apply( ret, elems.get() );
|
|
6467 }
|
|
6468
|
|
6469 return this.pushStack( ret );
|
|
6470 };
|
|
6471 });
|
|
6472
|
|
6473 function getAll( context, tag ) {
|
|
6474 var elems, elem,
|
|
6475 i = 0,
|
|
6476 found = typeof context.getElementsByTagName !== core_strundefined ? context.getElementsByTagName( tag || "*" ) :
|
|
6477 typeof context.querySelectorAll !== core_strundefined ? context.querySelectorAll( tag || "*" ) :
|
|
6478 undefined;
|
|
6479
|
|
6480 if ( !found ) {
|
|
6481 for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
|
|
6482 if ( !tag || jQuery.nodeName( elem, tag ) ) {
|
|
6483 found.push( elem );
|
|
6484 } else {
|
|
6485 jQuery.merge( found, getAll( elem, tag ) );
|
|
6486 }
|
|
6487 }
|
|
6488 }
|
|
6489
|
|
6490 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
|
|
6491 jQuery.merge( [ context ], found ) :
|
|
6492 found;
|
|
6493 }
|
|
6494
|
|
6495 // Used in buildFragment, fixes the defaultChecked property
|
|
6496 function fixDefaultChecked( elem ) {
|
|
6497 if ( manipulation_rcheckableType.test( elem.type ) ) {
|
|
6498 elem.defaultChecked = elem.checked;
|
|
6499 }
|
|
6500 }
|
|
6501
|
|
6502 jQuery.extend({
|
|
6503 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
|
6504 var destElements, node, clone, i, srcElements,
|
|
6505 inPage = jQuery.contains( elem.ownerDocument, elem );
|
|
6506
|
|
6507 if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
|
|
6508 clone = elem.cloneNode( true );
|
|
6509
|
|
6510 // IE<=8 does not properly clone detached, unknown element nodes
|
|
6511 } else {
|
|
6512 fragmentDiv.innerHTML = elem.outerHTML;
|
|
6513 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
|
|
6514 }
|
|
6515
|
|
6516 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
|
|
6517 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
|
|
6518
|
|
6519 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
|
|
6520 destElements = getAll( clone );
|
|
6521 srcElements = getAll( elem );
|
|
6522
|
|
6523 // Fix all IE cloning issues
|
|
6524 for ( i = 0; (node = srcElements[i]) != null; ++i ) {
|
|
6525 // Ensure that the destination node is not null; Fixes #9587
|
|
6526 if ( destElements[i] ) {
|
|
6527 fixCloneNodeIssues( node, destElements[i] );
|
|
6528 }
|
|
6529 }
|
|
6530 }
|
|
6531
|
|
6532 // Copy the events from the original to the clone
|
|
6533 if ( dataAndEvents ) {
|
|
6534 if ( deepDataAndEvents ) {
|
|
6535 srcElements = srcElements || getAll( elem );
|
|
6536 destElements = destElements || getAll( clone );
|
|
6537
|
|
6538 for ( i = 0; (node = srcElements[i]) != null; i++ ) {
|
|
6539 cloneCopyEvent( node, destElements[i] );
|
|
6540 }
|
|
6541 } else {
|
|
6542 cloneCopyEvent( elem, clone );
|
|
6543 }
|
|
6544 }
|
|
6545
|
|
6546 // Preserve script evaluation history
|
|
6547 destElements = getAll( clone, "script" );
|
|
6548 if ( destElements.length > 0 ) {
|
|
6549 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
|
|
6550 }
|
|
6551
|
|
6552 destElements = srcElements = node = null;
|
|
6553
|
|
6554 // Return the cloned set
|
|
6555 return clone;
|
|
6556 },
|
|
6557
|
|
6558 buildFragment: function( elems, context, scripts, selection ) {
|
|
6559 var j, elem, contains,
|
|
6560 tmp, tag, tbody, wrap,
|
|
6561 l = elems.length,
|
|
6562
|
|
6563 // Ensure a safe fragment
|
|
6564 safe = createSafeFragment( context ),
|
|
6565
|
|
6566 nodes = [],
|
|
6567 i = 0;
|
|
6568
|
|
6569 for ( ; i < l; i++ ) {
|
|
6570 elem = elems[ i ];
|
|
6571
|
|
6572 if ( elem || elem === 0 ) {
|
|
6573
|
|
6574 // Add nodes directly
|
|
6575 if ( jQuery.type( elem ) === "object" ) {
|
|
6576 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
|
|
6577
|
|
6578 // Convert non-html into a text node
|
|
6579 } else if ( !rhtml.test( elem ) ) {
|
|
6580 nodes.push( context.createTextNode( elem ) );
|
|
6581
|
|
6582 // Convert html into DOM nodes
|
|
6583 } else {
|
|
6584 tmp = tmp || safe.appendChild( context.createElement("div") );
|
|
6585
|
|
6586 // Deserialize a standard representation
|
|
6587 tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
|
|
6588 wrap = wrapMap[ tag ] || wrapMap._default;
|
|
6589
|
|
6590 tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
|
|
6591
|
|
6592 // Descend through wrappers to the right content
|
|
6593 j = wrap[0];
|
|
6594 while ( j-- ) {
|
|
6595 tmp = tmp.lastChild;
|
|
6596 }
|
|
6597
|
|
6598 // Manually add leading whitespace removed by IE
|
|
6599 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
|
|
6600 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
|
|
6601 }
|
|
6602
|
|
6603 // Remove IE's autoinserted <tbody> from table fragments
|
|
6604 if ( !jQuery.support.tbody ) {
|
|
6605
|
|
6606 // String was a <table>, *may* have spurious <tbody>
|
|
6607 elem = tag === "table" && !rtbody.test( elem ) ?
|
|
6608 tmp.firstChild :
|
|
6609
|
|
6610 // String was a bare <thead> or <tfoot>
|
|
6611 wrap[1] === "<table>" && !rtbody.test( elem ) ?
|
|
6612 tmp :
|
|
6613 0;
|
|
6614
|
|
6615 j = elem && elem.childNodes.length;
|
|
6616 while ( j-- ) {
|
|
6617 if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
|
|
6618 elem.removeChild( tbody );
|
|
6619 }
|
|
6620 }
|
|
6621 }
|
|
6622
|
|
6623 jQuery.merge( nodes, tmp.childNodes );
|
|
6624
|
|
6625 // Fix #12392 for WebKit and IE > 9
|
|
6626 tmp.textContent = "";
|
|
6627
|
|
6628 // Fix #12392 for oldIE
|
|
6629 while ( tmp.firstChild ) {
|
|
6630 tmp.removeChild( tmp.firstChild );
|
|
6631 }
|
|
6632
|
|
6633 // Remember the top-level container for proper cleanup
|
|
6634 tmp = safe.lastChild;
|
|
6635 }
|
|
6636 }
|
|
6637 }
|
|
6638
|
|
6639 // Fix #11356: Clear elements from fragment
|
|
6640 if ( tmp ) {
|
|
6641 safe.removeChild( tmp );
|
|
6642 }
|
|
6643
|
|
6644 // Reset defaultChecked for any radios and checkboxes
|
|
6645 // about to be appended to the DOM in IE 6/7 (#8060)
|
|
6646 if ( !jQuery.support.appendChecked ) {
|
|
6647 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
|
|
6648 }
|
|
6649
|
|
6650 i = 0;
|
|
6651 while ( (elem = nodes[ i++ ]) ) {
|
|
6652
|
|
6653 // #4087 - If origin and destination elements are the same, and this is
|
|
6654 // that element, do not do anything
|
|
6655 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
|
|
6656 continue;
|
|
6657 }
|
|
6658
|
|
6659 contains = jQuery.contains( elem.ownerDocument, elem );
|
|
6660
|
|
6661 // Append to fragment
|
|
6662 tmp = getAll( safe.appendChild( elem ), "script" );
|
|
6663
|
|
6664 // Preserve script evaluation history
|
|
6665 if ( contains ) {
|
|
6666 setGlobalEval( tmp );
|
|
6667 }
|
|
6668
|
|
6669 // Capture executables
|
|
6670 if ( scripts ) {
|
|
6671 j = 0;
|
|
6672 while ( (elem = tmp[ j++ ]) ) {
|
|
6673 if ( rscriptType.test( elem.type || "" ) ) {
|
|
6674 scripts.push( elem );
|
|
6675 }
|
|
6676 }
|
|
6677 }
|
|
6678 }
|
|
6679
|
|
6680 tmp = null;
|
|
6681
|
|
6682 return safe;
|
|
6683 },
|
|
6684
|
|
6685 cleanData: function( elems, /* internal */ acceptData ) {
|
|
6686 var elem, type, id, data,
|
|
6687 i = 0,
|
|
6688 internalKey = jQuery.expando,
|
|
6689 cache = jQuery.cache,
|
|
6690 deleteExpando = jQuery.support.deleteExpando,
|
|
6691 special = jQuery.event.special;
|
|
6692
|
|
6693 for ( ; (elem = elems[i]) != null; i++ ) {
|
|
6694
|
|
6695 if ( acceptData || jQuery.acceptData( elem ) ) {
|
|
6696
|
|
6697 id = elem[ internalKey ];
|
|
6698 data = id && cache[ id ];
|
|
6699
|
|
6700 if ( data ) {
|
|
6701 if ( data.events ) {
|
|
6702 for ( type in data.events ) {
|
|
6703 if ( special[ type ] ) {
|
|
6704 jQuery.event.remove( elem, type );
|
|
6705
|
|
6706 // This is a shortcut to avoid jQuery.event.remove's overhead
|
|
6707 } else {
|
|
6708 jQuery.removeEvent( elem, type, data.handle );
|
|
6709 }
|
|
6710 }
|
|
6711 }
|
|
6712
|
|
6713 // Remove cache only if it was not already removed by jQuery.event.remove
|
|
6714 if ( cache[ id ] ) {
|
|
6715
|
|
6716 delete cache[ id ];
|
|
6717
|
|
6718 // IE does not allow us to delete expando properties from nodes,
|
|
6719 // nor does it have a removeAttribute function on Document nodes;
|
|
6720 // we must handle all of these cases
|
|
6721 if ( deleteExpando ) {
|
|
6722 delete elem[ internalKey ];
|
|
6723
|
|
6724 } else if ( typeof elem.removeAttribute !== core_strundefined ) {
|
|
6725 elem.removeAttribute( internalKey );
|
|
6726
|
|
6727 } else {
|
|
6728 elem[ internalKey ] = null;
|
|
6729 }
|
|
6730
|
|
6731 core_deletedIds.push( id );
|
|
6732 }
|
|
6733 }
|
|
6734 }
|
|
6735 }
|
|
6736 },
|
|
6737
|
|
6738 _evalUrl: function( url ) {
|
|
6739 return jQuery.ajax({
|
|
6740 url: url,
|
|
6741 type: "GET",
|
|
6742 dataType: "script",
|
|
6743 async: false,
|
|
6744 global: false,
|
|
6745 "throws": true
|
|
6746 });
|
|
6747 }
|
|
6748 });
|
|
6749 jQuery.fn.extend({
|
|
6750 wrapAll: function( html ) {
|
|
6751 if ( jQuery.isFunction( html ) ) {
|
|
6752 return this.each(function(i) {
|
|
6753 jQuery(this).wrapAll( html.call(this, i) );
|
|
6754 });
|
|
6755 }
|
|
6756
|
|
6757 if ( this[0] ) {
|
|
6758 // The elements to wrap the target around
|
|
6759 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
|
|
6760
|
|
6761 if ( this[0].parentNode ) {
|
|
6762 wrap.insertBefore( this[0] );
|
|
6763 }
|
|
6764
|
|
6765 wrap.map(function() {
|
|
6766 var elem = this;
|
|
6767
|
|
6768 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
|
|
6769 elem = elem.firstChild;
|
|
6770 }
|
|
6771
|
|
6772 return elem;
|
|
6773 }).append( this );
|
|
6774 }
|
|
6775
|
|
6776 return this;
|
|
6777 },
|
|
6778
|
|
6779 wrapInner: function( html ) {
|
|
6780 if ( jQuery.isFunction( html ) ) {
|
|
6781 return this.each(function(i) {
|
|
6782 jQuery(this).wrapInner( html.call(this, i) );
|
|
6783 });
|
|
6784 }
|
|
6785
|
|
6786 return this.each(function() {
|
|
6787 var self = jQuery( this ),
|
|
6788 contents = self.contents();
|
|
6789
|
|
6790 if ( contents.length ) {
|
|
6791 contents.wrapAll( html );
|
|
6792
|
|
6793 } else {
|
|
6794 self.append( html );
|
|
6795 }
|
|
6796 });
|
|
6797 },
|
|
6798
|
|
6799 wrap: function( html ) {
|
|
6800 var isFunction = jQuery.isFunction( html );
|
|
6801
|
|
6802 return this.each(function(i) {
|
|
6803 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
|
|
6804 });
|
|
6805 },
|
|
6806
|
|
6807 unwrap: function() {
|
|
6808 return this.parent().each(function() {
|
|
6809 if ( !jQuery.nodeName( this, "body" ) ) {
|
|
6810 jQuery( this ).replaceWith( this.childNodes );
|
|
6811 }
|
|
6812 }).end();
|
|
6813 }
|
|
6814 });
|
|
6815 var iframe, getStyles, curCSS,
|
|
6816 ralpha = /alpha\([^)]*\)/i,
|
|
6817 ropacity = /opacity\s*=\s*([^)]*)/,
|
|
6818 rposition = /^(top|right|bottom|left)$/,
|
|
6819 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
|
|
6820 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
|
|
6821 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
|
|
6822 rmargin = /^margin/,
|
|
6823 rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
|
|
6824 rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
|
|
6825 rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ),
|
|
6826 elemdisplay = { BODY: "block" },
|
|
6827
|
|
6828 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
|
|
6829 cssNormalTransform = {
|
|
6830 letterSpacing: 0,
|
|
6831 fontWeight: 400
|
|
6832 },
|
|
6833
|
|
6834 cssExpand = [ "Top", "Right", "Bottom", "Left" ],
|
|
6835 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
|
|
6836
|
|
6837 // return a css property mapped to a potentially vendor prefixed property
|
|
6838 function vendorPropName( style, name ) {
|
|
6839
|
|
6840 // shortcut for names that are not vendor prefixed
|
|
6841 if ( name in style ) {
|
|
6842 return name;
|
|
6843 }
|
|
6844
|
|
6845 // check for vendor prefixed names
|
|
6846 var capName = name.charAt(0).toUpperCase() + name.slice(1),
|
|
6847 origName = name,
|
|
6848 i = cssPrefixes.length;
|
|
6849
|
|
6850 while ( i-- ) {
|
|
6851 name = cssPrefixes[ i ] + capName;
|
|
6852 if ( name in style ) {
|
|
6853 return name;
|
|
6854 }
|
|
6855 }
|
|
6856
|
|
6857 return origName;
|
|
6858 }
|
|
6859
|
|
6860 function isHidden( elem, el ) {
|
|
6861 // isHidden might be called from jQuery#filter function;
|
|
6862 // in that case, element will be second argument
|
|
6863 elem = el || elem;
|
|
6864 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
|
|
6865 }
|
|
6866
|
|
6867 function showHide( elements, show ) {
|
|
6868 var display, elem, hidden,
|
|
6869 values = [],
|
|
6870 index = 0,
|
|
6871 length = elements.length;
|
|
6872
|
|
6873 for ( ; index < length; index++ ) {
|
|
6874 elem = elements[ index ];
|
|
6875 if ( !elem.style ) {
|
|
6876 continue;
|
|
6877 }
|
|
6878
|
|
6879 values[ index ] = jQuery._data( elem, "olddisplay" );
|
|
6880 display = elem.style.display;
|
|
6881 if ( show ) {
|
|
6882 // Reset the inline display of this element to learn if it is
|
|
6883 // being hidden by cascaded rules or not
|
|
6884 if ( !values[ index ] && display === "none" ) {
|
|
6885 elem.style.display = "";
|
|
6886 }
|
|
6887
|
|
6888 // Set elements which have been overridden with display: none
|
|
6889 // in a stylesheet to whatever the default browser style is
|
|
6890 // for such an element
|
|
6891 if ( elem.style.display === "" && isHidden( elem ) ) {
|
|
6892 values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
|
|
6893 }
|
|
6894 } else {
|
|
6895
|
|
6896 if ( !values[ index ] ) {
|
|
6897 hidden = isHidden( elem );
|
|
6898
|
|
6899 if ( display && display !== "none" || !hidden ) {
|
|
6900 jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
|
|
6901 }
|
|
6902 }
|
|
6903 }
|
|
6904 }
|
|
6905
|
|
6906 // Set the display of most of the elements in a second loop
|
|
6907 // to avoid the constant reflow
|
|
6908 for ( index = 0; index < length; index++ ) {
|
|
6909 elem = elements[ index ];
|
|
6910 if ( !elem.style ) {
|
|
6911 continue;
|
|
6912 }
|
|
6913 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
|
|
6914 elem.style.display = show ? values[ index ] || "" : "none";
|
|
6915 }
|
|
6916 }
|
|
6917
|
|
6918 return elements;
|
|
6919 }
|
|
6920
|
|
6921 jQuery.fn.extend({
|
|
6922 css: function( name, value ) {
|
|
6923 return jQuery.access( this, function( elem, name, value ) {
|
|
6924 var len, styles,
|
|
6925 map = {},
|
|
6926 i = 0;
|
|
6927
|
|
6928 if ( jQuery.isArray( name ) ) {
|
|
6929 styles = getStyles( elem );
|
|
6930 len = name.length;
|
|
6931
|
|
6932 for ( ; i < len; i++ ) {
|
|
6933 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
|
|
6934 }
|
|
6935
|
|
6936 return map;
|
|
6937 }
|
|
6938
|
|
6939 return value !== undefined ?
|
|
6940 jQuery.style( elem, name, value ) :
|
|
6941 jQuery.css( elem, name );
|
|
6942 }, name, value, arguments.length > 1 );
|
|
6943 },
|
|
6944 show: function() {
|
|
6945 return showHide( this, true );
|
|
6946 },
|
|
6947 hide: function() {
|
|
6948 return showHide( this );
|
|
6949 },
|
|
6950 toggle: function( state ) {
|
|
6951 var bool = typeof state === "boolean";
|
|
6952
|
|
6953 return this.each(function() {
|
|
6954 if ( bool ? state : isHidden( this ) ) {
|
|
6955 jQuery( this ).show();
|
|
6956 } else {
|
|
6957 jQuery( this ).hide();
|
|
6958 }
|
|
6959 });
|
|
6960 }
|
|
6961 });
|
|
6962
|
|
6963 jQuery.extend({
|
|
6964 // Add in style property hooks for overriding the default
|
|
6965 // behavior of getting and setting a style property
|
|
6966 cssHooks: {
|
|
6967 opacity: {
|
|
6968 get: function( elem, computed ) {
|
|
6969 if ( computed ) {
|
|
6970 // We should always get a number back from opacity
|
|
6971 var ret = curCSS( elem, "opacity" );
|
|
6972 return ret === "" ? "1" : ret;
|
|
6973 }
|
|
6974 }
|
|
6975 }
|
|
6976 },
|
|
6977
|
|
6978 // Don't automatically add "px" to these possibly-unitless properties
|
|
6979 cssNumber: {
|
|
6980 "columnCount": true,
|
|
6981 "fillOpacity": true,
|
|
6982 "fontWeight": true,
|
|
6983 "lineHeight": true,
|
|
6984 "opacity": true,
|
|
6985 "orphans": true,
|
|
6986 "widows": true,
|
|
6987 "zIndex": true,
|
|
6988 "zoom": true
|
|
6989 },
|
|
6990
|
|
6991 // Add in properties whose names you wish to fix before
|
|
6992 // setting or getting the value
|
|
6993 cssProps: {
|
|
6994 // normalize float css property
|
|
6995 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
|
|
6996 },
|
|
6997
|
|
6998 // Get and set the style property on a DOM Node
|
|
6999 style: function( elem, name, value, extra ) {
|
|
7000 // Don't set styles on text and comment nodes
|
|
7001 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
|
|
7002 return;
|
|
7003 }
|
|
7004
|
|
7005 // Make sure that we're working with the right name
|
|
7006 var ret, type, hooks,
|
|
7007 origName = jQuery.camelCase( name ),
|
|
7008 style = elem.style;
|
|
7009
|
|
7010 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
|
|
7011
|
|
7012 // gets hook for the prefixed version
|
|
7013 // followed by the unprefixed version
|
|
7014 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
|
7015
|
|
7016 // Check if we're setting a value
|
|
7017 if ( value !== undefined ) {
|
|
7018 type = typeof value;
|
|
7019
|
|
7020 // convert relative number strings (+= or -=) to relative numbers. #7345
|
|
7021 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
|
|
7022 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
|
|
7023 // Fixes bug #9237
|
|
7024 type = "number";
|
|
7025 }
|
|
7026
|
|
7027 // Make sure that NaN and null values aren't set. See: #7116
|
|
7028 if ( value == null || type === "number" && isNaN( value ) ) {
|
|
7029 return;
|
|
7030 }
|
|
7031
|
|
7032 // If a number was passed in, add 'px' to the (except for certain CSS properties)
|
|
7033 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
|
|
7034 value += "px";
|
|
7035 }
|
|
7036
|
|
7037 // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
|
|
7038 // but it would mean to define eight (for every problematic property) identical functions
|
|
7039 if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
|
|
7040 style[ name ] = "inherit";
|
|
7041 }
|
|
7042
|
|
7043 // If a hook was provided, use that value, otherwise just set the specified value
|
|
7044 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
|
|
7045
|
|
7046 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
|
|
7047 // Fixes bug #5509
|
|
7048 try {
|
|
7049 style[ name ] = value;
|
|
7050 } catch(e) {}
|
|
7051 }
|
|
7052
|
|
7053 } else {
|
|
7054 // If a hook was provided get the non-computed value from there
|
|
7055 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
|
|
7056 return ret;
|
|
7057 }
|
|
7058
|
|
7059 // Otherwise just get the value from the style object
|
|
7060 return style[ name ];
|
|
7061 }
|
|
7062 },
|
|
7063
|
|
7064 css: function( elem, name, extra, styles ) {
|
|
7065 var num, val, hooks,
|
|
7066 origName = jQuery.camelCase( name );
|
|
7067
|
|
7068 // Make sure that we're working with the right name
|
|
7069 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
|
|
7070
|
|
7071 // gets hook for the prefixed version
|
|
7072 // followed by the unprefixed version
|
|
7073 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
|
7074
|
|
7075 // If a hook was provided get the computed value from there
|
|
7076 if ( hooks && "get" in hooks ) {
|
|
7077 val = hooks.get( elem, true, extra );
|
|
7078 }
|
|
7079
|
|
7080 // Otherwise, if a way to get the computed value exists, use that
|
|
7081 if ( val === undefined ) {
|
|
7082 val = curCSS( elem, name, styles );
|
|
7083 }
|
|
7084
|
|
7085 //convert "normal" to computed value
|
|
7086 if ( val === "normal" && name in cssNormalTransform ) {
|
|
7087 val = cssNormalTransform[ name ];
|
|
7088 }
|
|
7089
|
|
7090 // Return, converting to number if forced or a qualifier was provided and val looks numeric
|
|
7091 if ( extra === "" || extra ) {
|
|
7092 num = parseFloat( val );
|
|
7093 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
|
|
7094 }
|
|
7095 return val;
|
|
7096 }
|
|
7097 });
|
|
7098
|
|
7099 // NOTE: we've included the "window" in window.getComputedStyle
|
|
7100 // because jsdom on node.js will break without it.
|
|
7101 if ( window.getComputedStyle ) {
|
|
7102 getStyles = function( elem ) {
|
|
7103 return window.getComputedStyle( elem, null );
|
|
7104 };
|
|
7105
|
|
7106 curCSS = function( elem, name, _computed ) {
|
|
7107 var width, minWidth, maxWidth,
|
|
7108 computed = _computed || getStyles( elem ),
|
|
7109
|
|
7110 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
|
|
7111 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined,
|
|
7112 style = elem.style;
|
|
7113
|
|
7114 if ( computed ) {
|
|
7115
|
|
7116 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
|
|
7117 ret = jQuery.style( elem, name );
|
|
7118 }
|
|
7119
|
|
7120 // A tribute to the "awesome hack by Dean Edwards"
|
|
7121 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
|
|
7122 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
|
|
7123 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
|
|
7124 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
|
|
7125
|
|
7126 // Remember the original values
|
|
7127 width = style.width;
|
|
7128 minWidth = style.minWidth;
|
|
7129 maxWidth = style.maxWidth;
|
|
7130
|
|
7131 // Put in the new values to get a computed value out
|
|
7132 style.minWidth = style.maxWidth = style.width = ret;
|
|
7133 ret = computed.width;
|
|
7134
|
|
7135 // Revert the changed values
|
|
7136 style.width = width;
|
|
7137 style.minWidth = minWidth;
|
|
7138 style.maxWidth = maxWidth;
|
|
7139 }
|
|
7140 }
|
|
7141
|
|
7142 return ret;
|
|
7143 };
|
|
7144 } else if ( document.documentElement.currentStyle ) {
|
|
7145 getStyles = function( elem ) {
|
|
7146 return elem.currentStyle;
|
|
7147 };
|
|
7148
|
|
7149 curCSS = function( elem, name, _computed ) {
|
|
7150 var left, rs, rsLeft,
|
|
7151 computed = _computed || getStyles( elem ),
|
|
7152 ret = computed ? computed[ name ] : undefined,
|
|
7153 style = elem.style;
|
|
7154
|
|
7155 // Avoid setting ret to empty string here
|
|
7156 // so we don't default to auto
|
|
7157 if ( ret == null && style && style[ name ] ) {
|
|
7158 ret = style[ name ];
|
|
7159 }
|
|
7160
|
|
7161 // From the awesome hack by Dean Edwards
|
|
7162 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
|
7163
|
|
7164 // If we're not dealing with a regular pixel number
|
|
7165 // but a number that has a weird ending, we need to convert it to pixels
|
|
7166 // but not position css attributes, as those are proportional to the parent element instead
|
|
7167 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
|
|
7168 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
|
|
7169
|
|
7170 // Remember the original values
|
|
7171 left = style.left;
|
|
7172 rs = elem.runtimeStyle;
|
|
7173 rsLeft = rs && rs.left;
|
|
7174
|
|
7175 // Put in the new values to get a computed value out
|
|
7176 if ( rsLeft ) {
|
|
7177 rs.left = elem.currentStyle.left;
|
|
7178 }
|
|
7179 style.left = name === "fontSize" ? "1em" : ret;
|
|
7180 ret = style.pixelLeft + "px";
|
|
7181
|
|
7182 // Revert the changed values
|
|
7183 style.left = left;
|
|
7184 if ( rsLeft ) {
|
|
7185 rs.left = rsLeft;
|
|
7186 }
|
|
7187 }
|
|
7188
|
|
7189 return ret === "" ? "auto" : ret;
|
|
7190 };
|
|
7191 }
|
|
7192
|
|
7193 function setPositiveNumber( elem, value, subtract ) {
|
|
7194 var matches = rnumsplit.exec( value );
|
|
7195 return matches ?
|
|
7196 // Guard against undefined "subtract", e.g., when used as in cssHooks
|
|
7197 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
|
|
7198 value;
|
|
7199 }
|
|
7200
|
|
7201 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
|
|
7202 var i = extra === ( isBorderBox ? "border" : "content" ) ?
|
|
7203 // If we already have the right measurement, avoid augmentation
|
|
7204 4 :
|
|
7205 // Otherwise initialize for horizontal or vertical properties
|
|
7206 name === "width" ? 1 : 0,
|
|
7207
|
|
7208 val = 0;
|
|
7209
|
|
7210 for ( ; i < 4; i += 2 ) {
|
|
7211 // both box models exclude margin, so add it if we want it
|
|
7212 if ( extra === "margin" ) {
|
|
7213 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
|
|
7214 }
|
|
7215
|
|
7216 if ( isBorderBox ) {
|
|
7217 // border-box includes padding, so remove it if we want content
|
|
7218 if ( extra === "content" ) {
|
|
7219 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
|
7220 }
|
|
7221
|
|
7222 // at this point, extra isn't border nor margin, so remove border
|
|
7223 if ( extra !== "margin" ) {
|
|
7224 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
|
7225 }
|
|
7226 } else {
|
|
7227 // at this point, extra isn't content, so add padding
|
|
7228 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
|
7229
|
|
7230 // at this point, extra isn't content nor padding, so add border
|
|
7231 if ( extra !== "padding" ) {
|
|
7232 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
|
7233 }
|
|
7234 }
|
|
7235 }
|
|
7236
|
|
7237 return val;
|
|
7238 }
|
|
7239
|
|
7240 function getWidthOrHeight( elem, name, extra ) {
|
|
7241
|
|
7242 // Start with offset property, which is equivalent to the border-box value
|
|
7243 var valueIsBorderBox = true,
|
|
7244 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
|
|
7245 styles = getStyles( elem ),
|
|
7246 isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
|
|
7247
|
|
7248 // some non-html elements return undefined for offsetWidth, so check for null/undefined
|
|
7249 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
|
|
7250 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
|
|
7251 if ( val <= 0 || val == null ) {
|
|
7252 // Fall back to computed then uncomputed css if necessary
|
|
7253 val = curCSS( elem, name, styles );
|
|
7254 if ( val < 0 || val == null ) {
|
|
7255 val = elem.style[ name ];
|
|
7256 }
|
|
7257
|
|
7258 // Computed unit is not pixels. Stop here and return.
|
|
7259 if ( rnumnonpx.test(val) ) {
|
|
7260 return val;
|
|
7261 }
|
|
7262
|
|
7263 // we need the check for style in case a browser which returns unreliable values
|
|
7264 // for getComputedStyle silently falls back to the reliable elem.style
|
|
7265 valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
|
|
7266
|
|
7267 // Normalize "", auto, and prepare for extra
|
|
7268 val = parseFloat( val ) || 0;
|
|
7269 }
|
|
7270
|
|
7271 // use the active box-sizing model to add/subtract irrelevant styles
|
|
7272 return ( val +
|
|
7273 augmentWidthOrHeight(
|
|
7274 elem,
|
|
7275 name,
|
|
7276 extra || ( isBorderBox ? "border" : "content" ),
|
|
7277 valueIsBorderBox,
|
|
7278 styles
|
|
7279 )
|
|
7280 ) + "px";
|
|
7281 }
|
|
7282
|
|
7283 // Try to determine the default display value of an element
|
|
7284 function css_defaultDisplay( nodeName ) {
|
|
7285 var doc = document,
|
|
7286 display = elemdisplay[ nodeName ];
|
|
7287
|
|
7288 if ( !display ) {
|
|
7289 display = actualDisplay( nodeName, doc );
|
|
7290
|
|
7291 // If the simple way fails, read from inside an iframe
|
|
7292 if ( display === "none" || !display ) {
|
|
7293 // Use the already-created iframe if possible
|
|
7294 iframe = ( iframe ||
|
|
7295 jQuery("<iframe frameborder='0' width='0' height='0'/>")
|
|
7296 .css( "cssText", "display:block !important" )
|
|
7297 ).appendTo( doc.documentElement );
|
|
7298
|
|
7299 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
|
|
7300 doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document;
|
|
7301 doc.write("<!doctype html><html><body>");
|
|
7302 doc.close();
|
|
7303
|
|
7304 display = actualDisplay( nodeName, doc );
|
|
7305 iframe.detach();
|
|
7306 }
|
|
7307
|
|
7308 // Store the correct default display
|
|
7309 elemdisplay[ nodeName ] = display;
|
|
7310 }
|
|
7311
|
|
7312 return display;
|
|
7313 }
|
|
7314
|
|
7315 // Called ONLY from within css_defaultDisplay
|
|
7316 function actualDisplay( name, doc ) {
|
|
7317 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
|
|
7318 display = jQuery.css( elem[0], "display" );
|
|
7319 elem.remove();
|
|
7320 return display;
|
|
7321 }
|
|
7322
|
|
7323 jQuery.each([ "height", "width" ], function( i, name ) {
|
|
7324 jQuery.cssHooks[ name ] = {
|
|
7325 get: function( elem, computed, extra ) {
|
|
7326 if ( computed ) {
|
|
7327 // certain elements can have dimension info if we invisibly show them
|
|
7328 // however, it must have a current display style that would benefit from this
|
|
7329 return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
|
|
7330 jQuery.swap( elem, cssShow, function() {
|
|
7331 return getWidthOrHeight( elem, name, extra );
|
|
7332 }) :
|
|
7333 getWidthOrHeight( elem, name, extra );
|
|
7334 }
|
|
7335 },
|
|
7336
|
|
7337 set: function( elem, value, extra ) {
|
|
7338 var styles = extra && getStyles( elem );
|
|
7339 return setPositiveNumber( elem, value, extra ?
|
|
7340 augmentWidthOrHeight(
|
|
7341 elem,
|
|
7342 name,
|
|
7343 extra,
|
|
7344 jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
|
|
7345 styles
|
|
7346 ) : 0
|
|
7347 );
|
|
7348 }
|
|
7349 };
|
|
7350 });
|
|
7351
|
|
7352 if ( !jQuery.support.opacity ) {
|
|
7353 jQuery.cssHooks.opacity = {
|
|
7354 get: function( elem, computed ) {
|
|
7355 // IE uses filters for opacity
|
|
7356 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
|
|
7357 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
|
|
7358 computed ? "1" : "";
|
|
7359 },
|
|
7360
|
|
7361 set: function( elem, value ) {
|
|
7362 var style = elem.style,
|
|
7363 currentStyle = elem.currentStyle,
|
|
7364 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
|
|
7365 filter = currentStyle && currentStyle.filter || style.filter || "";
|
|
7366
|
|
7367 // IE has trouble with opacity if it does not have layout
|
|
7368 // Force it by setting the zoom level
|
|
7369 style.zoom = 1;
|
|
7370
|
|
7371 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
|
|
7372 // if value === "", then remove inline opacity #12685
|
|
7373 if ( ( value >= 1 || value === "" ) &&
|
|
7374 jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
|
|
7375 style.removeAttribute ) {
|
|
7376
|
|
7377 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
|
|
7378 // if "filter:" is present at all, clearType is disabled, we want to avoid this
|
|
7379 // style.removeAttribute is IE Only, but so apparently is this code path...
|
|
7380 style.removeAttribute( "filter" );
|
|
7381
|
|
7382 // if there is no filter style applied in a css rule or unset inline opacity, we are done
|
|
7383 if ( value === "" || currentStyle && !currentStyle.filter ) {
|
|
7384 return;
|
|
7385 }
|
|
7386 }
|
|
7387
|
|
7388 // otherwise, set new filter values
|
|
7389 style.filter = ralpha.test( filter ) ?
|
|
7390 filter.replace( ralpha, opacity ) :
|
|
7391 filter + " " + opacity;
|
|
7392 }
|
|
7393 };
|
|
7394 }
|
|
7395
|
|
7396 // These hooks cannot be added until DOM ready because the support test
|
|
7397 // for it is not run until after DOM ready
|
|
7398 jQuery(function() {
|
|
7399 if ( !jQuery.support.reliableMarginRight ) {
|
|
7400 jQuery.cssHooks.marginRight = {
|
|
7401 get: function( elem, computed ) {
|
|
7402 if ( computed ) {
|
|
7403 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
|
7404 // Work around by temporarily setting element display to inline-block
|
|
7405 return jQuery.swap( elem, { "display": "inline-block" },
|
|
7406 curCSS, [ elem, "marginRight" ] );
|
|
7407 }
|
|
7408 }
|
|
7409 };
|
|
7410 }
|
|
7411
|
|
7412 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
|
|
7413 // getComputedStyle returns percent when specified for top/left/bottom/right
|
|
7414 // rather than make the css module depend on the offset module, we just check for it here
|
|
7415 if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
|
|
7416 jQuery.each( [ "top", "left" ], function( i, prop ) {
|
|
7417 jQuery.cssHooks[ prop ] = {
|
|
7418 get: function( elem, computed ) {
|
|
7419 if ( computed ) {
|
|
7420 computed = curCSS( elem, prop );
|
|
7421 // if curCSS returns percentage, fallback to offset
|
|
7422 return rnumnonpx.test( computed ) ?
|
|
7423 jQuery( elem ).position()[ prop ] + "px" :
|
|
7424 computed;
|
|
7425 }
|
|
7426 }
|
|
7427 };
|
|
7428 });
|
|
7429 }
|
|
7430
|
|
7431 });
|
|
7432
|
|
7433 if ( jQuery.expr && jQuery.expr.filters ) {
|
|
7434 jQuery.expr.filters.hidden = function( elem ) {
|
|
7435 // Support: Opera <= 12.12
|
|
7436 // Opera reports offsetWidths and offsetHeights less than zero on some elements
|
|
7437 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
|
|
7438 (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
|
|
7439 };
|
|
7440
|
|
7441 jQuery.expr.filters.visible = function( elem ) {
|
|
7442 return !jQuery.expr.filters.hidden( elem );
|
|
7443 };
|
|
7444 }
|
|
7445
|
|
7446 // These hooks are used by animate to expand properties
|
|
7447 jQuery.each({
|
|
7448 margin: "",
|
|
7449 padding: "",
|
|
7450 border: "Width"
|
|
7451 }, function( prefix, suffix ) {
|
|
7452 jQuery.cssHooks[ prefix + suffix ] = {
|
|
7453 expand: function( value ) {
|
|
7454 var i = 0,
|
|
7455 expanded = {},
|
|
7456
|
|
7457 // assumes a single number if not a string
|
|
7458 parts = typeof value === "string" ? value.split(" ") : [ value ];
|
|
7459
|
|
7460 for ( ; i < 4; i++ ) {
|
|
7461 expanded[ prefix + cssExpand[ i ] + suffix ] =
|
|
7462 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
|
|
7463 }
|
|
7464
|
|
7465 return expanded;
|
|
7466 }
|
|
7467 };
|
|
7468
|
|
7469 if ( !rmargin.test( prefix ) ) {
|
|
7470 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
|
|
7471 }
|
|
7472 });
|
|
7473 var r20 = /%20/g,
|
|
7474 rbracket = /\[\]$/,
|
|
7475 rCRLF = /\r?\n/g,
|
|
7476 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
|
|
7477 rsubmittable = /^(?:input|select|textarea|keygen)/i;
|
|
7478
|
|
7479 jQuery.fn.extend({
|
|
7480 serialize: function() {
|
|
7481 return jQuery.param( this.serializeArray() );
|
|
7482 },
|
|
7483 serializeArray: function() {
|
|
7484 return this.map(function(){
|
|
7485 // Can add propHook for "elements" to filter or add form elements
|
|
7486 var elements = jQuery.prop( this, "elements" );
|
|
7487 return elements ? jQuery.makeArray( elements ) : this;
|
|
7488 })
|
|
7489 .filter(function(){
|
|
7490 var type = this.type;
|
|
7491 // Use .is(":disabled") so that fieldset[disabled] works
|
|
7492 return this.name && !jQuery( this ).is( ":disabled" ) &&
|
|
7493 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
|
|
7494 ( this.checked || !manipulation_rcheckableType.test( type ) );
|
|
7495 })
|
|
7496 .map(function( i, elem ){
|
|
7497 var val = jQuery( this ).val();
|
|
7498
|
|
7499 return val == null ?
|
|
7500 null :
|
|
7501 jQuery.isArray( val ) ?
|
|
7502 jQuery.map( val, function( val ){
|
|
7503 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
|
|
7504 }) :
|
|
7505 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
|
|
7506 }).get();
|
|
7507 }
|
|
7508 });
|
|
7509
|
|
7510 //Serialize an array of form elements or a set of
|
|
7511 //key/values into a query string
|
|
7512 jQuery.param = function( a, traditional ) {
|
|
7513 var prefix,
|
|
7514 s = [],
|
|
7515 add = function( key, value ) {
|
|
7516 // If value is a function, invoke it and return its value
|
|
7517 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
|
|
7518 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
|
|
7519 };
|
|
7520
|
|
7521 // Set traditional to true for jQuery <= 1.3.2 behavior.
|
|
7522 if ( traditional === undefined ) {
|
|
7523 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
|
|
7524 }
|
|
7525
|
|
7526 // If an array was passed in, assume that it is an array of form elements.
|
|
7527 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
|
|
7528 // Serialize the form elements
|
|
7529 jQuery.each( a, function() {
|
|
7530 add( this.name, this.value );
|
|
7531 });
|
|
7532
|
|
7533 } else {
|
|
7534 // If traditional, encode the "old" way (the way 1.3.2 or older
|
|
7535 // did it), otherwise encode params recursively.
|
|
7536 for ( prefix in a ) {
|
|
7537 buildParams( prefix, a[ prefix ], traditional, add );
|
|
7538 }
|
|
7539 }
|
|
7540
|
|
7541 // Return the resulting serialization
|
|
7542 return s.join( "&" ).replace( r20, "+" );
|
|
7543 };
|
|
7544
|
|
7545 function buildParams( prefix, obj, traditional, add ) {
|
|
7546 var name;
|
|
7547
|
|
7548 if ( jQuery.isArray( obj ) ) {
|
|
7549 // Serialize array item.
|
|
7550 jQuery.each( obj, function( i, v ) {
|
|
7551 if ( traditional || rbracket.test( prefix ) ) {
|
|
7552 // Treat each array item as a scalar.
|
|
7553 add( prefix, v );
|
|
7554
|
|
7555 } else {
|
|
7556 // Item is non-scalar (array or object), encode its numeric index.
|
|
7557 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
|
|
7558 }
|
|
7559 });
|
|
7560
|
|
7561 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
|
|
7562 // Serialize object item.
|
|
7563 for ( name in obj ) {
|
|
7564 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
|
|
7565 }
|
|
7566
|
|
7567 } else {
|
|
7568 // Serialize scalar item.
|
|
7569 add( prefix, obj );
|
|
7570 }
|
|
7571 }
|
|
7572 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
|
|
7573 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
|
7574 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
|
|
7575
|
|
7576 // Handle event binding
|
|
7577 jQuery.fn[ name ] = function( data, fn ) {
|
|
7578 return arguments.length > 0 ?
|
|
7579 this.on( name, null, data, fn ) :
|
|
7580 this.trigger( name );
|
|
7581 };
|
|
7582 });
|
|
7583
|
|
7584 jQuery.fn.extend({
|
|
7585 hover: function( fnOver, fnOut ) {
|
|
7586 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
|
|
7587 },
|
|
7588
|
|
7589 bind: function( types, data, fn ) {
|
|
7590 return this.on( types, null, data, fn );
|
|
7591 },
|
|
7592 unbind: function( types, fn ) {
|
|
7593 return this.off( types, null, fn );
|
|
7594 },
|
|
7595
|
|
7596 delegate: function( selector, types, data, fn ) {
|
|
7597 return this.on( types, selector, data, fn );
|
|
7598 },
|
|
7599 undelegate: function( selector, types, fn ) {
|
|
7600 // ( namespace ) or ( selector, types [, fn] )
|
|
7601 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
|
|
7602 }
|
|
7603 });
|
|
7604 var
|
|
7605 // Document location
|
|
7606 ajaxLocParts,
|
|
7607 ajaxLocation,
|
|
7608 ajax_nonce = jQuery.now(),
|
|
7609
|
|
7610 ajax_rquery = /\?/,
|
|
7611 rhash = /#.*$/,
|
|
7612 rts = /([?&])_=[^&]*/,
|
|
7613 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
|
|
7614 // #7653, #8125, #8152: local protocol detection
|
|
7615 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
|
|
7616 rnoContent = /^(?:GET|HEAD)$/,
|
|
7617 rprotocol = /^\/\//,
|
|
7618 rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
|
|
7619
|
|
7620 // Keep a copy of the old load method
|
|
7621 _load = jQuery.fn.load,
|
|
7622
|
|
7623 /* Prefilters
|
|
7624 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
|
|
7625 * 2) These are called:
|
|
7626 * - BEFORE asking for a transport
|
|
7627 * - AFTER param serialization (s.data is a string if s.processData is true)
|
|
7628 * 3) key is the dataType
|
|
7629 * 4) the catchall symbol "*" can be used
|
|
7630 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
|
|
7631 */
|
|
7632 prefilters = {},
|
|
7633
|
|
7634 /* Transports bindings
|
|
7635 * 1) key is the dataType
|
|
7636 * 2) the catchall symbol "*" can be used
|
|
7637 * 3) selection will start with transport dataType and THEN go to "*" if needed
|
|
7638 */
|
|
7639 transports = {},
|
|
7640
|
|
7641 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
|
|
7642 allTypes = "*/".concat("*");
|
|
7643
|
|
7644 // #8138, IE may throw an exception when accessing
|
|
7645 // a field from window.location if document.domain has been set
|
|
7646 try {
|
|
7647 ajaxLocation = location.href;
|
|
7648 } catch( e ) {
|
|
7649 // Use the href attribute of an A element
|
|
7650 // since IE will modify it given document.location
|
|
7651 ajaxLocation = document.createElement( "a" );
|
|
7652 ajaxLocation.href = "";
|
|
7653 ajaxLocation = ajaxLocation.href;
|
|
7654 }
|
|
7655
|
|
7656 // Segment location into parts
|
|
7657 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
|
|
7658
|
|
7659 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
|
|
7660 function addToPrefiltersOrTransports( structure ) {
|
|
7661
|
|
7662 // dataTypeExpression is optional and defaults to "*"
|
|
7663 return function( dataTypeExpression, func ) {
|
|
7664
|
|
7665 if ( typeof dataTypeExpression !== "string" ) {
|
|
7666 func = dataTypeExpression;
|
|
7667 dataTypeExpression = "*";
|
|
7668 }
|
|
7669
|
|
7670 var dataType,
|
|
7671 i = 0,
|
|
7672 dataTypes = dataTypeExpression.toLowerCase().match( core_rnotwhite ) || [];
|
|
7673
|
|
7674 if ( jQuery.isFunction( func ) ) {
|
|
7675 // For each dataType in the dataTypeExpression
|
|
7676 while ( (dataType = dataTypes[i++]) ) {
|
|
7677 // Prepend if requested
|
|
7678 if ( dataType[0] === "+" ) {
|
|
7679 dataType = dataType.slice( 1 ) || "*";
|
|
7680 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
|
|
7681
|
|
7682 // Otherwise append
|
|
7683 } else {
|
|
7684 (structure[ dataType ] = structure[ dataType ] || []).push( func );
|
|
7685 }
|
|
7686 }
|
|
7687 }
|
|
7688 };
|
|
7689 }
|
|
7690
|
|
7691 // Base inspection function for prefilters and transports
|
|
7692 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
|
|
7693
|
|
7694 var inspected = {},
|
|
7695 seekingTransport = ( structure === transports );
|
|
7696
|
|
7697 function inspect( dataType ) {
|
|
7698 var selected;
|
|
7699 inspected[ dataType ] = true;
|
|
7700 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
|
|
7701 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
|
|
7702 if( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
|
|
7703 options.dataTypes.unshift( dataTypeOrTransport );
|
|
7704 inspect( dataTypeOrTransport );
|
|
7705 return false;
|
|
7706 } else if ( seekingTransport ) {
|
|
7707 return !( selected = dataTypeOrTransport );
|
|
7708 }
|
|
7709 });
|
|
7710 return selected;
|
|
7711 }
|
|
7712
|
|
7713 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
|
|
7714 }
|
|
7715
|
|
7716 // A special extend for ajax options
|
|
7717 // that takes "flat" options (not to be deep extended)
|
|
7718 // Fixes #9887
|
|
7719 function ajaxExtend( target, src ) {
|
|
7720 var deep, key,
|
|
7721 flatOptions = jQuery.ajaxSettings.flatOptions || {};
|
|
7722
|
|
7723 for ( key in src ) {
|
|
7724 if ( src[ key ] !== undefined ) {
|
|
7725 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
|
|
7726 }
|
|
7727 }
|
|
7728 if ( deep ) {
|
|
7729 jQuery.extend( true, target, deep );
|
|
7730 }
|
|
7731
|
|
7732 return target;
|
|
7733 }
|
|
7734
|
|
7735 jQuery.fn.load = function( url, params, callback ) {
|
|
7736 if ( typeof url !== "string" && _load ) {
|
|
7737 return _load.apply( this, arguments );
|
|
7738 }
|
|
7739
|
|
7740 var selector, response, type,
|
|
7741 self = this,
|
|
7742 off = url.indexOf(" ");
|
|
7743
|
|
7744 if ( off >= 0 ) {
|
|
7745 selector = url.slice( off, url.length );
|
|
7746 url = url.slice( 0, off );
|
|
7747 }
|
|
7748
|
|
7749 // If it's a function
|
|
7750 if ( jQuery.isFunction( params ) ) {
|
|
7751
|
|
7752 // We assume that it's the callback
|
|
7753 callback = params;
|
|
7754 params = undefined;
|
|
7755
|
|
7756 // Otherwise, build a param string
|
|
7757 } else if ( params && typeof params === "object" ) {
|
|
7758 type = "POST";
|
|
7759 }
|
|
7760
|
|
7761 // If we have elements to modify, make the request
|
|
7762 if ( self.length > 0 ) {
|
|
7763 jQuery.ajax({
|
|
7764 url: url,
|
|
7765
|
|
7766 // if "type" variable is undefined, then "GET" method will be used
|
|
7767 type: type,
|
|
7768 dataType: "html",
|
|
7769 data: params
|
|
7770 }).done(function( responseText ) {
|
|
7771
|
|
7772 // Save response for use in complete callback
|
|
7773 response = arguments;
|
|
7774
|
|
7775 self.html( selector ?
|
|
7776
|
|
7777 // If a selector was specified, locate the right elements in a dummy div
|
|
7778 // Exclude scripts to avoid IE 'Permission Denied' errors
|
|
7779 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
|
|
7780
|
|
7781 // Otherwise use the full result
|
|
7782 responseText );
|
|
7783
|
|
7784 }).complete( callback && function( jqXHR, status ) {
|
|
7785 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
|
|
7786 });
|
|
7787 }
|
|
7788
|
|
7789 return this;
|
|
7790 };
|
|
7791
|
|
7792 // Attach a bunch of functions for handling common AJAX events
|
|
7793 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){
|
|
7794 jQuery.fn[ type ] = function( fn ){
|
|
7795 return this.on( type, fn );
|
|
7796 };
|
|
7797 });
|
|
7798
|
|
7799 jQuery.extend({
|
|
7800
|
|
7801 // Counter for holding the number of active queries
|
|
7802 active: 0,
|
|
7803
|
|
7804 // Last-Modified header cache for next request
|
|
7805 lastModified: {},
|
|
7806 etag: {},
|
|
7807
|
|
7808 ajaxSettings: {
|
|
7809 url: ajaxLocation,
|
|
7810 type: "GET",
|
|
7811 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
|
|
7812 global: true,
|
|
7813 processData: true,
|
|
7814 async: true,
|
|
7815 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
|
|
7816 /*
|
|
7817 timeout: 0,
|
|
7818 data: null,
|
|
7819 dataType: null,
|
|
7820 username: null,
|
|
7821 password: null,
|
|
7822 cache: null,
|
|
7823 throws: false,
|
|
7824 traditional: false,
|
|
7825 headers: {},
|
|
7826 */
|
|
7827
|
|
7828 accepts: {
|
|
7829 "*": allTypes,
|
|
7830 text: "text/plain",
|
|
7831 html: "text/html",
|
|
7832 xml: "application/xml, text/xml",
|
|
7833 json: "application/json, text/javascript"
|
|
7834 },
|
|
7835
|
|
7836 contents: {
|
|
7837 xml: /xml/,
|
|
7838 html: /html/,
|
|
7839 json: /json/
|
|
7840 },
|
|
7841
|
|
7842 responseFields: {
|
|
7843 xml: "responseXML",
|
|
7844 text: "responseText",
|
|
7845 json: "responseJSON"
|
|
7846 },
|
|
7847
|
|
7848 // Data converters
|
|
7849 // Keys separate source (or catchall "*") and destination types with a single space
|
|
7850 converters: {
|
|
7851
|
|
7852 // Convert anything to text
|
|
7853 "* text": String,
|
|
7854
|
|
7855 // Text to html (true = no transformation)
|
|
7856 "text html": true,
|
|
7857
|
|
7858 // Evaluate text as a json expression
|
|
7859 "text json": jQuery.parseJSON,
|
|
7860
|
|
7861 // Parse text as xml
|
|
7862 "text xml": jQuery.parseXML
|
|
7863 },
|
|
7864
|
|
7865 // For options that shouldn't be deep extended:
|
|
7866 // you can add your own custom options here if
|
|
7867 // and when you create one that shouldn't be
|
|
7868 // deep extended (see ajaxExtend)
|
|
7869 flatOptions: {
|
|
7870 url: true,
|
|
7871 context: true
|
|
7872 }
|
|
7873 },
|
|
7874
|
|
7875 // Creates a full fledged settings object into target
|
|
7876 // with both ajaxSettings and settings fields.
|
|
7877 // If target is omitted, writes into ajaxSettings.
|
|
7878 ajaxSetup: function( target, settings ) {
|
|
7879 return settings ?
|
|
7880
|
|
7881 // Building a settings object
|
|
7882 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
|
|
7883
|
|
7884 // Extending ajaxSettings
|
|
7885 ajaxExtend( jQuery.ajaxSettings, target );
|
|
7886 },
|
|
7887
|
|
7888 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
|
|
7889 ajaxTransport: addToPrefiltersOrTransports( transports ),
|
|
7890
|
|
7891 // Main method
|
|
7892 ajax: function( url, options ) {
|
|
7893
|
|
7894 // If url is an object, simulate pre-1.5 signature
|
|
7895 if ( typeof url === "object" ) {
|
|
7896 options = url;
|
|
7897 url = undefined;
|
|
7898 }
|
|
7899
|
|
7900 // Force options to be an object
|
|
7901 options = options || {};
|
|
7902
|
|
7903 var // Cross-domain detection vars
|
|
7904 parts,
|
|
7905 // Loop variable
|
|
7906 i,
|
|
7907 // URL without anti-cache param
|
|
7908 cacheURL,
|
|
7909 // Response headers as string
|
|
7910 responseHeadersString,
|
|
7911 // timeout handle
|
|
7912 timeoutTimer,
|
|
7913
|
|
7914 // To know if global events are to be dispatched
|
|
7915 fireGlobals,
|
|
7916
|
|
7917 transport,
|
|
7918 // Response headers
|
|
7919 responseHeaders,
|
|
7920 // Create the final options object
|
|
7921 s = jQuery.ajaxSetup( {}, options ),
|
|
7922 // Callbacks context
|
|
7923 callbackContext = s.context || s,
|
|
7924 // Context for global events is callbackContext if it is a DOM node or jQuery collection
|
|
7925 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
|
|
7926 jQuery( callbackContext ) :
|
|
7927 jQuery.event,
|
|
7928 // Deferreds
|
|
7929 deferred = jQuery.Deferred(),
|
|
7930 completeDeferred = jQuery.Callbacks("once memory"),
|
|
7931 // Status-dependent callbacks
|
|
7932 statusCode = s.statusCode || {},
|
|
7933 // Headers (they are sent all at once)
|
|
7934 requestHeaders = {},
|
|
7935 requestHeadersNames = {},
|
|
7936 // The jqXHR state
|
|
7937 state = 0,
|
|
7938 // Default abort message
|
|
7939 strAbort = "canceled",
|
|
7940 // Fake xhr
|
|
7941 jqXHR = {
|
|
7942 readyState: 0,
|
|
7943
|
|
7944 // Builds headers hashtable if needed
|
|
7945 getResponseHeader: function( key ) {
|
|
7946 var match;
|
|
7947 if ( state === 2 ) {
|
|
7948 if ( !responseHeaders ) {
|
|
7949 responseHeaders = {};
|
|
7950 while ( (match = rheaders.exec( responseHeadersString )) ) {
|
|
7951 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
|
|
7952 }
|
|
7953 }
|
|
7954 match = responseHeaders[ key.toLowerCase() ];
|
|
7955 }
|
|
7956 return match == null ? null : match;
|
|
7957 },
|
|
7958
|
|
7959 // Raw string
|
|
7960 getAllResponseHeaders: function() {
|
|
7961 return state === 2 ? responseHeadersString : null;
|
|
7962 },
|
|
7963
|
|
7964 // Caches the header
|
|
7965 setRequestHeader: function( name, value ) {
|
|
7966 var lname = name.toLowerCase();
|
|
7967 if ( !state ) {
|
|
7968 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
|
|
7969 requestHeaders[ name ] = value;
|
|
7970 }
|
|
7971 return this;
|
|
7972 },
|
|
7973
|
|
7974 // Overrides response content-type header
|
|
7975 overrideMimeType: function( type ) {
|
|
7976 if ( !state ) {
|
|
7977 s.mimeType = type;
|
|
7978 }
|
|
7979 return this;
|
|
7980 },
|
|
7981
|
|
7982 // Status-dependent callbacks
|
|
7983 statusCode: function( map ) {
|
|
7984 var code;
|
|
7985 if ( map ) {
|
|
7986 if ( state < 2 ) {
|
|
7987 for ( code in map ) {
|
|
7988 // Lazy-add the new callback in a way that preserves old ones
|
|
7989 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
|
|
7990 }
|
|
7991 } else {
|
|
7992 // Execute the appropriate callbacks
|
|
7993 jqXHR.always( map[ jqXHR.status ] );
|
|
7994 }
|
|
7995 }
|
|
7996 return this;
|
|
7997 },
|
|
7998
|
|
7999 // Cancel the request
|
|
8000 abort: function( statusText ) {
|
|
8001 var finalText = statusText || strAbort;
|
|
8002 if ( transport ) {
|
|
8003 transport.abort( finalText );
|
|
8004 }
|
|
8005 done( 0, finalText );
|
|
8006 return this;
|
|
8007 }
|
|
8008 };
|
|
8009
|
|
8010 // Attach deferreds
|
|
8011 deferred.promise( jqXHR ).complete = completeDeferred.add;
|
|
8012 jqXHR.success = jqXHR.done;
|
|
8013 jqXHR.error = jqXHR.fail;
|
|
8014
|
|
8015 // Remove hash character (#7531: and string promotion)
|
|
8016 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
|
|
8017 // Handle falsy url in the settings object (#10093: consistency with old signature)
|
|
8018 // We also use the url parameter if available
|
|
8019 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
|
|
8020
|
|
8021 // Alias method option to type as per ticket #12004
|
|
8022 s.type = options.method || options.type || s.method || s.type;
|
|
8023
|
|
8024 // Extract dataTypes list
|
|
8025 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( core_rnotwhite ) || [""];
|
|
8026
|
|
8027 // A cross-domain request is in order when we have a protocol:host:port mismatch
|
|
8028 if ( s.crossDomain == null ) {
|
|
8029 parts = rurl.exec( s.url.toLowerCase() );
|
|
8030 s.crossDomain = !!( parts &&
|
|
8031 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
|
|
8032 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
|
|
8033 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
|
|
8034 );
|
|
8035 }
|
|
8036
|
|
8037 // Convert data if not already a string
|
|
8038 if ( s.data && s.processData && typeof s.data !== "string" ) {
|
|
8039 s.data = jQuery.param( s.data, s.traditional );
|
|
8040 }
|
|
8041
|
|
8042 // Apply prefilters
|
|
8043 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
|
|
8044
|
|
8045 // If request was aborted inside a prefilter, stop there
|
|
8046 if ( state === 2 ) {
|
|
8047 return jqXHR;
|
|
8048 }
|
|
8049
|
|
8050 // We can fire global events as of now if asked to
|
|
8051 fireGlobals = s.global;
|
|
8052
|
|
8053 // Watch for a new set of requests
|
|
8054 if ( fireGlobals && jQuery.active++ === 0 ) {
|
|
8055 jQuery.event.trigger("ajaxStart");
|
|
8056 }
|
|
8057
|
|
8058 // Uppercase the type
|
|
8059 s.type = s.type.toUpperCase();
|
|
8060
|
|
8061 // Determine if request has content
|
|
8062 s.hasContent = !rnoContent.test( s.type );
|
|
8063
|
|
8064 // Save the URL in case we're toying with the If-Modified-Since
|
|
8065 // and/or If-None-Match header later on
|
|
8066 cacheURL = s.url;
|
|
8067
|
|
8068 // More options handling for requests with no content
|
|
8069 if ( !s.hasContent ) {
|
|
8070
|
|
8071 // If data is available, append data to url
|
|
8072 if ( s.data ) {
|
|
8073 cacheURL = ( s.url += ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
|
|
8074 // #9682: remove data so that it's not used in an eventual retry
|
|
8075 delete s.data;
|
|
8076 }
|
|
8077
|
|
8078 // Add anti-cache in url if needed
|
|
8079 if ( s.cache === false ) {
|
|
8080 s.url = rts.test( cacheURL ) ?
|
|
8081
|
|
8082 // If there is already a '_' parameter, set its value
|
|
8083 cacheURL.replace( rts, "$1_=" + ajax_nonce++ ) :
|
|
8084
|
|
8085 // Otherwise add one to the end
|
|
8086 cacheURL + ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ajax_nonce++;
|
|
8087 }
|
|
8088 }
|
|
8089
|
|
8090 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
|
8091 if ( s.ifModified ) {
|
|
8092 if ( jQuery.lastModified[ cacheURL ] ) {
|
|
8093 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
|
|
8094 }
|
|
8095 if ( jQuery.etag[ cacheURL ] ) {
|
|
8096 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
|
|
8097 }
|
|
8098 }
|
|
8099
|
|
8100 // Set the correct header, if data is being sent
|
|
8101 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
|
|
8102 jqXHR.setRequestHeader( "Content-Type", s.contentType );
|
|
8103 }
|
|
8104
|
|
8105 // Set the Accepts header for the server, depending on the dataType
|
|
8106 jqXHR.setRequestHeader(
|
|
8107 "Accept",
|
|
8108 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
|
|
8109 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
|
|
8110 s.accepts[ "*" ]
|
|
8111 );
|
|
8112
|
|
8113 // Check for headers option
|
|
8114 for ( i in s.headers ) {
|
|
8115 jqXHR.setRequestHeader( i, s.headers[ i ] );
|
|
8116 }
|
|
8117
|
|
8118 // Allow custom headers/mimetypes and early abort
|
|
8119 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
|
|
8120 // Abort if not done already and return
|
|
8121 return jqXHR.abort();
|
|
8122 }
|
|
8123
|
|
8124 // aborting is no longer a cancellation
|
|
8125 strAbort = "abort";
|
|
8126
|
|
8127 // Install callbacks on deferreds
|
|
8128 for ( i in { success: 1, error: 1, complete: 1 } ) {
|
|
8129 jqXHR[ i ]( s[ i ] );
|
|
8130 }
|
|
8131
|
|
8132 // Get transport
|
|
8133 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
|
|
8134
|
|
8135 // If no transport, we auto-abort
|
|
8136 if ( !transport ) {
|
|
8137 done( -1, "No Transport" );
|
|
8138 } else {
|
|
8139 jqXHR.readyState = 1;
|
|
8140
|
|
8141 // Send global event
|
|
8142 if ( fireGlobals ) {
|
|
8143 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
|
|
8144 }
|
|
8145 // Timeout
|
|
8146 if ( s.async && s.timeout > 0 ) {
|
|
8147 timeoutTimer = setTimeout(function() {
|
|
8148 jqXHR.abort("timeout");
|
|
8149 }, s.timeout );
|
|
8150 }
|
|
8151
|
|
8152 try {
|
|
8153 state = 1;
|
|
8154 transport.send( requestHeaders, done );
|
|
8155 } catch ( e ) {
|
|
8156 // Propagate exception as error if not done
|
|
8157 if ( state < 2 ) {
|
|
8158 done( -1, e );
|
|
8159 // Simply rethrow otherwise
|
|
8160 } else {
|
|
8161 throw e;
|
|
8162 }
|
|
8163 }
|
|
8164 }
|
|
8165
|
|
8166 // Callback for when everything is done
|
|
8167 function done( status, nativeStatusText, responses, headers ) {
|
|
8168 var isSuccess, success, error, response, modified,
|
|
8169 statusText = nativeStatusText;
|
|
8170
|
|
8171 // Called once
|
|
8172 if ( state === 2 ) {
|
|
8173 return;
|
|
8174 }
|
|
8175
|
|
8176 // State is "done" now
|
|
8177 state = 2;
|
|
8178
|
|
8179 // Clear timeout if it exists
|
|
8180 if ( timeoutTimer ) {
|
|
8181 clearTimeout( timeoutTimer );
|
|
8182 }
|
|
8183
|
|
8184 // Dereference transport for early garbage collection
|
|
8185 // (no matter how long the jqXHR object will be used)
|
|
8186 transport = undefined;
|
|
8187
|
|
8188 // Cache response headers
|
|
8189 responseHeadersString = headers || "";
|
|
8190
|
|
8191 // Set readyState
|
|
8192 jqXHR.readyState = status > 0 ? 4 : 0;
|
|
8193
|
|
8194 // Determine if successful
|
|
8195 isSuccess = status >= 200 && status < 300 || status === 304;
|
|
8196
|
|
8197 // Get response data
|
|
8198 if ( responses ) {
|
|
8199 response = ajaxHandleResponses( s, jqXHR, responses );
|
|
8200 }
|
|
8201
|
|
8202 // Convert no matter what (that way responseXXX fields are always set)
|
|
8203 response = ajaxConvert( s, response, jqXHR, isSuccess );
|
|
8204
|
|
8205 // If successful, handle type chaining
|
|
8206 if ( isSuccess ) {
|
|
8207
|
|
8208 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
|
8209 if ( s.ifModified ) {
|
|
8210 modified = jqXHR.getResponseHeader("Last-Modified");
|
|
8211 if ( modified ) {
|
|
8212 jQuery.lastModified[ cacheURL ] = modified;
|
|
8213 }
|
|
8214 modified = jqXHR.getResponseHeader("etag");
|
|
8215 if ( modified ) {
|
|
8216 jQuery.etag[ cacheURL ] = modified;
|
|
8217 }
|
|
8218 }
|
|
8219
|
|
8220 // if no content
|
|
8221 if ( status === 204 || s.type === "HEAD" ) {
|
|
8222 statusText = "nocontent";
|
|
8223
|
|
8224 // if not modified
|
|
8225 } else if ( status === 304 ) {
|
|
8226 statusText = "notmodified";
|
|
8227
|
|
8228 // If we have data, let's convert it
|
|
8229 } else {
|
|
8230 statusText = response.state;
|
|
8231 success = response.data;
|
|
8232 error = response.error;
|
|
8233 isSuccess = !error;
|
|
8234 }
|
|
8235 } else {
|
|
8236 // We extract error from statusText
|
|
8237 // then normalize statusText and status for non-aborts
|
|
8238 error = statusText;
|
|
8239 if ( status || !statusText ) {
|
|
8240 statusText = "error";
|
|
8241 if ( status < 0 ) {
|
|
8242 status = 0;
|
|
8243 }
|
|
8244 }
|
|
8245 }
|
|
8246
|
|
8247 // Set data for the fake xhr object
|
|
8248 jqXHR.status = status;
|
|
8249 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
|
|
8250
|
|
8251 // Success/Error
|
|
8252 if ( isSuccess ) {
|
|
8253 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
|
|
8254 } else {
|
|
8255 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
|
|
8256 }
|
|
8257
|
|
8258 // Status-dependent callbacks
|
|
8259 jqXHR.statusCode( statusCode );
|
|
8260 statusCode = undefined;
|
|
8261
|
|
8262 if ( fireGlobals ) {
|
|
8263 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
|
|
8264 [ jqXHR, s, isSuccess ? success : error ] );
|
|
8265 }
|
|
8266
|
|
8267 // Complete
|
|
8268 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
|
|
8269
|
|
8270 if ( fireGlobals ) {
|
|
8271 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
|
|
8272 // Handle the global AJAX counter
|
|
8273 if ( !( --jQuery.active ) ) {
|
|
8274 jQuery.event.trigger("ajaxStop");
|
|
8275 }
|
|
8276 }
|
|
8277 }
|
|
8278
|
|
8279 return jqXHR;
|
|
8280 },
|
|
8281
|
|
8282 getJSON: function( url, data, callback ) {
|
|
8283 return jQuery.get( url, data, callback, "json" );
|
|
8284 },
|
|
8285
|
|
8286 getScript: function( url, callback ) {
|
|
8287 return jQuery.get( url, undefined, callback, "script" );
|
|
8288 }
|
|
8289 });
|
|
8290
|
|
8291 jQuery.each( [ "get", "post" ], function( i, method ) {
|
|
8292 jQuery[ method ] = function( url, data, callback, type ) {
|
|
8293 // shift arguments if data argument was omitted
|
|
8294 if ( jQuery.isFunction( data ) ) {
|
|
8295 type = type || callback;
|
|
8296 callback = data;
|
|
8297 data = undefined;
|
|
8298 }
|
|
8299
|
|
8300 return jQuery.ajax({
|
|
8301 url: url,
|
|
8302 type: method,
|
|
8303 dataType: type,
|
|
8304 data: data,
|
|
8305 success: callback
|
|
8306 });
|
|
8307 };
|
|
8308 });
|
|
8309
|
|
8310 /* Handles responses to an ajax request:
|
|
8311 * - finds the right dataType (mediates between content-type and expected dataType)
|
|
8312 * - returns the corresponding response
|
|
8313 */
|
|
8314 function ajaxHandleResponses( s, jqXHR, responses ) {
|
|
8315 var firstDataType, ct, finalDataType, type,
|
|
8316 contents = s.contents,
|
|
8317 dataTypes = s.dataTypes;
|
|
8318
|
|
8319 // Remove auto dataType and get content-type in the process
|
|
8320 while( dataTypes[ 0 ] === "*" ) {
|
|
8321 dataTypes.shift();
|
|
8322 if ( ct === undefined ) {
|
|
8323 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
|
|
8324 }
|
|
8325 }
|
|
8326
|
|
8327 // Check if we're dealing with a known content-type
|
|
8328 if ( ct ) {
|
|
8329 for ( type in contents ) {
|
|
8330 if ( contents[ type ] && contents[ type ].test( ct ) ) {
|
|
8331 dataTypes.unshift( type );
|
|
8332 break;
|
|
8333 }
|
|
8334 }
|
|
8335 }
|
|
8336
|
|
8337 // Check to see if we have a response for the expected dataType
|
|
8338 if ( dataTypes[ 0 ] in responses ) {
|
|
8339 finalDataType = dataTypes[ 0 ];
|
|
8340 } else {
|
|
8341 // Try convertible dataTypes
|
|
8342 for ( type in responses ) {
|
|
8343 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
|
|
8344 finalDataType = type;
|
|
8345 break;
|
|
8346 }
|
|
8347 if ( !firstDataType ) {
|
|
8348 firstDataType = type;
|
|
8349 }
|
|
8350 }
|
|
8351 // Or just use first one
|
|
8352 finalDataType = finalDataType || firstDataType;
|
|
8353 }
|
|
8354
|
|
8355 // If we found a dataType
|
|
8356 // We add the dataType to the list if needed
|
|
8357 // and return the corresponding response
|
|
8358 if ( finalDataType ) {
|
|
8359 if ( finalDataType !== dataTypes[ 0 ] ) {
|
|
8360 dataTypes.unshift( finalDataType );
|
|
8361 }
|
|
8362 return responses[ finalDataType ];
|
|
8363 }
|
|
8364 }
|
|
8365
|
|
8366 /* Chain conversions given the request and the original response
|
|
8367 * Also sets the responseXXX fields on the jqXHR instance
|
|
8368 */
|
|
8369 function ajaxConvert( s, response, jqXHR, isSuccess ) {
|
|
8370 var conv2, current, conv, tmp, prev,
|
|
8371 converters = {},
|
|
8372 // Work with a copy of dataTypes in case we need to modify it for conversion
|
|
8373 dataTypes = s.dataTypes.slice();
|
|
8374
|
|
8375 // Create converters map with lowercased keys
|
|
8376 if ( dataTypes[ 1 ] ) {
|
|
8377 for ( conv in s.converters ) {
|
|
8378 converters[ conv.toLowerCase() ] = s.converters[ conv ];
|
|
8379 }
|
|
8380 }
|
|
8381
|
|
8382 current = dataTypes.shift();
|
|
8383
|
|
8384 // Convert to each sequential dataType
|
|
8385 while ( current ) {
|
|
8386
|
|
8387 if ( s.responseFields[ current ] ) {
|
|
8388 jqXHR[ s.responseFields[ current ] ] = response;
|
|
8389 }
|
|
8390
|
|
8391 // Apply the dataFilter if provided
|
|
8392 if ( !prev && isSuccess && s.dataFilter ) {
|
|
8393 response = s.dataFilter( response, s.dataType );
|
|
8394 }
|
|
8395
|
|
8396 prev = current;
|
|
8397 current = dataTypes.shift();
|
|
8398
|
|
8399 if ( current ) {
|
|
8400
|
|
8401 // There's only work to do if current dataType is non-auto
|
|
8402 if ( current === "*" ) {
|
|
8403
|
|
8404 current = prev;
|
|
8405
|
|
8406 // Convert response if prev dataType is non-auto and differs from current
|
|
8407 } else if ( prev !== "*" && prev !== current ) {
|
|
8408
|
|
8409 // Seek a direct converter
|
|
8410 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
|
|
8411
|
|
8412 // If none found, seek a pair
|
|
8413 if ( !conv ) {
|
|
8414 for ( conv2 in converters ) {
|
|
8415
|
|
8416 // If conv2 outputs current
|
|
8417 tmp = conv2.split( " " );
|
|
8418 if ( tmp[ 1 ] === current ) {
|
|
8419
|
|
8420 // If prev can be converted to accepted input
|
|
8421 conv = converters[ prev + " " + tmp[ 0 ] ] ||
|
|
8422 converters[ "* " + tmp[ 0 ] ];
|
|
8423 if ( conv ) {
|
|
8424 // Condense equivalence converters
|
|
8425 if ( conv === true ) {
|
|
8426 conv = converters[ conv2 ];
|
|
8427
|
|
8428 // Otherwise, insert the intermediate dataType
|
|
8429 } else if ( converters[ conv2 ] !== true ) {
|
|
8430 current = tmp[ 0 ];
|
|
8431 dataTypes.unshift( tmp[ 1 ] );
|
|
8432 }
|
|
8433 break;
|
|
8434 }
|
|
8435 }
|
|
8436 }
|
|
8437 }
|
|
8438
|
|
8439 // Apply converter (if not an equivalence)
|
|
8440 if ( conv !== true ) {
|
|
8441
|
|
8442 // Unless errors are allowed to bubble, catch and return them
|
|
8443 if ( conv && s[ "throws" ] ) {
|
|
8444 response = conv( response );
|
|
8445 } else {
|
|
8446 try {
|
|
8447 response = conv( response );
|
|
8448 } catch ( e ) {
|
|
8449 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
|
|
8450 }
|
|
8451 }
|
|
8452 }
|
|
8453 }
|
|
8454 }
|
|
8455 }
|
|
8456
|
|
8457 return { state: "success", data: response };
|
|
8458 }
|
|
8459 // Install script dataType
|
|
8460 jQuery.ajaxSetup({
|
|
8461 accepts: {
|
|
8462 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
|
|
8463 },
|
|
8464 contents: {
|
|
8465 script: /(?:java|ecma)script/
|
|
8466 },
|
|
8467 converters: {
|
|
8468 "text script": function( text ) {
|
|
8469 jQuery.globalEval( text );
|
|
8470 return text;
|
|
8471 }
|
|
8472 }
|
|
8473 });
|
|
8474
|
|
8475 // Handle cache's special case and global
|
|
8476 jQuery.ajaxPrefilter( "script", function( s ) {
|
|
8477 if ( s.cache === undefined ) {
|
|
8478 s.cache = false;
|
|
8479 }
|
|
8480 if ( s.crossDomain ) {
|
|
8481 s.type = "GET";
|
|
8482 s.global = false;
|
|
8483 }
|
|
8484 });
|
|
8485
|
|
8486 // Bind script tag hack transport
|
|
8487 jQuery.ajaxTransport( "script", function(s) {
|
|
8488
|
|
8489 // This transport only deals with cross domain requests
|
|
8490 if ( s.crossDomain ) {
|
|
8491
|
|
8492 var script,
|
|
8493 head = document.head || jQuery("head")[0] || document.documentElement;
|
|
8494
|
|
8495 return {
|
|
8496
|
|
8497 send: function( _, callback ) {
|
|
8498
|
|
8499 script = document.createElement("script");
|
|
8500
|
|
8501 script.async = true;
|
|
8502
|
|
8503 if ( s.scriptCharset ) {
|
|
8504 script.charset = s.scriptCharset;
|
|
8505 }
|
|
8506
|
|
8507 script.src = s.url;
|
|
8508
|
|
8509 // Attach handlers for all browsers
|
|
8510 script.onload = script.onreadystatechange = function( _, isAbort ) {
|
|
8511
|
|
8512 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
|
|
8513
|
|
8514 // Handle memory leak in IE
|
|
8515 script.onload = script.onreadystatechange = null;
|
|
8516
|
|
8517 // Remove the script
|
|
8518 if ( script.parentNode ) {
|
|
8519 script.parentNode.removeChild( script );
|
|
8520 }
|
|
8521
|
|
8522 // Dereference the script
|
|
8523 script = null;
|
|
8524
|
|
8525 // Callback if not abort
|
|
8526 if ( !isAbort ) {
|
|
8527 callback( 200, "success" );
|
|
8528 }
|
|
8529 }
|
|
8530 };
|
|
8531
|
|
8532 // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
|
|
8533 // Use native DOM manipulation to avoid our domManip AJAX trickery
|
|
8534 head.insertBefore( script, head.firstChild );
|
|
8535 },
|
|
8536
|
|
8537 abort: function() {
|
|
8538 if ( script ) {
|
|
8539 script.onload( undefined, true );
|
|
8540 }
|
|
8541 }
|
|
8542 };
|
|
8543 }
|
|
8544 });
|
|
8545 var oldCallbacks = [],
|
|
8546 rjsonp = /(=)\?(?=&|$)|\?\?/;
|
|
8547
|
|
8548 // Default jsonp settings
|
|
8549 jQuery.ajaxSetup({
|
|
8550 jsonp: "callback",
|
|
8551 jsonpCallback: function() {
|
|
8552 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) );
|
|
8553 this[ callback ] = true;
|
|
8554 return callback;
|
|
8555 }
|
|
8556 });
|
|
8557
|
|
8558 // Detect, normalize options and install callbacks for jsonp requests
|
|
8559 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
|
8560
|
|
8561 var callbackName, overwritten, responseContainer,
|
|
8562 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
|
|
8563 "url" :
|
|
8564 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
|
|
8565 );
|
|
8566
|
|
8567 // Handle iff the expected data type is "jsonp" or we have a parameter to set
|
|
8568 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
|
|
8569
|
|
8570 // Get callback name, remembering preexisting value associated with it
|
|
8571 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
|
|
8572 s.jsonpCallback() :
|
|
8573 s.jsonpCallback;
|
|
8574
|
|
8575 // Insert callback into url or form data
|
|
8576 if ( jsonProp ) {
|
|
8577 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
|
|
8578 } else if ( s.jsonp !== false ) {
|
|
8579 s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
|
|
8580 }
|
|
8581
|
|
8582 // Use data converter to retrieve json after script execution
|
|
8583 s.converters["script json"] = function() {
|
|
8584 if ( !responseContainer ) {
|
|
8585 jQuery.error( callbackName + " was not called" );
|
|
8586 }
|
|
8587 return responseContainer[ 0 ];
|
|
8588 };
|
|
8589
|
|
8590 // force json dataType
|
|
8591 s.dataTypes[ 0 ] = "json";
|
|
8592
|
|
8593 // Install callback
|
|
8594 overwritten = window[ callbackName ];
|
|
8595 window[ callbackName ] = function() {
|
|
8596 responseContainer = arguments;
|
|
8597 };
|
|
8598
|
|
8599 // Clean-up function (fires after converters)
|
|
8600 jqXHR.always(function() {
|
|
8601 // Restore preexisting value
|
|
8602 window[ callbackName ] = overwritten;
|
|
8603
|
|
8604 // Save back as free
|
|
8605 if ( s[ callbackName ] ) {
|
|
8606 // make sure that re-using the options doesn't screw things around
|
|
8607 s.jsonpCallback = originalSettings.jsonpCallback;
|
|
8608
|
|
8609 // save the callback name for future use
|
|
8610 oldCallbacks.push( callbackName );
|
|
8611 }
|
|
8612
|
|
8613 // Call if it was a function and we have a response
|
|
8614 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
|
|
8615 overwritten( responseContainer[ 0 ] );
|
|
8616 }
|
|
8617
|
|
8618 responseContainer = overwritten = undefined;
|
|
8619 });
|
|
8620
|
|
8621 // Delegate to script
|
|
8622 return "script";
|
|
8623 }
|
|
8624 });
|
|
8625 var xhrCallbacks, xhrSupported,
|
|
8626 xhrId = 0,
|
|
8627 // #5280: Internet Explorer will keep connections alive if we don't abort on unload
|
|
8628 xhrOnUnloadAbort = window.ActiveXObject && function() {
|
|
8629 // Abort all pending requests
|
|
8630 var key;
|
|
8631 for ( key in xhrCallbacks ) {
|
|
8632 xhrCallbacks[ key ]( undefined, true );
|
|
8633 }
|
|
8634 };
|
|
8635
|
|
8636 // Functions to create xhrs
|
|
8637 function createStandardXHR() {
|
|
8638 try {
|
|
8639 return new window.XMLHttpRequest();
|
|
8640 } catch( e ) {}
|
|
8641 }
|
|
8642
|
|
8643 function createActiveXHR() {
|
|
8644 try {
|
|
8645 return new window.ActiveXObject("Microsoft.XMLHTTP");
|
|
8646 } catch( e ) {}
|
|
8647 }
|
|
8648
|
|
8649 // Create the request object
|
|
8650 // (This is still attached to ajaxSettings for backward compatibility)
|
|
8651 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
|
|
8652 /* Microsoft failed to properly
|
|
8653 * implement the XMLHttpRequest in IE7 (can't request local files),
|
|
8654 * so we use the ActiveXObject when it is available
|
|
8655 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
|
|
8656 * we need a fallback.
|
|
8657 */
|
|
8658 function() {
|
|
8659 return !this.isLocal && createStandardXHR() || createActiveXHR();
|
|
8660 } :
|
|
8661 // For all other browsers, use the standard XMLHttpRequest object
|
|
8662 createStandardXHR;
|
|
8663
|
|
8664 // Determine support properties
|
|
8665 xhrSupported = jQuery.ajaxSettings.xhr();
|
|
8666 jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
|
|
8667 xhrSupported = jQuery.support.ajax = !!xhrSupported;
|
|
8668
|
|
8669 // Create transport if the browser can provide an xhr
|
|
8670 if ( xhrSupported ) {
|
|
8671
|
|
8672 jQuery.ajaxTransport(function( s ) {
|
|
8673 // Cross domain only allowed if supported through XMLHttpRequest
|
|
8674 if ( !s.crossDomain || jQuery.support.cors ) {
|
|
8675
|
|
8676 var callback;
|
|
8677
|
|
8678 return {
|
|
8679 send: function( headers, complete ) {
|
|
8680
|
|
8681 // Get a new xhr
|
|
8682 var handle, i,
|
|
8683 xhr = s.xhr();
|
|
8684
|
|
8685 // Open the socket
|
|
8686 // Passing null username, generates a login popup on Opera (#2865)
|
|
8687 if ( s.username ) {
|
|
8688 xhr.open( s.type, s.url, s.async, s.username, s.password );
|
|
8689 } else {
|
|
8690 xhr.open( s.type, s.url, s.async );
|
|
8691 }
|
|
8692
|
|
8693 // Apply custom fields if provided
|
|
8694 if ( s.xhrFields ) {
|
|
8695 for ( i in s.xhrFields ) {
|
|
8696 xhr[ i ] = s.xhrFields[ i ];
|
|
8697 }
|
|
8698 }
|
|
8699
|
|
8700 // Override mime type if needed
|
|
8701 if ( s.mimeType && xhr.overrideMimeType ) {
|
|
8702 xhr.overrideMimeType( s.mimeType );
|
|
8703 }
|
|
8704
|
|
8705 // X-Requested-With header
|
|
8706 // For cross-domain requests, seeing as conditions for a preflight are
|
|
8707 // akin to a jigsaw puzzle, we simply never set it to be sure.
|
|
8708 // (it can always be set on a per-request basis or even using ajaxSetup)
|
|
8709 // For same-domain requests, won't change header if already provided.
|
|
8710 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
|
|
8711 headers["X-Requested-With"] = "XMLHttpRequest";
|
|
8712 }
|
|
8713
|
|
8714 // Need an extra try/catch for cross domain requests in Firefox 3
|
|
8715 try {
|
|
8716 for ( i in headers ) {
|
|
8717 xhr.setRequestHeader( i, headers[ i ] );
|
|
8718 }
|
|
8719 } catch( err ) {}
|
|
8720
|
|
8721 // Do send the request
|
|
8722 // This may raise an exception which is actually
|
|
8723 // handled in jQuery.ajax (so no try/catch here)
|
|
8724 xhr.send( ( s.hasContent && s.data ) || null );
|
|
8725
|
|
8726 // Listener
|
|
8727 callback = function( _, isAbort ) {
|
|
8728 var status, responseHeaders, statusText, responses;
|
|
8729
|
|
8730 // Firefox throws exceptions when accessing properties
|
|
8731 // of an xhr when a network error occurred
|
|
8732 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
|
|
8733 try {
|
|
8734
|
|
8735 // Was never called and is aborted or complete
|
|
8736 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
|
|
8737
|
|
8738 // Only called once
|
|
8739 callback = undefined;
|
|
8740
|
|
8741 // Do not keep as active anymore
|
|
8742 if ( handle ) {
|
|
8743 xhr.onreadystatechange = jQuery.noop;
|
|
8744 if ( xhrOnUnloadAbort ) {
|
|
8745 delete xhrCallbacks[ handle ];
|
|
8746 }
|
|
8747 }
|
|
8748
|
|
8749 // If it's an abort
|
|
8750 if ( isAbort ) {
|
|
8751 // Abort it manually if needed
|
|
8752 if ( xhr.readyState !== 4 ) {
|
|
8753 xhr.abort();
|
|
8754 }
|
|
8755 } else {
|
|
8756 responses = {};
|
|
8757 status = xhr.status;
|
|
8758 responseHeaders = xhr.getAllResponseHeaders();
|
|
8759
|
|
8760 // When requesting binary data, IE6-9 will throw an exception
|
|
8761 // on any attempt to access responseText (#11426)
|
|
8762 if ( typeof xhr.responseText === "string" ) {
|
|
8763 responses.text = xhr.responseText;
|
|
8764 }
|
|
8765
|
|
8766 // Firefox throws an exception when accessing
|
|
8767 // statusText for faulty cross-domain requests
|
|
8768 try {
|
|
8769 statusText = xhr.statusText;
|
|
8770 } catch( e ) {
|
|
8771 // We normalize with Webkit giving an empty statusText
|
|
8772 statusText = "";
|
|
8773 }
|
|
8774
|
|
8775 // Filter status for non standard behaviors
|
|
8776
|
|
8777 // If the request is local and we have data: assume a success
|
|
8778 // (success with no data won't get notified, that's the best we
|
|
8779 // can do given current implementations)
|
|
8780 if ( !status && s.isLocal && !s.crossDomain ) {
|
|
8781 status = responses.text ? 200 : 404;
|
|
8782 // IE - #1450: sometimes returns 1223 when it should be 204
|
|
8783 } else if ( status === 1223 ) {
|
|
8784 status = 204;
|
|
8785 }
|
|
8786 }
|
|
8787 }
|
|
8788 } catch( firefoxAccessException ) {
|
|
8789 if ( !isAbort ) {
|
|
8790 complete( -1, firefoxAccessException );
|
|
8791 }
|
|
8792 }
|
|
8793
|
|
8794 // Call complete if needed
|
|
8795 if ( responses ) {
|
|
8796 complete( status, statusText, responses, responseHeaders );
|
|
8797 }
|
|
8798 };
|
|
8799
|
|
8800 if ( !s.async ) {
|
|
8801 // if we're in sync mode we fire the callback
|
|
8802 callback();
|
|
8803 } else if ( xhr.readyState === 4 ) {
|
|
8804 // (IE6 & IE7) if it's in cache and has been
|
|
8805 // retrieved directly we need to fire the callback
|
|
8806 setTimeout( callback );
|
|
8807 } else {
|
|
8808 handle = ++xhrId;
|
|
8809 if ( xhrOnUnloadAbort ) {
|
|
8810 // Create the active xhrs callbacks list if needed
|
|
8811 // and attach the unload handler
|
|
8812 if ( !xhrCallbacks ) {
|
|
8813 xhrCallbacks = {};
|
|
8814 jQuery( window ).unload( xhrOnUnloadAbort );
|
|
8815 }
|
|
8816 // Add to list of active xhrs callbacks
|
|
8817 xhrCallbacks[ handle ] = callback;
|
|
8818 }
|
|
8819 xhr.onreadystatechange = callback;
|
|
8820 }
|
|
8821 },
|
|
8822
|
|
8823 abort: function() {
|
|
8824 if ( callback ) {
|
|
8825 callback( undefined, true );
|
|
8826 }
|
|
8827 }
|
|
8828 };
|
|
8829 }
|
|
8830 });
|
|
8831 }
|
|
8832 var fxNow, timerId,
|
|
8833 rfxtypes = /^(?:toggle|show|hide)$/,
|
|
8834 rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
|
|
8835 rrun = /queueHooks$/,
|
|
8836 animationPrefilters = [ defaultPrefilter ],
|
|
8837 tweeners = {
|
|
8838 "*": [function( prop, value ) {
|
|
8839 var tween = this.createTween( prop, value ),
|
|
8840 target = tween.cur(),
|
|
8841 parts = rfxnum.exec( value ),
|
|
8842 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
|
|
8843
|
|
8844 // Starting value computation is required for potential unit mismatches
|
|
8845 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
|
|
8846 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
|
|
8847 scale = 1,
|
|
8848 maxIterations = 20;
|
|
8849
|
|
8850 if ( start && start[ 3 ] !== unit ) {
|
|
8851 // Trust units reported by jQuery.css
|
|
8852 unit = unit || start[ 3 ];
|
|
8853
|
|
8854 // Make sure we update the tween properties later on
|
|
8855 parts = parts || [];
|
|
8856
|
|
8857 // Iteratively approximate from a nonzero starting point
|
|
8858 start = +target || 1;
|
|
8859
|
|
8860 do {
|
|
8861 // If previous iteration zeroed out, double until we get *something*
|
|
8862 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
|
|
8863 scale = scale || ".5";
|
|
8864
|
|
8865 // Adjust and apply
|
|
8866 start = start / scale;
|
|
8867 jQuery.style( tween.elem, prop, start + unit );
|
|
8868
|
|
8869 // Update scale, tolerating zero or NaN from tween.cur()
|
|
8870 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
|
|
8871 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
|
|
8872 }
|
|
8873
|
|
8874 // Update tween properties
|
|
8875 if ( parts ) {
|
|
8876 start = tween.start = +start || +target || 0;
|
|
8877 tween.unit = unit;
|
|
8878 // If a +=/-= token was provided, we're doing a relative animation
|
|
8879 tween.end = parts[ 1 ] ?
|
|
8880 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
|
|
8881 +parts[ 2 ];
|
|
8882 }
|
|
8883
|
|
8884 return tween;
|
|
8885 }]
|
|
8886 };
|
|
8887
|
|
8888 // Animations created synchronously will run synchronously
|
|
8889 function createFxNow() {
|
|
8890 setTimeout(function() {
|
|
8891 fxNow = undefined;
|
|
8892 });
|
|
8893 return ( fxNow = jQuery.now() );
|
|
8894 }
|
|
8895
|
|
8896 function createTween( value, prop, animation ) {
|
|
8897 var tween,
|
|
8898 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
|
|
8899 index = 0,
|
|
8900 length = collection.length;
|
|
8901 for ( ; index < length; index++ ) {
|
|
8902 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
|
|
8903
|
|
8904 // we're done with this property
|
|
8905 return tween;
|
|
8906 }
|
|
8907 }
|
|
8908 }
|
|
8909
|
|
8910 function Animation( elem, properties, options ) {
|
|
8911 var result,
|
|
8912 stopped,
|
|
8913 index = 0,
|
|
8914 length = animationPrefilters.length,
|
|
8915 deferred = jQuery.Deferred().always( function() {
|
|
8916 // don't match elem in the :animated selector
|
|
8917 delete tick.elem;
|
|
8918 }),
|
|
8919 tick = function() {
|
|
8920 if ( stopped ) {
|
|
8921 return false;
|
|
8922 }
|
|
8923 var currentTime = fxNow || createFxNow(),
|
|
8924 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
|
|
8925 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
|
|
8926 temp = remaining / animation.duration || 0,
|
|
8927 percent = 1 - temp,
|
|
8928 index = 0,
|
|
8929 length = animation.tweens.length;
|
|
8930
|
|
8931 for ( ; index < length ; index++ ) {
|
|
8932 animation.tweens[ index ].run( percent );
|
|
8933 }
|
|
8934
|
|
8935 deferred.notifyWith( elem, [ animation, percent, remaining ]);
|
|
8936
|
|
8937 if ( percent < 1 && length ) {
|
|
8938 return remaining;
|
|
8939 } else {
|
|
8940 deferred.resolveWith( elem, [ animation ] );
|
|
8941 return false;
|
|
8942 }
|
|
8943 },
|
|
8944 animation = deferred.promise({
|
|
8945 elem: elem,
|
|
8946 props: jQuery.extend( {}, properties ),
|
|
8947 opts: jQuery.extend( true, { specialEasing: {} }, options ),
|
|
8948 originalProperties: properties,
|
|
8949 originalOptions: options,
|
|
8950 startTime: fxNow || createFxNow(),
|
|
8951 duration: options.duration,
|
|
8952 tweens: [],
|
|
8953 createTween: function( prop, end ) {
|
|
8954 var tween = jQuery.Tween( elem, animation.opts, prop, end,
|
|
8955 animation.opts.specialEasing[ prop ] || animation.opts.easing );
|
|
8956 animation.tweens.push( tween );
|
|
8957 return tween;
|
|
8958 },
|
|
8959 stop: function( gotoEnd ) {
|
|
8960 var index = 0,
|
|
8961 // if we are going to the end, we want to run all the tweens
|
|
8962 // otherwise we skip this part
|
|
8963 length = gotoEnd ? animation.tweens.length : 0;
|
|
8964 if ( stopped ) {
|
|
8965 return this;
|
|
8966 }
|
|
8967 stopped = true;
|
|
8968 for ( ; index < length ; index++ ) {
|
|
8969 animation.tweens[ index ].run( 1 );
|
|
8970 }
|
|
8971
|
|
8972 // resolve when we played the last frame
|
|
8973 // otherwise, reject
|
|
8974 if ( gotoEnd ) {
|
|
8975 deferred.resolveWith( elem, [ animation, gotoEnd ] );
|
|
8976 } else {
|
|
8977 deferred.rejectWith( elem, [ animation, gotoEnd ] );
|
|
8978 }
|
|
8979 return this;
|
|
8980 }
|
|
8981 }),
|
|
8982 props = animation.props;
|
|
8983
|
|
8984 propFilter( props, animation.opts.specialEasing );
|
|
8985
|
|
8986 for ( ; index < length ; index++ ) {
|
|
8987 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
|
|
8988 if ( result ) {
|
|
8989 return result;
|
|
8990 }
|
|
8991 }
|
|
8992
|
|
8993 jQuery.map( props, createTween, animation );
|
|
8994
|
|
8995 if ( jQuery.isFunction( animation.opts.start ) ) {
|
|
8996 animation.opts.start.call( elem, animation );
|
|
8997 }
|
|
8998
|
|
8999 jQuery.fx.timer(
|
|
9000 jQuery.extend( tick, {
|
|
9001 elem: elem,
|
|
9002 anim: animation,
|
|
9003 queue: animation.opts.queue
|
|
9004 })
|
|
9005 );
|
|
9006
|
|
9007 // attach callbacks from options
|
|
9008 return animation.progress( animation.opts.progress )
|
|
9009 .done( animation.opts.done, animation.opts.complete )
|
|
9010 .fail( animation.opts.fail )
|
|
9011 .always( animation.opts.always );
|
|
9012 }
|
|
9013
|
|
9014 function propFilter( props, specialEasing ) {
|
|
9015 var index, name, easing, value, hooks;
|
|
9016
|
|
9017 // camelCase, specialEasing and expand cssHook pass
|
|
9018 for ( index in props ) {
|
|
9019 name = jQuery.camelCase( index );
|
|
9020 easing = specialEasing[ name ];
|
|
9021 value = props[ index ];
|
|
9022 if ( jQuery.isArray( value ) ) {
|
|
9023 easing = value[ 1 ];
|
|
9024 value = props[ index ] = value[ 0 ];
|
|
9025 }
|
|
9026
|
|
9027 if ( index !== name ) {
|
|
9028 props[ name ] = value;
|
|
9029 delete props[ index ];
|
|
9030 }
|
|
9031
|
|
9032 hooks = jQuery.cssHooks[ name ];
|
|
9033 if ( hooks && "expand" in hooks ) {
|
|
9034 value = hooks.expand( value );
|
|
9035 delete props[ name ];
|
|
9036
|
|
9037 // not quite $.extend, this wont overwrite keys already present.
|
|
9038 // also - reusing 'index' from above because we have the correct "name"
|
|
9039 for ( index in value ) {
|
|
9040 if ( !( index in props ) ) {
|
|
9041 props[ index ] = value[ index ];
|
|
9042 specialEasing[ index ] = easing;
|
|
9043 }
|
|
9044 }
|
|
9045 } else {
|
|
9046 specialEasing[ name ] = easing;
|
|
9047 }
|
|
9048 }
|
|
9049 }
|
|
9050
|
|
9051 jQuery.Animation = jQuery.extend( Animation, {
|
|
9052
|
|
9053 tweener: function( props, callback ) {
|
|
9054 if ( jQuery.isFunction( props ) ) {
|
|
9055 callback = props;
|
|
9056 props = [ "*" ];
|
|
9057 } else {
|
|
9058 props = props.split(" ");
|
|
9059 }
|
|
9060
|
|
9061 var prop,
|
|
9062 index = 0,
|
|
9063 length = props.length;
|
|
9064
|
|
9065 for ( ; index < length ; index++ ) {
|
|
9066 prop = props[ index ];
|
|
9067 tweeners[ prop ] = tweeners[ prop ] || [];
|
|
9068 tweeners[ prop ].unshift( callback );
|
|
9069 }
|
|
9070 },
|
|
9071
|
|
9072 prefilter: function( callback, prepend ) {
|
|
9073 if ( prepend ) {
|
|
9074 animationPrefilters.unshift( callback );
|
|
9075 } else {
|
|
9076 animationPrefilters.push( callback );
|
|
9077 }
|
|
9078 }
|
|
9079 });
|
|
9080
|
|
9081 function defaultPrefilter( elem, props, opts ) {
|
|
9082 /* jshint validthis: true */
|
|
9083 var prop, value, toggle, tween, hooks, oldfire,
|
|
9084 anim = this,
|
|
9085 orig = {},
|
|
9086 style = elem.style,
|
|
9087 hidden = elem.nodeType && isHidden( elem ),
|
|
9088 dataShow = jQuery._data( elem, "fxshow" );
|
|
9089
|
|
9090 // handle queue: false promises
|
|
9091 if ( !opts.queue ) {
|
|
9092 hooks = jQuery._queueHooks( elem, "fx" );
|
|
9093 if ( hooks.unqueued == null ) {
|
|
9094 hooks.unqueued = 0;
|
|
9095 oldfire = hooks.empty.fire;
|
|
9096 hooks.empty.fire = function() {
|
|
9097 if ( !hooks.unqueued ) {
|
|
9098 oldfire();
|
|
9099 }
|
|
9100 };
|
|
9101 }
|
|
9102 hooks.unqueued++;
|
|
9103
|
|
9104 anim.always(function() {
|
|
9105 // doing this makes sure that the complete handler will be called
|
|
9106 // before this completes
|
|
9107 anim.always(function() {
|
|
9108 hooks.unqueued--;
|
|
9109 if ( !jQuery.queue( elem, "fx" ).length ) {
|
|
9110 hooks.empty.fire();
|
|
9111 }
|
|
9112 });
|
|
9113 });
|
|
9114 }
|
|
9115
|
|
9116 // height/width overflow pass
|
|
9117 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
|
|
9118 // Make sure that nothing sneaks out
|
|
9119 // Record all 3 overflow attributes because IE does not
|
|
9120 // change the overflow attribute when overflowX and
|
|
9121 // overflowY are set to the same value
|
|
9122 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
|
|
9123
|
|
9124 // Set display property to inline-block for height/width
|
|
9125 // animations on inline elements that are having width/height animated
|
|
9126 if ( jQuery.css( elem, "display" ) === "inline" &&
|
|
9127 jQuery.css( elem, "float" ) === "none" ) {
|
|
9128
|
|
9129 // inline-level elements accept inline-block;
|
|
9130 // block-level elements need to be inline with layout
|
|
9131 if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
|
|
9132 style.display = "inline-block";
|
|
9133
|
|
9134 } else {
|
|
9135 style.zoom = 1;
|
|
9136 }
|
|
9137 }
|
|
9138 }
|
|
9139
|
|
9140 if ( opts.overflow ) {
|
|
9141 style.overflow = "hidden";
|
|
9142 if ( !jQuery.support.shrinkWrapBlocks ) {
|
|
9143 anim.always(function() {
|
|
9144 style.overflow = opts.overflow[ 0 ];
|
|
9145 style.overflowX = opts.overflow[ 1 ];
|
|
9146 style.overflowY = opts.overflow[ 2 ];
|
|
9147 });
|
|
9148 }
|
|
9149 }
|
|
9150
|
|
9151
|
|
9152 // show/hide pass
|
|
9153 for ( prop in props ) {
|
|
9154 value = props[ prop ];
|
|
9155 if ( rfxtypes.exec( value ) ) {
|
|
9156 delete props[ prop ];
|
|
9157 toggle = toggle || value === "toggle";
|
|
9158 if ( value === ( hidden ? "hide" : "show" ) ) {
|
|
9159 continue;
|
|
9160 }
|
|
9161 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
|
|
9162 }
|
|
9163 }
|
|
9164
|
|
9165 if ( !jQuery.isEmptyObject( orig ) ) {
|
|
9166 if ( dataShow ) {
|
|
9167 if ( "hidden" in dataShow ) {
|
|
9168 hidden = dataShow.hidden;
|
|
9169 }
|
|
9170 } else {
|
|
9171 dataShow = jQuery._data( elem, "fxshow", {} );
|
|
9172 }
|
|
9173
|
|
9174 // store state if its toggle - enables .stop().toggle() to "reverse"
|
|
9175 if ( toggle ) {
|
|
9176 dataShow.hidden = !hidden;
|
|
9177 }
|
|
9178 if ( hidden ) {
|
|
9179 jQuery( elem ).show();
|
|
9180 } else {
|
|
9181 anim.done(function() {
|
|
9182 jQuery( elem ).hide();
|
|
9183 });
|
|
9184 }
|
|
9185 anim.done(function() {
|
|
9186 var prop;
|
|
9187 jQuery._removeData( elem, "fxshow" );
|
|
9188 for ( prop in orig ) {
|
|
9189 jQuery.style( elem, prop, orig[ prop ] );
|
|
9190 }
|
|
9191 });
|
|
9192 for ( prop in orig ) {
|
|
9193 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
|
|
9194
|
|
9195 if ( !( prop in dataShow ) ) {
|
|
9196 dataShow[ prop ] = tween.start;
|
|
9197 if ( hidden ) {
|
|
9198 tween.end = tween.start;
|
|
9199 tween.start = prop === "width" || prop === "height" ? 1 : 0;
|
|
9200 }
|
|
9201 }
|
|
9202 }
|
|
9203 }
|
|
9204 }
|
|
9205
|
|
9206 function Tween( elem, options, prop, end, easing ) {
|
|
9207 return new Tween.prototype.init( elem, options, prop, end, easing );
|
|
9208 }
|
|
9209 jQuery.Tween = Tween;
|
|
9210
|
|
9211 Tween.prototype = {
|
|
9212 constructor: Tween,
|
|
9213 init: function( elem, options, prop, end, easing, unit ) {
|
|
9214 this.elem = elem;
|
|
9215 this.prop = prop;
|
|
9216 this.easing = easing || "swing";
|
|
9217 this.options = options;
|
|
9218 this.start = this.now = this.cur();
|
|
9219 this.end = end;
|
|
9220 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
|
|
9221 },
|
|
9222 cur: function() {
|
|
9223 var hooks = Tween.propHooks[ this.prop ];
|
|
9224
|
|
9225 return hooks && hooks.get ?
|
|
9226 hooks.get( this ) :
|
|
9227 Tween.propHooks._default.get( this );
|
|
9228 },
|
|
9229 run: function( percent ) {
|
|
9230 var eased,
|
|
9231 hooks = Tween.propHooks[ this.prop ];
|
|
9232
|
|
9233 if ( this.options.duration ) {
|
|
9234 this.pos = eased = jQuery.easing[ this.easing ](
|
|
9235 percent, this.options.duration * percent, 0, 1, this.options.duration
|
|
9236 );
|
|
9237 } else {
|
|
9238 this.pos = eased = percent;
|
|
9239 }
|
|
9240 this.now = ( this.end - this.start ) * eased + this.start;
|
|
9241
|
|
9242 if ( this.options.step ) {
|
|
9243 this.options.step.call( this.elem, this.now, this );
|
|
9244 }
|
|
9245
|
|
9246 if ( hooks && hooks.set ) {
|
|
9247 hooks.set( this );
|
|
9248 } else {
|
|
9249 Tween.propHooks._default.set( this );
|
|
9250 }
|
|
9251 return this;
|
|
9252 }
|
|
9253 };
|
|
9254
|
|
9255 Tween.prototype.init.prototype = Tween.prototype;
|
|
9256
|
|
9257 Tween.propHooks = {
|
|
9258 _default: {
|
|
9259 get: function( tween ) {
|
|
9260 var result;
|
|
9261
|
|
9262 if ( tween.elem[ tween.prop ] != null &&
|
|
9263 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
|
|
9264 return tween.elem[ tween.prop ];
|
|
9265 }
|
|
9266
|
|
9267 // passing an empty string as a 3rd parameter to .css will automatically
|
|
9268 // attempt a parseFloat and fallback to a string if the parse fails
|
|
9269 // so, simple values such as "10px" are parsed to Float.
|
|
9270 // complex values such as "rotate(1rad)" are returned as is.
|
|
9271 result = jQuery.css( tween.elem, tween.prop, "" );
|
|
9272 // Empty strings, null, undefined and "auto" are converted to 0.
|
|
9273 return !result || result === "auto" ? 0 : result;
|
|
9274 },
|
|
9275 set: function( tween ) {
|
|
9276 // use step hook for back compat - use cssHook if its there - use .style if its
|
|
9277 // available and use plain properties where available
|
|
9278 if ( jQuery.fx.step[ tween.prop ] ) {
|
|
9279 jQuery.fx.step[ tween.prop ]( tween );
|
|
9280 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
|
|
9281 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
|
|
9282 } else {
|
|
9283 tween.elem[ tween.prop ] = tween.now;
|
|
9284 }
|
|
9285 }
|
|
9286 }
|
|
9287 };
|
|
9288
|
|
9289 // Support: IE <=9
|
|
9290 // Panic based approach to setting things on disconnected nodes
|
|
9291
|
|
9292 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
|
|
9293 set: function( tween ) {
|
|
9294 if ( tween.elem.nodeType && tween.elem.parentNode ) {
|
|
9295 tween.elem[ tween.prop ] = tween.now;
|
|
9296 }
|
|
9297 }
|
|
9298 };
|
|
9299
|
|
9300 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
|
|
9301 var cssFn = jQuery.fn[ name ];
|
|
9302 jQuery.fn[ name ] = function( speed, easing, callback ) {
|
|
9303 return speed == null || typeof speed === "boolean" ?
|
|
9304 cssFn.apply( this, arguments ) :
|
|
9305 this.animate( genFx( name, true ), speed, easing, callback );
|
|
9306 };
|
|
9307 });
|
|
9308
|
|
9309 jQuery.fn.extend({
|
|
9310 fadeTo: function( speed, to, easing, callback ) {
|
|
9311
|
|
9312 // show any hidden elements after setting opacity to 0
|
|
9313 return this.filter( isHidden ).css( "opacity", 0 ).show()
|
|
9314
|
|
9315 // animate to the value specified
|
|
9316 .end().animate({ opacity: to }, speed, easing, callback );
|
|
9317 },
|
|
9318 animate: function( prop, speed, easing, callback ) {
|
|
9319 var empty = jQuery.isEmptyObject( prop ),
|
|
9320 optall = jQuery.speed( speed, easing, callback ),
|
|
9321 doAnimation = function() {
|
|
9322 // Operate on a copy of prop so per-property easing won't be lost
|
|
9323 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
|
|
9324
|
|
9325 // Empty animations, or finishing resolves immediately
|
|
9326 if ( empty || jQuery._data( this, "finish" ) ) {
|
|
9327 anim.stop( true );
|
|
9328 }
|
|
9329 };
|
|
9330 doAnimation.finish = doAnimation;
|
|
9331
|
|
9332 return empty || optall.queue === false ?
|
|
9333 this.each( doAnimation ) :
|
|
9334 this.queue( optall.queue, doAnimation );
|
|
9335 },
|
|
9336 stop: function( type, clearQueue, gotoEnd ) {
|
|
9337 var stopQueue = function( hooks ) {
|
|
9338 var stop = hooks.stop;
|
|
9339 delete hooks.stop;
|
|
9340 stop( gotoEnd );
|
|
9341 };
|
|
9342
|
|
9343 if ( typeof type !== "string" ) {
|
|
9344 gotoEnd = clearQueue;
|
|
9345 clearQueue = type;
|
|
9346 type = undefined;
|
|
9347 }
|
|
9348 if ( clearQueue && type !== false ) {
|
|
9349 this.queue( type || "fx", [] );
|
|
9350 }
|
|
9351
|
|
9352 return this.each(function() {
|
|
9353 var dequeue = true,
|
|
9354 index = type != null && type + "queueHooks",
|
|
9355 timers = jQuery.timers,
|
|
9356 data = jQuery._data( this );
|
|
9357
|
|
9358 if ( index ) {
|
|
9359 if ( data[ index ] && data[ index ].stop ) {
|
|
9360 stopQueue( data[ index ] );
|
|
9361 }
|
|
9362 } else {
|
|
9363 for ( index in data ) {
|
|
9364 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
|
|
9365 stopQueue( data[ index ] );
|
|
9366 }
|
|
9367 }
|
|
9368 }
|
|
9369
|
|
9370 for ( index = timers.length; index--; ) {
|
|
9371 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
|
|
9372 timers[ index ].anim.stop( gotoEnd );
|
|
9373 dequeue = false;
|
|
9374 timers.splice( index, 1 );
|
|
9375 }
|
|
9376 }
|
|
9377
|
|
9378 // start the next in the queue if the last step wasn't forced
|
|
9379 // timers currently will call their complete callbacks, which will dequeue
|
|
9380 // but only if they were gotoEnd
|
|
9381 if ( dequeue || !gotoEnd ) {
|
|
9382 jQuery.dequeue( this, type );
|
|
9383 }
|
|
9384 });
|
|
9385 },
|
|
9386 finish: function( type ) {
|
|
9387 if ( type !== false ) {
|
|
9388 type = type || "fx";
|
|
9389 }
|
|
9390 return this.each(function() {
|
|
9391 var index,
|
|
9392 data = jQuery._data( this ),
|
|
9393 queue = data[ type + "queue" ],
|
|
9394 hooks = data[ type + "queueHooks" ],
|
|
9395 timers = jQuery.timers,
|
|
9396 length = queue ? queue.length : 0;
|
|
9397
|
|
9398 // enable finishing flag on private data
|
|
9399 data.finish = true;
|
|
9400
|
|
9401 // empty the queue first
|
|
9402 jQuery.queue( this, type, [] );
|
|
9403
|
|
9404 if ( hooks && hooks.stop ) {
|
|
9405 hooks.stop.call( this, true );
|
|
9406 }
|
|
9407
|
|
9408 // look for any active animations, and finish them
|
|
9409 for ( index = timers.length; index--; ) {
|
|
9410 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
|
|
9411 timers[ index ].anim.stop( true );
|
|
9412 timers.splice( index, 1 );
|
|
9413 }
|
|
9414 }
|
|
9415
|
|
9416 // look for any animations in the old queue and finish them
|
|
9417 for ( index = 0; index < length; index++ ) {
|
|
9418 if ( queue[ index ] && queue[ index ].finish ) {
|
|
9419 queue[ index ].finish.call( this );
|
|
9420 }
|
|
9421 }
|
|
9422
|
|
9423 // turn off finishing flag
|
|
9424 delete data.finish;
|
|
9425 });
|
|
9426 }
|
|
9427 });
|
|
9428
|
|
9429 // Generate parameters to create a standard animation
|
|
9430 function genFx( type, includeWidth ) {
|
|
9431 var which,
|
|
9432 attrs = { height: type },
|
|
9433 i = 0;
|
|
9434
|
|
9435 // if we include width, step value is 1 to do all cssExpand values,
|
|
9436 // if we don't include width, step value is 2 to skip over Left and Right
|
|
9437 includeWidth = includeWidth? 1 : 0;
|
|
9438 for( ; i < 4 ; i += 2 - includeWidth ) {
|
|
9439 which = cssExpand[ i ];
|
|
9440 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
|
|
9441 }
|
|
9442
|
|
9443 if ( includeWidth ) {
|
|
9444 attrs.opacity = attrs.width = type;
|
|
9445 }
|
|
9446
|
|
9447 return attrs;
|
|
9448 }
|
|
9449
|
|
9450 // Generate shortcuts for custom animations
|
|
9451 jQuery.each({
|
|
9452 slideDown: genFx("show"),
|
|
9453 slideUp: genFx("hide"),
|
|
9454 slideToggle: genFx("toggle"),
|
|
9455 fadeIn: { opacity: "show" },
|
|
9456 fadeOut: { opacity: "hide" },
|
|
9457 fadeToggle: { opacity: "toggle" }
|
|
9458 }, function( name, props ) {
|
|
9459 jQuery.fn[ name ] = function( speed, easing, callback ) {
|
|
9460 return this.animate( props, speed, easing, callback );
|
|
9461 };
|
|
9462 });
|
|
9463
|
|
9464 jQuery.speed = function( speed, easing, fn ) {
|
|
9465 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
|
|
9466 complete: fn || !fn && easing ||
|
|
9467 jQuery.isFunction( speed ) && speed,
|
|
9468 duration: speed,
|
|
9469 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
|
|
9470 };
|
|
9471
|
|
9472 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
|
|
9473 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
|
|
9474
|
|
9475 // normalize opt.queue - true/undefined/null -> "fx"
|
|
9476 if ( opt.queue == null || opt.queue === true ) {
|
|
9477 opt.queue = "fx";
|
|
9478 }
|
|
9479
|
|
9480 // Queueing
|
|
9481 opt.old = opt.complete;
|
|
9482
|
|
9483 opt.complete = function() {
|
|
9484 if ( jQuery.isFunction( opt.old ) ) {
|
|
9485 opt.old.call( this );
|
|
9486 }
|
|
9487
|
|
9488 if ( opt.queue ) {
|
|
9489 jQuery.dequeue( this, opt.queue );
|
|
9490 }
|
|
9491 };
|
|
9492
|
|
9493 return opt;
|
|
9494 };
|
|
9495
|
|
9496 jQuery.easing = {
|
|
9497 linear: function( p ) {
|
|
9498 return p;
|
|
9499 },
|
|
9500 swing: function( p ) {
|
|
9501 return 0.5 - Math.cos( p*Math.PI ) / 2;
|
|
9502 }
|
|
9503 };
|
|
9504
|
|
9505 jQuery.timers = [];
|
|
9506 jQuery.fx = Tween.prototype.init;
|
|
9507 jQuery.fx.tick = function() {
|
|
9508 var timer,
|
|
9509 timers = jQuery.timers,
|
|
9510 i = 0;
|
|
9511
|
|
9512 fxNow = jQuery.now();
|
|
9513
|
|
9514 for ( ; i < timers.length; i++ ) {
|
|
9515 timer = timers[ i ];
|
|
9516 // Checks the timer has not already been removed
|
|
9517 if ( !timer() && timers[ i ] === timer ) {
|
|
9518 timers.splice( i--, 1 );
|
|
9519 }
|
|
9520 }
|
|
9521
|
|
9522 if ( !timers.length ) {
|
|
9523 jQuery.fx.stop();
|
|
9524 }
|
|
9525 fxNow = undefined;
|
|
9526 };
|
|
9527
|
|
9528 jQuery.fx.timer = function( timer ) {
|
|
9529 if ( timer() && jQuery.timers.push( timer ) ) {
|
|
9530 jQuery.fx.start();
|
|
9531 }
|
|
9532 };
|
|
9533
|
|
9534 jQuery.fx.interval = 13;
|
|
9535
|
|
9536 jQuery.fx.start = function() {
|
|
9537 if ( !timerId ) {
|
|
9538 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
|
|
9539 }
|
|
9540 };
|
|
9541
|
|
9542 jQuery.fx.stop = function() {
|
|
9543 clearInterval( timerId );
|
|
9544 timerId = null;
|
|
9545 };
|
|
9546
|
|
9547 jQuery.fx.speeds = {
|
|
9548 slow: 600,
|
|
9549 fast: 200,
|
|
9550 // Default speed
|
|
9551 _default: 400
|
|
9552 };
|
|
9553
|
|
9554 // Back Compat <1.8 extension point
|
|
9555 jQuery.fx.step = {};
|
|
9556
|
|
9557 if ( jQuery.expr && jQuery.expr.filters ) {
|
|
9558 jQuery.expr.filters.animated = function( elem ) {
|
|
9559 return jQuery.grep(jQuery.timers, function( fn ) {
|
|
9560 return elem === fn.elem;
|
|
9561 }).length;
|
|
9562 };
|
|
9563 }
|
|
9564 jQuery.fn.offset = function( options ) {
|
|
9565 if ( arguments.length ) {
|
|
9566 return options === undefined ?
|
|
9567 this :
|
|
9568 this.each(function( i ) {
|
|
9569 jQuery.offset.setOffset( this, options, i );
|
|
9570 });
|
|
9571 }
|
|
9572
|
|
9573 var docElem, win,
|
|
9574 box = { top: 0, left: 0 },
|
|
9575 elem = this[ 0 ],
|
|
9576 doc = elem && elem.ownerDocument;
|
|
9577
|
|
9578 if ( !doc ) {
|
|
9579 return;
|
|
9580 }
|
|
9581
|
|
9582 docElem = doc.documentElement;
|
|
9583
|
|
9584 // Make sure it's not a disconnected DOM node
|
|
9585 if ( !jQuery.contains( docElem, elem ) ) {
|
|
9586 return box;
|
|
9587 }
|
|
9588
|
|
9589 // If we don't have gBCR, just use 0,0 rather than error
|
|
9590 // BlackBerry 5, iOS 3 (original iPhone)
|
|
9591 if ( typeof elem.getBoundingClientRect !== core_strundefined ) {
|
|
9592 box = elem.getBoundingClientRect();
|
|
9593 }
|
|
9594 win = getWindow( doc );
|
|
9595 return {
|
|
9596 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
|
|
9597 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
|
|
9598 };
|
|
9599 };
|
|
9600
|
|
9601 jQuery.offset = {
|
|
9602
|
|
9603 setOffset: function( elem, options, i ) {
|
|
9604 var position = jQuery.css( elem, "position" );
|
|
9605
|
|
9606 // set position first, in-case top/left are set even on static elem
|
|
9607 if ( position === "static" ) {
|
|
9608 elem.style.position = "relative";
|
|
9609 }
|
|
9610
|
|
9611 var curElem = jQuery( elem ),
|
|
9612 curOffset = curElem.offset(),
|
|
9613 curCSSTop = jQuery.css( elem, "top" ),
|
|
9614 curCSSLeft = jQuery.css( elem, "left" ),
|
|
9615 calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
|
|
9616 props = {}, curPosition = {}, curTop, curLeft;
|
|
9617
|
|
9618 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
|
|
9619 if ( calculatePosition ) {
|
|
9620 curPosition = curElem.position();
|
|
9621 curTop = curPosition.top;
|
|
9622 curLeft = curPosition.left;
|
|
9623 } else {
|
|
9624 curTop = parseFloat( curCSSTop ) || 0;
|
|
9625 curLeft = parseFloat( curCSSLeft ) || 0;
|
|
9626 }
|
|
9627
|
|
9628 if ( jQuery.isFunction( options ) ) {
|
|
9629 options = options.call( elem, i, curOffset );
|
|
9630 }
|
|
9631
|
|
9632 if ( options.top != null ) {
|
|
9633 props.top = ( options.top - curOffset.top ) + curTop;
|
|
9634 }
|
|
9635 if ( options.left != null ) {
|
|
9636 props.left = ( options.left - curOffset.left ) + curLeft;
|
|
9637 }
|
|
9638
|
|
9639 if ( "using" in options ) {
|
|
9640 options.using.call( elem, props );
|
|
9641 } else {
|
|
9642 curElem.css( props );
|
|
9643 }
|
|
9644 }
|
|
9645 };
|
|
9646
|
|
9647
|
|
9648 jQuery.fn.extend({
|
|
9649
|
|
9650 position: function() {
|
|
9651 if ( !this[ 0 ] ) {
|
|
9652 return;
|
|
9653 }
|
|
9654
|
|
9655 var offsetParent, offset,
|
|
9656 parentOffset = { top: 0, left: 0 },
|
|
9657 elem = this[ 0 ];
|
|
9658
|
|
9659 // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is it's only offset parent
|
|
9660 if ( jQuery.css( elem, "position" ) === "fixed" ) {
|
|
9661 // we assume that getBoundingClientRect is available when computed position is fixed
|
|
9662 offset = elem.getBoundingClientRect();
|
|
9663 } else {
|
|
9664 // Get *real* offsetParent
|
|
9665 offsetParent = this.offsetParent();
|
|
9666
|
|
9667 // Get correct offsets
|
|
9668 offset = this.offset();
|
|
9669 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
|
|
9670 parentOffset = offsetParent.offset();
|
|
9671 }
|
|
9672
|
|
9673 // Add offsetParent borders
|
|
9674 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
|
|
9675 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
|
|
9676 }
|
|
9677
|
|
9678 // Subtract parent offsets and element margins
|
|
9679 // note: when an element has margin: auto the offsetLeft and marginLeft
|
|
9680 // are the same in Safari causing offset.left to incorrectly be 0
|
|
9681 return {
|
|
9682 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
|
|
9683 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
|
|
9684 };
|
|
9685 },
|
|
9686
|
|
9687 offsetParent: function() {
|
|
9688 return this.map(function() {
|
|
9689 var offsetParent = this.offsetParent || docElem;
|
|
9690 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position") === "static" ) ) {
|
|
9691 offsetParent = offsetParent.offsetParent;
|
|
9692 }
|
|
9693 return offsetParent || docElem;
|
|
9694 });
|
|
9695 }
|
|
9696 });
|
|
9697
|
|
9698
|
|
9699 // Create scrollLeft and scrollTop methods
|
|
9700 jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
|
|
9701 var top = /Y/.test( prop );
|
|
9702
|
|
9703 jQuery.fn[ method ] = function( val ) {
|
|
9704 return jQuery.access( this, function( elem, method, val ) {
|
|
9705 var win = getWindow( elem );
|
|
9706
|
|
9707 if ( val === undefined ) {
|
|
9708 return win ? (prop in win) ? win[ prop ] :
|
|
9709 win.document.documentElement[ method ] :
|
|
9710 elem[ method ];
|
|
9711 }
|
|
9712
|
|
9713 if ( win ) {
|
|
9714 win.scrollTo(
|
|
9715 !top ? val : jQuery( win ).scrollLeft(),
|
|
9716 top ? val : jQuery( win ).scrollTop()
|
|
9717 );
|
|
9718
|
|
9719 } else {
|
|
9720 elem[ method ] = val;
|
|
9721 }
|
|
9722 }, method, val, arguments.length, null );
|
|
9723 };
|
|
9724 });
|
|
9725
|
|
9726 function getWindow( elem ) {
|
|
9727 return jQuery.isWindow( elem ) ?
|
|
9728 elem :
|
|
9729 elem.nodeType === 9 ?
|
|
9730 elem.defaultView || elem.parentWindow :
|
|
9731 false;
|
|
9732 }
|
|
9733 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
|
|
9734 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
|
9735 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
|
|
9736 // margin is only for outerHeight, outerWidth
|
|
9737 jQuery.fn[ funcName ] = function( margin, value ) {
|
|
9738 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
|
|
9739 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
|
|
9740
|
|
9741 return jQuery.access( this, function( elem, type, value ) {
|
|
9742 var doc;
|
|
9743
|
|
9744 if ( jQuery.isWindow( elem ) ) {
|
|
9745 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
|
|
9746 // isn't a whole lot we can do. See pull request at this URL for discussion:
|
|
9747 // https://github.com/jquery/jquery/pull/764
|
|
9748 return elem.document.documentElement[ "client" + name ];
|
|
9749 }
|
|
9750
|
|
9751 // Get document width or height
|
|
9752 if ( elem.nodeType === 9 ) {
|
|
9753 doc = elem.documentElement;
|
|
9754
|
|
9755 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
|
|
9756 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
|
|
9757 return Math.max(
|
|
9758 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
|
|
9759 elem.body[ "offset" + name ], doc[ "offset" + name ],
|
|
9760 doc[ "client" + name ]
|
|
9761 );
|
|
9762 }
|
|
9763
|
|
9764 return value === undefined ?
|
|
9765 // Get width or height on the element, requesting but not forcing parseFloat
|
|
9766 jQuery.css( elem, type, extra ) :
|
|
9767
|
|
9768 // Set width or height on the element
|
|
9769 jQuery.style( elem, type, value, extra );
|
|
9770 }, type, chainable ? margin : undefined, chainable, null );
|
|
9771 };
|
|
9772 });
|
|
9773 });
|
|
9774 // Limit scope pollution from any deprecated API
|
|
9775 // (function() {
|
|
9776
|
|
9777 // The number of elements contained in the matched element set
|
|
9778 jQuery.fn.size = function() {
|
|
9779 return this.length;
|
|
9780 };
|
|
9781
|
|
9782 jQuery.fn.andSelf = jQuery.fn.addBack;
|
|
9783
|
|
9784 // })();
|
|
9785 if ( typeof module === "object" && module && typeof module.exports === "object" ) {
|
|
9786 // Expose jQuery as module.exports in loaders that implement the Node
|
|
9787 // module pattern (including browserify). Do not create the global, since
|
|
9788 // the user will be storing it themselves locally, and globals are frowned
|
|
9789 // upon in the Node module world.
|
|
9790 module.exports = jQuery;
|
|
9791 } else {
|
|
9792 // Otherwise expose jQuery to the global object as usual
|
|
9793 window.jQuery = window.$ = jQuery;
|
|
9794
|
|
9795 // Register as a named AMD module, since jQuery can be concatenated with other
|
|
9796 // files that may use define, but not via a proper concatenation script that
|
|
9797 // understands anonymous AMD modules. A named AMD is safest and most robust
|
|
9798 // way to register. Lowercase jquery is used because AMD module names are
|
|
9799 // derived from file names, and jQuery is normally delivered in a lowercase
|
|
9800 // file name. Do this after creating the global so that if an AMD module wants
|
|
9801 // to call noConflict to hide this version of jQuery, it will work.
|
|
9802 if ( typeof define === "function" && define.amd ) {
|
|
9803 define( "jquery", [], function () { return jQuery; } );
|
|
9804 }
|
|
9805 }
|
|
9806
|
|
9807 })( window );
|