Fixes based on recent testing. Key changes: EntryType DT (datetime) has been replaced...
[infodrom/rico3] / minsrc / ricoCalendar.js
index b801bca..265ff23 100644 (file)
@@ -39,6 +39,8 @@ Rico.CalendarControl.prototype = {
   initialize: function(id,options) {
     this.id=id;
     var today=new Date();
+    this.defaultMin = new Date(today.getFullYear()-50,0,1);
+    this.defaultMax = new Date(today.getFullYear()+50,11,31);
     Rico.extend(this, new Rico.Popup());
     Rico.extend(this.options, {
       ignoreClicks:true,
@@ -46,8 +48,8 @@ Rico.CalendarControl.prototype = {
       showWeekNumber : 0,
       showToday : 1,
       dateFmt : 'ISO8601',
-      minDate : new Date(today.getFullYear()-50,0,1),
-      maxDate : new Date(today.getFullYear()+50,11,31)
+      minDate : this.defaultMin,
+      maxDate : this.defaultMax
     });
     Rico.extend(this.options, options || {});
     /**
@@ -215,8 +217,8 @@ Rico.CalendarControl.prototype = {
     this.yearPopup=new Rico.Popup(document.createElement("div"),{shim:false,zIndex:10});
     this.yearPopup.content.className='ricoCalYearPrompt';
     if (Rico.theme.calendarPopdown) Rico.addClass(this.yearPopup.content,Rico.theme.calendarPopdown);
-    var p1=document.createElement("p");
-    p1.innerHTML=Rico.getPhraseById("calYearRange",this.options.minDate.getFullYear(),this.options.maxDate.getFullYear());
+    this.yearPrompt=document.createElement("p");
+    this.yearPrompt.innerHTML=" ";
     var p2=document.createElement("p");
     this.yearInput=p2.appendChild(document.createElement("input"));
     this.yearInput.maxlength=4;
@@ -226,7 +228,7 @@ Rico.CalendarControl.prototype = {
     p2.appendChild(a);
     a=Rico.floatButton('Cancel', Rico.eventHandle(this,'popDownYear'));
     p2.appendChild(a);
-    this.yearPopup.content.appendChild(p1);
+    this.yearPopup.content.appendChild(this.yearPrompt);
     this.yearPopup.content.appendChild(p2);
     this.container.appendChild(this.yearPopup.container);
     this.yearPopup.closePopup();
@@ -363,6 +365,7 @@ Rico.CalendarControl.prototype = {
       return false;
     }
     this.popDownMonth();
+    this.yearPrompt.innerHTML=Rico.getPhraseById("calYearRange",this.options.minDate.getFullYear(),this.options.maxDate.getFullYear());
     this.yearInput.disabled=false;
     this.yearInput.value='';   // this.yearSelected
     this.openYrMo(this.yearPopup,1);
@@ -516,8 +519,13 @@ Rico.CalendarControl.prototype = {
     }
   },
 
-  open : function(curval) {
+  open : function(curval,column) {
     if (!this.bPageLoaded) return;
+    if (column) {
+      this.setDateFmt(column.format.dateFmt);
+      this.options.minDate=column.format.min || this.defaultMin;
+      this.options.maxDate=column.format.max || this.defaultMax;
+    }
     var today = new Date();
     this.dateNow  = today.getDate();
     this.monthNow = today.getMonth();