summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authorwei <>2006-01-20 07:02:43 +0000
committerwei <>2006-01-20 07:02:43 +0000
commita48195e52865532add00af44788c938071eb0e1d (patch)
treec3d3bd95cfb09c7e4b45fe6363874bef8397d7ce /framework/Web
parent138dbc23381a82eaf17a2685cc3bdb54ad8b7f51 (diff)
Update date picker
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/Javascripts/datepicker/calendar.pngbin0 -> 775 bytes
-rw-r--r--framework/Web/Javascripts/datepicker/datepicker.js (renamed from framework/Web/Javascripts/prado/datepicker.js)22
-rw-r--r--framework/Web/Javascripts/datepicker/default.css (renamed from framework/Web/Javascripts/prado/datepicker_default.css)19
-rw-r--r--framework/Web/Javascripts/extended/date.js10
-rw-r--r--framework/Web/Javascripts/js/datepicker.js192
-rw-r--r--framework/Web/Javascripts/js/prado.js147
-rw-r--r--framework/Web/Javascripts/prado/test.html105
-rw-r--r--framework/Web/UI/WebControls/TDatePicker.php90
8 files changed, 282 insertions, 303 deletions
diff --git a/framework/Web/Javascripts/datepicker/calendar.png b/framework/Web/Javascripts/datepicker/calendar.png
new file mode 100644
index 00000000..c245f1b4
--- /dev/null
+++ b/framework/Web/Javascripts/datepicker/calendar.png
Binary files differ
diff --git a/framework/Web/Javascripts/prado/datepicker.js b/framework/Web/Javascripts/datepicker/datepicker.js
index f3c6ff27..5468fb6c 100644
--- a/framework/Web/Javascripts/prado/datepicker.js
+++ b/framework/Web/Javascripts/datepicker/datepicker.js
@@ -56,6 +56,7 @@ Prado.WebUI.TDatePicker.prototype =
this._calDiv = document.createElement("div");
this._calDiv.className = this.ClassName;
this._calDiv.style.display = "none";
+ this._calDiv.style.position = "absolute"
// header div
div = document.createElement("div");
@@ -137,7 +138,6 @@ Prado.WebUI.TDatePicker.prototype =
var text;
table = document.createElement("table");
- //table.style.width="100%";
table.className = "grid";
div.appendChild(table);
@@ -189,16 +189,17 @@ Prado.WebUI.TDatePicker.prototype =
var todayButton = document.createElement("button");
todayButton.className = "todayButton";
var today = this.newDate();
- var buttonText = today.getDate() + " " + this.MonthNames[today.getMonth()] + ", " + today.getFullYear();
+ var buttonText = today.SimpleFormat(this.Format);
todayButton.appendChild(document.createTextNode(buttonText));
div.appendChild(todayButton);
- var clearButton = document.createElement("button");
+ /*var clearButton = document.createElement("button");
clearButton.className = "clearButton";
buttonText = "Clear";
clearButton.appendChild(document.createTextNode(buttonText));
div.appendChild(clearButton);
-
+ */
+
if(Prado.Browser().ie)
{
this.iePopUp = document.createElement('iframe');
@@ -226,7 +227,7 @@ Prado.WebUI.TDatePicker.prototype =
Event.observe(previousMonth, "click", this.prevMonth.bindEvent(this));
Event.observe(nextMonth, "click", this.nextMonth.bindEvent(this));
Event.observe(todayButton, "click", this.selectToday.bindEvent(this));
- Event.observe(clearButton, "click", this.clearSelection.bindEvent(this));
+ //Event.observe(clearButton, "click", this.clearSelection.bindEvent(this));
Event.observe(this._monthSelect, "change", this.monthSelect.bindEvent(this));
Event.observe(this._yearSelect, "change", this.yearSelect.bindEvent(this));
@@ -259,11 +260,14 @@ Prado.WebUI.TDatePicker.prototype =
if(kc == Event.KEY_RETURN)
{
- //var d = new Date(this.currentDate);
- //this.setSelectedDate(this.currentDate);
+ this.setSelectedDate(this.selectedDate);
Event.stop(ev);
this.hide();
}
+ if(kc == Event.KEY_ESC)
+ {
+ Event.stop(ev); this.hide();
+ }
var getDaysPerMonth = function (nMonth, nYear)
@@ -349,8 +353,10 @@ Prado.WebUI.TDatePicker.prototype =
selectToday : function()
{
+ if(this.selectedDate.toISODate() == this.newDate().toISODate())
+ this.hide();
+
this.setSelectedDate(this.newDate());
- this.hide();
},
clearSelection : function()
diff --git a/framework/Web/Javascripts/prado/datepicker_default.css b/framework/Web/Javascripts/datepicker/default.css
index 3d57370b..cd03bb27 100644
--- a/framework/Web/Javascripts/prado/datepicker_default.css
+++ b/framework/Web/Javascripts/datepicker/default.css
@@ -1,7 +1,6 @@
.TDatePicker
{
border: 1px solid #919EA9;
- position: absolute;
background-color: White;
text-align: center;
font-size: 11px;
@@ -9,6 +8,24 @@
cursor: default;
}
+.TDatePickerButton
+{
+ width: 30px;
+}
+
+.TDatePickerImageButton
+{
+ padding: 2px;
+ border: 1px solid #919EA9;
+ vertical-align: top;
+ margin-left: 1px;
+}
+
+.TDatePickerImageButton:hover
+{
+ border-color: #ddd;
+}
+
.TDatePicker select
{
font-size: 11px;
diff --git a/framework/Web/Javascripts/extended/date.js b/framework/Web/Javascripts/extended/date.js
index 9e56ff64..b27f9da2 100644
--- a/framework/Web/Javascripts/extended/date.js
+++ b/framework/Web/Javascripts/extended/date.js
@@ -1,20 +1,24 @@
Object.extend(Date.prototype,
{
- SimpleFormat: function(format)
+ SimpleFormat: function(format, data)
{
+ data = data || {};
var bits = new Array();
bits['d'] = this.getDate();
bits['dd'] = String(this.getDate()).zerofill(2);
bits['M'] = this.getMonth()+1;
bits['MM'] = String(this.getMonth()+1).zerofill(2);
-
+ if(data.AbbreviatedMonthNames)
+ bits['MMM'] = data.AbbreviatedMonthNames[this.getMonth()];
+ if(data.MonthNames)
+ bits['MMMM'] = data.MonthNames[this.getMonth()];
var yearStr = "" + this.getFullYear();
yearStr = (yearStr.length == 2) ? '19' + yearStr: yearStr;
bits['yyyy'] = yearStr;
bits['yy'] = bits['yyyy'].toString().substr(2,2);
-
+
// do some funky regexs to replace the format string
// with the real values
var frm = new String(format);
diff --git a/framework/Web/Javascripts/js/datepicker.js b/framework/Web/Javascripts/js/datepicker.js
index e840fc68..4ab5cd68 100644
--- a/framework/Web/Javascripts/js/datepicker.js
+++ b/framework/Web/Javascripts/js/datepicker.js
@@ -25,6 +25,7 @@ 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);
@@ -120,14 +121,9 @@ this._calDiv.appendChild(_4);
var _17=document.createElement("button");
_17.className="todayButton";
var _18=this.newDate();
-var _19=_18.getDate()+" "+this.MonthNames[_18.getMonth()]+", "+_18.getFullYear();
+var _19=_18.SimpleFormat(this.Format);
_17.appendChild(document.createTextNode(_19));
_4.appendChild(_17);
-var _20=document.createElement("button");
-_20.className="clearButton";
-_19="Clear";
-_20.appendChild(document.createTextNode(_19));
-_4.appendChild(_20);
if(Prado.Browser().ie){
this.iePopUp=document.createElement("iframe");
this.iePopUp.src="";
@@ -146,19 +142,18 @@ _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));
-Event.observe(_20,"click",this.clearSelection.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(_21){
+},ieHack:function(_20){
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(_21){
+if(_20){
this.iePopUp.style.display="none";
}
}
@@ -171,51 +166,56 @@ ev=document.parentWindow.event;
}
var kc=ev.keyCode!=null?ev.keyCode:ev.charCode;
if(kc==Event.KEY_RETURN){
+this.setSelectedDate(this.selectedDate);
Event.stop(ev);
this.hide();
}
-var _24=function(_25,_26){
-_25=(_25+12)%12;
-var _27=[31,28,31,30,31,30,31,31,30,31,30,31];
-var res=_27[_25];
-if(_25==1){
-res+=_26%4==0&&!(_26%400==0)?1:0;
+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;
}
return res;
};
if(kc<37||kc>40){
return true;
}
-var _29=this.selectedDate;
-var d=_29.valueOf();
+var _28=this.selectedDate;
+var d=_28.valueOf();
if(kc==Event.KEY_LEFT){
if(ev.ctrlKey||ev.shiftKey){
-_29.setDate(Math.min(_29.getDate(),_24(_29.getMonth()-1,_29.getFullYear())));
-d=_29.setMonth(_29.getMonth()-1);
+_28.setDate(Math.min(_28.getDate(),_23(_28.getMonth()-1,_28.getFullYear())));
+d=_28.setMonth(_28.getMonth()-1);
}else{
d-=86400000;
}
}else{
if(kc==Event.KEY_RIGHT){
if(ev.ctrlKey||ev.shiftKey){
-_29.setDate(Math.min(_29.getDate(),_24(_29.getMonth()+1,_29.getFullYear())));
-d=_29.setMonth(_29.getMonth()+1);
+_28.setDate(Math.min(_28.getDate(),_23(_28.getMonth()+1,_28.getFullYear())));
+d=_28.setMonth(_28.getMonth()+1);
}else{
d+=86400000;
}
}else{
if(kc==Event.KEY_UP){
if(ev.ctrlKey||ev.shiftKey){
-_29.setDate(Math.min(_29.getDate(),_24(_29.getMonth(),_29.getFullYear()-1)));
-d=_29.setFullYear(_29.getFullYear()-1);
+_28.setDate(Math.min(_28.getDate(),_23(_28.getMonth(),_28.getFullYear()-1)));
+d=_28.setFullYear(_28.getFullYear()-1);
}else{
d-=604800000;
}
}else{
if(kc==Event.KEY_DOWN){
if(ev.ctrlKey||ev.shiftKey){
-_29.setDate(Math.min(_29.getDate(),_24(_29.getMonth(),_29.getFullYear()+1)));
-d=_29.setFullYear(_29.getFullYear()+1);
+_28.setDate(Math.min(_28.getDate(),_23(_28.getMonth(),_28.getFullYear()+1)));
+d=_28.setFullYear(_28.getFullYear()+1);
}else{
d+=7*24*61*60*1000;
}
@@ -245,8 +245,10 @@ d.setDate(n);
this.setSelectedDate(d);
this.hide();
},selectToday:function(){
-this.setSelectedDate(this.newDate());
+if(this.selectedDate.toISODate()==this.newDate().toISODate()){
this.hide();
+}
+this.setSelectedDate(this.newDate());
},clearSelection:function(){
this.setSelectedDate(this.newDate());
this.hide();
@@ -267,19 +269,19 @@ return false;
this.control.value=this.formatDate();
},formatDate:function(){
return this.selectedDate?this.selectedDate.SimpleFormat(this.Format):"";
-},newDate:function(_35){
-if(!_35){
-_35=new Date();
+},newDate:function(_34){
+if(!_34){
+_34=new Date();
}
-if(isString(_35)||isNumber(_35)){
-_35=new Date(_35);
+if(isString(_34)||isNumber(_34)){
+_34=new Date(_34);
}
-return new Date(_35.getFullYear(),_35.getMonth(),_35.getDate(),0,0,0);
-},setSelectedDate:function(_36){
-if(_36==null){
+return new Date(_34.getFullYear(),_34.getMonth(),_34.getDate(),0,0,0);
+},setSelectedDate:function(_35){
+if(_35==null){
return;
}
-this.selectedDate=this.newDate(_36);
+this.selectedDate=this.newDate(_35);
this.updateHeader();
this.update();
if(isFunction(this.onchange)){
@@ -289,13 +291,13 @@ this.onchange();
return this._calDiv;
},getSelectedDate:function(){
return isNull(this.selectedDate)?null:this.newDate(this.selectedDate);
-},setYear:function(_37){
+},setYear:function(_36){
var d=this.newDate(this.selectedDate);
-d.setFullYear(_37);
+d.setFullYear(_36);
this.setSelectedDate(d);
-},setMonth:function(_38){
+},setMonth:function(_37){
var d=this.newDate(this.selectedDate);
-d.setMonth(_38);
+d.setMonth(_37);
this.setSelectedDate(d);
},nextMonth:function(){
this.setMonth(this.selectedDate.getMonth()+1);
@@ -312,10 +314,10 @@ this.ieHack(false);
this.documentClickEvent=this.hideOnClick.bindEvent(this);
this.documentKeyDownEvent=this.keyPressed.bindEvent(this);
Event.observe(document.body,"click",this.documentClickEvent);
-var _40=Date.SimpleParse(Form.Element.getValue(this.control),this.Format);
-if(!isNull(_40)){
-this.selectedDate=_40;
-this.setSelectedDate(_40);
+var _39=Date.SimpleParse(Form.Element.getValue(this.control),this.Format);
+if(!isNull(_39)){
+this.selectedDate=_39;
+this.setSelectedDate(_39);
}
Event.observe(document,"keydown",this.documentKeyDownEvent);
this.showing=true;
@@ -325,17 +327,17 @@ if(!this.showing){
return;
}
var el=Event.element(ev);
-var _41=false;
+var _40=false;
do{
-_41=_41||el.className==this.ClassName;
-_41=_41||el==this.trigger;
-_41=_41||el==this.control;
-if(_41){
+_40=_40||el.className==this.ClassName;
+_40=_40||el==this.trigger;
+_40=_40||el==this.control;
+if(_40){
break;
}
el=el.parentNode;
}while(el);
-if(!_41){
+if(!_40){
this.hide();
}
},hide:function(){
@@ -349,61 +351,61 @@ Event.stopObserving(document.body,"click",this.documentClickEvent);
Event.stopObserving(document,"keydown",this.documentKeyDownEvent);
}
},update:function(){
-var _42=this.selectedDate;
-var _43=(this.newDate()).toISODate();
-var _44=_42.toISODate();
-var d1=new Date(_42.getFullYear(),_42.getMonth(),1);
-var d2=new Date(_42.getFullYear(),_42.getMonth()+1,1);
-var _47=Math.round((d2-d1)/(24*60*60*1000));
-var _48=(d1.getDay()-this.FirstDayOfWeek)%7;
-if(_48<0){
-_48+=7;
-}
-var _49=0;
-while(_49<_48){
-this.dateSlot[_49].value=-1;
-this.dateSlot[_49].data.data=String.fromCharCode(160);
-this.dateSlot[_49].data.parentNode.className="empty";
-_49++;
-}
-for(i=1;i<=_47;i++,_49++){
-var _50=this.dateSlot[_49];
-var _51=_50.data.parentNode;
-_50.value=i;
-_50.data.data=i;
-_51.className="date";
-if(d1.toISODate()==_43){
-_51.className+=" today";
+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()==_44){
-_51.className+=" selected";
+if(d1.toISODate()==_43){
+_50.className+=" selected";
}
d1=new Date(d1.getFullYear(),d1.getMonth(),d1.getDate()+1);
}
-var _52=_49;
-while(_49<42){
-this.dateSlot[_49].value=-1;
-this.dateSlot[_49].data.data=String.fromCharCode(160);
-this.dateSlot[_49].data.parentNode.className="empty";
-++_49;
+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;
}
},hover:function(ev){
Element.condClassName(Event.element(ev),"hover",ev.type=="mouseover");
},updateHeader:function(){
-var _53=this._monthSelect.options;
+var _52=this._monthSelect.options;
var m=this.selectedDate.getMonth();
-for(var i=0;i<_53.length;++i){
-_53[i].selected=false;
-if(_53[i].value==m){
-_53[i].selected=true;
-}
-}
-_53=this._yearSelect.options;
-var _54=this.selectedDate.getFullYear();
-for(var i=0;i<_53.length;++i){
-_53[i].selected=false;
-if(_53[i].value==_54){
-_53[i].selected=true;
+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;
}
}
}};
diff --git a/framework/Web/Javascripts/js/prado.js b/framework/Web/Javascripts/js/prado.js
index 92bd4921..590882fa 100644
--- a/framework/Web/Javascripts/js/prado.js
+++ b/framework/Web/Javascripts/js/prado.js
@@ -1961,144 +1961,151 @@ _89.push(_88[i]);
return _89;
}};
-Object.extend(Date.prototype,{SimpleFormat:function(_1){
-var _2=new Array();
-_2["d"]=this.getDate();
-_2["dd"]=String(this.getDate()).zerofill(2);
-_2["M"]=this.getMonth()+1;
-_2["MM"]=String(this.getMonth()+1).zerofill(2);
-var _3=""+this.getFullYear();
-_3=(_3.length==2)?"19"+_3:_3;
-_2["yyyy"]=_3;
-_2["yy"]=_2["yyyy"].toString().substr(2,2);
-var _4=new String(_1);
-for(var _5 in _2){
-var _6=new RegExp("\\b"+_5+"\\b","g");
-_4=_4.replace(_6,_2[_5]);
+Object.extend(Date.prototype,{SimpleFormat:function(_1,_2){
+_2=_2||{};
+var _3=new Array();
+_3["d"]=this.getDate();
+_3["dd"]=String(this.getDate()).zerofill(2);
+_3["M"]=this.getMonth()+1;
+_3["MM"]=String(this.getMonth()+1).zerofill(2);
+if(_2.AbbreviatedMonthNames){
+_3["MMM"]=_2.AbbreviatedMonthNames[this.getMonth()];
+}
+if(_2.MonthNames){
+_3["MMMM"]=_2.MonthNames[this.getMonth()];
+}
+var _4=""+this.getFullYear();
+_4=(_4.length==2)?"19"+_4:_4;
+_3["yyyy"]=_4;
+_3["yy"]=_3["yyyy"].toString().substr(2,2);
+var _5=new String(_1);
+for(var _6 in _3){
+var _7=new RegExp("\\b"+_6+"\\b","g");
+_5=_5.replace(_7,_3[_6]);
}
-return _4;
+return _5;
},toISODate:function(){
var y=this.getFullYear();
var m=String(this.getMonth()+1).zerofill(2);
var d=String(this.getDate()).zerofill(2);
return String(y)+String(m)+String(d);
}});
-Object.extend(Date,{SimpleParse:function(_10,_11){
-val=String(_10);
-_11=String(_11);
+Object.extend(Date,{SimpleParse:function(_11,_12){
+val=String(_11);
+_12=String(_12);
if(val.length<=0){
return null;
}
-if(_11.length<=0){
-return new Date(_10);
+if(_12.length<=0){
+return new Date(_11);
}
-var _12=function(val){
-var _14="1234567890";
+var _13=function(val){
+var _15="1234567890";
for(var i=0;i<val.length;i++){
-if(_14.indexOf(val.charAt(i))==-1){
+if(_15.indexOf(val.charAt(i))==-1){
return false;
}
}
return true;
};
-var _16=function(str,i,_18,_19){
-for(var x=_19;x>=_18;x--){
-var _21=str.substring(i,i+x);
-if(_21.length<_18){
+var _17=function(str,i,_19,_20){
+for(var x=_20;x>=_19;x--){
+var _22=str.substring(i,i+x);
+if(_22.length<_19){
return null;
}
-if(_12(_21)){
-return _21;
+if(_13(_22)){
+return _22;
}
}
return null;
};
-var _22=0;
var _23=0;
+var _24=0;
var c="";
-var _25="";
var _26="";
+var _27="";
var x,y;
var now=new Date();
-var _28=now.getFullYear();
-var _29=now.getMonth()+1;
-var _30=1;
-while(_23<_11.length){
-c=_11.charAt(_23);
-_25="";
-while((_11.charAt(_23)==c)&&(_23<_11.length)){
-_25+=_11.charAt(_23++);
-}
-if(_25=="yyyy"||_25=="yy"||_25=="y"){
-if(_25=="yyyy"){
+var _29=now.getFullYear();
+var _30=now.getMonth()+1;
+var _31=1;
+while(_24<_12.length){
+c=_12.charAt(_24);
+_26="";
+while((_12.charAt(_24)==c)&&(_24<_12.length)){
+_26+=_12.charAt(_24++);
+}
+if(_26=="yyyy"||_26=="yy"||_26=="y"){
+if(_26=="yyyy"){
x=4;
y=4;
}
-if(_25=="yy"){
+if(_26=="yy"){
x=2;
y=2;
}
-if(_25=="y"){
+if(_26=="y"){
x=2;
y=4;
}
-_28=_16(val,_22,x,y);
-if(_28==null){
+_29=_17(val,_23,x,y);
+if(_29==null){
return null;
}
-_22+=_28.length;
-if(_28.length==2){
-if(_28>70){
-_28=1900+(_28-0);
+_23+=_29.length;
+if(_29.length==2){
+if(_29>70){
+_29=1900+(_29-0);
}else{
-_28=2000+(_28-0);
+_29=2000+(_29-0);
}
}
}else{
-if(_25=="MM"||_25=="M"){
-_29=_16(val,_22,_25.length,2);
-if(_29==null||(_29<1)||(_29>12)){
+if(_26=="MM"||_26=="M"){
+_30=_17(val,_23,_26.length,2);
+if(_30==null||(_30<1)||(_30>12)){
return null;
}
-_22+=_29.length;
+_23+=_30.length;
}else{
-if(_25=="dd"||_25=="d"){
-_30=_16(val,_22,_25.length,2);
-if(_30==null||(_30<1)||(_30>31)){
+if(_26=="dd"||_26=="d"){
+_31=_17(val,_23,_26.length,2);
+if(_31==null||(_31<1)||(_31>31)){
return null;
}
-_22+=_30.length;
+_23+=_31.length;
}else{
-if(val.substring(_22,_22+_25.length)!=_25){
+if(val.substring(_23,_23+_26.length)!=_26){
return null;
}else{
-_22+=_25.length;
+_23+=_26.length;
}
}
}
}
}
-if(_22!=val.length){
+if(_23!=val.length){
return null;
}
-if(_29==2){
-if(((_28%4==0)&&(_28%100!=0))||(_28%400==0)){
-if(_30>29){
+if(_30==2){
+if(((_29%4==0)&&(_29%100!=0))||(_29%400==0)){
+if(_31>29){
return null;
}
}else{
-if(_30>28){
+if(_31>28){
return null;
}
}
}
-if((_29==4)||(_29==6)||(_29==9)||(_29==11)){
-if(_30>30){
+if((_30==4)||(_30==6)||(_30==9)||(_30==11)){
+if(_31>30){
return null;
}
}
-var _31=new Date(_28,_29-1,_30,0,0,0);
-return _31;
+var _32=new Date(_29,_30-1,_31,0,0,0);
+return _32;
}});
var Prado={Version:"3.0a",Browser:function(){
diff --git a/framework/Web/Javascripts/prado/test.html b/framework/Web/Javascripts/prado/test.html
deleted file mode 100644
index ab4ff973..00000000
--- a/framework/Web/Javascripts/prado/test.html
+++ /dev/null
@@ -1,105 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <title>Prado Date Picker</title>
- <script type="text/javascript" src="../js/prado.js"></script>
- <script type="text/javascript" src="../js/logger.js"></script>
- <script type="text/javascript" src="datepicker.js"></script>
-</head>
-
-<body>
-<form ID=Form1>
- <input type="text" name="textfield1" id="textfield1" />
- <input type="button" name="button1" id="button1" value="..." />
- <br />
- <input type="text" /> <br />
- <select><option value="1">One</option></select>
-
- <input type="button" id="b1" value="button 1" />
- <input type="button" id="start" value="start" />
- <input type="button" id="stop" value="stop" />
-</form>
-
-
-as<br/>
-dv<br/>
-as<br/>
-d<br/>
-as<br/>
-d<br/>
-asd<br/>
-a<br/>
-sd<br/>
-dv<br/>
-as<br/>
-d<br/>
-as<br/>
-d<br/>
-asd<br/>
-a<br/>
-sd<br/>
-dv<br/>
-as<br/>
-d<br/>
-as<br/>
-d<br/>
-asd<br/>
-a<br/>
-sd<br/>
-<form>
- <input type="text" name="textfield2" id="text1" />
-</form>
-d<br/>
-as<br/>
-d<br/>
-asd<br/>
-a<br/>
-sd<br/>
-dv<br/>
-as<br/>
-d<br/>
-as<br/>
-d<br/>
-asd<br/>
-a<br/>
-sd<br/>
-
-<script type="text/javascript">
-
- var options = { "Trigger" : "button1", "Format" : "dd-MM-yyyy" };
- var datepicker1 = new Prado.WebUI.TDatePicker("textfield1", options);
- var datepicker2 = new Prado.WebUI.TDatePicker("textfield2", {'Format':'MM-dd-yy', 'UpToYear' : 2050});
- var test2 = { clicks : 0 };
- var test1 = Class.create();
- test1.prototype =
- {
- clicks : 0,
-
- initialize : function()
- {
- Event.observe("start", "click", this.start.bindEvent(this));
- Event.observe("stop", "click", this.stop.bindEvent(this));
- },
-
- start : function()
- {
- this.button1ClickEvent = this.clicked.bindEvent(this);
- Event.observe("b1", "click", this.button1ClickEvent);
- },
-
- stop : function()
- {
- Event.stopObserving("b1", "click", this.button1ClickEvent);
- },
-
- clicked : function()
- {
- Logger.warn("clicked " + (this.clicks++));
- }
- }
-
- new test1();
- </script>
-</body>
-</html>
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php
index 125b97c3..10d3248e 100644
--- a/framework/Web/UI/WebControls/TDatePicker.php
+++ b/framework/Web/UI/WebControls/TDatePicker.php
@@ -64,11 +64,11 @@ class TDatePicker extends TTextBox
}
/**
- * @param string calendar UI mode, "Basic", "Button" or "Image"
+ * @param string calendar UI mode, "Basic", "Button" or "ImageButton"
*/
public function setMode($value)
{
- $this->setViewState('Mode', TPropertyValue::ensureEnum($value, 'Basic', 'Button', 'Image'), 'Basic');
+ $this->setViewState('Mode', TPropertyValue::ensureEnum($value, 'Basic', 'Button', 'ImageButton'), 'Basic');
}
/**
@@ -81,7 +81,7 @@ class TDatePicker extends TTextBox
/**
* @param string the image url for "Image" UI mode.
*/
- public function setImageUrl($value)
+ public function setButtonImageUrl($value)
{
$this->setViewState('ImageUrl', $value, '');
}
@@ -89,7 +89,7 @@ class TDatePicker extends TTextBox
/**
* @return string the image url for "Image" UI mode.
*/
- public function getImageUrl()
+ public function getButtonImageUrl()
{
return $this->getViewState('ImageUrl', '');
}
@@ -99,7 +99,7 @@ class TDatePicker extends TTextBox
*/
public function setCalendarStyle($value)
{
- $this->setViewState('CalendarStyle', $value, 'datepicker_default');
+ $this->setViewState('CalendarStyle', $value, 'default');
}
/**
@@ -107,7 +107,7 @@ class TDatePicker extends TTextBox
*/
public function getCalendarStyle()
{
- return $this->getViewState('CalendarStyle', 'datepicker_default');
+ return $this->getViewState('CalendarStyle', 'default');
}
/**
@@ -127,38 +127,52 @@ class TDatePicker extends TTextBox
return $this->getViewState('FirstDayOfWeek', 1);
}
+ /**
+ * @return string text for the date picker button. Default is "...".
+ */
public function getButtonText()
{
return $this->getViewState('ButtonText', '...');
}
+ /**
+ * @param string text for the date picker button
+ */
public function setButtonText($value)
{
$this->setViewState('ButtonText', $value, '...');
}
/**
- * Sets the date picker starting year
- * @param integer starting year
+ * @param integer date picker starting year, default is 2000.
*/
public function setFromYear($value)
{
- $this->setViewState('FromYear', TPropertyValue::ensureInteger($value), 2000);
+ $this->setViewState('FromYear', TPropertyValue::ensureInteger($value), intval(@date('Y'))-5);
}
+ /**
+ * @return integer date picker starting year, default is -5 years
+ */
public function getFromYear()
{
- return $this->getViewState('FromYear', 2000);
+ return $this->getViewState('FromYear', intval(@date('Y'))-5);
}
+ /**
+ * @param integer date picker ending year, default +10 years
+ */
public function setUpToYear($value)
{
- $this-setViewState('UpToYear', TPropertyValue::ensureInteger($value), 2015);
+ $this-setViewState('UpToYear', TPropertyValue::ensureInteger($value), intval(@date('Y'))+10);
}
+ /**
+ * @return integer date picker ending year, default +10 years
+ */
public function getUpToYear()
{
- return $this->getViewState('UpToYear', 2015);
+ return $this->getViewState('UpToYear', intval(@date('Y'))+10);
}
protected function getDatePickerOptions()
@@ -170,7 +184,25 @@ class TDatePicker extends TTextBox
$options['UpToYear'] = $this->getUpToYear();
if($this->getMode()!=='Basic')
$options['Trigger'] = $this->getDatePickerButtonID();
+
+ $options = array_merge($options, $this->getCulturalOptions());
+ return $options;
+ }
+
+ protected function getCulturalOptions()
+ {
+ $app = $this->getApplication()->getGlobalization();
+ $culture = $this->getCulture() == '' ? $app->getCulture() : $this->getCulture();
+ if($culture == 'en') return array();
+ //expensive operations
+ Prado::using('System.I18N.core.DateTimeFormatInfo');
+ $info = Prado::createComponent('System.I18N.core.CultureInfo', $culture);
+ $date = $info->getDateTimeFormat();
+ $serializer = new TJavascriptSerializer($date->getMonthNames());
+ $options['MonthNames'] = $serializer->toList();
+ $serializer = new TJavascriptSerializer($date->getAbbreviatedDayNames());
+ $options['ShortWeekDayNames'] = $serializer->toList();
return $options;
}
@@ -192,7 +224,7 @@ class TDatePicker extends TTextBox
switch ($this->getMode())
{
case 'Button': $this->renderButtonDatePicker($writer); break;
- case 'Image' : $this->renderImageDatePicker($writer); break;
+ case 'ImageButton' : $this->renderImageButtonDatePicker($writer); break;
}
}
@@ -206,22 +238,38 @@ class TDatePicker extends TTextBox
{
$writer->addAttribute('id', $this->getDatePickerButtonID());
$writer->addAttribute('type', 'button');
+ $writer->addAttribute('class', $this->getCssClass().' TDatePickerButton');
$writer->addAttribute('value',$this->getButtonText());
$writer->renderBeginTag("input");
}
+ protected function renderImageButtonDatePicker($writer)
+ {
+ $url = $this->getButtonImageUrl();
+ $url = empty($url) ? $this->publishDefaultButtonImage() : $url;
+ $writer->addAttribute('id', $this->getDatePickerButtonID());
+ $writer->addAttribute('src', $url);
+ $writer->addAttribute('class', $this->getCssClass().' TDatePickerImageButton');
+ $writer->renderBeginTag('img');
+ }
+
+ protected function publishDefaultButtonImage()
+ {
+ $cs = $this->getPage()->getClientScript();
+ $image = 'System.Web.Javascripts.datepicker.calendar';
+ $file = Prado::getPathOfNamespace($image, '.png');
+ return $this->getService()->getAsset($file);
+ }
protected function publishCalendarStyle()
{
$cs = $this->getPage()->getClientScript();
-
- $style = $this->getCalendarStyle();
- $default = 'System.Web.Javascripts.prado.'.$style;
- $stylesheet = preg_match('/\.|\//', $style) ? $style : $default;
-
- $cssFile=Prado::getPathOfNamespace($stylesheet,'.css');
- if(!$cs->isStyleSheetFileRegistered($stylesheet))
- $cs->registerStyleSheetFile($stylesheet, $this->getService()->getAsset($cssFile));
+ $style = 'System.Web.Javascripts.datepicker.'.$this->getCalendarStyle();
+ $cssFile=Prado::getPathOfNamespace($style,'.css');
+ $url = $this->getService()->getAsset($cssFile);
+ if(!$cs->isStyleSheetFileRegistered($style))
+ $cs->registerStyleSheetFile($style, $url);
+ return $url;
}
protected function addAttributesToRender($writer)