@@ -49,8 +49,9 @@ discard block |
||
49 | 49 | $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n"; |
50 | 50 | $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
51 | 51 | $retour=$this->_addJsCondition($jsCondition,$retour); |
52 | - if ($immediatly) |
|
53 | - $this->jquery_code_for_compile[]=$retour; |
|
52 | + if ($immediatly) { |
|
53 | + $this->jquery_code_for_compile[]=$retour; |
|
54 | + } |
|
54 | 55 | return $retour; |
55 | 56 | } |
56 | 57 | |
@@ -86,12 +87,13 @@ discard block |
||
86 | 87 | if(JString::isNotNull($attr)){ |
87 | 88 | if ($attr==="value"){ |
88 | 89 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
89 | - }elseif ($attr==="html"){ |
|
90 | + } elseif ($attr==="html"){ |
|
90 | 91 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
91 | - }elseif(\substr($attr, 0,3)==="js:"){ |
|
92 | + } elseif(\substr($attr, 0,3)==="js:"){ |
|
92 | 93 | $retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n"; |
93 | - }elseif($attr!==null && $attr!=="") |
|
94 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
94 | + } elseif($attr!==null && $attr!=="") { |
|
95 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
96 | + } |
|
95 | 97 | } |
96 | 98 | return $retour; |
97 | 99 | } |
@@ -101,13 +103,14 @@ discard block |
||
101 | 103 | if ($responseElement!=="") { |
102 | 104 | if(isset($ajaxTransition)){ |
103 | 105 | $call=$this->setAjaxDataCall($ajaxTransition); |
104 | - }elseif(isset($this->ajaxTransition)){ |
|
106 | + } elseif(isset($this->ajaxTransition)){ |
|
105 | 107 | $call=$this->ajaxTransition; |
106 | 108 | } |
107 | - if(\is_callable($call)) |
|
108 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
109 | - else |
|
110 | - $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
109 | + if(\is_callable($call)) { |
|
110 | + $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
111 | + } else { |
|
112 | + $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
113 | + } |
|
111 | 114 | } |
112 | 115 | $retour.="\t".$jsCallback."\n"; |
113 | 116 | return $retour; |
@@ -122,8 +125,9 @@ discard block |
||
122 | 125 | } |
123 | 126 | |
124 | 127 | protected function _correctAjaxUrl($url) { |
125 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
126 | - $url=substr($url, 0, strlen($url)-1); |
|
128 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
129 | + $url=substr($url, 0, strlen($url)-1); |
|
130 | + } |
|
127 | 131 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
128 | 132 | $url=$this->getUrl($url); |
129 | 133 | } |
@@ -143,8 +147,9 @@ discard block |
||
143 | 147 | public static function _implodeParams($parameters){ |
144 | 148 | $allParameters=[]; |
145 | 149 | foreach ($parameters as $params){ |
146 | - if(isset($params)) |
|
147 | - $allParameters[]=self::_correctParams($params); |
|
150 | + if(isset($params)) { |
|
151 | + $allParameters[]=self::_correctParams($params); |
|
152 | + } |
|
148 | 153 | } |
149 | 154 | return \implode("+'&'+", $allParameters); |
150 | 155 | } |
@@ -173,8 +178,9 @@ discard block |
||
173 | 178 | |
174 | 179 | protected function setDefaultParameters(&$parameters,$default){ |
175 | 180 | foreach ($default as $k=>$v){ |
176 | - if(!isset($parameters[$k])) |
|
177 | - $parameters[$k]=$v; |
|
181 | + if(!isset($parameters[$k])) { |
|
182 | + $parameters[$k]=$v; |
|
183 | + } |
|
178 | 184 | } |
179 | 185 | } |
180 | 186 | |
@@ -245,8 +251,9 @@ discard block |
||
245 | 251 | $retour.="\t".$jsCallback."\n". |
246 | 252 | "\t$(document).trigger('jsonReady',[data]);\n". |
247 | 253 | "});\n"; |
248 | - if ($immediatly) |
|
249 | - $this->jquery_code_for_compile[]=$retour; |
|
254 | + if ($immediatly) { |
|
255 | + $this->jquery_code_for_compile[]=$retour; |
|
256 | + } |
|
250 | 257 | return $retour; |
251 | 258 | } |
252 | 259 | |
@@ -311,7 +318,7 @@ discard block |
||
311 | 318 | if($context===null){ |
312 | 319 | $parent="$('".$maskSelector."').parent()"; |
313 | 320 | $newElm = "$('#'+newId)"; |
314 | - }else{ |
|
321 | + } else{ |
|
315 | 322 | $parent=$context; |
316 | 323 | $newElm = $context.".find('#'+newId)"; |
317 | 324 | } |
@@ -324,8 +331,9 @@ discard block |
||
324 | 331 | $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"; |
325 | 332 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
326 | 333 | $retour.="\t".$jsCallback."\n"."});\n"; |
327 | - if ($immediatly) |
|
328 | - $this->jquery_code_for_compile[]=$retour; |
|
334 | + if ($immediatly) { |
|
335 | + $this->jquery_code_for_compile[]=$retour; |
|
336 | + } |
|
329 | 337 | return $retour; |
330 | 338 | } |
331 | 339 | |
@@ -528,8 +536,9 @@ discard block |
||
528 | 536 | $retour.="$('#".$form."').submit();\n"; |
529 | 537 | } |
530 | 538 | $retour=$this->_addJsCondition($jsCondition, $retour); |
531 | - if ($immediatly) |
|
532 | - $this->jquery_code_for_compile[]=$retour; |
|
539 | + if ($immediatly) { |
|
540 | + $this->jquery_code_for_compile[]=$retour; |
|
541 | + } |
|
533 | 542 | return $retour; |
534 | 543 | } |
535 | 544 |