Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Unify CJavascriptExpression usage

  • Loading branch information...
commit c89f31f886adda6c8759b6e908daf2982de6fa4b 1 parent 524475f
@mdomba mdomba authored
View
10 framework/web/widgets/CAutoComplete.php
@@ -270,7 +270,6 @@ protected function getClientOptions()
'matchCase', 'matchContains', 'mustMatch', 'selectFirst',
'extraParams', 'multiple', 'multipleSeparator', 'width',
'autoFill', 'max', 'scroll', 'scrollHeight', 'inputClass',
- 'formatItem', 'formatMatch', 'formatResult', 'highlight',
'resultsClass', 'loadingClass');
static $functions=array('formatItem', 'formatMatch', 'formatResult', 'highlight');
@@ -282,8 +281,13 @@ protected function getClientOptions()
}
foreach($functions as $func)
{
- if(!($this->$func instanceof CJavaScriptExpression) && is_string($this->$func) && strpos($this->$func,'js:')!==0)
- $options[$func]=new CJavaScriptExpression($this->$func);
+ if($this->$func!==null)
+ {
+ if($this->$func instanceof CJavaScriptExpression || is_string($this->$func) && strpos($this->$func,'js:')===0)
+ $options[$func]=$this->$func;
+ else
+ $options[$func]=new CJavaScriptExpression($this->$func);
+ }
}
return $options;
View
11 framework/web/widgets/CMaskedTextField.php
@@ -102,10 +102,13 @@ protected function getClientOptions()
if($this->placeholder!==null)
$options['placeholder']=$this->placeholder;
- if($this->completed instanceof CJavaScriptExpression || (is_string($this->completed) && strpos($this->completed,'js:')===0))
- $options['completed']=$this->completed;
- else
- $options['completed']=new CJavaScriptExpression($this->completed);
+ if($this->completed!==null)
+ {
+ if($this->completed instanceof CJavaScriptExpression || is_string($this->completed) && strpos($this->completed,'js:')===0)
+ $options['completed']=$this->completed;
+ else
+ $options['completed']=new CJavaScriptExpression($this->completed);
+ }
return $options;
}
View
7 framework/web/widgets/CMultiFileUpload.php
@@ -119,8 +119,11 @@ protected function getClientOptions()
$options=$this->options;
foreach(array('onFileRemove','afterFileRemove','onFileAppend','afterFileAppend','onFileSelect','afterFileSelect') as $event)
{
- if(isset($options[$event]) && !($options[$event] instanceof CJavaScriptExpression) && strpos($options[$event],'js:')!==0)
- $options[$event]=new CJavaScriptExpression($options[$event]);
+ if(isset($options[$event]) && !($options[$event] instanceof CJavaScriptExpression))
+ {
+ if(!is_string($options[$event]) || strpos($options[$event],'js:')!==0)
+ $options[$event]=new CJavaScriptExpression($options[$event]);
+ }
}
if($this->accept!==null)
View
27 framework/web/widgets/CStarRating.php
@@ -191,26 +191,15 @@ protected function getClientOptions()
$options['starWidth']=$this->starWidth;
if($this->readOnly===true)
$options['readOnly']=true;
- if($this->focus!==null)
+ foreach(array('focus', 'blur', 'callback') as $event)
{
- if(!($this->focus instanceof CJavaScriptExpression) && strpos($this->focus,'js:')!==0)
- $options['focus']=new CJavaScriptExpression($this->focus);
- else
- $options['focus']=$this->focus;
- }
- if($this->blur!==null)
- {
- if(!($this->blur instanceof CJavaScriptExpression) && strpos($this->blur,'js:')!==0)
- $options['blur']=new CJavaScriptExpression($this->blur);
- else
- $options['blur']=$this->blur;
- }
- if($this->callback!==null)
- {
- if(!($this->callback instanceof CJavaScriptExpression) && strpos($this->callback,'js:')!==0)
- $options['callback']=new CJavaScriptExpression($this->callback);
- else
- $options['callback']=$this->callback;
+ if($this->$event!==null)
+ {
+ if($this->$event instanceof CJavaScriptExpression || is_string($this->$event) && strpos($this->$event,'js:')===0)
+ $options[$event]=$this->$event;
+ else
+ $options[$event]=new CJavaScriptExpression($this->$event);
+ }
}
return $options;
}
View
21 framework/zii/widgets/CListView.php
@@ -218,20 +218,15 @@ public function registerClientScript()
$options['url']=CHtml::normalizeUrl($this->ajaxUrl);
if($this->updateSelector!==null)
$options['updateSelector']=$this->updateSelector;
- if($this->beforeAjaxUpdate!==null)
+ foreach(array('beforeAjaxUpdate', 'afterAjaxUpdate') as $event)
{
-
- if(!($this->beforeAjaxUpdate instanceof CJavaScriptExpression) && strpos($this->beforeAjaxUpdate,'js:')!==0)
- $options['beforeAjaxUpdate']=new CJavaScriptExpression($this->beforeAjaxUpdate);
- else
- $options['beforeAjaxUpdate']=$this->beforeAjaxUpdate;
- }
- if($this->afterAjaxUpdate!==null)
- {
- if(!($this->afterAjaxUpdate instanceof CJavaScriptExpression) && strpos($this->afterAjaxUpdate,'js:')!==0)
- $options['afterAjaxUpdate']=new CJavaScriptExpression($this->afterAjaxUpdate);
- else
- $options['afterAjaxUpdate']=$this->afterAjaxUpdate;
+ if($this->$event!==null)
+ {
+ if($this->$event instanceof CJavaScriptExpression || is_string($this->$event) && strpos($this->$event,'js:')===0)
+ $options[$event]=$this->$event;
+ else
+ $options[$event]=new CJavaScriptExpression($this->$event);
+ }
}
$options=CJavaScript::encode($options);
View
34 framework/zii/widgets/grid/CGridView.php
@@ -393,33 +393,15 @@ public function registerClientScript()
$options['url']=CHtml::normalizeUrl($this->ajaxUrl);
if($this->enablePagination)
$options['pageVar']=$this->dataProvider->getPagination()->pageVar;
- if($this->beforeAjaxUpdate!==null)
+ foreach(array('beforeAjaxUpdate', 'afterAjaxUpdate', 'ajaxUpdateError', 'selectionChanged') as $event)
{
- if((!$this->beforeAjaxUpdate instanceof CJavaScriptExpression) && strpos($this->beforeAjaxUpdate,'js:')!==0)
- $options['beforeAjaxUpdate']=new CJavaScriptExpression($this->beforeAjaxUpdate);
- else
- $options['beforeAjaxUpdate']=$this->beforeAjaxUpdate;
- }
- if($this->afterAjaxUpdate!==null)
- {
- if((!$this->afterAjaxUpdate instanceof CJavaScriptExpression) && strpos($this->afterAjaxUpdate,'js:')!==0)
- $options['afterAjaxUpdate']=new CJavaScriptExpression($this->afterAjaxUpdate);
- else
- $options['afterAjaxUpdate']=$this->afterAjaxUpdate;
- }
- if($this->ajaxUpdateError!==null)
- {
- if((!$this->ajaxUpdateError instanceof CJavaScriptExpression) && strpos($this->ajaxUpdateError,'js:')!==0)
- $options['ajaxUpdateError']=new CJavaScriptExpression($this->ajaxUpdateError);
- else
- $options['ajaxUpdateError']=$this->ajaxUpdateError;
- }
- if($this->selectionChanged!==null)
- {
- if((!$this->ajaxUpdateError instanceof CJavaScriptExpression) && strpos($this->selectionChanged,'js:')!==0)
- $options['selectionChanged']=new CJavaScriptExpression($this->selectionChanged);
- else
- $options['selectionChanged']=$this->selectionChanged;
+ if($this->$event!==null)
+ {
+ if($this->$event instanceof CJavaScriptExpression || is_string($this->$event) && strpos($this->$event,'js:')===0)
+ $options[$event]=$this->$event;
+ else
+ $options[$event]=new CJavaScriptExpression($this->$event);
+ }
}
$options=CJavaScript::encode($options);
View
2  framework/zii/widgets/jui/CJuiButton.php
@@ -166,7 +166,7 @@ public function run()
}
$options=empty($this->options) ? '' : CJavaScript::encode($this->options);
- if (isset($this->onclick))
+ if($this->onclick!==null)
{
if(!($this->onclick instanceof CJavaScriptExpression) && strpos($this->onclick,'js:')!==0)
$this->onclick=new CJavaScriptExpression($this->onclick);
Please sign in to comment.
Something went wrong with that request. Please try again.