Completed
Push — master ( b77ba2...042f42 )
by Jean-Christophe
03:22
created
Ajax/common/traits/JqueryAjaxTrait.php 1 patch
Braces   +32 added lines, -24 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
 		}
49 49
 		$retour.="$.".$method."(url,".$params.").done(function( data ) {\n";
50 50
 		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
51
-		if ($immediatly)
52
-			$this->jquery_code_for_compile[]=$retour;
51
+		if ($immediatly) {
52
+					$this->jquery_code_for_compile[]=$retour;
53
+		}
53 54
 		return $retour;
54 55
 	}
55 56
 
@@ -67,15 +68,17 @@  discard block
 block discarded – undo
67 68
 		$url=$this->_correctAjaxUrl($url);
68 69
 		$retour="url='".$url."';";
69 70
 		$slash="/";
70
-		if(JString::endswith($url, "/")===true)
71
-			$slash="";
71
+		if(JString::endswith($url, "/")===true) {
72
+					$slash="";
73
+		}
72 74
 		if(JString::isNotNull($attr)){
73
-			if ($attr==="value")
74
-				$retour.="url=url+'".$slash."'+$(this).val();\n";
75
-			elseif ($attr==="html")
76
-			$retour.="url=url+'".$slash."'+$(this).html();\n";
77
-			elseif($attr!==null && $attr!=="")
78
-					$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
75
+			if ($attr==="value") {
76
+							$retour.="url=url+'".$slash."'+$(this).val();\n";
77
+			} elseif ($attr==="html") {
78
+						$retour.="url=url+'".$slash."'+$(this).html();\n";
79
+			} elseif($attr!==null && $attr!=="") {
80
+								$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
81
+			}
79 82
 		}
80 83
 		return $retour;
81 84
 	}
@@ -85,13 +88,14 @@  discard block
 block discarded – undo
85 88
 		if ($responseElement!=="") {
86 89
 			if(isset($ajaxTransition)){
87 90
 				$call=$this->setAjaxDataCall($ajaxTransition);
88
-			}elseif(isset($this->ajaxTransition)){
91
+			} elseif(isset($this->ajaxTransition)){
89 92
 				$call=$this->ajaxTransition;
90 93
 			}
91
-			if(\is_callable($call))
92
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
93
-			else
94
-				$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
94
+			if(\is_callable($call)) {
95
+							$retour="\t".$call($responseElement,$jqueryDone).";\n";
96
+			} else {
97
+							$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
98
+			}
95 99
 		}
96 100
 		$retour.="\t".$jsCallback."\n";
97 101
 		return $retour;
@@ -105,8 +109,9 @@  discard block
 block discarded – undo
105 109
 	}
106 110
 
107 111
 	protected function _correctAjaxUrl($url) {
108
-		if ($url!=="/" && JString::endsWith($url, "/")===true)
109
-			$url=substr($url, 0, strlen($url)-1);
112
+		if ($url!=="/" && JString::endsWith($url, "/")===true) {
113
+					$url=substr($url, 0, strlen($url)-1);
114
+		}
110 115
 		if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
111 116
 			$url=$this->jsUtils->getUrl($url);
112 117
 		}
@@ -130,8 +135,9 @@  discard block
 block discarded – undo
130 135
 				$retour.="\t".$jsCallback."\n".
131 136
 						"\t$(document).trigger('jsonReady',[data]);\n".
132 137
 						"});\n";
133
-				if ($immediatly)
134
-					$this->jquery_code_for_compile[]=$retour;
138
+				if ($immediatly) {
139
+									$this->jquery_code_for_compile[]=$retour;
140
+				}
135 141
 					return $retour;
136 142
 	}
137 143
 
@@ -171,7 +177,7 @@  discard block
 block discarded – undo
171 177
 		if($context===null){
172 178
 			$parent="$('".$maskSelector."').parent()";
173 179
 			$newElm = "$('#'+newId)";
174
-		}else{
180
+		} else{
175 181
 			$parent=$context;
176 182
 			$newElm = $context.".find('#'+newId)";
177 183
 		}
@@ -184,8 +190,9 @@  discard block
 block discarded – undo
184 190
 		$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";
185 191
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
186 192
 		$retour.="\t".$jsCallback."\n"."});\n";
187
-		if ($immediatly)
188
-			$this->jquery_code_for_compile[]=$retour;
193
+		if ($immediatly) {
194
+					$this->jquery_code_for_compile[]=$retour;
195
+		}
189 196
 			return $retour;
190 197
 	}
191 198
 	/**
@@ -226,8 +233,9 @@  discard block
 block discarded – undo
226 233
 			}});\n";
227 234
 			$retour.="$('#".$form."').submit();\n";
228 235
 		}
229
-		if ($immediatly)
230
-			$this->jquery_code_for_compile[]=$retour;
236
+		if ($immediatly) {
237
+					$this->jquery_code_for_compile[]=$retour;
238
+		}
231 239
 			return $retour;
232 240
 	}
233 241
 
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
 		$jsCallback=NULL;
21 22
 		$attr="id";
Please login to merge, or discard this patch.