jQuery 1.0.4 - New Wave Javascript(js源文件)

jQuery 1.0.4 - New Wave Javascript(js源文件)

教程区编辑臧2021-01-22 18:36:09334A+A-
复制代码 代码如下:
/*preventexecutionofjQueryifincludedmorethenonce*/
if(typeofwindow.jQuery=="undefined"){
/*
*jQuery1.0.4-NewWaveJavascript
*
*Copyright(c)2006JohnResig(jquery.com)
*DuallicensedundertheMIT(MIT-LICENSE.txt)
*andGPL(GPL-LICENSE.txt)licenses.
*
*$Date:2006-12-1215:33:10-0500(Tue,12Dec2006)$
*$Rev:696$
*/

//Globalundefinedvariable
window.undefined=window.undefined;

varjQuery=function(a,c){

//Shortcutfordocumentready
if(a&&typeofa=="function"&&jQuery.fn.ready&&!a.nodeType&&a[0]==undefined)//SafarireportstypeofonDOMNodeListsasafunction
returnjQuery(document).ready(a);

//Makesurethataselectionwasprovided
a=a||document;

//WatchforwhenajQueryobjectispassedastheselector
if(a.jquery)
returnjQuery(jQuery.merge(a,[]));

//WatchforwhenajQueryobjectispassedatthecontext
if(c&&c.jquery)
returnjQuery(c).find(a);

//Ifthecontextisglobal,returnanewobject
if(window==this)
returnnewjQuery(a,c);

//HandleHTMLstrings
if(typeofa=="string"){
varm=/^[^<]*(<.+>)[^>]*$/.exec(a);
if(m)a=jQuery.clean([m[1]]);
}

//Watchforwhenanarrayispassedin
this.set(a.constructor==Array||a.length&&a!=window&&!a.nodeType&&a[0]!=undefined&&a[0].nodeType?
//AssumethatitisanarrayofDOMElements
jQuery.merge(a,[]):

//Findthematchingelementsandsavethemforlater
jQuery.find(a,c));

//Seeifanextrafunctionwasprovided
varfn=arguments[arguments.length-1];

//Ifso,executeitincontext
if(fn&&typeoffn=="function")
this.each(fn);

returnthis;
};

//Mapoverthe$incaseofoverwrite
if(typeof$!="undefined")
jQuery._$=$;

//MapthejQuerynamespacetothe'$'one
var$=jQuery;



jQuery.fn=jQuery.prototype={

jquery:"1.0.4",


size:function(){
returnthis.length;
},


get:function(num){
returnnum==undefined?

//Returna'clean'array
jQuery.merge(this,[]):

//Returnjusttheobject
this[num];
},

set:function(array){
//UseatrickyhacktomakethejQueryobject
//lookandfeellikeanarray
this.length=0;
[].push.apply(this,array);
returnthis;
},

each:function(fn,args){
returnjQuery.each(this,fn,args);
},

index:function(obj){
varpos=-1;
this.each(function(i){
if(this==obj)pos=i;
});
returnpos;
},


attr:function(key,value,type){
//Checktoseeifwe'resettingstylevalues
returnkey.constructor!=String||value!=undefined?
this.each(function(){
//Seeifwe'resettingahashofstyles
if(value==undefined)
//Setallthestyles
for(varpropinkey)
jQuery.attr(
type?this.style:this,
prop,key[prop]
);

//Seeifwe'resettingasinglekey/valuestyle
else
jQuery.attr(
type?this.style:this,
key,value
);
}):

//Lookforthecasewherewe'reaccessingastylevalue
jQuery[type||"attr"](this[0],key);
},


css:function(key,value){
returnthis.attr(key,value,"curCSS");
},

text:function(e){
e=e||this;
vart="";
for(varj=0;j<e.length;j++){
varr=e[j].childNodes;
for(vari=0;i<r.length;i++)
if(r[i].nodeType!=8)
t+=r[i].nodeType!=1?
r[i].nodeValue:jQuery.fn.text([r[i]]);
}
returnt;
},


wrap:function(){
//Theelementstowrapthetargetaround
vara=jQuery.clean(arguments);

//Wrapeachofthematchedelementsindividually
returnthis.each(function(){
//Clonethestructurethatwe'reusingtowrap
varb=a[0].cloneNode(true);

//Insertitbeforetheelementtobewrapped
this.parentNode.insertBefore(b,this);

//Findthedeepestpointinthewrapstructure
while(b.firstChild)
b=b.firstChild;

//Movethematchedelementtowithinthewrapstructure
b.appendChild(this);
});
},


append:function(){
returnthis.domManip(arguments,true,1,function(a){
this.appendChild(a);
});
},


prepend:function(){
returnthis.domManip(arguments,true,-1,function(a){
this.insertBefore(a,this.firstChild);
});
},


before:function(){
returnthis.domManip(arguments,false,1,function(a){
this.parentNode.insertBefore(a,this);
});
},


after:function(){
returnthis.domManip(arguments,false,-1,function(a){
this.parentNode.insertBefore(a,this.nextSibling);
});
},

end:function(){
if(!(this.stack&&this.stack.length))
returnthis;
returnthis.set(this.stack.pop());
},

find:function(t){
returnthis.pushStack(jQuery.map(this,function(a){
returnjQuery.find(t,a);
}),arguments);
},

clone:function(deep){
returnthis.pushStack(jQuery.map(this,function(a){
returna.cloneNode(deep!=undefined?deep:true);
}),arguments);
},


filter:function(t){
returnthis.pushStack(
t.constructor==Array&&
jQuery.map(this,function(a){
for(vari=0;i<t.length;i++)
if(jQuery.filter(t[i],[a]).r.length)
returna;
returnnull;
})||

t.constructor==Boolean&&
(t?this.get():[])||

typeoft=="function"&&
jQuery.grep(this,t)||

jQuery.filter(t,this).r,arguments);
},


not:function(t){
returnthis.pushStack(typeoft=="string"?
jQuery.filter(t,this,false).r:
jQuery.grep(this,function(a){returna!=t;}),arguments);
},


add:function(t){
returnthis.pushStack(jQuery.merge(this,typeoft=="string"?
jQuery.find(t):t.constructor==Array?t:[t]),arguments);
},

is:function(expr){
returnexpr?jQuery.filter(expr,this).r.length>0:false;
},

domManip:function(args,table,dir,fn){
varclone=this.size()>1;
vara=jQuery.clean(args);

returnthis.each(function(){
varobj=this;

if(table&&this.nodeName.toUpperCase()=="TABLE"&&a[0].nodeName.toUpperCase()!="THEAD"){
vartbody=this.getElementsByTagName("tbody");

if(!tbody.length){
obj=document.createElement("tbody");
this.appendChild(obj);
}else
obj=tbody[0];
}

for(vari=(dir<0?a.length-1:0);
i!=(dir<0?dir:a.length);i+=dir){
fn.apply(obj,[clone?a[i].cloneNode(true):a[i]]);
}
});
},

pushStack:function(a,args){
varfn=args&&args[args.length-1];
varfn2=args&&args[args.length-2];

if(fn&&fn.constructor!=Function)fn=null;
if(fn2&&fn2.constructor!=Function)fn2=null;

if(!fn){
if(!this.stack)this.stack=[];
this.stack.push(this.get());
this.set(a);
}else{
varold=this.get();
this.set(a);

if(fn2&&a.length||!fn2)
this.each(fn2||fn).set(old);
else
this.set(old).each(fn);
}

returnthis;
}
};


jQuery.extend=jQuery.fn.extend=function(){
//copyreferencetotargetobject
vartarget=arguments[0],
a=1;

//extendjQueryitselfifonlyoneargumentispassed
if(arguments.length==1){
target=this;
a=0;
}
varprop;
while(prop=arguments[a++])
//Extendthebaseobject
for(variinprop)target[i]=prop[i];

//Returnthemodifiedobject
returntarget;
};

jQuery.extend({

init:function(){
jQuery.initDone=true;

jQuery.each(jQuery.macros.axis,function(i,n){
jQuery.fn[i]=function(a){
varret=jQuery.map(this,n);
if(a&&typeofa=="string")
ret=jQuery.filter(a,ret).r;
returnthis.pushStack(ret,arguments);
};
});

jQuery.each(jQuery.macros.to,function(i,n){
jQuery.fn[i]=function(){
vara=arguments;
returnthis.each(function(){
for(varj=0;j<a.length;j++)
jQuery(a[j])[n](this);
});
};
});

jQuery.each(jQuery.macros.each,function(i,n){
jQuery.fn[i]=function(){
returnthis.each(n,arguments);
};
});

jQuery.each(jQuery.macros.filter,function(i,n){
jQuery.fn[n]=function(num,fn){
returnthis.filter(":"+n+"("+num+")",fn);
};
});

jQuery.each(jQuery.macros.attr,function(i,n){
n=n||i;
jQuery.fn[i]=function(h){
returnh==undefined?
this.length?this[0][n]:null:
this.attr(n,h);
};
});

jQuery.each(jQuery.macros.css,function(i,n){
jQuery.fn[n]=function(h){
returnh==undefined?
(this.length?jQuery.css(this[0],n):null):
this.css(n,h);
};
});

},

//argsisforinternalusageonly
each:function(obj,fn,args){
if(obj.length==undefined)
for(variinobj)
fn.apply(obj[i],args||[i,obj[i]]);
else
for(vari=0;i<obj.length;i++)
if(fn.apply(obj[i],args||[i,obj[i]])===false)break;
returnobj;
},

className:{
add:function(o,c){
if(jQuery.className.has(o,c))return;
o.className+=(o.className?"":"")+c;
},
remove:function(o,c){
if(!c){
o.className="";
}else{
varclasses=o.className.split("");
for(vari=0;i<classes.length;i++){
if(classes[i]==c){
classes.splice(i,1);
break;
}
}
o.className=classes.join('');
}
},
has:function(e,a){
if(e.className!=undefined)
e=e.className;
returnnewRegExp("(^|\\s)"+a+"(\\s|$)").test(e);
}
},

swap:function(e,o,f){
for(variino){
e.style["old"+i]=e.style[i];
e.style[i]=o[i];
}
f.apply(e,[]);
for(variino)
e.style[i]=e.style["old"+i];
},

css:function(e,p){
if(p=="height"||p=="width"){
varold={},oHeight,oWidth,d=["Top","Bottom","Right","Left"];

for(vari=0;i<d.length;i++){
old["padding"+d[i]]=0;
old["border"+d[i]+"Width"]=0;
}

jQuery.swap(e,old,function(){
if(jQuery.css(e,"display")!="none"){
oHeight=e.offsetHeight;
oWidth=e.offsetWidth;
}else{
e=jQuery(e.cloneNode(true))
.find(":radio").removeAttr("checked").end()
.css({
visibility:"hidden",position:"absolute",display:"block",right:"0",left:"0"
}).appendTo(e.parentNode)[0];

varparPos=jQuery.css(e.parentNode,"position");
if(parPos==""||parPos=="static")
e.parentNode.style.position="relative";

oHeight=e.clientHeight;
oWidth=e.clientWidth;

if(parPos==""||parPos=="static")
e.parentNode.style.position="static";

e.parentNode.removeChild(e);
}
});

returnp=="height"?oHeight:oWidth;
}

returnjQuery.curCSS(e,p);
},

curCSS:function(elem,prop,force){
varret;

if(prop=='opacity'&&jQuery.browser.msie)
returnjQuery.attr(elem.style,'opacity');

if(prop=="float"||prop=="cssFloat")
prop=jQuery.browser.msie?"styleFloat":"cssFloat";

if(!force&&elem.style[prop]){

ret=elem.style[prop];

}elseif(document.defaultView&&document.defaultView.getComputedStyle){

if(prop=="cssFloat"||prop=="styleFloat")
prop="float";

prop=prop.replace(/([A-Z])/g,"-$1").toLowerCase();
varcur=document.defaultView.getComputedStyle(elem,null);

if(cur)
ret=cur.getPropertyValue(prop);
elseif(prop=='display')
ret='none';
else
jQuery.swap(elem,{display:'block'},function(){
varc=document.defaultView.getComputedStyle(this,'');
ret=c&&c.getPropertyValue(prop)||'';
});

}elseif(elem.currentStyle){

varnewProp=prop.replace(/\-(\w)/g,function(m,c){returnc.toUpperCase();});
ret=elem.currentStyle[prop]||elem.currentStyle[newProp];

}

returnret;
},

clean:function(a){
varr=[];
for(vari=0;i<a.length;i++){
vararg=a[i];
if(typeofarg=="string"){//ConverthtmlstringintoDOMnodes
//Trimwhitespace,otherwiseindexOfwon'tworkasexpected
vars=jQuery.trim(arg),div=document.createElement("div"),wrap=[0,"",""];

if(!s.indexOf("<opt"))//optionoroptgroup
wrap=[1,"<select>","</select>"];
elseif(!s.indexOf("<thead")||!s.indexOf("<tbody"))
wrap=[1,"<table>","</table>"];
elseif(!s.indexOf("<tr"))
wrap=[2,"<table>","</table>"];//tbodyauto-inserted
elseif(!s.indexOf("<td")||!s.indexOf("<th"))
wrap=[3,"<table><tbody><tr>","</tr></tbody></table>"];

//Gotohtmlandback,thenpeeloffextrawrappers
div.innerHTML=wrap[1]+s+wrap[2];
while(wrap[0]--)div=div.firstChild;
arg=div.childNodes;
}


if(arg.length!=undefined&&((jQuery.browser.safari&&typeofarg=='function')||!arg.nodeType))//SafarireportstypeofonaDOMNodeListtobeafunction
for(varn=0;n<arg.length;n++)//HandlesArray,jQuery,DOMNodeListcollections
r.push(arg[n]);
else
r.push(arg.nodeType?arg:document.createTextNode(arg.toString()));
}

returnr;
},

expr:{
"":"m[2]=='*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
"#":"a.getAttribute('id')&&a.getAttribute('id')==m[2]",
":":{
//PositionChecks
lt:"i<m[3]-0",
gt:"i>m[3]-0",
nth:"m[3]-0==i",
eq:"m[3]-0==i",
first:"i==0",
last:"i==r.length-1",
even:"i%2==0",
odd:"i%2",

//ChildChecks
"nth-child":"jQuery.sibling(a,m[3]).cur",
"first-child":"jQuery.sibling(a,0).cur",
"last-child":"jQuery.sibling(a,0).last",
"only-child":"jQuery.sibling(a).length==1",

//ParentChecks
parent:"a.childNodes.length",
empty:"!a.childNodes.length",

//TextCheck
contains:"jQuery.fn.text.apply([a]).indexOf(m[3])>=0",

//Visibility
visible:"a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
hidden:"a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",

//Formattributes
enabled:"!a.disabled",
disabled:"a.disabled",
checked:"a.checked",
selected:"a.selected||jQuery.attr(a,'selected')",

//Formelements
text:"a.type=='text'",
radio:"a.type=='radio'",
checkbox:"a.type=='checkbox'",
file:"a.type=='file'",
password:"a.type=='password'",
submit:"a.type=='submit'",
image:"a.type=='image'",
reset:"a.type=='reset'",
button:"a.type=='button'",
input:"/input|select|textarea|button/i.test(a.nodeName)"
},
".":"jQuery.className.has(a,m[2])",
"@":{
"=":"z==m[4]",
"!=":"z!=m[4]",
"^=":"z&&!z.indexOf(m[4])",
"$=":"z&&z.substr(z.length-m[4].length,m[4].length)==m[4]",
"*=":"z&&z.indexOf(m[4])>=0",
"":"z"
},
"[":"jQuery.find(m[2],a).length"
},

token:[
"\\.\\.|/\\.\\.","a.parentNode",
">|/","jQuery.sibling(a.firstChild)",
"\\+","jQuery.sibling(a).next",
"~",function(a){
vars=jQuery.sibling(a);
returns.n>=0?s.slice(s.n+1):[];
}
],

find:function(t,context){
//MakesurethatthecontextisaDOMElement
if(context&&context.nodeType==undefined)
context=null;

//Setthecorrectcontext(ifnoneisprovided)
context=context||document;

if(t.constructor!=String)return[t];

if(!t.indexOf("//")){
context=context.documentElement;
t=t.substr(2,t.length);
}elseif(!t.indexOf("/")){
context=context.documentElement;
t=t.substr(1,t.length);
//FIXAssumetherootelementisright:(
if(t.indexOf("/")>=1)
t=t.substr(t.indexOf("/"),t.length);
}

varret=[context];
vardone=[];
varlast=null;

while(t.length>0&&last!=t){
varr=[];
last=t;

t=jQuery.trim(t).replace(/^\/\//i,"");

varfoundToken=false;

for(vari=0;i<jQuery.token.length;i+=2){
if(foundToken)continue;

varre=newRegExp("^("+jQuery.token[i]+")");
varm=re.exec(t);

if(m){
r=ret=jQuery.map(ret,jQuery.token[i+1]);
t=jQuery.trim(t.replace(re,""));
foundToken=true;
}
}

if(!foundToken){
if(!t.indexOf(",")||!t.indexOf("|")){
if(ret[0]==context)ret.shift();
done=jQuery.merge(done,ret);
r=ret=[context];
t=""+t.substr(1,t.length);
}else{
varre2=/^([#.]?)([a-z0-9\\*_-]*)/i;
varm=re2.exec(t);

if(m[1]=="#"){
//Ummm,shouldmakethisworkinallXMLdocs
varoid=document.getElementById(m[2]);
r=ret=oid?[oid]:[];
t=t.replace(re2,"");
}else{
if(!m[2]||m[1]==".")m[2]="*";

for(vari=0;i<ret.length;i++)
r=jQuery.merge(r,
m[2]=="*"?
jQuery.getAll(ret[i]):
ret[i].getElementsByTagName(m[2])
);
}
}

}

if(t){
varval=jQuery.filter(t,r);
ret=r=val.r;
t=jQuery.trim(val.t);
}
}

if(ret&&ret[0]==context)ret.shift();
done=jQuery.merge(done,ret);

returndone;
},

getAll:function(o,r){
r=r||[];
vars=o.childNodes;
for(vari=0;i<s.length;i++)
if(s[i].nodeType==1){
r.push(s[i]);
jQuery.getAll(s[i],r);
}
returnr;
},

attr:function(elem,name,value){
varfix={
"for":"htmlFor",
"class":"className",
"float":jQuery.browser.msie?"styleFloat":"cssFloat",
cssFloat:jQuery.browser.msie?"styleFloat":"cssFloat",
innerHTML:"innerHTML",
className:"className",
value:"value",
disabled:"disabled",
checked:"checked",
readonly:"readOnly"
};

//IEactuallyusesfiltersforopacity...elemisactuallyelem.style
if(name=="opacity"&&jQuery.browser.msie&&value!=undefined){
//IEhastroublewithopacityifitdoesnothavelayout
//Wouldprefertocheckelement.hasLayoutfirstbutdon'thaveaccesstotheelementhere
elem['zoom']=1;
if(value==1)//RemovefiltertoavoidmoreIEweirdness
returnelem["filter"]=elem["filter"].replace(/alpha\([^\)]*\)/gi,"");
else
returnelem["filter"]=elem["filter"].replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+value*100+")";
}elseif(name=="opacity"&&jQuery.browser.msie){
returnelem["filter"]?parseFloat(elem["filter"].match(/alpha\(opacity=(.*)\)/)[1])/100:1;
}

//Mozilladoesn'tplaywellwithopacity1
if(name=="opacity"&&jQuery.browser.mozilla&&value==1)value=0.9999;

if(fix[name]){
if(value!=undefined)elem[fix[name]]=value;
returnelem[fix[name]];
}elseif(value==undefined&&jQuery.browser.msie&&elem.nodeName&&elem.nodeName.toUpperCase()=='FORM'&&(name=='action'||name=='method')){
returnelem.getAttributeNode(name).nodeValue;
}elseif(elem.tagName){//IEelem.getAttributepassesevenforstyle
if(value!=undefined)elem.setAttribute(name,value);
returnelem.getAttribute(name);
}else{
name=name.replace(/-([a-z])/ig,function(z,b){returnb.toUpperCase();});
if(value!=undefined)elem[name]=value;
returnelem[name];
}
},

//Theregularexpressionsthatpowertheparsingengine
parse:[
//Match:[@value='test'],[@foo]
"\\[*(@)S*([!*$^=]*)*('?\"?)(.*?)\\4*\\]",

//Match:[div],[divp]
"(\\[)\s*(.*?)\s*\\]",

//Match::contains('foo')
"(:)S\\(\"?'?([^\\)]*?)\"?'?\\)",

//Match::even,:last-chlid
"([:.#]*)S"
],

filter:function(t,r,not){
//Figureoutifwe'redoingregular,orinverse,filtering
varg=not!==false?jQuery.grep:
function(a,f){returnjQuery.grep(a,f,true);};

while(t&&/^[a-z[({<*:.#]/i.test(t)){

varp=jQuery.parse;

for(vari=0;i<p.length;i++){

//Lookfor,andreplace,string-likesequences
//andfinallybuildaregexpoutofit
varre=newRegExp(
"^"+p[i].replace("S","([a-z*_-][a-z0-9_-]*)"),"i");

varm=re.exec(t);

if(m){
//Re-organizethefirstmatch
if(!i)
m=["",m[1],m[3],m[2],m[5]];

//Removewhatwejustmatched
t=t.replace(re,"");

break;
}
}

//:not()isaspecialcasethatcanbeoptimizedby
//keepingitoutoftheexpressionlist
if(m[1]==":"&&m[2]=="not")
r=jQuery.filter(m[3],r,false).r;

//Otherwise,findtheexpressiontoexecute
else{
varf=jQuery.expr[m[1]];
if(f.constructor!=String)
f=jQuery.expr[m[1]][m[2]];

//Buildacustommacrotoencloseit
eval("f=function(a,i){"+
(m[1]=="@"?"z=jQuery.attr(a,m[3]);":"")+
"return"+f+"}");

//Executeitagainstthecurrentfilter
r=g(r,f);
}
}

//Returnanarrayoffilteredelements(r)
//andthemodifiedexpressionstring(t)
return{r:r,t:t};
},

trim:function(t){
returnt.replace(/^\s+|\s+$/g,"");
},

parents:function(elem){
varmatched=[];
varcur=elem.parentNode;
while(cur&&cur!=document){
matched.push(cur);
cur=cur.parentNode;
}
returnmatched;
},

sibling:function(elem,pos,not){
varelems=[];

if(elem){
varsiblings=elem.parentNode.childNodes;
for(vari=0;i<siblings.length;i++){
if(not===true&&siblings[i]==elem)continue;

if(siblings[i].nodeType==1)
elems.push(siblings[i]);
if(siblings[i]==elem)
elems.n=elems.length-1;
}
}

returnjQuery.extend(elems,{
last:elems.n==elems.length-1,
cur:pos=="even"&&elems.n%2==0||pos=="odd"&&elems.n%2||elems[pos]==elem,
prev:elems[elems.n-1],
next:elems[elems.n+1]
});
},

merge:function(first,second){
varresult=[];

//Movebovertothenewarray(thishelpstoavoid
//StaticNodeListinstances)
for(vark=0;k<first.length;k++)
result[k]=first[k];

//Nowcheckforduplicatesbetweenaandbandonly
//addtheuniqueitems
for(vari=0;i<second.length;i++){
varnoCollision=true;

//Thecollision-checkingprocess
for(varj=0;j<first.length;j++)
if(second[i]==first[j])
noCollision=false;

//Iftheitemisunique,addit
if(noCollision)
result.push(second[i]);
}

returnresult;
},

grep:function(elems,fn,inv){
//Ifastringispassedinforthefunction,makeafunction
//forit(ahandyshortcut)
if(typeoffn=="string")
fn=newFunction("a","i","return"+fn);

varresult=[];

//Gothroughthearray,onlysavingtheitems
//thatpassthevalidatorfunction
for(vari=0;i<elems.length;i++)
if(!inv&&fn(elems[i],i)||inv&&!fn(elems[i],i))
result.push(elems[i]);

returnresult;
},

map:function(elems,fn){
//Ifastringispassedinforthefunction,makeafunction
//forit(ahandyshortcut)
if(typeoffn=="string")
fn=newFunction("a","return"+fn);

varresult=[];

//Gothroughthearray,translatingeachoftheitemstotheir
//newvalue(orvalues).
for(vari=0;i<elems.length;i++){
varval=fn(elems[i],i);

if(val!==null&&val!=undefined){
if(val.constructor!=Array)val=[val];
result=jQuery.merge(result,val);
}
}

returnresult;
},

/*
*Anumberofhelperfunctionsusedformanagingevents.
*ManyoftheideasbehindthiscodeorignatedfromDeanEdwards'addEventlibrary.
*/
event:{

//Bindaneventtoanelement
//OriginalbyDeanEdwards
add:function(element,type,handler){
//Forwhateverreason,IEhastroublepassingthewindowobject
//around,causingittobeclonedintheprocess
if(jQuery.browser.msie&&element.setInterval!=undefined)
element=window;

//MakesurethatthefunctionbeingexecutedhasauniqueID
if(!handler.guid)
handler.guid=this.guid++;

//Inittheelement'seventstructure
if(!element.events)
element.events={};

//Getthecurrentlistoffunctionsboundtothisevent
varhandlers=element.events[type];

//Ifithasn'tbeeninitializedyet
if(!handlers){
//Inittheeventhandlerqueue
handlers=element.events[type]={};

//Rememberanexistinghandler,ifit'salreadythere
if(element["on"+type])
handlers[0]=element["on"+type];
}

//Addthefunctiontotheelement'shandlerlist
handlers[handler.guid]=handler;

//Andbindtheglobaleventhandlertotheelement
element["on"+type]=this.handle;

//Rememberthefunctioninagloballist(fortriggering)
if(!this.global[type])
this.global[type]=[];
this.global[type].push(element);
},

guid:1,
global:{},

//Detachaneventorsetofeventsfromanelement
remove:function(element,type,handler){
if(element.events)
if(type&&element.events[type])
if(handler)
deleteelement.events[type][handler.guid];
else
for(variinelement.events[type])
deleteelement.events[type][i];
else
for(varjinelement.events)
this.remove(element,j);
},

trigger:function(type,data,element){
//Clonetheincomingdata,ifany
data=$.merge([],data||[]);

//Handleaglobaltrigger
if(!element){
varg=this.global[type];
if(g)
for(vari=0;i<g.length;i++)
this.trigger(type,data,g[i]);

//Handletriggeringasingleelement
}elseif(element["on"+type]){
//Passalongafakeevent
data.unshift(this.fix({type:type,target:element}));

//Triggertheevent
element["on"+type].apply(element,data);
}
},

handle:function(event){
if(typeofjQuery=="undefined")returnfalse;

event=jQuery.event.fix(event||window.event||{});//Emptyobjectisfortriggeredeventswithnodata

//Ifnocorrecteventwasfound,fail
if(!event)returnfalse;

varreturnValue=true;

varc=this.events[event.type];

varargs=[].slice.call(arguments,1);
args.unshift(event);

for(varjinc){
if(c[j].apply(this,args)===false){
event.preventDefault();
event.stopPropagation();
returnValue=false;
}
}

//CleanupaddedpropertiesinIEtopreventmemoryleak
if(jQuery.browser.msie)event.target=event.preventDefault=event.stopPropagation=null;

returnreturnValue;
},

fix:function(event){
//checkIE
if(jQuery.browser.msie){
//fixtargetproperty,ifavailable
//checkpreventsoverwritingoffaketargetcomingfromtrigger
if(event.srcElement)
event.target=event.srcElement;

//calculatepageX/Y
vare=document.documentElement,b=document.body;
event.pageX=event.clientX+(e.scrollLeft||b.scrollLeft);
event.pageY=event.clientY+(e.scrollTop||b.scrollTop);

//checksafariandiftargetisatextnode
}elseif(jQuery.browser.safari&&event.target.nodeType==3){
//targetisreadonly,clonetheeventobject
event=jQuery.extend({},event);
//getparentnodefromtextnode
event.target=event.target.parentNode;
}

//fixpreventDefaultandstopPropagation
if(!event.preventDefault)
event.preventDefault=function(){
this.returnValue=false;
};

if(!event.stopPropagation)
event.stopPropagation=function(){
this.cancelBubble=true;
};

returnevent;
}
}
});


/*
*WheathertheW3Ccompliantboxmodelisbeingused.
*
*@property
*@name$.boxModel
*@typeBoolean
*@catJavascript
*/
newfunction(){
varb=navigator.userAgent.toLowerCase();

//Figureoutwhatbrowserisbeingused
jQuery.browser={
safari:/webkit/.test(b),
opera:/opera/.test(b),
msie:/msie/.test(b)&&!/opera/.test(b),
mozilla:/mozilla/.test(b)&&!/(compatible|webkit)/.test(b)
};

//ChecktoseeiftheW3Cboxmodelisbeingused
jQuery.boxModel=!jQuery.browser.msie||document.compatMode=="CSS1Compat";
};

jQuery.macros={
to:{

appendTo:"append",

prependTo:"prepend",

insertBefore:"before",

insertAfter:"after"
},



css:"width,height,top,left,position,float,overflow,color,background".split(","),



filter:["eq","lt","gt","contains"],

attr:{


val:"value",


html:"innerHTML",


id:null,


title:null,


name:null,


href:null,


src:null,


rel:null
},

axis:{


parent:"a.parentNode",


ancestors:jQuery.parents,


parents:jQuery.parents,


next:"jQuery.sibling(a).next",


prev:"jQuery.sibling(a).prev",


siblings:"jQuery.sibling(a,null,true)",


children:"jQuery.sibling(a.firstChild)"
},

each:{

removeAttr:function(key){
jQuery.attr(this,key,"");
this.removeAttribute(key);
},

show:function(){
this.style.display=this.oldblock?this.oldblock:"";
if(jQuery.css(this,"display")=="none")
this.style.display="block";
},

hide:function(){
this.oldblock=this.oldblock||jQuery.css(this,"display");
if(this.oldblock=="none")
this.oldblock="block";
this.style.display="none";
},

toggle:function(){
jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"].apply(jQuery(this),arguments);
},

addClass:function(c){
jQuery.className.add(this,c);
},

removeClass:function(c){
jQuery.className.remove(this,c);
},

toggleClass:function(c){
jQuery.className[jQuery.className.has(this,c)?"remove":"add"](this,c);
},


remove:function(a){
if(!a||jQuery.filter(a,[this]).r)
this.parentNode.removeChild(this);
},

empty:function(){
while(this.firstChild)
this.removeChild(this.firstChild);
},

bind:function(type,fn){
jQuery.event.add(this,type,fn);
},


unbind:function(type,fn){
jQuery.event.remove(this,type,fn);
},

trigger:function(type,data){
jQuery.event.trigger(type,data,this);
}
}
};

jQuery.init();
jQuery.fn.extend({

//We'reoverridingtheoldtogglefunction,so
//rememberitforlater
_toggle:jQuery.fn.toggle,
toggle:function(a,b){
//Iftwofunctionsarepassedin,we're
//togglingonaclick
returna&&b&&a.constructor==Function&&b.constructor==Function?this.click(function(e){
//Figureoutwhichfunctiontoexecute
this.last=this.last==a?b:a;

//Makesurethatclicksstop
e.preventDefault();

//andexecutethefunction
returnthis.last.apply(this,[e])||false;
}):

//Otherwise,executetheoldtogglefunction
this._toggle.apply(this,arguments);
},
hover:function(f,g){

//Aprivatefunctionforhaandlingmouse'hovering'
functionhandleHover(e){
//Checkifmouse(over|out)arestillwithinthesameparentelement
varp=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;

//Traverseupthetree
while(p&&p!=this)try{p=p.parentNode}catch(e){p=this;};

//Ifweactuallyjustmousedontoasub-element,ignoreit
if(p==this)returnfalse;

//Executetherightfunction
return(e.type=="mouseover"?f:g).apply(this,[e]);
}

//Bindthefunctiontothetwoeventlisteners
returnthis.mouseover(handleHover).mouseout(handleHover);
},
ready:function(f){
//IftheDOMisalreadyready
if(jQuery.isReady)
//Executethefunctionimmediately
f.apply(document);

//Otherwise,rememberthefunctionforlater
else{
//Addthefunctiontothewaitlist
jQuery.readyList.push(f);
}

returnthis;
}
});

jQuery.extend({
/*
*AllthecodethatmakesDOMReadyworknicely.
*/
isReady:false,
readyList:[],

//HandlewhentheDOMisready
ready:function(){
//MakesurethattheDOMisnotalreadyloaded
if(!jQuery.isReady){
//RememberthattheDOMisready
jQuery.isReady=true;

//Iftherearefunctionsbound,toexecute
if(jQuery.readyList){
//Executeallofthem
for(vari=0;i<jQuery.readyList.length;i++)
jQuery.readyList[i].apply(document);

//Resetthelistoffunctions
jQuery.readyList=null;
}
//Removeeventlisentertoavoidmemoryleak
if(jQuery.browser.mozilla||jQuery.browser.opera)
document.removeEventListener("DOMContentLoaded",jQuery.ready,false);
}
}
});

newfunction(){

vare=("blur,focus,load,resize,scroll,unload,click,dblclick,"+
"mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select,"+
"submit,keydown,keypress,keyup,error").split(",");

//Gothroughalltheeventnames,butmakesurethat
//itisenclosedproperly
for(vari=0;i<e.length;i++)newfunction(){

varo=e[i];

//Handleeventbinding
jQuery.fn[o]=function(f){
returnf?this.bind(o,f):this.trigger(o);
};

//Handleeventunbinding
jQuery.fn["un"+o]=function(f){returnthis.unbind(o,f);};

//Finally,handleeventsthatonlyfireonce
jQuery.fn["one"+o]=function(f){
//saveclonedreferencetothis
varelement=jQuery(this);
varhandler=function(){
//unbinditselfwhenexecuted
element.unbind(o,handler);
element=null;
//applyoriginalhandlerwiththesamearguments
returnf.apply(this,arguments);
};
returnthis.bind(o,handler);
};

};

//IfMozillaisused
if(jQuery.browser.mozilla||jQuery.browser.opera){
//Usethehandyeventcallback
document.addEventListener("DOMContentLoaded",jQuery.ready,false);

//IfIEisused,usetheexcellenthackbyMatthiasMiller
//http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
}elseif(jQuery.browser.msie){

//Onlyworksifyoudocument.write()it
document.write("<scr"+"iptid=__ie_initdefer=true"+
"src=//:><\/script>");

//Usethedeferscripthack
varscript=document.getElementById("__ie_init");
if(script)//scriptdoesnotexistifjQueryisloadeddynamically
script.onreadystatechange=function(){
if(this.readyState!="complete")return;
this.parentNode.removeChild(this);
jQuery.ready();
};

//Clearfrommemory
script=null;

//IfSafariisused
}elseif(jQuery.browser.safari){
//Continuallychecktoseeifthedocument.readyStateisvalid
jQuery.safariTimer=setInterval(function(){
//loadedandcompletearebothvalidstates
if(document.readyState=="loaded"||
document.readyState=="complete"){

//Ifeitheronearefound,removethetimer
clearInterval(jQuery.safariTimer);
jQuery.safariTimer=null;

//andexecuteanywaitingfunctions
jQuery.ready();
}
},10);
}

//Afallbacktowindow.onload,thatwillalwayswork
jQuery.event.add(window,"load",jQuery.ready);

};

//CleanupafterIEtoavoidmemoryleaks
if(jQuery.browser.msie)jQuery(window).unload(function(){
varevent=jQuery.event,global=event.global;
for(vartypeinglobal){
varels=global[type],i=els.length;
if(i>0)doif(type!='unload')event.remove(els[i-1],type);while(--i);
}
});
jQuery.fn.extend({

//overwritetheoldshowmethod
_show:jQuery.fn.show,

show:function(speed,callback){
returnspeed?this.animate({
height:"show",width:"show",opacity:"show"
},speed,callback):this._show();
},

//Overwritetheoldhidemethod
_hide:jQuery.fn.hide,

hide:function(speed,callback){
returnspeed?this.animate({
height:"hide",width:"hide",opacity:"hide"
},speed,callback):this._hide();
},

slideDown:function(speed,callback){
returnthis.animate({height:"show"},speed,callback);
},

slideUp:function(speed,callback){
returnthis.animate({height:"hide"},speed,callback);
},

slideToggle:function(speed,callback){
returnthis.each(function(){
varstate=jQuery(this).is(":hidden")?"show":"hide";
jQuery(this).animate({height:state},speed,callback);
});
},

fadeIn:function(speed,callback){
returnthis.animate({opacity:"show"},speed,callback);
},

fadeOut:function(speed,callback){
returnthis.animate({opacity:"hide"},speed,callback);
},

fadeTo:function(speed,to,callback){
returnthis.animate({opacity:to},speed,callback);
},
animate:function(prop,speed,callback){
returnthis.queue(function(){

this.curAnim=jQuery.extend({},prop);

for(varpinprop){
vare=newjQuery.fx(this,jQuery.speed(speed,callback),p);
if(prop[p].constructor==Number)
e.custom(e.cur(),prop[p]);
else
e[prop[p]](prop);
}

});
},
queue:function(type,fn){
if(!fn){
fn=type;
type="fx";
}

returnthis.each(function(){
if(!this.queue)
this.queue={};

if(!this.queue[type])
this.queue[type]=[];

this.queue[type].push(fn);

if(this.queue[type].length==1)
fn.apply(this);
});
}

});

jQuery.extend({

speed:function(s,o){
o=o||{};

if(o.constructor==Function)
o={complete:o};

varss={slow:600,fast:200};
o.duration=(s&&s.constructor==Number?s:ss[s])||400;

//Queueing
o.oldComplete=o.complete;
o.complete=function(){
jQuery.dequeue(this,"fx");
if(o.oldComplete&&o.oldComplete.constructor==Function)
o.oldComplete.apply(this);
};

returno;
},

queue:{},

dequeue:function(elem,type){
type=type||"fx";

if(elem.queue&&elem.queue[type]){
//Removeself
elem.queue[type].shift();

//Getnextfunction
varf=elem.queue[type][0];

if(f)f.apply(elem);
}
},

/*
*Ioriginallywrotefx()asacloneofmoo.fxandintheprocess
*ofmakingitsmallinsizethecodebecameillegibletosane
*people.You'vebeenwarned.
*/

fx:function(elem,options,prop){

varz=this;

//Theusersoptions
z.o={
duration:options.duration||400,
complete:options.complete,
step:options.step
};

//Theelement
z.el=elem;

//Thestyles
vary=z.el.style;

//Storedisplayproperty
varoldDisplay=jQuery.css(z.el,'display');
//Setdisplaypropertytoblockforanimation
y.display="block";
//Makesurethatnothingsneaksout
y.overflow="hidden";

//Simplefunctionforsettingastylevalue
z.a=function(){
if(options.step)
options.step.apply(elem,[z.now]);

if(prop=="opacity")
jQuery.attr(y,"opacity",z.now);//Letattrhandleopacity
elseif(parseInt(z.now))//MyhateforIEwillneverdie
y[prop]=parseInt(z.now)+"px";
};

//Figureoutthemaximumnumbertorunto
z.max=function(){
returnparseFloat(jQuery.css(z.el,prop));
};

//Getthecurrentsize
z.cur=function(){
varr=parseFloat(jQuery.curCSS(z.el,prop));
returnr&&r>-10000?r:z.max();
};

//Startananimationfromonenumbertoanother
z.custom=function(from,to){
z.startTime=(newDate()).getTime();
z.now=from;
z.a();

z.timer=setInterval(function(){
z.step(from,to);
},13);
};

//Simple'show'function
z.show=function(){
if(!z.el.orig)z.el.orig={};

//Rememberwherewestarted,sothatwecangobacktoitlater
z.el.orig[prop]=this.cur();

z.o.show=true;

//Begintheanimation
z.custom(0,z.el.orig[prop]);

//StupidIE,lookwhatyoumademedo
if(prop!="opacity")
y[prop]="1px";
};

//Simple'hide'function
z.hide=function(){
if(!z.el.orig)z.el.orig={};

//Rememberwherewestarted,sothatwecangobacktoitlater
z.el.orig[prop]=this.cur();

z.o.hide=true;

//Begintheanimation
z.custom(z.el.orig[prop],0);
};

//Simple'toggle'function
z.toggle=function(){
if(!z.el.orig)z.el.orig={};

//Rememberwherewestarted,sothatwecangobacktoitlater
z.el.orig[prop]=this.cur();

if(oldDisplay=='none'){
z.o.show=true;

//StupidIE,lookwhatyoumademedo
if(prop!="opacity")
y[prop]="1px";

//Begintheanimation
z.custom(0,z.el.orig[prop]);
}else{
z.o.hide=true;

//Begintheanimation
z.custom(z.el.orig[prop],0);
}
};

//Eachstepofananimation
z.step=function(firstNum,lastNum){
vart=(newDate()).getTime();

if(t>z.o.duration+z.startTime){
//Stopthetimer
clearInterval(z.timer);
z.timer=null;

z.now=lastNum;
z.a();

z.el.curAnim[prop]=true;

vardone=true;
for(variinz.el.curAnim)
if(z.el.curAnim[i]!==true)
done=false;

if(done){
//Resettheoverflow
y.overflow='';

//Resetthedisplay
y.display=oldDisplay;
if(jQuery.css(z.el,'display')=='none')
y.display='block';

//Hidetheelementifthe"hide"operationwasdone
if(z.o.hide)
y.display='none';

//Resettheproperties,iftheitemhasbeenhiddenorshown
if(z.o.hide||z.o.show)
for(varpinz.el.curAnim)
if(p=="opacity")
jQuery.attr(y,p,z.el.orig[p]);
else
y[p]='';
}

//Ifacallbackwasprovided,executeit
if(done&&z.o.complete&&z.o.complete.constructor==Function)
//Executethecompletefunction
z.o.complete.apply(z.el);
}else{
//Figureoutwhereintheanimationweareandsetthenumber
varp=(t-this.startTime)/z.o.duration;
z.now=((-Math.cos(p*Math.PI)/2)+0.5)*(lastNum-firstNum)+firstNum;

//Performthenextstepoftheanimation
z.a();
}
};

}

});
jQuery.fn.extend({
loadIfModified:function(url,params,callback){
this.load(url,params,callback,1);
},
load:function(url,params,callback,ifModified){
if(url.constructor==Function)
returnthis.bind("load",url);

callback=callback||function(){};

//DefaulttoaGETrequest
vartype="GET";

//Ifthesecondparameterwasprovided
if(params){
//Ifit'safunction
if(params.constructor==Function){
//Weassumethatit'sthecallback
callback=params;
params=null;

//Otherwise,buildaparamstring
}else{
params=jQuery.param(params);
type="POST";
}
}

varself=this;

//Requesttheremotedocument
jQuery.ajax({
url:url,
type:type,
data:params,
ifModified:ifModified,
complete:function(res,status){
if(status=="success"||!ifModified&&status=="notmodified"){
//InjecttheHTMLintoallthematchedelements
self.html(res.responseText)
//Executeallthescriptsinsideofthenewly-injectedHTML
.evalScripts()
//Executecallback
.each(callback,[res.responseText,status,res]);
}else
callback.apply(self,[res.responseText,status,res]);
}
});
returnthis;
},
serialize:function(){
returnjQuery.param(this);
},
evalScripts:function(){
returnthis.find('script').each(function(){
if(this.src)
//forsomeweirdreason,itdoesn'tworkifthecallbackisommited
jQuery.getScript(this.src);
else{
jQuery.globalEval(this.text||this.textContent||this.innerHTML||"");
}
}).end();
}

});

//IfIEisused,createawrapperfortheXMLHttpRequestobject
if(jQuery.browser.msie&&typeofXMLHttpRequest=="undefined")
XMLHttpRequest=function(){
returnnewActiveXObject("Microsoft.XMLHTTP");
};

//AttachabunchoffunctionsforhandlingcommonAJAXevents

newfunction(){
vare="ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(",");

for(vari=0;i<e.length;i++)newfunction(){
varo=e[i];
jQuery.fn[o]=function(f){
returnthis.bind(o,f);
};
};
};

jQuery.extend({
get:function(url,data,callback,type,ifModified){
//shiftargumentsifdataargumentwasommited
if(data&&data.constructor==Function){
callback=data;
data=null;
}

//Delegate
jQuery.ajax({
url:url,
data:data,
success:callback,
dataType:type,
ifModified:ifModified
});
},
getIfModified:function(url,data,callback,type){
jQuery.get(url,data,callback,type,1);
},
getScript:function(url,callback){
if(callback)
jQuery.get(url,null,callback,"script");
else{
jQuery.get(url,null,null,"script");
}
},
getJSON:function(url,data,callback){
jQuery.get(url,data,callback,"json");
},
post:function(url,data,callback,type){
//Delegate
jQuery.ajax({
type:"POST",
url:url,
data:data,
success:callback,
dataType:type
});
},

//timeout(ms)
timeout:0,
ajaxTimeout:function(timeout){
jQuery.timeout=timeout;
},

//Last-Modifiedheadercachefornextrequest
lastModified:{},
ajax:function(s){
//TODOintroduceglobalsettings,allowingtheclienttomodifythemforallrequests,notonlytimeout
s=jQuery.extend({
global:true,
ifModified:false,
type:"GET",
timeout:jQuery.timeout,
complete:null,
success:null,
error:null,
dataType:null,
url:null,
data:null,
contentType:"application/x-www-form-urlencoded",
processData:true,
async:true,
beforeSend:null
},s);

//ifdataavailable
if(s.data){
//convertdataifnotalreadyastring
if(s.processData&&typeofs.data!='string')
s.data=jQuery.param(s.data);
//appenddatatourlforgetrequests
if(s.type.toLowerCase()=="get")
//"?"+dataor"&"+data(incasetherearealreadyparams)
s.url+=((s.url.indexOf("?")>-1)?"&":"?")+s.data;
}

//Watchforanewsetofrequests
if(s.global&&!jQuery.active++)
jQuery.event.trigger("ajaxStart");

varrequestDone=false;

//Createtherequestobject
varxml=newXMLHttpRequest();

//Openthesocket
xml.open(s.type,s.url,s.async);

//Setthecorrectheader,ifdataisbeingsent
if(s.data)
xml.setRequestHeader("Content-Type",s.contentType);

//SettheIf-Modified-Sinceheader,ififModifiedmode.
if(s.ifModified)
xml.setRequestHeader("If-Modified-Since",
jQuery.lastModified[s.url]||"Thu,01Jan197000:00:00GMT");

//Setheadersothecalledscriptknowsthatit'sanXMLHttpRequest
xml.setRequestHeader("X-Requested-With","XMLHttpRequest");

//Makesurethebrowsersendstherightcontentlength
if(xml.overrideMimeType)
xml.setRequestHeader("Connection","close");

//Allowcustomheaders/mimetypes
if(s.beforeSend)
s.beforeSend(xml);
if(s.global)
jQuery.event.trigger("ajaxSend",[xml,s]);

//Waitforaresponsetocomeback
varonreadystatechange=function(isTimeout){
//Thetransferiscompleteandthedataisavailable,ortherequesttimedout
if(xml&&(xml.readyState==4||isTimeout=="timeout")){
requestDone=true;

varstatus=jQuery.httpSuccess(xml)&&isTimeout!="timeout"?
s.ifModified&&jQuery.httpNotModified(xml,s.url)?"notmodified":"success":"error";

//Makesurethattherequestwassuccessfulornotmodified
if(status!="error"){
//CacheLast-Modifiedheader,ififModifiedmode.
varmodRes;
try{
modRes=xml.getResponseHeader("Last-Modified");
}catch(e){}//swallowexceptionthrownbyFFifheaderisnotavailable

if(s.ifModified&&modRes)
jQuery.lastModified[s.url]=modRes;

//processthedata(runsthexmlthroughhttpDataregardlessofcallback)
vardata=jQuery.httpData(xml,s.dataType);

//Ifalocalcallbackwasspecified,fireitandpassitthedata
if(s.success)
s.success(data,status);

//Firetheglobalcallback
if(s.global)
jQuery.event.trigger("ajaxSuccess",[xml,s]);

//Otherwise,therequestwasnotsuccessful
}else{
//Ifalocalcallbackwasspecified,fireit
if(s.error)s.error(xml,status);

//Firetheglobalcallback
if(s.global)
jQuery.event.trigger("ajaxError",[xml,s]);
}

//Therequestwascompleted
if(s.global)
jQuery.event.trigger("ajaxComplete",[xml,s]);

//HandletheglobalAJAXcounter
if(s.global&&!--jQuery.active)
jQuery.event.trigger("ajaxStop");

//Processresult
if(s.complete)s.complete(xml,status);

//Stopmemoryleaks
xml.onreadystatechange=function(){};
xml=null;

}
};
xml.onreadystatechange=onreadystatechange;

//Timeoutchecker
if(s.timeout>0)
setTimeout(function(){
//Checktoseeiftherequestisstillhappening
if(xml){
//Canceltherequest
xml.abort();

if(!requestDone)onreadystatechange("timeout");

//Clearfrommemory
xml=null;
}
},s.timeout);

//Sendthedata
xml.send(s.data);

//returnXMLHttpRequesttoallowabortingtherequestetc.
returnxml;
},

//Counterforholdingthenumberofactivequeries
active:0,

//DeterminesifanXMLHttpRequestwassuccessfulornot
httpSuccess:function(r){
try{
return!r.status&&location.protocol=="file:"||
(r.status>=200&&r.status<300)||r.status==304||
jQuery.browser.safari&&r.status==undefined;
}catch(e){}

returnfalse;
},

//DeterminesifanXMLHttpRequestreturnsNotModified
httpNotModified:function(xml,url){
try{
varxmlRes=xml.getResponseHeader("Last-Modified");

//Firefoxalwaysreturns200.checkLast-Modifieddate
returnxml.status==304||xmlRes==jQuery.lastModified[url]||
jQuery.browser.safari&&xml.status==undefined;
}catch(e){}

returnfalse;
},

/*GetthedataoutofanXMLHttpRequest.
*ReturnparsedXMLifcontent-typeheaderis"xml"andtypeis"xml"oromitted,
*otherwisereturnplaintext.
*(String)data-Thetypeofdatathatyou'reexpectingback,
*(e.g."xml","html","script")
*/
httpData:function(r,type){
varct=r.getResponseHeader("content-type");
vardata=!type&&ct&&ct.indexOf("xml")>=0;
data=type=="xml"||data?r.responseXML:r.responseText;

//Ifthetypeis"script",evalitinglobalcontext
if(type=="script"){
jQuery.globalEval(data);
}

//GettheJavaScriptobject,ifJSONisused.
if(type=="json")eval("data="+data);

//evaluatescriptswithinhtml
if(type=="html")jQuery("<div>").html(data).evalScripts();

returndata;
},

//Serializeanarrayofformelementsorasetof
//key/valuesintoaquerystring
param:function(a){
vars=[];

//Ifanarraywaspassedin,assumethatitisanarray
//offormelements
if(a.constructor==Array||a.jquery){
//Serializetheformelements
for(vari=0;i<a.length;i++)
s.push(a[i].name+"="+encodeURIComponent(a[i].value));

//Otherwise,assumethatit'sanobjectofkey/valuepairs
}else{
//Serializethekey/values
for(varjina){
//Ifthevalueisanarraythenthekeynamesneedtoberepeated
if(a[j].constructor==Array){
for(vark=0;k<a[j].length;k++){
s.push(j+"="+encodeURIComponent(a[j][k]));
}
}else{
s.push(j+"="+encodeURIComponent(a[j]));
}
}
}

//Returntheresultingserialization
returns.join("&");
},

//evalulatesascriptinglobalcontext
//notreliableforsafari
globalEval:function(data){
if(window.execScript)
window.execScript(data);
elseif(jQuery.browser.safari)
//safaridoesn'tprovideasynchronousglobaleval
window.setTimeout(data,0);
else
eval.call(window,data);
}

});
}//close:if(typeofwindow.jQuery=="undefined"){

点击这里复制本文地址 以上内容由聚米学院网友整理呈现,如对侵犯您的权益,请联系邮箱:fzsbm@qq.com

聚米学院 © All Rights Reserved.  Copyright jumtu.com.Some Rights Reserved.