diff --git a/CHANGELOG b/CHANGELOG index 2276b4fac..0928b4bfb 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -54,6 +54,7 @@ Version 1.1.11 work in progress - Enh: Added HTML5 history support on ajax requests on CGridView and CListView using History.js v1.7.2-r2 (https://github.com/balupton/history.js) from Benjamin Arthur Lupton (lightglitch) - Enh: Changed CldrCommand to use medium dateTimeFormat and updated 18n data using newest(6546) CLDR (tanakahisateru) - Enh: Added CErrorHandler::getHttpHeader() to send correct HTTP error codes (pgaultier) +- Enh: CClientScript::$scriptFilePosition and CClientScript::$scriptPosition for controlling default $position values for registerScriptFile and registerScript (resurtm) - Chg #440: Upgraded JQuery UI to 1.8.20 (samdark) - Chg #497: Added log component and preloaded it in default console application config in order to properly log errors (samdark) - Chg: Upgraded jQuery to 1.7.2 (samdark) diff --git a/framework/web/CClientScript.php b/framework/web/CClientScript.php index 473d722cf..eeeb3caad 100644 --- a/framework/web/CClientScript.php +++ b/framework/web/CClientScript.php @@ -160,6 +160,20 @@ class CClientScript extends CApplicationComponent * @since 1.1.3 */ public $coreScriptPosition=self::POS_HEAD; + /** + * @var integer Where the scripts registered using {@link registerScriptFile} will be inserted in the page. + * This can be one of the CClientScript::POS_* constants. + * Defaults to CClientScript::POS_HEAD. + * @since 1.1.11 + */ + public $scriptFilePosition=self::POS_HEAD; + /** + * @var integer Where the scripts registered using {@link registerScript} will be inserted in the page. + * This can be one of the CClientScript::POS_* constants. + * Defaults to CClientScript::POS_READY. + * @since 1.1.11 + */ + public $scriptPosition=self::POS_READY; private $_baseUrl; @@ -577,8 +591,10 @@ class CClientScript extends CApplicationComponent * * @return CClientScript the CClientScript object itself (to support method chaining, available since version 1.1.5). */ - public function registerScriptFile($url,$position=self::POS_HEAD) + public function registerScriptFile($url,$position=null) { + if($position===null) + $position=$this->scriptFilePosition; $this->hasScripts=true; $this->scriptFiles[$position][$url]=$url; $params=func_get_args(); @@ -600,8 +616,10 @@ class CClientScript extends CApplicationComponent * * @return CClientScript the CClientScript object itself (to support method chaining, available since version 1.1.5). */ - public function registerScript($id,$script,$position=self::POS_READY) + public function registerScript($id,$script,$position=null) { + if($position===null) + $position=$this->scriptPosition; $this->hasScripts=true; $this->scripts[$position][$id]=$script; if($position===self::POS_READY || $position===self::POS_LOAD)