diff options
author | tof <> | 2008-09-24 13:09:23 +0000 |
---|---|---|
committer | tof <> | 2008-09-24 13:09:23 +0000 |
commit | f3e65e200444acbb2aa58fc2ca63245d18e3a0b5 (patch) | |
tree | 0833754c1c87cfb18b444c4168aaaeaf64519c78 /framework/Web/Javascripts | |
parent | 797fc77c7e768cac2ad1f7caf8f6af104eafeaa8 (diff) |
Added TActiveDatePicker
Diffstat (limited to 'framework/Web/Javascripts')
-rw-r--r-- | framework/Web/Javascripts/source/packages.php | 7 | ||||
-rwxr-xr-x | framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js | 72 |
2 files changed, 78 insertions, 1 deletions
diff --git a/framework/Web/Javascripts/source/packages.php b/framework/Web/Javascripts/source/packages.php index 1cca7b7c..7c0a1674 100644 --- a/framework/Web/Javascripts/source/packages.php +++ b/framework/Web/Javascripts/source/packages.php @@ -60,6 +60,10 @@ $packages = array( 'tabpanel'=>array(
'prado/controls/tabpanel.js'
+ ), + + 'activedatepicker' => array( + 'prado/activecontrols/activedatepicker.js' ),
);
@@ -77,7 +81,8 @@ $dependencies = array( 'dragdrop' => array('prado', 'effects', 'dragdrop'),
'slider' => array('prado', 'slider'),
'keyboard' => array('prado', 'keyboard'),
- 'tabpanel' => array('prado', 'tabpanel'),
+ 'tabpanel' => array('prado', 'tabpanel'), + 'activedatepicker' => array ('datepicker', 'ajax', 'activedatepicker'),
);
return array($packages, $dependencies);
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js b/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js new file mode 100755 index 00000000..27c2aeba --- /dev/null +++ b/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js @@ -0,0 +1,72 @@ +/** + * 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(); + + //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"; + } + + Object.extend(this,options); + + 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); + Event.observe (day, "change", this.onDateChanged.bindEvent(this)); + Event.observe (month, "change", this.onDateChanged.bindEvent(this)); + 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).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); + } + 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(); + } +}); |