1 /* prevent execution of jQuery if included more than once */
2 if(typeof window
.jQuery
== "undefined") {
4 * jQuery 1.1.1 - New Wave Javascript
6 * Copyright (c) 2007 John Resig (jquery.com)
7 * Dual licensed under the MIT (MIT-LICENSE.txt)
8 * and GPL (GPL-LICENSE.txt) licenses.
10 * $Date: 2007-02-03 20:32:16 +0100 (Sat, 03 Feb 2007) $
14 // Global undefined variable
15 window
.undefined
= window
.undefined
;
16 var jQuery
= function(a
,c
) {
17 // If the context is global, return a new object
19 return new jQuery(a
,c
);
21 // Make sure that a selection was provided
24 // HANDLE: $(function)
25 // Shortcut for document ready
26 if ( jQuery
.isFunction(a
) )
27 return new jQuery(document
)[ jQuery
.fn
.ready ?
"ready" : "load" ]( a
);
29 // Handle HTML strings
30 if ( typeof a
== "string" ) {
31 // HANDLE: $(html) -> $(array)
32 var m
= /^
[^
<]*(<(.|\s
)+>)[^
>]*$
/.exec(a
);
34 a
= jQuery
.clean( [ m
[1] ] );
38 return new jQuery( c
).find( a
);
43 a
.constructor
== Array
&& a ||
45 // HANDLE: $(arraylike)
46 // Watch for when an array-like object is passed as the selector
47 (a
.jquery || a
.length
&& a
!= window
&& !a
.nodeType
&& a
[0] != undefined
&& a
[0].nodeType
) && jQuery
.makeArray( a
) ||
53 // Map over the $ in case of overwrite
54 if ( typeof $
!= "undefined" )
57 // Map the jQuery namespace to the '$' one
60 jQuery
.fn
= jQuery
.prototype = {
69 get
: function( num
) {
70 return num
== undefined ?
72 // Return a 'clean' array
73 jQuery
.makeArray( this ) :
75 // Return just the object
78 pushStack
: function( a
) {
80 ret
.prevObject
= this;
83 setArray
: function( a
) {
85 [].push
.apply( this, a
);
88 each
: function( fn
, args
) {
89 return jQuery
.each( this, fn
, args
);
91 index
: function( obj
) {
93 this.each(function(i
){
94 if ( this == obj
) pos
= i
;
99 attr
: function( key
, value
, type
) {
102 // Look for the case where we're accessing a style value
103 if ( key
.constructor
== String
)
104 if ( value
== undefined
)
105 return this.length
&& jQuery
[ type ||
"attr" ]( this[0], key
) || undefined
;
111 // Check to see if we're setting style values
112 return this.each(function(index
){
113 // Set all the styles
114 for ( var prop
in obj
)
116 type ?
this.style
: this,
117 prop
, jQuery
.prop(this, obj
[prop], type
, index
, prop
)
122 css
: function( key
, value
) {
123 return this.attr( key
, value
, "curCSS" );
127 if ( typeof e
== "string" )
128 return this.empty().append( document
.createTextNode( e
) );
131 jQuery
.each( e ||
this, function(){
132 jQuery
.each( this.childNodes
, function(){
133 if ( this.nodeType
!= 8 )
134 t
+= this.nodeType
!= 1 ?
135 this.nodeValue
: jQuery
.fn
.text([ this ]);
142 // The elements to wrap the target around
143 var a
= jQuery
.clean(arguments
);
145 // Wrap each of the matched elements individually
146 return this.each(function(){
147 // Clone the structure that we're using to wrap
148 var b
= a
[0].cloneNode(true);
150 // Insert it before the element to be wrapped
151 this.parentNode
.insertBefore( b
, this );
153 // Find the deepest point in the wrap structure
154 while ( b
.firstChild
)
157 // Move the matched element to within the wrap structure
158 b
.appendChild( this );
162 return this.domManip(arguments
, true, 1, function(a
){
163 this.appendChild( a
);
166 prepend
: function() {
167 return this.domManip(arguments
, true, -1, function(a
){
168 this.insertBefore( a
, this.firstChild
);
172 return this.domManip(arguments
, false, 1, function(a
){
173 this.parentNode
.insertBefore( a
, this );
177 return this.domManip(arguments
, false, -1, function(a
){
178 this.parentNode
.insertBefore( a
, this.nextSibling
);
182 return this.prevObject ||
jQuery([]);
185 return this.pushStack( jQuery
.map( this, function(a
){
186 return jQuery
.find(t
,a
);
189 clone
: function(deep
) {
190 return this.pushStack( jQuery
.map( this, function(a
){
191 return a
.cloneNode( deep
!= undefined ? deep
: true );
195 filter
: function(t
) {
196 return this.pushStack(
197 jQuery
.isFunction( t
) &&
198 jQuery
.grep(this, function(el
, index
){
199 return t
.apply(el
, [index])
202 jQuery
.multiFilter(t
,this) );
206 return this.pushStack(
207 t
.constructor
== String
&&
208 jQuery
.multiFilter(t
, this, true) ||
210 jQuery
.grep(this, function(a
) {
211 return ( t
.constructor
== Array || t
.jquery
)
212 ? jQuery
.inArray( a
, t
) < 0
219 return this.pushStack( jQuery
.merge(
221 t
.constructor
== String ?
223 t
.length
!= undefined
&& (!t
.nodeName || t
.nodeName
== "FORM") ?
228 return expr ? jQuery
.filter(expr
,this).r
.length
> 0 : false;
231 val
: function( val
) {
232 return val
== undefined ?
233 ( this.length ?
this[0].value
: null ) :
234 this.attr( "value", val
);
237 html
: function( val
) {
238 return val
== undefined ?
239 ( this.length ?
this[0].innerHTML
: null ) :
240 this.empty().append( val
);
242 domManip
: function(args
, table
, dir
, fn
){
243 var clone
= this.length
> 1;
244 var a
= jQuery
.clean(args
);
248 return this.each(function(){
251 if ( table
&& jQuery
.nodeName(this, "table") && jQuery
.nodeName(a
[0], "tr") )
252 obj
= this.getElementsByTagName("tbody")[0] ||
this.appendChild(document
.createElement("tbody"));
254 jQuery
.each( a
, function(){
255 fn
.apply( obj
, [ clone ?
this.cloneNode(true) : this ] );
262 jQuery
.extend
= jQuery
.fn
.extend
= function() {
263 // copy reference to target object
264 var target
= arguments
[0],
267 // extend jQuery itself if only one argument is passed
268 if ( arguments
.length
== 1 ) {
273 while (prop
= arguments
[a
++])
274 // Extend the base object
275 for ( var i
in prop
) target
[i] = prop
[i];
277 // Return the modified object
282 noConflict
: function() {
288 // This may seem like some crazy code, but trust me when I say that this
289 // is the only cross-browser way to do this. --John
290 isFunction
: function( fn
) {
291 return !!fn
&& typeof fn
!= "string" &&
292 typeof fn
[0] == "undefined" && /function/i
.test( fn
+ "" );
295 nodeName
: function( elem
, name
) {
296 return elem
.nodeName
&& elem
.nodeName
.toUpperCase() == name
.toUpperCase();
298 // args is for internal usage only
299 each
: function( obj
, fn
, args
) {
300 if ( obj
.length
== undefined
)
302 fn
.apply( obj
[i], args ||
[i
, obj
[i]] );
304 for ( var i
= 0, ol
= obj
.length
; i
< ol
; i
++ )
305 if ( fn
.apply( obj
[i], args ||
[i
, obj
[i]] ) === false ) break;
309 prop
: function(elem
, value
, type
, index
, prop
){
310 // Handle executable functions
311 if ( jQuery
.isFunction( value
) )
312 return value
.call( elem
, [index] );
314 // exclude the following css properties to add px
315 var exclude
= /z
-?index|font
-?weight|opacity|zoom|line
-?height
/i
;
317 // Handle passing in a number to a CSS property
318 return value
&& value
.constructor
== Number
&& type
== "curCSS" && !exclude
.test(prop
) ?
324 // internal only, use addClass("class")
325 add
: function( elem
, c
){
326 jQuery
.each( c
.split(/\s
+/), function(i
, cur
){
327 if ( !jQuery
.className
.has( elem
.className
, cur
) )
328 elem
.className
+= ( elem
.className ?
" " : "" ) + cur
;
332 // internal only, use removeClass("class")
333 remove
: function( elem
, c
){
335 jQuery
.grep( elem
.className
.split(/\s
+/), function(cur
){
336 return !jQuery
.className
.has( c
, cur
);
340 // internal only, use is(".class")
341 has
: function( t
, c
) {
342 t
= t
.className || t
;
343 return t
&& new RegExp("(^|\\s)" + c
+ "(\\s|$)").test( t
);
346 swap
: function(e
,o
,f
) {
348 e
.style
["old"+i
] = e
.style
[i];
353 e
.style
[i] = e
.style
["old"+i
];
357 if ( p
== "height" || p
== "width" ) {
358 var old
= {}, oHeight
, oWidth
, d
= ["Top","Bottom","Right","Left"];
360 jQuery
.each( d
, function(){
361 old
["padding" + this] = 0;
362 old
["border" + this + "Width"] = 0;
365 jQuery
.swap( e
, old
, function() {
366 if (jQuery
.css(e
,"display") != "none") {
367 oHeight
= e
.offsetHeight
;
368 oWidth
= e
.offsetWidth
;
370 e
= jQuery(e
.cloneNode(true))
371 .find(":radio").removeAttr("checked").end()
373 visibility
: "hidden", position
: "absolute", display
: "block", right
: "0", left
: "0"
374 }).appendTo(e
.parentNode
)[0];
376 var parPos
= jQuery
.css(e
.parentNode
,"position");
377 if ( parPos
== "" || parPos
== "static" )
378 e
.parentNode
.style
.position
= "relative";
380 oHeight
= e
.clientHeight
;
381 oWidth
= e
.clientWidth
;
383 if ( parPos
== "" || parPos
== "static" )
384 e
.parentNode
.style
.position
= "static";
386 e
.parentNode
.removeChild(e
);
390 return p
== "height" ? oHeight
: oWidth
;
393 return jQuery
.curCSS( e
, p
);
396 curCSS
: function(elem
, prop
, force
) {
399 if (prop
== "opacity" && jQuery
.browser
.msie
)
400 return jQuery
.attr(elem
.style
, "opacity");
402 if (prop
== "float" || prop
== "cssFloat")
403 prop
= jQuery
.browser
.msie ?
"styleFloat" : "cssFloat";
405 if (!force
&& elem
.style
[prop])
406 ret
= elem
.style
[prop];
408 else if (document
.defaultView
&& document
.defaultView
.getComputedStyle
) {
410 if (prop
== "cssFloat" || prop
== "styleFloat")
413 prop
= prop
.replace(/([A
-Z
])/g
,"-$1").toLowerCase();
414 var cur
= document
.defaultView
.getComputedStyle(elem
, null);
417 ret
= cur
.getPropertyValue(prop
);
418 else if ( prop
== "display" )
421 jQuery
.swap(elem
, { display
: "block" }, function() {
422 var c
= document
.defaultView
.getComputedStyle(this, "");
423 ret
= c
&& c
.getPropertyValue(prop
) ||
"";
426 } else if (elem
.currentStyle
) {
428 var newProp
= prop
.replace(/\
-(\w
)/g
,function(m
,c
){return c
.toUpperCase();});
429 ret
= elem
.currentStyle
[prop] || elem
.currentStyle
[newProp];
439 jQuery
.each( a
, function(i
,arg
){
442 if ( arg
.constructor
== Number
)
443 arg
= arg
.toString();
445 // Convert html string into DOM nodes
446 if ( typeof arg
== "string" ) {
447 // Trim whitespace, otherwise indexOf won't work as expected
448 var s
= jQuery
.trim(arg
), div
= document
.createElement("div"), tb
= [];
451 // option or optgroup
452 !s
.indexOf("<opt") &&
453 [1, "<select>", "</select>"] ||
455 (!s
.indexOf("<thead") ||
!s
.indexOf("<tbody") ||
!s
.indexOf("<tfoot")) &&
456 [1, "<table>", "</table>"] ||
459 [2, "<table><tbody>", "</tbody></table>"] ||
461 // <thead> matched above
462 (!s
.indexOf("<td") ||
!s
.indexOf("<th")) &&
463 [3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
467 // Go to html and back, then peel off extra wrappers
468 div
.innerHTML
= wrap
[1] + s
+ wrap
[2];
470 // Move to the right depth
472 div
= div
.firstChild
;
474 // Remove IE's autoinserted <tbody> from table fragments
475 if ( jQuery
.browser
.msie
) {
477 // String was a <table>, *may* have spurious <tbody>
478 if ( !s
.indexOf("<table") && s
.indexOf("<tbody") < 0 )
479 tb
= div
.firstChild
&& div
.firstChild
.childNodes
;
481 // String was a bare <thead> or <tfoot>
482 else if ( wrap
[1] == "<table>" && s
.indexOf("<tbody") < 0 )
485 for ( var n
= tb
.length
-1; n
>= 0 ; --n
)
486 if ( jQuery
.nodeName(tb
[n], "tbody") && !tb
[n].childNodes
.length
)
487 tb
[n].parentNode
.removeChild(tb
[n]);
491 arg
= div
.childNodes
;
494 if ( arg
.length
=== 0 )
497 if ( arg
[0] == undefined
)
500 r
= jQuery
.merge( r
, arg
);
507 attr
: function(elem
, name
, value
){
510 "class": "className",
511 "float": jQuery
.browser
.msie ?
"styleFloat" : "cssFloat",
512 cssFloat
: jQuery
.browser
.msie ?
"styleFloat" : "cssFloat",
513 innerHTML
: "innerHTML",
514 className
: "className",
516 disabled
: "disabled",
518 readonly
: "readOnly",
522 // IE actually uses filters for opacity ... elem is actually elem.style
523 if ( name
== "opacity" && jQuery
.browser
.msie
&& value
!= undefined
) {
524 // IE has trouble with opacity if it does not have layout
525 // Force it by setting the zoom level
528 // Set the alpha filter to set the opacity
529 return elem
.filter
= elem
.filter
.replace(/alpha\
([^\
)]*\
)/gi
,"") +
530 ( value
== 1 ?
"" : "alpha(opacity=" + value
* 100 + ")" );
532 } else if ( name
== "opacity" && jQuery
.browser
.msie
)
534 parseFloat( elem
.filter
.match(/alpha\
(opacity
=(.*)\
)/)[1] ) / 100 : 1;
536 // Mozilla doesn't play well with opacity 1
537 if ( name
== "opacity" && jQuery
.browser
.mozilla
&& value
== 1 )
540 // Certain attributes only work when accessed via the old DOM 0 way
542 if ( value
!= undefined
) elem
[fix
[name]] = value
;
543 return elem
[fix
[name]];
545 } else if ( value
== undefined
&& jQuery
.browser
.msie
&& jQuery
.nodeName(elem
, "form") && (name
== "action" || name
== "method") )
546 return elem
.getAttributeNode(name
).nodeValue
;
548 // IE elem.getAttribute passes even for style
549 else if ( elem
.tagName
) {
550 if ( value
!= undefined
) elem
.setAttribute( name
, value
);
551 return elem
.getAttribute( name
);
554 name
= name
.replace(/-([a
-z
])/ig
,function(z
,b
){return b
.toUpperCase();});
555 if ( value
!= undefined
) elem
[name] = value
;
560 return t
.replace(/^\s
+|\s
+$
/g
, "");
563 makeArray
: function( a
) {
566 if ( a
.constructor
!= Array
)
567 for ( var i
= 0, al
= a
.length
; i
< al
; i
++ )
575 inArray
: function( b
, a
) {
576 for ( var i
= 0, al
= a
.length
; i
< al
; i
++ )
581 merge
: function(first
, second
) {
582 var r
= [].slice
.call( first
, 0 );
584 // Now check for duplicates between the two arrays
585 // and only add the unique items
586 for ( var i
= 0, sl
= second
.length
; i
< sl
; i
++ )
587 // Check for duplicates
588 if ( jQuery
.inArray( second
[i], r
) == -1 )
589 // The item is unique, add it
590 first
.push( second
[i] );
594 grep
: function(elems
, fn
, inv
) {
595 // If a string is passed in for the function, make a function
596 // for it (a handy shortcut)
597 if ( typeof fn
== "string" )
598 fn
= new Function("a","i","return " + fn
);
602 // Go through the array, only saving the items
603 // that pass the validator function
604 for ( var i
= 0, el
= elems
.length
; i
< el
; i
++ )
605 if ( !inv
&& fn(elems
[i],i
) || inv
&& !fn(elems
[i],i
) )
606 result
.push( elems
[i] );
610 map
: function(elems
, fn
) {
611 // If a string is passed in for the function, make a function
612 // for it (a handy shortcut)
613 if ( typeof fn
== "string" )
614 fn
= new Function("a","return " + fn
);
616 var result
= [], r
= [];
618 // Go through the array, translating each of the items to their
619 // new value (or values).
620 for ( var i
= 0, el
= elems
.length
; i
< el
; i
++ ) {
621 var val
= fn(elems
[i],i
);
623 if ( val
!== null && val
!= undefined
) {
624 if ( val
.constructor
!= Array
) val
= [val];
625 result
= result
.concat( val
);
629 var r
= result
.length ?
[ result
[0] ] : [];
631 check
: for ( var i
= 1, rl
= result
.length
; i
< rl
; i
++ ) {
632 for ( var j
= 0; j
< i
; j
++ )
633 if ( result
[i] == r
[j] )
644 * Whether the W3C compliant box model is being used.
652 var b
= navigator
.userAgent
.toLowerCase();
654 // Figure out what browser is being used
656 safari
: /webkit
/.test(b
),
657 opera
: /opera
/.test(b
),
658 msie
: /msie
/.test(b
) && !/opera
/.test(b
),
659 mozilla
: /mozilla
/.test(b
) && !/(compatible|webkit
)/.test(b
)
662 // Check to see if the W3C box model is being used
663 jQuery
.boxModel
= !jQuery
.browser
.msie || document
.compatMode
== "CSS1Compat";
667 parent
: "a.parentNode",
668 parents
: "jQuery.parents(a)",
669 next
: "jQuery.nth(a,2,'nextSibling')",
670 prev
: "jQuery.nth(a,2,'previousSibling')",
671 siblings
: "jQuery.sibling(a.parentNode.firstChild,a)",
672 children
: "jQuery.sibling(a.firstChild)"
674 jQuery
.fn
[ i
] = function(a
) {
675 var ret
= jQuery
.map(this,n
);
676 if ( a
&& typeof a
== "string" )
677 ret
= jQuery
.multiFilter(a
,ret
);
678 return this.pushStack( ret
);
684 prependTo
: "prepend",
685 insertBefore
: "before",
688 jQuery
.fn
[ i
] = function(){
690 return this.each(function(){
691 for ( var j
= 0, al
= a
.length
; j
< al
; j
++ )
692 jQuery(a
[j])[n]( this );
698 removeAttr
: function( key
) {
699 jQuery
.attr( this, key
, "" );
700 this.removeAttribute( key
);
702 addClass
: function(c
){
703 jQuery
.className
.add(this,c
);
705 removeClass
: function(c
){
706 jQuery
.className
.remove(this,c
);
708 toggleClass
: function( c
){
709 jQuery
.className
[ jQuery
.className
.has(this,c
) ?
"remove" : "add" ](this, c
);
712 if ( !a || jQuery
.filter( a
, [this] ).r
.length
)
713 this.parentNode
.removeChild( this );
716 while ( this.firstChild
)
717 this.removeChild( this.firstChild
);
720 jQuery
.fn
[ i
] = function() {
721 return this.each( n
, arguments
);
725 jQuery
.each( [ "eq", "lt", "gt", "contains" ], function(i
,n
){
726 jQuery
.fn
[ n
] = function(num
,fn
) {
727 return this.filter( ":" + n
+ "(" + num
+ ")", fn
);
731 jQuery
.each( [ "height", "width" ], function(i
,n
){
732 jQuery
.fn
[ n
] = function(h
) {
733 return h
== undefined ?
734 ( this.length ? jQuery
.css( this[0], n
) : null ) :
735 this.css( n
, h
.constructor
== String ? h
: h
+ "px" );
740 "": "m[2]=='*'||jQuery.nodeName(a,m[2])",
741 "#": "a.getAttribute('id')==m[2]",
749 last
: "i==r.length-1",
754 "nth-child": "jQuery.nth(a.parentNode.firstChild,m[3],'nextSibling',a)==a",
755 "first-child": "jQuery.nth(a.parentNode.firstChild,1,'nextSibling')==a",
756 "last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a",
757 "only-child": "jQuery.sibling(a.parentNode.firstChild).length==1",
760 parent
: "a.firstChild",
761 empty
: "!a.firstChild",
764 contains
: "jQuery.fn.text.apply([a]).indexOf(m[3])>=0",
767 visible
: 'a.type!="hidden"&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
768 hidden
: 'a.type=="hidden"||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',
771 enabled
: "!a.disabled",
772 disabled
: "a.disabled",
773 checked
: "a.checked",
774 selected
: "a.selected||jQuery.attr(a,'selected')",
777 text
: "a.type=='text'",
778 radio
: "a.type=='radio'",
779 checkbox
: "a.type=='checkbox'",
780 file
: "a.type=='file'",
781 password
: "a.type=='password'",
782 submit
: "a.type=='submit'",
783 image
: "a.type=='image'",
784 reset
: "a.type=='reset'",
785 button
: 'a.type=="button"||jQuery.nodeName(a,"button")',
786 input
: "/input|select|textarea|button/i.test(a.nodeName)"
788 ".": "jQuery.className.has(a,m[2])",
792 "^=": "z&&!z.indexOf(m[4])",
793 "$=": "z&&z.substr(z.length - m[4].length,m[4].length)==m[4]",
794 "*=": "z&&z.indexOf(m[4])>=0",
796 _resort
: function(m
){
797 return ["", m
[1], m
[3], m
[2], m
[5]];
799 _prefix
: "z=a[m[3]]||jQuery.attr(a,m[3]);"
801 "[": "jQuery.find(m[2],a).length"
804 // The regular expressions that power the parsing engine
806 // Match: [@value='test'], [@foo]
807 /^\
[ *(@
)([a
-z0
-9_
-]*) *([!*$^
=]*) *('?"?)(.*?)\4 *\]/i,
809 // Match: [div], [div p]
810 /^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,
812 // Match: :contains('foo
')
813 /^(:)([a-z0-9_-]*)\("?'?
(.*?
(\
(.*?\
))?
[^
(]*?
)"?'?\)/i,
815 // Match: :even, :last-chlid
816 /^([:.#]*)([a-z0-9_*-]*)/i
820 /^(\/?\.\.)/, "a
.parentNode
",
821 /^(>|\/)/, "jQuery
.sibling(a
.firstChild
)",
822 /^(\+)/, "jQuery
.nth(a
,2,'nextSibling')",
824 var s = jQuery.sibling(a.parentNode.firstChild);
825 return s.slice(0, jQuery.inArray(a,s));
829 multiFilter: function( expr, elems, not ) {
832 while ( expr && expr != old ) {
834 var f = jQuery.filter( expr, elems, not );
835 expr = f.t.replace(/^\s*,\s*/, "" );
836 cur = not ? elems = f.r : jQuery.merge( cur, f.r );
841 find: function( t, context ) {
842 // Quickly handle non-string expressions
843 if ( typeof t != "string
" )
846 // Make sure that the context is a DOM Element
847 if ( context && !context.nodeType )
850 // Set the correct context (if none is provided)
851 context = context || document;
853 // Handle the common XPath // expression
854 if ( !t.indexOf("//") ) {
855 context
= context
.documentElement
;
856 t
= t
.substr(2,t
.length
);
858 // And the / root expression
859 } else if ( !t
.indexOf("/") ) {
860 context
= context
.documentElement
;
861 t
= t
.substr(1,t
.length
);
862 if ( t
.indexOf("/") >= 1 )
863 t
= t
.substr(t
.indexOf("/"),t
.length
);
866 // Initialize the search
867 var ret
= [context], done
= [], last
= null;
869 // Continue while a selector expression exists, and while
870 // we're no longer looping upon ourselves
871 while ( t
&& last
!= t
) {
875 t
= jQuery
.trim(t
).replace( /^\
/\
//i, "" );
877 var foundToken
= false;
879 // An attempt at speeding up child selectors that
880 // point to a specific element tag
881 var re
= /^
[\
/>]\s
*([a
-z0
-9*-]+)/i
;
885 // Perform our own iteration and filter
886 jQuery
.each( ret
, function(){
887 for ( var c
= this.firstChild
; c
; c
= c
.nextSibling
)
888 if ( c
.nodeType
== 1 && ( jQuery
.nodeName(c
, m
[1]) || m
[1] == "*" ) )
893 t
= t
.replace( re
, "" );
894 if ( t
.indexOf(" ") == 0 ) continue;
897 // Look for pre-defined expression tokens
898 for ( var i
= 0; i
< jQuery
.token
.length
; i
+= 2 ) {
899 // Attempt to match each, individual, token in
900 // the specified order
901 var re
= jQuery
.token
[i];
904 // If the token match was found
906 // Map it against the token's handler
907 r
= ret
= jQuery
.map( ret
, jQuery
.isFunction( jQuery
.token
[i
+1] ) ?
909 function(a
){ return eval(jQuery
.token
[i
+1]); });
911 // And remove the token
912 t
= jQuery
.trim( t
.replace( re
, "" ) );
919 // See if there's still an expression, and that we haven't already
921 if ( t
&& !foundToken
) {
922 // Handle multiple expressions
923 if ( !t
.indexOf(",") ) {
924 // Clean the result set
925 if ( ret
[0] == context
) ret
.shift();
927 // Merge the result sets
928 jQuery
.merge( done
, ret
);
933 // Touch up the selector string
934 t
= " " + t
.substr(1,t
.length
);
937 // Optomize for the case nodeName#idName
938 var re2
= /^
([a
-z0
-9_
-]+)(#
)([a
-z0
-9\\*_
-]*)/i
;
941 // Re-organize the results, so that they're consistent
943 m
= [ 0, m
[2], m
[3], m
[1] ];
946 // Otherwise, do a traditional filter check for
947 // ID, class, and element selectors
948 re2
= /^
([#
.]?
)([a
-z0
-9\\*_
-]*)/i
;
952 // Try to do a global search by ID, where we can
953 if ( m
[1] == "#" && ret
[ret
.length
-1].getElementById
) {
954 // Optimization for HTML document case
955 var oid
= ret
[ret
.length
-1].getElementById(m
[2]);
957 // Do a quick check for node name (where applicable) so
958 // that div#foo searches will be really fast
960 (!m
[3] || jQuery
.nodeName(oid
, m
[3])) ?
[oid] : [];
963 // Pre-compile a regular expression to handle class searches
965 var rec
= new RegExp("(^|\\s)" + m
[2] + "(\\s|$)");
967 // We need to find all descendant elements, it is more
968 // efficient to use getAll() when we are already further down
969 // the tree - we try to recognize that here
970 jQuery
.each( ret
, function(){
971 // Grab the tag name being searched for
972 var tag
= m
[1] != "" || m
[0] == "" ?
"*" : m
[2];
974 // Handle IE7 being really dumb about <object>s
975 if ( jQuery
.nodeName(this, "object") && tag
== "*" )
979 m
[1] != "" && ret
.length
!= 1 ?
980 jQuery
.getAll( this, [], m
[1], m
[2], rec
) :
981 this.getElementsByTagName( tag
)
985 // It's faster to filter by class and be done with it
986 if ( m
[1] == "." && ret
.length
== 1 )
987 r
= jQuery
.grep( r
, function(e
) {
988 return rec
.test(e
.className
);
991 // Same with ID filtering
992 if ( m
[1] == "#" && ret
.length
== 1 ) {
993 // Remember, then wipe out, the result set
997 // Then try to find the element with the ID
998 jQuery
.each( tmp
, function(){
999 if ( this.getAttribute("id") == m
[2] ) {
1009 t
= t
.replace( re2
, "" );
1014 // If a selector string still exists
1016 // Attempt to filter it
1017 var val
= jQuery
.filter(t
,r
);
1019 t
= jQuery
.trim(val
.t
);
1023 // Remove the root context
1024 if ( ret
&& ret
[0] == context
) ret
.shift();
1026 // And combine the results
1027 jQuery
.merge( done
, ret
);
1032 filter
: function(t
,r
,not
) {
1033 // Look for common filter expressions
1034 while ( t
&& /^
[a
-z
[({<*:.#
]/i
.test(t
) ) {
1036 var p
= jQuery
.parse
, m
;
1038 jQuery
.each( p
, function(i
,re
){
1040 // Look for, and replace, string-like sequences
1041 // and finally build a regexp out of it
1045 // Remove what we just matched
1046 t
= t
.substring( m
[0].length
);
1048 // Re-organize the first match
1049 if ( jQuery
.expr
[ m
[1] ]._resort
)
1050 m
= jQuery
.expr
[ m
[1] ]._resort( m
);
1056 // :not() is a special case that can be optimized by
1057 // keeping it out of the expression list
1058 if ( m
[1] == ":" && m
[2] == "not" )
1059 r
= jQuery
.filter(m
[3], r
, true).r
;
1061 // Handle classes as a special case (this will help to
1062 // improve the speed, as the regexp will only be compiled once)
1063 else if ( m
[1] == "." ) {
1065 var re
= new RegExp("(^|\\s)" + m
[2] + "(\\s|$)");
1066 r
= jQuery
.grep( r
, function(e
){
1067 return re
.test(e
.className ||
"");
1070 // Otherwise, find the expression to execute
1072 var f
= jQuery
.expr
[m
[1]];
1073 if ( typeof f
!= "string" )
1074 f
= jQuery
.expr
[m
[1]][m
[2]];
1076 // Build a custom macro to enclose it
1077 eval("f = function(a,i){" +
1078 ( jQuery
.expr
[ m
[1] ]._prefix ||
"" ) +
1079 "return " + f
+ "}");
1081 // Execute it against the current filter
1082 r
= jQuery
.grep( r
, f
, not
);
1086 // Return an array of filtered elements (r)
1087 // and the modified expression string (t)
1088 return { r
: r
, t
: t
};
1091 getAll
: function( o
, r
, token
, name
, re
) {
1092 for ( var s
= o
.firstChild
; s
; s
= s
.nextSibling
)
1093 if ( s
.nodeType
== 1 ) {
1097 add
= s
.className
&& re
.test(s
.className
);
1098 else if ( token
== "#" )
1099 add
= s
.getAttribute("id") == name
;
1104 if ( token
== "#" && r
.length
) break;
1107 jQuery
.getAll( s
, r
, token
, name
, re
);
1112 parents
: function( elem
){
1114 var cur
= elem
.parentNode
;
1115 while ( cur
&& cur
!= document
) {
1116 matched
.push( cur
);
1117 cur
= cur
.parentNode
;
1121 nth
: function(cur
,result
,dir
,elem
){
1122 result
= result ||
1;
1124 for ( ; cur
; cur
= cur
[dir] ) {
1125 if ( cur
.nodeType
== 1 ) num
++;
1126 if ( num
== result || result
== "even" && num
% 2 == 0 && num
> 1 && cur
== elem ||
1127 result
== "odd" && num
% 2 == 1 && cur
== elem
) return cur
;
1130 sibling
: function( n
, elem
) {
1133 for ( ; n
; n
= n
.nextSibling
) {
1134 if ( n
.nodeType
== 1 && (!elem || n
!= elem
) )
1142 * A number of helper functions used for managing events.
1143 * Many of the ideas behind this code orignated from
1144 * Dean Edwards' addEvent library.
1148 // Bind an event to an element
1149 // Original by Dean Edwards
1150 add
: function(element
, type
, handler
, data
) {
1151 // For whatever reason, IE has trouble passing the window object
1152 // around, causing it to be cloned in the process
1153 if ( jQuery
.browser
.msie
&& element
.setInterval
!= undefined
)
1156 // if data is passed, bind to handler
1158 handler
.data
= data
;
1160 // Make sure that the function being executed has a unique ID
1161 if ( !handler
.guid
)
1162 handler
.guid
= this.guid
++;
1164 // Init the element's event structure
1165 if (!element
.events
)
1166 element
.events
= {};
1168 // Get the current list of functions bound to this event
1169 var handlers
= element
.events
[type];
1171 // If it hasn't been initialized yet
1173 // Init the event handler queue
1174 handlers
= element
.events
[type] = {};
1176 // Remember an existing handler, if it's already there
1177 if (element
["on" + type
])
1178 handlers
[0] = element
["on" + type
];
1181 // Add the function to the element's handler list
1182 handlers
[handler
.guid
] = handler
;
1184 // And bind the global event handler to the element
1185 element
["on" + type
] = this.handle
;
1187 // Remember the function in a global list (for triggering)
1188 if (!this.global
[type])
1189 this.global
[type] = [];
1190 this.global
[type].push( element
);
1196 // Detach an event or set of events from an element
1197 remove
: function(element
, type
, handler
) {
1199 if ( type
&& type
.type
)
1200 delete element
.events
[ type
.type
][ type
.handler
.guid
];
1201 else if (type
&& element
.events
[type])
1203 delete element
.events
[type][handler
.guid
];
1205 for ( var i
in element
.events
[type] )
1206 delete element
.events
[type][i];
1208 for ( var j
in element
.events
)
1209 this.remove( element
, j
);
1212 trigger
: function(type
, data
, element
) {
1213 // Clone the incoming data, if any
1214 data
= jQuery
.makeArray(data ||
[]);
1216 // Handle a global trigger
1218 jQuery
.each( this.global
[type] ||
[], function(){
1219 jQuery
.event
.trigger( type
, data
, this );
1222 // Handle triggering a single element
1224 var handler
= element
["on" + type
], val
,
1225 fn
= jQuery
.isFunction( element
[ type
] );
1228 // Pass along a fake event
1229 data
.unshift( this.fix({ type
: type
, target
: element
}) );
1231 // Trigger the event
1232 if ( (val
= handler
.apply( element
, data
)) !== false )
1233 this.triggered
= true;
1236 if ( fn
&& val
!== false )
1239 this.triggered
= false;
1243 handle
: function(event
) {
1244 // Handle the second event of a trigger and when
1245 // an event is called after a page has unloaded
1246 if ( typeof jQuery
== "undefined" || jQuery
.event
.triggered
) return;
1248 // Empty object is for triggered events with no data
1249 event
= jQuery
.event
.fix( event || window
.event ||
{} );
1251 // returned undefined or false
1254 var c
= this.events
[event
.type
];
1256 var args
= [].slice
.call( arguments
, 1 );
1257 args
.unshift( event
);
1259 for ( var j
in c
) {
1260 // Pass in a reference to the handler function itself
1261 // So that we can later remove it
1262 args
[0].handler
= c
[j];
1263 args
[0].data
= c
[j].data
;
1265 if ( c
[j].apply( this, args
) === false ) {
1266 event
.preventDefault();
1267 event
.stopPropagation();
1268 returnValue
= false;
1272 // Clean up added properties in IE to prevent memory leak
1273 if (jQuery
.browser
.msie
) event
.target
= event
.preventDefault
= event
.stopPropagation
= event
.handler
= event
.data
= null;
1278 fix
: function(event
) {
1279 // Fix target property, if necessary
1280 if ( !event
.target
&& event
.srcElement
)
1281 event
.target
= event
.srcElement
;
1283 // Calculate pageX/Y if missing and clientX/Y available
1284 if ( event
.pageX
== undefined
&& event
.clientX
!= undefined
) {
1285 var e
= document
.documentElement
, b
= document
.body
;
1286 event
.pageX
= event
.clientX
+ (e
.scrollLeft || b
.scrollLeft
);
1287 event
.pageY
= event
.clientY
+ (e
.scrollTop || b
.scrollTop
);
1290 // check if target is a textnode (safari)
1291 if (jQuery
.browser
.safari
&& event
.target
.nodeType
== 3) {
1292 // store a copy of the original event object
1293 // and clone because target is read only
1294 var originalEvent
= event
;
1295 event
= jQuery
.extend({}, originalEvent
);
1297 // get parentnode from textnode
1298 event
.target
= originalEvent
.target
.parentNode
;
1300 // add preventDefault and stopPropagation since
1301 // they will not work on the clone
1302 event
.preventDefault
= function() {
1303 return originalEvent
.preventDefault();
1305 event
.stopPropagation
= function() {
1306 return originalEvent
.stopPropagation();
1310 // fix preventDefault and stopPropagation
1311 if (!event
.preventDefault
)
1312 event
.preventDefault
= function() {
1313 this.returnValue
= false;
1316 if (!event
.stopPropagation
)
1317 event
.stopPropagation
= function() {
1318 this.cancelBubble
= true;
1326 bind
: function( type
, data
, fn
) {
1327 return this.each(function(){
1328 jQuery
.event
.add( this, type
, fn || data
, data
);
1331 one
: function( type
, data
, fn
) {
1332 return this.each(function(){
1333 jQuery
.event
.add( this, type
, function(event
) {
1334 jQuery(this).unbind(event
);
1335 return (fn || data
).apply( this, arguments
);
1339 unbind
: function( type
, fn
) {
1340 return this.each(function(){
1341 jQuery
.event
.remove( this, type
, fn
);
1344 trigger
: function( type
, data
) {
1345 return this.each(function(){
1346 jQuery
.event
.trigger( type
, data
, this );
1349 toggle
: function() {
1350 // Save reference to arguments for access in closure
1353 return this.click(function(e
) {
1354 // Figure out which function to execute
1355 this.lastToggle
= this.lastToggle
== 0 ?
1 : 0;
1357 // Make sure that clicks stop
1360 // and execute the function
1361 return a
[this.lastToggle
].apply( this, [e] ) ||
false;
1364 hover
: function(f
,g
) {
1366 // A private function for handling mouse 'hovering'
1367 function handleHover(e
) {
1368 // Check if mouse(over|out) are still within the same parent element
1369 var p
= (e
.type
== "mouseover" ? e
.fromElement
: e
.toElement
) || e
.relatedTarget
;
1371 // Traverse up the tree
1372 while ( p
&& p
!= this ) try { p
= p
.parentNode
} catch(e
) { p
= this; };
1374 // If we actually just moused on to a sub-element, ignore it
1375 if ( p
== this ) return false;
1377 // Execute the right function
1378 return (e
.type
== "mouseover" ? f
: g
).apply(this, [e]);
1381 // Bind the function to the two event listeners
1382 return this.mouseover(handleHover
).mouseout(handleHover
);
1384 ready
: function(f
) {
1385 // If the DOM is already ready
1386 if ( jQuery
.isReady
)
1387 // Execute the function immediately
1388 f
.apply( document
, [jQuery] );
1390 // Otherwise, remember the function for later
1392 // Add the function to the wait list
1393 jQuery
.readyList
.push( function() { return f
.apply(this, [jQuery]) } );
1402 * All the code that makes DOM Ready work nicely.
1407 // Handle when the DOM is ready
1409 // Make sure that the DOM is not already loaded
1410 if ( !jQuery
.isReady
) {
1411 // Remember that the DOM is ready
1412 jQuery
.isReady
= true;
1414 // If there are functions bound, to execute
1415 if ( jQuery
.readyList
) {
1416 // Execute all of them
1417 jQuery
.each( jQuery
.readyList
, function(){
1418 this.apply( document
);
1421 // Reset the list of functions
1422 jQuery
.readyList
= null;
1424 // Remove event lisenter to avoid memory leak
1425 if ( jQuery
.browser
.mozilla || jQuery
.browser
.opera
)
1426 document
.removeEventListener( "DOMContentLoaded", jQuery
.ready
, false );
1433 jQuery
.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
1434 "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
1435 "submit,keydown,keypress,keyup,error").split(","), function(i
,o
){
1437 // Handle event binding
1438 jQuery
.fn
[o] = function(f
){
1439 return f ?
this.bind(o
, f
) : this.trigger(o
);
1444 // If Mozilla is used
1445 if ( jQuery
.browser
.mozilla || jQuery
.browser
.opera
)
1446 // Use the handy event callback
1447 document
.addEventListener( "DOMContentLoaded", jQuery
.ready
, false );
1449 // If IE is used, use the excellent hack by Matthias Miller
1450 // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
1451 else if ( jQuery
.browser
.msie
) {
1453 // Only works if you document.write() it
1454 document
.write("<scr" + "ipt id=__ie_init defer=true " +
1455 "src=//:><\/script>");
1457 // Use the defer script hack
1458 var script
= document
.getElementById("__ie_init");
1460 // script does not exist if jQuery is loaded dynamically
1462 script
.onreadystatechange
= function() {
1463 if ( this.readyState
!= "complete" ) return;
1464 this.parentNode
.removeChild( this );
1468 // Clear from memory
1471 // If Safari is used
1472 } else if ( jQuery
.browser
.safari
)
1473 // Continually check to see if the document.readyState is valid
1474 jQuery
.safariTimer
= setInterval(function(){
1475 // loaded and complete are both valid states
1476 if ( document
.readyState
== "loaded" ||
1477 document
.readyState
== "complete" ) {
1479 // If either one are found, remove the timer
1480 clearInterval( jQuery
.safariTimer
);
1481 jQuery
.safariTimer
= null;
1483 // and execute any waiting functions
1488 // A fallback to window.onload, that will always work
1489 jQuery
.event
.add( window
, "load", jQuery
.ready
);
1493 // Clean up after IE to avoid memory leaks
1494 if (jQuery
.browser
.msie
)
1495 jQuery(window
).one("unload", function() {
1496 var global
= jQuery
.event
.global
;
1497 for ( var type
in global
) {
1498 var els
= global
[type], i
= els
.length
;
1499 if ( i
&& type
!= 'unload' )
1501 jQuery
.event
.remove(els
[i
-1], type
);
1507 show
: function(speed
,callback
){
1508 var hidden
= this.filter(":hidden");
1511 height
: "show", width
: "show", opacity
: "show"
1512 }, speed
, callback
) :
1514 hidden
.each(function(){
1515 this.style
.display
= this.oldblock ?
this.oldblock
: "";
1516 if ( jQuery
.css(this,"display") == "none" )
1517 this.style
.display
= "block";
1522 hide
: function(speed
,callback
){
1523 var visible
= this.filter(":visible");
1526 height
: "hide", width
: "hide", opacity
: "hide"
1527 }, speed
, callback
) :
1529 visible
.each(function(){
1530 this.oldblock
= this.oldblock || jQuery
.css(this,"display");
1531 if ( this.oldblock
== "none" )
1532 this.oldblock
= "block";
1533 this.style
.display
= "none";
1538 // Save the old toggle function
1539 _toggle
: jQuery
.fn
.toggle
,
1540 toggle
: function( fn
, fn2
){
1541 var args
= arguments
;
1542 return jQuery
.isFunction(fn
) && jQuery
.isFunction(fn2
) ?
1543 this._toggle( fn
, fn2
) :
1544 this.each(function(){
1545 jQuery(this)[ jQuery(this).is(":hidden") ?
"show" : "hide" ]
1546 .apply( jQuery(this), args
);
1549 slideDown
: function(speed
,callback
){
1550 return this.animate({height
: "show"}, speed
, callback
);
1552 slideUp
: function(speed
,callback
){
1553 return this.animate({height
: "hide"}, speed
, callback
);
1555 slideToggle
: function(speed
, callback
){
1556 return this.each(function(){
1557 var state
= jQuery(this).is(":hidden") ?
"show" : "hide";
1558 jQuery(this).animate({height
: state
}, speed
, callback
);
1561 fadeIn
: function(speed
, callback
){
1562 return this.animate({opacity
: "show"}, speed
, callback
);
1564 fadeOut
: function(speed
, callback
){
1565 return this.animate({opacity
: "hide"}, speed
, callback
);
1567 fadeTo
: function(speed
,to
,callback
){
1568 return this.animate({opacity
: to
}, speed
, callback
);
1570 animate
: function( prop
, speed
, easing
, callback
) {
1571 return this.queue(function(){
1573 this.curAnim
= jQuery
.extend({}, prop
);
1574 var opt
= jQuery
.speed(speed
, easing
, callback
);
1576 for ( var p
in prop
) {
1577 var e
= new jQuery
.fx( this, opt
, p
);
1578 if ( prop
[p].constructor
== Number
)
1579 e
.custom( e
.cur(), prop
[p] );
1581 e
[ prop
[p] ]( prop
);
1586 queue
: function(type
,fn
){
1592 return this.each(function(){
1596 if ( !this.queue
[type] )
1597 this.queue
[type] = [];
1599 this.queue
[type].push( fn
);
1601 if ( this.queue
[type].length
== 1 )
1610 speed
: function(speed
, easing
, fn
) {
1611 var opt
= speed
&& speed
.constructor
== Object ? speed
: {
1612 complete
: fn ||
!fn
&& easing ||
1613 jQuery
.isFunction( speed
) && speed
,
1615 easing
: fn
&& easing || easing
&& easing
.constructor
!= Function
&& easing
1618 opt
.duration
= (opt
.duration
&& opt
.duration
.constructor
== Number ?
1620 { slow
: 600, fast
: 200 }[opt
.duration
]) ||
400;
1623 opt
.old
= opt
.complete
;
1624 opt
.complete
= function(){
1625 jQuery
.dequeue(this, "fx");
1626 if ( jQuery
.isFunction( opt
.old
) )
1627 opt
.old
.apply( this );
1637 dequeue
: function(elem
,type
){
1638 type
= type ||
"fx";
1640 if ( elem
.queue
&& elem
.queue
[type] ) {
1642 elem
.queue
[type].shift();
1644 // Get next function
1645 var f
= elem
.queue
[type][0];
1647 if ( f
) f
.apply( elem
);
1652 * I originally wrote fx() as a clone of moo.fx and in the process
1653 * of making it small in size the code became illegible to sane
1654 * people. You've been warned.
1657 fx
: function( elem
, options
, prop
){
1664 // Store display property
1665 var oldDisplay
= jQuery
.css(elem
, "display");
1667 // Make sure that nothing sneaks out
1668 y
.overflow
= "hidden";
1670 // Simple function for setting a style value
1673 options
.step
.apply( elem
, [ z
.now
] );
1675 if ( prop
== "opacity" )
1676 jQuery
.attr(y
, "opacity", z
.now
); // Let attr handle opacity
1677 else if ( parseInt(z
.now
) ) // My hate for IE will never die
1678 y
[prop] = parseInt(z
.now
) + "px";
1680 y
.display
= "block"; // Set display property to block for animation
1683 // Figure out the maximum number to run to
1685 return parseFloat( jQuery
.css(elem
,prop
) );
1688 // Get the current size
1690 var r
= parseFloat( jQuery
.curCSS(elem
, prop
) );
1691 return r
&& r
> -10000 ? r
: z
.max();
1694 // Start an animation from one number to another
1695 z
.custom
= function(from
,to
){
1696 z
.startTime
= (new Date()).getTime();
1700 z
.timer
= setInterval(function(){
1705 // Simple 'show' function
1706 z
.show
= function(){
1707 if ( !elem
.orig
) elem
.orig
= {};
1709 // Remember where we started, so that we can go back to it later
1710 elem
.orig
[prop] = this.cur();
1712 options
.show
= true;
1714 // Begin the animation
1715 z
.custom(0, elem
.orig
[prop]);
1717 // Stupid IE, look what you made me do
1718 if ( prop
!= "opacity" )
1722 // Simple 'hide' function
1723 z
.hide
= function(){
1724 if ( !elem
.orig
) elem
.orig
= {};
1726 // Remember where we started, so that we can go back to it later
1727 elem
.orig
[prop] = this.cur();
1729 options
.hide
= true;
1731 // Begin the animation
1732 z
.custom(elem
.orig
[prop], 0);
1735 //Simple 'toggle' function
1736 z
.toggle
= function() {
1737 if ( !elem
.orig
) elem
.orig
= {};
1739 // Remember where we started, so that we can go back to it later
1740 elem
.orig
[prop] = this.cur();
1742 if(oldDisplay
== "none") {
1743 options
.show
= true;
1745 // Stupid IE, look what you made me do
1746 if ( prop
!= "opacity" )
1749 // Begin the animation
1750 z
.custom(0, elem
.orig
[prop]);
1752 options
.hide
= true;
1754 // Begin the animation
1755 z
.custom(elem
.orig
[prop], 0);
1759 // Each step of an animation
1760 z
.step
= function(firstNum
, lastNum
){
1761 var t
= (new Date()).getTime();
1763 if (t
> options
.duration
+ z
.startTime
) {
1765 clearInterval(z
.timer
);
1771 if (elem
.curAnim
) elem
.curAnim
[ prop
] = true;
1774 for ( var i
in elem
.curAnim
)
1775 if ( elem
.curAnim
[i] !== true )
1779 // Reset the overflow
1782 // Reset the display
1783 y
.display
= oldDisplay
;
1784 if (jQuery
.css(elem
, "display") == "none")
1785 y
.display
= "block";
1787 // Hide the element if the "hide" operation was done
1791 // Reset the properties, if the item has been hidden or shown
1792 if ( options
.hide || options
.show
)
1793 for ( var p
in elem
.curAnim
)
1795 jQuery
.attr(y
, p
, elem
.orig
[p]);
1800 // If a callback was provided, execute it
1801 if ( done
&& jQuery
.isFunction( options
.complete
) )
1802 // Execute the complete function
1803 options
.complete
.apply( elem
);
1805 var n
= t
- this.startTime
;
1806 // Figure out where in the animation we are and set the number
1807 var p
= n
/ options
.duration
;
1809 // If the easing function exists, then use it
1810 z
.now
= options
.easing
&& jQuery
.easing
[options
.easing
] ?
1811 jQuery
.easing
[options
.easing
](p
, n
, firstNum
, (lastNum
-firstNum
), options
.duration
) :
1812 // else use default linear easing
1813 ((-Math
.cos(p
*Math
.PI
)/2) + 0.5) * (lastNum
-firstNum
) + firstNum
;
1815 // Perform the next step of the animation
1823 loadIfModified
: function( url
, params
, callback
) {
1824 this.load( url
, params
, callback
, 1 );
1826 load
: function( url
, params
, callback
, ifModified
) {
1827 if ( jQuery
.isFunction( url
) )
1828 return this.bind("load", url
);
1830 callback
= callback ||
function(){};
1832 // Default to a GET request
1835 // If the second parameter was provided
1837 // If it's a function
1838 if ( jQuery
.isFunction( params
) ) {
1839 // We assume that it's the callback
1843 // Otherwise, build a param string
1845 params
= jQuery
.param( params
);
1851 // Request the remote document
1856 ifModified
: ifModified
,
1857 complete
: function(res
, status
){
1858 if ( status
== "success" ||
!ifModified
&& status
== "notmodified" )
1859 // Inject the HTML into all the matched elements
1860 self
.attr("innerHTML", res
.responseText
)
1861 // Execute all the scripts inside of the newly-injected HTML
1864 .each( callback
, [res
.responseText
, status
, res
] );
1866 callback
.apply( self
, [res
.responseText
, status
, res
] );
1871 serialize
: function() {
1872 return jQuery
.param( this );
1874 evalScripts
: function() {
1875 return this.find("script").each(function(){
1877 jQuery
.getScript( this.src
);
1879 jQuery
.globalEval( this.text ||
this.textContent ||
this.innerHTML ||
"" );
1885 // If IE is used, create a wrapper for the XMLHttpRequest object
1886 if ( !window
.XMLHttpRequest
)
1887 XMLHttpRequest
= function(){
1888 return new ActiveXObject("Microsoft.XMLHTTP");
1891 // Attach a bunch of functions for handling common AJAX events
1893 jQuery
.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i
,o
){
1894 jQuery
.fn
[o] = function(f
){
1895 return this.bind(o
, f
);
1900 get
: function( url
, data
, callback
, type
, ifModified
) {
1901 // shift arguments if data argument was ommited
1902 if ( jQuery
.isFunction( data
) ) {
1907 return jQuery
.ajax({
1912 ifModified
: ifModified
1915 getIfModified
: function( url
, data
, callback
, type
) {
1916 return jQuery
.get(url
, data
, callback
, type
, 1);
1918 getScript
: function( url
, callback
) {
1919 return jQuery
.get(url
, null, callback
, "script");
1921 getJSON
: function( url
, data
, callback
) {
1922 return jQuery
.get(url
, data
, callback
, "json");
1924 post
: function( url
, data
, callback
, type
) {
1925 if ( jQuery
.isFunction( data
) ) {
1930 return jQuery
.ajax({
1941 ajaxTimeout
: function( timeout
) {
1942 jQuery
.ajaxSettings
.timeout
= timeout
;
1944 ajaxSetup
: function( settings
) {
1945 jQuery
.extend( jQuery
.ajaxSettings
, settings
);
1952 contentType
: "application/x-www-form-urlencoded",
1958 // Last-Modified header cache for next request
1960 ajax
: function( s
) {
1961 // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
1962 s
= jQuery
.extend({}, jQuery
.ajaxSettings
, s
);
1964 // if data available
1966 // convert data if not already a string
1967 if (s
.processData
&& typeof s
.data
!= "string")
1968 s
.data
= jQuery
.param(s
.data
);
1969 // append data to url for get requests
1970 if( s
.type
.toLowerCase() == "get" ) {
1971 // "?" + data or "&" + data (in case there are already params)
1972 s
.url
+= ((s
.url
.indexOf("?") > -1) ?
"&" : "?") + s
.data
;
1973 // IE likes to send both get and post data, prevent this
1978 // Watch for a new set of requests
1979 if ( s
.global
&& ! jQuery
.active
++ )
1980 jQuery
.event
.trigger( "ajaxStart" );
1982 var requestDone
= false;
1984 // Create the request object
1985 var xml
= new XMLHttpRequest();
1988 xml
.open(s
.type
, s
.url
, s
.async
);
1990 // Set the correct header, if data is being sent
1992 xml
.setRequestHeader("Content-Type", s
.contentType
);
1994 // Set the If-Modified-Since header, if ifModified mode.
1996 xml
.setRequestHeader("If-Modified-Since",
1997 jQuery
.lastModified
[s
.url
] ||
"Thu, 01 Jan 1970 00:00:00 GMT" );
1999 // Set header so the called script knows that it's an XMLHttpRequest
2000 xml
.setRequestHeader("X-Requested-With", "XMLHttpRequest");
2002 // Make sure the browser sends the right content length
2003 if ( xml
.overrideMimeType
)
2004 xml
.setRequestHeader("Connection", "close");
2006 // Allow custom headers/mimetypes
2011 jQuery
.event
.trigger("ajaxSend", [xml
, s
]);
2013 // Wait for a response to come back
2014 var onreadystatechange
= function(isTimeout
){
2015 // The transfer is complete and the data is available, or the request timed out
2016 if ( xml
&& (xml
.readyState
== 4 || isTimeout
== "timeout") ) {
2020 status
= jQuery
.httpSuccess( xml
) && isTimeout
!= "timeout" ?
2021 s
.ifModified
&& jQuery
.httpNotModified( xml
, s
.url
) ?
"notmodified" : "success" : "error";
2022 // Make sure that the request was successful or notmodified
2023 if ( status
!= "error" ) {
2024 // Cache Last-Modified header, if ifModified mode.
2027 modRes
= xml
.getResponseHeader("Last-Modified");
2028 } catch(e
) {} // swallow exception thrown by FF if header is not available
2030 if ( s
.ifModified
&& modRes
)
2031 jQuery
.lastModified
[s
.url
] = modRes
;
2033 // process the data (runs the xml through httpData regardless of callback)
2034 var data
= jQuery
.httpData( xml
, s
.dataType
);
2036 // If a local callback was specified, fire it and pass it the data
2038 s
.success( data
, status
);
2040 // Fire the global callback
2042 jQuery
.event
.trigger( "ajaxSuccess", [xml
, s
] );
2044 jQuery
.handleError(s
, xml
, status
);
2047 jQuery
.handleError(s
, xml
, status
, e
);
2050 // The request was completed
2052 jQuery
.event
.trigger( "ajaxComplete", [xml
, s
] );
2054 // Handle the global AJAX counter
2055 if ( s
.global
&& ! --jQuery
.active
)
2056 jQuery
.event
.trigger( "ajaxStop" );
2060 s
.complete(xml
, status
);
2062 // Stop memory leaks
2063 xml
.onreadystatechange
= function(){};
2067 xml
.onreadystatechange
= onreadystatechange
;
2070 if ( s
.timeout
> 0 )
2071 setTimeout(function(){
2072 // Check to see if the request is still happening
2074 // Cancel the request
2078 onreadystatechange( "timeout" );
2082 // save non-leaking reference
2089 jQuery
.handleError(s
, xml
, null, e
);
2092 // firefox 1.5 doesn't fire statechange for sync requests
2094 onreadystatechange();
2096 // return XMLHttpRequest to allow aborting the request etc.
2100 handleError
: function( s
, xml
, status
, e
) {
2101 // If a local callback was specified, fire it
2102 if ( s
.error
) s
.error( xml
, status
, e
);
2104 // Fire the global callback
2106 jQuery
.event
.trigger( "ajaxError", [xml
, s
, e
] );
2109 // Counter for holding the number of active queries
2112 // Determines if an XMLHttpRequest was successful or not
2113 httpSuccess
: function( r
) {
2115 return !r
.status
&& location
.protocol
== "file:" ||
2116 ( r
.status
>= 200 && r
.status
< 300 ) || r
.status
== 304 ||
2117 jQuery
.browser
.safari
&& r
.status
== undefined
;
2122 // Determines if an XMLHttpRequest returns NotModified
2123 httpNotModified
: function( xml
, url
) {
2125 var xmlRes
= xml
.getResponseHeader("Last-Modified");
2127 // Firefox always returns 200. check Last-Modified date
2128 return xml
.status
== 304 || xmlRes
== jQuery
.lastModified
[url] ||
2129 jQuery
.browser
.safari
&& xml
.status
== undefined
;
2134 /* Get the data out of an XMLHttpRequest.
2135 * Return parsed XML if content-type header is "xml" and type is "xml" or omitted,
2136 * otherwise return plain text.
2137 * (String) data - The type of data that you're expecting back,
2138 * (e.g. "xml", "html", "script")
2140 httpData
: function( r
, type
) {
2141 var ct
= r
.getResponseHeader("content-type");
2142 var data
= !type
&& ct
&& ct
.indexOf("xml") >= 0;
2143 data
= type
== "xml" || data ? r
.responseXML
: r
.responseText
;
2145 // If the type is "script", eval it in global context
2146 if ( type
== "script" )
2147 jQuery
.globalEval( data
);
2149 // Get the JavaScript object, if JSON is used.
2150 if ( type
== "json" )
2151 eval( "data = " + data
);
2153 // evaluate scripts within html
2154 if ( type
== "html" )
2155 jQuery("<div>").html(data
).evalScripts();
2160 // Serialize an array of form elements or a set of
2161 // key/values into a query string
2162 param
: function( a
) {
2165 // If an array was passed in, assume that it is an array
2167 if ( a
.constructor
== Array || a
.jquery
)
2168 // Serialize the form elements
2169 jQuery
.each( a
, function(){
2170 s
.push( encodeURIComponent(this.name
) + "=" + encodeURIComponent( this.value
) );
2173 // Otherwise, assume that it's an object of key/value pairs
2175 // Serialize the key/values
2177 // If the value is an array then the key names need to be repeated
2178 if ( a
[j] && a
[j].constructor
== Array
)
2179 jQuery
.each( a
[j], function(){
2180 s
.push( encodeURIComponent(j
) + "=" + encodeURIComponent( this ) );
2183 s
.push( encodeURIComponent(j
) + "=" + encodeURIComponent( a
[j] ) );
2185 // Return the resulting serialization
2189 // evalulates a script in global context
2190 // not reliable for safari
2191 globalEval
: function( data
) {
2192 if ( window
.execScript
)
2193 window
.execScript( data
);
2194 else if ( jQuery
.browser
.safari
)
2195 // safari doesn't provide a synchronous global eval
2196 window
.setTimeout( data
, 0 );
2198 eval
.call( window
, data
);