diff options
Diffstat (limited to 'framework')
-rw-r--r-- | framework/Web/Javascripts/clientscripts.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TColorPicker.php | 56 |
2 files changed, 13 insertions, 45 deletions
diff --git a/framework/Web/Javascripts/clientscripts.php b/framework/Web/Javascripts/clientscripts.php index f810901b..1070a8d0 100644 --- a/framework/Web/Javascripts/clientscripts.php +++ b/framework/Web/Javascripts/clientscripts.php @@ -124,7 +124,7 @@ function combine_javascript($files) {
$filename = $base.'/'.$file;
if(is_file($filename)) //relies on get_client_script_files() for security
- $content .= file_get_contents($filename);
+ $content .= "\x0D\x0A".file_get_contents($filename); //add CR+LF
else
error_log('Prado client script: missing file '.$filename);
}
diff --git a/framework/Web/UI/WebControls/TColorPicker.php b/framework/Web/UI/WebControls/TColorPicker.php index efdcbeb4..5f0c0b03 100644 --- a/framework/Web/UI/WebControls/TColorPicker.php +++ b/framework/Web/UI/WebControls/TColorPicker.php @@ -109,19 +109,16 @@ class TColorPicker extends TTextBox * Get javascript color picker options.
* @return array color picker client-side options
*/
- protected function getColorPickerOptions()
+ protected function getPostBackOptions()
{
- $options['ID'] = $this->getClientID();
+ $options = parent::getPostBackOptions();
$options['ClassName'] = $this->getCssClass();
$options['ShowColorPicker'] = $this->getShowColorPicker();
-
if($options['ShowColorPicker'])
{
$mode = $this->getMode();
-
if($mode == TColorPickerMode::Full) $options['Mode'] = $mode;
else if($mode == TColorPickerMode::Simple) $options['Palette'] = 'Tiny';
-
$options['OKButtonText'] = $this->getOKButtonText();
$options['CancelButtonText'] = $this->getCancelButtonText();
}
@@ -145,26 +142,13 @@ class TColorPicker extends TTextBox public function onPreRender($param)
{
parent::onPreRender($param);
- $this->publishColorPickerStyle();
- }
-
- /**
- * Publish the color picker style Css asset file.
- * @return string Css file url.
- */
- protected function publishColorPickerStyle()
- {
- $cs = $this->getPage()->getClientScript();
- $url = $this->getAssetUrl($this->getColorPickerStyle().'.css');
- if(!$cs->isStyleSheetFileRegistered($url))
- $cs->registerStyleSheetFile($url, $url);
- return $url;
+ $this->publishColorPickerAssets();
}
/**
- * Publish the color picker image assets.
+ * Publish the color picker assets.
*/
- protected function publishColorPickerImageAssets()
+ protected function publishColorPickerAssets()
{
$cs = $this->getPage()->getClientScript();
$key = "prado:".get_class($this);
@@ -173,39 +157,23 @@ class TColorPicker extends TTextBox $options = TJavaScript::encode($imgs);
$code = "Prado.WebUI.TColorPicker.UIImages = {$options};";
$cs->registerEndScript($key, $code);
+ $cs->registerPradoScript("colorpicker");
+ $url = $this->getAssetUrl($this->getColorPickerStyle().'.css');
+ if(!$cs->isStyleSheetFileRegistered($url))
+ $cs->registerStyleSheetFile($url, $url);
}
/**
- * Registers the javascript code to initialize the color picker.
- * Must use "Event.OnLoad" to initialize the color picker when the
- * full page is loaded, otherwise IE will throw an error.
- * @param THtmlWriter writer
- */
- protected function addAttributesToRender($writer)
- {
- parent::addAttributesToRender($writer);
- $writer->addAttribute('id',$this->getClientID());
- $scripts = $this->getPage()->getClientScript();
- $scripts->registerPradoScript("colorpicker");
- $options = TJavaScript::encode($this->getColorPickerOptions());
- $id = $this->getClientID();
- $code = "Event.OnLoad(function(){ new Prado.WebUI.TColorPicker($options); });";
- $scripts->registerEndScript("prado:$id", $code);
- }
-
- /**
- * Renders body content.
+ * Renders additional body content.
* This method overrides parent implementation by adding
* additional color picker button.
* @param THtmlWriter writer
*/
- public function render($writer)
+ public function renderEndTag($writer)
{
- parent::render($writer);
+ parent::renderEndTag($writer);
$color = $this->getText();
-
- $this->publishColorPickerImageAssets();
$writer->addAttribute('class', 'TColorPicker_button');
$writer->renderBeginTag('span');
|