@@ -719,6 +719,9 @@ discard block |
||
719 | 719 | return $this->_create_json($json_result, $match_array_type); |
720 | 720 | } |
721 | 721 | |
722 | + /** |
|
723 | + * @param boolean $match_array_type |
|
724 | + */ |
|
722 | 725 | private function _create_json($json_result, $match_array_type) { |
723 | 726 | $json=array (); |
724 | 727 | $_is_assoc=TRUE; |
@@ -742,7 +745,7 @@ discard block |
||
742 | 745 | * Checks for an associative array |
743 | 746 | * |
744 | 747 | * @param type |
745 | - * @return type |
|
748 | + * @return boolean |
|
746 | 749 | */ |
747 | 750 | public function _is_associative_array($arr) { |
748 | 751 | foreach ( array_keys($arr) as $key => $val ) { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * JsUtils Class : Phalcon service to be injected |
26 | 26 | */ |
27 | 27 | abstract class _JsUtils implements InjectionAwareInterface { |
28 | - use JsUtilsEventsTrait,JsUtilsActionsTrait,JsUtilsAjaxTrait; |
|
28 | + use JsUtilsEventsTrait, JsUtilsActionsTrait, JsUtilsAjaxTrait; |
|
29 | 29 | |
30 | 30 | protected $_di; |
31 | 31 | protected $js; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | protected function _setDi($di) { |
56 | 56 | $this->_di=$di; |
57 | - if ($this->js!=null&&$di!=null) |
|
57 | + if ($this->js!=null && $di!=null) |
|
58 | 58 | $this->js->setDi($di); |
59 | 59 | } |
60 | 60 | |
@@ -147,18 +147,18 @@ discard block |
||
147 | 147 | |
148 | 148 | |
149 | 149 | public function __construct($params=array()) { |
150 | - $defaults=array ( |
|
150 | + $defaults=array( |
|
151 | 151 | 'driver' => 'Jquery', |
152 | 152 | 'debug' => true |
153 | 153 | ); |
154 | - foreach ( $defaults as $key => $val ) { |
|
155 | - if (isset($params[$key])&&$params[$key]!=="") { |
|
154 | + foreach ($defaults as $key => $val) { |
|
155 | + if (isset($params[$key]) && $params[$key]!=="") { |
|
156 | 156 | $defaults[$key]=$params[$key]; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | extract($defaults); |
160 | 160 | $this->js=new Jquery($defaults); |
161 | - $this->cdns=array (); |
|
161 | + $this->cdns=array(); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | public function addToCompile($jsScript) { |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function compile($view=NULL, $view_var='script_foot', $script_tags=TRUE) { |
198 | 198 | $bs=$this->_bootstrap; |
199 | - if (isset($bs)&&isset($view)) { |
|
199 | + if (isset($bs) && isset($view)) { |
|
200 | 200 | $bs->compileHtml($this, $view); |
201 | 201 | } |
202 | 202 | $sem=$this->_semantic; |
203 | - if (isset($sem)&&isset($view)) { |
|
203 | + if (isset($sem) && isset($view)) { |
|
204 | 204 | $sem->compileHtml($this, $view); |
205 | 205 | } |
206 | 206 | return $this->js->_compile($view, $view_var, $script_tags); |
@@ -280,27 +280,27 @@ discard block |
||
280 | 280 | $json_result=$result->result_array(); |
281 | 281 | } elseif (is_array($result)) { |
282 | 282 | $json_result=$result; |
283 | - } else { |
|
283 | + }else { |
|
284 | 284 | return $this->_prep_args($result); |
285 | 285 | } |
286 | - } else { |
|
286 | + }else { |
|
287 | 287 | return 'null'; |
288 | 288 | } |
289 | 289 | return $this->_create_json($json_result, $match_array_type); |
290 | 290 | } |
291 | 291 | |
292 | 292 | private function _create_json($json_result, $match_array_type) { |
293 | - $json=array (); |
|
293 | + $json=array(); |
|
294 | 294 | $_is_assoc=TRUE; |
295 | - if (!is_array($json_result)&&empty($json_result)) { |
|
295 | + if (!is_array($json_result) && empty($json_result)) { |
|
296 | 296 | show_error("Generate JSON Failed - Illegal key, value pair."); |
297 | 297 | } elseif ($match_array_type) { |
298 | 298 | $_is_assoc=$this->_is_associative_array($json_result); |
299 | 299 | } |
300 | - foreach ( $json_result as $k => $v ) { |
|
300 | + foreach ($json_result as $k => $v) { |
|
301 | 301 | if ($_is_assoc) { |
302 | 302 | $json[]=$this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type); |
303 | - } else { |
|
303 | + }else { |
|
304 | 304 | $json[]=$this->generate_json($v, $match_array_type); |
305 | 305 | } |
306 | 306 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @return type |
316 | 316 | */ |
317 | 317 | public function _is_associative_array($arr) { |
318 | - foreach ( array_keys($arr) as $key => $val ) { |
|
318 | + foreach (array_keys($arr) as $key => $val) { |
|
319 | 319 | if ($key!==$val) { |
320 | 320 | return TRUE; |
321 | 321 | } |
@@ -334,11 +334,11 @@ discard block |
||
334 | 334 | return 'null'; |
335 | 335 | } elseif (is_bool($result)) { |
336 | 336 | return ($result===TRUE) ? 'true' : 'false'; |
337 | - } elseif (is_string($result)||$is_key) { |
|
338 | - return '"'.str_replace(array ( |
|
339 | - '\\',"\t","\n","\r",'"','/' |
|
340 | - ), array ( |
|
341 | - '\\\\','\\t','\\n',"\\r",'\"','\/' |
|
337 | + } elseif (is_string($result) || $is_key) { |
|
338 | + return '"'.str_replace(array( |
|
339 | + '\\', "\t", "\n", "\r", '"', '/' |
|
340 | + ), array( |
|
341 | + '\\\\', '\\t', '\\n', "\\r", '\"', '\/' |
|
342 | 342 | ), $result).'"'; |
343 | 343 | } elseif (is_scalar($result)) { |
344 | 344 | return $result; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | |
352 | 352 | public function setCDNs($cdns) { |
353 | 353 | if (is_array($cdns)===false) { |
354 | - $cdns=array ( |
|
354 | + $cdns=array( |
|
355 | 355 | $cdns |
356 | 356 | ); |
357 | 357 | } |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | $hasJQueryUI=false; |
364 | 364 | $hasBootstrap=false; |
365 | 365 | $hasSemantic=false; |
366 | - $result=array (); |
|
367 | - foreach ( $this->cdns as $cdn ) { |
|
368 | - switch(get_class($cdn)) { |
|
366 | + $result=array(); |
|
367 | + foreach ($this->cdns as $cdn) { |
|
368 | + switch (get_class($cdn)) { |
|
369 | 369 | case "Ajax\lib\CDNJQuery": |
370 | 370 | $hasJQuery=true; |
371 | 371 | $result[0]=$cdn; |
@@ -375,11 +375,11 @@ discard block |
||
375 | 375 | $result[1]=$cdn; |
376 | 376 | break; |
377 | 377 | case "Ajax\lib\CDNCoreCss": |
378 | - if($cdn->getFramework()==="Bootstrap") |
|
378 | + if ($cdn->getFramework()==="Bootstrap") |
|
379 | 379 | $hasBootstrap=true; |
380 | - elseif($cdn->getFramework()==="Semantic") |
|
380 | + elseif ($cdn->getFramework()==="Semantic") |
|
381 | 381 | $hasSemantic=true; |
382 | - if($hasSemantic || $hasBootstrap) |
|
382 | + if ($hasSemantic || $hasBootstrap) |
|
383 | 383 | $result[2]=$cdn; |
384 | 384 | break; |
385 | 385 | } |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | if ($hasJQuery===false) { |
388 | 388 | $result[0]=new CDNJQuery("x"); |
389 | 389 | } |
390 | - if ($hasJQueryUI===false&&isset($this->_ui)) { |
|
390 | + if ($hasJQueryUI===false && isset($this->_ui)) { |
|
391 | 391 | $result[1]=new CDNGuiGen("x", $template); |
392 | 392 | } |
393 | - if ($hasBootstrap===false&&isset($this->_bootstrap)) { |
|
394 | - $result[2]=new CDNCoreCss("Bootstrap","x"); |
|
393 | + if ($hasBootstrap===false && isset($this->_bootstrap)) { |
|
394 | + $result[2]=new CDNCoreCss("Bootstrap", "x"); |
|
395 | 395 | } |
396 | - if ($hasSemantic===false&&isset($this->_semantic)) { |
|
397 | - $result[2]=new CDNCoreCss("Semantic","x"); |
|
396 | + if ($hasSemantic===false && isset($this->_semantic)) { |
|
397 | + $result[2]=new CDNCoreCss("Semantic", "x"); |
|
398 | 398 | } |
399 | 399 | ksort($result); |
400 | 400 | return implode("\n", $result); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $this->_setDi($di); |
408 | 408 | } |
409 | 409 | } |
410 | -} else { |
|
410 | +}else { |
|
411 | 411 | class JsUtils extends _JsUtils { |
412 | 412 | |
413 | 413 | public function setDi(DiInterface $di) { |
@@ -5,6 +5,10 @@ discard block |
||
5 | 5 | use Ajax\service\JString; |
6 | 6 | use Ajax\service\PhalconUtils; |
7 | 7 | trait JqueryAjaxTrait { |
8 | + |
|
9 | + /** |
|
10 | + * @param string $retour |
|
11 | + */ |
|
8 | 12 | protected function addLoading(&$retour, $responseElement) { |
9 | 13 | $loading_notifier='<div class="ajax-loader">'; |
10 | 14 | if ($this->ajaxLoader=='') { |
@@ -17,13 +21,23 @@ discard block |
||
17 | 21 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
18 | 22 | } |
19 | 23 | |
24 | + /** |
|
25 | + * @param string $url |
|
26 | + */ |
|
20 | 27 | public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
21 | 28 | return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
22 | 29 | } |
30 | + |
|
31 | + /** |
|
32 | + * @param string $url |
|
33 | + */ |
|
23 | 34 | public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
24 | 35 | return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
25 | 36 | } |
26 | 37 | |
38 | + /** |
|
39 | + * @param string $method |
|
40 | + */ |
|
27 | 41 | protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
28 | 42 | if(JString::isNull($params)){$params="{}";} |
29 | 43 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
@@ -40,6 +54,9 @@ discard block |
||
40 | 54 | return $retour; |
41 | 55 | } |
42 | 56 | |
57 | + /** |
|
58 | + * @param string $attr |
|
59 | + */ |
|
43 | 60 | protected function _getAjaxUrl($url,$attr){ |
44 | 61 | $url=$this->_correctAjaxUrl($url); |
45 | 62 | $retour="url='".$url."';\n"; |
@@ -171,6 +188,11 @@ discard block |
||
171 | 188 | return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
172 | 189 | } |
173 | 190 | |
191 | + /** |
|
192 | + * @param string $url |
|
193 | + * @param string $form |
|
194 | + * @param string $responseElement |
|
195 | + */ |
|
174 | 196 | public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
175 | 197 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
176 | 198 | $retour=$this->_getAjaxUrl($url, $attr); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | $loading_notifier='<div class="ajax-loader">'; |
10 | 10 | if ($this->ajaxLoader=='') { |
11 | 11 | $loading_notifier.="Loading..."; |
12 | - } else { |
|
12 | + }else { |
|
13 | 13 | $loading_notifier.=$this->ajaxLoader; |
14 | 14 | } |
15 | 15 | $loading_notifier.='</div>'; |
@@ -17,20 +17,20 @@ discard block |
||
17 | 17 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
18 | 18 | } |
19 | 19 | |
20 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
21 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
20 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
21 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
22 | 22 | } |
23 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
24 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
23 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
24 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
25 | 25 | } |
26 | 26 | |
27 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
28 | - if(JString::isNull($params)){$params="{}";} |
|
27 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
28 | + if (JString::isNull($params)) {$params="{}"; } |
|
29 | 29 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
30 | 30 | $retour=$this->_getAjaxUrl($url, $attr); |
31 | 31 | $responseElement=$this->_getResponseElement($responseElement); |
32 | 32 | $retour.="var self=this;\n"; |
33 | - if($hasLoader===true){ |
|
33 | + if ($hasLoader===true) { |
|
34 | 34 | $this->addLoading($retour, $responseElement); |
35 | 35 | } |
36 | 36 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
@@ -40,22 +40,22 @@ discard block |
||
40 | 40 | return $retour; |
41 | 41 | } |
42 | 42 | |
43 | - protected function _getAjaxUrl($url,$attr){ |
|
43 | + protected function _getAjaxUrl($url, $attr) { |
|
44 | 44 | $url=$this->_correctAjaxUrl($url); |
45 | 45 | $retour="url='".$url."';\n"; |
46 | 46 | $slash="/"; |
47 | - if(PhalconUtils::endsWith($url, "/")) |
|
47 | + if (PhalconUtils::endsWith($url, "/")) |
|
48 | 48 | $slash=""; |
49 | - if(JString::isNotNull($attr)){ |
|
49 | + if (JString::isNotNull($attr)) { |
|
50 | 50 | if ($attr=="value") |
51 | 51 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
52 | - else if($attr!=null && $attr!=="") |
|
52 | + else if ($attr!=null && $attr!=="") |
|
53 | 53 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
54 | 54 | } |
55 | 55 | return $retour; |
56 | 56 | } |
57 | 57 | |
58 | - protected function _getOnAjaxDone($responseElement,$jsCallback){ |
|
58 | + protected function _getOnAjaxDone($responseElement, $jsCallback) { |
|
59 | 59 | $retour=""; |
60 | 60 | if ($responseElement!=="") { |
61 | 61 | $retour="\t$({$responseElement}).html( data );\n"; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | return $retour; |
65 | 65 | } |
66 | 66 | |
67 | - protected function _getResponseElement($responseElement){ |
|
67 | + protected function _getResponseElement($responseElement) { |
|
68 | 68 | if ($responseElement!=="") { |
69 | 69 | $responseElement=$this->_prep_value($responseElement); |
70 | 70 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | protected function _correctAjaxUrl($url) { |
75 | 75 | if (PhalconUtils::endsWith($url, "/")) |
76 | 76 | $url=substr($url, 0, strlen($url)-1); |
77 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
77 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
78 | 78 | $url=$this->_di->get("url")->get($url); |
79 | 79 | } |
80 | 80 | return $url; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param string $jsCallback javascript code to execute after the request |
89 | 89 | * @param boolean $immediatly |
90 | 90 | */ |
91 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
91 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
92 | 92 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
93 | 93 | $retour=$this->_getAjaxUrl($url, $attr); |
94 | 94 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param string $url the request address |
110 | 110 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
111 | 111 | */ |
112 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
112 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
113 | 113 | $preventDefault=true; |
114 | 114 | $stopPropagation=true; |
115 | 115 | $jsCallback=null; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $params="{}"; |
120 | 120 | $immediatly=true; |
121 | 121 | extract($parameters); |
122 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
122 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -131,19 +131,19 @@ discard block |
||
131 | 131 | * @param string $context jquery DOM element, array container. |
132 | 132 | * @param boolean $immediatly |
133 | 133 | */ |
134 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) { |
|
134 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) { |
|
135 | 135 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
136 | 136 | $retour=$this->_getAjaxUrl($url, $attr); |
137 | - if($context===null){ |
|
137 | + if ($context===null) { |
|
138 | 138 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
139 | - $newElm = "$('#'+newId)"; |
|
140 | - }else{ |
|
139 | + $newElm="$('#'+newId)"; |
|
140 | + }else { |
|
141 | 141 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
142 | - $newElm = $context.".find('#'+newId)"; |
|
142 | + $newElm=$context.".find('#'+newId)"; |
|
143 | 143 | } |
144 | 144 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
145 | 145 | $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"; |
146 | - $retour.= $appendTo; |
|
146 | + $retour.=$appendTo; |
|
147 | 147 | $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"; |
148 | 148 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
149 | 149 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -158,26 +158,26 @@ discard block |
||
158 | 158 | * @param string $url the request address |
159 | 159 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
160 | 160 | */ |
161 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
161 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
162 | 162 | $preventDefault=true; |
163 | 163 | $stopPropagation=true; |
164 | 164 | $jsCallback=null; |
165 | 165 | $attr="id"; |
166 | 166 | $method="get"; |
167 | - $context = null; |
|
167 | + $context=null; |
|
168 | 168 | $params="{}"; |
169 | 169 | $immediatly=true; |
170 | 170 | extract($parameters); |
171 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
171 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
172 | 172 | } |
173 | 173 | |
174 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
174 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
175 | 175 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
176 | 176 | $retour=$this->_getAjaxUrl($url, $attr); |
177 | 177 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
178 | 178 | $responseElement=$this->_getResponseElement($responseElement); |
179 | 179 | $retour.="var self=this;\n"; |
180 | - if($hasLoader===true){ |
|
180 | + if ($hasLoader===true) { |
|
181 | 181 | $this->addLoading($retour, $responseElement); |
182 | 182 | } |
183 | 183 | $retour.="$.post(url,params).done(function( data ) {\n"; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @param string $responseElement |
205 | 205 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
206 | 206 | */ |
207 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
207 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
208 | 208 | $preventDefault=true; |
209 | 209 | $stopPropagation=true; |
210 | 210 | $jsCallback=null; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $hasLoader=true; |
213 | 213 | $immediatly=true; |
214 | 214 | extract($parameters); |
215 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
215 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param string $responseElement |
226 | 226 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
227 | 227 | */ |
228 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
228 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
229 | 229 | $preventDefault=true; |
230 | 230 | $stopPropagation=true; |
231 | 231 | $jsCallback=null; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $hasLoader=true; |
234 | 234 | $immediatly=true; |
235 | 235 | extract($parameters); |
236 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
236 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @param string $responseElement |
247 | 247 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
248 | 248 | */ |
249 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
249 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
250 | 250 | $preventDefault=true; |
251 | 251 | $stopPropagation=true; |
252 | 252 | $validation=false; |
@@ -255,6 +255,6 @@ discard block |
||
255 | 255 | $hasLoader=true; |
256 | 256 | $immediatly=true; |
257 | 257 | extract($parameters); |
258 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
258 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | \ No newline at end of file |
@@ -35,8 +35,9 @@ discard block |
||
35 | 35 | } |
36 | 36 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
37 | 37 | $retour.=$this->_getOnAjaxDone($responseElement, $jsCallback)."});\n"; |
38 | - if ($immediatly) |
|
39 | - $this->jquery_code_for_compile[]=$retour; |
|
38 | + if ($immediatly) { |
|
39 | + $this->jquery_code_for_compile[]=$retour; |
|
40 | + } |
|
40 | 41 | return $retour; |
41 | 42 | } |
42 | 43 | |
@@ -44,13 +45,15 @@ discard block |
||
44 | 45 | $url=$this->_correctAjaxUrl($url); |
45 | 46 | $retour="url='".$url."';\n"; |
46 | 47 | $slash="/"; |
47 | - if(PhalconUtils::endsWith($url, "/")) |
|
48 | - $slash=""; |
|
48 | + if(PhalconUtils::endsWith($url, "/")) { |
|
49 | + $slash=""; |
|
50 | + } |
|
49 | 51 | if(JString::isNotNull($attr)){ |
50 | - if ($attr=="value") |
|
51 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
52 | - else if($attr!=null && $attr!=="") |
|
53 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
52 | + if ($attr=="value") { |
|
53 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
54 | + } else if($attr!=null && $attr!=="") { |
|
55 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
56 | + } |
|
54 | 57 | } |
55 | 58 | return $retour; |
56 | 59 | } |
@@ -72,8 +75,9 @@ discard block |
||
72 | 75 | } |
73 | 76 | |
74 | 77 | protected function _correctAjaxUrl($url) { |
75 | - if (PhalconUtils::endsWith($url, "/")) |
|
76 | - $url=substr($url, 0, strlen($url)-1); |
|
78 | + if (PhalconUtils::endsWith($url, "/")) { |
|
79 | + $url=substr($url, 0, strlen($url)-1); |
|
80 | + } |
|
77 | 81 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
78 | 82 | $url=$this->_di->get("url")->get($url); |
79 | 83 | } |
@@ -97,8 +101,9 @@ discard block |
||
97 | 101 | $retour.="\t".$jsCallback."\n". |
98 | 102 | "\t$(document).trigger('jsonReady',[data]);\n". |
99 | 103 | "});\n"; |
100 | - if ($immediatly) |
|
101 | - $this->jquery_code_for_compile[]=$retour; |
|
104 | + if ($immediatly) { |
|
105 | + $this->jquery_code_for_compile[]=$retour; |
|
106 | + } |
|
102 | 107 | return $retour; |
103 | 108 | } |
104 | 109 | |
@@ -137,7 +142,7 @@ discard block |
||
137 | 142 | if($context===null){ |
138 | 143 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
139 | 144 | $newElm = "$('#'+newId)"; |
140 | - }else{ |
|
145 | + } else{ |
|
141 | 146 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
142 | 147 | $newElm = $context.".find('#'+newId)"; |
143 | 148 | } |
@@ -147,8 +152,9 @@ discard block |
||
147 | 152 | $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"; |
148 | 153 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
149 | 154 | $retour.="\t".$jsCallback."\n"."});\n"; |
150 | - if ($immediatly) |
|
151 | - $this->jquery_code_for_compile[]=$retour; |
|
155 | + if ($immediatly) { |
|
156 | + $this->jquery_code_for_compile[]=$retour; |
|
157 | + } |
|
152 | 158 | return $retour; |
153 | 159 | } |
154 | 160 | /** |
@@ -189,8 +195,9 @@ discard block |
||
189 | 195 | }});\n"; |
190 | 196 | $retour.="$('#".$form."').submit();\n"; |
191 | 197 | } |
192 | - if ($immediatly) |
|
193 | - $this->jquery_code_for_compile[]=$retour; |
|
198 | + if ($immediatly) { |
|
199 | + $this->jquery_code_for_compile[]=$retour; |
|
200 | + } |
|
194 | 201 | return $retour; |
195 | 202 | } |
196 | 203 |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param string $element |
209 | 209 | * @param array $options |
210 | - * @return void |
|
210 | + * @return string |
|
211 | 211 | */ |
212 | 212 | public function sortable($element, $options=array()) { |
213 | 213 | if (count($options)>0) { |
@@ -351,6 +351,7 @@ discard block |
||
351 | 351 | /** |
352 | 352 | * A wrapper for writing document.ready() |
353 | 353 | * |
354 | + * @param string $js |
|
354 | 355 | * @return string |
355 | 356 | */ |
356 | 357 | public function _document_ready($js) { |
@@ -420,6 +421,9 @@ discard block |
||
420 | 421 | return $speed; |
421 | 422 | } |
422 | 423 | |
424 | + /** |
|
425 | + * @param string $input |
|
426 | + */ |
|
423 | 427 | private function minify($input) { |
424 | 428 | if(trim($input) === "") return $input; |
425 | 429 | return preg_replace( |
@@ -17,21 +17,21 @@ discard block |
||
17 | 17 | * jQuery Class |
18 | 18 | */ |
19 | 19 | class Jquery { |
20 | - use JqueryEventsTrait,JqueryAjaxTrait,JqueryActionsTrait; |
|
20 | + use JqueryEventsTrait, JqueryAjaxTrait, JqueryActionsTrait; |
|
21 | 21 | protected $_di; |
22 | 22 | protected $_ui; |
23 | 23 | protected $_bootstrap; |
24 | 24 | protected $_semantic; |
25 | 25 | protected $libraryFile; |
26 | 26 | protected $_javascript_folder='js'; |
27 | - protected $jquery_code_for_load=array (); |
|
28 | - protected $jquery_code_for_compile=array (); |
|
27 | + protected $jquery_code_for_load=array(); |
|
28 | + protected $jquery_code_for_compile=array(); |
|
29 | 29 | protected $jquery_corner_active=FALSE; |
30 | 30 | protected $jquery_table_sorter_active=FALSE; |
31 | 31 | protected $jquery_table_sorter_pager_active=FALSE; |
32 | 32 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
33 | - protected $jquery_events=array ( |
|
34 | - "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" |
|
33 | + protected $jquery_events=array( |
|
34 | + "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" |
|
35 | 35 | ); |
36 | 36 | |
37 | 37 | public function setDi($di) { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | public function __construct($params) { |
63 | 63 | $this->params=array(); |
64 | - foreach ( $params as $key => $val ) { |
|
64 | + foreach ($params as $key => $val) { |
|
65 | 65 | $this->params[$key]=$params[$key]; |
66 | 66 | } |
67 | 67 | } |
@@ -144,12 +144,12 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function _output($array_js='') { |
146 | 146 | if (!is_array($array_js)) { |
147 | - $array_js=array ( |
|
147 | + $array_js=array( |
|
148 | 148 | $array_js |
149 | 149 | ); |
150 | 150 | } |
151 | 151 | |
152 | - foreach ( $array_js as $js ) { |
|
152 | + foreach ($array_js as $js) { |
|
153 | 153 | $this->jquery_code_for_compile[]="\t$js\n"; |
154 | 154 | } |
155 | 155 | } |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | * @param string $param |
169 | 169 | * @param boolean $immediatly delayed if false |
170 | 170 | */ |
171 | - public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
171 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
172 | 172 | $element=$this->_prep_element($element); |
173 | 173 | if (isset($param)) { |
174 | 174 | $param=$this->_prep_value($param); |
175 | 175 | $str="$({$element}).{$jQueryCall}({$param});"; |
176 | - } else |
|
176 | + }else |
|
177 | 177 | $str="$({$element}).{$jQueryCall}();"; |
178 | 178 | if ($immediatly) |
179 | 179 | $this->jquery_code_for_compile[]=$str; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param boolean $immediatly delayed if false |
188 | 188 | * @return string |
189 | 189 | */ |
190 | - public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
|
190 | + public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) { |
|
191 | 191 | $to=$this->_prep_element($to); |
192 | 192 | $element=$this->_prep_element($element); |
193 | 193 | $str="$({$to}).{$jQueryCall}({$element});"; |
@@ -211,12 +211,12 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function sortable($element, $options=array()) { |
213 | 213 | if (count($options)>0) { |
214 | - $sort_options=array (); |
|
215 | - foreach ( $options as $k => $v ) { |
|
214 | + $sort_options=array(); |
|
215 | + foreach ($options as $k => $v) { |
|
216 | 216 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
217 | 217 | } |
218 | 218 | $sort_options=implode(",", $sort_options); |
219 | - } else { |
|
219 | + }else { |
|
220 | 220 | $sort_options=''; |
221 | 221 | } |
222 | 222 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. |
251 | 251 | * @return string |
252 | 252 | */ |
253 | - public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
253 | + public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
254 | 254 | if (is_array($js)) { |
255 | 255 | $js=implode("\n\t\t", $js); |
256 | 256 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
265 | 265 | else |
266 | 266 | $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
267 | - if($immediatly) |
|
267 | + if ($immediatly) |
|
268 | 268 | $this->jquery_code_for_compile[]=$event; |
269 | 269 | return $event; |
270 | 270 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | |
307 | 307 | // External references |
308 | 308 | $external_scripts=implode('', $this->jquery_code_for_load); |
309 | - extract(array ( |
|
309 | + extract(array( |
|
310 | 310 | 'library_src' => $external_scripts |
311 | 311 | )); |
312 | 312 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $script.='});'; |
322 | 322 | |
323 | 323 | $this->jquery_code_for_compile=array(); |
324 | - if($this->params["debug"]==false){ |
|
324 | + if ($this->params["debug"]==false) { |
|
325 | 325 | $script=$this->minify($script); |
326 | 326 | } |
327 | 327 | $output=($script_tags===FALSE) ? $script : $this->inline($script); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @return void |
344 | 344 | */ |
345 | 345 | public function _clear_compile() { |
346 | - $this->jquery_code_for_compile=array (); |
|
346 | + $this->jquery_code_for_compile=array(); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | // -------------------------------------------------------------------- |
@@ -355,12 +355,12 @@ discard block |
||
355 | 355 | */ |
356 | 356 | public function _document_ready($js) { |
357 | 357 | if (!is_array($js)) { |
358 | - $js=array ( |
|
358 | + $js=array( |
|
359 | 359 | $js |
360 | 360 | ); |
361 | 361 | } |
362 | 362 | |
363 | - foreach ( $js as $script ) { |
|
363 | + foreach ($js as $script) { |
|
364 | 364 | $this->jquery_code_for_compile[]=$script; |
365 | 365 | } |
366 | 366 | } |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | * @return string |
377 | 377 | */ |
378 | 378 | public function _prep_element($element) { |
379 | - if (strrpos($element, 'this')===false&&strrpos($element, 'event')===false&&strrpos($element, 'self')===false) { |
|
379 | + if (strrpos($element, 'this')===false && strrpos($element, 'event')===false && strrpos($element, 'self')===false) { |
|
380 | 380 | $element='"'.addslashes($element).'"'; |
381 | 381 | } |
382 | 382 | return $element; |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | if (is_array($value)) { |
395 | 395 | $value=implode(",", $value); |
396 | 396 | } |
397 | - if (strrpos($value, 'this')===false&&strrpos($value, 'event')===false&&strrpos($value, 'self')===false) { |
|
397 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false && strrpos($value, 'self')===false) { |
|
398 | 398 | $value='"'.$value.'"'; |
399 | 399 | } |
400 | 400 | return $value; |
@@ -409,8 +409,8 @@ discard block |
||
409 | 409 | * @return string |
410 | 410 | */ |
411 | 411 | private function _validate_speed($speed) { |
412 | - if (in_array($speed, array ( |
|
413 | - 'slow','normal','fast' |
|
412 | + if (in_array($speed, array( |
|
413 | + 'slow', 'normal', 'fast' |
|
414 | 414 | ))) { |
415 | 415 | $speed='"'.$speed.'"'; |
416 | 416 | } elseif (preg_match("/[^0-9]/", $speed)) { |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | } |
422 | 422 | |
423 | 423 | private function minify($input) { |
424 | - if(trim($input) === "") return $input; |
|
424 | + if (trim($input)==="") return $input; |
|
425 | 425 | return preg_replace( |
426 | 426 | array( |
427 | 427 | // Remove comment(s) |
@@ -173,10 +173,12 @@ discard block |
||
173 | 173 | if (isset($param)) { |
174 | 174 | $param=$this->_prep_value($param); |
175 | 175 | $str="$({$element}).{$jQueryCall}({$param});"; |
176 | - } else |
|
177 | - $str="$({$element}).{$jQueryCall}();"; |
|
178 | - if ($immediatly) |
|
179 | - $this->jquery_code_for_compile[]=$str; |
|
176 | + } else { |
|
177 | + $str="$({$element}).{$jQueryCall}();"; |
|
178 | + } |
|
179 | + if ($immediatly) { |
|
180 | + $this->jquery_code_for_compile[]=$str; |
|
181 | + } |
|
180 | 182 | return $str; |
181 | 183 | } |
182 | 184 | /** |
@@ -191,8 +193,9 @@ discard block |
||
191 | 193 | $to=$this->_prep_element($to); |
192 | 194 | $element=$this->_prep_element($element); |
193 | 195 | $str="$({$to}).{$jQueryCall}({$element});"; |
194 | - if ($immediatly) |
|
195 | - $this->jquery_code_for_compile[]=$str; |
|
196 | + if ($immediatly) { |
|
197 | + $this->jquery_code_for_compile[]=$str; |
|
198 | + } |
|
196 | 199 | return $str; |
197 | 200 | } |
198 | 201 | // -------------------------------------------------------------------- |
@@ -260,12 +263,14 @@ discard block |
||
260 | 263 | if ($stopPropagation===true) { |
261 | 264 | $js="event.stopPropagation();\n".$js; |
262 | 265 | } |
263 | - if (array_search($event, $this->jquery_events)===false) |
|
264 | - $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
265 | - else |
|
266 | - $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
267 | - if($immediatly) |
|
268 | - $this->jquery_code_for_compile[]=$event; |
|
266 | + if (array_search($event, $this->jquery_events)===false) { |
|
267 | + $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
268 | + } else { |
|
269 | + $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
270 | + } |
|
271 | + if($immediatly) { |
|
272 | + $this->jquery_code_for_compile[]=$event; |
|
273 | + } |
|
269 | 274 | return $event; |
270 | 275 | } |
271 | 276 | |
@@ -326,8 +331,9 @@ discard block |
||
326 | 331 | } |
327 | 332 | $output=($script_tags===FALSE) ? $script : $this->inline($script); |
328 | 333 | |
329 | - if ($view!=NULL) |
|
330 | - $view->setVar($view_var, $output); |
|
334 | + if ($view!=NULL) { |
|
335 | + $view->setVar($view_var, $output); |
|
336 | + } |
|
331 | 337 | return $output; |
332 | 338 | } |
333 | 339 | |
@@ -421,7 +427,9 @@ discard block |
||
421 | 427 | } |
422 | 428 | |
423 | 429 | private function minify($input) { |
424 | - if(trim($input) === "") return $input; |
|
430 | + if(trim($input) === "") { |
|
431 | + return $input; |
|
432 | + } |
|
425 | 433 | return preg_replace( |
426 | 434 | array( |
427 | 435 | // Remove comment(s) |
@@ -93,7 +93,6 @@ |
||
93 | 93 | /** |
94 | 94 | * Return a new Semantic Html Breadcrumb |
95 | 95 | * @param string $identifier |
96 | - * @param array $elements |
|
97 | 96 | * @param boolean $autoActive sets the last element's class to <b>active</b> if true. default : true |
98 | 97 | * @param function $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()} |
99 | 98 | * @return HtmlBreadcrumb |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | use Ajax\semantic\traits\SemanticHtmlElementsTrait; |
21 | 21 | |
22 | 22 | class Semantic extends BaseGui { |
23 | - use SemanticComponentsTrait,SemanticHtmlElementsTrait; |
|
23 | + use SemanticComponentsTrait, SemanticHtmlElementsTrait; |
|
24 | 24 | public function __construct($autoCompile=true) { |
25 | 25 | parent::__construct($autoCompile=true); |
26 | 26 | } |
@@ -31,24 +31,24 @@ discard block |
||
31 | 31 | * @param array $items |
32 | 32 | * @return Ajax\semantic\html\collections\HtmlMenu |
33 | 33 | */ |
34 | - public function htmlMenu($identifier,$items=array()){ |
|
35 | - return $this->addHtmlComponent(new HtmlMenu($identifier,$items)); |
|
34 | + public function htmlMenu($identifier, $items=array()) { |
|
35 | + return $this->addHtmlComponent(new HtmlMenu($identifier, $items)); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /**Adds an icon menu |
39 | 39 | * @param string $identifier |
40 | 40 | * @param array $items icons |
41 | 41 | */ |
42 | - public function htmlIconMenu($identifier,$items=array()){ |
|
43 | - return $this->addHtmlComponent(new HtmlIconMenu($identifier,$items)); |
|
42 | + public function htmlIconMenu($identifier, $items=array()) { |
|
43 | + return $this->addHtmlComponent(new HtmlIconMenu($identifier, $items)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /**Adds an labeled icon menu |
47 | 47 | * @param string $identifier |
48 | 48 | * @param array $items icons |
49 | 49 | */ |
50 | - public function htmlLabeledIconMenu($identifier,$items=array()){ |
|
51 | - return $this->addHtmlComponent(new HtmlLabeledIconMenu($identifier,$items)); |
|
50 | + public function htmlLabeledIconMenu($identifier, $items=array()) { |
|
51 | + return $this->addHtmlComponent(new HtmlLabeledIconMenu($identifier, $items)); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param string $value |
57 | 57 | * @param array $items |
58 | 58 | */ |
59 | - public function htmlDropdown($identifier, $value="", $items=array()){ |
|
60 | - return $this->addHtmlComponent(new HtmlDropdown($identifier,$value,$items)); |
|
59 | + public function htmlDropdown($identifier, $value="", $items=array()) { |
|
60 | + return $this->addHtmlComponent(new HtmlDropdown($identifier, $value, $items)); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | * @param string $identifier |
66 | 66 | * @param string $content |
67 | 67 | */ |
68 | - public function htmlMessage($identifier, $content=""){ |
|
69 | - return $this->addHtmlComponent(new HtmlMessage($identifier,$content)); |
|
68 | + public function htmlMessage($identifier, $content="") { |
|
69 | + return $this->addHtmlComponent(new HtmlMessage($identifier, $content)); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @param string $identifier |
74 | 74 | * @param mixed $content |
75 | 75 | */ |
76 | - public function htmlPopup(BaseHtml $container,$identifier,$content){ |
|
77 | - return $this->addHtmlComponent(new HtmlPopup($container,$identifier,$content)); |
|
76 | + public function htmlPopup(BaseHtml $container, $identifier, $content) { |
|
77 | + return $this->addHtmlComponent(new HtmlPopup($container, $identifier, $content)); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * @param boolean $createCols |
85 | 85 | * @param boolean $implicitRows |
86 | 86 | */ |
87 | - public function htmlGrid($identifier,$numRows=1,$numCols=NULL,$createCols=true,$implicitRows=false){ |
|
88 | - return $this->addHtmlComponent(new HtmlGrid($identifier,$numRows,$numCols,$createCols,$implicitRows)); |
|
87 | + public function htmlGrid($identifier, $numRows=1, $numCols=NULL, $createCols=true, $implicitRows=false) { |
|
88 | + return $this->addHtmlComponent(new HtmlGrid($identifier, $numRows, $numCols, $createCols, $implicitRows)); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @param function $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()} |
99 | 99 | * @return HtmlBreadcrumb |
100 | 100 | */ |
101 | - public function htmlBreadcrumb( $identifier,$items=array(),$autoActive=true,$startIndex=0,$hrefFunction=NULL){ |
|
102 | - return $this->addHtmlComponent(new HtmlBreadcrumb($identifier,$items,$autoActive,$startIndex,$hrefFunction)); |
|
101 | + public function htmlBreadcrumb($identifier, $items=array(), $autoActive=true, $startIndex=0, $hrefFunction=NULL) { |
|
102 | + return $this->addHtmlComponent(new HtmlBreadcrumb($identifier, $items, $autoActive, $startIndex, $hrefFunction)); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @param string $identifier |
117 | 117 | * @return HtmlAccordion |
118 | 118 | */ |
119 | - public function htmlAccordionMenu($identifier,$items=array()) { |
|
120 | - return $this->addHtmlComponent(new HtmlAccordionMenu($identifier,$items)); |
|
119 | + public function htmlAccordionMenu($identifier, $items=array()) { |
|
120 | + return $this->addHtmlComponent(new HtmlAccordionMenu($identifier, $items)); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param string $identifier |
126 | 126 | * @param array $elements |
127 | 127 | */ |
128 | - public function htmlForm($identifier,$elements=array()) { |
|
129 | - return $this->addHtmlComponent(new HtmlForm($identifier,$elements)); |
|
128 | + public function htmlForm($identifier, $elements=array()) { |
|
129 | + return $this->addHtmlComponent(new HtmlForm($identifier, $elements)); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | \ No newline at end of file |
@@ -25,10 +25,16 @@ |
||
25 | 25 | return $this->addComponent(new Popup($this->js), $attachTo, $params); |
26 | 26 | } |
27 | 27 | |
28 | + /** |
|
29 | + * @param string $attachTo |
|
30 | + */ |
|
28 | 31 | public function dropdown($attachTo=NULL, $params=NULL) { |
29 | 32 | return $this->addComponent(new Dropdown($this->js), $attachTo, $params); |
30 | 33 | } |
31 | 34 | |
35 | + /** |
|
36 | + * @param string $attachTo |
|
37 | + */ |
|
32 | 38 | public function accordion($attachTo=NULL, $params=NULL) { |
33 | 39 | return $this->addComponent(new Accordion($this->js), $attachTo, $params); |
34 | 40 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @param string $identifier |
63 | - * @param number $niveau |
|
63 | + * @param integer $niveau |
|
64 | 64 | * @param mixed $content |
65 | 65 | * @param string $type |
66 | 66 | * @return HtmlHeader |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | * @param boolean $asIcons |
36 | 36 | * @return HtmlButtonGroups |
37 | 37 | */ |
38 | - public function htmlButtonGroups($identifier,$elements=array(),$asIcons=false){ |
|
39 | - return $this->addHtmlComponent(new HtmlButtonGroups($identifier, $elements,$asIcons)); |
|
38 | + public function htmlButtonGroups($identifier, $elements=array(), $asIcons=false) { |
|
39 | + return $this->addHtmlComponent(new HtmlButtonGroups($identifier, $elements, $asIcons)); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param string $content |
46 | 46 | * @return HtmlContainer |
47 | 47 | */ |
48 | - public function htmlContainer($identifier,$content=""){ |
|
48 | + public function htmlContainer($identifier, $content="") { |
|
49 | 49 | return $this->addHtmlComponent(new HtmlContainer($identifier, $content)); |
50 | 50 | } |
51 | 51 | |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * @param string $content |
55 | 55 | * @return HtmlDivider |
56 | 56 | */ |
57 | - public function htmlDivider($identifier,$content="",$tagName="div"){ |
|
58 | - return $this->addHtmlComponent(new HtmlDivider($identifier, $content,$tagName)); |
|
57 | + public function htmlDivider($identifier, $content="", $tagName="div") { |
|
58 | + return $this->addHtmlComponent(new HtmlDivider($identifier, $content, $tagName)); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * @param string $type |
66 | 66 | * @return HtmlHeader |
67 | 67 | */ |
68 | - public function htmlHeader($identifier,$niveau=1,$content=NULL,$type="page"){ |
|
69 | - return $this->addHtmlComponent(new HtmlHeader($identifier,$niveau,$content,$type)); |
|
68 | + public function htmlHeader($identifier, $niveau=1, $content=NULL, $type="page") { |
|
69 | + return $this->addHtmlComponent(new HtmlHeader($identifier, $niveau, $content, $type)); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param string $icon |
75 | 75 | * @return HtmlIcon |
76 | 76 | */ |
77 | - public function htmlIcon($identifier,$icon){ |
|
77 | + public function htmlIcon($identifier, $icon) { |
|
78 | 78 | return $this->addHtmlComponent(new HtmlIcon($identifier, $icon)); |
79 | 79 | } |
80 | 80 | |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | * @param array $icons |
85 | 85 | * @return HtmlIconGroups |
86 | 86 | */ |
87 | - public function htmlIconGroups($identifier,$size="",$icons=array()){ |
|
88 | - $group=new HtmlIconGroups($identifier,$size); |
|
89 | - if(JArray::isAssociative($icons)){ |
|
90 | - foreach ($icons as $icon=>$size){ |
|
91 | - $group->add($icon,$size); |
|
87 | + public function htmlIconGroups($identifier, $size="", $icons=array()) { |
|
88 | + $group=new HtmlIconGroups($identifier, $size); |
|
89 | + if (JArray::isAssociative($icons)) { |
|
90 | + foreach ($icons as $icon=>$size) { |
|
91 | + $group->add($icon, $size); |
|
92 | 92 | } |
93 | - }else{ |
|
94 | - foreach ($icons as $icon){ |
|
93 | + }else { |
|
94 | + foreach ($icons as $icon) { |
|
95 | 95 | $group->add($icon); |
96 | 96 | } |
97 | 97 | } |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | * @param string $placeholder |
107 | 107 | * @return HtmlInput |
108 | 108 | */ |
109 | - public function htmlInput($identifier,$type="text",$value="",$placeholder=""){ |
|
110 | - return $this->addHtmlComponent(new HtmlInput($identifier,$type,$value,$placeholder)); |
|
109 | + public function htmlInput($identifier, $type="text", $value="", $placeholder="") { |
|
110 | + return $this->addHtmlComponent(new HtmlInput($identifier, $type, $value, $placeholder)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @param string $tagName |
117 | 117 | * @return HtmlLabel |
118 | 118 | */ |
119 | - public function htmlLabel($identifier,$content="",$tagName="div"){ |
|
120 | - return $this->addHtmlComponent(new HtmlLabel($identifier, $content,$tagName)); |
|
119 | + public function htmlLabel($identifier, $content="", $tagName="div") { |
|
120 | + return $this->addHtmlComponent(new HtmlLabel($identifier, $content, $tagName)); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @param array $items |
127 | 127 | * @return HtmlList |
128 | 128 | */ |
129 | - public function htmlList($identifier,$items=array()){ |
|
130 | - return $this->addHtmlComponent(new HtmlList($identifier,$items)); |
|
129 | + public function htmlList($identifier, $items=array()) { |
|
130 | + return $this->addHtmlComponent(new HtmlList($identifier, $items)); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * @param string $content |
137 | 137 | * @return HtmlSegment |
138 | 138 | */ |
139 | - public function htmlSegment($identifier, $content=""){ |
|
140 | - return $this->addHtmlComponent(new HtmlSegment($identifier,$content)); |
|
139 | + public function htmlSegment($identifier, $content="") { |
|
140 | + return $this->addHtmlComponent(new HtmlSegment($identifier, $content)); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param array $items the segments |
147 | 147 | * @return HtmlSegmentGroups |
148 | 148 | */ |
149 | - public function htmlSegmentGroups($identifier, $items=array()){ |
|
150 | - return $this->addHtmlComponent(new HtmlSegmentGroups($identifier,$items)); |
|
149 | + public function htmlSegmentGroups($identifier, $items=array()) { |
|
150 | + return $this->addHtmlComponent(new HtmlSegmentGroups($identifier, $items)); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | \ No newline at end of file |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | if (isset($value)) { |
17 | 17 | $value=$this->_prep_value($value); |
18 | 18 | $str="$({$element}).attr(\"$attributeName\",{$value});"; |
19 | - } else |
|
19 | + }else |
|
20 | 20 | $str="$({$element}).attr(\"$attributeName\");"; |
21 | 21 | if ($immediatly) |
22 | 22 | $this->jquery_code_for_compile[]=$str; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param boolean $immediatly defers the execution if set to false |
31 | 31 | * @return string |
32 | 32 | */ |
33 | - public function after($element='this', $value='', $immediatly=false){ |
|
33 | + public function after($element='this', $value='', $immediatly=false) { |
|
34 | 34 | $element=$this->_prep_element($element); |
35 | 35 | $value=$this->_prep_value($value); |
36 | 36 | $str="$({$element}).after({$value});"; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $animations="\t\t\t"; |
57 | 57 | if (is_array($params)) { |
58 | - foreach ( $params as $param => $value ) { |
|
58 | + foreach ($params as $param => $value) { |
|
59 | 59 | $animations.=$param.': \''.$value.'\', '; |
60 | 60 | } |
61 | 61 | } |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | * @param boolean $immediatly |
349 | 349 | * @return string |
350 | 350 | */ |
351 | - public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="",$immediatly=true) { |
|
352 | - return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation,$immediatly); |
|
351 | + public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="", $immediatly=true) { |
|
352 | + return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation, $immediatly); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param boolean $immediatly |
376 | 376 | * @return String |
377 | 377 | */ |
378 | - public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
379 | - return $this->_add_event($element, $this->_exec($js), $event, $preventDefault, $stopPropagation,$immediatly); |
|
378 | + public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
379 | + return $this->_add_event($element, $this->_exec($js), $event, $preventDefault, $stopPropagation, $immediatly); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | \ No newline at end of file |
@@ -16,10 +16,12 @@ discard block |
||
16 | 16 | if (isset($value)) { |
17 | 17 | $value=$this->_prep_value($value); |
18 | 18 | $str="$({$element}).attr(\"$attributeName\",{$value});"; |
19 | - } else |
|
20 | - $str="$({$element}).attr(\"$attributeName\");"; |
|
21 | - if ($immediatly) |
|
22 | - $this->jquery_code_for_compile[]=$str; |
|
19 | + } else { |
|
20 | + $str="$({$element}).attr(\"$attributeName\");"; |
|
21 | + } |
|
22 | + if ($immediatly) { |
|
23 | + $this->jquery_code_for_compile[]=$str; |
|
24 | + } |
|
23 | 25 | return $str; |
24 | 26 | } |
25 | 27 | |
@@ -34,8 +36,9 @@ discard block |
||
34 | 36 | $element=$this->_prep_element($element); |
35 | 37 | $value=$this->_prep_value($value); |
36 | 38 | $str="$({$element}).after({$value});"; |
37 | - if ($immediatly) |
|
38 | - $this->jquery_code_for_compile[]=$str; |
|
39 | + if ($immediatly) { |
|
40 | + $this->jquery_code_for_compile[]=$str; |
|
41 | + } |
|
39 | 42 | return $str; |
40 | 43 | } |
41 | 44 | |
@@ -71,8 +74,9 @@ discard block |
||
71 | 74 | |
72 | 75 | $str="$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; |
73 | 76 | |
74 | - if ($immediatly) |
|
75 | - $this->jquery_code_for_compile[]=$str; |
|
77 | + if ($immediatly) { |
|
78 | + $this->jquery_code_for_compile[]=$str; |
|
79 | + } |
|
76 | 80 | return $str; |
77 | 81 | } |
78 | 82 | |
@@ -97,8 +101,9 @@ discard block |
||
97 | 101 | |
98 | 102 | $str="$({$element}).fadeIn({$speed}{$callback});"; |
99 | 103 | |
100 | - if ($immediatly) |
|
101 | - $this->jquery_code_for_compile[]=$str; |
|
104 | + if ($immediatly) { |
|
105 | + $this->jquery_code_for_compile[]=$str; |
|
106 | + } |
|
102 | 107 | return $str; |
103 | 108 | } |
104 | 109 | |
@@ -123,8 +128,9 @@ discard block |
||
123 | 128 | |
124 | 129 | $str="$({$element}).fadeOut({$speed}{$callback});"; |
125 | 130 | |
126 | - if ($immediatly) |
|
127 | - $this->jquery_code_for_compile[]=$str; |
|
131 | + if ($immediatly) { |
|
132 | + $this->jquery_code_for_compile[]=$str; |
|
133 | + } |
|
128 | 134 | return $str; |
129 | 135 | } |
130 | 136 | |
@@ -149,8 +155,9 @@ discard block |
||
149 | 155 | |
150 | 156 | $str="$({$element}).hide({$speed}{$callback});"; |
151 | 157 | |
152 | - if ($immediatly) |
|
153 | - $this->jquery_code_for_compile[]=$str; |
|
158 | + if ($immediatly) { |
|
159 | + $this->jquery_code_for_compile[]=$str; |
|
160 | + } |
|
154 | 161 | return $str; |
155 | 162 | } |
156 | 163 | |
@@ -177,8 +184,9 @@ discard block |
||
177 | 184 | |
178 | 185 | $str="$({$element}).slideUp({$speed}{$callback});"; |
179 | 186 | |
180 | - if ($immediatly) |
|
181 | - $this->jquery_code_for_compile[]=$str; |
|
187 | + if ($immediatly) { |
|
188 | + $this->jquery_code_for_compile[]=$str; |
|
189 | + } |
|
182 | 190 | return $str; |
183 | 191 | } |
184 | 192 | |
@@ -203,8 +211,9 @@ discard block |
||
203 | 211 | |
204 | 212 | $str="$({$element}).slideDown({$speed}{$callback});"; |
205 | 213 | |
206 | - if ($immediatly) |
|
207 | - $this->jquery_code_for_compile[]=$str; |
|
214 | + if ($immediatly) { |
|
215 | + $this->jquery_code_for_compile[]=$str; |
|
216 | + } |
|
208 | 217 | return $str; |
209 | 218 | } |
210 | 219 | |
@@ -229,8 +238,9 @@ discard block |
||
229 | 238 | |
230 | 239 | $str="$({$element}).slideToggle({$speed}{$callback});"; |
231 | 240 | |
232 | - if ($immediatly) |
|
233 | - $this->jquery_code_for_compile[]=$str; |
|
241 | + if ($immediatly) { |
|
242 | + $this->jquery_code_for_compile[]=$str; |
|
243 | + } |
|
234 | 244 | return $str; |
235 | 245 | } |
236 | 246 | |
@@ -247,8 +257,9 @@ discard block |
||
247 | 257 | $element=$this->_prep_element($element); |
248 | 258 | $str="$({$element}).toggle();"; |
249 | 259 | |
250 | - if ($immediatly) |
|
251 | - $this->jquery_code_for_compile[]=$str; |
|
260 | + if ($immediatly) { |
|
261 | + $this->jquery_code_for_compile[]=$str; |
|
262 | + } |
|
252 | 263 | return $str; |
253 | 264 | } |
254 | 265 | |
@@ -264,8 +275,9 @@ discard block |
||
264 | 275 | $element=$this->_prep_element($element); |
265 | 276 | $str="$({$element}).trigger(\"$event\");"; |
266 | 277 | |
267 | - if ($immediatly) |
|
268 | - $this->jquery_code_for_compile[]=$str; |
|
278 | + if ($immediatly) { |
|
279 | + $this->jquery_code_for_compile[]=$str; |
|
280 | + } |
|
269 | 281 | return $str; |
270 | 282 | } |
271 | 283 | |
@@ -290,8 +302,9 @@ discard block |
||
290 | 302 | |
291 | 303 | $str="$({$element}).show({$speed}{$callback});"; |
292 | 304 | |
293 | - if ($immediatly) |
|
294 | - $this->jquery_code_for_compile[]=$str; |
|
305 | + if ($immediatly) { |
|
306 | + $this->jquery_code_for_compile[]=$str; |
|
307 | + } |
|
295 | 308 | return $str; |
296 | 309 | } |
297 | 310 | |
@@ -309,8 +322,9 @@ discard block |
||
309 | 322 | $str.="else{".$jsCodeIfFalse."}"; |
310 | 323 | } |
311 | 324 | |
312 | - if ($immediatly) |
|
313 | - $this->jquery_code_for_compile[]=$str; |
|
325 | + if ($immediatly) { |
|
326 | + $this->jquery_code_for_compile[]=$str; |
|
327 | + } |
|
314 | 328 | return $str; |
315 | 329 | } |
316 | 330 | |
@@ -327,11 +341,13 @@ discard block |
||
327 | 341 | public function _doJQuery($element, $jqueryCall, $param="", $jsCallback="", $immediatly=false) { |
328 | 342 | $param=$this->_prep_value($param); |
329 | 343 | $callback=""; |
330 | - if ($jsCallback!="") |
|
331 | - $callback=", function(event){\n{$jsCallback}\n}"; |
|
344 | + if ($jsCallback!="") { |
|
345 | + $callback=", function(event){\n{$jsCallback}\n}"; |
|
346 | + } |
|
332 | 347 | $script="$(".$this->_prep_element($element).").".$jqueryCall."(".$param.$callback.");\n"; |
333 | - if ($immediatly) |
|
334 | - $this->jquery_code_for_compile[]=$script; |
|
348 | + if ($immediatly) { |
|
349 | + $this->jquery_code_for_compile[]=$script; |
|
350 | + } |
|
335 | 351 | return $script; |
336 | 352 | } |
337 | 353 | |
@@ -360,8 +376,9 @@ discard block |
||
360 | 376 | */ |
361 | 377 | public function _exec($js, $immediatly=false) { |
362 | 378 | $script=$js."\n"; |
363 | - if ($immediatly) |
|
364 | - $this->jquery_code_for_compile[]=$script; |
|
379 | + if ($immediatly) { |
|
380 | + $this->jquery_code_for_compile[]=$script; |
|
381 | + } |
|
365 | 382 | return $script; |
366 | 383 | } |
367 | 384 |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * @param string $jsCallback javascript code to execute after the request |
18 | 18 | * @param boolean $hasLoader true for showing ajax loader. default : true |
19 | 19 | */ |
20 | - public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true) { |
|
21 | - return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,true); |
|
20 | + public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true) { |
|
21 | + return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, true); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * @param string $jsCallback javascript code to execute after the request |
30 | 30 | * @param boolean $immediatly |
31 | 31 | */ |
32 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
33 | - return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context,$immediatly); |
|
32 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
33 | + return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context, $immediatly); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | * @param string $url the request address |
41 | 41 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
42 | 42 | */ |
43 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
44 | - return $this->js->_jsonOn($event, $element, $url,$parameters); |
|
43 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
44 | + return $this->js->_jsonOn($event, $element, $url, $parameters); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * @param string $url the request url |
86 | 86 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
87 | 87 | */ |
88 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
89 | - return $this->js->_jsonArrayOn($event,$element,$maskSelector, $url, $parameters); |
|
88 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
89 | + return $this->js->_jsonArrayOn($event, $element, $maskSelector, $url, $parameters); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param string $jsCallback javascript code to execute after the request |
99 | 99 | * @param string $attr the html attribute added to the request |
100 | 100 | */ |
101 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id") { |
|
101 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id") { |
|
102 | 102 | return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false); |
103 | 103 | } |
104 | 104 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * @param string $jsCallback javascript code to execute after the request |
137 | 137 | * @param boolean $hasLoader true for showing ajax loader. default : true |
138 | 138 | */ |
139 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true) { |
|
140 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,true); |
|
139 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true) { |
|
140 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, true); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @param string $jsCallback javascript code to execute after the request |
151 | 151 | * @param boolean $hasLoader true for showing ajax loader. default : true |
152 | 152 | */ |
153 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true) { |
|
154 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,false); |
|
153 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true) { |
|
154 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, false); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
166 | 166 | */ |
167 | 167 | public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
168 | - return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
168 | + return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * @param string $jsCallback javascript code to execute after the request |
190 | 190 | * @param boolean $hasLoader true for showing ajax loader. default : true |
191 | 191 | */ |
192 | - public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true) { |
|
193 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,true); |
|
192 | + public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $hasLoader=true) { |
|
193 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader, true); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | * @param string $attr the html attribute added to the request |
204 | 204 | * @param boolean $hasLoader true for showing ajax loader. default : true |
205 | 205 | */ |
206 | - public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true) { |
|
207 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,false); |
|
206 | + public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true) { |
|
207 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, false); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
219 | 219 | */ |
220 | 220 | public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
221 | - return $this->js->_postFormOn($event,$element, $url, $form, $responseElement, $parameters); |
|
221 | + return $this->js->_postFormOn($event, $element, $url, $form, $responseElement, $parameters); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @return string |
14 | 14 | */ |
15 | 15 | public function addClass($element='this', $class='', $immediatly=false) { |
16 | - return $this->js->_genericCallValue('addClass',$element, $class, $immediatly); |
|
16 | + return $this->js->_genericCallValue('addClass', $element, $class, $immediatly); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * @param boolean $immediatly defers the execution if set to false |
24 | 24 | * @return string |
25 | 25 | */ |
26 | - public function after($to, $element, $immediatly=false){ |
|
27 | - return $this->js->_genericCallElement('after',$to, $element, $immediatly); |
|
26 | + public function after($to, $element, $immediatly=false) { |
|
27 | + return $this->js->_genericCallElement('after', $to, $element, $immediatly); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @param boolean $immediatly defers the execution if set to false |
35 | 35 | * @return string |
36 | 36 | */ |
37 | - public function before($to, $element, $immediatly=false){ |
|
38 | - return $this->js->_genericCallElement('before',$to, $element, $immediatly); |
|
37 | + public function before($to, $element, $immediatly=false) { |
|
38 | + return $this->js->_genericCallElement('before', $to, $element, $immediatly); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * @param string $value |
56 | 56 | * @param boolean $immediatly defers the execution if set to false |
57 | 57 | */ |
58 | - public function val($element='this',$value='',$immediatly=false){ |
|
59 | - return $this->js->_genericCallValue('val',$element,$value,$immediatly); |
|
58 | + public function val($element='this', $value='', $immediatly=false) { |
|
59 | + return $this->js->_genericCallValue('val', $element, $value, $immediatly); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param boolean $immediatly defers the execution if set to false |
67 | 67 | */ |
68 | 68 | public function html($element='this', $value='', $immediatly=false) { |
69 | - return $this->js->_genericCallValue('html',$element, $value, $immediatly); |
|
69 | + return $this->js->_genericCallValue('html', $element, $value, $immediatly); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return string |
92 | 92 | */ |
93 | 93 | public function append($to, $element, $immediatly=false) { |
94 | - return $this->js->_genericCallElement('append',$to, $element, $immediatly); |
|
94 | + return $this->js->_genericCallElement('append', $to, $element, $immediatly); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @return string |
103 | 103 | */ |
104 | 104 | public function prepend($to, $element, $immediatly=false) { |
105 | - return $this->js->_genericCallElement('prepend',$to, $element, $immediatly); |
|
105 | + return $this->js->_genericCallElement('prepend', $to, $element, $immediatly); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return string |
154 | 154 | */ |
155 | 155 | public function removeClass($element='this', $class='', $immediatly=false) { |
156 | - return $this->js->_genericCall('removeClass',$element, $class, $immediatly); |
|
156 | + return $this->js->_genericCall('removeClass', $element, $class, $immediatly); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @return string |
215 | 215 | */ |
216 | 216 | public function toggleClass($element='this', $class='', $immediatly=false) { |
217 | - return $this->js->_genericCallValue('toggleClass',$element, $class, $immediatly); |
|
217 | + return $this->js->_genericCallValue('toggleClass', $element, $class, $immediatly); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $preventDefault=false; |
291 | 291 | $immediatly=true; |
292 | 292 | extract($parameters); |
293 | - return $this->js->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback,$immediatly); |
|
293 | + return $this->js->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback, $immediatly); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $preventDefault=false; |
318 | 318 | $immediatly=true; |
319 | 319 | extract($parameters); |
320 | - $script=$this->js->_execOn($element, $event, $js, $preventDefault, $stopPropagation,$immediatly); |
|
320 | + $script=$this->js->_execOn($element, $event, $js, $preventDefault, $stopPropagation, $immediatly); |
|
321 | 321 | return $script; |
322 | 322 | } |
323 | 323 | } |
324 | 324 | \ No newline at end of file |