diff options
author | tof <> | 2008-02-05 14:26:24 +0000 |
---|---|---|
committer | tof <> | 2008-02-05 14:26:24 +0000 |
commit | 4cf602da9d7cd37e49d7e645f49605e141eb05fb (patch) | |
tree | d9a09353ce69ae6e823644ae105ef40a2554879a | |
parent | 515beaea9b54627f33f58debfc8619be085f8d81 (diff) |
Fixed #785
-rw-r--r-- | .gitattributes | 1 | ||||
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | framework/Web/Javascripts/source/prado/datepicker/datepicker.js | 46 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDatePicker.php | 6 | ||||
-rw-r--r-- | tests/FunctionalTests/tickets/protected/pages/Ticket785.page | 20 | ||||
-rw-r--r-- | tests/FunctionalTests/tickets/protected/pages/Ticket785.php | 7 | ||||
-rw-r--r-- | tests/FunctionalTests/tickets/tests/Ticket785TestCase.php | 33 |
7 files changed, 111 insertions, 3 deletions
diff --git a/.gitattributes b/.gitattributes index ee186a59..c219cf49 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3007,6 +3007,7 @@ tests/FunctionalTests/tickets/protected/pages/Ticket719.page -text tests/FunctionalTests/tickets/protected/pages/Ticket72.page -text tests/FunctionalTests/tickets/protected/pages/Ticket72.php -text tests/FunctionalTests/tickets/protected/pages/Ticket722.page -text +tests/FunctionalTests/tickets/protected/pages/Ticket785.page -text tests/FunctionalTests/tickets/protected/pages/Ticket93.page -text tests/FunctionalTests/tickets/protected/pages/Ticket93.php -text tests/FunctionalTests/tickets/protected/pages/ToggleTest.page -text @@ -7,6 +7,7 @@ BUG: Ticket#744 - Callback error handling is improved (Qiang) BUG: Ticket#750 - The "expire" parameter is used inconsistently in cache modules (Qiang) BUG: Ticket#753 - Themes not allways being set (Qiang) BUG: Ticket#776 - Logout button should not cause validation in blog tutorial (Qiang) +BUG: Ticket#785 - TDatePicker OnDateChanged event problem (Christophe) BUG: Fixed a bug in TPropertyValue::ensureArray() (Qiang) CHG: Changed TConditional so that the controls in its template behave like they are in its parent (Qiang) CHG: Active Record many-to-many relationship change from self::HAS_MANY to self::MANY_TO_MANY (Wei) 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
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket785.page b/tests/FunctionalTests/tickets/protected/pages/Ticket785.page new file mode 100644 index 00000000..1b402a17 --- /dev/null +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket785.page @@ -0,0 +1,20 @@ +<com:TContent ID="Content">
+<com:TDatePicker Id="datePicker" InputMode="DropDownList"> + <prop:ClientSide.OnDateChanged> + $('selDate').innerHTML=parameter; + </prop:ClientSide.OnDateChanged> +</com:TDatePicker> +<p> +Client Side Selected date : <span id="selDate"></span> +</p> + + +<com:TDatePicker Id="datePicker2" InputMode="TextBox" DateFormat="MM/dd/yyyy" Date="12/01/20007" > + <prop:ClientSide.OnDateChanged> + $('selDate2').innerHTML=parameter; + </prop:ClientSide.OnDateChanged> +</com:TDatePicker> +<p> +Client Side Selected date : <span id="selDate2"></span> +</p>
+</com:TContent>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket785.php b/tests/FunctionalTests/tickets/protected/pages/Ticket785.php new file mode 100644 index 00000000..91ba918d --- /dev/null +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket785.php @@ -0,0 +1,7 @@ +<?php + +class Ticket785 extends TPage +{ + +} +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket785TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket785TestCase.php new file mode 100644 index 00000000..53851f7a --- /dev/null +++ b/tests/FunctionalTests/tickets/tests/Ticket785TestCase.php @@ -0,0 +1,33 @@ +<?php +class Ticket785TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket785'); + $this->assertTitle("Verifying Ticket 785"); + + $this->assertText('selDate', ''); + $this->select($base."datePicker_year", "2007"); + $this->pause(800); + $expectedDate=date("d-m").'-2007'; + $this->assertText('selDate', $expectedDate); + + $this->click($base."datePickerbutton"); + $this->pause(800); + $this->click("css=input.todayButton"); + $this->pause(800); + $this->clickAt("css=body","0,0"); // Hide calendar + $expectedDate=date("d-m-Y"); + $this->assertText('selDate', $expectedDate); + + $this->assertText('selDate2', ''); + $this->type($base.'datePicker2', '12/05/2006'); + $this->pause(800); + $this->clickAt("css=body","0,0"); + $this->assertText('selDate2', '12/05/2006'); + + } + +} +?>
\ No newline at end of file |