comparison node_modules/jQuery/lib/node-jquery.js @ 77:cd921abc8887

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