Completed
Push — master ( 55f351...d9189f )
by Jean-Christophe
03:28
created
Ajax/service/AjaxTransition.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Ajax\service;
3 3
 class AjaxTransition {
4
-	public static function none($responseElement,$jqueryDone="html"){
4
+	public static function none($responseElement, $jqueryDone="html") {
5 5
 		return "$({$responseElement}).{$jqueryDone}( data )";
6 6
 	}
7 7
 
8
-	public static function fade($responseElement,$jqueryDone="html"){
8
+	public static function fade($responseElement, $jqueryDone="html") {
9 9
 		return "$({$responseElement}).hide().{$jqueryDone}( data ).fadeIn()";
10 10
 	}
11 11
 
12
-	public static function slide($responseElement,$jqueryDone="html"){
12
+	public static function slide($responseElement, $jqueryDone="html") {
13 13
 		return "$({$responseElement}).hide().{$jqueryDone}( data ).slideDown()";
14 14
 	}
15 15
 
16
-	public static function bSlidedown($responseElement,$jqueryDone="html"){
16
+	public static function bSlidedown($responseElement, $jqueryDone="html") {
17 17
 		return "$({$responseElement}).{$jqueryDone}( data ).transition('slide down in')";
18 18
 	}
19 19
 
20
-	public static function bScale($responseElement,$jqueryDone="html"){
20
+	public static function bScale($responseElement, $jqueryDone="html") {
21 21
 		return "$({$responseElement}).{$jqueryDone}( data ).transition('scale in')";
22 22
 	}
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/Jquery.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
  * @license Apache 2 http://www.apache.org/licenses/
16 16
  **/
17 17
 class Jquery {
18
-	use JqueryEventsTrait,JqueryAjaxTrait,JqueryActionsTrait;
18
+	use JqueryEventsTrait, JqueryAjaxTrait, JqueryActionsTrait;
19 19
 	protected $_ui;
20 20
 	protected $_bootstrap;
21 21
 	protected $_semantic;
22
-	protected $jquery_code_for_compile=array ();
22
+	protected $jquery_code_for_compile=array();
23 23
 	protected $jsUtils;
24 24
 	protected $params;
25 25
 
26
-	protected $jquery_events=array (
27
-			"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"
26
+	protected $jquery_events=array(
27
+			"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"
28 28
 	);
29 29
 
30 30
 	public function ui($ui=NULL) {
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 		return $this->_semantic;
49 49
 	}
50 50
 
51
-	public function __construct($params,$jsUtils) {
51
+	public function __construct($params, $jsUtils) {
52 52
 		$this->params=array();
53
-		foreach ( $params as $key => $val ) {
53
+		foreach ($params as $key => $val) {
54 54
 				$this->params[$key]=$params[$key];
55 55
 		}
56 56
 		$this->jsUtils=$jsUtils;
57
-		if(isset($params["ajaxTransition"]))
57
+		if (isset($params["ajaxTransition"]))
58 58
 			$this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]);
59 59
 	}
60 60
 
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function _output($array_js='') {
118 118
 		if (!is_array($array_js)) {
119
-			$array_js=array (
119
+			$array_js=array(
120 120
 					$array_js
121 121
 			);
122 122
 		}
123 123
 
124
-		foreach ( $array_js as $js ) {
124
+		foreach ($array_js as $js) {
125 125
 			$this->jquery_code_for_compile[]="\t$js\n";
126 126
 		}
127 127
 	}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @param string $param
134 134
 	 * @param boolean $immediatly delayed if false
135 135
 	 */
136
-	public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) {
136
+	public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) {
137 137
 		$element=Javascript::prep_element($element);
138 138
 		if (isset($param)) {
139 139
 			$param=Javascript::prep_value($param);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @param boolean $immediatly delayed if false
153 153
 	 * @return string
154 154
 	 */
155
-	public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) {
155
+	public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) {
156 156
 		$to=Javascript::prep_element($to);
157 157
 		$element=Javascript::prep_element($element);
158 158
 		$str="$({$to}).{$jQueryCall}({$element});";
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	public function sortable($element, $options=array()) {
172 172
 		if (count($options)>0) {
173
-			$sort_options=array ();
174
-			foreach ( $options as $k => $v ) {
173
+			$sort_options=array();
174
+			foreach ($options as $k => $v) {
175 175
 				$sort_options[]="\n\t\t".$k.': '.$v."";
176 176
 			}
177 177
 			$sort_options=implode(",", $sort_options);
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.
204 204
 	 * @return string
205 205
 	 */
206
-	public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true) {
206
+	public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true) {
207 207
 		if (\is_array($js)) {
208 208
 			$js=implode("\n\t\t", $js);
209 209
 		}
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n";
218 218
 		else
219 219
 			$event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n";
220
-		if($immediatly)
220
+		if ($immediatly)
221 221
 			$this->jquery_code_for_compile[]=$event;
222 222
 		return $event;
223 223
 	}
@@ -243,29 +243,29 @@  discard block
 block discarded – undo
243 243
 		$script='$(document).ready(function() {'."\n";
244 244
 		$script.=implode('', $this->jquery_code_for_compile);
245 245
 		$script.='})';
246
-		if($this->params["defer"]){
246
+		if ($this->params["defer"]) {
247 247
 			$script=$this->defer($script);
248 248
 		}
249 249
 		$script.=";";
250 250
 		$this->jquery_code_for_compile=array();
251
-		if($this->params["debug"]===false){
251
+		if ($this->params["debug"]===false) {
252 252
 			$script=$this->minify($script);
253 253
 		}
254 254
 		$output=($script_tags===FALSE) ? $script : $this->inline($script);
255 255
 
256
-		if ($view!==NULL){
257
-			$this->jsUtils->createScriptVariable($view,$view_var, $output);
256
+		if ($view!==NULL) {
257
+			$this->jsUtils->createScriptVariable($view, $view_var, $output);
258 258
 		}
259 259
 		return $output;
260 260
 	}
261 261
 
262
-	private function defer($script){
262
+	private function defer($script) {
263 263
 		$result="window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { defer(method) }, 50);};";
264 264
 		$result.="window.defer(function(){".$script."})";
265 265
 		return $result;
266 266
 	}
267 267
 
268
-	private function _compileLibrary($library){
268
+	private function _compileLibrary($library) {
269 269
 		if ($library!=NULL) {
270 270
 			if ($library->isAutoCompile()) {
271 271
 				$library->compile(true);
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 * @return void
284 284
 	 */
285 285
 	public function _clear_compile() {
286
-		$this->jquery_code_for_compile=array ();
286
+		$this->jquery_code_for_compile=array();
287 287
 	}
288 288
 
289 289
 	/**
@@ -292,18 +292,18 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	public function _document_ready($js) {
294 294
 		if (!is_array($js)) {
295
-			$js=array (
295
+			$js=array(
296 296
 					$js
297 297
 			);
298 298
 		}
299 299
 
300
-		foreach ( $js as $script ) {
300
+		foreach ($js as $script) {
301 301
 			$this->jquery_code_for_compile[]=$script;
302 302
 		}
303 303
 	}
304 304
 
305 305
 	private function minify($input) {
306
-	if(trim($input) === "") return $input;
306
+	if (trim($input)==="") return $input;
307 307
 	return preg_replace(
308 308
 			array(
309 309
 					// Remove comment(s)
Please login to merge, or discard this patch.
Braces   +23 added lines, -15 removed lines patch added patch discarded remove patch
@@ -54,8 +54,9 @@  discard block
 block discarded – undo
54 54
 				$this->params[$key]=$params[$key];
55 55
 		}
56 56
 		$this->jsUtils=$jsUtils;
57
-		if(isset($params["ajaxTransition"]))
58
-			$this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]);
57
+		if(isset($params["ajaxTransition"])) {
58
+					$this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]);
59
+		}
59 60
 	}
60 61
 
61 62
 	/**
@@ -138,10 +139,12 @@  discard block
 block discarded – undo
138 139
 		if (isset($param)) {
139 140
 			$param=Javascript::prep_value($param);
140 141
 			$str="$({$element}).{$jQueryCall}({$param});";
141
-		} else
142
-			$str="$({$element}).{$jQueryCall}();";
143
-			if ($immediatly)
144
-				$this->jquery_code_for_compile[]=$str;
142
+		} else {
143
+					$str="$({$element}).{$jQueryCall}();";
144
+		}
145
+			if ($immediatly) {
146
+							$this->jquery_code_for_compile[]=$str;
147
+			}
145 148
 			return $str;
146 149
 	}
147 150
 	/**
@@ -156,8 +159,9 @@  discard block
 block discarded – undo
156 159
 		$to=Javascript::prep_element($to);
157 160
 		$element=Javascript::prep_element($element);
158 161
 		$str="$({$to}).{$jQueryCall}({$element});";
159
-		if ($immediatly)
160
-			$this->jquery_code_for_compile[]=$str;
162
+		if ($immediatly) {
163
+					$this->jquery_code_for_compile[]=$str;
164
+		}
161 165
 			return $str;
162 166
 	}
163 167
 
@@ -213,12 +217,14 @@  discard block
 block discarded – undo
213 217
 		if ($stopPropagation===true) {
214 218
 			$js=Javascript::$stopPropagation.$js;
215 219
 		}
216
-		if (array_search($event, $this->jquery_events)===false)
217
-			$event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n";
218
-		else
219
-			$event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n";
220
-		if($immediatly)
221
-			$this->jquery_code_for_compile[]=$event;
220
+		if (array_search($event, $this->jquery_events)===false) {
221
+					$event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n";
222
+		} else {
223
+					$event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n";
224
+		}
225
+		if($immediatly) {
226
+					$this->jquery_code_for_compile[]=$event;
227
+		}
222 228
 		return $event;
223 229
 	}
224 230
 
@@ -303,7 +309,9 @@  discard block
 block discarded – undo
303 309
 	}
304 310
 
305 311
 	private function minify($input) {
306
-	if(trim($input) === "") return $input;
312
+	if(trim($input) === "") {
313
+		return $input;
314
+	}
307 315
 	return preg_replace(
308 316
 			array(
309 317
 					// Remove comment(s)
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsAjaxTrait.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
26 26
 	 * @param string|callable $ajaxTransition
27 27
 	 */
28
-	public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
29
-		return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true);
28
+	public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
29
+		return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true);
30 30
 	}
31 31
 
32 32
 	/**
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	 * @param string $jsCallback javascript code to execute after the request
38 38
 	 * @param boolean $immediatly
39 39
 	 */
40
-	public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) {
41
-		return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context,$immediatly);
40
+	public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) {
41
+		return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context, $immediatly);
42 42
 	}
43 43
 
44 44
 	/**
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	 * @param string $url the request address
49 49
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
50 50
 	 */
51
-	public function jsonOn($event,$element, $url,$parameters=array()) {
52
-		return $this->js->_jsonOn($event, $element, $url,$parameters);
51
+	public function jsonOn($event, $element, $url, $parameters=array()) {
52
+		return $this->js->_jsonOn($event, $element, $url, $parameters);
53 53
 	}
54 54
 
55 55
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @param string $jsCallback javascript code to execute after the request
72 72
 	 */
73 73
 	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL) {
74
-		return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, NULL,true);
74
+		return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, NULL, true);
75 75
 	}
76 76
 
77 77
 	/**
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 	 * @param string $url the request url
94 94
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
95 95
 	 */
96
-	public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) {
97
-		return $this->js->_jsonArrayOn($event,$element,$maskSelector, $url, $parameters);
96
+	public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) {
97
+		return $this->js->_jsonArrayOn($event, $element, $maskSelector, $url, $parameters);
98 98
 	}
99 99
 
100 100
 	/**
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
109 109
 	 * @param string|callable $ajaxTransition
110 110
 	 */
111
-	public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) {
112
-		return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false,$jqueryDone,$ajaxTransition);
111
+	public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) {
112
+		return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition);
113 113
 	}
114 114
 
115 115
 	/**
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
149 149
 	 * @param string|callable $ajaxTransition
150 150
 	 */
151
-	public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
152
-		return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true);
151
+	public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
152
+		return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true);
153 153
 	}
154 154
 
155 155
 	/**
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
165 165
 	 * @param string|callable $ajaxTransition
166 166
 	 */
167
-	public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
168
-		return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false);
167
+	public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
168
+		return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false);
169 169
 	}
170 170
 
171 171
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null)
180 180
 	 */
181 181
 	public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
182
-		return $this->js->_postOn($event, $element,  $url, $params, $responseElement, $parameters);
182
+		return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters);
183 183
 	}
184 184
 
185 185
 	/**
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
206 206
 	 * @param string|callable $ajaxTransition
207 207
 	 */
208
-	public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
209
-		return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true);
208
+	public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
209
+		return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true);
210 210
 	}
211 211
 
212 212
 	/**
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
222 222
 	 * @param string|callable $ajaxTransition
223 223
 	 */
224
-	public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
225
-		return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false);
224
+	public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
225
+		return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false);
226 226
 	}
227 227
 
228 228
 	/**
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null)
237 237
 	 */
238 238
 	public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) {
239
-		return $this->js->_postFormOn($event,$element, $url, $form, $responseElement, $parameters);
239
+		return $this->js->_postFormOn($event, $element, $url, $form, $responseElement, $parameters);
240 240
 	}
241 241
 
242 242
 	/**
Please login to merge, or discard this patch.
Ajax/common/traits/JqueryAjaxTrait.php 2 patches
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	protected $ajaxTransition;
18 18
 	protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>';
19 19
 
20
-	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
20
+	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true);
21 21
 	protected function addLoading(&$retour, $responseElement) {
22 22
 		$loading_notifier='<div class="ajax-loader">';
23 23
 		if ($this->ajaxLoader=='') {
@@ -30,66 +30,66 @@  discard block
 block discarded – undo
30 30
 		$retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n";
31 31
 	}
32 32
 
33
-	public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
34
-		return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly);
33
+	public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
34
+		return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly);
35 35
 	}
36
-	public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
37
-		return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly);
36
+	public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
37
+		return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly);
38 38
 	}
39 39
 
40
-	protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
41
-		if(JString::isNull($params)){$params="{}";}
40
+	protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
41
+		if (JString::isNull($params)) {$params="{}"; }
42 42
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
43 43
 		$retour=$this->_getAjaxUrl($url, $attr);
44 44
 		$responseElement=$this->_getResponseElement($responseElement);
45 45
 		$retour.="var self=this;\n";
46
-		if($hasLoader===true){
46
+		if ($hasLoader===true) {
47 47
 			$this->addLoading($retour, $responseElement);
48 48
 		}
49 49
 		$retour.="$.".$method."(url,".$params.").done(function( data ) {\n";
50
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
50
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
51 51
 		if ($immediatly)
52 52
 			$this->jquery_code_for_compile[]=$retour;
53 53
 			return $retour;
54 54
 	}
55 55
 
56
-	protected function setAjaxDataCall($params){
56
+	protected function setAjaxDataCall($params) {
57 57
 		$result=null;
58
-		if(!\is_callable($params) && \method_exists("Ajax\service\AjaxTransition",$params)){
59
-			$result=function ($responseElement,$jqueryDone="html") use($params){
60
-				return AjaxTransition::{$params}($responseElement,$jqueryDone);
58
+		if (!\is_callable($params) && \method_exists("Ajax\service\AjaxTransition", $params)) {
59
+			$result=function($responseElement, $jqueryDone="html") use($params){
60
+				return AjaxTransition::{$params}($responseElement, $jqueryDone);
61 61
 			};
62 62
 		}
63 63
 		return $result;
64 64
 	}
65 65
 
66
-	protected function _getAjaxUrl($url,$attr){
66
+	protected function _getAjaxUrl($url, $attr) {
67 67
 		$url=$this->_correctAjaxUrl($url);
68 68
 		$retour="url='".$url."';";
69 69
 		$slash="/";
70
-		if(JString::endswith($url, "/")===true)
70
+		if (JString::endswith($url, "/")===true)
71 71
 			$slash="";
72
-		if(JString::isNotNull($attr)){
72
+		if (JString::isNotNull($attr)) {
73 73
 			if ($attr==="value")
74 74
 				$retour.="url=url+'".$slash."'+$(this).val();\n";
75 75
 			elseif ($attr==="html")
76 76
 			$retour.="url=url+'".$slash."'+$(this).html();\n";
77
-			elseif($attr!=null && $attr!=="")
77
+			elseif ($attr!=null && $attr!=="")
78 78
 					$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
79 79
 		}
80 80
 		return $retour;
81 81
 	}
82 82
 
83
-	protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){
84
-		$retour="";$call=null;
83
+	protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) {
84
+		$retour=""; $call=null;
85 85
 		if ($responseElement!=="") {
86
-			if(isset($ajaxTransition)){
86
+			if (isset($ajaxTransition)) {
87 87
 				$call=$this->setAjaxDataCall($ajaxTransition);
88
-			}elseif(isset($this->ajaxTransition)){
88
+			}elseif (isset($this->ajaxTransition)) {
89 89
 				$call=$this->ajaxTransition;
90 90
 			}
91
-			if(\is_callable($call))
92
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
91
+			if (\is_callable($call))
92
+				$retour="\t".$call($responseElement, $jqueryDone).";\n";
93 93
 			else
94 94
 				$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
95 95
 		}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		return $retour;
98 98
 	}
99 99
 
100
-	protected function _getResponseElement($responseElement){
100
+	protected function _getResponseElement($responseElement) {
101 101
 		if ($responseElement!=="") {
102 102
 			$responseElement=Javascript::prep_value($responseElement);
103 103
 		}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	protected function _correctAjaxUrl($url) {
108 108
 		if ($url!=="/" && JString::endsWith($url, "/")===true)
109 109
 			$url=substr($url, 0, strlen($url)-1);
110
-		if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
110
+		if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) {
111 111
 			$url=$this->jsUtils->getUrl($url);
112 112
 		}
113 113
 		return $url;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @param string $jsCallback javascript code to execute after the request
122 122
 	 * @param boolean $immediatly
123 123
 	 */
124
-	public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) {
124
+	public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) {
125 125
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
126 126
 		$retour=$this->_getAjaxUrl($url, $attr);
127 127
 		$retour.="$.{$method}(url,".$params.").done(function( data ) {\n";
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @param string $url the request address
143 143
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
144 144
 	 */
145
-	public function _jsonOn($event,$element, $url,$parameters=array()) {
145
+	public function _jsonOn($event, $element, $url, $parameters=array()) {
146 146
 		$preventDefault=true;
147 147
 		$stopPropagation=true;
148 148
 		$jsCallback=null;
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 		$params="{}";
153 153
 		$immediatly=true;
154 154
 		extract($parameters);
155
-		return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly);
155
+		return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly);
156 156
 	}
157 157
 
158 158
 	/**
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
 	 * @param string $context jquery DOM element, array container.
165 165
 	 * @param boolean $immediatly
166 166
 	 */
167
-	public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) {
167
+	public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) {
168 168
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
169 169
 		$retour=$this->_getAjaxUrl($url, $attr);
170
-		if($context===null){
170
+		if ($context===null) {
171 171
 			$appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n";
172
-			$newElm = "$('#'+newId)";
173
-		}else{
172
+			$newElm="$('#'+newId)";
173
+		} else {
174 174
 			$appendTo="\t\tnewElm.appendTo(".$context.");\n";
175
-			$newElm = $context.".find('#'+newId)";
175
+			$newElm=$context.".find('#'+newId)";
176 176
 		}
177 177
 		$retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n";
178 178
 		$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();newElm.attr('id',newId);\n";
179
-		$retour.= $appendTo;
179
+		$retour.=$appendTo;
180 180
 		$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";
181 181
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
182 182
 		$retour.="\t".$jsCallback."\n"."});\n";
@@ -191,30 +191,30 @@  discard block
 block discarded – undo
191 191
 	 * @param string $url the request address
192 192
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null)
193 193
 	 */
194
-	public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) {
194
+	public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) {
195 195
 		$preventDefault=true;
196 196
 		$stopPropagation=true;
197 197
 		$jsCallback=null;
198 198
 		$attr="id";
199 199
 		$method="get";
200
-		$context = null;
200
+		$context=null;
201 201
 		$params="{}";
202 202
 		$immediatly=true;
203 203
 		extract($parameters);
204
-		return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly);
204
+		return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly);
205 205
 	}
206 206
 
207
-	public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
207
+	public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
208 208
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
209 209
 		$retour=$this->_getAjaxUrl($url, $attr);
210 210
 		$retour.="\nvar params=$('#".$form."').serialize();\n";
211 211
 		$responseElement=$this->_getResponseElement($responseElement);
212 212
 		$retour.="var self=this;\n";
213
-		if($hasLoader===true){
213
+		if ($hasLoader===true) {
214 214
 			$this->addLoading($retour, $responseElement);
215 215
 		}
216 216
 		$retour.="$.post(url,params).done(function( data ) {\n";
217
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
217
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
218 218
 
219 219
 		if ($validation) {
220 220
 			$retour="$('#".$form."').validate({submitHandler: function(form) {
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 * @param string $responseElement
238 238
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null,"jqueryDone"=>"html")
239 239
 	 */
240
-	public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) {
240
+	public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
241 241
 		$preventDefault=true;
242 242
 		$stopPropagation=true;
243 243
 		$jsCallback=null;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 		$jqueryDone="html";
248 248
 		$ajaxTransition=null;
249 249
 		extract($parameters);
250
-		return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
250
+		return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
251 251
 	}
252 252
 
253 253
 	/**
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 * @param string $responseElement
261 261
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null)
262 262
 	 */
263
-	public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) {
263
+	public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
264 264
 		$preventDefault=true;
265 265
 		$stopPropagation=true;
266 266
 		$jsCallback=null;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 		$jqueryDone="html";
271 271
 		$ajaxTransition=null;
272 272
 		extract($parameters);
273
-		return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
273
+		return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
274 274
 	}
275 275
 
276 276
 	/**
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 * @param string $responseElement
284 284
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null,"immediatly"=>true)
285 285
 	 */
286
-	public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) {
286
+	public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) {
287 287
 		$preventDefault=true;
288 288
 		$stopPropagation=true;
289 289
 		$validation=false;
@@ -294,6 +294,6 @@  discard block
 block discarded – undo
294 294
 		$jqueryDone="html";
295 295
 		$ajaxTransition=null;
296 296
 		extract($parameters);
297
-		return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
297
+		return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
298 298
 	}
299 299
 }
300 300
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +32 added lines, -24 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
 		}
49 49
 		$retour.="$.".$method."(url,".$params.").done(function( data ) {\n";
50 50
 		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
51
-		if ($immediatly)
52
-			$this->jquery_code_for_compile[]=$retour;
51
+		if ($immediatly) {
52
+					$this->jquery_code_for_compile[]=$retour;
53
+		}
53 54
 			return $retour;
54 55
 	}
55 56
 
@@ -67,15 +68,17 @@  discard block
 block discarded – undo
67 68
 		$url=$this->_correctAjaxUrl($url);
68 69
 		$retour="url='".$url."';";
69 70
 		$slash="/";
70
-		if(JString::endswith($url, "/")===true)
71
-			$slash="";
71
+		if(JString::endswith($url, "/")===true) {
72
+					$slash="";
73
+		}
72 74
 		if(JString::isNotNull($attr)){
73
-			if ($attr==="value")
74
-				$retour.="url=url+'".$slash."'+$(this).val();\n";
75
-			elseif ($attr==="html")
76
-			$retour.="url=url+'".$slash."'+$(this).html();\n";
77
-			elseif($attr!=null && $attr!=="")
78
-					$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
75
+			if ($attr==="value") {
76
+							$retour.="url=url+'".$slash."'+$(this).val();\n";
77
+			} elseif ($attr==="html") {
78
+						$retour.="url=url+'".$slash."'+$(this).html();\n";
79
+			} elseif($attr!=null && $attr!=="") {
80
+								$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
81
+			}
79 82
 		}
80 83
 		return $retour;
81 84
 	}
@@ -85,13 +88,14 @@  discard block
 block discarded – undo
85 88
 		if ($responseElement!=="") {
86 89
 			if(isset($ajaxTransition)){
87 90
 				$call=$this->setAjaxDataCall($ajaxTransition);
88
-			}elseif(isset($this->ajaxTransition)){
91
+			} elseif(isset($this->ajaxTransition)){
89 92
 				$call=$this->ajaxTransition;
90 93
 			}
91
-			if(\is_callable($call))
92
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
93
-			else
94
-				$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
94
+			if(\is_callable($call)) {
95
+							$retour="\t".$call($responseElement,$jqueryDone).";\n";
96
+			} else {
97
+							$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
98
+			}
95 99
 		}
96 100
 		$retour.="\t".$jsCallback."\n";
97 101
 		return $retour;
@@ -105,8 +109,9 @@  discard block
 block discarded – undo
105 109
 	}
106 110
 
107 111
 	protected function _correctAjaxUrl($url) {
108
-		if ($url!=="/" && JString::endsWith($url, "/")===true)
109
-			$url=substr($url, 0, strlen($url)-1);
112
+		if ($url!=="/" && JString::endsWith($url, "/")===true) {
113
+					$url=substr($url, 0, strlen($url)-1);
114
+		}
110 115
 		if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
111 116
 			$url=$this->jsUtils->getUrl($url);
112 117
 		}
@@ -130,8 +135,9 @@  discard block
 block discarded – undo
130 135
 				$retour.="\t".$jsCallback."\n".
131 136
 						"\t$(document).trigger('jsonReady',[data]);\n".
132 137
 						"});\n";
133
-				if ($immediatly)
134
-					$this->jquery_code_for_compile[]=$retour;
138
+				if ($immediatly) {
139
+									$this->jquery_code_for_compile[]=$retour;
140
+				}
135 141
 					return $retour;
136 142
 	}
137 143
 
@@ -170,7 +176,7 @@  discard block
 block discarded – undo
170 176
 		if($context===null){
171 177
 			$appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n";
172 178
 			$newElm = "$('#'+newId)";
173
-		}else{
179
+		} else{
174 180
 			$appendTo="\t\tnewElm.appendTo(".$context.");\n";
175 181
 			$newElm = $context.".find('#'+newId)";
176 182
 		}
@@ -180,8 +186,9 @@  discard block
 block discarded – undo
180 186
 		$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";
181 187
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
182 188
 		$retour.="\t".$jsCallback."\n"."});\n";
183
-		if ($immediatly)
184
-			$this->jquery_code_for_compile[]=$retour;
189
+		if ($immediatly) {
190
+					$this->jquery_code_for_compile[]=$retour;
191
+		}
185 192
 			return $retour;
186 193
 	}
187 194
 	/**
@@ -222,8 +229,9 @@  discard block
 block discarded – undo
222 229
 			}});\n";
223 230
 			$retour.="$('#".$form."').submit();\n";
224 231
 		}
225
-		if ($immediatly)
226
-			$this->jquery_code_for_compile[]=$retour;
232
+		if ($immediatly) {
233
+					$this->jquery_code_for_compile[]=$retour;
234
+		}
227 235
 			return $retour;
228 236
 	}
229 237
 
Please login to merge, or discard this patch.