From 418baf36d477bcbdd6fb4eaf4037ea6a2d93f21c Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 4 Dec 2005 17:51:05 +0000 Subject: --- framework/Web/Javascripts/js/base.js | 966 +++++++++++++++++++++++++++++++++++ 1 file changed, 966 insertions(+) create mode 100644 framework/Web/Javascripts/js/base.js (limited to 'framework/Web/Javascripts/js') diff --git a/framework/Web/Javascripts/js/base.js b/framework/Web/Javascripts/js/base.js new file mode 100644 index 00000000..fdd4ee8f --- /dev/null +++ b/framework/Web/Javascripts/js/base.js @@ -0,0 +1,966 @@ +var Prototype={Version:"1.4.0_rc1",emptyFunction:function(){ +},K:function(x){ +return x; +}}; + +if(!Array.prototype.push){ +Array.prototype.push=function(){ +var _1=this.length; +for(var i=0;i0&&parent.frames.length){ +d=parent.frames[n.substring(p+1)].document; +n=n.substring(0,p); +} +if(!(x=d[n])&&d.all){ +x=d.all[n]; +} +for(i=0;!x&&i]+>/gi,""); +},escapeHTML:function(){ +var _1=document.createElement("div"); +var _2=document.createTextNode(this); +_1.appendChild(_2); +return _1.innerHTML; +},unescapeHTML:function(){ +var _3=document.createElement("div"); +_3.innerHTML=this.stripTags(); +return _3.childNodes[0]?_3.childNodes[0].nodeValue:""; +},toQueryParams:function(){ +var _4=this.match(/^\??(.*)$/)[1].split("&"); +return _4.inject({},function(_5,_6){ +var _7=_6.split("="); +_5[_7[0]]=_7[1]; +return _5; +}); +},toArray:function(){ +return this.split(""); +},camelize:function(){ +var _8=this.split("-"); +if(_8.length==1){ +return _8[0]; +} +var _9=this.indexOf("-")==0?_8[0].charAt(0).toUpperCase()+_8[0].substring(1):_8[0]; +for(var i=1,len=_8.length;i=(_41||_42)){ +_41=_42; +} +}); +return _41; +},min:function(_44){ +var _45; +this.each(function(_46,_47){ +_46=(_44||Prototype.K)(_46,_47); +if(_46<=(_45||_46)){ +_45=_46; +} +}); +return _45; +},partition:function(_48){ +var _49=[],falses=[]; +this.each(function(_50,_51){ +((_48||Prototype.K)(_50,_51)?_49:falses).push(_50); +}); +return [_49,falses]; +},pluck:function(_52){ +var _53=[]; +this.each(function(_54,_55){ +_53.push(_54[_52]); +}); +return _53; +},reject:function(_56){ +var _57=[]; +this.each(function(_58,_59){ +if(!_56(_58,_59)){ +_57.push(_58); +} +}); +return _57; +},sortBy:function(_60){ +return this.collect(function(_61,_62){ +return {value:_61,criteria:_60(_61,_62)}; +}).sort(function(_63,_64){ +var a=_63.criteria,b=_64.criteria; +return ab?1:0; +}).pluck("value"); +},toArray:function(){ +return this.collect(Prototype.K); +},zip:function(){ +var _66=Prototype.K,args=$A(arguments); +if(typeof args.last()=="function"){ +_66=args.pop(); +} +var _67=[this].concat(args).map($A); +return this.map(function(_68,_69){ +_66(_68=_67.pluck(_69)); +return _68; +}); +},inspect:function(){ +return "#"; +}}; +Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray}); + +var $A=Array.from=function(_1){ +if(_1.toArray){ +return _1.toArray(); +}else{ +var _2=[]; +for(var i=0;i<_1.length;i++){ +_2.push(_1[i]); +} +return _2; +} +}; +Object.extend(Array.prototype,Enumerable); +Object.extend(Array.prototype,{_each:function(_4){ +for(var i=0;i0;i--){ +_11.push(this[i-1]); +} +return _11; +},inspect:function(){ +return "["+this.map(Object.inspect).join(", ")+"]"; +}}); + +Array.prototype.indexOf=function(_1,_2,_3){ +_2=_2||0; +for(var i=_2;ithis[i]){ +n=this[i]; +} +} +return n; +}; +Array.prototype.max=function(){ +if(!this.length){ +return; +} +var n=this[0]; +for(var i=1;i0; +}; +Array.prototype.each=function(fn){ +return each(this,fn); +}; +Array.prototype.map=function(fn){ +return map(this,fn); +}; +Array.prototype.filter=function(fn){ +return filter(this,fn); +}; +Array.prototype.select=Array.prototype.filter; +Array.prototype.reduce=function(){ +var _24=map(arguments); +fn=_24.pop(); +d=_24.pop(); +return reduce(this,d,fn); +}; +Array.prototype.inject=Array.prototype.reduce; +Array.prototype.reject=function(fn){ +if(typeof (fn)=="string"){ +fn=__strfn("item,idx,list",fn); +} +var _25=this; +var _26=[]; +fn=fn||function(v){ +return v; +}; +map(_25,function(_28,idx,_29){ +if(fn(_28,idx,_29)){ +_26.push(idx); +} +}); +_26.reverse().each(function(idx){ +_25.splice(idx,1); +}); +return _25; +}; +function __strfn(_30,fn){ +function quote(s){ +return "\""+s.replace(/"/g,"\\\"")+"\""; +} +if(!/\breturn\b/.test(fn)){ +fn=fn.replace(/;\s*$/,""); +fn=fn.insert(fn.lastIndexOf(";")+1," return "); +} +return eval("new Function("+map(_30.split(/\s*,\s*/),quote).join()+","+quote(fn)+")"); +} +function each(_32,fn){ +if(typeof (fn)=="string"){ +return each(_32,__strfn("item,idx,list",fn)); +} +for(var i=0;i<_32.length;i++){ +fn(_32[i],i,_32); +} +} +function map(_33,fn){ +if(typeof (fn)=="string"){ +return map(_33,__strfn("item,idx,list",fn)); +} +var _34=[]; +fn=fn||function(v){ +return v; +}; +for(var i=0;i<_33.length;i++){ +_34.push(fn(_33[i],i,_33)); +} +return _34; +} +function combine(){ +var _35=map(arguments); +var _36=map(_35.slice(0,-1),"map(item)"); +var fn=_35.last(); +var _37=map(_36,"item.length").max(); +var _38=[]; +if(!fn){ +fn=function(){ +return map(arguments); +}; +} +if(typeof fn=="string"){ +if(_36.length>26){ +throw "string functions can take at most 26 lists"; +} +var a="a".charCodeAt(0); +fn=__strfn(map(range(a,a+_36.length),"String.fromCharCode(item)").join(","),fn); +} +map(_36,function(li){ +while(li.length<_37){ +li.push(null); +} +map(li,function(_40,ix){ +if(ix<_38.length){ +_38[ix].push(_40); +}else{ +_38.push([_40]); +} +}); +}); +return map(_38,function(val){ +return fn.apply(fn,val); +}); +} +function filter(_43,fn){ +if(typeof (fn)=="string"){ +return filter(_43,__strfn("item,idx,list",fn)); +} +var _44=[]; +fn=fn||function(v){ +return v; +}; +map(_43,function(_45,idx,_43){ +if(fn(_45,idx,_43)){ +_44.push(_45); +} +}); +return _44; +} +function reduce(_46,_47,fn){ +if(undef(fn)){ +fn=_47; +_47=window.undefined; +} +if(typeof (fn)=="string"){ +return reduce(_46,_47,__strfn("a,b",fn)); +} +if(isdef(_47)){ +_46.splice(0,0,_47); +} +if(_46.length===0){ +return false; +} +if(_46.length===1){ +return _46[0]; +} +var _48=_46[0]; +var i=1; +while(i<_46.length){ +_48=fn(_48,_46[i++]); +} +return _48; +} +function range(_49,_50,_51){ +if(isUndefined(_50)){ +return range(0,_49,_51); +} +if(isUndefined(_51)){ +_51=1; +} +var ss=(_51/Math.abs(_51)); +var r=[]; +for(i=_49;i*ss<_50*ss;i=i+_51){ +r.push(i); +} +return r; +} + +var Hash={_each:function(_1){ +for(key in this){ +var _2=this[key]; +if(typeof _2=="function"){ +continue; +} +var _3=[key,_2]; +_3.key=key; +_3.value=_2; +_1(_3); +} +},keys:function(){ +return this.pluck("key"); +},values:function(){ +return this.pluck("value"); +},merge:function(_4){ +return $H(_4).inject($H(this),function(_5,_6){ +_5[_6.key]=_6.value; +return _5; +}); +},toQueryString:function(){ +return this.map(function(_7){ +return _7.map(encodeURIComponent).join("="); +}).join("&"); +},inspect:function(){ +return "#"; +}}; +function $H(_9){ +var _10=Object.extend({},_9||{}); +Object.extend(_10,Enumerable); +Object.extend(_10,Hash); +return _10; +} + +var Range=Class.create(); +Object.extend(Range.prototype,Enumerable); +Object.extend(Range.prototype,{initialize:function(_1,_2,_3){ +this.start=_1; +this.end=_2; +this.exclusive=_3; +},_each:function(_4){ +var _5=this.start; +do{ +_4(_5); +_5=_5.succ(); +}while(this.include(_5)); +},include:function(_6){ +if(_60)){ +_10.action=_9.actionUrl; +} +if(_9.trackFocus){ +var _12=_10.elements["PRADO_LASTFOCUS"]; +if((typeof (_12)!="undefined")&&(_12!=null)){ +var _13=document.activeElement; +if(typeof (_13)=="undefined"){ +_12.value=_7; +}else{ +if((_13!=null)&&(typeof (_13.id)!="undefined")){ +if(_13.id.length>0){ +_12.value=_13.id; +}else{ +if(typeof (_13.name)!="undefined"){ +_12.value=_13.name; +} +} +} +} +} +} +if(!_9.clientSubmit){ +_11=false; +} +} +} +if(_11&&(!_10.onsubmit||_10.onsubmit())){ +_10.PRADO_POSTBACK_TARGET.value=_7; +_10.PRADO_POSTBACK_PARAMETER.value=_8; +_10.submit(); +} +}; + +Prado.Focus=Class.create(); +Prado.Focus.setFocus=function(id){ +var _2=document.getElementById?document.getElementById(id):document.all[id]; +if(_2&&!Prado.Focus.canFocusOn(_2)){ +_2=Prado.Focus.findTarget(_2); +} +if(_2){ +try{ +_2.focus(); +_2.scrollIntoView(false); +if(window.__smartNav){ +window.__smartNav.ae=_2.id; +} +} +catch(e){ +} +} +}; +Prado.Focus.canFocusOn=function(_3){ +if(!_3||!(_3.tagName)){ +return false; +} +var _4=_3.tagName.toLowerCase(); +return !_3.disabled&&(!_3.type||_3.type.toLowerCase()!="hidden")&&Prado.Focus.isFocusableTag(_4)&&Prado.Focus.isVisible(_3); +}; +Prado.Focus.isFocusableTag=function(_5){ +return (_5=="input"||_5=="textarea"||_5=="select"||_5=="button"||_5=="a"); +}; +Prado.Focus.findTarget=function(_6){ +if(!_6||!(_6.tagName)){ +return null; +} +var _7=_6.tagName.toLowerCase(); +if(_7=="undefined"){ +return null; +} +var _8=_6.childNodes; +if(_8){ +for(var i=0;i<_8.length;i++){ +try{ +if(Prado.Focus.canFocusOn(_8[i])){ +return _8[i]; +}else{ +var _10=Prado.Focus.findTarget(_8[i]); +if(_10){ +return _10; +} +} +} +catch(e){ +} +} +} +return null; +}; +Prado.Focus.isVisible=function(_11){ +var _12=_11; +while((typeof (_12)!="undefined")&&(_12!=null)){ +if(_12.disabled||(typeof (_12.style)!="undefined"&&((typeof (_12.style.display)!="undefined"&&_12.style.display=="none")||(typeof (_12.style.visibility)!="undefined"&&_12.style.visibility=="hidden")))){ +return false; +} +if(typeof (_12.parentNode)!="undefined"&&_12.parentNode!=null&&_12.parentNode!=_12&&_12.parentNode.tagName.toLowerCase()!="body"){ +_12=_12.parentNode; +}else{ +return true; +} +} +return true; +}; + + -- cgit v1.2.3