summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/js
diff options
context:
space:
mode:
authorwei <>2006-02-18 23:41:16 +0000
committerwei <>2006-02-18 23:41:16 +0000
commit270282e3a26b21184a2051995cb5b9a2755b823d (patch)
tree761d82ad761996f329d63acc770fc5a0bce9d5a2 /framework/Web/Javascripts/js
parentf1cc3c880b564362e7f00b18326e116884879231 (diff)
Update some javascript code.
Diffstat (limited to 'framework/Web/Javascripts/js')
-rw-r--r--framework/Web/Javascripts/js/colorpicker.js4
-rw-r--r--framework/Web/Javascripts/js/datepicker.js323
-rw-r--r--framework/Web/Javascripts/js/validator.js9
3 files changed, 185 insertions, 151 deletions
diff --git a/framework/Web/Javascripts/js/colorpicker.js b/framework/Web/Javascripts/js/colorpicker.js
index 2484b6d8..e220ab33 100644
--- a/framework/Web/Javascripts/js/colorpicker.js
+++ b/framework/Web/Javascripts/js/colorpicker.js
@@ -320,7 +320,7 @@ this.inputs=_65;
var _67=Prado.WebUI.TColorPicker.UIImages;
this.inputs["currentColor"]=SPAN({className:"currentColor"});
this.inputs["oldColor"]=SPAN({className:"oldColor"});
-var _68=TABLE({className:"inputs"},TBODY(null,TR(null,TD({className:"currentcolor",colSpan:2},this.inputs["currentColor"],this.inputs["oldColor"])),TR(null,TD(null,"H:"),TD(null,this.inputs["H"],"\xc2\xb0")),TR(null,TD(null,"S:"),TD(null,this.inputs["S"],"%")),TR(null,TD(null,"V:"),TD(null,this.inputs["V"],"%")),TR(null,TD({className:"gap"},"R:"),TD({className:"gap"},this.inputs["R"])),TR(null,TD(null,"G:"),TD(null,this.inputs["G"])),TR(null,TD(null,"B:"),TD(null,this.inputs["B"])),TR(null,TD({className:"gap"},"#"),TD({className:"gap"},this.inputs["HEX"]))));
+var _68=TABLE({className:"inputs"},TBODY(null,TR(null,TD({className:"currentcolor",colSpan:2},this.inputs["currentColor"],this.inputs["oldColor"])),TR(null,TD(null,"H:"),TD(null,this.inputs["H"],'°')),TR(null,TD(null,"S:"),TD(null,this.inputs["S"],"%")),TR(null,TD(null,"V:"),TD(null,this.inputs["V"],"%")),TR(null,TD({className:"gap"},"R:"),TD({className:"gap"},this.inputs["R"])),TR(null,TD(null,"G:"),TD(null,this.inputs["G"])),TR(null,TD(null,"B:"),TD(null,this.inputs["B"])),TR(null,TD({className:"gap"},"#"),TD({className:"gap"},this.inputs["HEX"]))));
var _69={selector:SPAN({className:"selector"}),background:SPAN({className:"colorpanel"}),slider:SPAN({className:"slider"}),hue:SPAN({className:"strip"})};
if(Prado.Browser().ie){
var _70="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader";
@@ -350,9 +350,7 @@ this._onMouseMove=this.onMouseMove.bind(this);
Event.observe(this.inputs.background,"mousedown",this._onColorMouseDown);
Event.observe(this.inputs.hue,"mousedown",this._onHueMouseDown);
Event.observe(document.body,"mouseup",this._onMouseUp);
-if(!Prado.Browser().ie){
Event.observe(document.body,"mousemove",this._onMouseMove);
-}
Event.observe(this.buttons.Cancel,"click",this.hide.bindEvent(this,this.options["Mode"]));
Event.observe(this.buttons.OK,"click",this.onOKClicked.bind(this));
},onColorMouseDown:function(ev){
diff --git a/framework/Web/Javascripts/js/datepicker.js b/framework/Web/Javascripts/js/datepicker.js
index 4ab5cd68..b9d7b610 100644
--- a/framework/Web/Javascripts/js/datepicker.js
+++ b/framework/Web/Javascripts/js/datepicker.js
@@ -1,46 +1,46 @@
Prado.WebUI.TDatePicker=Class.create();
-Prado.WebUI.TDatePicker.prototype={MonthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],ShortWeekDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Format:"yyyy-MM-dd",FirstDayOfWeek:1,ClassName:"TDatePicker",FromYear:2000,UpToYear:2015,initialize:function(_1,_2){
-this.attr=_2||[];
-this.control=$(_1);
+Prado.WebUI.TDatePicker.prototype={MonthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],ShortWeekDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Format:"yyyy-MM-dd",FirstDayOfWeek:1,ClassName:"TDatePicker",FromYear:2000,UpToYear:2015,initialize:function(_1){
+this.options=_1||[];
+this.control=$(_1.ID);
this.dateSlot=new Array(42);
this.weekSlot=new Array(6);
this.minimalDaysInFirstWeek=4;
this.selectedDate=this.newDate();
-if(this.attr.Trigger){
-this.trigger=$(this.attr.Trigger);
-var _3=this.attr.TriggerEvent||"click";
+if(this.options.Trigger){
+this.trigger=$(this.options.Trigger);
+var _2=this.options.TriggerEvent||"click";
}else{
this.trigger=this.control;
-var _3=this.attr.TriggerEvent||"focus";
+var _2=this.options.TriggerEvent||"focus";
}
-Event.observe(this.trigger,_3,this.show.bindEvent(this));
-Object.extend(this,_2);
+Object.extend(this,_1);
+Event.observe(this.trigger,_2,this.show.bindEvent(this));
this.create();
},create:function(){
+var _3;
var _4;
var _5;
-var _6;
var tr;
var td;
this._calDiv=document.createElement("div");
this._calDiv.className=this.ClassName;
this._calDiv.style.display="none";
this._calDiv.style.position="absolute";
-_4=document.createElement("div");
-_4.className="calendarHeader";
-this._calDiv.appendChild(_4);
-_5=document.createElement("table");
-_5.style.cellSpacing=0;
+_3=document.createElement("div");
+_3.className="calendarHeader";
+this._calDiv.appendChild(_3);
+_4=document.createElement("table");
+_4.style.cellSpacing=0;
+_3.appendChild(_4);
+_5=document.createElement("tbody");
_4.appendChild(_5);
-_6=document.createElement("tbody");
-_5.appendChild(_6);
tr=document.createElement("tr");
-_6.appendChild(tr);
+_5.appendChild(tr);
td=document.createElement("td");
-var _9=document.createElement("button");
-_9.className="prevMonthButton";
-_9.appendChild(document.createTextNode("<<"));
-td.appendChild(_9);
+var _8=document.createElement("button");
+_8.className="prevMonthButton";
+_8.appendChild(document.createTextNode("<<"));
+td.appendChild(_8);
tr.appendChild(td);
td=document.createElement("td");
tr.appendChild(td);
@@ -72,58 +72,58 @@ this._yearSelect.appendChild(opt);
td.appendChild(this._yearSelect);
td=document.createElement("td");
td.className="nextMonthButton";
-var _12=document.createElement("button");
-_12.appendChild(document.createTextNode(">>"));
-td.appendChild(_12);
+var _11=document.createElement("button");
+_11.appendChild(document.createTextNode(">>"));
+td.appendChild(_11);
tr.appendChild(td);
-_4=document.createElement("div");
-_4.className="calendarBody";
-this._calDiv.appendChild(_4);
-var _13=_4;
-var _14;
-_5=document.createElement("table");
-_5.className="grid";
-_4.appendChild(_5);
-var _15=document.createElement("thead");
-_5.appendChild(_15);
+_3=document.createElement("div");
+_3.className="calendarBody";
+this._calDiv.appendChild(_3);
+var _12=_3;
+var _13;
+_4=document.createElement("table");
+_4.className="grid";
+_3.appendChild(_4);
+var _14=document.createElement("thead");
+_4.appendChild(_14);
tr=document.createElement("tr");
-_15.appendChild(tr);
+_14.appendChild(tr);
for(i=0;i<7;++i){
td=document.createElement("th");
-_14=document.createTextNode(this.ShortWeekDayNames[(i+this.FirstDayOfWeek)%7]);
-td.appendChild(_14);
+_13=document.createTextNode(this.ShortWeekDayNames[(i+this.FirstDayOfWeek)%7]);
+td.appendChild(_13);
td.className="weekDayHead";
tr.appendChild(td);
}
-_6=document.createElement("tbody");
-_5.appendChild(_6);
+_5=document.createElement("tbody");
+_4.appendChild(_5);
for(week=0;week<6;++week){
tr=document.createElement("tr");
-_6.appendChild(tr);
+_5.appendChild(tr);
for(day=0;day<7;++day){
td=document.createElement("td");
td.className="calendarDate";
-_14=document.createTextNode(String.fromCharCode(160));
-td.appendChild(_14);
+_13=document.createTextNode(String.fromCharCode(160));
+td.appendChild(_13);
tr.appendChild(td);
var tmp=new Object();
tmp.tag="DATE";
tmp.value=-1;
-tmp.data=_14;
+tmp.data=_13;
this.dateSlot[(week*7)+day]=tmp;
Event.observe(td,"mouseover",this.hover.bindEvent(this));
Event.observe(td,"mouseout",this.hover.bindEvent(this));
}
}
-_4=document.createElement("div");
-_4.className="calendarFooter";
-this._calDiv.appendChild(_4);
-var _17=document.createElement("button");
-_17.className="todayButton";
-var _18=this.newDate();
-var _19=_18.SimpleFormat(this.Format);
-_17.appendChild(document.createTextNode(_19));
-_4.appendChild(_17);
+_3=document.createElement("div");
+_3.className="calendarFooter";
+this._calDiv.appendChild(_3);
+var _16=document.createElement("button");
+_16.className="todayButton";
+var _17=this.newDate();
+var _18=_17.SimpleFormat(this.Format);
+_16.appendChild(document.createTextNode(_18));
+_3.appendChild(_16);
if(Prado.Browser().ie){
this.iePopUp=document.createElement("iframe");
this.iePopUp.src="";
@@ -136,24 +136,24 @@ document.body.appendChild(this._calDiv);
this.update();
this.updateHeader();
this.ieHack(true);
-_9.hideFocus=true;
-_12.hideFocus=true;
-_17.hideFocus=true;
-Event.observe(_9,"click",this.prevMonth.bindEvent(this));
-Event.observe(_12,"click",this.nextMonth.bindEvent(this));
-Event.observe(_17,"click",this.selectToday.bindEvent(this));
+_8.hideFocus=true;
+_11.hideFocus=true;
+_16.hideFocus=true;
+Event.observe(_8,"click",this.prevMonth.bindEvent(this));
+Event.observe(_11,"click",this.nextMonth.bindEvent(this));
+Event.observe(_16,"click",this.selectToday.bindEvent(this));
Event.observe(this._monthSelect,"change",this.monthSelect.bindEvent(this));
Event.observe(this._yearSelect,"change",this.yearSelect.bindEvent(this));
Event.observe(this._calDiv,"mousewheel",this.mouseWheelChange.bindEvent(this));
-Event.observe(_13,"click",this.selectDate.bindEvent(this));
-},ieHack:function(_20){
+Event.observe(_12,"click",this.selectDate.bindEvent(this));
+},ieHack:function(_19){
if(this.iePopUp){
this.iePopUp.style.display="block";
this.iePopUp.style.top=(this._calDiv.offsetTop-1)+"px";
this.iePopUp.style.left=(this._calDiv.offsetLeft-1)+"px";
this.iePopUp.style.width=Math.abs(this._calDiv.offsetWidth-2)+"px";
this.iePopUp.style.height=(this._calDiv.offsetHeight+1)+"px";
-if(_20){
+if(_19){
this.iePopUp.style.display="none";
}
}
@@ -174,48 +174,48 @@ if(kc==Event.KEY_ESC){
Event.stop(ev);
this.hide();
}
-var _23=function(_24,_25){
-_24=(_24+12)%12;
-var _26=[31,28,31,30,31,30,31,31,30,31,30,31];
-var res=_26[_24];
-if(_24==1){
-res+=_25%4==0&&!(_25%400==0)?1:0;
+var _22=function(_23,_24){
+_23=(_23+12)%12;
+var _25=[31,28,31,30,31,30,31,31,30,31,30,31];
+var res=_25[_23];
+if(_23==1){
+res+=_24%4==0&&!(_24%400==0)?1:0;
}
return res;
};
if(kc<37||kc>40){
return true;
}
-var _28=this.selectedDate;
-var d=_28.valueOf();
+var _27=this.selectedDate;
+var d=_27.valueOf();
if(kc==Event.KEY_LEFT){
if(ev.ctrlKey||ev.shiftKey){
-_28.setDate(Math.min(_28.getDate(),_23(_28.getMonth()-1,_28.getFullYear())));
-d=_28.setMonth(_28.getMonth()-1);
+_27.setDate(Math.min(_27.getDate(),_22(_27.getMonth()-1,_27.getFullYear())));
+d=_27.setMonth(_27.getMonth()-1);
}else{
d-=86400000;
}
}else{
if(kc==Event.KEY_RIGHT){
if(ev.ctrlKey||ev.shiftKey){
-_28.setDate(Math.min(_28.getDate(),_23(_28.getMonth()+1,_28.getFullYear())));
-d=_28.setMonth(_28.getMonth()+1);
+_27.setDate(Math.min(_27.getDate(),_22(_27.getMonth()+1,_27.getFullYear())));
+d=_27.setMonth(_27.getMonth()+1);
}else{
d+=86400000;
}
}else{
if(kc==Event.KEY_UP){
if(ev.ctrlKey||ev.shiftKey){
-_28.setDate(Math.min(_28.getDate(),_23(_28.getMonth(),_28.getFullYear()-1)));
-d=_28.setFullYear(_28.getFullYear()-1);
+_27.setDate(Math.min(_27.getDate(),_22(_27.getMonth(),_27.getFullYear()-1)));
+d=_27.setFullYear(_27.getFullYear()-1);
}else{
d-=604800000;
}
}else{
if(kc==Event.KEY_DOWN){
if(ev.ctrlKey||ev.shiftKey){
-_28.setDate(Math.min(_28.getDate(),_23(_28.getMonth(),_28.getFullYear()+1)));
-d=_28.setFullYear(_28.getFullYear()+1);
+_27.setDate(Math.min(_27.getDate(),_22(_27.getMonth(),_27.getFullYear()+1)));
+d=_27.setFullYear(_27.getFullYear()+1);
}else{
d+=7*24*61*60*1000;
}
@@ -266,22 +266,35 @@ var m=d.getMonth()+n;
this.setMonth(m);
return false;
},onchange:function(){
+if(this.options.InputMode=="TextBox"){
this.control.value=this.formatDate();
+}else{
+var day=$(this.options.ID+"_day");
+var _34=$(this.options.ID+"_month");
+var _35=$(this.options.ID+"_year").options;
+var _36=this.selectedDate;
+day.selectedIndex=_36.getDate()-1;
+_34.selectedIndex=_36.getMonth();
+var _37=_36.getFullYear();
+for(var i=0;i<_35.length;i++){
+_35[i].selected=_35[i].value.toInteger()==_37;
+}
+}
},formatDate:function(){
return this.selectedDate?this.selectedDate.SimpleFormat(this.Format):"";
-},newDate:function(_34){
-if(!_34){
-_34=new Date();
+},newDate:function(_38){
+if(!_38){
+_38=new Date();
}
-if(isString(_34)||isNumber(_34)){
-_34=new Date(_34);
+if(isString(_38)||isNumber(_38)){
+_38=new Date(_38);
}
-return new Date(_34.getFullYear(),_34.getMonth(),_34.getDate(),0,0,0);
-},setSelectedDate:function(_35){
-if(_35==null){
+return new Date(_38.getFullYear(),_38.getMonth(),_38.getDate(),0,0,0);
+},setSelectedDate:function(_39){
+if(_39==null){
return;
}
-this.selectedDate=this.newDate(_35);
+this.selectedDate=this.newDate(_39);
this.updateHeader();
this.update();
if(isFunction(this.onchange)){
@@ -291,13 +304,13 @@ this.onchange();
return this._calDiv;
},getSelectedDate:function(){
return isNull(this.selectedDate)?null:this.newDate(this.selectedDate);
-},setYear:function(_36){
+},setYear:function(_40){
var d=this.newDate(this.selectedDate);
-d.setFullYear(_36);
+d.setFullYear(_40);
this.setSelectedDate(d);
-},setMonth:function(_37){
+},setMonth:function(_41){
var d=this.newDate(this.selectedDate);
-d.setMonth(_37);
+d.setMonth(_41);
this.setSelectedDate(d);
},nextMonth:function(){
this.setMonth(this.selectedDate.getMonth()+1);
@@ -306,7 +319,11 @@ this.setMonth(this.selectedDate.getMonth()-1);
},show:function(){
if(!this.showing){
var pos=Position.cumulativeOffset(this.control);
+if(this.options.InputMode=="TextBox"){
pos[1]+=this.control.offsetHeight;
+}else{
+pos[1]+=$(this.options.ID+"_day").offsetHeight-1;
+}
this._calDiv.style.display="block";
this._calDiv.style.top=(pos[1]-1)+"px";
this._calDiv.style.left=pos[0]+"px";
@@ -314,30 +331,40 @@ this.ieHack(false);
this.documentClickEvent=this.hideOnClick.bindEvent(this);
this.documentKeyDownEvent=this.keyPressed.bindEvent(this);
Event.observe(document.body,"click",this.documentClickEvent);
-var _39=Date.SimpleParse(Form.Element.getValue(this.control),this.Format);
-if(!isNull(_39)){
-this.selectedDate=_39;
-this.setSelectedDate(_39);
+var _43=this.getDateFromInput();
+if(!isNull(_43)){
+this.selectedDate=_43;
+this.setSelectedDate(_43);
}
Event.observe(document,"keydown",this.documentKeyDownEvent);
this.showing=true;
}
+},getDateFromInput:function(){
+if(this.options.InputMode=="TextBox"){
+return Date.SimpleParse($F(this.control),this.Format);
+}else{
+var day=$F(this.options.ID+"_day");
+var _44=$F(this.options.ID+"_month");
+var _45=$F(this.options.ID+"_year");
+var _46=new Date(_45,_44,day,0,0,0);
+return _46;
+}
},hideOnClick:function(ev){
if(!this.showing){
return;
}
var el=Event.element(ev);
-var _40=false;
+var _47=false;
do{
-_40=_40||el.className==this.ClassName;
-_40=_40||el==this.trigger;
-_40=_40||el==this.control;
-if(_40){
+_47=_47||el.className==this.ClassName;
+_47=_47||el==this.trigger;
+_47=_47||el==this.control;
+if(_47){
break;
}
el=el.parentNode;
}while(el);
-if(!_40){
+if(!_47){
this.hide();
}
},hide:function(){
@@ -351,61 +378,61 @@ Event.stopObserving(document.body,"click",this.documentClickEvent);
Event.stopObserving(document,"keydown",this.documentKeyDownEvent);
}
},update:function(){
-var _41=this.selectedDate;
-var _42=(this.newDate()).toISODate();
-var _43=_41.toISODate();
-var d1=new Date(_41.getFullYear(),_41.getMonth(),1);
-var d2=new Date(_41.getFullYear(),_41.getMonth()+1,1);
-var _46=Math.round((d2-d1)/(24*60*60*1000));
-var _47=(d1.getDay()-this.FirstDayOfWeek)%7;
-if(_47<0){
-_47+=7;
-}
-var _48=0;
-while(_48<_47){
-this.dateSlot[_48].value=-1;
-this.dateSlot[_48].data.data=String.fromCharCode(160);
-this.dateSlot[_48].data.parentNode.className="empty";
-_48++;
-}
-for(i=1;i<=_46;i++,_48++){
-var _49=this.dateSlot[_48];
-var _50=_49.data.parentNode;
-_49.value=i;
-_49.data.data=i;
-_50.className="date";
-if(d1.toISODate()==_42){
-_50.className+=" today";
-}
-if(d1.toISODate()==_43){
-_50.className+=" selected";
+var _48=this.selectedDate;
+var _49=(this.newDate()).toISODate();
+var _50=_48.toISODate();
+var d1=new Date(_48.getFullYear(),_48.getMonth(),1);
+var d2=new Date(_48.getFullYear(),_48.getMonth()+1,1);
+var _53=Math.round((d2-d1)/(24*60*60*1000));
+var _54=(d1.getDay()-this.FirstDayOfWeek)%7;
+if(_54<0){
+_54+=7;
+}
+var _55=0;
+while(_55<_54){
+this.dateSlot[_55].value=-1;
+this.dateSlot[_55].data.data=String.fromCharCode(160);
+this.dateSlot[_55].data.parentNode.className="empty";
+_55++;
+}
+for(i=1;i<=_53;i++,_55++){
+var _56=this.dateSlot[_55];
+var _57=_56.data.parentNode;
+_56.value=i;
+_56.data.data=i;
+_57.className="date";
+if(d1.toISODate()==_49){
+_57.className+=" today";
+}
+if(d1.toISODate()==_50){
+_57.className+=" selected";
}
d1=new Date(d1.getFullYear(),d1.getMonth(),d1.getDate()+1);
}
-var _51=_48;
-while(_48<42){
-this.dateSlot[_48].value=-1;
-this.dateSlot[_48].data.data=String.fromCharCode(160);
-this.dateSlot[_48].data.parentNode.className="empty";
-++_48;
+var _58=_55;
+while(_55<42){
+this.dateSlot[_55].value=-1;
+this.dateSlot[_55].data.data=String.fromCharCode(160);
+this.dateSlot[_55].data.parentNode.className="empty";
+++_55;
}
},hover:function(ev){
Element.condClassName(Event.element(ev),"hover",ev.type=="mouseover");
},updateHeader:function(){
-var _52=this._monthSelect.options;
+var _59=this._monthSelect.options;
var m=this.selectedDate.getMonth();
-for(var i=0;i<_52.length;++i){
-_52[i].selected=false;
-if(_52[i].value==m){
-_52[i].selected=true;
-}
-}
-_52=this._yearSelect.options;
-var _53=this.selectedDate.getFullYear();
-for(var i=0;i<_52.length;++i){
-_52[i].selected=false;
-if(_52[i].value==_53){
-_52[i].selected=true;
+for(var i=0;i<_59.length;++i){
+_59[i].selected=false;
+if(_59[i].value==m){
+_59[i].selected=true;
+}
+}
+_59=this._yearSelect.options;
+var _60=this.selectedDate.getFullYear();
+for(var i=0;i<_59.length;++i){
+_59[i].selected=false;
+if(_59[i].value==_60){
+_59[i].selected=true;
}
}
}};
diff --git a/framework/Web/Javascripts/js/validator.js b/framework/Web/Javascripts/js/validator.js
index f5ca2c8b..e1d0806a 100644
--- a/framework/Web/Javascripts/js/validator.js
+++ b/framework/Web/Javascripts/js/validator.js
@@ -243,20 +243,29 @@ var _55=_54||this.attr.refresh=="1";
var _56=this.getMessages();
if(_56.length<=0||!this.visible||!this.enabled){
if(_55){
+if(this.attr.display=="None"||this.attr.display=="Dynamic"){
Element.hide(this.div);
+}else{
+this.div.style.visibility="hidden";
+}
}
return;
}
if(Prado.Validation.HasTargetGroup){
if(Prado.Validation.CurrentTargetGroup!=this.group){
if(_55){
+if(this.attr.display=="None"||this.attr.display=="Dynamic"){
Element.hide(this.div);
+}else{
+this.div.style.visibility="hidden";
+}
}
return;
}
}
if(this.attr.showsummary!="False"&&_55){
this.div.style.display="block";
+this.div.style.visibility="visible";
while(this.div.childNodes.length>0){
this.div.removeChild(this.div.lastChild);
}