Completed
Push — master ( 93b0d7...a78505 )
by Jean-Christophe
02:42
created
Ajax/common/traits/JsUtilsAjaxTrait.php 1 patch
Braces   +27 added lines, -20 removed lines patch added patch discarded remove patch
@@ -52,8 +52,9 @@  discard block
 block discarded – undo
52 52
 		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n";
53 53
 		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
54 54
 		$retour=$this->_addJsCondition($jsCondition,$retour);
55
-		if ($immediatly)
56
-			$this->jquery_code_for_compile[]=$retour;
55
+		if ($immediatly) {
56
+					$this->jquery_code_for_compile[]=$retour;
57
+		}
57 58
 		return $retour;
58 59
 	}
59 60
 
@@ -89,12 +90,13 @@  discard block
 block discarded – undo
89 90
 		if(JString::isNotNull($attr)){
90 91
 			if ($attr==="value"){
91 92
 				$retour.="url=url+'".$slash."'+$(this).val();\n";
92
-			}elseif ($attr==="html"){
93
+			} elseif ($attr==="html"){
93 94
 				$retour.="url=url+'".$slash."'+$(this).html();\n";
94
-			}elseif(\substr($attr, 0,3)==="js:"){
95
+			} elseif(\substr($attr, 0,3)==="js:"){
95 96
 				$retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n";
96
-			}elseif($attr!==null && $attr!=="")
97
-				$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
97
+			} elseif($attr!==null && $attr!=="") {
98
+							$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
99
+			}
98 100
 		}
99 101
 		return $retour;
100 102
 	}
@@ -104,13 +106,14 @@  discard block
 block discarded – undo
104 106
 		if (JString::isNotNull($responseElement)) {
105 107
 			if(isset($ajaxTransition)){
106 108
 				$call=$this->setAjaxDataCall($ajaxTransition);
107
-			}elseif(isset($this->ajaxTransition)){
109
+			} elseif(isset($this->ajaxTransition)){
108 110
 				$call=$this->ajaxTransition;
109 111
 			}
110
-			if(\is_callable($call))
111
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
112
-			else
113
-				$retour="\t{$responseElement}.{$jqueryDone}( data );\n";
112
+			if(\is_callable($call)) {
113
+							$retour="\t".$call($responseElement,$jqueryDone).";\n";
114
+			} else {
115
+							$retour="\t{$responseElement}.{$jqueryDone}( data );\n";
116
+			}
114 117
 		}
115 118
 		$retour.="\t".$jsCallback."\n";
116 119
 		return $retour;
@@ -125,8 +128,9 @@  discard block
 block discarded – undo
125 128
 	}
126 129
 
127 130
 	protected function _correctAjaxUrl($url) {
128
-		if ($url!=="/" && JString::endsWith($url, "/")===true)
129
-			$url=substr($url, 0, strlen($url)-1);
131
+		if ($url!=="/" && JString::endsWith($url, "/")===true) {
132
+					$url=substr($url, 0, strlen($url)-1);
133
+		}
130 134
 			if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
131 135
 				$url=$this->getUrl($url);
132 136
 			}
@@ -146,8 +150,9 @@  discard block
 block discarded – undo
146 150
 	public static function _implodeParams($parameters){
147 151
 		$allParameters=[];
148 152
 		foreach ($parameters as $params){
149
-			if(isset($params))
150
-				$allParameters[]=self::_correctParams($params);
153
+			if(isset($params)) {
154
+							$allParameters[]=self::_correctParams($params);
155
+			}
151 156
 		}
152 157
 		return \implode("+'&'+", $allParameters);
153 158
 	}
@@ -176,8 +181,9 @@  discard block
 block discarded – undo
176 181
 
177 182
 	protected function setDefaultParameters(&$parameters,$default){
178 183
 		foreach ($default as $k=>$v){
179
-			if(!isset($parameters[$k]))
180
-				$parameters[$k]=$v;
184
+			if(!isset($parameters[$k])) {
185
+							$parameters[$k]=$v;
186
+			}
181 187
 		}
182 188
 	}
183 189
 
@@ -295,7 +301,7 @@  discard block
 block discarded – undo
295 301
 		if($context===null){
296 302
 			$parent="$('".$maskSelector."').parent()";
297 303
 			$newElm = "$('#'+newId)";
298
-		}else{
304
+		} else{
299 305
 			$parent=$context;
300 306
 			$newElm = $context.".find('#'+newId)";
301 307
 		}
@@ -497,8 +503,9 @@  discard block
 block discarded – undo
497 503
 			$retour.="$('#".$form."').submit();\n";
498 504
 		}
499 505
 		$retour=$this->_addJsCondition($jsCondition, $retour);
500
-		if ($immediatly)
501
-			$this->jquery_code_for_compile[]=$retour;
506
+		if ($immediatly) {
507
+					$this->jquery_code_for_compile[]=$retour;
508
+		}
502 509
 		return $retour;
503 510
 	}
504 511
 
Please login to merge, or discard this patch.
Ajax/service/AjaxCall.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function compile(JsUtils $js=null) {
17
-		if ($js===null)
18
-			return;
17
+		if ($js===null) {
18
+					return;
19
+		}
19 20
 		$params="{}";
20 21
 		$stopPropagation=true;
21 22
 		$preventDefault=true;
Please login to merge, or discard this patch.