summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authortof <>2008-02-05 14:26:24 +0000
committertof <>2008-02-05 14:26:24 +0000
commit4cf602da9d7cd37e49d7e645f49605e141eb05fb (patch)
treed9a09353ce69ae6e823644ae105ef40a2554879a /framework
parent515beaea9b54627f33f58debfc8619be085f8d81 (diff)
Fixed #785
Diffstat (limited to 'framework')
-rw-r--r--framework/Web/Javascripts/source/prado/datepicker/datepicker.js46
-rw-r--r--framework/Web/UI/WebControls/TDatePicker.php6
2 files changed, 49 insertions, 3 deletions
diff --git a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js
index ade26d26..f502b0d3 100644
--- a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js
+++ b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js
@@ -83,6 +83,27 @@ Prado.WebUI.TDatePicker.prototype =
Object.extend(this,options);
Event.observe(this.trigger, triggerEvent, this.show.bindEvent(this));
+
+ // Listen to change event if needed
+ if (typeof(this.options.OnDateChanged) == "function")
+ {
+ 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);
+ Event.observe (day, "change", this.onDateChanged.bindEvent(this));
+ Event.observe (month, "change", this.onDateChanged.bindEvent(this));
+ Event.observe (year, "change", this.onDateChanged.bindEvent(this));
+
+ }
+
+
+ }
},
@@ -430,6 +451,28 @@ Prado.WebUI.TDatePicker.prototype =
return false;
},
+ // Respond to change event on the textbox or dropdown list
+ // This method raises OnDateChanged event on client side if it has been defined
+ onDateChanged : function ()
+ {
+ if (this.options.OnDateChanged)
+ {
+ var date;
+ if (this.options.InputMode == "TextBox")
+ {
+ date=this.control.value;
+ }
+ else
+ {
+ var day = Prado.WebUI.TDatePicker.getDayListControl(this.control).selectedIndex+1;
+ var month = Prado.WebUI.TDatePicker.getMonthListControl(this.control).selectedIndex;
+ var year = Prado.WebUI.TDatePicker.getYearListControl(this.control).value;
+ date=new Date(year, month, day, 0,0,0).SimpleFormat(this.Format, this);
+ }
+ this.options.OnDateChanged(this, date);
+ }
+ },
+
onChange : function()
{
if(this.options.InputMode == "TextBox")
@@ -480,11 +523,12 @@ Prado.WebUI.TDatePicker.prototype =
{
if (date == null)
return;
+ var old=this.selectedDate;
this.selectedDate = this.newDate(date);
this.updateHeader();
this.update();
- if (typeof(this.onChange) == "function")
+ if (old - this.selectedDate !=0 && typeof(this.onChange) == "function")
this.onChange(this, date);
},
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php
index 2580ab78..29a57e25 100644
--- a/framework/Web/UI/WebControls/TDatePicker.php
+++ b/framework/Web/UI/WebControls/TDatePicker.php
@@ -848,12 +848,14 @@ class TDatePicker extends TTextBox
* TDatePickerClientScript class.
*
* Client-side date picker event {@link setOnDateChanged OnDateChanged}
- * can be modified through the {@link TDatePicker:: getClientSide ClientSide}
+ * can be modified through the {@link TDatePicker::getClientSide ClientSide}
* property of a date picker.
*
* The <tt>OnDateChanged</tt> event is raise when the date picker's date
* is changed.
- *
+ * The formatted date according to {@link TDatePicker::getDateFormat DateFormat} is sent
+ * as parameter to this event
+ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Id$
* @package System.Web.UI.WebControls