@@ -16,19 +16,19 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | /** |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
152 | 152 | * @param string|callable $ajaxTransition |
153 | 153 | */ |
154 | - public function ajax($method,$url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
154 | + public function ajax($method, $url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
155 | 155 | $method=\strtolower($method); |
156 | - return $this->_ajax($method,$url,$params,$responseElement,$jsCallback,null,$hasLoader,$jqueryDone,$ajaxTransition,true); |
|
156 | + return $this->_ajax($method, $url, $params, $responseElement, $jsCallback, null, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param string $context |
167 | 167 | * @param boolean $immediatly |
168 | 168 | */ |
169 | - private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
169 | + private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
170 | 170 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
171 | 171 | $retour=$this->_getAjaxUrl($url, $attr); |
172 | 172 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * @param string $context |
190 | 190 | * @param boolean $immediatly |
191 | 191 | */ |
192 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL,$context="document",$immediatly=false) { |
|
193 | - return $this->_json($url,$method,$params,$jsCallback,NULL,$context,$immediatly); |
|
192 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $context="document", $immediatly=false) { |
|
193 | + return $this->_json($url, $method, $params, $jsCallback, NULL, $context, $immediatly); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param string $url the request address |
201 | 201 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
202 | 202 | */ |
203 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
203 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
204 | 204 | $preventDefault=true; |
205 | 205 | $stopPropagation=true; |
206 | 206 | $jsCallback=null; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $params="{}"; |
211 | 211 | $immediatly=true; |
212 | 212 | extract($parameters); |
213 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
213 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @param string $jsCallback javascript code to execute after the request |
222 | 222 | * @param string $context jquery DOM element, array container. |
223 | 223 | */ |
224 | - public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL,$context=NULL) { |
|
225 | - return $this->json($url, $method, $params, $jsCallback, $context,false); |
|
224 | + public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL, $context=NULL) { |
|
225 | + return $this->json($url, $method, $params, $jsCallback, $context, false); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -235,22 +235,22 @@ discard block |
||
235 | 235 | * @param string $rowClass the css class for the new element |
236 | 236 | * @param boolean $immediatly |
237 | 237 | */ |
238 | - private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$attr="id",$immediatly=false) { |
|
238 | + private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $attr="id", $immediatly=false) { |
|
239 | 239 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
240 | 240 | $retour=$this->_getAjaxUrl($url, $attr); |
241 | - if($context===null){ |
|
241 | + if ($context===null) { |
|
242 | 242 | $parent="$('".$maskSelector."').parent()"; |
243 | - $newElm = "$('#'+newId)"; |
|
244 | - }else{ |
|
243 | + $newElm="$('#'+newId)"; |
|
244 | + } else { |
|
245 | 245 | $parent=$context; |
246 | - $newElm = $context.".find('#'+newId)"; |
|
246 | + $newElm=$context.".find('#'+newId)"; |
|
247 | 247 | } |
248 | 248 | $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
249 | 249 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
250 | 250 | $retour.=$parent.".find('._json').remove();"; |
251 | 251 | $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(); |
252 | 252 | 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"; |
253 | - $retour.= $appendTo; |
|
253 | + $retour.=$appendTo; |
|
254 | 254 | $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"; |
255 | 255 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
256 | 256 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @param string $context jquery DOM element, array container. |
270 | 270 | * @param boolean $immediatly |
271 | 271 | */ |
272 | - public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$immediatly=false) { |
|
273 | - return $this->_jsonArray($maskSelector, $url,$method,$params,$jsCallback,$rowClass,$context,NULL,$immediatly); |
|
272 | + public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $immediatly=false) { |
|
273 | + return $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, NULL, $immediatly); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | * @param string $rowClass the css class for the new element |
284 | 284 | * @param string $context jquery DOM element, array container. |
285 | 285 | */ |
286 | - public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL) { |
|
287 | - return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback,$rowClass,$context,false); |
|
286 | + public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL) { |
|
287 | + return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, false); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -294,18 +294,18 @@ discard block |
||
294 | 294 | * @param string $url the request url |
295 | 295 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true) |
296 | 296 | */ |
297 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
297 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
298 | 298 | $preventDefault=true; |
299 | 299 | $stopPropagation=true; |
300 | 300 | $jsCallback=null; |
301 | 301 | $attr="id"; |
302 | 302 | $method="get"; |
303 | - $context = null; |
|
303 | + $context=null; |
|
304 | 304 | $params="{}"; |
305 | 305 | $immediatly=true; |
306 | 306 | $rowClass="_json"; |
307 | 307 | extract($parameters); |
308 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $rowClass, $context,$attr), $event, $preventDefault, $stopPropagation,$immediatly); |
|
308 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, $attr), $event, $preventDefault, $stopPropagation, $immediatly); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
320 | 320 | * @param string|callable $ajaxTransition |
321 | 321 | */ |
322 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) { |
|
323 | - return $this->_get($url, $params,$responseElement,$jsCallback,$attr,false,$jqueryDone,$ajaxTransition); |
|
322 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) { |
|
323 | + return $this->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $ajaxTransition=null; |
344 | 344 | $params="{}"; |
345 | 345 | extract($parameters); |
346 | - return $this->_add_event($element, $this->_get($url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
346 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $ajaxTransition=null; |
368 | 368 | $params="{}"; |
369 | 369 | extract($parameters); |
370 | - return $this->_add_event($element, $this->_ajax($method,$url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
370 | + return $this->_add_event($element, $this->_ajax($method, $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -394,8 +394,8 @@ discard block |
||
394 | 394 | return $this->getOn("click", $element, $url, $responseElement, $parameters); |
395 | 395 | } |
396 | 396 | |
397 | - private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
398 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
397 | + private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
398 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
409 | 409 | * @param string|callable $ajaxTransition |
410 | 410 | */ |
411 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
412 | - return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
411 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
412 | + return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
425 | 425 | * @param string|callable $ajaxTransition |
426 | 426 | */ |
427 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
428 | - return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
427 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
428 | + return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | $jqueryDone="html"; |
449 | 449 | $ajaxTransition=null; |
450 | 450 | extract($parameters); |
451 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
451 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -464,20 +464,20 @@ discard block |
||
464 | 464 | return $this->postOn("click", $element, $url, $params, $responseElement, $parameters); |
465 | 465 | } |
466 | 466 | |
467 | - private function _postForm($url, $form, $responseElement, $params=null,$validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
467 | + private function _postForm($url, $form, $responseElement, $params=null, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
468 | 468 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
469 | 469 | $retour=$this->_getAjaxUrl($url, $attr); |
470 | 470 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
471 | - if(isset($params)){ |
|
471 | + if (isset($params)) { |
|
472 | 472 | $retour.="params+='&'+$.param(".$params.");\n"; |
473 | 473 | } |
474 | 474 | $responseElement=$this->_getResponseElement($responseElement); |
475 | 475 | $retour.="var self=this;\n"; |
476 | - if($hasLoader===true){ |
|
476 | + if ($hasLoader===true) { |
|
477 | 477 | $this->addLoading($retour, $responseElement); |
478 | 478 | } |
479 | 479 | $retour.="$.post(url,params).done(function( data ) {\n"; |
480 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
480 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
481 | 481 | |
482 | 482 | if ($validation) { |
483 | 483 | $retour="$('#".$form."').validate({submitHandler: function(form) { |
@@ -501,8 +501,8 @@ discard block |
||
501 | 501 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
502 | 502 | * @param string|callable $ajaxTransition |
503 | 503 | */ |
504 | - public function postForm($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
505 | - return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
504 | + public function postForm($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
505 | + return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -519,8 +519,8 @@ discard block |
||
519 | 519 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
520 | 520 | * @param string|callable $ajaxTransition |
521 | 521 | */ |
522 | - public function postFormDeferred($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
523 | - return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
522 | + public function postFormDeferred($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
523 | + return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | /** |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | $jqueryDone="html"; |
546 | 546 | $ajaxTransition=null; |
547 | 547 | extract($parameters); |
548 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement,$params, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
548 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -15,36 +15,36 @@ discard block |
||
15 | 15 | protected $_paramParts=array(); |
16 | 16 | |
17 | 17 | public function __construct($identifier, $header="", $content="", $actions=null) { |
18 | - parent::__construct($identifier, "div","ui modal"); |
|
19 | - if(isset($header)){ |
|
18 | + parent::__construct($identifier, "div", "ui modal"); |
|
19 | + if (isset($header)) { |
|
20 | 20 | $this->setHeader($header); |
21 | 21 | } |
22 | - if(isset($content)){ |
|
22 | + if (isset($content)) { |
|
23 | 23 | $this->setContent($content); |
24 | 24 | } |
25 | - if(isset($actions)){ |
|
25 | + if (isset($actions)) { |
|
26 | 26 | $this->setActions($actions); |
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function setHeader($value) { |
31 | - $this->content["header"]=new HtmlSemDoubleElement("header-" . $this->identifier, "a", "header", $value); |
|
31 | + $this->content["header"]=new HtmlSemDoubleElement("header-".$this->identifier, "a", "header", $value); |
|
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function setContent($value) { |
36 | - $this->content["content"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", $value); |
|
36 | + $this->content["content"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", $value); |
|
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | 40 | public function setActions($actions) { |
41 | - $this->content["actions"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "actions"); |
|
42 | - if(\is_array($actions)){ |
|
43 | - foreach ($actions as $action){ |
|
41 | + $this->content["actions"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "actions"); |
|
42 | + if (\is_array($actions)) { |
|
43 | + foreach ($actions as $action) { |
|
44 | 44 | $this->addAction($action); |
45 | 45 | } |
46 | 46 | } |
47 | - else{ |
|
47 | + else { |
|
48 | 48 | $this->addAction($actions); |
49 | 49 | } |
50 | 50 | return $this; |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | * @param string|BaseHtml $action |
55 | 55 | * @return HtmlButton |
56 | 56 | */ |
57 | - public function addAction($action){ |
|
58 | - if(!$action instanceof BaseHtml){ |
|
57 | + public function addAction($action) { |
|
58 | + if (!$action instanceof BaseHtml) { |
|
59 | 59 | $class=""; |
60 | - if(\array_search($action, ["Okay","Yes"])!==false){ |
|
60 | + if (\array_search($action, ["Okay", "Yes"])!==false) { |
|
61 | 61 | $class="approve"; |
62 | 62 | } |
63 | - if(\array_search($action, ["Close","Cancel","No"])!==false){ |
|
63 | + if (\array_search($action, ["Close", "Cancel", "No"])!==false) { |
|
64 | 64 | $class="cancel"; |
65 | 65 | } |
66 | - $action=new HtmlButton("action-".$this->identifier."-".\sizeof($this->content["actions"]->getContent()),$action); |
|
67 | - if($class!=="") |
|
66 | + $action=new HtmlButton("action-".$this->identifier."-".\sizeof($this->content["actions"]->getContent()), $action); |
|
67 | + if ($class!=="") |
|
68 | 68 | $action->addToProperty("class", $class); |
69 | 69 | } |
70 | 70 | return $this->addElementInPart($action, "actions"); |
@@ -74,66 +74,66 @@ discard block |
||
74 | 74 | * @param int $index |
75 | 75 | * @return HtmlButton |
76 | 76 | */ |
77 | - public function getAction($index){ |
|
77 | + public function getAction($index) { |
|
78 | 78 | return $this->content["actions"]->getContent()[$index]; |
79 | 79 | } |
80 | 80 | |
81 | - public function addContent($content,$before=false){ |
|
82 | - $this->content["content"]->addContent($content,$before); |
|
81 | + public function addContent($content, $before=false) { |
|
82 | + $this->content["content"]->addContent($content, $before); |
|
83 | 83 | return $this; |
84 | 84 | } |
85 | 85 | |
86 | - public function addImageContent($image,$description=NULL){ |
|
86 | + public function addImageContent($image, $description=NULL) { |
|
87 | 87 | $content=$this->content["content"]; |
88 | - if(isset($description)){ |
|
89 | - $description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description); |
|
90 | - $content->addContent($description,true); |
|
88 | + if (isset($description)) { |
|
89 | + $description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description); |
|
90 | + $content->addContent($description, true); |
|
91 | 91 | } |
92 | - if($image!==""){ |
|
93 | - $img=new HtmlImage("image-".$this->identifier,$image,"","medium"); |
|
94 | - $content->addContent($img,true); |
|
95 | - $content->addToProperty("class","image"); |
|
92 | + if ($image!=="") { |
|
93 | + $img=new HtmlImage("image-".$this->identifier, $image, "", "medium"); |
|
94 | + $content->addContent($img, true); |
|
95 | + $content->addToProperty("class", "image"); |
|
96 | 96 | } |
97 | 97 | return $this; |
98 | 98 | } |
99 | 99 | |
100 | - public function addIconContent($icon,$description=NULL){ |
|
100 | + public function addIconContent($icon, $description=NULL) { |
|
101 | 101 | $content=$this->content["content"]; |
102 | - if(isset($description)){ |
|
103 | - $description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description); |
|
104 | - $content->addContent($description,true); |
|
102 | + if (isset($description)) { |
|
103 | + $description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description); |
|
104 | + $content->addContent($description, true); |
|
105 | 105 | } |
106 | - if($icon!==""){ |
|
107 | - $img=new HtmlIcon("image-".$this->identifier,$icon); |
|
108 | - $content->addContent($img,true); |
|
109 | - $content->addToProperty("class","image"); |
|
106 | + if ($icon!=="") { |
|
107 | + $img=new HtmlIcon("image-".$this->identifier, $icon); |
|
108 | + $content->addContent($img, true); |
|
109 | + $content->addToProperty("class", "image"); |
|
110 | 110 | } |
111 | 111 | return $this; |
112 | 112 | } |
113 | 113 | |
114 | - private function addElementInPart($element,$part) { |
|
114 | + private function addElementInPart($element, $part) { |
|
115 | 115 | $this->content[$part]->addContent($element); |
116 | 116 | return $element; |
117 | 117 | } |
118 | 118 | |
119 | - public function showDimmer($value){ |
|
120 | - $value=$value?"show":"hide"; |
|
119 | + public function showDimmer($value) { |
|
120 | + $value=$value ? "show" : "hide"; |
|
121 | 121 | $this->_paramParts[]=["'".$value." dimmer'"]; |
122 | 122 | return $this; |
123 | 123 | } |
124 | 124 | |
125 | - public function setInverted($recursive=true){ |
|
125 | + public function setInverted($recursive=true) { |
|
126 | 126 | $this->_params["inverted"]=true; |
127 | 127 | return $this; |
128 | 128 | } |
129 | 129 | |
130 | - public function setBasic(){ |
|
130 | + public function setBasic() { |
|
131 | 131 | return $this->addToProperty("class", "basic"); |
132 | 132 | } |
133 | 133 | |
134 | 134 | |
135 | - public function setTransition($value){ |
|
136 | - $this->_paramParts[]=["'setting'","'transition'","'".$value."'"]; |
|
135 | + public function setTransition($value) { |
|
136 | + $this->_paramParts[]=["'setting'", "'transition'", "'".$value."'"]; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @param string $viewName |
144 | 144 | * @param $params The parameters to pass to the view |
145 | 145 | */ |
146 | - public function renderView(JsUtils $js,$initialController,$viewName, $params=array()) { |
|
147 | - return $this->setContent($js->renderContent($initialController, $viewName,$params)); |
|
146 | + public function renderView(JsUtils $js, $initialController, $viewName, $params=array()) { |
|
147 | + return $this->setContent($js->renderContent($initialController, $viewName, $params)); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | * @param string $actionName the action name |
156 | 156 | * @param array $params |
157 | 157 | */ |
158 | - public function forward(JsUtils $js,$initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
159 | - return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName,$params)); |
|
158 | + public function forward(JsUtils $js, $initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
159 | + return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName, $params)); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
167 | 167 | */ |
168 | 168 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
169 | - $this->content=JArray::sortAssociative($this->content, ["header","content","actions" ]); |
|
169 | + $this->content=JArray::sortAssociative($this->content, ["header", "content", "actions"]); |
|
170 | 170 | return parent::compile($js, $view); |
171 | 171 | } |
172 | 172 | /* |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @see BaseHtml::run() |
175 | 175 | */ |
176 | 176 | public function run(JsUtils $js) { |
177 | - if(isset($this->_bsComponent)===false) |
|
178 | - $this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts); |
|
177 | + if (isset($this->_bsComponent)===false) |
|
178 | + $this->_bsComponent=$js->semantic()->modal("#".$this->identifier, $this->_params, $this->_paramParts); |
|
179 | 179 | $this->addEventsOnRun($js); |
180 | 180 | return $this->_bsComponent; |
181 | 181 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | return $this->jsDo("hide"); |
189 | 189 | } |
190 | 190 | |
191 | - public function onHidden($js){ |
|
191 | + public function onHidden($js) { |
|
192 | 192 | $this->_params["onHidden"]=$js; |
193 | 193 | } |
194 | 194 | } |
@@ -43,8 +43,7 @@ discard block |
||
43 | 43 | foreach ($actions as $action){ |
44 | 44 | $this->addAction($action); |
45 | 45 | } |
46 | - } |
|
47 | - else{ |
|
46 | + } else{ |
|
48 | 47 | $this->addAction($actions); |
49 | 48 | } |
50 | 49 | return $this; |
@@ -64,8 +63,9 @@ discard block |
||
64 | 63 | $class="cancel"; |
65 | 64 | } |
66 | 65 | $action=new HtmlButton("action-".$this->identifier."-".\sizeof($this->content["actions"]->getContent()),$action); |
67 | - if($class!=="") |
|
68 | - $action->addToProperty("class", $class); |
|
66 | + if($class!=="") { |
|
67 | + $action->addToProperty("class", $class); |
|
68 | + } |
|
69 | 69 | } |
70 | 70 | return $this->addElementInPart($action, "actions"); |
71 | 71 | } |
@@ -174,8 +174,9 @@ discard block |
||
174 | 174 | * @see BaseHtml::run() |
175 | 175 | */ |
176 | 176 | public function run(JsUtils $js) { |
177 | - if(isset($this->_bsComponent)===false) |
|
178 | - $this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts); |
|
177 | + if(isset($this->_bsComponent)===false) { |
|
178 | + $this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts); |
|
179 | + } |
|
179 | 180 | $this->addEventsOnRun($js); |
180 | 181 | return $this->_bsComponent; |
181 | 182 | } |