5a920362 |
1 | /*! |
2 | * jQuery JavaScript Library v1.8.2 |
3 | * http://jquery.com/ |
4 | * |
5 | * Includes Sizzle.js |
6 | * http://sizzlejs.com/ |
7 | * |
8 | * Copyright 2012 jQuery Foundation and other contributors |
9 | * Released under the MIT license |
10 | * http://jquery.org/license |
11 | * |
12 | * Date: Thu Sep 20 2012 21:13:05 GMT-0400 (Eastern Daylight Time) |
13 | */ |
14 | (function( window, undefined ) { |
15 | var |
16 | // A central reference to the root jQuery(document) |
17 | rootjQuery, |
18 | |
19 | // The deferred used on DOM ready |
20 | readyList, |
21 | |
22 | // Use the correct document accordingly with window argument (sandbox) |
23 | document = window.document, |
24 | location = window.location, |
25 | navigator = window.navigator, |
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 | // Save a reference to some core methods |
34 | core_push = Array.prototype.push, |
35 | core_slice = Array.prototype.slice, |
36 | core_indexOf = Array.prototype.indexOf, |
37 | core_toString = Object.prototype.toString, |
38 | core_hasOwn = Object.prototype.hasOwnProperty, |
39 | core_trim = String.prototype.trim, |
40 | |
41 | // Define a local copy of jQuery |
42 | jQuery = function( selector, context ) { |
43 | // The jQuery object is actually just the init constructor 'enhanced' |
44 | return new jQuery.fn.init( selector, context, rootjQuery ); |
45 | }, |
46 | |
47 | // Used for matching numbers |
48 | core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source, |
49 | |
50 | // Used for detecting and trimming whitespace |
51 | core_rnotwhite = /\S/, |
52 | core_rspace = /\s+/, |
53 | |
54 | // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) |
55 | rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, |
56 | |
57 | // A simple way to check for HTML strings |
58 | // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) |
59 | rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, |
60 | |
61 | // Match a standalone tag |
62 | rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, |
63 | |
64 | // JSON RegExp |
65 | rvalidchars = /^[\],:{}\s]*$/, |
66 | rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, |
67 | rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, |
68 | rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g, |
69 | |
70 | // Matches dashed string for camelizing |
71 | rmsPrefix = /^-ms-/, |
72 | rdashAlpha = /-([\da-z])/gi, |
73 | |
74 | // Used by jQuery.camelCase as callback to replace() |
75 | fcamelCase = function( all, letter ) { |
76 | return ( letter + "" ).toUpperCase(); |
77 | }, |
78 | |
79 | // The ready event handler and self cleanup method |
80 | DOMContentLoaded = function() { |
81 | if ( document.addEventListener ) { |
82 | document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
83 | jQuery.ready(); |
84 | } else if ( document.readyState === "complete" ) { |
85 | // we're here because readyState === "complete" in oldIE |
86 | // which is good enough for us to call the dom ready! |
87 | document.detachEvent( "onreadystatechange", DOMContentLoaded ); |
88 | jQuery.ready(); |
89 | } |
90 | }, |
91 | |
92 | // [[Class]] -> type pairs |
93 | class2type = {}; |
94 | |
95 | jQuery.fn = jQuery.prototype = { |
96 | constructor: jQuery, |
97 | init: function( selector, context, rootjQuery ) { |
98 | var match, elem, ret, doc; |
99 | |
100 | // Handle $(""), $(null), $(undefined), $(false) |
101 | if ( !selector ) { |
102 | return this; |
103 | } |
104 | |
105 | // Handle $(DOMElement) |
106 | if ( selector.nodeType ) { |
107 | this.context = this[0] = selector; |
108 | this.length = 1; |
109 | return this; |
110 | } |
111 | |
112 | // Handle HTML strings |
113 | if ( typeof selector === "string" ) { |
114 | if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { |
115 | // Assume that strings that start and end with <> are HTML and skip the regex check |
116 | match = [ null, selector, null ]; |
117 | |
118 | } else { |
119 | match = rquickExpr.exec( selector ); |
120 | } |
121 | |
122 | // Match html or make sure no context is specified for #id |
123 | if ( match && (match[1] || !context) ) { |
124 | |
125 | // HANDLE: $(html) -> $(array) |
126 | if ( match[1] ) { |
127 | context = context instanceof jQuery ? context[0] : context; |
128 | doc = ( context && context.nodeType ? context.ownerDocument || context : document ); |
129 | |
130 | // scripts is true for back-compat |
131 | selector = jQuery.parseHTML( match[1], doc, true ); |
132 | if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { |
133 | this.attr.call( selector, context, true ); |
134 | } |
135 | |
136 | return jQuery.merge( this, selector ); |
137 | |
138 | // HANDLE: $(#id) |
139 | } else { |
140 | elem = document.getElementById( match[2] ); |
141 | |
142 | // Check parentNode to catch when Blackberry 4.6 returns |
143 | // nodes that are no longer in the document #6963 |
144 | if ( elem && elem.parentNode ) { |
145 | // Handle the case where IE and Opera return items |
146 | // by name instead of ID |
147 | if ( elem.id !== match[2] ) { |
148 | return rootjQuery.find( selector ); |
149 | } |
150 | |
151 | // Otherwise, we inject the element directly into the jQuery object |
152 | this.length = 1; |
153 | this[0] = elem; |
154 | } |
155 | |
156 | this.context = document; |
157 | this.selector = selector; |
158 | return this; |
159 | } |
160 | |
161 | // HANDLE: $(expr, $(...)) |
162 | } else if ( !context || context.jquery ) { |
163 | return ( context || rootjQuery ).find( selector ); |
164 | |
165 | // HANDLE: $(expr, context) |
166 | // (which is just equivalent to: $(context).find(expr) |
167 | } else { |
168 | return this.constructor( context ).find( selector ); |
169 | } |
170 | |
171 | // HANDLE: $(function) |
172 | // Shortcut for document ready |
173 | } else if ( jQuery.isFunction( selector ) ) { |
174 | return rootjQuery.ready( selector ); |
175 | } |
176 | |
177 | if ( selector.selector !== undefined ) { |
178 | this.selector = selector.selector; |
179 | this.context = selector.context; |
180 | } |
181 | |
182 | return jQuery.makeArray( selector, this ); |
183 | }, |
184 | |
185 | // Start with an empty selector |
186 | selector: "", |
187 | |
188 | // The current version of jQuery being used |
189 | jquery: "1.8.2", |
190 | |
191 | // The default length of a jQuery object is 0 |
192 | length: 0, |
193 | |
194 | // The number of elements contained in the matched element set |
195 | size: function() { |
196 | return this.length; |
197 | }, |
198 | |
199 | toArray: function() { |
200 | return core_slice.call( this ); |
201 | }, |
202 | |
203 | // Get the Nth element in the matched element set OR |
204 | // Get the whole matched element set as a clean array |
205 | get: function( num ) { |
206 | return num == null ? |
207 | |
208 | // Return a 'clean' array |
209 | this.toArray() : |
210 | |
211 | // Return just the object |
212 | ( num < 0 ? this[ this.length + num ] : this[ num ] ); |
213 | }, |
214 | |
215 | // Take an array of elements and push it onto the stack |
216 | // (returning the new matched element set) |
217 | pushStack: function( elems, name, selector ) { |
218 | |
219 | // Build a new jQuery matched element set |
220 | var ret = jQuery.merge( this.constructor(), elems ); |
221 | |
222 | // Add the old object onto the stack (as a reference) |
223 | ret.prevObject = this; |
224 | |
225 | ret.context = this.context; |
226 | |
227 | if ( name === "find" ) { |
228 | ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; |
229 | } else if ( name ) { |
230 | ret.selector = this.selector + "." + name + "(" + selector + ")"; |
231 | } |
232 | |
233 | // Return the newly-formed element set |
234 | return ret; |
235 | }, |
236 | |
237 | // Execute a callback for every element in the matched set. |
238 | // (You can seed the arguments with an array of args, but this is |
239 | // only used internally.) |
240 | each: function( callback, args ) { |
241 | return jQuery.each( this, callback, args ); |
242 | }, |
243 | |
244 | ready: function( fn ) { |
245 | // Add the callback |
246 | jQuery.ready.promise().done( fn ); |
247 | |
248 | return this; |
249 | }, |
250 | |
251 | eq: function( i ) { |
252 | i = +i; |
253 | return i === -1 ? |
254 | this.slice( i ) : |
255 | this.slice( i, i + 1 ); |
256 | }, |
257 | |
258 | first: function() { |
259 | return this.eq( 0 ); |
260 | }, |
261 | |
262 | last: function() { |
263 | return this.eq( -1 ); |
264 | }, |
265 | |
266 | slice: function() { |
267 | return this.pushStack( core_slice.apply( this, arguments ), |
268 | "slice", core_slice.call(arguments).join(",") ); |
269 | }, |
270 | |
271 | map: function( callback ) { |
272 | return this.pushStack( jQuery.map(this, function( elem, i ) { |
273 | return callback.call( elem, i, elem ); |
274 | })); |
275 | }, |
276 | |
277 | end: function() { |
278 | return this.prevObject || this.constructor(null); |
279 | }, |
280 | |
281 | // For internal use only. |
282 | // Behaves like an Array's method, not like a jQuery method. |
283 | push: core_push, |
284 | sort: [].sort, |
285 | splice: [].splice |
286 | }; |
287 | |
288 | // Give the init function the jQuery prototype for later instantiation |
289 | jQuery.fn.init.prototype = jQuery.fn; |
290 | |
291 | jQuery.extend = jQuery.fn.extend = function() { |
292 | var options, name, src, copy, copyIsArray, clone, |
293 | target = arguments[0] || {}, |
294 | i = 1, |
295 | length = arguments.length, |
296 | deep = false; |
297 | |
298 | // Handle a deep copy situation |
299 | if ( typeof target === "boolean" ) { |
300 | deep = target; |
301 | target = arguments[1] || {}; |
302 | // skip the boolean and the target |
303 | i = 2; |
304 | } |
305 | |
306 | // Handle case when target is a string or something (possible in deep copy) |
307 | if ( typeof target !== "object" && !jQuery.isFunction(target) ) { |
308 | target = {}; |
309 | } |
310 | |
311 | // extend jQuery itself if only one argument is passed |
312 | if ( length === i ) { |
313 | target = this; |
314 | --i; |
315 | } |
316 | |
317 | for ( ; i < length; i++ ) { |
318 | // Only deal with non-null/undefined values |
319 | if ( (options = arguments[ i ]) != null ) { |
320 | // Extend the base object |
321 | for ( name in options ) { |
322 | src = target[ name ]; |
323 | copy = options[ name ]; |
324 | |
325 | // Prevent never-ending loop |
326 | if ( target === copy ) { |
327 | continue; |
328 | } |
329 | |
330 | // Recurse if we're merging plain objects or arrays |
331 | if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { |
332 | if ( copyIsArray ) { |
333 | copyIsArray = false; |
334 | clone = src && jQuery.isArray(src) ? src : []; |
335 | |
336 | } else { |
337 | clone = src && jQuery.isPlainObject(src) ? src : {}; |
338 | } |
339 | |
340 | // Never move original objects, clone them |
341 | target[ name ] = jQuery.extend( deep, clone, copy ); |
342 | |
343 | // Don't bring in undefined values |
344 | } else if ( copy !== undefined ) { |
345 | target[ name ] = copy; |
346 | } |
347 | } |
348 | } |
349 | } |
350 | |
351 | // Return the modified object |
352 | return target; |
353 | }; |
354 | |
355 | jQuery.extend({ |
356 | noConflict: function( deep ) { |
357 | if ( window.$ === jQuery ) { |
358 | window.$ = _$; |
359 | } |
360 | |
361 | if ( deep && window.jQuery === jQuery ) { |
362 | window.jQuery = _jQuery; |
363 | } |
364 | |
365 | return jQuery; |
366 | }, |
367 | |
368 | // Is the DOM ready to be used? Set to true once it occurs. |
369 | isReady: false, |
370 | |
371 | // A counter to track how many items to wait for before |
372 | // the ready event fires. See #6781 |
373 | readyWait: 1, |
374 | |
375 | // Hold (or release) the ready event |
376 | holdReady: function( hold ) { |
377 | if ( hold ) { |
378 | jQuery.readyWait++; |
379 | } else { |
380 | jQuery.ready( true ); |
381 | } |
382 | }, |
383 | |
384 | // Handle when the DOM is ready |
385 | ready: function( wait ) { |
386 | |
387 | // Abort if there are pending holds or we're already ready |
388 | if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { |
389 | return; |
390 | } |
391 | |
392 | // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). |
393 | if ( !document.body ) { |
394 | return setTimeout( jQuery.ready, 1 ); |
395 | } |
396 | |
397 | // Remember that the DOM is ready |
398 | jQuery.isReady = true; |
399 | |
400 | // If a normal DOM Ready event fired, decrement, and wait if need be |
401 | if ( wait !== true && --jQuery.readyWait > 0 ) { |
402 | return; |
403 | } |
404 | |
405 | // If there are functions bound, to execute |
406 | readyList.resolveWith( document, [ jQuery ] ); |
407 | |
408 | // Trigger any bound ready events |
409 | if ( jQuery.fn.trigger ) { |
410 | jQuery( document ).trigger("ready").off("ready"); |
411 | } |
412 | }, |
413 | |
414 | // See test/unit/core.js for details concerning isFunction. |
415 | // Since version 1.3, DOM methods and functions like alert |
416 | // aren't supported. They return false on IE (#2968). |
417 | isFunction: function( obj ) { |
418 | return jQuery.type(obj) === "function"; |
419 | }, |
420 | |
421 | isArray: Array.isArray || function( obj ) { |
422 | return jQuery.type(obj) === "array"; |
423 | }, |
424 | |
425 | isWindow: function( obj ) { |
426 | return obj != null && obj == obj.window; |
427 | }, |
428 | |
429 | isNumeric: function( obj ) { |
430 | return !isNaN( parseFloat(obj) ) && isFinite( obj ); |
431 | }, |
432 | |
433 | type: function( obj ) { |
434 | return obj == null ? |
435 | String( obj ) : |
436 | class2type[ core_toString.call(obj) ] || "object"; |
437 | }, |
438 | |
439 | isPlainObject: function( obj ) { |
440 | // Must be an Object. |
441 | // Because of IE, we also have to check the presence of the constructor property. |
442 | // Make sure that DOM nodes and window objects don't pass through, as well |
443 | if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { |
444 | return false; |
445 | } |
446 | |
447 | try { |
448 | // Not own constructor property must be Object |
449 | if ( obj.constructor && |
450 | !core_hasOwn.call(obj, "constructor") && |
451 | !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { |
452 | return false; |
453 | } |
454 | } catch ( e ) { |
455 | // IE8,9 Will throw exceptions on certain host objects #9897 |
456 | return false; |
457 | } |
458 | |
459 | // Own properties are enumerated firstly, so to speed up, |
460 | // if last one is own, then all properties are own. |
461 | |
462 | var key; |
463 | for ( key in obj ) {} |
464 | |
465 | return key === undefined || core_hasOwn.call( obj, key ); |
466 | }, |
467 | |
468 | isEmptyObject: function( obj ) { |
469 | var name; |
470 | for ( name in obj ) { |
471 | return false; |
472 | } |
473 | return true; |
474 | }, |
475 | |
476 | error: function( msg ) { |
477 | throw new Error( msg ); |
478 | }, |
479 | |
480 | // data: string of html |
481 | // context (optional): If specified, the fragment will be created in this context, defaults to document |
482 | // scripts (optional): If true, will include scripts passed in the html string |
483 | parseHTML: function( data, context, scripts ) { |
484 | var parsed; |
485 | if ( !data || typeof data !== "string" ) { |
486 | return null; |
487 | } |
488 | if ( typeof context === "boolean" ) { |
489 | scripts = context; |
490 | context = 0; |
491 | } |
492 | context = context || document; |
493 | |
494 | // Single tag |
495 | if ( (parsed = rsingleTag.exec( data )) ) { |
496 | return [ context.createElement( parsed[1] ) ]; |
497 | } |
498 | |
499 | parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] ); |
500 | return jQuery.merge( [], |
501 | (parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes ); |
502 | }, |
503 | |
504 | parseJSON: function( data ) { |
505 | if ( !data || typeof data !== "string") { |
506 | return null; |
507 | } |
508 | |
509 | // Make sure leading/trailing whitespace is removed (IE can't handle it) |
510 | data = jQuery.trim( data ); |
511 | |
512 | // Attempt to parse using the native JSON parser first |
513 | if ( window.JSON && window.JSON.parse ) { |
514 | return window.JSON.parse( data ); |
515 | } |
516 | |
517 | // Make sure the incoming data is actual JSON |
518 | // Logic borrowed from http://json.org/json2.js |
519 | if ( rvalidchars.test( data.replace( rvalidescape, "@" ) |
520 | .replace( rvalidtokens, "]" ) |
521 | .replace( rvalidbraces, "")) ) { |
522 | |
523 | return ( new Function( "return " + data ) )(); |
524 | |
525 | } |
526 | jQuery.error( "Invalid JSON: " + data ); |
527 | }, |
528 | |
529 | // Cross-browser xml parsing |
530 | parseXML: function( data ) { |
531 | var xml, tmp; |
532 | if ( !data || typeof data !== "string" ) { |
533 | return null; |
534 | } |
535 | try { |
536 | if ( window.DOMParser ) { // Standard |
537 | tmp = new DOMParser(); |
538 | xml = tmp.parseFromString( data , "text/xml" ); |
539 | } else { // IE |
540 | xml = new ActiveXObject( "Microsoft.XMLDOM" ); |
541 | xml.async = "false"; |
542 | xml.loadXML( data ); |
543 | } |
544 | } catch( e ) { |
545 | xml = undefined; |
546 | } |
547 | if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { |
548 | jQuery.error( "Invalid XML: " + data ); |
549 | } |
550 | return xml; |
551 | }, |
552 | |
553 | noop: function() {}, |
554 | |
555 | // Evaluates a script in a global context |
556 | // Workarounds based on findings by Jim Driscoll |
557 | // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context |
558 | globalEval: function( data ) { |
559 | if ( data && core_rnotwhite.test( data ) ) { |
560 | // We use execScript on Internet Explorer |
561 | // We use an anonymous function so that context is window |
562 | // rather than jQuery in Firefox |
563 | ( window.execScript || function( data ) { |
564 | window[ "eval" ].call( window, data ); |
565 | } )( data ); |
566 | } |
567 | }, |
568 | |
569 | // Convert dashed to camelCase; used by the css and data modules |
570 | // Microsoft forgot to hump their vendor prefix (#9572) |
571 | camelCase: function( string ) { |
572 | return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); |
573 | }, |
574 | |
575 | nodeName: function( elem, name ) { |
576 | return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); |
577 | }, |
578 | |
579 | // args is for internal usage only |
580 | each: function( obj, callback, args ) { |
581 | var name, |
582 | i = 0, |
583 | length = obj.length, |
584 | isObj = length === undefined || jQuery.isFunction( obj ); |
585 | |
586 | if ( args ) { |
587 | if ( isObj ) { |
588 | for ( name in obj ) { |
589 | if ( callback.apply( obj[ name ], args ) === false ) { |
590 | break; |
591 | } |
592 | } |
593 | } else { |
594 | for ( ; i < length; ) { |
595 | if ( callback.apply( obj[ i++ ], args ) === false ) { |
596 | break; |
597 | } |
598 | } |
599 | } |
600 | |
601 | // A special, fast, case for the most common use of each |
602 | } else { |
603 | if ( isObj ) { |
604 | for ( name in obj ) { |
605 | if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) { |
606 | break; |
607 | } |
608 | } |
609 | } else { |
610 | for ( ; i < length; ) { |
611 | if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) { |
612 | break; |
613 | } |
614 | } |
615 | } |
616 | } |
617 | |
618 | return obj; |
619 | }, |
620 | |
621 | // Use native String.trim function wherever possible |
622 | trim: core_trim && !core_trim.call("\uFEFF\xA0") ? |
623 | function( text ) { |
624 | return text == null ? |
625 | "" : |
626 | core_trim.call( text ); |
627 | } : |
628 | |
629 | // Otherwise use our own trimming functionality |
630 | function( text ) { |
631 | return text == null ? |
632 | "" : |
633 | ( text + "" ).replace( rtrim, "" ); |
634 | }, |
635 | |
636 | // results is for internal usage only |
637 | makeArray: function( arr, results ) { |
638 | var type, |
639 | ret = results || []; |
640 | |
641 | if ( arr != null ) { |
642 | // The window, strings (and functions) also have 'length' |
643 | // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 |
644 | type = jQuery.type( arr ); |
645 | |
646 | if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) { |
647 | core_push.call( ret, arr ); |
648 | } else { |
649 | jQuery.merge( ret, arr ); |
650 | } |
651 | } |
652 | |
653 | return ret; |
654 | }, |
655 | |
656 | inArray: function( elem, arr, i ) { |
657 | var len; |
658 | |
659 | if ( arr ) { |
660 | if ( core_indexOf ) { |
661 | return core_indexOf.call( arr, elem, i ); |
662 | } |
663 | |
664 | len = arr.length; |
665 | i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; |
666 | |
667 | for ( ; i < len; i++ ) { |
668 | // Skip accessing in sparse arrays |
669 | if ( i in arr && arr[ i ] === elem ) { |
670 | return i; |
671 | } |
672 | } |
673 | } |
674 | |
675 | return -1; |
676 | }, |
677 | |
678 | merge: function( first, second ) { |
679 | var l = second.length, |
680 | i = first.length, |
681 | j = 0; |
682 | |
683 | if ( typeof l === "number" ) { |
684 | for ( ; j < l; j++ ) { |
685 | first[ i++ ] = second[ j ]; |
686 | } |
687 | |
688 | } else { |
689 | while ( second[j] !== undefined ) { |
690 | first[ i++ ] = second[ j++ ]; |
691 | } |
692 | } |
693 | |
694 | first.length = i; |
695 | |
696 | return first; |
697 | }, |
698 | |
699 | grep: function( elems, callback, inv ) { |
700 | var retVal, |
701 | ret = [], |
702 | i = 0, |
703 | length = elems.length; |
704 | inv = !!inv; |
705 | |
706 | // Go through the array, only saving the items |
707 | // that pass the validator function |
708 | for ( ; i < length; i++ ) { |
709 | retVal = !!callback( elems[ i ], i ); |
710 | if ( inv !== retVal ) { |
711 | ret.push( elems[ i ] ); |
712 | } |
713 | } |
714 | |
715 | return ret; |
716 | }, |
717 | |
718 | // arg is for internal usage only |
719 | map: function( elems, callback, arg ) { |
720 | var value, key, |
721 | ret = [], |
722 | i = 0, |
723 | length = elems.length, |
724 | // jquery objects are treated as arrays |
725 | isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; |
726 | |
727 | // Go through the array, translating each of the items to their |
728 | if ( isArray ) { |
729 | for ( ; i < length; i++ ) { |
730 | value = callback( elems[ i ], i, arg ); |
731 | |
732 | if ( value != null ) { |
733 | ret[ ret.length ] = value; |
734 | } |
735 | } |
736 | |
737 | // Go through every key on the object, |
738 | } else { |
739 | for ( key in elems ) { |
740 | value = callback( elems[ key ], key, arg ); |
741 | |
742 | if ( value != null ) { |
743 | ret[ ret.length ] = value; |
744 | } |
745 | } |
746 | } |
747 | |
748 | // Flatten any nested arrays |
749 | return ret.concat.apply( [], ret ); |
750 | }, |
751 | |
752 | // A global GUID counter for objects |
753 | guid: 1, |
754 | |
755 | // Bind a function to a context, optionally partially applying any |
756 | // arguments. |
757 | proxy: function( fn, context ) { |
758 | var tmp, args, proxy; |
759 | |
760 | if ( typeof context === "string" ) { |
761 | tmp = fn[ context ]; |
762 | context = fn; |
763 | fn = tmp; |
764 | } |
765 | |
766 | // Quick check to determine if target is callable, in the spec |
767 | // this throws a TypeError, but we will just return undefined. |
768 | if ( !jQuery.isFunction( fn ) ) { |
769 | return undefined; |
770 | } |
771 | |
772 | // Simulated bind |
773 | args = core_slice.call( arguments, 2 ); |
774 | proxy = function() { |
775 | return fn.apply( context, args.concat( core_slice.call( arguments ) ) ); |
776 | }; |
777 | |
778 | // Set the guid of unique handler to the same of original handler, so it can be removed |
779 | proxy.guid = fn.guid = fn.guid || jQuery.guid++; |
780 | |
781 | return proxy; |
782 | }, |
783 | |
784 | // Multifunctional method to get and set values of a collection |
785 | // The value/s can optionally be executed if it's a function |
786 | access: function( elems, fn, key, value, chainable, emptyGet, pass ) { |
787 | var exec, |
788 | bulk = key == null, |
789 | i = 0, |
790 | length = elems.length; |
791 | |
792 | // Sets many values |
793 | if ( key && typeof key === "object" ) { |
794 | for ( i in key ) { |
795 | jQuery.access( elems, fn, i, key[i], 1, emptyGet, value ); |
796 | } |
797 | chainable = 1; |
798 | |
799 | // Sets one value |
800 | } else if ( value !== undefined ) { |
801 | // Optionally, function values get executed if exec is true |
802 | exec = pass === undefined && jQuery.isFunction( value ); |
803 | |
804 | if ( bulk ) { |
805 | // Bulk operations only iterate when executing function values |
806 | if ( exec ) { |
807 | exec = fn; |
808 | fn = function( elem, key, value ) { |
809 | return exec.call( jQuery( elem ), value ); |
810 | }; |
811 | |
812 | // Otherwise they run against the entire set |
813 | } else { |
814 | fn.call( elems, value ); |
815 | fn = null; |
816 | } |
817 | } |
818 | |
819 | if ( fn ) { |
820 | for (; i < length; i++ ) { |
821 | fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); |
822 | } |
823 | } |
824 | |
825 | chainable = 1; |
826 | } |
827 | |
828 | return chainable ? |
829 | elems : |
830 | |
831 | // Gets |
832 | bulk ? |
833 | fn.call( elems ) : |
834 | length ? fn( elems[0], key ) : emptyGet; |
835 | }, |
836 | |
837 | now: function() { |
838 | return ( new Date() ).getTime(); |
839 | } |
840 | }); |
841 | |
842 | jQuery.ready.promise = function( obj ) { |
843 | if ( !readyList ) { |
844 | |
845 | readyList = jQuery.Deferred(); |
846 | |
847 | // Catch cases where $(document).ready() is called after the browser event has already occurred. |
848 | // we once tried to use readyState "interactive" here, but it caused issues like the one |
849 | // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 |
850 | if ( document.readyState === "complete" ) { |
851 | // Handle it asynchronously to allow scripts the opportunity to delay ready |
852 | setTimeout( jQuery.ready, 1 ); |
853 | |
854 | // Standards-based browsers support DOMContentLoaded |
855 | } else if ( document.addEventListener ) { |
856 | // Use the handy event callback |
857 | document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
858 | |
859 | // A fallback to window.onload, that will always work |
860 | window.addEventListener( "load", jQuery.ready, false ); |
861 | |
862 | // If IE event model is used |
863 | } else { |
864 | // Ensure firing before onload, maybe late but safe also for iframes |
865 | document.attachEvent( "onreadystatechange", DOMContentLoaded ); |
866 | |
867 | // A fallback to window.onload, that will always work |
868 | window.attachEvent( "onload", jQuery.ready ); |
869 | |
870 | // If IE and not a frame |
871 | // continually check to see if the document is ready |
872 | var top = false; |
873 | |
874 | try { |
875 | top = window.frameElement == null && document.documentElement; |
876 | } catch(e) {} |
877 | |
878 | if ( top && top.doScroll ) { |
879 | (function doScrollCheck() { |
880 | if ( !jQuery.isReady ) { |
881 | |
882 | try { |
883 | // Use the trick by Diego Perini |
884 | // http://javascript.nwbox.com/IEContentLoaded/ |
885 | top.doScroll("left"); |
886 | } catch(e) { |
887 | return setTimeout( doScrollCheck, 50 ); |
888 | } |
889 | |
890 | // and execute any waiting functions |
891 | jQuery.ready(); |
892 | } |
893 | })(); |
894 | } |
895 | } |
896 | } |
897 | return readyList.promise( obj ); |
898 | }; |
899 | |
900 | // Populate the class2type map |
901 | jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { |
902 | class2type[ "[object " + name + "]" ] = name.toLowerCase(); |
903 | }); |
904 | |
905 | // All jQuery objects should point back to these |
906 | rootjQuery = jQuery(document); |
907 | // String to Object options format cache |
908 | var optionsCache = {}; |
909 | |
910 | // Convert String-formatted options into Object-formatted ones and store in cache |
911 | function createOptions( options ) { |
912 | var object = optionsCache[ options ] = {}; |
913 | jQuery.each( options.split( core_rspace ), function( _, flag ) { |
914 | object[ flag ] = true; |
915 | }); |
916 | return object; |
917 | } |
918 | |
919 | /* |
920 | * Create a callback list using the following parameters: |
921 | * |
922 | * options: an optional list of space-separated options that will change how |
923 | * the callback list behaves or a more traditional option object |
924 | * |
925 | * By default a callback list will act like an event callback list and can be |
926 | * "fired" multiple times. |
927 | * |
928 | * Possible options: |
929 | * |
930 | * once: will ensure the callback list can only be fired once (like a Deferred) |
931 | * |
932 | * memory: will keep track of previous values and will call any callback added |
933 | * after the list has been fired right away with the latest "memorized" |
934 | * values (like a Deferred) |
935 | * |
936 | * unique: will ensure a callback can only be added once (no duplicate in the list) |
937 | * |
938 | * stopOnFalse: interrupt callings when a callback returns false |
939 | * |
940 | */ |
941 | jQuery.Callbacks = function( options ) { |
942 | |
943 | // Convert options from String-formatted to Object-formatted if needed |
944 | // (we check in cache first) |
945 | options = typeof options === "string" ? |
946 | ( optionsCache[ options ] || createOptions( options ) ) : |
947 | jQuery.extend( {}, options ); |
948 | |
949 | var // Last fire value (for non-forgettable lists) |
950 | memory, |
951 | // Flag to know if list was already fired |
952 | fired, |
953 | // Flag to know if list is currently firing |
954 | firing, |
955 | // First callback to fire (used internally by add and fireWith) |
956 | firingStart, |
957 | // End of the loop when firing |
958 | firingLength, |
959 | // Index of currently firing callback (modified by remove if needed) |
960 | firingIndex, |
961 | // Actual callback list |
962 | list = [], |
963 | // Stack of fire calls for repeatable lists |
964 | stack = !options.once && [], |
965 | // Fire callbacks |
966 | fire = function( data ) { |
967 | memory = options.memory && data; |
968 | fired = true; |
969 | firingIndex = firingStart || 0; |
970 | firingStart = 0; |
971 | firingLength = list.length; |
972 | firing = true; |
973 | for ( ; list && firingIndex < firingLength; firingIndex++ ) { |
974 | if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { |
975 | memory = false; // To prevent further calls using add |
976 | break; |
977 | } |
978 | } |
979 | firing = false; |
980 | if ( list ) { |
981 | if ( stack ) { |
982 | if ( stack.length ) { |
983 | fire( stack.shift() ); |
984 | } |
985 | } else if ( memory ) { |
986 | list = []; |
987 | } else { |
988 | self.disable(); |
989 | } |
990 | } |
991 | }, |
992 | // Actual Callbacks object |
993 | self = { |
994 | // Add a callback or a collection of callbacks to the list |
995 | add: function() { |
996 | if ( list ) { |
997 | // First, we save the current length |
998 | var start = list.length; |
999 | (function add( args ) { |
1000 | jQuery.each( args, function( _, arg ) { |
1001 | var type = jQuery.type( arg ); |
1002 | if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) { |
1003 | list.push( arg ); |
1004 | } else if ( arg && arg.length && type !== "string" ) { |
1005 | // Inspect recursively |
1006 | add( arg ); |
1007 | } |
1008 | }); |
1009 | })( arguments ); |
1010 | // Do we need to add the callbacks to the |
1011 | // current firing batch? |
1012 | if ( firing ) { |
1013 | firingLength = list.length; |
1014 | // With memory, if we're not firing then |
1015 | // we should call right away |
1016 | } else if ( memory ) { |
1017 | firingStart = start; |
1018 | fire( memory ); |
1019 | } |
1020 | } |
1021 | return this; |
1022 | }, |
1023 | // Remove a callback from the list |
1024 | remove: function() { |
1025 | if ( list ) { |
1026 | jQuery.each( arguments, function( _, arg ) { |
1027 | var index; |
1028 | while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { |
1029 | list.splice( index, 1 ); |
1030 | // Handle firing indexes |
1031 | if ( firing ) { |
1032 | if ( index <= firingLength ) { |
1033 | firingLength--; |
1034 | } |
1035 | if ( index <= firingIndex ) { |
1036 | firingIndex--; |
1037 | } |
1038 | } |
1039 | } |
1040 | }); |
1041 | } |
1042 | return this; |
1043 | }, |
1044 | // Control if a given callback is in the list |
1045 | has: function( fn ) { |
1046 | return jQuery.inArray( fn, list ) > -1; |
1047 | }, |
1048 | // Remove all callbacks from the list |
1049 | empty: function() { |
1050 | list = []; |
1051 | return this; |
1052 | }, |
1053 | // Have the list do nothing anymore |
1054 | disable: function() { |
1055 | list = stack = memory = undefined; |
1056 | return this; |
1057 | }, |
1058 | // Is it disabled? |
1059 | disabled: function() { |
1060 | return !list; |
1061 | }, |
1062 | // Lock the list in its current state |
1063 | lock: function() { |
1064 | stack = undefined; |
1065 | if ( !memory ) { |
1066 | self.disable(); |
1067 | } |
1068 | return this; |
1069 | }, |
1070 | // Is it locked? |
1071 | locked: function() { |
1072 | return !stack; |
1073 | }, |
1074 | // Call all callbacks with the given context and arguments |
1075 | fireWith: function( context, args ) { |
1076 | args = args || []; |
1077 | args = [ context, args.slice ? args.slice() : args ]; |
1078 | if ( list && ( !fired || stack ) ) { |
1079 | if ( firing ) { |
1080 | stack.push( args ); |
1081 | } else { |
1082 | fire( args ); |
1083 | } |
1084 | } |
1085 | return this; |
1086 | }, |
1087 | // Call all the callbacks with the given arguments |
1088 | fire: function() { |
1089 | self.fireWith( this, arguments ); |
1090 | return this; |
1091 | }, |
1092 | // To know if the callbacks have already been called at least once |
1093 | fired: function() { |
1094 | return !!fired; |
1095 | } |
1096 | }; |
1097 | |
1098 | return self; |
1099 | }; |
1100 | jQuery.extend({ |
1101 | |
1102 | Deferred: function( func ) { |
1103 | var tuples = [ |
1104 | // action, add listener, listener list, final state |
1105 | [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], |
1106 | [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], |
1107 | [ "notify", "progress", jQuery.Callbacks("memory") ] |
1108 | ], |
1109 | state = "pending", |
1110 | promise = { |
1111 | state: function() { |
1112 | return state; |
1113 | }, |
1114 | always: function() { |
1115 | deferred.done( arguments ).fail( arguments ); |
1116 | return this; |
1117 | }, |
1118 | then: function( /* fnDone, fnFail, fnProgress */ ) { |
1119 | var fns = arguments; |
1120 | return jQuery.Deferred(function( newDefer ) { |
1121 | jQuery.each( tuples, function( i, tuple ) { |
1122 | var action = tuple[ 0 ], |
1123 | fn = fns[ i ]; |
1124 | // deferred[ done | fail | progress ] for forwarding actions to newDefer |
1125 | deferred[ tuple[1] ]( jQuery.isFunction( fn ) ? |
1126 | function() { |
1127 | var returned = fn.apply( this, arguments ); |
1128 | if ( returned && jQuery.isFunction( returned.promise ) ) { |
1129 | returned.promise() |
1130 | .done( newDefer.resolve ) |
1131 | .fail( newDefer.reject ) |
1132 | .progress( newDefer.notify ); |
1133 | } else { |
1134 | newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); |
1135 | } |
1136 | } : |
1137 | newDefer[ action ] |
1138 | ); |
1139 | }); |
1140 | fns = null; |
1141 | }).promise(); |
1142 | }, |
1143 | // Get a promise for this deferred |
1144 | // If obj is provided, the promise aspect is added to the object |
1145 | promise: function( obj ) { |
1146 | return obj != null ? jQuery.extend( obj, promise ) : promise; |
1147 | } |
1148 | }, |
1149 | deferred = {}; |
1150 | |
1151 | // Keep pipe for back-compat |
1152 | promise.pipe = promise.then; |
1153 | |
1154 | // Add list-specific methods |
1155 | jQuery.each( tuples, function( i, tuple ) { |
1156 | var list = tuple[ 2 ], |
1157 | stateString = tuple[ 3 ]; |
1158 | |
1159 | // promise[ done | fail | progress ] = list.add |
1160 | promise[ tuple[1] ] = list.add; |
1161 | |
1162 | // Handle state |
1163 | if ( stateString ) { |
1164 | list.add(function() { |
1165 | // state = [ resolved | rejected ] |
1166 | state = stateString; |
1167 | |
1168 | // [ reject_list | resolve_list ].disable; progress_list.lock |
1169 | }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); |
1170 | } |
1171 | |
1172 | // deferred[ resolve | reject | notify ] = list.fire |
1173 | deferred[ tuple[0] ] = list.fire; |
1174 | deferred[ tuple[0] + "With" ] = list.fireWith; |
1175 | }); |
1176 | |
1177 | // Make the deferred a promise |
1178 | promise.promise( deferred ); |
1179 | |
1180 | // Call given func if any |
1181 | if ( func ) { |
1182 | func.call( deferred, deferred ); |
1183 | } |
1184 | |
1185 | // All done! |
1186 | return deferred; |
1187 | }, |
1188 | |
1189 | // Deferred helper |
1190 | when: function( subordinate /* , ..., subordinateN */ ) { |
1191 | var i = 0, |
1192 | resolveValues = core_slice.call( arguments ), |
1193 | length = resolveValues.length, |
1194 | |
1195 | // the count of uncompleted subordinates |
1196 | remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, |
1197 | |
1198 | // the master Deferred. If resolveValues consist of only a single Deferred, just use that. |
1199 | deferred = remaining === 1 ? subordinate : jQuery.Deferred(), |
1200 | |
1201 | // Update function for both resolve and progress values |
1202 | updateFunc = function( i, contexts, values ) { |
1203 | return function( value ) { |
1204 | contexts[ i ] = this; |
1205 | values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value; |
1206 | if( values === progressValues ) { |
1207 | deferred.notifyWith( contexts, values ); |
1208 | } else if ( !( --remaining ) ) { |
1209 | deferred.resolveWith( contexts, values ); |
1210 | } |
1211 | }; |
1212 | }, |
1213 | |
1214 | progressValues, progressContexts, resolveContexts; |
1215 | |
1216 | // add listeners to Deferred subordinates; treat others as resolved |
1217 | if ( length > 1 ) { |
1218 | progressValues = new Array( length ); |
1219 | progressContexts = new Array( length ); |
1220 | resolveContexts = new Array( length ); |
1221 | for ( ; i < length; i++ ) { |
1222 | if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { |
1223 | resolveValues[ i ].promise() |
1224 | .done( updateFunc( i, resolveContexts, resolveValues ) ) |
1225 | .fail( deferred.reject ) |
1226 | .progress( updateFunc( i, progressContexts, progressValues ) ); |
1227 | } else { |
1228 | --remaining; |
1229 | } |
1230 | } |
1231 | } |
1232 | |
1233 | // if we're not waiting on anything, resolve the master |
1234 | if ( !remaining ) { |
1235 | deferred.resolveWith( resolveContexts, resolveValues ); |
1236 | } |
1237 | |
1238 | return deferred.promise(); |
1239 | } |
1240 | }); |
1241 | jQuery.support = (function() { |
1242 | |
1243 | var support, |
1244 | all, |
1245 | a, |
1246 | select, |
1247 | opt, |
1248 | input, |
1249 | fragment, |
1250 | eventName, |
1251 | i, |
1252 | isSupported, |
1253 | clickFn, |
1254 | div = document.createElement("div"); |
1255 | |
1256 | // Preliminary tests |
1257 | div.setAttribute( "className", "t" ); |
1258 | div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; |
1259 | |
1260 | all = div.getElementsByTagName("*"); |
1261 | a = div.getElementsByTagName("a")[ 0 ]; |
1262 | a.style.cssText = "top:1px;float:left;opacity:.5"; |
1263 | |
1264 | // Can't get basic test support |
1265 | if ( !all || !all.length ) { |
1266 | return {}; |
1267 | } |
1268 | |
1269 | // First batch of supports tests |
1270 | select = document.createElement("select"); |
1271 | opt = select.appendChild( document.createElement("option") ); |
1272 | input = div.getElementsByTagName("input")[ 0 ]; |
1273 | |
1274 | support = { |
1275 | // IE strips leading whitespace when .innerHTML is used |
1276 | leadingWhitespace: ( div.firstChild.nodeType === 3 ), |
1277 | |
1278 | // Make sure that tbody elements aren't automatically inserted |
1279 | // IE will insert them into empty tables |
1280 | tbody: !div.getElementsByTagName("tbody").length, |
1281 | |
1282 | // Make sure that link elements get serialized correctly by innerHTML |
1283 | // This requires a wrapper element in IE |
1284 | htmlSerialize: !!div.getElementsByTagName("link").length, |
1285 | |
1286 | // Get the style information from getAttribute |
1287 | // (IE uses .cssText instead) |
1288 | style: /top/.test( a.getAttribute("style") ), |
1289 | |
1290 | // Make sure that URLs aren't manipulated |
1291 | // (IE normalizes it by default) |
1292 | hrefNormalized: ( a.getAttribute("href") === "/a" ), |
1293 | |
1294 | // Make sure that element opacity exists |
1295 | // (IE uses filter instead) |
1296 | // Use a regex to work around a WebKit issue. See #5145 |
1297 | opacity: /^0.5/.test( a.style.opacity ), |
1298 | |
1299 | // Verify style float existence |
1300 | // (IE uses styleFloat instead of cssFloat) |
1301 | cssFloat: !!a.style.cssFloat, |
1302 | |
1303 | // Make sure that if no value is specified for a checkbox |
1304 | // that it defaults to "on". |
1305 | // (WebKit defaults to "" instead) |
1306 | checkOn: ( input.value === "on" ), |
1307 | |
1308 | // Make sure that a selected-by-default option has a working selected property. |
1309 | // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) |
1310 | optSelected: opt.selected, |
1311 | |
1312 | // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) |
1313 | getSetAttribute: div.className !== "t", |
1314 | |
1315 | // Tests for enctype support on a form(#6743) |
1316 | enctype: !!document.createElement("form").enctype, |
1317 | |
1318 | // Makes sure cloning an html5 element does not cause problems |
1319 | // Where outerHTML is undefined, this still works |
1320 | html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>", |
1321 | |
1322 | // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode |
1323 | boxModel: ( document.compatMode === "CSS1Compat" ), |
1324 | |
1325 | // Will be defined later |
1326 | submitBubbles: true, |
1327 | changeBubbles: true, |
1328 | focusinBubbles: false, |
1329 | deleteExpando: true, |
1330 | noCloneEvent: true, |
1331 | inlineBlockNeedsLayout: false, |
1332 | shrinkWrapBlocks: false, |
1333 | reliableMarginRight: true, |
1334 | boxSizingReliable: true, |
1335 | pixelPosition: false |
1336 | }; |
1337 | |
1338 | // Make sure checked status is properly cloned |
1339 | input.checked = true; |
1340 | support.noCloneChecked = input.cloneNode( true ).checked; |
1341 | |
1342 | // Make sure that the options inside disabled selects aren't marked as disabled |
1343 | // (WebKit marks them as disabled) |
1344 | select.disabled = true; |
1345 | support.optDisabled = !opt.disabled; |
1346 | |
1347 | // Test to see if it's possible to delete an expando from an element |
1348 | // Fails in Internet Explorer |
1349 | try { |
1350 | delete div.test; |
1351 | } catch( e ) { |
1352 | support.deleteExpando = false; |
1353 | } |
1354 | |
1355 | if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { |
1356 | div.attachEvent( "onclick", clickFn = function() { |
1357 | // Cloning a node shouldn't copy over any |
1358 | // bound event handlers (IE does this) |
1359 | support.noCloneEvent = false; |
1360 | }); |
1361 | div.cloneNode( true ).fireEvent("onclick"); |
1362 | div.detachEvent( "onclick", clickFn ); |
1363 | } |
1364 | |
1365 | // Check if a radio maintains its value |
1366 | // after being appended to the DOM |
1367 | input = document.createElement("input"); |
1368 | input.value = "t"; |
1369 | input.setAttribute( "type", "radio" ); |
1370 | support.radioValue = input.value === "t"; |
1371 | |
1372 | input.setAttribute( "checked", "checked" ); |
1373 | |
1374 | // #11217 - WebKit loses check when the name is after the checked attribute |
1375 | input.setAttribute( "name", "t" ); |
1376 | |
1377 | div.appendChild( input ); |
1378 | fragment = document.createDocumentFragment(); |
1379 | fragment.appendChild( div.lastChild ); |
1380 | |
1381 | // WebKit doesn't clone checked state correctly in fragments |
1382 | support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; |
1383 | |
1384 | // Check if a disconnected checkbox will retain its checked |
1385 | // value of true after appended to the DOM (IE6/7) |
1386 | support.appendChecked = input.checked; |
1387 | |
1388 | fragment.removeChild( input ); |
1389 | fragment.appendChild( div ); |
1390 | |
1391 | // Technique from Juriy Zaytsev |
1392 | // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ |
1393 | // We only care about the case where non-standard event systems |
1394 | // are used, namely in IE. Short-circuiting here helps us to |
1395 | // avoid an eval call (in setAttribute) which can cause CSP |
1396 | // to go haywire. See: https://developer.mozilla.org/en/Security/CSP |
1397 | if ( div.attachEvent ) { |
1398 | for ( i in { |
1399 | submit: true, |
1400 | change: true, |
1401 | focusin: true |
1402 | }) { |
1403 | eventName = "on" + i; |
1404 | isSupported = ( eventName in div ); |
1405 | if ( !isSupported ) { |
1406 | div.setAttribute( eventName, "return;" ); |
1407 | isSupported = ( typeof div[ eventName ] === "function" ); |
1408 | } |
1409 | support[ i + "Bubbles" ] = isSupported; |
1410 | } |
1411 | } |
1412 | |
1413 | // Run tests that need a body at doc ready |
1414 | jQuery(function() { |
1415 | var container, div, tds, marginDiv, |
1416 | divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;", |
1417 | body = document.getElementsByTagName("body")[0]; |
1418 | |
1419 | if ( !body ) { |
1420 | // Return for frameset docs that don't have a body |
1421 | return; |
1422 | } |
1423 | |
1424 | container = document.createElement("div"); |
1425 | container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px"; |
1426 | body.insertBefore( container, body.firstChild ); |
1427 | |
1428 | // Construct the test element |
1429 | div = document.createElement("div"); |
1430 | container.appendChild( div ); |
1431 | |
1432 | // Check if table cells still have offsetWidth/Height when they are set |
1433 | // to display:none and there are still other visible table cells in a |
1434 | // table row; if so, offsetWidth/Height are not reliable for use when |
1435 | // determining if an element has been hidden directly using |
1436 | // display:none (it is still safe to use offsets if a parent element is |
1437 | // hidden; don safety goggles and see bug #4512 for more information). |
1438 | // (only IE 8 fails this test) |
1439 | div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>"; |
1440 | tds = div.getElementsByTagName("td"); |
1441 | tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; |
1442 | isSupported = ( tds[ 0 ].offsetHeight === 0 ); |
1443 | |
1444 | tds[ 0 ].style.display = ""; |
1445 | tds[ 1 ].style.display = "none"; |
1446 | |
1447 | // Check if empty table cells still have offsetWidth/Height |
1448 | // (IE <= 8 fail this test) |
1449 | support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); |
1450 | |
1451 | // Check box-sizing and margin behavior |
1452 | div.innerHTML = ""; |
1453 | div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; |
1454 | support.boxSizing = ( div.offsetWidth === 4 ); |
1455 | support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 ); |
1456 | |
1457 | // NOTE: To any future maintainer, we've window.getComputedStyle |
1458 | // because jsdom on node.js will break without it. |
1459 | if ( window.getComputedStyle ) { |
1460 | support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; |
1461 | support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; |
1462 | |
1463 | // Check if div with explicit width and no margin-right incorrectly |
1464 | // gets computed margin-right based on width of container. For more |
1465 | // info see bug #3333 |
1466 | // Fails in WebKit before Feb 2011 nightlies |
1467 | // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
1468 | marginDiv = document.createElement("div"); |
1469 | marginDiv.style.cssText = div.style.cssText = divReset; |
1470 | marginDiv.style.marginRight = marginDiv.style.width = "0"; |
1471 | div.style.width = "1px"; |
1472 | div.appendChild( marginDiv ); |
1473 | support.reliableMarginRight = |
1474 | !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); |
1475 | } |
1476 | |
1477 | if ( typeof div.style.zoom !== "undefined" ) { |
1478 | // Check if natively block-level elements act like inline-block |
1479 | // elements when setting their display to 'inline' and giving |
1480 | // them layout |
1481 | // (IE < 8 does this) |
1482 | div.innerHTML = ""; |
1483 | div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1"; |
1484 | support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); |
1485 | |
1486 | // Check if elements with layout shrink-wrap their children |
1487 | // (IE 6 does this) |
1488 | div.style.display = "block"; |
1489 | div.style.overflow = "visible"; |
1490 | div.innerHTML = "<div></div>"; |
1491 | div.firstChild.style.width = "5px"; |
1492 | support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); |
1493 | |
1494 | container.style.zoom = 1; |
1495 | } |
1496 | |
1497 | // Null elements to avoid leaks in IE |
1498 | body.removeChild( container ); |
1499 | container = div = tds = marginDiv = null; |
1500 | }); |
1501 | |
1502 | // Null elements to avoid leaks in IE |
1503 | fragment.removeChild( div ); |
1504 | all = a = select = opt = input = fragment = div = null; |
1505 | |
1506 | return support; |
1507 | })(); |
1508 | var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, |
1509 | rmultiDash = /([A-Z])/g; |
1510 | |
1511 | jQuery.extend({ |
1512 | cache: {}, |
1513 | |
1514 | deletedIds: [], |
1515 | |
1516 | // Remove at next major release (1.9/2.0) |
1517 | uuid: 0, |
1518 | |
1519 | // Unique for each copy of jQuery on the page |
1520 | // Non-digits removed to match rinlinejQuery |
1521 | expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), |
1522 | |
1523 | // The following elements throw uncatchable exceptions if you |
1524 | // attempt to add expando properties to them. |
1525 | noData: { |
1526 | "embed": true, |
1527 | // Ban all objects except for Flash (which handle expandos) |
1528 | "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", |
1529 | "applet": true |
1530 | }, |
1531 | |
1532 | hasData: function( elem ) { |
1533 | elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; |
1534 | return !!elem && !isEmptyDataObject( elem ); |
1535 | }, |
1536 | |
1537 | data: function( elem, name, data, pvt /* Internal Use Only */ ) { |
1538 | if ( !jQuery.acceptData( elem ) ) { |
1539 | return; |
1540 | } |
1541 | |
1542 | var thisCache, ret, |
1543 | internalKey = jQuery.expando, |
1544 | getByName = typeof name === "string", |
1545 | |
1546 | // We have to handle DOM nodes and JS objects differently because IE6-7 |
1547 | // can't GC object references properly across the DOM-JS boundary |
1548 | isNode = elem.nodeType, |
1549 | |
1550 | // Only DOM nodes need the global jQuery cache; JS object data is |
1551 | // attached directly to the object so GC can occur automatically |
1552 | cache = isNode ? jQuery.cache : elem, |
1553 | |
1554 | // Only defining an ID for JS objects if its cache already exists allows |
1555 | // the code to shortcut on the same path as a DOM node with no cache |
1556 | id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; |
1557 | |
1558 | // Avoid doing any more work than we need to when trying to get data on an |
1559 | // object that has no data at all |
1560 | if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) { |
1561 | return; |
1562 | } |
1563 | |
1564 | if ( !id ) { |
1565 | // Only DOM nodes need a new unique ID for each element since their data |
1566 | // ends up in the global cache |
1567 | if ( isNode ) { |
1568 | elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++; |
1569 | } else { |
1570 | id = internalKey; |
1571 | } |
1572 | } |
1573 | |
1574 | if ( !cache[ id ] ) { |
1575 | cache[ id ] = {}; |
1576 | |
1577 | // Avoids exposing jQuery metadata on plain JS objects when the object |
1578 | // is serialized using JSON.stringify |
1579 | if ( !isNode ) { |
1580 | cache[ id ].toJSON = jQuery.noop; |
1581 | } |
1582 | } |
1583 | |
1584 | // An object can be passed to jQuery.data instead of a key/value pair; this gets |
1585 | // shallow copied over onto the existing cache |
1586 | if ( typeof name === "object" || typeof name === "function" ) { |
1587 | if ( pvt ) { |
1588 | cache[ id ] = jQuery.extend( cache[ id ], name ); |
1589 | } else { |
1590 | cache[ id ].data = jQuery.extend( cache[ id ].data, name ); |
1591 | } |
1592 | } |
1593 | |
1594 | thisCache = cache[ id ]; |
1595 | |
1596 | // jQuery data() is stored in a separate object inside the object's internal data |
1597 | // cache in order to avoid key collisions between internal data and user-defined |
1598 | // data. |
1599 | if ( !pvt ) { |
1600 | if ( !thisCache.data ) { |
1601 | thisCache.data = {}; |
1602 | } |
1603 | |
1604 | thisCache = thisCache.data; |
1605 | } |
1606 | |
1607 | if ( data !== undefined ) { |
1608 | thisCache[ jQuery.camelCase( name ) ] = data; |
1609 | } |
1610 | |
1611 | // Check for both converted-to-camel and non-converted data property names |
1612 | // If a data property was specified |
1613 | if ( getByName ) { |
1614 | |
1615 | // First Try to find as-is property data |
1616 | ret = thisCache[ name ]; |
1617 | |
1618 | // Test for null|undefined property data |
1619 | if ( ret == null ) { |
1620 | |
1621 | // Try to find the camelCased property |
1622 | ret = thisCache[ jQuery.camelCase( name ) ]; |
1623 | } |
1624 | } else { |
1625 | ret = thisCache; |
1626 | } |
1627 | |
1628 | return ret; |
1629 | }, |
1630 | |
1631 | removeData: function( elem, name, pvt /* Internal Use Only */ ) { |
1632 | if ( !jQuery.acceptData( elem ) ) { |
1633 | return; |
1634 | } |
1635 | |
1636 | var thisCache, i, l, |
1637 | |
1638 | isNode = elem.nodeType, |
1639 | |
1640 | // See jQuery.data for more information |
1641 | cache = isNode ? jQuery.cache : elem, |
1642 | id = isNode ? elem[ jQuery.expando ] : jQuery.expando; |
1643 | |
1644 | // If there is already no cache entry for this object, there is no |
1645 | // purpose in continuing |
1646 | if ( !cache[ id ] ) { |
1647 | return; |
1648 | } |
1649 | |
1650 | if ( name ) { |
1651 | |
1652 | thisCache = pvt ? cache[ id ] : cache[ id ].data; |
1653 | |
1654 | if ( thisCache ) { |
1655 | |
1656 | // Support array or space separated string names for data keys |
1657 | if ( !jQuery.isArray( name ) ) { |
1658 | |
1659 | // try the string as a key before any manipulation |
1660 | if ( name in thisCache ) { |
1661 | name = [ name ]; |
1662 | } else { |
1663 | |
1664 | // split the camel cased version by spaces unless a key with the spaces exists |
1665 | name = jQuery.camelCase( name ); |
1666 | if ( name in thisCache ) { |
1667 | name = [ name ]; |
1668 | } else { |
1669 | name = name.split(" "); |
1670 | } |
1671 | } |
1672 | } |
1673 | |
1674 | for ( i = 0, l = name.length; i < l; i++ ) { |
1675 | delete thisCache[ name[i] ]; |
1676 | } |
1677 | |
1678 | // If there is no data left in the cache, we want to continue |
1679 | // and let the cache object itself get destroyed |
1680 | if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { |
1681 | return; |
1682 | } |
1683 | } |
1684 | } |
1685 | |
1686 | // See jQuery.data for more information |
1687 | if ( !pvt ) { |
1688 | delete cache[ id ].data; |
1689 | |
1690 | // Don't destroy the parent cache unless the internal data object |
1691 | // had been the only thing left in it |
1692 | if ( !isEmptyDataObject( cache[ id ] ) ) { |
1693 | return; |
1694 | } |
1695 | } |
1696 | |
1697 | // Destroy the cache |
1698 | if ( isNode ) { |
1699 | jQuery.cleanData( [ elem ], true ); |
1700 | |
1701 | // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) |
1702 | } else if ( jQuery.support.deleteExpando || cache != cache.window ) { |
1703 | delete cache[ id ]; |
1704 | |
1705 | // When all else fails, null |
1706 | } else { |
1707 | cache[ id ] = null; |
1708 | } |
1709 | }, |
1710 | |
1711 | // For internal use only. |
1712 | _data: function( elem, name, data ) { |
1713 | return jQuery.data( elem, name, data, true ); |
1714 | }, |
1715 | |
1716 | // A method for determining if a DOM node can handle the data expando |
1717 | acceptData: function( elem ) { |
1718 | var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ]; |
1719 | |
1720 | // nodes accept data unless otherwise specified; rejection can be conditional |
1721 | return !noData || noData !== true && elem.getAttribute("classid") === noData; |
1722 | } |
1723 | }); |
1724 | |
1725 | jQuery.fn.extend({ |
1726 | data: function( key, value ) { |
1727 | var parts, part, attr, name, l, |
1728 | elem = this[0], |
1729 | i = 0, |
1730 | data = null; |
1731 | |
1732 | // Gets all values |
1733 | if ( key === undefined ) { |
1734 | if ( this.length ) { |
1735 | data = jQuery.data( elem ); |
1736 | |
1737 | if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { |
1738 | attr = elem.attributes; |
1739 | for ( l = attr.length; i < l; i++ ) { |
1740 | name = attr[i].name; |
1741 | |
1742 | if ( !name.indexOf( "data-" ) ) { |
1743 | name = jQuery.camelCase( name.substring(5) ); |
1744 | |
1745 | dataAttr( elem, name, data[ name ] ); |
1746 | } |
1747 | } |
1748 | jQuery._data( elem, "parsedAttrs", true ); |
1749 | } |
1750 | } |
1751 | |
1752 | return data; |
1753 | } |
1754 | |
1755 | // Sets multiple values |
1756 | if ( typeof key === "object" ) { |
1757 | return this.each(function() { |
1758 | jQuery.data( this, key ); |
1759 | }); |
1760 | } |
1761 | |
1762 | parts = key.split( ".", 2 ); |
1763 | parts[1] = parts[1] ? "." + parts[1] : ""; |
1764 | part = parts[1] + "!"; |
1765 | |
1766 | return jQuery.access( this, function( value ) { |
1767 | |
1768 | if ( value === undefined ) { |
1769 | data = this.triggerHandler( "getData" + part, [ parts[0] ] ); |
1770 | |
1771 | // Try to fetch any internally stored data first |
1772 | if ( data === undefined && elem ) { |
1773 | data = jQuery.data( elem, key ); |
1774 | data = dataAttr( elem, key, data ); |
1775 | } |
1776 | |
1777 | return data === undefined && parts[1] ? |
1778 | this.data( parts[0] ) : |
1779 | data; |
1780 | } |
1781 | |
1782 | parts[1] = value; |
1783 | this.each(function() { |
1784 | var self = jQuery( this ); |
1785 | |
1786 | self.triggerHandler( "setData" + part, parts ); |
1787 | jQuery.data( this, key, value ); |
1788 | self.triggerHandler( "changeData" + part, parts ); |
1789 | }); |
1790 | }, null, value, arguments.length > 1, null, false ); |
1791 | }, |
1792 | |
1793 | removeData: function( key ) { |
1794 | return this.each(function() { |
1795 | jQuery.removeData( this, key ); |
1796 | }); |
1797 | } |
1798 | }); |
1799 | |
1800 | function dataAttr( elem, key, data ) { |
1801 | // If nothing was found internally, try to fetch any |
1802 | // data from the HTML5 data-* attribute |
1803 | if ( data === undefined && elem.nodeType === 1 ) { |
1804 | |
1805 | var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); |
1806 | |
1807 | data = elem.getAttribute( name ); |
1808 | |
1809 | if ( typeof data === "string" ) { |
1810 | try { |
1811 | data = data === "true" ? true : |
1812 | data === "false" ? false : |
1813 | data === "null" ? null : |
1814 | // Only convert to a number if it doesn't change the string |
1815 | +data + "" === data ? +data : |
1816 | rbrace.test( data ) ? jQuery.parseJSON( data ) : |
1817 | data; |
1818 | } catch( e ) {} |
1819 | |
1820 | // Make sure we set the data so it isn't changed later |
1821 | jQuery.data( elem, key, data ); |
1822 | |
1823 | } else { |
1824 | data = undefined; |
1825 | } |
1826 | } |
1827 | |
1828 | return data; |
1829 | } |
1830 | |
1831 | // checks a cache object for emptiness |
1832 | function isEmptyDataObject( obj ) { |
1833 | var name; |
1834 | for ( name in obj ) { |
1835 | |
1836 | // if the public data object is empty, the private is still empty |
1837 | if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { |
1838 | continue; |
1839 | } |
1840 | if ( name !== "toJSON" ) { |
1841 | return false; |
1842 | } |
1843 | } |
1844 | |
1845 | return true; |
1846 | } |
1847 | jQuery.extend({ |
1848 | queue: function( elem, type, data ) { |
1849 | var queue; |
1850 | |
1851 | if ( elem ) { |
1852 | type = ( type || "fx" ) + "queue"; |
1853 | queue = jQuery._data( elem, type ); |
1854 | |
1855 | // Speed up dequeue by getting out quickly if this is just a lookup |
1856 | if ( data ) { |
1857 | if ( !queue || jQuery.isArray(data) ) { |
1858 | queue = jQuery._data( elem, type, jQuery.makeArray(data) ); |
1859 | } else { |
1860 | queue.push( data ); |
1861 | } |
1862 | } |
1863 | return queue || []; |
1864 | } |
1865 | }, |
1866 | |
1867 | dequeue: function( elem, type ) { |
1868 | type = type || "fx"; |
1869 | |
1870 | var queue = jQuery.queue( elem, type ), |
1871 | startLength = queue.length, |
1872 | fn = queue.shift(), |
1873 | hooks = jQuery._queueHooks( elem, type ), |
1874 | next = function() { |
1875 | jQuery.dequeue( elem, type ); |
1876 | }; |
1877 | |
1878 | // If the fx queue is dequeued, always remove the progress sentinel |
1879 | if ( fn === "inprogress" ) { |
1880 | fn = queue.shift(); |
1881 | startLength--; |
1882 | } |
1883 | |
1884 | if ( fn ) { |
1885 | |
1886 | // Add a progress sentinel to prevent the fx queue from being |
1887 | // automatically dequeued |
1888 | if ( type === "fx" ) { |
1889 | queue.unshift( "inprogress" ); |
1890 | } |
1891 | |
1892 | // clear up the last queue stop function |
1893 | delete hooks.stop; |
1894 | fn.call( elem, next, hooks ); |
1895 | } |
1896 | |
1897 | if ( !startLength && hooks ) { |
1898 | hooks.empty.fire(); |
1899 | } |
1900 | }, |
1901 | |
1902 | // not intended for public consumption - generates a queueHooks object, or returns the current one |
1903 | _queueHooks: function( elem, type ) { |
1904 | var key = type + "queueHooks"; |
1905 | return jQuery._data( elem, key ) || jQuery._data( elem, key, { |
1906 | empty: jQuery.Callbacks("once memory").add(function() { |
1907 | jQuery.removeData( elem, type + "queue", true ); |
1908 | jQuery.removeData( elem, key, true ); |
1909 | }) |
1910 | }); |
1911 | } |
1912 | }); |
1913 | |
1914 | jQuery.fn.extend({ |
1915 | queue: function( type, data ) { |
1916 | var setter = 2; |
1917 | |
1918 | if ( typeof type !== "string" ) { |
1919 | data = type; |
1920 | type = "fx"; |
1921 | setter--; |
1922 | } |
1923 | |
1924 | if ( arguments.length < setter ) { |
1925 | return jQuery.queue( this[0], type ); |
1926 | } |
1927 | |
1928 | return data === undefined ? |
1929 | this : |
1930 | this.each(function() { |
1931 | var queue = jQuery.queue( this, type, data ); |
1932 | |
1933 | // ensure a hooks for this queue |
1934 | jQuery._queueHooks( this, type ); |
1935 | |
1936 | if ( type === "fx" && queue[0] !== "inprogress" ) { |
1937 | jQuery.dequeue( this, type ); |
1938 | } |
1939 | }); |
1940 | }, |
1941 | dequeue: function( type ) { |
1942 | return this.each(function() { |
1943 | jQuery.dequeue( this, type ); |
1944 | }); |
1945 | }, |
1946 | // Based off of the plugin by Clint Helfers, with permission. |
1947 | // http://blindsignals.com/index.php/2009/07/jquery-delay/ |
1948 | delay: function( time, type ) { |
1949 | time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; |
1950 | type = type || "fx"; |
1951 | |
1952 | return this.queue( type, function( next, hooks ) { |
1953 | var timeout = setTimeout( next, time ); |
1954 | hooks.stop = function() { |
1955 | clearTimeout( timeout ); |
1956 | }; |
1957 | }); |
1958 | }, |
1959 | clearQueue: function( type ) { |
1960 | return this.queue( type || "fx", [] ); |
1961 | }, |
1962 | // Get a promise resolved when queues of a certain type |
1963 | // are emptied (fx is the type by default) |
1964 | promise: function( type, obj ) { |
1965 | var tmp, |
1966 | count = 1, |
1967 | defer = jQuery.Deferred(), |
1968 | elements = this, |
1969 | i = this.length, |
1970 | resolve = function() { |
1971 | if ( !( --count ) ) { |
1972 | defer.resolveWith( elements, [ elements ] ); |
1973 | } |
1974 | }; |
1975 | |
1976 | if ( typeof type !== "string" ) { |
1977 | obj = type; |
1978 | type = undefined; |
1979 | } |
1980 | type = type || "fx"; |
1981 | |
1982 | while( i-- ) { |
1983 | tmp = jQuery._data( elements[ i ], type + "queueHooks" ); |
1984 | if ( tmp && tmp.empty ) { |
1985 | count++; |
1986 | tmp.empty.add( resolve ); |
1987 | } |
1988 | } |
1989 | resolve(); |
1990 | return defer.promise( obj ); |
1991 | } |
1992 | }); |
1993 | var nodeHook, boolHook, fixSpecified, |
1994 | rclass = /[\t\r\n]/g, |
1995 | rreturn = /\r/g, |
1996 | rtype = /^(?:button|input)$/i, |
1997 | rfocusable = /^(?:button|input|object|select|textarea)$/i, |
1998 | rclickable = /^a(?:rea|)$/i, |
1999 | rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, |
2000 | getSetAttribute = jQuery.support.getSetAttribute; |
2001 | |
2002 | jQuery.fn.extend({ |
2003 | attr: function( name, value ) { |
2004 | return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); |
2005 | }, |
2006 | |
2007 | removeAttr: function( name ) { |
2008 | return this.each(function() { |
2009 | jQuery.removeAttr( this, name ); |
2010 | }); |
2011 | }, |
2012 | |
2013 | prop: function( name, value ) { |
2014 | return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); |
2015 | }, |
2016 | |
2017 | removeProp: function( name ) { |
2018 | name = jQuery.propFix[ name ] || name; |
2019 | return this.each(function() { |
2020 | // try/catch handles cases where IE balks (such as removing a property on window) |
2021 | try { |
2022 | this[ name ] = undefined; |
2023 | delete this[ name ]; |
2024 | } catch( e ) {} |
2025 | }); |
2026 | }, |
2027 | |
2028 | addClass: function( value ) { |
2029 | var classNames, i, l, elem, |
2030 | setClass, c, cl; |
2031 | |
2032 | if ( jQuery.isFunction( value ) ) { |
2033 | return this.each(function( j ) { |
2034 | jQuery( this ).addClass( value.call(this, j, this.className) ); |
2035 | }); |
2036 | } |
2037 | |
2038 | if ( value && typeof value === "string" ) { |
2039 | classNames = value.split( core_rspace ); |
2040 | |
2041 | for ( i = 0, l = this.length; i < l; i++ ) { |
2042 | elem = this[ i ]; |
2043 | |
2044 | if ( elem.nodeType === 1 ) { |
2045 | if ( !elem.className && classNames.length === 1 ) { |
2046 | elem.className = value; |
2047 | |
2048 | } else { |
2049 | setClass = " " + elem.className + " "; |
2050 | |
2051 | for ( c = 0, cl = classNames.length; c < cl; c++ ) { |
2052 | if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) { |
2053 | setClass += classNames[ c ] + " "; |
2054 | } |
2055 | } |
2056 | elem.className = jQuery.trim( setClass ); |
2057 | } |
2058 | } |
2059 | } |
2060 | } |
2061 | |
2062 | return this; |
2063 | }, |
2064 | |
2065 | removeClass: function( value ) { |
2066 | var removes, className, elem, c, cl, i, l; |
2067 | |
2068 | if ( jQuery.isFunction( value ) ) { |
2069 | return this.each(function( j ) { |
2070 | jQuery( this ).removeClass( value.call(this, j, this.className) ); |
2071 | }); |
2072 | } |
2073 | if ( (value && typeof value === "string") || value === undefined ) { |
2074 | removes = ( value || "" ).split( core_rspace ); |
2075 | |
2076 | for ( i = 0, l = this.length; i < l; i++ ) { |
2077 | elem = this[ i ]; |
2078 | if ( elem.nodeType === 1 && elem.className ) { |
2079 | |
2080 | className = (" " + elem.className + " ").replace( rclass, " " ); |
2081 | |
2082 | // loop over each item in the removal list |
2083 | for ( c = 0, cl = removes.length; c < cl; c++ ) { |
2084 | // Remove until there is nothing to remove, |
2085 | while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) { |
2086 | className = className.replace( " " + removes[ c ] + " " , " " ); |
2087 | } |
2088 | } |
2089 | elem.className = value ? jQuery.trim( className ) : ""; |
2090 | } |
2091 | } |
2092 | } |
2093 | |
2094 | return this; |
2095 | }, |
2096 | |
2097 | toggleClass: function( value, stateVal ) { |
2098 | var type = typeof value, |
2099 | isBool = typeof stateVal === "boolean"; |
2100 | |
2101 | if ( jQuery.isFunction( value ) ) { |
2102 | return this.each(function( i ) { |
2103 | jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); |
2104 | }); |
2105 | } |
2106 | |
2107 | return this.each(function() { |
2108 | if ( type === "string" ) { |
2109 | // toggle individual class names |
2110 | var className, |
2111 | i = 0, |
2112 | self = jQuery( this ), |
2113 | state = stateVal, |
2114 | classNames = value.split( core_rspace ); |
2115 | |
2116 | while ( (className = classNames[ i++ ]) ) { |
2117 | // check each className given, space separated list |
2118 | state = isBool ? state : !self.hasClass( className ); |
2119 | self[ state ? "addClass" : "removeClass" ]( className ); |
2120 | } |
2121 | |
2122 | } else if ( type === "undefined" || type === "boolean" ) { |
2123 | if ( this.className ) { |
2124 | // store className if set |
2125 | jQuery._data( this, "__className__", this.className ); |
2126 | } |
2127 | |
2128 | // toggle whole className |
2129 | this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; |
2130 | } |
2131 | }); |
2132 | }, |
2133 | |
2134 | hasClass: function( selector ) { |
2135 | var className = " " + selector + " ", |
2136 | i = 0, |
2137 | l = this.length; |
2138 | for ( ; i < l; i++ ) { |
2139 | if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { |
2140 | return true; |
2141 | } |
2142 | } |
2143 | |
2144 | return false; |
2145 | }, |
2146 | |
2147 | val: function( value ) { |
2148 | var hooks, ret, isFunction, |
2149 | elem = this[0]; |
2150 | |
2151 | if ( !arguments.length ) { |
2152 | if ( elem ) { |
2153 | hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; |
2154 | |
2155 | if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { |
2156 | return ret; |
2157 | } |
2158 | |
2159 | ret = elem.value; |
2160 | |
2161 | return typeof ret === "string" ? |
2162 | // handle most common string cases |
2163 | ret.replace(rreturn, "") : |
2164 | // handle cases where value is null/undef or number |
2165 | ret == null ? "" : ret; |
2166 | } |
2167 | |
2168 | return; |
2169 | } |
2170 | |
2171 | isFunction = jQuery.isFunction( value ); |
2172 | |
2173 | return this.each(function( i ) { |
2174 | var val, |
2175 | self = jQuery(this); |
2176 | |
2177 | if ( this.nodeType !== 1 ) { |
2178 | return; |
2179 | } |
2180 | |
2181 | if ( isFunction ) { |
2182 | val = value.call( this, i, self.val() ); |
2183 | } else { |
2184 | val = value; |
2185 | } |
2186 | |
2187 | // Treat null/undefined as ""; convert numbers to string |
2188 | if ( val == null ) { |
2189 | val = ""; |
2190 | } else if ( typeof val === "number" ) { |
2191 | val += ""; |
2192 | } else if ( jQuery.isArray( val ) ) { |
2193 | val = jQuery.map(val, function ( value ) { |
2194 | return value == null ? "" : value + ""; |
2195 | }); |
2196 | } |
2197 | |
2198 | hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; |
2199 | |
2200 | // If set returns undefined, fall back to normal setting |
2201 | if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { |
2202 | this.value = val; |
2203 | } |
2204 | }); |
2205 | } |
2206 | }); |
2207 | |
2208 | jQuery.extend({ |
2209 | valHooks: { |
2210 | option: { |
2211 | get: function( elem ) { |
2212 | // attributes.value is undefined in Blackberry 4.7 but |
2213 | // uses .value. See #6932 |
2214 | var val = elem.attributes.value; |
2215 | return !val || val.specified ? elem.value : elem.text; |
2216 | } |
2217 | }, |
2218 | select: { |
2219 | get: function( elem ) { |
2220 | var value, i, max, option, |
2221 | index = elem.selectedIndex, |
2222 | values = [], |
2223 | options = elem.options, |
2224 | one = elem.type === "select-one"; |
2225 | |
2226 | // Nothing was selected |
2227 | if ( index < 0 ) { |
2228 | return null; |
2229 | } |
2230 | |
2231 | // Loop through all the selected options |
2232 | i = one ? index : 0; |
2233 | max = one ? index + 1 : options.length; |
2234 | for ( ; i < max; i++ ) { |
2235 | option = options[ i ]; |
2236 | |
2237 | // Don't return options that are disabled or in a disabled optgroup |
2238 | if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && |
2239 | (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { |
2240 | |
2241 | // Get the specific value for the option |
2242 | value = jQuery( option ).val(); |
2243 | |
2244 | // We don't need an array for one selects |
2245 | if ( one ) { |
2246 | return value; |
2247 | } |
2248 | |
2249 | // Multi-Selects return an array |
2250 | values.push( value ); |
2251 | } |
2252 | } |
2253 | |
2254 | // Fixes Bug #2551 -- select.val() broken in IE after form.reset() |
2255 | if ( one && !values.length && options.length ) { |
2256 | return jQuery( options[ index ] ).val(); |
2257 | } |
2258 | |
2259 | return values; |
2260 | }, |
2261 | |
2262 | set: function( elem, value ) { |
2263 | var values = jQuery.makeArray( value ); |
2264 | |
2265 | jQuery(elem).find("option").each(function() { |
2266 | this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; |
2267 | }); |
2268 | |
2269 | if ( !values.length ) { |
2270 | elem.selectedIndex = -1; |
2271 | } |
2272 | return values; |
2273 | } |
2274 | } |
2275 | }, |
2276 | |
2277 | // Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9 |
2278 | attrFn: {}, |
2279 | |
2280 | attr: function( elem, name, value, pass ) { |
2281 | var ret, hooks, notxml, |
2282 | nType = elem.nodeType; |
2283 | |
2284 | // don't get/set attributes on text, comment and attribute nodes |
2285 | if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
2286 | return; |
2287 | } |
2288 | |
2289 | if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) { |
2290 | return jQuery( elem )[ name ]( value ); |
2291 | } |
2292 | |
2293 | // Fallback to prop when attributes are not supported |
2294 | if ( typeof elem.getAttribute === "undefined" ) { |
2295 | return jQuery.prop( elem, name, value ); |
2296 | } |
2297 | |
2298 | notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); |
2299 | |
2300 | // All attributes are lowercase |
2301 | // Grab necessary hook if one is defined |
2302 | if ( notxml ) { |
2303 | name = name.toLowerCase(); |
2304 | hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); |
2305 | } |
2306 | |
2307 | if ( value !== undefined ) { |
2308 | |
2309 | if ( value === null ) { |
2310 | jQuery.removeAttr( elem, name ); |
2311 | return; |
2312 | |
2313 | } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { |
2314 | return ret; |
2315 | |
2316 | } else { |
2317 | elem.setAttribute( name, value + "" ); |
2318 | return value; |
2319 | } |
2320 | |
2321 | } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { |
2322 | return ret; |
2323 | |
2324 | } else { |
2325 | |
2326 | ret = elem.getAttribute( name ); |
2327 | |
2328 | // Non-existent attributes return null, we normalize to undefined |
2329 | return ret === null ? |
2330 | undefined : |
2331 | ret; |
2332 | } |
2333 | }, |
2334 | |
2335 | removeAttr: function( elem, value ) { |
2336 | var propName, attrNames, name, isBool, |
2337 | i = 0; |
2338 | |
2339 | if ( value && elem.nodeType === 1 ) { |
2340 | |
2341 | attrNames = value.split( core_rspace ); |
2342 | |
2343 | for ( ; i < attrNames.length; i++ ) { |
2344 | name = attrNames[ i ]; |
2345 | |
2346 | if ( name ) { |
2347 | propName = jQuery.propFix[ name ] || name; |
2348 | isBool = rboolean.test( name ); |
2349 | |
2350 | // See #9699 for explanation of this approach (setting first, then removal) |
2351 | // Do not do this for boolean attributes (see #10870) |
2352 | if ( !isBool ) { |
2353 | jQuery.attr( elem, name, "" ); |
2354 | } |
2355 | elem.removeAttribute( getSetAttribute ? name : propName ); |
2356 | |
2357 | // Set corresponding property to false for boolean attributes |
2358 | if ( isBool && propName in elem ) { |
2359 | elem[ propName ] = false; |
2360 | } |
2361 | } |
2362 | } |
2363 | } |
2364 | }, |
2365 | |
2366 | attrHooks: { |
2367 | type: { |
2368 | set: function( elem, value ) { |
2369 | // We can't allow the type property to be changed (since it causes problems in IE) |
2370 | if ( rtype.test( elem.nodeName ) && elem.parentNode ) { |
2371 | jQuery.error( "type property can't be changed" ); |
2372 | } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { |
2373 | // Setting the type on a radio button after the value resets the value in IE6-9 |
2374 | // Reset value to it's default in case type is set after value |
2375 | // This is for element creation |
2376 | var val = elem.value; |
2377 | elem.setAttribute( "type", value ); |
2378 | if ( val ) { |
2379 | elem.value = val; |
2380 | } |
2381 | return value; |
2382 | } |
2383 | } |
2384 | }, |
2385 | // Use the value property for back compat |
2386 | // Use the nodeHook for button elements in IE6/7 (#1954) |
2387 | value: { |
2388 | get: function( elem, name ) { |
2389 | if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { |
2390 | return nodeHook.get( elem, name ); |
2391 | } |
2392 | return name in elem ? |
2393 | elem.value : |
2394 | null; |
2395 | }, |
2396 | set: function( elem, value, name ) { |
2397 | if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { |
2398 | return nodeHook.set( elem, value, name ); |
2399 | } |
2400 | // Does not return so that setAttribute is also used |
2401 | elem.value = value; |
2402 | } |
2403 | } |
2404 | }, |
2405 | |
2406 | propFix: { |
2407 | tabindex: "tabIndex", |
2408 | readonly: "readOnly", |
2409 | "for": "htmlFor", |
2410 | "class": "className", |
2411 | maxlength: "maxLength", |
2412 | cellspacing: "cellSpacing", |
2413 | cellpadding: "cellPadding", |
2414 | rowspan: "rowSpan", |
2415 | colspan: "colSpan", |
2416 | usemap: "useMap", |
2417 | frameborder: "frameBorder", |
2418 | contenteditable: "contentEditable" |
2419 | }, |
2420 | |
2421 | prop: function( elem, name, value ) { |
2422 | var ret, hooks, notxml, |
2423 | nType = elem.nodeType; |
2424 | |
2425 | // don't get/set properties on text, comment and attribute nodes |
2426 | if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
2427 | return; |
2428 | } |
2429 | |
2430 | notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); |
2431 | |
2432 | if ( notxml ) { |
2433 | // Fix name and attach hooks |
2434 | name = jQuery.propFix[ name ] || name; |
2435 | hooks = jQuery.propHooks[ name ]; |
2436 | } |
2437 | |
2438 | if ( value !== undefined ) { |
2439 | if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { |
2440 | return ret; |
2441 | |
2442 | } else { |
2443 | return ( elem[ name ] = value ); |
2444 | } |
2445 | |
2446 | } else { |
2447 | if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { |
2448 | return ret; |
2449 | |
2450 | } else { |
2451 | return elem[ name ]; |
2452 | } |
2453 | } |
2454 | }, |
2455 | |
2456 | propHooks: { |
2457 | tabIndex: { |
2458 | get: function( elem ) { |
2459 | // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set |
2460 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
2461 | var attributeNode = elem.getAttributeNode("tabindex"); |
2462 | |
2463 | return attributeNode && attributeNode.specified ? |
2464 | parseInt( attributeNode.value, 10 ) : |
2465 | rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? |
2466 | 0 : |
2467 | undefined; |
2468 | } |
2469 | } |
2470 | } |
2471 | }); |
2472 | |
2473 | // Hook for boolean attributes |
2474 | boolHook = { |
2475 | get: function( elem, name ) { |
2476 | // Align boolean attributes with corresponding properties |
2477 | // Fall back to attribute presence where some booleans are not supported |
2478 | var attrNode, |
2479 | property = jQuery.prop( elem, name ); |
2480 | return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? |
2481 | name.toLowerCase() : |
2482 | undefined; |
2483 | }, |
2484 | set: function( elem, value, name ) { |
2485 | var propName; |
2486 | if ( value === false ) { |
2487 | // Remove boolean attributes when set to false |
2488 | jQuery.removeAttr( elem, name ); |
2489 | } else { |
2490 | // value is true since we know at this point it's type boolean and not false |
2491 | // Set boolean attributes to the same name and set the DOM property |
2492 | propName = jQuery.propFix[ name ] || name; |
2493 | if ( propName in elem ) { |
2494 | // Only set the IDL specifically if it already exists on the element |
2495 | elem[ propName ] = true; |
2496 | } |
2497 | |
2498 | elem.setAttribute( name, name.toLowerCase() ); |
2499 | } |
2500 | return name; |
2501 | } |
2502 | }; |
2503 | |
2504 | // IE6/7 do not support getting/setting some attributes with get/setAttribute |
2505 | if ( !getSetAttribute ) { |
2506 | |
2507 | fixSpecified = { |
2508 | name: true, |
2509 | id: true, |
2510 | coords: true |
2511 | }; |
2512 | |
2513 | // Use this for any attribute in IE6/7 |
2514 | // This fixes almost every IE6/7 issue |
2515 | nodeHook = jQuery.valHooks.button = { |
2516 | get: function( elem, name ) { |
2517 | var ret; |
2518 | ret = elem.getAttributeNode( name ); |
2519 | return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ? |
2520 | ret.value : |
2521 | undefined; |
2522 | }, |
2523 | set: function( elem, value, name ) { |
2524 | // Set the existing or create a new attribute node |
2525 | var ret = elem.getAttributeNode( name ); |
2526 | if ( !ret ) { |
2527 | ret = document.createAttribute( name ); |
2528 | elem.setAttributeNode( ret ); |
2529 | } |
2530 | return ( ret.value = value + "" ); |
2531 | } |
2532 | }; |
2533 | |
2534 | // Set width and height to auto instead of 0 on empty string( Bug #8150 ) |
2535 | // This is for removals |
2536 | jQuery.each([ "width", "height" ], function( i, name ) { |
2537 | jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { |
2538 | set: function( elem, value ) { |
2539 | if ( value === "" ) { |
2540 | elem.setAttribute( name, "auto" ); |
2541 | return value; |
2542 | } |
2543 | } |
2544 | }); |
2545 | }); |
2546 | |
2547 | // Set contenteditable to false on removals(#10429) |
2548 | // Setting to empty string throws an error as an invalid value |
2549 | jQuery.attrHooks.contenteditable = { |
2550 | get: nodeHook.get, |
2551 | set: function( elem, value, name ) { |
2552 | if ( value === "" ) { |
2553 | value = "false"; |
2554 | } |
2555 | nodeHook.set( elem, value, name ); |
2556 | } |
2557 | }; |
2558 | } |
2559 | |
2560 | |
2561 | // Some attributes require a special call on IE |
2562 | if ( !jQuery.support.hrefNormalized ) { |
2563 | jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { |
2564 | jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { |
2565 | get: function( elem ) { |
2566 | var ret = elem.getAttribute( name, 2 ); |
2567 | return ret === null ? undefined : ret; |
2568 | } |
2569 | }); |
2570 | }); |
2571 | } |
2572 | |
2573 | if ( !jQuery.support.style ) { |
2574 | jQuery.attrHooks.style = { |
2575 | get: function( elem ) { |
2576 | // Return undefined in the case of empty string |
2577 | // Normalize to lowercase since IE uppercases css property names |
2578 | return elem.style.cssText.toLowerCase() || undefined; |
2579 | }, |
2580 | set: function( elem, value ) { |
2581 | return ( elem.style.cssText = value + "" ); |
2582 | } |
2583 | }; |
2584 | } |
2585 | |
2586 | // Safari mis-reports the default selected property of an option |
2587 | // Accessing the parent's selectedIndex property fixes it |
2588 | if ( !jQuery.support.optSelected ) { |
2589 | jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { |
2590 | get: function( elem ) { |
2591 | var parent = elem.parentNode; |
2592 | |
2593 | if ( parent ) { |
2594 | parent.selectedIndex; |
2595 | |
2596 | // Make sure that it also works with optgroups, see #5701 |
2597 | if ( parent.parentNode ) { |
2598 | parent.parentNode.selectedIndex; |
2599 | } |
2600 | } |
2601 | return null; |
2602 | } |
2603 | }); |
2604 | } |
2605 | |
2606 | // IE6/7 call enctype encoding |
2607 | if ( !jQuery.support.enctype ) { |
2608 | jQuery.propFix.enctype = "encoding"; |
2609 | } |
2610 | |
2611 | // Radios and checkboxes getter/setter |
2612 | if ( !jQuery.support.checkOn ) { |
2613 | jQuery.each([ "radio", "checkbox" ], function() { |
2614 | jQuery.valHooks[ this ] = { |
2615 | get: function( elem ) { |
2616 | // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified |
2617 | return elem.getAttribute("value") === null ? "on" : elem.value; |
2618 | } |
2619 | }; |
2620 | }); |
2621 | } |
2622 | jQuery.each([ "radio", "checkbox" ], function() { |
2623 | jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { |
2624 | set: function( elem, value ) { |
2625 | if ( jQuery.isArray( value ) ) { |
2626 | return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); |
2627 | } |
2628 | } |
2629 | }); |
2630 | }); |
2631 | var rformElems = /^(?:textarea|input|select)$/i, |
2632 | rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/, |
2633 | rhoverHack = /(?:^|\s)hover(\.\S+|)\b/, |
2634 | rkeyEvent = /^key/, |
2635 | rmouseEvent = /^(?:mouse|contextmenu)|click/, |
2636 | rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, |
2637 | hoverHack = function( events ) { |
2638 | return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); |
2639 | }; |
2640 | |
2641 | /* |
2642 | * Helper functions for managing events -- not part of the public interface. |
2643 | * Props to Dean Edwards' addEvent library for many of the ideas. |
2644 | */ |
2645 | jQuery.event = { |
2646 | |
2647 | add: function( elem, types, handler, data, selector ) { |
2648 | |
2649 | var elemData, eventHandle, events, |
2650 | t, tns, type, namespaces, handleObj, |
2651 | handleObjIn, handlers, special; |
2652 | |
2653 | // Don't attach events to noData or text/comment nodes (allow plain objects tho) |
2654 | if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { |
2655 | return; |
2656 | } |
2657 | |
2658 | // Caller can pass in an object of custom data in lieu of the handler |
2659 | if ( handler.handler ) { |
2660 | handleObjIn = handler; |
2661 | handler = handleObjIn.handler; |
2662 | selector = handleObjIn.selector; |
2663 | } |
2664 | |
2665 | // Make sure that the handler has a unique ID, used to find/remove it later |
2666 | if ( !handler.guid ) { |
2667 | handler.guid = jQuery.guid++; |
2668 | } |
2669 | |
2670 | // Init the element's event structure and main handler, if this is the first |
2671 | events = elemData.events; |
2672 | if ( !events ) { |
2673 | elemData.events = events = {}; |
2674 | } |
2675 | eventHandle = elemData.handle; |
2676 | if ( !eventHandle ) { |
2677 | elemData.handle = eventHandle = function( e ) { |
2678 | // Discard the second event of a jQuery.event.trigger() and |
2679 | // when an event is called after a page has unloaded |
2680 | return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? |
2681 | jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : |
2682 | undefined; |
2683 | }; |
2684 | // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events |
2685 | eventHandle.elem = elem; |
2686 | } |
2687 | |
2688 | // Handle multiple events separated by a space |
2689 | // jQuery(...).bind("mouseover mouseout", fn); |
2690 | types = jQuery.trim( hoverHack(types) ).split( " " ); |
2691 | for ( t = 0; t < types.length; t++ ) { |
2692 | |
2693 | tns = rtypenamespace.exec( types[t] ) || []; |
2694 | type = tns[1]; |
2695 | namespaces = ( tns[2] || "" ).split( "." ).sort(); |
2696 | |
2697 | // If event changes its type, use the special event handlers for the changed type |
2698 | special = jQuery.event.special[ type ] || {}; |
2699 | |
2700 | // If selector defined, determine special event api type, otherwise given type |
2701 | type = ( selector ? special.delegateType : special.bindType ) || type; |
2702 | |
2703 | // Update special based on newly reset type |
2704 | special = jQuery.event.special[ type ] || {}; |
2705 | |
2706 | // handleObj is passed to all event handlers |
2707 | handleObj = jQuery.extend({ |
2708 | type: type, |
2709 | origType: tns[1], |
2710 | data: data, |
2711 | handler: handler, |
2712 | guid: handler.guid, |
2713 | selector: selector, |
2714 | needsContext: selector && jQuery.expr.match.needsContext.test( selector ), |
2715 | namespace: namespaces.join(".") |
2716 | }, handleObjIn ); |
2717 | |
2718 | // Init the event handler queue if we're the first |
2719 | handlers = events[ type ]; |
2720 | if ( !handlers ) { |
2721 | handlers = events[ type ] = []; |
2722 | handlers.delegateCount = 0; |
2723 | |
2724 | // Only use addEventListener/attachEvent if the special events handler returns false |
2725 | if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { |
2726 | // Bind the global event handler to the element |
2727 | if ( elem.addEventListener ) { |
2728 | elem.addEventListener( type, eventHandle, false ); |
2729 | |
2730 | } else if ( elem.attachEvent ) { |
2731 | elem.attachEvent( "on" + type, eventHandle ); |
2732 | } |
2733 | } |
2734 | } |
2735 | |
2736 | if ( special.add ) { |
2737 | special.add.call( elem, handleObj ); |
2738 | |
2739 | if ( !handleObj.handler.guid ) { |
2740 | handleObj.handler.guid = handler.guid; |
2741 | } |
2742 | } |
2743 | |
2744 | // Add to the element's handler list, delegates in front |
2745 | if ( selector ) { |
2746 | handlers.splice( handlers.delegateCount++, 0, handleObj ); |
2747 | } else { |
2748 | handlers.push( handleObj ); |
2749 | } |
2750 | |
2751 | // Keep track of which events have ever been used, for event optimization |
2752 | jQuery.event.global[ type ] = true; |
2753 | } |
2754 | |
2755 | // Nullify elem to prevent memory leaks in IE |
2756 | elem = null; |
2757 | }, |
2758 | |
2759 | global: {}, |
2760 | |
2761 | // Detach an event or set of events from an element |
2762 | remove: function( elem, types, handler, selector, mappedTypes ) { |
2763 | |
2764 | var t, tns, type, origType, namespaces, origCount, |
2765 | j, events, special, eventType, handleObj, |
2766 | elemData = jQuery.hasData( elem ) && jQuery._data( elem ); |
2767 | |
2768 | if ( !elemData || !(events = elemData.events) ) { |
2769 | return; |
2770 | } |
2771 | |
2772 | // Once for each type.namespace in types; type may be omitted |
2773 | types = jQuery.trim( hoverHack( types || "" ) ).split(" "); |
2774 | for ( t = 0; t < types.length; t++ ) { |
2775 | tns = rtypenamespace.exec( types[t] ) || []; |
2776 | type = origType = tns[1]; |
2777 | namespaces = tns[2]; |
2778 | |
2779 | // Unbind all events (on this namespace, if provided) for the element |
2780 | if ( !type ) { |
2781 | for ( type in events ) { |
2782 | jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); |
2783 | } |
2784 | continue; |
2785 | } |
2786 | |
2787 | special = jQuery.event.special[ type ] || {}; |
2788 | type = ( selector? special.delegateType : special.bindType ) || type; |
2789 | eventType = events[ type ] || []; |
2790 | origCount = eventType.length; |
2791 | namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null; |
2792 | |
2793 | // Remove matching events |
2794 | for ( j = 0; j < eventType.length; j++ ) { |
2795 | handleObj = eventType[ j ]; |
2796 | |
2797 | if ( ( mappedTypes || origType === handleObj.origType ) && |
2798 | ( !handler || handler.guid === handleObj.guid ) && |
2799 | ( !namespaces || namespaces.test( handleObj.namespace ) ) && |
2800 | ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { |
2801 | eventType.splice( j--, 1 ); |
2802 | |
2803 | if ( handleObj.selector ) { |
2804 | eventType.delegateCount--; |
2805 | } |
2806 | if ( special.remove ) { |
2807 | special.remove.call( elem, handleObj ); |
2808 | } |
2809 | } |
2810 | } |
2811 | |
2812 | // Remove generic event handler if we removed something and no more handlers exist |
2813 | // (avoids potential for endless recursion during removal of special event handlers) |
2814 | if ( eventType.length === 0 && origCount !== eventType.length ) { |
2815 | if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { |
2816 | jQuery.removeEvent( elem, type, elemData.handle ); |
2817 | } |
2818 | |
2819 | delete events[ type ]; |
2820 | } |
2821 | } |
2822 | |
2823 | // Remove the expando if it's no longer used |
2824 | if ( jQuery.isEmptyObject( events ) ) { |
2825 | delete elemData.handle; |
2826 | |
2827 | // removeData also checks for emptiness and clears the expando if empty |
2828 | // so use it instead of delete |
2829 | jQuery.removeData( elem, "events", true ); |
2830 | } |
2831 | }, |
2832 | |
2833 | // Events that are safe to short-circuit if no handlers are attached. |
2834 | // Native DOM events should not be added, they may have inline handlers. |
2835 | customEvent: { |
2836 | "getData": true, |
2837 | "setData": true, |
2838 | "changeData": true |
2839 | }, |
2840 | |
2841 | trigger: function( event, data, elem, onlyHandlers ) { |
2842 | // Don't do events on text and comment nodes |
2843 | if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { |
2844 | return; |
2845 | } |
2846 | |
2847 | // Event object or event type |
2848 | var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType, |
2849 | type = event.type || event, |
2850 | namespaces = []; |
2851 | |
2852 | // focus/blur morphs to focusin/out; ensure we're not firing them right now |
2853 | if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { |
2854 | return; |
2855 | } |
2856 | |
2857 | if ( type.indexOf( "!" ) >= 0 ) { |
2858 | // Exclusive events trigger only for the exact event (no namespaces) |
2859 | type = type.slice(0, -1); |
2860 | exclusive = true; |
2861 | } |
2862 | |
2863 | if ( type.indexOf( "." ) >= 0 ) { |
2864 | // Namespaced trigger; create a regexp to match event type in handle() |
2865 | namespaces = type.split("."); |
2866 | type = namespaces.shift(); |
2867 | namespaces.sort(); |
2868 | } |
2869 | |
2870 | if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { |
2871 | // No jQuery handlers for this event type, and it can't have inline handlers |
2872 | return; |
2873 | } |
2874 | |
2875 | // Caller can pass in an Event, Object, or just an event type string |
2876 | event = typeof event === "object" ? |
2877 | // jQuery.Event object |
2878 | event[ jQuery.expando ] ? event : |
2879 | // Object literal |
2880 | new jQuery.Event( type, event ) : |
2881 | // Just the event type (string) |
2882 | new jQuery.Event( type ); |
2883 | |
2884 | event.type = type; |
2885 | event.isTrigger = true; |
2886 | event.exclusive = exclusive; |
2887 | event.namespace = namespaces.join( "." ); |
2888 | event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null; |
2889 | ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; |
2890 | |
2891 | // Handle a global trigger |
2892 | if ( !elem ) { |
2893 | |
2894 | // TODO: Stop taunting the data cache; remove global events and always attach to document |
2895 | cache = jQuery.cache; |
2896 | for ( i in cache ) { |
2897 | if ( cache[ i ].events && cache[ i ].events[ type ] ) { |
2898 | jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); |
2899 | } |
2900 | } |
2901 | return; |
2902 | } |
2903 | |
2904 | // Clean up the event in case it is being reused |
2905 | event.result = undefined; |
2906 | if ( !event.target ) { |
2907 | event.target = elem; |
2908 | } |
2909 | |
2910 | // Clone any incoming data and prepend the event, creating the handler arg list |
2911 | data = data != null ? jQuery.makeArray( data ) : []; |
2912 | data.unshift( event ); |
2913 | |
2914 | // Allow special events to draw outside the lines |
2915 | special = jQuery.event.special[ type ] || {}; |
2916 | if ( special.trigger && special.trigger.apply( elem, data ) === false ) { |
2917 | return; |
2918 | } |
2919 | |
2920 | // Determine event propagation path in advance, per W3C events spec (#9951) |
2921 | // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) |
2922 | eventPath = [[ elem, special.bindType || type ]]; |
2923 | if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { |
2924 | |
2925 | bubbleType = special.delegateType || type; |
2926 | cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; |
2927 | for ( old = elem; cur; cur = cur.parentNode ) { |
2928 | eventPath.push([ cur, bubbleType ]); |
2929 | old = cur; |
2930 | } |
2931 | |
2932 | // Only add window if we got to document (e.g., not plain obj or detached DOM) |
2933 | if ( old === (elem.ownerDocument || document) ) { |
2934 | eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); |
2935 | } |
2936 | } |
2937 | |
2938 | // Fire handlers on the event path |
2939 | for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { |
2940 | |
2941 | cur = eventPath[i][0]; |
2942 | event.type = eventPath[i][1]; |
2943 | |
2944 | handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); |
2945 | if ( handle ) { |
2946 | handle.apply( cur, data ); |
2947 | } |
2948 | // Note that this is a bare JS function and not a jQuery handler |
2949 | handle = ontype && cur[ ontype ]; |
2950 | if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) { |
2951 | event.preventDefault(); |
2952 | } |
2953 | } |
2954 | event.type = type; |
2955 | |
2956 | // If nobody prevented the default action, do it now |
2957 | if ( !onlyHandlers && !event.isDefaultPrevented() ) { |
2958 | |
2959 | if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && |
2960 | !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { |
2961 | |
2962 | // Call a native DOM method on the target with the same name name as the event. |
2963 | // Can't use an .isFunction() check here because IE6/7 fails that test. |
2964 | // Don't do default actions on window, that's where global variables be (#6170) |
2965 | // IE<9 dies on focus/blur to hidden element (#1486) |
2966 | if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { |
2967 | |
2968 | // Don't re-trigger an onFOO event when we call its FOO() method |
2969 | old = elem[ ontype ]; |
2970 | |
2971 | if ( old ) { |
2972 | elem[ ontype ] = null; |
2973 | } |
2974 | |
2975 | // Prevent re-triggering of the same event, since we already bubbled it above |
2976 | jQuery.event.triggered = type; |
2977 | elem[ type ](); |
2978 | jQuery.event.triggered = undefined; |
2979 | |
2980 | if ( old ) { |
2981 | elem[ ontype ] = old; |
2982 | } |
2983 | } |
2984 | } |
2985 | } |
2986 | |
2987 | return event.result; |
2988 | }, |
2989 | |
2990 | dispatch: function( event ) { |
2991 | |
2992 | // Make a writable jQuery.Event from the native event object |
2993 | event = jQuery.event.fix( event || window.event ); |
2994 | |
2995 | var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related, |
2996 | handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), |
2997 | delegateCount = handlers.delegateCount, |
2998 | args = core_slice.call( arguments ), |
2999 | run_all = !event.exclusive && !event.namespace, |
3000 | special = jQuery.event.special[ event.type ] || {}, |
3001 | handlerQueue = []; |
3002 | |
3003 | // Use the fix-ed jQuery.Event rather than the (read-only) native event |
3004 | args[0] = event; |
3005 | event.delegateTarget = this; |
3006 | |
3007 | // Call the preDispatch hook for the mapped type, and let it bail if desired |
3008 | if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { |
3009 | return; |
3010 | } |
3011 | |
3012 | // Determine handlers that should run if there are delegated events |
3013 | // Avoid non-left-click bubbling in Firefox (#3861) |
3014 | if ( delegateCount && !(event.button && event.type === "click") ) { |
3015 | |
3016 | for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { |
3017 | |
3018 | // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764) |
3019 | if ( cur.disabled !== true || event.type !== "click" ) { |
3020 | selMatch = {}; |
3021 | matches = []; |
3022 | for ( i = 0; i < delegateCount; i++ ) { |
3023 | handleObj = handlers[ i ]; |
3024 | sel = handleObj.selector; |
3025 | |
3026 | if ( selMatch[ sel ] === undefined ) { |
3027 | selMatch[ sel ] = handleObj.needsContext ? |
3028 | jQuery( sel, this ).index( cur ) >= 0 : |
3029 | jQuery.find( sel, this, null, [ cur ] ).length; |
3030 | } |
3031 | if ( selMatch[ sel ] ) { |
3032 | matches.push( handleObj ); |
3033 | } |
3034 | } |
3035 | if ( matches.length ) { |
3036 | handlerQueue.push({ elem: cur, matches: matches }); |
3037 | } |
3038 | } |
3039 | } |
3040 | } |
3041 | |
3042 | // Add the remaining (directly-bound) handlers |
3043 | if ( handlers.length > delegateCount ) { |
3044 | handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); |
3045 | } |
3046 | |
3047 | // Run delegates first; they may want to stop propagation beneath us |
3048 | for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { |
3049 | matched = handlerQueue[ i ]; |
3050 | event.currentTarget = matched.elem; |
3051 | |
3052 | for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { |
3053 | handleObj = matched.matches[ j ]; |
3054 | |
3055 | // Triggered event must either 1) be non-exclusive and have no namespace, or |
3056 | // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). |
3057 | if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { |
3058 | |
3059 | event.data = handleObj.data; |
3060 | event.handleObj = handleObj; |
3061 | |
3062 | ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) |
3063 | .apply( matched.elem, args ); |
3064 | |
3065 | if ( ret !== undefined ) { |
3066 | event.result = ret; |
3067 | if ( ret === false ) { |
3068 | event.preventDefault(); |
3069 | event.stopPropagation(); |
3070 | } |
3071 | } |
3072 | } |
3073 | } |
3074 | } |
3075 | |
3076 | // Call the postDispatch hook for the mapped type |
3077 | if ( special.postDispatch ) { |
3078 | special.postDispatch.call( this, event ); |
3079 | } |
3080 | |
3081 | return event.result; |
3082 | }, |
3083 | |
3084 | // Includes some event props shared by KeyEvent and MouseEvent |
3085 | // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** |
3086 | props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), |
3087 | |
3088 | fixHooks: {}, |
3089 | |
3090 | keyHooks: { |
3091 | props: "char charCode key keyCode".split(" "), |
3092 | filter: function( event, original ) { |
3093 | |
3094 | // Add which for key events |
3095 | if ( event.which == null ) { |
3096 | event.which = original.charCode != null ? original.charCode : original.keyCode; |
3097 | } |
3098 | |
3099 | return event; |
3100 | } |
3101 | }, |
3102 | |
3103 | mouseHooks: { |
3104 | props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), |
3105 | filter: function( event, original ) { |
3106 | var eventDoc, doc, body, |
3107 | button = original.button, |
3108 | fromElement = original.fromElement; |
3109 | |
3110 | // Calculate pageX/Y if missing and clientX/Y available |
3111 | if ( event.pageX == null && original.clientX != null ) { |
3112 | eventDoc = event.target.ownerDocument || document; |
3113 | doc = eventDoc.documentElement; |
3114 | body = eventDoc.body; |
3115 | |
3116 | event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); |
3117 | event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); |
3118 | } |
3119 | |
3120 | // Add relatedTarget, if necessary |
3121 | if ( !event.relatedTarget && fromElement ) { |
3122 | event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; |
3123 | } |
3124 | |
3125 | // Add which for click: 1 === left; 2 === middle; 3 === right |
3126 | // Note: button is not normalized, so don't use it |
3127 | if ( !event.which && button !== undefined ) { |
3128 | event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); |
3129 | } |
3130 | |
3131 | return event; |
3132 | } |
3133 | }, |
3134 | |
3135 | fix: function( event ) { |
3136 | if ( event[ jQuery.expando ] ) { |
3137 | return event; |
3138 | } |
3139 | |
3140 | // Create a writable copy of the event object and normalize some properties |
3141 | var i, prop, |
3142 | originalEvent = event, |
3143 | fixHook = jQuery.event.fixHooks[ event.type ] || {}, |
3144 | copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; |
3145 | |
3146 | event = jQuery.Event( originalEvent ); |
3147 | |
3148 | for ( i = copy.length; i; ) { |
3149 | prop = copy[ --i ]; |
3150 | event[ prop ] = originalEvent[ prop ]; |
3151 | } |
3152 | |
3153 | // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) |
3154 | if ( !event.target ) { |
3155 | event.target = originalEvent.srcElement || document; |
3156 | } |
3157 | |
3158 | // Target should not be a text node (#504, Safari) |
3159 | if ( event.target.nodeType === 3 ) { |
3160 | event.target = event.target.parentNode; |
3161 | } |
3162 | |
3163 | // For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8) |
3164 | event.metaKey = !!event.metaKey; |
3165 | |
3166 | return fixHook.filter? fixHook.filter( event, originalEvent ) : event; |
3167 | }, |
3168 | |
3169 | special: { |
3170 | load: { |
3171 | // Prevent triggered image.load events from bubbling to window.load |
3172 | noBubble: true |
3173 | }, |
3174 | |
3175 | focus: { |
3176 | delegateType: "focusin" |
3177 | }, |
3178 | blur: { |
3179 | delegateType: "focusout" |
3180 | }, |
3181 | |
3182 | beforeunload: { |
3183 | setup: function( data, namespaces, eventHandle ) { |
3184 | // We only want to do this special case on windows |
3185 | if ( jQuery.isWindow( this ) ) { |
3186 | this.onbeforeunload = eventHandle; |
3187 | } |
3188 | }, |
3189 | |
3190 | teardown: function( namespaces, eventHandle ) { |
3191 | if ( this.onbeforeunload === eventHandle ) { |
3192 | this.onbeforeunload = null; |
3193 | } |
3194 | } |
3195 | } |
3196 | }, |
3197 | |
3198 | simulate: function( type, elem, event, bubble ) { |
3199 | // Piggyback on a donor event to simulate a different one. |
3200 | // Fake originalEvent to avoid donor's stopPropagation, but if the |
3201 | // simulated event prevents default then we do the same on the donor. |
3202 | var e = jQuery.extend( |
3203 | new jQuery.Event(), |
3204 | event, |
3205 | { type: type, |
3206 | isSimulated: true, |
3207 | originalEvent: {} |
3208 | } |
3209 | ); |
3210 | if ( bubble ) { |
3211 | jQuery.event.trigger( e, null, elem ); |
3212 | } else { |
3213 | jQuery.event.dispatch.call( elem, e ); |
3214 | } |
3215 | if ( e.isDefaultPrevented() ) { |
3216 | event.preventDefault(); |
3217 | } |
3218 | } |
3219 | }; |
3220 | |
3221 | // Some plugins are using, but it's undocumented/deprecated and will be removed. |
3222 | // The 1.7 special event interface should provide all the hooks needed now. |
3223 | jQuery.event.handle = jQuery.event.dispatch; |
3224 | |
3225 | jQuery.removeEvent = document.removeEventListener ? |
3226 | function( elem, type, handle ) { |
3227 | if ( elem.removeEventListener ) { |
3228 | elem.removeEventListener( type, handle, false ); |
3229 | } |
3230 | } : |
3231 | function( elem, type, handle ) { |
3232 | var name = "on" + type; |
3233 | |
3234 | if ( elem.detachEvent ) { |
3235 | |
3236 | // #8545, #7054, preventing memory leaks for custom events in IE6-8 – |
3237 | // detachEvent needed property on element, by name of that event, to properly expose it to GC |
3238 | if ( typeof elem[ name ] === "undefined" ) { |
3239 | elem[ name ] = null; |
3240 | } |
3241 | |
3242 | elem.detachEvent( name, handle ); |
3243 | } |
3244 | }; |
3245 | |
3246 | jQuery.Event = function( src, props ) { |
3247 | // Allow instantiation without the 'new' keyword |
3248 | if ( !(this instanceof jQuery.Event) ) { |
3249 | return new jQuery.Event( src, props ); |
3250 | } |
3251 | |
3252 | // Event object |
3253 | if ( src && src.type ) { |
3254 | this.originalEvent = src; |
3255 | this.type = src.type; |
3256 | |
3257 | // Events bubbling up the document may have been marked as prevented |
3258 | // by a handler lower down the tree; reflect the correct value. |
3259 | this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || |
3260 | src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; |
3261 | |
3262 | // Event type |
3263 | } else { |
3264 | this.type = src; |
3265 | } |
3266 | |
3267 | // Put explicitly provided properties onto the event object |
3268 | if ( props ) { |
3269 | jQuery.extend( this, props ); |
3270 | } |
3271 | |
3272 | // Create a timestamp if incoming event doesn't have one |
3273 | this.timeStamp = src && src.timeStamp || jQuery.now(); |
3274 | |
3275 | // Mark it as fixed |
3276 | this[ jQuery.expando ] = true; |
3277 | }; |
3278 | |
3279 | function returnFalse() { |
3280 | return false; |
3281 | } |
3282 | function returnTrue() { |
3283 | return true; |
3284 | } |
3285 | |
3286 | // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
3287 | // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
3288 | jQuery.Event.prototype = { |
3289 | preventDefault: function() { |
3290 | this.isDefaultPrevented = returnTrue; |
3291 | |
3292 | var e = this.originalEvent; |
3293 | if ( !e ) { |
3294 | return; |
3295 | } |
3296 | |
3297 | // if preventDefault exists run it on the original event |
3298 | if ( e.preventDefault ) { |
3299 | e.preventDefault(); |
3300 | |
3301 | // otherwise set the returnValue property of the original event to false (IE) |
3302 | } else { |
3303 | e.returnValue = false; |
3304 | } |
3305 | }, |
3306 | stopPropagation: function() { |
3307 | this.isPropagationStopped = returnTrue; |
3308 | |
3309 | var e = this.originalEvent; |
3310 | if ( !e ) { |
3311 | return; |
3312 | } |
3313 | // if stopPropagation exists run it on the original event |
3314 | if ( e.stopPropagation ) { |
3315 | e.stopPropagation(); |
3316 | } |
3317 | // otherwise set the cancelBubble property of the original event to true (IE) |
3318 | e.cancelBubble = true; |
3319 | }, |
3320 | stopImmediatePropagation: function() { |
3321 | this.isImmediatePropagationStopped = returnTrue; |
3322 | this.stopPropagation(); |
3323 | }, |
3324 | isDefaultPrevented: returnFalse, |
3325 | isPropagationStopped: returnFalse, |
3326 | isImmediatePropagationStopped: returnFalse |
3327 | }; |
3328 | |
3329 | // Create mouseenter/leave events using mouseover/out and event-time checks |
3330 | jQuery.each({ |
3331 | mouseenter: "mouseover", |
3332 | mouseleave: "mouseout" |
3333 | }, function( orig, fix ) { |
3334 | jQuery.event.special[ orig ] = { |
3335 | delegateType: fix, |
3336 | bindType: fix, |
3337 | |
3338 | handle: function( event ) { |
3339 | var ret, |
3340 | target = this, |
3341 | related = event.relatedTarget, |
3342 | handleObj = event.handleObj, |
3343 | selector = handleObj.selector; |
3344 | |
3345 | // For mousenter/leave call the handler if related is outside the target. |
3346 | // NB: No relatedTarget if the mouse left/entered the browser window |
3347 | if ( !related || (related !== target && !jQuery.contains( target, related )) ) { |
3348 | event.type = handleObj.origType; |
3349 | ret = handleObj.handler.apply( this, arguments ); |
3350 | event.type = fix; |
3351 | } |
3352 | return ret; |
3353 | } |
3354 | }; |
3355 | }); |
3356 | |
3357 | // IE submit delegation |
3358 | if ( !jQuery.support.submitBubbles ) { |
3359 | |
3360 | jQuery.event.special.submit = { |
3361 | setup: function() { |
3362 | // Only need this for delegated form submit events |
3363 | if ( jQuery.nodeName( this, "form" ) ) { |
3364 | return false; |
3365 | } |
3366 | |
3367 | // Lazy-add a submit handler when a descendant form may potentially be submitted |
3368 | jQuery.event.add( this, "click._submit keypress._submit", function( e ) { |
3369 | // Node name check avoids a VML-related crash in IE (#9807) |
3370 | var elem = e.target, |
3371 | form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; |
3372 | if ( form && !jQuery._data( form, "_submit_attached" ) ) { |
3373 | jQuery.event.add( form, "submit._submit", function( event ) { |
3374 | event._submit_bubble = true; |
3375 | }); |
3376 | jQuery._data( form, "_submit_attached", true ); |
3377 | } |
3378 | }); |
3379 | // return undefined since we don't need an event listener |
3380 | }, |
3381 | |
3382 | postDispatch: function( event ) { |
3383 | // If form was submitted by the user, bubble the event up the tree |
3384 | if ( event._submit_bubble ) { |
3385 | delete event._submit_bubble; |
3386 | if ( this.parentNode && !event.isTrigger ) { |
3387 | jQuery.event.simulate( "submit", this.parentNode, event, true ); |
3388 | } |
3389 | } |
3390 | }, |
3391 | |
3392 | teardown: function() { |
3393 | // Only need this for delegated form submit events |
3394 | if ( jQuery.nodeName( this, "form" ) ) { |
3395 | return false; |
3396 | } |
3397 | |
3398 | // Remove delegated handlers; cleanData eventually reaps submit handlers attached above |
3399 | jQuery.event.remove( this, "._submit" ); |
3400 | } |
3401 | }; |
3402 | } |
3403 | |
3404 | // IE change delegation and checkbox/radio fix |
3405 | if ( !jQuery.support.changeBubbles ) { |
3406 | |
3407 | jQuery.event.special.change = { |
3408 | |
3409 | setup: function() { |
3410 | |
3411 | if ( rformElems.test( this.nodeName ) ) { |
3412 | // IE doesn't fire change on a check/radio until blur; trigger it on click |
3413 | // after a propertychange. Eat the blur-change in special.change.handle. |
3414 | // This still fires onchange a second time for check/radio after blur. |
3415 | if ( this.type === "checkbox" || this.type === "radio" ) { |
3416 | jQuery.event.add( this, "propertychange._change", function( event ) { |
3417 | if ( event.originalEvent.propertyName === "checked" ) { |
3418 | this._just_changed = true; |
3419 | } |
3420 | }); |
3421 | jQuery.event.add( this, "click._change", function( event ) { |
3422 | if ( this._just_changed && !event.isTrigger ) { |
3423 | this._just_changed = false; |
3424 | } |
3425 | // Allow triggered, simulated change events (#11500) |
3426 | jQuery.event.simulate( "change", this, event, true ); |
3427 | }); |
3428 | } |
3429 | return false; |
3430 | } |
3431 | // Delegated event; lazy-add a change handler on descendant inputs |
3432 | jQuery.event.add( this, "beforeactivate._change", function( e ) { |
3433 | var elem = e.target; |
3434 | |
3435 | if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) { |
3436 | jQuery.event.add( elem, "change._change", function( event ) { |
3437 | if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { |
3438 | jQuery.event.simulate( "change", this.parentNode, event, true ); |
3439 | } |
3440 | }); |
3441 | jQuery._data( elem, "_change_attached", true ); |
3442 | } |
3443 | }); |
3444 | }, |
3445 | |
3446 | handle: function( event ) { |
3447 | var elem = event.target; |
3448 | |
3449 | // Swallow native change events from checkbox/radio, we already triggered them above |
3450 | if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { |
3451 | return event.handleObj.handler.apply( this, arguments ); |
3452 | } |
3453 | }, |
3454 | |
3455 | teardown: function() { |
3456 | jQuery.event.remove( this, "._change" ); |
3457 | |
3458 | return !rformElems.test( this.nodeName ); |
3459 | } |
3460 | }; |
3461 | } |
3462 | |
3463 | // Create "bubbling" focus and blur events |
3464 | if ( !jQuery.support.focusinBubbles ) { |
3465 | jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
3466 | |
3467 | // Attach a single capturing handler while someone wants focusin/focusout |
3468 | var attaches = 0, |
3469 | handler = function( event ) { |
3470 | jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); |
3471 | }; |
3472 | |
3473 | jQuery.event.special[ fix ] = { |
3474 | setup: function() { |
3475 | if ( attaches++ === 0 ) { |
3476 | document.addEventListener( orig, handler, true ); |
3477 | } |
3478 | }, |
3479 | teardown: function() { |
3480 | if ( --attaches === 0 ) { |
3481 | document.removeEventListener( orig, handler, true ); |
3482 | } |
3483 | } |
3484 | }; |
3485 | }); |
3486 | } |
3487 | |
3488 | jQuery.fn.extend({ |
3489 | |
3490 | on: function( types, selector, data, fn, /*INTERNAL*/ one ) { |
3491 | var origFn, type; |
3492 | |
3493 | // Types can be a map of types/handlers |
3494 | if ( typeof types === "object" ) { |
3495 | // ( types-Object, selector, data ) |
3496 | if ( typeof selector !== "string" ) { // && selector != null |
3497 | // ( types-Object, data ) |
3498 | data = data || selector; |
3499 | selector = undefined; |
3500 | } |
3501 | for ( type in types ) { |
3502 | this.on( type, selector, data, types[ type ], one ); |
3503 | } |
3504 | return this; |
3505 | } |
3506 | |
3507 | if ( data == null && fn == null ) { |
3508 | // ( types, fn ) |
3509 | fn = selector; |
3510 | data = selector = undefined; |
3511 | } else if ( fn == null ) { |
3512 | if ( typeof selector === "string" ) { |
3513 | // ( types, selector, fn ) |
3514 | fn = data; |
3515 | data = undefined; |
3516 | } else { |
3517 | // ( types, data, fn ) |
3518 | fn = data; |
3519 | data = selector; |
3520 | selector = undefined; |
3521 | } |
3522 | } |
3523 | if ( fn === false ) { |
3524 | fn = returnFalse; |
3525 | } else if ( !fn ) { |
3526 | return this; |
3527 | } |
3528 | |
3529 | if ( one === 1 ) { |
3530 | origFn = fn; |
3531 | fn = function( event ) { |
3532 | // Can use an empty set, since event contains the info |
3533 | jQuery().off( event ); |
3534 | return origFn.apply( this, arguments ); |
3535 | }; |
3536 | // Use same guid so caller can remove using origFn |
3537 | fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); |
3538 | } |
3539 | return this.each( function() { |
3540 | jQuery.event.add( this, types, fn, data, selector ); |
3541 | }); |
3542 | }, |
3543 | one: function( types, selector, data, fn ) { |
3544 | return this.on( types, selector, data, fn, 1 ); |
3545 | }, |
3546 | off: function( types, selector, fn ) { |
3547 | var handleObj, type; |
3548 | if ( types && types.preventDefault && types.handleObj ) { |
3549 | // ( event ) dispatched jQuery.Event |
3550 | handleObj = types.handleObj; |
3551 | jQuery( types.delegateTarget ).off( |
3552 | handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, |
3553 | handleObj.selector, |
3554 | handleObj.handler |
3555 | ); |
3556 | return this; |
3557 | } |
3558 | if ( typeof types === "object" ) { |
3559 | // ( types-object [, selector] ) |
3560 | for ( type in types ) { |
3561 | this.off( type, selector, types[ type ] ); |
3562 | } |
3563 | return this; |
3564 | } |
3565 | if ( selector === false || typeof selector === "function" ) { |
3566 | // ( types [, fn] ) |
3567 | fn = selector; |
3568 | selector = undefined; |
3569 | } |
3570 | if ( fn === false ) { |
3571 | fn = returnFalse; |
3572 | } |
3573 | return this.each(function() { |
3574 | jQuery.event.remove( this, types, fn, selector ); |
3575 | }); |
3576 | }, |
3577 | |
3578 | bind: function( types, data, fn ) { |
3579 | return this.on( types, null, data, fn ); |
3580 | }, |
3581 | unbind: function( types, fn ) { |
3582 | return this.off( types, null, fn ); |
3583 | }, |
3584 | |
3585 | live: function( types, data, fn ) { |
3586 | jQuery( this.context ).on( types, this.selector, data, fn ); |
3587 | return this; |
3588 | }, |
3589 | die: function( types, fn ) { |
3590 | jQuery( this.context ).off( types, this.selector || "**", fn ); |
3591 | return this; |
3592 | }, |
3593 | |
3594 | delegate: function( selector, types, data, fn ) { |
3595 | return this.on( types, selector, data, fn ); |
3596 | }, |
3597 | undelegate: function( selector, types, fn ) { |
3598 | // ( namespace ) or ( selector, types [, fn] ) |
3599 | return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); |
3600 | }, |
3601 | |
3602 | trigger: function( type, data ) { |
3603 | return this.each(function() { |
3604 | jQuery.event.trigger( type, data, this ); |
3605 | }); |
3606 | }, |
3607 | triggerHandler: function( type, data ) { |
3608 | if ( this[0] ) { |
3609 | return jQuery.event.trigger( type, data, this[0], true ); |
3610 | } |
3611 | }, |
3612 | |
3613 | toggle: function( fn ) { |
3614 | // Save reference to arguments for access in closure |
3615 | var args = arguments, |
3616 | guid = fn.guid || jQuery.guid++, |
3617 | i = 0, |
3618 | toggler = function( event ) { |
3619 | // Figure out which function to execute |
3620 | var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; |
3621 | jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); |
3622 | |
3623 | // Make sure that clicks stop |
3624 | event.preventDefault(); |
3625 | |
3626 | // and execute the function |
3627 | return args[ lastToggle ].apply( this, arguments ) || false; |
3628 | }; |
3629 | |
3630 | // link all the functions, so any of them can unbind this click handler |
3631 | toggler.guid = guid; |
3632 | while ( i < args.length ) { |
3633 | args[ i++ ].guid = guid; |
3634 | } |
3635 | |
3636 | return this.click( toggler ); |
3637 | }, |
3638 | |
3639 | hover: function( fnOver, fnOut ) { |
3640 | return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
3641 | } |
3642 | }); |
3643 | |
3644 | jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + |
3645 | "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
3646 | "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { |
3647 | |
3648 | // Handle event binding |
3649 | jQuery.fn[ name ] = function( data, fn ) { |
3650 | if ( fn == null ) { |
3651 | fn = data; |
3652 | data = null; |
3653 | } |
3654 | |
3655 | return arguments.length > 0 ? |
3656 | this.on( name, null, data, fn ) : |
3657 | this.trigger( name ); |
3658 | }; |
3659 | |
3660 | if ( rkeyEvent.test( name ) ) { |
3661 | jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; |
3662 | } |
3663 | |
3664 | if ( rmouseEvent.test( name ) ) { |
3665 | jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; |
3666 | } |
3667 | }); |
3668 | /*!\r |
3669 | * Sizzle CSS Selector Engine\r |
3670 | * Copyright 2012 jQuery Foundation and other contributors\r |
3671 | * Released under the MIT license\r |
3672 | * http://sizzlejs.com/\r |
3673 | */\r |
3674 | (function( window, undefined ) {\r |
3675 | \r |
3676 | var cachedruns,\r |
3677 | assertGetIdNotName,\r |
3678 | Expr,\r |
3679 | getText,\r |
3680 | isXML,\r |
3681 | contains,\r |
3682 | compile,\r |
3683 | sortOrder,\r |
3684 | hasDuplicate,\r |
3685 | outermostContext,\r |
3686 | \r |
3687 | baseHasDuplicate = true,\r |
3688 | strundefined = "undefined",\r |
3689 | \r |
3690 | expando = ( "sizcache" + Math.random() ).replace( ".", "" ),\r |
3691 | \r |
3692 | Token = String,\r |
3693 | document = window.document,\r |
3694 | docElem = document.documentElement,\r |
3695 | dirruns = 0,\r |
3696 | done = 0,\r |
3697 | pop = [].pop,\r |
3698 | push = [].push,\r |
3699 | slice = [].slice,\r |
3700 | // Use a stripped-down indexOf if a native one is unavailable\r |
3701 | indexOf = [].indexOf || function( elem ) {\r |
3702 | var i = 0,\r |
3703 | len = this.length;\r |
3704 | for ( ; i < len; i++ ) {\r |
3705 | if ( this[i] === elem ) {\r |
3706 | return i;\r |
3707 | }\r |
3708 | }\r |
3709 | return -1;\r |
3710 | },\r |
3711 | \r |
3712 | // Augment a function for special use by Sizzle\r |
3713 | markFunction = function( fn, value ) {\r |
3714 | fn[ expando ] = value == null || value;\r |
3715 | return fn;\r |
3716 | },\r |
3717 | \r |
3718 | createCache = function() {\r |
3719 | var cache = {},\r |
3720 | keys = [];\r |
3721 | \r |
3722 | return markFunction(function( key, value ) {\r |
3723 | // Only keep the most recent entries\r |
3724 | if ( keys.push( key ) > Expr.cacheLength ) {\r |
3725 | delete cache[ keys.shift() ];\r |
3726 | }\r |
3727 | \r |
3728 | return (cache[ key ] = value);\r |
3729 | }, cache );\r |
3730 | },\r |
3731 | \r |
3732 | classCache = createCache(),\r |
3733 | tokenCache = createCache(),\r |
3734 | compilerCache = createCache(),\r |
3735 | \r |
3736 | // Regex\r |
3737 | \r |
3738 | // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace\r |
3739 | whitespace = "[\\x20\\t\\r\\n\\f]",\r |
3740 | // http://www.w3.org/TR/css3-syntax/#characters\r |
3741 | characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",\r |
3742 | \r |
3743 | // Loosely modeled on CSS identifier characters\r |
3744 | // An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors)\r |
3745 | // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier\r |
3746 | identifier = characterEncoding.replace( "w", "w#" ),\r |
3747 | \r |
3748 | // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors\r |
3749 | operators = "([*^$|!~]?=)",\r |
3750 | attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +\r |
3751 | "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",\r |
3752 | \r |
3753 | // Prefer arguments not in parens/brackets,\r |
3754 | // then attribute selectors and non-pseudos (denoted by :),\r |
3755 | // then anything else\r |
3756 | // These preferences are here to reduce the number of selectors\r |
3757 | // needing tokenize in the PSEUDO preFilter\r |
3758 | pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",\r |
3759 | \r |
3760 | // For matchExpr.POS and matchExpr.needsContext\r |
3761 | pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +\r |
3762 | "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",\r |
3763 | \r |
3764 | // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter\r |
3765 | rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),\r |
3766 | \r |
3767 | rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),\r |
3768 | rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),\r |
3769 | rpseudo = new RegExp( pseudos ),\r |
3770 | \r |
3771 | // Easily-parseable/retrievable ID or TAG or CLASS selectors\r |
3772 | rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,\r |
3773 | \r |
3774 | rnot = /^:not/,\r |
3775 | rsibling = /[\x20\t\r\n\f]*[+~]/,\r |
3776 | rendsWithNot = /:not\($/,\r |
3777 | \r |
3778 | rheader = /h\d/i,\r |
3779 | rinputs = /input|select|textarea|button/i,\r |
3780 | \r |
3781 | rbackslash = /\\(?!\\)/g,\r |
3782 | \r |
3783 | matchExpr = {\r |
3784 | "ID": new RegExp( "^#(" + characterEncoding + ")" ),\r |
3785 | "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),\r |
3786 | "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),\r |
3787 | "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),\r |
3788 | "ATTR": new RegExp( "^" + attributes ),\r |
3789 | "PSEUDO": new RegExp( "^" + pseudos ),\r |
3790 | "POS": new RegExp( pos, "i" ),\r |
3791 | "CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace +\r |
3792 | "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +\r |
3793 | "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),\r |
3794 | // For use in libraries implementing .is()\r |
3795 | "needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )\r |
3796 | },\r |
3797 | \r |
3798 | // Support\r |
3799 | \r |
3800 | // Used for testing something on an element\r |
3801 | assert = function( fn ) {\r |
3802 | var div = document.createElement("div");\r |
3803 | \r |
3804 | try {\r |
3805 | return fn( div );\r |
3806 | } catch (e) {\r |
3807 | return false;\r |
3808 | } finally {\r |
3809 | // release memory in IE\r |
3810 | div = null;\r |
3811 | }\r |
3812 | },\r |
3813 | \r |
3814 | // Check if getElementsByTagName("*") returns only elements\r |
3815 | assertTagNameNoComments = assert(function( div ) {\r |
3816 | div.appendChild( document.createComment("") );\r |
3817 | return !div.getElementsByTagName("*").length;\r |
3818 | }),\r |
3819 | \r |
3820 | // Check if getAttribute returns normalized href attributes\r |
3821 | assertHrefNotNormalized = assert(function( div ) {\r |
3822 | div.innerHTML = "<a href='#'></a>";\r |
3823 | return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&\r |
3824 | div.firstChild.getAttribute("href") === "#";\r |
3825 | }),\r |
3826 | \r |
3827 | // Check if attributes should be retrieved by attribute nodes\r |
3828 | assertAttributes = assert(function( div ) {\r |
3829 | div.innerHTML = "<select></select>";\r |
3830 | var type = typeof div.lastChild.getAttribute("multiple");\r |
3831 | // IE8 returns a string for some attributes even when not present\r |
3832 | return type !== "boolean" && type !== "string";\r |
3833 | }),\r |
3834 | \r |
3835 | // Check if getElementsByClassName can be trusted\r |
3836 | assertUsableClassName = assert(function( div ) {\r |
3837 | // Opera can't find a second classname (in 9.6)\r |
3838 | div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";\r |
3839 | if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {\r |
3840 | return false;\r |
3841 | }\r |
3842 | \r |
3843 | // Safari 3.2 caches class attributes and doesn't catch changes\r |
3844 | div.lastChild.className = "e";\r |
3845 | return div.getElementsByClassName("e").length === 2;\r |
3846 | }),\r |
3847 | \r |
3848 | // Check if getElementById returns elements by name\r |
3849 | // Check if getElementsByName privileges form controls or returns elements by ID\r |
3850 | assertUsableName = assert(function( div ) {\r |
3851 | // Inject content\r |
3852 | div.id = expando + 0;\r |
3853 | div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>";\r |
3854 | docElem.insertBefore( div, docElem.firstChild );\r |
3855 | \r |
3856 | // Test\r |
3857 | var pass = document.getElementsByName &&\r |
3858 | // buggy browsers will return fewer than the correct 2\r |
3859 | document.getElementsByName( expando ).length === 2 +\r |
3860 | // buggy browsers will return more than the correct 0\r |
3861 | document.getElementsByName( expando + 0 ).length;\r |
3862 | assertGetIdNotName = !document.getElementById( expando );\r |
3863 | \r |
3864 | // Cleanup\r |
3865 | docElem.removeChild( div );\r |
3866 | \r |
3867 | return pass;\r |
3868 | });\r |
3869 | \r |
3870 | // If slice is not available, provide a backup\r |
3871 | try {\r |
3872 | slice.call( docElem.childNodes, 0 )[0].nodeType;\r |
3873 | } catch ( e ) {\r |
3874 | slice = function( i ) {\r |
3875 | var elem,\r |
3876 | results = [];\r |
3877 | for ( ; (elem = this[i]); i++ ) {\r |
3878 | results.push( elem );\r |
3879 | }\r |
3880 | return results;\r |
3881 | };\r |
3882 | }\r |
3883 | \r |
3884 | function Sizzle( selector, context, results, seed ) {\r |
3885 | results = results || [];\r |
3886 | context = context || document;\r |
3887 | var match, elem, xml, m,\r |
3888 | nodeType = context.nodeType;\r |
3889 | \r |
3890 | if ( !selector || typeof selector !== "string" ) {\r |
3891 | return results;\r |
3892 | }\r |
3893 | \r |
3894 | if ( nodeType !== 1 && nodeType !== 9 ) {\r |
3895 | return [];\r |
3896 | }\r |
3897 | \r |
3898 | xml = isXML( context );\r |
3899 | \r |
3900 | if ( !xml && !seed ) {\r |
3901 | if ( (match = rquickExpr.exec( selector )) ) {\r |
3902 | // Speed-up: Sizzle("#ID")\r |
3903 | if ( (m = match[1]) ) {\r |
3904 | if ( nodeType === 9 ) {\r |
3905 | elem = context.getElementById( m );\r |
3906 | // Check parentNode to catch when Blackberry 4.6 returns\r |
3907 | // nodes that are no longer in the document #6963\r |
3908 | if ( elem && elem.parentNode ) {\r |
3909 | // Handle the case where IE, Opera, and Webkit return items\r |
3910 | // by name instead of ID\r |
3911 | if ( elem.id === m ) {\r |
3912 | results.push( elem );\r |
3913 | return results;\r |
3914 | }\r |
3915 | } else {\r |
3916 | return results;\r |
3917 | }\r |
3918 | } else {\r |
3919 | // Context is not a document\r |
3920 | if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&\r |
3921 | contains( context, elem ) && elem.id === m ) {\r |
3922 | results.push( elem );\r |
3923 | return results;\r |
3924 | }\r |
3925 | }\r |
3926 | \r |
3927 | // Speed-up: Sizzle("TAG")\r |
3928 | } else if ( match[2] ) {\r |
3929 | push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );\r |
3930 | return results;\r |
3931 | \r |
3932 | // Speed-up: Sizzle(".CLASS")\r |
3933 | } else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) {\r |
3934 | push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );\r |
3935 | return results;\r |
3936 | }\r |
3937 | }\r |
3938 | }\r |
3939 | \r |
3940 | // All others\r |
3941 | return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );\r |
3942 | }\r |
3943 | \r |
3944 | Sizzle.matches = function( expr, elements ) {\r |
3945 | return Sizzle( expr, null, null, elements );\r |
3946 | };\r |
3947 | \r |
3948 | Sizzle.matchesSelector = function( elem, expr ) {\r |
3949 | return Sizzle( expr, null, null, [ elem ] ).length > 0;\r |
3950 | };\r |
3951 | \r |
3952 | // Returns a function to use in pseudos for input types\r |
3953 | function createInputPseudo( type ) {\r |
3954 | return function( elem ) {\r |
3955 | var name = elem.nodeName.toLowerCase();\r |
3956 | return name === "input" && elem.type === type;\r |
3957 | };\r |
3958 | }\r |
3959 | \r |
3960 | // Returns a function to use in pseudos for buttons\r |
3961 | function createButtonPseudo( type ) {\r |
3962 | return function( elem ) {\r |
3963 | var name = elem.nodeName.toLowerCase();\r |
3964 | return (name === "input" || name === "button") && elem.type === type;\r |
3965 | };\r |
3966 | }\r |
3967 | \r |
3968 | // Returns a function to use in pseudos for positionals\r |
3969 | function createPositionalPseudo( fn ) {\r |
3970 | return markFunction(function( argument ) {\r |
3971 | argument = +argument;\r |
3972 | return markFunction(function( seed, matches ) {\r |
3973 | var j,\r |
3974 | matchIndexes = fn( [], seed.length, argument ),\r |
3975 | i = matchIndexes.length;\r |
3976 | \r |
3977 | // Match elements found at the specified indexes\r |
3978 | while ( i-- ) {\r |
3979 | if ( seed[ (j = matchIndexes[i]) ] ) {\r |
3980 | seed[j] = !(matches[j] = seed[j]);\r |
3981 | }\r |
3982 | }\r |
3983 | });\r |
3984 | });\r |
3985 | }\r |
3986 | \r |
3987 | /**\r |
3988 | * Utility function for retrieving the text value of an array of DOM nodes\r |
3989 | * @param {Array|Element} elem\r |
3990 | */\r |
3991 | getText = Sizzle.getText = function( elem ) {\r |
3992 | var node,\r |
3993 | ret = "",\r |
3994 | i = 0,\r |
3995 | nodeType = elem.nodeType;\r |
3996 | \r |
3997 | if ( nodeType ) {\r |
3998 | if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {\r |
3999 | // Use textContent for elements\r |
4000 | // innerText usage removed for consistency of new lines (see #11153)\r |
4001 | if ( typeof elem.textContent === "string" ) {\r |
4002 | return elem.textContent;\r |
4003 | } else {\r |
4004 | // Traverse its children\r |
4005 | for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {\r |
4006 | ret += getText( elem );\r |
4007 | }\r |
4008 | }\r |
4009 | } else if ( nodeType === 3 || nodeType === 4 ) {\r |
4010 | return elem.nodeValue;\r |
4011 | }\r |
4012 | // Do not include comment or processing instruction nodes\r |
4013 | } else {\r |
4014 | \r |
4015 | // If no nodeType, this is expected to be an array\r |
4016 | for ( ; (node = elem[i]); i++ ) {\r |
4017 | // Do not traverse comment nodes\r |
4018 | ret += getText( node );\r |
4019 | }\r |
4020 | }\r |
4021 | return ret;\r |
4022 | };\r |
4023 | \r |
4024 | isXML = Sizzle.isXML = function( elem ) {\r |
4025 | // documentElement is verified for cases where it doesn't yet exist\r |
4026 | // (such as loading iframes in IE - #4833)\r |
4027 | var documentElement = elem && (elem.ownerDocument || elem).documentElement;\r |
4028 | return documentElement ? documentElement.nodeName !== "HTML" : false;\r |
4029 | };\r |
4030 | \r |
4031 | // Element contains another\r |
4032 | contains = Sizzle.contains = docElem.contains ?\r |
4033 | function( a, b ) {\r |
4034 | var adown = a.nodeType === 9 ? a.documentElement : a,\r |
4035 | bup = b && b.parentNode;\r |
4036 | return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) );\r |
4037 | } :\r |
4038 | docElem.compareDocumentPosition ?\r |
4039 | function( a, b ) {\r |
4040 | return b && !!( a.compareDocumentPosition( b ) & 16 );\r |
4041 | } :\r |
4042 | function( a, b ) {\r |
4043 | while ( (b = b.parentNode) ) {\r |
4044 | if ( b === a ) {\r |
4045 | return true;\r |
4046 | }\r |
4047 | }\r |
4048 | return false;\r |
4049 | };\r |
4050 | \r |
4051 | Sizzle.attr = function( elem, name ) {\r |
4052 | var val,\r |
4053 | xml = isXML( elem );\r |
4054 | \r |
4055 | if ( !xml ) {\r |
4056 | name = name.toLowerCase();\r |
4057 | }\r |
4058 | if ( (val = Expr.attrHandle[ name ]) ) {\r |
4059 | return val( elem );\r |
4060 | }\r |
4061 | if ( xml || assertAttributes ) {\r |
4062 | return elem.getAttribute( name );\r |
4063 | }\r |
4064 | val = elem.getAttributeNode( name );\r |
4065 | return val ?\r |
4066 | typeof elem[ name ] === "boolean" ?\r |
4067 | elem[ name ] ? name : null :\r |
4068 | val.specified ? val.value : null :\r |
4069 | null;\r |
4070 | };\r |
4071 | \r |
4072 | Expr = Sizzle.selectors = {\r |
4073 | \r |
4074 | // Can be adjusted by the user\r |
4075 | cacheLength: 50,\r |
4076 | \r |
4077 | createPseudo: markFunction,\r |
4078 | \r |
4079 | match: matchExpr,\r |
4080 | \r |
4081 | // IE6/7 return a modified href\r |
4082 | attrHandle: assertHrefNotNormalized ?\r |
4083 | {} :\r |
4084 | {\r |
4085 | "href": function( elem ) {\r |
4086 | return elem.getAttribute( "href", 2 );\r |
4087 | },\r |
4088 | "type": function( elem ) {\r |
4089 | return elem.getAttribute("type");\r |
4090 | }\r |
4091 | },\r |
4092 | \r |
4093 | find: {\r |
4094 | "ID": assertGetIdNotName ?\r |
4095 | function( id, context, xml ) {\r |
4096 | if ( typeof context.getElementById !== strundefined && !xml ) {\r |
4097 | var m = context.getElementById( id );\r |
4098 | // Check parentNode to catch when Blackberry 4.6 returns\r |
4099 | // nodes that are no longer in the document #6963\r |
4100 | return m && m.parentNode ? [m] : [];\r |
4101 | }\r |
4102 | } :\r |
4103 | function( id, context, xml ) {\r |
4104 | if ( typeof context.getElementById !== strundefined && !xml ) {\r |
4105 | var m = context.getElementById( id );\r |
4106 | \r |
4107 | return m ?\r |
4108 | m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?\r |
4109 | [m] :\r |
4110 | undefined :\r |
4111 | [];\r |
4112 | }\r |
4113 | },\r |
4114 | \r |
4115 | "TAG": assertTagNameNoComments ?\r |
4116 | function( tag, context ) {\r |
4117 | if ( typeof context.getElementsByTagName !== strundefined ) {\r |
4118 | return context.getElementsByTagName( tag );\r |
4119 | }\r |
4120 | } :\r |
4121 | function( tag, context ) {\r |
4122 | var results = context.getElementsByTagName( tag );\r |
4123 | \r |
4124 | // Filter out possible comments\r |
4125 | if ( tag === "*" ) {\r |
4126 | var elem,\r |
4127 | tmp = [],\r |
4128 | i = 0;\r |
4129 | \r |
4130 | for ( ; (elem = results[i]); i++ ) {\r |
4131 | if ( elem.nodeType === 1 ) {\r |
4132 | tmp.push( elem );\r |
4133 | }\r |
4134 | }\r |
4135 | \r |
4136 | return tmp;\r |
4137 | }\r |
4138 | return results;\r |
4139 | },\r |
4140 | \r |
4141 | "NAME": assertUsableName && function( tag, context ) {\r |
4142 | if ( typeof context.getElementsByName !== strundefined ) {\r |
4143 | return context.getElementsByName( name );\r |
4144 | }\r |
4145 | },\r |
4146 | \r |
4147 | "CLASS": assertUsableClassName && function( className, context, xml ) {\r |
4148 | if ( typeof context.getElementsByClassName !== strundefined && !xml ) {\r |
4149 | return context.getElementsByClassName( className );\r |
4150 | }\r |
4151 | }\r |
4152 | },\r |
4153 | \r |
4154 | relative: {\r |
4155 | ">": { dir: "parentNode", first: true },\r |
4156 | " ": { dir: "parentNode" },\r |
4157 | "+": { dir: "previousSibling", first: true },\r |
4158 | "~": { dir: "previousSibling" }\r |
4159 | },\r |
4160 | \r |
4161 | preFilter: {\r |
4162 | "ATTR": function( match ) {\r |
4163 | match[1] = match[1].replace( rbackslash, "" );\r |
4164 | \r |
4165 | // Move the given value to match[3] whether quoted or unquoted\r |
4166 | match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" );\r |
4167 | \r |
4168 | if ( match[2] === "~=" ) {\r |
4169 | match[3] = " " + match[3] + " ";\r |
4170 | }\r |
4171 | \r |
4172 | return match.slice( 0, 4 );\r |
4173 | },\r |
4174 | \r |
4175 | "CHILD": function( match ) {\r |
4176 | /* matches from matchExpr["CHILD"]\r |
4177 | 1 type (only|nth|...)\r |
4178 | 2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)\r |
4179 | 3 xn-component of xn+y argument ([+-]?\d*n|)\r |
4180 | 4 sign of xn-component\r |
4181 | 5 x of xn-component\r |
4182 | 6 sign of y-component\r |
4183 | 7 y of y-component\r |
4184 | */\r |
4185 | match[1] = match[1].toLowerCase();\r |
4186 | \r |
4187 | if ( match[1] === "nth" ) {\r |
4188 | // nth-child requires argument\r |
4189 | if ( !match[2] ) {\r |
4190 | Sizzle.error( match[0] );\r |
4191 | }\r |
4192 | \r |
4193 | // numeric x and y parameters for Expr.filter.CHILD\r |
4194 | // remember that false/true cast respectively to 0/1\r |
4195 | match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) );\r |
4196 | match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" );\r |
4197 | \r |
4198 | // other types prohibit arguments\r |
4199 | } else if ( match[2] ) {\r |
4200 | Sizzle.error( match[0] );\r |
4201 | }\r |
4202 | \r |
4203 | return match;\r |
4204 | },\r |
4205 | \r |
4206 | "PSEUDO": function( match ) {\r |
4207 | var unquoted, excess;\r |
4208 | if ( matchExpr["CHILD"].test( match[0] ) ) {\r |
4209 | return null;\r |
4210 | }\r |
4211 | \r |
4212 | if ( match[3] ) {\r |
4213 | match[2] = match[3];\r |
4214 | } else if ( (unquoted = match[4]) ) {\r |
4215 | // Only check arguments that contain a pseudo\r |
4216 | if ( rpseudo.test(unquoted) &&\r |
4217 | // Get excess from tokenize (recursively)\r |
4218 | (excess = tokenize( unquoted, true )) &&\r |
4219 | // advance to the next closing parenthesis\r |
4220 | (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {\r |
4221 | \r |
4222 | // excess is a negative index\r |
4223 | unquoted = unquoted.slice( 0, excess );\r |
4224 | match[0] = match[0].slice( 0, excess );\r |
4225 | }\r |
4226 | match[2] = unquoted;\r |
4227 | }\r |
4228 | \r |
4229 | // Return only captures needed by the pseudo filter method (type and argument)\r |
4230 | return match.slice( 0, 3 );\r |
4231 | }\r |
4232 | },\r |
4233 | \r |
4234 | filter: {\r |
4235 | "ID": assertGetIdNotName ?\r |
4236 | function( id ) {\r |
4237 | id = id.replace( rbackslash, "" );\r |
4238 | return function( elem ) {\r |
4239 | return elem.getAttribute("id") === id;\r |
4240 | };\r |
4241 | } :\r |
4242 | function( id ) {\r |
4243 | id = id.replace( rbackslash, "" );\r |
4244 | return function( elem ) {\r |
4245 | var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");\r |
4246 | return node && node.value === id;\r |
4247 | };\r |
4248 | },\r |
4249 | \r |
4250 | "TAG": function( nodeName ) {\r |
4251 | if ( nodeName === "*" ) {\r |
4252 | return function() { return true; };\r |
4253 | }\r |
4254 | nodeName = nodeName.replace( rbackslash, "" ).toLowerCase();\r |
4255 | \r |
4256 | return function( elem ) {\r |
4257 | return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;\r |
4258 | };\r |
4259 | },\r |
4260 | \r |
4261 | "CLASS": function( className ) {\r |
4262 | var pattern = classCache[ expando ][ className ];\r |
4263 | if ( !pattern ) {\r |
4264 | pattern = classCache( className, new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)") );\r |
4265 | }\r |
4266 | return function( elem ) {\r |
4267 | return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );\r |
4268 | };\r |
4269 | },\r |
4270 | \r |
4271 | "ATTR": function( name, operator, check ) {\r |
4272 | return function( elem, context ) {\r |
4273 | var result = Sizzle.attr( elem, name );\r |
4274 | \r |
4275 | if ( result == null ) {\r |
4276 | return operator === "!=";\r |
4277 | }\r |
4278 | if ( !operator ) {\r |
4279 | return true;\r |
4280 | }\r |
4281 | \r |
4282 | result += "";\r |
4283 | \r |
4284 | return operator === "=" ? result === check :\r |
4285 | operator === "!=" ? result !== check :\r |
4286 | operator === "^=" ? check && result.indexOf( check ) === 0 :\r |
4287 | operator === "*=" ? check && result.indexOf( check ) > -1 :\r |
4288 | operator === "$=" ? check && result.substr( result.length - check.length ) === check :\r |
4289 | operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :\r |
4290 | operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :\r |
4291 | false;\r |
4292 | };\r |
4293 | },\r |
4294 | \r |
4295 | "CHILD": function( type, argument, first, last ) {\r |
4296 | \r |
4297 | if ( type === "nth" ) {\r |
4298 | return function( elem ) {\r |
4299 | var node, diff,\r |
4300 | parent = elem.parentNode;\r |
4301 | \r |
4302 | if ( first === 1 && last === 0 ) {\r |
4303 | return true;\r |
4304 | }\r |
4305 | \r |
4306 | if ( parent ) {\r |
4307 | diff = 0;\r |
4308 | for ( node = parent.firstChild; node; node = node.nextSibling ) {\r |
4309 | if ( node.nodeType === 1 ) {\r |
4310 | diff++;\r |
4311 | if ( elem === node ) {\r |
4312 | break;\r |
4313 | }\r |
4314 | }\r |
4315 | }\r |
4316 | }\r |
4317 | \r |
4318 | // Incorporate the offset (or cast to NaN), then check against cycle size\r |
4319 | diff -= last;\r |
4320 | return diff === first || ( diff % first === 0 && diff / first >= 0 );\r |
4321 | };\r |
4322 | }\r |
4323 | \r |
4324 | return function( elem ) {\r |
4325 | var node = elem;\r |
4326 | \r |
4327 | switch ( type ) {\r |
4328 | case "only":\r |
4329 | case "first":\r |
4330 | while ( (node = node.previousSibling) ) {\r |
4331 | if ( node.nodeType === 1 ) {\r |
4332 | return false;\r |
4333 | }\r |
4334 | }\r |
4335 | \r |
4336 | if ( type === "first" ) {\r |
4337 | return true;\r |
4338 | }\r |
4339 | \r |
4340 | node = elem;\r |
4341 | \r |
4342 | /* falls through */\r |
4343 | case "last":\r |
4344 | while ( (node = node.nextSibling) ) {\r |
4345 | if ( node.nodeType === 1 ) {\r |
4346 | return false;\r |
4347 | }\r |
4348 | }\r |
4349 | \r |
4350 | return true;\r |
4351 | }\r |
4352 | };\r |
4353 | },\r |
4354 | \r |
4355 | "PSEUDO": function( pseudo, argument ) {\r |
4356 | // pseudo-class names are case-insensitive\r |
4357 | // http://www.w3.org/TR/selectors/#pseudo-classes\r |
4358 | // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters\r |
4359 | // Remember that setFilters inherits from pseudos\r |
4360 | var args,\r |
4361 | fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||\r |
4362 | Sizzle.error( "unsupported pseudo: " + pseudo );\r |
4363 | \r |
4364 | // The user may use createPseudo to indicate that\r |
4365 | // arguments are needed to create the filter function\r |
4366 | // just as Sizzle does\r |
4367 | if ( fn[ expando ] ) {\r |
4368 | return fn( argument );\r |
4369 | }\r |
4370 | \r |
4371 | // But maintain support for old signatures\r |
4372 | if ( fn.length > 1 ) {\r |
4373 | args = [ pseudo, pseudo, "", argument ];\r |
4374 | return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?\r |
4375 | markFunction(function( seed, matches ) {\r |
4376 | var idx,\r |
4377 | matched = fn( seed, argument ),\r |
4378 | i = matched.length;\r |
4379 | while ( i-- ) {\r |
4380 | idx = indexOf.call( seed, matched[i] );\r |
4381 | seed[ idx ] = !( matches[ idx ] = matched[i] );\r |
4382 | }\r |
4383 | }) :\r |
4384 | function( elem ) {\r |
4385 | return fn( elem, 0, args );\r |
4386 | };\r |
4387 | }\r |
4388 | \r |
4389 | return fn;\r |
4390 | }\r |
4391 | },\r |
4392 | \r |
4393 | pseudos: {\r |
4394 | "not": markFunction(function( selector ) {\r |
4395 | // Trim the selector passed to compile\r |
4396 | // to avoid treating leading and trailing\r |
4397 | // spaces as combinators\r |
4398 | var input = [],\r |
4399 | results = [],\r |
4400 | matcher = compile( selector.replace( rtrim, "$1" ) );\r |
4401 | \r |
4402 | return matcher[ expando ] ?\r |
4403 | markFunction(function( seed, matches, context, xml ) {\r |
4404 | var elem,\r |
4405 | unmatched = matcher( seed, null, xml, [] ),\r |
4406 | i = seed.length;\r |
4407 | \r |
4408 | // Match elements unmatched by `matcher`\r |
4409 | while ( i-- ) {\r |
4410 | if ( (elem = unmatched[i]) ) {\r |
4411 | seed[i] = !(matches[i] = elem);\r |
4412 | }\r |
4413 | }\r |
4414 | }) :\r |
4415 | function( elem, context, xml ) {\r |
4416 | input[0] = elem;\r |
4417 | matcher( input, null, xml, results );\r |
4418 | return !results.pop();\r |
4419 | };\r |
4420 | }),\r |
4421 | \r |
4422 | "has": markFunction(function( selector ) {\r |
4423 | return function( elem ) {\r |
4424 | return Sizzle( selector, elem ).length > 0;\r |
4425 | };\r |
4426 | }),\r |
4427 | \r |
4428 | "contains": markFunction(function( text ) {\r |
4429 | return function( elem ) {\r |
4430 | return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;\r |
4431 | };\r |
4432 | }),\r |
4433 | \r |
4434 | "enabled": function( elem ) {\r |
4435 | return elem.disabled === false;\r |
4436 | },\r |
4437 | \r |
4438 | "disabled": function( elem ) {\r |
4439 | return elem.disabled === true;\r |
4440 | },\r |
4441 | \r |
4442 | "checked": function( elem ) {\r |
4443 | // In CSS3, :checked should return both checked and selected elements\r |
4444 | // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked\r |
4445 | var nodeName = elem.nodeName.toLowerCase();\r |
4446 | return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);\r |
4447 | },\r |
4448 | \r |
4449 | "selected": function( elem ) {\r |
4450 | // Accessing this property makes selected-by-default\r |
4451 | // options in Safari work properly\r |
4452 | if ( elem.parentNode ) {\r |
4453 | elem.parentNode.selectedIndex;\r |
4454 | }\r |
4455 | \r |
4456 | return elem.selected === true;\r |
4457 | },\r |
4458 | \r |
4459 | "parent": function( elem ) {\r |
4460 | return !Expr.pseudos["empty"]( elem );\r |
4461 | },\r |
4462 | \r |
4463 | "empty": function( elem ) {\r |
4464 | // http://www.w3.org/TR/selectors/#empty-pseudo\r |
4465 | // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),\r |
4466 | // not comment, processing instructions, or others\r |
4467 | // Thanks to Diego Perini for the nodeName shortcut\r |
4468 | // Greater than "@" means alpha characters (specifically not starting with "#" or "?")\r |
4469 | var nodeType;\r |
4470 | elem = elem.firstChild;\r |
4471 | while ( elem ) {\r |
4472 | if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) {\r |
4473 | return false;\r |
4474 | }\r |
4475 | elem = elem.nextSibling;\r |
4476 | }\r |
4477 | return true;\r |
4478 | },\r |
4479 | \r |
4480 | "header": function( elem ) {\r |
4481 | return rheader.test( elem.nodeName );\r |
4482 | },\r |
4483 | \r |
4484 | "text": function( elem ) {\r |
4485 | var type, attr;\r |
4486 | // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)\r |
4487 | // use getAttribute instead to test this case\r |
4488 | return elem.nodeName.toLowerCase() === "input" &&\r |
4489 | (type = elem.type) === "text" &&\r |
4490 | ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type );\r |
4491 | },\r |
4492 | \r |
4493 | // Input types\r |
4494 | "radio": createInputPseudo("radio"),\r |
4495 | "checkbox": createInputPseudo("checkbox"),\r |
4496 | "file": createInputPseudo("file"),\r |
4497 | "password": createInputPseudo("password"),\r |
4498 | "image": createInputPseudo("image"),\r |
4499 | \r |
4500 | "submit": createButtonPseudo("submit"),\r |
4501 | "reset": createButtonPseudo("reset"),\r |
4502 | \r |
4503 | "button": function( elem ) {\r |
4504 | var name = elem.nodeName.toLowerCase();\r |
4505 | return name === "input" && elem.type === "button" || name === "button";\r |
4506 | },\r |
4507 | \r |
4508 | "input": function( elem ) {\r |
4509 | return rinputs.test( elem.nodeName );\r |
4510 | },\r |
4511 | \r |
4512 | "focus": function( elem ) {\r |
4513 | var doc = elem.ownerDocument;\r |
4514 | return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href);\r |
4515 | },\r |
4516 | \r |
4517 | "active": function( elem ) {\r |
4518 | return elem === elem.ownerDocument.activeElement;\r |
4519 | },\r |
4520 | \r |
4521 | // Positional types\r |
4522 | "first": createPositionalPseudo(function( matchIndexes, length, argument ) {\r |
4523 | return [ 0 ];\r |
4524 | }),\r |
4525 | \r |
4526 | "last": createPositionalPseudo(function( matchIndexes, length, argument ) {\r |
4527 | return [ length - 1 ];\r |
4528 | }),\r |
4529 | \r |
4530 | "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {\r |
4531 | return [ argument < 0 ? argument + length : argument ];\r |
4532 | }),\r |
4533 | \r |
4534 | "even": createPositionalPseudo(function( matchIndexes, length, argument ) {\r |
4535 | for ( var i = 0; i < length; i += 2 ) {\r |
4536 | matchIndexes.push( i );\r |
4537 | }\r |
4538 | return matchIndexes;\r |
4539 | }),\r |
4540 | \r |
4541 | "odd": createPositionalPseudo(function( matchIndexes, length, argument ) {\r |
4542 | for ( var i = 1; i < length; i += 2 ) {\r |
4543 | matchIndexes.push( i );\r |
4544 | }\r |
4545 | return matchIndexes;\r |
4546 | }),\r |
4547 | \r |
4548 | "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {\r |
4549 | for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) {\r |
4550 | matchIndexes.push( i );\r |
4551 | }\r |
4552 | return matchIndexes;\r |
4553 | }),\r |
4554 | \r |
4555 | "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {\r |
4556 | for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) {\r |
4557 | matchIndexes.push( i );\r |
4558 | }\r |
4559 | return matchIndexes;\r |
4560 | })\r |
4561 | }\r |
4562 | };\r |
4563 | \r |
4564 | function siblingCheck( a, b, ret ) {\r |
4565 | if ( a === b ) {\r |
4566 | return ret;\r |
4567 | }\r |
4568 | \r |
4569 | var cur = a.nextSibling;\r |
4570 | \r |
4571 | while ( cur ) {\r |
4572 | if ( cur === b ) {\r |
4573 | return -1;\r |
4574 | }\r |
4575 | \r |
4576 | cur = cur.nextSibling;\r |
4577 | }\r |
4578 | \r |
4579 | return 1;\r |
4580 | }\r |
4581 | \r |
4582 | sortOrder = docElem.compareDocumentPosition ?\r |
4583 | function( a, b ) {\r |
4584 | if ( a === b ) {\r |
4585 | hasDuplicate = true;\r |
4586 | return 0;\r |
4587 | }\r |
4588 | \r |
4589 | return ( !a.compareDocumentPosition || !b.compareDocumentPosition ?\r |
4590 | a.compareDocumentPosition :\r |
4591 | a.compareDocumentPosition(b) & 4\r |
4592 | ) ? -1 : 1;\r |
4593 | } :\r |
4594 | function( a, b ) {\r |
4595 | // The nodes are identical, we can exit early\r |
4596 | if ( a === b ) {\r |
4597 | hasDuplicate = true;\r |
4598 | return 0;\r |
4599 | \r |
4600 | // Fallback to using sourceIndex (in IE) if it's available on both nodes\r |
4601 | } else if ( a.sourceIndex && b.sourceIndex ) {\r |
4602 | return a.sourceIndex - b.sourceIndex;\r |
4603 | }\r |
4604 | \r |
4605 | var al, bl,\r |
4606 | ap = [],\r |
4607 | bp = [],\r |
4608 | aup = a.parentNode,\r |
4609 | bup = b.parentNode,\r |
4610 | cur = aup;\r |
4611 | \r |
4612 | // If the nodes are siblings (or identical) we can do a quick check\r |
4613 | if ( aup === bup ) {\r |
4614 | return siblingCheck( a, b );\r |
4615 | \r |
4616 | // If no parents were found then the nodes are disconnected\r |
4617 | } else if ( !aup ) {\r |
4618 | return -1;\r |
4619 | \r |
4620 | } else if ( !bup ) {\r |
4621 | return 1;\r |
4622 | }\r |
4623 | \r |
4624 | // Otherwise they're somewhere else in the tree so we need\r |
4625 | // to build up a full list of the parentNodes for comparison\r |
4626 | while ( cur ) {\r |
4627 | ap.unshift( cur );\r |
4628 | cur = cur.parentNode;\r |
4629 | }\r |
4630 | \r |
4631 | cur = bup;\r |
4632 | \r |
4633 | while ( cur ) {\r |
4634 | bp.unshift( cur );\r |
4635 | cur = cur.parentNode;\r |
4636 | }\r |
4637 | \r |
4638 | al = ap.length;\r |
4639 | bl = bp.length;\r |
4640 | \r |
4641 | // Start walking down the tree looking for a discrepancy\r |
4642 | for ( var i = 0; i < al && i < bl; i++ ) {\r |
4643 | if ( ap[i] !== bp[i] ) {\r |
4644 | return siblingCheck( ap[i], bp[i] );\r |
4645 | }\r |
4646 | }\r |
4647 | \r |
4648 | // We ended someplace up the tree so do a sibling check\r |
4649 | return i === al ?\r |
4650 | siblingCheck( a, bp[i], -1 ) :\r |
4651 | siblingCheck( ap[i], b, 1 );\r |
4652 | };\r |
4653 | \r |
4654 | // Always assume the presence of duplicates if sort doesn't\r |
4655 | // pass them to our comparison function (as in Google Chrome).\r |
4656 | [0, 0].sort( sortOrder );\r |
4657 | baseHasDuplicate = !hasDuplicate;\r |
4658 | \r |
4659 | // Document sorting and removing duplicates\r |
4660 | Sizzle.uniqueSort = function( results ) {\r |
4661 | var elem,\r |
4662 | i = 1;\r |
4663 | \r |
4664 | hasDuplicate = baseHasDuplicate;\r |
4665 | results.sort( sortOrder );\r |
4666 | \r |
4667 | if ( hasDuplicate ) {\r |
4668 | for ( ; (elem = results[i]); i++ ) {\r |
4669 | if ( elem === results[ i - 1 ] ) {\r |
4670 | results.splice( i--, 1 );\r |
4671 | }\r |
4672 | }\r |
4673 | }\r |
4674 | \r |
4675 | return results;\r |
4676 | };\r |
4677 | \r |
4678 | Sizzle.error = function( msg ) {\r |
4679 | throw new Error( "Syntax error, unrecognized expression: " + msg );\r |
4680 | };\r |
4681 | \r |
4682 | function tokenize( selector, parseOnly ) {\r |
4683 | var matched, match, tokens, type, soFar, groups, preFilters,\r |
4684 | cached = tokenCache[ expando ][ selector ];\r |
4685 | \r |
4686 | if ( cached ) {\r |
4687 | return parseOnly ? 0 : cached.slice( 0 );\r |
4688 | }\r |
4689 | \r |
4690 | soFar = selector;\r |
4691 | groups = [];\r |
4692 | preFilters = Expr.preFilter;\r |
4693 | \r |
4694 | while ( soFar ) {\r |
4695 | \r |
4696 | // Comma and first run\r |
4697 | if ( !matched || (match = rcomma.exec( soFar )) ) {\r |
4698 | if ( match ) {\r |
4699 | soFar = soFar.slice( match[0].length );\r |
4700 | }\r |
4701 | groups.push( tokens = [] );\r |
4702 | }\r |
4703 | \r |
4704 | matched = false;\r |
4705 | \r |
4706 | // Combinators\r |
4707 | if ( (match = rcombinators.exec( soFar )) ) {\r |
4708 | tokens.push( matched = new Token( match.shift() ) );\r |
4709 | soFar = soFar.slice( matched.length );\r |
4710 | \r |
4711 | // Cast descendant combinators to space\r |
4712 | matched.type = match[0].replace( rtrim, " " );\r |
4713 | }\r |
4714 | \r |
4715 | // Filters\r |
4716 | for ( type in Expr.filter ) {\r |
4717 | if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||\r |
4718 | // The last two arguments here are (context, xml) for backCompat\r |
4719 | (match = preFilters[ type ]( match, document, true ))) ) {\r |
4720 | \r |
4721 | tokens.push( matched = new Token( match.shift() ) );\r |
4722 | soFar = soFar.slice( matched.length );\r |
4723 | matched.type = type;\r |
4724 | matched.matches = match;\r |
4725 | }\r |
4726 | }\r |
4727 | \r |
4728 | if ( !matched ) {\r |
4729 | break;\r |
4730 | }\r |
4731 | }\r |
4732 | \r |
4733 | // Return the length of the invalid excess\r |
4734 | // if we're just parsing\r |
4735 | // Otherwise, throw an error or return tokens\r |
4736 | return parseOnly ?\r |
4737 | soFar.length :\r |
4738 | soFar ?\r |
4739 | Sizzle.error( selector ) :\r |
4740 | // Cache the tokens\r |
4741 | tokenCache( selector, groups ).slice( 0 );\r |
4742 | }\r |
4743 | \r |
4744 | function addCombinator( matcher, combinator, base ) {\r |
4745 | var dir = combinator.dir,\r |
4746 | checkNonElements = base && combinator.dir === "parentNode",\r |
4747 | doneName = done++;\r |
4748 | \r |
4749 | return combinator.first ?\r |
4750 | // Check against closest ancestor/preceding element\r |
4751 | function( elem, context, xml ) {\r |
4752 | while ( (elem = elem[ dir ]) ) {\r |
4753 | if ( checkNonElements || elem.nodeType === 1 ) {\r |
4754 | return matcher( elem, context, xml );\r |
4755 | }\r |
4756 | }\r |
4757 | } :\r |
4758 | \r |
4759 | // Check against all ancestor/preceding elements\r |
4760 | function( elem, context, xml ) {\r |
4761 | // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching\r |
4762 | if ( !xml ) {\r |
4763 | var cache,\r |
4764 | dirkey = dirruns + " " + doneName + " ",\r |
4765 | cachedkey = dirkey + cachedruns;\r |
4766 | while ( (elem = elem[ dir ]) ) {\r |
4767 | if ( checkNonElements || elem.nodeType === 1 ) {\r |
4768 | if ( (cache = elem[ expando ]) === cachedkey ) {\r |
4769 | return elem.sizset;\r |
4770 | } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {\r |
4771 | if ( elem.sizset ) {\r |
4772 | return elem;\r |
4773 | }\r |
4774 | } else {\r |
4775 | elem[ expando ] = cachedkey;\r |
4776 | if ( matcher( elem, context, xml ) ) {\r |
4777 | elem.sizset = true;\r |
4778 | return elem;\r |
4779 | }\r |
4780 | elem.sizset = false;\r |
4781 | }\r |
4782 | }\r |
4783 | }\r |
4784 | } else {\r |
4785 | while ( (elem = elem[ dir ]) ) {\r |
4786 | if ( checkNonElements || elem.nodeType === 1 ) {\r |
4787 | if ( matcher( elem, context, xml ) ) {\r |
4788 | return elem;\r |
4789 | }\r |
4790 | }\r |
4791 | }\r |
4792 | }\r |
4793 | };\r |
4794 | }\r |
4795 | \r |
4796 | function elementMatcher( matchers ) {\r |
4797 | return matchers.length > 1 ?\r |
4798 | function( elem, context, xml ) {\r |
4799 | var i = matchers.length;\r |
4800 | while ( i-- ) {\r |
4801 | if ( !matchers[i]( elem, context, xml ) ) {\r |
4802 | return false;\r |
4803 | }\r |
4804 | }\r |
4805 | return true;\r |
4806 | } :\r |
4807 | matchers[0];\r |
4808 | }\r |
4809 | \r |
4810 | function condense( unmatched, map, filter, context, xml ) {\r |
4811 | var elem,\r |
4812 | newUnmatched = [],\r |
4813 | i = 0,\r |
4814 | len = unmatched.length,\r |
4815 | mapped = map != null;\r |
4816 | \r |
4817 | for ( ; i < len; i++ ) {\r |
4818 | if ( (elem = unmatched[i]) ) {\r |
4819 | if ( !filter || filter( elem, context, xml ) ) {\r |
4820 | newUnmatched.push( elem );\r |
4821 | if ( mapped ) {\r |
4822 | map.push( i );\r |
4823 | }\r |
4824 | }\r |
4825 | }\r |
4826 | }\r |
4827 | \r |
4828 | return newUnmatched;\r |
4829 | }\r |
4830 | \r |
4831 | function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {\r |
4832 | if ( postFilter && !postFilter[ expando ] ) {\r |
4833 | postFilter = setMatcher( postFilter );\r |
4834 | }\r |
4835 | if ( postFinder && !postFinder[ expando ] ) {\r |
4836 | postFinder = setMatcher( postFinder, postSelector );\r |
4837 | }\r |
4838 | return markFunction(function( seed, results, context, xml ) {\r |
4839 | // Positional selectors apply to seed elements, so it is invalid to follow them with relative ones\r |
4840 | if ( seed && postFinder ) {\r |
4841 | return;\r |
4842 | }\r |
4843 | \r |
4844 | var i, elem, postFilterIn,\r |
4845 | preMap = [],\r |
4846 | postMap = [],\r |
4847 | preexisting = results.length,\r |
4848 | \r |
4849 | // Get initial elements from seed or context\r |
4850 | elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [], seed ),\r |
4851 | \r |
4852 | // Prefilter to get matcher input, preserving a map for seed-results synchronization\r |
4853 | matcherIn = preFilter && ( seed || !selector ) ?\r |
4854 | condense( elems, preMap, preFilter, context, xml ) :\r |
4855 | elems,\r |
4856 | \r |
4857 | matcherOut = matcher ?\r |
4858 | // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,\r |
4859 | postFinder || ( seed ? preFilter : preexisting || postFilter ) ?\r |
4860 | \r |
4861 | // ...intermediate processing is necessary\r |
4862 | [] :\r |
4863 | \r |
4864 | // ...otherwise use results directly\r |
4865 | results :\r |
4866 | matcherIn;\r |
4867 | \r |
4868 | // Find primary matches\r |
4869 | if ( matcher ) {\r |
4870 | matcher( matcherIn, matcherOut, context, xml );\r |
4871 | }\r |
4872 | \r |
4873 | // Apply postFilter\r |
4874 | if ( postFilter ) {\r |
4875 | postFilterIn = condense( matcherOut, postMap );\r |
4876 | postFilter( postFilterIn, [], context, xml );\r |
4877 | \r |
4878 | // Un-match failing elements by moving them back to matcherIn\r |
4879 | i = postFilterIn.length;\r |
4880 | while ( i-- ) {\r |
4881 | if ( (elem = postFilterIn[i]) ) {\r |
4882 | matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);\r |
4883 | }\r |
4884 | }\r |
4885 | }\r |
4886 | \r |
4887 | // Keep seed and results synchronized\r |
4888 | if ( seed ) {\r |
4889 | // Ignore postFinder because it can't coexist with seed\r |
4890 | i = preFilter && matcherOut.length;\r |
4891 | while ( i-- ) {\r |
4892 | if ( (elem = matcherOut[i]) ) {\r |
4893 | seed[ preMap[i] ] = !(results[ preMap[i] ] = elem);\r |
4894 | }\r |
4895 | }\r |
4896 | } else {\r |
4897 | matcherOut = condense(\r |
4898 | matcherOut === results ?\r |
4899 | matcherOut.splice( preexisting, matcherOut.length ) :\r |
4900 | matcherOut\r |
4901 | );\r |
4902 | if ( postFinder ) {\r |
4903 | postFinder( null, results, matcherOut, xml );\r |
4904 | } else {\r |
4905 | push.apply( results, matcherOut );\r |
4906 | }\r |
4907 | }\r |
4908 | });\r |
4909 | }\r |
4910 | \r |
4911 | function matcherFromTokens( tokens ) {\r |
4912 | var checkContext, matcher, j,\r |
4913 | len = tokens.length,\r |
4914 | leadingRelative = Expr.relative[ tokens[0].type ],\r |
4915 | implicitRelative = leadingRelative || Expr.relative[" "],\r |
4916 | i = leadingRelative ? 1 : 0,\r |
4917 | \r |
4918 | // The foundational matcher ensures that elements are reachable from top-level context(s)\r |
4919 | matchContext = addCombinator( function( elem ) {\r |
4920 | return elem === checkContext;\r |
4921 | }, implicitRelative, true ),\r |
4922 | matchAnyContext = addCombinator( function( elem ) {\r |
4923 | return indexOf.call( checkContext, elem ) > -1;\r |
4924 | }, implicitRelative, true ),\r |
4925 | matchers = [ function( elem, context, xml ) {\r |
4926 | return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (\r |
4927 | (checkContext = context).nodeType ?\r |
4928 | matchContext( elem, context, xml ) :\r |
4929 | matchAnyContext( elem, context, xml ) );\r |
4930 | } ];\r |
4931 | \r |
4932 | for ( ; i < len; i++ ) {\r |
4933 | if ( (matcher = Expr.relative[ tokens[i].type ]) ) {\r |
4934 | matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];\r |
4935 | } else {\r |
4936 | // The concatenated values are (context, xml) for backCompat\r |
4937 | matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );\r |
4938 | \r |
4939 | // Return special upon seeing a positional matcher\r |
4940 | if ( matcher[ expando ] ) {\r |
4941 | // Find the next relative operator (if any) for proper handling\r |
4942 | j = ++i;\r |
4943 | for ( ; j < len; j++ ) {\r |
4944 | if ( Expr.relative[ tokens[j].type ] ) {\r |
4945 | break;\r |
4946 | }\r |
4947 | }\r |
4948 | return setMatcher(\r |
4949 | i > 1 && elementMatcher( matchers ),\r |
4950 | i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ),\r |
4951 | matcher,\r |
4952 | i < j && matcherFromTokens( tokens.slice( i, j ) ),\r |
4953 | j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),\r |
4954 | j < len && tokens.join("")\r |
4955 | );\r |
4956 | }\r |
4957 | matchers.push( matcher );\r |
4958 | }\r |
4959 | }\r |
4960 | \r |
4961 | return elementMatcher( matchers );\r |
4962 | }\r |
4963 | \r |
4964 | function matcherFromGroupMatchers( elementMatchers, setMatchers ) {\r |
4965 | var bySet = setMatchers.length > 0,\r |
4966 | byElement = elementMatchers.length > 0,\r |
4967 | superMatcher = function( seed, context, xml, results, expandContext ) {\r |
4968 | var elem, j, matcher,\r |
4969 | setMatched = [],\r |
4970 | matchedCount = 0,\r |
4971 | i = "0",\r |
4972 | unmatched = seed && [],\r |
4973 | outermost = expandContext != null,\r |
4974 | contextBackup = outermostContext,\r |
4975 | // We must always have either seed elements or context\r |
4976 | elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),\r |
4977 | // Nested matchers should use non-integer dirruns\r |
4978 | dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);\r |
4979 | \r |
4980 | if ( outermost ) {\r |
4981 | outermostContext = context !== document && context;\r |
4982 | cachedruns = superMatcher.el;\r |
4983 | }\r |
4984 | \r |
4985 | // Add elements passing elementMatchers directly to results\r |
4986 | for ( ; (elem = elems[i]) != null; i++ ) {\r |
4987 | if ( byElement && elem ) {\r |
4988 | for ( j = 0; (matcher = elementMatchers[j]); j++ ) {\r |
4989 | if ( matcher( elem, context, xml ) ) {\r |
4990 | results.push( elem );\r |
4991 | break;\r |
4992 | }\r |
4993 | }\r |
4994 | if ( outermost ) {\r |
4995 | dirruns = dirrunsUnique;\r |
4996 | cachedruns = ++superMatcher.el;\r |
4997 | }\r |
4998 | }\r |
4999 | \r |
5000 | // Track unmatched elements for set filters\r |
5001 | if ( bySet ) {\r |
5002 | // They will have gone through all possible matchers\r |
5003 | if ( (elem = !matcher && elem) ) {\r |
5004 | matchedCount--;\r |
5005 | }\r |
5006 | \r |
5007 | // Lengthen the array for every element, matched or not\r |
5008 | if ( seed ) {\r |
5009 | unmatched.push( elem );\r |
5010 | }\r |
5011 | }\r |
5012 | }\r |
5013 | \r |
5014 | // Apply set filters to unmatched elements\r |
5015 | matchedCount += i;\r |
5016 | if ( bySet && i !== matchedCount ) {\r |
5017 | for ( j = 0; (matcher = setMatchers[j]); j++ ) {\r |
5018 | matcher( unmatched, setMatched, context, xml );\r |
5019 | }\r |
5020 | \r |
5021 | if ( seed ) {\r |
5022 | // Reintegrate element matches to eliminate the need for sorting\r |
5023 | if ( matchedCount > 0 ) {\r |
5024 | while ( i-- ) {\r |
5025 | if ( !(unmatched[i] || setMatched[i]) ) {\r |
5026 | setMatched[i] = pop.call( results );\r |
5027 | }\r |
5028 | }\r |
5029 | }\r |
5030 | \r |
5031 | // Discard index placeholder values to get only actual matches\r |
5032 | setMatched = condense( setMatched );\r |
5033 | }\r |
5034 | \r |
5035 | // Add matches to results\r |
5036 | push.apply( results, setMatched );\r |
5037 | \r |
5038 | // Seedless set matches succeeding multiple successful matchers stipulate sorting\r |
5039 | if ( outermost && !seed && setMatched.length > 0 &&\r |
5040 | ( matchedCount + setMatchers.length ) > 1 ) {\r |
5041 | \r |
5042 | Sizzle.uniqueSort( results );\r |
5043 | }\r |
5044 | }\r |
5045 | \r |
5046 | // Override manipulation of globals by nested matchers\r |
5047 | if ( outermost ) {\r |
5048 | dirruns = dirrunsUnique;\r |
5049 | outermostContext = contextBackup;\r |
5050 | }\r |
5051 | \r |
5052 | return unmatched;\r |
5053 | };\r |
5054 | \r |
5055 | superMatcher.el = 0;\r |
5056 | return bySet ?\r |
5057 | markFunction( superMatcher ) :\r |
5058 | superMatcher;\r |
5059 | }\r |
5060 | \r |
5061 | compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {\r |
5062 | var i,\r |
5063 | setMatchers = [],\r |
5064 | elementMatchers = [],\r |
5065 | cached = compilerCache[ expando ][ selector ];\r |
5066 | \r |
5067 | if ( !cached ) {\r |
5068 | // Generate a function of recursive functions that can be used to check each element\r |
5069 | if ( !group ) {\r |
5070 | group = tokenize( selector );\r |
5071 | }\r |
5072 | i = group.length;\r |
5073 | while ( i-- ) {\r |
5074 | cached = matcherFromTokens( group[i] );\r |
5075 | if ( cached[ expando ] ) {\r |
5076 | setMatchers.push( cached );\r |
5077 | } else {\r |
5078 | elementMatchers.push( cached );\r |
5079 | }\r |
5080 | }\r |
5081 | \r |
5082 | // Cache the compiled function\r |
5083 | cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );\r |
5084 | }\r |
5085 | return cached;\r |
5086 | };\r |
5087 | \r |
5088 | function multipleContexts( selector, contexts, results, seed ) {\r |
5089 | var i = 0,\r |
5090 | len = contexts.length;\r |
5091 | for ( ; i < len; i++ ) {\r |
5092 | Sizzle( selector, contexts[i], results, seed );\r |
5093 | }\r |
5094 | return results;\r |
5095 | }\r |
5096 | \r |
5097 | function select( selector, context, results, seed, xml ) {\r |
5098 | var i, tokens, token, type, find,\r |
5099 | match = tokenize( selector ),\r |
5100 | j = match.length;\r |
5101 | \r |
5102 | if ( !seed ) {\r |
5103 | // Try to minimize operations if there is only one group\r |
5104 | if ( match.length === 1 ) {\r |
5105 | \r |
5106 | // Take a shortcut and set the context if the root selector is an ID\r |
5107 | tokens = match[0] = match[0].slice( 0 );\r |
5108 | if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&\r |
5109 | context.nodeType === 9 && !xml &&\r |
5110 | Expr.relative[ tokens[1].type ] ) {\r |
5111 | \r |
5112 | context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0];\r |
5113 | if ( !context ) {\r |
5114 | return results;\r |
5115 | }\r |
5116 | \r |
5117 | selector = selector.slice( tokens.shift().length );\r |
5118 | }\r |
5119 | \r |
5120 | // Fetch a seed set for right-to-left matching\r |
5121 | for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {\r |
5122 | token = tokens[i];\r |
5123 | \r |
5124 | // Abort if we hit a combinator\r |
5125 | if ( Expr.relative[ (type = token.type) ] ) {\r |
5126 | break;\r |
5127 | }\r |
5128 | if ( (find = Expr.find[ type ]) ) {\r |
5129 | // Search, expanding context for leading sibling combinators\r |
5130 | if ( (seed = find(\r |
5131 | token.matches[0].replace( rbackslash, "" ),\r |
5132 | rsibling.test( tokens[0].type ) && context.parentNode || context,\r |
5133 | xml\r |
5134 | )) ) {\r |
5135 | \r |
5136 | // If seed is empty or no tokens remain, we can return early\r |
5137 | tokens.splice( i, 1 );\r |
5138 | selector = seed.length && tokens.join("");\r |
5139 | if ( !selector ) {\r |
5140 | push.apply( results, slice.call( seed, 0 ) );\r |
5141 | return results;\r |
5142 | }\r |
5143 | \r |
5144 | break;\r |
5145 | }\r |
5146 | }\r |
5147 | }\r |
5148 | }\r |
5149 | }\r |
5150 | \r |
5151 | // Compile and execute a filtering function\r |
5152 | // Provide `match` to avoid retokenization if we modified the selector above\r |
5153 | compile( selector, match )(\r |
5154 | seed,\r |
5155 | context,\r |
5156 | xml,\r |
5157 | results,\r |
5158 | rsibling.test( selector )\r |
5159 | );\r |
5160 | return results;\r |
5161 | }\r |
5162 | \r |
5163 | if ( document.querySelectorAll ) {\r |
5164 | (function() {\r |
5165 | var disconnectedMatch,\r |
5166 | oldSelect = select,\r |
5167 | rescape = /'|\\/g,\r |
5168 | rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,\r |
5169 | \r |
5170 | // qSa(:focus) reports false when true (Chrome 21),\r |
5171 | // A support test would require too much code (would include document ready)\r |
5172 | rbuggyQSA = [":focus"],\r |
5173 | \r |
5174 | // matchesSelector(:focus) reports false when true (Chrome 21),\r |
5175 | // matchesSelector(:active) reports false when true (IE9/Opera 11.5)\r |
5176 | // A support test would require too much code (would include document ready)\r |
5177 | // just skip matchesSelector for :active\r |
5178 | rbuggyMatches = [ ":active", ":focus" ],\r |
5179 | matches = docElem.matchesSelector ||\r |
5180 | docElem.mozMatchesSelector ||\r |
5181 | docElem.webkitMatchesSelector ||\r |
5182 | docElem.oMatchesSelector ||\r |
5183 | docElem.msMatchesSelector;\r |
5184 | \r |
5185 | // Build QSA regex\r |
5186 | // Regex strategy adopted from Diego Perini\r |
5187 | assert(function( div ) {\r |
5188 | // Select is set to empty string on purpose\r |
5189 | // This is to test IE's treatment of not explictly\r |
5190 | // setting a boolean content attribute,\r |
5191 | // since its presence should be enough\r |
5192 | // http://bugs.jquery.com/ticket/12359\r |
5193 | div.innerHTML = "<select><option selected=''></option></select>";\r |
5194 | \r |
5195 | // IE8 - Some boolean attributes are not treated correctly\r |
5196 | if ( !div.querySelectorAll("[selected]").length ) {\r |
5197 | rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );\r |
5198 | }\r |
5199 | \r |
5200 | // Webkit/Opera - :checked should return selected option elements\r |
5201 | // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked\r |
5202 | // IE8 throws error here (do not put tests after this one)\r |
5203 | if ( !div.querySelectorAll(":checked").length ) {\r |
5204 | rbuggyQSA.push(":checked");\r |
5205 | }\r |
5206 | });\r |
5207 | \r |
5208 | assert(function( div ) {\r |
5209 | \r |
5210 | // Opera 10-12/IE9 - ^= $= *= and empty values\r |
5211 | // Should not select anything\r |
5212 | div.innerHTML = "<p test=''></p>";\r |
5213 | if ( div.querySelectorAll("[test^='']").length ) {\r |
5214 | rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );\r |
5215 | }\r |
5216 | \r |
5217 | // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)\r |
5218 | // IE8 throws error here (do not put tests after this one)\r |
5219 | div.innerHTML = "<input type='hidden'/>";\r |
5220 | if ( !div.querySelectorAll(":enabled").length ) {\r |
5221 | rbuggyQSA.push(":enabled", ":disabled");\r |
5222 | }\r |
5223 | });\r |
5224 | \r |
5225 | // rbuggyQSA always contains :focus, so no need for a length check\r |
5226 | rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") );\r |
5227 | \r |
5228 | select = function( selector, context, results, seed, xml ) {\r |
5229 | // Only use querySelectorAll when not filtering,\r |
5230 | // when this is not xml,\r |
5231 | // and when no QSA bugs apply\r |
5232 | if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {\r |
5233 | var groups, i,\r |
5234 | old = true,\r |
5235 | nid = expando,\r |
5236 | newContext = context,\r |
5237 | newSelector = context.nodeType === 9 && selector;\r |
5238 | \r |
5239 | // qSA works strangely on Element-rooted queries\r |
5240 | // We can work around this by specifying an extra ID on the root\r |
5241 | // and working up from there (Thanks to Andrew Dupont for the technique)\r |
5242 | // IE 8 doesn't work on object elements\r |
5243 | if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {\r |
5244 | groups = tokenize( selector );\r |
5245 | \r |
5246 | if ( (old = context.getAttribute("id")) ) {\r |
5247 | nid = old.replace( rescape, "\\$&" );\r |
5248 | } else {\r |
5249 | context.setAttribute( "id", nid );\r |
5250 | }\r |
5251 | nid = "[id='" + nid + "'] ";\r |
5252 | \r |
5253 | i = groups.length;\r |
5254 | while ( i-- ) {\r |
5255 | groups[i] = nid + groups[i].join("");\r |
5256 | }\r |
5257 | newContext = rsibling.test( selector ) && context.parentNode || context;\r |
5258 | newSelector = groups.join(",");\r |
5259 | }\r |
5260 | \r |
5261 | if ( newSelector ) {\r |
5262 | try {\r |
5263 | push.apply( results, slice.call( newContext.querySelectorAll(\r |
5264 | newSelector\r |
5265 | ), 0 ) );\r |
5266 | return results;\r |
5267 | } catch(qsaError) {\r |
5268 | } finally {\r |
5269 | if ( !old ) {\r |
5270 | context.removeAttribute("id");\r |
5271 | }\r |
5272 | }\r |
5273 | }\r |
5274 | }\r |
5275 | \r |
5276 | return oldSelect( selector, context, results, seed, xml );\r |
5277 | };\r |
5278 | \r |
5279 | if ( matches ) {\r |
5280 | assert(function( div ) {\r |
5281 | // Check to see if it's possible to do matchesSelector\r |
5282 | // on a disconnected node (IE 9)\r |
5283 | disconnectedMatch = matches.call( div, "div" );\r |
5284 | \r |
5285 | // This should fail with an exception\r |
5286 | // Gecko does not error, returns false instead\r |
5287 | try {\r |
5288 | matches.call( div, "[test!='']:sizzle" );\r |
5289 | rbuggyMatches.push( "!=", pseudos );\r |
5290 | } catch ( e ) {}\r |
5291 | });\r |
5292 | \r |
5293 | // rbuggyMatches always contains :active and :focus, so no need for a length check\r |
5294 | rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );\r |
5295 | \r |
5296 | Sizzle.matchesSelector = function( elem, expr ) {\r |
5297 | // Make sure that attribute selectors are quoted\r |
5298 | expr = expr.replace( rattributeQuotes, "='$1']" );\r |
5299 | \r |
5300 | // rbuggyMatches always contains :active, so no need for an existence check\r |
5301 | if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) {\r |
5302 | try {\r |
5303 | var ret = matches.call( elem, expr );\r |
5304 | \r |
5305 | // IE 9's matchesSelector returns false on disconnected nodes\r |
5306 | if ( ret || disconnectedMatch ||\r |
5307 | // As well, disconnected nodes are said to be in a document\r |
5308 | // fragment in IE 9\r |
5309 | elem.document && elem.document.nodeType !== 11 ) {\r |
5310 | return ret;\r |
5311 | }\r |
5312 | } catch(e) {}\r |
5313 | }\r |
5314 | \r |
5315 | return Sizzle( expr, null, null, [ elem ] ).length > 0;\r |
5316 | };\r |
5317 | }\r |
5318 | })();\r |
5319 | }\r |
5320 | \r |
5321 | // Deprecated\r |
5322 | Expr.pseudos["nth"] = Expr.pseudos["eq"];\r |
5323 | \r |
5324 | // Back-compat\r |
5325 | function setFilters() {}\r |
5326 | Expr.filters = setFilters.prototype = Expr.pseudos;\r |
5327 | Expr.setFilters = new setFilters();\r |
5328 | \r |
5329 | // Override sizzle attribute retrieval |
5330 | Sizzle.attr = jQuery.attr; |
5331 | jQuery.find = Sizzle; |
5332 | jQuery.expr = Sizzle.selectors; |
5333 | jQuery.expr[":"] = jQuery.expr.pseudos; |
5334 | jQuery.unique = Sizzle.uniqueSort; |
5335 | jQuery.text = Sizzle.getText; |
5336 | jQuery.isXMLDoc = Sizzle.isXML; |
5337 | jQuery.contains = Sizzle.contains; |
5338 | \r |
5339 | \r |
5340 | })( window );\r |
5341 | var runtil = /Until$/, |
5342 | rparentsprev = /^(?:parents|prev(?:Until|All))/, |
5343 | isSimple = /^.[^:#\[\.,]*$/, |
5344 | rneedsContext = jQuery.expr.match.needsContext, |
5345 | // methods guaranteed to produce a unique set when starting from a unique set |
5346 | guaranteedUnique = { |
5347 | children: true, |
5348 | contents: true, |
5349 | next: true, |
5350 | prev: true |
5351 | }; |
5352 | |
5353 | jQuery.fn.extend({ |
5354 | find: function( selector ) { |
5355 | var i, l, length, n, r, ret, |
5356 | self = this; |
5357 | |
5358 | if ( typeof selector !== "string" ) { |
5359 | return jQuery( selector ).filter(function() { |
5360 | for ( i = 0, l = self.length; i < l; i++ ) { |
5361 | if ( jQuery.contains( self[ i ], this ) ) { |
5362 | return true; |
5363 | } |
5364 | } |
5365 | }); |
5366 | } |
5367 | |
5368 | ret = this.pushStack( "", "find", selector ); |
5369 | |
5370 | for ( i = 0, l = this.length; i < l; i++ ) { |
5371 | length = ret.length; |
5372 | jQuery.find( selector, this[i], ret ); |
5373 | |
5374 | if ( i > 0 ) { |
5375 | // Make sure that the results are unique |
5376 | for ( n = length; n < ret.length; n++ ) { |
5377 | for ( r = 0; r < length; r++ ) { |
5378 | if ( ret[r] === ret[n] ) { |
5379 | ret.splice(n--, 1); |
5380 | break; |
5381 | } |
5382 | } |
5383 | } |
5384 | } |
5385 | } |
5386 | |
5387 | return ret; |
5388 | }, |
5389 | |
5390 | has: function( target ) { |
5391 | var i, |
5392 | targets = jQuery( target, this ), |
5393 | len = targets.length; |
5394 | |
5395 | return this.filter(function() { |
5396 | for ( i = 0; i < len; i++ ) { |
5397 | if ( jQuery.contains( this, targets[i] ) ) { |
5398 | return true; |
5399 | } |
5400 | } |
5401 | }); |
5402 | }, |
5403 | |
5404 | not: function( selector ) { |
5405 | return this.pushStack( winnow(this, selector, false), "not", selector); |
5406 | }, |
5407 | |
5408 | filter: function( selector ) { |
5409 | return this.pushStack( winnow(this, selector, true), "filter", selector ); |
5410 | }, |
5411 | |
5412 | is: function( selector ) { |
5413 | return !!selector && ( |
5414 | typeof selector === "string" ? |
5415 | // If this is a positional/relative selector, check membership in the returned set |
5416 | // so $("p:first").is("p:last") won't return true for a doc with two "p". |
5417 | rneedsContext.test( selector ) ? |
5418 | jQuery( selector, this.context ).index( this[0] ) >= 0 : |
5419 | jQuery.filter( selector, this ).length > 0 : |
5420 | this.filter( selector ).length > 0 ); |
5421 | }, |
5422 | |
5423 | closest: function( selectors, context ) { |
5424 | var cur, |
5425 | i = 0, |
5426 | l = this.length, |
5427 | ret = [], |
5428 | pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? |
5429 | jQuery( selectors, context || this.context ) : |
5430 | 0; |
5431 | |
5432 | for ( ; i < l; i++ ) { |
5433 | cur = this[i]; |
5434 | |
5435 | while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) { |
5436 | if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { |
5437 | ret.push( cur ); |
5438 | break; |
5439 | } |
5440 | cur = cur.parentNode; |
5441 | } |
5442 | } |
5443 | |
5444 | ret = ret.length > 1 ? jQuery.unique( ret ) : ret; |
5445 | |
5446 | return this.pushStack( ret, "closest", selectors ); |
5447 | }, |
5448 | |
5449 | // Determine the position of an element within |
5450 | // the matched set of elements |
5451 | index: function( elem ) { |
5452 | |
5453 | // No argument, return index in parent |
5454 | if ( !elem ) { |
5455 | return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; |
5456 | } |
5457 | |
5458 | // index in selector |
5459 | if ( typeof elem === "string" ) { |
5460 | return jQuery.inArray( this[0], jQuery( elem ) ); |
5461 | } |
5462 | |
5463 | // Locate the position of the desired element |
5464 | return jQuery.inArray( |
5465 | // If it receives a jQuery object, the first element is used |
5466 | elem.jquery ? elem[0] : elem, this ); |
5467 | }, |
5468 | |
5469 | add: function( selector, context ) { |
5470 | var set = typeof selector === "string" ? |
5471 | jQuery( selector, context ) : |
5472 | jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), |
5473 | all = jQuery.merge( this.get(), set ); |
5474 | |
5475 | return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? |
5476 | all : |
5477 | jQuery.unique( all ) ); |
5478 | }, |
5479 | |
5480 | addBack: function( selector ) { |
5481 | return this.add( selector == null ? |
5482 | this.prevObject : this.prevObject.filter(selector) |
5483 | ); |
5484 | } |
5485 | }); |
5486 | |
5487 | jQuery.fn.andSelf = jQuery.fn.addBack; |
5488 | |
5489 | // A painfully simple check to see if an element is disconnected |
5490 | // from a document (should be improved, where feasible). |
5491 | function isDisconnected( node ) { |
5492 | return !node || !node.parentNode || node.parentNode.nodeType === 11; |
5493 | } |
5494 | |
5495 | function sibling( cur, dir ) { |
5496 | do { |
5497 | cur = cur[ dir ]; |
5498 | } while ( cur && cur.nodeType !== 1 ); |
5499 | |
5500 | return cur; |
5501 | } |
5502 | |
5503 | jQuery.each({ |
5504 | parent: function( elem ) { |
5505 | var parent = elem.parentNode; |
5506 | return parent && parent.nodeType !== 11 ? parent : null; |
5507 | }, |
5508 | parents: function( elem ) { |
5509 | return jQuery.dir( elem, "parentNode" ); |
5510 | }, |
5511 | parentsUntil: function( elem, i, until ) { |
5512 | return jQuery.dir( elem, "parentNode", until ); |
5513 | }, |
5514 | next: function( elem ) { |
5515 | return sibling( elem, "nextSibling" ); |
5516 | }, |
5517 | prev: function( elem ) { |
5518 | return sibling( elem, "previousSibling" ); |
5519 | }, |
5520 | nextAll: function( elem ) { |
5521 | return jQuery.dir( elem, "nextSibling" ); |
5522 | }, |
5523 | prevAll: function( elem ) { |
5524 | return jQuery.dir( elem, "previousSibling" ); |
5525 | }, |
5526 | nextUntil: function( elem, i, until ) { |
5527 | return jQuery.dir( elem, "nextSibling", until ); |
5528 | }, |
5529 | prevUntil: function( elem, i, until ) { |
5530 | return jQuery.dir( elem, "previousSibling", until ); |
5531 | }, |
5532 | siblings: function( elem ) { |
5533 | return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); |
5534 | }, |
5535 | children: function( elem ) { |
5536 | return jQuery.sibling( elem.firstChild ); |
5537 | }, |
5538 | contents: function( elem ) { |
5539 | return jQuery.nodeName( elem, "iframe" ) ? |
5540 | elem.contentDocument || elem.contentWindow.document : |
5541 | jQuery.merge( [], elem.childNodes ); |
5542 | } |
5543 | }, function( name, fn ) { |
5544 | jQuery.fn[ name ] = function( until, selector ) { |
5545 | var ret = jQuery.map( this, fn, until ); |
5546 | |
5547 | if ( !runtil.test( name ) ) { |
5548 | selector = until; |
5549 | } |
5550 | |
5551 | if ( selector && typeof selector === "string" ) { |
5552 | ret = jQuery.filter( selector, ret ); |
5553 | } |
5554 | |
5555 | ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; |
5556 | |
5557 | if ( this.length > 1 && rparentsprev.test( name ) ) { |
5558 | ret = ret.reverse(); |
5559 | } |
5560 | |
5561 | return this.pushStack( ret, name, core_slice.call( arguments ).join(",") ); |
5562 | }; |
5563 | }); |
5564 | |
5565 | jQuery.extend({ |
5566 | filter: function( expr, elems, not ) { |
5567 | if ( not ) { |
5568 | expr = ":not(" + expr + ")"; |
5569 | } |
5570 | |
5571 | return elems.length === 1 ? |
5572 | jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : |
5573 | jQuery.find.matches(expr, elems); |
5574 | }, |
5575 | |
5576 | dir: function( elem, dir, until ) { |
5577 | var matched = [], |
5578 | cur = elem[ dir ]; |
5579 | |
5580 | while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { |
5581 | if ( cur.nodeType === 1 ) { |
5582 | matched.push( cur ); |
5583 | } |
5584 | cur = cur[dir]; |
5585 | } |
5586 | return matched; |
5587 | }, |
5588 | |
5589 | sibling: function( n, elem ) { |
5590 | var r = []; |
5591 | |
5592 | for ( ; n; n = n.nextSibling ) { |
5593 | if ( n.nodeType === 1 && n !== elem ) { |
5594 | r.push( n ); |
5595 | } |
5596 | } |
5597 | |
5598 | return r; |
5599 | } |
5600 | }); |
5601 | |
5602 | // Implement the identical functionality for filter and not |
5603 | function winnow( elements, qualifier, keep ) { |
5604 | |
5605 | // Can't pass null or undefined to indexOf in Firefox 4 |
5606 | // Set to 0 to skip string check |
5607 | qualifier = qualifier || 0; |
5608 | |
5609 | if ( jQuery.isFunction( qualifier ) ) { |
5610 | return jQuery.grep(elements, function( elem, i ) { |
5611 | var retVal = !!qualifier.call( elem, i, elem ); |
5612 | return retVal === keep; |
5613 | }); |
5614 | |
5615 | } else if ( qualifier.nodeType ) { |
5616 | return jQuery.grep(elements, function( elem, i ) { |
5617 | return ( elem === qualifier ) === keep; |
5618 | }); |
5619 | |
5620 | } else if ( typeof qualifier === "string" ) { |
5621 | var filtered = jQuery.grep(elements, function( elem ) { |
5622 | return elem.nodeType === 1; |
5623 | }); |
5624 | |
5625 | if ( isSimple.test( qualifier ) ) { |
5626 | return jQuery.filter(qualifier, filtered, !keep); |
5627 | } else { |
5628 | qualifier = jQuery.filter( qualifier, filtered ); |
5629 | } |
5630 | } |
5631 | |
5632 | return jQuery.grep(elements, function( elem, i ) { |
5633 | return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; |
5634 | }); |
5635 | } |
5636 | function createSafeFragment( document ) { |
5637 | var list = nodeNames.split( "|" ), |
5638 | safeFrag = document.createDocumentFragment(); |
5639 | |
5640 | if ( safeFrag.createElement ) { |
5641 | while ( list.length ) { |
5642 | safeFrag.createElement( |
5643 | list.pop() |
5644 | ); |
5645 | } |
5646 | } |
5647 | return safeFrag; |
5648 | } |
5649 | |
5650 | var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + |
5651 | "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", |
5652 | rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, |
5653 | rleadingWhitespace = /^\s+/, |
5654 | rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, |
5655 | rtagName = /<([\w:]+)/, |
5656 | rtbody = /<tbody/i, |
5657 | rhtml = /<|&#?\w+;/, |
5658 | rnoInnerhtml = /<(?:script|style|link)/i, |
5659 | rnocache = /<(?:script|object|embed|option|style)/i, |
5660 | rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), |
5661 | rcheckableType = /^(?:checkbox|radio)$/, |
5662 | // checked="checked" or checked |
5663 | rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
5664 | rscriptType = /\/(java|ecma)script/i, |
5665 | rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g, |
5666 | wrapMap = { |
5667 | option: [ 1, "<select multiple='multiple'>", "</select>" ], |
5668 | legend: [ 1, "<fieldset>", "</fieldset>" ], |
5669 | thead: [ 1, "<table>", "</table>" ], |
5670 | tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
5671 | td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
5672 | col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], |
5673 | area: [ 1, "<map>", "</map>" ], |
5674 | _default: [ 0, "", "" ] |
5675 | }, |
5676 | safeFragment = createSafeFragment( document ), |
5677 | fragmentDiv = safeFragment.appendChild( document.createElement("div") ); |
5678 | |
5679 | wrapMap.optgroup = wrapMap.option; |
5680 | wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
5681 | wrapMap.th = wrapMap.td; |
5682 | |
5683 | // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, |
5684 | // unless wrapped in a div with non-breaking characters in front of it. |
5685 | if ( !jQuery.support.htmlSerialize ) { |
5686 | wrapMap._default = [ 1, "X<div>", "</div>" ]; |
5687 | } |
5688 | |
5689 | jQuery.fn.extend({ |
5690 | text: function( value ) { |
5691 | return jQuery.access( this, function( value ) { |
5692 | return value === undefined ? |
5693 | jQuery.text( this ) : |
5694 | this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); |
5695 | }, null, value, arguments.length ); |
5696 | }, |
5697 | |
5698 | wrapAll: function( html ) { |
5699 | if ( jQuery.isFunction( html ) ) { |
5700 | return this.each(function(i) { |
5701 | jQuery(this).wrapAll( html.call(this, i) ); |
5702 | }); |
5703 | } |
5704 | |
5705 | if ( this[0] ) { |
5706 | // The elements to wrap the target around |
5707 | var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); |
5708 | |
5709 | if ( this[0].parentNode ) { |
5710 | wrap.insertBefore( this[0] ); |
5711 | } |
5712 | |
5713 | wrap.map(function() { |
5714 | var elem = this; |
5715 | |
5716 | while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { |
5717 | elem = elem.firstChild; |
5718 | } |
5719 | |
5720 | return elem; |
5721 | }).append( this ); |
5722 | } |
5723 | |
5724 | return this; |
5725 | }, |
5726 | |
5727 | wrapInner: function( html ) { |
5728 | if ( jQuery.isFunction( html ) ) { |
5729 | return this.each(function(i) { |
5730 | jQuery(this).wrapInner( html.call(this, i) ); |
5731 | }); |
5732 | } |
5733 | |
5734 | return this.each(function() { |
5735 | var self = jQuery( this ), |
5736 | contents = self.contents(); |
5737 | |
5738 | if ( contents.length ) { |
5739 | contents.wrapAll( html ); |
5740 | |
5741 | } else { |
5742 | self.append( html ); |
5743 | } |
5744 | }); |
5745 | }, |
5746 | |
5747 | wrap: function( html ) { |
5748 | var isFunction = jQuery.isFunction( html ); |
5749 | |
5750 | return this.each(function(i) { |
5751 | jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); |
5752 | }); |
5753 | }, |
5754 | |
5755 | unwrap: function() { |
5756 | return this.parent().each(function() { |
5757 | if ( !jQuery.nodeName( this, "body" ) ) { |
5758 | jQuery( this ).replaceWith( this.childNodes ); |
5759 | } |
5760 | }).end(); |
5761 | }, |
5762 | |
5763 | append: function() { |
5764 | return this.domManip(arguments, true, function( elem ) { |
5765 | if ( this.nodeType === 1 || this.nodeType === 11 ) { |
5766 | this.appendChild( elem ); |
5767 | } |
5768 | }); |
5769 | }, |
5770 | |
5771 | prepend: function() { |
5772 | return this.domManip(arguments, true, function( elem ) { |
5773 | if ( this.nodeType === 1 || this.nodeType === 11 ) { |
5774 | this.insertBefore( elem, this.firstChild ); |
5775 | } |
5776 | }); |
5777 | }, |
5778 | |
5779 | before: function() { |
5780 | if ( !isDisconnected( this[0] ) ) { |
5781 | return this.domManip(arguments, false, function( elem ) { |
5782 | this.parentNode.insertBefore( elem, this ); |
5783 | }); |
5784 | } |
5785 | |
5786 | if ( arguments.length ) { |
5787 | var set = jQuery.clean( arguments ); |
5788 | return this.pushStack( jQuery.merge( set, this ), "before", this.selector ); |
5789 | } |
5790 | }, |
5791 | |
5792 | after: function() { |
5793 | if ( !isDisconnected( this[0] ) ) { |
5794 | return this.domManip(arguments, false, function( elem ) { |
5795 | this.parentNode.insertBefore( elem, this.nextSibling ); |
5796 | }); |
5797 | } |
5798 | |
5799 | if ( arguments.length ) { |
5800 | var set = jQuery.clean( arguments ); |
5801 | return this.pushStack( jQuery.merge( this, set ), "after", this.selector ); |
5802 | } |
5803 | }, |
5804 | |
5805 | // keepData is for internal use only--do not document |
5806 | remove: function( selector, keepData ) { |
5807 | var elem, |
5808 | i = 0; |
5809 | |
5810 | for ( ; (elem = this[i]) != null; i++ ) { |
5811 | if ( !selector || jQuery.filter( selector, [ elem ] ).length ) { |
5812 | if ( !keepData && elem.nodeType === 1 ) { |
5813 | jQuery.cleanData( elem.getElementsByTagName("*") ); |
5814 | jQuery.cleanData( [ elem ] ); |
5815 | } |
5816 | |
5817 | if ( elem.parentNode ) { |
5818 | elem.parentNode.removeChild( elem ); |
5819 | } |
5820 | } |
5821 | } |
5822 | |
5823 | return this; |
5824 | }, |
5825 | |
5826 | empty: function() { |
5827 | var elem, |
5828 | i = 0; |
5829 | |
5830 | for ( ; (elem = this[i]) != null; i++ ) { |
5831 | // Remove element nodes and prevent memory leaks |
5832 | if ( elem.nodeType === 1 ) { |
5833 | jQuery.cleanData( elem.getElementsByTagName("*") ); |
5834 | } |
5835 | |
5836 | // Remove any remaining nodes |
5837 | while ( elem.firstChild ) { |
5838 | elem.removeChild( elem.firstChild ); |
5839 | } |
5840 | } |
5841 | |
5842 | return this; |
5843 | }, |
5844 | |
5845 | clone: function( dataAndEvents, deepDataAndEvents ) { |
5846 | dataAndEvents = dataAndEvents == null ? false : dataAndEvents; |
5847 | deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; |
5848 | |
5849 | return this.map( function () { |
5850 | return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); |
5851 | }); |
5852 | }, |
5853 | |
5854 | html: function( value ) { |
5855 | return jQuery.access( this, function( value ) { |
5856 | var elem = this[0] || {}, |
5857 | i = 0, |
5858 | l = this.length; |
5859 | |
5860 | if ( value === undefined ) { |
5861 | return elem.nodeType === 1 ? |
5862 | elem.innerHTML.replace( rinlinejQuery, "" ) : |
5863 | undefined; |
5864 | } |
5865 | |
5866 | // See if we can take a shortcut and just use innerHTML |
5867 | if ( typeof value === "string" && !rnoInnerhtml.test( value ) && |
5868 | ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) && |
5869 | ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && |
5870 | !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { |
5871 | |
5872 | value = value.replace( rxhtmlTag, "<$1></$2>" ); |
5873 | |
5874 | try { |
5875 | for (; i < l; i++ ) { |
5876 | // Remove element nodes and prevent memory leaks |
5877 | elem = this[i] || {}; |
5878 | if ( elem.nodeType === 1 ) { |
5879 | jQuery.cleanData( elem.getElementsByTagName( "*" ) ); |
5880 | elem.innerHTML = value; |
5881 | } |
5882 | } |
5883 | |
5884 | elem = 0; |
5885 | |
5886 | // If using innerHTML throws an exception, use the fallback method |
5887 | } catch(e) {} |
5888 | } |
5889 | |
5890 | if ( elem ) { |
5891 | this.empty().append( value ); |
5892 | } |
5893 | }, null, value, arguments.length ); |
5894 | }, |
5895 | |
5896 | replaceWith: function( value ) { |
5897 | if ( !isDisconnected( this[0] ) ) { |
5898 | // Make sure that the elements are removed from the DOM before they are inserted |
5899 | // this can help fix replacing a parent with child elements |
5900 | if ( jQuery.isFunction( value ) ) { |
5901 | return this.each(function(i) { |
5902 | var self = jQuery(this), old = self.html(); |
5903 | self.replaceWith( value.call( this, i, old ) ); |
5904 | }); |
5905 | } |
5906 | |
5907 | if ( typeof value !== "string" ) { |
5908 | value = jQuery( value ).detach(); |
5909 | } |
5910 | |
5911 | return this.each(function() { |
5912 | var next = this.nextSibling, |
5913 | parent = this.parentNode; |
5914 | |
5915 | jQuery( this ).remove(); |
5916 | |
5917 | if ( next ) { |
5918 | jQuery(next).before( value ); |
5919 | } else { |
5920 | jQuery(parent).append( value ); |
5921 | } |
5922 | }); |
5923 | } |
5924 | |
5925 | return this.length ? |
5926 | this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : |
5927 | this; |
5928 | }, |
5929 | |
5930 | detach: function( selector ) { |
5931 | return this.remove( selector, true ); |
5932 | }, |
5933 | |
5934 | domManip: function( args, table, callback ) { |
5935 | |
5936 | // Flatten any nested arrays |
5937 | args = [].concat.apply( [], args ); |
5938 | |
5939 | var results, first, fragment, iNoClone, |
5940 | i = 0, |
5941 | value = args[0], |
5942 | scripts = [], |
5943 | l = this.length; |
5944 | |
5945 | // We can't cloneNode fragments that contain checked, in WebKit |
5946 | if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) { |
5947 | return this.each(function() { |
5948 | jQuery(this).domManip( args, table, callback ); |
5949 | }); |
5950 | } |
5951 | |
5952 | if ( jQuery.isFunction(value) ) { |
5953 | return this.each(function(i) { |
5954 | var self = jQuery(this); |
5955 | args[0] = value.call( this, i, table ? self.html() : undefined ); |
5956 | self.domManip( args, table, callback ); |
5957 | }); |
5958 | } |
5959 | |
5960 | if ( this[0] ) { |
5961 | results = jQuery.buildFragment( args, this, scripts ); |
5962 | fragment = results.fragment; |
5963 | first = fragment.firstChild; |
5964 | |
5965 | if ( fragment.childNodes.length === 1 ) { |
5966 | fragment = first; |
5967 | } |
5968 | |
5969 | if ( first ) { |
5970 | table = table && jQuery.nodeName( first, "tr" ); |
5971 | |
5972 | // Use the original fragment for the last item instead of the first because it can end up |
5973 | // being emptied incorrectly in certain situations (#8070). |
5974 | // Fragments from the fragment cache must always be cloned and never used in place. |
5975 | for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) { |
5976 | callback.call( |
5977 | table && jQuery.nodeName( this[i], "table" ) ? |
5978 | findOrAppend( this[i], "tbody" ) : |
5979 | this[i], |
5980 | i === iNoClone ? |
5981 | fragment : |
5982 | jQuery.clone( fragment, true, true ) |
5983 | ); |
5984 | } |
5985 | } |
5986 | |
5987 | // Fix #11809: Avoid leaking memory |
5988 | fragment = first = null; |
5989 | |
5990 | if ( scripts.length ) { |
5991 | jQuery.each( scripts, function( i, elem ) { |
5992 | if ( elem.src ) { |
5993 | if ( jQuery.ajax ) { |
5994 | jQuery.ajax({ |
5995 | url: elem.src, |
5996 | type: "GET", |
5997 | dataType: "script", |
5998 | async: false, |
5999 | global: false, |
6000 | "throws": true |
6001 | }); |
6002 | } else { |
6003 | jQuery.error("no ajax"); |
6004 | } |
6005 | } else { |
6006 | jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) ); |
6007 | } |
6008 | |
6009 | if ( elem.parentNode ) { |
6010 | elem.parentNode.removeChild( elem ); |
6011 | } |
6012 | }); |
6013 | } |
6014 | } |
6015 | |
6016 | return this; |
6017 | } |
6018 | }); |
6019 | |
6020 | function findOrAppend( elem, tag ) { |
6021 | return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) ); |
6022 | } |
6023 | |
6024 | function cloneCopyEvent( src, dest ) { |
6025 | |
6026 | if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { |
6027 | return; |
6028 | } |
6029 | |
6030 | var type, i, l, |
6031 | oldData = jQuery._data( src ), |
6032 | curData = jQuery._data( dest, oldData ), |
6033 | events = oldData.events; |
6034 | |
6035 | if ( events ) { |
6036 | delete curData.handle; |
6037 | curData.events = {}; |
6038 | |
6039 | for ( type in events ) { |
6040 | for ( i = 0, l = events[ type ].length; i < l; i++ ) { |
6041 | jQuery.event.add( dest, type, events[ type ][ i ] ); |
6042 | } |
6043 | } |
6044 | } |
6045 | |
6046 | // make the cloned public data object a copy from the original |
6047 | if ( curData.data ) { |
6048 | curData.data = jQuery.extend( {}, curData.data ); |
6049 | } |
6050 | } |
6051 | |
6052 | function cloneFixAttributes( src, dest ) { |
6053 | var nodeName; |
6054 | |
6055 | // We do not need to do anything for non-Elements |
6056 | if ( dest.nodeType !== 1 ) { |
6057 | return; |
6058 | } |
6059 | |
6060 | // clearAttributes removes the attributes, which we don't want, |
6061 | // but also removes the attachEvent events, which we *do* want |
6062 | if ( dest.clearAttributes ) { |
6063 | dest.clearAttributes(); |
6064 | } |
6065 | |
6066 | // mergeAttributes, in contrast, only merges back on the |
6067 | // original attributes, not the events |
6068 | if ( dest.mergeAttributes ) { |
6069 | dest.mergeAttributes( src ); |
6070 | } |
6071 | |
6072 | nodeName = dest.nodeName.toLowerCase(); |
6073 | |
6074 | if ( nodeName === "object" ) { |
6075 | // IE6-10 improperly clones children of object elements using classid. |
6076 | // IE10 throws NoModificationAllowedError if parent is null, #12132. |
6077 | if ( dest.parentNode ) { |
6078 | dest.outerHTML = src.outerHTML; |
6079 | } |
6080 | |
6081 | // This path appears unavoidable for IE9. When cloning an object |
6082 | // element in IE9, the outerHTML strategy above is not sufficient. |
6083 | // If the src has innerHTML and the destination does not, |
6084 | // copy the src.innerHTML into the dest.innerHTML. #10324 |
6085 | if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) { |
6086 | dest.innerHTML = src.innerHTML; |
6087 | } |
6088 | |
6089 | } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) { |
6090 | // IE6-8 fails to persist the checked state of a cloned checkbox |
6091 | // or radio button. Worse, IE6-7 fail to give the cloned element |
6092 | // a checked appearance if the defaultChecked value isn't also set |
6093 | |
6094 | dest.defaultChecked = dest.checked = src.checked; |
6095 | |
6096 | // IE6-7 get confused and end up setting the value of a cloned |
6097 | // checkbox/radio button to an empty string instead of "on" |
6098 | if ( dest.value !== src.value ) { |
6099 | dest.value = src.value; |
6100 | } |
6101 | |
6102 | // IE6-8 fails to return the selected option to the default selected |
6103 | // state when cloning options |
6104 | } else if ( nodeName === "option" ) { |
6105 | dest.selected = src.defaultSelected; |
6106 | |
6107 | // IE6-8 fails to set the defaultValue to the correct value when |
6108 | // cloning other types of input fields |
6109 | } else if ( nodeName === "input" || nodeName === "textarea" ) { |
6110 | dest.defaultValue = src.defaultValue; |
6111 | |
6112 | // IE blanks contents when cloning scripts |
6113 | } else if ( nodeName === "script" && dest.text !== src.text ) { |
6114 | dest.text = src.text; |
6115 | } |
6116 | |
6117 | // Event data gets referenced instead of copied if the expando |
6118 | // gets copied too |
6119 | dest.removeAttribute( jQuery.expando ); |
6120 | } |
6121 | |
6122 | jQuery.buildFragment = function( args, context, scripts ) { |
6123 | var fragment, cacheable, cachehit, |
6124 | first = args[ 0 ]; |
6125 | |
6126 | // Set context from what may come in as undefined or a jQuery collection or a node |
6127 | // Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 & |
6128 | // also doubles as fix for #8950 where plain objects caused createDocumentFragment exception |
6129 | context = context || document; |
6130 | context = !context.nodeType && context[0] || context; |
6131 | context = context.ownerDocument || context; |
6132 | |
6133 | // Only cache "small" (1/2 KB) HTML strings that are associated with the main document |
6134 | // Cloning options loses the selected state, so don't cache them |
6135 | // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment |
6136 | // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache |
6137 | // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501 |
6138 | if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document && |
6139 | first.charAt(0) === "<" && !rnocache.test( first ) && |
6140 | (jQuery.support.checkClone || !rchecked.test( first )) && |
6141 | (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) { |
6142 | |
6143 | // Mark cacheable and look for a hit |
6144 | cacheable = true; |
6145 | fragment = jQuery.fragments[ first ]; |
6146 | cachehit = fragment !== undefined; |
6147 | } |
6148 | |
6149 | if ( !fragment ) { |
6150 | fragment = context.createDocumentFragment(); |
6151 | jQuery.clean( args, context, fragment, scripts ); |
6152 | |
6153 | // Update the cache, but only store false |
6154 | // unless this is a second parsing of the same content |
6155 | if ( cacheable ) { |
6156 | jQuery.fragments[ first ] = cachehit && fragment; |
6157 | } |
6158 | } |
6159 | |
6160 | return { fragment: fragment, cacheable: cacheable }; |
6161 | }; |
6162 | |
6163 | jQuery.fragments = {}; |
6164 | |
6165 | jQuery.each({ |
6166 | appendTo: "append", |
6167 | prependTo: "prepend", |
6168 | insertBefore: "before", |
6169 | insertAfter: "after", |
6170 | replaceAll: "replaceWith" |
6171 | }, function( name, original ) { |
6172 | jQuery.fn[ name ] = function( selector ) { |
6173 | var elems, |
6174 | i = 0, |
6175 | ret = [], |
6176 | insert = jQuery( selector ), |
6177 | l = insert.length, |
6178 | parent = this.length === 1 && this[0].parentNode; |
6179 | |
6180 | if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) { |
6181 | insert[ original ]( this[0] ); |
6182 | return this; |
6183 | } else { |
6184 | for ( ; i < l; i++ ) { |
6185 | elems = ( i > 0 ? this.clone(true) : this ).get(); |
6186 | jQuery( insert[i] )[ original ]( elems ); |
6187 | ret = ret.concat( elems ); |
6188 | } |
6189 | |
6190 | return this.pushStack( ret, name, insert.selector ); |
6191 | } |
6192 | }; |
6193 | }); |
6194 | |
6195 | function getAll( elem ) { |
6196 | if ( typeof elem.getElementsByTagName !== "undefined" ) { |
6197 | return elem.getElementsByTagName( "*" ); |
6198 | |
6199 | } else if ( typeof elem.querySelectorAll !== "undefined" ) { |
6200 | return elem.querySelectorAll( "*" ); |
6201 | |
6202 | } else { |
6203 | return []; |
6204 | } |
6205 | } |
6206 | |
6207 | // Used in clean, fixes the defaultChecked property |
6208 | function fixDefaultChecked( elem ) { |
6209 | if ( rcheckableType.test( elem.type ) ) { |
6210 | elem.defaultChecked = elem.checked; |
6211 | } |
6212 | } |
6213 | |
6214 | jQuery.extend({ |
6215 | clone: function( elem, dataAndEvents, deepDataAndEvents ) { |
6216 | var srcElements, |
6217 | destElements, |
6218 | i, |
6219 | clone; |
6220 | |
6221 | if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { |
6222 | clone = elem.cloneNode( true ); |
6223 | |
6224 | // IE<=8 does not properly clone detached, unknown element nodes |
6225 | } else { |
6226 | fragmentDiv.innerHTML = elem.outerHTML; |
6227 | fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); |
6228 | } |
6229 | |
6230 | if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && |
6231 | (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { |
6232 | // IE copies events bound via attachEvent when using cloneNode. |
6233 | // Calling detachEvent on the clone will also remove the events |
6234 | // from the original. In order to get around this, we use some |
6235 | // proprietary methods to clear the events. Thanks to MooTools |
6236 | // guys for this hotness. |
6237 | |
6238 | cloneFixAttributes( elem, clone ); |
6239 | |
6240 | // Using Sizzle here is crazy slow, so we use getElementsByTagName instead |
6241 | srcElements = getAll( elem ); |
6242 | destElements = getAll( clone ); |
6243 | |
6244 | // Weird iteration because IE will replace the length property |
6245 | // with an element if you are cloning the body and one of the |
6246 | // elements on the page has a name or id of "length" |
6247 | for ( i = 0; srcElements[i]; ++i ) { |
6248 | // Ensure that the destination node is not null; Fixes #9587 |
6249 | if ( destElements[i] ) { |
6250 | cloneFixAttributes( srcElements[i], destElements[i] ); |
6251 | } |
6252 | } |
6253 | } |
6254 | |
6255 | // Copy the events from the original to the clone |
6256 | if ( dataAndEvents ) { |
6257 | cloneCopyEvent( elem, clone ); |
6258 | |
6259 | if ( deepDataAndEvents ) { |
6260 | srcElements = getAll( elem ); |
6261 | destElements = getAll( clone ); |
6262 | |
6263 | for ( i = 0; srcElements[i]; ++i ) { |
6264 | cloneCopyEvent( srcElements[i], destElements[i] ); |
6265 | } |
6266 | } |
6267 | } |
6268 | |
6269 | srcElements = destElements = null; |
6270 | |
6271 | // Return the cloned set |
6272 | return clone; |
6273 | }, |
6274 | |
6275 | clean: function( elems, context, fragment, scripts ) { |
6276 | var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags, |
6277 | safe = context === document && safeFragment, |
6278 | ret = []; |
6279 | |
6280 | // Ensure that context is a document |
6281 | if ( !context || typeof context.createDocumentFragment === "undefined" ) { |
6282 | context = document; |
6283 | } |
6284 | |
6285 | // Use the already-created safe fragment if context permits |
6286 | for ( i = 0; (elem = elems[i]) != null; i++ ) { |
6287 | if ( typeof elem === "number" ) { |
6288 | elem += ""; |
6289 | } |
6290 | |
6291 | if ( !elem ) { |
6292 | continue; |
6293 | } |
6294 | |
6295 | // Convert html string into DOM nodes |
6296 | if ( typeof elem === "string" ) { |
6297 | if ( !rhtml.test( elem ) ) { |
6298 | elem = context.createTextNode( elem ); |
6299 | } else { |
6300 | // Ensure a safe container in which to render the html |
6301 | safe = safe || createSafeFragment( context ); |
6302 | div = context.createElement("div"); |
6303 | safe.appendChild( div ); |
6304 | |
6305 | // Fix "XHTML"-style tags in all browsers |
6306 | elem = elem.replace(rxhtmlTag, "<$1></$2>"); |
6307 | |
6308 | // Go to html and back, then peel off extra wrappers |
6309 | tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(); |
6310 | wrap = wrapMap[ tag ] || wrapMap._default; |
6311 | depth = wrap[0]; |
6312 | div.innerHTML = wrap[1] + elem + wrap[2]; |
6313 | |
6314 | // Move to the right depth |
6315 | while ( depth-- ) { |
6316 | div = div.lastChild; |
6317 | } |
6318 | |
6319 | // Remove IE's autoinserted <tbody> from table fragments |
6320 | if ( !jQuery.support.tbody ) { |
6321 | |
6322 | // String was a <table>, *may* have spurious <tbody> |
6323 | hasBody = rtbody.test(elem); |
6324 | tbody = tag === "table" && !hasBody ? |
6325 | div.firstChild && div.firstChild.childNodes : |
6326 | |
6327 | // String was a bare <thead> or <tfoot> |
6328 | wrap[1] === "<table>" && !hasBody ? |
6329 | div.childNodes : |
6330 | []; |
6331 | |
6332 | for ( j = tbody.length - 1; j >= 0 ; --j ) { |
6333 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
6334 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
6335 | } |
6336 | } |
6337 | } |
6338 | |
6339 | // IE completely kills leading whitespace when innerHTML is used |
6340 | if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
6341 | div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
6342 | } |
6343 | |
6344 | elem = div.childNodes; |
6345 | |
6346 | // Take out of fragment container (we need a fresh div each time) |
6347 | div.parentNode.removeChild( div ); |
6348 | } |
6349 | } |
6350 | |
6351 | if ( elem.nodeType ) { |
6352 | ret.push( elem ); |
6353 | } else { |
6354 | jQuery.merge( ret, elem ); |
6355 | } |
6356 | } |
6357 | |
6358 | // Fix #11356: Clear elements from safeFragment |
6359 | if ( div ) { |
6360 | elem = div = safe = null; |
6361 | } |
6362 | |
6363 | // Reset defaultChecked for any radios and checkboxes |
6364 | // about to be appended to the DOM in IE 6/7 (#8060) |
6365 | if ( !jQuery.support.appendChecked ) { |
6366 | for ( i = 0; (elem = ret[i]) != null; i++ ) { |
6367 | if ( jQuery.nodeName( elem, "input" ) ) { |
6368 | fixDefaultChecked( elem ); |
6369 | } else if ( typeof elem.getElementsByTagName !== "undefined" ) { |
6370 | jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked ); |
6371 | } |
6372 | } |
6373 | } |
6374 | |
6375 | // Append elements to a provided document fragment |
6376 | if ( fragment ) { |
6377 | // Special handling of each script element |
6378 | handleScript = function( elem ) { |
6379 | // Check if we consider it executable |
6380 | if ( !elem.type || rscriptType.test( elem.type ) ) { |
6381 | // Detach the script and store it in the scripts array (if provided) or the fragment |
6382 | // Return truthy to indicate that it has been handled |
6383 | return scripts ? |
6384 | scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) : |
6385 | fragment.appendChild( elem ); |
6386 | } |
6387 | }; |
6388 | |
6389 | for ( i = 0; (elem = ret[i]) != null; i++ ) { |
6390 | // Check if we're done after handling an executable script |
6391 | if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) { |
6392 | // Append to fragment and handle embedded scripts |
6393 | fragment.appendChild( elem ); |
6394 | if ( typeof elem.getElementsByTagName !== "undefined" ) { |
6395 | // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration |
6396 | jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript ); |
6397 | |
6398 | // Splice the scripts into ret after their former ancestor and advance our index beyond them |
6399 | ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); |
6400 | i += jsTags.length; |
6401 | } |
6402 | } |
6403 | } |
6404 | } |
6405 | |
6406 | return ret; |
6407 | }, |
6408 | |
6409 | cleanData: function( elems, /* internal */ acceptData ) { |
6410 | var data, id, elem, type, |
6411 | i = 0, |
6412 | internalKey = jQuery.expando, |
6413 | cache = jQuery.cache, |
6414 | deleteExpando = jQuery.support.deleteExpando, |
6415 | special = jQuery.event.special; |
6416 | |
6417 | for ( ; (elem = elems[i]) != null; i++ ) { |
6418 | |
6419 | if ( acceptData || jQuery.acceptData( elem ) ) { |
6420 | |
6421 | id = elem[ internalKey ]; |
6422 | data = id && cache[ id ]; |
6423 | |
6424 | if ( data ) { |
6425 | if ( data.events ) { |
6426 | for ( type in data.events ) { |
6427 | if ( special[ type ] ) { |
6428 | jQuery.event.remove( elem, type ); |
6429 | |
6430 | // This is a shortcut to avoid jQuery.event.remove's overhead |
6431 | } else { |
6432 | jQuery.removeEvent( elem, type, data.handle ); |
6433 | } |
6434 | } |
6435 | } |
6436 | |
6437 | // Remove cache only if it was not already removed by jQuery.event.remove |
6438 | if ( cache[ id ] ) { |
6439 | |
6440 | delete cache[ id ]; |
6441 | |
6442 | // IE does not allow us to delete expando properties from nodes, |
6443 | // nor does it have a removeAttribute function on Document nodes; |
6444 | // we must handle all of these cases |
6445 | if ( deleteExpando ) { |
6446 | delete elem[ internalKey ]; |
6447 | |
6448 | } else if ( elem.removeAttribute ) { |
6449 | elem.removeAttribute( internalKey ); |
6450 | |
6451 | } else { |
6452 | elem[ internalKey ] = null; |
6453 | } |
6454 | |
6455 | jQuery.deletedIds.push( id ); |
6456 | } |
6457 | } |
6458 | } |
6459 | } |
6460 | } |
6461 | }); |
6462 | // Limit scope pollution from any deprecated API |
6463 | (function() { |
6464 | |
6465 | var matched, browser; |
6466 | |
6467 | // Use of jQuery.browser is frowned upon. |
6468 | // More details: http://api.jquery.com/jQuery.browser |
6469 | // jQuery.uaMatch maintained for back-compat |
6470 | jQuery.uaMatch = function( ua ) { |
6471 | ua = ua.toLowerCase(); |
6472 | |
6473 | var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || |
6474 | /(webkit)[ \/]([\w.]+)/.exec( ua ) || |
6475 | /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || |
6476 | /(msie) ([\w.]+)/.exec( ua ) || |
6477 | ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || |
6478 | []; |
6479 | |
6480 | return { |
6481 | browser: match[ 1 ] || "", |
6482 | version: match[ 2 ] || "0" |
6483 | }; |
6484 | }; |
6485 | |
6486 | matched = jQuery.uaMatch( navigator.userAgent ); |
6487 | browser = {}; |
6488 | |
6489 | if ( matched.browser ) { |
6490 | browser[ matched.browser ] = true; |
6491 | browser.version = matched.version; |
6492 | } |
6493 | |
6494 | // Chrome is Webkit, but Webkit is also Safari. |
6495 | if ( browser.chrome ) { |
6496 | browser.webkit = true; |
6497 | } else if ( browser.webkit ) { |
6498 | browser.safari = true; |
6499 | } |
6500 | |
6501 | jQuery.browser = browser; |
6502 | |
6503 | jQuery.sub = function() { |
6504 | function jQuerySub( selector, context ) { |
6505 | return new jQuerySub.fn.init( selector, context ); |
6506 | } |
6507 | jQuery.extend( true, jQuerySub, this ); |
6508 | jQuerySub.superclass = this; |
6509 | jQuerySub.fn = jQuerySub.prototype = this(); |
6510 | jQuerySub.fn.constructor = jQuerySub; |
6511 | jQuerySub.sub = this.sub; |
6512 | jQuerySub.fn.init = function init( selector, context ) { |
6513 | if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { |
6514 | context = jQuerySub( context ); |
6515 | } |
6516 | |
6517 | return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); |
6518 | }; |
6519 | jQuerySub.fn.init.prototype = jQuerySub.fn; |
6520 | var rootjQuerySub = jQuerySub(document); |
6521 | return jQuerySub; |
6522 | }; |
6523 | |
6524 | })(); |
6525 | var curCSS, iframe, iframeDoc, |
6526 | ralpha = /alpha\([^)]*\)/i, |
6527 | ropacity = /opacity=([^)]*)/, |
6528 | rposition = /^(top|right|bottom|left)$/, |
6529 | // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" |
6530 | // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display |
6531 | rdisplayswap = /^(none|table(?!-c[ea]).+)/, |
6532 | rmargin = /^margin/, |
6533 | rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ), |
6534 | rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ), |
6535 | rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ), |
6536 | elemdisplay = {}, |
6537 | |
6538 | cssShow = { position: "absolute", visibility: "hidden", display: "block" }, |
6539 | cssNormalTransform = { |
6540 | letterSpacing: 0, |
6541 | fontWeight: 400 |
6542 | }, |
6543 | |
6544 | cssExpand = [ "Top", "Right", "Bottom", "Left" ], |
6545 | cssPrefixes = [ "Webkit", "O", "Moz", "ms" ], |
6546 | |
6547 | eventsToggle = jQuery.fn.toggle; |
6548 | |
6549 | // return a css property mapped to a potentially vendor prefixed property |
6550 | function vendorPropName( style, name ) { |
6551 | |
6552 | // shortcut for names that are not vendor prefixed |
6553 | if ( name in style ) { |
6554 | return name; |
6555 | } |
6556 | |
6557 | // check for vendor prefixed names |
6558 | var capName = name.charAt(0).toUpperCase() + name.slice(1), |
6559 | origName = name, |
6560 | i = cssPrefixes.length; |
6561 | |
6562 | while ( i-- ) { |
6563 | name = cssPrefixes[ i ] + capName; |
6564 | if ( name in style ) { |
6565 | return name; |
6566 | } |
6567 | } |
6568 | |
6569 | return origName; |
6570 | } |
6571 | |
6572 | function isHidden( elem, el ) { |
6573 | elem = el || elem; |
6574 | return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); |
6575 | } |
6576 | |
6577 | function showHide( elements, show ) { |
6578 | var elem, display, |
6579 | values = [], |
6580 | index = 0, |
6581 | length = elements.length; |
6582 | |
6583 | for ( ; index < length; index++ ) { |
6584 | elem = elements[ index ]; |
6585 | if ( !elem.style ) { |
6586 | continue; |
6587 | } |
6588 | values[ index ] = jQuery._data( elem, "olddisplay" ); |
6589 | if ( show ) { |
6590 | // Reset the inline display of this element to learn if it is |
6591 | // being hidden by cascaded rules or not |
6592 | if ( !values[ index ] && elem.style.display === "none" ) { |
6593 | elem.style.display = ""; |
6594 | } |
6595 | |
6596 | // Set elements which have been overridden with display: none |
6597 | // in a stylesheet to whatever the default browser style is |
6598 | // for such an element |
6599 | if ( elem.style.display === "" && isHidden( elem ) ) { |
6600 | values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) ); |
6601 | } |
6602 | } else { |
6603 | display = curCSS( elem, "display" ); |
6604 | |
6605 | if ( !values[ index ] && display !== "none" ) { |
6606 | jQuery._data( elem, "olddisplay", display ); |
6607 | } |
6608 | } |
6609 | } |
6610 | |
6611 | // Set the display of most of the elements in a second loop |
6612 | // to avoid the constant reflow |
6613 | for ( index = 0; index < length; index++ ) { |
6614 | elem = elements[ index ]; |
6615 | if ( !elem.style ) { |
6616 | continue; |
6617 | } |
6618 | if ( !show || elem.style.display === "none" || elem.style.display === "" ) { |
6619 | elem.style.display = show ? values[ index ] || "" : "none"; |
6620 | } |
6621 | } |
6622 | |
6623 | return elements; |
6624 | } |
6625 | |
6626 | jQuery.fn.extend({ |
6627 | css: function( name, value ) { |
6628 | return jQuery.access( this, function( elem, name, value ) { |
6629 | return value !== undefined ? |
6630 | jQuery.style( elem, name, value ) : |
6631 | jQuery.css( elem, name ); |
6632 | }, name, value, arguments.length > 1 ); |
6633 | }, |
6634 | show: function() { |
6635 | return showHide( this, true ); |
6636 | }, |
6637 | hide: function() { |
6638 | return showHide( this ); |
6639 | }, |
6640 | toggle: function( state, fn2 ) { |
6641 | var bool = typeof state === "boolean"; |
6642 | |
6643 | if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) { |
6644 | return eventsToggle.apply( this, arguments ); |
6645 | } |
6646 | |
6647 | return this.each(function() { |
6648 | if ( bool ? state : isHidden( this ) ) { |
6649 | jQuery( this ).show(); |
6650 | } else { |
6651 | jQuery( this ).hide(); |
6652 | } |
6653 | }); |
6654 | } |
6655 | }); |
6656 | |
6657 | jQuery.extend({ |
6658 | // Add in style property hooks for overriding the default |
6659 | // behavior of getting and setting a style property |
6660 | cssHooks: { |
6661 | opacity: { |
6662 | get: function( elem, computed ) { |
6663 | if ( computed ) { |
6664 | // We should always get a number back from opacity |
6665 | var ret = curCSS( elem, "opacity" ); |
6666 | return ret === "" ? "1" : ret; |
6667 | |
6668 | } |
6669 | } |
6670 | } |
6671 | }, |
6672 | |
6673 | // Exclude the following css properties to add px |
6674 | cssNumber: { |
6675 | "fillOpacity": true, |
6676 | "fontWeight": true, |
6677 | "lineHeight": true, |
6678 | "opacity": true, |
6679 | "orphans": true, |
6680 | "widows": true, |
6681 | "zIndex": true, |
6682 | "zoom": true |
6683 | }, |
6684 | |
6685 | // Add in properties whose names you wish to fix before |
6686 | // setting or getting the value |
6687 | cssProps: { |
6688 | // normalize float css property |
6689 | "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat" |
6690 | }, |
6691 | |
6692 | // Get and set the style property on a DOM Node |
6693 | style: function( elem, name, value, extra ) { |
6694 | // Don't set styles on text and comment nodes |
6695 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { |
6696 | return; |
6697 | } |
6698 | |
6699 | // Make sure that we're working with the right name |
6700 | var ret, type, hooks, |
6701 | origName = jQuery.camelCase( name ), |
6702 | style = elem.style; |
6703 | |
6704 | name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); |
6705 | |
6706 | // gets hook for the prefixed version |
6707 | // followed by the unprefixed version |
6708 | hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
6709 | |
6710 | // Check if we're setting a value |
6711 | if ( value !== undefined ) { |
6712 | type = typeof value; |
6713 | |
6714 | // convert relative number strings (+= or -=) to relative numbers. #7345 |
6715 | if ( type === "string" && (ret = rrelNum.exec( value )) ) { |
6716 | value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); |
6717 | // Fixes bug #9237 |
6718 | type = "number"; |
6719 | } |
6720 | |
6721 | // Make sure that NaN and null values aren't set. See: #7116 |
6722 | if ( value == null || type === "number" && isNaN( value ) ) { |
6723 | return; |
6724 | } |
6725 | |
6726 | // If a number was passed in, add 'px' to the (except for certain CSS properties) |
6727 | if ( type === "number" && !jQuery.cssNumber[ origName ] ) { |
6728 | value += "px"; |
6729 | } |
6730 | |
6731 | // If a hook was provided, use that value, otherwise just set the specified value |
6732 | if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { |
6733 | // Wrapped to prevent IE from throwing errors when 'invalid' values are provided |
6734 | // Fixes bug #5509 |
6735 | try { |
6736 | style[ name ] = value; |
6737 | } catch(e) {} |
6738 | } |
6739 | |
6740 | } else { |
6741 | // If a hook was provided get the non-computed value from there |
6742 | if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { |
6743 | return ret; |
6744 | } |
6745 | |
6746 | // Otherwise just get the value from the style object |
6747 | return style[ name ]; |
6748 | } |
6749 | }, |
6750 | |
6751 | css: function( elem, name, numeric, extra ) { |
6752 | var val, num, hooks, |
6753 | origName = jQuery.camelCase( name ); |
6754 | |
6755 | // Make sure that we're working with the right name |
6756 | name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); |
6757 | |
6758 | // gets hook for the prefixed version |
6759 | // followed by the unprefixed version |
6760 | hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
6761 | |
6762 | // If a hook was provided get the computed value from there |
6763 | if ( hooks && "get" in hooks ) { |
6764 | val = hooks.get( elem, true, extra ); |
6765 | } |
6766 | |
6767 | // Otherwise, if a way to get the computed value exists, use that |
6768 | if ( val === undefined ) { |
6769 | val = curCSS( elem, name ); |
6770 | } |
6771 | |
6772 | //convert "normal" to computed value |
6773 | if ( val === "normal" && name in cssNormalTransform ) { |
6774 | val = cssNormalTransform[ name ]; |
6775 | } |
6776 | |
6777 | // Return, converting to number if forced or a qualifier was provided and val looks numeric |
6778 | if ( numeric || extra !== undefined ) { |
6779 | num = parseFloat( val ); |
6780 | return numeric || jQuery.isNumeric( num ) ? num || 0 : val; |
6781 | } |
6782 | return val; |
6783 | }, |
6784 | |
6785 | // A method for quickly swapping in/out CSS properties to get correct calculations |
6786 | swap: function( elem, options, callback ) { |
6787 | var ret, name, |
6788 | old = {}; |
6789 | |
6790 | // Remember the old values, and insert the new ones |
6791 | for ( name in options ) { |
6792 | old[ name ] = elem.style[ name ]; |
6793 | elem.style[ name ] = options[ name ]; |
6794 | } |
6795 | |
6796 | ret = callback.call( elem ); |
6797 | |
6798 | // Revert the old values |
6799 | for ( name in options ) { |
6800 | elem.style[ name ] = old[ name ]; |
6801 | } |
6802 | |
6803 | return ret; |
6804 | } |
6805 | }); |
6806 | |
6807 | // NOTE: To any future maintainer, we've window.getComputedStyle |
6808 | // because jsdom on node.js will break without it. |
6809 | if ( window.getComputedStyle ) { |
6810 | curCSS = function( elem, name ) { |
6811 | var ret, width, minWidth, maxWidth, |
6812 | computed = window.getComputedStyle( elem, null ), |
6813 | style = elem.style; |
6814 | |
6815 | if ( computed ) { |
6816 | |
6817 | ret = computed[ name ]; |
6818 | if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { |
6819 | ret = jQuery.style( elem, name ); |
6820 | } |
6821 | |
6822 | // A tribute to the "awesome hack by Dean Edwards" |
6823 | // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right |
6824 | // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels |
6825 | // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values |
6826 | if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { |
6827 | width = style.width; |
6828 | minWidth = style.minWidth; |
6829 | maxWidth = style.maxWidth; |
6830 | |
6831 | style.minWidth = style.maxWidth = style.width = ret; |
6832 | ret = computed.width; |
6833 | |
6834 | style.width = width; |
6835 | style.minWidth = minWidth; |
6836 | style.maxWidth = maxWidth; |
6837 | } |
6838 | } |
6839 | |
6840 | return ret; |
6841 | }; |
6842 | } else if ( document.documentElement.currentStyle ) { |
6843 | curCSS = function( elem, name ) { |
6844 | var left, rsLeft, |
6845 | ret = elem.currentStyle && elem.currentStyle[ name ], |
6846 | style = elem.style; |
6847 | |
6848 | // Avoid setting ret to empty string here |
6849 | // so we don't default to auto |
6850 | if ( ret == null && style && style[ name ] ) { |
6851 | ret = style[ name ]; |
6852 | } |
6853 | |
6854 | // From the awesome hack by Dean Edwards |
6855 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 |
6856 | |
6857 | // If we're not dealing with a regular pixel number |
6858 | // but a number that has a weird ending, we need to convert it to pixels |
6859 | // but not position css attributes, as those are proportional to the parent element instead |
6860 | // and we can't measure the parent instead because it might trigger a "stacking dolls" problem |
6861 | if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { |
6862 | |
6863 | // Remember the original values |
6864 | left = style.left; |
6865 | rsLeft = elem.runtimeStyle && elem.runtimeStyle.left; |
6866 | |
6867 | // Put in the new values to get a computed value out |
6868 | if ( rsLeft ) { |
6869 | elem.runtimeStyle.left = elem.currentStyle.left; |
6870 | } |
6871 | style.left = name === "fontSize" ? "1em" : ret; |
6872 | ret = style.pixelLeft + "px"; |
6873 | |
6874 | // Revert the changed values |
6875 | style.left = left; |
6876 | if ( rsLeft ) { |
6877 | elem.runtimeStyle.left = rsLeft; |
6878 | } |
6879 | } |
6880 | |
6881 | return ret === "" ? "auto" : ret; |
6882 | }; |
6883 | } |
6884 | |
6885 | function setPositiveNumber( elem, value, subtract ) { |
6886 | var matches = rnumsplit.exec( value ); |
6887 | return matches ? |
6888 | Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : |
6889 | value; |
6890 | } |
6891 | |
6892 | function augmentWidthOrHeight( elem, name, extra, isBorderBox ) { |
6893 | var i = extra === ( isBorderBox ? "border" : "content" ) ? |
6894 | // If we already have the right measurement, avoid augmentation |
6895 | 4 : |
6896 | // Otherwise initialize for horizontal or vertical properties |
6897 | name === "width" ? 1 : 0, |
6898 | |
6899 | val = 0; |
6900 | |
6901 | for ( ; i < 4; i += 2 ) { |
6902 | // both box models exclude margin, so add it if we want it |
6903 | if ( extra === "margin" ) { |
6904 | // we use jQuery.css instead of curCSS here |
6905 | // because of the reliableMarginRight CSS hook! |
6906 | val += jQuery.css( elem, extra + cssExpand[ i ], true ); |
6907 | } |
6908 | |
6909 | // From this point on we use curCSS for maximum performance (relevant in animations) |
6910 | if ( isBorderBox ) { |
6911 | // border-box includes padding, so remove it if we want content |
6912 | if ( extra === "content" ) { |
6913 | val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0; |
6914 | } |
6915 | |
6916 | // at this point, extra isn't border nor margin, so remove border |
6917 | if ( extra !== "margin" ) { |
6918 | val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; |
6919 | } |
6920 | } else { |
6921 | // at this point, extra isn't content, so add padding |
6922 | val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0; |
6923 | |
6924 | // at this point, extra isn't content nor padding, so add border |
6925 | if ( extra !== "padding" ) { |
6926 | val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; |
6927 | } |
6928 | } |
6929 | } |
6930 | |
6931 | return val; |
6932 | } |
6933 | |
6934 | function getWidthOrHeight( elem, name, extra ) { |
6935 | |
6936 | // Start with offset property, which is equivalent to the border-box value |
6937 | var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, |
6938 | valueIsBorderBox = true, |
6939 | isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"; |
6940 | |
6941 | // some non-html elements return undefined for offsetWidth, so check for null/undefined |
6942 | // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 |
6943 | // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 |
6944 | if ( val <= 0 || val == null ) { |
6945 | // Fall back to computed then uncomputed css if necessary |
6946 | val = curCSS( elem, name ); |
6947 | if ( val < 0 || val == null ) { |
6948 | val = elem.style[ name ]; |
6949 | } |
6950 | |
6951 | // Computed unit is not pixels. Stop here and return. |
6952 | if ( rnumnonpx.test(val) ) { |
6953 | return val; |
6954 | } |
6955 | |
6956 | // we need the check for style in case a browser which returns unreliable values |
6957 | // for getComputedStyle silently falls back to the reliable elem.style |
6958 | valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] ); |
6959 | |
6960 | // Normalize "", auto, and prepare for extra |
6961 | val = parseFloat( val ) || 0; |
6962 | } |
6963 | |
6964 | // use the active box-sizing model to add/subtract irrelevant styles |
6965 | return ( val + |
6966 | augmentWidthOrHeight( |
6967 | elem, |
6968 | name, |
6969 | extra || ( isBorderBox ? "border" : "content" ), |
6970 | valueIsBorderBox |
6971 | ) |
6972 | ) + "px"; |
6973 | } |
6974 | |
6975 | |
6976 | // Try to determine the default display value of an element |
6977 | function css_defaultDisplay( nodeName ) { |
6978 | if ( elemdisplay[ nodeName ] ) { |
6979 | return elemdisplay[ nodeName ]; |
6980 | } |
6981 | |
6982 | var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ), |
6983 | display = elem.css("display"); |
6984 | elem.remove(); |
6985 | |
6986 | // If the simple way fails, |
6987 | // get element's real default display by attaching it to a temp iframe |
6988 | if ( display === "none" || display === "" ) { |
6989 | // Use the already-created iframe if possible |
6990 | iframe = document.body.appendChild( |
6991 | iframe || jQuery.extend( document.createElement("iframe"), { |
6992 | frameBorder: 0, |
6993 | width: 0, |
6994 | height: 0 |
6995 | }) |
6996 | ); |
6997 | |
6998 | // Create a cacheable copy of the iframe document on first call. |
6999 | // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML |
7000 | // document to it; WebKit & Firefox won't allow reusing the iframe document. |
7001 | if ( !iframeDoc || !iframe.createElement ) { |
7002 | iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document; |
7003 | iframeDoc.write("<!doctype html><html><body>"); |
7004 | iframeDoc.close(); |
7005 | } |
7006 | |
7007 | elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) ); |
7008 | |
7009 | display = curCSS( elem, "display" ); |
7010 | document.body.removeChild( iframe ); |
7011 | } |
7012 | |
7013 | // Store the correct default display |
7014 | elemdisplay[ nodeName ] = display; |
7015 | |
7016 | return display; |
7017 | } |
7018 | |
7019 | jQuery.each([ "height", "width" ], function( i, name ) { |
7020 | jQuery.cssHooks[ name ] = { |
7021 | get: function( elem, computed, extra ) { |
7022 | if ( computed ) { |
7023 | // certain elements can have dimension info if we invisibly show them |
7024 | // however, it must have a current display style that would benefit from this |
7025 | if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) { |
7026 | return jQuery.swap( elem, cssShow, function() { |
7027 | return getWidthOrHeight( elem, name, extra ); |
7028 | }); |
7029 | } else { |
7030 | return getWidthOrHeight( elem, name, extra ); |
7031 | } |
7032 | } |
7033 | }, |
7034 | |
7035 | set: function( elem, value, extra ) { |
7036 | return setPositiveNumber( elem, value, extra ? |
7037 | augmentWidthOrHeight( |
7038 | elem, |
7039 | name, |
7040 | extra, |
7041 | jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box" |
7042 | ) : 0 |
7043 | ); |
7044 | } |
7045 | }; |
7046 | }); |
7047 | |
7048 | if ( !jQuery.support.opacity ) { |
7049 | jQuery.cssHooks.opacity = { |
7050 | get: function( elem, computed ) { |
7051 | // IE uses filters for opacity |
7052 | return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? |
7053 | ( 0.01 * parseFloat( RegExp.$1 ) ) + "" : |
7054 | computed ? "1" : ""; |
7055 | }, |
7056 | |
7057 | set: function( elem, value ) { |
7058 | var style = elem.style, |
7059 | currentStyle = elem.currentStyle, |
7060 | opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "", |
7061 | filter = currentStyle && currentStyle.filter || style.filter || ""; |
7062 | |
7063 | // IE has trouble with opacity if it does not have layout |
7064 | // Force it by setting the zoom level |
7065 | style.zoom = 1; |
7066 | |
7067 | // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 |
7068 | if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" && |
7069 | style.removeAttribute ) { |
7070 | |
7071 | // Setting style.filter to null, "" & " " still leave "filter:" in the cssText |
7072 | // if "filter:" is present at all, clearType is disabled, we want to avoid this |
7073 | // style.removeAttribute is IE Only, but so apparently is this code path... |
7074 | style.removeAttribute( "filter" ); |
7075 | |
7076 | // if there there is no filter style applied in a css rule, we are done |
7077 | if ( currentStyle && !currentStyle.filter ) { |
7078 | return; |
7079 | } |
7080 | } |
7081 | |
7082 | // otherwise, set new filter values |
7083 | style.filter = ralpha.test( filter ) ? |
7084 | filter.replace( ralpha, opacity ) : |
7085 | filter + " " + opacity; |
7086 | } |
7087 | }; |
7088 | } |
7089 | |
7090 | // These hooks cannot be added until DOM ready because the support test |
7091 | // for it is not run until after DOM ready |
7092 | jQuery(function() { |
7093 | if ( !jQuery.support.reliableMarginRight ) { |
7094 | jQuery.cssHooks.marginRight = { |
7095 | get: function( elem, computed ) { |
7096 | // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
7097 | // Work around by temporarily setting element display to inline-block |
7098 | return jQuery.swap( elem, { "display": "inline-block" }, function() { |
7099 | if ( computed ) { |
7100 | return curCSS( elem, "marginRight" ); |
7101 | } |
7102 | }); |
7103 | } |
7104 | }; |
7105 | } |
7106 | |
7107 | // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 |
7108 | // getComputedStyle returns percent when specified for top/left/bottom/right |
7109 | // rather than make the css module depend on the offset module, we just check for it here |
7110 | if ( !jQuery.support.pixelPosition && jQuery.fn.position ) { |
7111 | jQuery.each( [ "top", "left" ], function( i, prop ) { |
7112 | jQuery.cssHooks[ prop ] = { |
7113 | get: function( elem, computed ) { |
7114 | if ( computed ) { |
7115 | var ret = curCSS( elem, prop ); |
7116 | // if curCSS returns percentage, fallback to offset |
7117 | return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret; |
7118 | } |
7119 | } |
7120 | }; |
7121 | }); |
7122 | } |
7123 | |
7124 | }); |
7125 | |
7126 | if ( jQuery.expr && jQuery.expr.filters ) { |
7127 | jQuery.expr.filters.hidden = function( elem ) { |
7128 | return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none"); |
7129 | }; |
7130 | |
7131 | jQuery.expr.filters.visible = function( elem ) { |
7132 | return !jQuery.expr.filters.hidden( elem ); |
7133 | }; |
7134 | } |
7135 | |
7136 | // These hooks are used by animate to expand properties |
7137 | jQuery.each({ |
7138 | margin: "", |
7139 | padding: "", |
7140 | border: "Width" |
7141 | }, function( prefix, suffix ) { |
7142 | jQuery.cssHooks[ prefix + suffix ] = { |
7143 | expand: function( value ) { |
7144 | var i, |
7145 | |
7146 | // assumes a single number if not a string |
7147 | parts = typeof value === "string" ? value.split(" ") : [ value ], |
7148 | expanded = {}; |
7149 | |
7150 | for ( i = 0; i < 4; i++ ) { |
7151 | expanded[ prefix + cssExpand[ i ] + suffix ] = |
7152 | parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; |
7153 | } |
7154 | |
7155 | return expanded; |
7156 | } |
7157 | }; |
7158 | |
7159 | if ( !rmargin.test( prefix ) ) { |
7160 | jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; |
7161 | } |
7162 | }); |
7163 | var r20 = /%20/g, |
7164 | rbracket = /\[\]$/, |
7165 | rCRLF = /\r?\n/g, |
7166 | rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, |
7167 | rselectTextarea = /^(?:select|textarea)/i; |
7168 | |
7169 | jQuery.fn.extend({ |
7170 | serialize: function() { |
7171 | return jQuery.param( this.serializeArray() ); |
7172 | }, |
7173 | serializeArray: function() { |
7174 | return this.map(function(){ |
7175 | return this.elements ? jQuery.makeArray( this.elements ) : this; |
7176 | }) |
7177 | .filter(function(){ |
7178 | return this.name && !this.disabled && |
7179 | ( this.checked || rselectTextarea.test( this.nodeName ) || |
7180 | rinput.test( this.type ) ); |
7181 | }) |
7182 | .map(function( i, elem ){ |
7183 | var val = jQuery( this ).val(); |
7184 | |
7185 | return val == null ? |
7186 | null : |
7187 | jQuery.isArray( val ) ? |
7188 | jQuery.map( val, function( val, i ){ |
7189 | return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
7190 | }) : |
7191 | { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
7192 | }).get(); |
7193 | } |
7194 | }); |
7195 | |
7196 | //Serialize an array of form elements or a set of |
7197 | //key/values into a query string |
7198 | jQuery.param = function( a, traditional ) { |
7199 | var prefix, |
7200 | s = [], |
7201 | add = function( key, value ) { |
7202 | // If value is a function, invoke it and return its value |
7203 | value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); |
7204 | s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
7205 | }; |
7206 | |
7207 | // Set traditional to true for jQuery <= 1.3.2 behavior. |
7208 | if ( traditional === undefined ) { |
7209 | traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; |
7210 | } |
7211 | |
7212 | // If an array was passed in, assume that it is an array of form elements. |
7213 | if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
7214 | // Serialize the form elements |
7215 | jQuery.each( a, function() { |
7216 | add( this.name, this.value ); |
7217 | }); |
7218 | |
7219 | } else { |
7220 | // If traditional, encode the "old" way (the way 1.3.2 or older |
7221 | // did it), otherwise encode params recursively. |
7222 | for ( prefix in a ) { |
7223 | buildParams( prefix, a[ prefix ], traditional, add ); |
7224 | } |
7225 | } |
7226 | |
7227 | // Return the resulting serialization |
7228 | return s.join( "&" ).replace( r20, "+" ); |
7229 | }; |
7230 | |
7231 | function buildParams( prefix, obj, traditional, add ) { |
7232 | var name; |
7233 | |
7234 | if ( jQuery.isArray( obj ) ) { |
7235 | // Serialize array item. |
7236 | jQuery.each( obj, function( i, v ) { |
7237 | if ( traditional || rbracket.test( prefix ) ) { |
7238 | // Treat each array item as a scalar. |
7239 | add( prefix, v ); |
7240 | |
7241 | } else { |
7242 | // If array item is non-scalar (array or object), encode its |
7243 | // numeric index to resolve deserialization ambiguity issues. |
7244 | // Note that rack (as of 1.0.0) can't currently deserialize |
7245 | // nested arrays properly, and attempting to do so may cause |
7246 | // a server error. Possible fixes are to modify rack's |
7247 | // deserialization algorithm or to provide an option or flag |
7248 | // to force array serialization to be shallow. |
7249 | buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); |
7250 | } |
7251 | }); |
7252 | |
7253 | } else if ( !traditional && jQuery.type( obj ) === "object" ) { |
7254 | // Serialize object item. |
7255 | for ( name in obj ) { |
7256 | buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
7257 | } |
7258 | |
7259 | } else { |
7260 | // Serialize scalar item. |
7261 | add( prefix, obj ); |
7262 | } |
7263 | } |
7264 | var |
7265 | // Document location |
7266 | ajaxLocParts, |
7267 | ajaxLocation, |
7268 | |
7269 | rhash = /#.*$/, |
7270 | rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL |
7271 | // #7653, #8125, #8152: local protocol detection |
7272 | rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, |
7273 | rnoContent = /^(?:GET|HEAD)$/, |
7274 | rprotocol = /^\/\//, |
7275 | rquery = /\?/, |
7276 | rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, |
7277 | rts = /([?&])_=[^&]*/, |
7278 | rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/, |
7279 | |
7280 | // Keep a copy of the old load method |
7281 | _load = jQuery.fn.load, |
7282 | |
7283 | /* Prefilters |
7284 | * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) |
7285 | * 2) These are called: |
7286 | * - BEFORE asking for a transport |
7287 | * - AFTER param serialization (s.data is a string if s.processData is true) |
7288 | * 3) key is the dataType |
7289 | * 4) the catchall symbol "*" can be used |
7290 | * 5) execution will start with transport dataType and THEN continue down to "*" if needed |
7291 | */ |
7292 | prefilters = {}, |
7293 | |
7294 | /* Transports bindings |
7295 | * 1) key is the dataType |
7296 | * 2) the catchall symbol "*" can be used |
7297 | * 3) selection will start with transport dataType and THEN go to "*" if needed |
7298 | */ |
7299 | transports = {}, |
7300 | |
7301 | // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression |
7302 | allTypes = ["*/"] + ["*"]; |
7303 | |
7304 | // #8138, IE may throw an exception when accessing |
7305 | // a field from window.location if document.domain has been set |
7306 | try { |
7307 | ajaxLocation = location.href; |
7308 | } catch( e ) { |
7309 | // Use the href attribute of an A element |
7310 | // since IE will modify it given document.location |
7311 | ajaxLocation = document.createElement( "a" ); |
7312 | ajaxLocation.href = ""; |
7313 | ajaxLocation = ajaxLocation.href; |
7314 | } |
7315 | |
7316 | // Segment location into parts |
7317 | ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; |
7318 | |
7319 | // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport |
7320 | function addToPrefiltersOrTransports( structure ) { |
7321 | |
7322 | // dataTypeExpression is optional and defaults to "*" |
7323 | return function( dataTypeExpression, func ) { |
7324 | |
7325 | if ( typeof dataTypeExpression !== "string" ) { |
7326 | func = dataTypeExpression; |
7327 | dataTypeExpression = "*"; |
7328 | } |
7329 | |
7330 | var dataType, list, placeBefore, |
7331 | dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ), |
7332 | i = 0, |
7333 | length = dataTypes.length; |
7334 | |
7335 | if ( jQuery.isFunction( func ) ) { |
7336 | // For each dataType in the dataTypeExpression |
7337 | for ( ; i < length; i++ ) { |
7338 | dataType = dataTypes[ i ]; |
7339 | // We control if we're asked to add before |
7340 | // any existing element |
7341 | placeBefore = /^\+/.test( dataType ); |
7342 | if ( placeBefore ) { |
7343 | dataType = dataType.substr( 1 ) || "*"; |
7344 | } |
7345 | list = structure[ dataType ] = structure[ dataType ] || []; |
7346 | // then we add to the structure accordingly |
7347 | list[ placeBefore ? "unshift" : "push" ]( func ); |
7348 | } |
7349 | } |
7350 | }; |
7351 | } |
7352 | |
7353 | // Base inspection function for prefilters and transports |
7354 | function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, |
7355 | dataType /* internal */, inspected /* internal */ ) { |
7356 | |
7357 | dataType = dataType || options.dataTypes[ 0 ]; |
7358 | inspected = inspected || {}; |
7359 | |
7360 | inspected[ dataType ] = true; |
7361 | |
7362 | var selection, |
7363 | list = structure[ dataType ], |
7364 | i = 0, |
7365 | length = list ? list.length : 0, |
7366 | executeOnly = ( structure === prefilters ); |
7367 | |
7368 | for ( ; i < length && ( executeOnly || !selection ); i++ ) { |
7369 | selection = list[ i ]( options, originalOptions, jqXHR ); |
7370 | // If we got redirected to another dataType |
7371 | // we try there if executing only and not done already |
7372 | if ( typeof selection === "string" ) { |
7373 | if ( !executeOnly || inspected[ selection ] ) { |
7374 | selection = undefined; |
7375 | } else { |
7376 | options.dataTypes.unshift( selection ); |
7377 | selection = inspectPrefiltersOrTransports( |
7378 | structure, options, originalOptions, jqXHR, selection, inspected ); |
7379 | } |
7380 | } |
7381 | } |
7382 | // If we're only executing or nothing was selected |
7383 | // we try the catchall dataType if not done already |
7384 | if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) { |
7385 | selection = inspectPrefiltersOrTransports( |
7386 | structure, options, originalOptions, jqXHR, "*", inspected ); |
7387 | } |
7388 | // unnecessary when only executing (prefilters) |
7389 | // but it'll be ignored by the caller in that case |
7390 | return selection; |
7391 | } |
7392 | |
7393 | // A special extend for ajax options |
7394 | // that takes "flat" options (not to be deep extended) |
7395 | // Fixes #9887 |
7396 | function ajaxExtend( target, src ) { |
7397 | var key, deep, |
7398 | flatOptions = jQuery.ajaxSettings.flatOptions || {}; |
7399 | for ( key in src ) { |
7400 | if ( src[ key ] !== undefined ) { |
7401 | ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; |
7402 | } |
7403 | } |
7404 | if ( deep ) { |
7405 | jQuery.extend( true, target, deep ); |
7406 | } |
7407 | } |
7408 | |
7409 | jQuery.fn.load = function( url, params, callback ) { |
7410 | if ( typeof url !== "string" && _load ) { |
7411 | return _load.apply( this, arguments ); |
7412 | } |
7413 | |
7414 | // Don't do a request if no elements are being requested |
7415 | if ( !this.length ) { |
7416 | return this; |
7417 | } |
7418 | |
7419 | var selector, type, response, |
7420 | self = this, |
7421 | off = url.indexOf(" "); |
7422 | |
7423 | if ( off >= 0 ) { |
7424 | selector = url.slice( off, url.length ); |
7425 | url = url.slice( 0, off ); |
7426 | } |
7427 | |
7428 | // If it's a function |
7429 | if ( jQuery.isFunction( params ) ) { |
7430 | |
7431 | // We assume that it's the callback |
7432 | callback = params; |
7433 | params = undefined; |
7434 | |
7435 | // Otherwise, build a param string |
7436 | } else if ( params && typeof params === "object" ) { |
7437 | type = "POST"; |
7438 | } |
7439 | |
7440 | // Request the remote document |
7441 | jQuery.ajax({ |
7442 | url: url, |
7443 | |
7444 | // if "type" variable is undefined, then "GET" method will be used |
7445 | type: type, |
7446 | dataType: "html", |
7447 | data: params, |
7448 | complete: function( jqXHR, status ) { |
7449 | if ( callback ) { |
7450 | self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); |
7451 | } |
7452 | } |
7453 | }).done(function( responseText ) { |
7454 | |
7455 | // Save response for use in complete callback |
7456 | response = arguments; |
7457 | |
7458 | // See if a selector was specified |
7459 | self.html( selector ? |
7460 | |
7461 | // Create a dummy div to hold the results |
7462 | jQuery("<div>") |
7463 | |
7464 | // inject the contents of the document in, removing the scripts |
7465 | // to avoid any 'Permission Denied' errors in IE |
7466 | .append( responseText.replace( rscript, "" ) ) |
7467 | |
7468 | // Locate the specified elements |
7469 | .find( selector ) : |
7470 | |
7471 | // If not, just inject the full result |
7472 | responseText ); |
7473 | |
7474 | }); |
7475 | |
7476 | return this; |
7477 | }; |
7478 | |
7479 | // Attach a bunch of functions for handling common AJAX events |
7480 | jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){ |
7481 | jQuery.fn[ o ] = function( f ){ |
7482 | return this.on( o, f ); |
7483 | }; |
7484 | }); |
7485 | |
7486 | jQuery.each( [ "get", "post" ], function( i, method ) { |
7487 | jQuery[ method ] = function( url, data, callback, type ) { |
7488 | // shift arguments if data argument was omitted |
7489 | if ( jQuery.isFunction( data ) ) { |
7490 | type = type || callback; |
7491 | callback = data; |
7492 | data = undefined; |
7493 | } |
7494 | |
7495 | return jQuery.ajax({ |
7496 | type: method, |
7497 | url: url, |
7498 | data: data, |
7499 | success: callback, |
7500 | dataType: type |
7501 | }); |
7502 | }; |
7503 | }); |
7504 | |
7505 | jQuery.extend({ |
7506 | |
7507 | getScript: function( url, callback ) { |
7508 | return jQuery.get( url, undefined, callback, "script" ); |
7509 | }, |
7510 | |
7511 | getJSON: function( url, data, callback ) { |
7512 | return jQuery.get( url, data, callback, "json" ); |
7513 | }, |
7514 | |
7515 | // Creates a full fledged settings object into target |
7516 | // with both ajaxSettings and settings fields. |
7517 | // If target is omitted, writes into ajaxSettings. |
7518 | ajaxSetup: function( target, settings ) { |
7519 | if ( settings ) { |
7520 | // Building a settings object |
7521 | ajaxExtend( target, jQuery.ajaxSettings ); |
7522 | } else { |
7523 | // Extending ajaxSettings |
7524 | settings = target; |
7525 | target = jQuery.ajaxSettings; |
7526 | } |
7527 | ajaxExtend( target, settings ); |
7528 | return target; |
7529 | }, |
7530 | |
7531 | ajaxSettings: { |
7532 | url: ajaxLocation, |
7533 | isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), |
7534 | global: true, |
7535 | type: "GET", |
7536 | contentType: "application/x-www-form-urlencoded; charset=UTF-8", |
7537 | processData: true, |
7538 | async: true, |
7539 | /* |
7540 | timeout: 0, |
7541 | data: null, |
7542 | dataType: null, |
7543 | username: null, |
7544 | password: null, |
7545 | cache: null, |
7546 | throws: false, |
7547 | traditional: false, |
7548 | headers: {}, |
7549 | */ |
7550 | |
7551 | accepts: { |
7552 | xml: "application/xml, text/xml", |
7553 | html: "text/html", |
7554 | text: "text/plain", |
7555 | json: "application/json, text/javascript", |
7556 | "*": allTypes |
7557 | }, |
7558 | |
7559 | contents: { |
7560 | xml: /xml/, |
7561 | html: /html/, |
7562 | json: /json/ |
7563 | }, |
7564 | |
7565 | responseFields: { |
7566 | xml: "responseXML", |
7567 | text: "responseText" |
7568 | }, |
7569 | |
7570 | // List of data converters |
7571 | // 1) key format is "source_type destination_type" (a single space in-between) |
7572 | // 2) the catchall symbol "*" can be used for source_type |
7573 | converters: { |
7574 | |
7575 | // Convert anything to text |
7576 | "* text": window.String, |
7577 | |
7578 | // Text to html (true = no transformation) |
7579 | "text html": true, |
7580 | |
7581 | // Evaluate text as a json expression |
7582 | "text json": jQuery.parseJSON, |
7583 | |
7584 | // Parse text as xml |
7585 | "text xml": jQuery.parseXML |
7586 | }, |
7587 | |
7588 | // For options that shouldn't be deep extended: |
7589 | // you can add your own custom options here if |
7590 | // and when you create one that shouldn't be |
7591 | // deep extended (see ajaxExtend) |
7592 | flatOptions: { |
7593 | context: true, |
7594 | url: true |
7595 | } |
7596 | }, |
7597 | |
7598 | ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), |
7599 | ajaxTransport: addToPrefiltersOrTransports( transports ), |
7600 | |
7601 | // Main method |
7602 | ajax: function( url, options ) { |
7603 | |
7604 | // If url is an object, simulate pre-1.5 signature |
7605 | if ( typeof url === "object" ) { |
7606 | options = url; |
7607 | url = undefined; |
7608 | } |
7609 | |
7610 | // Force options to be an object |
7611 | options = options || {}; |
7612 | |
7613 | var // ifModified key |
7614 | ifModifiedKey, |
7615 | // Response headers |
7616 | responseHeadersString, |
7617 | responseHeaders, |
7618 | // transport |
7619 | transport, |
7620 | // timeout handle |
7621 | timeoutTimer, |
7622 | // Cross-domain detection vars |
7623 | parts, |
7624 | // To know if global events are to be dispatched |
7625 | fireGlobals, |
7626 | // Loop variable |
7627 | i, |
7628 | // Create the final options object |
7629 | s = jQuery.ajaxSetup( {}, options ), |
7630 | // Callbacks context |
7631 | callbackContext = s.context || s, |
7632 | // Context for global events |
7633 | // It's the callbackContext if one was provided in the options |
7634 | // and if it's a DOM node or a jQuery collection |
7635 | globalEventContext = callbackContext !== s && |
7636 | ( callbackContext.nodeType || callbackContext instanceof jQuery ) ? |
7637 | jQuery( callbackContext ) : jQuery.event, |
7638 | // Deferreds |
7639 | deferred = jQuery.Deferred(), |
7640 | completeDeferred = jQuery.Callbacks( "once memory" ), |
7641 | // Status-dependent callbacks |
7642 | statusCode = s.statusCode || {}, |
7643 | // Headers (they are sent all at once) |
7644 | requestHeaders = {}, |
7645 | requestHeadersNames = {}, |
7646 | // The jqXHR state |
7647 | state = 0, |
7648 | // Default abort message |
7649 | strAbort = "canceled", |
7650 | // Fake xhr |
7651 | jqXHR = { |
7652 | |
7653 | readyState: 0, |
7654 | |
7655 | // Caches the header |
7656 | setRequestHeader: function( name, value ) { |
7657 | if ( !state ) { |
7658 | var lname = name.toLowerCase(); |
7659 | name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; |
7660 | requestHeaders[ name ] = value; |
7661 | } |
7662 | return this; |
7663 | }, |
7664 | |
7665 | // Raw string |
7666 | getAllResponseHeaders: function() { |
7667 | return state === 2 ? responseHeadersString : null; |
7668 | }, |
7669 | |
7670 | // Builds headers hashtable if needed |
7671 | getResponseHeader: function( key ) { |
7672 | var match; |
7673 | if ( state === 2 ) { |
7674 | if ( !responseHeaders ) { |
7675 | responseHeaders = {}; |
7676 | while( ( match = rheaders.exec( responseHeadersString ) ) ) { |
7677 | responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; |
7678 | } |
7679 | } |
7680 | match = responseHeaders[ key.toLowerCase() ]; |
7681 | } |
7682 | return match === undefined ? null : match; |
7683 | }, |
7684 | |
7685 | // Overrides response content-type header |
7686 | overrideMimeType: function( type ) { |
7687 | if ( !state ) { |
7688 | s.mimeType = type; |
7689 | } |
7690 | return this; |
7691 | }, |
7692 | |
7693 | // Cancel the request |
7694 | abort: function( statusText ) { |
7695 | statusText = statusText || strAbort; |
7696 | if ( transport ) { |
7697 | transport.abort( statusText ); |
7698 | } |
7699 | done( 0, statusText ); |
7700 | return this; |
7701 | } |
7702 | }; |
7703 | |
7704 | // Callback for when everything is done |
7705 | // It is defined here because jslint complains if it is declared |
7706 | // at the end of the function (which would be more logical and readable) |
7707 | function done( status, nativeStatusText, responses, headers ) { |
7708 | var isSuccess, success, error, response, modified, |
7709 | statusText = nativeStatusText; |
7710 | |
7711 | // Called once |
7712 | if ( state === 2 ) { |
7713 | return; |
7714 | } |
7715 | |
7716 | // State is "done" now |
7717 | state = 2; |
7718 | |
7719 | // Clear timeout if it exists |
7720 | if ( timeoutTimer ) { |
7721 | clearTimeout( timeoutTimer ); |
7722 | } |
7723 | |
7724 | // Dereference transport for early garbage collection |
7725 | // (no matter how long the jqXHR object will be used) |
7726 | transport = undefined; |
7727 | |
7728 | // Cache response headers |
7729 | responseHeadersString = headers || ""; |
7730 | |
7731 | // Set readyState |
7732 | jqXHR.readyState = status > 0 ? 4 : 0; |
7733 | |
7734 | // Get response data |
7735 | if ( responses ) { |
7736 | response = ajaxHandleResponses( s, jqXHR, responses ); |
7737 | } |
7738 | |
7739 | // If successful, handle type chaining |
7740 | if ( status >= 200 && status < 300 || status === 304 ) { |
7741 | |
7742 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
7743 | if ( s.ifModified ) { |
7744 | |
7745 | modified = jqXHR.getResponseHeader("Last-Modified"); |
7746 | if ( modified ) { |
7747 | jQuery.lastModified[ ifModifiedKey ] = modified; |
7748 | } |
7749 | modified = jqXHR.getResponseHeader("Etag"); |
7750 | if ( modified ) { |
7751 | jQuery.etag[ ifModifiedKey ] = modified; |
7752 | } |
7753 | } |
7754 | |
7755 | // If not modified |
7756 | if ( status === 304 ) { |
7757 | |
7758 | statusText = "notmodified"; |
7759 | isSuccess = true; |
7760 | |
7761 | // If we have data |
7762 | } else { |
7763 | |
7764 | isSuccess = ajaxConvert( s, response ); |
7765 | statusText = isSuccess.state; |
7766 | success = isSuccess.data; |
7767 | error = isSuccess.error; |
7768 | isSuccess = !error; |
7769 | } |
7770 | } else { |
7771 | // We extract error from statusText |
7772 | // then normalize statusText and status for non-aborts |
7773 | error = statusText; |
7774 | if ( !statusText || status ) { |
7775 | statusText = "error"; |
7776 | if ( status < 0 ) { |
7777 | status = 0; |
7778 | } |
7779 | } |
7780 | } |
7781 | |
7782 | // Set data for the fake xhr object |
7783 | jqXHR.status = status; |
7784 | jqXHR.statusText = ( nativeStatusText || statusText ) + ""; |
7785 | |
7786 | // Success/Error |
7787 | if ( isSuccess ) { |
7788 | deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); |
7789 | } else { |
7790 | deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); |
7791 | } |
7792 | |
7793 | // Status-dependent callbacks |
7794 | jqXHR.statusCode( statusCode ); |
7795 | statusCode = undefined; |
7796 | |
7797 | if ( fireGlobals ) { |
7798 | globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), |
7799 | [ jqXHR, s, isSuccess ? success : error ] ); |
7800 | } |
7801 | |
7802 | // Complete |
7803 | completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); |
7804 | |
7805 | if ( fireGlobals ) { |
7806 | globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); |
7807 | // Handle the global AJAX counter |
7808 | if ( !( --jQuery.active ) ) { |
7809 | jQuery.event.trigger( "ajaxStop" ); |
7810 | } |
7811 | } |
7812 | } |
7813 | |
7814 | // Attach deferreds |
7815 | deferred.promise( jqXHR ); |
7816 | jqXHR.success = jqXHR.done; |
7817 | jqXHR.error = jqXHR.fail; |
7818 | jqXHR.complete = completeDeferred.add; |
7819 | |
7820 | // Status-dependent callbacks |
7821 | jqXHR.statusCode = function( map ) { |
7822 | if ( map ) { |
7823 | var tmp; |
7824 | if ( state < 2 ) { |
7825 | for ( tmp in map ) { |
7826 | statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; |
7827 | } |
7828 | } else { |
7829 | tmp = map[ jqXHR.status ]; |
7830 | jqXHR.always( tmp ); |
7831 | } |
7832 | } |
7833 | return this; |
7834 | }; |
7835 | |
7836 | // Remove hash character (#7531: and string promotion) |
7837 | // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) |
7838 | // We also use the url parameter if available |
7839 | s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); |
7840 | |
7841 | // Extract dataTypes list |
7842 | s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace ); |
7843 | |
7844 | // A cross-domain request is in order when we have a protocol:host:port mismatch |
7845 | if ( s.crossDomain == null ) { |
7846 | parts = rurl.exec( s.url.toLowerCase() ) || false; |
7847 | s.crossDomain = parts && ( parts.join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !== |
7848 | ( ajaxLocParts.join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ); |
7849 | } |
7850 | |
7851 | // Convert data if not already a string |
7852 | if ( s.data && s.processData && typeof s.data !== "string" ) { |
7853 | s.data = jQuery.param( s.data, s.traditional ); |
7854 | } |
7855 | |
7856 | // Apply prefilters |
7857 | inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); |
7858 | |
7859 | // If request was aborted inside a prefilter, stop there |
7860 | if ( state === 2 ) { |
7861 | return jqXHR; |
7862 | } |
7863 | |
7864 | // We can fire global events as of now if asked to |
7865 | fireGlobals = s.global; |
7866 | |
7867 | // Uppercase the type |
7868 | s.type = s.type.toUpperCase(); |
7869 | |
7870 | // Determine if request has content |
7871 | s.hasContent = !rnoContent.test( s.type ); |
7872 | |
7873 | // Watch for a new set of requests |
7874 | if ( fireGlobals && jQuery.active++ === 0 ) { |
7875 | jQuery.event.trigger( "ajaxStart" ); |
7876 | } |
7877 | |
7878 | // More options handling for requests with no content |
7879 | if ( !s.hasContent ) { |
7880 | |
7881 | // If data is available, append data to url |
7882 | if ( s.data ) { |
7883 | s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; |
7884 | // #9682: remove data so that it's not used in an eventual retry |
7885 | delete s.data; |
7886 | } |
7887 | |
7888 | // Get ifModifiedKey before adding the anti-cache parameter |
7889 | ifModifiedKey = s.url; |
7890 | |
7891 | // Add anti-cache in url if needed |
7892 | if ( s.cache === false ) { |
7893 | |
7894 | var ts = jQuery.now(), |
7895 | // try replacing _= if it is there |
7896 | ret = s.url.replace( rts, "$1_=" + ts ); |
7897 | |
7898 | // if nothing was replaced, add timestamp to the end |
7899 | s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); |
7900 | } |
7901 | } |
7902 | |
7903 | // Set the correct header, if data is being sent |
7904 | if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { |
7905 | jqXHR.setRequestHeader( "Content-Type", s.contentType ); |
7906 | } |
7907 | |
7908 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
7909 | if ( s.ifModified ) { |
7910 | ifModifiedKey = ifModifiedKey || s.url; |
7911 | if ( jQuery.lastModified[ ifModifiedKey ] ) { |
7912 | jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] ); |
7913 | } |
7914 | if ( jQuery.etag[ ifModifiedKey ] ) { |
7915 | jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] ); |
7916 | } |
7917 | } |
7918 | |
7919 | // Set the Accepts header for the server, depending on the dataType |
7920 | jqXHR.setRequestHeader( |
7921 | "Accept", |
7922 | s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? |
7923 | s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : |
7924 | s.accepts[ "*" ] |
7925 | ); |
7926 | |
7927 | // Check for headers option |
7928 | for ( i in s.headers ) { |
7929 | jqXHR.setRequestHeader( i, s.headers[ i ] ); |
7930 | } |
7931 | |
7932 | // Allow custom headers/mimetypes and early abort |
7933 | if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { |
7934 | // Abort if not done already and return |
7935 | return jqXHR.abort(); |
7936 | |
7937 | } |
7938 | |
7939 | // aborting is no longer a cancellation |
7940 | strAbort = "abort"; |
7941 | |
7942 | // Install callbacks on deferreds |
7943 | for ( i in { success: 1, error: 1, complete: 1 } ) { |
7944 | jqXHR[ i ]( s[ i ] ); |
7945 | } |
7946 | |
7947 | // Get transport |
7948 | transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); |
7949 | |
7950 | // If no transport, we auto-abort |
7951 | if ( !transport ) { |
7952 | done( -1, "No Transport" ); |
7953 | } else { |
7954 | jqXHR.readyState = 1; |
7955 | // Send global event |
7956 | if ( fireGlobals ) { |
7957 | globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); |
7958 | } |
7959 | // Timeout |
7960 | if ( s.async && s.timeout > 0 ) { |
7961 | timeoutTimer = setTimeout( function(){ |
7962 | jqXHR.abort( "timeout" ); |
7963 | }, s.timeout ); |
7964 | } |
7965 | |
7966 | try { |
7967 | state = 1; |
7968 | transport.send( requestHeaders, done ); |
7969 | } catch (e) { |
7970 | // Propagate exception as error if not done |
7971 | if ( state < 2 ) { |
7972 | done( -1, e ); |
7973 | // Simply rethrow otherwise |
7974 | } else { |
7975 | throw e; |
7976 | } |
7977 | } |
7978 | } |
7979 | |
7980 | return jqXHR; |
7981 | }, |
7982 | |
7983 | // Counter for holding the number of active queries |
7984 | active: 0, |
7985 | |
7986 | // Last-Modified header cache for next request |
7987 | lastModified: {}, |
7988 | etag: {} |
7989 | |
7990 | }); |
7991 | |
7992 | /* Handles responses to an ajax request: |
7993 | * - sets all responseXXX fields accordingly |
7994 | * - finds the right dataType (mediates between content-type and expected dataType) |
7995 | * - returns the corresponding response |
7996 | */ |
7997 | function ajaxHandleResponses( s, jqXHR, responses ) { |
7998 | |
7999 | var ct, type, finalDataType, firstDataType, |
8000 | contents = s.contents, |
8001 | dataTypes = s.dataTypes, |
8002 | responseFields = s.responseFields; |
8003 | |
8004 | // Fill responseXXX fields |
8005 | for ( type in responseFields ) { |
8006 | if ( type in responses ) { |
8007 | jqXHR[ responseFields[type] ] = responses[ type ]; |
8008 | } |
8009 | } |
8010 | |
8011 | // Remove auto dataType and get content-type in the process |
8012 | while( dataTypes[ 0 ] === "*" ) { |
8013 | dataTypes.shift(); |
8014 | if ( ct === undefined ) { |
8015 | ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); |
8016 | } |
8017 | } |
8018 | |
8019 | // Check if we're dealing with a known content-type |
8020 | if ( ct ) { |
8021 | for ( type in contents ) { |
8022 | if ( contents[ type ] && contents[ type ].test( ct ) ) { |
8023 | dataTypes.unshift( type ); |
8024 | break; |
8025 | } |
8026 | } |
8027 | } |
8028 | |
8029 | // Check to see if we have a response for the expected dataType |
8030 | if ( dataTypes[ 0 ] in responses ) { |
8031 | finalDataType = dataTypes[ 0 ]; |
8032 | } else { |
8033 | // Try convertible dataTypes |
8034 | for ( type in responses ) { |
8035 | if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { |
8036 | finalDataType = type; |
8037 | break; |
8038 | } |
8039 | if ( !firstDataType ) { |
8040 | firstDataType = type; |
8041 | } |
8042 | } |
8043 | // Or just use first one |
8044 | finalDataType = finalDataType || firstDataType; |
8045 | } |
8046 | |
8047 | // If we found a dataType |
8048 | // We add the dataType to the list if needed |
8049 | // and return the corresponding response |
8050 | if ( finalDataType ) { |
8051 | if ( finalDataType !== dataTypes[ 0 ] ) { |
8052 | dataTypes.unshift( finalDataType ); |
8053 | } |
8054 | return responses[ finalDataType ]; |
8055 | } |
8056 | } |
8057 | |
8058 | // Chain conversions given the request and the original response |
8059 | function ajaxConvert( s, response ) { |
8060 | |
8061 | var conv, conv2, current, tmp, |
8062 | // Work with a copy of dataTypes in case we need to modify it for conversion |
8063 | dataTypes = s.dataTypes.slice(), |
8064 | prev = dataTypes[ 0 ], |
8065 | converters = {}, |
8066 | i = 0; |
8067 | |
8068 | // Apply the dataFilter if provided |
8069 | if ( s.dataFilter ) { |
8070 | response = s.dataFilter( response, s.dataType ); |
8071 | } |
8072 | |
8073 | // Create converters map with lowercased keys |
8074 | if ( dataTypes[ 1 ] ) { |
8075 | for ( conv in s.converters ) { |
8076 | converters[ conv.toLowerCase() ] = s.converters[ conv ]; |
8077 | } |
8078 | } |
8079 | |
8080 | // Convert to each sequential dataType, tolerating list modification |
8081 | for ( ; (current = dataTypes[++i]); ) { |
8082 | |
8083 | // There's only work to do if current dataType is non-auto |
8084 | if ( current !== "*" ) { |
8085 | |
8086 | // Convert response if prev dataType is non-auto and differs from current |
8087 | if ( prev !== "*" && prev !== current ) { |
8088 | |
8089 | // Seek a direct converter |
8090 | conv = converters[ prev + " " + current ] || converters[ "* " + current ]; |
8091 | |
8092 | // If none found, seek a pair |
8093 | if ( !conv ) { |
8094 | for ( conv2 in converters ) { |
8095 | |
8096 | // If conv2 outputs current |
8097 | tmp = conv2.split(" "); |
8098 | if ( tmp[ 1 ] === current ) { |
8099 | |
8100 | // If prev can be converted to accepted input |
8101 | conv = converters[ prev + " " + tmp[ 0 ] ] || |
8102 | converters[ "* " + tmp[ 0 ] ]; |
8103 | if ( conv ) { |
8104 | // Condense equivalence converters |
8105 | if ( conv === true ) { |
8106 | conv = converters[ conv2 ]; |
8107 | |
8108 | // Otherwise, insert the intermediate dataType |
8109 | } else if ( converters[ conv2 ] !== true ) { |
8110 | current = tmp[ 0 ]; |
8111 | dataTypes.splice( i--, 0, current ); |
8112 | } |
8113 | |
8114 | break; |
8115 | } |
8116 | } |
8117 | } |
8118 | } |
8119 | |
8120 | // Apply converter (if not an equivalence) |
8121 | if ( conv !== true ) { |
8122 | |
8123 | // Unless errors are allowed to bubble, catch and return them |
8124 | if ( conv && s["throws"] ) { |
8125 | response = conv( response ); |
8126 | } else { |
8127 | try { |
8128 | response = conv( response ); |
8129 | } catch ( e ) { |
8130 | return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current }; |
8131 | } |
8132 | } |
8133 | } |
8134 | } |
8135 | |
8136 | // Update prev for next iteration |
8137 | prev = current; |
8138 | } |
8139 | } |
8140 | |
8141 | return { state: "success", data: response }; |
8142 | } |
8143 | var oldCallbacks = [], |
8144 | rquestion = /\?/, |
8145 | rjsonp = /(=)\?(?=&|$)|\?\?/, |
8146 | nonce = jQuery.now(); |
8147 | |
8148 | // Default jsonp settings |
8149 | jQuery.ajaxSetup({ |
8150 | jsonp: "callback", |
8151 | jsonpCallback: function() { |
8152 | var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); |
8153 | this[ callback ] = true; |
8154 | return callback; |
8155 | } |
8156 | }); |
8157 | |
8158 | // Detect, normalize options and install callbacks for jsonp requests |
8159 | jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { |
8160 | |
8161 | var callbackName, overwritten, responseContainer, |
8162 | data = s.data, |
8163 | url = s.url, |
8164 | hasCallback = s.jsonp !== false, |
8165 | replaceInUrl = hasCallback && rjsonp.test( url ), |
8166 | replaceInData = hasCallback && !replaceInUrl && typeof data === "string" && |
8167 | !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && |
8168 | rjsonp.test( data ); |
8169 | |
8170 | // Handle iff the expected data type is "jsonp" or we have a parameter to set |
8171 | if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) { |
8172 | |
8173 | // Get callback name, remembering preexisting value associated with it |
8174 | callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? |
8175 | s.jsonpCallback() : |
8176 | s.jsonpCallback; |
8177 | overwritten = window[ callbackName ]; |
8178 | |
8179 | // Insert callback into url or form data |
8180 | if ( replaceInUrl ) { |
8181 | s.url = url.replace( rjsonp, "$1" + callbackName ); |
8182 | } else if ( replaceInData ) { |
8183 | s.data = data.replace( rjsonp, "$1" + callbackName ); |
8184 | } else if ( hasCallback ) { |
8185 | s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; |
8186 | } |
8187 | |
8188 | // Use data converter to retrieve json after script execution |
8189 | s.converters["script json"] = function() { |
8190 | if ( !responseContainer ) { |
8191 | jQuery.error( callbackName + " was not called" ); |
8192 | } |
8193 | return responseContainer[ 0 ]; |
8194 | }; |
8195 | |
8196 | // force json dataType |
8197 | s.dataTypes[ 0 ] = "json"; |
8198 | |
8199 | // Install callback |
8200 | window[ callbackName ] = function() { |
8201 | responseContainer = arguments; |
8202 | }; |
8203 | |
8204 | // Clean-up function (fires after converters) |
8205 | jqXHR.always(function() { |
8206 | // Restore preexisting value |
8207 | window[ callbackName ] = overwritten; |
8208 | |
8209 | // Save back as free |
8210 | if ( s[ callbackName ] ) { |
8211 | // make sure that re-using the options doesn't screw things around |
8212 | s.jsonpCallback = originalSettings.jsonpCallback; |
8213 | |
8214 | // save the callback name for future use |
8215 | oldCallbacks.push( callbackName ); |
8216 | } |
8217 | |
8218 | // Call if it was a function and we have a response |
8219 | if ( responseContainer && jQuery.isFunction( overwritten ) ) { |
8220 | overwritten( responseContainer[ 0 ] ); |
8221 | } |
8222 | |
8223 | responseContainer = overwritten = undefined; |
8224 | }); |
8225 | |
8226 | // Delegate to script |
8227 | return "script"; |
8228 | } |
8229 | }); |
8230 | // Install script dataType |
8231 | jQuery.ajaxSetup({ |
8232 | accepts: { |
8233 | script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" |
8234 | }, |
8235 | contents: { |
8236 | script: /javascript|ecmascript/ |
8237 | }, |
8238 | converters: { |
8239 | "text script": function( text ) { |
8240 | jQuery.globalEval( text ); |
8241 | return text; |
8242 | } |
8243 | } |
8244 | }); |
8245 | |
8246 | // Handle cache's special case and global |
8247 | jQuery.ajaxPrefilter( "script", function( s ) { |
8248 | if ( s.cache === undefined ) { |
8249 | s.cache = false; |
8250 | } |
8251 | if ( s.crossDomain ) { |
8252 | s.type = "GET"; |
8253 | s.global = false; |
8254 | } |
8255 | }); |
8256 | |
8257 | // Bind script tag hack transport |
8258 | jQuery.ajaxTransport( "script", function(s) { |
8259 | |
8260 | // This transport only deals with cross domain requests |
8261 | if ( s.crossDomain ) { |
8262 | |
8263 | var script, |
8264 | head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; |
8265 | |
8266 | return { |
8267 | |
8268 | send: function( _, callback ) { |
8269 | |
8270 | script = document.createElement( "script" ); |
8271 | |
8272 | script.async = "async"; |
8273 | |
8274 | if ( s.scriptCharset ) { |
8275 | script.charset = s.scriptCharset; |
8276 | } |
8277 | |
8278 | script.src = s.url; |
8279 | |
8280 | // Attach handlers for all browsers |
8281 | script.onload = script.onreadystatechange = function( _, isAbort ) { |
8282 | |
8283 | if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { |
8284 | |
8285 | // Handle memory leak in IE |
8286 | script.onload = script.onreadystatechange = null; |
8287 | |
8288 | // Remove the script |
8289 | if ( head && script.parentNode ) { |
8290 | head.removeChild( script ); |
8291 | } |
8292 | |
8293 | // Dereference the script |
8294 | script = undefined; |
8295 | |
8296 | // Callback if not abort |
8297 | if ( !isAbort ) { |
8298 | callback( 200, "success" ); |
8299 | } |
8300 | } |
8301 | }; |
8302 | // Use insertBefore instead of appendChild to circumvent an IE6 bug. |
8303 | // This arises when a base node is used (#2709 and #4378). |
8304 | head.insertBefore( script, head.firstChild ); |
8305 | }, |
8306 | |
8307 | abort: function() { |
8308 | if ( script ) { |
8309 | script.onload( 0, 1 ); |
8310 | } |
8311 | } |
8312 | }; |
8313 | } |
8314 | }); |
8315 | var xhrCallbacks, |
8316 | // #5280: Internet Explorer will keep connections alive if we don't abort on unload |
8317 | xhrOnUnloadAbort = window.ActiveXObject ? function() { |
8318 | // Abort all pending requests |
8319 | for ( var key in xhrCallbacks ) { |
8320 | xhrCallbacks[ key ]( 0, 1 ); |
8321 | } |
8322 | } : false, |
8323 | xhrId = 0; |
8324 | |
8325 | // Functions to create xhrs |
8326 | function createStandardXHR() { |
8327 | try { |
8328 | return new window.XMLHttpRequest(); |
8329 | } catch( e ) {} |
8330 | } |
8331 | |
8332 | function createActiveXHR() { |
8333 | try { |
8334 | return new window.ActiveXObject( "Microsoft.XMLHTTP" ); |
8335 | } catch( e ) {} |
8336 | } |
8337 | |
8338 | // Create the request object |
8339 | // (This is still attached to ajaxSettings for backward compatibility) |
8340 | jQuery.ajaxSettings.xhr = window.ActiveXObject ? |
8341 | /* Microsoft failed to properly |
8342 | * implement the XMLHttpRequest in IE7 (can't request local files), |
8343 | * so we use the ActiveXObject when it is available |
8344 | * Additionally XMLHttpRequest can be disabled in IE7/IE8 so |
8345 | * we need a fallback. |
8346 | */ |
8347 | function() { |
8348 | return !this.isLocal && createStandardXHR() || createActiveXHR(); |
8349 | } : |
8350 | // For all other browsers, use the standard XMLHttpRequest object |
8351 | createStandardXHR; |
8352 | |
8353 | // Determine support properties |
8354 | (function( xhr ) { |
8355 | jQuery.extend( jQuery.support, { |
8356 | ajax: !!xhr, |
8357 | cors: !!xhr && ( "withCredentials" in xhr ) |
8358 | }); |
8359 | })( jQuery.ajaxSettings.xhr() ); |
8360 | |
8361 | // Create transport if the browser can provide an xhr |
8362 | if ( jQuery.support.ajax ) { |
8363 | |
8364 | jQuery.ajaxTransport(function( s ) { |
8365 | // Cross domain only allowed if supported through XMLHttpRequest |
8366 | if ( !s.crossDomain || jQuery.support.cors ) { |
8367 | |
8368 | var callback; |
8369 | |
8370 | return { |
8371 | send: function( headers, complete ) { |
8372 | |
8373 | // Get a new xhr |
8374 | var handle, i, |
8375 | xhr = s.xhr(); |
8376 | |
8377 | // Open the socket |
8378 | // Passing null username, generates a login popup on Opera (#2865) |
8379 | if ( s.username ) { |
8380 | xhr.open( s.type, s.url, s.async, s.username, s.password ); |
8381 | } else { |
8382 | xhr.open( s.type, s.url, s.async ); |
8383 | } |
8384 | |
8385 | // Apply custom fields if provided |
8386 | if ( s.xhrFields ) { |
8387 | for ( i in s.xhrFields ) { |
8388 | xhr[ i ] = s.xhrFields[ i ]; |
8389 | } |
8390 | } |
8391 | |
8392 | // Override mime type if needed |
8393 | if ( s.mimeType && xhr.overrideMimeType ) { |
8394 | xhr.overrideMimeType( s.mimeType ); |
8395 | } |
8396 | |
8397 | // X-Requested-With header |
8398 | // For cross-domain requests, seeing as conditions for a preflight are |
8399 | // akin to a jigsaw puzzle, we simply never set it to be sure. |
8400 | // (it can always be set on a per-request basis or even using ajaxSetup) |
8401 | // For same-domain requests, won't change header if already provided. |
8402 | if ( !s.crossDomain && !headers["X-Requested-With"] ) { |
8403 | headers[ "X-Requested-With" ] = "XMLHttpRequest"; |
8404 | } |
8405 | |
8406 | // Need an extra try/catch for cross domain requests in Firefox 3 |
8407 | try { |
8408 | for ( i in headers ) { |
8409 | xhr.setRequestHeader( i, headers[ i ] ); |
8410 | } |
8411 | } catch( _ ) {} |
8412 | |
8413 | // Do send the request |
8414 | // This may raise an exception which is actually |
8415 | // handled in jQuery.ajax (so no try/catch here) |
8416 | xhr.send( ( s.hasContent && s.data ) || null ); |
8417 | |
8418 | // Listener |
8419 | callback = function( _, isAbort ) { |
8420 | |
8421 | var status, |
8422 | statusText, |
8423 | responseHeaders, |
8424 | responses, |
8425 | xml; |
8426 | |
8427 | // Firefox throws exceptions when accessing properties |
8428 | // of an xhr when a network error occurred |
8429 | // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) |
8430 | try { |
8431 | |
8432 | // Was never called and is aborted or complete |
8433 | if ( callback && ( isAbort || xhr.readyState === 4 ) ) { |
8434 | |
8435 | // Only called once |
8436 | callback = undefined; |
8437 | |
8438 | // Do not keep as active anymore |
8439 | if ( handle ) { |
8440 | xhr.onreadystatechange = jQuery.noop; |
8441 | if ( xhrOnUnloadAbort ) { |
8442 | delete xhrCallbacks[ handle ]; |
8443 | } |
8444 | } |
8445 | |
8446 | // If it's an abort |
8447 | if ( isAbort ) { |
8448 | // Abort it manually if needed |
8449 | if ( xhr.readyState !== 4 ) { |
8450 | xhr.abort(); |
8451 | } |
8452 | } else { |
8453 | status = xhr.status; |
8454 | responseHeaders = xhr.getAllResponseHeaders(); |
8455 | responses = {}; |
8456 | xml = xhr.responseXML; |
8457 | |
8458 | // Construct response list |
8459 | if ( xml && xml.documentElement /* #4958 */ ) { |
8460 | responses.xml = xml; |
8461 | } |
8462 | |
8463 | // When requesting binary data, IE6-9 will throw an exception |
8464 | // on any attempt to access responseText (#11426) |
8465 | try { |
8466 | responses.text = xhr.responseText; |
8467 | } catch( _ ) { |
8468 | } |
8469 | |
8470 | // Firefox throws an exception when accessing |
8471 | // statusText for faulty cross-domain requests |
8472 | try { |
8473 | statusText = xhr.statusText; |
8474 | } catch( e ) { |
8475 | // We normalize with Webkit giving an empty statusText |
8476 | statusText = ""; |
8477 | } |
8478 | |
8479 | // Filter status for non standard behaviors |
8480 | |
8481 | // If the request is local and we have data: assume a success |
8482 | // (success with no data won't get notified, that's the best we |
8483 | // can do given current implementations) |
8484 | if ( !status && s.isLocal && !s.crossDomain ) { |
8485 | status = responses.text ? 200 : 404; |
8486 | // IE - #1450: sometimes returns 1223 when it should be 204 |
8487 | } else if ( status === 1223 ) { |
8488 | status = 204; |
8489 | } |
8490 | } |
8491 | } |
8492 | } catch( firefoxAccessException ) { |
8493 | if ( !isAbort ) { |
8494 | complete( -1, firefoxAccessException ); |
8495 | } |
8496 | } |
8497 | |
8498 | // Call complete if needed |
8499 | if ( responses ) { |
8500 | complete( status, statusText, responses, responseHeaders ); |
8501 | } |
8502 | }; |
8503 | |
8504 | if ( !s.async ) { |
8505 | // if we're in sync mode we fire the callback |
8506 | callback(); |
8507 | } else if ( xhr.readyState === 4 ) { |
8508 | // (IE6 & IE7) if it's in cache and has been |
8509 | // retrieved directly we need to fire the callback |
8510 | setTimeout( callback, 0 ); |
8511 | } else { |
8512 | handle = ++xhrId; |
8513 | if ( xhrOnUnloadAbort ) { |
8514 | // Create the active xhrs callbacks list if needed |
8515 | // and attach the unload handler |
8516 | if ( !xhrCallbacks ) { |
8517 | xhrCallbacks = {}; |
8518 | jQuery( window ).unload( xhrOnUnloadAbort ); |
8519 | } |
8520 | // Add to list of active xhrs callbacks |
8521 | xhrCallbacks[ handle ] = callback; |
8522 | } |
8523 | xhr.onreadystatechange = callback; |
8524 | } |
8525 | }, |
8526 | |
8527 | abort: function() { |
8528 | if ( callback ) { |
8529 | callback(0,1); |
8530 | } |
8531 | } |
8532 | }; |
8533 | } |
8534 | }); |
8535 | } |
8536 | var fxNow, timerId, |
8537 | rfxtypes = /^(?:toggle|show|hide)$/, |
8538 | rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ), |
8539 | rrun = /queueHooks$/, |
8540 | animationPrefilters = [ defaultPrefilter ], |
8541 | tweeners = { |
8542 | "*": [function( prop, value ) { |
8543 | var end, unit, |
8544 | tween = this.createTween( prop, value ), |
8545 | parts = rfxnum.exec( value ), |
8546 | target = tween.cur(), |
8547 | start = +target || 0, |
8548 | scale = 1, |
8549 | maxIterations = 20; |
8550 | |
8551 | if ( parts ) { |
8552 | end = +parts[2]; |
8553 | unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" ); |
8554 | |
8555 | // We need to compute starting value |
8556 | if ( unit !== "px" && start ) { |
8557 | // Iteratively approximate from a nonzero starting point |
8558 | // Prefer the current property, because this process will be trivial if it uses the same units |
8559 | // Fallback to end or a simple constant |
8560 | start = jQuery.css( tween.elem, prop, true ) || end || 1; |
8561 | |
8562 | do { |
8563 | // If previous iteration zeroed out, double until we get *something* |
8564 | // Use a string for doubling factor so we don't accidentally see scale as unchanged below |
8565 | scale = scale || ".5"; |
8566 | |
8567 | // Adjust and apply |
8568 | start = start / scale; |
8569 | jQuery.style( tween.elem, prop, start + unit ); |
8570 | |
8571 | // Update scale, tolerating zero or NaN from tween.cur() |
8572 | // And breaking the loop if scale is unchanged or perfect, or if we've just had enough |
8573 | } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations ); |
8574 | } |
8575 | |
8576 | tween.unit = unit; |
8577 | tween.start = start; |
8578 | // If a +=/-= token was provided, we're doing a relative animation |
8579 | tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end; |
8580 | } |
8581 | return tween; |
8582 | }] |
8583 | }; |
8584 | |
8585 | // Animations created synchronously will run synchronously |
8586 | function createFxNow() { |
8587 | setTimeout(function() { |
8588 | fxNow = undefined; |
8589 | }, 0 ); |
8590 | return ( fxNow = jQuery.now() ); |
8591 | } |
8592 | |
8593 | function createTweens( animation, props ) { |
8594 | jQuery.each( props, function( prop, value ) { |
8595 | var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), |
8596 | index = 0, |
8597 | length = collection.length; |
8598 | for ( ; index < length; index++ ) { |
8599 | if ( collection[ index ].call( animation, prop, value ) ) { |
8600 | |
8601 | // we're done with this property |
8602 | return; |
8603 | } |
8604 | } |
8605 | }); |
8606 | } |
8607 | |
8608 | function Animation( elem, properties, options ) { |
8609 | var result, |
8610 | index = 0, |
8611 | tweenerIndex = 0, |
8612 | length = animationPrefilters.length, |
8613 | deferred = jQuery.Deferred().always( function() { |
8614 | // don't match elem in the :animated selector |
8615 | delete tick.elem; |
8616 | }), |
8617 | tick = function() { |
8618 | var currentTime = fxNow || createFxNow(), |
8619 | remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), |
8620 | percent = 1 - ( remaining / animation.duration || 0 ), |
8621 | index = 0, |
8622 | length = animation.tweens.length; |
8623 | |
8624 | for ( ; index < length ; index++ ) { |
8625 | animation.tweens[ index ].run( percent ); |
8626 | } |
8627 | |
8628 | deferred.notifyWith( elem, [ animation, percent, remaining ]); |
8629 | |
8630 | if ( percent < 1 && length ) { |
8631 | return remaining; |
8632 | } else { |
8633 | deferred.resolveWith( elem, [ animation ] ); |
8634 | return false; |
8635 | } |
8636 | }, |
8637 | animation = deferred.promise({ |
8638 | elem: elem, |
8639 | props: jQuery.extend( {}, properties ), |
8640 | opts: jQuery.extend( true, { specialEasing: {} }, options ), |
8641 | originalProperties: properties, |
8642 | originalOptions: options, |
8643 | startTime: fxNow || createFxNow(), |
8644 | duration: options.duration, |
8645 | tweens: [], |
8646 | createTween: function( prop, end, easing ) { |
8647 | var tween = jQuery.Tween( elem, animation.opts, prop, end, |
8648 | animation.opts.specialEasing[ prop ] || animation.opts.easing ); |
8649 | animation.tweens.push( tween ); |
8650 | return tween; |
8651 | }, |
8652 | stop: function( gotoEnd ) { |
8653 | var index = 0, |
8654 | // if we are going to the end, we want to run all the tweens |
8655 | // otherwise we skip this part |
8656 | length = gotoEnd ? animation.tweens.length : 0; |
8657 | |
8658 | for ( ; index < length ; index++ ) { |
8659 | animation.tweens[ index ].run( 1 ); |
8660 | } |
8661 | |
8662 | // resolve when we played the last frame |
8663 | // otherwise, reject |
8664 | if ( gotoEnd ) { |
8665 | deferred.resolveWith( elem, [ animation, gotoEnd ] ); |
8666 | } else { |
8667 | deferred.rejectWith( elem, [ animation, gotoEnd ] ); |
8668 | } |
8669 | return this; |
8670 | } |
8671 | }), |
8672 | props = animation.props; |
8673 | |
8674 | propFilter( props, animation.opts.specialEasing ); |
8675 | |
8676 | for ( ; index < length ; index++ ) { |
8677 | result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); |
8678 | if ( result ) { |
8679 | return result; |
8680 | } |
8681 | } |
8682 | |
8683 | createTweens( animation, props ); |
8684 | |
8685 | if ( jQuery.isFunction( animation.opts.start ) ) { |
8686 | animation.opts.start.call( elem, animation ); |
8687 | } |
8688 | |
8689 | jQuery.fx.timer( |
8690 | jQuery.extend( tick, { |
8691 | anim: animation, |
8692 | queue: animation.opts.queue, |
8693 | elem: elem |
8694 | }) |
8695 | ); |
8696 | |
8697 | // attach callbacks from options |
8698 | return animation.progress( animation.opts.progress ) |
8699 | .done( animation.opts.done, animation.opts.complete ) |
8700 | .fail( animation.opts.fail ) |
8701 | .always( animation.opts.always ); |
8702 | } |
8703 | |
8704 | function propFilter( props, specialEasing ) { |
8705 | var index, name, easing, value, hooks; |
8706 | |
8707 | // camelCase, specialEasing and expand cssHook pass |
8708 | for ( index in props ) { |
8709 | name = jQuery.camelCase( index ); |
8710 | easing = specialEasing[ name ]; |
8711 | value = props[ index ]; |
8712 | if ( jQuery.isArray( value ) ) { |
8713 | easing = value[ 1 ]; |
8714 | value = props[ index ] = value[ 0 ]; |
8715 | } |
8716 | |
8717 | if ( index !== name ) { |
8718 | props[ name ] = value; |
8719 | delete props[ index ]; |
8720 | } |
8721 | |
8722 | hooks = jQuery.cssHooks[ name ]; |
8723 | if ( hooks && "expand" in hooks ) { |
8724 | value = hooks.expand( value ); |
8725 | delete props[ name ]; |
8726 | |
8727 | // not quite $.extend, this wont overwrite keys already present. |
8728 | // also - reusing 'index' from above because we have the correct "name" |
8729 | for ( index in value ) { |
8730 | if ( !( index in props ) ) { |
8731 | props[ index ] = value[ index ]; |
8732 | specialEasing[ index ] = easing; |
8733 | } |
8734 | } |
8735 | } else { |
8736 | specialEasing[ name ] = easing; |
8737 | } |
8738 | } |
8739 | } |
8740 | |
8741 | jQuery.Animation = jQuery.extend( Animation, { |
8742 | |
8743 | tweener: function( props, callback ) { |
8744 | if ( jQuery.isFunction( props ) ) { |
8745 | callback = props; |
8746 | props = [ "*" ]; |
8747 | } else { |
8748 | props = props.split(" "); |
8749 | } |
8750 | |
8751 | var prop, |
8752 | index = 0, |
8753 | length = props.length; |
8754 | |
8755 | for ( ; index < length ; index++ ) { |
8756 | prop = props[ index ]; |
8757 | tweeners[ prop ] = tweeners[ prop ] || []; |
8758 | tweeners[ prop ].unshift( callback ); |
8759 | } |
8760 | }, |
8761 | |
8762 | prefilter: function( callback, prepend ) { |
8763 | if ( prepend ) { |
8764 | animationPrefilters.unshift( callback ); |
8765 | } else { |
8766 | animationPrefilters.push( callback ); |
8767 | } |
8768 | } |
8769 | }); |
8770 | |
8771 | function defaultPrefilter( elem, props, opts ) { |
8772 | var index, prop, value, length, dataShow, tween, hooks, oldfire, |
8773 | anim = this, |
8774 | style = elem.style, |
8775 | orig = {}, |
8776 | handled = [], |
8777 | hidden = elem.nodeType && isHidden( elem ); |
8778 | |
8779 | // handle queue: false promises |
8780 | if ( !opts.queue ) { |
8781 | hooks = jQuery._queueHooks( elem, "fx" ); |
8782 | if ( hooks.unqueued == null ) { |
8783 | hooks.unqueued = 0; |
8784 | oldfire = hooks.empty.fire; |
8785 | hooks.empty.fire = function() { |
8786 | if ( !hooks.unqueued ) { |
8787 | oldfire(); |
8788 | } |
8789 | }; |
8790 | } |
8791 | hooks.unqueued++; |
8792 | |
8793 | anim.always(function() { |
8794 | // doing this makes sure that the complete handler will be called |
8795 | // before this completes |
8796 | anim.always(function() { |
8797 | hooks.unqueued--; |
8798 | if ( !jQuery.queue( elem, "fx" ).length ) { |
8799 | hooks.empty.fire(); |
8800 | } |
8801 | }); |
8802 | }); |
8803 | } |
8804 | |
8805 | // height/width overflow pass |
8806 | if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { |
8807 | // Make sure that nothing sneaks out |
8808 | // Record all 3 overflow attributes because IE does not |
8809 | // change the overflow attribute when overflowX and |
8810 | // overflowY are set to the same value |
8811 | opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; |
8812 | |
8813 | // Set display property to inline-block for height/width |
8814 | // animations on inline elements that are having width/height animated |
8815 | if ( jQuery.css( elem, "display" ) === "inline" && |
8816 | jQuery.css( elem, "float" ) === "none" ) { |
8817 | |
8818 | // inline-level elements accept inline-block; |
8819 | // block-level elements need to be inline with layout |
8820 | if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) { |
8821 | style.display = "inline-block"; |
8822 | |
8823 | } else { |
8824 | style.zoom = 1; |
8825 | } |
8826 | } |
8827 | } |
8828 | |
8829 | if ( opts.overflow ) { |
8830 | style.overflow = "hidden"; |
8831 | if ( !jQuery.support.shrinkWrapBlocks ) { |
8832 | anim.done(function() { |
8833 | style.overflow = opts.overflow[ 0 ]; |
8834 | style.overflowX = opts.overflow[ 1 ]; |
8835 | style.overflowY = opts.overflow[ 2 ]; |
8836 | }); |
8837 | } |
8838 | } |
8839 | |
8840 | |
8841 | // show/hide pass |
8842 | for ( index in props ) { |
8843 | value = props[ index ]; |
8844 | if ( rfxtypes.exec( value ) ) { |
8845 | delete props[ index ]; |
8846 | if ( value === ( hidden ? "hide" : "show" ) ) { |
8847 | continue; |
8848 | } |
8849 | handled.push( index ); |
8850 | } |
8851 | } |
8852 | |
8853 | length = handled.length; |
8854 | if ( length ) { |
8855 | dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} ); |
8856 | if ( hidden ) { |
8857 | jQuery( elem ).show(); |
8858 | } else { |
8859 | anim.done(function() { |
8860 | jQuery( elem ).hide(); |
8861 | }); |
8862 | } |
8863 | anim.done(function() { |
8864 | var prop; |
8865 | jQuery.removeData( elem, "fxshow", true ); |
8866 | for ( prop in orig ) { |
8867 | jQuery.style( elem, prop, orig[ prop ] ); |
8868 | } |
8869 | }); |
8870 | for ( index = 0 ; index < length ; index++ ) { |
8871 | prop = handled[ index ]; |
8872 | tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 ); |
8873 | orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop ); |
8874 | |
8875 | if ( !( prop in dataShow ) ) { |
8876 | dataShow[ prop ] = tween.start; |
8877 | if ( hidden ) { |
8878 | tween.end = tween.start; |
8879 | tween.start = prop === "width" || prop === "height" ? 1 : 0; |
8880 | } |
8881 | } |
8882 | } |
8883 | } |
8884 | } |
8885 | |
8886 | function Tween( elem, options, prop, end, easing ) { |
8887 | return new Tween.prototype.init( elem, options, prop, end, easing ); |
8888 | } |
8889 | jQuery.Tween = Tween; |
8890 | |
8891 | Tween.prototype = { |
8892 | constructor: Tween, |
8893 | init: function( elem, options, prop, end, easing, unit ) { |
8894 | this.elem = elem; |
8895 | this.prop = prop; |
8896 | this.easing = easing || "swing"; |
8897 | this.options = options; |
8898 | this.start = this.now = this.cur(); |
8899 | this.end = end; |
8900 | this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); |
8901 | }, |
8902 | cur: function() { |
8903 | var hooks = Tween.propHooks[ this.prop ]; |
8904 | |
8905 | return hooks && hooks.get ? |
8906 | hooks.get( this ) : |
8907 | Tween.propHooks._default.get( this ); |
8908 | }, |
8909 | run: function( percent ) { |
8910 | var eased, |
8911 | hooks = Tween.propHooks[ this.prop ]; |
8912 | |
8913 | if ( this.options.duration ) { |
8914 | this.pos = eased = jQuery.easing[ this.easing ]( |
8915 | percent, this.options.duration * percent, 0, 1, this.options.duration |
8916 | ); |
8917 | } else { |
8918 | this.pos = eased = percent; |
8919 | } |
8920 | this.now = ( this.end - this.start ) * eased + this.start; |
8921 | |
8922 | if ( this.options.step ) { |
8923 | this.options.step.call( this.elem, this.now, this ); |
8924 | } |
8925 | |
8926 | if ( hooks && hooks.set ) { |
8927 | hooks.set( this ); |
8928 | } else { |
8929 | Tween.propHooks._default.set( this ); |
8930 | } |
8931 | return this; |
8932 | } |
8933 | }; |
8934 | |
8935 | Tween.prototype.init.prototype = Tween.prototype; |
8936 | |
8937 | Tween.propHooks = { |
8938 | _default: { |
8939 | get: function( tween ) { |
8940 | var result; |
8941 | |
8942 | if ( tween.elem[ tween.prop ] != null && |
8943 | (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { |
8944 | return tween.elem[ tween.prop ]; |
8945 | } |
8946 | |
8947 | // passing any value as a 4th parameter to .css will automatically |
8948 | // attempt a parseFloat and fallback to a string if the parse fails |
8949 | // so, simple values such as "10px" are parsed to Float. |
8950 | // complex values such as "rotate(1rad)" are returned as is. |
8951 | result = jQuery.css( tween.elem, tween.prop, false, "" ); |
8952 | // Empty strings, null, undefined and "auto" are converted to 0. |
8953 | return !result || result === "auto" ? 0 : result; |
8954 | }, |
8955 | set: function( tween ) { |
8956 | // use step hook for back compat - use cssHook if its there - use .style if its |
8957 | // available and use plain properties where available |
8958 | if ( jQuery.fx.step[ tween.prop ] ) { |
8959 | jQuery.fx.step[ tween.prop ]( tween ); |
8960 | } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { |
8961 | jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); |
8962 | } else { |
8963 | tween.elem[ tween.prop ] = tween.now; |
8964 | } |
8965 | } |
8966 | } |
8967 | }; |
8968 | |
8969 | // Remove in 2.0 - this supports IE8's panic based approach |
8970 | // to setting things on disconnected nodes |
8971 | |
8972 | Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { |
8973 | set: function( tween ) { |
8974 | if ( tween.elem.nodeType && tween.elem.parentNode ) { |
8975 | tween.elem[ tween.prop ] = tween.now; |
8976 | } |
8977 | } |
8978 | }; |
8979 | |
8980 | jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { |
8981 | var cssFn = jQuery.fn[ name ]; |
8982 | jQuery.fn[ name ] = function( speed, easing, callback ) { |
8983 | return speed == null || typeof speed === "boolean" || |
8984 | // special check for .toggle( handler, handler, ... ) |
8985 | ( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ? |
8986 | cssFn.apply( this, arguments ) : |
8987 | this.animate( genFx( name, true ), speed, easing, callback ); |
8988 | }; |
8989 | }); |
8990 | |
8991 | jQuery.fn.extend({ |
8992 | fadeTo: function( speed, to, easing, callback ) { |
8993 | |
8994 | // show any hidden elements after setting opacity to 0 |
8995 | return this.filter( isHidden ).css( "opacity", 0 ).show() |
8996 | |
8997 | // animate to the value specified |
8998 | .end().animate({ opacity: to }, speed, easing, callback ); |
8999 | }, |
9000 | animate: function( prop, speed, easing, callback ) { |
9001 | var empty = jQuery.isEmptyObject( prop ), |
9002 | optall = jQuery.speed( speed, easing, callback ), |
9003 | doAnimation = function() { |
9004 | // Operate on a copy of prop so per-property easing won't be lost |
9005 | var anim = Animation( this, jQuery.extend( {}, prop ), optall ); |
9006 | |
9007 | // Empty animations resolve immediately |
9008 | if ( empty ) { |
9009 | anim.stop( true ); |
9010 | } |
9011 | }; |
9012 | |
9013 | return empty || optall.queue === false ? |
9014 | this.each( doAnimation ) : |
9015 | this.queue( optall.queue, doAnimation ); |
9016 | }, |
9017 | stop: function( type, clearQueue, gotoEnd ) { |
9018 | var stopQueue = function( hooks ) { |
9019 | var stop = hooks.stop; |
9020 | delete hooks.stop; |
9021 | stop( gotoEnd ); |
9022 | }; |
9023 | |
9024 | if ( typeof type !== "string" ) { |
9025 | gotoEnd = clearQueue; |
9026 | clearQueue = type; |
9027 | type = undefined; |
9028 | } |
9029 | if ( clearQueue && type !== false ) { |
9030 | this.queue( type || "fx", [] ); |
9031 | } |
9032 | |
9033 | return this.each(function() { |
9034 | var dequeue = true, |
9035 | index = type != null && type + "queueHooks", |
9036 | timers = jQuery.timers, |
9037 | data = jQuery._data( this ); |
9038 | |
9039 | if ( index ) { |
9040 | if ( data[ index ] && data[ index ].stop ) { |
9041 | stopQueue( data[ index ] ); |
9042 | } |
9043 | } else { |
9044 | for ( index in data ) { |
9045 | if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { |
9046 | stopQueue( data[ index ] ); |
9047 | } |
9048 | } |
9049 | } |
9050 | |
9051 | for ( index = timers.length; index--; ) { |
9052 | if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { |
9053 | timers[ index ].anim.stop( gotoEnd ); |
9054 | dequeue = false; |
9055 | timers.splice( index, 1 ); |
9056 | } |
9057 | } |
9058 | |
9059 | // start the next in the queue if the last step wasn't forced |
9060 | // timers currently will call their complete callbacks, which will dequeue |
9061 | // but only if they were gotoEnd |
9062 | if ( dequeue || !gotoEnd ) { |
9063 | jQuery.dequeue( this, type ); |
9064 | } |
9065 | }); |
9066 | } |
9067 | }); |
9068 | |
9069 | // Generate parameters to create a standard animation |
9070 | function genFx( type, includeWidth ) { |
9071 | var which, |
9072 | attrs = { height: type }, |
9073 | i = 0; |
9074 | |
9075 | // if we include width, step value is 1 to do all cssExpand values, |
9076 | // if we don't include width, step value is 2 to skip over Left and Right |
9077 | includeWidth = includeWidth? 1 : 0; |
9078 | for( ; i < 4 ; i += 2 - includeWidth ) { |
9079 | which = cssExpand[ i ]; |
9080 | attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; |
9081 | } |
9082 | |
9083 | if ( includeWidth ) { |
9084 | attrs.opacity = attrs.width = type; |
9085 | } |
9086 | |
9087 | return attrs; |
9088 | } |
9089 | |
9090 | // Generate shortcuts for custom animations |
9091 | jQuery.each({ |
9092 | slideDown: genFx("show"), |
9093 | slideUp: genFx("hide"), |
9094 | slideToggle: genFx("toggle"), |
9095 | fadeIn: { opacity: "show" }, |
9096 | fadeOut: { opacity: "hide" }, |
9097 | fadeToggle: { opacity: "toggle" } |
9098 | }, function( name, props ) { |
9099 | jQuery.fn[ name ] = function( speed, easing, callback ) { |
9100 | return this.animate( props, speed, easing, callback ); |
9101 | }; |
9102 | }); |
9103 | |
9104 | jQuery.speed = function( speed, easing, fn ) { |
9105 | var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { |
9106 | complete: fn || !fn && easing || |
9107 | jQuery.isFunction( speed ) && speed, |
9108 | duration: speed, |
9109 | easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing |
9110 | }; |
9111 | |
9112 | opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
9113 | opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; |
9114 | |
9115 | // normalize opt.queue - true/undefined/null -> "fx" |
9116 | if ( opt.queue == null || opt.queue === true ) { |
9117 | opt.queue = "fx"; |
9118 | } |
9119 | |
9120 | // Queueing |
9121 | opt.old = opt.complete; |
9122 | |
9123 | opt.complete = function() { |
9124 | if ( jQuery.isFunction( opt.old ) ) { |
9125 | opt.old.call( this ); |
9126 | } |
9127 | |
9128 | if ( opt.queue ) { |
9129 | jQuery.dequeue( this, opt.queue ); |
9130 | } |
9131 | }; |
9132 | |
9133 | return opt; |
9134 | }; |
9135 | |
9136 | jQuery.easing = { |
9137 | linear: function( p ) { |
9138 | return p; |
9139 | }, |
9140 | swing: function( p ) { |
9141 | return 0.5 - Math.cos( p*Math.PI ) / 2; |
9142 | } |
9143 | }; |
9144 | |
9145 | jQuery.timers = []; |
9146 | jQuery.fx = Tween.prototype.init; |
9147 | jQuery.fx.tick = function() { |
9148 | var timer, |
9149 | timers = jQuery.timers, |
9150 | i = 0; |
9151 | |
9152 | for ( ; i < timers.length; i++ ) { |
9153 | timer = timers[ i ]; |
9154 | // Checks the timer has not already been removed |
9155 | if ( !timer() && timers[ i ] === timer ) { |
9156 | timers.splice( i--, 1 ); |
9157 | } |
9158 | } |
9159 | |
9160 | if ( !timers.length ) { |
9161 | jQuery.fx.stop(); |
9162 | } |
9163 | }; |
9164 | |
9165 | jQuery.fx.timer = function( timer ) { |
9166 | if ( timer() && jQuery.timers.push( timer ) && !timerId ) { |
9167 | timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); |
9168 | } |
9169 | }; |
9170 | |
9171 | jQuery.fx.interval = 13; |
9172 | |
9173 | jQuery.fx.stop = function() { |
9174 | clearInterval( timerId ); |
9175 | timerId = null; |
9176 | }; |
9177 | |
9178 | jQuery.fx.speeds = { |
9179 | slow: 600, |
9180 | fast: 200, |
9181 | // Default speed |
9182 | _default: 400 |
9183 | }; |
9184 | |
9185 | // Back Compat <1.8 extension point |
9186 | jQuery.fx.step = {}; |
9187 | |
9188 | if ( jQuery.expr && jQuery.expr.filters ) { |
9189 | jQuery.expr.filters.animated = function( elem ) { |
9190 | return jQuery.grep(jQuery.timers, function( fn ) { |
9191 | return elem === fn.elem; |
9192 | }).length; |
9193 | }; |
9194 | } |
9195 | var rroot = /^(?:body|html)$/i; |
9196 | |
9197 | jQuery.fn.offset = function( options ) { |
9198 | if ( arguments.length ) { |
9199 | return options === undefined ? |
9200 | this : |
9201 | this.each(function( i ) { |
9202 | jQuery.offset.setOffset( this, options, i ); |
9203 | }); |
9204 | } |
9205 | |
9206 | var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, |
9207 | box = { top: 0, left: 0 }, |
9208 | elem = this[ 0 ], |
9209 | doc = elem && elem.ownerDocument; |
9210 | |
9211 | if ( !doc ) { |
9212 | return; |
9213 | } |
9214 | |
9215 | if ( (body = doc.body) === elem ) { |
9216 | return jQuery.offset.bodyOffset( elem ); |
9217 | } |
9218 | |
9219 | docElem = doc.documentElement; |
9220 | |
9221 | // Make sure it's not a disconnected DOM node |
9222 | if ( !jQuery.contains( docElem, elem ) ) { |
9223 | return box; |
9224 | } |
9225 | |
9226 | // If we don't have gBCR, just use 0,0 rather than error |
9227 | // BlackBerry 5, iOS 3 (original iPhone) |
9228 | if ( typeof elem.getBoundingClientRect !== "undefined" ) { |
9229 | box = elem.getBoundingClientRect(); |
9230 | } |
9231 | win = getWindow( doc ); |
9232 | clientTop = docElem.clientTop || body.clientTop || 0; |
9233 | clientLeft = docElem.clientLeft || body.clientLeft || 0; |
9234 | scrollTop = win.pageYOffset || docElem.scrollTop; |
9235 | scrollLeft = win.pageXOffset || docElem.scrollLeft; |
9236 | return { |
9237 | top: box.top + scrollTop - clientTop, |
9238 | left: box.left + scrollLeft - clientLeft |
9239 | }; |
9240 | }; |
9241 | |
9242 | jQuery.offset = { |
9243 | |
9244 | bodyOffset: function( body ) { |
9245 | var top = body.offsetTop, |
9246 | left = body.offsetLeft; |
9247 | |
9248 | if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) { |
9249 | top += parseFloat( jQuery.css(body, "marginTop") ) || 0; |
9250 | left += parseFloat( jQuery.css(body, "marginLeft") ) || 0; |
9251 | } |
9252 | |
9253 | return { top: top, left: left }; |
9254 | }, |
9255 | |
9256 | setOffset: function( elem, options, i ) { |
9257 | var position = jQuery.css( elem, "position" ); |
9258 | |
9259 | // set position first, in-case top/left are set even on static elem |
9260 | if ( position === "static" ) { |
9261 | elem.style.position = "relative"; |
9262 | } |
9263 | |
9264 | var curElem = jQuery( elem ), |
9265 | curOffset = curElem.offset(), |
9266 | curCSSTop = jQuery.css( elem, "top" ), |
9267 | curCSSLeft = jQuery.css( elem, "left" ), |
9268 | calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1, |
9269 | props = {}, curPosition = {}, curTop, curLeft; |
9270 | |
9271 | // need to be able to calculate position if either top or left is auto and position is either absolute or fixed |
9272 | if ( calculatePosition ) { |
9273 | curPosition = curElem.position(); |
9274 | curTop = curPosition.top; |
9275 | curLeft = curPosition.left; |
9276 | } else { |
9277 | curTop = parseFloat( curCSSTop ) || 0; |
9278 | curLeft = parseFloat( curCSSLeft ) || 0; |
9279 | } |
9280 | |
9281 | if ( jQuery.isFunction( options ) ) { |
9282 | options = options.call( elem, i, curOffset ); |
9283 | } |
9284 | |
9285 | if ( options.top != null ) { |
9286 | props.top = ( options.top - curOffset.top ) + curTop; |
9287 | } |
9288 | if ( options.left != null ) { |
9289 | props.left = ( options.left - curOffset.left ) + curLeft; |
9290 | } |
9291 | |
9292 | if ( "using" in options ) { |
9293 | options.using.call( elem, props ); |
9294 | } else { |
9295 | curElem.css( props ); |
9296 | } |
9297 | } |
9298 | }; |
9299 | |
9300 | |
9301 | jQuery.fn.extend({ |
9302 | |
9303 | position: function() { |
9304 | if ( !this[0] ) { |
9305 | return; |
9306 | } |
9307 | |
9308 | var elem = this[0], |
9309 | |
9310 | // Get *real* offsetParent |
9311 | offsetParent = this.offsetParent(), |
9312 | |
9313 | // Get correct offsets |
9314 | offset = this.offset(), |
9315 | parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); |
9316 | |
9317 | // Subtract element margins |
9318 | // note: when an element has margin: auto the offsetLeft and marginLeft |
9319 | // are the same in Safari causing offset.left to incorrectly be 0 |
9320 | offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0; |
9321 | offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0; |
9322 | |
9323 | // Add offsetParent borders |
9324 | parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0; |
9325 | parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0; |
9326 | |
9327 | // Subtract the two offsets |
9328 | return { |
9329 | top: offset.top - parentOffset.top, |
9330 | left: offset.left - parentOffset.left |
9331 | }; |
9332 | }, |
9333 | |
9334 | offsetParent: function() { |
9335 | return this.map(function() { |
9336 | var offsetParent = this.offsetParent || document.body; |
9337 | while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) { |
9338 | offsetParent = offsetParent.offsetParent; |
9339 | } |
9340 | return offsetParent || document.body; |
9341 | }); |
9342 | } |
9343 | }); |
9344 | |
9345 | |
9346 | // Create scrollLeft and scrollTop methods |
9347 | jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) { |
9348 | var top = /Y/.test( prop ); |
9349 | |
9350 | jQuery.fn[ method ] = function( val ) { |
9351 | return jQuery.access( this, function( elem, method, val ) { |
9352 | var win = getWindow( elem ); |
9353 | |
9354 | if ( val === undefined ) { |
9355 | return win ? (prop in win) ? win[ prop ] : |
9356 | win.document.documentElement[ method ] : |
9357 | elem[ method ]; |
9358 | } |
9359 | |
9360 | if ( win ) { |
9361 | win.scrollTo( |
9362 | !top ? val : jQuery( win ).scrollLeft(), |
9363 | top ? val : jQuery( win ).scrollTop() |
9364 | ); |
9365 | |
9366 | } else { |
9367 | elem[ method ] = val; |
9368 | } |
9369 | }, method, val, arguments.length, null ); |
9370 | }; |
9371 | }); |
9372 | |
9373 | function getWindow( elem ) { |
9374 | return jQuery.isWindow( elem ) ? |
9375 | elem : |
9376 | elem.nodeType === 9 ? |
9377 | elem.defaultView || elem.parentWindow : |
9378 | false; |
9379 | } |
9380 | // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods |
9381 | jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { |
9382 | jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { |
9383 | // margin is only for outerHeight, outerWidth |
9384 | jQuery.fn[ funcName ] = function( margin, value ) { |
9385 | var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), |
9386 | extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); |
9387 | |
9388 | return jQuery.access( this, function( elem, type, value ) { |
9389 | var doc; |
9390 | |
9391 | if ( jQuery.isWindow( elem ) ) { |
9392 | // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there |
9393 | // isn't a whole lot we can do. See pull request at this URL for discussion: |
9394 | // https://github.com/jquery/jquery/pull/764 |
9395 | return elem.document.documentElement[ "client" + name ]; |
9396 | } |
9397 | |
9398 | // Get document width or height |
9399 | if ( elem.nodeType === 9 ) { |
9400 | doc = elem.documentElement; |
9401 | |
9402 | // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest |
9403 | // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it. |
9404 | return Math.max( |
9405 | elem.body[ "scroll" + name ], doc[ "scroll" + name ], |
9406 | elem.body[ "offset" + name ], doc[ "offset" + name ], |
9407 | doc[ "client" + name ] |
9408 | ); |
9409 | } |
9410 | |
9411 | return value === undefined ? |
9412 | // Get width or height on the element, requesting but not forcing parseFloat |
9413 | jQuery.css( elem, type, value, extra ) : |
9414 | |
9415 | // Set width or height on the element |
9416 | jQuery.style( elem, type, value, extra ); |
9417 | }, type, chainable ? margin : undefined, chainable, null ); |
9418 | }; |
9419 | }); |
9420 | }); |
9421 | // Expose jQuery to the global object |
9422 | window.jQuery = window.$ = jQuery; |
9423 | |
9424 | // Expose jQuery as an AMD module, but only for AMD loaders that |
9425 | // understand the issues with loading multiple versions of jQuery |
9426 | // in a page that all might call define(). The loader will indicate |
9427 | // they have special allowances for multiple jQuery versions by |
9428 | // specifying define.amd.jQuery = true. Register as a named module, |
9429 | // since jQuery can be concatenated with other files that may use define, |
9430 | // but not use a proper concatenation script that understands anonymous |
9431 | // AMD modules. A named AMD is safest and most robust way to register. |
9432 | // Lowercase jquery is used because AMD module names are derived from |
9433 | // file names, and jQuery is normally delivered in a lowercase file name. |
9434 | // Do this after creating the global so that if an AMD module wants to call |
9435 | // noConflict to hide this version of jQuery, it will work. |
9436 | if ( typeof define === "function" && define.amd && define.amd.jQuery ) { |
9437 | define( "jquery", [], function () { return jQuery; } ); |
9438 | } |
9439 | |
9440 | })( window ); |