2 // Will speed up references to window, and allows munging its name.
4 // Will speed up references to undefined, and allows munging its name.
6 // Map over jQuery in case of overwrite
7 _jQuery = window.jQuery,
8 // Map over the $ in case of overwrite
11 jQuery = window.jQuery = window.$ = function( selector, context ) {
12 // The jQuery object is actually just the init constructor 'enhanced'
13 return new jQuery.fn.init( selector, context );
16 // A simple way to check for HTML strings or ID strings
17 // (both of which we optimize for)
18 quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,
19 // Is it a simple selector
20 isSimple = /^.[^:#\[\.,]*$/;
22 jQuery.fn = jQuery.prototype = {
23 init: function( selector, context ) {
24 // Make sure that a selection was provided
25 selector = selector || document;
27 // Handle $(DOMElement)
28 if ( selector.nodeType ) {
31 this.context = selector;
34 // Handle HTML strings
35 if ( typeof selector === "string" ) {
36 // Are we dealing with HTML string or an ID?
37 var match = quickExpr.exec( selector );
39 // Verify a match, and that no context was specified for #id
40 if ( match && (match[1] || !context) ) {
42 // HANDLE: $(html) -> $(array)
44 selector = jQuery.clean( [ match[1] ], context );
48 var elem = document.getElementById( match[3] );
50 // Make sure an element was located
52 // Handle the case where IE and Opera return items
53 // by name instead of ID
54 if ( elem.id != match[3] )
55 return jQuery().find( selector );
57 // Otherwise, we inject the element directly into the jQuery object
58 var ret = jQuery( elem );
59 ret.context = document;
60 ret.selector = selector;
66 // HANDLE: $(expr, [context])
67 // (which is just equivalent to: $(content).find(expr)
69 return jQuery( context ).find( selector );
71 // HANDLE: $(function)
72 // Shortcut for document ready
73 } else if ( jQuery.isFunction( selector ) )
74 return jQuery( document ).ready( selector );
76 return this.setArray(jQuery.makeArray(selector));
79 // Start with an empty selector
82 // The current version of jQuery being used
85 // The number of elements contained in the matched element set
90 // Get the Nth element in the matched element set OR
91 // Get the whole matched element set as a clean array
92 get: function( num ) {
93 return num === undefined ?
95 // Return a 'clean' array
96 jQuery.makeArray( this ) :
98 // Return just the object
102 // Take an array of elements and push it onto the stack
103 // (returning the new matched element set)
104 pushStack: function( elems, name, selector ) {
105 // Build a new jQuery matched element set
106 var ret = jQuery( elems );
108 // Add the old object onto the stack (as a reference)
109 ret.prevObject = this;
111 ret.context = this.context;
113 if ( name === "find" )
114 ret.selector = this.selector + (this.selector ? " " : "") + selector;
116 ret.selector = this.selector + "." + name + "(" + selector + ")";
118 // Return the newly-formed element set
122 // Force the current matched set of elements to become
123 // the specified array of elements (destroying the stack in the process)
124 // You should use pushStack() in order to do this, but maintain the stack
125 setArray: function( elems ) {
126 // Resetting the length to 0, then using the native Array push
127 // is a super-fast way to populate an object with array-like properties
129 Array.prototype.push.apply( this, elems );
134 // Execute a callback for every element in the matched set.
135 // (You can seed the arguments with an array of args, but this is
136 // only used internally.)
137 each: function( callback, args ) {
138 return jQuery.each( this, callback, args );
141 // Determine the position of an element within
142 // the matched set of elements
143 index: function( elem ) {
144 // Locate the position of the desired element
145 return jQuery.inArray(
146 // If it receives a jQuery object, the first element is used
147 elem && elem.jquery ? elem[0] : elem
151 attr: function( name, value, type ) {
154 // Look for the case where we're accessing a style value
155 if ( typeof name === "string" )
156 if ( value === undefined )
157 return this[0] && jQuery[ type || "attr" ]( this[0], name );
161 options[ name ] = value;
164 // Check to see if we're setting style values
165 return this.each(function(i){
166 // Set all the styles
167 for ( name in options )
172 name, jQuery.prop( this, options[ name ], type, i, name )
177 css: function( key, value ) {
178 // ignore negative width and height values
179 if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
181 return this.attr( key, value, "curCSS" );
184 text: function( text ) {
185 if ( typeof text !== "object" && text != null )
186 return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
190 jQuery.each( text || this, function(){
191 jQuery.each( this.childNodes, function(){
192 if ( this.nodeType != 8 )
193 ret += this.nodeType != 1 ?
195 jQuery.fn.text( [ this ] );
202 wrapAll: function( html ) {
204 // The elements to wrap the target around
205 jQuery( html, this[0].ownerDocument )
207 .insertBefore( this[0] )
211 while ( elem.firstChild )
212 elem = elem.firstChild;
221 wrapInner: function( html ) {
222 return this.each(function(){
223 jQuery( this ).contents().wrapAll( html );
227 wrap: function( html ) {
228 return this.each(function(){
229 jQuery( this ).wrapAll( html );
234 return this.domManip(arguments, true, function(elem){
235 if (this.nodeType == 1)
236 this.appendChild( elem );
240 prepend: function() {
241 return this.domManip(arguments, true, function(elem){
242 if (this.nodeType == 1)
243 this.insertBefore( elem, this.firstChild );
248 return this.domManip(arguments, false, function(elem){
249 this.parentNode.insertBefore( elem, this );
254 return this.domManip(arguments, false, function(elem){
255 this.parentNode.insertBefore( elem, this.nextSibling );
260 return this.prevObject || jQuery( [] );
263 find: function( selector ) {
264 var elems = jQuery.map(this, function(elem){
265 return jQuery.find( selector, elem );
268 return this.pushStack( /[^+>] [^+>]/.test( selector ) ?
269 jQuery.unique( elems ) :
270 elems, "find", selector );
273 clone: function( events ) {
275 var ret = this.map(function(){
276 if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
277 // IE copies events bound via attachEvent when
278 // using cloneNode. Calling detachEvent on the
279 // clone will also remove the events from the orignal
280 // In order to get around this, we use innerHTML.
281 // Unfortunately, this means some modifications to
282 // attributes in IE that are actually only stored
283 // as properties will not be copied (such as the
284 // the name attribute on an input).
285 var clone = this.cloneNode(true),
286 container = document.createElement("div");
287 container.appendChild(clone);
288 return jQuery.clean([container.innerHTML])[0];
290 return this.cloneNode(true);
293 // Need to set the expando to null on the cloned set if it exists
294 // removeData doesn't work here, IE removes it from the original as well
295 // this is primarily for IE but the data expando shouldn't be copied over in any browser
296 var clone = ret.find("*").andSelf().each(function(){
297 if ( this[ expando ] !== undefined )
298 this[ expando ] = null;
301 // Copy the events from the original to the clone
302 if ( events === true )
303 this.find("*").andSelf().each(function(i){
304 if (this.nodeType == 3)
306 var events = jQuery.data( this, "events" );
308 for ( var type in events )
309 for ( var handler in events[ type ] )
310 jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data );
313 // Return the cloned set
317 filter: function( selector ) {
318 return this.pushStack(
319 jQuery.isFunction( selector ) &&
320 jQuery.grep(this, function(elem, i){
321 return selector.call( elem, i );
324 jQuery.multiFilter( selector, jQuery.grep(this, function(elem){
325 return elem.nodeType === 1;
326 }) ), "filter", selector );
329 closest: function( selector ) {
330 return this.map(function(){
332 while ( cur && cur.ownerDocument ) {
333 if ( jQuery(cur).is(selector) )
335 cur = cur.parentNode;
340 not: function( selector ) {
341 if ( typeof selector === "string" )
342 // test special case where just one selector is passed in
343 if ( isSimple.test( selector ) )
344 return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector );
346 selector = jQuery.multiFilter( selector, this );
348 var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
349 return this.filter(function() {
350 return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
354 add: function( selector ) {
355 return this.pushStack( jQuery.unique( jQuery.merge(
357 typeof selector === "string" ?
359 jQuery.makeArray( selector )
363 is: function( selector ) {
364 return !!selector && jQuery.multiFilter( selector, this ).length > 0;
367 hasClass: function( selector ) {
368 return !!selector && this.is( "." + selector );
371 val: function( value ) {
372 if ( value === undefined ) {
376 if( jQuery.nodeName( elem, 'option' ) )
377 return (elem.attributes.value || {}).specified ? elem.value : elem.text;
379 // We need to handle select boxes special
380 if ( jQuery.nodeName( elem, "select" ) ) {
381 var index = elem.selectedIndex,
383 options = elem.options,
384 one = elem.type == "select-one";
386 // Nothing was selected
390 // Loop through all the selected options
391 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
392 var option = options[ i ];
394 if ( option.selected ) {
395 // Get the specifc value for the option
396 value = jQuery(option).val();
398 // We don't need an array for one selects
402 // Multi-Selects return an array
403 values.push( value );
410 // Everything else, we just grab the value
411 return (elem.value || "").replace(/\r/g, "");
418 if ( typeof value === "number" )
421 return this.each(function(){
422 if ( this.nodeType != 1 )
425 if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) )
426 this.checked = (jQuery.inArray(this.value, value) >= 0 ||
427 jQuery.inArray(this.name, value) >= 0);
429 else if ( jQuery.nodeName( this, "select" ) ) {
430 var values = jQuery.makeArray(value);
432 jQuery( "option", this ).each(function(){
433 this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
434 jQuery.inArray( this.text, values ) >= 0);
437 if ( !values.length )
438 this.selectedIndex = -1;
445 html: function( value ) {
446 return value === undefined ?
450 this.empty().append( value );
453 replaceWith: function( value ) {
454 return this.after( value ).remove();
458 return this.slice( i, +i + 1 );
462 return this.pushStack( Array.prototype.slice.apply( this, arguments ),
463 "slice", Array.prototype.slice.call(arguments).join(",") );
466 map: function( callback ) {
467 return this.pushStack( jQuery.map(this, function(elem, i){
468 return callback.call( elem, i, elem );
472 andSelf: function() {
473 return this.add( this.prevObject );
476 domManip: function( args, table, callback ) {
478 var fragment = this[0].ownerDocument.createDocumentFragment(),
479 scripts = jQuery.clean( args, this[0].ownerDocument, fragment ),
480 first = fragment.firstChild,
481 extra = this.length > 1 ? fragment.cloneNode(true) : fragment;
484 for ( var i = 0, l = this.length; i < l; i++ )
485 callback.call( root(this[i], first), i > 0 ? extra.cloneNode(true) : fragment );
488 jQuery.each( scripts, evalScript );
493 function root( elem, cur ) {
494 return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ?
495 (elem.getElementsByTagName("tbody")[0] ||
496 elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
502 // Give the init function the jQuery prototype for later instantiation
503 jQuery.fn.init.prototype = jQuery.fn;
505 function evalScript( i, elem ) {
514 jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
516 if ( elem.parentNode )
517 elem.parentNode.removeChild( elem );
524 jQuery.extend = jQuery.fn.extend = function() {
525 // copy reference to target object
526 var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
528 // Handle a deep copy situation
529 if ( typeof target === "boolean" ) {
531 target = arguments[1] || {};
532 // skip the boolean and the target
536 // Handle case when target is a string or something (possible in deep copy)
537 if ( typeof target !== "object" && !jQuery.isFunction(target) )
540 // extend jQuery itself if only one argument is passed
546 for ( ; i < length; i++ )
547 // Only deal with non-null/undefined values
548 if ( (options = arguments[ i ]) != null )
549 // Extend the base object
550 for ( var name in options ) {
551 var src = target[ name ], copy = options[ name ];
553 // Prevent never-ending loop
554 if ( target === copy )
557 // Recurse if we're merging object values
558 if ( deep && copy && typeof copy === "object" && !copy.nodeType )
559 target[ name ] = jQuery.extend( deep,
560 // Never move original objects, clone them
561 src || ( copy.length != null ? [ ] : { } )
564 // Don't bring in undefined values
565 else if ( copy !== undefined )
566 target[ name ] = copy;
570 // Return the modified object
574 // exclude the following css properties to add px
575 var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
577 defaultView = document.defaultView || {},
578 toString = Object.prototype.toString;
581 noConflict: function( deep ) {
585 window.jQuery = _jQuery;
590 // See test/unit/core.js for details concerning isFunction.
591 // Since version 1.3, DOM methods and functions like alert
592 // aren't supported. They return false on IE (#2968).
593 isFunction: function( obj ) {
594 return toString.call(obj) === "[object Function]";
597 isArray: function( obj ) {
598 return toString.call(obj) === "[object Array]";
601 // check if an element is in a (or is an) XML document
602 isXMLDoc: function( elem ) {
603 return elem.documentElement && !elem.body ||
604 elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
607 // Evalulates a script in a global context
608 globalEval: function( data ) {
609 data = jQuery.trim( data );
612 // Inspired by code by Andrea Giammarchi
613 // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
614 var head = document.getElementsByTagName("head")[0] || document.documentElement,
615 script = document.createElement("script");
617 script.type = "text/javascript";
618 if ( jQuery.support.scriptEval )
619 script.appendChild( document.createTextNode( data ) );
623 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
624 // This arises when a base node is used (#2709).
625 head.insertBefore( script, head.firstChild );
626 head.removeChild( script );
630 nodeName: function( elem, name ) {
631 return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
634 // args is for internal usage only
635 each: function( object, callback, args ) {
636 var name, i = 0, length = object.length;
639 if ( length === undefined ) {
640 for ( name in object )
641 if ( callback.apply( object[ name ], args ) === false )
644 for ( ; i < length; )
645 if ( callback.apply( object[ i++ ], args ) === false )
648 // A special, fast, case for the most common use of each
650 if ( length === undefined ) {
651 for ( name in object )
652 if ( callback.call( object[ name ], name, object[ name ] ) === false )
655 for ( var value = object[0];
656 i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
662 prop: function( elem, value, type, i, name ) {
663 // Handle executable functions
664 if ( jQuery.isFunction( value ) )
665 value = value.call( elem, i );
667 // Handle passing in a number to a CSS property
668 return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ?
674 // internal only, use addClass("class")
675 add: function( elem, classNames ) {
676 jQuery.each((classNames || "").split(/\s+/), function(i, className){
677 if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) )
678 elem.className += (elem.className ? " " : "") + className;
682 // internal only, use removeClass("class")
683 remove: function( elem, classNames ) {
684 if (elem.nodeType == 1)
685 elem.className = classNames !== undefined ?
686 jQuery.grep(elem.className.split(/\s+/), function(className){
687 return !jQuery.className.has( classNames, className );
692 // internal only, use hasClass("class")
693 has: function( elem, className ) {
694 return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
698 // A method for quickly swapping in/out CSS properties to get correct calculations
699 swap: function( elem, options, callback ) {
701 // Remember the old values, and insert the new ones
702 for ( var name in options ) {
703 old[ name ] = elem.style[ name ];
704 elem.style[ name ] = options[ name ];
707 callback.call( elem );
709 // Revert the old values
710 for ( var name in options )
711 elem.style[ name ] = old[ name ];
714 css: function( elem, name, force ) {
715 if ( name == "width" || name == "height" ) {
716 var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
719 val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
720 var padding = 0, border = 0;
721 jQuery.each( which, function() {
722 padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
723 border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
725 val -= Math.round(padding + border);
728 if ( jQuery(elem).is(":visible") )
731 jQuery.swap( elem, props, getWH );
733 return Math.max(0, val);
736 return jQuery.curCSS( elem, name, force );
739 curCSS: function( elem, name, force ) {
740 var ret, style = elem.style;
742 // We need to handle opacity special in IE
743 if ( name == "opacity" && !jQuery.support.opacity ) {
744 ret = jQuery.attr( style, "opacity" );
751 // Make sure we're using the right name for getting the float value
752 if ( name.match( /float/i ) )
755 if ( !force && style && style[ name ] )
758 else if ( defaultView.getComputedStyle ) {
760 // Only "float" is needed here
761 if ( name.match( /float/i ) )
764 name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
766 var computedStyle = defaultView.getComputedStyle( elem, null );
769 ret = computedStyle.getPropertyValue( name );
771 // We should always get a number back from opacity
772 if ( name == "opacity" && ret == "" )
775 } else if ( elem.currentStyle ) {
776 var camelCase = name.replace(/\-(\w)/g, function(all, letter){
777 return letter.toUpperCase();
780 ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
782 // From the awesome hack by Dean Edwards
783 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
785 // If we're not dealing with a regular pixel number
786 // but a number that has a weird ending, we need to convert it to pixels
787 if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
788 // Remember the original values
789 var left = style.left, rsLeft = elem.runtimeStyle.left;
791 // Put in the new values to get a computed value out
792 elem.runtimeStyle.left = elem.currentStyle.left;
793 style.left = ret || 0;
794 ret = style.pixelLeft + "px";
796 // Revert the changed values
798 elem.runtimeStyle.left = rsLeft;
805 clean: function( elems, context, fragment ) {
806 context = context || document;
808 // !context.createElement fails in IE with an error but returns typeof 'object'
809 if ( typeof context.createElement === "undefined" )
810 context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
812 // If a single string is passed in and it's a single tag
813 // just do a createElement and skip the rest
814 if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) {
815 var match = /^<(\w+)\s*\/?>$/.exec(elems[0]);
817 return [ context.createElement( match[1] ) ];
820 var ret = [], scripts = [], div = context.createElement("div");
822 jQuery.each(elems, function(i, elem){
823 if ( typeof elem === "number" )
829 // Convert html string into DOM nodes
830 if ( typeof elem === "string" ) {
831 // Fix "XHTML"-style tags in all browsers
832 elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
833 return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
835 front + "></" + tag + ">";
838 // Trim whitespace, otherwise indexOf won't work as expected
839 var tags = jQuery.trim( elem ).toLowerCase();
842 // option or optgroup
843 !tags.indexOf("<opt") &&
844 [ 1, "<select multiple='multiple'>", "</select>" ] ||
846 !tags.indexOf("<leg") &&
847 [ 1, "<fieldset>", "</fieldset>" ] ||
849 tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
850 [ 1, "<table>", "</table>" ] ||
852 !tags.indexOf("<tr") &&
853 [ 2, "<table><tbody>", "</tbody></table>" ] ||
855 // <thead> matched above
856 (!tags.indexOf("<td") || !tags.indexOf("<th")) &&
857 [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||
859 !tags.indexOf("<col") &&
860 [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||
862 // IE can't serialize <link> and <script> tags normally
863 !jQuery.support.htmlSerialize &&
864 [ 1, "div<div>", "</div>" ] ||
868 // Go to html and back, then peel off extra wrappers
869 div.innerHTML = wrap[1] + elem + wrap[2];
871 // Move to the right depth
875 // Remove IE's autoinserted <tbody> from table fragments
876 if ( !jQuery.support.tbody ) {
878 // String was a <table>, *may* have spurious <tbody>
879 var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
880 div.firstChild && div.firstChild.childNodes :
882 // String was a bare <thead> or <tfoot>
883 wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?
887 for ( var j = tbody.length - 1; j >= 0 ; --j )
888 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length )
889 tbody[ j ].parentNode.removeChild( tbody[ j ] );
893 // IE completely kills leading whitespace when innerHTML is used
894 if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) )
895 div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
898 var found = div.getElementsByTagName("script");
900 while ( found.length ) {
901 scripts.push( found[0] );
902 found[0].parentNode.removeChild( found[0] );
906 elem = jQuery.makeArray( div.childNodes );
912 ret = jQuery.merge( ret, elem );
917 for ( var i = 0; ret[i]; i++ ) {
919 if ( jQuery.nodeName( node, "script" ) ) {
920 if( node.parentNode )
921 node.parentNode.removeChild( node );
923 if ( node.nodeType === 1 )
924 ret = jQuery.merge( ret, node.getElementsByTagName("script"));
925 fragment.appendChild( node );
935 attr: function( elem, name, value ) {
936 // don't set attributes on text and comment nodes
937 if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
940 var notxml = !jQuery.isXMLDoc( elem ),
941 // Whether we are setting (or getting)
942 set = value !== undefined;
944 // Try to normalize/fix the name
945 name = notxml && jQuery.props[ name ] || name;
947 // Only do all the following if this is a node (faster for style)
948 // IE elem.getAttribute passes even for style
949 if ( elem.tagName ) {
951 // These attributes require special treatment
952 var special = /href|src|style/.test( name );
954 // Safari mis-reports the default selected property of a hidden option
955 // Accessing the parent's selectedIndex property fixes it
956 if ( name == "selected" )
957 elem.parentNode.selectedIndex;
959 // If applicable, access the attribute via the DOM 0 way
960 if ( name in elem && notxml && !special ) {
962 // We can't allow the type property to be changed (since it causes problems in IE)
963 if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
964 throw "type property can't be changed";
966 elem[ name ] = value;
969 // browsers index elements by id/name on forms, give priority to attributes.
970 if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) )
971 return elem.getAttributeNode( name ).nodeValue;
976 if ( !jQuery.support.style && notxml && name == "style" )
977 return jQuery.attr( elem.style, "cssText", value );
980 // convert the value to a string (all browsers do this but IE) see #1070
981 elem.setAttribute( name, "" + value );
983 var attr = !jQuery.support.hrefNormalized && notxml && special
984 // Some attributes require a special call on IE
985 ? elem.getAttribute( name, 2 )
986 : elem.getAttribute( name );
988 // Non-existent attributes return null, we normalize to undefined
989 return attr === null ? undefined : attr;
992 // elem is actually elem.style ... set the style
994 // IE uses filters for opacity
995 if ( !jQuery.support.opacity && name == "opacity" ) {
997 // IE has trouble with opacity if it does not have layout
998 // Force it by setting the zoom level
1001 // Set the alpha filter to set the opacity
1002 elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
1003 (parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
1006 return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
1007 (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
1011 name = name.replace(/-([a-z])/ig, function(all, letter){
1012 return letter.toUpperCase();
1016 elem[ name ] = value;
1018 return elem[ name ];
1021 trim: function( text ) {
1022 return (text || "").replace( /^\s+|\s+$/g, "" );
1025 makeArray: function( array ) {
1028 if( array != null ){
1029 var i = array.length;
1030 // The window, strings (and functions) also have 'length'
1031 if( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval )
1035 ret[--i] = array[i];
1041 inArray: function( elem, array ) {
1042 for ( var i = 0, length = array.length; i < length; i++ )
1043 // Use === because on IE, window == document
1044 if ( array[ i ] === elem )
1050 merge: function( first, second ) {
1051 // We have to loop this way because IE & Opera overwrite the length
1052 // expando of getElementsByTagName
1053 var i = 0, elem, pos = first.length;
1054 // Also, we need to make sure that the correct elements are being returned
1055 // (IE returns comment nodes in a '*' query)
1056 if ( !jQuery.support.getAll ) {
1057 while ( (elem = second[ i++ ]) != null )
1058 if ( elem.nodeType != 8 )
1059 first[ pos++ ] = elem;
1062 while ( (elem = second[ i++ ]) != null )
1063 first[ pos++ ] = elem;
1068 unique: function( array ) {
1069 var ret = [], done = {};
1073 for ( var i = 0, length = array.length; i < length; i++ ) {
1074 var id = jQuery.data( array[ i ] );
1076 if ( !done[ id ] ) {
1078 ret.push( array[ i ] );
1089 grep: function( elems, callback, inv ) {
1092 // Go through the array, only saving the items
1093 // that pass the validator function
1094 for ( var i = 0, length = elems.length; i < length; i++ )
1095 if ( !inv != !callback( elems[ i ], i ) )
1096 ret.push( elems[ i ] );
1101 map: function( elems, callback ) {
1104 // Go through the array, translating each of the items to their
1105 // new value (or values).
1106 for ( var i = 0, length = elems.length; i < length; i++ ) {
1107 var value = callback( elems[ i ], i );
1109 if ( value != null )
1110 ret[ ret.length ] = value;
1113 return ret.concat.apply( [], ret );
1117 // Use of jQuery.browser is deprecated.
1118 // It's included for backwards compatibility and plugins,
1119 // although they should work to migrate away.
1121 var userAgent = navigator.userAgent.toLowerCase();
1123 // Figure out what browser is being used
1125 version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
1126 safari: /webkit/.test( userAgent ),
1127 opera: /opera/.test( userAgent ),
1128 msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
1129 mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
1132 // Check to see if the W3C box model is being used
1133 jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
1136 parent: function(elem){return elem.parentNode;},
1137 parents: function(elem){return jQuery.dir(elem,"parentNode");},
1138 next: function(elem){return jQuery.nth(elem,2,"nextSibling");},
1139 prev: function(elem){return jQuery.nth(elem,2,"previousSibling");},
1140 nextAll: function(elem){return jQuery.dir(elem,"nextSibling");},
1141 prevAll: function(elem){return jQuery.dir(elem,"previousSibling");},
1142 siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},
1143 children: function(elem){return jQuery.sibling(elem.firstChild);},
1144 contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}
1145 }, function(name, fn){
1146 jQuery.fn[ name ] = function( selector ) {
1147 var ret = jQuery.map( this, fn );
1149 if ( selector && typeof selector == "string" )
1150 ret = jQuery.multiFilter( selector, ret );
1152 return this.pushStack( jQuery.unique( ret ), name, selector );
1158 prependTo: "prepend",
1159 insertBefore: "before",
1160 insertAfter: "after",
1161 replaceAll: "replaceWith"
1162 }, function(name, original){
1163 jQuery.fn[ name ] = function() {
1164 var args = arguments;
1166 return this.each(function(){
1167 for ( var i = 0, length = args.length; i < length; i++ )
1168 jQuery( args[ i ] )[ original ]( this );
1174 removeAttr: function( name ) {
1175 jQuery.attr( this, name, "" );
1176 if (this.nodeType == 1)
1177 this.removeAttribute( name );
1180 addClass: function( classNames ) {
1181 jQuery.className.add( this, classNames );
1184 removeClass: function( classNames ) {
1185 jQuery.className.remove( this, classNames );
1188 toggleClass: function( classNames, state ) {
1189 if( typeof state !== "boolean" )
1190 state = !jQuery.className.has( this, classNames );
1191 jQuery.className[ state ? "add" : "remove" ]( this, classNames );
1194 remove: function( selector ) {
1195 if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
1196 // Prevent memory leaks
1197 jQuery( "*", this ).add([this]).each(function(){
1198 jQuery.event.remove(this);
1199 jQuery.removeData(this);
1201 if (this.parentNode)
1202 this.parentNode.removeChild( this );
1207 // Remove element nodes and prevent memory leaks
1208 jQuery( ">*", this ).remove();
1210 // Remove any remaining nodes
1211 while ( this.firstChild )
1212 this.removeChild( this.firstChild );
1214 }, function(name, fn){
1215 jQuery.fn[ name ] = function(){
1216 return this.each( fn, arguments );
1220 // Helper function used by the dimensions and offset modules
1221 function num(elem, prop) {
1222 return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;