Completed
Push — master ( 2b1feb...63bca8 )
by Jean-Christophe
03:46
created
Ajax/common/traits/JsUtilsActionsTrait.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 	/**
15 15
 	 * Ensures the speed parameter is valid for jQuery
16
-	 * @param string|int $speed
16
+	 * @param string $speed
17 17
 	 * @return string
18 18
 	 */
19 19
 	private function _validate_speed($speed) {
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 *
423 423
 	 * @param string $element
424 424
 	 * @param array $options
425
-	 * @return void
425
+	 * @return string
426 426
 	 */
427 427
 	public function sortable($element, $options=array()) {
428 428
 		if (count($options)>0) {
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 	 * @param string $jqueryCall the JQuery callback
494 494
 	 * @param mixed $param array or string parameters
495 495
 	 * @param string $jsCallback javascript code to execute after the jquery call
496
-	 * @return mixed
496
+	 * @return string
497 497
 	 */
498 498
 	public function doJQuery($element, $jqueryCall, $param="", $jsCallback="") {
499 499
 		return $this->_doJQuery($element, $jqueryCall, $param, $jsCallback, true);
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 	 * @param string $jqueryCall the JQuery callback
506 506
 	 * @param mixed $param array or string parameters
507 507
 	 * @param string $jsCallback javascript code to execute after the jquery call
508
-	 * @return mixed
508
+	 * @return string
509 509
 	 */
510 510
 	public function doJQueryDeferred($element, $jqueryCall, $param="", $jsCallback="") {
511 511
 		return $this->_doJQuery($element, $jqueryCall, $param, $jsCallback, false);
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 	 * @param string $element
518 518
 	 * @param string $elementToModify
519 519
 	 * @param string $jqueryCall
520
-	 * @param string|array $param
520
+	 * @param string $param
521 521
 	 * @param boolean $preventDefault
522 522
 	 * @param boolean $stopPropagation
523 523
 	 * @param string $jsCallback javascript code to execute after the jquery call
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 * @return string
18 18
 	 */
19 19
 	private function _validate_speed($speed) {
20
-		if (in_array($speed, array (
21
-				'slow','normal','fast'
20
+		if (in_array($speed, array(
21
+				'slow', 'normal', 'fast'
22 22
 		))) {
23 23
 			$speed='"'.$speed.'"';
24 24
 		} elseif (preg_match("/[^0-9]/", $speed)) {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param string $param
36 36
 	 * @param boolean $immediatly delayed if false
37 37
 	 */
38
-	public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) {
38
+	public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) {
39 39
 		$element=Javascript::prep_element($element);
40 40
 		if (isset($param)) {
41 41
 			$param=Javascript::prep_value($param);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @param boolean $immediatly delayed if false
56 56
 	 * @return string
57 57
 	 */
58
-	public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) {
58
+	public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) {
59 59
 		$to=Javascript::prep_element($to);
60 60
 		$element=Javascript::prep_element($element);
61 61
 		$str="$({$to}).{$jQueryCall}({$element});";
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @return string
73 73
 	 */
74 74
 	public function addClass($element='this', $class='', $immediatly=false) {
75
-		return $this->_genericCallValue('addClass',$element, $class, $immediatly);
75
+		return $this->_genericCallValue('addClass', $element, $class, $immediatly);
76 76
 	}
77 77
 
78 78
 	/**
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 	 * @param boolean $immediatly defers the execution if set to false
83 83
 	 * @return string
84 84
 	 */
85
-	public function after($to, $element, $immediatly=false){
86
-		return $this->_genericCallElement('after',$to, $element, $immediatly);
85
+	public function after($to, $element, $immediatly=false) {
86
+		return $this->_genericCallElement('after', $to, $element, $immediatly);
87 87
 	}
88 88
 
89 89
 	/**
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 	 * @param boolean $immediatly defers the execution if set to false
94 94
 	 * @return string
95 95
 	 */
96
-	public function before($to, $element, $immediatly=false){
97
-		return $this->_genericCallElement('before',$to, $element, $immediatly);
96
+	public function before($to, $element, $immediatly=false) {
97
+		return $this->_genericCallElement('before', $to, $element, $immediatly);
98 98
 	}
99 99
 
100 100
 	/**
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @param string $value
123 123
 	 * @param boolean $immediatly defers the execution if set to false
124 124
 	 */
125
-	public function val($element='this',$value='',$immediatly=false){
126
-		return $this->_genericCallValue('val',$element,$value,$immediatly);
125
+	public function val($element='this', $value='', $immediatly=false) {
126
+		return $this->_genericCallValue('val', $element, $value, $immediatly);
127 127
 	}
128 128
 
129 129
 	/**
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @param boolean $immediatly defers the execution if set to false
134 134
 	 */
135 135
 	public function html($element='this', $value='', $immediatly=false) {
136
-		return $this->_genericCallValue('html',$element, $value, $immediatly);
136
+		return $this->_genericCallValue('html', $element, $value, $immediatly);
137 137
 	}
138 138
 
139 139
 	/**
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 
153 153
 		$animations="\t\t\t";
154 154
 		if (\is_array($params)) {
155
-			foreach ( $params as $param => $value ) {
155
+			foreach ($params as $param => $value) {
156 156
 				$animations.=$param.': \''.$value.'\', ';
157 157
 			}
158 158
 		}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @return string
182 182
 	 */
183 183
 	public function append($to, $element, $immediatly=false) {
184
-		return $this->_genericCallElement('append',$to, $element, $immediatly);
184
+		return $this->_genericCallElement('append', $to, $element, $immediatly);
185 185
 	}
186 186
 
187 187
 	/**
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @return string
193 193
 	 */
194 194
 	public function prepend($to, $element, $immediatly=false) {
195
-		return $this->_genericCallElement('prepend',$to, $element, $immediatly);
195
+		return $this->_genericCallElement('prepend', $to, $element, $immediatly);
196 196
 	}
197 197
 
198 198
 	/**
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 * @return string
277 277
 	 */
278 278
 	public function removeClass($element='this', $class='', $immediatly=false) {
279
-		return $this->_genericCall('removeClass',$element, $class, $immediatly);
279
+		return $this->_genericCall('removeClass', $element, $class, $immediatly);
280 280
 	}
281 281
 
282 282
 	/**
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 	 * @return string
376 376
 	 */
377 377
 	public function toggleClass($element='this', $class='', $immediatly=false) {
378
-		return $this->_genericCallValue('toggleClass',$element, $class, $immediatly);
378
+		return $this->_genericCallValue('toggleClass', $element, $class, $immediatly);
379 379
 	}
380 380
 
381 381
 	/**
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 	 */
427 427
 	public function sortable($element, $options=array()) {
428 428
 		if (count($options)>0) {
429
-			$sort_options=array ();
430
-			foreach ( $options as $k => $v ) {
429
+			$sort_options=array();
430
+			foreach ($options as $k => $v) {
431 431
 				$sort_options[]="\n\t\t".$k.': '.$v."";
432 432
 			}
433 433
 			$sort_options=implode(",", $sort_options);
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
 	 * @param boolean $immediatly
525 525
 	 * @return string
526 526
 	 */
527
-	private function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="",$immediatly=true) {
528
-		return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation,$immediatly);
527
+	private function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="", $immediatly=true) {
528
+		return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation, $immediatly);
529 529
 	}
530 530
 
531 531
 	/**
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 		$preventDefault=false;
544 544
 		$immediatly=true;
545 545
 		extract($parameters);
546
-		return $this->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback,$immediatly);
546
+		return $this->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback, $immediatly);
547 547
 	}
548 548
 
549 549
 	/**
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 		$preventDefault=false;
573 573
 		$immediatly=true;
574 574
 		extract($parameters);
575
-		$script=$this->_add_event($element, $this->exec($js), $event, $preventDefault, $stopPropagation,$immediatly);
575
+		$script=$this->_add_event($element, $this->exec($js), $event, $preventDefault, $stopPropagation, $immediatly);
576 576
 		return $script;
577 577
 	}
578 578
 }
Please login to merge, or discard this patch.
Braces   +57 added lines, -38 removed lines patch added patch discarded remove patch
@@ -40,10 +40,12 @@  discard block
 block discarded – undo
40 40
 		if (isset($param)) {
41 41
 			$param=Javascript::prep_value($param);
42 42
 			$str="$({$element}).{$jQueryCall}({$param});";
43
-		} else
44
-			$str="$({$element}).{$jQueryCall}();";
45
-		if ($immediatly)
46
-			$this->jquery_code_for_compile[]=$str;
43
+		} else {
44
+					$str="$({$element}).{$jQueryCall}();";
45
+		}
46
+		if ($immediatly) {
47
+					$this->jquery_code_for_compile[]=$str;
48
+		}
47 49
 		return $str;
48 50
 	}
49 51
 
@@ -59,8 +61,9 @@  discard block
 block discarded – undo
59 61
 		$to=Javascript::prep_element($to);
60 62
 		$element=Javascript::prep_element($element);
61 63
 		$str="$({$to}).{$jQueryCall}({$element});";
62
-		if ($immediatly)
63
-			$this->jquery_code_for_compile[]=$str;
64
+		if ($immediatly) {
65
+					$this->jquery_code_for_compile[]=$str;
66
+		}
64 67
 		return $str;
65 68
 	}
66 69
 	/**
@@ -109,10 +112,12 @@  discard block
 block discarded – undo
109 112
 		if (isset($value)) {
110 113
 			$value=Javascript::prep_value($value);
111 114
 			$str="$({$element}).attr(\"$attributeName\",{$value});";
112
-		} else
113
-			$str="$({$element}).attr(\"$attributeName\");";
114
-		if ($immediatly)
115
-			$this->jquery_code_for_compile[]=$str;
115
+		} else {
116
+					$str="$({$element}).attr(\"$attributeName\");";
117
+		}
118
+		if ($immediatly) {
119
+					$this->jquery_code_for_compile[]=$str;
120
+		}
116 121
 		return $str;
117 122
 	}
118 123
 
@@ -168,8 +173,9 @@  discard block
 block discarded – undo
168 173
 
169 174
 		$str="$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");";
170 175
 
171
-		if ($immediatly)
172
-			$this->jquery_code_for_compile[]=$str;
176
+		if ($immediatly) {
177
+					$this->jquery_code_for_compile[]=$str;
178
+		}
173 179
 		return $str;
174 180
 	}
175 181
 
@@ -214,8 +220,9 @@  discard block
 block discarded – undo
214 220
 
215 221
 		$str="$({$element}).fadeIn({$speed}{$callback});";
216 222
 
217
-		if ($immediatly)
218
-			$this->jquery_code_for_compile[]=$str;
223
+		if ($immediatly) {
224
+					$this->jquery_code_for_compile[]=$str;
225
+		}
219 226
 		return $str;
220 227
 	}
221 228
 
@@ -238,8 +245,9 @@  discard block
 block discarded – undo
238 245
 
239 246
 		$str="$({$element}).fadeOut({$speed}{$callback});";
240 247
 
241
-		if ($immediatly)
242
-			$this->jquery_code_for_compile[]=$str;
248
+		if ($immediatly) {
249
+					$this->jquery_code_for_compile[]=$str;
250
+		}
243 251
 		return $str;
244 252
 	}
245 253
 
@@ -262,8 +270,9 @@  discard block
 block discarded – undo
262 270
 
263 271
 		$str="$({$element}).slideUp({$speed}{$callback});";
264 272
 
265
-		if ($immediatly)
266
-			$this->jquery_code_for_compile[]=$str;
273
+		if ($immediatly) {
274
+					$this->jquery_code_for_compile[]=$str;
275
+		}
267 276
 		return $str;
268 277
 	}
269 278
 
@@ -298,8 +307,9 @@  discard block
 block discarded – undo
298 307
 
299 308
 		$str="$({$element}).slideDown({$speed}{$callback});";
300 309
 
301
-		if ($immediatly)
302
-			$this->jquery_code_for_compile[]=$str;
310
+		if ($immediatly) {
311
+					$this->jquery_code_for_compile[]=$str;
312
+		}
303 313
 		return $str;
304 314
 	}
305 315
 
@@ -322,8 +332,9 @@  discard block
 block discarded – undo
322 332
 
323 333
 		$str="$({$element}).slideToggle({$speed}{$callback});";
324 334
 
325
-		if ($immediatly)
326
-			$this->jquery_code_for_compile[]=$str;
335
+		if ($immediatly) {
336
+					$this->jquery_code_for_compile[]=$str;
337
+		}
327 338
 		return $str;
328 339
 	}
329 340
 
@@ -346,8 +357,9 @@  discard block
 block discarded – undo
346 357
 
347 358
 		$str="$({$element}).hide({$speed}{$callback});";
348 359
 
349
-		if ($immediatly)
350
-			$this->jquery_code_for_compile[]=$str;
360
+		if ($immediatly) {
361
+					$this->jquery_code_for_compile[]=$str;
362
+		}
351 363
 		return $str;
352 364
 	}
353 365
 
@@ -362,8 +374,9 @@  discard block
 block discarded – undo
362 374
 		$element=Javascript::prep_element($element);
363 375
 		$str="$({$element}).toggle();";
364 376
 
365
-		if ($immediatly)
366
-			$this->jquery_code_for_compile[]=$str;
377
+		if ($immediatly) {
378
+					$this->jquery_code_for_compile[]=$str;
379
+		}
367 380
 		return $str;
368 381
 	}
369 382
 
@@ -388,8 +401,9 @@  discard block
 block discarded – undo
388 401
 		$element=Javascript::prep_element($element);
389 402
 		$str="$({$element}).trigger(\"$event\");";
390 403
 
391
-		if ($immediatly)
392
-			$this->jquery_code_for_compile[]=$str;
404
+		if ($immediatly) {
405
+					$this->jquery_code_for_compile[]=$str;
406
+		}
393 407
 		return $str;
394 408
 	}
395 409
 
@@ -412,8 +426,9 @@  discard block
 block discarded – undo
412 426
 
413 427
 		$str="$({$element}).show({$speed}{$callback});";
414 428
 
415
-		if ($immediatly)
416
-			$this->jquery_code_for_compile[]=$str;
429
+		if ($immediatly) {
430
+					$this->jquery_code_for_compile[]=$str;
431
+		}
417 432
 		return $str;
418 433
 	}
419 434
 
@@ -462,8 +477,9 @@  discard block
 block discarded – undo
462 477
 			$str.="else{".$jsCodeIfFalse."}";
463 478
 		}
464 479
 
465
-		if ($immediatly)
466
-			$this->jquery_code_for_compile[]=$str;
480
+		if ($immediatly) {
481
+					$this->jquery_code_for_compile[]=$str;
482
+		}
467 483
 		return $str;
468 484
 	}
469 485
 
@@ -479,11 +495,13 @@  discard block
 block discarded – undo
479 495
 	private function _doJQuery($element, $jqueryCall, $param="", $jsCallback="", $immediatly=false) {
480 496
 		$param=Javascript::prep_value($param);
481 497
 		$callback="";
482
-		if ($jsCallback!="")
483
-			$callback=", function(event){\n{$jsCallback}\n}";
498
+		if ($jsCallback!="") {
499
+					$callback=", function(event){\n{$jsCallback}\n}";
500
+		}
484 501
 			$script="$(".Javascript::prep_element($element).").".$jqueryCall."(".$param.$callback.");\n";
485
-			if ($immediatly)
486
-				$this->jquery_code_for_compile[]=$script;
502
+			if ($immediatly) {
503
+							$this->jquery_code_for_compile[]=$script;
504
+			}
487 505
 				return $script;
488 506
 	}
489 507
 
@@ -554,8 +572,9 @@  discard block
 block discarded – undo
554 572
 	 */
555 573
 	public function exec($js, $immediatly=false) {
556 574
 		$script=$js."\n";
557
-		if ($immediatly)
558
-			$this->jquery_code_for_compile[]=$script;
575
+		if ($immediatly) {
576
+					$this->jquery_code_for_compile[]=$script;
577
+		}
559 578
 		return $script;
560 579
 	}
561 580
 
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsAjaxTrait.php 3 patches
Doc Comments   +31 added lines patch added patch discarded remove patch
@@ -16,8 +16,17 @@  discard block
 block discarded – undo
16 16
 	protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>';
17 17
 
18 18
 	abstract public function getUrl($url);
19
+
20
+	/**
21
+	 * @param string $element
22
+	 * @param string $js
23
+	 * @param string $event
24
+	 */
19 25
 	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
20 26
 
27
+	/**
28
+	 * @param string $method
29
+	 */
21 30
 	protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
22 31
 		if(JString::isNull($params)){$params="{}";}
23 32
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
@@ -36,6 +45,9 @@  discard block
 block discarded – undo
36 45
 
37 46
 
38 47
 
48
+	/**
49
+	 * @param string $attr
50
+	 */
39 51
 	protected function _getAjaxUrl($url,$attr){
40 52
 		$url=$this->_correctAjaxUrl($url);
41 53
 		$retour="url='".$url."';";
@@ -53,6 +65,9 @@  discard block
 block discarded – undo
53 65
 			return $retour;
54 66
 	}
55 67
 
68
+	/**
69
+	 * @param string $jqueryDone
70
+	 */
56 71
 	protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){
57 72
 		$retour="";$call=null;
58 73
 		if ($responseElement!=="") {
@@ -86,6 +101,9 @@  discard block
 block discarded – undo
86 101
 			return $url;
87 102
 	}
88 103
 
104
+	/**
105
+	 * @param string $retour
106
+	 */
89 107
 	protected function addLoading(&$retour, $responseElement) {
90 108
 		$loading_notifier='<div class="ajax-loader">';
91 109
 		if ($this->ajaxLoader=='') {
@@ -252,6 +270,7 @@  discard block
 block discarded – undo
252 270
 	 * @param string $rowClass the css class for the new element
253 271
 	 * @param string $context jquery DOM element, array container.
254 272
 	 * @param boolean $immediatly
273
+	 * @param string $maskSelector
255 274
 	 */
256 275
 	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$immediatly=false) {
257 276
 		return $this->_jsonArray($maskSelector, $url,$method,$params,$jsCallback,$rowClass,$context,NULL,$immediatly);
@@ -342,6 +361,11 @@  discard block
 block discarded – undo
342 361
 		return $this->getOn("click", $element, $url, $responseElement, $parameters);
343 362
 	}
344 363
 
364
+	/**
365
+	 * @param string $url
366
+	 * @param string $jsCallback
367
+	 * @param callable $ajaxTransition
368
+	 */
345 369
 	private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
346 370
 		return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly);
347 371
 	}
@@ -412,6 +436,13 @@  discard block
 block discarded – undo
412 436
 		return $this->postOn("click", $element, $url, $params, $responseElement, $parameters);
413 437
 	}
414 438
 
439
+	/**
440
+	 * @param string $url
441
+	 * @param string $form
442
+	 * @param string $responseElement
443
+	 * @param string $jsCallback
444
+	 * @param callable $ajaxTransition
445
+	 */
415 446
 	private function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
416 447
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
417 448
 		$retour=$this->_getAjaxUrl($url, $attr);
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -16,19 +16,19 @@  discard block
 block discarded – undo
16 16
 	protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>';
17 17
 
18 18
 	abstract public function getUrl($url);
19
-	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
19
+	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true);
20 20
 
21
-	protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
22
-		if(JString::isNull($params)){$params="{}";}
21
+	protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
22
+		if (JString::isNull($params)) {$params="{}"; }
23 23
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
24 24
 		$retour=$this->_getAjaxUrl($url, $attr);
25 25
 		$responseElement=$this->_getResponseElement($responseElement);
26 26
 		$retour.="var self=this;\n";
27
-		if($hasLoader===true){
27
+		if ($hasLoader===true) {
28 28
 			$this->addLoading($retour, $responseElement);
29 29
 		}
30 30
 		$retour.="$.".$method."(url,".$params.").done(function( data ) {\n";
31
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
31
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
32 32
 		if ($immediatly)
33 33
 			$this->jquery_code_for_compile[]=$retour;
34 34
 			return $retour;
@@ -36,33 +36,33 @@  discard block
 block discarded – undo
36 36
 
37 37
 
38 38
 
39
-	protected function _getAjaxUrl($url,$attr){
39
+	protected function _getAjaxUrl($url, $attr) {
40 40
 		$url=$this->_correctAjaxUrl($url);
41 41
 		$retour="url='".$url."';";
42 42
 		$slash="/";
43
-		if(JString::endswith($url, "/")===true)
43
+		if (JString::endswith($url, "/")===true)
44 44
 			$slash="";
45
-			if(JString::isNotNull($attr)){
45
+			if (JString::isNotNull($attr)) {
46 46
 				if ($attr==="value")
47 47
 					$retour.="url=url+'".$slash."'+$(this).val();\n";
48 48
 				elseif ($attr==="html")
49 49
 					$retour.="url=url+'".$slash."'+$(this).html();\n";
50
-				elseif($attr!==null && $attr!=="")
50
+				elseif ($attr!==null && $attr!=="")
51 51
 					$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
52 52
 			}
53 53
 			return $retour;
54 54
 	}
55 55
 
56
-	protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){
57
-		$retour="";$call=null;
56
+	protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) {
57
+		$retour=""; $call=null;
58 58
 		if ($responseElement!=="") {
59
-			if(isset($ajaxTransition)){
59
+			if (isset($ajaxTransition)) {
60 60
 				$call=$this->setAjaxDataCall($ajaxTransition);
61
-			}elseif(isset($this->ajaxTransition)){
61
+			}elseif (isset($this->ajaxTransition)) {
62 62
 				$call=$this->ajaxTransition;
63 63
 			}
64
-			if(\is_callable($call))
65
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
64
+			if (\is_callable($call))
65
+				$retour="\t".$call($responseElement, $jqueryDone).";\n";
66 66
 				else
67 67
 					$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
68 68
 		}
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		return $retour;
71 71
 	}
72 72
 
73
-	protected function _getResponseElement($responseElement){
73
+	protected function _getResponseElement($responseElement) {
74 74
 		if ($responseElement!=="") {
75 75
 			$responseElement=Javascript::prep_value($responseElement);
76 76
 		}
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	protected function _correctAjaxUrl($url) {
81 81
 		if ($url!=="/" && JString::endsWith($url, "/")===true)
82 82
 			$url=substr($url, 0, strlen($url)-1);
83
-			if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
83
+			if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) {
84 84
 				$url=$this->getUrl($url);
85 85
 			}
86 86
 			return $url;
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 		$retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n";
99 99
 	}
100 100
 
101
-	protected function setAjaxDataCall($params){
101
+	protected function setAjaxDataCall($params) {
102 102
 		$result=null;
103
-		if(!\is_callable($params)){
104
-			$result=function ($responseElement,$jqueryDone="html") use($params){
105
-				return AjaxTransition::{$params}($responseElement,$jqueryDone);
103
+		if (!\is_callable($params)) {
104
+			$result=function($responseElement, $jqueryDone="html") use($params){
105
+				return AjaxTransition::{$params}($responseElement, $jqueryDone);
106 106
 			};
107 107
 		}
108 108
 		return $result;
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
123 123
 	 * @param string|callable $ajaxTransition
124 124
 	 */
125
-	private function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
126
-		return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly);
125
+	private function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
126
+		return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly);
127 127
 	}
128 128
 
129 129
 	/**
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
137 137
 	 * @param string|callable $ajaxTransition
138 138
 	 */
139
-	public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
140
-		return $this->_get($url,$params,$responseElement,$jsCallback,null,$hasLoader,$jqueryDone,$ajaxTransition,true);
139
+	public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
140
+		return $this->_get($url, $params, $responseElement, $jsCallback, null, $hasLoader, $jqueryDone, $ajaxTransition, true);
141 141
 	}
142 142
 
143 143
 	/**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @param string $context
151 151
 	 * @param boolean $immediatly
152 152
 	 */
153
-	private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) {
153
+	private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) {
154 154
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
155 155
 		$retour=$this->_getAjaxUrl($url, $attr);
156 156
 		$retour.="$.{$method}(url,".$params.").done(function( data ) {\n";
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	 * @param string $context
174 174
 	 * @param boolean $immediatly
175 175
 	 */
176
-	public function json($url, $method="get", $params="{}", $jsCallback=NULL,$context="document",$immediatly=false) {
177
-		return $this->_json($url,$method,$params,$jsCallback,NULL,$context,$immediatly);
176
+	public function json($url, $method="get", $params="{}", $jsCallback=NULL, $context="document", $immediatly=false) {
177
+		return $this->_json($url, $method, $params, $jsCallback, NULL, $context, $immediatly);
178 178
 	}
179 179
 
180 180
 	/**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 * @param string $url the request address
185 185
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
186 186
 	 */
187
-	public function jsonOn($event,$element, $url,$parameters=array()) {
187
+	public function jsonOn($event, $element, $url, $parameters=array()) {
188 188
 		$preventDefault=true;
189 189
 		$stopPropagation=true;
190 190
 		$jsCallback=null;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		$params="{}";
195 195
 		$immediatly=true;
196 196
 		extract($parameters);
197
-		return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly);
197
+		return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly);
198 198
 	}
199 199
 
200 200
 	/**
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 	 * @param string $jsCallback javascript code to execute after the request
206 206
 	 * @param string $context jquery DOM element, array container.
207 207
 	 */
208
-	public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL,$context=NULL) {
209
-		return $this->json($url, $method, $params, $jsCallback, $context,false);
208
+	public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL, $context=NULL) {
209
+		return $this->json($url, $method, $params, $jsCallback, $context, false);
210 210
 	}
211 211
 
212 212
 	/**
@@ -219,22 +219,22 @@  discard block
 block discarded – undo
219 219
 	 * @param string $rowClass the css class for the new element
220 220
 	 * @param boolean $immediatly
221 221
 	 */
222
-	private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$attr="id",$immediatly=false) {
222
+	private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $attr="id", $immediatly=false) {
223 223
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
224 224
 		$retour=$this->_getAjaxUrl($url, $attr);
225
-		if($context===null){
225
+		if ($context===null) {
226 226
 			$parent="$('".$maskSelector."').parent()";
227
-			$newElm = "$('#'+newId)";
228
-		}else{
227
+			$newElm="$('#'+newId)";
228
+		} else {
229 229
 			$parent=$context;
230
-			$newElm = $context.".find('#'+newId)";
230
+			$newElm=$context.".find('#'+newId)";
231 231
 		}
232 232
 		$appendTo="\t\tnewElm.appendTo(".$parent.");\n";
233 233
 		$retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n";
234 234
 		$retour.=$parent.".find('._json').remove();";
235 235
 		$retour.="\tdata=$.parseJSON(data);$.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();
236 236
 		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";
237
-		$retour.= $appendTo;
237
+		$retour.=$appendTo;
238 238
 		$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";
239 239
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
240 240
 		$retour.="\t".$jsCallback."\n"."});\n";
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 	 * @param string $context jquery DOM element, array container.
254 254
 	 * @param boolean $immediatly
255 255
 	 */
256
-	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$immediatly=false) {
257
-		return $this->_jsonArray($maskSelector, $url,$method,$params,$jsCallback,$rowClass,$context,NULL,$immediatly);
256
+	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $immediatly=false) {
257
+		return $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, NULL, $immediatly);
258 258
 	}
259 259
 
260 260
 	/**
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 	 * @param string $rowClass the css class for the new element
268 268
 	 * @param string $context jquery DOM element, array container.
269 269
 	 */
270
-	public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL) {
271
-		return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback,$rowClass,$context,false);
270
+	public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL) {
271
+		return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, false);
272 272
 	}
273 273
 
274 274
 	/**
@@ -278,18 +278,18 @@  discard block
 block discarded – undo
278 278
 	 * @param string $url the request url
279 279
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true)
280 280
 	 */
281
-	public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) {
281
+	public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) {
282 282
 		$preventDefault=true;
283 283
 		$stopPropagation=true;
284 284
 		$jsCallback=null;
285 285
 		$attr="id";
286 286
 		$method="get";
287
-		$context = null;
287
+		$context=null;
288 288
 		$params="{}";
289 289
 		$immediatly=true;
290 290
 		$rowClass="_json";
291 291
 		extract($parameters);
292
-		return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $rowClass, $context,$attr), $event, $preventDefault, $stopPropagation,$immediatly);
292
+		return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, $attr), $event, $preventDefault, $stopPropagation, $immediatly);
293 293
 	}
294 294
 
295 295
 	/**
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
304 304
 	 * @param string|callable $ajaxTransition
305 305
 	 */
306
-	public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) {
307
-		return $this->_get($url, $params,$responseElement,$jsCallback,$attr,false,$jqueryDone,$ajaxTransition);
306
+	public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) {
307
+		return $this->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition);
308 308
 	}
309 309
 
310 310
 	/**
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 		$ajaxTransition=null;
328 328
 		extract($parameters);
329 329
 		$params=JArray::getDefaultValue($parameters, "params", "{}");
330
-		return $this->_add_event($element, $this->_get($url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
330
+		return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
331 331
 	}
332 332
 
333 333
 	/**
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 		return $this->getOn("click", $element, $url, $responseElement, $parameters);
343 343
 	}
344 344
 
345
-	private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
346
-		return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly);
345
+	private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
346
+		return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly);
347 347
 	}
348 348
 
349 349
 	/**
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
357 357
 	 * @param string|callable $ajaxTransition
358 358
 	 */
359
-	public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
360
-		return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true);
359
+	public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
360
+		return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true);
361 361
 	}
362 362
 
363 363
 	/**
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
373 373
 	 * @param string|callable $ajaxTransition
374 374
 	 */
375
-	public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
376
-		return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false);
375
+	public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
376
+		return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false);
377 377
 	}
378 378
 
379 379
 	/**
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 		$jqueryDone="html";
397 397
 		$ajaxTransition=null;
398 398
 		extract($parameters);
399
-		return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
399
+		return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
400 400
 	}
401 401
 
402 402
 	/**
@@ -412,17 +412,17 @@  discard block
 block discarded – undo
412 412
 		return $this->postOn("click", $element, $url, $params, $responseElement, $parameters);
413 413
 	}
414 414
 
415
-	private function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
415
+	private function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
416 416
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
417 417
 		$retour=$this->_getAjaxUrl($url, $attr);
418 418
 		$retour.="\nvar params=$('#".$form."').serialize();\n";
419 419
 		$responseElement=$this->_getResponseElement($responseElement);
420 420
 		$retour.="var self=this;\n";
421
-		if($hasLoader===true){
421
+		if ($hasLoader===true) {
422 422
 			$this->addLoading($retour, $responseElement);
423 423
 		}
424 424
 		$retour.="$.post(url,params).done(function( data ) {\n";
425
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
425
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
426 426
 
427 427
 		if ($validation) {
428 428
 			$retour="$('#".$form."').validate({submitHandler: function(form) {
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
446 446
 	 * @param string|callable $ajaxTransition
447 447
 	 */
448
-	public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
449
-		return $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true);
448
+	public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
449
+		return $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true);
450 450
 	}
451 451
 
452 452
 	/**
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
462 462
 	 * @param string|callable $ajaxTransition
463 463
 	 */
464
-	public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
465
-		return $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false);
464
+	public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
465
+		return $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false);
466 466
 	}
467 467
 
468 468
 	/**
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 		$jqueryDone="html";
487 487
 		$ajaxTransition=null;
488 488
 		extract($parameters);
489
-		return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
489
+		return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
490 490
 	}
491 491
 
492 492
 	/**
Please login to merge, or discard this patch.
Braces   +32 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,8 +29,9 @@  discard block
 block discarded – undo
29 29
 		}
30 30
 		$retour.="$.".$method."(url,".$params.").done(function( data ) {\n";
31 31
 		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
32
-		if ($immediatly)
33
-			$this->jquery_code_for_compile[]=$retour;
32
+		if ($immediatly) {
33
+					$this->jquery_code_for_compile[]=$retour;
34
+		}
34 35
 			return $retour;
35 36
 	}
36 37
 
@@ -40,15 +41,17 @@  discard block
 block discarded – undo
40 41
 		$url=$this->_correctAjaxUrl($url);
41 42
 		$retour="url='".$url."';";
42 43
 		$slash="/";
43
-		if(JString::endswith($url, "/")===true)
44
-			$slash="";
44
+		if(JString::endswith($url, "/")===true) {
45
+					$slash="";
46
+		}
45 47
 			if(JString::isNotNull($attr)){
46
-				if ($attr==="value")
47
-					$retour.="url=url+'".$slash."'+$(this).val();\n";
48
-				elseif ($attr==="html")
49
-					$retour.="url=url+'".$slash."'+$(this).html();\n";
50
-				elseif($attr!==null && $attr!=="")
51
-					$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
48
+				if ($attr==="value") {
49
+									$retour.="url=url+'".$slash."'+$(this).val();\n";
50
+				} elseif ($attr==="html") {
51
+									$retour.="url=url+'".$slash."'+$(this).html();\n";
52
+				} elseif($attr!==null && $attr!=="") {
53
+									$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
54
+				}
52 55
 			}
53 56
 			return $retour;
54 57
 	}
@@ -58,13 +61,14 @@  discard block
 block discarded – undo
58 61
 		if ($responseElement!=="") {
59 62
 			if(isset($ajaxTransition)){
60 63
 				$call=$this->setAjaxDataCall($ajaxTransition);
61
-			}elseif(isset($this->ajaxTransition)){
64
+			} elseif(isset($this->ajaxTransition)){
62 65
 				$call=$this->ajaxTransition;
63 66
 			}
64
-			if(\is_callable($call))
65
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
66
-				else
67
-					$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
67
+			if(\is_callable($call)) {
68
+							$retour="\t".$call($responseElement,$jqueryDone).";\n";
69
+			} else {
70
+									$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
71
+				}
68 72
 		}
69 73
 		$retour.="\t".$jsCallback."\n";
70 74
 		return $retour;
@@ -78,8 +82,9 @@  discard block
 block discarded – undo
78 82
 	}
79 83
 
80 84
 	protected function _correctAjaxUrl($url) {
81
-		if ($url!=="/" && JString::endsWith($url, "/")===true)
82
-			$url=substr($url, 0, strlen($url)-1);
85
+		if ($url!=="/" && JString::endsWith($url, "/")===true) {
86
+					$url=substr($url, 0, strlen($url)-1);
87
+		}
83 88
 			if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
84 89
 				$url=$this->getUrl($url);
85 90
 			}
@@ -159,8 +164,9 @@  discard block
 block discarded – undo
159 164
 				$retour.="\t".$jsCallback."\n".
160 165
 						"\t$(document).trigger('jsonReady',[data]);\n".
161 166
 						"});\n";
162
-				if ($immediatly)
163
-					$this->jquery_code_for_compile[]=$retour;
167
+				if ($immediatly) {
168
+									$this->jquery_code_for_compile[]=$retour;
169
+				}
164 170
 		return $retour;
165 171
 	}
166 172
 
@@ -225,7 +231,7 @@  discard block
 block discarded – undo
225 231
 		if($context===null){
226 232
 			$parent="$('".$maskSelector."').parent()";
227 233
 			$newElm = "$('#'+newId)";
228
-		}else{
234
+		} else{
229 235
 			$parent=$context;
230 236
 			$newElm = $context.".find('#'+newId)";
231 237
 		}
@@ -238,8 +244,9 @@  discard block
 block discarded – undo
238 244
 		$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";
239 245
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
240 246
 		$retour.="\t".$jsCallback."\n"."});\n";
241
-		if ($immediatly)
242
-			$this->jquery_code_for_compile[]=$retour;
247
+		if ($immediatly) {
248
+					$this->jquery_code_for_compile[]=$retour;
249
+		}
243 250
 		return $retour;
244 251
 	}
245 252
 
@@ -430,8 +437,9 @@  discard block
 block discarded – undo
430 437
 			}});\n";
431 438
 			$retour.="$('#".$form."').submit();\n";
432 439
 		}
433
-		if ($immediatly)
434
-			$this->jquery_code_for_compile[]=$retour;
440
+		if ($immediatly) {
441
+					$this->jquery_code_for_compile[]=$retour;
442
+		}
435 443
 		return $retour;
436 444
 	}
437 445
 
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsEventsTrait.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 trait JsUtilsEventsTrait {
11 11
 
12 12
 
13
-	protected $jquery_events=array (
14
-			"bind","blur","change","click","dblclick","delegate","die","error","focus","focusin","focusout","hover","keydown","keypress","keyup","live","load","mousedown","mousseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","off","on","one","ready","resize","scroll","select","submit","toggle","trigger","triggerHandler","undind","undelegate","unload"
13
+	protected $jquery_events=array(
14
+			"bind", "blur", "change", "click", "dblclick", "delegate", "die", "error", "focus", "focusin", "focusout", "hover", "keydown", "keypress", "keyup", "live", "load", "mousedown", "mousseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "off", "on", "one", "ready", "resize", "scroll", "select", "submit", "toggle", "trigger", "triggerHandler", "undind", "undelegate", "unload"
15 15
 	);
16 16
 
17 17
 	/**
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.
25 25
 	 * @return string
26 26
 	 */
27
-	public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true) {
27
+	public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true) {
28 28
 		if (\is_array($js)) {
29 29
 			$js=implode("\n\t\t", $js);
30 30
 		}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 			$event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n";
39 39
 			else
40 40
 				$event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n";
41
-				if($immediatly)
41
+				if ($immediatly)
42 42
 					$this->jquery_code_for_compile[]=$event;
43 43
 					return $event;
44 44
 	}
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function click($element='this', $js='', $ret_false=TRUE) {
77 77
 		if (!is_array($js)) {
78
-			$js=array (
78
+			$js=array(
79 79
 					$js
80 80
 			);
81 81
 		}
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,12 +34,14 @@
 block discarded – undo
34 34
 		if ($stopPropagation===true) {
35 35
 			$js=Javascript::$stopPropagation.$js;
36 36
 		}
37
-		if (array_search($event, $this->jquery_events)===false)
38
-			$event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n";
39
-			else
40
-				$event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n";
41
-				if($immediatly)
42
-					$this->jquery_code_for_compile[]=$event;
37
+		if (array_search($event, $this->jquery_events)===false) {
38
+					$event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n";
39
+		} else {
40
+							$event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n";
41
+			}
42
+				if($immediatly) {
43
+									$this->jquery_code_for_compile[]=$event;
44
+				}
43 45
 					return $event;
44 46
 	}
45 47
 
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsInternalTrait.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@  discard block
 block discarded – undo
2 2
 namespace Ajax\common\traits;
3 3
 use Ajax\common\BaseGui;
4 4
 
5
-trait JsUtilsInternalTrait{
5
+trait JsUtilsInternalTrait {
6 6
 
7
-	protected $jquery_code_for_compile=array ();
7
+	protected $jquery_code_for_compile=array();
8 8
 
9 9
 	protected function _addToCompile($jsScript) {
10 10
 		$this->jquery_code_for_compile[]=$jsScript;
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 	 * @param BaseGui $library
15 15
 	 * @param mixed $view
16 16
 	 */
17
-	private function _compileLibrary($library, &$view=NULL){
17
+	private function _compileLibrary($library, &$view=NULL) {
18 18
 		if ($library!=NULL) {
19
-			if(isset($view))
19
+			if (isset($view))
20 20
 				$library->compileHtml($this, $view);
21 21
 			if ($library->isAutoCompile()) {
22 22
 				$library->compile(true);
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
 		}
25 25
 	}
26 26
 
27
-	private function defer($script){
27
+	private function defer($script) {
28 28
 		$result="window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { defer(method) }, 50);};";
29 29
 		$result.="window.defer(function(){".$script."})";
30 30
 		return $result;
31 31
 	}
32 32
 
33
-	private function ready($script){
33
+	private function ready($script) {
34 34
 		$result='$(document).ready(function() {'."\n";
35 35
 		$result.=$script.'})';
36 36
 		return $result;
37 37
 	}
38 38
 
39 39
 	private function minify($input) {
40
-		if(trim($input) === "") return $input;
40
+		if (trim($input)==="") return $input;
41 41
 		return preg_replace(
42 42
 				array(
43 43
 						// Remove comment(s)
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,8 +16,9 @@  discard block
 block discarded – undo
16 16
 	 */
17 17
 	private function _compileLibrary($library, &$view=NULL){
18 18
 		if ($library!=NULL) {
19
-			if(isset($view))
20
-				$library->compileHtml($this, $view);
19
+			if(isset($view)) {
20
+							$library->compileHtml($this, $view);
21
+			}
21 22
 			if ($library->isAutoCompile()) {
22 23
 				$library->compile(true);
23 24
 			}
@@ -37,7 +38,9 @@  discard block
 block discarded – undo
37 38
 	}
38 39
 
39 40
 	private function minify($input) {
40
-		if(trim($input) === "") return $input;
41
+		if(trim($input) === "") {
42
+			return $input;
43
+		}
41 44
 		return preg_replace(
42 45
 				array(
43 46
 						// Remove comment(s)
Please login to merge, or discard this patch.