Passed
Push — master ( 160666...0168a5 )
by Jean-Christophe
02:09
created
Ajax/common/traits/JsUtilsAjaxTrait.php 1 patch
Spacing   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -15,76 +15,76 @@  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
 		} elseif (\is_string($hasLoader)) {
48 48
 			$this->addLoading($retour, $hasLoader, $ajaxLoader);
49 49
 		}
50
-		$ajaxParameters = [
50
+		$ajaxParameters=[
51 51
 			"url" => "url",
52
-			"method" => "'" . \strtoupper($method) . "'"
52
+			"method" => "'".\strtoupper($method)."'"
53 53
 		];
54 54
 
55
-		$ajaxParameters["async"] = ($async ? "true" : "false");
55
+		$ajaxParameters["async"]=($async ? "true" : "false");
56 56
 
57 57
 		if (isset($params)) {
58
-			$ajaxParameters["data"] = self::_correctParams($params, $parameters);
58
+			$ajaxParameters["data"]=self::_correctParams($params, $parameters);
59 59
 		}
60 60
 		if (isset($headers)) {
61
-			$ajaxParameters["headers"] = $headers;
61
+			$ajaxParameters["headers"]=$headers;
62 62
 		}
63 63
 		if ($csrf) {
64
-			$csrf = (is_string($csrf)) ? $csrf : 'csrf-token';
65
-			$parameters["beforeSend"] = "jqXHR.setRequestHeader('{$csrf}', $('meta[name=\"{$csrf}\"]').attr('content'));";
64
+			$csrf=(is_string($csrf)) ? $csrf : 'csrf-token';
65
+			$parameters["beforeSend"]="jqXHR.setRequestHeader('{$csrf}', $('meta[name=\"{$csrf}\"]').attr('content'));";
66 66
 		}
67 67
 		if (isset($partial)) {
68
-			$ajaxParameters["xhr"] = "xhrProvider";
69
-			$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
+			$ajaxParameters["xhr"]="xhrProvider";
69
+			$retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };";
70 70
 		}
71 71
 		$this->createAjaxParameters($ajaxParameters, $parameters);
72
-		$retour .= "$.ajax({" . $this->implodeAjaxParameters($ajaxParameters) . "}).done(function( data, textStatus, jqXHR ) {\n";
73
-		$retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, ($historize ? $originalSelector : null)) . "})";
72
+		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n";
73
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, ($historize ? $originalSelector : null))."})";
74 74
 		if (isset($error)) {
75
-			$retour .= '.fail(function( jqXHR, textStatus, errorThrown ){' . $error . '})';
75
+			$retour.='.fail(function( jqXHR, textStatus, errorThrown ){'.$error.'})';
76 76
 		}
77
-		$retour .= '.always(function( dataOrjqXHR, textStatus, jqXHROrerrorThrown ) {' . ($always ?? '') . $this->removeLoader($hasLoader) . '})';
78
-		$retour .= ";\n";
79
-		$retour = $this->_addJsCondition($jsCondition, $retour);
77
+		$retour.='.always(function( dataOrjqXHR, textStatus, jqXHROrerrorThrown ) {'.($always ?? '').$this->removeLoader($hasLoader).'})';
78
+		$retour.=";\n";
79
+		$retour=$this->_addJsCondition($jsCondition, $retour);
80 80
 		if ($immediatly) {
81
-			$this->jquery_code_for_compile[] = $retour;
81
+			$this->jquery_code_for_compile[]=$retour;
82 82
 		}
83 83
 		return $retour;
84 84
 	}
85 85
 
86 86
 	protected function createAjaxParameters(&$original, $parameters) {
87
-		$validParameters = [
87
+		$validParameters=[
88 88
 			"contentType" => "%value%",
89 89
 			"dataType" => "'%value%'",
90 90
 			"beforeSend" => "function(jqXHR,settings){%value%}",
@@ -93,21 +93,21 @@  discard block
 block discarded – undo
93 93
 		];
94 94
 		foreach ($validParameters as $param => $mask) {
95 95
 			if (isset($parameters[$param])) {
96
-				$original[$param] = \str_replace("%value%", $parameters[$param], $mask);
96
+				$original[$param]=\str_replace("%value%", $parameters[$param], $mask);
97 97
 			}
98 98
 		}
99 99
 	}
100 100
 
101 101
 	protected function implodeAjaxParameters($ajaxParameters) {
102
-		$s = '';
102
+		$s='';
103 103
 		foreach ($ajaxParameters as $k => $v) {
104
-			if ($s !== '') {
105
-				$s .= ',';
104
+			if ($s!=='') {
105
+				$s.=',';
106 106
 			}
107 107
 			if (is_array($v)) {
108
-				$s .= "'{$k}':{" . self::implodeAjaxParameters($v) . "}";
108
+				$s.="'{$k}':{".self::implodeAjaxParameters($v)."}";
109 109
 			} else {
110
-				$s .= "'{$k}':{$v}";
110
+				$s.="'{$k}':{$v}";
111 111
 			}
112 112
 		}
113 113
 		return $s;
@@ -115,29 +115,29 @@  discard block
 block discarded – undo
115 115
 
116 116
 	protected function _addJsCondition($jsCondition, $jsSource) {
117 117
 		if (isset($jsCondition)) {
118
-			return "if(" . $jsCondition . "){\n" . $jsSource . "\n}";
118
+			return "if(".$jsCondition."){\n".$jsSource."\n}";
119 119
 		}
120 120
 		return $jsSource;
121 121
 	}
122 122
 
123 123
 	protected function _getAjaxUrl($url, $attr) {
124
-		$url = $this->_correctAjaxUrl($url);
125
-		$retour = "url='" . $url . "';";
126
-		$slash = "/";
127
-		if (JString::endswith($url, "/") === true) {
128
-			$slash = "";
124
+		$url=$this->_correctAjaxUrl($url);
125
+		$retour="url='".$url."';";
126
+		$slash="/";
127
+		if (JString::endswith($url, "/")===true) {
128
+			$slash="";
129 129
 		}
130 130
 
131 131
 		if (JString::isNotNull($attr)) {
132
-			if ($attr === "value") {
133
-				$retour .= "url=url+'" . $slash . "'+$(this).val();\n";
134
-			} elseif ($attr === "html") {
135
-				$retour .= "url=url+'" . $slash . "'+$(this).html();\n";
136
-			} elseif (\substr($attr, 0, 3) === "js:") {
137
-				$retour .= "url=url+'" . $slash . "'+" . \substr($attr, 3) . ";\n";
138
-			} elseif ($attr !== null && $attr !== "") {
139
-				$retour .= "let elmUrl=$(this).attr('" . $attr . "')||'';";
140
-				$retour .= "url=(!/^((http|https|ftp):\/\/)/.test(elmUrl))?url+'" . $slash . "'+elmUrl:elmUrl;\n";
132
+			if ($attr==="value") {
133
+				$retour.="url=url+'".$slash."'+$(this).val();\n";
134
+			} elseif ($attr==="html") {
135
+				$retour.="url=url+'".$slash."'+$(this).html();\n";
136
+			} elseif (\substr($attr, 0, 3)==="js:") {
137
+				$retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n";
138
+			} elseif ($attr!==null && $attr!=="") {
139
+				$retour.="let elmUrl=$(this).attr('".$attr."')||'';";
140
+				$retour.="url=(!/^((http|https|ftp):\/\/)/.test(elmUrl))?url+'".$slash."'+elmUrl:elmUrl;\n";
141 141
 			}
142 142
 		}
143 143
 		return $retour;
@@ -147,44 +147,44 @@  discard block
 block discarded – undo
147 147
 		return "window.onpopstate = function(e){if(e.state){var target=e.state.jqueryDone;$(e.state.selector)[target](e.state.html);}};";
148 148
 	}
149 149
 
150
-	protected function autoActiveLinks($previousURL = "window.location.href") {
151
-		$result = "\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}";
152
-		$result .= "\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;";
150
+	protected function autoActiveLinks($previousURL="window.location.href") {
151
+		$result="\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}";
152
+		$result.="\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;";
153 153
 		return $result;
154 154
 	}
155 155
 
156
-	protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $history = null) {
157
-		$retour = "";
158
-		$call = null;
156
+	protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $history=null) {
157
+		$retour="";
158
+		$call=null;
159 159
 		if (JString::isNotNull($responseElement)) {
160 160
 			if (isset($ajaxTransition)) {
161
-				$call = $this->setAjaxDataCall($ajaxTransition);
161
+				$call=$this->setAjaxDataCall($ajaxTransition);
162 162
 			} elseif (isset($this->ajaxTransition)) {
163
-				$call = $this->ajaxTransition;
163
+				$call=$this->ajaxTransition;
164 164
 			}
165 165
 			if (\is_callable($call))
166
-				$retour = "\t" . $call($responseElement, $jqueryDone) . ";\n";
166
+				$retour="\t".$call($responseElement, $jqueryDone).";\n";
167 167
 			else
168
-				$retour = "\t{$responseElement}.{$jqueryDone}( data );\n";
168
+				$retour="\t{$responseElement}.{$jqueryDone}( data );\n";
169 169
 		}
170 170
 		if (isset($history)) {
171 171
 			if ($this->params["autoActiveLinks"]) {
172
-				$retour .= $this->autoActiveLinks("url");
172
+				$retour.=$this->autoActiveLinks("url");
173 173
 			}
174
-			$retour .= "\nwindow.history.pushState({'html':data,'selector':" . Javascript::prep_value($history) . ",'jqueryDone':'{$jqueryDone}'},'', url);";
174
+			$retour.="\nwindow.history.pushState({'html':data,'selector':".Javascript::prep_value($history).",'jqueryDone':'{$jqueryDone}'},'', url);";
175 175
 		}
176
-		$retour .= "\t" . $jsCallback . "\n";
176
+		$retour.="\t".$jsCallback."\n";
177 177
 		return $retour;
178 178
 	}
179 179
 
180 180
 	protected function removeLoader($hasLoader) {
181
-		if ($hasLoader === true) {
181
+		if ($hasLoader===true) {
182 182
 			return "\n$('body').find('.ajax-loader').remove();";
183 183
 		}
184
-		if ($hasLoader === 'internal') {
184
+		if ($hasLoader==='internal') {
185 185
 			return "\n$(self).removeClass('loading');";
186 186
 		}
187
-		if ($hasLoader === 'internal-x') {
187
+		if ($hasLoader==='internal-x') {
188 188
 			return "\n$(self).children('.ajax-loader').remove();";
189 189
 		}
190 190
 		return "\n$('body').find('.loading').removeClass('loading');";
@@ -192,71 +192,71 @@  discard block
 block discarded – undo
192 192
 
193 193
 	protected function _getResponseElement($responseElement) {
194 194
 		if (JString::isNotNull($responseElement)) {
195
-			$responseElement = Javascript::prep_jquery_selector($responseElement);
195
+			$responseElement=Javascript::prep_jquery_selector($responseElement);
196 196
 		}
197 197
 		return $responseElement;
198 198
 	}
199 199
 
200 200
 	protected function _getFormElement($formElement) {
201 201
 		if (JString::isNotNull($formElement)) {
202
-			$formElement = Javascript::prep_value($formElement);
202
+			$formElement=Javascript::prep_value($formElement);
203 203
 		}
204 204
 		return $formElement;
205 205
 	}
206 206
 
207 207
 	protected function _correctAjaxUrl($url) {
208
-		if ($url !== "/" && JString::endsWith($url, "/") === true)
209
-			$url = substr($url, 0, strlen($url) - 1);
210
-		if (strncmp($url, 'http://', 7) != 0 && strncmp($url, 'https://', 8) != 0) {
211
-			$url = $this->getUrl($url);
208
+		if ($url!=="/" && JString::endsWith($url, "/")===true)
209
+			$url=substr($url, 0, strlen($url)-1);
210
+		if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) {
211
+			$url=$this->getUrl($url);
212 212
 		}
213 213
 		return $url;
214 214
 	}
215 215
 
216
-	public static function _correctParams($params, $ajaxParameters = []) {
216
+	public static function _correctParams($params, $ajaxParameters=[]) {
217 217
 		if (JString::isNull($params)) {
218 218
 			return "";
219 219
 		}
220 220
 		if (\preg_match("@^\{.*?\}$@", $params)) {
221
-			if (! isset($ajaxParameters['contentType']) || ! JString::contains($ajaxParameters['contentType'], 'json')) {
222
-				return '$.param(' . $params . ')';
221
+			if (!isset($ajaxParameters['contentType']) || !JString::contains($ajaxParameters['contentType'], 'json')) {
222
+				return '$.param('.$params.')';
223 223
 			} else {
224
-				return 'JSON.stringify(' . $params . ')';
224
+				return 'JSON.stringify('.$params.')';
225 225
 			}
226 226
 		}
227 227
 		return $params;
228 228
 	}
229 229
 
230 230
 	public static function _implodeParams($parameters) {
231
-		$allParameters = [];
231
+		$allParameters=[];
232 232
 		foreach ($parameters as $params) {
233 233
 			if (isset($params))
234
-				$allParameters[] = self::_correctParams($params);
234
+				$allParameters[]=self::_correctParams($params);
235 235
 		}
236 236
 		return \implode("+'&'+", $allParameters);
237 237
 	}
238 238
 
239
-	protected function addLoading(&$retour, $responseElement, $ajaxLoader = null) {
240
-		if (! isset($ajaxLoader)) {
241
-			$ajaxLoader = $this->ajaxLoader;
239
+	protected function addLoading(&$retour, $responseElement, $ajaxLoader=null) {
240
+		if (!isset($ajaxLoader)) {
241
+			$ajaxLoader=$this->ajaxLoader;
242 242
 		}
243
-		$loading_notifier = '<div class="ajax-loader ui active inverted dimmer">' . $ajaxLoader . '</div>';
244
-		$retour .= "\t\t{$responseElement}.append('{$loading_notifier}');\n";
243
+		$loading_notifier='<div class="ajax-loader ui active inverted dimmer">'.$ajaxLoader.'</div>';
244
+		$retour.="\t\t{$responseElement}.append('{$loading_notifier}');\n";
245 245
 	}
246 246
 
247
-	protected function addResponseLoading(&$retour, $responseElement, $ajaxLoader = null) {
248
-		if (! isset($ajaxLoader)) {
249
-			$ajaxLoader = $this->ajaxLoader;
247
+	protected function addResponseLoading(&$retour, $responseElement, $ajaxLoader=null) {
248
+		if (!isset($ajaxLoader)) {
249
+			$ajaxLoader=$this->ajaxLoader;
250 250
 		}
251
-		$loading_notifier = '<div class="ajax-loader">' . $ajaxLoader . '</div>';
252
-		$retour .= "{$responseElement}.empty();\n";
253
-		$retour .= "\t\t{$responseElement}.prepend('{$loading_notifier}');\n";
251
+		$loading_notifier='<div class="ajax-loader">'.$ajaxLoader.'</div>';
252
+		$retour.="{$responseElement}.empty();\n";
253
+		$retour.="\t\t{$responseElement}.prepend('{$loading_notifier}');\n";
254 254
 	}
255 255
 
256 256
 	protected function setAjaxDataCall($params) {
257
-		$result = null;
258
-		if (! \is_callable($params)) {
259
-			$result = function ($responseElement, $jqueryDone = 'html') use ($params) {
257
+		$result=null;
258
+		if (!\is_callable($params)) {
259
+			$result=function($responseElement, $jqueryDone='html') use ($params) {
260 260
 				return AjaxTransition::{$params}($responseElement, $jqueryDone);
261 261
 			};
262 262
 		}
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 
266 266
 	protected function setDefaultParameters(&$parameters, $default) {
267 267
 		foreach ($default as $k => $v) {
268
-			if (! isset($parameters[$k]))
269
-				$parameters[$k] = $v;
268
+			if (!isset($parameters[$k]))
269
+				$parameters[$k]=$v;
270 270
 		}
271 271
 	}
272 272
 
273 273
 	public function setAjaxLoader($loader) {
274
-		$this->ajaxLoader = $loader;
274
+		$this->ajaxLoader=$loader;
275 275
 	}
276 276
 
277 277
 	/**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @param string $responseElement
283 283
 	 *        	selector of the HTML element displaying the answer
284 284
 	 */
285
-	private function _get($url, $responseElement = '', $parameters = []) {
285
+	private function _get($url, $responseElement='', $parameters=[]) {
286 286
 		return $this->_ajax('get', $url, $responseElement, $parameters);
287 287
 	}
288 288
 
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 	 * @param array $parameters
297 297
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
298 298
 	 */
299
-	public function get($url, $responseElement = '', $parameters = []) {
300
-		$parameters['immediatly'] = true;
299
+	public function get($url, $responseElement='', $parameters=[]) {
300
+		$parameters['immediatly']=true;
301 301
 		return $this->_get($url, $responseElement, $parameters);
302 302
 	}
303 303
 
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 	 * @param array $parameters
314 314
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
315 315
 	 */
316
-	public function ajax($method, $url, $responseElement = '', $parameters = []) {
317
-		$parameters['immediatly'] = true;
316
+	public function ajax($method, $url, $responseElement='', $parameters=[]) {
317
+		$parameters['immediatly']=true;
318 318
 		return $this->_ajax($method, $url, $responseElement, $parameters);
319 319
 	}
320 320
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 	 *        	$immediatly
337 337
 	 * @return string
338 338
 	 */
339
-	public function ajaxInterval($method, $url, $interval, $globalName = null, $responseElement = '', $parameters = [], $immediatly = true) {
339
+	public function ajaxInterval($method, $url, $interval, $globalName=null, $responseElement='', $parameters=[], $immediatly=true) {
340 340
 		return $this->interval($this->ajaxDeferred($method, $url, $responseElement, $parameters), $interval, $globalName, $immediatly);
341 341
 	}
342 342
 
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
 	 * @param array $parameters
353 353
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
354 354
 	 */
355
-	public function ajaxDeferred($method, $url, $responseElement = '', $parameters = []) {
356
-		$parameters['immediatly'] = false;
355
+	public function ajaxDeferred($method, $url, $responseElement='', $parameters=[]) {
356
+		$parameters['immediatly']=false;
357 357
 		return $this->_ajax($method, $url, $responseElement, $parameters);
358 358
 	}
359 359
 
@@ -367,15 +367,15 @@  discard block
 block discarded – undo
367 367
 	 * @param array $parameters
368 368
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null)
369 369
 	 */
370
-	private function _json($url, $method = "get", $parameters = []) {
371
-		$parameters = \array_merge($parameters, [
370
+	private function _json($url, $method="get", $parameters=[]) {
371
+		$parameters=\array_merge($parameters, [
372 372
 			"hasLoader" => false
373 373
 		]);
374
-		$jsCallback = isset($parameters['jsCallback']) ? $parameters['jsCallback'] : "";
375
-		$context = isset($parameters['context']) ? $parameters['context'] : "document";
376
-		$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";
377
-		$retour .= "\t$(document).trigger('jsonReady',[data]);\n";
378
-		$parameters["jsCallback"] = $retour;
374
+		$jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : "";
375
+		$context=isset($parameters['context']) ? $parameters['context'] : "document";
376
+		$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";
377
+		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
378
+		$parameters["jsCallback"]=$retour;
379 379
 		return $this->_ajax($method, $url, null, $parameters);
380 380
 	}
381 381
 
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	 * @param array $parameters
390 390
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null)
391 391
 	 */
392
-	public function json($url, $method = "get", $parameters = []) {
392
+	public function json($url, $method="get", $parameters=[]) {
393 393
 		return $this->_json($url, $method, $parameters);
394 394
 	}
395 395
 
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @param array $parameters
406 406
 	 *        	default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true,"before"=>null,"listenerOn"=>false)
407 407
 	 */
408
-	public function jsonOn($event, $element, $url, $method = 'get', $parameters = array()) {
408
+	public function jsonOn($event, $element, $url, $method='get', $parameters=array()) {
409 409
 		$this->setDefaultParameters($parameters, [
410 410
 			'preventDefault' => true,
411 411
 			'stopPropagation' => true,
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
 	 * @param array $parameters
426 426
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null)
427 427
 	 */
428
-	public function jsonDeferred($url, $method = 'get', $parameters = []) {
429
-		$parameters['immediatly'] = false;
428
+	public function jsonDeferred($url, $method='get', $parameters=[]) {
429
+		$parameters['immediatly']=false;
430 430
 		return $this->_json($url, $method, $parameters);
431 431
 	}
432 432
 
@@ -441,29 +441,29 @@  discard block
 block discarded – undo
441 441
 	 * @param array $parameters
442 442
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null)
443 443
 	 */
444
-	private function _jsonArray($maskSelector, $url, $method = 'get', $parameters = []) {
445
-		$parameters = \array_merge($parameters, [
444
+	private function _jsonArray($maskSelector, $url, $method='get', $parameters=[]) {
445
+		$parameters=\array_merge($parameters, [
446 446
 			"hasLoader" => false
447 447
 		]);
448
-		$rowClass = isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json";
449
-		$jsCallback = isset($parameters['jsCallback']) ? $parameters['jsCallback'] : "";
450
-		$context = isset($parameters['context']) ? $parameters['context'] : null;
451
-		if ($context === null) {
452
-			$parent = "$('" . $maskSelector . "').parent()";
453
-			$newElm = "$('#'+newId)";
448
+		$rowClass=isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json";
449
+		$jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : "";
450
+		$context=isset($parameters['context']) ? $parameters['context'] : null;
451
+		if ($context===null) {
452
+			$parent="$('".$maskSelector."').parent()";
453
+			$newElm="$('#'+newId)";
454 454
 		} else {
455
-			$parent = $context;
456
-			$newElm = $context . ".find('#'+newId)";
455
+			$parent=$context;
456
+			$newElm=$context.".find('#'+newId)";
457 457
 		}
458
-		$appendTo = "\t\tnewElm.appendTo(" . $parent . ");\n";
459
-		$retour = $parent . ".find('.{$rowClass}').remove();";
460
-		$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();
458
+		$appendTo="\t\tnewElm.appendTo(".$parent.");\n";
459
+		$retour=$parent.".find('.{$rowClass}').remove();";
460
+		$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();
461 461
 		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";
462
-		$retour .= $appendTo;
463
-		$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";
464
-		$retour .= "\t$(document).trigger('jsonReady',[data]);\n";
465
-		$retour .= "\t" . $jsCallback;
466
-		$parameters["jsCallback"] = $retour;
462
+		$retour.=$appendTo;
463
+		$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";
464
+		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
465
+		$retour.="\t".$jsCallback;
466
+		$parameters["jsCallback"]=$retour;
467 467
 		return $this->_ajax($method, $url, null, $parameters);
468 468
 	}
469 469
 
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	 * @param array $parameters
479 479
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null)
480 480
 	 */
481
-	public function jsonArray($maskSelector, $url, $method = 'get', $parameters = []) {
481
+	public function jsonArray($maskSelector, $url, $method='get', $parameters=[]) {
482 482
 		return $this->_jsonArray($maskSelector, $url, $method, $parameters);
483 483
 	}
484 484
 
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 	 * @param array $parameters
494 494
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"rowClass"=>"_json","before"=>null)
495 495
 	 */
496
-	public function jsonArrayDeferred($maskSelector, $url, $method = 'get', $parameters = []) {
497
-		$parameters['immediatly'] = false;
496
+	public function jsonArrayDeferred($maskSelector, $url, $method='get', $parameters=[]) {
497
+		$parameters['immediatly']=false;
498 498
 		return $this->jsonArray($maskSelector, $url, $method, $parameters);
499 499
 	}
500 500
 
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 	 * @param array $parameters
511 511
 	 *        	default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true,"before"=>null,"listenerOn"=>false)
512 512
 	 */
513
-	public function jsonArrayOn($event, $element, $maskSelector, $url, $method = 'get', $parameters = array()) {
513
+	public function jsonArrayOn($event, $element, $maskSelector, $url, $method='get', $parameters=array()) {
514 514
 		$this->setDefaultParameters($parameters, [
515 515
 			'preventDefault' => true,
516 516
 			'stopPropagation' => true,
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 	 * @param array $parameters
532 532
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
533 533
 	 */
534
-	public function getDeferred($url, $responseElement = "", $parameters = []) {
535
-		$parameters['immediatly'] = false;
534
+	public function getDeferred($url, $responseElement="", $parameters=[]) {
535
+		$parameters['immediatly']=false;
536 536
 		return $this->_get($url, $responseElement, $parameters);
537 537
 	}
538 538
 
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
 	 * @param array $parameters
552 552
 	 *        	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)
553 553
 	 */
554
-	public function getOn($event, $element, $url, $responseElement = "", $parameters = array()) {
555
-		$parameters['method'] = 'get';
554
+	public function getOn($event, $element, $url, $responseElement="", $parameters=array()) {
555
+		$parameters['method']='get';
556 556
 		return $this->ajaxOn($event, $element, $url, $responseElement, $parameters);
557 557
 	}
558 558
 
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 	 * @param array $parameters
572 572
 	 *        	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)
573 573
 	 */
574
-	public function ajaxOn($event, $element, $url, $responseElement = '', $parameters = array()) {
574
+	public function ajaxOn($event, $element, $url, $responseElement='', $parameters=array()) {
575 575
 		$this->setDefaultParameters($parameters, [
576 576
 			'preventDefault' => true,
577 577
 			'stopPropagation' => true,
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 	 * @param array $parameters
596 596
 	 *        	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)
597 597
 	 */
598
-	public function ajaxOnClick($element, $url, $responseElement = '', $parameters = array()) {
598
+	public function ajaxOnClick($element, $url, $responseElement='', $parameters=array()) {
599 599
 		return $this->ajaxOn('click', $element, $url, $responseElement, $parameters);
600 600
 	}
601 601
 
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	 * @param array $parameters
613 613
 	 *        	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)
614 614
 	 */
615
-	public function getOnClick($element, $url, $responseElement = '', $parameters = array()) {
615
+	public function getOnClick($element, $url, $responseElement='', $parameters=array()) {
616 616
 		return $this->getOn('click', $element, $url, $responseElement, $parameters);
617 617
 	}
618 618
 
@@ -627,18 +627,18 @@  discard block
 block discarded – undo
627 627
 	 *        	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,"listenerOn"=>false)
628 628
 	 * @return $this
629 629
 	 */
630
-	public function getHref($element, $responseElement = "", $parameters = array()) {
631
-		$parameters['attr'] = 'href';
630
+	public function getHref($element, $responseElement="", $parameters=array()) {
631
+		$parameters['attr']='href';
632 632
 		if (JString::isNull($responseElement)) {
633
-			$responseElement = '%$(self).attr("data-target")%';
633
+			$responseElement='%$(self).attr("data-target")%';
634 634
 		} else {
635
-			$responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%';
635
+			$responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%';
636 636
 		}
637
-		if (! isset($parameters['historize'])) {
638
-			$parameters['historize'] = true;
637
+		if (!isset($parameters['historize'])) {
638
+			$parameters['historize']=true;
639 639
 		}
640
-		if (! isset($parameters['jsCallback'])) {
641
-			$parameters['jsCallback'] = 'var event = jQuery.Event( "getHref" );event.url = url;$(self).trigger(event);';
640
+		if (!isset($parameters['jsCallback'])) {
641
+			$parameters['jsCallback']='var event = jQuery.Event( "getHref" );event.url = url;$(self).trigger(event);';
642 642
 		}
643 643
 		return $this->getOnClick($element, "", $responseElement, $parameters);
644 644
 	}
@@ -654,15 +654,15 @@  discard block
 block discarded – undo
654 654
 	 *        	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,"listenerOn"=>false)
655 655
 	 * @return $this
656 656
 	 */
657
-	public function postHref($element, $responseElement = "", $parameters = array()) {
658
-		$parameters['attr'] = 'href';
657
+	public function postHref($element, $responseElement="", $parameters=array()) {
658
+		$parameters['attr']='href';
659 659
 		if (JString::isNull($responseElement)) {
660
-			$responseElement = '%$(this).attr("data-target")%';
660
+			$responseElement='%$(this).attr("data-target")%';
661 661
 		} else {
662
-			$responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%';
662
+			$responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%';
663 663
 		}
664
-		if (! isset($parameters['historize'])) {
665
-			$parameters['historize'] = true;
664
+		if (!isset($parameters['historize'])) {
665
+			$parameters['historize']=true;
666 666
 		}
667 667
 		return $this->postOnClick($element, '', '{}', $responseElement, $parameters);
668 668
 	}
@@ -678,29 +678,29 @@  discard block
 block discarded – undo
678 678
 	 *        	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,"listenerOn"=>false)
679 679
 	 * @return $this
680 680
 	 */
681
-	public function postFormAction($element, $responseElement = "", $parameters = array()) {
682
-		$parameters['attr'] = 'action';
681
+	public function postFormAction($element, $responseElement="", $parameters=array()) {
682
+		$parameters['attr']='action';
683 683
 		if (JString::isNull($responseElement)) {
684
-			$responseElement = '%$(self).attr("data-target")%';
684
+			$responseElement='%$(self).attr("data-target")%';
685 685
 		} else {
686
-			$responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%';
686
+			$responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%';
687 687
 		}
688
-		$formId = '%$(this).attr("id")%';
689
-		if (! isset($parameters['historize'])) {
690
-			$parameters['historize'] = true;
688
+		$formId='%$(this).attr("id")%';
689
+		if (!isset($parameters['historize'])) {
690
+			$parameters['historize']=true;
691 691
 		}
692
-		$parameters['preventDefault'] = true;
693
-		if (! isset($parameters['hasLoader'])) {
694
-			$parameters['hasLoader'] = '$(self).find("button, input[type=submit], input[type=button]")';
692
+		$parameters['preventDefault']=true;
693
+		if (!isset($parameters['hasLoader'])) {
694
+			$parameters['hasLoader']='$(self).find("button, input[type=submit], input[type=button]")';
695 695
 		}
696
-		if (! isset($parameters['jsCallback'])) {
697
-			$parameters['jsCallback'] = 'var event = jQuery.Event( "postFormAction" );event.params = Object.fromEntries(new URLSearchParams(params));$(self).trigger(event);';
696
+		if (!isset($parameters['jsCallback'])) {
697
+			$parameters['jsCallback']='var event = jQuery.Event( "postFormAction" );event.params = Object.fromEntries(new URLSearchParams(params));$(self).trigger(event);';
698 698
 		}
699 699
 		return $this->postFormOn('submit', $element, '', $formId, $responseElement, $parameters);
700 700
 	}
701 701
 
702
-	private function _post($url, $params = '{}', $responseElement = '', $parameters = []) {
703
-		$parameters['params'] = $params;
702
+	private function _post($url, $params='{}', $responseElement='', $parameters=[]) {
703
+		$parameters['params']=$params;
704 704
 		return $this->_ajax('POST', $url, $responseElement, $parameters);
705 705
 	}
706 706
 
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
 	 * @param array $parameters
717 717
 	 *        	default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
718 718
 	 */
719
-	public function post($url, $params = "{}", $responseElement = "", $parameters = []) {
720
-		$parameters['immediatly'] = true;
719
+	public function post($url, $params="{}", $responseElement="", $parameters=[]) {
720
+		$parameters['immediatly']=true;
721 721
 		return $this->_post($url, $params, $responseElement, $parameters);
722 722
 	}
723 723
 
@@ -734,8 +734,8 @@  discard block
 block discarded – undo
734 734
 	 * @param array $parameters
735 735
 	 *        	default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
736 736
 	 */
737
-	public function postDeferred($url, $params = "{}", $responseElement = "", $parameters = []) {
738
-		$parameters['immediatly'] = false;
737
+	public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) {
738
+		$parameters['immediatly']=false;
739 739
 		return $this->_post($url, $params, $responseElement, $parameters);
740 740
 	}
741 741
 
@@ -754,9 +754,9 @@  discard block
 block discarded – undo
754 754
 	 * @param array $parameters
755 755
 	 *        	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)
756 756
 	 */
757
-	public function postOn($event, $element, $url, $params = "{}", $responseElement = "", $parameters = array()) {
758
-		$parameters['method'] = 'post';
759
-		$parameters['params'] = $params;
757
+	public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
758
+		$parameters['method']='post';
759
+		$parameters['params']=$params;
760 760
 		return $this->ajaxOn($event, $element, $url, $responseElement, $parameters);
761 761
 	}
762 762
 
@@ -774,75 +774,75 @@  discard block
 block discarded – undo
774 774
 	 * @param array $parameters
775 775
 	 *        	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)
776 776
 	 */
777
-	public function postOnClick($element, $url, $params = '{}', $responseElement = '', $parameters = array()) {
777
+	public function postOnClick($element, $url, $params='{}', $responseElement='', $parameters=array()) {
778 778
 		return $this->postOn('click', $element, $url, $params, $responseElement, $parameters);
779 779
 	}
780 780
 
781
-	private function _postForm($url, $form, $responseElement, $parameters = []) {
781
+	private function _postForm($url, $form, $responseElement, $parameters=[]) {
782 782
 		if (isset($this->params['ajax'])) {
783 783
 			extract($this->params['ajax']);
784 784
 		}
785
-		$params = '{}';
786
-		$validation = false;
785
+		$params='{}';
786
+		$validation=false;
787 787
 		\extract($parameters);
788
-		$async = ($async) ? 'true' : 'false';
789
-		$jsCallback = isset($jsCallback) ? $jsCallback : "";
790
-		$retour = $this->_getAjaxUrl($url, $attr);
791
-		$form = $this->_getFormElement($form);
792
-		$retour .= "\n$('#'+" . $form . ").trigger('ajaxSubmit');";
793
-		if (! isset($contentType) || $contentType != 'false') {
794
-			$retour .= "\nvar params=$('#'+" . $form . ").serialize();\n";
788
+		$async=($async) ? 'true' : 'false';
789
+		$jsCallback=isset($jsCallback) ? $jsCallback : "";
790
+		$retour=$this->_getAjaxUrl($url, $attr);
791
+		$form=$this->_getFormElement($form);
792
+		$retour.="\n$('#'+".$form.").trigger('ajaxSubmit');";
793
+		if (!isset($contentType) || $contentType!='false') {
794
+			$retour.="\nvar params=$('#'+".$form.").serialize();\n";
795 795
 			if (isset($params)) {
796
-				$retour .= "params+='&'+" . self::_correctParams($params) . ";\n";
796
+				$retour.="params+='&'+".self::_correctParams($params).";\n";
797 797
 			}
798 798
 		} else {
799
-			$retour .= "\nvar params=new FormData($('#'+" . $form . ")[0]);\n";
799
+			$retour.="\nvar params=new FormData($('#'+".$form.")[0]);\n";
800 800
 		}
801
-		$responseElement = $this->_getResponseElement($responseElement);
802
-		$retour .= "var self=this;\n";
803
-		$before = isset($before) ? $before : "";
804
-		$retour .= $before;
805
-		if ($hasLoader === true) {
801
+		$responseElement=$this->_getResponseElement($responseElement);
802
+		$retour.="var self=this;\n";
803
+		$before=isset($before) ? $before : "";
804
+		$retour.=$before;
805
+		if ($hasLoader===true) {
806 806
 			$this->addLoading($retour, $responseElement, $ajaxLoader);
807
-		} elseif ($hasLoader === 'response') {
807
+		} elseif ($hasLoader==='response') {
808 808
 			$this->addResponseLoading($retour, $responseElement, $ajaxLoader);
809
-		} elseif ($hasLoader === 'internal-x') {
809
+		} elseif ($hasLoader==='internal-x') {
810 810
 			$this->addLoading($retour, '$(this).closest(".item, .step")', $ajaxLoader);
811
-		} elseif ($hasLoader === 'internal') {
812
-			$retour .= "\n$(this).addClass('loading');";
811
+		} elseif ($hasLoader==='internal') {
812
+			$retour.="\n$(this).addClass('loading');";
813 813
 		} elseif (\is_string($hasLoader)) {
814
-			$retour .= "\n$hasLoader.addClass('loading');";
814
+			$retour.="\n$hasLoader.addClass('loading');";
815 815
 		}
816
-		$ajaxParameters = [
816
+		$ajaxParameters=[
817 817
 			"url" => "url",
818 818
 			"method" => "'POST'",
819 819
 			"data" => "params",
820 820
 			"async" => $async
821 821
 		];
822 822
 		if (isset($headers)) {
823
-			$ajaxParameters["headers"] = $headers;
823
+			$ajaxParameters["headers"]=$headers;
824 824
 		}
825 825
 		if (isset($partial)) {
826
-			$ajaxParameters["xhr"] = "xhrProvider";
827
-			$retour .= "var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;" . $partial . ";}; };";
826
+			$ajaxParameters["xhr"]="xhrProvider";
827
+			$retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };";
828 828
 		}
829 829
 		$this->createAjaxParameters($ajaxParameters, $parameters);
830
-		$retour .= "$.ajax({" . $this->implodeAjaxParameters($ajaxParameters) . "}).done(function( data ) {\n";
831
-		$retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) . "})";
830
+		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n";
831
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."})";
832 832
 		if (isset($error)) {
833
-			$retour .= '.fail(function( jqXHR, textStatus, errorThrown ){' . $error . '})';
833
+			$retour.='.fail(function( jqXHR, textStatus, errorThrown ){'.$error.'})';
834 834
 		}
835
-		$retour .= '.always(function( dataOrjqXHR, textStatus, jqXHROrerrorThrown ) {' . ($always ?? '') . $this->removeLoader($hasLoader) . '})';
836
-		$retour .= ";\n";
835
+		$retour.='.always(function( dataOrjqXHR, textStatus, jqXHROrerrorThrown ) {'.($always ?? '').$this->removeLoader($hasLoader).'})';
836
+		$retour.=";\n";
837 837
 		if ($validation) {
838
-			$retour = "$('#'+" . $form . ").validate({submitHandler: function(form) {
839
-			" . $retour . "
838
+			$retour="$('#'+".$form.").validate({submitHandler: function(form) {
839
+			" . $retour."
840 840
 			}});\n";
841
-			$retour .= "$('#'+" . $form . ").submit();\n";
841
+			$retour.="$('#'+".$form.").submit();\n";
842 842
 		}
843
-		$retour = $this->_addJsCondition($jsCondition, $retour);
843
+		$retour=$this->_addJsCondition($jsCondition, $retour);
844 844
 		if ($immediatly)
845
-			$this->jquery_code_for_compile[] = $retour;
845
+			$this->jquery_code_for_compile[]=$retour;
846 846
 		return $retour;
847 847
 	}
848 848
 
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	 * @param array $parameters
859 859
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
860 860
 	 */
861
-	public function postForm($url, $form, $responseElement, $parameters = []) {
862
-		$parameters['immediatly'] = true;
861
+	public function postForm($url, $form, $responseElement, $parameters=[]) {
862
+		$parameters['immediatly']=true;
863 863
 		return $this->_postForm($url, $form, $responseElement, $parameters);
864 864
 	}
865 865
 
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 	 * @param array $parameters
877 877
 	 *        	default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null)
878 878
 	 */
879
-	public function postFormDeferred($url, $form, $responseElement, $parameters = []) {
880
-		$parameters['immediatly'] = false;
879
+	public function postFormDeferred($url, $form, $responseElement, $parameters=[]) {
880
+		$parameters['immediatly']=false;
881 881
 		return $this->_postForm($url, $form, $responseElement, $parameters);
882 882
 	}
883 883
 
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 	 * @param array $parameters
895 895
 	 *        	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)
896 896
 	 */
897
-	public function postFormOn($event, $element, $url, $form, $responseElement = "", $parameters = array()) {
897
+	public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) {
898 898
 		$this->setDefaultParameters($parameters, [
899 899
 			'preventDefault' => true,
900 900
 			'stopPropagation' => true,
@@ -916,11 +916,11 @@  discard block
 block discarded – undo
916 916
 	 * @param array $parameters
917 917
 	 *        	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)
918 918
 	 */
919
-	public function postFormOnClick($element, $url, $form, $responseElement = "", $parameters = array()) {
919
+	public function postFormOnClick($element, $url, $form, $responseElement="", $parameters=array()) {
920 920
 		return $this->postFormOn("click", $element, $url, $form, $responseElement, $parameters);
921 921
 	}
922 922
 
923
-	public function addCsrf($name = 'csrf-token') {
923
+	public function addCsrf($name='csrf-token') {
924 924
 		return "
925 925
 		$.ajaxSetup({
926 926
 			beforeSend: function(xhr, settings) {
Please login to merge, or discard this patch.