OLD | NEW |
| (Empty) |
1 /*! | |
2 * jQuery JavaScript Library v1.9.0 | |
3 * http://jquery.com/ | |
4 * | |
5 * Includes Sizzle.js | |
6 * http://sizzlejs.com/ | |
7 * | |
8 * Copyright 2005, 2012 jQuery Foundation, Inc. and other contributors | |
9 * Released under the MIT license | |
10 * http://jquery.org/license | |
11 * | |
12 * Date: 2013-1-14 | |
13 */ | |
14 (function( window, undefined ) { | |
15 "use strict"; | |
16 var | |
17 // A central reference to the root jQuery(document) | |
18 rootjQuery, | |
19 | |
20 // The deferred used on DOM ready | |
21 readyList, | |
22 | |
23 // Use the correct document accordingly with window argument (sandbox) | |
24 document = window.document, | |
25 location = window.location, | |
26 | |
27 // Map over jQuery in case of overwrite | |
28 _jQuery = window.jQuery, | |
29 | |
30 // Map over the $ in case of overwrite | |
31 _$ = window.$, | |
32 | |
33 // [[Class]] -> type pairs | |
34 class2type = {}, | |
35 | |
36 // List of deleted data cache ids, so we can reuse them | |
37 core_deletedIds = [], | |
38 | |
39 core_version = "1.9.0", | |
40 | |
41 // Save a reference to some core methods | |
42 core_concat = core_deletedIds.concat, | |
43 core_push = core_deletedIds.push, | |
44 core_slice = core_deletedIds.slice, | |
45 core_indexOf = core_deletedIds.indexOf, | |
46 core_toString = class2type.toString, | |
47 core_hasOwn = class2type.hasOwnProperty, | |
48 core_trim = core_version.trim, | |
49 | |
50 // Define a local copy of jQuery | |
51 jQuery = function( selector, context ) { | |
52 // The jQuery object is actually just the init constructor 'enha
nced' | |
53 return new jQuery.fn.init( selector, context, rootjQuery ); | |
54 }, | |
55 | |
56 // Used for matching numbers | |
57 core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, | |
58 | |
59 // Used for splitting on whitespace | |
60 core_rnotwhite = /\S+/g, | |
61 | |
62 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and
IE) | |
63 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, | |
64 | |
65 // A simple way to check for HTML strings | |
66 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) | |
67 // Strict HTML recognition (#11290: must start with <) | |
68 rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/, | |
69 | |
70 // Match a standalone tag | |
71 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, | |
72 | |
73 // JSON RegExp | |
74 rvalidchars = /^[\],:{}\s]*$/, | |
75 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, | |
76 rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, | |
77 rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]
?\d+|)/g, | |
78 | |
79 // Matches dashed string for camelizing | |
80 rmsPrefix = /^-ms-/, | |
81 rdashAlpha = /-([\da-z])/gi, | |
82 | |
83 // Used by jQuery.camelCase as callback to replace() | |
84 fcamelCase = function( all, letter ) { | |
85 return letter.toUpperCase(); | |
86 }, | |
87 | |
88 // The ready event handler and self cleanup method | |
89 DOMContentLoaded = function() { | |
90 if ( document.addEventListener ) { | |
91 document.removeEventListener( "DOMContentLoaded", DOMCon
tentLoaded, false ); | |
92 jQuery.ready(); | |
93 } else if ( document.readyState === "complete" ) { | |
94 // we're here because readyState === "complete" in oldIE | |
95 // which is good enough for us to call the dom ready! | |
96 document.detachEvent( "onreadystatechange", DOMContentLo
aded ); | |
97 jQuery.ready(); | |
98 } | |
99 }; | |
100 | |
101 jQuery.fn = jQuery.prototype = { | |
102 // The current version of jQuery being used | |
103 jquery: core_version, | |
104 | |
105 constructor: jQuery, | |
106 init: function( selector, context, rootjQuery ) { | |
107 var match, elem; | |
108 | |
109 // HANDLE: $(""), $(null), $(undefined), $(false) | |
110 if ( !selector ) { | |
111 return this; | |
112 } | |
113 | |
114 // Handle HTML strings | |
115 if ( typeof selector === "string" ) { | |
116 if ( selector.charAt(0) === "<" && selector.charAt( sele
ctor.length - 1 ) === ">" && selector.length >= 3 ) { | |
117 // Assume that strings that start and end with <
> are HTML and skip the regex check | |
118 match = [ null, selector, null ]; | |
119 | |
120 } else { | |
121 match = rquickExpr.exec( selector ); | |
122 } | |
123 | |
124 // Match html or make sure no context is specified for #
id | |
125 if ( match && (match[1] || !context) ) { | |
126 | |
127 // HANDLE: $(html) -> $(array) | |
128 if ( match[1] ) { | |
129 context = context instanceof jQuery ? co
ntext[0] : context; | |
130 | |
131 // scripts is true for back-compat | |
132 jQuery.merge( this, jQuery.parseHTML( | |
133 match[1], | |
134 context && context.nodeType ? co
ntext.ownerDocument || context : document, | |
135 true | |
136 ) ); | |
137 | |
138 // HANDLE: $(html, props) | |
139 if ( rsingleTag.test( match[1] ) && jQue
ry.isPlainObject( context ) ) { | |
140 for ( match in context ) { | |
141 // Properties of context
are called as methods if possible | |
142 if ( jQuery.isFunction(
this[ match ] ) ) { | |
143 this[ match ]( c
ontext[ match ] ); | |
144 | |
145 // ...and otherwise set
as attributes | |
146 } else { | |
147 this.attr( match
, context[ match ] ); | |
148 } | |
149 } | |
150 } | |
151 | |
152 return this; | |
153 | |
154 // HANDLE: $(#id) | |
155 } else { | |
156 elem = document.getElementById( match[2]
); | |
157 | |
158 // Check parentNode to catch when Blackb
erry 4.6 returns | |
159 // nodes that are no longer in the docum
ent #6963 | |
160 if ( elem && elem.parentNode ) { | |
161 // Handle the case where IE and
Opera return items | |
162 // by name instead of ID | |
163 if ( elem.id !== match[2] ) { | |
164 return rootjQuery.find(
selector ); | |
165 } | |
166 | |
167 // Otherwise, we inject the elem
ent directly into the jQuery object | |
168 this.length = 1; | |
169 this[0] = elem; | |
170 } | |
171 | |
172 this.context = document; | |
173 this.selector = selector; | |
174 return this; | |
175 } | |
176 | |
177 // HANDLE: $(expr, $(...)) | |
178 } else if ( !context || context.jquery ) { | |
179 return ( context || rootjQuery ).find( selector
); | |
180 | |
181 // HANDLE: $(expr, context) | |
182 // (which is just equivalent to: $(context).find(expr) | |
183 } else { | |
184 return this.constructor( context ).find( selecto
r ); | |
185 } | |
186 | |
187 // HANDLE: $(DOMElement) | |
188 } else if ( selector.nodeType ) { | |
189 this.context = this[0] = selector; | |
190 this.length = 1; | |
191 return this; | |
192 | |
193 // HANDLE: $(function) | |
194 // Shortcut for document ready | |
195 } else if ( jQuery.isFunction( selector ) ) { | |
196 return rootjQuery.ready( selector ); | |
197 } | |
198 | |
199 if ( selector.selector !== undefined ) { | |
200 this.selector = selector.selector; | |
201 this.context = selector.context; | |
202 } | |
203 | |
204 return jQuery.makeArray( selector, this ); | |
205 }, | |
206 | |
207 // Start with an empty selector | |
208 selector: "", | |
209 | |
210 // The default length of a jQuery object is 0 | |
211 length: 0, | |
212 | |
213 // The number of elements contained in the matched element set | |
214 size: function() { | |
215 return this.length; | |
216 }, | |
217 | |
218 toArray: function() { | |
219 return core_slice.call( this ); | |
220 }, | |
221 | |
222 // Get the Nth element in the matched element set OR | |
223 // Get the whole matched element set as a clean array | |
224 get: function( num ) { | |
225 return num == null ? | |
226 | |
227 // Return a 'clean' array | |
228 this.toArray() : | |
229 | |
230 // Return just the object | |
231 ( num < 0 ? this[ this.length + num ] : this[ num ] ); | |
232 }, | |
233 | |
234 // Take an array of elements and push it onto the stack | |
235 // (returning the new matched element set) | |
236 pushStack: function( elems ) { | |
237 | |
238 // Build a new jQuery matched element set | |
239 var ret = jQuery.merge( this.constructor(), elems ); | |
240 | |
241 // Add the old object onto the stack (as a reference) | |
242 ret.prevObject = this; | |
243 ret.context = this.context; | |
244 | |
245 // Return the newly-formed element set | |
246 return ret; | |
247 }, | |
248 | |
249 // Execute a callback for every element in the matched set. | |
250 // (You can seed the arguments with an array of args, but this is | |
251 // only used internally.) | |
252 each: function( callback, args ) { | |
253 return jQuery.each( this, callback, args ); | |
254 }, | |
255 | |
256 ready: function( fn ) { | |
257 // Add the callback | |
258 jQuery.ready.promise().done( fn ); | |
259 | |
260 return this; | |
261 }, | |
262 | |
263 slice: function() { | |
264 return this.pushStack( core_slice.apply( this, arguments ) ); | |
265 }, | |
266 | |
267 first: function() { | |
268 return this.eq( 0 ); | |
269 }, | |
270 | |
271 last: function() { | |
272 return this.eq( -1 ); | |
273 }, | |
274 | |
275 eq: function( i ) { | |
276 var len = this.length, | |
277 j = +i + ( i < 0 ? len : 0 ); | |
278 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); | |
279 }, | |
280 | |
281 map: function( callback ) { | |
282 return this.pushStack( jQuery.map(this, function( elem, i ) { | |
283 return callback.call( elem, i, elem ); | |
284 })); | |
285 }, | |
286 | |
287 end: function() { | |
288 return this.prevObject || this.constructor(null); | |
289 }, | |
290 | |
291 // For internal use only. | |
292 // Behaves like an Array's method, not like a jQuery method. | |
293 push: core_push, | |
294 sort: [].sort, | |
295 splice: [].splice | |
296 }; | |
297 | |
298 // Give the init function the jQuery prototype for later instantiation | |
299 jQuery.fn.init.prototype = jQuery.fn; | |
300 | |
301 jQuery.extend = jQuery.fn.extend = function() { | |
302 var options, name, src, copy, copyIsArray, clone, | |
303 target = arguments[0] || {}, | |
304 i = 1, | |
305 length = arguments.length, | |
306 deep = false; | |
307 | |
308 // Handle a deep copy situation | |
309 if ( typeof target === "boolean" ) { | |
310 deep = target; | |
311 target = arguments[1] || {}; | |
312 // skip the boolean and the target | |
313 i = 2; | |
314 } | |
315 | |
316 // Handle case when target is a string or something (possible in deep co
py) | |
317 if ( typeof target !== "object" && !jQuery.isFunction(target) ) { | |
318 target = {}; | |
319 } | |
320 | |
321 // extend jQuery itself if only one argument is passed | |
322 if ( length === i ) { | |
323 target = this; | |
324 --i; | |
325 } | |
326 | |
327 for ( ; i < length; i++ ) { | |
328 // Only deal with non-null/undefined values | |
329 if ( (options = arguments[ i ]) != null ) { | |
330 // Extend the base object | |
331 for ( name in options ) { | |
332 src = target[ name ]; | |
333 copy = options[ name ]; | |
334 | |
335 // Prevent never-ending loop | |
336 if ( target === copy ) { | |
337 continue; | |
338 } | |
339 | |
340 // Recurse if we're merging plain objects or arr
ays | |
341 if ( deep && copy && ( jQuery.isPlainObject(copy
) || (copyIsArray = jQuery.isArray(copy)) ) ) { | |
342 if ( copyIsArray ) { | |
343 copyIsArray = false; | |
344 clone = src && jQuery.isArray(sr
c) ? src : []; | |
345 | |
346 } else { | |
347 clone = src && jQuery.isPlainObj
ect(src) ? src : {}; | |
348 } | |
349 | |
350 // Never move original objects, clone th
em | |
351 target[ name ] = jQuery.extend( deep, cl
one, copy ); | |
352 | |
353 // Don't bring in undefined values | |
354 } else if ( copy !== undefined ) { | |
355 target[ name ] = copy; | |
356 } | |
357 } | |
358 } | |
359 } | |
360 | |
361 // Return the modified object | |
362 return target; | |
363 }; | |
364 | |
365 jQuery.extend({ | |
366 noConflict: function( deep ) { | |
367 if ( window.$ === jQuery ) { | |
368 window.$ = _$; | |
369 } | |
370 | |
371 if ( deep && window.jQuery === jQuery ) { | |
372 window.jQuery = _jQuery; | |
373 } | |
374 | |
375 return jQuery; | |
376 }, | |
377 | |
378 // Is the DOM ready to be used? Set to true once it occurs. | |
379 isReady: false, | |
380 | |
381 // A counter to track how many items to wait for before | |
382 // the ready event fires. See #6781 | |
383 readyWait: 1, | |
384 | |
385 // Hold (or release) the ready event | |
386 holdReady: function( hold ) { | |
387 if ( hold ) { | |
388 jQuery.readyWait++; | |
389 } else { | |
390 jQuery.ready( true ); | |
391 } | |
392 }, | |
393 | |
394 // Handle when the DOM is ready | |
395 ready: function( wait ) { | |
396 | |
397 // Abort if there are pending holds or we're already ready | |
398 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { | |
399 return; | |
400 } | |
401 | |
402 // Make sure body exists, at least, in case IE gets a little ove
rzealous (ticket #5443). | |
403 if ( !document.body ) { | |
404 return setTimeout( jQuery.ready ); | |
405 } | |
406 | |
407 // Remember that the DOM is ready | |
408 jQuery.isReady = true; | |
409 | |
410 // If a normal DOM Ready event fired, decrement, and wait if nee
d be | |
411 if ( wait !== true && --jQuery.readyWait > 0 ) { | |
412 return; | |
413 } | |
414 | |
415 // If there are functions bound, to execute | |
416 readyList.resolveWith( document, [ jQuery ] ); | |
417 | |
418 // Trigger any bound ready events | |
419 if ( jQuery.fn.trigger ) { | |
420 jQuery( document ).trigger("ready").off("ready"); | |
421 } | |
422 }, | |
423 | |
424 // See test/unit/core.js for details concerning isFunction. | |
425 // Since version 1.3, DOM methods and functions like alert | |
426 // aren't supported. They return false on IE (#2968). | |
427 isFunction: function( obj ) { | |
428 return jQuery.type(obj) === "function"; | |
429 }, | |
430 | |
431 isArray: Array.isArray || function( obj ) { | |
432 return jQuery.type(obj) === "array"; | |
433 }, | |
434 | |
435 isWindow: function( obj ) { | |
436 return obj != null && obj == obj.window; | |
437 }, | |
438 | |
439 isNumeric: function( obj ) { | |
440 return !isNaN( parseFloat(obj) ) && isFinite( obj ); | |
441 }, | |
442 | |
443 type: function( obj ) { | |
444 if ( obj == null ) { | |
445 return String( obj ); | |
446 } | |
447 return typeof obj === "object" || typeof obj === "function" ? | |
448 class2type[ core_toString.call(obj) ] || "object" : | |
449 typeof obj; | |
450 }, | |
451 | |
452 isPlainObject: function( obj ) { | |
453 // Must be an Object. | |
454 // Because of IE, we also have to check the presence of the cons
tructor property. | |
455 // Make sure that DOM nodes and window objects don't pass throug
h, as well | |
456 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQ
uery.isWindow( obj ) ) { | |
457 return false; | |
458 } | |
459 | |
460 try { | |
461 // Not own constructor property must be Object | |
462 if ( obj.constructor && | |
463 !core_hasOwn.call(obj, "constructor") && | |
464 !core_hasOwn.call(obj.constructor.prototype, "is
PrototypeOf") ) { | |
465 return false; | |
466 } | |
467 } catch ( e ) { | |
468 // IE8,9 Will throw exceptions on certain host objects #
9897 | |
469 return false; | |
470 } | |
471 | |
472 // Own properties are enumerated firstly, so to speed up, | |
473 // if last one is own, then all properties are own. | |
474 | |
475 var key; | |
476 for ( key in obj ) {} | |
477 | |
478 return key === undefined || core_hasOwn.call( obj, key ); | |
479 }, | |
480 | |
481 isEmptyObject: function( obj ) { | |
482 var name; | |
483 for ( name in obj ) { | |
484 return false; | |
485 } | |
486 return true; | |
487 }, | |
488 | |
489 error: function( msg ) { | |
490 throw new Error( msg ); | |
491 }, | |
492 | |
493 // data: string of html | |
494 // context (optional): If specified, the fragment will be created in thi
s context, defaults to document | |
495 // keepScripts (optional): If true, will include scripts passed in the h
tml string | |
496 parseHTML: function( data, context, keepScripts ) { | |
497 if ( !data || typeof data !== "string" ) { | |
498 return null; | |
499 } | |
500 if ( typeof context === "boolean" ) { | |
501 keepScripts = context; | |
502 context = false; | |
503 } | |
504 context = context || document; | |
505 | |
506 var parsed = rsingleTag.exec( data ), | |
507 scripts = !keepScripts && []; | |
508 | |
509 // Single tag | |
510 if ( parsed ) { | |
511 return [ context.createElement( parsed[1] ) ]; | |
512 } | |
513 | |
514 parsed = jQuery.buildFragment( [ data ], context, scripts ); | |
515 if ( scripts ) { | |
516 jQuery( scripts ).remove(); | |
517 } | |
518 return jQuery.merge( [], parsed.childNodes ); | |
519 }, | |
520 | |
521 parseJSON: function( data ) { | |
522 // Attempt to parse using the native JSON parser first | |
523 if ( window.JSON && window.JSON.parse ) { | |
524 return window.JSON.parse( data ); | |
525 } | |
526 | |
527 if ( data === null ) { | |
528 return data; | |
529 } | |
530 | |
531 if ( typeof data === "string" ) { | |
532 | |
533 // Make sure leading/trailing whitespace is removed (IE
can't handle it) | |
534 data = jQuery.trim( data ); | |
535 | |
536 if ( data ) { | |
537 // Make sure the incoming data is actual JSON | |
538 // Logic borrowed from http://json.org/json2.js | |
539 if ( rvalidchars.test( data.replace( rvalidescap
e, "@" ) | |
540 .replace( rvalidtokens, "]" ) | |
541 .replace( rvalidbraces, "")) ) { | |
542 | |
543 return ( new Function( "return " + data
) )(); | |
544 } | |
545 } | |
546 } | |
547 | |
548 jQuery.error( "Invalid JSON: " + data ); | |
549 }, | |
550 | |
551 // Cross-browser xml parsing | |
552 parseXML: function( data ) { | |
553 var xml, tmp; | |
554 if ( !data || typeof data !== "string" ) { | |
555 return null; | |
556 } | |
557 try { | |
558 if ( window.DOMParser ) { // Standard | |
559 tmp = new DOMParser(); | |
560 xml = tmp.parseFromString( data , "text/xml" ); | |
561 } else { // IE | |
562 xml = new ActiveXObject( "Microsoft.XMLDOM" ); | |
563 xml.async = "false"; | |
564 xml.loadXML( data ); | |
565 } | |
566 } catch( e ) { | |
567 xml = undefined; | |
568 } | |
569 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "
parsererror" ).length ) { | |
570 jQuery.error( "Invalid XML: " + data ); | |
571 } | |
572 return xml; | |
573 }, | |
574 | |
575 noop: function() {}, | |
576 | |
577 // Evaluates a script in a global context | |
578 // Workarounds based on findings by Jim Driscoll | |
579 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascr
ipt-global-context | |
580 globalEval: function( data ) { | |
581 if ( data && jQuery.trim( data ) ) { | |
582 // We use execScript on Internet Explorer | |
583 // We use an anonymous function so that context is windo
w | |
584 // rather than jQuery in Firefox | |
585 ( window.execScript || function( data ) { | |
586 window[ "eval" ].call( window, data ); | |
587 } )( data ); | |
588 } | |
589 }, | |
590 | |
591 // Convert dashed to camelCase; used by the css and data modules | |
592 // Microsoft forgot to hump their vendor prefix (#9572) | |
593 camelCase: function( string ) { | |
594 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, f
camelCase ); | |
595 }, | |
596 | |
597 nodeName: function( elem, name ) { | |
598 return elem.nodeName && elem.nodeName.toLowerCase() === name.toL
owerCase(); | |
599 }, | |
600 | |
601 // args is for internal usage only | |
602 each: function( obj, callback, args ) { | |
603 var value, | |
604 i = 0, | |
605 length = obj.length, | |
606 isArray = isArraylike( obj ); | |
607 | |
608 if ( args ) { | |
609 if ( isArray ) { | |
610 for ( ; i < length; i++ ) { | |
611 value = callback.apply( obj[ i ], args )
; | |
612 | |
613 if ( value === false ) { | |
614 break; | |
615 } | |
616 } | |
617 } else { | |
618 for ( i in obj ) { | |
619 value = callback.apply( obj[ i ], args )
; | |
620 | |
621 if ( value === false ) { | |
622 break; | |
623 } | |
624 } | |
625 } | |
626 | |
627 // A special, fast, case for the most common use of each | |
628 } else { | |
629 if ( isArray ) { | |
630 for ( ; i < length; i++ ) { | |
631 value = callback.call( obj[ i ], i, obj[
i ] ); | |
632 | |
633 if ( value === false ) { | |
634 break; | |
635 } | |
636 } | |
637 } else { | |
638 for ( i in obj ) { | |
639 value = callback.call( obj[ i ], i, obj[
i ] ); | |
640 | |
641 if ( value === false ) { | |
642 break; | |
643 } | |
644 } | |
645 } | |
646 } | |
647 | |
648 return obj; | |
649 }, | |
650 | |
651 // Use native String.trim function wherever possible | |
652 trim: core_trim && !core_trim.call("\uFEFF\xA0") ? | |
653 function( text ) { | |
654 return text == null ? | |
655 "" : | |
656 core_trim.call( text ); | |
657 } : | |
658 | |
659 // Otherwise use our own trimming functionality | |
660 function( text ) { | |
661 return text == null ? | |
662 "" : | |
663 ( text + "" ).replace( rtrim, "" ); | |
664 }, | |
665 | |
666 // results is for internal usage only | |
667 makeArray: function( arr, results ) { | |
668 var ret = results || []; | |
669 | |
670 if ( arr != null ) { | |
671 if ( isArraylike( Object(arr) ) ) { | |
672 jQuery.merge( ret, | |
673 typeof arr === "string" ? | |
674 [ arr ] : arr | |
675 ); | |
676 } else { | |
677 core_push.call( ret, arr ); | |
678 } | |
679 } | |
680 | |
681 return ret; | |
682 }, | |
683 | |
684 inArray: function( elem, arr, i ) { | |
685 var len; | |
686 | |
687 if ( arr ) { | |
688 if ( core_indexOf ) { | |
689 return core_indexOf.call( arr, elem, i ); | |
690 } | |
691 | |
692 len = arr.length; | |
693 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; | |
694 | |
695 for ( ; i < len; i++ ) { | |
696 // Skip accessing in sparse arrays | |
697 if ( i in arr && arr[ i ] === elem ) { | |
698 return i; | |
699 } | |
700 } | |
701 } | |
702 | |
703 return -1; | |
704 }, | |
705 | |
706 merge: function( first, second ) { | |
707 var l = second.length, | |
708 i = first.length, | |
709 j = 0; | |
710 | |
711 if ( typeof l === "number" ) { | |
712 for ( ; j < l; j++ ) { | |
713 first[ i++ ] = second[ j ]; | |
714 } | |
715 } else { | |
716 while ( second[j] !== undefined ) { | |
717 first[ i++ ] = second[ j++ ]; | |
718 } | |
719 } | |
720 | |
721 first.length = i; | |
722 | |
723 return first; | |
724 }, | |
725 | |
726 grep: function( elems, callback, inv ) { | |
727 var retVal, | |
728 ret = [], | |
729 i = 0, | |
730 length = elems.length; | |
731 inv = !!inv; | |
732 | |
733 // Go through the array, only saving the items | |
734 // that pass the validator function | |
735 for ( ; i < length; i++ ) { | |
736 retVal = !!callback( elems[ i ], i ); | |
737 if ( inv !== retVal ) { | |
738 ret.push( elems[ i ] ); | |
739 } | |
740 } | |
741 | |
742 return ret; | |
743 }, | |
744 | |
745 // arg is for internal usage only | |
746 map: function( elems, callback, arg ) { | |
747 var value, | |
748 i = 0, | |
749 length = elems.length, | |
750 isArray = isArraylike( elems ), | |
751 ret = []; | |
752 | |
753 // Go through the array, translating each of the items to their | |
754 if ( isArray ) { | |
755 for ( ; i < length; i++ ) { | |
756 value = callback( elems[ i ], i, arg ); | |
757 | |
758 if ( value != null ) { | |
759 ret[ ret.length ] = value; | |
760 } | |
761 } | |
762 | |
763 // Go through every key on the object, | |
764 } else { | |
765 for ( i in elems ) { | |
766 value = callback( elems[ i ], i, arg ); | |
767 | |
768 if ( value != null ) { | |
769 ret[ ret.length ] = value; | |
770 } | |
771 } | |
772 } | |
773 | |
774 // Flatten any nested arrays | |
775 return core_concat.apply( [], ret ); | |
776 }, | |
777 | |
778 // A global GUID counter for objects | |
779 guid: 1, | |
780 | |
781 // Bind a function to a context, optionally partially applying any | |
782 // arguments. | |
783 proxy: function( fn, context ) { | |
784 var tmp, args, proxy; | |
785 | |
786 if ( typeof context === "string" ) { | |
787 tmp = fn[ context ]; | |
788 context = fn; | |
789 fn = tmp; | |
790 } | |
791 | |
792 // Quick check to determine if target is callable, in the spec | |
793 // this throws a TypeError, but we will just return undefined. | |
794 if ( !jQuery.isFunction( fn ) ) { | |
795 return undefined; | |
796 } | |
797 | |
798 // Simulated bind | |
799 args = core_slice.call( arguments, 2 ); | |
800 proxy = function() { | |
801 return fn.apply( context || this, args.concat( core_slic
e.call( arguments ) ) ); | |
802 }; | |
803 | |
804 // Set the guid of unique handler to the same of original handle
r, so it can be removed | |
805 proxy.guid = fn.guid = fn.guid || jQuery.guid++; | |
806 | |
807 return proxy; | |
808 }, | |
809 | |
810 // Multifunctional method to get and set values of a collection | |
811 // The value/s can optionally be executed if it's a function | |
812 access: function( elems, fn, key, value, chainable, emptyGet, raw ) { | |
813 var i = 0, | |
814 length = elems.length, | |
815 bulk = key == null; | |
816 | |
817 // Sets many values | |
818 if ( jQuery.type( key ) === "object" ) { | |
819 chainable = true; | |
820 for ( i in key ) { | |
821 jQuery.access( elems, fn, i, key[i], true, empty
Get, raw ); | |
822 } | |
823 | |
824 // Sets one value | |
825 } else if ( value !== undefined ) { | |
826 chainable = true; | |
827 | |
828 if ( !jQuery.isFunction( value ) ) { | |
829 raw = true; | |
830 } | |
831 | |
832 if ( bulk ) { | |
833 // Bulk operations run against the entire set | |
834 if ( raw ) { | |
835 fn.call( elems, value ); | |
836 fn = null; | |
837 | |
838 // ...except when executing function values | |
839 } else { | |
840 bulk = fn; | |
841 fn = function( elem, key, value ) { | |
842 return bulk.call( jQuery( elem )
, value ); | |
843 }; | |
844 } | |
845 } | |
846 | |
847 if ( fn ) { | |
848 for ( ; i < length; i++ ) { | |
849 fn( elems[i], key, raw ? value : value.c
all( elems[i], i, fn( elems[i], key ) ) ); | |
850 } | |
851 } | |
852 } | |
853 | |
854 return chainable ? | |
855 elems : | |
856 | |
857 // Gets | |
858 bulk ? | |
859 fn.call( elems ) : | |
860 length ? fn( elems[0], key ) : emptyGet; | |
861 }, | |
862 | |
863 now: function() { | |
864 return ( new Date() ).getTime(); | |
865 } | |
866 }); | |
867 | |
868 jQuery.ready.promise = function( obj ) { | |
869 if ( !readyList ) { | |
870 | |
871 readyList = jQuery.Deferred(); | |
872 | |
873 // Catch cases where $(document).ready() is called after the bro
wser event has already occurred. | |
874 // we once tried to use readyState "interactive" here, but it ca
used issues like the one | |
875 // discovered by ChrisS here: http://bugs.jquery.com/ticket/1228
2#comment:15 | |
876 if ( document.readyState === "complete" ) { | |
877 // Handle it asynchronously to allow scripts the opportu
nity to delay ready | |
878 setTimeout( jQuery.ready ); | |
879 | |
880 // Standards-based browsers support DOMContentLoaded | |
881 } else if ( document.addEventListener ) { | |
882 // Use the handy event callback | |
883 document.addEventListener( "DOMContentLoaded", DOMConten
tLoaded, false ); | |
884 | |
885 // A fallback to window.onload, that will always work | |
886 window.addEventListener( "load", jQuery.ready, false ); | |
887 | |
888 // If IE event model is used | |
889 } else { | |
890 // Ensure firing before onload, maybe late but safe also
for iframes | |
891 document.attachEvent( "onreadystatechange", DOMContentLo
aded ); | |
892 | |
893 // A fallback to window.onload, that will always work | |
894 window.attachEvent( "onload", jQuery.ready ); | |
895 | |
896 // If IE and not a frame | |
897 // continually check to see if the document is ready | |
898 var top = false; | |
899 | |
900 try { | |
901 top = window.frameElement == null && document.do
cumentElement; | |
902 } catch(e) {} | |
903 | |
904 if ( top && top.doScroll ) { | |
905 (function doScrollCheck() { | |
906 if ( !jQuery.isReady ) { | |
907 | |
908 try { | |
909 // Use the trick by Dieg
o Perini | |
910 // http://javascript.nwb
ox.com/IEContentLoaded/ | |
911 top.doScroll("left"); | |
912 } catch(e) { | |
913 return setTimeout( doScr
ollCheck, 50 ); | |
914 } | |
915 | |
916 // and execute any waiting funct
ions | |
917 jQuery.ready(); | |
918 } | |
919 })(); | |
920 } | |
921 } | |
922 } | |
923 return readyList.promise( obj ); | |
924 }; | |
925 | |
926 // Populate the class2type map | |
927 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".spli
t(" "), function(i, name) { | |
928 class2type[ "[object " + name + "]" ] = name.toLowerCase(); | |
929 }); | |
930 | |
931 function isArraylike( obj ) { | |
932 var length = obj.length, | |
933 type = jQuery.type( obj ); | |
934 | |
935 if ( jQuery.isWindow( obj ) ) { | |
936 return false; | |
937 } | |
938 | |
939 if ( obj.nodeType === 1 && length ) { | |
940 return true; | |
941 } | |
942 | |
943 return type === "array" || type !== "function" && | |
944 ( length === 0 || | |
945 typeof length === "number" && length > 0 && ( length - 1 ) in ob
j ); | |
946 } | |
947 | |
948 // All jQuery objects should point back to these | |
949 rootjQuery = jQuery(document); | |
950 // String to Object options format cache | |
951 var optionsCache = {}; | |
952 | |
953 // Convert String-formatted options into Object-formatted ones and store in cach
e | |
954 function createOptions( options ) { | |
955 var object = optionsCache[ options ] = {}; | |
956 jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag )
{ | |
957 object[ flag ] = true; | |
958 }); | |
959 return object; | |
960 } | |
961 | |
962 /* | |
963 * Create a callback list using the following parameters: | |
964 * | |
965 * options: an optional list of space-separated options that will change ho
w | |
966 * the callback list behaves or a more traditional option o
bject | |
967 * | |
968 * By default a callback list will act like an event callback list and can be | |
969 * "fired" multiple times. | |
970 * | |
971 * Possible options: | |
972 * | |
973 * once: will ensure the callback list can only be fired
once (like a Deferred) | |
974 * | |
975 * memory: will keep track of previous values and will call
any callback added | |
976 * after the list has been fired right away
with the latest "memorized" | |
977 * values (like a Deferred) | |
978 * | |
979 * unique: will ensure a callback can only be added once (n
o duplicate in the list) | |
980 * | |
981 * stopOnFalse: interrupt callings when a callback returns false | |
982 * | |
983 */ | |
984 jQuery.Callbacks = function( options ) { | |
985 | |
986 // Convert options from String-formatted to Object-formatted if needed | |
987 // (we check in cache first) | |
988 options = typeof options === "string" ? | |
989 ( optionsCache[ options ] || createOptions( options ) ) : | |
990 jQuery.extend( {}, options ); | |
991 | |
992 var // Last fire value (for non-forgettable lists) | |
993 memory, | |
994 // Flag to know if list was already fired | |
995 fired, | |
996 // Flag to know if list is currently firing | |
997 firing, | |
998 // First callback to fire (used internally by add and fireWith) | |
999 firingStart, | |
1000 // End of the loop when firing | |
1001 firingLength, | |
1002 // Index of currently firing callback (modified by remove if nee
ded) | |
1003 firingIndex, | |
1004 // Actual callback list | |
1005 list = [], | |
1006 // Stack of fire calls for repeatable lists | |
1007 stack = !options.once && [], | |
1008 // Fire callbacks | |
1009 fire = function( data ) { | |
1010 memory = options.memory && data; | |
1011 fired = true; | |
1012 firingIndex = firingStart || 0; | |
1013 firingStart = 0; | |
1014 firingLength = list.length; | |
1015 firing = true; | |
1016 for ( ; list && firingIndex < firingLength; firingIndex+
+ ) { | |
1017 if ( list[ firingIndex ].apply( data[ 0 ], data[
1 ] ) === false && options.stopOnFalse ) { | |
1018 memory = false; // To prevent further ca
lls using add | |
1019 break; | |
1020 } | |
1021 } | |
1022 firing = false; | |
1023 if ( list ) { | |
1024 if ( stack ) { | |
1025 if ( stack.length ) { | |
1026 fire( stack.shift() ); | |
1027 } | |
1028 } else if ( memory ) { | |
1029 list = []; | |
1030 } else { | |
1031 self.disable(); | |
1032 } | |
1033 } | |
1034 }, | |
1035 // Actual Callbacks object | |
1036 self = { | |
1037 // Add a callback or a collection of callbacks to the li
st | |
1038 add: function() { | |
1039 if ( list ) { | |
1040 // First, we save the current length | |
1041 var start = list.length; | |
1042 (function add( args ) { | |
1043 jQuery.each( args, function( _,
arg ) { | |
1044 var type = jQuery.type(
arg ); | |
1045 if ( type === "function"
) { | |
1046 if ( !options.un
ique || !self.has( arg ) ) { | |
1047 list.pus
h( arg ); | |
1048 } | |
1049 } else if ( arg && arg.l
ength && type !== "string" ) { | |
1050 // Inspect recur
sively | |
1051 add( arg ); | |
1052 } | |
1053 }); | |
1054 })( arguments ); | |
1055 // Do we need to add the callbacks to th
e | |
1056 // current firing batch? | |
1057 if ( firing ) { | |
1058 firingLength = list.length; | |
1059 // With memory, if we're not firing then | |
1060 // we should call right away | |
1061 } else if ( memory ) { | |
1062 firingStart = start; | |
1063 fire( memory ); | |
1064 } | |
1065 } | |
1066 return this; | |
1067 }, | |
1068 // Remove a callback from the list | |
1069 remove: function() { | |
1070 if ( list ) { | |
1071 jQuery.each( arguments, function( _, arg
) { | |
1072 var index; | |
1073 while( ( index = jQuery.inArray(
arg, list, index ) ) > -1 ) { | |
1074 list.splice( index, 1 ); | |
1075 // Handle firing indexes | |
1076 if ( firing ) { | |
1077 if ( index <= fi
ringLength ) { | |
1078 firingLe
ngth--; | |
1079 } | |
1080 if ( index <= fi
ringIndex ) { | |
1081 firingIn
dex--; | |
1082 } | |
1083 } | |
1084 } | |
1085 }); | |
1086 } | |
1087 return this; | |
1088 }, | |
1089 // Control if a given callback is in the list | |
1090 has: function( fn ) { | |
1091 return jQuery.inArray( fn, list ) > -1; | |
1092 }, | |
1093 // Remove all callbacks from the list | |
1094 empty: function() { | |
1095 list = []; | |
1096 return this; | |
1097 }, | |
1098 // Have the list do nothing anymore | |
1099 disable: function() { | |
1100 list = stack = memory = undefined; | |
1101 return this; | |
1102 }, | |
1103 // Is it disabled? | |
1104 disabled: function() { | |
1105 return !list; | |
1106 }, | |
1107 // Lock the list in its current state | |
1108 lock: function() { | |
1109 stack = undefined; | |
1110 if ( !memory ) { | |
1111 self.disable(); | |
1112 } | |
1113 return this; | |
1114 }, | |
1115 // Is it locked? | |
1116 locked: function() { | |
1117 return !stack; | |
1118 }, | |
1119 // Call all callbacks with the given context and argumen
ts | |
1120 fireWith: function( context, args ) { | |
1121 args = args || []; | |
1122 args = [ context, args.slice ? args.slice() : ar
gs ]; | |
1123 if ( list && ( !fired || stack ) ) { | |
1124 if ( firing ) { | |
1125 stack.push( args ); | |
1126 } else { | |
1127 fire( args ); | |
1128 } | |
1129 } | |
1130 return this; | |
1131 }, | |
1132 // Call all the callbacks with the given arguments | |
1133 fire: function() { | |
1134 self.fireWith( this, arguments ); | |
1135 return this; | |
1136 }, | |
1137 // To know if the callbacks have already been called at
least once | |
1138 fired: function() { | |
1139 return !!fired; | |
1140 } | |
1141 }; | |
1142 | |
1143 return self; | |
1144 }; | |
1145 jQuery.extend({ | |
1146 | |
1147 Deferred: function( func ) { | |
1148 var tuples = [ | |
1149 // action, add listener, listener list, final st
ate | |
1150 [ "resolve", "done", jQuery.Callbacks("once memo
ry"), "resolved" ], | |
1151 [ "reject", "fail", jQuery.Callbacks("once memor
y"), "rejected" ], | |
1152 [ "notify", "progress", jQuery.Callbacks("memory
") ] | |
1153 ], | |
1154 state = "pending", | |
1155 promise = { | |
1156 state: function() { | |
1157 return state; | |
1158 }, | |
1159 always: function() { | |
1160 deferred.done( arguments ).fail( argumen
ts ); | |
1161 return this; | |
1162 }, | |
1163 then: function( /* fnDone, fnFail, fnProgress */
) { | |
1164 var fns = arguments; | |
1165 return jQuery.Deferred(function( newDefe
r ) { | |
1166 jQuery.each( tuples, function( i
, tuple ) { | |
1167 var action = tuple[ 0 ], | |
1168 fn = jQuery.isFu
nction( fns[ i ] ) && fns[ i ]; | |
1169 // deferred[ done | fail
| progress ] for forwarding actions to newDefer | |
1170 deferred[ tuple[1] ](fun
ction() { | |
1171 var returned = f
n && fn.apply( this, arguments ); | |
1172 if ( returned &&
jQuery.isFunction( returned.promise ) ) { | |
1173 returned
.promise() | |
1174
.done( newDefer.resolve ) | |
1175
.fail( newDefer.reject ) | |
1176
.progress( newDefer.notify ); | |
1177 } else { | |
1178 newDefer
[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ return
ed ] : arguments ); | |
1179 } | |
1180 }); | |
1181 }); | |
1182 fns = null; | |
1183 }).promise(); | |
1184 }, | |
1185 // Get a promise for this deferred | |
1186 // If obj is provided, the promise aspect is add
ed to the object | |
1187 promise: function( obj ) { | |
1188 return obj != null ? jQuery.extend( obj,
promise ) : promise; | |
1189 } | |
1190 }, | |
1191 deferred = {}; | |
1192 | |
1193 // Keep pipe for back-compat | |
1194 promise.pipe = promise.then; | |
1195 | |
1196 // Add list-specific methods | |
1197 jQuery.each( tuples, function( i, tuple ) { | |
1198 var list = tuple[ 2 ], | |
1199 stateString = tuple[ 3 ]; | |
1200 | |
1201 // promise[ done | fail | progress ] = list.add | |
1202 promise[ tuple[1] ] = list.add; | |
1203 | |
1204 // Handle state | |
1205 if ( stateString ) { | |
1206 list.add(function() { | |
1207 // state = [ resolved | rejected ] | |
1208 state = stateString; | |
1209 | |
1210 // [ reject_list | resolve_list ].disable; progr
ess_list.lock | |
1211 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2
].lock ); | |
1212 } | |
1213 | |
1214 // deferred[ resolve | reject | notify ] | |
1215 deferred[ tuple[0] ] = function() { | |
1216 deferred[ tuple[0] + "With" ]( this === deferred
? promise : this, arguments ); | |
1217 return this; | |
1218 }; | |
1219 deferred[ tuple[0] + "With" ] = list.fireWith; | |
1220 }); | |
1221 | |
1222 // Make the deferred a promise | |
1223 promise.promise( deferred ); | |
1224 | |
1225 // Call given func if any | |
1226 if ( func ) { | |
1227 func.call( deferred, deferred ); | |
1228 } | |
1229 | |
1230 // All done! | |
1231 return deferred; | |
1232 }, | |
1233 | |
1234 // Deferred helper | |
1235 when: function( subordinate /* , ..., subordinateN */ ) { | |
1236 var i = 0, | |
1237 resolveValues = core_slice.call( arguments ), | |
1238 length = resolveValues.length, | |
1239 | |
1240 // the count of uncompleted subordinates | |
1241 remaining = length !== 1 || ( subordinate && jQuery.isFu
nction( subordinate.promise ) ) ? length : 0, | |
1242 | |
1243 // the master Deferred. If resolveValues consist of only
a single Deferred, just use that. | |
1244 deferred = remaining === 1 ? subordinate : jQuery.Deferr
ed(), | |
1245 | |
1246 // Update function for both resolve and progress values | |
1247 updateFunc = function( i, contexts, values ) { | |
1248 return function( value ) { | |
1249 contexts[ i ] = this; | |
1250 values[ i ] = arguments.length > 1 ? cor
e_slice.call( arguments ) : value; | |
1251 if( values === progressValues ) { | |
1252 deferred.notifyWith( contexts, v
alues ); | |
1253 } else if ( !( --remaining ) ) { | |
1254 deferred.resolveWith( contexts,
values ); | |
1255 } | |
1256 }; | |
1257 }, | |
1258 | |
1259 progressValues, progressContexts, resolveContexts; | |
1260 | |
1261 // add listeners to Deferred subordinates; treat others as resol
ved | |
1262 if ( length > 1 ) { | |
1263 progressValues = new Array( length ); | |
1264 progressContexts = new Array( length ); | |
1265 resolveContexts = new Array( length ); | |
1266 for ( ; i < length; i++ ) { | |
1267 if ( resolveValues[ i ] && jQuery.isFunction( re
solveValues[ i ].promise ) ) { | |
1268 resolveValues[ i ].promise() | |
1269 .done( updateFunc( i, resolveCon
texts, resolveValues ) ) | |
1270 .fail( deferred.reject ) | |
1271 .progress( updateFunc( i, progre
ssContexts, progressValues ) ); | |
1272 } else { | |
1273 --remaining; | |
1274 } | |
1275 } | |
1276 } | |
1277 | |
1278 // if we're not waiting on anything, resolve the master | |
1279 if ( !remaining ) { | |
1280 deferred.resolveWith( resolveContexts, resolveValues ); | |
1281 } | |
1282 | |
1283 return deferred.promise(); | |
1284 } | |
1285 }); | |
1286 jQuery.support = (function() { | |
1287 | |
1288 var support, all, a, select, opt, input, fragment, eventName, isSupporte
d, i, | |
1289 div = document.createElement("div"); | |
1290 | |
1291 // Setup | |
1292 div.setAttribute( "className", "t" ); | |
1293 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='
checkbox'/>"; | |
1294 | |
1295 // Support tests won't run in some limited or non-browser environments | |
1296 all = div.getElementsByTagName("*"); | |
1297 a = div.getElementsByTagName("a")[ 0 ]; | |
1298 if ( !all || !a || !all.length ) { | |
1299 return {}; | |
1300 } | |
1301 | |
1302 // First batch of tests | |
1303 select = document.createElement("select"); | |
1304 opt = select.appendChild( document.createElement("option") ); | |
1305 input = div.getElementsByTagName("input")[ 0 ]; | |
1306 | |
1307 a.style.cssText = "top:1px;float:left;opacity:.5"; | |
1308 support = { | |
1309 // Test setAttribute on camelCase class. If it works, we need at
trFixes when doing get/setAttribute (ie6/7) | |
1310 getSetAttribute: div.className !== "t", | |
1311 | |
1312 // IE strips leading whitespace when .innerHTML is used | |
1313 leadingWhitespace: div.firstChild.nodeType === 3, | |
1314 | |
1315 // Make sure that tbody elements aren't automatically inserted | |
1316 // IE will insert them into empty tables | |
1317 tbody: !div.getElementsByTagName("tbody").length, | |
1318 | |
1319 // Make sure that link elements get serialized correctly by inne
rHTML | |
1320 // This requires a wrapper element in IE | |
1321 htmlSerialize: !!div.getElementsByTagName("link").length, | |
1322 | |
1323 // Get the style information from getAttribute | |
1324 // (IE uses .cssText instead) | |
1325 style: /top/.test( a.getAttribute("style") ), | |
1326 | |
1327 // Make sure that URLs aren't manipulated | |
1328 // (IE normalizes it by default) | |
1329 hrefNormalized: a.getAttribute("href") === "/a", | |
1330 | |
1331 // Make sure that element opacity exists | |
1332 // (IE uses filter instead) | |
1333 // Use a regex to work around a WebKit issue. See #5145 | |
1334 opacity: /^0.5/.test( a.style.opacity ), | |
1335 | |
1336 // Verify style float existence | |
1337 // (IE uses styleFloat instead of cssFloat) | |
1338 cssFloat: !!a.style.cssFloat, | |
1339 | |
1340 // Check the default checkbox/radio value ("" on WebKit; "on" el
sewhere) | |
1341 checkOn: !!input.value, | |
1342 | |
1343 // Make sure that a selected-by-default option has a working sel
ected property. | |
1344 // (WebKit defaults to false instead of true, IE too, if it's in
an optgroup) | |
1345 optSelected: opt.selected, | |
1346 | |
1347 // Tests for enctype support on a form (#6743) | |
1348 enctype: !!document.createElement("form").enctype, | |
1349 | |
1350 // Makes sure cloning an html5 element does not cause problems | |
1351 // Where outerHTML is undefined, this still works | |
1352 html5Clone: document.createElement("nav").cloneNode( true ).oute
rHTML !== "<:nav></:nav>", | |
1353 | |
1354 // jQuery.support.boxModel DEPRECATED in 1.8 since we don't supp
ort Quirks Mode | |
1355 boxModel: document.compatMode === "CSS1Compat", | |
1356 | |
1357 // Will be defined later | |
1358 deleteExpando: true, | |
1359 noCloneEvent: true, | |
1360 inlineBlockNeedsLayout: false, | |
1361 shrinkWrapBlocks: false, | |
1362 reliableMarginRight: true, | |
1363 boxSizingReliable: true, | |
1364 pixelPosition: false | |
1365 }; | |
1366 | |
1367 // Make sure checked status is properly cloned | |
1368 input.checked = true; | |
1369 support.noCloneChecked = input.cloneNode( true ).checked; | |
1370 | |
1371 // Make sure that the options inside disabled selects aren't marked as d
isabled | |
1372 // (WebKit marks them as disabled) | |
1373 select.disabled = true; | |
1374 support.optDisabled = !opt.disabled; | |
1375 | |
1376 // Support: IE<9 | |
1377 try { | |
1378 delete div.test; | |
1379 } catch( e ) { | |
1380 support.deleteExpando = false; | |
1381 } | |
1382 | |
1383 // Check if we can trust getAttribute("value") | |
1384 input = document.createElement("input"); | |
1385 input.setAttribute( "value", "" ); | |
1386 support.input = input.getAttribute( "value" ) === ""; | |
1387 | |
1388 // Check if an input maintains its value after becoming a radio | |
1389 input.value = "t"; | |
1390 input.setAttribute( "type", "radio" ); | |
1391 support.radioValue = input.value === "t"; | |
1392 | |
1393 // #11217 - WebKit loses check when the name is after the checked attrib
ute | |
1394 input.setAttribute( "checked", "t" ); | |
1395 input.setAttribute( "name", "t" ); | |
1396 | |
1397 fragment = document.createDocumentFragment(); | |
1398 fragment.appendChild( input ); | |
1399 | |
1400 // Check if a disconnected checkbox will retain its checked | |
1401 // value of true after appended to the DOM (IE6/7) | |
1402 support.appendChecked = input.checked; | |
1403 | |
1404 // WebKit doesn't clone checked state correctly in fragments | |
1405 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastCh
ild.checked; | |
1406 | |
1407 // Support: IE<9 | |
1408 // Opera does not clone events (and typeof div.attachEvent === undefined
). | |
1409 // IE9-10 clones events bound via attachEvent, but they don't trigger wi
th .click() | |
1410 if ( div.attachEvent ) { | |
1411 div.attachEvent( "onclick", function() { | |
1412 support.noCloneEvent = false; | |
1413 }); | |
1414 | |
1415 div.cloneNode( true ).click(); | |
1416 } | |
1417 | |
1418 // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin
event) | |
1419 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security
/CSP), test/csp.php | |
1420 for ( i in { submit: true, change: true, focusin: true }) { | |
1421 div.setAttribute( eventName = "on" + i, "t" ); | |
1422 | |
1423 support[ i + "Bubbles" ] = eventName in window || div.attributes
[ eventName ].expando === false; | |
1424 } | |
1425 | |
1426 div.style.backgroundClip = "content-box"; | |
1427 div.cloneNode( true ).style.backgroundClip = ""; | |
1428 support.clearCloneStyle = div.style.backgroundClip === "content-box"; | |
1429 | |
1430 // Run tests that need a body at doc ready | |
1431 jQuery(function() { | |
1432 var container, marginDiv, tds, | |
1433 divReset = "padding:0;margin:0;border:0;display:block;bo
x-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;
", | |
1434 body = document.getElementsByTagName("body")[0]; | |
1435 | |
1436 if ( !body ) { | |
1437 // Return for frameset docs that don't have a body | |
1438 return; | |
1439 } | |
1440 | |
1441 container = document.createElement("div"); | |
1442 container.style.cssText = "border:0;width:0;height:0;position:ab
solute;top:0;left:-9999px;margin-top:1px"; | |
1443 | |
1444 body.appendChild( container ).appendChild( div ); | |
1445 | |
1446 // Support: IE8 | |
1447 // Check if table cells still have offsetWidth/Height when they
are set | |
1448 // to display:none and there are still other visible table cells
in a | |
1449 // table row; if so, offsetWidth/Height are not reliable for use
when | |
1450 // determining if an element has been hidden directly using | |
1451 // display:none (it is still safe to use offsets if a parent ele
ment is | |
1452 // hidden; don safety goggles and see bug #4512 for more informa
tion). | |
1453 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>"; | |
1454 tds = div.getElementsByTagName("td"); | |
1455 tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:no
ne"; | |
1456 isSupported = ( tds[ 0 ].offsetHeight === 0 ); | |
1457 | |
1458 tds[ 0 ].style.display = ""; | |
1459 tds[ 1 ].style.display = "none"; | |
1460 | |
1461 // Support: IE8 | |
1462 // Check if empty table cells still have offsetWidth/Height | |
1463 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offset
Height === 0 ); | |
1464 | |
1465 // Check box-sizing and margin behavior | |
1466 div.innerHTML = ""; | |
1467 div.style.cssText = "box-sizing:border-box;-moz-box-sizing:borde
r-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4
px;margin-top:1%;position:absolute;top:1%;"; | |
1468 support.boxSizing = ( div.offsetWidth === 4 ); | |
1469 support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !==
1 ); | |
1470 | |
1471 // Use window.getComputedStyle because jsdom on node.js will bre
ak without it. | |
1472 if ( window.getComputedStyle ) { | |
1473 support.pixelPosition = ( window.getComputedStyle( div,
null ) || {} ).top !== "1%"; | |
1474 support.boxSizingReliable = ( window.getComputedStyle( d
iv, null ) || { width: "4px" } ).width === "4px"; | |
1475 | |
1476 // Check if div with explicit width and no margin-right
incorrectly | |
1477 // gets computed margin-right based on width of containe
r. (#3333) | |
1478 // Fails in WebKit before Feb 2011 nightlies | |
1479 // WebKit Bug 13343 - getComputedStyle returns wrong val
ue for margin-right | |
1480 marginDiv = div.appendChild( document.createElement("div
") ); | |
1481 marginDiv.style.cssText = div.style.cssText = divReset; | |
1482 marginDiv.style.marginRight = marginDiv.style.width = "0
"; | |
1483 div.style.width = "1px"; | |
1484 | |
1485 support.reliableMarginRight = | |
1486 !parseFloat( ( window.getComputedStyle( marginDi
v, null ) || {} ).marginRight ); | |
1487 } | |
1488 | |
1489 if ( typeof div.style.zoom !== "undefined" ) { | |
1490 // Support: IE<8 | |
1491 // Check if natively block-level elements act like inlin
e-block | |
1492 // elements when setting their display to 'inline' and g
iving | |
1493 // them layout | |
1494 div.innerHTML = ""; | |
1495 div.style.cssText = divReset + "width:1px;padding:1px;di
splay:inline;zoom:1"; | |
1496 support.inlineBlockNeedsLayout = ( div.offsetWidth === 3
); | |
1497 | |
1498 // Support: IE6 | |
1499 // Check if elements with layout shrink-wrap their child
ren | |
1500 div.style.display = "block"; | |
1501 div.innerHTML = "<div></div>"; | |
1502 div.firstChild.style.width = "5px"; | |
1503 support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); | |
1504 | |
1505 // Prevent IE 6 from affecting layout for positioned ele
ments #11048 | |
1506 // Prevent IE from shrinking the body in IE 7 mode #1286
9 | |
1507 body.style.zoom = 1; | |
1508 } | |
1509 | |
1510 body.removeChild( container ); | |
1511 | |
1512 // Null elements to avoid leaks in IE | |
1513 container = div = tds = marginDiv = null; | |
1514 }); | |
1515 | |
1516 // Null elements to avoid leaks in IE | |
1517 all = select = fragment = opt = a = input = null; | |
1518 | |
1519 return support; | |
1520 })(); | |
1521 | |
1522 var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, | |
1523 rmultiDash = /([A-Z])/g; | |
1524 | |
1525 function internalData( elem, name, data, pvt /* Internal Use Only */ ){ | |
1526 if ( !jQuery.acceptData( elem ) ) { | |
1527 return; | |
1528 } | |
1529 | |
1530 var thisCache, ret, | |
1531 internalKey = jQuery.expando, | |
1532 getByName = typeof name === "string", | |
1533 | |
1534 // We have to handle DOM nodes and JS objects differently becaus
e IE6-7 | |
1535 // can't GC object references properly across the DOM-JS boundar
y | |
1536 isNode = elem.nodeType, | |
1537 | |
1538 // Only DOM nodes need the global jQuery cache; JS object data i
s | |
1539 // attached directly to the object so GC can occur automatically | |
1540 cache = isNode ? jQuery.cache : elem, | |
1541 | |
1542 // Only defining an ID for JS objects if its cache already exist
s allows | |
1543 // the code to shortcut on the same path as a DOM node with no c
ache | |
1544 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && inter
nalKey; | |
1545 | |
1546 // Avoid doing any more work than we need to when trying to get data on
an | |
1547 // object that has no data at all | |
1548 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && da
ta === undefined ) { | |
1549 return; | |
1550 } | |
1551 | |
1552 if ( !id ) { | |
1553 // Only DOM nodes need a new unique ID for each element since th
eir data | |
1554 // ends up in the global cache | |
1555 if ( isNode ) { | |
1556 elem[ internalKey ] = id = core_deletedIds.pop() || jQue
ry.guid++; | |
1557 } else { | |
1558 id = internalKey; | |
1559 } | |
1560 } | |
1561 | |
1562 if ( !cache[ id ] ) { | |
1563 cache[ id ] = {}; | |
1564 | |
1565 // Avoids exposing jQuery metadata on plain JS objects when the
object | |
1566 // is serialized using JSON.stringify | |
1567 if ( !isNode ) { | |
1568 cache[ id ].toJSON = jQuery.noop; | |
1569 } | |
1570 } | |
1571 | |
1572 // An object can be passed to jQuery.data instead of a key/value pair; t
his gets | |
1573 // shallow copied over onto the existing cache | |
1574 if ( typeof name === "object" || typeof name === "function" ) { | |
1575 if ( pvt ) { | |
1576 cache[ id ] = jQuery.extend( cache[ id ], name ); | |
1577 } else { | |
1578 cache[ id ].data = jQuery.extend( cache[ id ].data, name
); | |
1579 } | |
1580 } | |
1581 | |
1582 thisCache = cache[ id ]; | |
1583 | |
1584 // jQuery data() is stored in a separate object inside the object's inte
rnal data | |
1585 // cache in order to avoid key collisions between internal data and user
-defined | |
1586 // data. | |
1587 if ( !pvt ) { | |
1588 if ( !thisCache.data ) { | |
1589 thisCache.data = {}; | |
1590 } | |
1591 | |
1592 thisCache = thisCache.data; | |
1593 } | |
1594 | |
1595 if ( data !== undefined ) { | |
1596 thisCache[ jQuery.camelCase( name ) ] = data; | |
1597 } | |
1598 | |
1599 // Check for both converted-to-camel and non-converted data property nam
es | |
1600 // If a data property was specified | |
1601 if ( getByName ) { | |
1602 | |
1603 // First Try to find as-is property data | |
1604 ret = thisCache[ name ]; | |
1605 | |
1606 // Test for null|undefined property data | |
1607 if ( ret == null ) { | |
1608 | |
1609 // Try to find the camelCased property | |
1610 ret = thisCache[ jQuery.camelCase( name ) ]; | |
1611 } | |
1612 } else { | |
1613 ret = thisCache; | |
1614 } | |
1615 | |
1616 return ret; | |
1617 } | |
1618 | |
1619 function internalRemoveData( elem, name, pvt /* For internal use only */ ){ | |
1620 if ( !jQuery.acceptData( elem ) ) { | |
1621 return; | |
1622 } | |
1623 | |
1624 var thisCache, i, l, | |
1625 | |
1626 isNode = elem.nodeType, | |
1627 | |
1628 // See jQuery.data for more information | |
1629 cache = isNode ? jQuery.cache : elem, | |
1630 id = isNode ? elem[ jQuery.expando ] : jQuery.expando; | |
1631 | |
1632 // If there is already no cache entry for this object, there is no | |
1633 // purpose in continuing | |
1634 if ( !cache[ id ] ) { | |
1635 return; | |
1636 } | |
1637 | |
1638 if ( name ) { | |
1639 | |
1640 thisCache = pvt ? cache[ id ] : cache[ id ].data; | |
1641 | |
1642 if ( thisCache ) { | |
1643 | |
1644 // Support array or space separated string names for dat
a keys | |
1645 if ( !jQuery.isArray( name ) ) { | |
1646 | |
1647 // try the string as a key before any manipulati
on | |
1648 if ( name in thisCache ) { | |
1649 name = [ name ]; | |
1650 } else { | |
1651 | |
1652 // split the camel cased version by spac
es unless a key with the spaces exists | |
1653 name = jQuery.camelCase( name ); | |
1654 if ( name in thisCache ) { | |
1655 name = [ name ]; | |
1656 } else { | |
1657 name = name.split(" "); | |
1658 } | |
1659 } | |
1660 } else { | |
1661 // If "name" is an array of keys... | |
1662 // When data is initially created, via ("key", "
val") signature, | |
1663 // keys will be converted to camelCase. | |
1664 // Since there is no way to tell _how_ a key was
added, remove | |
1665 // both plain key and camelCase key. #12786 | |
1666 // This will only penalize the array argument pa
th. | |
1667 name = name.concat( jQuery.map( name, jQuery.cam
elCase ) ); | |
1668 } | |
1669 | |
1670 for ( i = 0, l = name.length; i < l; i++ ) { | |
1671 delete thisCache[ name[i] ]; | |
1672 } | |
1673 | |
1674 // If there is no data left in the cache, we want to con
tinue | |
1675 // and let the cache object itself get destroyed | |
1676 if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )
( thisCache ) ) { | |
1677 return; | |
1678 } | |
1679 } | |
1680 } | |
1681 | |
1682 // See jQuery.data for more information | |
1683 if ( !pvt ) { | |
1684 delete cache[ id ].data; | |
1685 | |
1686 // Don't destroy the parent cache unless the internal data objec
t | |
1687 // had been the only thing left in it | |
1688 if ( !isEmptyDataObject( cache[ id ] ) ) { | |
1689 return; | |
1690 } | |
1691 } | |
1692 | |
1693 // Destroy the cache | |
1694 if ( isNode ) { | |
1695 jQuery.cleanData( [ elem ], true ); | |
1696 | |
1697 // Use delete when supported for expandos or `cache` is not a window per
isWindow (#10080) | |
1698 } else if ( jQuery.support.deleteExpando || cache != cache.window ) { | |
1699 delete cache[ id ]; | |
1700 | |
1701 // When all else fails, null | |
1702 } else { | |
1703 cache[ id ] = null; | |
1704 } | |
1705 } | |
1706 | |
1707 jQuery.extend({ | |
1708 cache: {}, | |
1709 | |
1710 // Unique for each copy of jQuery on the page | |
1711 // Non-digits removed to match rinlinejQuery | |
1712 expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, ""
), | |
1713 | |
1714 // The following elements throw uncatchable exceptions if you | |
1715 // attempt to add expando properties to them. | |
1716 noData: { | |
1717 "embed": true, | |
1718 // Ban all objects except for Flash (which handle expandos) | |
1719 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", | |
1720 "applet": true | |
1721 }, | |
1722 | |
1723 hasData: function( elem ) { | |
1724 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : el
em[ jQuery.expando ]; | |
1725 return !!elem && !isEmptyDataObject( elem ); | |
1726 }, | |
1727 | |
1728 data: function( elem, name, data ) { | |
1729 return internalData( elem, name, data, false ); | |
1730 }, | |
1731 | |
1732 removeData: function( elem, name ) { | |
1733 return internalRemoveData( elem, name, false ); | |
1734 }, | |
1735 | |
1736 // For internal use only. | |
1737 _data: function( elem, name, data ) { | |
1738 return internalData( elem, name, data, true ); | |
1739 }, | |
1740 | |
1741 _removeData: function( elem, name ) { | |
1742 return internalRemoveData( elem, name, true ); | |
1743 }, | |
1744 | |
1745 // A method for determining if a DOM node can handle the data expando | |
1746 acceptData: function( elem ) { | |
1747 var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLow
erCase() ]; | |
1748 | |
1749 // nodes accept data unless otherwise specified; rejection can b
e conditional | |
1750 return !noData || noData !== true && elem.getAttribute("classid"
) === noData; | |
1751 } | |
1752 }); | |
1753 | |
1754 jQuery.fn.extend({ | |
1755 data: function( key, value ) { | |
1756 var attrs, name, | |
1757 elem = this[0], | |
1758 i = 0, | |
1759 data = null; | |
1760 | |
1761 // Gets all values | |
1762 if ( key === undefined ) { | |
1763 if ( this.length ) { | |
1764 data = jQuery.data( elem ); | |
1765 | |
1766 if ( elem.nodeType === 1 && !jQuery._data( elem,
"parsedAttrs" ) ) { | |
1767 attrs = elem.attributes; | |
1768 for ( ; i < attrs.length; i++ ) { | |
1769 name = attrs[i].name; | |
1770 | |
1771 if ( !name.indexOf( "data-" ) )
{ | |
1772 name = jQuery.camelCase(
name.substring(5) ); | |
1773 | |
1774 dataAttr( elem, name, da
ta[ name ] ); | |
1775 } | |
1776 } | |
1777 jQuery._data( elem, "parsedAttrs", true
); | |
1778 } | |
1779 } | |
1780 | |
1781 return data; | |
1782 } | |
1783 | |
1784 // Sets multiple values | |
1785 if ( typeof key === "object" ) { | |
1786 return this.each(function() { | |
1787 jQuery.data( this, key ); | |
1788 }); | |
1789 } | |
1790 | |
1791 return jQuery.access( this, function( value ) { | |
1792 | |
1793 if ( value === undefined ) { | |
1794 // Try to fetch any internally stored data first | |
1795 return elem ? dataAttr( elem, key, jQuery.data(
elem, key ) ) : null; | |
1796 } | |
1797 | |
1798 this.each(function() { | |
1799 jQuery.data( this, key, value ); | |
1800 }); | |
1801 }, null, value, arguments.length > 1, null, true ); | |
1802 }, | |
1803 | |
1804 removeData: function( key ) { | |
1805 return this.each(function() { | |
1806 jQuery.removeData( this, key ); | |
1807 }); | |
1808 } | |
1809 }); | |
1810 | |
1811 function dataAttr( elem, key, data ) { | |
1812 // If nothing was found internally, try to fetch any | |
1813 // data from the HTML5 data-* attribute | |
1814 if ( data === undefined && elem.nodeType === 1 ) { | |
1815 | |
1816 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCas
e(); | |
1817 | |
1818 data = elem.getAttribute( name ); | |
1819 | |
1820 if ( typeof data === "string" ) { | |
1821 try { | |
1822 data = data === "true" ? true : | |
1823 data === "false" ? false : | |
1824 data === "null" ? null : | |
1825 // Only convert to a number if it doesn't change
the string | |
1826 +data + "" === data ? +data : | |
1827 rbrace.test( data ) ? jQuery.parseJSON( data ) : | |
1828 data; | |
1829 } catch( e ) {} | |
1830 | |
1831 // Make sure we set the data so it isn't changed later | |
1832 jQuery.data( elem, key, data ); | |
1833 | |
1834 } else { | |
1835 data = undefined; | |
1836 } | |
1837 } | |
1838 | |
1839 return data; | |
1840 } | |
1841 | |
1842 // checks a cache object for emptiness | |
1843 function isEmptyDataObject( obj ) { | |
1844 var name; | |
1845 for ( name in obj ) { | |
1846 | |
1847 // if the public data object is empty, the private is still empt
y | |
1848 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { | |
1849 continue; | |
1850 } | |
1851 if ( name !== "toJSON" ) { | |
1852 return false; | |
1853 } | |
1854 } | |
1855 | |
1856 return true; | |
1857 } | |
1858 jQuery.extend({ | |
1859 queue: function( elem, type, data ) { | |
1860 var queue; | |
1861 | |
1862 if ( elem ) { | |
1863 type = ( type || "fx" ) + "queue"; | |
1864 queue = jQuery._data( elem, type ); | |
1865 | |
1866 // Speed up dequeue by getting out quickly if this is ju
st a lookup | |
1867 if ( data ) { | |
1868 if ( !queue || jQuery.isArray(data) ) { | |
1869 queue = jQuery._data( elem, type, jQuery
.makeArray(data) ); | |
1870 } else { | |
1871 queue.push( data ); | |
1872 } | |
1873 } | |
1874 return queue || []; | |
1875 } | |
1876 }, | |
1877 | |
1878 dequeue: function( elem, type ) { | |
1879 type = type || "fx"; | |
1880 | |
1881 var queue = jQuery.queue( elem, type ), | |
1882 startLength = queue.length, | |
1883 fn = queue.shift(), | |
1884 hooks = jQuery._queueHooks( elem, type ), | |
1885 next = function() { | |
1886 jQuery.dequeue( elem, type ); | |
1887 }; | |
1888 | |
1889 // If the fx queue is dequeued, always remove the progress senti
nel | |
1890 if ( fn === "inprogress" ) { | |
1891 fn = queue.shift(); | |
1892 startLength--; | |
1893 } | |
1894 | |
1895 hooks.cur = fn; | |
1896 if ( fn ) { | |
1897 | |
1898 // Add a progress sentinel to prevent the fx queue from
being | |
1899 // automatically dequeued | |
1900 if ( type === "fx" ) { | |
1901 queue.unshift( "inprogress" ); | |
1902 } | |
1903 | |
1904 // clear up the last queue stop function | |
1905 delete hooks.stop; | |
1906 fn.call( elem, next, hooks ); | |
1907 } | |
1908 | |
1909 if ( !startLength && hooks ) { | |
1910 hooks.empty.fire(); | |
1911 } | |
1912 }, | |
1913 | |
1914 // not intended for public consumption - generates a queueHooks object,
or returns the current one | |
1915 _queueHooks: function( elem, type ) { | |
1916 var key = type + "queueHooks"; | |
1917 return jQuery._data( elem, key ) || jQuery._data( elem, key, { | |
1918 empty: jQuery.Callbacks("once memory").add(function() { | |
1919 jQuery._removeData( elem, type + "queue" ); | |
1920 jQuery._removeData( elem, key ); | |
1921 }) | |
1922 }); | |
1923 } | |
1924 }); | |
1925 | |
1926 jQuery.fn.extend({ | |
1927 queue: function( type, data ) { | |
1928 var setter = 2; | |
1929 | |
1930 if ( typeof type !== "string" ) { | |
1931 data = type; | |
1932 type = "fx"; | |
1933 setter--; | |
1934 } | |
1935 | |
1936 if ( arguments.length < setter ) { | |
1937 return jQuery.queue( this[0], type ); | |
1938 } | |
1939 | |
1940 return data === undefined ? | |
1941 this : | |
1942 this.each(function() { | |
1943 var queue = jQuery.queue( this, type, data ); | |
1944 | |
1945 // ensure a hooks for this queue | |
1946 jQuery._queueHooks( this, type ); | |
1947 | |
1948 if ( type === "fx" && queue[0] !== "inprogress"
) { | |
1949 jQuery.dequeue( this, type ); | |
1950 } | |
1951 }); | |
1952 }, | |
1953 dequeue: function( type ) { | |
1954 return this.each(function() { | |
1955 jQuery.dequeue( this, type ); | |
1956 }); | |
1957 }, | |
1958 // Based off of the plugin by Clint Helfers, with permission. | |
1959 // http://blindsignals.com/index.php/2009/07/jquery-delay/ | |
1960 delay: function( time, type ) { | |
1961 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; | |
1962 type = type || "fx"; | |
1963 | |
1964 return this.queue( type, function( next, hooks ) { | |
1965 var timeout = setTimeout( next, time ); | |
1966 hooks.stop = function() { | |
1967 clearTimeout( timeout ); | |
1968 }; | |
1969 }); | |
1970 }, | |
1971 clearQueue: function( type ) { | |
1972 return this.queue( type || "fx", [] ); | |
1973 }, | |
1974 // Get a promise resolved when queues of a certain type | |
1975 // are emptied (fx is the type by default) | |
1976 promise: function( type, obj ) { | |
1977 var tmp, | |
1978 count = 1, | |
1979 defer = jQuery.Deferred(), | |
1980 elements = this, | |
1981 i = this.length, | |
1982 resolve = function() { | |
1983 if ( !( --count ) ) { | |
1984 defer.resolveWith( elements, [ elements
] ); | |
1985 } | |
1986 }; | |
1987 | |
1988 if ( typeof type !== "string" ) { | |
1989 obj = type; | |
1990 type = undefined; | |
1991 } | |
1992 type = type || "fx"; | |
1993 | |
1994 while( i-- ) { | |
1995 tmp = jQuery._data( elements[ i ], type + "queueHooks" )
; | |
1996 if ( tmp && tmp.empty ) { | |
1997 count++; | |
1998 tmp.empty.add( resolve ); | |
1999 } | |
2000 } | |
2001 resolve(); | |
2002 return defer.promise( obj ); | |
2003 } | |
2004 }); | |
2005 var nodeHook, boolHook, | |
2006 rclass = /[\t\r\n]/g, | |
2007 rreturn = /\r/g, | |
2008 rfocusable = /^(?:input|select|textarea|button|object)$/i, | |
2009 rclickable = /^(?:a|area)$/i, | |
2010 rboolean = /^(?:checked|selected|autofocus|autoplay|async|controls|defer
|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i, | |
2011 ruseDefault = /^(?:checked|selected)$/i, | |
2012 getSetAttribute = jQuery.support.getSetAttribute, | |
2013 getSetInput = jQuery.support.input; | |
2014 | |
2015 jQuery.fn.extend({ | |
2016 attr: function( name, value ) { | |
2017 return jQuery.access( this, jQuery.attr, name, value, arguments.
length > 1 ); | |
2018 }, | |
2019 | |
2020 removeAttr: function( name ) { | |
2021 return this.each(function() { | |
2022 jQuery.removeAttr( this, name ); | |
2023 }); | |
2024 }, | |
2025 | |
2026 prop: function( name, value ) { | |
2027 return jQuery.access( this, jQuery.prop, name, value, arguments.
length > 1 ); | |
2028 }, | |
2029 | |
2030 removeProp: function( name ) { | |
2031 name = jQuery.propFix[ name ] || name; | |
2032 return this.each(function() { | |
2033 // try/catch handles cases where IE balks (such as remov
ing a property on window) | |
2034 try { | |
2035 this[ name ] = undefined; | |
2036 delete this[ name ]; | |
2037 } catch( e ) {} | |
2038 }); | |
2039 }, | |
2040 | |
2041 addClass: function( value ) { | |
2042 var classes, elem, cur, clazz, j, | |
2043 i = 0, | |
2044 len = this.length, | |
2045 proceed = typeof value === "string" && value; | |
2046 | |
2047 if ( jQuery.isFunction( value ) ) { | |
2048 return this.each(function( j ) { | |
2049 jQuery( this ).addClass( value.call( this, j, th
is.className ) ); | |
2050 }); | |
2051 } | |
2052 | |
2053 if ( proceed ) { | |
2054 // The disjunction here is for better compressibility (s
ee removeClass) | |
2055 classes = ( value || "" ).match( core_rnotwhite ) || []; | |
2056 | |
2057 for ( ; i < len; i++ ) { | |
2058 elem = this[ i ]; | |
2059 cur = elem.nodeType === 1 && ( elem.className ? | |
2060 ( " " + elem.className + " " ).replace(
rclass, " " ) : | |
2061 " " | |
2062 ); | |
2063 | |
2064 if ( cur ) { | |
2065 j = 0; | |
2066 while ( (clazz = classes[j++]) ) { | |
2067 if ( cur.indexOf( " " + clazz +
" " ) < 0 ) { | |
2068 cur += clazz + " "; | |
2069 } | |
2070 } | |
2071 elem.className = jQuery.trim( cur ); | |
2072 | |
2073 } | |
2074 } | |
2075 } | |
2076 | |
2077 return this; | |
2078 }, | |
2079 | |
2080 removeClass: function( value ) { | |
2081 var classes, elem, cur, clazz, j, | |
2082 i = 0, | |
2083 len = this.length, | |
2084 proceed = arguments.length === 0 || typeof value === "st
ring" && value; | |
2085 | |
2086 if ( jQuery.isFunction( value ) ) { | |
2087 return this.each(function( j ) { | |
2088 jQuery( this ).removeClass( value.call( this, j,
this.className ) ); | |
2089 }); | |
2090 } | |
2091 if ( proceed ) { | |
2092 classes = ( value || "" ).match( core_rnotwhite ) || []; | |
2093 | |
2094 for ( ; i < len; i++ ) { | |
2095 elem = this[ i ]; | |
2096 // This expression is here for better compressib
ility (see addClass) | |
2097 cur = elem.nodeType === 1 && ( elem.className ? | |
2098 ( " " + elem.className + " " ).replace(
rclass, " " ) : | |
2099 "" | |
2100 ); | |
2101 | |
2102 if ( cur ) { | |
2103 j = 0; | |
2104 while ( (clazz = classes[j++]) ) { | |
2105 // Remove *all* instances | |
2106 while ( cur.indexOf( " " + clazz
+ " " ) >= 0 ) { | |
2107 cur = cur.replace( " " +
clazz + " ", " " ); | |
2108 } | |
2109 } | |
2110 elem.className = value ? jQuery.trim( cu
r ) : ""; | |
2111 } | |
2112 } | |
2113 } | |
2114 | |
2115 return this; | |
2116 }, | |
2117 | |
2118 toggleClass: function( value, stateVal ) { | |
2119 var type = typeof value, | |
2120 isBool = typeof stateVal === "boolean"; | |
2121 | |
2122 if ( jQuery.isFunction( value ) ) { | |
2123 return this.each(function( i ) { | |
2124 jQuery( this ).toggleClass( value.call(this, i,
this.className, stateVal), stateVal ); | |
2125 }); | |
2126 } | |
2127 | |
2128 return this.each(function() { | |
2129 if ( type === "string" ) { | |
2130 // toggle individual class names | |
2131 var className, | |
2132 i = 0, | |
2133 self = jQuery( this ), | |
2134 state = stateVal, | |
2135 classNames = value.match( core_rnotwhite
) || []; | |
2136 | |
2137 while ( (className = classNames[ i++ ]) ) { | |
2138 // check each className given, space sep
arated list | |
2139 state = isBool ? state : !self.hasClass(
className ); | |
2140 self[ state ? "addClass" : "removeClass"
]( className ); | |
2141 } | |
2142 | |
2143 // Toggle whole class name | |
2144 } else if ( type === "undefined" || type === "boolean" )
{ | |
2145 if ( this.className ) { | |
2146 // store className if set | |
2147 jQuery._data( this, "__className__", thi
s.className ); | |
2148 } | |
2149 | |
2150 // If the element has a class name or if we're p
assed "false", | |
2151 // then remove the whole classname (if there was
one, the above saved it). | |
2152 // Otherwise bring back whatever was previously
saved (if anything), | |
2153 // falling back to the empty string if nothing w
as stored. | |
2154 this.className = this.className || value === fal
se ? "" : jQuery._data( this, "__className__" ) || ""; | |
2155 } | |
2156 }); | |
2157 }, | |
2158 | |
2159 hasClass: function( selector ) { | |
2160 var className = " " + selector + " ", | |
2161 i = 0, | |
2162 l = this.length; | |
2163 for ( ; i < l; i++ ) { | |
2164 if ( this[i].nodeType === 1 && (" " + this[i].className
+ " ").replace(rclass, " ").indexOf( className ) >= 0 ) { | |
2165 return true; | |
2166 } | |
2167 } | |
2168 | |
2169 return false; | |
2170 }, | |
2171 | |
2172 val: function( value ) { | |
2173 var hooks, ret, isFunction, | |
2174 elem = this[0]; | |
2175 | |
2176 if ( !arguments.length ) { | |
2177 if ( elem ) { | |
2178 hooks = jQuery.valHooks[ elem.type ] || jQuery.v
alHooks[ elem.nodeName.toLowerCase() ]; | |
2179 | |
2180 if ( hooks && "get" in hooks && (ret = hooks.get
( elem, "value" )) !== undefined ) { | |
2181 return ret; | |
2182 } | |
2183 | |
2184 ret = elem.value; | |
2185 | |
2186 return typeof ret === "string" ? | |
2187 // handle most common string cases | |
2188 ret.replace(rreturn, "") : | |
2189 // handle cases where value is null/unde
f or number | |
2190 ret == null ? "" : ret; | |
2191 } | |
2192 | |
2193 return; | |
2194 } | |
2195 | |
2196 isFunction = jQuery.isFunction( value ); | |
2197 | |
2198 return this.each(function( i ) { | |
2199 var val, | |
2200 self = jQuery(this); | |
2201 | |
2202 if ( this.nodeType !== 1 ) { | |
2203 return; | |
2204 } | |
2205 | |
2206 if ( isFunction ) { | |
2207 val = value.call( this, i, self.val() ); | |
2208 } else { | |
2209 val = value; | |
2210 } | |
2211 | |
2212 // Treat null/undefined as ""; convert numbers to string | |
2213 if ( val == null ) { | |
2214 val = ""; | |
2215 } else if ( typeof val === "number" ) { | |
2216 val += ""; | |
2217 } else if ( jQuery.isArray( val ) ) { | |
2218 val = jQuery.map(val, function ( value ) { | |
2219 return value == null ? "" : value + ""; | |
2220 }); | |
2221 } | |
2222 | |
2223 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[
this.nodeName.toLowerCase() ]; | |
2224 | |
2225 // If set returns undefined, fall back to normal setting | |
2226 if ( !hooks || !("set" in hooks) || hooks.set( this, val
, "value" ) === undefined ) { | |
2227 this.value = val; | |
2228 } | |
2229 }); | |
2230 } | |
2231 }); | |
2232 | |
2233 jQuery.extend({ | |
2234 valHooks: { | |
2235 option: { | |
2236 get: function( elem ) { | |
2237 // attributes.value is undefined in Blackberry 4
.7 but | |
2238 // uses .value. See #6932 | |
2239 var val = elem.attributes.value; | |
2240 return !val || val.specified ? elem.value : elem
.text; | |
2241 } | |
2242 }, | |
2243 select: { | |
2244 get: function( elem ) { | |
2245 var value, option, | |
2246 options = elem.options, | |
2247 index = elem.selectedIndex, | |
2248 one = elem.type === "select-one" || inde
x < 0, | |
2249 values = one ? null : [], | |
2250 max = one ? index + 1 : options.length, | |
2251 i = index < 0 ? | |
2252 max : | |
2253 one ? index : 0; | |
2254 | |
2255 // Loop through all the selected options | |
2256 for ( ; i < max; i++ ) { | |
2257 option = options[ i ]; | |
2258 | |
2259 // oldIE doesn't update selected after f
orm reset (#2551) | |
2260 if ( ( option.selected || i === index )
&& | |
2261 // Don't return options
that are disabled or in a disabled optgroup | |
2262 ( jQuery.support.optDisa
bled ? !option.disabled : option.getAttribute("disabled") === null ) && | |
2263 ( !option.parentNode.dis
abled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { | |
2264 | |
2265 // Get the specific value for th
e option | |
2266 value = jQuery( option ).val(); | |
2267 | |
2268 // We don't need an array for on
e selects | |
2269 if ( one ) { | |
2270 return value; | |
2271 } | |
2272 | |
2273 // Multi-Selects return an array | |
2274 values.push( value ); | |
2275 } | |
2276 } | |
2277 | |
2278 return values; | |
2279 }, | |
2280 | |
2281 set: function( elem, value ) { | |
2282 var values = jQuery.makeArray( value ); | |
2283 | |
2284 jQuery(elem).find("option").each(function() { | |
2285 this.selected = jQuery.inArray( jQuery(t
his).val(), values ) >= 0; | |
2286 }); | |
2287 | |
2288 if ( !values.length ) { | |
2289 elem.selectedIndex = -1; | |
2290 } | |
2291 return values; | |
2292 } | |
2293 } | |
2294 }, | |
2295 | |
2296 attr: function( elem, name, value ) { | |
2297 var ret, hooks, notxml, | |
2298 nType = elem.nodeType; | |
2299 | |
2300 // don't get/set attributes on text, comment and attribute nodes | |
2301 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | |
2302 return; | |
2303 } | |
2304 | |
2305 // Fallback to prop when attributes are not supported | |
2306 if ( typeof elem.getAttribute === "undefined" ) { | |
2307 return jQuery.prop( elem, name, value ); | |
2308 } | |
2309 | |
2310 notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); | |
2311 | |
2312 // All attributes are lowercase | |
2313 // Grab necessary hook if one is defined | |
2314 if ( notxml ) { | |
2315 name = name.toLowerCase(); | |
2316 hooks = jQuery.attrHooks[ name ] || ( rboolean.test( nam
e ) ? boolHook : nodeHook ); | |
2317 } | |
2318 | |
2319 if ( value !== undefined ) { | |
2320 | |
2321 if ( value === null ) { | |
2322 jQuery.removeAttr( elem, name ); | |
2323 | |
2324 } else if ( hooks && notxml && "set" in hooks && (ret =
hooks.set( elem, value, name )) !== undefined ) { | |
2325 return ret; | |
2326 | |
2327 } else { | |
2328 elem.setAttribute( name, value + "" ); | |
2329 return value; | |
2330 } | |
2331 | |
2332 } else if ( hooks && notxml && "get" in hooks && (ret = hooks.ge
t( elem, name )) !== null ) { | |
2333 return ret; | |
2334 | |
2335 } else { | |
2336 | |
2337 // In IE9+, Flash objects don't have .getAttribute (#129
45) | |
2338 // Support: IE9+ | |
2339 if ( typeof elem.getAttribute !== "undefined" ) { | |
2340 ret = elem.getAttribute( name ); | |
2341 } | |
2342 | |
2343 // Non-existent attributes return null, we normalize to
undefined | |
2344 return ret == null ? | |
2345 undefined : | |
2346 ret; | |
2347 } | |
2348 }, | |
2349 | |
2350 removeAttr: function( elem, value ) { | |
2351 var name, propName, | |
2352 i = 0, | |
2353 attrNames = value && value.match( core_rnotwhite ); | |
2354 | |
2355 if ( attrNames && elem.nodeType === 1 ) { | |
2356 while ( (name = attrNames[i++]) ) { | |
2357 propName = jQuery.propFix[ name ] || name; | |
2358 | |
2359 // Boolean attributes get special treatment (#10
870) | |
2360 if ( rboolean.test( name ) ) { | |
2361 // Set corresponding property to false f
or boolean attributes | |
2362 // Also clear defaultChecked/defaultSele
cted (if appropriate) for IE<8 | |
2363 if ( !getSetAttribute && ruseDefault.tes
t( name ) ) { | |
2364 elem[ jQuery.camelCase( "default
-" + name ) ] = | |
2365 elem[ propName ] = false
; | |
2366 } else { | |
2367 elem[ propName ] = false; | |
2368 } | |
2369 | |
2370 // See #9699 for explanation of this approach (s
etting first, then removal) | |
2371 } else { | |
2372 jQuery.attr( elem, name, "" ); | |
2373 } | |
2374 | |
2375 elem.removeAttribute( getSetAttribute ? name : p
ropName ); | |
2376 } | |
2377 } | |
2378 }, | |
2379 | |
2380 attrHooks: { | |
2381 type: { | |
2382 set: function( elem, value ) { | |
2383 if ( !jQuery.support.radioValue && value === "ra
dio" && jQuery.nodeName(elem, "input") ) { | |
2384 // Setting the type on a radio button af
ter the value resets the value in IE6-9 | |
2385 // Reset value to default in case type i
s set after value during creation | |
2386 var val = elem.value; | |
2387 elem.setAttribute( "type", value ); | |
2388 if ( val ) { | |
2389 elem.value = val; | |
2390 } | |
2391 return value; | |
2392 } | |
2393 } | |
2394 } | |
2395 }, | |
2396 | |
2397 propFix: { | |
2398 tabindex: "tabIndex", | |
2399 readonly: "readOnly", | |
2400 "for": "htmlFor", | |
2401 "class": "className", | |
2402 maxlength: "maxLength", | |
2403 cellspacing: "cellSpacing", | |
2404 cellpadding: "cellPadding", | |
2405 rowspan: "rowSpan", | |
2406 colspan: "colSpan", | |
2407 usemap: "useMap", | |
2408 frameborder: "frameBorder", | |
2409 contenteditable: "contentEditable" | |
2410 }, | |
2411 | |
2412 prop: function( elem, name, value ) { | |
2413 var ret, hooks, notxml, | |
2414 nType = elem.nodeType; | |
2415 | |
2416 // don't get/set properties on text, comment and attribute nodes | |
2417 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | |
2418 return; | |
2419 } | |
2420 | |
2421 notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); | |
2422 | |
2423 if ( notxml ) { | |
2424 // Fix name and attach hooks | |
2425 name = jQuery.propFix[ name ] || name; | |
2426 hooks = jQuery.propHooks[ name ]; | |
2427 } | |
2428 | |
2429 if ( value !== undefined ) { | |
2430 if ( hooks && "set" in hooks && (ret = hooks.set( elem,
value, name )) !== undefined ) { | |
2431 return ret; | |
2432 | |
2433 } else { | |
2434 return ( elem[ name ] = value ); | |
2435 } | |
2436 | |
2437 } else { | |
2438 if ( hooks && "get" in hooks && (ret = hooks.get( elem,
name )) !== null ) { | |
2439 return ret; | |
2440 | |
2441 } else { | |
2442 return elem[ name ]; | |
2443 } | |
2444 } | |
2445 }, | |
2446 | |
2447 propHooks: { | |
2448 tabIndex: { | |
2449 get: function( elem ) { | |
2450 // elem.tabIndex doesn't always return the corre
ct value when it hasn't been explicitly set | |
2451 // http://fluidproject.org/blog/2008/01/09/getti
ng-setting-and-removing-tabindex-values-with-javascript/ | |
2452 var attributeNode = elem.getAttributeNode("tabin
dex"); | |
2453 | |
2454 return attributeNode && attributeNode.specified
? | |
2455 parseInt( attributeNode.value, 10 ) : | |
2456 rfocusable.test( elem.nodeName ) || rcli
ckable.test( elem.nodeName ) && elem.href ? | |
2457 0 : | |
2458 undefined; | |
2459 } | |
2460 } | |
2461 } | |
2462 }); | |
2463 | |
2464 // Hook for boolean attributes | |
2465 boolHook = { | |
2466 get: function( elem, name ) { | |
2467 var | |
2468 // Use .prop to determine if this attribute is understoo
d as boolean | |
2469 prop = jQuery.prop( elem, name ), | |
2470 | |
2471 // Fetch it accordingly | |
2472 attr = typeof prop === "boolean" && elem.getAttribute( n
ame ), | |
2473 detail = typeof prop === "boolean" ? | |
2474 | |
2475 getSetInput && getSetAttribute ? | |
2476 attr != null : | |
2477 // oldIE fabricates an empty string for
missing boolean attributes | |
2478 // and conflates checked/selected into a
ttroperties | |
2479 ruseDefault.test( name ) ? | |
2480 elem[ jQuery.camelCase( "default
-" + name ) ] : | |
2481 !!attr : | |
2482 | |
2483 // fetch an attribute node for properties not re
cognized as boolean | |
2484 elem.getAttributeNode( name ); | |
2485 | |
2486 return detail && detail.value !== false ? | |
2487 name.toLowerCase() : | |
2488 undefined; | |
2489 }, | |
2490 set: function( elem, value, name ) { | |
2491 if ( value === false ) { | |
2492 // Remove boolean attributes when set to false | |
2493 jQuery.removeAttr( elem, name ); | |
2494 } else if ( getSetInput && getSetAttribute || !ruseDefault.test(
name ) ) { | |
2495 // IE<8 needs the *property* name | |
2496 elem.setAttribute( !getSetAttribute && jQuery.propFix[ n
ame ] || name, name ); | |
2497 | |
2498 // Use defaultChecked and defaultSelected for oldIE | |
2499 } else { | |
2500 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ na
me ] = true; | |
2501 } | |
2502 | |
2503 return name; | |
2504 } | |
2505 }; | |
2506 | |
2507 // fix oldIE value attroperty | |
2508 if ( !getSetInput || !getSetAttribute ) { | |
2509 jQuery.attrHooks.value = { | |
2510 get: function( elem, name ) { | |
2511 var ret = elem.getAttributeNode( name ); | |
2512 return jQuery.nodeName( elem, "input" ) ? | |
2513 | |
2514 // Ignore the value *property* by using defaultV
alue | |
2515 elem.defaultValue : | |
2516 | |
2517 ret && ret.specified ? ret.value : undefined; | |
2518 }, | |
2519 set: function( elem, value, name ) { | |
2520 if ( jQuery.nodeName( elem, "input" ) ) { | |
2521 // Does not return so that setAttribute is also
used | |
2522 elem.defaultValue = value; | |
2523 } else { | |
2524 // Use nodeHook if defined (#1954); otherwise se
tAttribute is fine | |
2525 return nodeHook && nodeHook.set( elem, value, na
me ); | |
2526 } | |
2527 } | |
2528 }; | |
2529 } | |
2530 | |
2531 // IE6/7 do not support getting/setting some attributes with get/setAttribute | |
2532 if ( !getSetAttribute ) { | |
2533 | |
2534 // Use this for any attribute in IE6/7 | |
2535 // This fixes almost every IE6/7 issue | |
2536 nodeHook = jQuery.valHooks.button = { | |
2537 get: function( elem, name ) { | |
2538 var ret = elem.getAttributeNode( name ); | |
2539 return ret && ( name === "id" || name === "name" || name
=== "coords" ? ret.value !== "" : ret.specified ) ? | |
2540 ret.value : | |
2541 undefined; | |
2542 }, | |
2543 set: function( elem, value, name ) { | |
2544 // Set the existing or create a new attribute node | |
2545 var ret = elem.getAttributeNode( name ); | |
2546 if ( !ret ) { | |
2547 elem.setAttributeNode( | |
2548 (ret = elem.ownerDocument.createAttribut
e( name )) | |
2549 ); | |
2550 } | |
2551 | |
2552 ret.value = value += ""; | |
2553 | |
2554 // Break association with cloned elements by also using
setAttribute (#9646) | |
2555 return name === "value" || value === elem.getAttribute(
name ) ? | |
2556 value : | |
2557 undefined; | |
2558 } | |
2559 }; | |
2560 | |
2561 // Set contenteditable to false on removals(#10429) | |
2562 // Setting to empty string throws an error as an invalid value | |
2563 jQuery.attrHooks.contenteditable = { | |
2564 get: nodeHook.get, | |
2565 set: function( elem, value, name ) { | |
2566 nodeHook.set( elem, value === "" ? false : value, name )
; | |
2567 } | |
2568 }; | |
2569 | |
2570 // Set width and height to auto instead of 0 on empty string( Bug #8150
) | |
2571 // This is for removals | |
2572 jQuery.each([ "width", "height" ], function( i, name ) { | |
2573 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name
], { | |
2574 set: function( elem, value ) { | |
2575 if ( value === "" ) { | |
2576 elem.setAttribute( name, "auto" ); | |
2577 return value; | |
2578 } | |
2579 } | |
2580 }); | |
2581 }); | |
2582 } | |
2583 | |
2584 | |
2585 // Some attributes require a special call on IE | |
2586 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx | |
2587 if ( !jQuery.support.hrefNormalized ) { | |
2588 jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { | |
2589 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name
], { | |
2590 get: function( elem ) { | |
2591 var ret = elem.getAttribute( name, 2 ); | |
2592 return ret == null ? undefined : ret; | |
2593 } | |
2594 }); | |
2595 }); | |
2596 | |
2597 // href/src property should get the full normalized URL (#10299/#12915) | |
2598 jQuery.each([ "href", "src" ], function( i, name ) { | |
2599 jQuery.propHooks[ name ] = { | |
2600 get: function( elem ) { | |
2601 return elem.getAttribute( name, 4 ); | |
2602 } | |
2603 }; | |
2604 }); | |
2605 } | |
2606 | |
2607 if ( !jQuery.support.style ) { | |
2608 jQuery.attrHooks.style = { | |
2609 get: function( elem ) { | |
2610 // Return undefined in the case of empty string | |
2611 // Note: IE uppercases css property names, but if we wer
e to .toLowerCase() | |
2612 // .cssText, that would destroy case senstitivity in URL
's, like in "background" | |
2613 return elem.style.cssText || undefined; | |
2614 }, | |
2615 set: function( elem, value ) { | |
2616 return ( elem.style.cssText = value + "" ); | |
2617 } | |
2618 }; | |
2619 } | |
2620 | |
2621 // Safari mis-reports the default selected property of an option | |
2622 // Accessing the parent's selectedIndex property fixes it | |
2623 if ( !jQuery.support.optSelected ) { | |
2624 jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { | |
2625 get: function( elem ) { | |
2626 var parent = elem.parentNode; | |
2627 | |
2628 if ( parent ) { | |
2629 parent.selectedIndex; | |
2630 | |
2631 // Make sure that it also works with optgroups,
see #5701 | |
2632 if ( parent.parentNode ) { | |
2633 parent.parentNode.selectedIndex; | |
2634 } | |
2635 } | |
2636 return null; | |
2637 } | |
2638 }); | |
2639 } | |
2640 | |
2641 // IE6/7 call enctype encoding | |
2642 if ( !jQuery.support.enctype ) { | |
2643 jQuery.propFix.enctype = "encoding"; | |
2644 } | |
2645 | |
2646 // Radios and checkboxes getter/setter | |
2647 if ( !jQuery.support.checkOn ) { | |
2648 jQuery.each([ "radio", "checkbox" ], function() { | |
2649 jQuery.valHooks[ this ] = { | |
2650 get: function( elem ) { | |
2651 // Handle the case where in Webkit "" is returne
d instead of "on" if a value isn't specified | |
2652 return elem.getAttribute("value") === null ? "on
" : elem.value; | |
2653 } | |
2654 }; | |
2655 }); | |
2656 } | |
2657 jQuery.each([ "radio", "checkbox" ], function() { | |
2658 jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { | |
2659 set: function( elem, value ) { | |
2660 if ( jQuery.isArray( value ) ) { | |
2661 return ( elem.checked = jQuery.inArray( jQuery(e
lem).val(), value ) >= 0 ); | |
2662 } | |
2663 } | |
2664 }); | |
2665 }); | |
2666 var rformElems = /^(?:input|select|textarea)$/i, | |
2667 rkeyEvent = /^key/, | |
2668 rmouseEvent = /^(?:mouse|contextmenu)|click/, | |
2669 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, | |
2670 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; | |
2671 | |
2672 function returnTrue() { | |
2673 return true; | |
2674 } | |
2675 | |
2676 function returnFalse() { | |
2677 return false; | |
2678 } | |
2679 | |
2680 /* | |
2681 * Helper functions for managing events -- not part of the public interface. | |
2682 * Props to Dean Edwards' addEvent library for many of the ideas. | |
2683 */ | |
2684 jQuery.event = { | |
2685 | |
2686 global: {}, | |
2687 | |
2688 add: function( elem, types, handler, data, selector ) { | |
2689 | |
2690 var handleObjIn, eventHandle, tmp, | |
2691 events, t, handleObj, | |
2692 special, handlers, type, namespaces, origType, | |
2693 // Don't attach events to noData or text/comment nodes (
but allow plain objects) | |
2694 elemData = elem.nodeType !== 3 && elem.nodeType !== 8 &&
jQuery._data( elem ); | |
2695 | |
2696 if ( !elemData ) { | |
2697 return; | |
2698 } | |
2699 | |
2700 // Caller can pass in an object of custom data in lieu of the ha
ndler | |
2701 if ( handler.handler ) { | |
2702 handleObjIn = handler; | |
2703 handler = handleObjIn.handler; | |
2704 selector = handleObjIn.selector; | |
2705 } | |
2706 | |
2707 // Make sure that the handler has a unique ID, used to find/remo
ve it later | |
2708 if ( !handler.guid ) { | |
2709 handler.guid = jQuery.guid++; | |
2710 } | |
2711 | |
2712 // Init the element's event structure and main handler, if this
is the first | |
2713 if ( !(events = elemData.events) ) { | |
2714 events = elemData.events = {}; | |
2715 } | |
2716 if ( !(eventHandle = elemData.handle) ) { | |
2717 eventHandle = elemData.handle = function( e ) { | |
2718 // Discard the second event of a jQuery.event.tr
igger() and | |
2719 // when an event is called after a page has unlo
aded | |
2720 return typeof jQuery !== "undefined" && (!e || j
Query.event.triggered !== e.type) ? | |
2721 jQuery.event.dispatch.apply( eventHandle
.elem, arguments ) : | |
2722 undefined; | |
2723 }; | |
2724 // Add elem as a property of the handle fn to prevent a
memory leak with IE non-native events | |
2725 eventHandle.elem = elem; | |
2726 } | |
2727 | |
2728 // Handle multiple events separated by a space | |
2729 // jQuery(...).bind("mouseover mouseout", fn); | |
2730 types = ( types || "" ).match( core_rnotwhite ) || [""]; | |
2731 t = types.length; | |
2732 while ( t-- ) { | |
2733 tmp = rtypenamespace.exec( types[t] ) || []; | |
2734 type = origType = tmp[1]; | |
2735 namespaces = ( tmp[2] || "" ).split( "." ).sort(); | |
2736 | |
2737 // If event changes its type, use the special event hand
lers for the changed type | |
2738 special = jQuery.event.special[ type ] || {}; | |
2739 | |
2740 // If selector defined, determine special event api type
, otherwise given type | |
2741 type = ( selector ? special.delegateType : special.bindT
ype ) || type; | |
2742 | |
2743 // Update special based on newly reset type | |
2744 special = jQuery.event.special[ type ] || {}; | |
2745 | |
2746 // handleObj is passed to all event handlers | |
2747 handleObj = jQuery.extend({ | |
2748 type: type, | |
2749 origType: origType, | |
2750 data: data, | |
2751 handler: handler, | |
2752 guid: handler.guid, | |
2753 selector: selector, | |
2754 needsContext: selector && jQuery.expr.match.need
sContext.test( selector ), | |
2755 namespace: namespaces.join(".") | |
2756 }, handleObjIn ); | |
2757 | |
2758 // Init the event handler queue if we're the first | |
2759 if ( !(handlers = events[ type ]) ) { | |
2760 handlers = events[ type ] = []; | |
2761 handlers.delegateCount = 0; | |
2762 | |
2763 // Only use addEventListener/attachEvent if the
special events handler returns false | |
2764 if ( !special.setup || special.setup.call( elem,
data, namespaces, eventHandle ) === false ) { | |
2765 // Bind the global event handler to the
element | |
2766 if ( elem.addEventListener ) { | |
2767 elem.addEventListener( type, eve
ntHandle, false ); | |
2768 | |
2769 } else if ( elem.attachEvent ) { | |
2770 elem.attachEvent( "on" + type, e
ventHandle ); | |
2771 } | |
2772 } | |
2773 } | |
2774 | |
2775 if ( special.add ) { | |
2776 special.add.call( elem, handleObj ); | |
2777 | |
2778 if ( !handleObj.handler.guid ) { | |
2779 handleObj.handler.guid = handler.guid; | |
2780 } | |
2781 } | |
2782 | |
2783 // Add to the element's handler list, delegates in front | |
2784 if ( selector ) { | |
2785 handlers.splice( handlers.delegateCount++, 0, ha
ndleObj ); | |
2786 } else { | |
2787 handlers.push( handleObj ); | |
2788 } | |
2789 | |
2790 // Keep track of which events have ever been used, for e
vent optimization | |
2791 jQuery.event.global[ type ] = true; | |
2792 } | |
2793 | |
2794 // Nullify elem to prevent memory leaks in IE | |
2795 elem = null; | |
2796 }, | |
2797 | |
2798 // Detach an event or set of events from an element | |
2799 remove: function( elem, types, handler, selector, mappedTypes ) { | |
2800 | |
2801 var j, origCount, tmp, | |
2802 events, t, handleObj, | |
2803 special, handlers, type, namespaces, origType, | |
2804 elemData = jQuery.hasData( elem ) && jQuery._data( elem
); | |
2805 | |
2806 if ( !elemData || !(events = elemData.events) ) { | |
2807 return; | |
2808 } | |
2809 | |
2810 // Once for each type.namespace in types; type may be omitted | |
2811 types = ( types || "" ).match( core_rnotwhite ) || [""]; | |
2812 t = types.length; | |
2813 while ( t-- ) { | |
2814 tmp = rtypenamespace.exec( types[t] ) || []; | |
2815 type = origType = tmp[1]; | |
2816 namespaces = ( tmp[2] || "" ).split( "." ).sort(); | |
2817 | |
2818 // Unbind all events (on this namespace, if provided) fo
r the element | |
2819 if ( !type ) { | |
2820 for ( type in events ) { | |
2821 jQuery.event.remove( elem, type + types[
t ], handler, selector, true ); | |
2822 } | |
2823 continue; | |
2824 } | |
2825 | |
2826 special = jQuery.event.special[ type ] || {}; | |
2827 type = ( selector ? special.delegateType : special.bindT
ype ) || type; | |
2828 handlers = events[ type ] || []; | |
2829 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join(
"\\.(?:.*\\.|)") + "(\\.|$)" ); | |
2830 | |
2831 // Remove matching events | |
2832 origCount = j = handlers.length; | |
2833 while ( j-- ) { | |
2834 handleObj = handlers[ j ]; | |
2835 | |
2836 if ( ( mappedTypes || origType === handleObj.ori
gType ) && | |
2837 ( !handler || handler.guid === handleObj
.guid ) && | |
2838 ( !tmp || tmp.test( handleObj.namespace
) ) && | |
2839 ( !selector || selector === handleObj.se
lector || selector === "**" && handleObj.selector ) ) { | |
2840 handlers.splice( j, 1 ); | |
2841 | |
2842 if ( handleObj.selector ) { | |
2843 handlers.delegateCount--; | |
2844 } | |
2845 if ( special.remove ) { | |
2846 special.remove.call( elem, handl
eObj ); | |
2847 } | |
2848 } | |
2849 } | |
2850 | |
2851 // Remove generic event handler if we removed something
and no more handlers exist | |
2852 // (avoids potential for endless recursion during remova
l of special event handlers) | |
2853 if ( origCount && !handlers.length ) { | |
2854 if ( !special.teardown || special.teardown.call(
elem, namespaces, elemData.handle ) === false ) { | |
2855 jQuery.removeEvent( elem, type, elemData
.handle ); | |
2856 } | |
2857 | |
2858 delete events[ type ]; | |
2859 } | |
2860 } | |
2861 | |
2862 // Remove the expando if it's no longer used | |
2863 if ( jQuery.isEmptyObject( events ) ) { | |
2864 delete elemData.handle; | |
2865 | |
2866 // removeData also checks for emptiness and clears the e
xpando if empty | |
2867 // so use it instead of delete | |
2868 jQuery._removeData( elem, "events" ); | |
2869 } | |
2870 }, | |
2871 | |
2872 trigger: function( event, data, elem, onlyHandlers ) { | |
2873 | |
2874 var i, cur, tmp, bubbleType, ontype, handle, special, | |
2875 eventPath = [ elem || document ], | |
2876 type = event.type || event, | |
2877 namespaces = event.namespace ? event.namespace.split("."
) : []; | |
2878 | |
2879 cur = tmp = elem = elem || document; | |
2880 | |
2881 // Don't do events on text and comment nodes | |
2882 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { | |
2883 return; | |
2884 } | |
2885 | |
2886 // focus/blur morphs to focusin/out; ensure we're not firing the
m right now | |
2887 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { | |
2888 return; | |
2889 } | |
2890 | |
2891 if ( type.indexOf(".") >= 0 ) { | |
2892 // Namespaced trigger; create a regexp to match event ty
pe in handle() | |
2893 namespaces = type.split("."); | |
2894 type = namespaces.shift(); | |
2895 namespaces.sort(); | |
2896 } | |
2897 ontype = type.indexOf(":") < 0 && "on" + type; | |
2898 | |
2899 // Caller can pass in a jQuery.Event object, Object, or just an
event type string | |
2900 event = event[ jQuery.expando ] ? | |
2901 event : | |
2902 new jQuery.Event( type, typeof event === "object" && eve
nt ); | |
2903 | |
2904 event.isTrigger = true; | |
2905 event.namespace = namespaces.join("."); | |
2906 event.namespace_re = event.namespace ? | |
2907 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)")
+ "(\\.|$)" ) : | |
2908 null; | |
2909 | |
2910 // Clean up the event in case it is being reused | |
2911 event.result = undefined; | |
2912 if ( !event.target ) { | |
2913 event.target = elem; | |
2914 } | |
2915 | |
2916 // Clone any incoming data and prepend the event, creating the h
andler arg list | |
2917 data = data == null ? | |
2918 [ event ] : | |
2919 jQuery.makeArray( data, [ event ] ); | |
2920 | |
2921 // Allow special events to draw outside the lines | |
2922 special = jQuery.event.special[ type ] || {}; | |
2923 if ( !onlyHandlers && special.trigger && special.trigger.apply(
elem, data ) === false ) { | |
2924 return; | |
2925 } | |
2926 | |
2927 // Determine event propagation path in advance, per W3C events s
pec (#9951) | |
2928 // Bubble up to document, then to window; watch for a global own
erDocument var (#9724) | |
2929 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( ele
m ) ) { | |
2930 | |
2931 bubbleType = special.delegateType || type; | |
2932 if ( !rfocusMorph.test( bubbleType + type ) ) { | |
2933 cur = cur.parentNode; | |
2934 } | |
2935 for ( ; cur; cur = cur.parentNode ) { | |
2936 eventPath.push( cur ); | |
2937 tmp = cur; | |
2938 } | |
2939 | |
2940 // Only add window if we got to document (e.g., not plai
n obj or detached DOM) | |
2941 if ( tmp === (elem.ownerDocument || document) ) { | |
2942 eventPath.push( tmp.defaultView || tmp.parentWin
dow || window ); | |
2943 } | |
2944 } | |
2945 | |
2946 // Fire handlers on the event path | |
2947 i = 0; | |
2948 while ( (cur = eventPath[i++]) && !event.isPropagationStopped()
) { | |
2949 | |
2950 event.type = i > 1 ? | |
2951 bubbleType : | |
2952 special.bindType || type; | |
2953 | |
2954 // jQuery handler | |
2955 handle = ( jQuery._data( cur, "events" ) || {} )[ event.
type ] && jQuery._data( cur, "handle" ); | |
2956 if ( handle ) { | |
2957 handle.apply( cur, data ); | |
2958 } | |
2959 | |
2960 // Native handler | |
2961 handle = ontype && cur[ ontype ]; | |
2962 if ( handle && jQuery.acceptData( cur ) && handle.apply
&& handle.apply( cur, data ) === false ) { | |
2963 event.preventDefault(); | |
2964 } | |
2965 } | |
2966 event.type = type; | |
2967 | |
2968 // If nobody prevented the default action, do it now | |
2969 if ( !onlyHandlers && !event.isDefaultPrevented() ) { | |
2970 | |
2971 if ( (!special._default || special._default.apply( elem.
ownerDocument, data ) === false) && | |
2972 !(type === "click" && jQuery.nodeName( elem, "a"
)) && jQuery.acceptData( elem ) ) { | |
2973 | |
2974 // Call a native DOM method on the target with t
he same name name as the event. | |
2975 // Can't use an .isFunction() check here because
IE6/7 fails that test. | |
2976 // Don't do default actions on window, that's wh
ere global variables be (#6170) | |
2977 if ( ontype && elem[ type ] && !jQuery.isWindow(
elem ) ) { | |
2978 | |
2979 // Don't re-trigger an onFOO event when
we call its FOO() method | |
2980 tmp = elem[ ontype ]; | |
2981 | |
2982 if ( tmp ) { | |
2983 elem[ ontype ] = null; | |
2984 } | |
2985 | |
2986 // Prevent re-triggering of the same eve
nt, since we already bubbled it above | |
2987 jQuery.event.triggered = type; | |
2988 try { | |
2989 elem[ type ](); | |
2990 } catch ( e ) { | |
2991 // IE<9 dies on focus/blur to hi
dden element (#1486,#12518) | |
2992 // only reproducible on winXP IE
8 native, not IE9 in IE8 mode | |
2993 } | |
2994 jQuery.event.triggered = undefined; | |
2995 | |
2996 if ( tmp ) { | |
2997 elem[ ontype ] = tmp; | |
2998 } | |
2999 } | |
3000 } | |
3001 } | |
3002 | |
3003 return event.result; | |
3004 }, | |
3005 | |
3006 dispatch: function( event ) { | |
3007 | |
3008 // Make a writable jQuery.Event from the native event object | |
3009 event = jQuery.event.fix( event ); | |
3010 | |
3011 var i, j, ret, matched, handleObj, | |
3012 handlerQueue = [], | |
3013 args = core_slice.call( arguments ), | |
3014 handlers = ( jQuery._data( this, "events" ) || {} )[ eve
nt.type ] || [], | |
3015 special = jQuery.event.special[ event.type ] || {}; | |
3016 | |
3017 // Use the fix-ed jQuery.Event rather than the (read-only) nativ
e event | |
3018 args[0] = event; | |
3019 event.delegateTarget = this; | |
3020 | |
3021 // Call the preDispatch hook for the mapped type, and let it bai
l if desired | |
3022 if ( special.preDispatch && special.preDispatch.call( this, even
t ) === false ) { | |
3023 return; | |
3024 } | |
3025 | |
3026 // Determine handlers | |
3027 handlerQueue = jQuery.event.handlers.call( this, event, handlers
); | |
3028 | |
3029 // Run delegates first; they may want to stop propagation beneat
h us | |
3030 i = 0; | |
3031 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationS
topped() ) { | |
3032 event.currentTarget = matched.elem; | |
3033 | |
3034 j = 0; | |
3035 while ( (handleObj = matched.handlers[ j++ ]) && !event.
isImmediatePropagationStopped() ) { | |
3036 | |
3037 // Triggered event must either 1) have no namesp
ace, or | |
3038 // 2) have namespace(s) a subset or equal to tho
se in the bound event (both can have no namespace). | |
3039 if ( !event.namespace_re || event.namespace_re.t
est( handleObj.namespace ) ) { | |
3040 | |
3041 event.handleObj = handleObj; | |
3042 event.data = handleObj.data; | |
3043 | |
3044 ret = ( (jQuery.event.special[ handleObj
.origType ] || {}).handle || handleObj.handler ) | |
3045 .apply( matched.elem, ar
gs ); | |
3046 | |
3047 if ( ret !== undefined ) { | |
3048 if ( (event.result = ret) === fa
lse ) { | |
3049 event.preventDefault(); | |
3050 event.stopPropagation(); | |
3051 } | |
3052 } | |
3053 } | |
3054 } | |
3055 } | |
3056 | |
3057 // Call the postDispatch hook for the mapped type | |
3058 if ( special.postDispatch ) { | |
3059 special.postDispatch.call( this, event ); | |
3060 } | |
3061 | |
3062 return event.result; | |
3063 }, | |
3064 | |
3065 handlers: function( event, handlers ) { | |
3066 var i, matches, sel, handleObj, | |
3067 handlerQueue = [], | |
3068 delegateCount = handlers.delegateCount, | |
3069 cur = event.target; | |
3070 | |
3071 // Find delegate handlers | |
3072 // Black-hole SVG <use> instance trees (#13180) | |
3073 // Avoid non-left-click bubbling in Firefox (#3861) | |
3074 if ( delegateCount && cur.nodeType && (!event.button || event.ty
pe !== "click") ) { | |
3075 | |
3076 for ( ; cur != this; cur = cur.parentNode || this ) { | |
3077 | |
3078 // Don't process clicks on disabled elements (#6
911, #8165, #11382, #11764) | |
3079 if ( cur.disabled !== true || event.type !== "cl
ick" ) { | |
3080 matches = []; | |
3081 for ( i = 0; i < delegateCount; i++ ) { | |
3082 handleObj = handlers[ i ]; | |
3083 | |
3084 // Don't conflict with Object.pr
ototype properties (#13203) | |
3085 sel = handleObj.selector + " "; | |
3086 | |
3087 if ( matches[ sel ] === undefine
d ) { | |
3088 matches[ sel ] = handleO
bj.needsContext ? | |
3089 jQuery( sel, thi
s ).index( cur ) >= 0 : | |
3090 jQuery.find( sel
, this, null, [ cur ] ).length; | |
3091 } | |
3092 if ( matches[ sel ] ) { | |
3093 matches.push( handleObj
); | |
3094 } | |
3095 } | |
3096 if ( matches.length ) { | |
3097 handlerQueue.push({ elem: cur, h
andlers: matches }); | |
3098 } | |
3099 } | |
3100 } | |
3101 } | |
3102 | |
3103 // Add the remaining (directly-bound) handlers | |
3104 if ( delegateCount < handlers.length ) { | |
3105 handlerQueue.push({ elem: this, handlers: handlers.slice
( delegateCount ) }); | |
3106 } | |
3107 | |
3108 return handlerQueue; | |
3109 }, | |
3110 | |
3111 fix: function( event ) { | |
3112 if ( event[ jQuery.expando ] ) { | |
3113 return event; | |
3114 } | |
3115 | |
3116 // Create a writable copy of the event object and normalize some
properties | |
3117 var i, prop, | |
3118 originalEvent = event, | |
3119 fixHook = jQuery.event.fixHooks[ event.type ] || {}, | |
3120 copy = fixHook.props ? this.props.concat( fixHook.props
) : this.props; | |
3121 | |
3122 event = new jQuery.Event( originalEvent ); | |
3123 | |
3124 i = copy.length; | |
3125 while ( i-- ) { | |
3126 prop = copy[ i ]; | |
3127 event[ prop ] = originalEvent[ prop ]; | |
3128 } | |
3129 | |
3130 // Support: IE<9 | |
3131 // Fix target property (#1925) | |
3132 if ( !event.target ) { | |
3133 event.target = originalEvent.srcElement || document; | |
3134 } | |
3135 | |
3136 // Support: Chrome 23+, Safari? | |
3137 // Target should not be a text node (#504, #13143) | |
3138 if ( event.target.nodeType === 3 ) { | |
3139 event.target = event.target.parentNode; | |
3140 } | |
3141 | |
3142 // Support: IE<9 | |
3143 // For mouse/key events, metaKey==false if it's undefined (#3368
, #11328) | |
3144 event.metaKey = !!event.metaKey; | |
3145 | |
3146 return fixHook.filter ? fixHook.filter( event, originalEvent ) :
event; | |
3147 }, | |
3148 | |
3149 // Includes some event props shared by KeyEvent and MouseEvent | |
3150 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaK
ey relatedTarget shiftKey target timeStamp view which".split(" "), | |
3151 | |
3152 fixHooks: {}, | |
3153 | |
3154 keyHooks: { | |
3155 props: "char charCode key keyCode".split(" "), | |
3156 filter: function( event, original ) { | |
3157 | |
3158 // Add which for key events | |
3159 if ( event.which == null ) { | |
3160 event.which = original.charCode != null ? origin
al.charCode : original.keyCode; | |
3161 } | |
3162 | |
3163 return event; | |
3164 } | |
3165 }, | |
3166 | |
3167 mouseHooks: { | |
3168 props: "button buttons clientX clientY fromElement offsetX offse
tY pageX pageY screenX screenY toElement".split(" "), | |
3169 filter: function( event, original ) { | |
3170 var eventDoc, doc, body, | |
3171 button = original.button, | |
3172 fromElement = original.fromElement; | |
3173 | |
3174 // Calculate pageX/Y if missing and clientX/Y available | |
3175 if ( event.pageX == null && original.clientX != null ) { | |
3176 eventDoc = event.target.ownerDocument || documen
t; | |
3177 doc = eventDoc.documentElement; | |
3178 body = eventDoc.body; | |
3179 | |
3180 event.pageX = original.clientX + ( doc && doc.sc
rollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body &&
body.clientLeft || 0 ); | |
3181 event.pageY = original.clientY + ( doc && doc.sc
rollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body &&
body.clientTop || 0 ); | |
3182 } | |
3183 | |
3184 // Add relatedTarget, if necessary | |
3185 if ( !event.relatedTarget && fromElement ) { | |
3186 event.relatedTarget = fromElement === event.targ
et ? original.toElement : fromElement; | |
3187 } | |
3188 | |
3189 // Add which for click: 1 === left; 2 === middle; 3 ===
right | |
3190 // Note: button is not normalized, so don't use it | |
3191 if ( !event.which && button !== undefined ) { | |
3192 event.which = ( button & 1 ? 1 : ( button & 2 ?
3 : ( button & 4 ? 2 : 0 ) ) ); | |
3193 } | |
3194 | |
3195 return event; | |
3196 } | |
3197 }, | |
3198 | |
3199 special: { | |
3200 load: { | |
3201 // Prevent triggered image.load events from bubbling to
window.load | |
3202 noBubble: true | |
3203 }, | |
3204 click: { | |
3205 // For checkbox, fire native event so checked state will
be right | |
3206 trigger: function() { | |
3207 if ( jQuery.nodeName( this, "input" ) && this.ty
pe === "checkbox" && this.click ) { | |
3208 this.click(); | |
3209 return false; | |
3210 } | |
3211 } | |
3212 }, | |
3213 focus: { | |
3214 // Fire native event if possible so blur/focus sequence
is correct | |
3215 trigger: function() { | |
3216 if ( this !== document.activeElement && this.foc
us ) { | |
3217 try { | |
3218 this.focus(); | |
3219 return false; | |
3220 } catch ( e ) { | |
3221 // Support: IE<9 | |
3222 // If we error on focus to hidde
n element (#1486, #12518), | |
3223 // let .trigger() run the handle
rs | |
3224 } | |
3225 } | |
3226 }, | |
3227 delegateType: "focusin" | |
3228 }, | |
3229 blur: { | |
3230 trigger: function() { | |
3231 if ( this === document.activeElement && this.blu
r ) { | |
3232 this.blur(); | |
3233 return false; | |
3234 } | |
3235 }, | |
3236 delegateType: "focusout" | |
3237 }, | |
3238 | |
3239 beforeunload: { | |
3240 postDispatch: function( event ) { | |
3241 | |
3242 // Even when returnValue equals to undefined Fir
efox will still show alert | |
3243 if ( event.result !== undefined ) { | |
3244 event.originalEvent.returnValue = event.
result; | |
3245 } | |
3246 } | |
3247 } | |
3248 }, | |
3249 | |
3250 simulate: function( type, elem, event, bubble ) { | |
3251 // Piggyback on a donor event to simulate a different one. | |
3252 // Fake originalEvent to avoid donor's stopPropagation, but if t
he | |
3253 // simulated event prevents default then we do the same on the d
onor. | |
3254 var e = jQuery.extend( | |
3255 new jQuery.Event(), | |
3256 event, | |
3257 { type: type, | |
3258 isSimulated: true, | |
3259 originalEvent: {} | |
3260 } | |
3261 ); | |
3262 if ( bubble ) { | |
3263 jQuery.event.trigger( e, null, elem ); | |
3264 } else { | |
3265 jQuery.event.dispatch.call( elem, e ); | |
3266 } | |
3267 if ( e.isDefaultPrevented() ) { | |
3268 event.preventDefault(); | |
3269 } | |
3270 } | |
3271 }; | |
3272 | |
3273 jQuery.removeEvent = document.removeEventListener ? | |
3274 function( elem, type, handle ) { | |
3275 if ( elem.removeEventListener ) { | |
3276 elem.removeEventListener( type, handle, false ); | |
3277 } | |
3278 } : | |
3279 function( elem, type, handle ) { | |
3280 var name = "on" + type; | |
3281 | |
3282 if ( elem.detachEvent ) { | |
3283 | |
3284 // #8545, #7054, preventing memory leaks for custom even
ts in IE6-8 | |
3285 // detachEvent needed property on element, by name of th
at event, to properly expose it to GC | |
3286 if ( typeof elem[ name ] === "undefined" ) { | |
3287 elem[ name ] = null; | |
3288 } | |
3289 | |
3290 elem.detachEvent( name, handle ); | |
3291 } | |
3292 }; | |
3293 | |
3294 jQuery.Event = function( src, props ) { | |
3295 // Allow instantiation without the 'new' keyword | |
3296 if ( !(this instanceof jQuery.Event) ) { | |
3297 return new jQuery.Event( src, props ); | |
3298 } | |
3299 | |
3300 // Event object | |
3301 if ( src && src.type ) { | |
3302 this.originalEvent = src; | |
3303 this.type = src.type; | |
3304 | |
3305 // Events bubbling up the document may have been marked as preve
nted | |
3306 // by a handler lower down the tree; reflect the correct value. | |
3307 this.isDefaultPrevented = ( src.defaultPrevented || src.returnVa
lue === false || | |
3308 src.getPreventDefault && src.getPreventDefault() ) ? ret
urnTrue : returnFalse; | |
3309 | |
3310 // Event type | |
3311 } else { | |
3312 this.type = src; | |
3313 } | |
3314 | |
3315 // Put explicitly provided properties onto the event object | |
3316 if ( props ) { | |
3317 jQuery.extend( this, props ); | |
3318 } | |
3319 | |
3320 // Create a timestamp if incoming event doesn't have one | |
3321 this.timeStamp = src && src.timeStamp || jQuery.now(); | |
3322 | |
3323 // Mark it as fixed | |
3324 this[ jQuery.expando ] = true; | |
3325 }; | |
3326 | |
3327 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language
Binding | |
3328 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.
html | |
3329 jQuery.Event.prototype = { | |
3330 isDefaultPrevented: returnFalse, | |
3331 isPropagationStopped: returnFalse, | |
3332 isImmediatePropagationStopped: returnFalse, | |
3333 | |
3334 preventDefault: function() { | |
3335 var e = this.originalEvent; | |
3336 | |
3337 this.isDefaultPrevented = returnTrue; | |
3338 if ( !e ) { | |
3339 return; | |
3340 } | |
3341 | |
3342 // If preventDefault exists, run it on the original event | |
3343 if ( e.preventDefault ) { | |
3344 e.preventDefault(); | |
3345 | |
3346 // Support: IE | |
3347 // Otherwise set the returnValue property of the original event
to false | |
3348 } else { | |
3349 e.returnValue = false; | |
3350 } | |
3351 }, | |
3352 stopPropagation: function() { | |
3353 var e = this.originalEvent; | |
3354 | |
3355 this.isPropagationStopped = returnTrue; | |
3356 if ( !e ) { | |
3357 return; | |
3358 } | |
3359 // If stopPropagation exists, run it on the original event | |
3360 if ( e.stopPropagation ) { | |
3361 e.stopPropagation(); | |
3362 } | |
3363 | |
3364 // Support: IE | |
3365 // Set the cancelBubble property of the original event to true | |
3366 e.cancelBubble = true; | |
3367 }, | |
3368 stopImmediatePropagation: function() { | |
3369 this.isImmediatePropagationStopped = returnTrue; | |
3370 this.stopPropagation(); | |
3371 } | |
3372 }; | |
3373 | |
3374 // Create mouseenter/leave events using mouseover/out and event-time checks | |
3375 jQuery.each({ | |
3376 mouseenter: "mouseover", | |
3377 mouseleave: "mouseout" | |
3378 }, function( orig, fix ) { | |
3379 jQuery.event.special[ orig ] = { | |
3380 delegateType: fix, | |
3381 bindType: fix, | |
3382 | |
3383 handle: function( event ) { | |
3384 var ret, | |
3385 target = this, | |
3386 related = event.relatedTarget, | |
3387 handleObj = event.handleObj; | |
3388 | |
3389 // For mousenter/leave call the handler if related is ou
tside the target. | |
3390 // NB: No relatedTarget if the mouse left/entered the br
owser window | |
3391 if ( !related || (related !== target && !jQuery.contains
( target, related )) ) { | |
3392 event.type = handleObj.origType; | |
3393 ret = handleObj.handler.apply( this, arguments )
; | |
3394 event.type = fix; | |
3395 } | |
3396 return ret; | |
3397 } | |
3398 }; | |
3399 }); | |
3400 | |
3401 // IE submit delegation | |
3402 if ( !jQuery.support.submitBubbles ) { | |
3403 | |
3404 jQuery.event.special.submit = { | |
3405 setup: function() { | |
3406 // Only need this for delegated form submit events | |
3407 if ( jQuery.nodeName( this, "form" ) ) { | |
3408 return false; | |
3409 } | |
3410 | |
3411 // Lazy-add a submit handler when a descendant form may
potentially be submitted | |
3412 jQuery.event.add( this, "click._submit keypress._submit"
, function( e ) { | |
3413 // Node name check avoids a VML-related crash in
IE (#9807) | |
3414 var elem = e.target, | |
3415 form = jQuery.nodeName( elem, "input" )
|| jQuery.nodeName( elem, "button" ) ? elem.form : undefined; | |
3416 if ( form && !jQuery._data( form, "submitBubbles
" ) ) { | |
3417 jQuery.event.add( form, "submit._submit"
, function( event ) { | |
3418 event._submit_bubble = true; | |
3419 }); | |
3420 jQuery._data( form, "submitBubbles", tru
e ); | |
3421 } | |
3422 }); | |
3423 // return undefined since we don't need an event listene
r | |
3424 }, | |
3425 | |
3426 postDispatch: function( event ) { | |
3427 // If form was submitted by the user, bubble the event u
p the tree | |
3428 if ( event._submit_bubble ) { | |
3429 delete event._submit_bubble; | |
3430 if ( this.parentNode && !event.isTrigger ) { | |
3431 jQuery.event.simulate( "submit", this.pa
rentNode, event, true ); | |
3432 } | |
3433 } | |
3434 }, | |
3435 | |
3436 teardown: function() { | |
3437 // Only need this for delegated form submit events | |
3438 if ( jQuery.nodeName( this, "form" ) ) { | |
3439 return false; | |
3440 } | |
3441 | |
3442 // Remove delegated handlers; cleanData eventually reaps
submit handlers attached above | |
3443 jQuery.event.remove( this, "._submit" ); | |
3444 } | |
3445 }; | |
3446 } | |
3447 | |
3448 // IE change delegation and checkbox/radio fix | |
3449 if ( !jQuery.support.changeBubbles ) { | |
3450 | |
3451 jQuery.event.special.change = { | |
3452 | |
3453 setup: function() { | |
3454 | |
3455 if ( rformElems.test( this.nodeName ) ) { | |
3456 // IE doesn't fire change on a check/radio until
blur; trigger it on click | |
3457 // after a propertychange. Eat the blur-change i
n special.change.handle. | |
3458 // This still fires onchange a second time for c
heck/radio after blur. | |
3459 if ( this.type === "checkbox" || this.type === "
radio" ) { | |
3460 jQuery.event.add( this, "propertychange.
_change", function( event ) { | |
3461 if ( event.originalEvent.propert
yName === "checked" ) { | |
3462 this._just_changed = tru
e; | |
3463 } | |
3464 }); | |
3465 jQuery.event.add( this, "click._change",
function( event ) { | |
3466 if ( this._just_changed && !even
t.isTrigger ) { | |
3467 this._just_changed = fal
se; | |
3468 } | |
3469 // Allow triggered, simulated ch
ange events (#11500) | |
3470 jQuery.event.simulate( "change",
this, event, true ); | |
3471 }); | |
3472 } | |
3473 return false; | |
3474 } | |
3475 // Delegated event; lazy-add a change handler on descend
ant inputs | |
3476 jQuery.event.add( this, "beforeactivate._change", functi
on( e ) { | |
3477 var elem = e.target; | |
3478 | |
3479 if ( rformElems.test( elem.nodeName ) && !jQuery
._data( elem, "changeBubbles" ) ) { | |
3480 jQuery.event.add( elem, "change._change"
, function( event ) { | |
3481 if ( this.parentNode && !event.i
sSimulated && !event.isTrigger ) { | |
3482 jQuery.event.simulate( "
change", this.parentNode, event, true ); | |
3483 } | |
3484 }); | |
3485 jQuery._data( elem, "changeBubbles", tru
e ); | |
3486 } | |
3487 }); | |
3488 }, | |
3489 | |
3490 handle: function( event ) { | |
3491 var elem = event.target; | |
3492 | |
3493 // Swallow native change events from checkbox/radio, we
already triggered them above | |
3494 if ( this !== elem || event.isSimulated || event.isTrigg
er || (elem.type !== "radio" && elem.type !== "checkbox") ) { | |
3495 return event.handleObj.handler.apply( this, argu
ments ); | |
3496 } | |
3497 }, | |
3498 | |
3499 teardown: function() { | |
3500 jQuery.event.remove( this, "._change" ); | |
3501 | |
3502 return !rformElems.test( this.nodeName ); | |
3503 } | |
3504 }; | |
3505 } | |
3506 | |
3507 // Create "bubbling" focus and blur events | |
3508 if ( !jQuery.support.focusinBubbles ) { | |
3509 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix
) { | |
3510 | |
3511 // Attach a single capturing handler while someone wants focusin
/focusout | |
3512 var attaches = 0, | |
3513 handler = function( event ) { | |
3514 jQuery.event.simulate( fix, event.target, jQuery
.event.fix( event ), true ); | |
3515 }; | |
3516 | |
3517 jQuery.event.special[ fix ] = { | |
3518 setup: function() { | |
3519 if ( attaches++ === 0 ) { | |
3520 document.addEventListener( orig, handler
, true ); | |
3521 } | |
3522 }, | |
3523 teardown: function() { | |
3524 if ( --attaches === 0 ) { | |
3525 document.removeEventListener( orig, hand
ler, true ); | |
3526 } | |
3527 } | |
3528 }; | |
3529 }); | |
3530 } | |
3531 | |
3532 jQuery.fn.extend({ | |
3533 | |
3534 on: function( types, selector, data, fn, /*INTERNAL*/ one ) { | |
3535 var origFn, type; | |
3536 | |
3537 // Types can be a map of types/handlers | |
3538 if ( typeof types === "object" ) { | |
3539 // ( types-Object, selector, data ) | |
3540 if ( typeof selector !== "string" ) { | |
3541 // ( types-Object, data ) | |
3542 data = data || selector; | |
3543 selector = undefined; | |
3544 } | |
3545 for ( type in types ) { | |
3546 this.on( type, selector, data, types[ type ], on
e ); | |
3547 } | |
3548 return this; | |
3549 } | |
3550 | |
3551 if ( data == null && fn == null ) { | |
3552 // ( types, fn ) | |
3553 fn = selector; | |
3554 data = selector = undefined; | |
3555 } else if ( fn == null ) { | |
3556 if ( typeof selector === "string" ) { | |
3557 // ( types, selector, fn ) | |
3558 fn = data; | |
3559 data = undefined; | |
3560 } else { | |
3561 // ( types, data, fn ) | |
3562 fn = data; | |
3563 data = selector; | |
3564 selector = undefined; | |
3565 } | |
3566 } | |
3567 if ( fn === false ) { | |
3568 fn = returnFalse; | |
3569 } else if ( !fn ) { | |
3570 return this; | |
3571 } | |
3572 | |
3573 if ( one === 1 ) { | |
3574 origFn = fn; | |
3575 fn = function( event ) { | |
3576 // Can use an empty set, since event contains th
e info | |
3577 jQuery().off( event ); | |
3578 return origFn.apply( this, arguments ); | |
3579 }; | |
3580 // Use same guid so caller can remove using origFn | |
3581 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ )
; | |
3582 } | |
3583 return this.each( function() { | |
3584 jQuery.event.add( this, types, fn, data, selector ); | |
3585 }); | |
3586 }, | |
3587 one: function( types, selector, data, fn ) { | |
3588 return this.on( types, selector, data, fn, 1 ); | |
3589 }, | |
3590 off: function( types, selector, fn ) { | |
3591 var handleObj, type; | |
3592 if ( types && types.preventDefault && types.handleObj ) { | |
3593 // ( event ) dispatched jQuery.Event | |
3594 handleObj = types.handleObj; | |
3595 jQuery( types.delegateTarget ).off( | |
3596 handleObj.namespace ? handleObj.origType + "." +
handleObj.namespace : handleObj.origType, | |
3597 handleObj.selector, | |
3598 handleObj.handler | |
3599 ); | |
3600 return this; | |
3601 } | |
3602 if ( typeof types === "object" ) { | |
3603 // ( types-object [, selector] ) | |
3604 for ( type in types ) { | |
3605 this.off( type, selector, types[ type ] ); | |
3606 } | |
3607 return this; | |
3608 } | |
3609 if ( selector === false || typeof selector === "function" ) { | |
3610 // ( types [, fn] ) | |
3611 fn = selector; | |
3612 selector = undefined; | |
3613 } | |
3614 if ( fn === false ) { | |
3615 fn = returnFalse; | |
3616 } | |
3617 return this.each(function() { | |
3618 jQuery.event.remove( this, types, fn, selector ); | |
3619 }); | |
3620 }, | |
3621 | |
3622 bind: function( types, data, fn ) { | |
3623 return this.on( types, null, data, fn ); | |
3624 }, | |
3625 unbind: function( types, fn ) { | |
3626 return this.off( types, null, fn ); | |
3627 }, | |
3628 | |
3629 delegate: function( selector, types, data, fn ) { | |
3630 return this.on( types, selector, data, fn ); | |
3631 }, | |
3632 undelegate: function( selector, types, fn ) { | |
3633 // ( namespace ) or ( selector, types [, fn] ) | |
3634 return arguments.length === 1 ? this.off( selector, "**" ) : thi
s.off( types, selector || "**", fn ); | |
3635 }, | |
3636 | |
3637 trigger: function( type, data ) { | |
3638 return this.each(function() { | |
3639 jQuery.event.trigger( type, data, this ); | |
3640 }); | |
3641 }, | |
3642 triggerHandler: function( type, data ) { | |
3643 var elem = this[0]; | |
3644 if ( elem ) { | |
3645 return jQuery.event.trigger( type, data, elem, true ); | |
3646 } | |
3647 }, | |
3648 | |
3649 hover: function( fnOver, fnOut ) { | |
3650 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); | |
3651 } | |
3652 }); | |
3653 | |
3654 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
ick " + | |
3655 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave "
+ | |
3656 "change select submit keydown keypress keyup error contextmenu").split("
"), function( i, name ) { | |
3657 | |
3658 // Handle event binding | |
3659 jQuery.fn[ name ] = function( data, fn ) { | |
3660 return arguments.length > 0 ? | |
3661 this.on( name, null, data, fn ) : | |
3662 this.trigger( name ); | |
3663 }; | |
3664 | |
3665 if ( rkeyEvent.test( name ) ) { | |
3666 jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; | |
3667 } | |
3668 | |
3669 if ( rmouseEvent.test( name ) ) { | |
3670 jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; | |
3671 } | |
3672 }); | |
3673 /*! | |
3674 * Sizzle CSS Selector Engine | |
3675 * Copyright 2012 jQuery Foundation and other contributors | |
3676 * Released under the MIT license | |
3677 * http://sizzlejs.com/ | |
3678 */ | |
3679 (function( window, undefined ) { | |
3680 | |
3681 var i, | |
3682 cachedruns, | |
3683 Expr, | |
3684 getText, | |
3685 isXML, | |
3686 compile, | |
3687 hasDuplicate, | |
3688 outermostContext, | |
3689 | |
3690 // Local document vars | |
3691 setDocument, | |
3692 document, | |
3693 docElem, | |
3694 documentIsXML, | |
3695 rbuggyQSA, | |
3696 rbuggyMatches, | |
3697 matches, | |
3698 contains, | |
3699 sortOrder, | |
3700 | |
3701 // Instance-specific data | |
3702 expando = "sizzle" + -(new Date()), | |
3703 preferredDoc = window.document, | |
3704 support = {}, | |
3705 dirruns = 0, | |
3706 done = 0, | |
3707 classCache = createCache(), | |
3708 tokenCache = createCache(), | |
3709 compilerCache = createCache(), | |
3710 | |
3711 // General-purpose constants | |
3712 strundefined = typeof undefined, | |
3713 MAX_NEGATIVE = 1 << 31, | |
3714 | |
3715 // Array methods | |
3716 arr = [], | |
3717 pop = arr.pop, | |
3718 push = arr.push, | |
3719 slice = arr.slice, | |
3720 // Use a stripped-down indexOf if we can't use a native one | |
3721 indexOf = arr.indexOf || function( elem ) { | |
3722 var i = 0, | |
3723 len = this.length; | |
3724 for ( ; i < len; i++ ) { | |
3725 if ( this[i] === elem ) { | |
3726 return i; | |
3727 } | |
3728 } | |
3729 return -1; | |
3730 }, | |
3731 | |
3732 | |
3733 // Regular expressions | |
3734 | |
3735 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace | |
3736 whitespace = "[\\x20\\t\\r\\n\\f]", | |
3737 // http://www.w3.org/TR/css3-syntax/#characters | |
3738 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", | |
3739 | |
3740 // Loosely modeled on CSS identifier characters | |
3741 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css
3-selectors/#attribute-selectors | |
3742 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-iden
tifier | |
3743 identifier = characterEncoding.replace( "w", "w#" ), | |
3744 | |
3745 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-select
ors | |
3746 operators = "([*^$|!~]?=)", | |
3747 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + white
space + | |
3748 "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])
*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", | |
3749 | |
3750 // Prefer arguments quoted, | |
3751 // then not containing pseudos/brackets, | |
3752 // then attribute selectors/non-parenthetical expressions, | |
3753 // then anything else | |
3754 // These preferences are here to reduce the number of selectors | |
3755 // needing tokenize in the PSEUDO preFilter | |
3756 pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*
?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)", | |
3757 | |
3758 // Leading and non-escaped trailing whitespace, capturing some non-white
space characters preceding the latter | |
3759 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + w
hitespace + "+$", "g" ), | |
3760 | |
3761 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), | |
3762 rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])
" + whitespace + "*" ), | |
3763 rpseudo = new RegExp( pseudos ), | |
3764 ridentifier = new RegExp( "^" + identifier + "$" ), | |
3765 | |
3766 matchExpr = { | |
3767 "ID": new RegExp( "^#(" + characterEncoding + ")" ), | |
3768 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), | |
3769 "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")[
'\"]?\\]" ), | |
3770 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" )
+ ")" ), | |
3771 "ATTR": new RegExp( "^" + attributes ), | |
3772 "PSEUDO": new RegExp( "^" + pseudos ), | |
3773 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of
-type)(?:\\(" + whitespace + | |
3774 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]
|)" + whitespace + | |
3775 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), | |
3776 // For use in libraries implementing .is() | |
3777 // We use this for POS matching in `select` | |
3778 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|od
d|eq|gt|lt|nth|first|last)(?:\\(" + | |
3779 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?
=[^-]|$)", "i" ) | |
3780 }, | |
3781 | |
3782 rsibling = /[\x20\t\r\n\f]*[+~]/, | |
3783 | |
3784 rnative = /\{\s*\[native code\]\s*\}/, | |
3785 | |
3786 // Easily-parseable/retrievable ID or TAG or CLASS selectors | |
3787 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, | |
3788 | |
3789 rinputs = /^(?:input|select|textarea|button)$/i, | |
3790 rheader = /^h\d$/i, | |
3791 | |
3792 rescape = /'|\\/g, | |
3793 rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g, | |
3794 | |
3795 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-character
s | |
3796 runescape = /\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g, | |
3797 funescape = function( _, escaped ) { | |
3798 var high = "0x" + escaped - 0x10000; | |
3799 // NaN means non-codepoint | |
3800 return high !== high ? | |
3801 escaped : | |
3802 // BMP codepoint | |
3803 high < 0 ? | |
3804 String.fromCharCode( high + 0x10000 ) : | |
3805 // Supplemental Plane codepoint (surrogate pair) | |
3806 String.fromCharCode( high >> 10 | 0xD800, high &
0x3FF | 0xDC00 ); | |
3807 }; | |
3808 | |
3809 // Use a stripped-down slice if we can't use a native one | |
3810 try { | |
3811 slice.call( docElem.childNodes, 0 )[0].nodeType; | |
3812 } catch ( e ) { | |
3813 slice = function( i ) { | |
3814 var elem, | |
3815 results = []; | |
3816 for ( ; (elem = this[i]); i++ ) { | |
3817 results.push( elem ); | |
3818 } | |
3819 return results; | |
3820 }; | |
3821 } | |
3822 | |
3823 /** | |
3824 * For feature detection | |
3825 * @param {Function} fn The function to test for native support | |
3826 */ | |
3827 function isNative( fn ) { | |
3828 return rnative.test( fn + "" ); | |
3829 } | |
3830 | |
3831 /** | |
3832 * Create key-value caches of limited size | |
3833 * @returns {Function(string, Object)} Returns the Object data after storing it
on itself with | |
3834 * property name the (space-suffixed) string and (if the cache is larger th
an Expr.cacheLength) | |
3835 * deleting the oldest entry | |
3836 */ | |
3837 function createCache() { | |
3838 var cache, | |
3839 keys = []; | |
3840 | |
3841 return (cache = function( key, value ) { | |
3842 // Use (key + " ") to avoid collision with native prototype prop
erties (see Issue #157) | |
3843 if ( keys.push( key += " " ) > Expr.cacheLength ) { | |
3844 // Only keep the most recent entries | |
3845 delete cache[ keys.shift() ]; | |
3846 } | |
3847 return (cache[ key ] = value); | |
3848 }); | |
3849 } | |
3850 | |
3851 /** | |
3852 * Mark a function for special use by Sizzle | |
3853 * @param {Function} fn The function to mark | |
3854 */ | |
3855 function markFunction( fn ) { | |
3856 fn[ expando ] = true; | |
3857 return fn; | |
3858 } | |
3859 | |
3860 /** | |
3861 * Support testing using an element | |
3862 * @param {Function} fn Passed the created div and expects a boolean result | |
3863 */ | |
3864 function assert( fn ) { | |
3865 var div = document.createElement("div"); | |
3866 | |
3867 try { | |
3868 return fn( div ); | |
3869 } catch (e) { | |
3870 return false; | |
3871 } finally { | |
3872 // release memory in IE | |
3873 div = null; | |
3874 } | |
3875 } | |
3876 | |
3877 function Sizzle( selector, context, results, seed ) { | |
3878 var match, elem, m, nodeType, | |
3879 // QSA vars | |
3880 i, groups, old, nid, newContext, newSelector; | |
3881 | |
3882 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== d
ocument ) { | |
3883 setDocument( context ); | |
3884 } | |
3885 | |
3886 context = context || document; | |
3887 results = results || []; | |
3888 | |
3889 if ( !selector || typeof selector !== "string" ) { | |
3890 return results; | |
3891 } | |
3892 | |
3893 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { | |
3894 return []; | |
3895 } | |
3896 | |
3897 if ( !documentIsXML && !seed ) { | |
3898 | |
3899 // Shortcuts | |
3900 if ( (match = rquickExpr.exec( selector )) ) { | |
3901 // Speed-up: Sizzle("#ID") | |
3902 if ( (m = match[1]) ) { | |
3903 if ( nodeType === 9 ) { | |
3904 elem = context.getElementById( m ); | |
3905 // Check parentNode to catch when Blackb
erry 4.6 returns | |
3906 // nodes that are no longer in the docum
ent #6963 | |
3907 if ( elem && elem.parentNode ) { | |
3908 // Handle the case where IE, Ope
ra, and Webkit return items | |
3909 // by name instead of ID | |
3910 if ( elem.id === m ) { | |
3911 results.push( elem ); | |
3912 return results; | |
3913 } | |
3914 } else { | |
3915 return results; | |
3916 } | |
3917 } else { | |
3918 // Context is not a document | |
3919 if ( context.ownerDocument && (elem = co
ntext.ownerDocument.getElementById( m )) && | |
3920 contains( context, elem ) && ele
m.id === m ) { | |
3921 results.push( elem ); | |
3922 return results; | |
3923 } | |
3924 } | |
3925 | |
3926 // Speed-up: Sizzle("TAG") | |
3927 } else if ( match[2] ) { | |
3928 push.apply( results, slice.call(context.getEleme
ntsByTagName( selector ), 0) ); | |
3929 return results; | |
3930 | |
3931 // Speed-up: Sizzle(".CLASS") | |
3932 } else if ( (m = match[3]) && support.getByClassName &&
context.getElementsByClassName ) { | |
3933 push.apply( results, slice.call(context.getEleme
ntsByClassName( m ), 0) ); | |
3934 return results; | |
3935 } | |
3936 } | |
3937 | |
3938 // QSA path | |
3939 if ( support.qsa && !rbuggyQSA.test(selector) ) { | |
3940 old = true; | |
3941 nid = expando; | |
3942 newContext = context; | |
3943 newSelector = nodeType === 9 && selector; | |
3944 | |
3945 // qSA works strangely on Element-rooted queries | |
3946 // We can work around this by specifying an extra ID on
the root | |
3947 // and working up from there (Thanks to Andrew Dupont fo
r the technique) | |
3948 // IE 8 doesn't work on object elements | |
3949 if ( nodeType === 1 && context.nodeName.toLowerCase() !=
= "object" ) { | |
3950 groups = tokenize( selector ); | |
3951 | |
3952 if ( (old = context.getAttribute("id")) ) { | |
3953 nid = old.replace( rescape, "\\$&" ); | |
3954 } else { | |
3955 context.setAttribute( "id", nid ); | |
3956 } | |
3957 nid = "[id='" + nid + "'] "; | |
3958 | |
3959 i = groups.length; | |
3960 while ( i-- ) { | |
3961 groups[i] = nid + toSelector( groups[i]
); | |
3962 } | |
3963 newContext = rsibling.test( selector ) && contex
t.parentNode || context; | |
3964 newSelector = groups.join(","); | |
3965 } | |
3966 | |
3967 if ( newSelector ) { | |
3968 try { | |
3969 push.apply( results, slice.call( newCont
ext.querySelectorAll( | |
3970 newSelector | |
3971 ), 0 ) ); | |
3972 return results; | |
3973 } catch(qsaError) { | |
3974 } finally { | |
3975 if ( !old ) { | |
3976 context.removeAttribute("id"); | |
3977 } | |
3978 } | |
3979 } | |
3980 } | |
3981 } | |
3982 | |
3983 // All others | |
3984 return select( selector.replace( rtrim, "$1" ), context, results, seed )
; | |
3985 } | |
3986 | |
3987 /** | |
3988 * Detect xml | |
3989 * @param {Element|Object} elem An element or a document | |
3990 */ | |
3991 isXML = Sizzle.isXML = function( elem ) { | |
3992 // documentElement is verified for cases where it doesn't yet exist | |
3993 // (such as loading iframes in IE - #4833) | |
3994 var documentElement = elem && (elem.ownerDocument || elem).documentEleme
nt; | |
3995 return documentElement ? documentElement.nodeName !== "HTML" : false; | |
3996 }; | |
3997 | |
3998 /** | |
3999 * Sets document-related variables once based on the current document | |
4000 * @param {Element|Object} [doc] An element or document object to use to set the
document | |
4001 * @returns {Object} Returns the current document | |
4002 */ | |
4003 setDocument = Sizzle.setDocument = function( node ) { | |
4004 var doc = node ? node.ownerDocument || node : preferredDoc; | |
4005 | |
4006 // If no document and documentElement is available, return | |
4007 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { | |
4008 return document; | |
4009 } | |
4010 | |
4011 // Set our document | |
4012 document = doc; | |
4013 docElem = doc.documentElement; | |
4014 | |
4015 // Support tests | |
4016 documentIsXML = isXML( doc ); | |
4017 | |
4018 // Check if getElementsByTagName("*") returns only elements | |
4019 support.tagNameNoComments = assert(function( div ) { | |
4020 div.appendChild( doc.createComment("") ); | |
4021 return !div.getElementsByTagName("*").length; | |
4022 }); | |
4023 | |
4024 // Check if attributes should be retrieved by attribute nodes | |
4025 support.attributes = assert(function( div ) { | |
4026 div.innerHTML = "<select></select>"; | |
4027 var type = typeof div.lastChild.getAttribute("multiple"); | |
4028 // IE8 returns a string for some attributes even when not presen
t | |
4029 return type !== "boolean" && type !== "string"; | |
4030 }); | |
4031 | |
4032 // Check if getElementsByClassName can be trusted | |
4033 support.getByClassName = assert(function( div ) { | |
4034 // Opera can't find a second classname (in 9.6) | |
4035 div.innerHTML = "<div class='hidden e'></div><div class='hidden'
></div>"; | |
4036 if ( !div.getElementsByClassName || !div.getElementsByClassName(
"e").length ) { | |
4037 return false; | |
4038 } | |
4039 | |
4040 // Safari 3.2 caches class attributes and doesn't catch changes | |
4041 div.lastChild.className = "e"; | |
4042 return div.getElementsByClassName("e").length === 2; | |
4043 }); | |
4044 | |
4045 // Check if getElementById returns elements by name | |
4046 // Check if getElementsByName privileges form controls or returns elemen
ts by ID | |
4047 support.getByName = assert(function( div ) { | |
4048 // Inject content | |
4049 div.id = expando + 0; | |
4050 div.innerHTML = "<a name='" + expando + "'></a><div name='" + ex
pando + "'></div>"; | |
4051 docElem.insertBefore( div, docElem.firstChild ); | |
4052 | |
4053 // Test | |
4054 var pass = doc.getElementsByName && | |
4055 // buggy browsers will return fewer than the correct 2 | |
4056 doc.getElementsByName( expando ).length === 2 + | |
4057 // buggy browsers will return more than the correct 0 | |
4058 doc.getElementsByName( expando + 0 ).length; | |
4059 support.getIdNotName = !doc.getElementById( expando ); | |
4060 | |
4061 // Cleanup | |
4062 docElem.removeChild( div ); | |
4063 | |
4064 return pass; | |
4065 }); | |
4066 | |
4067 // IE6/7 return modified attributes | |
4068 Expr.attrHandle = assert(function( div ) { | |
4069 div.innerHTML = "<a href='#'></a>"; | |
4070 return div.firstChild && typeof div.firstChild.getAttribute !==
strundefined && | |
4071 div.firstChild.getAttribute("href") === "#"; | |
4072 }) ? | |
4073 {} : | |
4074 { | |
4075 "href": function( elem ) { | |
4076 return elem.getAttribute( "href", 2 ); | |
4077 }, | |
4078 "type": function( elem ) { | |
4079 return elem.getAttribute("type"); | |
4080 } | |
4081 }; | |
4082 | |
4083 // ID find and filter | |
4084 if ( support.getIdNotName ) { | |
4085 Expr.find["ID"] = function( id, context ) { | |
4086 if ( typeof context.getElementById !== strundefined && !
documentIsXML ) { | |
4087 var m = context.getElementById( id ); | |
4088 // Check parentNode to catch when Blackberry 4.6
returns | |
4089 // nodes that are no longer in the document #696
3 | |
4090 return m && m.parentNode ? [m] : []; | |
4091 } | |
4092 }; | |
4093 Expr.filter["ID"] = function( id ) { | |
4094 var attrId = id.replace( runescape, funescape ); | |
4095 return function( elem ) { | |
4096 return elem.getAttribute("id") === attrId; | |
4097 }; | |
4098 }; | |
4099 } else { | |
4100 Expr.find["ID"] = function( id, context ) { | |
4101 if ( typeof context.getElementById !== strundefined && !
documentIsXML ) { | |
4102 var m = context.getElementById( id ); | |
4103 | |
4104 return m ? | |
4105 m.id === id || typeof m.getAttributeNode
!== strundefined && m.getAttributeNode("id").value === id ? | |
4106 [m] : | |
4107 undefined : | |
4108 []; | |
4109 } | |
4110 }; | |
4111 Expr.filter["ID"] = function( id ) { | |
4112 var attrId = id.replace( runescape, funescape ); | |
4113 return function( elem ) { | |
4114 var node = typeof elem.getAttributeNode !== stru
ndefined && elem.getAttributeNode("id"); | |
4115 return node && node.value === attrId; | |
4116 }; | |
4117 }; | |
4118 } | |
4119 | |
4120 // Tag | |
4121 Expr.find["TAG"] = support.tagNameNoComments ? | |
4122 function( tag, context ) { | |
4123 if ( typeof context.getElementsByTagName !== strundefine
d ) { | |
4124 return context.getElementsByTagName( tag ); | |
4125 } | |
4126 } : | |
4127 function( tag, context ) { | |
4128 var elem, | |
4129 tmp = [], | |
4130 i = 0, | |
4131 results = context.getElementsByTagName( tag ); | |
4132 | |
4133 // Filter out possible comments | |
4134 if ( tag === "*" ) { | |
4135 for ( ; (elem = results[i]); i++ ) { | |
4136 if ( elem.nodeType === 1 ) { | |
4137 tmp.push( elem ); | |
4138 } | |
4139 } | |
4140 | |
4141 return tmp; | |
4142 } | |
4143 return results; | |
4144 }; | |
4145 | |
4146 // Name | |
4147 Expr.find["NAME"] = support.getByName && function( tag, context ) { | |
4148 if ( typeof context.getElementsByName !== strundefined ) { | |
4149 return context.getElementsByName( name ); | |
4150 } | |
4151 }; | |
4152 | |
4153 // Class | |
4154 Expr.find["CLASS"] = support.getByClassName && function( className, cont
ext ) { | |
4155 if ( typeof context.getElementsByClassName !== strundefined && !
documentIsXML ) { | |
4156 return context.getElementsByClassName( className ); | |
4157 } | |
4158 }; | |
4159 | |
4160 // QSA and matchesSelector support | |
4161 | |
4162 // matchesSelector(:active) reports false when true (IE9/Opera 11.5) | |
4163 rbuggyMatches = []; | |
4164 | |
4165 // qSa(:focus) reports false when true (Chrome 21), | |
4166 // no need to also add to buggyMatches since matches checks buggyQSA | |
4167 // A support test would require too much code (would include document re
ady) | |
4168 rbuggyQSA = [ ":focus" ]; | |
4169 | |
4170 if ( (support.qsa = isNative(doc.querySelectorAll)) ) { | |
4171 // Build QSA regex | |
4172 // Regex strategy adopted from Diego Perini | |
4173 assert(function( div ) { | |
4174 // Select is set to empty string on purpose | |
4175 // This is to test IE's treatment of not explictly | |
4176 // setting a boolean content attribute, | |
4177 // since its presence should be enough | |
4178 // http://bugs.jquery.com/ticket/12359 | |
4179 div.innerHTML = "<select><option selected=''></option></
select>"; | |
4180 | |
4181 // IE8 - Some boolean attributes are not treated correct
ly | |
4182 if ( !div.querySelectorAll("[selected]").length ) { | |
4183 rbuggyQSA.push( "\\[" + whitespace + "*(?:checke
d|disabled|ismap|multiple|readonly|selected|value)" ); | |
4184 } | |
4185 | |
4186 // Webkit/Opera - :checked should return selected option
elements | |
4187 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929
/#checked | |
4188 // IE8 throws error here and will not see later tests | |
4189 if ( !div.querySelectorAll(":checked").length ) { | |
4190 rbuggyQSA.push(":checked"); | |
4191 } | |
4192 }); | |
4193 | |
4194 assert(function( div ) { | |
4195 | |
4196 // Opera 10-12/IE8 - ^= $= *= and empty values | |
4197 // Should not select anything | |
4198 div.innerHTML = "<input type='hidden' i=''/>"; | |
4199 if ( div.querySelectorAll("[i^='']").length ) { | |
4200 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\
"|'')" ); | |
4201 } | |
4202 | |
4203 // FF 3.5 - :enabled/:disabled and hidden elements (hidd
en elements are still enabled) | |
4204 // IE8 throws error here and will not see later tests | |
4205 if ( !div.querySelectorAll(":enabled").length ) { | |
4206 rbuggyQSA.push( ":enabled", ":disabled" ); | |
4207 } | |
4208 | |
4209 // Opera 10-11 does not throw on post-comma invalid pseu
dos | |
4210 div.querySelectorAll("*,:x"); | |
4211 rbuggyQSA.push(",.*:"); | |
4212 }); | |
4213 } | |
4214 | |
4215 if ( (support.matchesSelector = isNative( (matches = docElem.matchesSele
ctor || | |
4216 docElem.mozMatchesSelector || | |
4217 docElem.webkitMatchesSelector || | |
4218 docElem.oMatchesSelector || | |
4219 docElem.msMatchesSelector) )) ) { | |
4220 | |
4221 assert(function( div ) { | |
4222 // Check to see if it's possible to do matchesSelector | |
4223 // on a disconnected node (IE 9) | |
4224 support.disconnectedMatch = matches.call( div, "div" ); | |
4225 | |
4226 // This should fail with an exception | |
4227 // Gecko does not error, returns false instead | |
4228 matches.call( div, "[s!='']:x" ); | |
4229 rbuggyMatches.push( "!=", pseudos ); | |
4230 }); | |
4231 } | |
4232 | |
4233 rbuggyQSA = new RegExp( rbuggyQSA.join("|") ); | |
4234 rbuggyMatches = new RegExp( rbuggyMatches.join("|") ); | |
4235 | |
4236 // Element contains another | |
4237 // Purposefully does not implement inclusive descendent | |
4238 // As in, an element does not contain itself | |
4239 contains = isNative(docElem.contains) || docElem.compareDocumentPosition
? | |
4240 function( a, b ) { | |
4241 var adown = a.nodeType === 9 ? a.documentElement : a, | |
4242 bup = b && b.parentNode; | |
4243 return a === bup || !!( bup && bup.nodeType === 1 && ( | |
4244 adown.contains ? | |
4245 adown.contains( bup ) : | |
4246 a.compareDocumentPosition && a.compareDo
cumentPosition( bup ) & 16 | |
4247 )); | |
4248 } : | |
4249 function( a, b ) { | |
4250 if ( b ) { | |
4251 while ( (b = b.parentNode) ) { | |
4252 if ( b === a ) { | |
4253 return true; | |
4254 } | |
4255 } | |
4256 } | |
4257 return false; | |
4258 }; | |
4259 | |
4260 // Document order sorting | |
4261 sortOrder = docElem.compareDocumentPosition ? | |
4262 function( a, b ) { | |
4263 var compare; | |
4264 | |
4265 if ( a === b ) { | |
4266 hasDuplicate = true; | |
4267 return 0; | |
4268 } | |
4269 | |
4270 if ( (compare = b.compareDocumentPosition && a.compareDocumentPo
sition && a.compareDocumentPosition( b )) ) { | |
4271 if ( compare & 1 || a.parentNode && a.parentNode.nodeTyp
e === 11 ) { | |
4272 if ( a === doc || contains( preferredDoc, a ) )
{ | |
4273 return -1; | |
4274 } | |
4275 if ( b === doc || contains( preferredDoc, b ) )
{ | |
4276 return 1; | |
4277 } | |
4278 return 0; | |
4279 } | |
4280 return compare & 4 ? -1 : 1; | |
4281 } | |
4282 | |
4283 return a.compareDocumentPosition ? -1 : 1; | |
4284 } : | |
4285 function( a, b ) { | |
4286 var cur, | |
4287 i = 0, | |
4288 aup = a.parentNode, | |
4289 bup = b.parentNode, | |
4290 ap = [ a ], | |
4291 bp = [ b ]; | |
4292 | |
4293 // The nodes are identical, we can exit early | |
4294 if ( a === b ) { | |
4295 hasDuplicate = true; | |
4296 return 0; | |
4297 | |
4298 // Fallback to using sourceIndex (in IE) if it's available on bo
th nodes | |
4299 } else if ( a.sourceIndex && b.sourceIndex ) { | |
4300 return ( ~b.sourceIndex || MAX_NEGATIVE ) - ( contains(
preferredDoc, a ) && ~a.sourceIndex || MAX_NEGATIVE ); | |
4301 | |
4302 // Parentless nodes are either documents or disconnected | |
4303 } else if ( !aup || !bup ) { | |
4304 return a === doc ? -1 : | |
4305 b === doc ? 1 : | |
4306 aup ? -1 : | |
4307 bup ? 1 : | |
4308 0; | |
4309 | |
4310 // If the nodes are siblings, we can do a quick check | |
4311 } else if ( aup === bup ) { | |
4312 return siblingCheck( a, b ); | |
4313 } | |
4314 | |
4315 // Otherwise we need full lists of their ancestors for compariso
n | |
4316 cur = a; | |
4317 while ( (cur = cur.parentNode) ) { | |
4318 ap.unshift( cur ); | |
4319 } | |
4320 cur = b; | |
4321 while ( (cur = cur.parentNode) ) { | |
4322 bp.unshift( cur ); | |
4323 } | |
4324 | |
4325 // Walk down the tree looking for a discrepancy | |
4326 while ( ap[i] === bp[i] ) { | |
4327 i++; | |
4328 } | |
4329 | |
4330 return i ? | |
4331 // Do a sibling check if the nodes have a common ancesto
r | |
4332 siblingCheck( ap[i], bp[i] ) : | |
4333 | |
4334 // Otherwise nodes in our document sort first | |
4335 ap[i] === preferredDoc ? -1 : | |
4336 bp[i] === preferredDoc ? 1 : | |
4337 0; | |
4338 }; | |
4339 | |
4340 // Always assume the presence of duplicates if sort doesn't | |
4341 // pass them to our comparison function (as in Google Chrome). | |
4342 hasDuplicate = false; | |
4343 [0, 0].sort( sortOrder ); | |
4344 support.detectDuplicates = hasDuplicate; | |
4345 | |
4346 return document; | |
4347 }; | |
4348 | |
4349 Sizzle.matches = function( expr, elements ) { | |
4350 return Sizzle( expr, null, null, elements ); | |
4351 }; | |
4352 | |
4353 Sizzle.matchesSelector = function( elem, expr ) { | |
4354 // Set document vars if needed | |
4355 if ( ( elem.ownerDocument || elem ) !== document ) { | |
4356 setDocument( elem ); | |
4357 } | |
4358 | |
4359 // Make sure that attribute selectors are quoted | |
4360 expr = expr.replace( rattributeQuotes, "='$1']" ); | |
4361 | |
4362 // rbuggyQSA always contains :focus, so no need for an existence check | |
4363 if ( support.matchesSelector && !documentIsXML && (!rbuggyMatches || !rb
uggyMatches.test(expr)) && !rbuggyQSA.test(expr) ) { | |
4364 try { | |
4365 var ret = matches.call( elem, expr ); | |
4366 | |
4367 // IE 9's matchesSelector returns false on disconnected
nodes | |
4368 if ( ret || support.disconnectedMatch || | |
4369 // As well, disconnected nodes are said
to be in a document | |
4370 // fragment in IE 9 | |
4371 elem.document && elem.document.nodeType
!== 11 ) { | |
4372 return ret; | |
4373 } | |
4374 } catch(e) {} | |
4375 } | |
4376 | |
4377 return Sizzle( expr, document, null, [elem] ).length > 0; | |
4378 }; | |
4379 | |
4380 Sizzle.contains = function( context, elem ) { | |
4381 // Set document vars if needed | |
4382 if ( ( context.ownerDocument || context ) !== document ) { | |
4383 setDocument( context ); | |
4384 } | |
4385 return contains( context, elem ); | |
4386 }; | |
4387 | |
4388 Sizzle.attr = function( elem, name ) { | |
4389 var val; | |
4390 | |
4391 // Set document vars if needed | |
4392 if ( ( elem.ownerDocument || elem ) !== document ) { | |
4393 setDocument( elem ); | |
4394 } | |
4395 | |
4396 if ( !documentIsXML ) { | |
4397 name = name.toLowerCase(); | |
4398 } | |
4399 if ( (val = Expr.attrHandle[ name ]) ) { | |
4400 return val( elem ); | |
4401 } | |
4402 if ( documentIsXML || support.attributes ) { | |
4403 return elem.getAttribute( name ); | |
4404 } | |
4405 return ( (val = elem.getAttributeNode( name )) || elem.getAttribute( nam
e ) ) && elem[ name ] === true ? | |
4406 name : | |
4407 val && val.specified ? val.value : null; | |
4408 }; | |
4409 | |
4410 Sizzle.error = function( msg ) { | |
4411 throw new Error( "Syntax error, unrecognized expression: " + msg ); | |
4412 }; | |
4413 | |
4414 // Document sorting and removing duplicates | |
4415 Sizzle.uniqueSort = function( results ) { | |
4416 var elem, | |
4417 duplicates = [], | |
4418 i = 1, | |
4419 j = 0; | |
4420 | |
4421 // Unless we *know* we can detect duplicates, assume their presence | |
4422 hasDuplicate = !support.detectDuplicates; | |
4423 results.sort( sortOrder ); | |
4424 | |
4425 if ( hasDuplicate ) { | |
4426 for ( ; (elem = results[i]); i++ ) { | |
4427 if ( elem === results[ i - 1 ] ) { | |
4428 j = duplicates.push( i ); | |
4429 } | |
4430 } | |
4431 while ( j-- ) { | |
4432 results.splice( duplicates[ j ], 1 ); | |
4433 } | |
4434 } | |
4435 | |
4436 return results; | |
4437 }; | |
4438 | |
4439 function siblingCheck( a, b ) { | |
4440 var cur = a && b && a.nextSibling; | |
4441 | |
4442 for ( ; cur; cur = cur.nextSibling ) { | |
4443 if ( cur === b ) { | |
4444 return -1; | |
4445 } | |
4446 } | |
4447 | |
4448 return a ? 1 : -1; | |
4449 } | |
4450 | |
4451 // Returns a function to use in pseudos for input types | |
4452 function createInputPseudo( type ) { | |
4453 return function( elem ) { | |
4454 var name = elem.nodeName.toLowerCase(); | |
4455 return name === "input" && elem.type === type; | |
4456 }; | |
4457 } | |
4458 | |
4459 // Returns a function to use in pseudos for buttons | |
4460 function createButtonPseudo( type ) { | |
4461 return function( elem ) { | |
4462 var name = elem.nodeName.toLowerCase(); | |
4463 return (name === "input" || name === "button") && elem.type ===
type; | |
4464 }; | |
4465 } | |
4466 | |
4467 // Returns a function to use in pseudos for positionals | |
4468 function createPositionalPseudo( fn ) { | |
4469 return markFunction(function( argument ) { | |
4470 argument = +argument; | |
4471 return markFunction(function( seed, matches ) { | |
4472 var j, | |
4473 matchIndexes = fn( [], seed.length, argument ), | |
4474 i = matchIndexes.length; | |
4475 | |
4476 // Match elements found at the specified indexes | |
4477 while ( i-- ) { | |
4478 if ( seed[ (j = matchIndexes[i]) ] ) { | |
4479 seed[j] = !(matches[j] = seed[j]); | |
4480 } | |
4481 } | |
4482 }); | |
4483 }); | |
4484 } | |
4485 | |
4486 /** | |
4487 * Utility function for retrieving the text value of an array of DOM nodes | |
4488 * @param {Array|Element} elem | |
4489 */ | |
4490 getText = Sizzle.getText = function( elem ) { | |
4491 var node, | |
4492 ret = "", | |
4493 i = 0, | |
4494 nodeType = elem.nodeType; | |
4495 | |
4496 if ( !nodeType ) { | |
4497 // If no nodeType, this is expected to be an array | |
4498 for ( ; (node = elem[i]); i++ ) { | |
4499 // Do not traverse comment nodes | |
4500 ret += getText( node ); | |
4501 } | |
4502 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { | |
4503 // Use textContent for elements | |
4504 // innerText usage removed for consistency of new lines (see #11
153) | |
4505 if ( typeof elem.textContent === "string" ) { | |
4506 return elem.textContent; | |
4507 } else { | |
4508 // Traverse its children | |
4509 for ( elem = elem.firstChild; elem; elem = elem.nextSibl
ing ) { | |
4510 ret += getText( elem ); | |
4511 } | |
4512 } | |
4513 } else if ( nodeType === 3 || nodeType === 4 ) { | |
4514 return elem.nodeValue; | |
4515 } | |
4516 // Do not include comment or processing instruction nodes | |
4517 | |
4518 return ret; | |
4519 }; | |
4520 | |
4521 Expr = Sizzle.selectors = { | |
4522 | |
4523 // Can be adjusted by the user | |
4524 cacheLength: 50, | |
4525 | |
4526 createPseudo: markFunction, | |
4527 | |
4528 match: matchExpr, | |
4529 | |
4530 find: {}, | |
4531 | |
4532 relative: { | |
4533 ">": { dir: "parentNode", first: true }, | |
4534 " ": { dir: "parentNode" }, | |
4535 "+": { dir: "previousSibling", first: true }, | |
4536 "~": { dir: "previousSibling" } | |
4537 }, | |
4538 | |
4539 preFilter: { | |
4540 "ATTR": function( match ) { | |
4541 match[1] = match[1].replace( runescape, funescape ); | |
4542 | |
4543 // Move the given value to match[3] whether quoted or un
quoted | |
4544 match[3] = ( match[4] || match[5] || "" ).replace( runes
cape, funescape ); | |
4545 | |
4546 if ( match[2] === "~=" ) { | |
4547 match[3] = " " + match[3] + " "; | |
4548 } | |
4549 | |
4550 return match.slice( 0, 4 ); | |
4551 }, | |
4552 | |
4553 "CHILD": function( match ) { | |
4554 /* matches from matchExpr["CHILD"] | |
4555 1 type (only|nth|...) | |
4556 2 what (child|of-type) | |
4557 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) | |
4558 4 xn-component of xn+y argument ([+-]?\d*n|) | |
4559 5 sign of xn-component | |
4560 6 x of xn-component | |
4561 7 sign of y-component | |
4562 8 y of y-component | |
4563 */ | |
4564 match[1] = match[1].toLowerCase(); | |
4565 | |
4566 if ( match[1].slice( 0, 3 ) === "nth" ) { | |
4567 // nth-* requires argument | |
4568 if ( !match[3] ) { | |
4569 Sizzle.error( match[0] ); | |
4570 } | |
4571 | |
4572 // numeric x and y parameters for Expr.filter.CH
ILD | |
4573 // remember that false/true cast respectively to
0/1 | |
4574 match[4] = +( match[4] ? match[5] + (match[6] ||
1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); | |
4575 match[5] = +( ( match[7] + match[8] ) || match[3
] === "odd" ); | |
4576 | |
4577 // other types prohibit arguments | |
4578 } else if ( match[3] ) { | |
4579 Sizzle.error( match[0] ); | |
4580 } | |
4581 | |
4582 return match; | |
4583 }, | |
4584 | |
4585 "PSEUDO": function( match ) { | |
4586 var excess, | |
4587 unquoted = !match[5] && match[2]; | |
4588 | |
4589 if ( matchExpr["CHILD"].test( match[0] ) ) { | |
4590 return null; | |
4591 } | |
4592 | |
4593 // Accept quoted arguments as-is | |
4594 if ( match[4] ) { | |
4595 match[2] = match[4]; | |
4596 | |
4597 // Strip excess characters from unquoted arguments | |
4598 } else if ( unquoted && rpseudo.test( unquoted ) && | |
4599 // Get excess from tokenize (recursively) | |
4600 (excess = tokenize( unquoted, true )) && | |
4601 // advance to the next closing parenthesis | |
4602 (excess = unquoted.indexOf( ")", unquoted.length
- excess ) - unquoted.length) ) { | |
4603 | |
4604 // excess is a negative index | |
4605 match[0] = match[0].slice( 0, excess ); | |
4606 match[2] = unquoted.slice( 0, excess ); | |
4607 } | |
4608 | |
4609 // Return only captures needed by the pseudo filter meth
od (type and argument) | |
4610 return match.slice( 0, 3 ); | |
4611 } | |
4612 }, | |
4613 | |
4614 filter: { | |
4615 | |
4616 "TAG": function( nodeName ) { | |
4617 if ( nodeName === "*" ) { | |
4618 return function() { return true; }; | |
4619 } | |
4620 | |
4621 nodeName = nodeName.replace( runescape, funescape ).toLo
werCase(); | |
4622 return function( elem ) { | |
4623 return elem.nodeName && elem.nodeName.toLowerCas
e() === nodeName; | |
4624 }; | |
4625 }, | |
4626 | |
4627 "CLASS": function( className ) { | |
4628 var pattern = classCache[ className + " " ]; | |
4629 | |
4630 return pattern || | |
4631 (pattern = new RegExp( "(^|" + whitespace + ")"
+ className + "(" + whitespace + "|$)" )) && | |
4632 classCache( className, function( elem ) { | |
4633 return pattern.test( elem.className || (
typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" )
; | |
4634 }); | |
4635 }, | |
4636 | |
4637 "ATTR": function( name, operator, check ) { | |
4638 return function( elem ) { | |
4639 var result = Sizzle.attr( elem, name ); | |
4640 | |
4641 if ( result == null ) { | |
4642 return operator === "!="; | |
4643 } | |
4644 if ( !operator ) { | |
4645 return true; | |
4646 } | |
4647 | |
4648 result += ""; | |
4649 | |
4650 return operator === "=" ? result === check : | |
4651 operator === "!=" ? result !== check : | |
4652 operator === "^=" ? check && result.inde
xOf( check ) === 0 : | |
4653 operator === "*=" ? check && result.inde
xOf( check ) > -1 : | |
4654 operator === "$=" ? check && result.subs
tr( result.length - check.length ) === check : | |
4655 operator === "~=" ? ( " " + result + " "
).indexOf( check ) > -1 : | |
4656 operator === "|=" ? result === check ||
result.substr( 0, check.length + 1 ) === check + "-" : | |
4657 false; | |
4658 }; | |
4659 }, | |
4660 | |
4661 "CHILD": function( type, what, argument, first, last ) { | |
4662 var simple = type.slice( 0, 3 ) !== "nth", | |
4663 forward = type.slice( -4 ) !== "last", | |
4664 ofType = what === "of-type"; | |
4665 | |
4666 return first === 1 && last === 0 ? | |
4667 | |
4668 // Shortcut for :nth-*(n) | |
4669 function( elem ) { | |
4670 return !!elem.parentNode; | |
4671 } : | |
4672 | |
4673 function( elem, context, xml ) { | |
4674 var cache, outerCache, node, diff, nodeI
ndex, start, | |
4675 dir = simple !== forward ? "next
Sibling" : "previousSibling", | |
4676 parent = elem.parentNode, | |
4677 name = ofType && elem.nodeName.t
oLowerCase(), | |
4678 useCache = !xml && !ofType; | |
4679 | |
4680 if ( parent ) { | |
4681 | |
4682 // :(first|last|only)-(child|of-
type) | |
4683 if ( simple ) { | |
4684 while ( dir ) { | |
4685 node = elem; | |
4686 while ( (node =
node[ dir ]) ) { | |
4687 if ( ofT
ype ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { | |
4688
return false; | |
4689 } | |
4690 } | |
4691 // Reverse direc
tion for :only-* (if we haven't yet done so) | |
4692 start = dir = ty
pe === "only" && !start && "nextSibling"; | |
4693 } | |
4694 return true; | |
4695 } | |
4696 | |
4697 start = [ forward ? parent.first
Child : parent.lastChild ]; | |
4698 | |
4699 // non-xml :nth-child(...) store
s cache data on `parent` | |
4700 if ( forward && useCache ) { | |
4701 // Seek `elem` from a pr
eviously-cached index | |
4702 outerCache = parent[ exp
ando ] || (parent[ expando ] = {}); | |
4703 cache = outerCache[ type
] || []; | |
4704 nodeIndex = cache[0] ===
dirruns && cache[1]; | |
4705 diff = cache[0] === dirr
uns && cache[2]; | |
4706 node = nodeIndex && pare
nt.childNodes[ nodeIndex ]; | |
4707 | |
4708 while ( (node = ++nodeIn
dex && node && node[ dir ] || | |
4709 | |
4710 // Fallback to s
eeking `elem` from the start | |
4711 (diff = nodeInde
x = 0) || start.pop()) ) { | |
4712 | |
4713 // When found, c
ache indexes on `parent` and break | |
4714 if ( node.nodeTy
pe === 1 && ++diff && node === elem ) { | |
4715 outerCac
he[ type ] = [ dirruns, nodeIndex, diff ]; | |
4716 break; | |
4717 } | |
4718 } | |
4719 | |
4720 // Use previously-cached element
index if available | |
4721 } else if ( useCache && (cache =
(elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns )
{ | |
4722 diff = cache[1]; | |
4723 | |
4724 // xml :nth-child(...) or :nth-l
ast-child(...) or :nth(-last)?-of-type(...) | |
4725 } else { | |
4726 // Use the same loop as
above to seek `elem` from the start | |
4727 while ( (node = ++nodeIn
dex && node && node[ dir ] || | |
4728 (diff = nodeInde
x = 0) || start.pop()) ) { | |
4729 | |
4730 if ( ( ofType ?
node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { | |
4731 // Cache
the index of each encountered element | |
4732 if ( use
Cache ) { | |
4733
(node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; | |
4734 } | |
4735 | |
4736 if ( nod
e === elem ) { | |
4737
break; | |
4738 } | |
4739 } | |
4740 } | |
4741 } | |
4742 | |
4743 // Incorporate the offset, then
check against cycle size | |
4744 diff -= last; | |
4745 return diff === first || ( diff
% first === 0 && diff / first >= 0 ); | |
4746 } | |
4747 }; | |
4748 }, | |
4749 | |
4750 "PSEUDO": function( pseudo, argument ) { | |
4751 // pseudo-class names are case-insensitive | |
4752 // http://www.w3.org/TR/selectors/#pseudo-classes | |
4753 // Prioritize by case sensitivity in case custom pseudos
are added with uppercase letters | |
4754 // Remember that setFilters inherits from pseudos | |
4755 var args, | |
4756 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[
pseudo.toLowerCase() ] || | |
4757 Sizzle.error( "unsupported pseudo: " + p
seudo ); | |
4758 | |
4759 // The user may use createPseudo to indicate that | |
4760 // arguments are needed to create the filter function | |
4761 // just as Sizzle does | |
4762 if ( fn[ expando ] ) { | |
4763 return fn( argument ); | |
4764 } | |
4765 | |
4766 // But maintain support for old signatures | |
4767 if ( fn.length > 1 ) { | |
4768 args = [ pseudo, pseudo, "", argument ]; | |
4769 return Expr.setFilters.hasOwnProperty( pseudo.to
LowerCase() ) ? | |
4770 markFunction(function( seed, matches ) { | |
4771 var idx, | |
4772 matched = fn( seed, argu
ment ), | |
4773 i = matched.length; | |
4774 while ( i-- ) { | |
4775 idx = indexOf.call( seed
, matched[i] ); | |
4776 seed[ idx ] = !( matches
[ idx ] = matched[i] ); | |
4777 } | |
4778 }) : | |
4779 function( elem ) { | |
4780 return fn( elem, 0, args ); | |
4781 }; | |
4782 } | |
4783 | |
4784 return fn; | |
4785 } | |
4786 }, | |
4787 | |
4788 pseudos: { | |
4789 // Potentially complex pseudos | |
4790 "not": markFunction(function( selector ) { | |
4791 // Trim the selector passed to compile | |
4792 // to avoid treating leading and trailing | |
4793 // spaces as combinators | |
4794 var input = [], | |
4795 results = [], | |
4796 matcher = compile( selector.replace( rtrim, "$1"
) ); | |
4797 | |
4798 return matcher[ expando ] ? | |
4799 markFunction(function( seed, matches, context, x
ml ) { | |
4800 var elem, | |
4801 unmatched = matcher( seed, null,
xml, [] ), | |
4802 i = seed.length; | |
4803 | |
4804 // Match elements unmatched by `matcher` | |
4805 while ( i-- ) { | |
4806 if ( (elem = unmatched[i]) ) { | |
4807 seed[i] = !(matches[i] =
elem); | |
4808 } | |
4809 } | |
4810 }) : | |
4811 function( elem, context, xml ) { | |
4812 input[0] = elem; | |
4813 matcher( input, null, xml, results ); | |
4814 return !results.pop(); | |
4815 }; | |
4816 }), | |
4817 | |
4818 "has": markFunction(function( selector ) { | |
4819 return function( elem ) { | |
4820 return Sizzle( selector, elem ).length > 0; | |
4821 }; | |
4822 }), | |
4823 | |
4824 "contains": markFunction(function( text ) { | |
4825 return function( elem ) { | |
4826 return ( elem.textContent || elem.innerText || g
etText( elem ) ).indexOf( text ) > -1; | |
4827 }; | |
4828 }), | |
4829 | |
4830 // "Whether an element is represented by a :lang() selector | |
4831 // is based solely on the element's language value | |
4832 // being equal to the identifier C, | |
4833 // or beginning with the identifier C immediately followed by "-
". | |
4834 // The matching of C against the element's language value is per
formed case-insensitively. | |
4835 // The identifier C does not have to be a valid language name." | |
4836 // http://www.w3.org/TR/selectors/#lang-pseudo | |
4837 "lang": markFunction( function( lang ) { | |
4838 // lang value must be a valid identifider | |
4839 if ( !ridentifier.test(lang || "") ) { | |
4840 Sizzle.error( "unsupported lang: " + lang ); | |
4841 } | |
4842 lang = lang.replace( runescape, funescape ).toLowerCase(
); | |
4843 return function( elem ) { | |
4844 var elemLang; | |
4845 do { | |
4846 if ( (elemLang = documentIsXML ? | |
4847 elem.getAttribute("xml:lang") ||
elem.getAttribute("lang") : | |
4848 elem.lang) ) { | |
4849 | |
4850 elemLang = elemLang.toLowerCase(
); | |
4851 return elemLang === lang || elem
Lang.indexOf( lang + "-" ) === 0; | |
4852 } | |
4853 } while ( (elem = elem.parentNode) && elem.nodeT
ype === 1 ); | |
4854 return false; | |
4855 }; | |
4856 }), | |
4857 | |
4858 // Miscellaneous | |
4859 "target": function( elem ) { | |
4860 var hash = window.location && window.location.hash; | |
4861 return hash && hash.slice( 1 ) === elem.id; | |
4862 }, | |
4863 | |
4864 "root": function( elem ) { | |
4865 return elem === docElem; | |
4866 }, | |
4867 | |
4868 "focus": function( elem ) { | |
4869 return elem === document.activeElement && (!document.has
Focus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); | |
4870 }, | |
4871 | |
4872 // Boolean properties | |
4873 "enabled": function( elem ) { | |
4874 return elem.disabled === false; | |
4875 }, | |
4876 | |
4877 "disabled": function( elem ) { | |
4878 return elem.disabled === true; | |
4879 }, | |
4880 | |
4881 "checked": function( elem ) { | |
4882 // In CSS3, :checked should return both checked and sele
cted elements | |
4883 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929
/#checked | |
4884 var nodeName = elem.nodeName.toLowerCase(); | |
4885 return (nodeName === "input" && !!elem.checked) || (node
Name === "option" && !!elem.selected); | |
4886 }, | |
4887 | |
4888 "selected": function( elem ) { | |
4889 // Accessing this property makes selected-by-default | |
4890 // options in Safari work properly | |
4891 if ( elem.parentNode ) { | |
4892 elem.parentNode.selectedIndex; | |
4893 } | |
4894 | |
4895 return elem.selected === true; | |
4896 }, | |
4897 | |
4898 // Contents | |
4899 "empty": function( elem ) { | |
4900 // http://www.w3.org/TR/selectors/#empty-pseudo | |
4901 // :empty is only affected by element nodes and content
nodes(including text(3), cdata(4)), | |
4902 // not comment, processing instructions, or others | |
4903 // Thanks to Diego Perini for the nodeName shortcut | |
4904 // Greater than "@" means alpha characters (specifical
ly not starting with "#" or "?") | |
4905 for ( elem = elem.firstChild; elem; elem = elem.nextSibl
ing ) { | |
4906 if ( elem.nodeName > "@" || elem.nodeType === 3
|| elem.nodeType === 4 ) { | |
4907 return false; | |
4908 } | |
4909 } | |
4910 return true; | |
4911 }, | |
4912 | |
4913 "parent": function( elem ) { | |
4914 return !Expr.pseudos["empty"]( elem ); | |
4915 }, | |
4916 | |
4917 // Element/input types | |
4918 "header": function( elem ) { | |
4919 return rheader.test( elem.nodeName ); | |
4920 }, | |
4921 | |
4922 "input": function( elem ) { | |
4923 return rinputs.test( elem.nodeName ); | |
4924 }, | |
4925 | |
4926 "button": function( elem ) { | |
4927 var name = elem.nodeName.toLowerCase(); | |
4928 return name === "input" && elem.type === "button" || nam
e === "button"; | |
4929 }, | |
4930 | |
4931 "text": function( elem ) { | |
4932 var attr; | |
4933 // IE6 and 7 will map elem.type to 'text' for new HTML5
types (search, etc) | |
4934 // use getAttribute instead to test this case | |
4935 return elem.nodeName.toLowerCase() === "input" && | |
4936 elem.type === "text" && | |
4937 ( (attr = elem.getAttribute("type")) == null ||
attr.toLowerCase() === elem.type ); | |
4938 }, | |
4939 | |
4940 // Position-in-collection | |
4941 "first": createPositionalPseudo(function() { | |
4942 return [ 0 ]; | |
4943 }), | |
4944 | |
4945 "last": createPositionalPseudo(function( matchIndexes, length )
{ | |
4946 return [ length - 1 ]; | |
4947 }), | |
4948 | |
4949 "eq": createPositionalPseudo(function( matchIndexes, length, arg
ument ) { | |
4950 return [ argument < 0 ? argument + length : argument ]; | |
4951 }), | |
4952 | |
4953 "even": createPositionalPseudo(function( matchIndexes, length )
{ | |
4954 var i = 0; | |
4955 for ( ; i < length; i += 2 ) { | |
4956 matchIndexes.push( i ); | |
4957 } | |
4958 return matchIndexes; | |
4959 }), | |
4960 | |
4961 "odd": createPositionalPseudo(function( matchIndexes, length ) { | |
4962 var i = 1; | |
4963 for ( ; i < length; i += 2 ) { | |
4964 matchIndexes.push( i ); | |
4965 } | |
4966 return matchIndexes; | |
4967 }), | |
4968 | |
4969 "lt": createPositionalPseudo(function( matchIndexes, length, arg
ument ) { | |
4970 var i = argument < 0 ? argument + length : argument; | |
4971 for ( ; --i >= 0; ) { | |
4972 matchIndexes.push( i ); | |
4973 } | |
4974 return matchIndexes; | |
4975 }), | |
4976 | |
4977 "gt": createPositionalPseudo(function( matchIndexes, length, arg
ument ) { | |
4978 var i = argument < 0 ? argument + length : argument; | |
4979 for ( ; ++i < length; ) { | |
4980 matchIndexes.push( i ); | |
4981 } | |
4982 return matchIndexes; | |
4983 }) | |
4984 } | |
4985 }; | |
4986 | |
4987 // Add button/input type pseudos | |
4988 for ( i in { radio: true, checkbox: true, file: true, password: true, image: tru
e } ) { | |
4989 Expr.pseudos[ i ] = createInputPseudo( i ); | |
4990 } | |
4991 for ( i in { submit: true, reset: true } ) { | |
4992 Expr.pseudos[ i ] = createButtonPseudo( i ); | |
4993 } | |
4994 | |
4995 function tokenize( selector, parseOnly ) { | |
4996 var matched, match, tokens, type, | |
4997 soFar, groups, preFilters, | |
4998 cached = tokenCache[ selector + " " ]; | |
4999 | |
5000 if ( cached ) { | |
5001 return parseOnly ? 0 : cached.slice( 0 ); | |
5002 } | |
5003 | |
5004 soFar = selector; | |
5005 groups = []; | |
5006 preFilters = Expr.preFilter; | |
5007 | |
5008 while ( soFar ) { | |
5009 | |
5010 // Comma and first run | |
5011 if ( !matched || (match = rcomma.exec( soFar )) ) { | |
5012 if ( match ) { | |
5013 // Don't consume trailing commas as valid | |
5014 soFar = soFar.slice( match[0].length ) || soFar; | |
5015 } | |
5016 groups.push( tokens = [] ); | |
5017 } | |
5018 | |
5019 matched = false; | |
5020 | |
5021 // Combinators | |
5022 if ( (match = rcombinators.exec( soFar )) ) { | |
5023 matched = match.shift(); | |
5024 tokens.push( { | |
5025 value: matched, | |
5026 // Cast descendant combinators to space | |
5027 type: match[0].replace( rtrim, " " ) | |
5028 } ); | |
5029 soFar = soFar.slice( matched.length ); | |
5030 } | |
5031 | |
5032 // Filters | |
5033 for ( type in Expr.filter ) { | |
5034 if ( (match = matchExpr[ type ].exec( soFar )) && (!preF
ilters[ type ] || | |
5035 (match = preFilters[ type ]( match ))) ) { | |
5036 matched = match.shift(); | |
5037 tokens.push( { | |
5038 value: matched, | |
5039 type: type, | |
5040 matches: match | |
5041 } ); | |
5042 soFar = soFar.slice( matched.length ); | |
5043 } | |
5044 } | |
5045 | |
5046 if ( !matched ) { | |
5047 break; | |
5048 } | |
5049 } | |
5050 | |
5051 // Return the length of the invalid excess | |
5052 // if we're just parsing | |
5053 // Otherwise, throw an error or return tokens | |
5054 return parseOnly ? | |
5055 soFar.length : | |
5056 soFar ? | |
5057 Sizzle.error( selector ) : | |
5058 // Cache the tokens | |
5059 tokenCache( selector, groups ).slice( 0 ); | |
5060 } | |
5061 | |
5062 function toSelector( tokens ) { | |
5063 var i = 0, | |
5064 len = tokens.length, | |
5065 selector = ""; | |
5066 for ( ; i < len; i++ ) { | |
5067 selector += tokens[i].value; | |
5068 } | |
5069 return selector; | |
5070 } | |
5071 | |
5072 function addCombinator( matcher, combinator, base ) { | |
5073 var dir = combinator.dir, | |
5074 checkNonElements = base && combinator.dir === "parentNode", | |
5075 doneName = done++; | |
5076 | |
5077 return combinator.first ? | |
5078 // Check against closest ancestor/preceding element | |
5079 function( elem, context, xml ) { | |
5080 while ( (elem = elem[ dir ]) ) { | |
5081 if ( elem.nodeType === 1 || checkNonElements ) { | |
5082 return matcher( elem, context, xml ); | |
5083 } | |
5084 } | |
5085 } : | |
5086 | |
5087 // Check against all ancestor/preceding elements | |
5088 function( elem, context, xml ) { | |
5089 var data, cache, outerCache, | |
5090 dirkey = dirruns + " " + doneName; | |
5091 | |
5092 // We can't set arbitrary data on XML nodes, so they don
't benefit from dir caching | |
5093 if ( xml ) { | |
5094 while ( (elem = elem[ dir ]) ) { | |
5095 if ( elem.nodeType === 1 || checkNonElem
ents ) { | |
5096 if ( matcher( elem, context, xml
) ) { | |
5097 return true; | |
5098 } | |
5099 } | |
5100 } | |
5101 } else { | |
5102 while ( (elem = elem[ dir ]) ) { | |
5103 if ( elem.nodeType === 1 || checkNonElem
ents ) { | |
5104 outerCache = elem[ expando ] ||
(elem[ expando ] = {}); | |
5105 if ( (cache = outerCache[ dir ])
&& cache[0] === dirkey ) { | |
5106 if ( (data = cache[1]) =
== true || data === cachedruns ) { | |
5107 return data ===
true; | |
5108 } | |
5109 } else { | |
5110 cache = outerCache[ dir
] = [ dirkey ]; | |
5111 cache[1] = matcher( elem
, context, xml ) || cachedruns; | |
5112 if ( cache[1] === true )
{ | |
5113 return true; | |
5114 } | |
5115 } | |
5116 } | |
5117 } | |
5118 } | |
5119 }; | |
5120 } | |
5121 | |
5122 function elementMatcher( matchers ) { | |
5123 return matchers.length > 1 ? | |
5124 function( elem, context, xml ) { | |
5125 var i = matchers.length; | |
5126 while ( i-- ) { | |
5127 if ( !matchers[i]( elem, context, xml ) ) { | |
5128 return false; | |
5129 } | |
5130 } | |
5131 return true; | |
5132 } : | |
5133 matchers[0]; | |
5134 } | |
5135 | |
5136 function condense( unmatched, map, filter, context, xml ) { | |
5137 var elem, | |
5138 newUnmatched = [], | |
5139 i = 0, | |
5140 len = unmatched.length, | |
5141 mapped = map != null; | |
5142 | |
5143 for ( ; i < len; i++ ) { | |
5144 if ( (elem = unmatched[i]) ) { | |
5145 if ( !filter || filter( elem, context, xml ) ) { | |
5146 newUnmatched.push( elem ); | |
5147 if ( mapped ) { | |
5148 map.push( i ); | |
5149 } | |
5150 } | |
5151 } | |
5152 } | |
5153 | |
5154 return newUnmatched; | |
5155 } | |
5156 | |
5157 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postS
elector ) { | |
5158 if ( postFilter && !postFilter[ expando ] ) { | |
5159 postFilter = setMatcher( postFilter ); | |
5160 } | |
5161 if ( postFinder && !postFinder[ expando ] ) { | |
5162 postFinder = setMatcher( postFinder, postSelector ); | |
5163 } | |
5164 return markFunction(function( seed, results, context, xml ) { | |
5165 var temp, i, elem, | |
5166 preMap = [], | |
5167 postMap = [], | |
5168 preexisting = results.length, | |
5169 | |
5170 // Get initial elements from seed or context | |
5171 elems = seed || multipleContexts( selector || "*", conte
xt.nodeType ? [ context ] : context, [] ), | |
5172 | |
5173 // Prefilter to get matcher input, preserving a map for
seed-results synchronization | |
5174 matcherIn = preFilter && ( seed || !selector ) ? | |
5175 condense( elems, preMap, preFilter, context, xml
) : | |
5176 elems, | |
5177 | |
5178 matcherOut = matcher ? | |
5179 // If we have a postFinder, or filtered seed, or
non-seed postFilter or preexisting results, | |
5180 postFinder || ( seed ? preFilter : preexisting |
| postFilter ) ? | |
5181 | |
5182 // ...intermediate processing is necessa
ry | |
5183 [] : | |
5184 | |
5185 // ...otherwise use results directly | |
5186 results : | |
5187 matcherIn; | |
5188 | |
5189 // Find primary matches | |
5190 if ( matcher ) { | |
5191 matcher( matcherIn, matcherOut, context, xml ); | |
5192 } | |
5193 | |
5194 // Apply postFilter | |
5195 if ( postFilter ) { | |
5196 temp = condense( matcherOut, postMap ); | |
5197 postFilter( temp, [], context, xml ); | |
5198 | |
5199 // Un-match failing elements by moving them back to matc
herIn | |
5200 i = temp.length; | |
5201 while ( i-- ) { | |
5202 if ( (elem = temp[i]) ) { | |
5203 matcherOut[ postMap[i] ] = !(matcherIn[
postMap[i] ] = elem); | |
5204 } | |
5205 } | |
5206 } | |
5207 | |
5208 if ( seed ) { | |
5209 if ( postFinder || preFilter ) { | |
5210 if ( postFinder ) { | |
5211 // Get the final matcherOut by condensin
g this intermediate into postFinder contexts | |
5212 temp = []; | |
5213 i = matcherOut.length; | |
5214 while ( i-- ) { | |
5215 if ( (elem = matcherOut[i]) ) { | |
5216 // Restore matcherIn sin
ce elem is not yet a final match | |
5217 temp.push( (matcherIn[i]
= elem) ); | |
5218 } | |
5219 } | |
5220 postFinder( null, (matcherOut = []), tem
p, xml ); | |
5221 } | |
5222 | |
5223 // Move matched elements from seed to results to
keep them synchronized | |
5224 i = matcherOut.length; | |
5225 while ( i-- ) { | |
5226 if ( (elem = matcherOut[i]) && | |
5227 (temp = postFinder ? indexOf.cal
l( seed, elem ) : preMap[i]) > -1 ) { | |
5228 | |
5229 seed[temp] = !(results[temp] = e
lem); | |
5230 } | |
5231 } | |
5232 } | |
5233 | |
5234 // Add elements to results, through postFinder if defined | |
5235 } else { | |
5236 matcherOut = condense( | |
5237 matcherOut === results ? | |
5238 matcherOut.splice( preexisting, matcherO
ut.length ) : | |
5239 matcherOut | |
5240 ); | |
5241 if ( postFinder ) { | |
5242 postFinder( null, results, matcherOut, xml ); | |
5243 } else { | |
5244 push.apply( results, matcherOut ); | |
5245 } | |
5246 } | |
5247 }); | |
5248 } | |
5249 | |
5250 function matcherFromTokens( tokens ) { | |
5251 var checkContext, matcher, j, | |
5252 len = tokens.length, | |
5253 leadingRelative = Expr.relative[ tokens[0].type ], | |
5254 implicitRelative = leadingRelative || Expr.relative[" "], | |
5255 i = leadingRelative ? 1 : 0, | |
5256 | |
5257 // The foundational matcher ensures that elements are reachable
from top-level context(s) | |
5258 matchContext = addCombinator( function( elem ) { | |
5259 return elem === checkContext; | |
5260 }, implicitRelative, true ), | |
5261 matchAnyContext = addCombinator( function( elem ) { | |
5262 return indexOf.call( checkContext, elem ) > -1; | |
5263 }, implicitRelative, true ), | |
5264 matchers = [ function( elem, context, xml ) { | |
5265 return ( !leadingRelative && ( xml || context !== outerm
ostContext ) ) || ( | |
5266 (checkContext = context).nodeType ? | |
5267 matchContext( elem, context, xml ) : | |
5268 matchAnyContext( elem, context, xml ) ); | |
5269 } ]; | |
5270 | |
5271 for ( ; i < len; i++ ) { | |
5272 if ( (matcher = Expr.relative[ tokens[i].type ]) ) { | |
5273 matchers = [ addCombinator(elementMatcher( matchers ), m
atcher) ]; | |
5274 } else { | |
5275 matcher = Expr.filter[ tokens[i].type ].apply( null, tok
ens[i].matches ); | |
5276 | |
5277 // Return special upon seeing a positional matcher | |
5278 if ( matcher[ expando ] ) { | |
5279 // Find the next relative operator (if any) for
proper handling | |
5280 j = ++i; | |
5281 for ( ; j < len; j++ ) { | |
5282 if ( Expr.relative[ tokens[j].type ] ) { | |
5283 break; | |
5284 } | |
5285 } | |
5286 return setMatcher( | |
5287 i > 1 && elementMatcher( matchers ), | |
5288 i > 1 && toSelector( tokens.slice( 0, i
- 1 ) ).replace( rtrim, "$1" ), | |
5289 matcher, | |
5290 i < j && matcherFromTokens( tokens.slice
( i, j ) ), | |
5291 j < len && matcherFromTokens( (tokens =
tokens.slice( j )) ), | |
5292 j < len && toSelector( tokens ) | |
5293 ); | |
5294 } | |
5295 matchers.push( matcher ); | |
5296 } | |
5297 } | |
5298 | |
5299 return elementMatcher( matchers ); | |
5300 } | |
5301 | |
5302 function matcherFromGroupMatchers( elementMatchers, setMatchers ) { | |
5303 // A counter to specify which element is currently being matched | |
5304 var matcherCachedRuns = 0, | |
5305 bySet = setMatchers.length > 0, | |
5306 byElement = elementMatchers.length > 0, | |
5307 superMatcher = function( seed, context, xml, results, expandCont
ext ) { | |
5308 var elem, j, matcher, | |
5309 setMatched = [], | |
5310 matchedCount = 0, | |
5311 i = "0", | |
5312 unmatched = seed && [], | |
5313 outermost = expandContext != null, | |
5314 contextBackup = outermostContext, | |
5315 // We must always have either seed elements or c
ontext | |
5316 elems = seed || byElement && Expr.find["TAG"]( "
*", expandContext && context.parentNode || context ), | |
5317 // Nested matchers should use non-integer dirrun
s | |
5318 dirrunsUnique = (dirruns += contextBackup == nul
l ? 1 : Math.E); | |
5319 | |
5320 if ( outermost ) { | |
5321 outermostContext = context !== document && conte
xt; | |
5322 cachedruns = matcherCachedRuns; | |
5323 } | |
5324 | |
5325 // Add elements passing elementMatchers directly to resu
lts | |
5326 for ( ; (elem = elems[i]) != null; i++ ) { | |
5327 if ( byElement && elem ) { | |
5328 for ( j = 0; (matcher = elementMatchers[
j]); j++ ) { | |
5329 if ( matcher( elem, context, xml
) ) { | |
5330 results.push( elem ); | |
5331 break; | |
5332 } | |
5333 } | |
5334 if ( outermost ) { | |
5335 dirruns = dirrunsUnique; | |
5336 cachedruns = ++matcherCachedRuns
; | |
5337 } | |
5338 } | |
5339 | |
5340 // Track unmatched elements for set filters | |
5341 if ( bySet ) { | |
5342 // They will have gone through all possi
ble matchers | |
5343 if ( (elem = !matcher && elem) ) { | |
5344 matchedCount--; | |
5345 } | |
5346 | |
5347 // Lengthen the array for every element,
matched or not | |
5348 if ( seed ) { | |
5349 unmatched.push( elem ); | |
5350 } | |
5351 } | |
5352 } | |
5353 | |
5354 // Apply set filters to unmatched elements | |
5355 // `i` starts as a string, so matchedCount would equal "
00" if there are no elements | |
5356 matchedCount += i; | |
5357 if ( bySet && i !== matchedCount ) { | |
5358 for ( j = 0; (matcher = setMatchers[j]); j++ ) { | |
5359 matcher( unmatched, setMatched, context,
xml ); | |
5360 } | |
5361 | |
5362 if ( seed ) { | |
5363 // Reintegrate element matches to elimin
ate the need for sorting | |
5364 if ( matchedCount > 0 ) { | |
5365 while ( i-- ) { | |
5366 if ( !(unmatched[i] || s
etMatched[i]) ) { | |
5367 setMatched[i] =
pop.call( results ); | |
5368 } | |
5369 } | |
5370 } | |
5371 | |
5372 // Discard index placeholder values to g
et only actual matches | |
5373 setMatched = condense( setMatched ); | |
5374 } | |
5375 | |
5376 // Add matches to results | |
5377 push.apply( results, setMatched ); | |
5378 | |
5379 // Seedless set matches succeeding multiple succ
essful matchers stipulate sorting | |
5380 if ( outermost && !seed && setMatched.length > 0
&& | |
5381 ( matchedCount + setMatchers.length ) >
1 ) { | |
5382 | |
5383 Sizzle.uniqueSort( results ); | |
5384 } | |
5385 } | |
5386 | |
5387 // Override manipulation of globals by nested matchers | |
5388 if ( outermost ) { | |
5389 dirruns = dirrunsUnique; | |
5390 outermostContext = contextBackup; | |
5391 } | |
5392 | |
5393 return unmatched; | |
5394 }; | |
5395 | |
5396 return bySet ? | |
5397 markFunction( superMatcher ) : | |
5398 superMatcher; | |
5399 } | |
5400 | |
5401 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { | |
5402 var i, | |
5403 setMatchers = [], | |
5404 elementMatchers = [], | |
5405 cached = compilerCache[ selector + " " ]; | |
5406 | |
5407 if ( !cached ) { | |
5408 // Generate a function of recursive functions that can be used t
o check each element | |
5409 if ( !group ) { | |
5410 group = tokenize( selector ); | |
5411 } | |
5412 i = group.length; | |
5413 while ( i-- ) { | |
5414 cached = matcherFromTokens( group[i] ); | |
5415 if ( cached[ expando ] ) { | |
5416 setMatchers.push( cached ); | |
5417 } else { | |
5418 elementMatchers.push( cached ); | |
5419 } | |
5420 } | |
5421 | |
5422 // Cache the compiled function | |
5423 cached = compilerCache( selector, matcherFromGroupMatchers( elem
entMatchers, setMatchers ) ); | |
5424 } | |
5425 return cached; | |
5426 }; | |
5427 | |
5428 function multipleContexts( selector, contexts, results ) { | |
5429 var i = 0, | |
5430 len = contexts.length; | |
5431 for ( ; i < len; i++ ) { | |
5432 Sizzle( selector, contexts[i], results ); | |
5433 } | |
5434 return results; | |
5435 } | |
5436 | |
5437 function select( selector, context, results, seed ) { | |
5438 var i, tokens, token, type, find, | |
5439 match = tokenize( selector ); | |
5440 | |
5441 if ( !seed ) { | |
5442 // Try to minimize operations if there is only one group | |
5443 if ( match.length === 1 ) { | |
5444 | |
5445 // Take a shortcut and set the context if the root selec
tor is an ID | |
5446 tokens = match[0] = match[0].slice( 0 ); | |
5447 if ( tokens.length > 2 && (token = tokens[0]).type === "
ID" && | |
5448 context.nodeType === 9 && !documentIsXML
&& | |
5449 Expr.relative[ tokens[1].type ] ) { | |
5450 | |
5451 context = Expr.find["ID"]( token.matches[0].repl
ace( runescape, funescape ), context )[0]; | |
5452 if ( !context ) { | |
5453 return results; | |
5454 } | |
5455 | |
5456 selector = selector.slice( tokens.shift().value.
length ); | |
5457 } | |
5458 | |
5459 // Fetch a seed set for right-to-left matching | |
5460 for ( i = matchExpr["needsContext"].test( selector ) ? -
1 : tokens.length - 1; i >= 0; i-- ) { | |
5461 token = tokens[i]; | |
5462 | |
5463 // Abort if we hit a combinator | |
5464 if ( Expr.relative[ (type = token.type) ] ) { | |
5465 break; | |
5466 } | |
5467 if ( (find = Expr.find[ type ]) ) { | |
5468 // Search, expanding context for leading
sibling combinators | |
5469 if ( (seed = find( | |
5470 token.matches[0].replace( runesc
ape, funescape ), | |
5471 rsibling.test( tokens[0].type )
&& context.parentNode || context | |
5472 )) ) { | |
5473 | |
5474 // If seed is empty or no tokens
remain, we can return early | |
5475 tokens.splice( i, 1 ); | |
5476 selector = seed.length && toSele
ctor( tokens ); | |
5477 if ( !selector ) { | |
5478 push.apply( results, sli
ce.call( seed, 0 ) ); | |
5479 return results; | |
5480 } | |
5481 | |
5482 break; | |
5483 } | |
5484 } | |
5485 } | |
5486 } | |
5487 } | |
5488 | |
5489 // Compile and execute a filtering function | |
5490 // Provide `match` to avoid retokenization if we modified the selector a
bove | |
5491 compile( selector, match )( | |
5492 seed, | |
5493 context, | |
5494 documentIsXML, | |
5495 results, | |
5496 rsibling.test( selector ) | |
5497 ); | |
5498 return results; | |
5499 } | |
5500 | |
5501 // Deprecated | |
5502 Expr.pseudos["nth"] = Expr.pseudos["eq"]; | |
5503 | |
5504 // Easy API for creating new setFilters | |
5505 function setFilters() {} | |
5506 Expr.filters = setFilters.prototype = Expr.pseudos; | |
5507 Expr.setFilters = new setFilters(); | |
5508 | |
5509 // Initialize with the default document | |
5510 setDocument(); | |
5511 | |
5512 // Override sizzle attribute retrieval | |
5513 Sizzle.attr = jQuery.attr; | |
5514 jQuery.find = Sizzle; | |
5515 jQuery.expr = Sizzle.selectors; | |
5516 jQuery.expr[":"] = jQuery.expr.pseudos; | |
5517 jQuery.unique = Sizzle.uniqueSort; | |
5518 jQuery.text = Sizzle.getText; | |
5519 jQuery.isXMLDoc = Sizzle.isXML; | |
5520 jQuery.contains = Sizzle.contains; | |
5521 | |
5522 | |
5523 })( window ); | |
5524 var runtil = /Until$/, | |
5525 rparentsprev = /^(?:parents|prev(?:Until|All))/, | |
5526 isSimple = /^.[^:#\[\.,]*$/, | |
5527 rneedsContext = jQuery.expr.match.needsContext, | |
5528 // methods guaranteed to produce a unique set when starting from a uniqu
e set | |
5529 guaranteedUnique = { | |
5530 children: true, | |
5531 contents: true, | |
5532 next: true, | |
5533 prev: true | |
5534 }; | |
5535 | |
5536 jQuery.fn.extend({ | |
5537 find: function( selector ) { | |
5538 var i, ret, self; | |
5539 | |
5540 if ( typeof selector !== "string" ) { | |
5541 self = this; | |
5542 return this.pushStack( jQuery( selector ).filter(functio
n() { | |
5543 for ( i = 0; i < self.length; i++ ) { | |
5544 if ( jQuery.contains( self[ i ], this )
) { | |
5545 return true; | |
5546 } | |
5547 } | |
5548 }) ); | |
5549 } | |
5550 | |
5551 ret = []; | |
5552 for ( i = 0; i < this.length; i++ ) { | |
5553 jQuery.find( selector, this[ i ], ret ); | |
5554 } | |
5555 | |
5556 // Needed because $( selector, context ) becomes $( context ).fi
nd( selector ) | |
5557 ret = this.pushStack( jQuery.unique( ret ) ); | |
5558 ret.selector = ( this.selector ? this.selector + " " : "" ) + se
lector; | |
5559 return ret; | |
5560 }, | |
5561 | |
5562 has: function( target ) { | |
5563 var i, | |
5564 targets = jQuery( target, this ), | |
5565 len = targets.length; | |
5566 | |
5567 return this.filter(function() { | |
5568 for ( i = 0; i < len; i++ ) { | |
5569 if ( jQuery.contains( this, targets[i] ) ) { | |
5570 return true; | |
5571 } | |
5572 } | |
5573 }); | |
5574 }, | |
5575 | |
5576 not: function( selector ) { | |
5577 return this.pushStack( winnow(this, selector, false) ); | |
5578 }, | |
5579 | |
5580 filter: function( selector ) { | |
5581 return this.pushStack( winnow(this, selector, true) ); | |
5582 }, | |
5583 | |
5584 is: function( selector ) { | |
5585 return !!selector && ( | |
5586 typeof selector === "string" ? | |
5587 // If this is a positional/relative selector, ch
eck membership in the returned set | |
5588 // so $("p:first").is("p:last") won't return tru
e for a doc with two "p". | |
5589 rneedsContext.test( selector ) ? | |
5590 jQuery( selector, this.context ).index(
this[0] ) >= 0 : | |
5591 jQuery.filter( selector, this ).length >
0 : | |
5592 this.filter( selector ).length > 0 ); | |
5593 }, | |
5594 | |
5595 closest: function( selectors, context ) { | |
5596 var cur, | |
5597 i = 0, | |
5598 l = this.length, | |
5599 ret = [], | |
5600 pos = rneedsContext.test( selectors ) || typeof selector
s !== "string" ? | |
5601 jQuery( selectors, context || this.context ) : | |
5602 0; | |
5603 | |
5604 for ( ; i < l; i++ ) { | |
5605 cur = this[i]; | |
5606 | |
5607 while ( cur && cur.ownerDocument && cur !== context && c
ur.nodeType !== 11 ) { | |
5608 if ( pos ? pos.index(cur) > -1 : jQuery.find.mat
chesSelector(cur, selectors) ) { | |
5609 ret.push( cur ); | |
5610 break; | |
5611 } | |
5612 cur = cur.parentNode; | |
5613 } | |
5614 } | |
5615 | |
5616 return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : r
et ); | |
5617 }, | |
5618 | |
5619 // Determine the position of an element within | |
5620 // the matched set of elements | |
5621 index: function( elem ) { | |
5622 | |
5623 // No argument, return index in parent | |
5624 if ( !elem ) { | |
5625 return ( this[0] && this[0].parentNode ) ? this.first().
prevAll().length : -1; | |
5626 } | |
5627 | |
5628 // index in selector | |
5629 if ( typeof elem === "string" ) { | |
5630 return jQuery.inArray( this[0], jQuery( elem ) ); | |
5631 } | |
5632 | |
5633 // Locate the position of the desired element | |
5634 return jQuery.inArray( | |
5635 // If it receives a jQuery object, the first element is
used | |
5636 elem.jquery ? elem[0] : elem, this ); | |
5637 }, | |
5638 | |
5639 add: function( selector, context ) { | |
5640 var set = typeof selector === "string" ? | |
5641 jQuery( selector, context ) : | |
5642 jQuery.makeArray( selector && selector.nodeType
? [ selector ] : selector ), | |
5643 all = jQuery.merge( this.get(), set ); | |
5644 | |
5645 return this.pushStack( jQuery.unique(all) ); | |
5646 }, | |
5647 | |
5648 addBack: function( selector ) { | |
5649 return this.add( selector == null ? | |
5650 this.prevObject : this.prevObject.filter(selector) | |
5651 ); | |
5652 } | |
5653 }); | |
5654 | |
5655 jQuery.fn.andSelf = jQuery.fn.addBack; | |
5656 | |
5657 function sibling( cur, dir ) { | |
5658 do { | |
5659 cur = cur[ dir ]; | |
5660 } while ( cur && cur.nodeType !== 1 ); | |
5661 | |
5662 return cur; | |
5663 } | |
5664 | |
5665 jQuery.each({ | |
5666 parent: function( elem ) { | |
5667 var parent = elem.parentNode; | |
5668 return parent && parent.nodeType !== 11 ? parent : null; | |
5669 }, | |
5670 parents: function( elem ) { | |
5671 return jQuery.dir( elem, "parentNode" ); | |
5672 }, | |
5673 parentsUntil: function( elem, i, until ) { | |
5674 return jQuery.dir( elem, "parentNode", until ); | |
5675 }, | |
5676 next: function( elem ) { | |
5677 return sibling( elem, "nextSibling" ); | |
5678 }, | |
5679 prev: function( elem ) { | |
5680 return sibling( elem, "previousSibling" ); | |
5681 }, | |
5682 nextAll: function( elem ) { | |
5683 return jQuery.dir( elem, "nextSibling" ); | |
5684 }, | |
5685 prevAll: function( elem ) { | |
5686 return jQuery.dir( elem, "previousSibling" ); | |
5687 }, | |
5688 nextUntil: function( elem, i, until ) { | |
5689 return jQuery.dir( elem, "nextSibling", until ); | |
5690 }, | |
5691 prevUntil: function( elem, i, until ) { | |
5692 return jQuery.dir( elem, "previousSibling", until ); | |
5693 }, | |
5694 siblings: function( elem ) { | |
5695 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, ele
m ); | |
5696 }, | |
5697 children: function( elem ) { | |
5698 return jQuery.sibling( elem.firstChild ); | |
5699 }, | |
5700 contents: function( elem ) { | |
5701 return jQuery.nodeName( elem, "iframe" ) ? | |
5702 elem.contentDocument || elem.contentWindow.document : | |
5703 jQuery.merge( [], elem.childNodes ); | |
5704 } | |
5705 }, function( name, fn ) { | |
5706 jQuery.fn[ name ] = function( until, selector ) { | |
5707 var ret = jQuery.map( this, fn, until ); | |
5708 | |
5709 if ( !runtil.test( name ) ) { | |
5710 selector = until; | |
5711 } | |
5712 | |
5713 if ( selector && typeof selector === "string" ) { | |
5714 ret = jQuery.filter( selector, ret ); | |
5715 } | |
5716 | |
5717 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.uniq
ue( ret ) : ret; | |
5718 | |
5719 if ( this.length > 1 && rparentsprev.test( name ) ) { | |
5720 ret = ret.reverse(); | |
5721 } | |
5722 | |
5723 return this.pushStack( ret ); | |
5724 }; | |
5725 }); | |
5726 | |
5727 jQuery.extend({ | |
5728 filter: function( expr, elems, not ) { | |
5729 if ( not ) { | |
5730 expr = ":not(" + expr + ")"; | |
5731 } | |
5732 | |
5733 return elems.length === 1 ? | |
5734 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0]
] : [] : | |
5735 jQuery.find.matches(expr, elems); | |
5736 }, | |
5737 | |
5738 dir: function( elem, dir, until ) { | |
5739 var matched = [], | |
5740 cur = elem[ dir ]; | |
5741 | |
5742 while ( cur && cur.nodeType !== 9 && (until === undefined || cur
.nodeType !== 1 || !jQuery( cur ).is( until )) ) { | |
5743 if ( cur.nodeType === 1 ) { | |
5744 matched.push( cur ); | |
5745 } | |
5746 cur = cur[dir]; | |
5747 } | |
5748 return matched; | |
5749 }, | |
5750 | |
5751 sibling: function( n, elem ) { | |
5752 var r = []; | |
5753 | |
5754 for ( ; n; n = n.nextSibling ) { | |
5755 if ( n.nodeType === 1 && n !== elem ) { | |
5756 r.push( n ); | |
5757 } | |
5758 } | |
5759 | |
5760 return r; | |
5761 } | |
5762 }); | |
5763 | |
5764 // Implement the identical functionality for filter and not | |
5765 function winnow( elements, qualifier, keep ) { | |
5766 | |
5767 // Can't pass null or undefined to indexOf in Firefox 4 | |
5768 // Set to 0 to skip string check | |
5769 qualifier = qualifier || 0; | |
5770 | |
5771 if ( jQuery.isFunction( qualifier ) ) { | |
5772 return jQuery.grep(elements, function( elem, i ) { | |
5773 var retVal = !!qualifier.call( elem, i, elem ); | |
5774 return retVal === keep; | |
5775 }); | |
5776 | |
5777 } else if ( qualifier.nodeType ) { | |
5778 return jQuery.grep(elements, function( elem ) { | |
5779 return ( elem === qualifier ) === keep; | |
5780 }); | |
5781 | |
5782 } else if ( typeof qualifier === "string" ) { | |
5783 var filtered = jQuery.grep(elements, function( elem ) { | |
5784 return elem.nodeType === 1; | |
5785 }); | |
5786 | |
5787 if ( isSimple.test( qualifier ) ) { | |
5788 return jQuery.filter(qualifier, filtered, !keep); | |
5789 } else { | |
5790 qualifier = jQuery.filter( qualifier, filtered ); | |
5791 } | |
5792 } | |
5793 | |
5794 return jQuery.grep(elements, function( elem ) { | |
5795 return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; | |
5796 }); | |
5797 } | |
5798 function createSafeFragment( document ) { | |
5799 var list = nodeNames.split( "|" ), | |
5800 safeFrag = document.createDocumentFragment(); | |
5801 | |
5802 if ( safeFrag.createElement ) { | |
5803 while ( list.length ) { | |
5804 safeFrag.createElement( | |
5805 list.pop() | |
5806 ); | |
5807 } | |
5808 } | |
5809 return safeFrag; | |
5810 } | |
5811 | |
5812 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
ption|figure|footer|" + | |
5813 "header|hgroup|mark|meter|nav|output|progress|section|summary|ti
me|video", | |
5814 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, | |
5815 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), | |
5816 rleadingWhitespace = /^\s+/, | |
5817 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+
)[^>]*)\/>/gi, | |
5818 rtagName = /<([\w:]+)/, | |
5819 rtbody = /<tbody/i, | |
5820 rhtml = /<|&#?\w+;/, | |
5821 rnoInnerhtml = /<(?:script|style|link)/i, | |
5822 manipulation_rcheckableType = /^(?:checkbox|radio)$/i, | |
5823 // checked="checked" or checked | |
5824 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, | |
5825 rscriptType = /^$|\/(?:java|ecma)script/i, | |
5826 rscriptTypeMasked = /^true\/(.*)/, | |
5827 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, | |
5828 | |
5829 // We have to close these tags to support XHTML (#13200) | |
5830 wrapMap = { | |
5831 option: [ 1, "<select multiple='multiple'>", "</select>" ], | |
5832 legend: [ 1, "<fieldset>", "</fieldset>" ], | |
5833 area: [ 1, "<map>", "</map>" ], | |
5834 param: [ 1, "<object>", "</object>" ], | |
5835 thead: [ 1, "<table>", "</table>" ], | |
5836 tr: [ 2, "<table><tbody>", "</tbody></table>" ], | |
5837 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></tabl
e>" ], | |
5838 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], | |
5839 | |
5840 // IE6-8 can't serialize link, script, style, or any html5 (NoSc
ope) tags, | |
5841 // unless wrapped in a div with non-breaking characters in front
of it. | |
5842 _default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X
<div>", "</div>" ] | |
5843 }, | |
5844 safeFragment = createSafeFragment( document ), | |
5845 fragmentDiv = safeFragment.appendChild( document.createElement("div") ); | |
5846 | |
5847 wrapMap.optgroup = wrapMap.option; | |
5848 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.the
ad; | |
5849 wrapMap.th = wrapMap.td; | |
5850 | |
5851 jQuery.fn.extend({ | |
5852 text: function( value ) { | |
5853 return jQuery.access( this, function( value ) { | |
5854 return value === undefined ? | |
5855 jQuery.text( this ) : | |
5856 this.empty().append( ( this[0] && this[0].ownerD
ocument || document ).createTextNode( value ) ); | |
5857 }, null, value, arguments.length ); | |
5858 }, | |
5859 | |
5860 wrapAll: function( html ) { | |
5861 if ( jQuery.isFunction( html ) ) { | |
5862 return this.each(function(i) { | |
5863 jQuery(this).wrapAll( html.call(this, i) ); | |
5864 }); | |
5865 } | |
5866 | |
5867 if ( this[0] ) { | |
5868 // The elements to wrap the target around | |
5869 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).c
lone(true); | |
5870 | |
5871 if ( this[0].parentNode ) { | |
5872 wrap.insertBefore( this[0] ); | |
5873 } | |
5874 | |
5875 wrap.map(function() { | |
5876 var elem = this; | |
5877 | |
5878 while ( elem.firstChild && elem.firstChild.nodeT
ype === 1 ) { | |
5879 elem = elem.firstChild; | |
5880 } | |
5881 | |
5882 return elem; | |
5883 }).append( this ); | |
5884 } | |
5885 | |
5886 return this; | |
5887 }, | |
5888 | |
5889 wrapInner: function( html ) { | |
5890 if ( jQuery.isFunction( html ) ) { | |
5891 return this.each(function(i) { | |
5892 jQuery(this).wrapInner( html.call(this, i) ); | |
5893 }); | |
5894 } | |
5895 | |
5896 return this.each(function() { | |
5897 var self = jQuery( this ), | |
5898 contents = self.contents(); | |
5899 | |
5900 if ( contents.length ) { | |
5901 contents.wrapAll( html ); | |
5902 | |
5903 } else { | |
5904 self.append( html ); | |
5905 } | |
5906 }); | |
5907 }, | |
5908 | |
5909 wrap: function( html ) { | |
5910 var isFunction = jQuery.isFunction( html ); | |
5911 | |
5912 return this.each(function(i) { | |
5913 jQuery( this ).wrapAll( isFunction ? html.call(this, i)
: html ); | |
5914 }); | |
5915 }, | |
5916 | |
5917 unwrap: function() { | |
5918 return this.parent().each(function() { | |
5919 if ( !jQuery.nodeName( this, "body" ) ) { | |
5920 jQuery( this ).replaceWith( this.childNodes ); | |
5921 } | |
5922 }).end(); | |
5923 }, | |
5924 | |
5925 append: function() { | |
5926 return this.domManip(arguments, true, function( elem ) { | |
5927 if ( this.nodeType === 1 || this.nodeType === 11 || this
.nodeType === 9 ) { | |
5928 this.appendChild( elem ); | |
5929 } | |
5930 }); | |
5931 }, | |
5932 | |
5933 prepend: function() { | |
5934 return this.domManip(arguments, true, function( elem ) { | |
5935 if ( this.nodeType === 1 || this.nodeType === 11 || this
.nodeType === 9 ) { | |
5936 this.insertBefore( elem, this.firstChild ); | |
5937 } | |
5938 }); | |
5939 }, | |
5940 | |
5941 before: function() { | |
5942 return this.domManip( arguments, false, function( elem ) { | |
5943 if ( this.parentNode ) { | |
5944 this.parentNode.insertBefore( elem, this ); | |
5945 } | |
5946 }); | |
5947 }, | |
5948 | |
5949 after: function() { | |
5950 return this.domManip( arguments, false, function( elem ) { | |
5951 if ( this.parentNode ) { | |
5952 this.parentNode.insertBefore( elem, this.nextSib
ling ); | |
5953 } | |
5954 }); | |
5955 }, | |
5956 | |
5957 // keepData is for internal use only--do not document | |
5958 remove: function( selector, keepData ) { | |
5959 var elem, | |
5960 i = 0; | |
5961 | |
5962 for ( ; (elem = this[i]) != null; i++ ) { | |
5963 if ( !selector || jQuery.filter( selector, [ elem ] ).le
ngth > 0 ) { | |
5964 if ( !keepData && elem.nodeType === 1 ) { | |
5965 jQuery.cleanData( getAll( elem ) ); | |
5966 } | |
5967 | |
5968 if ( elem.parentNode ) { | |
5969 if ( keepData && jQuery.contains( elem.o
wnerDocument, elem ) ) { | |
5970 setGlobalEval( getAll( elem, "sc
ript" ) ); | |
5971 } | |
5972 elem.parentNode.removeChild( elem ); | |
5973 } | |
5974 } | |
5975 } | |
5976 | |
5977 return this; | |
5978 }, | |
5979 | |
5980 empty: function() { | |
5981 var elem, | |
5982 i = 0; | |
5983 | |
5984 for ( ; (elem = this[i]) != null; i++ ) { | |
5985 // Remove element nodes and prevent memory leaks | |
5986 if ( elem.nodeType === 1 ) { | |
5987 jQuery.cleanData( getAll( elem, false ) ); | |
5988 } | |
5989 | |
5990 // Remove any remaining nodes | |
5991 while ( elem.firstChild ) { | |
5992 elem.removeChild( elem.firstChild ); | |
5993 } | |
5994 | |
5995 // If this is a select, ensure that it displays empty (#
12336) | |
5996 // Support: IE<9 | |
5997 if ( elem.options && jQuery.nodeName( elem, "select" ) )
{ | |
5998 elem.options.length = 0; | |
5999 } | |
6000 } | |
6001 | |
6002 return this; | |
6003 }, | |
6004 | |
6005 clone: function( dataAndEvents, deepDataAndEvents ) { | |
6006 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; | |
6007 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents :
deepDataAndEvents; | |
6008 | |
6009 return this.map( function () { | |
6010 return jQuery.clone( this, dataAndEvents, deepDataAndEve
nts ); | |
6011 }); | |
6012 }, | |
6013 | |
6014 html: function( value ) { | |
6015 return jQuery.access( this, function( value ) { | |
6016 var elem = this[0] || {}, | |
6017 i = 0, | |
6018 l = this.length; | |
6019 | |
6020 if ( value === undefined ) { | |
6021 return elem.nodeType === 1 ? | |
6022 elem.innerHTML.replace( rinlinejQuery, "
" ) : | |
6023 undefined; | |
6024 } | |
6025 | |
6026 // See if we can take a shortcut and just use innerHTML | |
6027 if ( typeof value === "string" && !rnoInnerhtml.test( va
lue ) && | |
6028 ( jQuery.support.htmlSerialize || !rnoshimcache.
test( value ) ) && | |
6029 ( jQuery.support.leadingWhitespace || !rleadingW
hitespace.test( value ) ) && | |
6030 !wrapMap[ ( rtagName.exec( value ) || ["", ""] )
[1].toLowerCase() ] ) { | |
6031 | |
6032 value = value.replace( rxhtmlTag, "<$1></$2>" ); | |
6033 | |
6034 try { | |
6035 for (; i < l; i++ ) { | |
6036 // Remove element nodes and prev
ent memory leaks | |
6037 elem = this[i] || {}; | |
6038 if ( elem.nodeType === 1 ) { | |
6039 jQuery.cleanData( getAll
( elem, false ) ); | |
6040 elem.innerHTML = value; | |
6041 } | |
6042 } | |
6043 | |
6044 elem = 0; | |
6045 | |
6046 // If using innerHTML throws an exception, use t
he fallback method | |
6047 } catch(e) {} | |
6048 } | |
6049 | |
6050 if ( elem ) { | |
6051 this.empty().append( value ); | |
6052 } | |
6053 }, null, value, arguments.length ); | |
6054 }, | |
6055 | |
6056 replaceWith: function( value ) { | |
6057 var isFunc = jQuery.isFunction( value ); | |
6058 | |
6059 // Make sure that the elements are removed from the DOM before t
hey are inserted | |
6060 // this can help fix replacing a parent with child elements | |
6061 if ( !isFunc && typeof value !== "string" ) { | |
6062 value = jQuery( value ).not( this ).detach(); | |
6063 } | |
6064 | |
6065 return this.domManip( [ value ], true, function( elem ) { | |
6066 var next = this.nextSibling, | |
6067 parent = this.parentNode; | |
6068 | |
6069 if ( parent && this.nodeType === 1 || this.nodeType ===
11 ) { | |
6070 | |
6071 jQuery( this ).remove(); | |
6072 | |
6073 if ( next ) { | |
6074 next.parentNode.insertBefore( elem, next
); | |
6075 } else { | |
6076 parent.appendChild( elem ); | |
6077 } | |
6078 } | |
6079 }); | |
6080 }, | |
6081 | |
6082 detach: function( selector ) { | |
6083 return this.remove( selector, true ); | |
6084 }, | |
6085 | |
6086 domManip: function( args, table, callback ) { | |
6087 | |
6088 // Flatten any nested arrays | |
6089 args = core_concat.apply( [], args ); | |
6090 | |
6091 var fragment, first, scripts, hasScripts, node, doc, | |
6092 i = 0, | |
6093 l = this.length, | |
6094 set = this, | |
6095 iNoClone = l - 1, | |
6096 value = args[0], | |
6097 isFunction = jQuery.isFunction( value ); | |
6098 | |
6099 // We can't cloneNode fragments that contain checked, in WebKit | |
6100 if ( isFunction || !( l <= 1 || typeof value !== "string" || jQu
ery.support.checkClone || !rchecked.test( value ) ) ) { | |
6101 return this.each(function( index ) { | |
6102 var self = set.eq( index ); | |
6103 if ( isFunction ) { | |
6104 args[0] = value.call( this, index, table
? self.html() : undefined ); | |
6105 } | |
6106 self.domManip( args, table, callback ); | |
6107 }); | |
6108 } | |
6109 | |
6110 if ( l ) { | |
6111 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDo
cument, false, this ); | |
6112 first = fragment.firstChild; | |
6113 | |
6114 if ( fragment.childNodes.length === 1 ) { | |
6115 fragment = first; | |
6116 } | |
6117 | |
6118 if ( first ) { | |
6119 table = table && jQuery.nodeName( first, "tr" ); | |
6120 scripts = jQuery.map( getAll( fragment, "script"
), disableScript ); | |
6121 hasScripts = scripts.length; | |
6122 | |
6123 // Use the original fragment for the last item i
nstead of the first because it can end up | |
6124 // being emptied incorrectly in certain situatio
ns (#8070). | |
6125 for ( ; i < l; i++ ) { | |
6126 node = fragment; | |
6127 | |
6128 if ( i !== iNoClone ) { | |
6129 node = jQuery.clone( node, true,
true ); | |
6130 | |
6131 // Keep references to cloned scr
ipts for later restoration | |
6132 if ( hasScripts ) { | |
6133 jQuery.merge( scripts, g
etAll( node, "script" ) ); | |
6134 } | |
6135 } | |
6136 | |
6137 callback.call( | |
6138 table && jQuery.nodeName( this[i
], "table" ) ? | |
6139 findOrAppend( this[i], "
tbody" ) : | |
6140 this[i], | |
6141 node, | |
6142 i | |
6143 ); | |
6144 } | |
6145 | |
6146 if ( hasScripts ) { | |
6147 doc = scripts[ scripts.length - 1 ].owne
rDocument; | |
6148 | |
6149 // Reenable scripts | |
6150 jQuery.map( scripts, restoreScript ); | |
6151 | |
6152 // Evaluate executable scripts on first
document insertion | |
6153 for ( i = 0; i < hasScripts; i++ ) { | |
6154 node = scripts[ i ]; | |
6155 if ( rscriptType.test( node.type
|| "" ) && | |
6156 !jQuery._data( node, "gl
obalEval" ) && jQuery.contains( doc, node ) ) { | |
6157 | |
6158 if ( node.src ) { | |
6159 // Hope ajax is
available... | |
6160 jQuery.ajax({ | |
6161 url: nod
e.src, | |
6162 type: "G
ET", | |
6163 dataType
: "script", | |
6164 async: f
alse, | |
6165 global:
false, | |
6166 "throws"
: true | |
6167 }); | |
6168 } else { | |
6169 jQuery.globalEva
l( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScri
pt, "" ) ); | |
6170 } | |
6171 } | |
6172 } | |
6173 } | |
6174 | |
6175 // Fix #11809: Avoid leaking memory | |
6176 fragment = first = null; | |
6177 } | |
6178 } | |
6179 | |
6180 return this; | |
6181 } | |
6182 }); | |
6183 | |
6184 function findOrAppend( elem, tag ) { | |
6185 return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.own
erDocument.createElement( tag ) ); | |
6186 } | |
6187 | |
6188 // Replace/restore the type attribute of script elements for safe DOM manipulati
on | |
6189 function disableScript( elem ) { | |
6190 var attr = elem.getAttributeNode("type"); | |
6191 elem.type = ( attr && attr.specified ) + "/" + elem.type; | |
6192 return elem; | |
6193 } | |
6194 function restoreScript( elem ) { | |
6195 var match = rscriptTypeMasked.exec( elem.type ); | |
6196 if ( match ) { | |
6197 elem.type = match[1]; | |
6198 } else { | |
6199 elem.removeAttribute("type"); | |
6200 } | |
6201 return elem; | |
6202 } | |
6203 | |
6204 // Mark scripts as having already been evaluated | |
6205 function setGlobalEval( elems, refElements ) { | |
6206 var elem, | |
6207 i = 0; | |
6208 for ( ; (elem = elems[i]) != null; i++ ) { | |
6209 jQuery._data( elem, "globalEval", !refElements || jQuery._data(
refElements[i], "globalEval" ) ); | |
6210 } | |
6211 } | |
6212 | |
6213 function cloneCopyEvent( src, dest ) { | |
6214 | |
6215 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { | |
6216 return; | |
6217 } | |
6218 | |
6219 var type, i, l, | |
6220 oldData = jQuery._data( src ), | |
6221 curData = jQuery._data( dest, oldData ), | |
6222 events = oldData.events; | |
6223 | |
6224 if ( events ) { | |
6225 delete curData.handle; | |
6226 curData.events = {}; | |
6227 | |
6228 for ( type in events ) { | |
6229 for ( i = 0, l = events[ type ].length; i < l; i++ ) { | |
6230 jQuery.event.add( dest, type, events[ type ][ i
] ); | |
6231 } | |
6232 } | |
6233 } | |
6234 | |
6235 // make the cloned public data object a copy from the original | |
6236 if ( curData.data ) { | |
6237 curData.data = jQuery.extend( {}, curData.data ); | |
6238 } | |
6239 } | |
6240 | |
6241 function fixCloneNodeIssues( src, dest ) { | |
6242 var nodeName, data, e; | |
6243 | |
6244 // We do not need to do anything for non-Elements | |
6245 if ( dest.nodeType !== 1 ) { | |
6246 return; | |
6247 } | |
6248 | |
6249 nodeName = dest.nodeName.toLowerCase(); | |
6250 | |
6251 // IE6-8 copies events bound via attachEvent when using cloneNode. | |
6252 if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) { | |
6253 data = jQuery._data( dest ); | |
6254 | |
6255 for ( e in data.events ) { | |
6256 jQuery.removeEvent( dest, e, data.handle ); | |
6257 } | |
6258 | |
6259 // Event data gets referenced instead of copied if the expando g
ets copied too | |
6260 dest.removeAttribute( jQuery.expando ); | |
6261 } | |
6262 | |
6263 // IE blanks contents when cloning scripts, and tries to evaluate newly-
set text | |
6264 if ( nodeName === "script" && dest.text !== src.text ) { | |
6265 disableScript( dest ).text = src.text; | |
6266 restoreScript( dest ); | |
6267 | |
6268 // IE6-10 improperly clones children of object elements using classid. | |
6269 // IE10 throws NoModificationAllowedError if parent is null, #12132. | |
6270 } else if ( nodeName === "object" ) { | |
6271 if ( dest.parentNode ) { | |
6272 dest.outerHTML = src.outerHTML; | |
6273 } | |
6274 | |
6275 // This path appears unavoidable for IE9. When cloning an object | |
6276 // element in IE9, the outerHTML strategy above is not sufficien
t. | |
6277 // If the src has innerHTML and the destination does not, | |
6278 // copy the src.innerHTML into the dest.innerHTML. #10324 | |
6279 if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.tri
m(dest.innerHTML) ) ) { | |
6280 dest.innerHTML = src.innerHTML; | |
6281 } | |
6282 | |
6283 } else if ( nodeName === "input" && manipulation_rcheckableType.test( sr
c.type ) ) { | |
6284 // IE6-8 fails to persist the checked state of a cloned checkbox | |
6285 // or radio button. Worse, IE6-7 fail to give the cloned element | |
6286 // a checked appearance if the defaultChecked value isn't also s
et | |
6287 | |
6288 dest.defaultChecked = dest.checked = src.checked; | |
6289 | |
6290 // IE6-7 get confused and end up setting the value of a cloned | |
6291 // checkbox/radio button to an empty string instead of "on" | |
6292 if ( dest.value !== src.value ) { | |
6293 dest.value = src.value; | |
6294 } | |
6295 | |
6296 // IE6-8 fails to return the selected option to the default selected | |
6297 // state when cloning options | |
6298 } else if ( nodeName === "option" ) { | |
6299 dest.defaultSelected = dest.selected = src.defaultSelected; | |
6300 | |
6301 // IE6-8 fails to set the defaultValue to the correct value when | |
6302 // cloning other types of input fields | |
6303 } else if ( nodeName === "input" || nodeName === "textarea" ) { | |
6304 dest.defaultValue = src.defaultValue; | |
6305 } | |
6306 } | |
6307 | |
6308 jQuery.each({ | |
6309 appendTo: "append", | |
6310 prependTo: "prepend", | |
6311 insertBefore: "before", | |
6312 insertAfter: "after", | |
6313 replaceAll: "replaceWith" | |
6314 }, function( name, original ) { | |
6315 jQuery.fn[ name ] = function( selector ) { | |
6316 var elems, | |
6317 i = 0, | |
6318 ret = [], | |
6319 insert = jQuery( selector ), | |
6320 last = insert.length - 1; | |
6321 | |
6322 for ( ; i <= last; i++ ) { | |
6323 elems = i === last ? this : this.clone(true); | |
6324 jQuery( insert[i] )[ original ]( elems ); | |
6325 | |
6326 // Modern browsers can apply jQuery collections as array
s, but oldIE needs a .get() | |
6327 core_push.apply( ret, elems.get() ); | |
6328 } | |
6329 | |
6330 return this.pushStack( ret ); | |
6331 }; | |
6332 }); | |
6333 | |
6334 function getAll( context, tag ) { | |
6335 var elems, elem, | |
6336 i = 0, | |
6337 found = typeof context.getElementsByTagName !== "undefined" ? co
ntext.getElementsByTagName( tag || "*" ) : | |
6338 typeof context.querySelectorAll !== "undefined" ? contex
t.querySelectorAll( tag || "*" ) : | |
6339 undefined; | |
6340 | |
6341 if ( !found ) { | |
6342 for ( found = [], elems = context.childNodes || context; (elem =
elems[i]) != null; i++ ) { | |
6343 if ( !tag || jQuery.nodeName( elem, tag ) ) { | |
6344 found.push( elem ); | |
6345 } else { | |
6346 jQuery.merge( found, getAll( elem, tag ) ); | |
6347 } | |
6348 } | |
6349 } | |
6350 | |
6351 return tag === undefined || tag && jQuery.nodeName( context, tag ) ? | |
6352 jQuery.merge( [ context ], found ) : | |
6353 found; | |
6354 } | |
6355 | |
6356 // Used in buildFragment, fixes the defaultChecked property | |
6357 function fixDefaultChecked( elem ) { | |
6358 if ( manipulation_rcheckableType.test( elem.type ) ) { | |
6359 elem.defaultChecked = elem.checked; | |
6360 } | |
6361 } | |
6362 | |
6363 jQuery.extend({ | |
6364 clone: function( elem, dataAndEvents, deepDataAndEvents ) { | |
6365 var destElements, srcElements, node, i, clone, | |
6366 inPage = jQuery.contains( elem.ownerDocument, elem ); | |
6367 | |
6368 if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnos
himcache.test( "<" + elem.nodeName + ">" ) ) { | |
6369 clone = elem.cloneNode( true ); | |
6370 | |
6371 // IE<=8 does not properly clone detached, unknown element nodes | |
6372 } else { | |
6373 fragmentDiv.innerHTML = elem.outerHTML; | |
6374 fragmentDiv.removeChild( clone = fragmentDiv.firstChild
); | |
6375 } | |
6376 | |
6377 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChe
cked) && | |
6378 (elem.nodeType === 1 || elem.nodeType === 11) &&
!jQuery.isXMLDoc(elem) ) { | |
6379 | |
6380 // We eschew Sizzle here for performance reasons: http:/
/jsperf.com/getall-vs-sizzle/2 | |
6381 destElements = getAll( clone ); | |
6382 srcElements = getAll( elem ); | |
6383 | |
6384 // Fix all IE cloning issues | |
6385 for ( i = 0; (node = srcElements[i]) != null; ++i ) { | |
6386 // Ensure that the destination node is not null;
Fixes #9587 | |
6387 if ( destElements[i] ) { | |
6388 fixCloneNodeIssues( node, destElements[i
] ); | |
6389 } | |
6390 } | |
6391 } | |
6392 | |
6393 // Copy the events from the original to the clone | |
6394 if ( dataAndEvents ) { | |
6395 if ( deepDataAndEvents ) { | |
6396 srcElements = srcElements || getAll( elem ); | |
6397 destElements = destElements || getAll( clone ); | |
6398 | |
6399 for ( i = 0; (node = srcElements[i]) != null; i+
+ ) { | |
6400 cloneCopyEvent( node, destElements[i] ); | |
6401 } | |
6402 } else { | |
6403 cloneCopyEvent( elem, clone ); | |
6404 } | |
6405 } | |
6406 | |
6407 // Preserve script evaluation history | |
6408 destElements = getAll( clone, "script" ); | |
6409 if ( destElements.length > 0 ) { | |
6410 setGlobalEval( destElements, !inPage && getAll( elem, "s
cript" ) ); | |
6411 } | |
6412 | |
6413 destElements = srcElements = node = null; | |
6414 | |
6415 // Return the cloned set | |
6416 return clone; | |
6417 }, | |
6418 | |
6419 buildFragment: function( elems, context, scripts, selection ) { | |
6420 var contains, elem, tag, tmp, wrap, tbody, j, | |
6421 l = elems.length, | |
6422 | |
6423 // Ensure a safe fragment | |
6424 safe = createSafeFragment( context ), | |
6425 | |
6426 nodes = [], | |
6427 i = 0; | |
6428 | |
6429 for ( ; i < l; i++ ) { | |
6430 elem = elems[ i ]; | |
6431 | |
6432 if ( elem || elem === 0 ) { | |
6433 | |
6434 // Add nodes directly | |
6435 if ( jQuery.type( elem ) === "object" ) { | |
6436 jQuery.merge( nodes, elem.nodeType ? [ e
lem ] : elem ); | |
6437 | |
6438 // Convert non-html into a text node | |
6439 } else if ( !rhtml.test( elem ) ) { | |
6440 nodes.push( context.createTextNode( elem
) ); | |
6441 | |
6442 // Convert html into DOM nodes | |
6443 } else { | |
6444 tmp = tmp || safe.appendChild( context.c
reateElement("div") ); | |
6445 | |
6446 // Deserialize a standard representation | |
6447 tag = ( rtagName.exec( elem ) || ["", ""
] )[1].toLowerCase(); | |
6448 wrap = wrapMap[ tag ] || wrapMap._defaul
t; | |
6449 | |
6450 tmp.innerHTML = wrap[1] + elem.replace(
rxhtmlTag, "<$1></$2>" ) + wrap[2]; | |
6451 | |
6452 // Descend through wrappers to the right
content | |
6453 j = wrap[0]; | |
6454 while ( j-- ) { | |
6455 tmp = tmp.lastChild; | |
6456 } | |
6457 | |
6458 // Manually add leading whitespace remov
ed by IE | |
6459 if ( !jQuery.support.leadingWhitespace &
& rleadingWhitespace.test( elem ) ) { | |
6460 nodes.push( context.createTextNo
de( rleadingWhitespace.exec( elem )[0] ) ); | |
6461 } | |
6462 | |
6463 // Remove IE's autoinserted <tbody> from
table fragments | |
6464 if ( !jQuery.support.tbody ) { | |
6465 | |
6466 // String was a <table>, *may* h
ave spurious <tbody> | |
6467 elem = tag === "table" && !rtbod
y.test( elem ) ? | |
6468 tmp.firstChild : | |
6469 | |
6470 // String was a bare <th
ead> or <tfoot> | |
6471 wrap[1] === "<table>" &&
!rtbody.test( elem ) ? | |
6472 tmp : | |
6473 0; | |
6474 | |
6475 j = elem && elem.childNodes.leng
th; | |
6476 while ( j-- ) { | |
6477 if ( jQuery.nodeName( (t
body = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) { | |
6478 elem.removeChild
( tbody ); | |
6479 } | |
6480 } | |
6481 } | |
6482 | |
6483 jQuery.merge( nodes, tmp.childNodes ); | |
6484 | |
6485 // Fix #12392 for WebKit and IE > 9 | |
6486 tmp.textContent = ""; | |
6487 | |
6488 // Fix #12392 for oldIE | |
6489 while ( tmp.firstChild ) { | |
6490 tmp.removeChild( tmp.firstChild
); | |
6491 } | |
6492 | |
6493 // Remember the top-level container for
proper cleanup | |
6494 tmp = safe.lastChild; | |
6495 } | |
6496 } | |
6497 } | |
6498 | |
6499 // Fix #11356: Clear elements from fragment | |
6500 if ( tmp ) { | |
6501 safe.removeChild( tmp ); | |
6502 } | |
6503 | |
6504 // Reset defaultChecked for any radios and checkboxes | |
6505 // about to be appended to the DOM in IE 6/7 (#8060) | |
6506 if ( !jQuery.support.appendChecked ) { | |
6507 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked
); | |
6508 } | |
6509 | |
6510 i = 0; | |
6511 while ( (elem = nodes[ i++ ]) ) { | |
6512 | |
6513 // #4087 - If origin and destination elements are the sa
me, and this is | |
6514 // that element, do not do anything | |
6515 if ( selection && jQuery.inArray( elem, selection ) !==
-1 ) { | |
6516 continue; | |
6517 } | |
6518 | |
6519 contains = jQuery.contains( elem.ownerDocument, elem ); | |
6520 | |
6521 // Append to fragment | |
6522 tmp = getAll( safe.appendChild( elem ), "script" ); | |
6523 | |
6524 // Preserve script evaluation history | |
6525 if ( contains ) { | |
6526 setGlobalEval( tmp ); | |
6527 } | |
6528 | |
6529 // Capture executables | |
6530 if ( scripts ) { | |
6531 j = 0; | |
6532 while ( (elem = tmp[ j++ ]) ) { | |
6533 if ( rscriptType.test( elem.type || "" )
) { | |
6534 scripts.push( elem ); | |
6535 } | |
6536 } | |
6537 } | |
6538 } | |
6539 | |
6540 tmp = null; | |
6541 | |
6542 return safe; | |
6543 }, | |
6544 | |
6545 cleanData: function( elems, /* internal */ acceptData ) { | |
6546 var data, id, elem, type, | |
6547 i = 0, | |
6548 internalKey = jQuery.expando, | |
6549 cache = jQuery.cache, | |
6550 deleteExpando = jQuery.support.deleteExpando, | |
6551 special = jQuery.event.special; | |
6552 | |
6553 for ( ; (elem = elems[i]) != null; i++ ) { | |
6554 | |
6555 if ( acceptData || jQuery.acceptData( elem ) ) { | |
6556 | |
6557 id = elem[ internalKey ]; | |
6558 data = id && cache[ id ]; | |
6559 | |
6560 if ( data ) { | |
6561 if ( data.events ) { | |
6562 for ( type in data.events ) { | |
6563 if ( special[ type ] ) { | |
6564 jQuery.event.rem
ove( elem, type ); | |
6565 | |
6566 // This is a shortcut to
avoid jQuery.event.remove's overhead | |
6567 } else { | |
6568 jQuery.removeEve
nt( elem, type, data.handle ); | |
6569 } | |
6570 } | |
6571 } | |
6572 | |
6573 // Remove cache only if it was not alrea
dy removed by jQuery.event.remove | |
6574 if ( cache[ id ] ) { | |
6575 | |
6576 delete cache[ id ]; | |
6577 | |
6578 // IE does not allow us to delet
e expando properties from nodes, | |
6579 // nor does it have a removeAttr
ibute function on Document nodes; | |
6580 // we must handle all of these c
ases | |
6581 if ( deleteExpando ) { | |
6582 delete elem[ internalKey
]; | |
6583 | |
6584 } else if ( typeof elem.removeAt
tribute !== "undefined" ) { | |
6585 elem.removeAttribute( in
ternalKey ); | |
6586 | |
6587 } else { | |
6588 elem[ internalKey ] = nu
ll; | |
6589 } | |
6590 | |
6591 core_deletedIds.push( id ); | |
6592 } | |
6593 } | |
6594 } | |
6595 } | |
6596 } | |
6597 }); | |
6598 var curCSS, getStyles, iframe, | |
6599 ralpha = /alpha\([^)]*\)/i, | |
6600 ropacity = /opacity\s*=\s*([^)]*)/, | |
6601 rposition = /^(top|right|bottom|left)$/, | |
6602 // swappable if display is none or starts with table except "table", "ta
ble-cell", or "table-caption" | |
6603 // see here for display values: https://developer.mozilla.org/en-US/docs
/CSS/display | |
6604 rdisplayswap = /^(none|table(?!-c[ea]).+)/, | |
6605 rmargin = /^margin/, | |
6606 rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ), | |
6607 rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ), | |
6608 rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ), | |
6609 elemdisplay = { BODY: "block" }, | |
6610 | |
6611 cssShow = { position: "absolute", visibility: "hidden", display: "block"
}, | |
6612 cssNormalTransform = { | |
6613 letterSpacing: 0, | |
6614 fontWeight: 400 | |
6615 }, | |
6616 | |
6617 cssExpand = [ "Top", "Right", "Bottom", "Left" ], | |
6618 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; | |
6619 | |
6620 // return a css property mapped to a potentially vendor prefixed property | |
6621 function vendorPropName( style, name ) { | |
6622 | |
6623 // shortcut for names that are not vendor prefixed | |
6624 if ( name in style ) { | |
6625 return name; | |
6626 } | |
6627 | |
6628 // check for vendor prefixed names | |
6629 var capName = name.charAt(0).toUpperCase() + name.slice(1), | |
6630 origName = name, | |
6631 i = cssPrefixes.length; | |
6632 | |
6633 while ( i-- ) { | |
6634 name = cssPrefixes[ i ] + capName; | |
6635 if ( name in style ) { | |
6636 return name; | |
6637 } | |
6638 } | |
6639 | |
6640 return origName; | |
6641 } | |
6642 | |
6643 function isHidden( elem, el ) { | |
6644 // isHidden might be called from jQuery#filter function; | |
6645 // in that case, element will be second argument | |
6646 elem = el || elem; | |
6647 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( ele
m.ownerDocument, elem ); | |
6648 } | |
6649 | |
6650 function showHide( elements, show ) { | |
6651 var elem, | |
6652 values = [], | |
6653 index = 0, | |
6654 length = elements.length; | |
6655 | |
6656 for ( ; index < length; index++ ) { | |
6657 elem = elements[ index ]; | |
6658 if ( !elem.style ) { | |
6659 continue; | |
6660 } | |
6661 values[ index ] = jQuery._data( elem, "olddisplay" ); | |
6662 if ( show ) { | |
6663 // Reset the inline display of this element to learn if
it is | |
6664 // being hidden by cascaded rules or not | |
6665 if ( !values[ index ] && elem.style.display === "none" )
{ | |
6666 elem.style.display = ""; | |
6667 } | |
6668 | |
6669 // Set elements which have been overridden with display:
none | |
6670 // in a stylesheet to whatever the default browser style
is | |
6671 // for such an element | |
6672 if ( elem.style.display === "" && isHidden( elem ) ) { | |
6673 values[ index ] = jQuery._data( elem, "olddispla
y", css_defaultDisplay(elem.nodeName) ); | |
6674 } | |
6675 } else if ( !values[ index ] && !isHidden( elem ) ) { | |
6676 jQuery._data( elem, "olddisplay", jQuery.css( elem, "dis
play" ) ); | |
6677 } | |
6678 } | |
6679 | |
6680 // Set the display of most of the elements in a second loop | |
6681 // to avoid the constant reflow | |
6682 for ( index = 0; index < length; index++ ) { | |
6683 elem = elements[ index ]; | |
6684 if ( !elem.style ) { | |
6685 continue; | |
6686 } | |
6687 if ( !show || elem.style.display === "none" || elem.style.displa
y === "" ) { | |
6688 elem.style.display = show ? values[ index ] || "" : "non
e"; | |
6689 } | |
6690 } | |
6691 | |
6692 return elements; | |
6693 } | |
6694 | |
6695 jQuery.fn.extend({ | |
6696 css: function( name, value ) { | |
6697 return jQuery.access( this, function( elem, name, value ) { | |
6698 var styles, len, | |
6699 map = {}, | |
6700 i = 0; | |
6701 | |
6702 if ( jQuery.isArray( name ) ) { | |
6703 styles = getStyles( elem ); | |
6704 len = name.length; | |
6705 | |
6706 for ( ; i < len; i++ ) { | |
6707 map[ name[ i ] ] = jQuery.css( elem, nam
e[ i ], false, styles ); | |
6708 } | |
6709 | |
6710 return map; | |
6711 } | |
6712 | |
6713 return value !== undefined ? | |
6714 jQuery.style( elem, name, value ) : | |
6715 jQuery.css( elem, name ); | |
6716 }, name, value, arguments.length > 1 ); | |
6717 }, | |
6718 show: function() { | |
6719 return showHide( this, true ); | |
6720 }, | |
6721 hide: function() { | |
6722 return showHide( this ); | |
6723 }, | |
6724 toggle: function( state ) { | |
6725 var bool = typeof state === "boolean"; | |
6726 | |
6727 return this.each(function() { | |
6728 if ( bool ? state : isHidden( this ) ) { | |
6729 jQuery( this ).show(); | |
6730 } else { | |
6731 jQuery( this ).hide(); | |
6732 } | |
6733 }); | |
6734 } | |
6735 }); | |
6736 | |
6737 jQuery.extend({ | |
6738 // Add in style property hooks for overriding the default | |
6739 // behavior of getting and setting a style property | |
6740 cssHooks: { | |
6741 opacity: { | |
6742 get: function( elem, computed ) { | |
6743 if ( computed ) { | |
6744 // We should always get a number back fr
om opacity | |
6745 var ret = curCSS( elem, "opacity" ); | |
6746 return ret === "" ? "1" : ret; | |
6747 } | |
6748 } | |
6749 } | |
6750 }, | |
6751 | |
6752 // Exclude the following css properties to add px | |
6753 cssNumber: { | |
6754 "columnCount": true, | |
6755 "fillOpacity": true, | |
6756 "fontWeight": true, | |
6757 "lineHeight": true, | |
6758 "opacity": true, | |
6759 "orphans": true, | |
6760 "widows": true, | |
6761 "zIndex": true, | |
6762 "zoom": true | |
6763 }, | |
6764 | |
6765 // Add in properties whose names you wish to fix before | |
6766 // setting or getting the value | |
6767 cssProps: { | |
6768 // normalize float css property | |
6769 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat" | |
6770 }, | |
6771 | |
6772 // Get and set the style property on a DOM Node | |
6773 style: function( elem, name, value, extra ) { | |
6774 // Don't set styles on text and comment nodes | |
6775 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !ele
m.style ) { | |
6776 return; | |
6777 } | |
6778 | |
6779 // Make sure that we're working with the right name | |
6780 var ret, type, hooks, | |
6781 origName = jQuery.camelCase( name ), | |
6782 style = elem.style; | |
6783 | |
6784 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origNam
e ] = vendorPropName( style, origName ) ); | |
6785 | |
6786 // gets hook for the prefixed version | |
6787 // followed by the unprefixed version | |
6788 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; | |
6789 | |
6790 // Check if we're setting a value | |
6791 if ( value !== undefined ) { | |
6792 type = typeof value; | |
6793 | |
6794 // convert relative number strings (+= or -=) to relativ
e numbers. #7345 | |
6795 if ( type === "string" && (ret = rrelNum.exec( value ))
) { | |
6796 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQ
uery.css( elem, name ) ); | |
6797 // Fixes bug #9237 | |
6798 type = "number"; | |
6799 } | |
6800 | |
6801 // Make sure that NaN and null values aren't set. See: #
7116 | |
6802 if ( value == null || type === "number" && isNaN( value
) ) { | |
6803 return; | |
6804 } | |
6805 | |
6806 // If a number was passed in, add 'px' to the (except fo
r certain CSS properties) | |
6807 if ( type === "number" && !jQuery.cssNumber[ origName ]
) { | |
6808 value += "px"; | |
6809 } | |
6810 | |
6811 // Fixes #8908, it can be done more correctly by specifi
ng setters in cssHooks, | |
6812 // but it would mean to define eight (for every problema
tic property) identical functions | |
6813 if ( !jQuery.support.clearCloneStyle && value === "" &&
name.indexOf("background") === 0 ) { | |
6814 style[ name ] = "inherit"; | |
6815 } | |
6816 | |
6817 // If a hook was provided, use that value, otherwise jus
t set the specified value | |
6818 if ( !hooks || !("set" in hooks) || (value = hooks.set(
elem, value, extra )) !== undefined ) { | |
6819 | |
6820 // Wrapped to prevent IE from throwing errors wh
en 'invalid' values are provided | |
6821 // Fixes bug #5509 | |
6822 try { | |
6823 style[ name ] = value; | |
6824 } catch(e) {} | |
6825 } | |
6826 | |
6827 } else { | |
6828 // If a hook was provided get the non-computed value fro
m there | |
6829 if ( hooks && "get" in hooks && (ret = hooks.get( elem,
false, extra )) !== undefined ) { | |
6830 return ret; | |
6831 } | |
6832 | |
6833 // Otherwise just get the value from the style object | |
6834 return style[ name ]; | |
6835 } | |
6836 }, | |
6837 | |
6838 css: function( elem, name, extra, styles ) { | |
6839 var val, num, hooks, | |
6840 origName = jQuery.camelCase( name ); | |
6841 | |
6842 // Make sure that we're working with the right name | |
6843 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origNam
e ] = vendorPropName( elem.style, origName ) ); | |
6844 | |
6845 // gets hook for the prefixed version | |
6846 // followed by the unprefixed version | |
6847 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; | |
6848 | |
6849 // If a hook was provided get the computed value from there | |
6850 if ( hooks && "get" in hooks ) { | |
6851 val = hooks.get( elem, true, extra ); | |
6852 } | |
6853 | |
6854 // Otherwise, if a way to get the computed value exists, use tha
t | |
6855 if ( val === undefined ) { | |
6856 val = curCSS( elem, name, styles ); | |
6857 } | |
6858 | |
6859 //convert "normal" to computed value | |
6860 if ( val === "normal" && name in cssNormalTransform ) { | |
6861 val = cssNormalTransform[ name ]; | |
6862 } | |
6863 | |
6864 // Return, converting to number if forced or a qualifier was pro
vided and val looks numeric | |
6865 if ( extra ) { | |
6866 num = parseFloat( val ); | |
6867 return extra === true || jQuery.isNumeric( num ) ? num |
| 0 : val; | |
6868 } | |
6869 return val; | |
6870 }, | |
6871 | |
6872 // A method for quickly swapping in/out CSS properties to get correct ca
lculations | |
6873 swap: function( elem, options, callback, args ) { | |
6874 var ret, name, | |
6875 old = {}; | |
6876 | |
6877 // Remember the old values, and insert the new ones | |
6878 for ( name in options ) { | |
6879 old[ name ] = elem.style[ name ]; | |
6880 elem.style[ name ] = options[ name ]; | |
6881 } | |
6882 | |
6883 ret = callback.apply( elem, args || [] ); | |
6884 | |
6885 // Revert the old values | |
6886 for ( name in options ) { | |
6887 elem.style[ name ] = old[ name ]; | |
6888 } | |
6889 | |
6890 return ret; | |
6891 } | |
6892 }); | |
6893 | |
6894 // NOTE: we've included the "window" in window.getComputedStyle | |
6895 // because jsdom on node.js will break without it. | |
6896 if ( window.getComputedStyle ) { | |
6897 getStyles = function( elem ) { | |
6898 return window.getComputedStyle( elem, null ); | |
6899 }; | |
6900 | |
6901 curCSS = function( elem, name, _computed ) { | |
6902 var width, minWidth, maxWidth, | |
6903 computed = _computed || getStyles( elem ), | |
6904 | |
6905 // getPropertyValue is only needed for .css('filter') in
IE9, see #12537 | |
6906 ret = computed ? computed.getPropertyValue( name ) || co
mputed[ name ] : undefined, | |
6907 style = elem.style; | |
6908 | |
6909 if ( computed ) { | |
6910 | |
6911 if ( ret === "" && !jQuery.contains( elem.ownerDocument,
elem ) ) { | |
6912 ret = jQuery.style( elem, name ); | |
6913 } | |
6914 | |
6915 // A tribute to the "awesome hack by Dean Edwards" | |
6916 // Chrome < 17 and Safari 5.0 uses "computed value" inst
ead of "used value" for margin-right | |
6917 // Safari 5.1.7 (at least) returns percentage for a larg
er set of values, but width seems to be reliably pixels | |
6918 // this is against the CSSOM draft spec: http://dev.w3.o
rg/csswg/cssom/#resolved-values | |
6919 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { | |
6920 | |
6921 // Remember the original values | |
6922 width = style.width; | |
6923 minWidth = style.minWidth; | |
6924 maxWidth = style.maxWidth; | |
6925 | |
6926 // Put in the new values to get a computed value
out | |
6927 style.minWidth = style.maxWidth = style.width =
ret; | |
6928 ret = computed.width; | |
6929 | |
6930 // Revert the changed values | |
6931 style.width = width; | |
6932 style.minWidth = minWidth; | |
6933 style.maxWidth = maxWidth; | |
6934 } | |
6935 } | |
6936 | |
6937 return ret; | |
6938 }; | |
6939 } else if ( document.documentElement.currentStyle ) { | |
6940 getStyles = function( elem ) { | |
6941 return elem.currentStyle; | |
6942 }; | |
6943 | |
6944 curCSS = function( elem, name, _computed ) { | |
6945 var left, rs, rsLeft, | |
6946 computed = _computed || getStyles( elem ), | |
6947 ret = computed ? computed[ name ] : undefined, | |
6948 style = elem.style; | |
6949 | |
6950 // Avoid setting ret to empty string here | |
6951 // so we don't default to auto | |
6952 if ( ret == null && style && style[ name ] ) { | |
6953 ret = style[ name ]; | |
6954 } | |
6955 | |
6956 // From the awesome hack by Dean Edwards | |
6957 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102
291 | |
6958 | |
6959 // If we're not dealing with a regular pixel number | |
6960 // but a number that has a weird ending, we need to convert it t
o pixels | |
6961 // but not position css attributes, as those are proportional to
the parent element instead | |
6962 // and we can't measure the parent instead because it might trig
ger a "stacking dolls" problem | |
6963 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { | |
6964 | |
6965 // Remember the original values | |
6966 left = style.left; | |
6967 rs = elem.runtimeStyle; | |
6968 rsLeft = rs && rs.left; | |
6969 | |
6970 // Put in the new values to get a computed value out | |
6971 if ( rsLeft ) { | |
6972 rs.left = elem.currentStyle.left; | |
6973 } | |
6974 style.left = name === "fontSize" ? "1em" : ret; | |
6975 ret = style.pixelLeft + "px"; | |
6976 | |
6977 // Revert the changed values | |
6978 style.left = left; | |
6979 if ( rsLeft ) { | |
6980 rs.left = rsLeft; | |
6981 } | |
6982 } | |
6983 | |
6984 return ret === "" ? "auto" : ret; | |
6985 }; | |
6986 } | |
6987 | |
6988 function setPositiveNumber( elem, value, subtract ) { | |
6989 var matches = rnumsplit.exec( value ); | |
6990 return matches ? | |
6991 // Guard against undefined "subtract", e.g., when used as in css
Hooks | |
6992 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ]
|| "px" ) : | |
6993 value; | |
6994 } | |
6995 | |
6996 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { | |
6997 var i = extra === ( isBorderBox ? "border" : "content" ) ? | |
6998 // If we already have the right measurement, avoid augmentation | |
6999 4 : | |
7000 // Otherwise initialize for horizontal or vertical properties | |
7001 name === "width" ? 1 : 0, | |
7002 | |
7003 val = 0; | |
7004 | |
7005 for ( ; i < 4; i += 2 ) { | |
7006 // both box models exclude margin, so add it if we want it | |
7007 if ( extra === "margin" ) { | |
7008 val += jQuery.css( elem, extra + cssExpand[ i ], true, s
tyles ); | |
7009 } | |
7010 | |
7011 if ( isBorderBox ) { | |
7012 // border-box includes padding, so remove it if we want
content | |
7013 if ( extra === "content" ) { | |
7014 val -= jQuery.css( elem, "padding" + cssExpand[
i ], true, styles ); | |
7015 } | |
7016 | |
7017 // at this point, extra isn't border nor margin, so remo
ve border | |
7018 if ( extra !== "margin" ) { | |
7019 val -= jQuery.css( elem, "border" + cssExpand[ i
] + "Width", true, styles ); | |
7020 } | |
7021 } else { | |
7022 // at this point, extra isn't content, so add padding | |
7023 val += jQuery.css( elem, "padding" + cssExpand[ i ], tru
e, styles ); | |
7024 | |
7025 // at this point, extra isn't content nor padding, so ad
d border | |
7026 if ( extra !== "padding" ) { | |
7027 val += jQuery.css( elem, "border" + cssExpand[ i
] + "Width", true, styles ); | |
7028 } | |
7029 } | |
7030 } | |
7031 | |
7032 return val; | |
7033 } | |
7034 | |
7035 function getWidthOrHeight( elem, name, extra ) { | |
7036 | |
7037 // Start with offset property, which is equivalent to the border-box val
ue | |
7038 var valueIsBorderBox = true, | |
7039 val = name === "width" ? elem.offsetWidth : elem.offsetHeight, | |
7040 styles = getStyles( elem ), | |
7041 isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "box
Sizing", false, styles ) === "border-box"; | |
7042 | |
7043 // some non-html elements return undefined for offsetWidth, so check for
null/undefined | |
7044 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 | |
7045 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 | |
7046 if ( val <= 0 || val == null ) { | |
7047 // Fall back to computed then uncomputed css if necessary | |
7048 val = curCSS( elem, name, styles ); | |
7049 if ( val < 0 || val == null ) { | |
7050 val = elem.style[ name ]; | |
7051 } | |
7052 | |
7053 // Computed unit is not pixels. Stop here and return. | |
7054 if ( rnumnonpx.test(val) ) { | |
7055 return val; | |
7056 } | |
7057 | |
7058 // we need the check for style in case a browser which returns u
nreliable values | |
7059 // for getComputedStyle silently falls back to the reliable elem
.style | |
7060 valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReli
able || val === elem.style[ name ] ); | |
7061 | |
7062 // Normalize "", auto, and prepare for extra | |
7063 val = parseFloat( val ) || 0; | |
7064 } | |
7065 | |
7066 // use the active box-sizing model to add/subtract irrelevant styles | |
7067 return ( val + | |
7068 augmentWidthOrHeight( | |
7069 elem, | |
7070 name, | |
7071 extra || ( isBorderBox ? "border" : "content" ), | |
7072 valueIsBorderBox, | |
7073 styles | |
7074 ) | |
7075 ) + "px"; | |
7076 } | |
7077 | |
7078 // Try to determine the default display value of an element | |
7079 function css_defaultDisplay( nodeName ) { | |
7080 var doc = document, | |
7081 display = elemdisplay[ nodeName ]; | |
7082 | |
7083 if ( !display ) { | |
7084 display = actualDisplay( nodeName, doc ); | |
7085 | |
7086 // If the simple way fails, read from inside an iframe | |
7087 if ( display === "none" || !display ) { | |
7088 // Use the already-created iframe if possible | |
7089 iframe = ( iframe || | |
7090 jQuery("<iframe frameborder='0' width='0' height
='0'/>") | |
7091 .css( "cssText", "display:block !important" ) | |
7092 ).appendTo( doc.documentElement ); | |
7093 | |
7094 // Always write a new HTML skeleton so Webkit and Firefo
x don't choke on reuse | |
7095 doc = ( iframe[0].contentWindow || iframe[0].contentDocu
ment ).document; | |
7096 doc.write("<!doctype html><html><body>"); | |
7097 doc.close(); | |
7098 | |
7099 display = actualDisplay( nodeName, doc ); | |
7100 iframe.detach(); | |
7101 } | |
7102 | |
7103 // Store the correct default display | |
7104 elemdisplay[ nodeName ] = display; | |
7105 } | |
7106 | |
7107 return display; | |
7108 } | |
7109 | |
7110 // Called ONLY from within css_defaultDisplay | |
7111 function actualDisplay( name, doc ) { | |
7112 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), | |
7113 display = jQuery.css( elem[0], "display" ); | |
7114 elem.remove(); | |
7115 return display; | |
7116 } | |
7117 | |
7118 jQuery.each([ "height", "width" ], function( i, name ) { | |
7119 jQuery.cssHooks[ name ] = { | |
7120 get: function( elem, computed, extra ) { | |
7121 if ( computed ) { | |
7122 // certain elements can have dimension info if w
e invisibly show them | |
7123 // however, it must have a current display style
that would benefit from this | |
7124 return elem.offsetWidth === 0 && rdisplayswap.te
st( jQuery.css( elem, "display" ) ) ? | |
7125 jQuery.swap( elem, cssShow, function() { | |
7126 return getWidthOrHeight( elem, n
ame, extra ); | |
7127 }) : | |
7128 getWidthOrHeight( elem, name, extra ); | |
7129 } | |
7130 }, | |
7131 | |
7132 set: function( elem, value, extra ) { | |
7133 var styles = extra && getStyles( elem ); | |
7134 return setPositiveNumber( elem, value, extra ? | |
7135 augmentWidthOrHeight( | |
7136 elem, | |
7137 name, | |
7138 extra, | |
7139 jQuery.support.boxSizing && jQuery.css(
elem, "boxSizing", false, styles ) === "border-box", | |
7140 styles | |
7141 ) : 0 | |
7142 ); | |
7143 } | |
7144 }; | |
7145 }); | |
7146 | |
7147 if ( !jQuery.support.opacity ) { | |
7148 jQuery.cssHooks.opacity = { | |
7149 get: function( elem, computed ) { | |
7150 // IE uses filters for opacity | |
7151 return ropacity.test( (computed && elem.currentStyle ? e
lem.currentStyle.filter : elem.style.filter) || "" ) ? | |
7152 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" : | |
7153 computed ? "1" : ""; | |
7154 }, | |
7155 | |
7156 set: function( elem, value ) { | |
7157 var style = elem.style, | |
7158 currentStyle = elem.currentStyle, | |
7159 opacity = jQuery.isNumeric( value ) ? "alpha(opa
city=" + value * 100 + ")" : "", | |
7160 filter = currentStyle && currentStyle.filter ||
style.filter || ""; | |
7161 | |
7162 // IE has trouble with opacity if it does not have layou
t | |
7163 // Force it by setting the zoom level | |
7164 style.zoom = 1; | |
7165 | |
7166 // if setting opacity to 1, and no other filters exist -
attempt to remove filter attribute #6652 | |
7167 // if value === "", then remove inline opacity #12685 | |
7168 if ( ( value >= 1 || value === "" ) && | |
7169 jQuery.trim( filter.replace( ralpha, ""
) ) === "" && | |
7170 style.removeAttribute ) { | |
7171 | |
7172 // Setting style.filter to null, "" & " " still
leave "filter:" in the cssText | |
7173 // if "filter:" is present at all, clearType is
disabled, we want to avoid this | |
7174 // style.removeAttribute is IE Only, but so appa
rently is this code path... | |
7175 style.removeAttribute( "filter" ); | |
7176 | |
7177 // if there is no filter style applied in a css
rule or unset inline opacity, we are done | |
7178 if ( value === "" || currentStyle && !currentSty
le.filter ) { | |
7179 return; | |
7180 } | |
7181 } | |
7182 | |
7183 // otherwise, set new filter values | |
7184 style.filter = ralpha.test( filter ) ? | |
7185 filter.replace( ralpha, opacity ) : | |
7186 filter + " " + opacity; | |
7187 } | |
7188 }; | |
7189 } | |
7190 | |
7191 // These hooks cannot be added until DOM ready because the support test | |
7192 // for it is not run until after DOM ready | |
7193 jQuery(function() { | |
7194 if ( !jQuery.support.reliableMarginRight ) { | |
7195 jQuery.cssHooks.marginRight = { | |
7196 get: function( elem, computed ) { | |
7197 if ( computed ) { | |
7198 // WebKit Bug 13343 - getComputedStyle r
eturns wrong value for margin-right | |
7199 // Work around by temporarily setting el
ement display to inline-block | |
7200 return jQuery.swap( elem, { "display": "
inline-block" }, | |
7201 curCSS, [ elem, "marginRight" ]
); | |
7202 } | |
7203 } | |
7204 }; | |
7205 } | |
7206 | |
7207 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 | |
7208 // getComputedStyle returns percent when specified for top/left/bottom/r
ight | |
7209 // rather than make the css module depend on the offset module, we just
check for it here | |
7210 if ( !jQuery.support.pixelPosition && jQuery.fn.position ) { | |
7211 jQuery.each( [ "top", "left" ], function( i, prop ) { | |
7212 jQuery.cssHooks[ prop ] = { | |
7213 get: function( elem, computed ) { | |
7214 if ( computed ) { | |
7215 computed = curCSS( elem, prop ); | |
7216 // if curCSS returns percentage,
fallback to offset | |
7217 return rnumnonpx.test( computed
) ? | |
7218 jQuery( elem ).position(
)[ prop ] + "px" : | |
7219 computed; | |
7220 } | |
7221 } | |
7222 }; | |
7223 }); | |
7224 } | |
7225 | |
7226 }); | |
7227 | |
7228 if ( jQuery.expr && jQuery.expr.filters ) { | |
7229 jQuery.expr.filters.hidden = function( elem ) { | |
7230 return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) ||
(!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) ||
jQuery.css( elem, "display" )) === "none"); | |
7231 }; | |
7232 | |
7233 jQuery.expr.filters.visible = function( elem ) { | |
7234 return !jQuery.expr.filters.hidden( elem ); | |
7235 }; | |
7236 } | |
7237 | |
7238 // These hooks are used by animate to expand properties | |
7239 jQuery.each({ | |
7240 margin: "", | |
7241 padding: "", | |
7242 border: "Width" | |
7243 }, function( prefix, suffix ) { | |
7244 jQuery.cssHooks[ prefix + suffix ] = { | |
7245 expand: function( value ) { | |
7246 var i = 0, | |
7247 expanded = {}, | |
7248 | |
7249 // assumes a single number if not a string | |
7250 parts = typeof value === "string" ? value.split(
" ") : [ value ]; | |
7251 | |
7252 for ( ; i < 4; i++ ) { | |
7253 expanded[ prefix + cssExpand[ i ] + suffix ] = | |
7254 parts[ i ] || parts[ i - 2 ] || parts[ 0
]; | |
7255 } | |
7256 | |
7257 return expanded; | |
7258 } | |
7259 }; | |
7260 | |
7261 if ( !rmargin.test( prefix ) ) { | |
7262 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; | |
7263 } | |
7264 }); | |
7265 var r20 = /%20/g, | |
7266 rbracket = /\[\]$/, | |
7267 rCRLF = /\r?\n/g, | |
7268 rsubmitterTypes = /^(?:submit|button|image|reset)$/i, | |
7269 rsubmittable = /^(?:input|select|textarea|keygen)/i; | |
7270 | |
7271 jQuery.fn.extend({ | |
7272 serialize: function() { | |
7273 return jQuery.param( this.serializeArray() ); | |
7274 }, | |
7275 serializeArray: function() { | |
7276 return this.map(function(){ | |
7277 // Can add propHook for "elements" to filter or add form
elements | |
7278 var elements = jQuery.prop( this, "elements" ); | |
7279 return elements ? jQuery.makeArray( elements ) : this; | |
7280 }) | |
7281 .filter(function(){ | |
7282 var type = this.type; | |
7283 // Use .is(":disabled") so that fieldset[disabled] works | |
7284 return this.name && !jQuery( this ).is( ":disabled" ) && | |
7285 rsubmittable.test( this.nodeName ) && !rsubmitte
rTypes.test( type ) && | |
7286 ( this.checked || !manipulation_rcheckableType.t
est( type ) ); | |
7287 }) | |
7288 .map(function( i, elem ){ | |
7289 var val = jQuery( this ).val(); | |
7290 | |
7291 return val == null ? | |
7292 null : | |
7293 jQuery.isArray( val ) ? | |
7294 jQuery.map( val, function( val ){ | |
7295 return { name: elem.name, value:
val.replace( rCRLF, "\r\n" ) }; | |
7296 }) : | |
7297 { name: elem.name, value: val.replace( r
CRLF, "\r\n" ) }; | |
7298 }).get(); | |
7299 } | |
7300 }); | |
7301 | |
7302 //Serialize an array of form elements or a set of | |
7303 //key/values into a query string | |
7304 jQuery.param = function( a, traditional ) { | |
7305 var prefix, | |
7306 s = [], | |
7307 add = function( key, value ) { | |
7308 // If value is a function, invoke it and return its valu
e | |
7309 value = jQuery.isFunction( value ) ? value() : ( value =
= null ? "" : value ); | |
7310 s[ s.length ] = encodeURIComponent( key ) + "=" + encode
URIComponent( value ); | |
7311 }; | |
7312 | |
7313 // Set traditional to true for jQuery <= 1.3.2 behavior. | |
7314 if ( traditional === undefined ) { | |
7315 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditi
onal; | |
7316 } | |
7317 | |
7318 // If an array was passed in, assume that it is an array of form element
s. | |
7319 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) )
{ | |
7320 // Serialize the form elements | |
7321 jQuery.each( a, function() { | |
7322 add( this.name, this.value ); | |
7323 }); | |
7324 | |
7325 } else { | |
7326 // If traditional, encode the "old" way (the way 1.3.2 or older | |
7327 // did it), otherwise encode params recursively. | |
7328 for ( prefix in a ) { | |
7329 buildParams( prefix, a[ prefix ], traditional, add ); | |
7330 } | |
7331 } | |
7332 | |
7333 // Return the resulting serialization | |
7334 return s.join( "&" ).replace( r20, "+" ); | |
7335 }; | |
7336 | |
7337 function buildParams( prefix, obj, traditional, add ) { | |
7338 var name; | |
7339 | |
7340 if ( jQuery.isArray( obj ) ) { | |
7341 // Serialize array item. | |
7342 jQuery.each( obj, function( i, v ) { | |
7343 if ( traditional || rbracket.test( prefix ) ) { | |
7344 // Treat each array item as a scalar. | |
7345 add( prefix, v ); | |
7346 | |
7347 } else { | |
7348 // Item is non-scalar (array or object), encode
its numeric index. | |
7349 buildParams( prefix + "[" + ( typeof v === "obje
ct" ? i : "" ) + "]", v, traditional, add ); | |
7350 } | |
7351 }); | |
7352 | |
7353 } else if ( !traditional && jQuery.type( obj ) === "object" ) { | |
7354 // Serialize object item. | |
7355 for ( name in obj ) { | |
7356 buildParams( prefix + "[" + name + "]", obj[ name ], tra
ditional, add ); | |
7357 } | |
7358 | |
7359 } else { | |
7360 // Serialize scalar item. | |
7361 add( prefix, obj ); | |
7362 } | |
7363 } | |
7364 var | |
7365 // Document location | |
7366 ajaxLocParts, | |
7367 ajaxLocation, | |
7368 | |
7369 ajax_nonce = jQuery.now(), | |
7370 | |
7371 ajax_rquery = /\?/, | |
7372 rhash = /#.*$/, | |
7373 rts = /([?&])_=[^&]*/, | |
7374 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character
at EOL | |
7375 // #7653, #8125, #8152: local protocol detection | |
7376 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget
):$/, | |
7377 rnoContent = /^(?:GET|HEAD)$/, | |
7378 rprotocol = /^\/\//, | |
7379 rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/, | |
7380 | |
7381 // Keep a copy of the old load method | |
7382 _load = jQuery.fn.load, | |
7383 | |
7384 /* Prefilters | |
7385 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js f
or an example) | |
7386 * 2) These are called: | |
7387 * - BEFORE asking for a transport | |
7388 * - AFTER param serialization (s.data is a string if s.processData i
s true) | |
7389 * 3) key is the dataType | |
7390 * 4) the catchall symbol "*" can be used | |
7391 * 5) execution will start with transport dataType and THEN continue dow
n to "*" if needed | |
7392 */ | |
7393 prefilters = {}, | |
7394 | |
7395 /* Transports bindings | |
7396 * 1) key is the dataType | |
7397 * 2) the catchall symbol "*" can be used | |
7398 * 3) selection will start with transport dataType and THEN go to "*" if
needed | |
7399 */ | |
7400 transports = {}, | |
7401 | |
7402 // Avoid comment-prolog char sequence (#10098); must appease lint and ev
ade compression | |
7403 allTypes = "*/".concat("*"); | |
7404 | |
7405 // #8138, IE may throw an exception when accessing | |
7406 // a field from window.location if document.domain has been set | |
7407 try { | |
7408 ajaxLocation = location.href; | |
7409 } catch( e ) { | |
7410 // Use the href attribute of an A element | |
7411 // since IE will modify it given document.location | |
7412 ajaxLocation = document.createElement( "a" ); | |
7413 ajaxLocation.href = ""; | |
7414 ajaxLocation = ajaxLocation.href; | |
7415 } | |
7416 | |
7417 // Segment location into parts | |
7418 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; | |
7419 | |
7420 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport | |
7421 function addToPrefiltersOrTransports( structure ) { | |
7422 | |
7423 // dataTypeExpression is optional and defaults to "*" | |
7424 return function( dataTypeExpression, func ) { | |
7425 | |
7426 if ( typeof dataTypeExpression !== "string" ) { | |
7427 func = dataTypeExpression; | |
7428 dataTypeExpression = "*"; | |
7429 } | |
7430 | |
7431 var dataType, | |
7432 i = 0, | |
7433 dataTypes = dataTypeExpression.toLowerCase().match( core
_rnotwhite ) || []; | |
7434 | |
7435 if ( jQuery.isFunction( func ) ) { | |
7436 // For each dataType in the dataTypeExpression | |
7437 while ( (dataType = dataTypes[i++]) ) { | |
7438 // Prepend if requested | |
7439 if ( dataType[0] === "+" ) { | |
7440 dataType = dataType.slice( 1 ) || "*"; | |
7441 (structure[ dataType ] = structure[ data
Type ] || []).unshift( func ); | |
7442 | |
7443 // Otherwise append | |
7444 } else { | |
7445 (structure[ dataType ] = structure[ data
Type ] || []).push( func ); | |
7446 } | |
7447 } | |
7448 } | |
7449 }; | |
7450 } | |
7451 | |
7452 // Base inspection function for prefilters and transports | |
7453 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
HR ) { | |
7454 | |
7455 var inspected = {}, | |
7456 seekingTransport = ( structure === transports ); | |
7457 | |
7458 function inspect( dataType ) { | |
7459 var selected; | |
7460 inspected[ dataType ] = true; | |
7461 jQuery.each( structure[ dataType ] || [], function( _, prefilter
OrFactory ) { | |
7462 var dataTypeOrTransport = prefilterOrFactory( options, o
riginalOptions, jqXHR ); | |
7463 if( typeof dataTypeOrTransport === "string" && !seekingT
ransport && !inspected[ dataTypeOrTransport ] ) { | |
7464 options.dataTypes.unshift( dataTypeOrTransport )
; | |
7465 inspect( dataTypeOrTransport ); | |
7466 return false; | |
7467 } else if ( seekingTransport ) { | |
7468 return !( selected = dataTypeOrTransport ); | |
7469 } | |
7470 }); | |
7471 return selected; | |
7472 } | |
7473 | |
7474 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect
( "*" ); | |
7475 } | |
7476 | |
7477 // A special extend for ajax options | |
7478 // that takes "flat" options (not to be deep extended) | |
7479 // Fixes #9887 | |
7480 function ajaxExtend( target, src ) { | |
7481 var key, deep, | |
7482 flatOptions = jQuery.ajaxSettings.flatOptions || {}; | |
7483 | |
7484 for ( key in src ) { | |
7485 if ( src[ key ] !== undefined ) { | |
7486 ( flatOptions[ key ] ? target : ( deep || (deep = {}) )
)[ key ] = src[ key ]; | |
7487 } | |
7488 } | |
7489 if ( deep ) { | |
7490 jQuery.extend( true, target, deep ); | |
7491 } | |
7492 | |
7493 return target; | |
7494 } | |
7495 | |
7496 jQuery.fn.load = function( url, params, callback ) { | |
7497 if ( typeof url !== "string" && _load ) { | |
7498 return _load.apply( this, arguments ); | |
7499 } | |
7500 | |
7501 var selector, type, response, | |
7502 self = this, | |
7503 off = url.indexOf(" "); | |
7504 | |
7505 if ( off >= 0 ) { | |
7506 selector = url.slice( off, url.length ); | |
7507 url = url.slice( 0, off ); | |
7508 } | |
7509 | |
7510 // If it's a function | |
7511 if ( jQuery.isFunction( params ) ) { | |
7512 | |
7513 // We assume that it's the callback | |
7514 callback = params; | |
7515 params = undefined; | |
7516 | |
7517 // Otherwise, build a param string | |
7518 } else if ( params && typeof params === "object" ) { | |
7519 type = "POST"; | |
7520 } | |
7521 | |
7522 // If we have elements to modify, make the request | |
7523 if ( self.length > 0 ) { | |
7524 jQuery.ajax({ | |
7525 url: url, | |
7526 | |
7527 // if "type" variable is undefined, then "GET" method wi
ll be used | |
7528 type: type, | |
7529 dataType: "html", | |
7530 data: params | |
7531 }).done(function( responseText ) { | |
7532 | |
7533 // Save response for use in complete callback | |
7534 response = arguments; | |
7535 | |
7536 self.html( selector ? | |
7537 | |
7538 // If a selector was specified, locate the right
elements in a dummy div | |
7539 // Exclude scripts to avoid IE 'Permission Denie
d' errors | |
7540 jQuery("<div>").append( jQuery.parseHTML( respon
seText ) ).find( selector ) : | |
7541 | |
7542 // Otherwise use the full result | |
7543 responseText ); | |
7544 | |
7545 }).complete( callback && function( jqXHR, status ) { | |
7546 self.each( callback, response || [ jqXHR.responseText, s
tatus, jqXHR ] ); | |
7547 }); | |
7548 } | |
7549 | |
7550 return this; | |
7551 }; | |
7552 | |
7553 // Attach a bunch of functions for handling common AJAX events | |
7554 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSucces
s", "ajaxSend" ], function( i, type ){ | |
7555 jQuery.fn[ type ] = function( fn ){ | |
7556 return this.on( type, fn ); | |
7557 }; | |
7558 }); | |
7559 | |
7560 jQuery.each( [ "get", "post" ], function( i, method ) { | |
7561 jQuery[ method ] = function( url, data, callback, type ) { | |
7562 // shift arguments if data argument was omitted | |
7563 if ( jQuery.isFunction( data ) ) { | |
7564 type = type || callback; | |
7565 callback = data; | |
7566 data = undefined; | |
7567 } | |
7568 | |
7569 return jQuery.ajax({ | |
7570 url: url, | |
7571 type: method, | |
7572 dataType: type, | |
7573 data: data, | |
7574 success: callback | |
7575 }); | |
7576 }; | |
7577 }); | |
7578 | |
7579 jQuery.extend({ | |
7580 | |
7581 // Counter for holding the number of active queries | |
7582 active: 0, | |
7583 | |
7584 // Last-Modified header cache for next request | |
7585 lastModified: {}, | |
7586 etag: {}, | |
7587 | |
7588 ajaxSettings: { | |
7589 url: ajaxLocation, | |
7590 type: "GET", | |
7591 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), | |
7592 global: true, | |
7593 processData: true, | |
7594 async: true, | |
7595 contentType: "application/x-www-form-urlencoded; charset=UTF-8", | |
7596 /* | |
7597 timeout: 0, | |
7598 data: null, | |
7599 dataType: null, | |
7600 username: null, | |
7601 password: null, | |
7602 cache: null, | |
7603 throws: false, | |
7604 traditional: false, | |
7605 headers: {}, | |
7606 */ | |
7607 | |
7608 accepts: { | |
7609 "*": allTypes, | |
7610 text: "text/plain", | |
7611 html: "text/html", | |
7612 xml: "application/xml, text/xml", | |
7613 json: "application/json, text/javascript" | |
7614 }, | |
7615 | |
7616 contents: { | |
7617 xml: /xml/, | |
7618 html: /html/, | |
7619 json: /json/ | |
7620 }, | |
7621 | |
7622 responseFields: { | |
7623 xml: "responseXML", | |
7624 text: "responseText" | |
7625 }, | |
7626 | |
7627 // Data converters | |
7628 // Keys separate source (or catchall "*") and destination types
with a single space | |
7629 converters: { | |
7630 | |
7631 // Convert anything to text | |
7632 "* text": window.String, | |
7633 | |
7634 // Text to html (true = no transformation) | |
7635 "text html": true, | |
7636 | |
7637 // Evaluate text as a json expression | |
7638 "text json": jQuery.parseJSON, | |
7639 | |
7640 // Parse text as xml | |
7641 "text xml": jQuery.parseXML | |
7642 }, | |
7643 | |
7644 // For options that shouldn't be deep extended: | |
7645 // you can add your own custom options here if | |
7646 // and when you create one that shouldn't be | |
7647 // deep extended (see ajaxExtend) | |
7648 flatOptions: { | |
7649 url: true, | |
7650 context: true | |
7651 } | |
7652 }, | |
7653 | |
7654 // Creates a full fledged settings object into target | |
7655 // with both ajaxSettings and settings fields. | |
7656 // If target is omitted, writes into ajaxSettings. | |
7657 ajaxSetup: function( target, settings ) { | |
7658 return settings ? | |
7659 | |
7660 // Building a settings object | |
7661 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), s
ettings ) : | |
7662 | |
7663 // Extending ajaxSettings | |
7664 ajaxExtend( jQuery.ajaxSettings, target ); | |
7665 }, | |
7666 | |
7667 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), | |
7668 ajaxTransport: addToPrefiltersOrTransports( transports ), | |
7669 | |
7670 // Main method | |
7671 ajax: function( url, options ) { | |
7672 | |
7673 // If url is an object, simulate pre-1.5 signature | |
7674 if ( typeof url === "object" ) { | |
7675 options = url; | |
7676 url = undefined; | |
7677 } | |
7678 | |
7679 // Force options to be an object | |
7680 options = options || {}; | |
7681 | |
7682 var transport, | |
7683 // URL without anti-cache param | |
7684 cacheURL, | |
7685 // Response headers | |
7686 responseHeadersString, | |
7687 responseHeaders, | |
7688 // timeout handle | |
7689 timeoutTimer, | |
7690 // Cross-domain detection vars | |
7691 parts, | |
7692 // To know if global events are to be dispatched | |
7693 fireGlobals, | |
7694 // Loop variable | |
7695 i, | |
7696 // Create the final options object | |
7697 s = jQuery.ajaxSetup( {}, options ), | |
7698 // Callbacks context | |
7699 callbackContext = s.context || s, | |
7700 // Context for global events is callbackContext if it is
a DOM node or jQuery collection | |
7701 globalEventContext = s.context && ( callbackContext.node
Type || callbackContext.jquery ) ? | |
7702 jQuery( callbackContext ) : | |
7703 jQuery.event, | |
7704 // Deferreds | |
7705 deferred = jQuery.Deferred(), | |
7706 completeDeferred = jQuery.Callbacks("once memory"), | |
7707 // Status-dependent callbacks | |
7708 statusCode = s.statusCode || {}, | |
7709 // Headers (they are sent all at once) | |
7710 requestHeaders = {}, | |
7711 requestHeadersNames = {}, | |
7712 // The jqXHR state | |
7713 state = 0, | |
7714 // Default abort message | |
7715 strAbort = "canceled", | |
7716 // Fake xhr | |
7717 jqXHR = { | |
7718 readyState: 0, | |
7719 | |
7720 // Builds headers hashtable if needed | |
7721 getResponseHeader: function( key ) { | |
7722 var match; | |
7723 if ( state === 2 ) { | |
7724 if ( !responseHeaders ) { | |
7725 responseHeaders = {}; | |
7726 while ( (match = rheader
s.exec( responseHeadersString )) ) { | |
7727 responseHeaders[
match[1].toLowerCase() ] = match[ 2 ]; | |
7728 } | |
7729 } | |
7730 match = responseHeaders[ key.toL
owerCase() ]; | |
7731 } | |
7732 return match == null ? null : match; | |
7733 }, | |
7734 | |
7735 // Raw string | |
7736 getAllResponseHeaders: function() { | |
7737 return state === 2 ? responseHeadersStri
ng : null; | |
7738 }, | |
7739 | |
7740 // Caches the header | |
7741 setRequestHeader: function( name, value ) { | |
7742 var lname = name.toLowerCase(); | |
7743 if ( !state ) { | |
7744 name = requestHeadersNames[ lnam
e ] = requestHeadersNames[ lname ] || name; | |
7745 requestHeaders[ name ] = value; | |
7746 } | |
7747 return this; | |
7748 }, | |
7749 | |
7750 // Overrides response content-type header | |
7751 overrideMimeType: function( type ) { | |
7752 if ( !state ) { | |
7753 s.mimeType = type; | |
7754 } | |
7755 return this; | |
7756 }, | |
7757 | |
7758 // Status-dependent callbacks | |
7759 statusCode: function( map ) { | |
7760 var code; | |
7761 if ( map ) { | |
7762 if ( state < 2 ) { | |
7763 for ( code in map ) { | |
7764 // Lazy-add the
new callback in a way that preserves old ones | |
7765 statusCode[ code
] = [ statusCode[ code ], map[ code ] ]; | |
7766 } | |
7767 } else { | |
7768 // Execute the appropria
te callbacks | |
7769 jqXHR.always( map[ jqXHR
.status ] ); | |
7770 } | |
7771 } | |
7772 return this; | |
7773 }, | |
7774 | |
7775 // Cancel the request | |
7776 abort: function( statusText ) { | |
7777 var finalText = statusText || strAbort; | |
7778 if ( transport ) { | |
7779 transport.abort( finalText ); | |
7780 } | |
7781 done( 0, finalText ); | |
7782 return this; | |
7783 } | |
7784 }; | |
7785 | |
7786 // Attach deferreds | |
7787 deferred.promise( jqXHR ).complete = completeDeferred.add; | |
7788 jqXHR.success = jqXHR.done; | |
7789 jqXHR.error = jqXHR.fail; | |
7790 | |
7791 // Remove hash character (#7531: and string promotion) | |
7792 // Add protocol if not provided (#5866: IE7 issue with protocol-
less urls) | |
7793 // Handle falsy url in the settings object (#10093: consistency
with old signature) | |
7794 // We also use the url parameter if available | |
7795 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash
, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); | |
7796 | |
7797 // Alias method option to type as per ticket #12004 | |
7798 s.type = options.method || options.type || s.method || s.type; | |
7799 | |
7800 // Extract dataTypes list | |
7801 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().mat
ch( core_rnotwhite ) || [""]; | |
7802 | |
7803 // A cross-domain request is in order when we have a protocol:ho
st:port mismatch | |
7804 if ( s.crossDomain == null ) { | |
7805 parts = rurl.exec( s.url.toLowerCase() ); | |
7806 s.crossDomain = !!( parts && | |
7807 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ]
!== ajaxLocParts[ 2 ] || | |
7808 ( parts[ 3 ] || ( parts[ 1 ] === "http:"
? 80 : 443 ) ) != | |
7809 ( ajaxLocParts[ 3 ] || ( ajaxLoc
Parts[ 1 ] === "http:" ? 80 : 443 ) ) ) | |
7810 ); | |
7811 } | |
7812 | |
7813 // Convert data if not already a string | |
7814 if ( s.data && s.processData && typeof s.data !== "string" ) { | |
7815 s.data = jQuery.param( s.data, s.traditional ); | |
7816 } | |
7817 | |
7818 // Apply prefilters | |
7819 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); | |
7820 | |
7821 // If request was aborted inside a prefilter, stop there | |
7822 if ( state === 2 ) { | |
7823 return jqXHR; | |
7824 } | |
7825 | |
7826 // We can fire global events as of now if asked to | |
7827 fireGlobals = s.global; | |
7828 | |
7829 // Watch for a new set of requests | |
7830 if ( fireGlobals && jQuery.active++ === 0 ) { | |
7831 jQuery.event.trigger("ajaxStart"); | |
7832 } | |
7833 | |
7834 // Uppercase the type | |
7835 s.type = s.type.toUpperCase(); | |
7836 | |
7837 // Determine if request has content | |
7838 s.hasContent = !rnoContent.test( s.type ); | |
7839 | |
7840 // Save the URL in case we're toying with the If-Modified-Since | |
7841 // and/or If-None-Match header later on | |
7842 cacheURL = s.url; | |
7843 | |
7844 // More options handling for requests with no content | |
7845 if ( !s.hasContent ) { | |
7846 | |
7847 // If data is available, append data to url | |
7848 if ( s.data ) { | |
7849 cacheURL = ( s.url += ( ajax_rquery.test( cacheU
RL ) ? "&" : "?" ) + s.data ); | |
7850 // #9682: remove data so that it's not used in a
n eventual retry | |
7851 delete s.data; | |
7852 } | |
7853 | |
7854 // Add anti-cache in url if needed | |
7855 if ( s.cache === false ) { | |
7856 s.url = rts.test( cacheURL ) ? | |
7857 | |
7858 // If there is already a '_' parameter,
set its value | |
7859 cacheURL.replace( rts, "$1_=" + ajax_non
ce++ ) : | |
7860 | |
7861 // Otherwise add one to the end | |
7862 cacheURL + ( ajax_rquery.test( cacheURL
) ? "&" : "?" ) + "_=" + ajax_nonce++; | |
7863 } | |
7864 } | |
7865 | |
7866 // Set the If-Modified-Since and/or If-None-Match header, if in
ifModified mode. | |
7867 if ( s.ifModified ) { | |
7868 if ( jQuery.lastModified[ cacheURL ] ) { | |
7869 jqXHR.setRequestHeader( "If-Modified-Since", jQu
ery.lastModified[ cacheURL ] ); | |
7870 } | |
7871 if ( jQuery.etag[ cacheURL ] ) { | |
7872 jqXHR.setRequestHeader( "If-None-Match", jQuery.
etag[ cacheURL ] ); | |
7873 } | |
7874 } | |
7875 | |
7876 // Set the correct header, if data is being sent | |
7877 if ( s.data && s.hasContent && s.contentType !== false || option
s.contentType ) { | |
7878 jqXHR.setRequestHeader( "Content-Type", s.contentType ); | |
7879 } | |
7880 | |
7881 // Set the Accepts header for the server, depending on the dataT
ype | |
7882 jqXHR.setRequestHeader( | |
7883 "Accept", | |
7884 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? | |
7885 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ]
!== "*" ? ", " + allTypes + "; q=0.01" : "" ) : | |
7886 s.accepts[ "*" ] | |
7887 ); | |
7888 | |
7889 // Check for headers option | |
7890 for ( i in s.headers ) { | |
7891 jqXHR.setRequestHeader( i, s.headers[ i ] ); | |
7892 } | |
7893 | |
7894 // Allow custom headers/mimetypes and early abort | |
7895 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR
, s ) === false || state === 2 ) ) { | |
7896 // Abort if not done already and return | |
7897 return jqXHR.abort(); | |
7898 } | |
7899 | |
7900 // aborting is no longer a cancellation | |
7901 strAbort = "abort"; | |
7902 | |
7903 // Install callbacks on deferreds | |
7904 for ( i in { success: 1, error: 1, complete: 1 } ) { | |
7905 jqXHR[ i ]( s[ i ] ); | |
7906 } | |
7907 | |
7908 // Get transport | |
7909 transport = inspectPrefiltersOrTransports( transports, s, option
s, jqXHR ); | |
7910 | |
7911 // If no transport, we auto-abort | |
7912 if ( !transport ) { | |
7913 done( -1, "No Transport" ); | |
7914 } else { | |
7915 jqXHR.readyState = 1; | |
7916 | |
7917 // Send global event | |
7918 if ( fireGlobals ) { | |
7919 globalEventContext.trigger( "ajaxSend", [ jqXHR,
s ] ); | |
7920 } | |
7921 // Timeout | |
7922 if ( s.async && s.timeout > 0 ) { | |
7923 timeoutTimer = setTimeout(function() { | |
7924 jqXHR.abort("timeout"); | |
7925 }, s.timeout ); | |
7926 } | |
7927 | |
7928 try { | |
7929 state = 1; | |
7930 transport.send( requestHeaders, done ); | |
7931 } catch ( e ) { | |
7932 // Propagate exception as error if not done | |
7933 if ( state < 2 ) { | |
7934 done( -1, e ); | |
7935 // Simply rethrow otherwise | |
7936 } else { | |
7937 throw e; | |
7938 } | |
7939 } | |
7940 } | |
7941 | |
7942 // Callback for when everything is done | |
7943 function done( status, nativeStatusText, responses, headers ) { | |
7944 var isSuccess, success, error, response, modified, | |
7945 statusText = nativeStatusText; | |
7946 | |
7947 // Called once | |
7948 if ( state === 2 ) { | |
7949 return; | |
7950 } | |
7951 | |
7952 // State is "done" now | |
7953 state = 2; | |
7954 | |
7955 // Clear timeout if it exists | |
7956 if ( timeoutTimer ) { | |
7957 clearTimeout( timeoutTimer ); | |
7958 } | |
7959 | |
7960 // Dereference transport for early garbage collection | |
7961 // (no matter how long the jqXHR object will be used) | |
7962 transport = undefined; | |
7963 | |
7964 // Cache response headers | |
7965 responseHeadersString = headers || ""; | |
7966 | |
7967 // Set readyState | |
7968 jqXHR.readyState = status > 0 ? 4 : 0; | |
7969 | |
7970 // Get response data | |
7971 if ( responses ) { | |
7972 response = ajaxHandleResponses( s, jqXHR, respon
ses ); | |
7973 } | |
7974 | |
7975 // If successful, handle type chaining | |
7976 if ( status >= 200 && status < 300 || status === 304 ) { | |
7977 | |
7978 // Set the If-Modified-Since and/or If-None-Matc
h header, if in ifModified mode. | |
7979 if ( s.ifModified ) { | |
7980 modified = jqXHR.getResponseHeader("Last
-Modified"); | |
7981 if ( modified ) { | |
7982 jQuery.lastModified[ cacheURL ]
= modified; | |
7983 } | |
7984 modified = jqXHR.getResponseHeader("etag
"); | |
7985 if ( modified ) { | |
7986 jQuery.etag[ cacheURL ] = modifi
ed; | |
7987 } | |
7988 } | |
7989 | |
7990 // If not modified | |
7991 if ( status === 304 ) { | |
7992 isSuccess = true; | |
7993 statusText = "notmodified"; | |
7994 | |
7995 // If we have data | |
7996 } else { | |
7997 isSuccess = ajaxConvert( s, response ); | |
7998 statusText = isSuccess.state; | |
7999 success = isSuccess.data; | |
8000 error = isSuccess.error; | |
8001 isSuccess = !error; | |
8002 } | |
8003 } else { | |
8004 // We extract error from statusText | |
8005 // then normalize statusText and status for non-
aborts | |
8006 error = statusText; | |
8007 if ( status || !statusText ) { | |
8008 statusText = "error"; | |
8009 if ( status < 0 ) { | |
8010 status = 0; | |
8011 } | |
8012 } | |
8013 } | |
8014 | |
8015 // Set data for the fake xhr object | |
8016 jqXHR.status = status; | |
8017 jqXHR.statusText = ( nativeStatusText || statusText ) +
""; | |
8018 | |
8019 // Success/Error | |
8020 if ( isSuccess ) { | |
8021 deferred.resolveWith( callbackContext, [ success
, statusText, jqXHR ] ); | |
8022 } else { | |
8023 deferred.rejectWith( callbackContext, [ jqXHR, s
tatusText, error ] ); | |
8024 } | |
8025 | |
8026 // Status-dependent callbacks | |
8027 jqXHR.statusCode( statusCode ); | |
8028 statusCode = undefined; | |
8029 | |
8030 if ( fireGlobals ) { | |
8031 globalEventContext.trigger( isSuccess ? "ajaxSuc
cess" : "ajaxError", | |
8032 [ jqXHR, s, isSuccess ? success : error
] ); | |
8033 } | |
8034 | |
8035 // Complete | |
8036 completeDeferred.fireWith( callbackContext, [ jqXHR, sta
tusText ] ); | |
8037 | |
8038 if ( fireGlobals ) { | |
8039 globalEventContext.trigger( "ajaxComplete", [ jq
XHR, s ] ); | |
8040 // Handle the global AJAX counter | |
8041 if ( !( --jQuery.active ) ) { | |
8042 jQuery.event.trigger("ajaxStop"); | |
8043 } | |
8044 } | |
8045 } | |
8046 | |
8047 return jqXHR; | |
8048 }, | |
8049 | |
8050 getScript: function( url, callback ) { | |
8051 return jQuery.get( url, undefined, callback, "script" ); | |
8052 }, | |
8053 | |
8054 getJSON: function( url, data, callback ) { | |
8055 return jQuery.get( url, data, callback, "json" ); | |
8056 } | |
8057 }); | |
8058 | |
8059 /* Handles responses to an ajax request: | |
8060 * - sets all responseXXX fields accordingly | |
8061 * - finds the right dataType (mediates between content-type and expected dataTy
pe) | |
8062 * - returns the corresponding response | |
8063 */ | |
8064 function ajaxHandleResponses( s, jqXHR, responses ) { | |
8065 | |
8066 var ct, type, finalDataType, firstDataType, | |
8067 contents = s.contents, | |
8068 dataTypes = s.dataTypes, | |
8069 responseFields = s.responseFields; | |
8070 | |
8071 // Fill responseXXX fields | |
8072 for ( type in responseFields ) { | |
8073 if ( type in responses ) { | |
8074 jqXHR[ responseFields[type] ] = responses[ type ]; | |
8075 } | |
8076 } | |
8077 | |
8078 // Remove auto dataType and get content-type in the process | |
8079 while( dataTypes[ 0 ] === "*" ) { | |
8080 dataTypes.shift(); | |
8081 if ( ct === undefined ) { | |
8082 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type
"); | |
8083 } | |
8084 } | |
8085 | |
8086 // Check if we're dealing with a known content-type | |
8087 if ( ct ) { | |
8088 for ( type in contents ) { | |
8089 if ( contents[ type ] && contents[ type ].test( ct ) ) { | |
8090 dataTypes.unshift( type ); | |
8091 break; | |
8092 } | |
8093 } | |
8094 } | |
8095 | |
8096 // Check to see if we have a response for the expected dataType | |
8097 if ( dataTypes[ 0 ] in responses ) { | |
8098 finalDataType = dataTypes[ 0 ]; | |
8099 } else { | |
8100 // Try convertible dataTypes | |
8101 for ( type in responses ) { | |
8102 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataT
ypes[0] ] ) { | |
8103 finalDataType = type; | |
8104 break; | |
8105 } | |
8106 if ( !firstDataType ) { | |
8107 firstDataType = type; | |
8108 } | |
8109 } | |
8110 // Or just use first one | |
8111 finalDataType = finalDataType || firstDataType; | |
8112 } | |
8113 | |
8114 // If we found a dataType | |
8115 // We add the dataType to the list if needed | |
8116 // and return the corresponding response | |
8117 if ( finalDataType ) { | |
8118 if ( finalDataType !== dataTypes[ 0 ] ) { | |
8119 dataTypes.unshift( finalDataType ); | |
8120 } | |
8121 return responses[ finalDataType ]; | |
8122 } | |
8123 } | |
8124 | |
8125 // Chain conversions given the request and the original response | |
8126 function ajaxConvert( s, response ) { | |
8127 | |
8128 var conv, conv2, current, tmp, | |
8129 converters = {}, | |
8130 i = 0, | |
8131 // Work with a copy of dataTypes in case we need to modify it fo
r conversion | |
8132 dataTypes = s.dataTypes.slice(), | |
8133 prev = dataTypes[ 0 ]; | |
8134 | |
8135 // Apply the dataFilter if provided | |
8136 if ( s.dataFilter ) { | |
8137 response = s.dataFilter( response, s.dataType ); | |
8138 } | |
8139 | |
8140 // Create converters map with lowercased keys | |
8141 if ( dataTypes[ 1 ] ) { | |
8142 for ( conv in s.converters ) { | |
8143 converters[ conv.toLowerCase() ] = s.converters[ conv ]; | |
8144 } | |
8145 } | |
8146 | |
8147 // Convert to each sequential dataType, tolerating list modification | |
8148 for ( ; (current = dataTypes[++i]); ) { | |
8149 | |
8150 // There's only work to do if current dataType is non-auto | |
8151 if ( current !== "*" ) { | |
8152 | |
8153 // Convert response if prev dataType is non-auto and dif
fers from current | |
8154 if ( prev !== "*" && prev !== current ) { | |
8155 | |
8156 // Seek a direct converter | |
8157 conv = converters[ prev + " " + current ] || con
verters[ "* " + current ]; | |
8158 | |
8159 // If none found, seek a pair | |
8160 if ( !conv ) { | |
8161 for ( conv2 in converters ) { | |
8162 | |
8163 // If conv2 outputs current | |
8164 tmp = conv2.split(" "); | |
8165 if ( tmp[ 1 ] === current ) { | |
8166 | |
8167 // If prev can be conver
ted to accepted input | |
8168 conv = converters[ prev
+ " " + tmp[ 0 ] ] || | |
8169 converters[ "* "
+ tmp[ 0 ] ]; | |
8170 if ( conv ) { | |
8171 // Condense equi
valence converters | |
8172 if ( conv === tr
ue ) { | |
8173 conv = c
onverters[ conv2 ]; | |
8174 | |
8175 // Otherwise, in
sert the intermediate dataType | |
8176 } else if ( conv
erters[ conv2 ] !== true ) { | |
8177 current
= tmp[ 0 ]; | |
8178 dataType
s.splice( i--, 0, current ); | |
8179 } | |
8180 | |
8181 break; | |
8182 } | |
8183 } | |
8184 } | |
8185 } | |
8186 | |
8187 // Apply converter (if not an equivalence) | |
8188 if ( conv !== true ) { | |
8189 | |
8190 // Unless errors are allowed to bubble,
catch and return them | |
8191 if ( conv && s["throws"] ) { | |
8192 response = conv( response ); | |
8193 } else { | |
8194 try { | |
8195 response = conv( respons
e ); | |
8196 } catch ( e ) { | |
8197 return { state: "parsere
rror", error: conv ? e : "No conversion from " + prev + " to " + current }; | |
8198 } | |
8199 } | |
8200 } | |
8201 } | |
8202 | |
8203 // Update prev for next iteration | |
8204 prev = current; | |
8205 } | |
8206 } | |
8207 | |
8208 return { state: "success", data: response }; | |
8209 } | |
8210 // Install script dataType | |
8211 jQuery.ajaxSetup({ | |
8212 accepts: { | |
8213 script: "text/javascript, application/javascript, application/ec
mascript, application/x-ecmascript" | |
8214 }, | |
8215 contents: { | |
8216 script: /(?:java|ecma)script/ | |
8217 }, | |
8218 converters: { | |
8219 "text script": function( text ) { | |
8220 jQuery.globalEval( text ); | |
8221 return text; | |
8222 } | |
8223 } | |
8224 }); | |
8225 | |
8226 // Handle cache's special case and global | |
8227 jQuery.ajaxPrefilter( "script", function( s ) { | |
8228 if ( s.cache === undefined ) { | |
8229 s.cache = false; | |
8230 } | |
8231 if ( s.crossDomain ) { | |
8232 s.type = "GET"; | |
8233 s.global = false; | |
8234 } | |
8235 }); | |
8236 | |
8237 // Bind script tag hack transport | |
8238 jQuery.ajaxTransport( "script", function(s) { | |
8239 | |
8240 // This transport only deals with cross domain requests | |
8241 if ( s.crossDomain ) { | |
8242 | |
8243 var script, | |
8244 head = document.head || jQuery("head")[0] || document.do
cumentElement; | |
8245 | |
8246 return { | |
8247 | |
8248 send: function( _, callback ) { | |
8249 | |
8250 script = document.createElement("script"); | |
8251 | |
8252 script.async = true; | |
8253 | |
8254 if ( s.scriptCharset ) { | |
8255 script.charset = s.scriptCharset; | |
8256 } | |
8257 | |
8258 script.src = s.url; | |
8259 | |
8260 // Attach handlers for all browsers | |
8261 script.onload = script.onreadystatechange = func
tion( _, isAbort ) { | |
8262 | |
8263 if ( isAbort || !script.readyState || /l
oaded|complete/.test( script.readyState ) ) { | |
8264 | |
8265 // Handle memory leak in IE | |
8266 script.onload = script.onreadyst
atechange = null; | |
8267 | |
8268 // Remove the script | |
8269 if ( script.parentNode ) { | |
8270 script.parentNode.remove
Child( script ); | |
8271 } | |
8272 | |
8273 // Dereference the script | |
8274 script = null; | |
8275 | |
8276 // Callback if not abort | |
8277 if ( !isAbort ) { | |
8278 callback( 200, "success"
); | |
8279 } | |
8280 } | |
8281 }; | |
8282 | |
8283 // Circumvent IE6 bugs with base elements (#2709
and #4378) by prepending | |
8284 // Use native DOM manipulation to avoid our domM
anip AJAX trickery | |
8285 head.insertBefore( script, head.firstChild ); | |
8286 }, | |
8287 | |
8288 abort: function() { | |
8289 if ( script ) { | |
8290 script.onload( undefined, true ); | |
8291 } | |
8292 } | |
8293 }; | |
8294 } | |
8295 }); | |
8296 var oldCallbacks = [], | |
8297 rjsonp = /(=)\?(?=&|$)|\?\?/; | |
8298 | |
8299 // Default jsonp settings | |
8300 jQuery.ajaxSetup({ | |
8301 jsonp: "callback", | |
8302 jsonpCallback: function() { | |
8303 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + (
ajax_nonce++ ) ); | |
8304 this[ callback ] = true; | |
8305 return callback; | |
8306 } | |
8307 }); | |
8308 | |
8309 // Detect, normalize options and install callbacks for jsonp requests | |
8310 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { | |
8311 | |
8312 var callbackName, overwritten, responseContainer, | |
8313 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? | |
8314 "url" : | |
8315 typeof s.data === "string" && !( s.contentType || "" ).i
ndexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" | |
8316 ); | |
8317 | |
8318 // Handle iff the expected data type is "jsonp" or we have a parameter t
o set | |
8319 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { | |
8320 | |
8321 // Get callback name, remembering preexisting value associated w
ith it | |
8322 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallb
ack ) ? | |
8323 s.jsonpCallback() : | |
8324 s.jsonpCallback; | |
8325 | |
8326 // Insert callback into url or form data | |
8327 if ( jsonProp ) { | |
8328 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + ca
llbackName ); | |
8329 } else if ( s.jsonp !== false ) { | |
8330 s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.j
sonp + "=" + callbackName; | |
8331 } | |
8332 | |
8333 // Use data converter to retrieve json after script execution | |
8334 s.converters["script json"] = function() { | |
8335 if ( !responseContainer ) { | |
8336 jQuery.error( callbackName + " was not called" )
; | |
8337 } | |
8338 return responseContainer[ 0 ]; | |
8339 }; | |
8340 | |
8341 // force json dataType | |
8342 s.dataTypes[ 0 ] = "json"; | |
8343 | |
8344 // Install callback | |
8345 overwritten = window[ callbackName ]; | |
8346 window[ callbackName ] = function() { | |
8347 responseContainer = arguments; | |
8348 }; | |
8349 | |
8350 // Clean-up function (fires after converters) | |
8351 jqXHR.always(function() { | |
8352 // Restore preexisting value | |
8353 window[ callbackName ] = overwritten; | |
8354 | |
8355 // Save back as free | |
8356 if ( s[ callbackName ] ) { | |
8357 // make sure that re-using the options doesn't s
crew things around | |
8358 s.jsonpCallback = originalSettings.jsonpCallback
; | |
8359 | |
8360 // save the callback name for future use | |
8361 oldCallbacks.push( callbackName ); | |
8362 } | |
8363 | |
8364 // Call if it was a function and we have a response | |
8365 if ( responseContainer && jQuery.isFunction( overwritten
) ) { | |
8366 overwritten( responseContainer[ 0 ] ); | |
8367 } | |
8368 | |
8369 responseContainer = overwritten = undefined; | |
8370 }); | |
8371 | |
8372 // Delegate to script | |
8373 return "script"; | |
8374 } | |
8375 }); | |
8376 var xhrCallbacks, xhrSupported, | |
8377 xhrId = 0, | |
8378 // #5280: Internet Explorer will keep connections alive if we don't abor
t on unload | |
8379 xhrOnUnloadAbort = window.ActiveXObject && function() { | |
8380 // Abort all pending requests | |
8381 var key; | |
8382 for ( key in xhrCallbacks ) { | |
8383 xhrCallbacks[ key ]( undefined, true ); | |
8384 } | |
8385 }; | |
8386 | |
8387 // Functions to create xhrs | |
8388 function createStandardXHR() { | |
8389 try { | |
8390 return new window.XMLHttpRequest(); | |
8391 } catch( e ) {} | |
8392 } | |
8393 | |
8394 function createActiveXHR() { | |
8395 try { | |
8396 return new window.ActiveXObject("Microsoft.XMLHTTP"); | |
8397 } catch( e ) {} | |
8398 } | |
8399 | |
8400 // Create the request object | |
8401 // (This is still attached to ajaxSettings for backward compatibility) | |
8402 jQuery.ajaxSettings.xhr = window.ActiveXObject ? | |
8403 /* Microsoft failed to properly | |
8404 * implement the XMLHttpRequest in IE7 (can't request local files), | |
8405 * so we use the ActiveXObject when it is available | |
8406 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so | |
8407 * we need a fallback. | |
8408 */ | |
8409 function() { | |
8410 return !this.isLocal && createStandardXHR() || createActiveXHR()
; | |
8411 } : | |
8412 // For all other browsers, use the standard XMLHttpRequest object | |
8413 createStandardXHR; | |
8414 | |
8415 // Determine support properties | |
8416 xhrSupported = jQuery.ajaxSettings.xhr(); | |
8417 jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); | |
8418 xhrSupported = jQuery.support.ajax = !!xhrSupported; | |
8419 | |
8420 // Create transport if the browser can provide an xhr | |
8421 if ( xhrSupported ) { | |
8422 | |
8423 jQuery.ajaxTransport(function( s ) { | |
8424 // Cross domain only allowed if supported through XMLHttpRequest | |
8425 if ( !s.crossDomain || jQuery.support.cors ) { | |
8426 | |
8427 var callback; | |
8428 | |
8429 return { | |
8430 send: function( headers, complete ) { | |
8431 | |
8432 // Get a new xhr | |
8433 var handle, i, | |
8434 xhr = s.xhr(); | |
8435 | |
8436 // Open the socket | |
8437 // Passing null username, generates a lo
gin popup on Opera (#2865) | |
8438 if ( s.username ) { | |
8439 xhr.open( s.type, s.url, s.async
, s.username, s.password ); | |
8440 } else { | |
8441 xhr.open( s.type, s.url, s.async
); | |
8442 } | |
8443 | |
8444 // Apply custom fields if provided | |
8445 if ( s.xhrFields ) { | |
8446 for ( i in s.xhrFields ) { | |
8447 xhr[ i ] = s.xhrFields[
i ]; | |
8448 } | |
8449 } | |
8450 | |
8451 // Override mime type if needed | |
8452 if ( s.mimeType && xhr.overrideMimeType
) { | |
8453 xhr.overrideMimeType( s.mimeType
); | |
8454 } | |
8455 | |
8456 // X-Requested-With header | |
8457 // For cross-domain requests, seeing as
conditions for a preflight are | |
8458 // akin to a jigsaw puzzle, we simply ne
ver set it to be sure. | |
8459 // (it can always be set on a per-reques
t basis or even using ajaxSetup) | |
8460 // For same-domain requests, won't chang
e header if already provided. | |
8461 if ( !s.crossDomain && !headers["X-Reque
sted-With"] ) { | |
8462 headers["X-Requested-With"] = "X
MLHttpRequest"; | |
8463 } | |
8464 | |
8465 // Need an extra try/catch for cross dom
ain requests in Firefox 3 | |
8466 try { | |
8467 for ( i in headers ) { | |
8468 xhr.setRequestHeader( i,
headers[ i ] ); | |
8469 } | |
8470 } catch( err ) {} | |
8471 | |
8472 // Do send the request | |
8473 // This may raise an exception which is
actually | |
8474 // handled in jQuery.ajax (so no try/cat
ch here) | |
8475 xhr.send( ( s.hasContent && s.data ) ||
null ); | |
8476 | |
8477 // Listener | |
8478 callback = function( _, isAbort ) { | |
8479 | |
8480 var status, | |
8481 statusText, | |
8482 responseHeaders, | |
8483 responses, | |
8484 xml; | |
8485 | |
8486 // Firefox throws exceptions whe
n accessing properties | |
8487 // of an xhr when a network erro
r occurred | |
8488 // http://helpful.knobs-dials.co
m/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) | |
8489 try { | |
8490 | |
8491 // Was never called and
is aborted or complete | |
8492 if ( callback && ( isAbo
rt || xhr.readyState === 4 ) ) { | |
8493 | |
8494 // Only called o
nce | |
8495 callback = undef
ined; | |
8496 | |
8497 // Do not keep a
s active anymore | |
8498 if ( handle ) { | |
8499 xhr.onre
adystatechange = jQuery.noop; | |
8500 if ( xhr
OnUnloadAbort ) { | |
8501
delete xhrCallbacks[ handle ]; | |
8502 } | |
8503 } | |
8504 | |
8505 // If it's an ab
ort | |
8506 if ( isAbort ) { | |
8507 // Abort
it manually if needed | |
8508 if ( xhr
.readyState !== 4 ) { | |
8509
xhr.abort(); | |
8510 } | |
8511 } else { | |
8512 response
s = {}; | |
8513 status =
xhr.status; | |
8514 xml = xh
r.responseXML; | |
8515 response
Headers = xhr.getAllResponseHeaders(); | |
8516 | |
8517 // Const
ruct response list | |
8518 if ( xml
&& xml.documentElement /* #4958 */ ) { | |
8519
responses.xml = xml; | |
8520 } | |
8521 | |
8522 // When
requesting binary data, IE6-9 will throw an exception | |
8523 // on an
y attempt to access responseText (#11426) | |
8524 if ( typ
eof xhr.responseText === "string" ) { | |
8525
responses.text = xhr.responseText; | |
8526 } | |
8527 | |
8528 // Firef
ox throws an exception when accessing | |
8529 // statu
sText for faulty cross-domain requests | |
8530 try { | |
8531
statusText = xhr.statusText; | |
8532 } catch(
e ) { | |
8533
// We normalize with Webkit giving an empty statusText | |
8534
statusText = ""; | |
8535 } | |
8536 | |
8537 // Filte
r status for non standard behaviors | |
8538 | |
8539 // If th
e request is local and we have data: assume a success | |
8540 // (succ
ess with no data won't get notified, that's the best we | |
8541 // can d
o given current implementations) | |
8542 if ( !st
atus && s.isLocal && !s.crossDomain ) { | |
8543
status = responses.text ? 200 : 404; | |
8544 // IE -
#1450: sometimes returns 1223 when it should be 204 | |
8545 } else i
f ( status === 1223 ) { | |
8546
status = 204; | |
8547 } | |
8548 } | |
8549 } | |
8550 } catch( firefoxAccessException
) { | |
8551 if ( !isAbort ) { | |
8552 complete( -1, fi
refoxAccessException ); | |
8553 } | |
8554 } | |
8555 | |
8556 // Call complete if needed | |
8557 if ( responses ) { | |
8558 complete( status, status
Text, responses, responseHeaders ); | |
8559 } | |
8560 }; | |
8561 | |
8562 if ( !s.async ) { | |
8563 // if we're in sync mode we fire
the callback | |
8564 callback(); | |
8565 } else if ( xhr.readyState === 4 ) { | |
8566 // (IE6 & IE7) if it's in cache
and has been | |
8567 // retrieved directly we need to
fire the callback | |
8568 setTimeout( callback ); | |
8569 } else { | |
8570 handle = ++xhrId; | |
8571 if ( xhrOnUnloadAbort ) { | |
8572 // Create the active xhr
s callbacks list if needed | |
8573 // and attach the unload
handler | |
8574 if ( !xhrCallbacks ) { | |
8575 xhrCallbacks = {
}; | |
8576 jQuery( window )
.unload( xhrOnUnloadAbort ); | |
8577 } | |
8578 // Add to list of active
xhrs callbacks | |
8579 xhrCallbacks[ handle ] =
callback; | |
8580 } | |
8581 xhr.onreadystatechange = callbac
k; | |
8582 } | |
8583 }, | |
8584 | |
8585 abort: function() { | |
8586 if ( callback ) { | |
8587 callback( undefined, true ); | |
8588 } | |
8589 } | |
8590 }; | |
8591 } | |
8592 }); | |
8593 } | |
8594 var fxNow, timerId, | |
8595 rfxtypes = /^(?:toggle|show|hide)$/, | |
8596 rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" )
, | |
8597 rrun = /queueHooks$/, | |
8598 animationPrefilters = [ defaultPrefilter ], | |
8599 tweeners = { | |
8600 "*": [function( prop, value ) { | |
8601 var end, unit, | |
8602 tween = this.createTween( prop, value ), | |
8603 parts = rfxnum.exec( value ), | |
8604 target = tween.cur(), | |
8605 start = +target || 0, | |
8606 scale = 1, | |
8607 maxIterations = 20; | |
8608 | |
8609 if ( parts ) { | |
8610 end = +parts[2]; | |
8611 unit = parts[3] || ( jQuery.cssNumber[ prop ] ?
"" : "px" ); | |
8612 | |
8613 // We need to compute starting value | |
8614 if ( unit !== "px" && start ) { | |
8615 // Iteratively approximate from a nonzer
o starting point | |
8616 // Prefer the current property, because
this process will be trivial if it uses the same units | |
8617 // Fallback to end or a simple constant | |
8618 start = jQuery.css( tween.elem, prop, tr
ue ) || end || 1; | |
8619 | |
8620 do { | |
8621 // If previous iteration zeroed
out, double until we get *something* | |
8622 // Use a string for doubling fac
tor so we don't accidentally see scale as unchanged below | |
8623 scale = scale || ".5"; | |
8624 | |
8625 // Adjust and apply | |
8626 start = start / scale; | |
8627 jQuery.style( tween.elem, prop,
start + unit ); | |
8628 | |
8629 // Update scale, tolerating zero or NaN
from tween.cur() | |
8630 // And breaking the loop if scale is unc
hanged or perfect, or if we've just had enough | |
8631 } while ( scale !== (scale = tween.cur()
/ target) && scale !== 1 && --maxIterations ); | |
8632 } | |
8633 | |
8634 tween.unit = unit; | |
8635 tween.start = start; | |
8636 // If a +=/-= token was provided, we're doing a
relative animation | |
8637 tween.end = parts[1] ? start + ( parts[1] + 1 )
* end : end; | |
8638 } | |
8639 return tween; | |
8640 }] | |
8641 }; | |
8642 | |
8643 // Animations created synchronously will run synchronously | |
8644 function createFxNow() { | |
8645 setTimeout(function() { | |
8646 fxNow = undefined; | |
8647 }); | |
8648 return ( fxNow = jQuery.now() ); | |
8649 } | |
8650 | |
8651 function createTweens( animation, props ) { | |
8652 jQuery.each( props, function( prop, value ) { | |
8653 var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*
" ] ), | |
8654 index = 0, | |
8655 length = collection.length; | |
8656 for ( ; index < length; index++ ) { | |
8657 if ( collection[ index ].call( animation, prop, value )
) { | |
8658 | |
8659 // we're done with this property | |
8660 return; | |
8661 } | |
8662 } | |
8663 }); | |
8664 } | |
8665 | |
8666 function Animation( elem, properties, options ) { | |
8667 var result, | |
8668 stopped, | |
8669 index = 0, | |
8670 length = animationPrefilters.length, | |
8671 deferred = jQuery.Deferred().always( function() { | |
8672 // don't match elem in the :animated selector | |
8673 delete tick.elem; | |
8674 }), | |
8675 tick = function() { | |
8676 if ( stopped ) { | |
8677 return false; | |
8678 } | |
8679 var currentTime = fxNow || createFxNow(), | |
8680 remaining = Math.max( 0, animation.startTime + a
nimation.duration - currentTime ), | |
8681 // archaic crash bug won't allow us to use 1 - (
0.5 || 0 ) (#12497) | |
8682 temp = remaining / animation.duration || 0, | |
8683 percent = 1 - temp, | |
8684 index = 0, | |
8685 length = animation.tweens.length; | |
8686 | |
8687 for ( ; index < length ; index++ ) { | |
8688 animation.tweens[ index ].run( percent ); | |
8689 } | |
8690 | |
8691 deferred.notifyWith( elem, [ animation, percent, remaini
ng ]); | |
8692 | |
8693 if ( percent < 1 && length ) { | |
8694 return remaining; | |
8695 } else { | |
8696 deferred.resolveWith( elem, [ animation ] ); | |
8697 return false; | |
8698 } | |
8699 }, | |
8700 animation = deferred.promise({ | |
8701 elem: elem, | |
8702 props: jQuery.extend( {}, properties ), | |
8703 opts: jQuery.extend( true, { specialEasing: {} }, option
s ), | |
8704 originalProperties: properties, | |
8705 originalOptions: options, | |
8706 startTime: fxNow || createFxNow(), | |
8707 duration: options.duration, | |
8708 tweens: [], | |
8709 createTween: function( prop, end ) { | |
8710 var tween = jQuery.Tween( elem, animation.opts,
prop, end, | |
8711 animation.opts.specialEasing[ pr
op ] || animation.opts.easing ); | |
8712 animation.tweens.push( tween ); | |
8713 return tween; | |
8714 }, | |
8715 stop: function( gotoEnd ) { | |
8716 var index = 0, | |
8717 // if we are going to the end, we want t
o run all the tweens | |
8718 // otherwise we skip this part | |
8719 length = gotoEnd ? animation.tweens.leng
th : 0; | |
8720 if ( stopped ) { | |
8721 return this; | |
8722 } | |
8723 stopped = true; | |
8724 for ( ; index < length ; index++ ) { | |
8725 animation.tweens[ index ].run( 1 ); | |
8726 } | |
8727 | |
8728 // resolve when we played the last frame | |
8729 // otherwise, reject | |
8730 if ( gotoEnd ) { | |
8731 deferred.resolveWith( elem, [ animation,
gotoEnd ] ); | |
8732 } else { | |
8733 deferred.rejectWith( elem, [ animation,
gotoEnd ] ); | |
8734 } | |
8735 return this; | |
8736 } | |
8737 }), | |
8738 props = animation.props; | |
8739 | |
8740 propFilter( props, animation.opts.specialEasing ); | |
8741 | |
8742 for ( ; index < length ; index++ ) { | |
8743 result = animationPrefilters[ index ].call( animation, elem, pro
ps, animation.opts ); | |
8744 if ( result ) { | |
8745 return result; | |
8746 } | |
8747 } | |
8748 | |
8749 createTweens( animation, props ); | |
8750 | |
8751 if ( jQuery.isFunction( animation.opts.start ) ) { | |
8752 animation.opts.start.call( elem, animation ); | |
8753 } | |
8754 | |
8755 jQuery.fx.timer( | |
8756 jQuery.extend( tick, { | |
8757 elem: elem, | |
8758 anim: animation, | |
8759 queue: animation.opts.queue | |
8760 }) | |
8761 ); | |
8762 | |
8763 // attach callbacks from options | |
8764 return animation.progress( animation.opts.progress ) | |
8765 .done( animation.opts.done, animation.opts.complete ) | |
8766 .fail( animation.opts.fail ) | |
8767 .always( animation.opts.always ); | |
8768 } | |
8769 | |
8770 function propFilter( props, specialEasing ) { | |
8771 var index, name, easing, value, hooks; | |
8772 | |
8773 // camelCase, specialEasing and expand cssHook pass | |
8774 for ( index in props ) { | |
8775 name = jQuery.camelCase( index ); | |
8776 easing = specialEasing[ name ]; | |
8777 value = props[ index ]; | |
8778 if ( jQuery.isArray( value ) ) { | |
8779 easing = value[ 1 ]; | |
8780 value = props[ index ] = value[ 0 ]; | |
8781 } | |
8782 | |
8783 if ( index !== name ) { | |
8784 props[ name ] = value; | |
8785 delete props[ index ]; | |
8786 } | |
8787 | |
8788 hooks = jQuery.cssHooks[ name ]; | |
8789 if ( hooks && "expand" in hooks ) { | |
8790 value = hooks.expand( value ); | |
8791 delete props[ name ]; | |
8792 | |
8793 // not quite $.extend, this wont overwrite keys already
present. | |
8794 // also - reusing 'index' from above because we have the
correct "name" | |
8795 for ( index in value ) { | |
8796 if ( !( index in props ) ) { | |
8797 props[ index ] = value[ index ]; | |
8798 specialEasing[ index ] = easing; | |
8799 } | |
8800 } | |
8801 } else { | |
8802 specialEasing[ name ] = easing; | |
8803 } | |
8804 } | |
8805 } | |
8806 | |
8807 jQuery.Animation = jQuery.extend( Animation, { | |
8808 | |
8809 tweener: function( props, callback ) { | |
8810 if ( jQuery.isFunction( props ) ) { | |
8811 callback = props; | |
8812 props = [ "*" ]; | |
8813 } else { | |
8814 props = props.split(" "); | |
8815 } | |
8816 | |
8817 var prop, | |
8818 index = 0, | |
8819 length = props.length; | |
8820 | |
8821 for ( ; index < length ; index++ ) { | |
8822 prop = props[ index ]; | |
8823 tweeners[ prop ] = tweeners[ prop ] || []; | |
8824 tweeners[ prop ].unshift( callback ); | |
8825 } | |
8826 }, | |
8827 | |
8828 prefilter: function( callback, prepend ) { | |
8829 if ( prepend ) { | |
8830 animationPrefilters.unshift( callback ); | |
8831 } else { | |
8832 animationPrefilters.push( callback ); | |
8833 } | |
8834 } | |
8835 }); | |
8836 | |
8837 function defaultPrefilter( elem, props, opts ) { | |
8838 /*jshint validthis:true */ | |
8839 var index, prop, value, length, dataShow, toggle, tween, hooks, oldfire, | |
8840 anim = this, | |
8841 style = elem.style, | |
8842 orig = {}, | |
8843 handled = [], | |
8844 hidden = elem.nodeType && isHidden( elem ); | |
8845 | |
8846 // handle queue: false promises | |
8847 if ( !opts.queue ) { | |
8848 hooks = jQuery._queueHooks( elem, "fx" ); | |
8849 if ( hooks.unqueued == null ) { | |
8850 hooks.unqueued = 0; | |
8851 oldfire = hooks.empty.fire; | |
8852 hooks.empty.fire = function() { | |
8853 if ( !hooks.unqueued ) { | |
8854 oldfire(); | |
8855 } | |
8856 }; | |
8857 } | |
8858 hooks.unqueued++; | |
8859 | |
8860 anim.always(function() { | |
8861 // doing this makes sure that the complete handler will
be called | |
8862 // before this completes | |
8863 anim.always(function() { | |
8864 hooks.unqueued--; | |
8865 if ( !jQuery.queue( elem, "fx" ).length ) { | |
8866 hooks.empty.fire(); | |
8867 } | |
8868 }); | |
8869 }); | |
8870 } | |
8871 | |
8872 // height/width overflow pass | |
8873 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) )
{ | |
8874 // Make sure that nothing sneaks out | |
8875 // Record all 3 overflow attributes because IE does not | |
8876 // change the overflow attribute when overflowX and | |
8877 // overflowY are set to the same value | |
8878 opts.overflow = [ style.overflow, style.overflowX, style.overflo
wY ]; | |
8879 | |
8880 // Set display property to inline-block for height/width | |
8881 // animations on inline elements that are having width/height an
imated | |
8882 if ( jQuery.css( elem, "display" ) === "inline" && | |
8883 jQuery.css( elem, "float" ) === "none" ) { | |
8884 | |
8885 // inline-level elements accept inline-block; | |
8886 // block-level elements need to be inline with layout | |
8887 if ( !jQuery.support.inlineBlockNeedsLayout || css_defau
ltDisplay( elem.nodeName ) === "inline" ) { | |
8888 style.display = "inline-block"; | |
8889 | |
8890 } else { | |
8891 style.zoom = 1; | |
8892 } | |
8893 } | |
8894 } | |
8895 | |
8896 if ( opts.overflow ) { | |
8897 style.overflow = "hidden"; | |
8898 if ( !jQuery.support.shrinkWrapBlocks ) { | |
8899 anim.done(function() { | |
8900 style.overflow = opts.overflow[ 0 ]; | |
8901 style.overflowX = opts.overflow[ 1 ]; | |
8902 style.overflowY = opts.overflow[ 2 ]; | |
8903 }); | |
8904 } | |
8905 } | |
8906 | |
8907 | |
8908 // show/hide pass | |
8909 for ( index in props ) { | |
8910 value = props[ index ]; | |
8911 if ( rfxtypes.exec( value ) ) { | |
8912 delete props[ index ]; | |
8913 toggle = toggle || value === "toggle"; | |
8914 if ( value === ( hidden ? "hide" : "show" ) ) { | |
8915 continue; | |
8916 } | |
8917 handled.push( index ); | |
8918 } | |
8919 } | |
8920 | |
8921 length = handled.length; | |
8922 if ( length ) { | |
8923 dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem,
"fxshow", {} ); | |
8924 if ( "hidden" in dataShow ) { | |
8925 hidden = dataShow.hidden; | |
8926 } | |
8927 | |
8928 // store state if its toggle - enables .stop().toggle() to "reve
rse" | |
8929 if ( toggle ) { | |
8930 dataShow.hidden = !hidden; | |
8931 } | |
8932 if ( hidden ) { | |
8933 jQuery( elem ).show(); | |
8934 } else { | |
8935 anim.done(function() { | |
8936 jQuery( elem ).hide(); | |
8937 }); | |
8938 } | |
8939 anim.done(function() { | |
8940 var prop; | |
8941 jQuery._removeData( elem, "fxshow" ); | |
8942 for ( prop in orig ) { | |
8943 jQuery.style( elem, prop, orig[ prop ] ); | |
8944 } | |
8945 }); | |
8946 for ( index = 0 ; index < length ; index++ ) { | |
8947 prop = handled[ index ]; | |
8948 tween = anim.createTween( prop, hidden ? dataShow[ prop
] : 0 ); | |
8949 orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, p
rop ); | |
8950 | |
8951 if ( !( prop in dataShow ) ) { | |
8952 dataShow[ prop ] = tween.start; | |
8953 if ( hidden ) { | |
8954 tween.end = tween.start; | |
8955 tween.start = prop === "width" || prop =
== "height" ? 1 : 0; | |
8956 } | |
8957 } | |
8958 } | |
8959 } | |
8960 } | |
8961 | |
8962 function Tween( elem, options, prop, end, easing ) { | |
8963 return new Tween.prototype.init( elem, options, prop, end, easing ); | |
8964 } | |
8965 jQuery.Tween = Tween; | |
8966 | |
8967 Tween.prototype = { | |
8968 constructor: Tween, | |
8969 init: function( elem, options, prop, end, easing, unit ) { | |
8970 this.elem = elem; | |
8971 this.prop = prop; | |
8972 this.easing = easing || "swing"; | |
8973 this.options = options; | |
8974 this.start = this.now = this.cur(); | |
8975 this.end = end; | |
8976 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); | |
8977 }, | |
8978 cur: function() { | |
8979 var hooks = Tween.propHooks[ this.prop ]; | |
8980 | |
8981 return hooks && hooks.get ? | |
8982 hooks.get( this ) : | |
8983 Tween.propHooks._default.get( this ); | |
8984 }, | |
8985 run: function( percent ) { | |
8986 var eased, | |
8987 hooks = Tween.propHooks[ this.prop ]; | |
8988 | |
8989 if ( this.options.duration ) { | |
8990 this.pos = eased = jQuery.easing[ this.easing ]( | |
8991 percent, this.options.duration * percent, 0, 1,
this.options.duration | |
8992 ); | |
8993 } else { | |
8994 this.pos = eased = percent; | |
8995 } | |
8996 this.now = ( this.end - this.start ) * eased + this.start; | |
8997 | |
8998 if ( this.options.step ) { | |
8999 this.options.step.call( this.elem, this.now, this ); | |
9000 } | |
9001 | |
9002 if ( hooks && hooks.set ) { | |
9003 hooks.set( this ); | |
9004 } else { | |
9005 Tween.propHooks._default.set( this ); | |
9006 } | |
9007 return this; | |
9008 } | |
9009 }; | |
9010 | |
9011 Tween.prototype.init.prototype = Tween.prototype; | |
9012 | |
9013 Tween.propHooks = { | |
9014 _default: { | |
9015 get: function( tween ) { | |
9016 var result; | |
9017 | |
9018 if ( tween.elem[ tween.prop ] != null && | |
9019 (!tween.elem.style || tween.elem.style[ tween.pr
op ] == null) ) { | |
9020 return tween.elem[ tween.prop ]; | |
9021 } | |
9022 | |
9023 // passing a non empty string as a 3rd parameter to .css
will automatically | |
9024 // attempt a parseFloat and fallback to a string if the
parse fails | |
9025 // so, simple values such as "10px" are parsed to Float. | |
9026 // complex values such as "rotate(1rad)" are returned as
is. | |
9027 result = jQuery.css( tween.elem, tween.prop, "auto" ); | |
9028 // Empty strings, null, undefined and "auto" are convert
ed to 0. | |
9029 return !result || result === "auto" ? 0 : result; | |
9030 }, | |
9031 set: function( tween ) { | |
9032 // use step hook for back compat - use cssHook if its th
ere - use .style if its | |
9033 // available and use plain properties where available | |
9034 if ( jQuery.fx.step[ tween.prop ] ) { | |
9035 jQuery.fx.step[ tween.prop ]( tween ); | |
9036 } else if ( tween.elem.style && ( tween.elem.style[ jQue
ry.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { | |
9037 jQuery.style( tween.elem, tween.prop, tween.now
+ tween.unit ); | |
9038 } else { | |
9039 tween.elem[ tween.prop ] = tween.now; | |
9040 } | |
9041 } | |
9042 } | |
9043 }; | |
9044 | |
9045 // Remove in 2.0 - this supports IE8's panic based approach | |
9046 // to setting things on disconnected nodes | |
9047 | |
9048 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { | |
9049 set: function( tween ) { | |
9050 if ( tween.elem.nodeType && tween.elem.parentNode ) { | |
9051 tween.elem[ tween.prop ] = tween.now; | |
9052 } | |
9053 } | |
9054 }; | |
9055 | |
9056 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { | |
9057 var cssFn = jQuery.fn[ name ]; | |
9058 jQuery.fn[ name ] = function( speed, easing, callback ) { | |
9059 return speed == null || typeof speed === "boolean" ? | |
9060 cssFn.apply( this, arguments ) : | |
9061 this.animate( genFx( name, true ), speed, easing, callba
ck ); | |
9062 }; | |
9063 }); | |
9064 | |
9065 jQuery.fn.extend({ | |
9066 fadeTo: function( speed, to, easing, callback ) { | |
9067 | |
9068 // show any hidden elements after setting opacity to 0 | |
9069 return this.filter( isHidden ).css( "opacity", 0 ).show() | |
9070 | |
9071 // animate to the value specified | |
9072 .end().animate({ opacity: to }, speed, easing, callback
); | |
9073 }, | |
9074 animate: function( prop, speed, easing, callback ) { | |
9075 var empty = jQuery.isEmptyObject( prop ), | |
9076 optall = jQuery.speed( speed, easing, callback ), | |
9077 doAnimation = function() { | |
9078 // Operate on a copy of prop so per-property eas
ing won't be lost | |
9079 var anim = Animation( this, jQuery.extend( {}, p
rop ), optall ); | |
9080 doAnimation.finish = function() { | |
9081 anim.stop( true ); | |
9082 }; | |
9083 // Empty animations, or finishing resolves immed
iately | |
9084 if ( empty || jQuery._data( this, "finish" ) ) { | |
9085 anim.stop( true ); | |
9086 } | |
9087 }; | |
9088 doAnimation.finish = doAnimation; | |
9089 | |
9090 return empty || optall.queue === false ? | |
9091 this.each( doAnimation ) : | |
9092 this.queue( optall.queue, doAnimation ); | |
9093 }, | |
9094 stop: function( type, clearQueue, gotoEnd ) { | |
9095 var stopQueue = function( hooks ) { | |
9096 var stop = hooks.stop; | |
9097 delete hooks.stop; | |
9098 stop( gotoEnd ); | |
9099 }; | |
9100 | |
9101 if ( typeof type !== "string" ) { | |
9102 gotoEnd = clearQueue; | |
9103 clearQueue = type; | |
9104 type = undefined; | |
9105 } | |
9106 if ( clearQueue && type !== false ) { | |
9107 this.queue( type || "fx", [] ); | |
9108 } | |
9109 | |
9110 return this.each(function() { | |
9111 var dequeue = true, | |
9112 index = type != null && type + "queueHooks", | |
9113 timers = jQuery.timers, | |
9114 data = jQuery._data( this ); | |
9115 | |
9116 if ( index ) { | |
9117 if ( data[ index ] && data[ index ].stop ) { | |
9118 stopQueue( data[ index ] ); | |
9119 } | |
9120 } else { | |
9121 for ( index in data ) { | |
9122 if ( data[ index ] && data[ index ].stop
&& rrun.test( index ) ) { | |
9123 stopQueue( data[ index ] ); | |
9124 } | |
9125 } | |
9126 } | |
9127 | |
9128 for ( index = timers.length; index--; ) { | |
9129 if ( timers[ index ].elem === this && (type == n
ull || timers[ index ].queue === type) ) { | |
9130 timers[ index ].anim.stop( gotoEnd ); | |
9131 dequeue = false; | |
9132 timers.splice( index, 1 ); | |
9133 } | |
9134 } | |
9135 | |
9136 // start the next in the queue if the last step wasn't f
orced | |
9137 // timers currently will call their complete callbacks,
which will dequeue | |
9138 // but only if they were gotoEnd | |
9139 if ( dequeue || !gotoEnd ) { | |
9140 jQuery.dequeue( this, type ); | |
9141 } | |
9142 }); | |
9143 }, | |
9144 finish: function( type ) { | |
9145 if ( type !== false ) { | |
9146 type = type || "fx"; | |
9147 } | |
9148 return this.each(function() { | |
9149 var index, | |
9150 data = jQuery._data( this ), | |
9151 queue = data[ type + "queue" ], | |
9152 hooks = data[ type + "queueHooks" ], | |
9153 timers = jQuery.timers, | |
9154 length = queue ? queue.length : 0; | |
9155 | |
9156 // enable finishing flag on private data | |
9157 data.finish = true; | |
9158 | |
9159 // empty the queue first | |
9160 jQuery.queue( this, type, [] ); | |
9161 | |
9162 if ( hooks && hooks.cur && hooks.cur.finish ) { | |
9163 hooks.cur.finish.call( this ); | |
9164 } | |
9165 | |
9166 // look for any active animations, and finish them | |
9167 for ( index = timers.length; index--; ) { | |
9168 if ( timers[ index ].elem === this && timers[ in
dex ].queue === type ) { | |
9169 timers[ index ].anim.stop( true ); | |
9170 timers.splice( index, 1 ); | |
9171 } | |
9172 } | |
9173 | |
9174 // look for any animations in the old queue and finish t
hem | |
9175 for ( index = 0; index < length; index++ ) { | |
9176 if ( queue[ index ] && queue[ index ].finish ) { | |
9177 queue[ index ].finish.call( this ); | |
9178 } | |
9179 } | |
9180 | |
9181 // turn off finishing flag | |
9182 delete data.finish; | |
9183 }); | |
9184 } | |
9185 }); | |
9186 | |
9187 // Generate parameters to create a standard animation | |
9188 function genFx( type, includeWidth ) { | |
9189 var which, | |
9190 attrs = { height: type }, | |
9191 i = 0; | |
9192 | |
9193 // if we include width, step value is 1 to do all cssExpand values, | |
9194 // if we don't include width, step value is 2 to skip over Left and Righ
t | |
9195 includeWidth = includeWidth? 1 : 0; | |
9196 for( ; i < 4 ; i += 2 - includeWidth ) { | |
9197 which = cssExpand[ i ]; | |
9198 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; | |
9199 } | |
9200 | |
9201 if ( includeWidth ) { | |
9202 attrs.opacity = attrs.width = type; | |
9203 } | |
9204 | |
9205 return attrs; | |
9206 } | |
9207 | |
9208 // Generate shortcuts for custom animations | |
9209 jQuery.each({ | |
9210 slideDown: genFx("show"), | |
9211 slideUp: genFx("hide"), | |
9212 slideToggle: genFx("toggle"), | |
9213 fadeIn: { opacity: "show" }, | |
9214 fadeOut: { opacity: "hide" }, | |
9215 fadeToggle: { opacity: "toggle" } | |
9216 }, function( name, props ) { | |
9217 jQuery.fn[ name ] = function( speed, easing, callback ) { | |
9218 return this.animate( props, speed, easing, callback ); | |
9219 }; | |
9220 }); | |
9221 | |
9222 jQuery.speed = function( speed, easing, fn ) { | |
9223 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed
) : { | |
9224 complete: fn || !fn && easing || | |
9225 jQuery.isFunction( speed ) && speed, | |
9226 duration: speed, | |
9227 easing: fn && easing || easing && !jQuery.isFunction( easing ) &
& easing | |
9228 }; | |
9229 | |
9230 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? op
t.duration : | |
9231 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duratio
n ] : jQuery.fx.speeds._default; | |
9232 | |
9233 // normalize opt.queue - true/undefined/null -> "fx" | |
9234 if ( opt.queue == null || opt.queue === true ) { | |
9235 opt.queue = "fx"; | |
9236 } | |
9237 | |
9238 // Queueing | |
9239 opt.old = opt.complete; | |
9240 | |
9241 opt.complete = function() { | |
9242 if ( jQuery.isFunction( opt.old ) ) { | |
9243 opt.old.call( this ); | |
9244 } | |
9245 | |
9246 if ( opt.queue ) { | |
9247 jQuery.dequeue( this, opt.queue ); | |
9248 } | |
9249 }; | |
9250 | |
9251 return opt; | |
9252 }; | |
9253 | |
9254 jQuery.easing = { | |
9255 linear: function( p ) { | |
9256 return p; | |
9257 }, | |
9258 swing: function( p ) { | |
9259 return 0.5 - Math.cos( p*Math.PI ) / 2; | |
9260 } | |
9261 }; | |
9262 | |
9263 jQuery.timers = []; | |
9264 jQuery.fx = Tween.prototype.init; | |
9265 jQuery.fx.tick = function() { | |
9266 var timer, | |
9267 timers = jQuery.timers, | |
9268 i = 0; | |
9269 | |
9270 fxNow = jQuery.now(); | |
9271 | |
9272 for ( ; i < timers.length; i++ ) { | |
9273 timer = timers[ i ]; | |
9274 // Checks the timer has not already been removed | |
9275 if ( !timer() && timers[ i ] === timer ) { | |
9276 timers.splice( i--, 1 ); | |
9277 } | |
9278 } | |
9279 | |
9280 if ( !timers.length ) { | |
9281 jQuery.fx.stop(); | |
9282 } | |
9283 fxNow = undefined; | |
9284 }; | |
9285 | |
9286 jQuery.fx.timer = function( timer ) { | |
9287 if ( timer() && jQuery.timers.push( timer ) ) { | |
9288 jQuery.fx.start(); | |
9289 } | |
9290 }; | |
9291 | |
9292 jQuery.fx.interval = 13; | |
9293 | |
9294 jQuery.fx.start = function() { | |
9295 if ( !timerId ) { | |
9296 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); | |
9297 } | |
9298 }; | |
9299 | |
9300 jQuery.fx.stop = function() { | |
9301 clearInterval( timerId ); | |
9302 timerId = null; | |
9303 }; | |
9304 | |
9305 jQuery.fx.speeds = { | |
9306 slow: 600, | |
9307 fast: 200, | |
9308 // Default speed | |
9309 _default: 400 | |
9310 }; | |
9311 | |
9312 // Back Compat <1.8 extension point | |
9313 jQuery.fx.step = {}; | |
9314 | |
9315 if ( jQuery.expr && jQuery.expr.filters ) { | |
9316 jQuery.expr.filters.animated = function( elem ) { | |
9317 return jQuery.grep(jQuery.timers, function( fn ) { | |
9318 return elem === fn.elem; | |
9319 }).length; | |
9320 }; | |
9321 } | |
9322 jQuery.fn.offset = function( options ) { | |
9323 if ( arguments.length ) { | |
9324 return options === undefined ? | |
9325 this : | |
9326 this.each(function( i ) { | |
9327 jQuery.offset.setOffset( this, options, i ); | |
9328 }); | |
9329 } | |
9330 | |
9331 var docElem, win, | |
9332 box = { top: 0, left: 0 }, | |
9333 elem = this[ 0 ], | |
9334 doc = elem && elem.ownerDocument; | |
9335 | |
9336 if ( !doc ) { | |
9337 return; | |
9338 } | |
9339 | |
9340 docElem = doc.documentElement; | |
9341 | |
9342 // Make sure it's not a disconnected DOM node | |
9343 if ( !jQuery.contains( docElem, elem ) ) { | |
9344 return box; | |
9345 } | |
9346 | |
9347 // If we don't have gBCR, just use 0,0 rather than error | |
9348 // BlackBerry 5, iOS 3 (original iPhone) | |
9349 if ( typeof elem.getBoundingClientRect !== "undefined" ) { | |
9350 box = elem.getBoundingClientRect(); | |
9351 } | |
9352 win = getWindow( doc ); | |
9353 return { | |
9354 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( do
cElem.clientTop || 0 ), | |
9355 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( d
ocElem.clientLeft || 0 ) | |
9356 }; | |
9357 }; | |
9358 | |
9359 jQuery.offset = { | |
9360 | |
9361 setOffset: function( elem, options, i ) { | |
9362 var position = jQuery.css( elem, "position" ); | |
9363 | |
9364 // set position first, in-case top/left are set even on static e
lem | |
9365 if ( position === "static" ) { | |
9366 elem.style.position = "relative"; | |
9367 } | |
9368 | |
9369 var curElem = jQuery( elem ), | |
9370 curOffset = curElem.offset(), | |
9371 curCSSTop = jQuery.css( elem, "top" ), | |
9372 curCSSLeft = jQuery.css( elem, "left" ), | |
9373 calculatePosition = ( position === "absolute" || positio
n === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1, | |
9374 props = {}, curPosition = {}, curTop, curLeft; | |
9375 | |
9376 // need to be able to calculate position if either top or left i
s auto and position is either absolute or fixed | |
9377 if ( calculatePosition ) { | |
9378 curPosition = curElem.position(); | |
9379 curTop = curPosition.top; | |
9380 curLeft = curPosition.left; | |
9381 } else { | |
9382 curTop = parseFloat( curCSSTop ) || 0; | |
9383 curLeft = parseFloat( curCSSLeft ) || 0; | |
9384 } | |
9385 | |
9386 if ( jQuery.isFunction( options ) ) { | |
9387 options = options.call( elem, i, curOffset ); | |
9388 } | |
9389 | |
9390 if ( options.top != null ) { | |
9391 props.top = ( options.top - curOffset.top ) + curTop; | |
9392 } | |
9393 if ( options.left != null ) { | |
9394 props.left = ( options.left - curOffset.left ) + curLeft
; | |
9395 } | |
9396 | |
9397 if ( "using" in options ) { | |
9398 options.using.call( elem, props ); | |
9399 } else { | |
9400 curElem.css( props ); | |
9401 } | |
9402 } | |
9403 }; | |
9404 | |
9405 | |
9406 jQuery.fn.extend({ | |
9407 | |
9408 position: function() { | |
9409 if ( !this[ 0 ] ) { | |
9410 return; | |
9411 } | |
9412 | |
9413 var offsetParent, offset, | |
9414 parentOffset = { top: 0, left: 0 }, | |
9415 elem = this[ 0 ]; | |
9416 | |
9417 // fixed elements are offset from window (parentOffset = {top:0,
left: 0}, because it is it's only offset parent | |
9418 if ( jQuery.css( elem, "position" ) === "fixed" ) { | |
9419 // we assume that getBoundingClientRect is available whe
n computed position is fixed | |
9420 offset = elem.getBoundingClientRect(); | |
9421 } else { | |
9422 // Get *real* offsetParent | |
9423 offsetParent = this.offsetParent(); | |
9424 | |
9425 // Get correct offsets | |
9426 offset = this.offset(); | |
9427 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { | |
9428 parentOffset = offsetParent.offset(); | |
9429 } | |
9430 | |
9431 // Add offsetParent borders | |
9432 parentOffset.top += jQuery.css( offsetParent[ 0 ], "bor
derTopWidth", true ); | |
9433 parentOffset.left += jQuery.css( offsetParent[ 0 ], "bor
derLeftWidth", true ); | |
9434 } | |
9435 | |
9436 // Subtract parent offsets and element margins | |
9437 // note: when an element has margin: auto the offsetLeft and mar
ginLeft | |
9438 // are the same in Safari causing offset.left to incorrectly be
0 | |
9439 return { | |
9440 top: offset.top - parentOffset.top - jQuery.css( elem,
"marginTop", true ), | |
9441 left: offset.left - parentOffset.left - jQuery.css( elem
, "marginLeft", true) | |
9442 }; | |
9443 }, | |
9444 | |
9445 offsetParent: function() { | |
9446 return this.map(function() { | |
9447 var offsetParent = this.offsetParent || document.documen
tElement; | |
9448 while ( offsetParent && ( !jQuery.nodeName( offsetParent
, "html" ) && jQuery.css( offsetParent, "position") === "static" ) ) { | |
9449 offsetParent = offsetParent.offsetParent; | |
9450 } | |
9451 return offsetParent || document.documentElement; | |
9452 }); | |
9453 } | |
9454 }); | |
9455 | |
9456 | |
9457 // Create scrollLeft and scrollTop methods | |
9458 jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( me
thod, prop ) { | |
9459 var top = /Y/.test( prop ); | |
9460 | |
9461 jQuery.fn[ method ] = function( val ) { | |
9462 return jQuery.access( this, function( elem, method, val ) { | |
9463 var win = getWindow( elem ); | |
9464 | |
9465 if ( val === undefined ) { | |
9466 return win ? (prop in win) ? win[ prop ] : | |
9467 win.document.documentElement[ method ] : | |
9468 elem[ method ]; | |
9469 } | |
9470 | |
9471 if ( win ) { | |
9472 win.scrollTo( | |
9473 !top ? val : jQuery( win ).scrollLeft(), | |
9474 top ? val : jQuery( win ).scrollTop() | |
9475 ); | |
9476 | |
9477 } else { | |
9478 elem[ method ] = val; | |
9479 } | |
9480 }, method, val, arguments.length, null ); | |
9481 }; | |
9482 }); | |
9483 | |
9484 function getWindow( elem ) { | |
9485 return jQuery.isWindow( elem ) ? | |
9486 elem : | |
9487 elem.nodeType === 9 ? | |
9488 elem.defaultView || elem.parentWindow : | |
9489 false; | |
9490 } | |
9491 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth met
hods | |
9492 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { | |
9493 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + nam
e }, function( defaultExtra, funcName ) { | |
9494 // margin is only for outerHeight, outerWidth | |
9495 jQuery.fn[ funcName ] = function( margin, value ) { | |
9496 var chainable = arguments.length && ( defaultExtra || ty
peof margin !== "boolean" ), | |
9497 extra = defaultExtra || ( margin === true || val
ue === true ? "margin" : "border" ); | |
9498 | |
9499 return jQuery.access( this, function( elem, type, value
) { | |
9500 var doc; | |
9501 | |
9502 if ( jQuery.isWindow( elem ) ) { | |
9503 // As of 5/8/2012 this will yield incorr
ect results for Mobile Safari, but there | |
9504 // isn't a whole lot we can do. See pull
request at this URL for discussion: | |
9505 // https://github.com/jquery/jquery/pull
/764 | |
9506 return elem.document.documentElement[ "c
lient" + name ]; | |
9507 } | |
9508 | |
9509 // Get document width or height | |
9510 if ( elem.nodeType === 9 ) { | |
9511 doc = elem.documentElement; | |
9512 | |
9513 // Either scroll[Width/Height] or offset
[Width/Height] or client[Width/Height], whichever is greatest | |
9514 // unfortunately, this causes bug #3838
in IE6/8 only, but there is currently no good, small way to fix it. | |
9515 return Math.max( | |
9516 elem.body[ "scroll" + name ], do
c[ "scroll" + name ], | |
9517 elem.body[ "offset" + name ], do
c[ "offset" + name ], | |
9518 doc[ "client" + name ] | |
9519 ); | |
9520 } | |
9521 | |
9522 return value === undefined ? | |
9523 // Get width or height on the element, r
equesting but not forcing parseFloat | |
9524 jQuery.css( elem, type, extra ) : | |
9525 | |
9526 // Set width or height on the element | |
9527 jQuery.style( elem, type, value, extra )
; | |
9528 }, type, chainable ? margin : undefined, chainable, null
); | |
9529 }; | |
9530 }); | |
9531 }); | |
9532 // Limit scope pollution from any deprecated API | |
9533 // (function() { | |
9534 | |
9535 // })(); | |
9536 // Expose jQuery to the global object | |
9537 window.jQuery = window.$ = jQuery; | |
9538 | |
9539 // Expose jQuery as an AMD module, but only for AMD loaders that | |
9540 // understand the issues with loading multiple versions of jQuery | |
9541 // in a page that all might call define(). The loader will indicate | |
9542 // they have special allowances for multiple jQuery versions by | |
9543 // specifying define.amd.jQuery = true. Register as a named module, | |
9544 // since jQuery can be concatenated with other files that may use define, | |
9545 // but not use a proper concatenation script that understands anonymous | |
9546 // AMD modules. A named AMD is safest and most robust way to register. | |
9547 // Lowercase jquery is used because AMD module names are derived from | |
9548 // file names, and jQuery is normally delivered in a lowercase file name. | |
9549 // Do this after creating the global so that if an AMD module wants to call | |
9550 // noConflict to hide this version of jQuery, it will work. | |
9551 if ( typeof define === "function" && define.amd && define.amd.jQuery ) { | |
9552 define( "jquery", [], function () { return jQuery; } ); | |
9553 } | |
9554 | |
9555 })( window ); | |
OLD | NEW |