summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes1
-rwxr-xr-xframework/Web/UI/ActiveControls/TActiveClientScript.php83
-rw-r--r--framework/Web/UI/WebControls/TClientScript.php41
3 files changed, 89 insertions, 36 deletions
diff --git a/.gitattributes b/.gitattributes
index 94651891..91241ef3 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -3481,6 +3481,7 @@ framework/Web/THttpUtility.php -text
framework/Web/TUrlManager.php -text
framework/Web/TUrlMapping.php -text
framework/Web/UI/ActiveControls/TActiveButton.php -text
+framework/Web/UI/ActiveControls/TActiveClientScript.php -text
framework/Web/UI/ActiveControls/TActiveControlAdapter.php -text
framework/Web/UI/ActiveControls/TActiveCustomValidator.php -text
framework/Web/UI/ActiveControls/TActiveDataGrid.php -text
diff --git a/framework/Web/UI/ActiveControls/TActiveClientScript.php b/framework/Web/UI/ActiveControls/TActiveClientScript.php
new file mode 100755
index 00000000..fba74f4c
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TActiveClientScript.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * TActiveClientScript class file
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2011 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id: TActiveClientScript.php 3144 2012-05-19 10:07:03Z ctrlaltca $
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * TActiveClientScript class
+ *
+ * This is the active counterpart of the {@link TClientScript} class.
+ *
+ * TActiveClientScript has the ability to render itself on ajax
+ * callbacks. This means that every variable or function declared in javascript
+ * code will be available to the page.
+ *
+ * Beware that when rendered on normal (postback) or ajax callbacks, some
+ * javascript code won't behave in the same way.
+ * When rendered as part of a normal/postback response, scripts will execute instantly
+ * where they are in the page and in a synchronous fashion.
+ * Instead, when they are rendered as part of a callback response,
+ * they will be executed when all DOM modifications are complete and any dynamic
+ * script file includes are loaded, out-of-band and practically all blocks at once,
+ * regardless of where they actually occour in the original template/markup code.
+ * This can potentially hurt compatibility and graceful fallback.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id: TActiveClientScript.php 3144 2012-05-19 10:07:03Z ctrlaltca $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.2
+ */
+
+class TActiveClientScript extends TClientScript
+{
+ /**
+ * Renders the custom script file.
+ * @param THtmLWriter the renderer
+ */
+ protected function renderCustomScriptFile($writer)
+ {
+ if(($scriptUrl = $this->getScriptUrl())!=='')
+ {
+ if($this->getPage()->getIsCallback())
+ {
+ $cs = $this->getPage()->getClientScript();
+ $uniqueid=$this->ClientID.'_custom';
+ if(!$cs->isScriptFileRegistered($uniqueid))
+ $cs->registerScriptFile($uniqueid, $scriptUrl);
+ } else {
+ $writer->write("<script type=\"text/javascript\" src=\"$scriptUrl\"></script>\n");
+ }
+ }
+ }
+
+ /**
+ * Registers the body content as javascript.
+ * @param THtmlWriter the renderer
+ */
+ protected function renderCustomScript($writer)
+ {
+ if($this->getHasControls())
+ {
+ if($this->getPage()->getIsCallback())
+ {
+ $extWriter= $this->getPage()->getResponse()->createHtmlWriter();
+ $extWriter->getWriter()->setBoundary($this->ClientID);
+ $extWriter->write("/*<![CDATA[*/\n");
+ $this->renderChildren($extWriter);
+ $extWriter->write("\n/*]]>*/");
+ $this->getPage()->getCallbackClient()->appendScriptBlock($extWriter);
+ } else {
+ $writer->write("<script type=\"text/javascript\">\n/*<![CDATA[*/\n");
+ $this->renderChildren($writer);
+ $writer->write("\n/*]]>*/\n</script>\n");
+ }
+ }
+ }
+}
diff --git a/framework/Web/UI/WebControls/TClientScript.php b/framework/Web/UI/WebControls/TClientScript.php
index 0679aa74..9e2f247d 100644
--- a/framework/Web/UI/WebControls/TClientScript.php
+++ b/framework/Web/UI/WebControls/TClientScript.php
@@ -4,7 +4,7 @@
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2011 PradoSoft
+ * @copyright Copyright &copy; 2005-2011 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.WebControls
@@ -31,20 +31,6 @@
* Contents within TClientScript will be treated as javascript code and will be
* rendered in place.
*
- * Since Prado 3.2, TClientScript gained the ability to render itself on ajax
- * callbacks. This means that every variable or function declared in javascript
- * code will be available to the page.
- *
- * Beware that when rendered on normal (postback) or ajax callbacks, some
- * javascript code won't behave in the same way.
- * When rendered as part of a normal/postback response, scripts will execute instantly
- * where they are in the page and in a synchronous fashion.
- * Instead, when they are rendered as part of a callback response,
- * they will be executed when all DOM modifications are complete and any dynamic
- * script file includes are loaded, out-of-band and practically all blocks at once,
- * regardless of where they actually occour in the original template/markup code.
- * This can potentially hurt compatibility and graceful fallback.
- *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Id$
* @package System.Web.UI.WebControls
@@ -125,17 +111,7 @@ class TClientScript extends TControl
protected function renderCustomScriptFile($writer)
{
if(($scriptUrl = $this->getScriptUrl())!=='')
- {
- if($this->getPage()->getIsCallback())
- {
- $cs = $this->getPage()->getClientScript();
- $uniqueid=$this->ClientID.'_custom';
- if(!$cs->isScriptFileRegistered($uniqueid))
- $cs->registerScriptFile($uniqueid, $scriptUrl);
- } else {
- $writer->write("<script type=\"text/javascript\" src=\"$scriptUrl\"></script>\n");
- }
- }
+ $writer->write("<script type=\"text/javascript\" src=\"$scriptUrl\"></script>\n");
}
/**
@@ -146,16 +122,9 @@ class TClientScript extends TControl
{
if($this->getHasControls())
{
- if($this->getPage()->getIsCallback())
- {
- $extWriter= $this->getPage()->getResponse()->createHtmlWriter();
- $this->renderChildren($extWriter);
- $this->getPage()->getCallbackClient()->appendScriptBlock($extWriter);
- } else {
- $writer->write("<script type=\"text/javascript\">\n/*<![CDATA[*/\n");
- $this->renderChildren($writer);
- $writer->write("\n/*]]>*/\n</script>\n");
- }
+ $writer->write("<script type=\"text/javascript\">\n/*<![CDATA[*/\n");
+ $this->renderChildren($writer);
+ $writer->write("\n/*]]>*/\n</script>\n");
}
}
}