Passed
Push — master ( 2aba7e...e38ed8 )
by Jean-Christophe
02:21
created
Ajax/common/traits/JsUtilsAjaxTrait.php 1 patch
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -15,69 +15,69 @@  discard block
 block discarded – undo
15 15
 
16 16
 	protected $ajaxTransition;
17 17
 
18
-	protected $ajaxLoader = "<div class=\"ui active centered inline text loader\">Loading</div>";
18
+	protected $ajaxLoader="<div class=\"ui active centered inline text loader\">Loading</div>";
19 19
 
20 20
 	abstract public function getUrl($url);
21 21
 
22
-	abstract public function _add_event($element, $js, $event, $preventDefault = false, $stopPropagation = false, $immediatly = true, $listenerOn = false);
22
+	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true, $listenerOn=false);
23 23
 
24
-	abstract public function interval($jsCode, $time, $globalName = null, $immediatly = true);
24
+	abstract public function interval($jsCode, $time, $globalName=null, $immediatly=true);
25 25
 
26
-	protected function _ajax($method, $url, $responseElement = '', $parameters = []) {
26
+	protected function _ajax($method, $url, $responseElement='', $parameters=[]) {
27 27
 		if (isset($this->params['ajax'])) {
28 28
 			extract($this->params['ajax']);
29 29
 		}
30 30
 		extract($parameters);
31 31
 
32
-		$jsCallback = isset($jsCallback) ? $jsCallback : '';
33
-		$retour = $this->_getAjaxUrl($url, $attr);
34
-		$originalSelector = $responseElement;
35
-		$responseElement = $this->_getResponseElement($responseElement);
36
-		$retour .= "var self=this;\n";
37
-		$before = isset($before) ? $before : "";
38
-		$retour .= $before;
39
-		if ($hasLoader === true && JString::isNotNull($responseElement)) {
32
+		$jsCallback=isset($jsCallback) ? $jsCallback : '';
33
+		$retour=$this->_getAjaxUrl($url, $attr);
34
+		$originalSelector=$responseElement;
35
+		$responseElement=$this->_getResponseElement($responseElement);
36
+		$retour.="var self=this;\n";
37
+		$before=isset($before) ? $before : "";
38
+		$retour.=$before;
39
+		if ($hasLoader===true && JString::isNotNull($responseElement)) {
40 40
 			$this->addLoading($retour, $responseElement, $ajaxLoader);
41
-		} elseif ($hasLoader === 'response') {
41
+		} elseif ($hasLoader==='response') {
42 42
 			$this->addResponseLoading($retour, $responseElement, $ajaxLoader);
43
-		} elseif ($hasLoader === 'internal-x') {
43
+		} elseif ($hasLoader==='internal-x') {
44 44
 			$this->addLoading($retour, '$(this).closest(".item, .step")', $ajaxLoader);
45
-		} elseif ($hasLoader === 'internal') {
46
-			$retour .= "\n$(this).addClass('loading');";
45
+		} elseif ($hasLoader==='internal') {
46
+			$retour.="\n$(this).addClass('loading');";
47 47
 		}
48
-		$ajaxParameters = [
48
+		$ajaxParameters=[
49 49
 			"url" => "url",
50
-			"method" => "'" . \strtoupper($method) . "'"
50
+			"method" => "'".\strtoupper($method)."'"
51 51
 		];
52 52
 
53
-		$ajaxParameters["async"] = ($async ? "true" : "false");
53
+		$ajaxParameters["async"]=($async ? "true" : "false");
54 54
 
55 55
 		if (isset($params)) {
56
-			$ajaxParameters["data"] = self::_correctParams($params, $parameters);
56
+			$ajaxParameters["data"]=self::_correctParams($params, $parameters);
57 57
 		}
58 58
 		if (isset($headers)) {
59
-			$ajaxParameters["headers"] = $headers;
59
+			$ajaxParameters["headers"]=$headers;
60 60
 		}
61 61
 		if ($csrf) {
62
-			$csrf = (is_string($csrf)) ? $csrf : 'csrf-token';
63
-			$parameters["beforeSend"] = "jqXHR.setRequestHeader('{$csrf}', $('meta[name=\"{$csrf}\"]').attr('content'));";
62
+			$csrf=(is_string($csrf)) ? $csrf : 'csrf-token';
63
+			$parameters["beforeSend"]="jqXHR.setRequestHeader('{$csrf}', $('meta[name=\"{$csrf}\"]').attr('content'));";
64 64
 		}
65 65
 		if (isset($partial)) {
66
-			$ajaxParameters["xhr"] = "xhrProvider";
67
-			$retour .= "var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;" . $partial . ";}; };";
66
+			$ajaxParameters["xhr"]="xhrProvider";
67
+			$retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };";
68 68
 		}
69 69
 		$this->createAjaxParameters($ajaxParameters, $parameters);
70
-		$retour .= "$.ajax({" . $this->implodeAjaxParameters($ajaxParameters) . "}).done(function( data, textStatus, jqXHR ) {\n";
71
-		$retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null)) . "});\n";
70
+		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n";
71
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null))."});\n";
72 72
 
73
-		$retour = $this->_addJsCondition($jsCondition, $retour);
73
+		$retour=$this->_addJsCondition($jsCondition, $retour);
74 74
 		if ($immediatly)
75
-			$this->jquery_code_for_compile[] = $retour;
75
+			$this->jquery_code_for_compile[]=$retour;
76 76
 		return $retour;
77 77
 	}
78 78
 
79 79
 	protected function createAjaxParameters(&$original, $parameters) {
80
-		$validParameters = [
80
+		$validParameters=[
81 81
 			"contentType" => "%value%",
82 82
 			"dataType" => "'%value%'",
83 83
 			"beforeSend" => "function(jqXHR,settings){%value%}",
@@ -86,21 +86,21 @@  discard block
 block discarded – undo
86 86
 		];
87 87
 		foreach ($validParameters as $param => $mask) {
88 88
 			if (isset($parameters[$param])) {
89
-				$original[$param] = \str_replace("%value%", $parameters[$param], $mask);
89
+				$original[$param]=\str_replace("%value%", $parameters[$param], $mask);
90 90
 			}
91 91
 		}
92 92
 	}
93 93
 
94 94
 	protected function implodeAjaxParameters($ajaxParameters) {
95
-		$s = '';
95
+		$s='';
96 96
 		foreach ($ajaxParameters as $k => $v) {
97
-			if ($s !== '') {
98
-				$s .= ',';
97
+			if ($s!=='') {
98
+				$s.=',';
99 99
 			}
100 100
 			if (is_array($v)) {
101
-				$s .= "'{$k}':{" . self::implodeAjaxParameters($v) . "}";
101
+				$s.="'{$k}':{".self::implodeAjaxParameters($v)."}";
102 102
 			} else {
103
-				$s .= "'{$k}':{$v}";
103
+				$s.="'{$k}':{$v}";
104 104
 			}
105 105
 		}
106 106
 		return $s;
@@ -108,27 +108,27 @@  discard block
 block discarded – undo
108 108
 
109 109
 	protected function _addJsCondition($jsCondition, $jsSource) {
110 110
 		if (isset($jsCondition)) {
111
-			return "if(" . $jsCondition . "){\n" . $jsSource . "\n}";
111
+			return "if(".$jsCondition."){\n".$jsSource."\n}";
112 112
 		}
113 113
 		return $jsSource;
114 114
 	}
115 115
 
116 116
 	protected function _getAjaxUrl($url, $attr) {
117
-		$url = $this->_correctAjaxUrl($url);
118
-		$retour = "url='" . $url . "';";
119
-		$slash = "/";
120
-		if (JString::endswith($url, "/") === true) {
121
-			$slash = "";
117
+		$url=$this->_correctAjaxUrl($url);
118
+		$retour="url='".$url."';";
119
+		$slash="/";
120
+		if (JString::endswith($url, "/")===true) {
121
+			$slash="";
122 122
 		}
123 123
 		if (JString::isNotNull($attr)) {
124
-			if ($attr === "value") {
125
-				$retour .= "url=url+'" . $slash . "'+$(this).val();\n";
126
-			} elseif ($attr === "html") {
127
-				$retour .= "url=url+'" . $slash . "'+$(this).html();\n";
128
-			} elseif (\substr($attr, 0, 3) === "js:") {
129
-				$retour .= "url=url+'" . $slash . "'+" . \substr($attr, 3) . ";\n";
130
-			} elseif ($attr !== null && $attr !== "")
131
-				$retour .= "url=url+'" . $slash . "'+($(this).attr('" . $attr . "')||'');\n";
124
+			if ($attr==="value") {
125
+				$retour.="url=url+'".$slash."'+$(this).val();\n";
126
+			} elseif ($attr==="html") {
127
+				$retour.="url=url+'".$slash."'+$(this).html();\n";
128
+			} elseif (\substr($attr, 0, 3)==="js:") {
129
+				$retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n";
130
+			} elseif ($attr!==null && $attr!=="")
131
+				$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
132 132
 		}
133 133
 		return $retour;
134 134
 	}
@@ -137,101 +137,101 @@  discard block
 block discarded – undo
137 137
 		return "window.onpopstate = function(e){if(e.state){var target=e.state.jqueryDone;$(e.state.selector)[target](e.state.html);}};";
138 138
 	}
139 139
 
140
-	protected function autoActiveLinks($previousURL = "window.location.href") {
141
-		$result = "\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}";
142
-		$result .= "\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;";
140
+	protected function autoActiveLinks($previousURL="window.location.href") {
141
+		$result="\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}";
142
+		$result.="\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;";
143 143
 		return $result;
144 144
 	}
145 145
 
146
-	protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader = false, $history = null) {
147
-		$retour = "";
148
-		$call = null;
146
+	protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader=false, $history=null) {
147
+		$retour="";
148
+		$call=null;
149 149
 		if (JString::isNotNull($responseElement)) {
150 150
 			if (isset($ajaxTransition)) {
151
-				$call = $this->setAjaxDataCall($ajaxTransition);
151
+				$call=$this->setAjaxDataCall($ajaxTransition);
152 152
 			} elseif (isset($this->ajaxTransition)) {
153
-				$call = $this->ajaxTransition;
153
+				$call=$this->ajaxTransition;
154 154
 			}
155 155
 			if (\is_callable($call))
156
-				$retour = "\t" . $call($responseElement, $jqueryDone) . ";\n";
156
+				$retour="\t".$call($responseElement, $jqueryDone).";\n";
157 157
 			else
158
-				$retour = "\t{$responseElement}.{$jqueryDone}( data );\n";
158
+				$retour="\t{$responseElement}.{$jqueryDone}( data );\n";
159 159
 		}
160 160
 		if (isset($history)) {
161 161
 			if ($this->params["autoActiveLinks"]) {
162
-				$retour .= $this->autoActiveLinks("url");
162
+				$retour.=$this->autoActiveLinks("url");
163 163
 			}
164
-			$retour .= "\nwindow.history.pushState({'html':data,'selector':" . Javascript::prep_value($history) . ",'jqueryDone':'{$jqueryDone}'},'', url);";
164
+			$retour.="\nwindow.history.pushState({'html':data,'selector':".Javascript::prep_value($history).",'jqueryDone':'{$jqueryDone}'},'', url);";
165 165
 		}
166
-		if ($hasLoader === 'internal') {
167
-			$retour .= "\n$(self).removeClass('loading');";
168
-		} elseif ($hasLoader === 'internal-x') {
169
-			$retour .= "\n$(self).children('.ajax-loader').remove();";
166
+		if ($hasLoader==='internal') {
167
+			$retour.="\n$(self).removeClass('loading');";
168
+		} elseif ($hasLoader==='internal-x') {
169
+			$retour.="\n$(self).children('.ajax-loader').remove();";
170 170
 		}
171
-		$retour .= "\t" . $jsCallback . "\n";
171
+		$retour.="\t".$jsCallback."\n";
172 172
 		return $retour;
173 173
 	}
174 174
 
175 175
 	protected function _getResponseElement($responseElement) {
176 176
 		if (JString::isNotNull($responseElement)) {
177
-			$responseElement = Javascript::prep_jquery_selector($responseElement);
177
+			$responseElement=Javascript::prep_jquery_selector($responseElement);
178 178
 		}
179 179
 		return $responseElement;
180 180
 	}
181 181
 
182 182
 	protected function _correctAjaxUrl($url) {
183
-		if ($url !== "/" && JString::endsWith($url, "/") === true)
184
-			$url = substr($url, 0, strlen($url) - 1);
185
-		if (strncmp($url, 'http://', 7) != 0 && strncmp($url, 'https://', 8) != 0) {
186
-			$url = $this->getUrl($url);
183
+		if ($url!=="/" && JString::endsWith($url, "/")===true)
184
+			$url=substr($url, 0, strlen($url)-1);
185
+		if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) {
186
+			$url=$this->getUrl($url);
187 187
 		}
188 188
 		return $url;
189 189
 	}
190 190
 
191
-	public static function _correctParams($params, $ajaxParameters = []) {
191
+	public static function _correctParams($params, $ajaxParameters=[]) {
192 192
 		if (JString::isNull($params)) {
193 193
 			return "";
194 194
 		}
195 195
 		if (\preg_match("@^\{.*?\}$@", $params)) {
196
-			if (! isset($ajaxParameters['contentType']) || ! JString::contains($ajaxParameters['contentType'], 'json')) {
197
-				return '$.param(' . $params . ')';
196
+			if (!isset($ajaxParameters['contentType']) || !JString::contains($ajaxParameters['contentType'], 'json')) {
197
+				return '$.param('.$params.')';
198 198
 			} else {
199
-				return 'JSON.stringify(' . $params . ')';
199
+				return 'JSON.stringify('.$params.')';
200 200
 			}
201 201
 		}
202 202
 		return $params;
203 203
 	}
204 204
 
205 205
 	public static function _implodeParams($parameters) {
206
-		$allParameters = [];
206
+		$allParameters=[];
207 207
 		foreach ($parameters as $params) {
208 208
 			if (isset($params))
209
-				$allParameters[] = self::_correctParams($params);
209
+				$allParameters[]=self::_correctParams($params);
210 210
 		}
211 211
 		return \implode("+'&'+", $allParameters);
212 212
 	}
213 213
 
214
-	protected function addLoading(&$retour, $responseElement, $ajaxLoader = null) {
215
-		if (! isset($ajaxLoader)) {
216
-			$ajaxLoader = $this->ajaxLoader;
214
+	protected function addLoading(&$retour, $responseElement, $ajaxLoader=null) {
215
+		if (!isset($ajaxLoader)) {
216
+			$ajaxLoader=$this->ajaxLoader;
217 217
 		}
218
-		$loading_notifier = '<div class="ajax-loader ui active inverted dimmer">' . $ajaxLoader . '</div>';
219
-		$retour .= "\t\t{$responseElement}.append('{$loading_notifier}');\n";
218
+		$loading_notifier='<div class="ajax-loader ui active inverted dimmer">'.$ajaxLoader.'</div>';
219
+		$retour.="\t\t{$responseElement}.append('{$loading_notifier}');\n";
220 220
 	}
221 221
 
222
-	protected function addResponseLoading(&$retour, $responseElement, $ajaxLoader = null) {
223
-		if (! isset($ajaxLoader)) {
224
-			$ajaxLoader = $this->ajaxLoader;
222
+	protected function addResponseLoading(&$retour, $responseElement, $ajaxLoader=null) {
223
+		if (!isset($ajaxLoader)) {
224
+			$ajaxLoader=$this->ajaxLoader;
225 225
 		}
226
-		$loading_notifier = '<div class="ajax-loader">' . $ajaxLoader . '</div>';
227
-		$retour .= "{$responseElement}.empty();\n";
228
-		$retour .= "\t\t{$responseElement}.prepend('{$loading_notifier}');\n";
226
+		$loading_notifier='<div class="ajax-loader">'.$ajaxLoader.'</div>';
227
+		$retour.="{$responseElement}.empty();\n";
228
+		$retour.="\t\t{$responseElement}.prepend('{$loading_notifier}');\n";
229 229
 	}
230 230
 
231 231
 	protected function setAjaxDataCall($params) {
232
-		$result = null;
233
-		if (! \is_callable($params)) {
234
-			$result = function ($responseElement, $jqueryDone = 'html') use ($params) {
232
+		$result=null;
233
+		if (!\is_callable($params)) {
234
+			$result=function($responseElement, $jqueryDone='html') use ($params) {
235 235
 				return AjaxTransition::{$params}($responseElement, $jqueryDone);
236 236
 			};
237 237
 		}
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
 
241 241
 	protected function setDefaultParameters(&$parameters, $default) {
242 242
 		foreach ($default as $k => $v) {
243
-			if (! isset($parameters[$k]))
244
-				$parameters[$k] = $v;
243
+			if (!isset($parameters[$k]))
244
+				$parameters[$k]=$v;
245 245
 		}
246 246
 	}
247 247
 
248 248
 	public function setAjaxLoader($loader) {
249
-		$this->ajaxLoader = $loader;
249
+		$this->ajaxLoader=$loader;
250 250
 	}
251 251
 
252 252
 	/**
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * @param string $responseElement
258 258
 	 *        	selector of the HTML element displaying the answer
259 259
 	 */
260
-	private function _get($url, $responseElement = '', $parameters = []) {
260
+	private function _get($url, $responseElement='', $parameters=[]) {
261 261
 		return $this->_ajax('get', $url, $responseElement, $parameters);
262 262
 	}
263 263
 
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 	 * @param array $parameters
272 272
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
273 273
 	 */
274
-	public function get($url, $responseElement = '', $parameters = []) {
275
-		$parameters['immediatly'] = true;
274
+	public function get($url, $responseElement='', $parameters=[]) {
275
+		$parameters['immediatly']=true;
276 276
 		return $this->_get($url, $responseElement, $parameters);
277 277
 	}
278 278
 
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 	 * @param array $parameters
289 289
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
290 290
 	 */
291
-	public function ajax($method, $url, $responseElement = '', $parameters = []) {
292
-		$parameters['immediatly'] = true;
291
+	public function ajax($method, $url, $responseElement='', $parameters=[]) {
292
+		$parameters['immediatly']=true;
293 293
 		return $this->_ajax($method, $url, $responseElement, $parameters);
294 294
 	}
295 295
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	 *        	$immediatly
312 312
 	 * @return string
313 313
 	 */
314
-	public function ajaxInterval($method, $url, $interval, $globalName = null, $responseElement = '', $parameters = [], $immediatly = true) {
314
+	public function ajaxInterval($method, $url, $interval, $globalName=null, $responseElement='', $parameters=[], $immediatly=true) {
315 315
 		return $this->interval($this->ajaxDeferred($method, $url, $responseElement, $parameters), $interval, $globalName, $immediatly);
316 316
 	}
317 317
 
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
 	 * @param array $parameters
328 328
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
329 329
 	 */
330
-	public function ajaxDeferred($method, $url, $responseElement = '', $parameters = []) {
331
-		$parameters['immediatly'] = false;
330
+	public function ajaxDeferred($method, $url, $responseElement='', $parameters=[]) {
331
+		$parameters['immediatly']=false;
332 332
 		return $this->_ajax($method, $url, $responseElement, $parameters);
333 333
 	}
334 334
 
@@ -342,15 +342,15 @@  discard block
 block discarded – undo
342 342
 	 * @param array $parameters
343 343
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null)
344 344
 	 */
345
-	private function _json($url, $method = "get", $parameters = []) {
346
-		$parameters = \array_merge($parameters, [
345
+	private function _json($url, $method="get", $parameters=[]) {
346
+		$parameters=\array_merge($parameters, [
347 347
 			"hasLoader" => false
348 348
 		]);
349
-		$jsCallback = isset($parameters['jsCallback']) ? $parameters['jsCallback'] : "";
350
-		$context = isset($parameters['context']) ? $parameters['context'] : "document";
351
-		$retour = "\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t" . $jsCallback . ";" . "\n\tfor(var key in data){" . "if($('#'+key," . $context . ").length){ if($('#'+key," . $context . ").is('[value]')) { $('#'+key," . $context . ").val(data[key]);} else { $('#'+key," . $context . ").html(data[key]); }}};\n";
352
-		$retour .= "\t$(document).trigger('jsonReady',[data]);\n";
353
-		$parameters["jsCallback"] = $retour;
349
+		$jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : "";
350
+		$context=isset($parameters['context']) ? $parameters['context'] : "document";
351
+		$retour="\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t".$jsCallback.";"."\n\tfor(var key in data){"."if($('#'+key,".$context.").length){ if($('#'+key,".$context.").is('[value]')) { $('#'+key,".$context.").val(data[key]);} else { $('#'+key,".$context.").html(data[key]); }}};\n";
352
+		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
353
+		$parameters["jsCallback"]=$retour;
354 354
 		return $this->_ajax($method, $url, null, $parameters);
355 355
 	}
356 356
 
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	 * @param array $parameters
365 365
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null)
366 366
 	 */
367
-	public function json($url, $method = "get", $parameters = []) {
367
+	public function json($url, $method="get", $parameters=[]) {
368 368
 		return $this->_json($url, $method, $parameters);
369 369
 	}
370 370
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 * @param array $parameters
381 381
 	 *        	default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true,"before"=>null,"listenerOn"=>false)
382 382
 	 */
383
-	public function jsonOn($event, $element, $url, $method = 'get', $parameters = array()) {
383
+	public function jsonOn($event, $element, $url, $method='get', $parameters=array()) {
384 384
 		$this->setDefaultParameters($parameters, [
385 385
 			'preventDefault' => true,
386 386
 			'stopPropagation' => true,
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
 	 * @param array $parameters
401 401
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null)
402 402
 	 */
403
-	public function jsonDeferred($url, $method = 'get', $parameters = []) {
404
-		$parameters['immediatly'] = false;
403
+	public function jsonDeferred($url, $method='get', $parameters=[]) {
404
+		$parameters['immediatly']=false;
405 405
 		return $this->_json($url, $method, $parameters);
406 406
 	}
407 407
 
@@ -416,29 +416,29 @@  discard block
 block discarded – undo
416 416
 	 * @param array $parameters
417 417
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null)
418 418
 	 */
419
-	private function _jsonArray($maskSelector, $url, $method = 'get', $parameters = []) {
420
-		$parameters = \array_merge($parameters, [
419
+	private function _jsonArray($maskSelector, $url, $method='get', $parameters=[]) {
420
+		$parameters=\array_merge($parameters, [
421 421
 			"hasLoader" => false
422 422
 		]);
423
-		$rowClass = isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json";
424
-		$jsCallback = isset($parameters['jsCallback']) ? $parameters['jsCallback'] : "";
425
-		$context = isset($parameters['context']) ? $parameters['context'] : null;
426
-		if ($context === null) {
427
-			$parent = "$('" . $maskSelector . "').parent()";
428
-			$newElm = "$('#'+newId)";
423
+		$rowClass=isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json";
424
+		$jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : "";
425
+		$context=isset($parameters['context']) ? $parameters['context'] : null;
426
+		if ($context===null) {
427
+			$parent="$('".$maskSelector."').parent()";
428
+			$newElm="$('#'+newId)";
429 429
 		} else {
430
-			$parent = $context;
431
-			$newElm = $context . ".find('#'+newId)";
430
+			$parent=$context;
431
+			$newElm=$context.".find('#'+newId)";
432 432
 		}
433
-		$appendTo = "\t\tnewElm.appendTo(" . $parent . ");\n";
434
-		$retour = $parent . ".find('.{$rowClass}').remove();";
435
-		$retour .= "\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.each(data, function(index, value) {\n" . "\tvar created=false;var maskElm=$('" . $maskSelector . "').first();maskElm.hide();" . "\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;" . "\tvar newElm=" . $newElm . ";\n" . "\tif(!newElm.length){\n" . "\t\tnewElm=maskElm.clone();
433
+		$appendTo="\t\tnewElm.appendTo(".$parent.");\n";
434
+		$retour=$parent.".find('.{$rowClass}').remove();";
435
+		$retour.="\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone();
436 436
 		newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n";
437
-		$retour .= $appendTo;
438
-		$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";
439
-		$retour .= "\t$(document).trigger('jsonReady',[data]);\n";
440
-		$retour .= "\t" . $jsCallback;
441
-		$parameters["jsCallback"] = $retour;
437
+		$retour.=$appendTo;
438
+		$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";
439
+		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
440
+		$retour.="\t".$jsCallback;
441
+		$parameters["jsCallback"]=$retour;
442 442
 		return $this->_ajax($method, $url, null, $parameters);
443 443
 	}
444 444
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	 * @param array $parameters
454 454
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null)
455 455
 	 */
456
-	public function jsonArray($maskSelector, $url, $method = 'get', $parameters = []) {
456
+	public function jsonArray($maskSelector, $url, $method='get', $parameters=[]) {
457 457
 		return $this->_jsonArray($maskSelector, $url, $method, $parameters);
458 458
 	}
459 459
 
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
 	 * @param array $parameters
469 469
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"rowClass"=>"_json","before"=>null)
470 470
 	 */
471
-	public function jsonArrayDeferred($maskSelector, $url, $method = 'get', $parameters = []) {
472
-		$parameters['immediatly'] = false;
471
+	public function jsonArrayDeferred($maskSelector, $url, $method='get', $parameters=[]) {
472
+		$parameters['immediatly']=false;
473 473
 		return $this->jsonArray($maskSelector, $url, $method, $parameters);
474 474
 	}
475 475
 
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 	 * @param array $parameters
486 486
 	 *        	default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true,"before"=>null,"listenerOn"=>false)
487 487
 	 */
488
-	public function jsonArrayOn($event, $element, $maskSelector, $url, $method = 'get', $parameters = array()) {
488
+	public function jsonArrayOn($event, $element, $maskSelector, $url, $method='get', $parameters=array()) {
489 489
 		$this->setDefaultParameters($parameters, [
490 490
 			'preventDefault' => true,
491 491
 			'stopPropagation' => true,
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
 	 * @param array $parameters
507 507
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
508 508
 	 */
509
-	public function getDeferred($url, $responseElement = "", $parameters = []) {
510
-		$parameters['immediatly'] = false;
509
+	public function getDeferred($url, $responseElement="", $parameters=[]) {
510
+		$parameters['immediatly']=false;
511 511
 		return $this->_get($url, $responseElement, $parameters);
512 512
 	}
513 513
 
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
 	 * @param array $parameters
527 527
 	 *        	default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false)
528 528
 	 */
529
-	public function getOn($event, $element, $url, $responseElement = "", $parameters = array()) {
530
-		$parameters['method'] = 'get';
529
+	public function getOn($event, $element, $url, $responseElement="", $parameters=array()) {
530
+		$parameters['method']='get';
531 531
 		return $this->ajaxOn($event, $element, $url, $responseElement, $parameters);
532 532
 	}
533 533
 
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	 * @param array $parameters
547 547
 	 *        	default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false)
548 548
 	 */
549
-	public function ajaxOn($event, $element, $url, $responseElement = '', $parameters = array()) {
549
+	public function ajaxOn($event, $element, $url, $responseElement='', $parameters=array()) {
550 550
 		$this->setDefaultParameters($parameters, [
551 551
 			'preventDefault' => true,
552 552
 			'stopPropagation' => true,
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	 * @param array $parameters
571 571
 	 *        	default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false)
572 572
 	 */
573
-	public function ajaxOnClick($element, $url, $responseElement = '', $parameters = array()) {
573
+	public function ajaxOnClick($element, $url, $responseElement='', $parameters=array()) {
574 574
 		return $this->ajaxOn('click', $element, $url, $responseElement, $parameters);
575 575
 	}
576 576
 
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 	 * @param array $parameters
588 588
 	 *        	default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false)
589 589
 	 */
590
-	public function getOnClick($element, $url, $responseElement = '', $parameters = array()) {
590
+	public function getOnClick($element, $url, $responseElement='', $parameters=array()) {
591 591
 		return $this->getOn('click', $element, $url, $responseElement, $parameters);
592 592
 	}
593 593
 
@@ -602,15 +602,15 @@  discard block
 block discarded – undo
602 602
 	 *        	default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null)
603 603
 	 * @return $this
604 604
 	 */
605
-	public function getHref($element, $responseElement = "", $parameters = array()) {
606
-		$parameters['attr'] = 'href';
605
+	public function getHref($element, $responseElement="", $parameters=array()) {
606
+		$parameters['attr']='href';
607 607
 		if (JString::isNull($responseElement)) {
608
-			$responseElement = '%$(self).attr("data-target")%';
608
+			$responseElement='%$(self).attr("data-target")%';
609 609
 		} else {
610
-			$responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%';
610
+			$responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%';
611 611
 		}
612
-		if (! isset($parameters['historize'])) {
613
-			$parameters['historize'] = true;
612
+		if (!isset($parameters['historize'])) {
613
+			$parameters['historize']=true;
614 614
 		}
615 615
 		return $this->getOnClick($element, "", $responseElement, $parameters);
616 616
 	}
@@ -626,21 +626,21 @@  discard block
 block discarded – undo
626 626
 	 *        	default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null)
627 627
 	 * @return $this
628 628
 	 */
629
-	public function postHref($element, $responseElement = "", $parameters = array()) {
630
-		$parameters['attr'] = 'href';
629
+	public function postHref($element, $responseElement="", $parameters=array()) {
630
+		$parameters['attr']='href';
631 631
 		if (JString::isNull($responseElement)) {
632
-			$responseElement = '%$(this).attr("data-target")%';
632
+			$responseElement='%$(this).attr("data-target")%';
633 633
 		} else {
634
-			$responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%';
634
+			$responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%';
635 635
 		}
636
-		if (! isset($parameters['historize'])) {
637
-			$parameters['historize'] = true;
636
+		if (!isset($parameters['historize'])) {
637
+			$parameters['historize']=true;
638 638
 		}
639 639
 		return $this->postOnClick($element, '', '{}', $responseElement, $parameters);
640 640
 	}
641 641
 
642
-	private function _post($url, $params = '{}', $responseElement = '', $parameters = []) {
643
-		$parameters['params'] = $params;
642
+	private function _post($url, $params='{}', $responseElement='', $parameters=[]) {
643
+		$parameters['params']=$params;
644 644
 		return $this->_ajax('POST', $url, $responseElement, $parameters);
645 645
 	}
646 646
 
@@ -656,8 +656,8 @@  discard block
 block discarded – undo
656 656
 	 * @param array $parameters
657 657
 	 *        	default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
658 658
 	 */
659
-	public function post($url, $params = "{}", $responseElement = "", $parameters = []) {
660
-		$parameters['immediatly'] = true;
659
+	public function post($url, $params="{}", $responseElement="", $parameters=[]) {
660
+		$parameters['immediatly']=true;
661 661
 		return $this->_post($url, $params, $responseElement, $parameters);
662 662
 	}
663 663
 
@@ -674,8 +674,8 @@  discard block
 block discarded – undo
674 674
 	 * @param array $parameters
675 675
 	 *        	default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
676 676
 	 */
677
-	public function postDeferred($url, $params = "{}", $responseElement = "", $parameters = []) {
678
-		$parameters['immediatly'] = false;
677
+	public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) {
678
+		$parameters['immediatly']=false;
679 679
 		return $this->_post($url, $params, $responseElement, $parameters);
680 680
 	}
681 681
 
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
 	 * @param array $parameters
695 695
 	 *        	default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false)
696 696
 	 */
697
-	public function postOn($event, $element, $url, $params = "{}", $responseElement = "", $parameters = array()) {
698
-		$parameters['method'] = 'post';
699
-		$parameters['params'] = $params;
697
+	public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
698
+		$parameters['method']='post';
699
+		$parameters['params']=$params;
700 700
 		return $this->ajaxOn($event, $element, $url, $responseElement, $parameters);
701 701
 	}
702 702
 
@@ -714,66 +714,66 @@  discard block
 block discarded – undo
714 714
 	 * @param array $parameters
715 715
 	 *        	default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"before"=>null,"listenerOn"=>false)
716 716
 	 */
717
-	public function postOnClick($element, $url, $params = '{}', $responseElement = '', $parameters = array()) {
717
+	public function postOnClick($element, $url, $params='{}', $responseElement='', $parameters=array()) {
718 718
 		return $this->postOn('click', $element, $url, $params, $responseElement, $parameters);
719 719
 	}
720 720
 
721
-	private function _postForm($url, $form, $responseElement, $parameters = []) {
721
+	private function _postForm($url, $form, $responseElement, $parameters=[]) {
722 722
 		if (isset($this->params['ajax'])) {
723 723
 			extract($this->params['ajax']);
724 724
 		}
725
-		$params = '{}';
726
-		$validation = false;
725
+		$params='{}';
726
+		$validation=false;
727 727
 		\extract($parameters);
728
-		$async = ($async) ? 'true' : 'false';
729
-		$jsCallback = isset($jsCallback) ? $jsCallback : "";
730
-		$retour = $this->_getAjaxUrl($url, $attr);
731
-		$retour .= "\n$('#" . $form . "').trigger('ajaxSubmit');";
732
-		if (! isset($contentType) || $contentType != 'false') {
733
-			$retour .= "\nvar params=$('#" . $form . "').serialize();\n";
728
+		$async=($async) ? 'true' : 'false';
729
+		$jsCallback=isset($jsCallback) ? $jsCallback : "";
730
+		$retour=$this->_getAjaxUrl($url, $attr);
731
+		$retour.="\n$('#".$form."').trigger('ajaxSubmit');";
732
+		if (!isset($contentType) || $contentType!='false') {
733
+			$retour.="\nvar params=$('#".$form."').serialize();\n";
734 734
 			if (isset($params)) {
735
-				$retour .= "params+='&'+" . self::_correctParams($params) . ";\n";
735
+				$retour.="params+='&'+".self::_correctParams($params).";\n";
736 736
 			}
737 737
 		} else {
738
-			$retour .= "\nvar params=new FormData($('#" . $form . "')[0]);\n";
738
+			$retour.="\nvar params=new FormData($('#".$form."')[0]);\n";
739 739
 		}
740
-		$responseElement = $this->_getResponseElement($responseElement);
741
-		$retour .= "var self=this;\n";
742
-		$before = isset($before) ? $before : "";
743
-		$retour .= $before;
744
-		if ($hasLoader === true) {
740
+		$responseElement=$this->_getResponseElement($responseElement);
741
+		$retour.="var self=this;\n";
742
+		$before=isset($before) ? $before : "";
743
+		$retour.=$before;
744
+		if ($hasLoader===true) {
745 745
 			$this->addLoading($retour, $responseElement, $ajaxLoader);
746
-		} elseif ($hasLoader === 'response') {
746
+		} elseif ($hasLoader==='response') {
747 747
 			$this->addResponseLoading($retour, $responseElement, $ajaxLoader);
748
-		} elseif ($hasLoader === 'internal') {
749
-			$retour .= "\n$(this).addClass('loading');";
748
+		} elseif ($hasLoader==='internal') {
749
+			$retour.="\n$(this).addClass('loading');";
750 750
 		}
751
-		$ajaxParameters = [
751
+		$ajaxParameters=[
752 752
 			"url" => "url",
753 753
 			"method" => "'POST'",
754 754
 			"data" => "params",
755 755
 			"async" => $async
756 756
 		];
757 757
 		if (isset($headers)) {
758
-			$ajaxParameters["headers"] = $headers;
758
+			$ajaxParameters["headers"]=$headers;
759 759
 		}
760 760
 		if (isset($partial)) {
761
-			$ajaxParameters["xhr"] = "xhrProvider";
762
-			$retour .= "var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;" . $partial . ";}; };";
761
+			$ajaxParameters["xhr"]="xhrProvider";
762
+			$retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };";
763 763
 		}
764 764
 		$this->createAjaxParameters($ajaxParameters, $parameters);
765
-		$retour .= "$.ajax({" . $this->implodeAjaxParameters($ajaxParameters) . "}).done(function( data ) {\n";
766
-		$retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader) . "});\n";
765
+		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n";
766
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader)."});\n";
767 767
 
768 768
 		if ($validation) {
769
-			$retour = "$('#" . $form . "').validate({submitHandler: function(form) {
770
-			" . $retour . "
769
+			$retour="$('#".$form."').validate({submitHandler: function(form) {
770
+			" . $retour."
771 771
 			}});\n";
772
-			$retour .= "$('#" . $form . "').submit();\n";
772
+			$retour.="$('#".$form."').submit();\n";
773 773
 		}
774
-		$retour = $this->_addJsCondition($jsCondition, $retour);
774
+		$retour=$this->_addJsCondition($jsCondition, $retour);
775 775
 		if ($immediatly)
776
-			$this->jquery_code_for_compile[] = $retour;
776
+			$this->jquery_code_for_compile[]=$retour;
777 777
 		return $retour;
778 778
 	}
779 779
 
@@ -789,8 +789,8 @@  discard block
 block discarded – undo
789 789
 	 * @param array $parameters
790 790
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
791 791
 	 */
792
-	public function postForm($url, $form, $responseElement, $parameters = []) {
793
-		$parameters['immediatly'] = true;
792
+	public function postForm($url, $form, $responseElement, $parameters=[]) {
793
+		$parameters['immediatly']=true;
794 794
 		return $this->_postForm($url, $form, $responseElement, $parameters);
795 795
 	}
796 796
 
@@ -807,8 +807,8 @@  discard block
 block discarded – undo
807 807
 	 * @param array $parameters
808 808
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
809 809
 	 */
810
-	public function postFormDeferred($url, $form, $responseElement, $parameters = []) {
811
-		$parameters['immediatly'] = false;
810
+	public function postFormDeferred($url, $form, $responseElement, $parameters=[]) {
811
+		$parameters['immediatly']=false;
812 812
 		return $this->_postForm($url, $form, $responseElement, $parameters);
813 813
 	}
814 814
 
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 	 * @param array $parameters
826 826
 	 *        	default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false)
827 827
 	 */
828
-	public function postFormOn($event, $element, $url, $form, $responseElement = "", $parameters = array()) {
828
+	public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) {
829 829
 		$this->setDefaultParameters($parameters, [
830 830
 			'preventDefault' => true,
831 831
 			'stopPropagation' => true,
@@ -847,11 +847,11 @@  discard block
 block discarded – undo
847 847
 	 * @param array $parameters
848 848
 	 *        	default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false)
849 849
 	 */
850
-	public function postFormOnClick($element, $url, $form, $responseElement = "", $parameters = array()) {
850
+	public function postFormOnClick($element, $url, $form, $responseElement="", $parameters=array()) {
851 851
 		return $this->postFormOn("click", $element, $url, $form, $responseElement, $parameters);
852 852
 	}
853 853
 
854
-	public function addCsrf($name = 'csrf-token') {
854
+	public function addCsrf($name='csrf-token') {
855 855
 		return "
856 856
 		$.ajaxSetup({
857 857
 			beforeSend: function(xhr, settings) {
Please login to merge, or discard this patch.