20 parent::__construct(
$js);
21 $this->events=array ();
25 foreach ( $this->events as $event => $jsCode ) {
27 if($event==
"execute"){
28 $this->jquery_code_for_compile []=$jsCode;
29 }
else if($event==
"beforeExecute"){
30 \array_unshift($this->jquery_code_for_compile, $jsCode);
33 $this->jquery_code_for_compile []=
"$( \"".$selector.
"\" ).on(\"".$event.
"\" , function( event, data ) {".$jsCode.
"});";
42 $selector.=
" ".$itemSelector;
47 $result=implode(
"\n", $this->jquery_code_for_compile);
48 $result=str_ireplace(
"\"%",
"", $result);
49 $result=str_ireplace(
"%\"",
"", $result);
50 $result=str_replace(array (
60 $this->jquery_code_for_compile=array ();
61 $this->jquery_code_for_compile []=
"$( \"".$this->attachTo.
"\" ).{$this->uiName}(".$this->
getParamsAsJSON($allParams).
");";
70 public function attach($identifier) {
71 $this->attachTo=$identifier;
75 return $this->
setParam($event,
"%function( event, ui ) {".$jsCode.
"}%");
78 public function on($event, $jsCode) {
79 $this->events [$event]=$jsCode;
84 if (\is_array($typeCtrl)) {
85 if (array_search($value, $typeCtrl)===
false)
86 throw new \Exception(
"La valeur passée a propriété `".$key.
"` pour le composant `".$this->uiName.
"` ne fait pas partie des valeurs possibles : {".implode(
",", $typeCtrl).
"}");
88 if (!$typeCtrl($value)) {
89 throw new \Exception(
"La fonction ".$typeCtrl.
" a retourné faux pour l'affectation de la propriété ".$key.
" au composant ".$this->uiName);
92 return $this->
setParam($key, $value);
static getValueBetween(&$str, $before="{{", $after="}}")
Base component for JQuery UI visuals components.
setItemSelector($itemSelector)
__construct(JsUtils $js=NULL)
Base component for JQuery UI visuals components.
addEvent($event, $jsCode)
_createSelector($itemSelector, $selector)
setParamCtrl($key, $value, $typeCtrl)