From 2ea02214b2fb6bedb58dbbd318ef171a9e146524 Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 29 May 2006 03:08:07 +0000 Subject: Merge from 3.0 branch till 1099. --- framework/Web/UI/WebControls/TDatePicker.php | 30 ++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'framework/Web/UI/WebControls/TDatePicker.php') diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index 59a71c90..a746437b 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -681,6 +681,18 @@ class TDatePicker extends TTextBox else throw new TConfigurationException('datepicker_calendarstyle_invalid',$style); } + + /** + * Publish the spacer.gif for IE iframe source. + * @return string the URL for the spacer.gif. + */ + protected function publishIFrameSpacer() + { + $cs = $this->getPage()->getClientScript(); + $spacer = 'System.Web.Javascripts.datepicker.spacer'; + if(($file = Prado::getPathOfNamespace($spacer,'.gif')) != null) + return $this->publishFilePath($file); + } /** * Add the client id to the input textbox, and register the client scripts. @@ -696,18 +708,24 @@ class TDatePicker extends TTextBox /** * Registers the javascript code to initialize the date picker. - * Must use "Event.OnLoad" to initialize the date picker when the - * full page is loaded, otherwise IE will throw an error. */ protected function registerCalendarClientScript() { if($this->getShowCalendar()) { - $scripts = $this->getPage()->getClientScript(); - $scripts->registerPradoScript("datepicker"); + $cs = $this->getPage()->getClientScript(); + $cs->registerPradoScript("datepicker"); + + if(!$cs->isEndScriptRegistered('TDatePicker.spacer')) + { + $spacer = $this->publishIFrameSpacer(); + $code = "Prado.WebUI.TDatePicker.spacer = '$spacer';"; + $cs->registerEndScript('TDatePicker.spacer', $code); + } + $options = TJavaScript::encode($this->getDatePickerOptions()); - $code = "Event.OnLoad(function(){ new Prado.WebUI.TDatePicker($options); });"; - $scripts->registerEndScript("prado:".$this->getClientID(), $code); + $code = "new Prado.WebUI.TDatePicker($options);"; + $cs->registerEndScript("prado:".$this->getClientID(), $code); } } } -- cgit v1.2.3