summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2007-04-20 04:38:32 +0000
committerwei <>2007-04-20 04:38:32 +0000
commit411c988c5b8d5de72a325e2c8cc6a23f0cc335e8 (patch)
tree9165e41cde9829720a29e25f84b00ba459b22522
parent9ebc3a5817f47ece534fea71d6b10a08411ee4be (diff)
Fixed #606, #605, and javascript problems with combining multiple js files under linux.
-rw-r--r--.gitattributes1
-rw-r--r--framework/Web/Javascripts/clientscripts.php2
-rw-r--r--framework/Web/UI/WebControls/TColorPicker.php56
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket606.page5
4 files changed, 19 insertions, 45 deletions
diff --git a/.gitattributes b/.gitattributes
index f2059a03..e27ec026 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2533,6 +2533,7 @@ tests/FunctionalTests/tickets/protected/pages/Ticket586.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket587.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket587.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket605.page -text
+tests/FunctionalTests/tickets/protected/pages/Ticket606.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket68.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket72.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket72.php -text
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');
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket606.page b/tests/FunctionalTests/tickets/protected/pages/Ticket606.page
new file mode 100644
index 00000000..a1a8f551
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket606.page
@@ -0,0 +1,5 @@
+<com:TContent ID="Content">
+
+<com:TColorPicker Mode="Full" />
+
+</com:TContent> \ No newline at end of file