|
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=NULL) { |
|
11
|
|
|
parent::__construct($js); |
|
12
|
|
|
$this->paramParts=array(); |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
protected function addBehavior($name) { |
|
16
|
|
|
$this->paramParts[]=[$name]; |
|
17
|
|
|
return $this; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
protected function generateParamParts(){ |
|
21
|
|
|
$results=[]; |
|
22
|
|
|
foreach ($this->paramParts as $paramPart){ |
|
23
|
|
|
$results[]="{$this->uiName}(".\implode(",", $paramPart).")"; |
|
24
|
|
|
} |
|
25
|
|
|
return \implode(".", $results); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function getScript() { |
|
29
|
|
|
$allParams=$this->params; |
|
30
|
|
|
$this->jquery_code_for_compile=array (); |
|
31
|
|
|
$this->compileJsCodes(); |
|
32
|
|
|
$paramParts=""; |
|
33
|
|
|
if(\sizeof($this->paramParts)>0){ |
|
34
|
|
|
$paramParts=".".$this->generateParamParts(); |
|
35
|
|
|
} |
|
36
|
|
|
$this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).")".$paramParts.";"; |
|
|
|
|
|
|
37
|
|
|
$this->compileEvents(); |
|
38
|
|
|
return $this->compileJQueryCode(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function setParamParts($paramParts) { |
|
42
|
|
|
$this->paramParts=$paramParts; |
|
43
|
|
|
return $this; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function addComponentEvent($event,$jsCode){ |
|
47
|
|
|
$jsCode=\str_ireplace("\"","%quote%", $jsCode); |
|
48
|
|
|
return $this->setParam($event, "%function(module){".$jsCode."}%"); |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function setJs(JsUtils $js){ |
|
52
|
|
|
$this->js=$js; |
|
53
|
|
|
$js->semantic()->addComponent($this, $this->attachTo, $this->params); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
} |
|
57
|
|
|
|