1010 * @property array $jquery_code_for_compile
1111 */
1212trait JsUtilsEventsTrait {
13- protected $ jquery_events = array (
14- " bind " ,
15- " blur " ,
16- " change " ,
17- " click " ,
18- " dblclick " ,
19- " delegate " ,
20- " die " ,
21- " error " ,
22- " focus " ,
23- " focusin " ,
24- " focusout " ,
25- " hover " ,
26- " keydown " ,
27- " keypress " ,
28- " keyup " ,
29- " live " ,
30- " load " ,
31- " mousedown " ,
32- " mousseenter " ,
33- " mouseleave " ,
34- " mousemove " ,
35- " mouseout " ,
36- " mouseover " ,
37- " mouseup " ,
38- " off " ,
39- " on " ,
40- " one " ,
41- " ready " ,
42- " resize " ,
43- " scroll " ,
44- " select " ,
45- " submit " ,
46- " toggle " ,
47- " trigger " ,
48- " triggerHandler " ,
49- " undind " ,
50- " undelegate " ,
51- " unload "
52- ) ;
13+ protected $ jquery_events = [
14+ ' bind ' ,
15+ ' blur ' ,
16+ ' change ' ,
17+ ' click ' ,
18+ ' dblclick ' ,
19+ ' delegate ' ,
20+ ' die ' ,
21+ ' error ' ,
22+ ' focus ' ,
23+ ' focusin ' ,
24+ ' focusout ' ,
25+ ' hover ' ,
26+ ' keydown ' ,
27+ ' keypress ' ,
28+ ' keyup ' ,
29+ ' live ' ,
30+ ' load ' ,
31+ ' mousedown ' ,
32+ ' mousseenter ' ,
33+ ' mouseleave ' ,
34+ ' mousemove ' ,
35+ ' mouseout ' ,
36+ ' mouseover ' ,
37+ ' mouseup ' ,
38+ ' off ' ,
39+ ' on ' ,
40+ ' one ' ,
41+ ' ready ' ,
42+ ' resize ' ,
43+ ' scroll ' ,
44+ ' select ' ,
45+ ' submit ' ,
46+ ' toggle ' ,
47+ ' trigger ' ,
48+ ' triggerHandler ' ,
49+ ' undind ' ,
50+ ' undelegate ' ,
51+ ' unload '
52+ ] ;
5353
5454 abstract public function _add_event ($ element , $ js , $ event , $ preventDefault = false , $ stopPropagation = false , $ immediatly = true , $ listenerOn =false );
5555
@@ -62,8 +62,8 @@ abstract public function _add_event($element, $js, $event, $preventDefault = fal
6262 * code to execute
6363 * @return string
6464 */
65- public function blur ($ element = 'this ' , $ js = '' ) {
66- return $ this ->_add_event ( $ element , $ js , 'blur ' );
65+ public function blur ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
66+ return $ this ->_add_event ( $ element , $ js , 'blur ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
6767 }
6868
6969 /**
@@ -75,10 +75,11 @@ public function blur($element = 'this', $js = '') {
7575 * code to execute
7676 * @param boolean $preventDefault
7777 * @param boolean $stopPropagation
78+ * @param boolean|string $listenerOn use a selector for a delegated event handler
7879 * @return string
7980 */
80- public function change ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false ) {
81- return $ this ->_add_event ( $ element , $ js , 'change ' , $ preventDefault , $ stopPropagation );
81+ public function change ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
82+ return $ this ->_add_event ( $ element , $ js , 'change ' , $ preventDefault , $ stopPropagation, true , $ listenerOn );
8283 }
8384
8485 /**
@@ -92,9 +93,10 @@ public function change($element = 'this', $js = '', $preventDefault = false, $st
9293 * or not to return false
9394 * @param boolean $preventDefault
9495 * @param boolean $stopPropagation
96+ * @param boolean|string $listenerOn use a selector for a delegated event handler
9597 * @return string
9698 */
97- public function click ($ element = 'this ' , $ js = '' , $ ret_false = TRUE , $ preventDefault = false , $ stopPropagation = false ) {
99+ public function click ($ element = 'this ' , $ js = '' , $ ret_false = TRUE , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
98100 if (! is_array ( $ js )) {
99101 $ js = array (
100102 $ js
@@ -105,7 +107,7 @@ public function click($element = 'this', $js = '', $ret_false = TRUE, $preventDe
105107 $ js [] = "return false; " ;
106108 }
107109
108- return $ this ->_add_event ( $ element , $ js , 'click ' , $ preventDefault , $ stopPropagation );
110+ return $ this ->_add_event ( $ element , $ js , 'click ' , $ preventDefault , $ stopPropagation, true , $ listenerOn );
109111 }
110112
111113 /**
@@ -115,10 +117,13 @@ public function click($element = 'this', $js = '', $ret_false = TRUE, $preventDe
115117 * element to attach the event to
116118 * @param string $js
117119 * code to execute
120+ * @param boolean $preventDefault
121+ * @param boolean $stopPropagation
122+ * @param boolean|string $listenerOn use a selector for a delegated event handler
118123 * @return string
119124 */
120- public function contextmenu ($ element = 'this ' , $ js = '' ) {
121- return $ this ->_add_event ( $ element , $ js , 'contextmenu ' );
125+ public function contextmenu ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
126+ return $ this ->_add_event ( $ element , $ js , 'contextmenu ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
122127 }
123128
124129 /**
@@ -128,10 +133,13 @@ public function contextmenu($element = 'this', $js = '') {
128133 * element to attach the event to
129134 * @param string $js
130135 * code to execute
136+ * @param boolean $preventDefault
137+ * @param boolean $stopPropagation
138+ * @param boolean|string $listenerOn use a selector for a delegated event handler
131139 * @return string
132140 */
133- public function dblclick ($ element = 'this ' , $ js = '' ) {
134- return $ this ->_add_event ( $ element , $ js , 'dblclick ' );
141+ public function dblclick ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
142+ return $ this ->_add_event ( $ element , $ js , 'dblclick ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
135143 }
136144
137145 /**
@@ -154,10 +162,13 @@ public function error($element = 'this', $js = '') {
154162 * element to attach the event to
155163 * @param string $js
156164 * code to execute
165+ * @param boolean $preventDefault
166+ * @param boolean $stopPropagation
167+ * @param boolean|string $listenerOn use a selector for a delegated event handler
157168 * @return string
158169 */
159- public function focus ($ element = 'this ' , $ js = '' ) {
160- return $ this ->_add_event ( $ element , $ js , 'focus ' );
170+ public function focus ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
171+ return $ this ->_add_event ( $ element , $ js , 'focus ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
161172 }
162173
163174 /**
@@ -183,10 +194,13 @@ public function hover($element = 'this', $over = '', $out = '') {
183194 * element to attach the event to
184195 * @param string $js
185196 * code to execute
197+ * @param boolean $preventDefault
198+ * @param boolean $stopPropagation
199+ * @param boolean|string $listenerOn use a selector for a delegated event handler
186200 * @return string
187201 */
188- public function keydown ($ element = 'this ' , $ js = '' ) {
189- return $ this ->_add_event ( $ element , $ js , 'keydown ' );
202+ public function keydown ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
203+ return $ this ->_add_event ( $ element , $ js , 'keydown ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
190204 }
191205
192206 /**
@@ -196,10 +210,13 @@ public function keydown($element = 'this', $js = '') {
196210 * element to attach the event to
197211 * @param string $js
198212 * code to execute
213+ * @param boolean $preventDefault
214+ * @param boolean $stopPropagation
215+ * @param boolean|string $listenerOn use a selector for a delegated event handler
199216 * @return string
200217 */
201- public function keypress ($ element = 'this ' , $ js = '' ) {
202- return $ this ->_add_event ( $ element , $ js , 'keypress ' );
218+ public function keypress ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
219+ return $ this ->_add_event ( $ element , $ js , 'keypress ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
203220 }
204221
205222 /**
@@ -209,10 +226,13 @@ public function keypress($element = 'this', $js = '') {
209226 * element to attach the event to
210227 * @param string $js
211228 * code to execute
229+ * @param boolean $preventDefault
230+ * @param boolean $stopPropagation
231+ * @param boolean|string $listenerOn use a selector for a delegated event handler
212232 * @return string
213233 */
214- public function keyup ($ element = 'this ' , $ js = '' ) {
215- return $ this ->_add_event ( $ element , $ js , 'keyup ' );
234+ public function keyup ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
235+ return $ this ->_add_event ( $ element , $ js , 'keyup ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
216236 }
217237
218238 /**
@@ -222,10 +242,13 @@ public function keyup($element = 'this', $js = '') {
222242 * element to attach the event to
223243 * @param string $js
224244 * code to execute
245+ * @param boolean $preventDefault
246+ * @param boolean $stopPropagation
247+ * @param boolean|string $listenerOn use a selector for a delegated event handler
225248 * @return string
226249 */
227- public function load ($ element = 'this ' , $ js = '' ) {
228- return $ this ->_add_event ( $ element , $ js , 'load ' );
250+ public function load ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
251+ return $ this ->_add_event ( $ element , $ js , 'load ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
229252 }
230253
231254 /**
@@ -235,10 +258,13 @@ public function load($element = 'this', $js = '') {
235258 * element to attach the event to
236259 * @param string $js
237260 * code to execute
261+ * @param boolean $preventDefault
262+ * @param boolean $stopPropagation
263+ * @param boolean|string $listenerOn use a selector for a delegated event handler
238264 * @return string
239265 */
240- public function mousedown ($ element = 'this ' , $ js = '' ) {
241- return $ this ->_add_event ( $ element , $ js , 'mousedown ' );
266+ public function mousedown ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
267+ return $ this ->_add_event ( $ element , $ js , 'mousedown ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
242268 }
243269
244270 /**
@@ -248,10 +274,13 @@ public function mousedown($element = 'this', $js = '') {
248274 * element to attach the event to
249275 * @param string $js
250276 * code to execute
277+ * @param boolean $preventDefault
278+ * @param boolean $stopPropagation
279+ * @param boolean|string $listenerOn use a selector for a delegated event handler
251280 * @return string
252281 */
253- public function mouseout ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false ) {
254- return $ this ->_add_event ( $ element , $ js , 'mouseout ' , $ preventDefault , $ stopPropagation );
282+ public function mouseout ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
283+ return $ this ->_add_event ( $ element , $ js , 'mouseout ' , $ preventDefault , $ stopPropagation, true , $ listenerOn );
255284 }
256285
257286 /**
@@ -261,10 +290,13 @@ public function mouseout($element = 'this', $js = '', $preventDefault = false, $
261290 * element to attach the event to
262291 * @param string $js
263292 * code to execute
293+ * @param boolean $preventDefault
294+ * @param boolean $stopPropagation
295+ * @param boolean|string $listenerOn use a selector for a delegated event handler
264296 * @return string
265297 */
266- public function mouseleave ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false ) {
267- return $ this ->_add_event ( $ element , $ js , 'mouseleave ' , $ preventDefault , $ stopPropagation );
298+ public function mouseleave ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
299+ return $ this ->_add_event ( $ element , $ js , 'mouseleave ' , $ preventDefault , $ stopPropagation, true , $ listenerOn );
268300 }
269301
270302 /**
@@ -274,10 +306,13 @@ public function mouseleave($element = 'this', $js = '', $preventDefault = false,
274306 * element to attach the event to
275307 * @param string $js
276308 * code to execute
309+ * @param boolean $preventDefault
310+ * @param boolean $stopPropagation
311+ * @param boolean|string $listenerOn use a selector for a delegated event handler
277312 * @return string
278313 */
279- public function mouseenter ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false ) {
280- return $ this ->_add_event ( $ element , $ js , 'mouseenter ' , $ preventDefault , $ stopPropagation );
314+ public function mouseenter ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
315+ return $ this ->_add_event ( $ element , $ js , 'mouseenter ' , $ preventDefault , $ stopPropagation, true , $ listenerOn );
281316 }
282317
283318 /**
@@ -287,10 +322,13 @@ public function mouseenter($element = 'this', $js = '', $preventDefault = false,
287322 * element to attach the event to
288323 * @param string $js
289324 * code to execute
325+ * @param boolean $preventDefault
326+ * @param boolean $stopPropagation
327+ * @param boolean|string $listenerOn use a selector for a delegated event handler
290328 * @return string
291329 */
292- public function mouseover ($ element = 'this ' , $ js = '' ) {
293- return $ this ->_add_event ( $ element , $ js , 'mouseover ' );
330+ public function mouseover ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
331+ return $ this ->_add_event ( $ element , $ js , 'mouseover ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
294332 }
295333
296334 /**
@@ -300,10 +338,13 @@ public function mouseover($element = 'this', $js = '') {
300338 * element to attach the event to
301339 * @param string $js
302340 * code to execute
341+ * @param boolean $preventDefault
342+ * @param boolean $stopPropagation
343+ * @param boolean|string $listenerOn use a selector for a delegated event handler
303344 * @return string
304345 */
305- public function mouseup ($ element = 'this ' , $ js = '' ) {
306- return $ this ->_add_event ( $ element , $ js , 'mouseup ' );
346+ public function mouseup ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
347+ return $ this ->_add_event ( $ element , $ js , 'mouseup ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
307348 }
308349
309350 /**
@@ -313,10 +354,13 @@ public function mouseup($element = 'this', $js = '') {
313354 * element to attach the event to
314355 * @param string $js
315356 * code to execute
357+ * @param boolean $preventDefault
358+ * @param boolean $stopPropagation
359+ * @param boolean|string $listenerOn use a selector for a delegated event handler
316360 * @return string
317361 */
318- public function unload ($ element = 'this ' , $ js = '' ) {
319- return $ this ->_add_event ( $ element , $ js , 'unload ' );
362+ public function unload ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
363+ return $ this ->_add_event ( $ element , $ js , 'unload ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
320364 }
321365
322366 // --------------------------------------------------------------------
@@ -327,10 +371,13 @@ public function unload($element = 'this', $js = '') {
327371 * element to attach the event to
328372 * @param string $js
329373 * code to execute
374+ * @param boolean $preventDefault
375+ * @param boolean $stopPropagation
376+ * @param boolean|string $listenerOn use a selector for a delegated event handler
330377 * @return string
331378 */
332- public function resize ($ element = 'this ' , $ js = '' ) {
333- return $ this ->_add_event ( $ element , $ js , 'resize ' );
379+ public function resize ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
380+ return $ this ->_add_event ( $ element , $ js , 'resize ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
334381 }
335382
336383 // --------------------------------------------------------------------
@@ -341,9 +388,12 @@ public function resize($element = 'this', $js = '') {
341388 * element to attach the event to
342389 * @param string $js
343390 * code to execute
391+ * @param boolean $preventDefault
392+ * @param boolean $stopPropagation
393+ * @param boolean|string $listenerOn use a selector for a delegated event handler
344394 * @return string
345395 */
346- public function scroll ($ element = 'this ' , $ js = '' ) {
347- return $ this ->_add_event ( $ element , $ js , 'scroll ' );
396+ public function scroll ($ element = 'this ' , $ js = '' , $ preventDefault = false , $ stopPropagation = false , $ listenerOn = false ) {
397+ return $ this ->_add_event ( $ element , $ js , 'scroll ' , $ preventDefault , $ stopPropagation , true , $ listenerOn );
348398 }
349399}
0 commit comments