@@ -7,17 +7,17 @@ |
||
7 | 7 | |
8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
9 | 9 | |
10 | - public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false) { |
|
11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items))->asSelect($identifier,$multiple), $label); |
|
10 | + public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items))->asSelect($identifier, $multiple), $label); |
|
12 | 12 | } |
13 | 13 | |
14 | - public function setItems($items){ |
|
14 | + public function setItems($items) { |
|
15 | 15 | return $this->getField()->setItems($items); |
16 | 16 | } |
17 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
18 | - return $this->getField()->addItem($item,$value,$image); |
|
17 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
18 | + return $this->getField()->addItem($item, $value, $image); |
|
19 | 19 | } |
20 | - public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL){ |
|
21 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true); |
|
20 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL) { |
|
21 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true); |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -5,5 +5,5 @@ |
||
5 | 5 | use Ajax\common\BaseEnum; |
6 | 6 | |
7 | 7 | abstract class CheckboxType extends BaseEnum { |
8 | - const STANDARD="",TOGGLE="toggle",SLIDER="slider"; |
|
8 | + const STANDARD="", TOGGLE="toggle", SLIDER="slider"; |
|
9 | 9 | } |
10 | 10 | \ No newline at end of file |
@@ -9,10 +9,10 @@ |
||
9 | 9 | * @author jc |
10 | 10 | * @version 1.001 |
11 | 11 | */ |
12 | -abstract class HtmlSemCollection extends HtmlCollection{ |
|
12 | +abstract class HtmlSemCollection extends HtmlCollection { |
|
13 | 13 | use BaseTrait; |
14 | - public function __construct( $identifier, $tagName="div",$baseClass=""){ |
|
15 | - parent::__construct( $identifier, $tagName); |
|
14 | + public function __construct($identifier, $tagName="div", $baseClass="") { |
|
15 | + parent::__construct($identifier, $tagName); |
|
16 | 16 | $this->_baseClass=$baseClass; |
17 | 17 | $this->setClass($baseClass); |
18 | 18 | } |
@@ -7,26 +7,26 @@ |
||
7 | 7 | |
8 | 8 | class HtmlTextarea extends HtmlDoubleElement { |
9 | 9 | |
10 | - public function __construct($identifier,$value=NULL,$placeholder=NULL,$rows=NULL) { |
|
10 | + public function __construct($identifier, $value=NULL, $placeholder=NULL, $rows=NULL) { |
|
11 | 11 | parent::__construct($identifier, "textarea"); |
12 | 12 | $this->setValue($value); |
13 | 13 | $this->setPlaceholder($placeholder); |
14 | - if(isset($rows)) |
|
14 | + if (isset($rows)) |
|
15 | 15 | $this->setRows($rows); |
16 | 16 | } |
17 | 17 | public function setValue($value) { |
18 | - if(isset($value)) |
|
18 | + if (isset($value)) |
|
19 | 19 | $this->setContent($value); |
20 | 20 | return $this; |
21 | 21 | } |
22 | 22 | |
23 | - public function setPlaceholder($value){ |
|
24 | - if(JString::isNotNull($value)) |
|
23 | + public function setPlaceholder($value) { |
|
24 | + if (JString::isNotNull($value)) |
|
25 | 25 | $this->setProperty("placeholder", $value); |
26 | 26 | return $this; |
27 | 27 | } |
28 | 28 | |
29 | - public function setRows($count){ |
|
29 | + public function setRows($count) { |
|
30 | 30 | $this->setProperty("rows", $count); |
31 | 31 | } |
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -11,18 +11,21 @@ |
||
11 | 11 | parent::__construct($identifier, "textarea"); |
12 | 12 | $this->setValue($value); |
13 | 13 | $this->setPlaceholder($placeholder); |
14 | - if(isset($rows)) |
|
15 | - $this->setRows($rows); |
|
14 | + if(isset($rows)) { |
|
15 | + $this->setRows($rows); |
|
16 | + } |
|
16 | 17 | } |
17 | 18 | public function setValue($value) { |
18 | - if(isset($value)) |
|
19 | - $this->setContent($value); |
|
19 | + if(isset($value)) { |
|
20 | + $this->setContent($value); |
|
21 | + } |
|
20 | 22 | return $this; |
21 | 23 | } |
22 | 24 | |
23 | 25 | public function setPlaceholder($value){ |
24 | - if(JString::isNotNull($value)) |
|
25 | - $this->setProperty("placeholder", $value); |
|
26 | + if(JString::isNotNull($value)) { |
|
27 | + $this->setProperty("placeholder", $value); |
|
28 | + } |
|
26 | 29 | return $this; |
27 | 30 | } |
28 | 31 |
@@ -8,17 +8,17 @@ |
||
8 | 8 | class HtmlFormTextarea extends HtmlFormField { |
9 | 9 | use TextFieldsTrait; |
10 | 10 | |
11 | - public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
|
12 | - if(!isset($placeholder)) |
|
11 | + public function __construct($identifier, $label=NULL, $value=NULL, $placeholder=NULL, $rows=NULL) { |
|
12 | + if (!isset($placeholder)) |
|
13 | 13 | $placeholder=$label; |
14 | - parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
|
14 | + parent::__construct("field-".$identifier, new HtmlTextarea($identifier, $value, $placeholder, $rows), $label); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Defines the textarea row count |
19 | 19 | * @param int $count |
20 | 20 | */ |
21 | - public function setRows($count){ |
|
21 | + public function setRows($count) { |
|
22 | 22 | $this->getField()->setRows($count); |
23 | 23 | } |
24 | 24 | } |
25 | 25 | \ No newline at end of file |
@@ -8,8 +8,9 @@ |
||
8 | 8 | class HtmlFormInput extends HtmlFormField { |
9 | 9 | |
10 | 10 | public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
11 | - if(!isset($placeholder)) |
|
12 | - $placeholder=$label; |
|
11 | + if(!isset($placeholder)) { |
|
12 | + $placeholder=$label; |
|
13 | + } |
|
13 | 14 | parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
14 | 15 | } |
15 | 16 |
@@ -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( |
@@ -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) |
@@ -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 | |
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 | } |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function _output($array_js='') { |
137 | 137 | if (!is_array($array_js)) { |
138 | - $array_js=array ( |
|
138 | + $array_js=array( |
|
139 | 139 | $array_js |
140 | 140 | ); |
141 | 141 | } |
142 | 142 | |
143 | - foreach ( $array_js as $js ) { |
|
143 | + foreach ($array_js as $js) { |
|
144 | 144 | $this->jquery_code_for_compile[]="\t$js\n"; |
145 | 145 | } |
146 | 146 | } |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * @param string $param |
153 | 153 | * @param boolean $immediatly delayed if false |
154 | 154 | */ |
155 | - public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
155 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
156 | 156 | $element=$this->_prep_element($element); |
157 | 157 | if (isset($param)) { |
158 | 158 | $param=$this->_prep_value($param); |
159 | 159 | $str="$({$element}).{$jQueryCall}({$param});"; |
160 | - } else |
|
160 | + }else |
|
161 | 161 | $str="$({$element}).{$jQueryCall}();"; |
162 | 162 | if ($immediatly) |
163 | 163 | $this->jquery_code_for_compile[]=$str; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param boolean $immediatly delayed if false |
172 | 172 | * @return string |
173 | 173 | */ |
174 | - public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
|
174 | + public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) { |
|
175 | 175 | $to=$this->_prep_element($to); |
176 | 176 | $element=$this->_prep_element($element); |
177 | 177 | $str="$({$to}).{$jQueryCall}({$element});"; |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function sortable($element, $options=array()) { |
191 | 191 | if (count($options)>0) { |
192 | - $sort_options=array (); |
|
193 | - foreach ( $options as $k => $v ) { |
|
192 | + $sort_options=array(); |
|
193 | + foreach ($options as $k => $v) { |
|
194 | 194 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
195 | 195 | } |
196 | 196 | $sort_options=implode(",", $sort_options); |
197 | - } else { |
|
197 | + }else { |
|
198 | 198 | $sort_options=''; |
199 | 199 | } |
200 | 200 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. |
223 | 223 | * @return string |
224 | 224 | */ |
225 | - public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
225 | + public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
226 | 226 | if (is_array($js)) { |
227 | 227 | $js=implode("\n\t\t", $js); |
228 | 228 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
237 | 237 | else |
238 | 238 | $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
239 | - if($immediatly) |
|
239 | + if ($immediatly) |
|
240 | 240 | $this->jquery_code_for_compile[]=$event; |
241 | 241 | return $event; |
242 | 242 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | // External references |
278 | 278 | $external_scripts=implode('', $this->jquery_code_for_load); |
279 | - extract(array ( |
|
279 | + extract(array( |
|
280 | 280 | 'library_src' => $external_scripts |
281 | 281 | )); |
282 | 282 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $script.='});'; |
292 | 292 | |
293 | 293 | $this->jquery_code_for_compile=array(); |
294 | - if($this->params["debug"]==false){ |
|
294 | + if ($this->params["debug"]==false) { |
|
295 | 295 | $script=$this->minify($script); |
296 | 296 | } |
297 | 297 | $output=($script_tags===FALSE) ? $script : $this->inline($script); |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @return void |
312 | 312 | */ |
313 | 313 | public function _clear_compile() { |
314 | - $this->jquery_code_for_compile=array (); |
|
314 | + $this->jquery_code_for_compile=array(); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function _document_ready($js) { |
322 | 322 | if (!is_array($js)) { |
323 | - $js=array ( |
|
323 | + $js=array( |
|
324 | 324 | $js |
325 | 325 | ); |
326 | 326 | } |
327 | 327 | |
328 | - foreach ( $js as $script ) { |
|
328 | + foreach ($js as $script) { |
|
329 | 329 | $this->jquery_code_for_compile[]=$script; |
330 | 330 | } |
331 | 331 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @return string |
340 | 340 | */ |
341 | 341 | public function _prep_element($element) { |
342 | - if (strrpos($element, 'this')===false&&strrpos($element, 'event')===false&&strrpos($element, 'self')===false) { |
|
342 | + if (strrpos($element, 'this')===false && strrpos($element, 'event')===false && strrpos($element, 'self')===false) { |
|
343 | 343 | $element='"'.addslashes($element).'"'; |
344 | 344 | } |
345 | 345 | return $element; |
@@ -357,14 +357,14 @@ discard block |
||
357 | 357 | if (is_array($value)) { |
358 | 358 | $value=implode(",", $value); |
359 | 359 | } |
360 | - if (strrpos($value, 'this')===false&&strrpos($value, 'event')===false&&strrpos($value, 'self')===false) { |
|
360 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false && strrpos($value, 'self')===false) { |
|
361 | 361 | $value='"'.$value.'"'; |
362 | 362 | } |
363 | 363 | return $value; |
364 | 364 | } |
365 | 365 | |
366 | 366 | private function minify($input) { |
367 | - if(trim($input) === "") return $input; |
|
367 | + if (trim($input)==="") return $input; |
|
368 | 368 | return preg_replace( |
369 | 369 | array( |
370 | 370 | // Remove comment(s) |
@@ -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 |
@@ -3,7 +3,17 @@ discard block |
||
3 | 3 | namespace Ajax\common\traits; |
4 | 4 | |
5 | 5 | trait JqueryActionsTrait { |
6 | + |
|
7 | + /** |
|
8 | + * @param string $element |
|
9 | + * @param string $js |
|
10 | + * @param string $event |
|
11 | + */ |
|
6 | 12 | public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
13 | + |
|
14 | + /** |
|
15 | + * @param string $element |
|
16 | + */ |
|
7 | 17 | public abstract function _prep_element($element); |
8 | 18 | public abstract function _prep_value($value); |
9 | 19 | |
@@ -384,7 +394,7 @@ discard block |
||
384 | 394 | |
385 | 395 | /** |
386 | 396 | * Ensures the speed parameter is valid for jQuery |
387 | - * @param string|int $speed |
|
397 | + * @param string $speed |
|
388 | 398 | * @return string |
389 | 399 | */ |
390 | 400 | private function _validate_speed($speed) { |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | namespace Ajax\common\traits; |
4 | 4 | |
5 | 5 | trait JqueryActionsTrait { |
6 | - public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
6 | + public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
7 | 7 | public abstract function _prep_element($element); |
8 | 8 | public abstract function _prep_value($value); |
9 | 9 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | if (isset($value)) { |
20 | 20 | $value=$this->_prep_value($value); |
21 | 21 | $str="$({$element}).attr(\"$attributeName\",{$value});"; |
22 | - } else |
|
22 | + }else |
|
23 | 23 | $str="$({$element}).attr(\"$attributeName\");"; |
24 | 24 | if ($immediatly) |
25 | 25 | $this->jquery_code_for_compile[]=$str; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param boolean $immediatly defers the execution if set to false |
34 | 34 | * @return string |
35 | 35 | */ |
36 | - public function after($element='this', $value='', $immediatly=false){ |
|
36 | + public function after($element='this', $value='', $immediatly=false) { |
|
37 | 37 | $element=$this->_prep_element($element); |
38 | 38 | $value=$this->_prep_value($value); |
39 | 39 | $str="$({$element}).after({$value});"; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | $animations="\t\t\t"; |
60 | 60 | if (is_array($params)) { |
61 | - foreach ( $params as $param => $value ) { |
|
61 | + foreach ($params as $param => $value) { |
|
62 | 62 | $animations.=$param.': \''.$value.'\', '; |
63 | 63 | } |
64 | 64 | } |
@@ -351,8 +351,8 @@ discard block |
||
351 | 351 | * @param boolean $immediatly |
352 | 352 | * @return string |
353 | 353 | */ |
354 | - public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="",$immediatly=true) { |
|
355 | - return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation,$immediatly); |
|
354 | + public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="", $immediatly=true) { |
|
355 | + return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation, $immediatly); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param boolean $immediatly |
379 | 379 | * @return String |
380 | 380 | */ |
381 | - public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
382 | - return $this->_add_event($element, $this->_exec($js), $event, $preventDefault, $stopPropagation,$immediatly); |
|
381 | + public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
382 | + return $this->_add_event($element, $this->_exec($js), $event, $preventDefault, $stopPropagation, $immediatly); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | * @return string |
389 | 389 | */ |
390 | 390 | private function _validate_speed($speed) { |
391 | - if (in_array($speed, array ( |
|
392 | - 'slow','normal','fast' |
|
391 | + if (in_array($speed, array( |
|
392 | + 'slow', 'normal', 'fast' |
|
393 | 393 | ))) { |
394 | 394 | $speed='"'.$speed.'"'; |
395 | 395 | } elseif (preg_match("/[^0-9]/", $speed)) { |
@@ -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 |