Completed
Push — master ( 9281ef...7089ac )
by Jean-Christophe
03:28
created

SimpleSemExtComponent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Ajax\semantic\components;
4
5
use Ajax\common\components\SimpleExtComponent;
6
use Ajax\JsUtils;
7
8
class SimpleSemExtComponent extends SimpleExtComponent {
9
	protected $paramParts;
10
	public function __construct(JsUtils $js) {
11
		parent::__construct($js);
12
		$this->paramParts=array();
13
	}
14
15
	protected function generateParamParts(){
16
		$results=[];
17
		foreach ($this->paramParts as $paramPart){
18
			$results[]="{$this->uiName}(".\implode(",", $paramPart).")";
19
		}
20
		return \implode(".", $results);
21
	}
22
23
	public function getScript() {
24
		$allParams=$this->params;
25
		$this->jquery_code_for_compile=array ();
26
		$paramParts="";
27
		if(\sizeof($this->paramParts)>0){
28
			$paramParts=".".$this->generateParamParts();
29
		}
30
		$this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).")".$paramParts.";";
31
		$this->compileEvents();
32
		return $this->compileJQueryCode();
33
	}
34
35
	public function setParamParts($paramParts) {
36
		$this->paramParts=$paramParts;
37
		return $this;
38
	}
39
40
	public function addComponentEvent($event,$jsCode){
41
		$jsCode=str_ireplace("\"","%quote%", $jsCode);
42
		return $this->setParam($event, "%function(){".$jsCode."}%");
43
	}
44
45
}