renommage des SDK pour plus de précision
[auf-django-sdk.git] / docs / _build / html / _static / jquery.js
CommitLineData
66f276c9
PH
1/*!
2 * jQuery JavaScript Library v1.7.2
3 * http://jquery.com/
4 *
5 * Copyright 2011, John Resig
6 * Dual licensed under the MIT or GPL Version 2 licenses.
7 * http://jquery.org/license
8 *
9 * Includes Sizzle.js
10 * http://sizzlejs.com/
11 * Copyright 2011, The Dojo Foundation
12 * Released under the MIT, BSD, and GPL Licenses.
13 *
14 * Date: Wed Jul 30 14:06:55 UTC 2014
15 */
16(function( window, undefined ) {
17
18// Use the correct document accordingly with window argument (sandbox)
19var document = window.document,
20 navigator = window.navigator,
21 location = window.location;
22var jQuery = (function() {
23
24// Define a local copy of jQuery
25var jQuery = function( selector, context ) {
26 // The jQuery object is actually just the init constructor 'enhanced'
27 return new jQuery.fn.init( selector, context, rootjQuery );
28 },
29
30 // Map over jQuery in case of overwrite
31 _jQuery = window.jQuery,
32
33 // Map over the $ in case of overwrite
34 _$ = window.$,
35
36 // A central reference to the root jQuery(document)
37 rootjQuery,
38
39 // A simple way to check for HTML strings or ID strings
40 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
41 quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
42
43 // Check if a string has a non-whitespace character in it
44 rnotwhite = /\S/,
45
46 // Used for trimming whitespace
47 trimLeft = /^\s+/,
48 trimRight = /\s+$/,
49
50 // Match a standalone tag
51 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
52
53 // JSON RegExp
54 rvalidchars = /^[\],:{}\s]*$/,
55 rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
56 rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
57 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
58
59 // Useragent RegExp
60 rwebkit = /(webkit)[ \/]([\w.]+)/,
61 ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
62 rmsie = /(msie) ([\w.]+)/,
63 rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
64
65 // Matches dashed string for camelizing
66 rdashAlpha = /-([a-z]|[0-9])/ig,
67 rmsPrefix = /^-ms-/,
68
69 // Used by jQuery.camelCase as callback to replace()
70 fcamelCase = function( all, letter ) {
71 return ( letter + "" ).toUpperCase();
72 },
73
74 // Keep a UserAgent string for use with jQuery.browser
75 userAgent = navigator.userAgent,
76
77 // For matching the engine and version of the browser
78 browserMatch,
79
80 // The deferred used on DOM ready
81 readyList,
82
83 // The ready event handler
84 DOMContentLoaded,
85
86 // Save a reference to some core methods
87 toString = Object.prototype.toString,
88 hasOwn = Object.prototype.hasOwnProperty,
89 push = Array.prototype.push,
90 slice = Array.prototype.slice,
91 trim = String.prototype.trim,
92 indexOf = Array.prototype.indexOf,
93
94 // [[Class]] -> type pairs
95 class2type = {};
96
97jQuery.fn = jQuery.prototype = {
98 constructor: jQuery,
99 init: function( selector, context, rootjQuery ) {
100 var match, elem, ret, doc;
101
102 // Handle $(""), $(null), or $(undefined)
103 if ( !selector ) {
104 return this;
105 }
106
107 // Handle $(DOMElement)
108 if ( selector.nodeType ) {
109 this.context = this[0] = selector;
110 this.length = 1;
111 return this;
112 }
113
114 // The body element only exists once, optimize finding it
115 if ( selector === "body" && !context && document.body ) {
116 this.context = document;
117 this[0] = document.body;
118 this.selector = selector;
119 this.length = 1;
120 return this;
121 }
122
123 // Handle HTML strings
124 if ( typeof selector === "string" ) {
125 // Are we dealing with HTML string or an ID?
126 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
127 // Assume that strings that start and end with <> are HTML and skip the regex check
128 match = [ null, selector, null ];
129
130 } else {
131 match = quickExpr.exec( selector );
132 }
133
134 // Verify a match, and that no context was specified for #id
135 if ( match && (match[1] || !context) ) {
136
137 // HANDLE: $(html) -> $(array)
138 if ( match[1] ) {
139 context = context instanceof jQuery ? context[0] : context;
140 doc = ( context ? context.ownerDocument || context : document );
141
142 // If a single string is passed in and it's a single tag
143 // just do a createElement and skip the rest
144 ret = rsingleTag.exec( selector );
145
146 if ( ret ) {
147 if ( jQuery.isPlainObject( context ) ) {
148 selector = [ document.createElement( ret[1] ) ];
149 jQuery.fn.attr.call( selector, context, true );
150
151 } else {
152 selector = [ doc.createElement( ret[1] ) ];
153 }
154
155 } else {
156 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
157 selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
158 }
159
160 return jQuery.merge( this, selector );
161
162 // HANDLE: $("#id")
163 } else {
164 elem = document.getElementById( match[2] );
165
166 // Check parentNode to catch when Blackberry 4.6 returns
167 // nodes that are no longer in the document #6963
168 if ( elem && elem.parentNode ) {
169 // Handle the case where IE and Opera return items
170 // by name instead of ID
171 if ( elem.id !== match[2] ) {
172 return rootjQuery.find( selector );
173 }
174
175 // Otherwise, we inject the element directly into the jQuery object
176 this.length = 1;
177 this[0] = elem;
178 }
179
180 this.context = document;
181 this.selector = selector;
182 return this;
183 }
184
185 // HANDLE: $(expr, $(...))
186 } else if ( !context || context.jquery ) {
187 return ( context || rootjQuery ).find( selector );
188
189 // HANDLE: $(expr, context)
190 // (which is just equivalent to: $(context).find(expr)
191 } else {
192 return this.constructor( context ).find( selector );
193 }
194
195 // HANDLE: $(function)
196 // Shortcut for document ready
197 } else if ( jQuery.isFunction( selector ) ) {
198 return rootjQuery.ready( selector );
199 }
200
201 if ( selector.selector !== undefined ) {
202 this.selector = selector.selector;
203 this.context = selector.context;
204 }
205
206 return jQuery.makeArray( selector, this );
207 },
208
209 // Start with an empty selector
210 selector: "",
211
212 // The current version of jQuery being used
213 jquery: "1.7.2",
214
215 // The default length of a jQuery object is 0
216 length: 0,
217
218 // The number of elements contained in the matched element set
219 size: function() {
220 return this.length;
221 },
222
223 toArray: function() {
224 return slice.call( this, 0 );
225 },
226
227 // Get the Nth element in the matched element set OR
228 // Get the whole matched element set as a clean array
229 get: function( num ) {
230 return num == null ?
231
232 // Return a 'clean' array
233 this.toArray() :
234
235 // Return just the object
236 ( num < 0 ? this[ this.length + num ] : this[ num ] );
237 },
238
239 // Take an array of elements and push it onto the stack
240 // (returning the new matched element set)
241 pushStack: function( elems, name, selector ) {
242 // Build a new jQuery matched element set
243 var ret = this.constructor();
244
245 if ( jQuery.isArray( elems ) ) {
246 push.apply( ret, elems );
247
248 } else {
249 jQuery.merge( ret, elems );
250 }
251
252 // Add the old object onto the stack (as a reference)
253 ret.prevObject = this;
254
255 ret.context = this.context;
256
257 if ( name === "find" ) {
258 ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
259 } else if ( name ) {
260 ret.selector = this.selector + "." + name + "(" + selector + ")";
261 }
262
263 // Return the newly-formed element set
264 return ret;
265 },
266
267 // Execute a callback for every element in the matched set.
268 // (You can seed the arguments with an array of args, but this is
269 // only used internally.)
270 each: function( callback, args ) {
271 return jQuery.each( this, callback, args );
272 },
273
274 ready: function( fn ) {
275 // Attach the listeners
276 jQuery.bindReady();
277
278 // Add the callback
279 readyList.add( fn );
280
281 return this;
282 },
283
284 eq: function( i ) {
285 i = +i;
286 return i === -1 ?
287 this.slice( i ) :
288 this.slice( i, i + 1 );
289 },
290
291 first: function() {
292 return this.eq( 0 );
293 },
294
295 last: function() {
296 return this.eq( -1 );
297 },
298
299 slice: function() {
300 return this.pushStack( slice.apply( this, arguments ),
301 "slice", slice.call(arguments).join(",") );
302 },
303
304 map: function( callback ) {
305 return this.pushStack( jQuery.map(this, function( elem, i ) {
306 return callback.call( elem, i, elem );
307 }));
308 },
309
310 end: function() {
311 return this.prevObject || this.constructor(null);
312 },
313
314 // For internal use only.
315 // Behaves like an Array's method, not like a jQuery method.
316 push: push,
317 sort: [].sort,
318 splice: [].splice
319};
320
321// Give the init function the jQuery prototype for later instantiation
322jQuery.fn.init.prototype = jQuery.fn;
323
324jQuery.extend = jQuery.fn.extend = function() {
325 var options, name, src, copy, copyIsArray, clone,
326 target = arguments[0] || {},
327 i = 1,
328 length = arguments.length,
329 deep = false;
330
331 // Handle a deep copy situation
332 if ( typeof target === "boolean" ) {
333 deep = target;
334 target = arguments[1] || {};
335 // skip the boolean and the target
336 i = 2;
337 }
338
339 // Handle case when target is a string or something (possible in deep copy)
340 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
341 target = {};
342 }
343
344 // extend jQuery itself if only one argument is passed
345 if ( length === i ) {
346 target = this;
347 --i;
348 }
349
350 for ( ; i < length; i++ ) {
351 // Only deal with non-null/undefined values
352 if ( (options = arguments[ i ]) != null ) {
353 // Extend the base object
354 for ( name in options ) {
355 src = target[ name ];
356 copy = options[ name ];
357
358 // Prevent never-ending loop
359 if ( target === copy ) {
360 continue;
361 }
362
363 // Recurse if we're merging plain objects or arrays
364 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
365 if ( copyIsArray ) {
366 copyIsArray = false;
367 clone = src && jQuery.isArray(src) ? src : [];
368
369 } else {
370 clone = src && jQuery.isPlainObject(src) ? src : {};
371 }
372
373 // Never move original objects, clone them
374 target[ name ] = jQuery.extend( deep, clone, copy );
375
376 // Don't bring in undefined values
377 } else if ( copy !== undefined ) {
378 target[ name ] = copy;
379 }
380 }
381 }
382 }
383
384 // Return the modified object
385 return target;
386};
387
388jQuery.extend({
389 noConflict: function( deep ) {
390 if ( window.$ === jQuery ) {
391 window.$ = _$;
392 }
393
394 if ( deep && window.jQuery === jQuery ) {
395 window.jQuery = _jQuery;
396 }
397
398 return jQuery;
399 },
400
401 // Is the DOM ready to be used? Set to true once it occurs.
402 isReady: false,
403
404 // A counter to track how many items to wait for before
405 // the ready event fires. See #6781
406 readyWait: 1,
407
408 // Hold (or release) the ready event
409 holdReady: function( hold ) {
410 if ( hold ) {
411 jQuery.readyWait++;
412 } else {
413 jQuery.ready( true );
414 }
415 },
416
417 // Handle when the DOM is ready
418 ready: function( wait ) {
419 // Either a released hold or an DOMready/load event and not yet ready
420 if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
421 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
422 if ( !document.body ) {
423 return setTimeout( jQuery.ready, 1 );
424 }
425
426 // Remember that the DOM is ready
427 jQuery.isReady = true;
428
429 // If a normal DOM Ready event fired, decrement, and wait if need be
430 if ( wait !== true && --jQuery.readyWait > 0 ) {
431 return;
432 }
433
434 // If there are functions bound, to execute
435 readyList.fireWith( document, [ jQuery ] );
436
437 // Trigger any bound ready events
438 if ( jQuery.fn.trigger ) {
439 jQuery( document ).trigger( "ready" ).off( "ready" );
440 }
441 }
442 },
443
444 bindReady: function() {
445 if ( readyList ) {
446 return;
447 }
448
449 readyList = jQuery.Callbacks( "once memory" );
450
451 // Catch cases where $(document).ready() is called after the
452 // browser event has already occurred.
453 if ( document.readyState === "complete" ) {
454 // Handle it asynchronously to allow scripts the opportunity to delay ready
455 return setTimeout( jQuery.ready, 1 );
456 }
457
458 // Mozilla, Opera and webkit nightlies currently support this event
459 if ( document.addEventListener ) {
460 // Use the handy event callback
461 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
462
463 // A fallback to window.onload, that will always work
464 window.addEventListener( "load", jQuery.ready, false );
465
466 // If IE event model is used
467 } else if ( document.attachEvent ) {
468 // ensure firing before onload,
469 // maybe late but safe also for iframes
470 document.attachEvent( "onreadystatechange", DOMContentLoaded );
471
472 // A fallback to window.onload, that will always work
473 window.attachEvent( "onload", jQuery.ready );
474
475 // If IE and not a frame
476 // continually check to see if the document is ready
477 var toplevel = false;
478
479 try {
480 toplevel = window.frameElement == null;
481 } catch(e) {}
482
483 if ( document.documentElement.doScroll && toplevel ) {
484 doScrollCheck();
485 }
486 }
487 },
488
489 // See test/unit/core.js for details concerning isFunction.
490 // Since version 1.3, DOM methods and functions like alert
491 // aren't supported. They return false on IE (#2968).
492 isFunction: function( obj ) {
493 return jQuery.type(obj) === "function";
494 },
495
496 isArray: Array.isArray || function( obj ) {
497 return jQuery.type(obj) === "array";
498 },
499
500 isWindow: function( obj ) {
501 return obj != null && obj == obj.window;
502 },
503
504 isNumeric: function( obj ) {
505 return !isNaN( parseFloat(obj) ) && isFinite( obj );
506 },
507
508 type: function( obj ) {
509 return obj == null ?
510 String( obj ) :
511 class2type[ toString.call(obj) ] || "object";
512 },
513
514 isPlainObject: function( obj ) {
515 // Must be an Object.
516 // Because of IE, we also have to check the presence of the constructor property.
517 // Make sure that DOM nodes and window objects don't pass through, as well
518 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
519 return false;
520 }
521
522 try {
523 // Not own constructor property must be Object
524 if ( obj.constructor &&
525 !hasOwn.call(obj, "constructor") &&
526 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
527 return false;
528 }
529 } catch ( e ) {
530 // IE8,9 Will throw exceptions on certain host objects #9897
531 return false;
532 }
533
534 // Own properties are enumerated firstly, so to speed up,
535 // if last one is own, then all properties are own.
536
537 var key;
538 for ( key in obj ) {}
539
540 return key === undefined || hasOwn.call( obj, key );
541 },
542
543 isEmptyObject: function( obj ) {
544 for ( var name in obj ) {
545 return false;
546 }
547 return true;
548 },
549
550 error: function( msg ) {
551 throw new Error( msg );
552 },
553
554 parseJSON: function( data ) {
555 if ( typeof data !== "string" || !data ) {
556 return null;
557 }
558
559 // Make sure leading/trailing whitespace is removed (IE can't handle it)
560 data = jQuery.trim( data );
561
562 // Attempt to parse using the native JSON parser first
563 if ( window.JSON && window.JSON.parse ) {
564 return window.JSON.parse( data );
565 }
566
567 // Make sure the incoming data is actual JSON
568 // Logic borrowed from http://json.org/json2.js
569 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
570 .replace( rvalidtokens, "]" )
571 .replace( rvalidbraces, "")) ) {
572
573 return ( new Function( "return " + data ) )();
574
575 }
576 jQuery.error( "Invalid JSON: " + data );
577 },
578
579 // Cross-browser xml parsing
580 parseXML: function( data ) {
581 if ( typeof data !== "string" || !data ) {
582 return null;
583 }
584 var xml, tmp;
585 try {
586 if ( window.DOMParser ) { // Standard
587 tmp = new DOMParser();
588 xml = tmp.parseFromString( data , "text/xml" );
589 } else { // IE
590 xml = new ActiveXObject( "Microsoft.XMLDOM" );
591 xml.async = "false";
592 xml.loadXML( data );
593 }
594 } catch( e ) {
595 xml = undefined;
596 }
597 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
598 jQuery.error( "Invalid XML: " + data );
599 }
600 return xml;
601 },
602
603 noop: function() {},
604
605 // Evaluates a script in a global context
606 // Workarounds based on findings by Jim Driscoll
607 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
608 globalEval: function( data ) {
609 if ( data && rnotwhite.test( data ) ) {
610 // We use execScript on Internet Explorer
611 // We use an anonymous function so that context is window
612 // rather than jQuery in Firefox
613 ( window.execScript || function( data ) {
614 window[ "eval" ].call( window, data );
615 } )( data );
616 }
617 },
618
619 // Convert dashed to camelCase; used by the css and data modules
620 // Microsoft forgot to hump their vendor prefix (#9572)
621 camelCase: function( string ) {
622 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
623 },
624
625 nodeName: function( elem, name ) {
626 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
627 },
628
629 // args is for internal usage only
630 each: function( object, callback, args ) {
631 var name, i = 0,
632 length = object.length,
633 isObj = length === undefined || jQuery.isFunction( object );
634
635 if ( args ) {
636 if ( isObj ) {
637 for ( name in object ) {
638 if ( callback.apply( object[ name ], args ) === false ) {
639 break;
640 }
641 }
642 } else {
643 for ( ; i < length; ) {
644 if ( callback.apply( object[ i++ ], args ) === false ) {
645 break;
646 }
647 }
648 }
649
650 // A special, fast, case for the most common use of each
651 } else {
652 if ( isObj ) {
653 for ( name in object ) {
654 if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
655 break;
656 }
657 }
658 } else {
659 for ( ; i < length; ) {
660 if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
661 break;
662 }
663 }
664 }
665 }
666
667 return object;
668 },
669
670 // Use native String.trim function wherever possible
671 trim: trim ?
672 function( text ) {
673 return text == null ?
674 "" :
675 trim.call( text );
676 } :
677
678 // Otherwise use our own trimming functionality
679 function( text ) {
680 return text == null ?
681 "" :
682 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
683 },
684
685 // results is for internal usage only
686 makeArray: function( array, results ) {
687 var ret = results || [];
688
689 if ( array != null ) {
690 // The window, strings (and functions) also have 'length'
691 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
692 var type = jQuery.type( array );
693
694 if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
695 push.call( ret, array );
696 } else {
697 jQuery.merge( ret, array );
698 }
699 }
700
701 return ret;
702 },
703
704 inArray: function( elem, array, i ) {
705 var len;
706
707 if ( array ) {
708 if ( indexOf ) {
709 return indexOf.call( array, elem, i );
710 }
711
712 len = array.length;
713 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
714
715 for ( ; i < len; i++ ) {
716 // Skip accessing in sparse arrays
717 if ( i in array && array[ i ] === elem ) {
718 return i;
719 }
720 }
721 }
722
723 return -1;
724 },
725
726 merge: function( first, second ) {
727 var i = first.length,
728 j = 0;
729
730 if ( typeof second.length === "number" ) {
731 for ( var l = second.length; j < l; j++ ) {
732 first[ i++ ] = second[ j ];
733 }
734
735 } else {
736 while ( second[j] !== undefined ) {
737 first[ i++ ] = second[ j++ ];
738 }
739 }
740
741 first.length = i;
742
743 return first;
744 },
745
746 grep: function( elems, callback, inv ) {
747 var ret = [], retVal;
748 inv = !!inv;
749
750 // Go through the array, only saving the items
751 // that pass the validator function
752 for ( var i = 0, length = elems.length; i < length; i++ ) {
753 retVal = !!callback( elems[ i ], i );
754 if ( inv !== retVal ) {
755 ret.push( elems[ i ] );
756 }
757 }
758
759 return ret;
760 },
761
762 // arg is for internal usage only
763 map: function( elems, callback, arg ) {
764 var value, key, ret = [],
765 i = 0,
766 length = elems.length,
767 // jquery objects are treated as arrays
768 isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
769
770 // Go through the array, translating each of the items to their
771 if ( isArray ) {
772 for ( ; i < length; i++ ) {
773 value = callback( elems[ i ], i, arg );
774
775 if ( value != null ) {
776 ret[ ret.length ] = value;
777 }
778 }
779
780 // Go through every key on the object,
781 } else {
782 for ( key in elems ) {
783 value = callback( elems[ key ], key, arg );
784
785 if ( value != null ) {
786 ret[ ret.length ] = value;
787 }
788 }
789 }
790
791 // Flatten any nested arrays
792 return ret.concat.apply( [], ret );
793 },
794
795 // A global GUID counter for objects
796 guid: 1,
797
798 // Bind a function to a context, optionally partially applying any
799 // arguments.
800 proxy: function( fn, context ) {
801 if ( typeof context === "string" ) {
802 var tmp = fn[ context ];
803 context = fn;
804 fn = tmp;
805 }
806
807 // Quick check to determine if target is callable, in the spec
808 // this throws a TypeError, but we will just return undefined.
809 if ( !jQuery.isFunction( fn ) ) {
810 return undefined;
811 }
812
813 // Simulated bind
814 var args = slice.call( arguments, 2 ),
815 proxy = function() {
816 return fn.apply( context, args.concat( slice.call( arguments ) ) );
817 };
818
819 // Set the guid of unique handler to the same of original handler, so it can be removed
820 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
821
822 return proxy;
823 },
824
825 // Mutifunctional method to get and set values to a collection
826 // The value/s can optionally be executed if it's a function
827 access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
828 var exec,
829 bulk = key == null,
830 i = 0,
831 length = elems.length;
832
833 // Sets many values
834 if ( key && typeof key === "object" ) {
835 for ( i in key ) {
836 jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
837 }
838 chainable = 1;
839
840 // Sets one value
841 } else if ( value !== undefined ) {
842 // Optionally, function values get executed if exec is true
843 exec = pass === undefined && jQuery.isFunction( value );
844
845 if ( bulk ) {
846 // Bulk operations only iterate when executing function values
847 if ( exec ) {
848 exec = fn;
849 fn = function( elem, key, value ) {
850 return exec.call( jQuery( elem ), value );
851 };
852
853 // Otherwise they run against the entire set
854 } else {
855 fn.call( elems, value );
856 fn = null;
857 }
858 }
859
860 if ( fn ) {
861 for (; i < length; i++ ) {
862 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
863 }
864 }
865
866 chainable = 1;
867 }
868
869 return chainable ?
870 elems :
871
872 // Gets
873 bulk ?
874 fn.call( elems ) :
875 length ? fn( elems[0], key ) : emptyGet;
876 },
877
878 now: function() {
879 return ( new Date() ).getTime();
880 },
881
882 // Use of jQuery.browser is frowned upon.
883 // More details: http://docs.jquery.com/Utilities/jQuery.browser
884 uaMatch: function( ua ) {
885 ua = ua.toLowerCase();
886
887 var match = rwebkit.exec( ua ) ||
888 ropera.exec( ua ) ||
889 rmsie.exec( ua ) ||
890 ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
891 [];
892
893 return { browser: match[1] || "", version: match[2] || "0" };
894 },
895
896 sub: function() {
897 function jQuerySub( selector, context ) {
898 return new jQuerySub.fn.init( selector, context );
899 }
900 jQuery.extend( true, jQuerySub, this );
901 jQuerySub.superclass = this;
902 jQuerySub.fn = jQuerySub.prototype = this();
903 jQuerySub.fn.constructor = jQuerySub;
904 jQuerySub.sub = this.sub;
905 jQuerySub.fn.init = function init( selector, context ) {
906 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
907 context = jQuerySub( context );
908 }
909
910 return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
911 };
912 jQuerySub.fn.init.prototype = jQuerySub.fn;
913 var rootjQuerySub = jQuerySub(document);
914 return jQuerySub;
915 },
916
917 browser: {}
918});
919
920// Populate the class2type map
921jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
922 class2type[ "[object " + name + "]" ] = name.toLowerCase();
923});
924
925browserMatch = jQuery.uaMatch( userAgent );
926if ( browserMatch.browser ) {
927 jQuery.browser[ browserMatch.browser ] = true;
928 jQuery.browser.version = browserMatch.version;
929}
930
931// Deprecated, use jQuery.browser.webkit instead
932if ( jQuery.browser.webkit ) {
933 jQuery.browser.safari = true;
934}
935
936// IE doesn't match non-breaking spaces with \s
937if ( rnotwhite.test( "\xA0" ) ) {
938 trimLeft = /^[\s\xA0]+/;
939 trimRight = /[\s\xA0]+$/;
940}
941
942// All jQuery objects should point back to these
943rootjQuery = jQuery(document);
944
945// Cleanup functions for the document ready method
946if ( document.addEventListener ) {
947 DOMContentLoaded = function() {
948 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
949 jQuery.ready();
950 };
951
952} else if ( document.attachEvent ) {
953 DOMContentLoaded = function() {
954 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
955 if ( document.readyState === "complete" ) {
956 document.detachEvent( "onreadystatechange", DOMContentLoaded );
957 jQuery.ready();
958 }
959 };
960}
961
962// The DOM ready check for Internet Explorer
963function doScrollCheck() {
964 if ( jQuery.isReady ) {
965 return;
966 }
967
968 try {
969 // If IE is used, use the trick by Diego Perini
970 // http://javascript.nwbox.com/IEContentLoaded/
971 document.documentElement.doScroll("left");
972 } catch(e) {
973 setTimeout( doScrollCheck, 1 );
974 return;
975 }
976
977 // and execute any waiting functions
978 jQuery.ready();
979}
980
981return jQuery;
982
983})();
984
985
986// String to Object flags format cache
987var flagsCache = {};
988
989// Convert String-formatted flags into Object-formatted ones and store in cache
990function createFlags( flags ) {
991 var object = flagsCache[ flags ] = {},
992 i, length;
993 flags = flags.split( /\s+/ );
994 for ( i = 0, length = flags.length; i < length; i++ ) {
995 object[ flags[i] ] = true;
996 }
997 return object;
998}
999
1000/*
1001 * Create a callback list using the following parameters:
1002 *
1003 * flags: an optional list of space-separated flags that will change how
1004 * the callback list behaves
1005 *
1006 * By default a callback list will act like an event callback list and can be
1007 * "fired" multiple times.
1008 *
1009 * Possible flags:
1010 *
1011 * once: will ensure the callback list can only be fired once (like a Deferred)
1012 *
1013 * memory: will keep track of previous values and will call any callback added
1014 * after the list has been fired right away with the latest "memorized"
1015 * values (like a Deferred)
1016 *
1017 * unique: will ensure a callback can only be added once (no duplicate in the list)
1018 *
1019 * stopOnFalse: interrupt callings when a callback returns false
1020 *
1021 */
1022jQuery.Callbacks = function( flags ) {
1023
1024 // Convert flags from String-formatted to Object-formatted
1025 // (we check in cache first)
1026 flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
1027
1028 var // Actual callback list
1029 list = [],
1030 // Stack of fire calls for repeatable lists
1031 stack = [],
1032 // Last fire value (for non-forgettable lists)
1033 memory,
1034 // Flag to know if list was already fired
1035 fired,
1036 // Flag to know if list is currently firing
1037 firing,
1038 // First callback to fire (used internally by add and fireWith)
1039 firingStart,
1040 // End of the loop when firing
1041 firingLength,
1042 // Index of currently firing callback (modified by remove if needed)
1043 firingIndex,
1044 // Add one or several callbacks to the list
1045 add = function( args ) {
1046 var i,
1047 length,
1048 elem,
1049 type,
1050 actual;
1051 for ( i = 0, length = args.length; i < length; i++ ) {
1052 elem = args[ i ];
1053 type = jQuery.type( elem );
1054 if ( type === "array" ) {
1055 // Inspect recursively
1056 add( elem );
1057 } else if ( type === "function" ) {
1058 // Add if not in unique mode and callback is not in
1059 if ( !flags.unique || !self.has( elem ) ) {
1060 list.push( elem );
1061 }
1062 }
1063 }
1064 },
1065 // Fire callbacks
1066 fire = function( context, args ) {
1067 args = args || [];
1068 memory = !flags.memory || [ context, args ];
1069 fired = true;
1070 firing = true;
1071 firingIndex = firingStart || 0;
1072 firingStart = 0;
1073 firingLength = list.length;
1074 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
1075 if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) {
1076 memory = true; // Mark as halted
1077 break;
1078 }
1079 }
1080 firing = false;
1081 if ( list ) {
1082 if ( !flags.once ) {
1083 if ( stack && stack.length ) {
1084 memory = stack.shift();
1085 self.fireWith( memory[ 0 ], memory[ 1 ] );
1086 }
1087 } else if ( memory === true ) {
1088 self.disable();
1089 } else {
1090 list = [];
1091 }
1092 }
1093 },
1094 // Actual Callbacks object
1095 self = {
1096 // Add a callback or a collection of callbacks to the list
1097 add: function() {
1098 if ( list ) {
1099 var length = list.length;
1100 add( arguments );
1101 // Do we need to add the callbacks to the
1102 // current firing batch?
1103 if ( firing ) {
1104 firingLength = list.length;
1105 // With memory, if we're not firing then
1106 // we should call right away, unless previous
1107 // firing was halted (stopOnFalse)
1108 } else if ( memory && memory !== true ) {
1109 firingStart = length;
1110 fire( memory[ 0 ], memory[ 1 ] );
1111 }
1112 }
1113 return this;
1114 },
1115 // Remove a callback from the list
1116 remove: function() {
1117 if ( list ) {
1118 var args = arguments,
1119 argIndex = 0,
1120 argLength = args.length;
1121 for ( ; argIndex < argLength ; argIndex++ ) {
1122 for ( var i = 0; i < list.length; i++ ) {
1123 if ( args[ argIndex ] === list[ i ] ) {
1124 // Handle firingIndex and firingLength
1125 if ( firing ) {
1126 if ( i <= firingLength ) {
1127 firingLength--;
1128 if ( i <= firingIndex ) {
1129 firingIndex--;
1130 }
1131 }
1132 }
1133 // Remove the element
1134 list.splice( i--, 1 );
1135 // If we have some unicity property then
1136 // we only need to do this once
1137 if ( flags.unique ) {
1138 break;
1139 }
1140 }
1141 }
1142 }
1143 }
1144 return this;
1145 },
1146 // Control if a given callback is in the list
1147 has: function( fn ) {
1148 if ( list ) {
1149 var i = 0,
1150 length = list.length;
1151 for ( ; i < length; i++ ) {
1152 if ( fn === list[ i ] ) {
1153 return true;
1154 }
1155 }
1156 }
1157 return false;
1158 },
1159 // Remove all callbacks from the list
1160 empty: function() {
1161 list = [];
1162 return this;
1163 },
1164 // Have the list do nothing anymore
1165 disable: function() {
1166 list = stack = memory = undefined;
1167 return this;
1168 },
1169 // Is it disabled?
1170 disabled: function() {
1171 return !list;
1172 },
1173 // Lock the list in its current state
1174 lock: function() {
1175 stack = undefined;
1176 if ( !memory || memory === true ) {
1177 self.disable();
1178 }
1179 return this;
1180 },
1181 // Is it locked?
1182 locked: function() {
1183 return !stack;
1184 },
1185 // Call all callbacks with the given context and arguments
1186 fireWith: function( context, args ) {
1187 if ( stack ) {
1188 if ( firing ) {
1189 if ( !flags.once ) {
1190 stack.push( [ context, args ] );
1191 }
1192 } else if ( !( flags.once && memory ) ) {
1193 fire( context, args );
1194 }
1195 }
1196 return this;
1197 },
1198 // Call all the callbacks with the given arguments
1199 fire: function() {
1200 self.fireWith( this, arguments );
1201 return this;
1202 },
1203 // To know if the callbacks have already been called at least once
1204 fired: function() {
1205 return !!fired;
1206 }
1207 };
1208
1209 return self;
1210};
1211
1212
1213
1214
1215var // Static reference to slice
1216 sliceDeferred = [].slice;
1217
1218jQuery.extend({
1219
1220 Deferred: function( func ) {
1221 var doneList = jQuery.Callbacks( "once memory" ),
1222 failList = jQuery.Callbacks( "once memory" ),
1223 progressList = jQuery.Callbacks( "memory" ),
1224 state = "pending",
1225 lists = {
1226 resolve: doneList,
1227 reject: failList,
1228 notify: progressList
1229 },
1230 promise = {
1231 done: doneList.add,
1232 fail: failList.add,
1233 progress: progressList.add,
1234
1235 state: function() {
1236 return state;
1237 },
1238
1239 // Deprecated
1240 isResolved: doneList.fired,
1241 isRejected: failList.fired,
1242
1243 then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
1244 deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
1245 return this;
1246 },
1247 always: function() {
1248 deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
1249 return this;
1250 },
1251 pipe: function( fnDone, fnFail, fnProgress ) {
1252 return jQuery.Deferred(function( newDefer ) {
1253 jQuery.each( {
1254 done: [ fnDone, "resolve" ],
1255 fail: [ fnFail, "reject" ],
1256 progress: [ fnProgress, "notify" ]
1257 }, function( handler, data ) {
1258 var fn = data[ 0 ],
1259 action = data[ 1 ],
1260 returned;
1261 if ( jQuery.isFunction( fn ) ) {
1262 deferred[ handler ](function() {
1263 returned = fn.apply( this, arguments );
1264 if ( returned && jQuery.isFunction( returned.promise ) ) {
1265 returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
1266 } else {
1267 newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1268 }
1269 });
1270 } else {
1271 deferred[ handler ]( newDefer[ action ] );
1272 }
1273 });
1274 }).promise();
1275 },
1276 // Get a promise for this deferred
1277 // If obj is provided, the promise aspect is added to the object
1278 promise: function( obj ) {
1279 if ( obj == null ) {
1280 obj = promise;
1281 } else {
1282 for ( var key in promise ) {
1283 obj[ key ] = promise[ key ];
1284 }
1285 }
1286 return obj;
1287 }
1288 },
1289 deferred = promise.promise({}),
1290 key;
1291
1292 for ( key in lists ) {
1293 deferred[ key ] = lists[ key ].fire;
1294 deferred[ key + "With" ] = lists[ key ].fireWith;
1295 }
1296
1297 // Handle state
1298 deferred.done( function() {
1299 state = "resolved";
1300 }, failList.disable, progressList.lock ).fail( function() {
1301 state = "rejected";
1302 }, doneList.disable, progressList.lock );
1303
1304 // Call given func if any
1305 if ( func ) {
1306 func.call( deferred, deferred );
1307 }
1308
1309 // All done!
1310 return deferred;
1311 },
1312
1313 // Deferred helper
1314 when: function( firstParam ) {
1315 var args = sliceDeferred.call( arguments, 0 ),
1316 i = 0,
1317 length = args.length,
1318 pValues = new Array( length ),
1319 count = length,
1320 pCount = length,
1321 deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
1322 firstParam :
1323 jQuery.Deferred(),
1324 promise = deferred.promise();
1325 function resolveFunc( i ) {
1326 return function( value ) {
1327 args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1328 if ( !( --count ) ) {
1329 deferred.resolveWith( deferred, args );
1330 }
1331 };
1332 }
1333 function progressFunc( i ) {
1334 return function( value ) {
1335 pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1336 deferred.notifyWith( promise, pValues );
1337 };
1338 }
1339 if ( length > 1 ) {
1340 for ( ; i < length; i++ ) {
1341 if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
1342 args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );
1343 } else {
1344 --count;
1345 }
1346 }
1347 if ( !count ) {
1348 deferred.resolveWith( deferred, args );
1349 }
1350 } else if ( deferred !== firstParam ) {
1351 deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
1352 }
1353 return promise;
1354 }
1355});
1356
1357
1358
1359
1360jQuery.support = (function() {
1361
1362 var support,
1363 all,
1364 a,
1365 select,
1366 opt,
1367 input,
1368 fragment,
1369 tds,
1370 events,
1371 eventName,
1372 i,
1373 isSupported,
1374 div = document.createElement( "div" ),
1375 documentElement = document.documentElement;
1376
1377 // Preliminary tests
1378 div.setAttribute("className", "t");
1379 div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
1380
1381 all = div.getElementsByTagName( "*" );
1382 a = div.getElementsByTagName( "a" )[ 0 ];
1383
1384 // Can't get basic test support
1385 if ( !all || !all.length || !a ) {
1386 return {};
1387 }
1388
1389 // First batch of supports tests
1390 select = document.createElement( "select" );
1391 opt = select.appendChild( document.createElement("option") );
1392 input = div.getElementsByTagName( "input" )[ 0 ];
1393
1394 support = {
1395 // IE strips leading whitespace when .innerHTML is used
1396 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
1397
1398 // Make sure that tbody elements aren't automatically inserted
1399 // IE will insert them into empty tables
1400 tbody: !div.getElementsByTagName("tbody").length,
1401
1402 // Make sure that link elements get serialized correctly by innerHTML
1403 // This requires a wrapper element in IE
1404 htmlSerialize: !!div.getElementsByTagName("link").length,
1405
1406 // Get the style information from getAttribute
1407 // (IE uses .cssText instead)
1408 style: /top/.test( a.getAttribute("style") ),
1409
1410 // Make sure that URLs aren't manipulated
1411 // (IE normalizes it by default)
1412 hrefNormalized: ( a.getAttribute("href") === "/a" ),
1413
1414 // Make sure that element opacity exists
1415 // (IE uses filter instead)
1416 // Use a regex to work around a WebKit issue. See #5145
1417 opacity: /^0.55/.test( a.style.opacity ),
1418
1419 // Verify style float existence
1420 // (IE uses styleFloat instead of cssFloat)
1421 cssFloat: !!a.style.cssFloat,
1422
1423 // Make sure that if no value is specified for a checkbox
1424 // that it defaults to "on".
1425 // (WebKit defaults to "" instead)
1426 checkOn: ( input.value === "on" ),
1427
1428 // Make sure that a selected-by-default option has a working selected property.
1429 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1430 optSelected: opt.selected,
1431
1432 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1433 getSetAttribute: div.className !== "t",
1434
1435 // Tests for enctype support on a form(#6743)
1436 enctype: !!document.createElement("form").enctype,
1437
1438 // Makes sure cloning an html5 element does not cause problems
1439 // Where outerHTML is undefined, this still works
1440 html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
1441
1442 // Will be defined later
1443 submitBubbles: true,
1444 changeBubbles: true,
1445 focusinBubbles: false,
1446 deleteExpando: true,
1447 noCloneEvent: true,
1448 inlineBlockNeedsLayout: false,
1449 shrinkWrapBlocks: false,
1450 reliableMarginRight: true,
1451 pixelMargin: true
1452 };
1453
1454 // jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel instead
1455 jQuery.boxModel = support.boxModel = (document.compatMode === "CSS1Compat");
1456
1457 // Make sure checked status is properly cloned
1458 input.checked = true;
1459 support.noCloneChecked = input.cloneNode( true ).checked;
1460
1461 // Make sure that the options inside disabled selects aren't marked as disabled
1462 // (WebKit marks them as disabled)
1463 select.disabled = true;
1464 support.optDisabled = !opt.disabled;
1465
1466 // Test to see if it's possible to delete an expando from an element
1467 // Fails in Internet Explorer
1468 try {
1469 delete div.test;
1470 } catch( e ) {
1471 support.deleteExpando = false;
1472 }
1473
1474 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1475 div.attachEvent( "onclick", function() {
1476 // Cloning a node shouldn't copy over any
1477 // bound event handlers (IE does this)
1478 support.noCloneEvent = false;
1479 });
1480 div.cloneNode( true ).fireEvent( "onclick" );
1481 }
1482
1483 // Check if a radio maintains its value
1484 // after being appended to the DOM
1485 input = document.createElement("input");
1486 input.value = "t";
1487 input.setAttribute("type", "radio");
1488 support.radioValue = input.value === "t";
1489
1490 input.setAttribute("checked", "checked");
1491
1492 // #11217 - WebKit loses check when the name is after the checked attribute
1493 input.setAttribute( "name", "t" );
1494
1495 div.appendChild( input );
1496 fragment = document.createDocumentFragment();
1497 fragment.appendChild( div.lastChild );
1498
1499 // WebKit doesn't clone checked state correctly in fragments
1500 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1501
1502 // Check if a disconnected checkbox will retain its checked
1503 // value of true after appended to the DOM (IE6/7)
1504 support.appendChecked = input.checked;
1505
1506 fragment.removeChild( input );
1507 fragment.appendChild( div );
1508
1509 // Technique from Juriy Zaytsev
1510 // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
1511 // We only care about the case where non-standard event systems
1512 // are used, namely in IE. Short-circuiting here helps us to
1513 // avoid an eval call (in setAttribute) which can cause CSP
1514 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1515 if ( div.attachEvent ) {
1516 for ( i in {
1517 submit: 1,
1518 change: 1,
1519 focusin: 1
1520 }) {
1521 eventName = "on" + i;
1522 isSupported = ( eventName in div );
1523 if ( !isSupported ) {
1524 div.setAttribute( eventName, "return;" );
1525 isSupported = ( typeof div[ eventName ] === "function" );
1526 }
1527 support[ i + "Bubbles" ] = isSupported;
1528 }
1529 }
1530
1531 fragment.removeChild( div );
1532
1533 // Null elements to avoid leaks in IE
1534 fragment = select = opt = div = input = null;
1535
1536 // Run tests that need a body at doc ready
1537 jQuery(function() {
1538 var container, outer, inner, table, td, offsetSupport,
1539 marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight,
1540 paddingMarginBorderVisibility, paddingMarginBorder,
1541 body = document.getElementsByTagName("body")[0];
1542
1543 if ( !body ) {
1544 // Return for frameset docs that don't have a body
1545 return;
1546 }
1547
1548 conMarginTop = 1;
1549 paddingMarginBorder = "padding:0;margin:0;border:";
1550 positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;";
1551 paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;";
1552 style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;";
1553 html = "<div " + style + "display:block;'><div style='" + paddingMarginBorder + "0;display:block;overflow:hidden;'></div></div>" +
1554 "<table " + style + "' cellpadding='0' cellspacing='0'>" +
1555 "<tr><td></td></tr></table>";
1556
1557 container = document.createElement("div");
1558 container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
1559 body.insertBefore( container, body.firstChild );
1560
1561 // Construct the test element
1562 div = document.createElement("div");
1563 container.appendChild( div );
1564
1565 // Check if table cells still have offsetWidth/Height when they are set
1566 // to display:none and there are still other visible table cells in a
1567 // table row; if so, offsetWidth/Height are not reliable for use when
1568 // determining if an element has been hidden directly using
1569 // display:none (it is still safe to use offsets if a parent element is
1570 // hidden; don safety goggles and see bug #4512 for more information).
1571 // (only IE 8 fails this test)
1572 div.innerHTML = "<table><tr><td style='" + paddingMarginBorder + "0;display:none'></td><td>t</td></tr></table>";
1573 tds = div.getElementsByTagName( "td" );
1574 isSupported = ( tds[ 0 ].offsetHeight === 0 );
1575
1576 tds[ 0 ].style.display = "";
1577 tds[ 1 ].style.display = "none";
1578
1579 // Check if empty table cells still have offsetWidth/Height
1580 // (IE <= 8 fail this test)
1581 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1582
1583 // Check if div with explicit width and no margin-right incorrectly
1584 // gets computed margin-right based on width of container. For more
1585 // info see bug #3333
1586 // Fails in WebKit before Feb 2011 nightlies
1587 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1588 if ( window.getComputedStyle ) {
1589 div.innerHTML = "";
1590 marginDiv = document.createElement( "div" );
1591 marginDiv.style.width = "0";
1592 marginDiv.style.marginRight = "0";
1593 div.style.width = "2px";
1594 div.appendChild( marginDiv );
1595 support.reliableMarginRight =
1596 ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
1597 }
1598
1599 if ( typeof div.style.zoom !== "undefined" ) {
1600 // Check if natively block-level elements act like inline-block
1601 // elements when setting their display to 'inline' and giving
1602 // them layout
1603 // (IE < 8 does this)
1604 div.innerHTML = "";
1605 div.style.width = div.style.padding = "1px";
1606 div.style.border = 0;
1607 div.style.overflow = "hidden";
1608 div.style.display = "inline";
1609 div.style.zoom = 1;
1610 support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
1611
1612 // Check if elements with layout shrink-wrap their children
1613 // (IE 6 does this)
1614 div.style.display = "block";
1615 div.style.overflow = "visible";
1616 div.innerHTML = "<div style='width:5px;'></div>";
1617 support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
1618 }
1619
1620 div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility;
1621 div.innerHTML = html;
1622
1623 outer = div.firstChild;
1624 inner = outer.firstChild;
1625 td = outer.nextSibling.firstChild.firstChild;
1626
1627 offsetSupport = {
1628 doesNotAddBorder: ( inner.offsetTop !== 5 ),
1629 doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
1630 };
1631
1632 inner.style.position = "fixed";
1633 inner.style.top = "20px";
1634
1635 // safari subtracts parent border width here which is 5px
1636 offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
1637 inner.style.position = inner.style.top = "";
1638
1639 outer.style.overflow = "hidden";
1640 outer.style.position = "relative";
1641
1642 offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
1643 offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
1644
1645 if ( window.getComputedStyle ) {
1646 div.style.marginTop = "1%";
1647 support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%";
1648 }
1649
1650 if ( typeof container.style.zoom !== "undefined" ) {
1651 container.style.zoom = 1;
1652 }
1653
1654 body.removeChild( container );
1655 marginDiv = div = container = null;
1656
1657 jQuery.extend( support, offsetSupport );
1658 });
1659
1660 return support;
1661})();
1662
1663
1664
1665
1666var rbrace = /^(?:\{.*\}|\[.*\])$/,
1667 rmultiDash = /([A-Z])/g;
1668
1669jQuery.extend({
1670 cache: {},
1671
1672 // Please use with caution
1673 uuid: 0,
1674
1675 // Unique for each copy of jQuery on the page
1676 // Non-digits removed to match rinlinejQuery
1677 expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
1678
1679 // The following elements throw uncatchable exceptions if you
1680 // attempt to add expando properties to them.
1681 noData: {
1682 "embed": true,
1683 // Ban all objects except for Flash (which handle expandos)
1684 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1685 "applet": true
1686 },
1687
1688 hasData: function( elem ) {
1689 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1690 return !!elem && !isEmptyDataObject( elem );
1691 },
1692
1693 data: function( elem, name, data, pvt /* Internal Use Only */ ) {
1694 if ( !jQuery.acceptData( elem ) ) {
1695 return;
1696 }
1697
1698 var privateCache, thisCache, ret,
1699 internalKey = jQuery.expando,
1700 getByName = typeof name === "string",
1701
1702 // We have to handle DOM nodes and JS objects differently because IE6-7
1703 // can't GC object references properly across the DOM-JS boundary
1704 isNode = elem.nodeType,
1705
1706 // Only DOM nodes need the global jQuery cache; JS object data is
1707 // attached directly to the object so GC can occur automatically
1708 cache = isNode ? jQuery.cache : elem,
1709
1710 // Only defining an ID for JS objects if its cache already exists allows
1711 // the code to shortcut on the same path as a DOM node with no cache
1712 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey,
1713 isEvents = name === "events";
1714
1715 // Avoid doing any more work than we need to when trying to get data on an
1716 // object that has no data at all
1717 if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {
1718 return;
1719 }
1720
1721 if ( !id ) {
1722 // Only DOM nodes need a new unique ID for each element since their data
1723 // ends up in the global cache
1724 if ( isNode ) {
1725 elem[ internalKey ] = id = ++jQuery.uuid;
1726 } else {
1727 id = internalKey;
1728 }
1729 }
1730
1731 if ( !cache[ id ] ) {
1732 cache[ id ] = {};
1733
1734 // Avoids exposing jQuery metadata on plain JS objects when the object
1735 // is serialized using JSON.stringify
1736 if ( !isNode ) {
1737 cache[ id ].toJSON = jQuery.noop;
1738 }
1739 }
1740
1741 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1742 // shallow copied over onto the existing cache
1743 if ( typeof name === "object" || typeof name === "function" ) {
1744 if ( pvt ) {
1745 cache[ id ] = jQuery.extend( cache[ id ], name );
1746 } else {
1747 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
1748 }
1749 }
1750
1751 privateCache = thisCache = cache[ id ];
1752
1753 // jQuery data() is stored in a separate object inside the object's internal data
1754 // cache in order to avoid key collisions between internal data and user-defined
1755 // data.
1756 if ( !pvt ) {
1757 if ( !thisCache.data ) {
1758 thisCache.data = {};
1759 }
1760
1761 thisCache = thisCache.data;
1762 }
1763
1764 if ( data !== undefined ) {
1765 thisCache[ jQuery.camelCase( name ) ] = data;
1766 }
1767
1768 // Users should not attempt to inspect the internal events object using jQuery.data,
1769 // it is undocumented and subject to change. But does anyone listen? No.
1770 if ( isEvents && !thisCache[ name ] ) {
1771 return privateCache.events;
1772 }
1773
1774 // Check for both converted-to-camel and non-converted data property names
1775 // If a data property was specified
1776 if ( getByName ) {
1777
1778 // First Try to find as-is property data
1779 ret = thisCache[ name ];
1780
1781 // Test for null|undefined property data
1782 if ( ret == null ) {
1783
1784 // Try to find the camelCased property
1785 ret = thisCache[ jQuery.camelCase( name ) ];
1786 }
1787 } else {
1788 ret = thisCache;
1789 }
1790
1791 return ret;
1792 },
1793
1794 removeData: function( elem, name, pvt /* Internal Use Only */ ) {
1795 if ( !jQuery.acceptData( elem ) ) {
1796 return;
1797 }
1798
1799 var thisCache, i, l,
1800
1801 // Reference to internal data cache key
1802 internalKey = jQuery.expando,
1803
1804 isNode = elem.nodeType,
1805
1806 // See jQuery.data for more information
1807 cache = isNode ? jQuery.cache : elem,
1808
1809 // See jQuery.data for more information
1810 id = isNode ? elem[ internalKey ] : internalKey;
1811
1812 // If there is already no cache entry for this object, there is no
1813 // purpose in continuing
1814 if ( !cache[ id ] ) {
1815 return;
1816 }
1817
1818 if ( name ) {
1819
1820 thisCache = pvt ? cache[ id ] : cache[ id ].data;
1821
1822 if ( thisCache ) {
1823
1824 // Support array or space separated string names for data keys
1825 if ( !jQuery.isArray( name ) ) {
1826
1827 // try the string as a key before any manipulation
1828 if ( name in thisCache ) {
1829 name = [ name ];
1830 } else {
1831
1832 // split the camel cased version by spaces unless a key with the spaces exists
1833 name = jQuery.camelCase( name );
1834 if ( name in thisCache ) {
1835 name = [ name ];
1836 } else {
1837 name = name.split( " " );
1838 }
1839 }
1840 }
1841
1842 for ( i = 0, l = name.length; i < l; i++ ) {
1843 delete thisCache[ name[i] ];
1844 }
1845
1846 // If there is no data left in the cache, we want to continue
1847 // and let the cache object itself get destroyed
1848 if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
1849 return;
1850 }
1851 }
1852 }
1853
1854 // See jQuery.data for more information
1855 if ( !pvt ) {
1856 delete cache[ id ].data;
1857
1858 // Don't destroy the parent cache unless the internal data object
1859 // had been the only thing left in it
1860 if ( !isEmptyDataObject(cache[ id ]) ) {
1861 return;
1862 }
1863 }
1864
1865 // Browsers that fail expando deletion also refuse to delete expandos on
1866 // the window, but it will allow it on all other JS objects; other browsers
1867 // don't care
1868 // Ensure that `cache` is not a window object #10080
1869 if ( jQuery.support.deleteExpando || !cache.setInterval ) {
1870 delete cache[ id ];
1871 } else {
1872 cache[ id ] = null;
1873 }
1874
1875 // We destroyed the cache and need to eliminate the expando on the node to avoid
1876 // false lookups in the cache for entries that no longer exist
1877 if ( isNode ) {
1878 // IE does not allow us to delete expando properties from nodes,
1879 // nor does it have a removeAttribute function on Document nodes;
1880 // we must handle all of these cases
1881 if ( jQuery.support.deleteExpando ) {
1882 delete elem[ internalKey ];
1883 } else if ( elem.removeAttribute ) {
1884 elem.removeAttribute( internalKey );
1885 } else {
1886 elem[ internalKey ] = null;
1887 }
1888 }
1889 },
1890
1891 // For internal use only.
1892 _data: function( elem, name, data ) {
1893 return jQuery.data( elem, name, data, true );
1894 },
1895
1896 // A method for determining if a DOM node can handle the data expando
1897 acceptData: function( elem ) {
1898 if ( elem.nodeName ) {
1899 var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
1900
1901 if ( match ) {
1902 return !(match === true || elem.getAttribute("classid") !== match);
1903 }
1904 }
1905
1906 return true;
1907 }
1908});
1909
1910jQuery.fn.extend({
1911 data: function( key, value ) {
1912 var parts, part, attr, name, l,
1913 elem = this[0],
1914 i = 0,
1915 data = null;
1916
1917 // Gets all values
1918 if ( key === undefined ) {
1919 if ( this.length ) {
1920 data = jQuery.data( elem );
1921
1922 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
1923 attr = elem.attributes;
1924 for ( l = attr.length; i < l; i++ ) {
1925 name = attr[i].name;
1926
1927 if ( name.indexOf( "data-" ) === 0 ) {
1928 name = jQuery.camelCase( name.substring(5) );
1929
1930 dataAttr( elem, name, data[ name ] );
1931 }
1932 }
1933 jQuery._data( elem, "parsedAttrs", true );
1934 }
1935 }
1936
1937 return data;
1938 }
1939
1940 // Sets multiple values
1941 if ( typeof key === "object" ) {
1942 return this.each(function() {
1943 jQuery.data( this, key );
1944 });
1945 }
1946
1947 parts = key.split( ".", 2 );
1948 parts[1] = parts[1] ? "." + parts[1] : "";
1949 part = parts[1] + "!";
1950
1951 return jQuery.access( this, function( value ) {
1952
1953 if ( value === undefined ) {
1954 data = this.triggerHandler( "getData" + part, [ parts[0] ] );
1955
1956 // Try to fetch any internally stored data first
1957 if ( data === undefined && elem ) {
1958 data = jQuery.data( elem, key );
1959 data = dataAttr( elem, key, data );
1960 }
1961
1962 return data === undefined && parts[1] ?
1963 this.data( parts[0] ) :
1964 data;
1965 }
1966
1967 parts[1] = value;
1968 this.each(function() {
1969 var self = jQuery( this );
1970
1971 self.triggerHandler( "setData" + part, parts );
1972 jQuery.data( this, key, value );
1973 self.triggerHandler( "changeData" + part, parts );
1974 });
1975 }, null, value, arguments.length > 1, null, false );
1976 },
1977
1978 removeData: function( key ) {
1979 return this.each(function() {
1980 jQuery.removeData( this, key );
1981 });
1982 }
1983});
1984
1985function dataAttr( elem, key, data ) {
1986 // If nothing was found internally, try to fetch any
1987 // data from the HTML5 data-* attribute
1988 if ( data === undefined && elem.nodeType === 1 ) {
1989
1990 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1991
1992 data = elem.getAttribute( name );
1993
1994 if ( typeof data === "string" ) {
1995 try {
1996 data = data === "true" ? true :
1997 data === "false" ? false :
1998 data === "null" ? null :
1999 jQuery.isNumeric( data ) ? +data :
2000 rbrace.test( data ) ? jQuery.parseJSON( data ) :
2001 data;
2002 } catch( e ) {}
2003
2004 // Make sure we set the data so it isn't changed later
2005 jQuery.data( elem, key, data );
2006
2007 } else {
2008 data = undefined;
2009 }
2010 }
2011
2012 return data;
2013}
2014
2015// checks a cache object for emptiness
2016function isEmptyDataObject( obj ) {
2017 for ( var name in obj ) {
2018
2019 // if the public data object is empty, the private is still empty
2020 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
2021 continue;
2022 }
2023 if ( name !== "toJSON" ) {
2024 return false;
2025 }
2026 }
2027
2028 return true;
2029}
2030
2031
2032
2033
2034function handleQueueMarkDefer( elem, type, src ) {
2035 var deferDataKey = type + "defer",
2036 queueDataKey = type + "queue",
2037 markDataKey = type + "mark",
2038 defer = jQuery._data( elem, deferDataKey );
2039 if ( defer &&
2040 ( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
2041 ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
2042 // Give room for hard-coded callbacks to fire first
2043 // and eventually mark/queue something else on the element
2044 setTimeout( function() {
2045 if ( !jQuery._data( elem, queueDataKey ) &&
2046 !jQuery._data( elem, markDataKey ) ) {
2047 jQuery.removeData( elem, deferDataKey, true );
2048 defer.fire();
2049 }
2050 }, 0 );
2051 }
2052}
2053
2054jQuery.extend({
2055
2056 _mark: function( elem, type ) {
2057 if ( elem ) {
2058 type = ( type || "fx" ) + "mark";
2059 jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
2060 }
2061 },
2062
2063 _unmark: function( force, elem, type ) {
2064 if ( force !== true ) {
2065 type = elem;
2066 elem = force;
2067 force = false;
2068 }
2069 if ( elem ) {
2070 type = type || "fx";
2071 var key = type + "mark",
2072 count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
2073 if ( count ) {
2074 jQuery._data( elem, key, count );
2075 } else {
2076 jQuery.removeData( elem, key, true );
2077 handleQueueMarkDefer( elem, type, "mark" );
2078 }
2079 }
2080 },
2081
2082 queue: function( elem, type, data ) {
2083 var q;
2084 if ( elem ) {
2085 type = ( type || "fx" ) + "queue";
2086 q = jQuery._data( elem, type );
2087
2088 // Speed up dequeue by getting out quickly if this is just a lookup
2089 if ( data ) {
2090 if ( !q || jQuery.isArray(data) ) {
2091 q = jQuery._data( elem, type, jQuery.makeArray(data) );
2092 } else {
2093 q.push( data );
2094 }
2095 }
2096 return q || [];
2097 }
2098 },
2099
2100 dequeue: function( elem, type ) {
2101 type = type || "fx";
2102
2103 var queue = jQuery.queue( elem, type ),
2104 fn = queue.shift(),
2105 hooks = {};
2106
2107 // If the fx queue is dequeued, always remove the progress sentinel
2108 if ( fn === "inprogress" ) {
2109 fn = queue.shift();
2110 }
2111
2112 if ( fn ) {
2113 // Add a progress sentinel to prevent the fx queue from being
2114 // automatically dequeued
2115 if ( type === "fx" ) {
2116 queue.unshift( "inprogress" );
2117 }
2118
2119 jQuery._data( elem, type + ".run", hooks );
2120 fn.call( elem, function() {
2121 jQuery.dequeue( elem, type );
2122 }, hooks );
2123 }
2124
2125 if ( !queue.length ) {
2126 jQuery.removeData( elem, type + "queue " + type + ".run", true );
2127 handleQueueMarkDefer( elem, type, "queue" );
2128 }
2129 }
2130});
2131
2132jQuery.fn.extend({
2133 queue: function( type, data ) {
2134 var setter = 2;
2135
2136 if ( typeof type !== "string" ) {
2137 data = type;
2138 type = "fx";
2139 setter--;
2140 }
2141
2142 if ( arguments.length < setter ) {
2143 return jQuery.queue( this[0], type );
2144 }
2145
2146 return data === undefined ?
2147 this :
2148 this.each(function() {
2149 var queue = jQuery.queue( this, type, data );
2150
2151 if ( type === "fx" && queue[0] !== "inprogress" ) {
2152 jQuery.dequeue( this, type );
2153 }
2154 });
2155 },
2156 dequeue: function( type ) {
2157 return this.each(function() {
2158 jQuery.dequeue( this, type );
2159 });
2160 },
2161 // Based off of the plugin by Clint Helfers, with permission.
2162 // http://blindsignals.com/index.php/2009/07/jquery-delay/
2163 delay: function( time, type ) {
2164 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
2165 type = type || "fx";
2166
2167 return this.queue( type, function( next, hooks ) {
2168 var timeout = setTimeout( next, time );
2169 hooks.stop = function() {
2170 clearTimeout( timeout );
2171 };
2172 });
2173 },
2174 clearQueue: function( type ) {
2175 return this.queue( type || "fx", [] );
2176 },
2177 // Get a promise resolved when queues of a certain type
2178 // are emptied (fx is the type by default)
2179 promise: function( type, object ) {
2180 if ( typeof type !== "string" ) {
2181 object = type;
2182 type = undefined;
2183 }
2184 type = type || "fx";
2185 var defer = jQuery.Deferred(),
2186 elements = this,
2187 i = elements.length,
2188 count = 1,
2189 deferDataKey = type + "defer",
2190 queueDataKey = type + "queue",
2191 markDataKey = type + "mark",
2192 tmp;
2193 function resolve() {
2194 if ( !( --count ) ) {
2195 defer.resolveWith( elements, [ elements ] );
2196 }
2197 }
2198 while( i-- ) {
2199 if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
2200 ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
2201 jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
2202 jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
2203 count++;
2204 tmp.add( resolve );
2205 }
2206 }
2207 resolve();
2208 return defer.promise( object );
2209 }
2210});
2211
2212
2213
2214
2215var rclass = /[\n\t\r]/g,
2216 rspace = /\s+/,
2217 rreturn = /\r/g,
2218 rtype = /^(?:button|input)$/i,
2219 rfocusable = /^(?:button|input|object|select|textarea)$/i,
2220 rclickable = /^a(?:rea)?$/i,
2221 rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
2222 getSetAttribute = jQuery.support.getSetAttribute,
2223 nodeHook, boolHook, fixSpecified;
2224
2225jQuery.fn.extend({
2226 attr: function( name, value ) {
2227 return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
2228 },
2229
2230 removeAttr: function( name ) {
2231 return this.each(function() {
2232 jQuery.removeAttr( this, name );
2233 });
2234 },
2235
2236 prop: function( name, value ) {
2237 return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
2238 },
2239
2240 removeProp: function( name ) {
2241 name = jQuery.propFix[ name ] || name;
2242 return this.each(function() {
2243 // try/catch handles cases where IE balks (such as removing a property on window)
2244 try {
2245 this[ name ] = undefined;
2246 delete this[ name ];
2247 } catch( e ) {}
2248 });
2249 },
2250
2251 addClass: function( value ) {
2252 var classNames, i, l, elem,
2253 setClass, c, cl;
2254
2255 if ( jQuery.isFunction( value ) ) {
2256 return this.each(function( j ) {
2257 jQuery( this ).addClass( value.call(this, j, this.className) );
2258 });
2259 }
2260
2261 if ( value && typeof value === "string" ) {
2262 classNames = value.split( rspace );
2263
2264 for ( i = 0, l = this.length; i < l; i++ ) {
2265 elem = this[ i ];
2266
2267 if ( elem.nodeType === 1 ) {
2268 if ( !elem.className && classNames.length === 1 ) {
2269 elem.className = value;
2270
2271 } else {
2272 setClass = " " + elem.className + " ";
2273
2274 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2275 if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
2276 setClass += classNames[ c ] + " ";
2277 }
2278 }
2279 elem.className = jQuery.trim( setClass );
2280 }
2281 }
2282 }
2283 }
2284
2285 return this;
2286 },
2287
2288 removeClass: function( value ) {
2289 var classNames, i, l, elem, className, c, cl;
2290
2291 if ( jQuery.isFunction( value ) ) {
2292 return this.each(function( j ) {
2293 jQuery( this ).removeClass( value.call(this, j, this.className) );
2294 });
2295 }
2296
2297 if ( (value && typeof value === "string") || value === undefined ) {
2298 classNames = ( value || "" ).split( rspace );
2299
2300 for ( i = 0, l = this.length; i < l; i++ ) {
2301 elem = this[ i ];
2302
2303 if ( elem.nodeType === 1 && elem.className ) {
2304 if ( value ) {
2305 className = (" " + elem.className + " ").replace( rclass, " " );
2306 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2307 className = className.replace(" " + classNames[ c ] + " ", " ");
2308 }
2309 elem.className = jQuery.trim( className );
2310
2311 } else {
2312 elem.className = "";
2313 }
2314 }
2315 }
2316 }
2317
2318 return this;
2319 },
2320
2321 toggleClass: function( value, stateVal ) {
2322 var type = typeof value,
2323 isBool = typeof stateVal === "boolean";
2324
2325 if ( jQuery.isFunction( value ) ) {
2326 return this.each(function( i ) {
2327 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2328 });
2329 }
2330
2331 return this.each(function() {
2332 if ( type === "string" ) {
2333 // toggle individual class names
2334 var className,
2335 i = 0,
2336 self = jQuery( this ),
2337 state = stateVal,
2338 classNames = value.split( rspace );
2339
2340 while ( (className = classNames[ i++ ]) ) {
2341 // check each className given, space seperated list
2342 state = isBool ? state : !self.hasClass( className );
2343 self[ state ? "addClass" : "removeClass" ]( className );
2344 }
2345
2346 } else if ( type === "undefined" || type === "boolean" ) {
2347 if ( this.className ) {
2348 // store className if set
2349 jQuery._data( this, "__className__", this.className );
2350 }
2351
2352 // toggle whole className
2353 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2354 }
2355 });
2356 },
2357
2358 hasClass: function( selector ) {
2359 var className = " " + selector + " ",
2360 i = 0,
2361 l = this.length;
2362 for ( ; i < l; i++ ) {
2363 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
2364 return true;
2365 }
2366 }
2367
2368 return false;
2369 },
2370
2371 val: function( value ) {
2372 var hooks, ret, isFunction,
2373 elem = this[0];
2374
2375 if ( !arguments.length ) {
2376 if ( elem ) {
2377 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
2378
2379 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2380 return ret;
2381 }
2382
2383 ret = elem.value;
2384
2385 return typeof ret === "string" ?
2386 // handle most common string cases
2387 ret.replace(rreturn, "") :
2388 // handle cases where value is null/undef or number
2389 ret == null ? "" : ret;
2390 }
2391
2392 return;
2393 }
2394
2395 isFunction = jQuery.isFunction( value );
2396
2397 return this.each(function( i ) {
2398 var self = jQuery(this), val;
2399
2400 if ( this.nodeType !== 1 ) {
2401 return;
2402 }
2403
2404 if ( isFunction ) {
2405 val = value.call( this, i, self.val() );
2406 } else {
2407 val = value;
2408 }
2409
2410 // Treat null/undefined as ""; convert numbers to string
2411 if ( val == null ) {
2412 val = "";
2413 } else if ( typeof val === "number" ) {
2414 val += "";
2415 } else if ( jQuery.isArray( val ) ) {
2416 val = jQuery.map(val, function ( value ) {
2417 return value == null ? "" : value + "";
2418 });
2419 }
2420
2421 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
2422
2423 // If set returns undefined, fall back to normal setting
2424 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
2425 this.value = val;
2426 }
2427 });
2428 }
2429});
2430
2431jQuery.extend({
2432 valHooks: {
2433 option: {
2434 get: function( elem ) {
2435 // attributes.value is undefined in Blackberry 4.7 but
2436 // uses .value. See #6932
2437 var val = elem.attributes.value;
2438 return !val || val.specified ? elem.value : elem.text;
2439 }
2440 },
2441 select: {
2442 get: function( elem ) {
2443 var value, i, max, option,
2444 index = elem.selectedIndex,
2445 values = [],
2446 options = elem.options,
2447 one = elem.type === "select-one";
2448
2449 // Nothing was selected
2450 if ( index < 0 ) {
2451 return null;
2452 }
2453
2454 // Loop through all the selected options
2455 i = one ? index : 0;
2456 max = one ? index + 1 : options.length;
2457 for ( ; i < max; i++ ) {
2458 option = options[ i ];
2459
2460 // Don't return options that are disabled or in a disabled optgroup
2461 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2462 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
2463
2464 // Get the specific value for the option
2465 value = jQuery( option ).val();
2466
2467 // We don't need an array for one selects
2468 if ( one ) {
2469 return value;
2470 }
2471
2472 // Multi-Selects return an array
2473 values.push( value );
2474 }
2475 }
2476
2477 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2478 if ( one && !values.length && options.length ) {
2479 return jQuery( options[ index ] ).val();
2480 }
2481
2482 return values;
2483 },
2484
2485 set: function( elem, value ) {
2486 var values = jQuery.makeArray( value );
2487
2488 jQuery(elem).find("option").each(function() {
2489 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2490 });
2491
2492 if ( !values.length ) {
2493 elem.selectedIndex = -1;
2494 }
2495 return values;
2496 }
2497 }
2498 },
2499
2500 attrFn: {
2501 val: true,
2502 css: true,
2503 html: true,
2504 text: true,
2505 data: true,
2506 width: true,
2507 height: true,
2508 offset: true
2509 },
2510
2511 attr: function( elem, name, value, pass ) {
2512 var ret, hooks, notxml,
2513 nType = elem.nodeType;
2514
2515 // don't get/set attributes on text, comment and attribute nodes
2516 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2517 return;
2518 }
2519
2520 if ( pass && name in jQuery.attrFn ) {
2521 return jQuery( elem )[ name ]( value );
2522 }
2523
2524 // Fallback to prop when attributes are not supported
2525 if ( typeof elem.getAttribute === "undefined" ) {
2526 return jQuery.prop( elem, name, value );
2527 }
2528
2529 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2530
2531 // All attributes are lowercase
2532 // Grab necessary hook if one is defined
2533 if ( notxml ) {
2534 name = name.toLowerCase();
2535 hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
2536 }
2537
2538 if ( value !== undefined ) {
2539
2540 if ( value === null ) {
2541 jQuery.removeAttr( elem, name );
2542 return;
2543
2544 } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
2545 return ret;
2546
2547 } else {
2548 elem.setAttribute( name, "" + value );
2549 return value;
2550 }
2551
2552 } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
2553 return ret;
2554
2555 } else {
2556
2557 ret = elem.getAttribute( name );
2558
2559 // Non-existent attributes return null, we normalize to undefined
2560 return ret === null ?
2561 undefined :
2562 ret;
2563 }
2564 },
2565
2566 removeAttr: function( elem, value ) {
2567 var propName, attrNames, name, l, isBool,
2568 i = 0;
2569
2570 if ( value && elem.nodeType === 1 ) {
2571 attrNames = value.toLowerCase().split( rspace );
2572 l = attrNames.length;
2573
2574 for ( ; i < l; i++ ) {
2575 name = attrNames[ i ];
2576
2577 if ( name ) {
2578 propName = jQuery.propFix[ name ] || name;
2579 isBool = rboolean.test( name );
2580
2581 // See #9699 for explanation of this approach (setting first, then removal)
2582 // Do not do this for boolean attributes (see #10870)
2583 if ( !isBool ) {
2584 jQuery.attr( elem, name, "" );
2585 }
2586 elem.removeAttribute( getSetAttribute ? name : propName );
2587
2588 // Set corresponding property to false for boolean attributes
2589 if ( isBool && propName in elem ) {
2590 elem[ propName ] = false;
2591 }
2592 }
2593 }
2594 }
2595 },
2596
2597 attrHooks: {
2598 type: {
2599 set: function( elem, value ) {
2600 // We can't allow the type property to be changed (since it causes problems in IE)
2601 if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
2602 jQuery.error( "type property can't be changed" );
2603 } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2604 // Setting the type on a radio button after the value resets the value in IE6-9
2605 // Reset value to it's default in case type is set after value
2606 // This is for element creation
2607 var val = elem.value;
2608 elem.setAttribute( "type", value );
2609 if ( val ) {
2610 elem.value = val;
2611 }
2612 return value;
2613 }
2614 }
2615 },
2616 // Use the value property for back compat
2617 // Use the nodeHook for button elements in IE6/7 (#1954)
2618 value: {
2619 get: function( elem, name ) {
2620 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2621 return nodeHook.get( elem, name );
2622 }
2623 return name in elem ?
2624 elem.value :
2625 null;
2626 },
2627 set: function( elem, value, name ) {
2628 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2629 return nodeHook.set( elem, value, name );
2630 }
2631 // Does not return so that setAttribute is also used
2632 elem.value = value;
2633 }
2634 }
2635 },
2636
2637 propFix: {
2638 tabindex: "tabIndex",
2639 readonly: "readOnly",
2640 "for": "htmlFor",
2641 "class": "className",
2642 maxlength: "maxLength",
2643 cellspacing: "cellSpacing",
2644 cellpadding: "cellPadding",
2645 rowspan: "rowSpan",
2646 colspan: "colSpan",
2647 usemap: "useMap",
2648 frameborder: "frameBorder",
2649 contenteditable: "contentEditable"
2650 },
2651
2652 prop: function( elem, name, value ) {
2653 var ret, hooks, notxml,
2654 nType = elem.nodeType;
2655
2656 // don't get/set properties on text, comment and attribute nodes
2657 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2658 return;
2659 }
2660
2661 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2662
2663 if ( notxml ) {
2664 // Fix name and attach hooks
2665 name = jQuery.propFix[ name ] || name;
2666 hooks = jQuery.propHooks[ name ];
2667 }
2668
2669 if ( value !== undefined ) {
2670 if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2671 return ret;
2672
2673 } else {
2674 return ( elem[ name ] = value );
2675 }
2676
2677 } else {
2678 if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2679 return ret;
2680
2681 } else {
2682 return elem[ name ];
2683 }
2684 }
2685 },
2686
2687 propHooks: {
2688 tabIndex: {
2689 get: function( elem ) {
2690 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2691 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2692 var attributeNode = elem.getAttributeNode("tabindex");
2693
2694 return attributeNode && attributeNode.specified ?
2695 parseInt( attributeNode.value, 10 ) :
2696 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2697 0 :
2698 undefined;
2699 }
2700 }
2701 }
2702});
2703
2704// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)
2705jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex;
2706
2707// Hook for boolean attributes
2708boolHook = {
2709 get: function( elem, name ) {
2710 // Align boolean attributes with corresponding properties
2711 // Fall back to attribute presence where some booleans are not supported
2712 var attrNode,
2713 property = jQuery.prop( elem, name );
2714 return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
2715 name.toLowerCase() :
2716 undefined;
2717 },
2718 set: function( elem, value, name ) {
2719 var propName;
2720 if ( value === false ) {
2721 // Remove boolean attributes when set to false
2722 jQuery.removeAttr( elem, name );
2723 } else {
2724 // value is true since we know at this point it's type boolean and not false
2725 // Set boolean attributes to the same name and set the DOM property
2726 propName = jQuery.propFix[ name ] || name;
2727 if ( propName in elem ) {
2728 // Only set the IDL specifically if it already exists on the element
2729 elem[ propName ] = true;
2730 }
2731
2732 elem.setAttribute( name, name.toLowerCase() );
2733 }
2734 return name;
2735 }
2736};
2737
2738// IE6/7 do not support getting/setting some attributes with get/setAttribute
2739if ( !getSetAttribute ) {
2740
2741 fixSpecified = {
2742 name: true,
2743 id: true,
2744 coords: true
2745 };
2746
2747 // Use this for any attribute in IE6/7
2748 // This fixes almost every IE6/7 issue
2749 nodeHook = jQuery.valHooks.button = {
2750 get: function( elem, name ) {
2751 var ret;
2752 ret = elem.getAttributeNode( name );
2753 return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ?
2754 ret.nodeValue :
2755 undefined;
2756 },
2757 set: function( elem, value, name ) {
2758 // Set the existing or create a new attribute node
2759 var ret = elem.getAttributeNode( name );
2760 if ( !ret ) {
2761 ret = document.createAttribute( name );
2762 elem.setAttributeNode( ret );
2763 }
2764 return ( ret.nodeValue = value + "" );
2765 }
2766 };
2767
2768 // Apply the nodeHook to tabindex
2769 jQuery.attrHooks.tabindex.set = nodeHook.set;
2770
2771 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2772 // This is for removals
2773 jQuery.each([ "width", "height" ], function( i, name ) {
2774 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2775 set: function( elem, value ) {
2776 if ( value === "" ) {
2777 elem.setAttribute( name, "auto" );
2778 return value;
2779 }
2780 }
2781 });
2782 });
2783
2784 // Set contenteditable to false on removals(#10429)
2785 // Setting to empty string throws an error as an invalid value
2786 jQuery.attrHooks.contenteditable = {
2787 get: nodeHook.get,
2788 set: function( elem, value, name ) {
2789 if ( value === "" ) {
2790 value = "false";
2791 }
2792 nodeHook.set( elem, value, name );
2793 }
2794 };
2795}
2796
2797
2798// Some attributes require a special call on IE
2799if ( !jQuery.support.hrefNormalized ) {
2800 jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2801 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2802 get: function( elem ) {
2803 var ret = elem.getAttribute( name, 2 );
2804 return ret === null ? undefined : ret;
2805 }
2806 });
2807 });
2808}
2809
2810if ( !jQuery.support.style ) {
2811 jQuery.attrHooks.style = {
2812 get: function( elem ) {
2813 // Return undefined in the case of empty string
2814 // Normalize to lowercase since IE uppercases css property names
2815 return elem.style.cssText.toLowerCase() || undefined;
2816 },
2817 set: function( elem, value ) {
2818 return ( elem.style.cssText = "" + value );
2819 }
2820 };
2821}
2822
2823// Safari mis-reports the default selected property of an option
2824// Accessing the parent's selectedIndex property fixes it
2825if ( !jQuery.support.optSelected ) {
2826 jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2827 get: function( elem ) {
2828 var parent = elem.parentNode;
2829
2830 if ( parent ) {
2831 parent.selectedIndex;
2832
2833 // Make sure that it also works with optgroups, see #5701
2834 if ( parent.parentNode ) {
2835 parent.parentNode.selectedIndex;
2836 }
2837 }
2838 return null;
2839 }
2840 });
2841}
2842
2843// IE6/7 call enctype encoding
2844if ( !jQuery.support.enctype ) {
2845 jQuery.propFix.enctype = "encoding";
2846}
2847
2848// Radios and checkboxes getter/setter
2849if ( !jQuery.support.checkOn ) {
2850 jQuery.each([ "radio", "checkbox" ], function() {
2851 jQuery.valHooks[ this ] = {
2852 get: function( elem ) {
2853 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2854 return elem.getAttribute("value") === null ? "on" : elem.value;
2855 }
2856 };
2857 });
2858}
2859jQuery.each([ "radio", "checkbox" ], function() {
2860 jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2861 set: function( elem, value ) {
2862 if ( jQuery.isArray( value ) ) {
2863 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
2864 }
2865 }
2866 });
2867});
2868
2869
2870
2871
2872var rformElems = /^(?:textarea|input|select)$/i,
2873 rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
2874 rhoverHack = /(?:^|\s)hover(\.\S+)?\b/,
2875 rkeyEvent = /^key/,
2876 rmouseEvent = /^(?:mouse|contextmenu)|click/,
2877 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
2878 rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
2879 quickParse = function( selector ) {
2880 var quick = rquickIs.exec( selector );
2881 if ( quick ) {
2882 // 0 1 2 3
2883 // [ _, tag, id, class ]
2884 quick[1] = ( quick[1] || "" ).toLowerCase();
2885 quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" );
2886 }
2887 return quick;
2888 },
2889 quickIs = function( elem, m ) {
2890 var attrs = elem.attributes || {};
2891 return (
2892 (!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
2893 (!m[2] || (attrs.id || {}).value === m[2]) &&
2894 (!m[3] || m[3].test( (attrs[ "class" ] || {}).value ))
2895 );
2896 },
2897 hoverHack = function( events ) {
2898 return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
2899 };
2900
2901/*
2902 * Helper functions for managing events -- not part of the public interface.
2903 * Props to Dean Edwards' addEvent library for many of the ideas.
2904 */
2905jQuery.event = {
2906
2907 add: function( elem, types, handler, data, selector ) {
2908
2909 var elemData, eventHandle, events,
2910 t, tns, type, namespaces, handleObj,
2911 handleObjIn, quick, handlers, special;
2912
2913 // Don't attach events to noData or text/comment nodes (allow plain objects tho)
2914 if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
2915 return;
2916 }
2917
2918 // Caller can pass in an object of custom data in lieu of the handler
2919 if ( handler.handler ) {
2920 handleObjIn = handler;
2921 handler = handleObjIn.handler;
2922 selector = handleObjIn.selector;
2923 }
2924
2925 // Make sure that the handler has a unique ID, used to find/remove it later
2926 if ( !handler.guid ) {
2927 handler.guid = jQuery.guid++;
2928 }
2929
2930 // Init the element's event structure and main handler, if this is the first
2931 events = elemData.events;
2932 if ( !events ) {
2933 elemData.events = events = {};
2934 }
2935 eventHandle = elemData.handle;
2936 if ( !eventHandle ) {
2937 elemData.handle = eventHandle = function( e ) {
2938 // Discard the second event of a jQuery.event.trigger() and
2939 // when an event is called after a page has unloaded
2940 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2941 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
2942 undefined;
2943 };
2944 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2945 eventHandle.elem = elem;
2946 }
2947
2948 // Handle multiple events separated by a space
2949 // jQuery(...).bind("mouseover mouseout", fn);
2950 types = jQuery.trim( hoverHack(types) ).split( " " );
2951 for ( t = 0; t < types.length; t++ ) {
2952
2953 tns = rtypenamespace.exec( types[t] ) || [];
2954 type = tns[1];
2955 namespaces = ( tns[2] || "" ).split( "." ).sort();
2956
2957 // If event changes its type, use the special event handlers for the changed type
2958 special = jQuery.event.special[ type ] || {};
2959
2960 // If selector defined, determine special event api type, otherwise given type
2961 type = ( selector ? special.delegateType : special.bindType ) || type;
2962
2963 // Update special based on newly reset type
2964 special = jQuery.event.special[ type ] || {};
2965
2966 // handleObj is passed to all event handlers
2967 handleObj = jQuery.extend({
2968 type: type,
2969 origType: tns[1],
2970 data: data,
2971 handler: handler,
2972 guid: handler.guid,
2973 selector: selector,
2974 quick: selector && quickParse( selector ),
2975 namespace: namespaces.join(".")
2976 }, handleObjIn );
2977
2978 // Init the event handler queue if we're the first
2979 handlers = events[ type ];
2980 if ( !handlers ) {
2981 handlers = events[ type ] = [];
2982 handlers.delegateCount = 0;
2983
2984 // Only use addEventListener/attachEvent if the special events handler returns false
2985 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2986 // Bind the global event handler to the element
2987 if ( elem.addEventListener ) {
2988 elem.addEventListener( type, eventHandle, false );
2989
2990 } else if ( elem.attachEvent ) {
2991 elem.attachEvent( "on" + type, eventHandle );
2992 }
2993 }
2994 }
2995
2996 if ( special.add ) {
2997 special.add.call( elem, handleObj );
2998
2999 if ( !handleObj.handler.guid ) {
3000 handleObj.handler.guid = handler.guid;
3001 }
3002 }
3003
3004 // Add to the element's handler list, delegates in front
3005 if ( selector ) {
3006 handlers.splice( handlers.delegateCount++, 0, handleObj );
3007 } else {
3008 handlers.push( handleObj );
3009 }
3010
3011 // Keep track of which events have ever been used, for event optimization
3012 jQuery.event.global[ type ] = true;
3013 }
3014
3015 // Nullify elem to prevent memory leaks in IE
3016 elem = null;
3017 },
3018
3019 global: {},
3020
3021 // Detach an event or set of events from an element
3022 remove: function( elem, types, handler, selector, mappedTypes ) {
3023
3024 var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
3025 t, tns, type, origType, namespaces, origCount,
3026 j, events, special, handle, eventType, handleObj;
3027
3028 if ( !elemData || !(events = elemData.events) ) {
3029 return;
3030 }
3031
3032 // Once for each type.namespace in types; type may be omitted
3033 types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
3034 for ( t = 0; t < types.length; t++ ) {
3035 tns = rtypenamespace.exec( types[t] ) || [];
3036 type = origType = tns[1];
3037 namespaces = tns[2];
3038
3039 // Unbind all events (on this namespace, if provided) for the element
3040 if ( !type ) {
3041 for ( type in events ) {
3042 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
3043 }
3044 continue;
3045 }
3046
3047 special = jQuery.event.special[ type ] || {};
3048 type = ( selector? special.delegateType : special.bindType ) || type;
3049 eventType = events[ type ] || [];
3050 origCount = eventType.length;
3051 namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
3052
3053 // Remove matching events
3054 for ( j = 0; j < eventType.length; j++ ) {
3055 handleObj = eventType[ j ];
3056
3057 if ( ( mappedTypes || origType === handleObj.origType ) &&
3058 ( !handler || handler.guid === handleObj.guid ) &&
3059 ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
3060 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
3061 eventType.splice( j--, 1 );
3062
3063 if ( handleObj.selector ) {
3064 eventType.delegateCount--;
3065 }
3066 if ( special.remove ) {
3067 special.remove.call( elem, handleObj );
3068 }
3069 }
3070 }
3071
3072 // Remove generic event handler if we removed something and no more handlers exist
3073 // (avoids potential for endless recursion during removal of special event handlers)
3074 if ( eventType.length === 0 && origCount !== eventType.length ) {
3075 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
3076 jQuery.removeEvent( elem, type, elemData.handle );
3077 }
3078
3079 delete events[ type ];
3080 }
3081 }
3082
3083 // Remove the expando if it's no longer used
3084 if ( jQuery.isEmptyObject( events ) ) {
3085 handle = elemData.handle;
3086 if ( handle ) {
3087 handle.elem = null;
3088 }
3089
3090 // removeData also checks for emptiness and clears the expando if empty
3091 // so use it instead of delete
3092 jQuery.removeData( elem, [ "events", "handle" ], true );
3093 }
3094 },
3095
3096 // Events that are safe to short-circuit if no handlers are attached.
3097 // Native DOM events should not be added, they may have inline handlers.
3098 customEvent: {
3099 "getData": true,
3100 "setData": true,
3101 "changeData": true
3102 },
3103
3104 trigger: function( event, data, elem, onlyHandlers ) {
3105 // Don't do events on text and comment nodes
3106 if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
3107 return;
3108 }
3109
3110 // Event object or event type
3111 var type = event.type || event,
3112 namespaces = [],
3113 cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType;
3114
3115 // focus/blur morphs to focusin/out; ensure we're not firing them right now
3116 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
3117 return;
3118 }
3119
3120 if ( type.indexOf( "!" ) >= 0 ) {
3121 // Exclusive events trigger only for the exact event (no namespaces)
3122 type = type.slice(0, -1);
3123 exclusive = true;
3124 }
3125
3126 if ( type.indexOf( "." ) >= 0 ) {
3127 // Namespaced trigger; create a regexp to match event type in handle()
3128 namespaces = type.split(".");
3129 type = namespaces.shift();
3130 namespaces.sort();
3131 }
3132
3133 if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
3134 // No jQuery handlers for this event type, and it can't have inline handlers
3135 return;
3136 }
3137
3138 // Caller can pass in an Event, Object, or just an event type string
3139 event = typeof event === "object" ?
3140 // jQuery.Event object
3141 event[ jQuery.expando ] ? event :
3142 // Object literal
3143 new jQuery.Event( type, event ) :
3144 // Just the event type (string)
3145 new jQuery.Event( type );
3146
3147 event.type = type;
3148 event.isTrigger = true;
3149 event.exclusive = exclusive;
3150 event.namespace = namespaces.join( "." );
3151 event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
3152 ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
3153
3154 // Handle a global trigger
3155 if ( !elem ) {
3156
3157 // TODO: Stop taunting the data cache; remove global events and always attach to document
3158 cache = jQuery.cache;
3159 for ( i in cache ) {
3160 if ( cache[ i ].events && cache[ i ].events[ type ] ) {
3161 jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
3162 }
3163 }
3164 return;
3165 }
3166
3167 // Clean up the event in case it is being reused
3168 event.result = undefined;
3169 if ( !event.target ) {
3170 event.target = elem;
3171 }
3172
3173 // Clone any incoming data and prepend the event, creating the handler arg list
3174 data = data != null ? jQuery.makeArray( data ) : [];
3175 data.unshift( event );
3176
3177 // Allow special events to draw outside the lines
3178 special = jQuery.event.special[ type ] || {};
3179 if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
3180 return;
3181 }
3182
3183 // Determine event propagation path in advance, per W3C events spec (#9951)
3184 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
3185 eventPath = [[ elem, special.bindType || type ]];
3186 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
3187
3188 bubbleType = special.delegateType || type;
3189 cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
3190 old = null;
3191 for ( ; cur; cur = cur.parentNode ) {
3192 eventPath.push([ cur, bubbleType ]);
3193 old = cur;
3194 }
3195
3196 // Only add window if we got to document (e.g., not plain obj or detached DOM)
3197 if ( old && old === elem.ownerDocument ) {
3198 eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
3199 }
3200 }
3201
3202 // Fire handlers on the event path
3203 for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
3204
3205 cur = eventPath[i][0];
3206 event.type = eventPath[i][1];
3207
3208 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
3209 if ( handle ) {
3210 handle.apply( cur, data );
3211 }
3212 // Note that this is a bare JS function and not a jQuery handler
3213 handle = ontype && cur[ ontype ];
3214 if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
3215 event.preventDefault();
3216 }
3217 }
3218 event.type = type;
3219
3220 // If nobody prevented the default action, do it now
3221 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
3222
3223 if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
3224 !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
3225
3226 // Call a native DOM method on the target with the same name name as the event.
3227 // Can't use an .isFunction() check here because IE6/7 fails that test.
3228 // Don't do default actions on window, that's where global variables be (#6170)
3229 // IE<9 dies on focus/blur to hidden element (#1486)
3230 if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
3231
3232 // Don't re-trigger an onFOO event when we call its FOO() method
3233 old = elem[ ontype ];
3234
3235 if ( old ) {
3236 elem[ ontype ] = null;
3237 }
3238
3239 // Prevent re-triggering of the same event, since we already bubbled it above
3240 jQuery.event.triggered = type;
3241 elem[ type ]();
3242 jQuery.event.triggered = undefined;
3243
3244 if ( old ) {
3245 elem[ ontype ] = old;
3246 }
3247 }
3248 }
3249 }
3250
3251 return event.result;
3252 },
3253
3254 dispatch: function( event ) {
3255
3256 // Make a writable jQuery.Event from the native event object
3257 event = jQuery.event.fix( event || window.event );
3258
3259 var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
3260 delegateCount = handlers.delegateCount,
3261 args = [].slice.call( arguments, 0 ),
3262 run_all = !event.exclusive && !event.namespace,
3263 special = jQuery.event.special[ event.type ] || {},
3264 handlerQueue = [],
3265 i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related;
3266
3267 // Use the fix-ed jQuery.Event rather than the (read-only) native event
3268 args[0] = event;
3269 event.delegateTarget = this;
3270
3271 // Call the preDispatch hook for the mapped type, and let it bail if desired
3272 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
3273 return;
3274 }
3275
3276 // Determine handlers that should run if there are delegated events
3277 // Avoid non-left-click bubbling in Firefox (#3861)
3278 if ( delegateCount && !(event.button && event.type === "click") ) {
3279
3280 // Pregenerate a single jQuery object for reuse with .is()
3281 jqcur = jQuery(this);
3282 jqcur.context = this.ownerDocument || this;
3283
3284 for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
3285
3286 // Don't process events on disabled elements (#6911, #8165)
3287 if ( cur.disabled !== true ) {
3288 selMatch = {};
3289 matches = [];
3290 jqcur[0] = cur;
3291 for ( i = 0; i < delegateCount; i++ ) {
3292 handleObj = handlers[ i ];
3293 sel = handleObj.selector;
3294
3295 if ( selMatch[ sel ] === undefined ) {
3296 selMatch[ sel ] = (
3297 handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel )
3298 );
3299 }
3300 if ( selMatch[ sel ] ) {
3301 matches.push( handleObj );
3302 }
3303 }
3304 if ( matches.length ) {
3305 handlerQueue.push({ elem: cur, matches: matches });
3306 }
3307 }
3308 }
3309 }
3310
3311 // Add the remaining (directly-bound) handlers
3312 if ( handlers.length > delegateCount ) {
3313 handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
3314 }
3315
3316 // Run delegates first; they may want to stop propagation beneath us
3317 for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
3318 matched = handlerQueue[ i ];
3319 event.currentTarget = matched.elem;
3320
3321 for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
3322 handleObj = matched.matches[ j ];
3323
3324 // Triggered event must either 1) be non-exclusive and have no namespace, or
3325 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3326 if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
3327
3328 event.data = handleObj.data;
3329 event.handleObj = handleObj;
3330
3331 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
3332 .apply( matched.elem, args );
3333
3334 if ( ret !== undefined ) {
3335 event.result = ret;
3336 if ( ret === false ) {
3337 event.preventDefault();
3338 event.stopPropagation();
3339 }
3340 }
3341 }
3342 }
3343 }
3344
3345 // Call the postDispatch hook for the mapped type
3346 if ( special.postDispatch ) {
3347 special.postDispatch.call( this, event );
3348 }
3349
3350 return event.result;
3351 },
3352
3353 // Includes some event props shared by KeyEvent and MouseEvent
3354 // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
3355 props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3356
3357 fixHooks: {},
3358
3359 keyHooks: {
3360 props: "char charCode key keyCode".split(" "),
3361 filter: function( event, original ) {
3362
3363 // Add which for key events
3364 if ( event.which == null ) {
3365 event.which = original.charCode != null ? original.charCode : original.keyCode;
3366 }
3367
3368 return event;
3369 }
3370 },
3371
3372 mouseHooks: {
3373 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3374 filter: function( event, original ) {
3375 var eventDoc, doc, body,
3376 button = original.button,
3377 fromElement = original.fromElement;
3378
3379 // Calculate pageX/Y if missing and clientX/Y available
3380 if ( event.pageX == null && original.clientX != null ) {
3381 eventDoc = event.target.ownerDocument || document;
3382 doc = eventDoc.documentElement;
3383 body = eventDoc.body;
3384
3385 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
3386 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
3387 }
3388
3389 // Add relatedTarget, if necessary
3390 if ( !event.relatedTarget && fromElement ) {
3391 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
3392 }
3393
3394 // Add which for click: 1 === left; 2 === middle; 3 === right
3395 // Note: button is not normalized, so don't use it
3396 if ( !event.which && button !== undefined ) {
3397 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
3398 }
3399
3400 return event;
3401 }
3402 },
3403
3404 fix: function( event ) {
3405 if ( event[ jQuery.expando ] ) {
3406 return event;
3407 }
3408
3409 // Create a writable copy of the event object and normalize some properties
3410 var i, prop,
3411 originalEvent = event,
3412 fixHook = jQuery.event.fixHooks[ event.type ] || {},
3413 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
3414
3415 event = jQuery.Event( originalEvent );
3416
3417 for ( i = copy.length; i; ) {
3418 prop = copy[ --i ];
3419 event[ prop ] = originalEvent[ prop ];
3420 }
3421
3422 // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
3423 if ( !event.target ) {
3424 event.target = originalEvent.srcElement || document;
3425 }
3426
3427 // Target should not be a text node (#504, Safari)
3428 if ( event.target.nodeType === 3 ) {
3429 event.target = event.target.parentNode;
3430 }
3431
3432 // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8)
3433 if ( event.metaKey === undefined ) {
3434 event.metaKey = event.ctrlKey;
3435 }
3436
3437 return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
3438 },
3439
3440 special: {
3441 ready: {
3442 // Make sure the ready event is setup
3443 setup: jQuery.bindReady
3444 },
3445
3446 load: {
3447 // Prevent triggered image.load events from bubbling to window.load
3448 noBubble: true
3449 },
3450
3451 focus: {
3452 delegateType: "focusin"
3453 },
3454 blur: {
3455 delegateType: "focusout"
3456 },
3457
3458 beforeunload: {
3459 setup: function( data, namespaces, eventHandle ) {
3460 // We only want to do this special case on windows
3461 if ( jQuery.isWindow( this ) ) {
3462 this.onbeforeunload = eventHandle;
3463 }
3464 },
3465
3466 teardown: function( namespaces, eventHandle ) {
3467 if ( this.onbeforeunload === eventHandle ) {
3468 this.onbeforeunload = null;
3469 }
3470 }
3471 }
3472 },
3473
3474 simulate: function( type, elem, event, bubble ) {
3475 // Piggyback on a donor event to simulate a different one.
3476 // Fake originalEvent to avoid donor's stopPropagation, but if the
3477 // simulated event prevents default then we do the same on the donor.
3478 var e = jQuery.extend(
3479 new jQuery.Event(),
3480 event,
3481 { type: type,
3482 isSimulated: true,
3483 originalEvent: {}
3484 }
3485 );
3486 if ( bubble ) {
3487 jQuery.event.trigger( e, null, elem );
3488 } else {
3489 jQuery.event.dispatch.call( elem, e );
3490 }
3491 if ( e.isDefaultPrevented() ) {
3492 event.preventDefault();
3493 }
3494 }
3495};
3496
3497// Some plugins are using, but it's undocumented/deprecated and will be removed.
3498// The 1.7 special event interface should provide all the hooks needed now.
3499jQuery.event.handle = jQuery.event.dispatch;
3500
3501jQuery.removeEvent = document.removeEventListener ?
3502 function( elem, type, handle ) {
3503 if ( elem.removeEventListener ) {
3504 elem.removeEventListener( type, handle, false );
3505 }
3506 } :
3507 function( elem, type, handle ) {
3508 if ( elem.detachEvent ) {
3509 elem.detachEvent( "on" + type, handle );
3510 }
3511 };
3512
3513jQuery.Event = function( src, props ) {
3514 // Allow instantiation without the 'new' keyword
3515 if ( !(this instanceof jQuery.Event) ) {
3516 return new jQuery.Event( src, props );
3517 }
3518
3519 // Event object
3520 if ( src && src.type ) {
3521 this.originalEvent = src;
3522 this.type = src.type;
3523
3524 // Events bubbling up the document may have been marked as prevented
3525 // by a handler lower down the tree; reflect the correct value.
3526 this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
3527 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
3528
3529 // Event type
3530 } else {
3531 this.type = src;
3532 }
3533
3534 // Put explicitly provided properties onto the event object
3535 if ( props ) {
3536 jQuery.extend( this, props );
3537 }
3538
3539 // Create a timestamp if incoming event doesn't have one
3540 this.timeStamp = src && src.timeStamp || jQuery.now();
3541
3542 // Mark it as fixed
3543 this[ jQuery.expando ] = true;
3544};
3545
3546function returnFalse() {
3547 return false;
3548}
3549function returnTrue() {
3550 return true;
3551}
3552
3553// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3554// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3555jQuery.Event.prototype = {
3556 preventDefault: function() {
3557 this.isDefaultPrevented = returnTrue;
3558
3559 var e = this.originalEvent;
3560 if ( !e ) {
3561 return;
3562 }
3563
3564 // if preventDefault exists run it on the original event
3565 if ( e.preventDefault ) {
3566 e.preventDefault();
3567
3568 // otherwise set the returnValue property of the original event to false (IE)
3569 } else {
3570 e.returnValue = false;
3571 }
3572 },
3573 stopPropagation: function() {
3574 this.isPropagationStopped = returnTrue;
3575
3576 var e = this.originalEvent;
3577 if ( !e ) {
3578 return;
3579 }
3580 // if stopPropagation exists run it on the original event
3581 if ( e.stopPropagation ) {
3582 e.stopPropagation();
3583 }
3584 // otherwise set the cancelBubble property of the original event to true (IE)
3585 e.cancelBubble = true;
3586 },
3587 stopImmediatePropagation: function() {
3588 this.isImmediatePropagationStopped = returnTrue;
3589 this.stopPropagation();
3590 },
3591 isDefaultPrevented: returnFalse,
3592 isPropagationStopped: returnFalse,
3593 isImmediatePropagationStopped: returnFalse
3594};
3595
3596// Create mouseenter/leave events using mouseover/out and event-time checks
3597jQuery.each({
3598 mouseenter: "mouseover",
3599 mouseleave: "mouseout"
3600}, function( orig, fix ) {
3601 jQuery.event.special[ orig ] = {
3602 delegateType: fix,
3603 bindType: fix,
3604
3605 handle: function( event ) {
3606 var target = this,
3607 related = event.relatedTarget,
3608 handleObj = event.handleObj,
3609 selector = handleObj.selector,
3610 ret;
3611
3612 // For mousenter/leave call the handler if related is outside the target.
3613 // NB: No relatedTarget if the mouse left/entered the browser window
3614 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
3615 event.type = handleObj.origType;
3616 ret = handleObj.handler.apply( this, arguments );
3617 event.type = fix;
3618 }
3619 return ret;
3620 }
3621 };
3622});
3623
3624// IE submit delegation
3625if ( !jQuery.support.submitBubbles ) {
3626
3627 jQuery.event.special.submit = {
3628 setup: function() {
3629 // Only need this for delegated form submit events
3630 if ( jQuery.nodeName( this, "form" ) ) {
3631 return false;
3632 }
3633
3634 // Lazy-add a submit handler when a descendant form may potentially be submitted
3635 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
3636 // Node name check avoids a VML-related crash in IE (#9807)
3637 var elem = e.target,
3638 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
3639 if ( form && !form._submit_attached ) {
3640 jQuery.event.add( form, "submit._submit", function( event ) {
3641 event._submit_bubble = true;
3642 });
3643 form._submit_attached = true;
3644 }
3645 });
3646 // return undefined since we don't need an event listener
3647 },
3648
3649 postDispatch: function( event ) {
3650 // If form was submitted by the user, bubble the event up the tree
3651 if ( event._submit_bubble ) {
3652 delete event._submit_bubble;
3653 if ( this.parentNode && !event.isTrigger ) {
3654 jQuery.event.simulate( "submit", this.parentNode, event, true );
3655 }
3656 }
3657 },
3658
3659 teardown: function() {
3660 // Only need this for delegated form submit events
3661 if ( jQuery.nodeName( this, "form" ) ) {
3662 return false;
3663 }
3664
3665 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3666 jQuery.event.remove( this, "._submit" );
3667 }
3668 };
3669}
3670
3671// IE change delegation and checkbox/radio fix
3672if ( !jQuery.support.changeBubbles ) {
3673
3674 jQuery.event.special.change = {
3675
3676 setup: function() {
3677
3678 if ( rformElems.test( this.nodeName ) ) {
3679 // IE doesn't fire change on a check/radio until blur; trigger it on click
3680 // after a propertychange. Eat the blur-change in special.change.handle.
3681 // This still fires onchange a second time for check/radio after blur.
3682 if ( this.type === "checkbox" || this.type === "radio" ) {
3683 jQuery.event.add( this, "propertychange._change", function( event ) {
3684 if ( event.originalEvent.propertyName === "checked" ) {
3685 this._just_changed = true;
3686 }
3687 });
3688 jQuery.event.add( this, "click._change", function( event ) {
3689 if ( this._just_changed && !event.isTrigger ) {
3690 this._just_changed = false;
3691 jQuery.event.simulate( "change", this, event, true );
3692 }
3693 });
3694 }
3695 return false;
3696 }
3697 // Delegated event; lazy-add a change handler on descendant inputs
3698 jQuery.event.add( this, "beforeactivate._change", function( e ) {
3699 var elem = e.target;
3700
3701 if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {
3702 jQuery.event.add( elem, "change._change", function( event ) {
3703 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
3704 jQuery.event.simulate( "change", this.parentNode, event, true );
3705 }
3706 });
3707 elem._change_attached = true;
3708 }
3709 });
3710 },
3711
3712 handle: function( event ) {
3713 var elem = event.target;
3714
3715 // Swallow native change events from checkbox/radio, we already triggered them above
3716 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
3717 return event.handleObj.handler.apply( this, arguments );
3718 }
3719 },
3720
3721 teardown: function() {
3722 jQuery.event.remove( this, "._change" );
3723
3724 return rformElems.test( this.nodeName );
3725 }
3726 };
3727}
3728
3729// Create "bubbling" focus and blur events
3730if ( !jQuery.support.focusinBubbles ) {
3731 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3732
3733 // Attach a single capturing handler while someone wants focusin/focusout
3734 var attaches = 0,
3735 handler = function( event ) {
3736 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
3737 };
3738
3739 jQuery.event.special[ fix ] = {
3740 setup: function() {
3741 if ( attaches++ === 0 ) {
3742 document.addEventListener( orig, handler, true );
3743 }
3744 },
3745 teardown: function() {
3746 if ( --attaches === 0 ) {
3747 document.removeEventListener( orig, handler, true );
3748 }
3749 }
3750 };
3751 });
3752}
3753
3754jQuery.fn.extend({
3755
3756 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
3757 var origFn, type;
3758
3759 // Types can be a map of types/handlers
3760 if ( typeof types === "object" ) {
3761 // ( types-Object, selector, data )
3762 if ( typeof selector !== "string" ) { // && selector != null
3763 // ( types-Object, data )
3764 data = data || selector;
3765 selector = undefined;
3766 }
3767 for ( type in types ) {
3768 this.on( type, selector, data, types[ type ], one );
3769 }
3770 return this;
3771 }
3772
3773 if ( data == null && fn == null ) {
3774 // ( types, fn )
3775 fn = selector;
3776 data = selector = undefined;
3777 } else if ( fn == null ) {
3778 if ( typeof selector === "string" ) {
3779 // ( types, selector, fn )
3780 fn = data;
3781 data = undefined;
3782 } else {
3783 // ( types, data, fn )
3784 fn = data;
3785 data = selector;
3786 selector = undefined;
3787 }
3788 }
3789 if ( fn === false ) {
3790 fn = returnFalse;
3791 } else if ( !fn ) {
3792 return this;
3793 }
3794
3795 if ( one === 1 ) {
3796 origFn = fn;
3797 fn = function( event ) {
3798 // Can use an empty set, since event contains the info
3799 jQuery().off( event );
3800 return origFn.apply( this, arguments );
3801 };
3802 // Use same guid so caller can remove using origFn
3803 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
3804 }
3805 return this.each( function() {
3806 jQuery.event.add( this, types, fn, data, selector );
3807 });
3808 },
3809 one: function( types, selector, data, fn ) {
3810 return this.on( types, selector, data, fn, 1 );
3811 },
3812 off: function( types, selector, fn ) {
3813 if ( types && types.preventDefault && types.handleObj ) {
3814 // ( event ) dispatched jQuery.Event
3815 var handleObj = types.handleObj;
3816 jQuery( types.delegateTarget ).off(
3817 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
3818 handleObj.selector,
3819 handleObj.handler
3820 );
3821 return this;
3822 }
3823 if ( typeof types === "object" ) {
3824 // ( types-object [, selector] )
3825 for ( var type in types ) {
3826 this.off( type, selector, types[ type ] );
3827 }
3828 return this;
3829 }
3830 if ( selector === false || typeof selector === "function" ) {
3831 // ( types [, fn] )
3832 fn = selector;
3833 selector = undefined;
3834 }
3835 if ( fn === false ) {
3836 fn = returnFalse;
3837 }
3838 return this.each(function() {
3839 jQuery.event.remove( this, types, fn, selector );
3840 });
3841 },
3842
3843 bind: function( types, data, fn ) {
3844 return this.on( types, null, data, fn );
3845 },
3846 unbind: function( types, fn ) {