Completed
Push — master ( 35727f...fb65dc )
by Jean-Christophe
04:36
created
Ajax/common/traits/JqueryAjaxTrait.php 1 patch
Braces   +24 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,8 +40,9 @@  discard block
 block discarded – undo
40 40
 		}
41 41
 		$retour.="$.".$method."(url,".$params.").done(function( data ) {\n";
42 42
 		$retour.=$this->_getOnAjaxDone($responseElement, $jsCallback)."});\n";
43
-		if ($immediatly)
44
-			$this->jquery_code_for_compile[]=$retour;
43
+		if ($immediatly) {
44
+					$this->jquery_code_for_compile[]=$retour;
45
+		}
45 46
 			return $retour;
46 47
 	}
47 48
 
@@ -49,13 +50,15 @@  discard block
 block discarded – undo
49 50
 		$url=$this->_correctAjaxUrl($url);
50 51
 		$retour="url='".$url."';\n";
51 52
 		$slash="/";
52
-		if(PhalconUtils::endsWith($url, "/")===true)
53
-			$slash="";
53
+		if(PhalconUtils::endsWith($url, "/")===true) {
54
+					$slash="";
55
+		}
54 56
 		if(JString::isNotNull($attr)){
55
-			if ($attr=="value")
56
-				$retour.="url=url+'".$slash."'+$(this).val();\n";
57
-				else if($attr!=null && $attr!=="")
58
-					$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
57
+			if ($attr=="value") {
58
+							$retour.="url=url+'".$slash."'+$(this).val();\n";
59
+			} else if($attr!=null && $attr!=="") {
60
+									$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
61
+				}
59 62
 		}
60 63
 		return $retour;
61 64
 	}
@@ -77,8 +80,9 @@  discard block
 block discarded – undo
77 80
 	}
78 81
 
79 82
 	protected function _correctAjaxUrl($url) {
80
-		if ($url!=="/" && JString::endsWith($url, "/")===true)
81
-			$url=substr($url, 0, strlen($url)-1);
83
+		if ($url!=="/" && JString::endsWith($url, "/")===true) {
84
+					$url=substr($url, 0, strlen($url)-1);
85
+		}
82 86
 		if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
83 87
 			$url=$this->jsUtils->getUrl($url);
84 88
 		}
@@ -102,8 +106,9 @@  discard block
 block discarded – undo
102 106
 				$retour.="\t".$jsCallback."\n".
103 107
 						"\t$(document).trigger('jsonReady',[data]);\n".
104 108
 						"});\n";
105
-				if ($immediatly)
106
-					$this->jquery_code_for_compile[]=$retour;
109
+				if ($immediatly) {
110
+									$this->jquery_code_for_compile[]=$retour;
111
+				}
107 112
 					return $retour;
108 113
 	}
109 114
 
@@ -142,7 +147,7 @@  discard block
 block discarded – undo
142 147
 		if($context===null){
143 148
 			$appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n";
144 149
 			$newElm = "$('#'+newId)";
145
-		}else{
150
+		} else{
146 151
 			$appendTo="\t\tnewElm.appendTo(".$context.");\n";
147 152
 			$newElm = $context.".find('#'+newId)";
148 153
 		}
@@ -152,8 +157,9 @@  discard block
 block discarded – undo
152 157
 		$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";
153 158
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
154 159
 		$retour.="\t".$jsCallback."\n"."});\n";
155
-		if ($immediatly)
156
-			$this->jquery_code_for_compile[]=$retour;
160
+		if ($immediatly) {
161
+					$this->jquery_code_for_compile[]=$retour;
162
+		}
157 163
 			return $retour;
158 164
 	}
159 165
 	/**
@@ -194,8 +200,9 @@  discard block
 block discarded – undo
194 200
 			}});\n";
195 201
 			$retour.="$('#".$form."').submit();\n";
196 202
 		}
197
-		if ($immediatly)
198
-			$this->jquery_code_for_compile[]=$retour;
203
+		if ($immediatly) {
204
+					$this->jquery_code_for_compile[]=$retour;
205
+		}
199 206
 			return $retour;
200 207
 	}
201 208
 
Please login to merge, or discard this patch.