Completed
Push — master ( 3f2ff8...3555a5 )
by Jean-Christophe
03:49
created
Ajax/common/traits/JqueryAjaxTrait.php 1 patch
Braces   +25 added lines, -18 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@  discard block
 block discarded – undo
46 46
 		}
47 47
 		$retour.="$.".$method."(url,".$params.").done(function( data ) {\n";
48 48
 		$retour.=$this->_getOnAjaxDone($responseElement, $jsCallback)."});\n";
49
-		if ($immediatly)
50
-			$this->jquery_code_for_compile[]=$retour;
49
+		if ($immediatly) {
50
+					$this->jquery_code_for_compile[]=$retour;
51
+		}
51 52
 			return $retour;
52 53
 	}
53 54
 
@@ -55,13 +56,15 @@  discard block
 block discarded – undo
55 56
 		$url=$this->_correctAjaxUrl($url);
56 57
 		$retour="url='".$url."';\n";
57 58
 		$slash="/";
58
-		if(JString::endswith($url, "/")===true)
59
-			$slash="";
59
+		if(JString::endswith($url, "/")===true) {
60
+					$slash="";
61
+		}
60 62
 		if(JString::isNotNull($attr)){
61
-			if ($attr=="value")
62
-				$retour.="url=url+'".$slash."'+$(this).val();\n";
63
-				else if($attr!=null && $attr!=="")
64
-					$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
63
+			if ($attr=="value") {
64
+							$retour.="url=url+'".$slash."'+$(this).val();\n";
65
+			} else if($attr!=null && $attr!=="") {
66
+									$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
67
+				}
65 68
 		}
66 69
 		return $retour;
67 70
 	}
@@ -72,7 +75,7 @@  discard block
 block discarded – undo
72 75
 			if(JString::startswith($responseElement, "-")){
73 76
 				$responseElement=\substr($responseElement, 0);
74 77
 				$retour="\t$({$responseElement}).replaceWith( data );\n";
75
-			}else{
78
+			} else{
76 79
 				$retour="\t$({$responseElement}).html( data );\n";
77 80
 			}
78 81
 		}
@@ -88,8 +91,9 @@  discard block
 block discarded – undo
88 91
 	}
89 92
 
90 93
 	protected function _correctAjaxUrl($url) {
91
-		if ($url!=="/" && JString::endsWith($url, "/")===true)
92
-			$url=substr($url, 0, strlen($url)-1);
94
+		if ($url!=="/" && JString::endsWith($url, "/")===true) {
95
+					$url=substr($url, 0, strlen($url)-1);
96
+		}
93 97
 		if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
94 98
 			$url=$this->jsUtils->getUrl($url);
95 99
 		}
@@ -113,8 +117,9 @@  discard block
 block discarded – undo
113 117
 				$retour.="\t".$jsCallback."\n".
114 118
 						"\t$(document).trigger('jsonReady',[data]);\n".
115 119
 						"});\n";
116
-				if ($immediatly)
117
-					$this->jquery_code_for_compile[]=$retour;
120
+				if ($immediatly) {
121
+									$this->jquery_code_for_compile[]=$retour;
122
+				}
118 123
 					return $retour;
119 124
 	}
120 125
 
@@ -153,7 +158,7 @@  discard block
 block discarded – undo
153 158
 		if($context===null){
154 159
 			$appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n";
155 160
 			$newElm = "$('#'+newId)";
156
-		}else{
161
+		} else{
157 162
 			$appendTo="\t\tnewElm.appendTo(".$context.");\n";
158 163
 			$newElm = $context.".find('#'+newId)";
159 164
 		}
@@ -163,8 +168,9 @@  discard block
 block discarded – undo
163 168
 		$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";
164 169
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
165 170
 		$retour.="\t".$jsCallback."\n"."});\n";
166
-		if ($immediatly)
167
-			$this->jquery_code_for_compile[]=$retour;
171
+		if ($immediatly) {
172
+					$this->jquery_code_for_compile[]=$retour;
173
+		}
168 174
 			return $retour;
169 175
 	}
170 176
 	/**
@@ -205,8 +211,9 @@  discard block
 block discarded – undo
205 211
 			}});\n";
206 212
 			$retour.="$('#".$form."').submit();\n";
207 213
 		}
208
-		if ($immediatly)
209
-			$this->jquery_code_for_compile[]=$retour;
214
+		if ($immediatly) {
215
+					$this->jquery_code_for_compile[]=$retour;
216
+		}
210 217
 			return $retour;
211 218
 	}
212 219
 
Please login to merge, or discard this patch.