@@ -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 |
@@ -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 |
@@ -13,8 +13,9 @@ |
||
13 | 13 | if(\is_array($value)){ |
14 | 14 | $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
15 | 15 | return $itemO; |
16 | - }else |
|
17 | - return new HtmlFormInput($value); |
|
16 | + } else { |
|
17 | + return new HtmlFormInput($value); |
|
18 | + } |
|
18 | 19 | } |
19 | 20 | |
20 | 21 | public function addInputs($inputs,$fieldslabel=null){ |
@@ -9,26 +9,26 @@ discard block |
||
9 | 9 | use Ajax\semantic\html\collections\form\HtmlFormCheckbox; |
10 | 10 | use Ajax\semantic\html\collections\form\HtmlFormRadio; |
11 | 11 | trait FieldsTrait { |
12 | - public abstract function addFields($fields=NULL,$label=NULL); |
|
12 | + public abstract function addFields($fields=NULL, $label=NULL); |
|
13 | 13 | public abstract function addItem($item); |
14 | 14 | |
15 | - protected function createItem($value){ |
|
16 | - if(\is_array($value)){ |
|
17 | - $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
|
15 | + protected function createItem($value) { |
|
16 | + if (\is_array($value)) { |
|
17 | + $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id", ""), JArray::getDefaultValue($value, "label", null), JArray::getDefaultValue($value, "type", "text"), JArray::getDefaultValue($value, "value", ""), JArray::getDefaultValue($value, "placeholder", JArray::getDefaultValue($value, "label", null))); |
|
18 | 18 | return $itemO; |
19 | 19 | }else |
20 | 20 | return new HtmlFormInput($value); |
21 | 21 | } |
22 | 22 | |
23 | - public function addInputs($inputs,$fieldslabel=null){ |
|
23 | + public function addInputs($inputs, $fieldslabel=null) { |
|
24 | 24 | $fields=array(); |
25 | - foreach ($inputs as $input){ |
|
25 | + foreach ($inputs as $input) { |
|
26 | 26 | \extract($input); |
27 | - $f=new HtmlFormInput("",""); |
|
27 | + $f=new HtmlFormInput("", ""); |
|
28 | 28 | $f->fromArray($input); |
29 | 29 | $fields[]=$f; |
30 | 30 | } |
31 | - return $this->addFields($fields,$fieldslabel); |
|
31 | + return $this->addFields($fields, $fieldslabel); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,27 +39,27 @@ discard block |
||
39 | 39 | * @param boolean $multiple |
40 | 40 | * @return \Ajax\common\html\HtmlDoubleElement |
41 | 41 | */ |
42 | - public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){ |
|
43 | - return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple)); |
|
42 | + public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
43 | + return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple)); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){ |
|
47 | - return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder)); |
|
46 | + public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
47 | + return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder)); |
|
48 | 48 | } |
49 | 49 | |
50 | - public function addPassword($identifier, $label=NULL){ |
|
51 | - return $this->addItem(new HtmlFormInput($identifier,$label,"password","","")); |
|
50 | + public function addPassword($identifier, $label=NULL) { |
|
51 | + return $this->addItem(new HtmlFormInput($identifier, $label, "password", "", "")); |
|
52 | 52 | } |
53 | 53 | |
54 | - public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){ |
|
55 | - return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick)); |
|
54 | + public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) { |
|
55 | + return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
|
56 | 56 | } |
57 | 57 | |
58 | - public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){ |
|
59 | - return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type)); |
|
58 | + public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) { |
|
59 | + return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type)); |
|
60 | 60 | } |
61 | 61 | |
62 | - public function addRadio($identifier, $name,$label=NULL,$value=NULL){ |
|
63 | - return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value)); |
|
62 | + public function addRadio($identifier, $name, $label=NULL, $value=NULL) { |
|
63 | + return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value)); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | \ No newline at end of file |
@@ -3,11 +3,11 @@ |
||
3 | 3 | namespace Ajax\semantic\html\collections\form; |
4 | 4 | |
5 | 5 | trait TextFieldsTrait { |
6 | - public function setPlaceholder($value){ |
|
6 | + public function setPlaceholder($value) { |
|
7 | 7 | return $this->getField()->setPlaceholder($value); |
8 | 8 | } |
9 | 9 | |
10 | - public function setValue($value){ |
|
10 | + public function setValue($value) { |
|
11 | 11 | return $this->getField()->setValue($value); |
12 | 12 | } |
13 | 13 | } |
14 | 14 | \ No newline at end of file |
@@ -9,7 +9,17 @@ discard block |
||
9 | 9 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
10 | 10 | |
11 | 11 | public abstract function _prep_value($value); |
12 | + |
|
13 | + /** |
|
14 | + * @param string $element |
|
15 | + * @param string $js |
|
16 | + * @param string $event |
|
17 | + */ |
|
12 | 18 | public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
19 | + |
|
20 | + /** |
|
21 | + * @param string $retour |
|
22 | + */ |
|
13 | 23 | protected function addLoading(&$retour, $responseElement) { |
14 | 24 | $loading_notifier='<div class="ajax-loader">'; |
15 | 25 | if ($this->ajaxLoader=='') { |
@@ -22,13 +32,23 @@ discard block |
||
22 | 32 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
23 | 33 | } |
24 | 34 | |
35 | + /** |
|
36 | + * @param string $url |
|
37 | + */ |
|
25 | 38 | public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
26 | 39 | return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
27 | 40 | } |
41 | + |
|
42 | + /** |
|
43 | + * @param string $url |
|
44 | + */ |
|
28 | 45 | public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
29 | 46 | return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
30 | 47 | } |
31 | 48 | |
49 | + /** |
|
50 | + * @param string $method |
|
51 | + */ |
|
32 | 52 | protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
33 | 53 | if(JString::isNull($params)){$params="{}";} |
34 | 54 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
@@ -45,6 +65,9 @@ discard block |
||
45 | 65 | return $retour; |
46 | 66 | } |
47 | 67 | |
68 | + /** |
|
69 | + * @param string $attr |
|
70 | + */ |
|
48 | 71 | protected function _getAjaxUrl($url,$attr){ |
49 | 72 | $url=$this->_correctAjaxUrl($url); |
50 | 73 | $retour="url='".$url."';\n"; |
@@ -176,6 +199,11 @@ discard block |
||
176 | 199 | return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
177 | 200 | } |
178 | 201 | |
202 | + /** |
|
203 | + * @param string $url |
|
204 | + * @param string $form |
|
205 | + * @param string $responseElement |
|
206 | + */ |
|
179 | 207 | public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
180 | 208 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
181 | 209 | $retour=$this->_getAjaxUrl($url, $attr); |
@@ -3,8 +3,6 @@ |
||
3 | 3 | namespace Ajax\common\traits; |
4 | 4 | |
5 | 5 | use Ajax\service\JString; |
6 | -use Ajax\service\PhalconUtils; |
|
7 | -use Symfony\Component\Config\Definition\Exception\Exception; |
|
8 | 6 | trait JqueryAjaxTrait { |
9 | 7 | |
10 | 8 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
11 | 11 | |
12 | 12 | public abstract function _prep_value($value); |
13 | - public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
13 | + public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
14 | 14 | protected function addLoading(&$retour, $responseElement) { |
15 | 15 | $loading_notifier='<div class="ajax-loader">'; |
16 | 16 | if ($this->ajaxLoader=='') { |
17 | 17 | $loading_notifier.="Loading..."; |
18 | - } else { |
|
18 | + }else { |
|
19 | 19 | $loading_notifier.=$this->ajaxLoader; |
20 | 20 | } |
21 | 21 | $loading_notifier.='</div>'; |
@@ -23,20 +23,20 @@ discard block |
||
23 | 23 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
24 | 24 | } |
25 | 25 | |
26 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
27 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
26 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
27 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
28 | 28 | } |
29 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
30 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
29 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
30 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
31 | 31 | } |
32 | 32 | |
33 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
34 | - if(JString::isNull($params)){$params="{}";} |
|
33 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
34 | + if (JString::isNull($params)) {$params="{}"; } |
|
35 | 35 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
36 | 36 | $retour=$this->_getAjaxUrl($url, $attr); |
37 | 37 | $responseElement=$this->_getResponseElement($responseElement); |
38 | 38 | $retour.="var self=this;\n"; |
39 | - if($hasLoader===true){ |
|
39 | + if ($hasLoader===true) { |
|
40 | 40 | $this->addLoading($retour, $responseElement); |
41 | 41 | } |
42 | 42 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | return $retour; |
47 | 47 | } |
48 | 48 | |
49 | - protected function _getAjaxUrl($url,$attr){ |
|
49 | + protected function _getAjaxUrl($url, $attr) { |
|
50 | 50 | $url=$this->_correctAjaxUrl($url); |
51 | 51 | $retour="url='".$url."';\n"; |
52 | 52 | $slash="/"; |
53 | - if(JString::endswith($url, "/")===true) |
|
53 | + if (JString::endswith($url, "/")===true) |
|
54 | 54 | $slash=""; |
55 | - if(JString::isNotNull($attr)){ |
|
55 | + if (JString::isNotNull($attr)) { |
|
56 | 56 | if ($attr=="value") |
57 | 57 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
58 | - else if($attr!=null && $attr!=="") |
|
58 | + else if ($attr!=null && $attr!=="") |
|
59 | 59 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
60 | 60 | } |
61 | 61 | return $retour; |
62 | 62 | } |
63 | 63 | |
64 | - protected function _getOnAjaxDone($responseElement,$jsCallback){ |
|
64 | + protected function _getOnAjaxDone($responseElement, $jsCallback) { |
|
65 | 65 | $retour=""; |
66 | 66 | if ($responseElement!=="") { |
67 | 67 | $retour="\t$({$responseElement}).html( data );\n"; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | return $retour; |
71 | 71 | } |
72 | 72 | |
73 | - protected function _getResponseElement($responseElement){ |
|
73 | + protected function _getResponseElement($responseElement) { |
|
74 | 74 | if ($responseElement!=="") { |
75 | 75 | $responseElement=$this->_prep_value($responseElement); |
76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | protected function _correctAjaxUrl($url) { |
81 | 81 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
82 | 82 | $url=substr($url, 0, strlen($url)-1); |
83 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
83 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
84 | 84 | $url=$this->jsUtils->getUrl($url); |
85 | 85 | } |
86 | 86 | return $url; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param string $jsCallback javascript code to execute after the request |
95 | 95 | * @param boolean $immediatly |
96 | 96 | */ |
97 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
97 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
98 | 98 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
99 | 99 | $retour=$this->_getAjaxUrl($url, $attr); |
100 | 100 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param string $url the request address |
116 | 116 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
117 | 117 | */ |
118 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
118 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
119 | 119 | $preventDefault=true; |
120 | 120 | $stopPropagation=true; |
121 | 121 | $jsCallback=null; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $params="{}"; |
126 | 126 | $immediatly=true; |
127 | 127 | extract($parameters); |
128 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
128 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | * @param string $context jquery DOM element, array container. |
138 | 138 | * @param boolean $immediatly |
139 | 139 | */ |
140 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) { |
|
140 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) { |
|
141 | 141 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
142 | 142 | $retour=$this->_getAjaxUrl($url, $attr); |
143 | - if($context===null){ |
|
143 | + if ($context===null) { |
|
144 | 144 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
145 | - $newElm = "$('#'+newId)"; |
|
146 | - }else{ |
|
145 | + $newElm="$('#'+newId)"; |
|
146 | + }else { |
|
147 | 147 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
148 | - $newElm = $context.".find('#'+newId)"; |
|
148 | + $newElm=$context.".find('#'+newId)"; |
|
149 | 149 | } |
150 | 150 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
151 | 151 | $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"; |
152 | - $retour.= $appendTo; |
|
152 | + $retour.=$appendTo; |
|
153 | 153 | $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"; |
154 | 154 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
155 | 155 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -164,26 +164,26 @@ discard block |
||
164 | 164 | * @param string $url the request address |
165 | 165 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
166 | 166 | */ |
167 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
167 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
168 | 168 | $preventDefault=true; |
169 | 169 | $stopPropagation=true; |
170 | 170 | $jsCallback=null; |
171 | 171 | $attr="id"; |
172 | 172 | $method="get"; |
173 | - $context = null; |
|
173 | + $context=null; |
|
174 | 174 | $params="{}"; |
175 | 175 | $immediatly=true; |
176 | 176 | extract($parameters); |
177 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
177 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
178 | 178 | } |
179 | 179 | |
180 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
180 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
181 | 181 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
182 | 182 | $retour=$this->_getAjaxUrl($url, $attr); |
183 | 183 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
184 | 184 | $responseElement=$this->_getResponseElement($responseElement); |
185 | 185 | $retour.="var self=this;\n"; |
186 | - if($hasLoader===true){ |
|
186 | + if ($hasLoader===true) { |
|
187 | 187 | $this->addLoading($retour, $responseElement); |
188 | 188 | } |
189 | 189 | $retour.="$.post(url,params).done(function( data ) {\n"; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param string $responseElement |
211 | 211 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
212 | 212 | */ |
213 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
213 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
214 | 214 | $preventDefault=true; |
215 | 215 | $stopPropagation=true; |
216 | 216 | $jsCallback=null; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $hasLoader=true; |
219 | 219 | $immediatly=true; |
220 | 220 | extract($parameters); |
221 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
221 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param string $responseElement |
232 | 232 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
233 | 233 | */ |
234 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
234 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
235 | 235 | $preventDefault=true; |
236 | 236 | $stopPropagation=true; |
237 | 237 | $jsCallback=null; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $hasLoader=true; |
240 | 240 | $immediatly=true; |
241 | 241 | extract($parameters); |
242 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
242 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @param string $responseElement |
253 | 253 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
254 | 254 | */ |
255 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
255 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
256 | 256 | $preventDefault=true; |
257 | 257 | $stopPropagation=true; |
258 | 258 | $validation=false; |
@@ -261,6 +261,6 @@ discard block |
||
261 | 261 | $hasLoader=true; |
262 | 262 | $immediatly=true; |
263 | 263 | extract($parameters); |
264 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
264 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | \ No newline at end of file |
@@ -41,8 +41,9 @@ discard block |
||
41 | 41 | } |
42 | 42 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
43 | 43 | $retour.=$this->_getOnAjaxDone($responseElement, $jsCallback)."});\n"; |
44 | - if ($immediatly) |
|
45 | - $this->jquery_code_for_compile[]=$retour; |
|
44 | + if ($immediatly) { |
|
45 | + $this->jquery_code_for_compile[]=$retour; |
|
46 | + } |
|
46 | 47 | return $retour; |
47 | 48 | } |
48 | 49 | |
@@ -50,13 +51,15 @@ discard block |
||
50 | 51 | $url=$this->_correctAjaxUrl($url); |
51 | 52 | $retour="url='".$url."';\n"; |
52 | 53 | $slash="/"; |
53 | - if(JString::endswith($url, "/")===true) |
|
54 | - $slash=""; |
|
54 | + if(JString::endswith($url, "/")===true) { |
|
55 | + $slash=""; |
|
56 | + } |
|
55 | 57 | if(JString::isNotNull($attr)){ |
56 | - if ($attr=="value") |
|
57 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
58 | - else if($attr!=null && $attr!=="") |
|
59 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
58 | + if ($attr=="value") { |
|
59 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
60 | + } else if($attr!=null && $attr!=="") { |
|
61 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
62 | + } |
|
60 | 63 | } |
61 | 64 | return $retour; |
62 | 65 | } |
@@ -78,8 +81,9 @@ discard block |
||
78 | 81 | } |
79 | 82 | |
80 | 83 | protected function _correctAjaxUrl($url) { |
81 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
82 | - $url=substr($url, 0, strlen($url)-1); |
|
84 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
85 | + $url=substr($url, 0, strlen($url)-1); |
|
86 | + } |
|
83 | 87 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
84 | 88 | $url=$this->jsUtils->getUrl($url); |
85 | 89 | } |
@@ -103,8 +107,9 @@ discard block |
||
103 | 107 | $retour.="\t".$jsCallback."\n". |
104 | 108 | "\t$(document).trigger('jsonReady',[data]);\n". |
105 | 109 | "});\n"; |
106 | - if ($immediatly) |
|
107 | - $this->jquery_code_for_compile[]=$retour; |
|
110 | + if ($immediatly) { |
|
111 | + $this->jquery_code_for_compile[]=$retour; |
|
112 | + } |
|
108 | 113 | return $retour; |
109 | 114 | } |
110 | 115 | |
@@ -143,7 +148,7 @@ discard block |
||
143 | 148 | if($context===null){ |
144 | 149 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
145 | 150 | $newElm = "$('#'+newId)"; |
146 | - }else{ |
|
151 | + } else{ |
|
147 | 152 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
148 | 153 | $newElm = $context.".find('#'+newId)"; |
149 | 154 | } |
@@ -153,8 +158,9 @@ discard block |
||
153 | 158 | $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"; |
154 | 159 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
155 | 160 | $retour.="\t".$jsCallback."\n"."});\n"; |
156 | - if ($immediatly) |
|
157 | - $this->jquery_code_for_compile[]=$retour; |
|
161 | + if ($immediatly) { |
|
162 | + $this->jquery_code_for_compile[]=$retour; |
|
163 | + } |
|
158 | 164 | return $retour; |
159 | 165 | } |
160 | 166 | /** |
@@ -195,8 +201,9 @@ discard block |
||
195 | 201 | }});\n"; |
196 | 202 | $retour.="$('#".$form."').submit();\n"; |
197 | 203 | } |
198 | - if ($immediatly) |
|
199 | - $this->jquery_code_for_compile[]=$retour; |
|
204 | + if ($immediatly) { |
|
205 | + $this->jquery_code_for_compile[]=$retour; |
|
206 | + } |
|
200 | 207 | return $retour; |
201 | 208 | } |
202 | 209 |
@@ -3,7 +3,16 @@ |
||
3 | 3 | namespace Ajax\common\traits; |
4 | 4 | |
5 | 5 | trait JqueryEventsTrait { |
6 | + |
|
7 | + /** |
|
8 | + * @param string $element |
|
9 | + */ |
|
6 | 10 | public abstract function _prep_element($element); |
11 | + |
|
12 | + /** |
|
13 | + * @param string $element |
|
14 | + * @param string $event |
|
15 | + */ |
|
7 | 16 | public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
8 | 17 | |
9 | 18 | /** |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | trait JqueryEventsTrait { |
6 | 6 | public abstract function _prep_element($element); |
7 | - public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
7 | + public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Blur |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function _click($element='this', $js=array(), $ret_false=TRUE) { |
48 | 48 | if (!is_array($js)) { |
49 | - $js=array ( |
|
49 | + $js=array( |
|
50 | 50 | $js |
51 | 51 | ); |
52 | 52 | } |
@@ -21,6 +21,9 @@ discard block |
||
21 | 21 | protected $params=array("action"=>"nothing","on"=>"hover"); |
22 | 22 | protected $input; |
23 | 23 | |
24 | + /** |
|
25 | + * @param string $identifier |
|
26 | + */ |
|
24 | 27 | public function __construct($identifier, $value="", $items=array()) { |
25 | 28 | parent::__construct($identifier, "div"); |
26 | 29 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
@@ -47,7 +50,7 @@ discard block |
||
47 | 50 | /** |
48 | 51 | * Insert an item at a position |
49 | 52 | * @param mixed $item |
50 | - * @param number $position |
|
53 | + * @param integer $position |
|
51 | 54 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
52 | 55 | */ |
53 | 56 | public function insertItem($item,$position=0){ |
@@ -196,6 +199,9 @@ discard block |
||
196 | 199 | } |
197 | 200 | } |
198 | 201 | |
202 | + /** |
|
203 | + * @param string $action |
|
204 | + */ |
|
199 | 205 | public function setAction($action){ |
200 | 206 | $this->params["action"]=$action; |
201 | 207 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $itemO=$item; |
64 | 64 | if(!$item instanceof HtmlDropdownItem){ |
65 | 65 | $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
66 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
66 | + } elseif($itemO instanceof HtmlDropdownItem){ |
|
67 | 67 | $this->addToProperty("class", "vertical"); |
68 | 68 | } |
69 | 69 | return $itemO; |
@@ -77,8 +77,9 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | public function addInput($name){ |
80 | - if(!isset($name)) |
|
81 | - $name="input-".$this->identifier; |
|
80 | + if(!isset($name)) { |
|
81 | + $name="input-".$this->identifier; |
|
82 | + } |
|
82 | 83 | $this->setAction("activate"); |
83 | 84 | $this->input=new HtmlInput($name,"hidden"); |
84 | 85 | } |
@@ -88,7 +89,7 @@ discard block |
||
88 | 89 | foreach ($items as $k=>$v){ |
89 | 90 | $this->addItem($v)->setData($k); |
90 | 91 | } |
91 | - }else{ |
|
92 | + } else{ |
|
92 | 93 | foreach ($items as $item){ |
93 | 94 | $this->addItem($item); |
94 | 95 | } |
@@ -105,7 +106,7 @@ discard block |
||
105 | 106 | if($dropdown===false){ |
106 | 107 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
107 | 108 | $dropdown="menu"; |
108 | - }else{ |
|
109 | + } else{ |
|
109 | 110 | $dropdown="dropdown"; |
110 | 111 | $this->mClass="menu"; |
111 | 112 | } |
@@ -121,18 +122,22 @@ discard block |
||
121 | 122 | } |
122 | 123 | |
123 | 124 | public function asButton($floating=false){ |
124 | - if($floating) |
|
125 | - $this->addToProperty("class", "floating"); |
|
125 | + if($floating) { |
|
126 | + $this->addToProperty("class", "floating"); |
|
127 | + } |
|
126 | 128 | return $this->addToProperty("class", "button"); |
127 | 129 | } |
128 | 130 | |
129 | 131 | public function asSelect($name=NULL,$multiple=false,$selection=true){ |
130 | - if(isset($name)) |
|
131 | - $this->addInput($name); |
|
132 | - if($multiple) |
|
133 | - $this->addToProperty("class", "multiple"); |
|
134 | - if ($selection) |
|
135 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
132 | + if(isset($name)) { |
|
133 | + $this->addInput($name); |
|
134 | + } |
|
135 | + if($multiple) { |
|
136 | + $this->addToProperty("class", "multiple"); |
|
137 | + } |
|
138 | + if ($selection) { |
|
139 | + $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
140 | + } |
|
136 | 141 | return $this; |
137 | 142 | } |
138 | 143 | |
@@ -142,8 +147,9 @@ discard block |
||
142 | 147 | } |
143 | 148 | |
144 | 149 | public function setSelect($name=NULL,$multiple=false){ |
145 | - if(!isset($name)) |
|
146 | - $name="select-".$this->identifier; |
|
150 | + if(!isset($name)) { |
|
151 | + $name="select-".$this->identifier; |
|
152 | + } |
|
147 | 153 | $this->input=null; |
148 | 154 | if($multiple){ |
149 | 155 | $this->setProperty("multiple", true); |
@@ -174,12 +180,13 @@ discard block |
||
174 | 180 | public function setValue($value){ |
175 | 181 | if(isset($this->input)){ |
176 | 182 | $this->input->setProperty("value", $value); |
177 | - }else{ |
|
183 | + } else{ |
|
178 | 184 | $this->setProperty("value", $value); |
179 | 185 | } |
180 | 186 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
181 | - if(isset($textElement)) |
|
182 | - $textElement->setContent($value); |
|
187 | + if(isset($textElement)) { |
|
188 | + $textElement->setContent($value); |
|
189 | + } |
|
183 | 190 | return $this; |
184 | 191 | } |
185 | 192 | |
@@ -189,8 +196,9 @@ discard block |
||
189 | 196 | */ |
190 | 197 | public function run(JsUtils $js) { |
191 | 198 | if($this->propertyContains("class", "simple")===false){ |
192 | - if(isset($this->_bsComponent)===false) |
|
193 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
199 | + if(isset($this->_bsComponent)===false) { |
|
200 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
201 | + } |
|
194 | 202 | $this->addEventsOnRun($js); |
195 | 203 | return $this->_bsComponent; |
196 | 204 | } |
@@ -17,31 +17,31 @@ discard block |
||
17 | 17 | } |
18 | 18 | protected $mClass="menu"; |
19 | 19 | protected $mTagName="div"; |
20 | - protected $items=array (); |
|
21 | - protected $_params=array("action"=>"nothing","on"=>"hover"); |
|
20 | + protected $items=array(); |
|
21 | + protected $_params=array("action"=>"nothing", "on"=>"hover"); |
|
22 | 22 | protected $input; |
23 | 23 | |
24 | 24 | public function __construct($identifier, $value="", $items=array()) { |
25 | 25 | parent::__construct($identifier, "div"); |
26 | 26 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
27 | 27 | $this->setProperty("class", "ui dropdown"); |
28 | - $content=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
28 | + $content=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
29 | 29 | $content->setClass("text"); |
30 | 30 | $content->setContent($value); |
31 | - $content->wrap("",new HtmlIcon("", "dropdown")); |
|
31 | + $content->wrap("", new HtmlIcon("", "dropdown")); |
|
32 | 32 | $this->content=array($content); |
33 | 33 | $this->tagName="div"; |
34 | 34 | $this->addItems($items); |
35 | 35 | } |
36 | 36 | |
37 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
38 | - $itemO=$this->beforeAddItem($item,$value,$image); |
|
37 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
38 | + $itemO=$this->beforeAddItem($item, $value, $image); |
|
39 | 39 | $this->items[]=$itemO; |
40 | 40 | return $itemO; |
41 | 41 | } |
42 | 42 | |
43 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
44 | - $this->addIconP($icon,$before,$labeled); |
|
43 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
44 | + $this->addIconP($icon, $before, $labeled); |
|
45 | 45 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
46 | 46 | } |
47 | 47 | /** |
@@ -50,25 +50,25 @@ discard block |
||
50 | 50 | * @param number $position |
51 | 51 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
52 | 52 | */ |
53 | - public function insertItem($item,$position=0){ |
|
53 | + public function insertItem($item, $position=0) { |
|
54 | 54 | $itemO=$this->beforeAddItem($item); |
55 | - $start = array_slice($this->items, 0, $position); |
|
56 | - $end = array_slice($this->items, $position); |
|
57 | - $start[] = $item; |
|
55 | + $start=array_slice($this->items, 0, $position); |
|
56 | + $end=array_slice($this->items, $position); |
|
57 | + $start[]=$item; |
|
58 | 58 | $this->items=array_merge($start, $end); |
59 | 59 | return $itemO; |
60 | 60 | } |
61 | 61 | |
62 | - protected function beforeAddItem($item,$value=NULL,$image=NULL){ |
|
62 | + protected function beforeAddItem($item, $value=NULL, $image=NULL) { |
|
63 | 63 | $itemO=$item; |
64 | - if(\is_array($item)){ |
|
64 | + if (\is_array($item)) { |
|
65 | 65 | $value=JArray::getValue($item, "value", 1); |
66 | 66 | $image=JArray::getValue($item, "image", 2); |
67 | 67 | $item=JArray::getValue($item, "item", 0); |
68 | 68 | } |
69 | - if(!$item instanceof HtmlDropdownItem){ |
|
70 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
|
71 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
69 | + if (!$item instanceof HtmlDropdownItem) { |
|
70 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image); |
|
71 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
72 | 72 | $this->addToProperty("class", "vertical"); |
73 | 73 | } |
74 | 74 | return $itemO; |
@@ -81,76 +81,76 @@ discard block |
||
81 | 81 | $this->addItem($function($object)); |
82 | 82 | } |
83 | 83 | |
84 | - public function addInput($name){ |
|
85 | - if(!isset($name)) |
|
84 | + public function addInput($name) { |
|
85 | + if (!isset($name)) |
|
86 | 86 | $name="input-".$this->identifier; |
87 | 87 | $this->setAction("activate"); |
88 | - $this->input=new HtmlInput($name,"hidden"); |
|
88 | + $this->input=new HtmlInput($name, "hidden"); |
|
89 | 89 | } |
90 | 90 | |
91 | - public function addItems($items){ |
|
92 | - if(JArray::isAssociative($items)){ |
|
93 | - foreach ($items as $k=>$v){ |
|
91 | + public function addItems($items) { |
|
92 | + if (JArray::isAssociative($items)) { |
|
93 | + foreach ($items as $k=>$v) { |
|
94 | 94 | $this->addItem($v)->setData($k); |
95 | 95 | } |
96 | - }else{ |
|
97 | - foreach ($items as $item){ |
|
96 | + }else { |
|
97 | + foreach ($items as $item) { |
|
98 | 98 | $this->addItem($item); |
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - public function count(){ |
|
103 | + public function count() { |
|
104 | 104 | return \sizeof($this->items); |
105 | 105 | } |
106 | 106 | /** |
107 | 107 | * @param boolean $dropdown |
108 | 108 | */ |
109 | - public function asDropdown($dropdown){ |
|
110 | - if($dropdown===false){ |
|
109 | + public function asDropdown($dropdown) { |
|
110 | + if ($dropdown===false) { |
|
111 | 111 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
112 | 112 | $dropdown="menu"; |
113 | - }else{ |
|
113 | + }else { |
|
114 | 114 | $dropdown="dropdown"; |
115 | 115 | $this->mClass="menu"; |
116 | 116 | } |
117 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
117 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
118 | 118 | } |
119 | 119 | |
120 | - public function setVertical(){ |
|
121 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
120 | + public function setVertical() { |
|
121 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
122 | 122 | } |
123 | 123 | |
124 | - public function setSimple(){ |
|
125 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
124 | + public function setSimple() { |
|
125 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
126 | 126 | } |
127 | 127 | |
128 | - public function asButton($floating=false){ |
|
129 | - if($floating) |
|
128 | + public function asButton($floating=false) { |
|
129 | + if ($floating) |
|
130 | 130 | $this->addToProperty("class", "floating"); |
131 | 131 | return $this->addToProperty("class", "button"); |
132 | 132 | } |
133 | 133 | |
134 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
135 | - if(isset($name)) |
|
134 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
135 | + if (isset($name)) |
|
136 | 136 | $this->addInput($name); |
137 | - if($multiple) |
|
137 | + if ($multiple) |
|
138 | 138 | $this->addToProperty("class", "multiple"); |
139 | 139 | if ($selection) |
140 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
140 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
141 | 141 | return $this; |
142 | 142 | } |
143 | 143 | |
144 | - public function asSearch($name=NULL,$multiple=false,$selection=false){ |
|
145 | - $this->asSelect($name,$multiple,$selection); |
|
144 | + public function asSearch($name=NULL, $multiple=false, $selection=false) { |
|
145 | + $this->asSelect($name, $multiple, $selection); |
|
146 | 146 | return $this->addToProperty("class", "search"); |
147 | 147 | } |
148 | 148 | |
149 | - public function setSelect($name=NULL,$multiple=false){ |
|
150 | - if(!isset($name)) |
|
149 | + public function setSelect($name=NULL, $multiple=false) { |
|
150 | + if (!isset($name)) |
|
151 | 151 | $name="select-".$this->identifier; |
152 | 152 | $this->input=null; |
153 | - if($multiple){ |
|
153 | + if ($multiple) { |
|
154 | 154 | $this->setProperty("multiple", true); |
155 | 155 | $this->addToProperty("class", "multiple"); |
156 | 156 | } |
@@ -158,32 +158,32 @@ discard block |
||
158 | 158 | $this->tagName="select"; |
159 | 159 | $this->setProperty("name", $name); |
160 | 160 | $this->content=null; |
161 | - foreach ($this->items as $item){ |
|
161 | + foreach ($this->items as $item) { |
|
162 | 162 | $item->asOption(); |
163 | 163 | } |
164 | 164 | return $this; |
165 | 165 | } |
166 | 166 | |
167 | - public function asSubmenu($pointing=NULL){ |
|
167 | + public function asSubmenu($pointing=NULL) { |
|
168 | 168 | $this->setClass("ui dropdown link item"); |
169 | - if(isset($pointing)){ |
|
169 | + if (isset($pointing)) { |
|
170 | 170 | $this->setPointing($pointing); |
171 | 171 | } |
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | |
175 | - public function setPointing($value=Direction::NONE){ |
|
176 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
175 | + public function setPointing($value=Direction::NONE) { |
|
176 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
177 | 177 | } |
178 | 178 | |
179 | - public function setValue($value){ |
|
180 | - if(isset($this->input)){ |
|
179 | + public function setValue($value) { |
|
180 | + if (isset($this->input)) { |
|
181 | 181 | $this->input->setProperty("value", $value); |
182 | - }else{ |
|
182 | + }else { |
|
183 | 183 | $this->setProperty("value", $value); |
184 | 184 | } |
185 | 185 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
186 | - if(isset($textElement)) |
|
186 | + if (isset($textElement)) |
|
187 | 187 | $textElement->setContent($value); |
188 | 188 | return $this; |
189 | 189 | } |
@@ -193,23 +193,23 @@ discard block |
||
193 | 193 | * @see BaseHtml::run() |
194 | 194 | */ |
195 | 195 | public function run(JsUtils $js) { |
196 | - if($this->propertyContains("class", "simple")===false){ |
|
197 | - if(isset($this->_bsComponent)===false) |
|
198 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
196 | + if ($this->propertyContains("class", "simple")===false) { |
|
197 | + if (isset($this->_bsComponent)===false) |
|
198 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
199 | 199 | $this->addEventsOnRun($js); |
200 | 200 | return $this->_bsComponent; |
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - public function setCompact(){ |
|
204 | + public function setCompact() { |
|
205 | 205 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
206 | 206 | } |
207 | 207 | |
208 | - public function setAction($action){ |
|
208 | + public function setAction($action) { |
|
209 | 209 | $this->_params["action"]=$action; |
210 | 210 | } |
211 | 211 | |
212 | - public function setFullTextSearch($value){ |
|
212 | + public function setFullTextSearch($value) { |
|
213 | 213 | $this->_params["fullTextSearch"]=$value; |
214 | 214 | } |
215 | 215 | } |
216 | 216 | \ No newline at end of file |