@@ -19,17 +19,17 @@ discard block |
||
19 | 19 | |
20 | 20 | protected function createItem($value) { |
21 | 21 | $count=$this->count(); |
22 | - $item=new HtmlListItem("item-" . $this->identifier . "-" . $count, $value); |
|
22 | + $item=new HtmlListItem("item-".$this->identifier."-".$count, $value); |
|
23 | 23 | return $item; |
24 | 24 | } |
25 | 25 | |
26 | 26 | public function addHeader($niveau, $content) { |
27 | - $header=new HtmlHeader("header-" . $this->identifier, $niveau, $content, "page"); |
|
27 | + $header=new HtmlHeader("header-".$this->identifier, $niveau, $content, "page"); |
|
28 | 28 | $this->wrap($header); |
29 | 29 | return $header; |
30 | 30 | } |
31 | 31 | |
32 | - public function getItemPart($index,$partName="header"){ |
|
32 | + public function getItemPart($index, $partName="header") { |
|
33 | 33 | return $this->getItem($index)->getPart($partName); |
34 | 34 | } |
35 | 35 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | public function asLink() { |
41 | - $this->addToPropertyCtrl("class", "link", array ("link" )); |
|
41 | + $this->addToPropertyCtrl("class", "link", array("link")); |
|
42 | 42 | return $this->contentAs("a"); |
43 | 43 | } |
44 | 44 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | return $this->addItem($list); |
49 | 49 | } |
50 | 50 | |
51 | - protected function getItemToAdd($item){ |
|
51 | + protected function getItemToAdd($item) { |
|
52 | 52 | $itemO=parent::getItemToAdd($item); |
53 | - if($itemO instanceof AbstractCheckbox) |
|
53 | + if ($itemO instanceof AbstractCheckbox) |
|
54 | 54 | $itemO->addClass("item"); |
55 | 55 | return $itemO; |
56 | 56 | } |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | public function run(JsUtils $js) { |
71 | - if ($this->_hasCheckedList === true) { |
|
72 | - $jsCode=include dirname(__FILE__) . '/../../components/jsTemplates/tplCheckedList.php'; |
|
73 | - $jsCode=\str_replace("%identifier%", "#" . $this->identifier, $jsCode); |
|
71 | + if ($this->_hasCheckedList===true) { |
|
72 | + $jsCode=include dirname(__FILE__).'/../../components/jsTemplates/tplCheckedList.php'; |
|
73 | + $jsCode=\str_replace("%identifier%", "#".$this->identifier, $jsCode); |
|
74 | 74 | $this->executeOnRun($jsCode); |
75 | 75 | } |
76 | 76 | return parent::run($js); |
@@ -100,42 +100,42 @@ discard block |
||
100 | 100 | * @param string $notAllChecked |
101 | 101 | * @return HtmlList |
102 | 102 | */ |
103 | - public function addCheckedList($items=array(), $masterItem=NULL, $values=array(),$notAllChecked=false,$name=null) { |
|
103 | + public function addCheckedList($items=array(), $masterItem=NULL, $values=array(), $notAllChecked=false, $name=null) { |
|
104 | 104 | $count=$this->count(); |
105 | - $identifier=$this->identifier . "-" . $count; |
|
105 | + $identifier=$this->identifier."-".$count; |
|
106 | 106 | if (isset($masterItem)) { |
107 | - if(\is_array($masterItem)){ |
|
108 | - $masterO=new HtmlFormCheckbox("master-" . $identifier, @$masterItem[0],@$masterItem[1]); |
|
109 | - if(isset($name)) |
|
107 | + if (\is_array($masterItem)) { |
|
108 | + $masterO=new HtmlFormCheckbox("master-".$identifier, @$masterItem[0], @$masterItem[1]); |
|
109 | + if (isset($name)) |
|
110 | 110 | $masterO->setName($name); |
111 | - if(isset($masterItem[1])){ |
|
112 | - if(\array_search($masterItem[1], $values)!==false){ |
|
111 | + if (isset($masterItem[1])) { |
|
112 | + if (\array_search($masterItem[1], $values)!==false) { |
|
113 | 113 | $masterO->getDataField()->setProperty("checked", ""); |
114 | 114 | } |
115 | 115 | } |
116 | - }else{ |
|
117 | - $masterO=new HtmlFormCheckbox("master-" . $identifier, $masterItem); |
|
116 | + } else { |
|
117 | + $masterO=new HtmlFormCheckbox("master-".$identifier, $masterItem); |
|
118 | 118 | } |
119 | - if($notAllChecked){ |
|
119 | + if ($notAllChecked) { |
|
120 | 120 | $masterO->getDataField()->addClass("_notAllChecked"); |
121 | 121 | } |
122 | 122 | $masterO->getHtmlCk()->addToProperty("class", "master"); |
123 | 123 | $masterO->setClass("item"); |
124 | 124 | $this->addItem($masterO); |
125 | 125 | } |
126 | - $fields=array (); |
|
126 | + $fields=array(); |
|
127 | 127 | $i=0; |
128 | - foreach ( $items as $val => $caption ) { |
|
129 | - $itemO=new HtmlFormCheckbox($identifier . "-" . $i++, $caption, $val, "child"); |
|
130 | - if (\array_search($val, $values) !== false) { |
|
128 | + foreach ($items as $val => $caption) { |
|
129 | + $itemO=new HtmlFormCheckbox($identifier."-".$i++, $caption, $val, "child"); |
|
130 | + if (\array_search($val, $values)!==false) { |
|
131 | 131 | $itemO->getDataField()->setProperty("checked", ""); |
132 | 132 | } |
133 | - if(isset($name)) |
|
133 | + if (isset($name)) |
|
134 | 134 | $itemO->setName($name); |
135 | 135 | $itemO->setClass("item"); |
136 | 136 | $fields[]=$itemO; |
137 | 137 | } |
138 | - if (isset($masterO) === true) { |
|
138 | + if (isset($masterO)===true) { |
|
139 | 139 | $list=new HtmlList("", $fields); |
140 | 140 | $list->setClass("list"); |
141 | 141 | $masterO->addContent($list); |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | return $this; |
147 | 147 | } |
148 | 148 | |
149 | - public function setIcons($icons){ |
|
150 | - if(!\is_array($icons)){ |
|
149 | + public function setIcons($icons) { |
|
150 | + if (!\is_array($icons)) { |
|
151 | 151 | $icons=\array_fill(0, \sizeof($this->content), $icons); |
152 | 152 | } |
153 | - $max=\min(\sizeof($icons),\sizeof($this->content)); |
|
154 | - for($i=0;$i<$max;$i++){ |
|
153 | + $max=\min(\sizeof($icons), \sizeof($this->content)); |
|
154 | + for ($i=0; $i<$max; $i++) { |
|
155 | 155 | $this->content[$i]->addIcon($icons[$i]); |
156 | 156 | } |
157 | 157 | return $this; |
@@ -38,22 +38,22 @@ discard block |
||
38 | 38 | return $this->getHtmlCk()->attachEvents($events); |
39 | 39 | } |
40 | 40 | |
41 | - public function getField(){ |
|
41 | + public function getField() { |
|
42 | 42 | return $this->content["field"]; |
43 | 43 | } |
44 | 44 | |
45 | - public function getHtmlCk(){ |
|
45 | + public function getHtmlCk() { |
|
46 | 46 | return $this->content["field"]; |
47 | 47 | } |
48 | 48 | |
49 | - public function setName($name){ |
|
49 | + public function setName($name) { |
|
50 | 50 | $this->getDataField()->setProperty("name", $name); |
51 | 51 | return $this; |
52 | 52 | } |
53 | 53 | |
54 | - public function getDataField(){ |
|
55 | - $field= $this->getField(); |
|
56 | - if($field instanceof AbstractCheckbox) |
|
54 | + public function getDataField() { |
|
55 | + $field=$this->getField(); |
|
56 | + if ($field instanceof AbstractCheckbox) |
|
57 | 57 | $field=$field->getField(); |
58 | 58 | return $field; |
59 | 59 | } |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | * @param boolean $value |
64 | 64 | * @return HtmlFormField |
65 | 65 | */ |
66 | - public function setChecked($value=true){ |
|
67 | - if($value===true){ |
|
66 | + public function setChecked($value=true) { |
|
67 | + if ($value===true) { |
|
68 | 68 | $this->getDataField()->setProperty("checked", "checked"); |
69 | - }else{ |
|
69 | + } else { |
|
70 | 70 | $this->getDataField()->removeProperty("checked"); |
71 | 71 | } |
72 | 72 | return $this; |
@@ -16,18 +16,18 @@ discard block |
||
16 | 16 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
17 | 17 | |
18 | 18 | abstract public function getUrl($url); |
19 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
19 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
20 | 20 | |
21 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
21 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
22 | 22 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
23 | 23 | $retour=$this->_getAjaxUrl($url, $attr); |
24 | 24 | $responseElement=$this->_getResponseElement($responseElement); |
25 | 25 | $retour.="var self=this;\n"; |
26 | - if($hasLoader===true){ |
|
26 | + if ($hasLoader===true) { |
|
27 | 27 | $this->addLoading($retour, $responseElement); |
28 | 28 | } |
29 | 29 | $retour.="$.".$method."(url,".self::_correctParams($params).").done(function( data ) {\n"; |
30 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
30 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
31 | 31 | if ($immediatly) |
32 | 32 | $this->jquery_code_for_compile[]=$retour; |
33 | 33 | return $retour; |
@@ -35,33 +35,33 @@ discard block |
||
35 | 35 | |
36 | 36 | |
37 | 37 | |
38 | - protected function _getAjaxUrl($url,$attr){ |
|
38 | + protected function _getAjaxUrl($url, $attr) { |
|
39 | 39 | $url=$this->_correctAjaxUrl($url); |
40 | 40 | $retour="url='".$url."';"; |
41 | 41 | $slash="/"; |
42 | - if(JString::endswith($url, "/")===true) |
|
42 | + if (JString::endswith($url, "/")===true) |
|
43 | 43 | $slash=""; |
44 | - if(JString::isNotNull($attr)){ |
|
44 | + if (JString::isNotNull($attr)) { |
|
45 | 45 | if ($attr==="value") |
46 | 46 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
47 | 47 | elseif ($attr==="html") |
48 | 48 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
49 | - elseif($attr!==null && $attr!=="") |
|
49 | + elseif ($attr!==null && $attr!=="") |
|
50 | 50 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
51 | 51 | } |
52 | 52 | return $retour; |
53 | 53 | } |
54 | 54 | |
55 | - protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){ |
|
56 | - $retour="";$call=null; |
|
55 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) { |
|
56 | + $retour=""; $call=null; |
|
57 | 57 | if ($responseElement!=="") { |
58 | - if(isset($ajaxTransition)){ |
|
58 | + if (isset($ajaxTransition)) { |
|
59 | 59 | $call=$this->setAjaxDataCall($ajaxTransition); |
60 | - }elseif(isset($this->ajaxTransition)){ |
|
60 | + }elseif (isset($this->ajaxTransition)) { |
|
61 | 61 | $call=$this->ajaxTransition; |
62 | 62 | } |
63 | - if(\is_callable($call)) |
|
64 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
63 | + if (\is_callable($call)) |
|
64 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
65 | 65 | else |
66 | 66 | $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
67 | 67 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | return $retour; |
70 | 70 | } |
71 | 71 | |
72 | - protected function _getResponseElement($responseElement){ |
|
72 | + protected function _getResponseElement($responseElement) { |
|
73 | 73 | if ($responseElement!=="") { |
74 | 74 | $responseElement=Javascript::prep_value($responseElement); |
75 | 75 | } |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | protected function _correctAjaxUrl($url) { |
80 | 80 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
81 | 81 | $url=substr($url, 0, strlen($url)-1); |
82 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
82 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
83 | 83 | $url=$this->getUrl($url); |
84 | 84 | } |
85 | 85 | return $url; |
86 | 86 | } |
87 | 87 | |
88 | - public static function _correctParams($params){ |
|
89 | - if(JString::isNull($params)){ |
|
88 | + public static function _correctParams($params) { |
|
89 | + if (JString::isNull($params)) { |
|
90 | 90 | return ""; |
91 | 91 | } |
92 | - if(\preg_match("@^\{.*?\}$@", $params)){ |
|
92 | + if (\preg_match("@^\{.*?\}$@", $params)) { |
|
93 | 93 | return '$.param('.$params.')'; |
94 | 94 | } |
95 | 95 | return $params; |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
108 | 108 | } |
109 | 109 | |
110 | - protected function setAjaxDataCall($params){ |
|
110 | + protected function setAjaxDataCall($params) { |
|
111 | 111 | $result=null; |
112 | - if(!\is_callable($params)){ |
|
113 | - $result=function ($responseElement,$jqueryDone="html") use($params){ |
|
114 | - return AjaxTransition::{$params}($responseElement,$jqueryDone); |
|
112 | + if (!\is_callable($params)) { |
|
113 | + $result=function($responseElement, $jqueryDone="html") use($params){ |
|
114 | + return AjaxTransition::{$params}($responseElement, $jqueryDone); |
|
115 | 115 | }; |
116 | 116 | } |
117 | 117 | return $result; |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
132 | 132 | * @param string|callable $ajaxTransition |
133 | 133 | */ |
134 | - private function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
135 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
134 | + private function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
135 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
146 | 146 | * @param string|callable $ajaxTransition |
147 | 147 | */ |
148 | - public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
149 | - return $this->_get($url,$params,$responseElement,$jsCallback,null,$hasLoader,$jqueryDone,$ajaxTransition,true); |
|
148 | + public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
149 | + return $this->_get($url, $params, $responseElement, $jsCallback, null, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
161 | 161 | * @param string|callable $ajaxTransition |
162 | 162 | */ |
163 | - public function ajax($method,$url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
163 | + public function ajax($method, $url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
164 | 164 | $method=\strtolower($method); |
165 | - return $this->_ajax($method,$url,$params,$responseElement,$jsCallback,null,$hasLoader,$jqueryDone,$ajaxTransition,true); |
|
165 | + return $this->_ajax($method, $url, $params, $responseElement, $jsCallback, null, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @param string $context |
176 | 176 | * @param boolean $immediatly |
177 | 177 | */ |
178 | - private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
178 | + private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
179 | 179 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
180 | 180 | $retour=$this->_getAjaxUrl($url, $attr); |
181 | 181 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | * @param string $context |
199 | 199 | * @param boolean $immediatly |
200 | 200 | */ |
201 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL,$context="document",$immediatly=false) { |
|
202 | - return $this->_json($url,$method,$params,$jsCallback,NULL,$context,$immediatly); |
|
201 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $context="document", $immediatly=false) { |
|
202 | + return $this->_json($url, $method, $params, $jsCallback, NULL, $context, $immediatly); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param string $url the request address |
210 | 210 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
211 | 211 | */ |
212 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
212 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
213 | 213 | $preventDefault=true; |
214 | 214 | $stopPropagation=true; |
215 | 215 | $jsCallback=null; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $params="{}"; |
220 | 220 | $immediatly=true; |
221 | 221 | extract($parameters); |
222 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
222 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @param string $jsCallback javascript code to execute after the request |
231 | 231 | * @param string $context jquery DOM element, array container. |
232 | 232 | */ |
233 | - public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL,$context=NULL) { |
|
234 | - return $this->json($url, $method, $params, $jsCallback, $context,false); |
|
233 | + public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL, $context=NULL) { |
|
234 | + return $this->json($url, $method, $params, $jsCallback, $context, false); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | * @param string $rowClass the css class for the new element |
245 | 245 | * @param boolean $immediatly |
246 | 246 | */ |
247 | - private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$attr="id",$immediatly=false) { |
|
247 | + private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $attr="id", $immediatly=false) { |
|
248 | 248 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
249 | 249 | $retour=$this->_getAjaxUrl($url, $attr); |
250 | - if($context===null){ |
|
250 | + if ($context===null) { |
|
251 | 251 | $parent="$('".$maskSelector."').parent()"; |
252 | - $newElm = "$('#'+newId)"; |
|
253 | - }else{ |
|
252 | + $newElm="$('#'+newId)"; |
|
253 | + } else { |
|
254 | 254 | $parent=$context; |
255 | - $newElm = $context.".find('#'+newId)"; |
|
255 | + $newElm=$context.".find('#'+newId)"; |
|
256 | 256 | } |
257 | 257 | $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
258 | 258 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
259 | 259 | $retour.=$parent.".find('._json').remove();"; |
260 | 260 | $retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone(); |
261 | 261 | newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n"; |
262 | - $retour.= $appendTo; |
|
262 | + $retour.=$appendTo; |
|
263 | 263 | $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
264 | 264 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
265 | 265 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | * @param string $context jquery DOM element, array container. |
279 | 279 | * @param boolean $immediatly |
280 | 280 | */ |
281 | - public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$immediatly=false) { |
|
282 | - return $this->_jsonArray($maskSelector, $url,$method,$params,$jsCallback,$rowClass,$context,NULL,$immediatly); |
|
281 | + public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $immediatly=false) { |
|
282 | + return $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, NULL, $immediatly); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | * @param string $rowClass the css class for the new element |
293 | 293 | * @param string $context jquery DOM element, array container. |
294 | 294 | */ |
295 | - public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL) { |
|
296 | - return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback,$rowClass,$context,false); |
|
295 | + public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL) { |
|
296 | + return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, false); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -303,18 +303,18 @@ discard block |
||
303 | 303 | * @param string $url the request url |
304 | 304 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true) |
305 | 305 | */ |
306 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
306 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
307 | 307 | $preventDefault=true; |
308 | 308 | $stopPropagation=true; |
309 | 309 | $jsCallback=null; |
310 | 310 | $attr="id"; |
311 | 311 | $method="get"; |
312 | - $context = null; |
|
312 | + $context=null; |
|
313 | 313 | $params="{}"; |
314 | 314 | $immediatly=true; |
315 | 315 | $rowClass="_json"; |
316 | 316 | extract($parameters); |
317 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $rowClass, $context,$attr), $event, $preventDefault, $stopPropagation,$immediatly); |
|
317 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, $attr), $event, $preventDefault, $stopPropagation, $immediatly); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -328,8 +328,8 @@ discard block |
||
328 | 328 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
329 | 329 | * @param string|callable $ajaxTransition |
330 | 330 | */ |
331 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) { |
|
332 | - return $this->_get($url, $params,$responseElement,$jsCallback,$attr,false,$jqueryDone,$ajaxTransition); |
|
331 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) { |
|
332 | + return $this->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $ajaxTransition=null; |
353 | 353 | $params="{}"; |
354 | 354 | extract($parameters); |
355 | - return $this->_add_event($element, $this->_get($url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
355 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | $ajaxTransition=null; |
377 | 377 | $params="{}"; |
378 | 378 | extract($parameters); |
379 | - return $this->_add_event($element, $this->_ajax($method,$url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
379 | + return $this->_add_event($element, $this->_ajax($method, $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | /** |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | return $this->getOn("click", $element, $url, $responseElement, $parameters); |
404 | 404 | } |
405 | 405 | |
406 | - private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
407 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
406 | + private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
407 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
418 | 418 | * @param string|callable $ajaxTransition |
419 | 419 | */ |
420 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
421 | - return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
420 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
421 | + return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
434 | 434 | * @param string|callable $ajaxTransition |
435 | 435 | */ |
436 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
437 | - return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
436 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
437 | + return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | $jqueryDone="html"; |
458 | 458 | $ajaxTransition=null; |
459 | 459 | extract($parameters); |
460 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
460 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | /** |
@@ -473,20 +473,20 @@ discard block |
||
473 | 473 | return $this->postOn("click", $element, $url, $params, $responseElement, $parameters); |
474 | 474 | } |
475 | 475 | |
476 | - private function _postForm($url, $form, $responseElement, $params=null,$validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
476 | + private function _postForm($url, $form, $responseElement, $params=null, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
477 | 477 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
478 | 478 | $retour=$this->_getAjaxUrl($url, $attr); |
479 | 479 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
480 | - if(isset($params)){ |
|
480 | + if (isset($params)) { |
|
481 | 481 | $retour.="params+='&'+".self::_correctParams($params).";\n"; |
482 | 482 | } |
483 | 483 | $responseElement=$this->_getResponseElement($responseElement); |
484 | 484 | $retour.="var self=this;\n"; |
485 | - if($hasLoader===true){ |
|
485 | + if ($hasLoader===true) { |
|
486 | 486 | $this->addLoading($retour, $responseElement); |
487 | 487 | } |
488 | 488 | $retour.="$.post(url,params).done(function( data ) {\n"; |
489 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
489 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
490 | 490 | |
491 | 491 | if ($validation) { |
492 | 492 | $retour="$('#".$form."').validate({submitHandler: function(form) { |
@@ -510,8 +510,8 @@ discard block |
||
510 | 510 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
511 | 511 | * @param string|callable $ajaxTransition |
512 | 512 | */ |
513 | - public function postForm($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
514 | - return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
513 | + public function postForm($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
514 | + return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
529 | 529 | * @param string|callable $ajaxTransition |
530 | 530 | */ |
531 | - public function postFormDeferred($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
532 | - return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
531 | + public function postFormDeferred($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
532 | + return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | $jqueryDone="html"; |
555 | 555 | $ajaxTransition=null; |
556 | 556 | extract($parameters); |
557 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement,$params, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
557 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | * @property string identifier |
13 | 13 | * @property BaseHtml _self |
14 | 14 | */ |
15 | -trait BaseHtmlEventsTrait{ |
|
15 | +trait BaseHtmlEventsTrait { |
|
16 | 16 | |
17 | - protected $_events=array (); |
|
17 | + protected $_events=array(); |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @param string $event |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | * @return BaseHtml |
25 | 25 | */ |
26 | 26 | public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
27 | - if ($stopPropagation === true) { |
|
28 | - $jsCode=Javascript::$stopPropagation . $jsCode; |
|
27 | + if ($stopPropagation===true) { |
|
28 | + $jsCode=Javascript::$stopPropagation.$jsCode; |
|
29 | 29 | } |
30 | - if ($preventDefault === true) { |
|
31 | - $jsCode=Javascript::$preventDefault . $jsCode; |
|
30 | + if ($preventDefault===true) { |
|
31 | + $jsCode=Javascript::$preventDefault.$jsCode; |
|
32 | 32 | } |
33 | 33 | return $this->_addEvent($event, $jsCode); |
34 | 34 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | if (\is_array($this->_events[$event])) { |
44 | 44 | $this->_events[$event][]=$jsCode; |
45 | 45 | } else { |
46 | - $this->_events[$event]=array ($this->_events[$event],$jsCode ); |
|
46 | + $this->_events[$event]=array($this->_events[$event], $jsCode); |
|
47 | 47 | } |
48 | 48 | } else { |
49 | 49 | $this->_events[$event]=$jsCode; |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | return $this->onClick($jsCode); |
71 | 71 | } |
72 | 72 | |
73 | - public function onCreate($jsCode){ |
|
74 | - if(isset($this->_events["_create"])){ |
|
73 | + public function onCreate($jsCode) { |
|
74 | + if (isset($this->_events["_create"])) { |
|
75 | 75 | $this->_events["_create"][]=$jsCode; |
76 | - }else{ |
|
76 | + } else { |
|
77 | 77 | $this->_events["_create"]=[$jsCode]; |
78 | 78 | } |
79 | 79 | return $this; |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | public function addEventsOnRun(JsUtils $js=NULL) { |
83 | 83 | $this->_eventsOnCreate($js); |
84 | 84 | if (isset($this->_bsComponent)) { |
85 | - foreach ( $this->_events as $event => $jsCode ) { |
|
85 | + foreach ($this->_events as $event => $jsCode) { |
|
86 | 86 | $code=$jsCode; |
87 | 87 | if (\is_array($jsCode)) { |
88 | 88 | $code=""; |
89 | - foreach ( $jsCode as $jsC ) { |
|
89 | + foreach ($jsCode as $jsC) { |
|
90 | 90 | if ($jsC instanceof AjaxCall) { |
91 | - $code.="\n" . $jsC->compile($js); |
|
91 | + $code.="\n".$jsC->compile($js); |
|
92 | 92 | } else { |
93 | - $code.="\n" . $jsC; |
|
93 | + $code.="\n".$jsC; |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | } elseif ($jsCode instanceof AjaxCall) { |
@@ -98,18 +98,18 @@ discard block |
||
98 | 98 | } |
99 | 99 | $this->_bsComponent->addEvent($event, $code); |
100 | 100 | } |
101 | - $this->_events=array (); |
|
101 | + $this->_events=array(); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | - protected function _eventsOnCreate(JsUtils $js=NULL){ |
|
106 | - if(isset($this->_events["_create"])){ |
|
105 | + protected function _eventsOnCreate(JsUtils $js=NULL) { |
|
106 | + if (isset($this->_events["_create"])) { |
|
107 | 107 | $create=$this->_events["_create"]; |
108 | - if(\is_array($create)){ |
|
108 | + if (\is_array($create)) { |
|
109 | 109 | $create=\implode("", $create); |
110 | 110 | } |
111 | - if(isset($js) && $create!=="") |
|
112 | - $js->exec($create,true); |
|
111 | + if (isset($js) && $create!=="") |
|
112 | + $js->exec($create, true); |
|
113 | 113 | unset($this->_events["_create"]); |
114 | 114 | } |
115 | 115 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @return BaseHtml |
124 | 124 | */ |
125 | 125 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
126 | - $params=array ("url" => $url,"responseElement" => $responseElement ); |
|
126 | + $params=array("url" => $url, "responseElement" => $responseElement); |
|
127 | 127 | $params=array_merge($params, $parameters); |
128 | 128 | $this->_addEvent($event, new AjaxCall($operation, $params)); |
129 | 129 | return $this; |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | |
140 | 140 | public function postOn($event, $url, $params="{}", $responseElement="", $parameters=array()) { |
141 | 141 | $allParameters=[]; |
142 | - if(isset($parameters["params"])){ |
|
142 | + if (isset($parameters["params"])) { |
|
143 | 143 | $allParameters[]=JsUtils::_correctParams($parameters["params"]); |
144 | 144 | } |
145 | - if(isset($params)){ |
|
145 | + if (isset($params)) { |
|
146 | 146 | $allParameters[]=JsUtils::_correctParams($params); |
147 | 147 | } |
148 | 148 | $parameters["params"]=\implode("+'&'+", $allParameters); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | public function jsDoJquery($jqueryCall, $param="") { |
166 | - return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . Javascript::prep_value($param) . ");"; |
|
166 | + return "$('#".$this->identifier."').".$jqueryCall."(".Javascript::prep_value($param).");"; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | public function executeOnRun($jsCode) { |
@@ -183,6 +183,6 @@ discard block |
||
183 | 183 | } |
184 | 184 | |
185 | 185 | public function jsToggle($value) { |
186 | - return $this->jsDoJquery("toggle",$value); |
|
186 | + return $this->jsDoJquery("toggle", $value); |
|
187 | 187 | } |
188 | 188 | } |