JS弹出框thickbox.docx
《JS弹出框thickbox.docx》由会员分享,可在线阅读,更多相关《JS弹出框thickbox.docx(57页珍藏版)》请在冰点文库上搜索。
JS弹出框thickbox
/*PrototypeJavaScriptframework,version1.4.0
*(c)2005SamStephenson
*
*THISFILEISAUTOMATICALLYGENERATED.Whensendingpatches,pleasediff
*againstthesourcetree,availablefromthePrototypedarcsrepository.
*
*PrototypeisfreelydistributableunderthetermsofanMIT-stylelicense.
*
*Fordetails,seethePrototypewebsite:
*
/*--------------------------------------------------------------------------*/
varPrototype={
Version:
'1.4.0',
ScriptFragment:
'(?
:
>)((\n|\r|.)*?
)(?
:
<\/script>)',
emptyFunction:
function(){},
K:
function(x){returnx}
}
varClass={
create:
function(){
returnfunction(){
this.initialize.apply(this,arguments);
}
}
}
varAbstract=newObject();
Object.extend=function(destination,source){
for(propertyinsource){
destination[property]=source[property];
}
returndestination;
}
Object.inspect=function(object){
try{
if(object==undefined)return'undefined';
if(object==null)return'null';
returnobject.inspect?
object.inspect():
object.toString();
}catch(e){
if(einstanceofRangeError)return'...';
throwe;
}
}
Function.prototype.bind=function(){
var__method=this,args=$A(arguments),object=args.shift();
returnfunction(){
return__method.apply(object,args.concat($A(arguments)));
}
}
Function.prototype.bindAsEventListener=function(object){
var__method=this;
returnfunction(event){
return__method.call(object,event||window.event);
}
}
Object.extend(Number.prototype,{
toColorPart:
function(){
vardigits=this.toString(16);
if(this<16)return'0'+digits;
returndigits;
},
succ:
function(){
returnthis+1;
},
times:
function(iterator){
$R(0,this,true).each(iterator);
returnthis;
}
});
varTry={
these:
function(){
varreturnValue;
for(vari=0;ivarlambda=arguments[i];
try{
returnValue=lambda();
break;
}catch(e){}
}
returnreturnValue;
}
}
/*--------------------------------------------------------------------------*/
varPeriodicalExecuter=Class.create();
PeriodicalExecuter.prototype={
initialize:
function(callback,frequency){
this.callback=callback;
this.frequency=frequency;
this.currentlyExecuting=false;
this.registerCallback();
},
registerCallback:
function(){
setInterval(this.onTimerEvent.bind(this),this.frequency*1000);
},
onTimerEvent:
function(){
if(!
this.currentlyExecuting){
try{
this.currentlyExecuting=true;
this.callback();
}finally{
this.currentlyExecuting=false;
}
}
}
}
/*--------------------------------------------------------------------------*/
function$(){
varelements=newArray();
for(vari=0;ivarelement=arguments[i];
if(typeofelement=='string')
element=document.getElementById(element);
if(arguments.length==1)
returnelement;
elements.push(element);
}
returnelements;
}
Object.extend(String.prototype,{
stripTags:
function(){
returnthis.replace(/<\/?
[^>]+>/gi,'');
},
stripScripts:
function(){
returnthis.replace(newRegExp(Prototype.ScriptFragment,'img'),'');
},
extractScripts:
function(){
varmatchAll=newRegExp(Prototype.ScriptFragment,'img');
varmatchOne=newRegExp(Prototype.ScriptFragment,'im');
return(this.match(matchAll)||[]).map(function(scriptTag){
return(scriptTag.match(matchOne)||['',''])[1];
});
},
evalScripts:
function(){
returnthis.extractScripts().map(eval);
},
escapeHTML:
function(){
vardiv=document.createElement('div');
vartext=document.createTextNode(this);
div.appendChild(text);
returndiv.innerHTML;
},
unescapeHTML:
function(){
vardiv=document.createElement('div');
div.innerHTML=this.stripTags();
returndiv.childNodes[0]?
div.childNodes[0].nodeValue:
'';
},
toQueryParams:
function(){
varpairs=this.match(/^\?
?
(.*)$/)[1].split('&');
returnpairs.inject({},function(params,pairString){
varpair=pairString.split('=');
params[pair[0]]=pair[1];
returnparams;
});
},
toArray:
function(){
returnthis.split('');
},
camelize:
function(){
varoStringList=this.split('-');
if(oStringList.length==1)returnoStringList[0];
varcamelizedString=this.indexOf('-')==0
?
oStringList[0].charAt(0).toUpperCase()+oStringList[0].substring
(1)
:
oStringList[0];
for(vari=1,len=oStringList.length;ivars=oStringList[i];
camelizedString+=s.charAt(0).toUpperCase()+s.substring
(1);
}
returncamelizedString;
},
inspect:
function(){
return"'"+this.replace('\\','\\\\').replace("'",'\\\'')+"'";
}
});
String.prototype.parseQuery=String.prototype.toQueryParams;
var$break=newObject();
var$continue=newObject();
varEnumerable={
each:
function(iterator){
varindex=0;
try{
this._each(function(value){
try{
iterator(value,index++);
}catch(e){
if(e!
=$continue)throwe;
}
});
}catch(e){
if(e!
=$break)throwe;
}
},
all:
function(iterator){
varresult=true;
this.each(function(value,index){
result=result&&!
!
(iterator||Prototype.K)(value,index);
if(!
result)throw$break;
});
returnresult;
},
any:
function(iterator){
varresult=true;
this.each(function(value,index){
if(result=!
!
(iterator||Prototype.K)(value,index))
throw$break;
});
returnresult;
},
collect:
function(iterator){
varresults=[];
this.each(function(value,index){
results.push(iterator(value,index));
});
returnresults;
},
detect:
function(iterator){
varresult;
this.each(function(value,index){
if(iterator(value,index)){
result=value;
throw$break;
}
});
returnresult;
},
findAll:
function(iterator){
varresults=[];
this.each(function(value,index){
if(iterator(value,index))
results.push(value);
});
returnresults;
},
grep:
function(pattern,iterator){
varresults=[];
this.each(function(value,index){
varstringValue=value.toString();
if(stringValue.match(pattern))
results.push((iterator||Prototype.K)(value,index));
})
returnresults;
},
include:
function(object){
varfound=false;
this.each(function(value){
if(value==object){
found=true;
throw$break;
}
});
returnfound;
},
inject:
function(memo,iterator){
this.each(function(value,index){
memo=iterator(memo,value,index);
});
returnmemo;
},
invoke:
function(method){
varargs=$A(arguments).slice
(1);
returnthis.collect(function(value){
returnvalue[method].apply(value,args);
});
},
max:
function(iterator){
varresult;
this.each(function(value,index){
value=(iterator||Prototype.K)(value,index);
if(value>=(result||value))
result=value;
});
returnresult;
},
min:
function(iterator){
varresult;
this.each(function(value,index){
value=(iterator||Prototype.K)(value,index);
if(value<=(result||value))
result=value;
});
returnresult;
},
partition:
function(iterator){
vartrues=[],falses=[];
this.each(function(value,index){
((iterator||Prototype.K)(value,index)?
trues:
falses).push(value);
});
return[trues,falses];
},
pluck:
function(property){
varresults=[];
this.each(function(value,index){
results.push(value[property]);
});
returnresults;
},
reject:
function(iterator){
varresults=[];
this.each(function(value,index){
if(!
iterator(value,index))
results.push(value);
});
returnresults;
},
sortBy:
function(iterator){
returnthis.collect(function(value,index){
return{value:
value,criteria:
iterator(value,index)};
}).sort(function(left,right){
vara=left.criteria,b=right.criteria;
returna
-1:
a>b?
1:
0;
}).pluck('value');
},
toArray:
function(){
returnthis.collect(Prototype.K);
},
zip:
function(){
variterator=Prototype.K,args=$A(arguments);
if(typeofargs.last()=='function')
iterator=args.pop();
varcollections=[this].concat(args).map($A);
returnthis.map(function(value,index){
iterator(value=collections.pluck(index));
returnvalue;
});
},
inspect:
function(){
return'#'+this.toArray().inspect()+'>';
}
}
Object.extend(Enumerable,{
map:
Enumerable.collect,
find:
Enumerable.detect,
select:
Enumerable.findAll,
member:
Enumerable.include,
entries:
Enumerable.toArray
});
var$A=Array.from=function(iterable){
if(!
iterable)return[];
if(iterable.toArray){
returniterable.toArray();
}else{
varresults=[];
for(vari=0;iresults.push(iterable[i]);
returnresults;
}
}
Object.extend(Array.prototype,Enumerable);
Array.prototype._reverse=Array.prototype.reverse;
Object.extend(Array.prototype,{
_each:
function(iterator){
for(vari=0;iiterator(this[i]);
},
clear:
function(){
this.length=0;
returnthis;
},
first:
function(){
returnthis[0];
},
last:
function(){
returnthis[this.length-1];
},
compact:
function(){
returnthis.select(function(value){
returnvalue!
=undefined||value!
=null;
});
},
flatten:
function(){
returnthis.inject([],function(array,value){
returnarray.concat(value.constructor==Array?
value.flatten():
[value]);
});
},
without:
function(){
varvalues=$A(arguments);
returnthis.select(function(value){
return!
values.include(value);
});
},
indexOf:
function(object){
for(vari=0;iif(this[i]==object)returni;
return-1;
},
reverse:
function(inline){
return(inline!
==false?
thi