diff options
-rwxr-xr-x | framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js | 177 | ||||
-rwxr-xr-x | tests/FunctionalTests/active-controls/tests/ActiveDatePickerTestCase.php | 8 |
2 files changed, 93 insertions, 92 deletions
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js b/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js index 68d0e429..8857ee05 100755 --- a/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js @@ -1,90 +1,91 @@ -/** - * TActiveDatePicker control - */ -Prado.WebUI.TActiveDatePicker = Class.extend(Prado.WebUI.TDatePicker, -{ - initialize : function(options) - { - this.options = options || []; - this.control = $(options.ID); - this.dateSlot = new Array(42); - this.weekSlot = new Array(6); - this.minimalDaysInFirstWeek = 4; - this.selectedDate = this.newDate(); - this.positionMode = 'Bottom'; - - - // Issue 181
- $(this.control).stopObserving(); - - //which element to trigger to show the calendar - if(this.options.Trigger) - { - this.trigger = $(this.options.Trigger) ; - var triggerEvent = this.options.TriggerEvent || "click"; - } - else - { - this.trigger = this.control; - var triggerEvent = this.options.TriggerEvent || "focus"; - } +/**
+ * TActiveDatePicker control
+ */
+Prado.WebUI.TActiveDatePicker = Class.extend(Prado.WebUI.TDatePicker,
+{
+ initialize : function(options)
+ {
+ this.options = options || [];
+ this.control = $(options.ID);
+ this.dateSlot = new Array(42);
+ this.weekSlot = new Array(6);
+ this.minimalDaysInFirstWeek = 4;
+ this.selectedDate = this.newDate();
+ this.positionMode = 'Bottom';
+
+
+ // Issue 181
+ $(this.control).stopObserving();
+
+ //which element to trigger to show the calendar
+ if(this.options.Trigger)
+ {
+ this.trigger = $(this.options.Trigger) ;
+ var triggerEvent = this.options.TriggerEvent || "click";
+ }
+ else
+ {
+ this.trigger = this.control;
+ var triggerEvent = this.options.TriggerEvent || "focus";
+ }
// Issue 181
- $(this.trigger).stopObserving(); - - // Popup position - if(this.options.PositionMode == 'Top') - { - this.positionMode = this.options.PositionMode; - } - - Object.extend(this,options); - - if (this.options.ShowCalendar) - Event.observe(this.trigger, triggerEvent, this.show.bindEvent(this)); - - // Listen to change event - if(this.options.InputMode == "TextBox") - { - Event.observe(this.control, "change", this.onDateChanged.bindEvent(this)); - } - else - { - var day = Prado.WebUI.TDatePicker.getDayListControl(this.control); - var month = Prado.WebUI.TDatePicker.getMonthListControl(this.control); - var year = Prado.WebUI.TDatePicker.getYearListControl(this.control); - if (day) Event.observe (day, "change", this.onDateChanged.bindEvent(this)); - if (month) Event.observe (month, "change", this.onDateChanged.bindEvent(this)); - if (year) Event.observe (year, "change", this.onDateChanged.bindEvent(this)); - - } - - }, - - // Respond to change event on the textbox or dropdown list - // This method raises OnDateChanged event on client side if it has been defined, - // and raise the callback request - onDateChanged : function () - { - var date; - if (this.options.InputMode == "TextBox") - { - date=this.control.value; - } - else - { - var day = Prado.WebUI.TDatePicker.getDayListControl(this.control); - if (day) day=day.selectedIndex+1; - var month = Prado.WebUI.TDatePicker.getMonthListControl(this.control); - if (month) month=month.selectedIndex; - var year = Prado.WebUI.TDatePicker.getYearListControl(this.control); - if (year) year=year.value; - date=new Date(year, month, day, 0,0,0).SimpleFormat(this.Format, this); - } - if (typeof(this.options.OnDateChanged) == "function") this.options.OnDateChanged(this, date); - - // Make callback request - var request = new Prado.CallbackRequest(this.options.EventTarget,this.options); - request.dispatch(); - } -}); + if(this.trigger)
+ $(this.trigger).stopObserving();
+
+ // Popup position
+ if(this.options.PositionMode == 'Top')
+ {
+ this.positionMode = this.options.PositionMode;
+ }
+
+ Object.extend(this,options);
+
+ if (this.options.ShowCalendar)
+ Event.observe(this.trigger, triggerEvent, this.show.bindEvent(this));
+
+ // Listen to change event
+ if(this.options.InputMode == "TextBox")
+ {
+ Event.observe(this.control, "change", this.onDateChanged.bindEvent(this));
+ }
+ else
+ {
+ var day = Prado.WebUI.TDatePicker.getDayListControl(this.control);
+ var month = Prado.WebUI.TDatePicker.getMonthListControl(this.control);
+ var year = Prado.WebUI.TDatePicker.getYearListControl(this.control);
+ if (day) Event.observe (day, "change", this.onDateChanged.bindEvent(this));
+ if (month) Event.observe (month, "change", this.onDateChanged.bindEvent(this));
+ if (year) Event.observe (year, "change", this.onDateChanged.bindEvent(this));
+
+ }
+
+ },
+
+ // Respond to change event on the textbox or dropdown list
+ // This method raises OnDateChanged event on client side if it has been defined,
+ // and raise the callback request
+ onDateChanged : function ()
+ {
+ var date;
+ if (this.options.InputMode == "TextBox")
+ {
+ date=this.control.value;
+ }
+ else
+ {
+ var day = Prado.WebUI.TDatePicker.getDayListControl(this.control);
+ if (day) day=day.selectedIndex+1;
+ var month = Prado.WebUI.TDatePicker.getMonthListControl(this.control);
+ if (month) month=month.selectedIndex;
+ var year = Prado.WebUI.TDatePicker.getYearListControl(this.control);
+ if (year) year=year.value;
+ date=new Date(year, month, day, 0,0,0).SimpleFormat(this.Format, this);
+ }
+ if (typeof(this.options.OnDateChanged) == "function") this.options.OnDateChanged(this, date);
+
+ // Make callback request
+ var request = new Prado.CallbackRequest(this.options.EventTarget,this.options);
+ request.dispatch();
+ }
+});
diff --git a/tests/FunctionalTests/active-controls/tests/ActiveDatePickerTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveDatePickerTestCase.php index c3b47934..f5915634 100755 --- a/tests/FunctionalTests/active-controls/tests/ActiveDatePickerTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/ActiveDatePickerTestCase.php @@ -100,9 +100,9 @@ class ActiveDatePickerTestCase extends SeleniumTestCase $this->verifySelected("datepicker2_month", date('m', $dateToCheck)); $this->verifySelected("datepicker2_day", date('d', $dateToCheck)); $this->verifySelected("datepicker2_year", date('Y', $dateToCheck)); - $this->select("datepicker2_year", 2005); + $this->select("datepicker2_year", date('Y')+1); $this->pause(800); - $dateToCheck=mktime(0,0,0,(int)date('m'),(int)date('d'), 2005); + $dateToCheck=mktime(0,0,0,(int)date('m'),(int)date('d'), date('Y')+1); $this->verifyText("status2", date('m-d-Y', $dateToCheck)); @@ -110,9 +110,9 @@ class ActiveDatePickerTestCase extends SeleniumTestCase $dateToCheck=time(); $this->verifySelected("datepicker3_month", date('F', $dateToCheck)); $this->verifySelected("datepicker3_year", date('Y', $dateToCheck)); - $this->select("datepicker3_year", 2005); + $this->select("datepicker3_year", date('Y')+1); $this->pause(800); - $dateToCheck=mktime(0,0,0,(int)date('m'),(int)date('d'), 2005); + $dateToCheck=mktime(0,0,0,(int)date('m'),(int)date('d'), date('Y')+1); $this->verifyText("status3", date('m/Y', $dateToCheck)); } } |