1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\common\traits; |
4
|
|
|
|
5
|
|
|
trait JsUtilsEventsTrait { |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Outputs a javascript library blur event |
9
|
|
|
* |
10
|
|
|
* @param string $element element to attach the event to |
11
|
|
|
* @param string $js code to execute |
12
|
|
|
* @return string |
13
|
|
|
*/ |
14
|
|
|
public function blur($element='this', $js='') { |
15
|
|
|
return $this->js->_blur($element, $js); |
|
|
|
|
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Outputs a javascript library change event |
20
|
|
|
* |
21
|
|
|
* @param string $element element to attach the event to |
22
|
|
|
* @param string $js code to execute |
23
|
|
|
* @return string |
24
|
|
|
*/ |
25
|
|
|
public function change($element='this', $js='') { |
26
|
|
|
return $this->js->_change($element, $js); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Outputs a javascript library click event |
31
|
|
|
* |
32
|
|
|
* @param string $element element to attach the event to |
33
|
|
|
* @param string $js code to execute |
34
|
|
|
* @param boolean $ret_false or not to return false |
35
|
|
|
* @return string |
36
|
|
|
*/ |
37
|
|
|
public function click($element='this', $js='', $ret_false=TRUE) { |
38
|
|
|
return $this->js->_click($element, $js, $ret_false); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Outputs a javascript library contextmenu event |
43
|
|
|
* |
44
|
|
|
* @param string $element element to attach the event to |
45
|
|
|
* @param string $js code to execute |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function contextmenu($element='this', $js='') { |
49
|
|
|
return $this->js->_contextmenu($element, $js); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Outputs a javascript library dblclick event |
55
|
|
|
* |
56
|
|
|
* @param string $element element to attach the event to |
57
|
|
|
* @param string $js code to execute |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
public function dblclick($element='this', $js='') { |
61
|
|
|
return $this->js->_dblclick($element, $js); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Outputs a javascript library error event |
66
|
|
|
* |
67
|
|
|
* @param string $element element to attach the event to |
68
|
|
|
* @param string $js code to execute |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
public function error($element='this', $js='') { |
72
|
|
|
return $this->js->_error($element, $js); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Outputs a javascript library focus event |
77
|
|
|
* |
78
|
|
|
* @param string $element element to attach the event to |
79
|
|
|
* @param string $js code to execute |
80
|
|
|
* @return string |
81
|
|
|
*/ |
82
|
|
|
public function focus($element='this', $js='') { |
83
|
|
|
return $this->js->_add_event($element, $js, "focus"); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Outputs a javascript library hover event |
88
|
|
|
* |
89
|
|
|
* @param string $element |
90
|
|
|
* @param string $over code for mouse over |
91
|
|
|
* @param string $out code for mouse out |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function hover($element='this', $over, $out) { |
95
|
|
|
return $this->js->_hover($element, $over, $out); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Outputs a javascript library keydown event |
100
|
|
|
* |
101
|
|
|
* @param string $element element to attach the event to |
102
|
|
|
* @param string $js code to execute |
103
|
|
|
* @return string |
104
|
|
|
*/ |
105
|
|
|
public function keydown($element='this', $js='') { |
106
|
|
|
return $this->js->_keydown($element, $js); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Outputs a javascript library keypress event |
111
|
|
|
* |
112
|
|
|
* @param string $element element to attach the event to |
113
|
|
|
* @param string $js code to execute |
114
|
|
|
* @return string |
115
|
|
|
*/ |
116
|
|
|
public function keypress($element='this', $js='') { |
117
|
|
|
return $this->js->_keypress($element, $js); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Outputs a javascript library keydown event |
122
|
|
|
* |
123
|
|
|
* @param string $element element to attach the event to |
124
|
|
|
* @param string $js code to execute |
125
|
|
|
* @return string |
126
|
|
|
*/ |
127
|
|
|
public function keyup($element='this', $js='') { |
128
|
|
|
return $this->js->_keyup($element, $js); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Outputs a javascript library load event |
133
|
|
|
* |
134
|
|
|
* @param string $element element to attach the event to |
135
|
|
|
* @param string $js code to execute |
136
|
|
|
* @return string |
137
|
|
|
*/ |
138
|
|
|
public function load($element='this', $js='') { |
139
|
|
|
return $this->js->_load($element, $js); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Outputs a javascript library mousedown event |
144
|
|
|
* |
145
|
|
|
* @param string $element element to attach the event to |
146
|
|
|
* @param string $js code to execute |
147
|
|
|
* @return string |
148
|
|
|
*/ |
149
|
|
|
public function mousedown($element='this', $js='') { |
150
|
|
|
return $this->js->_mousedown($element, $js); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Outputs a javascript library mouseout event |
155
|
|
|
* |
156
|
|
|
* @param string $element element to attach the event to |
157
|
|
|
* @param string $js code to execute |
158
|
|
|
* @return string |
159
|
|
|
*/ |
160
|
|
|
public function mouseout($element='this', $js='') { |
161
|
|
|
return $this->js->_mouseout($element, $js); |
162
|
|
|
} |
163
|
|
|
/** |
164
|
|
|
* Outputs a javascript library mouseover event |
165
|
|
|
* |
166
|
|
|
* @param string $element element to attach the event to |
167
|
|
|
* @param string $js code to execute |
168
|
|
|
* @return string |
169
|
|
|
*/ |
170
|
|
|
public function mouseover($element='this', $js='') { |
171
|
|
|
return $this->js->_mouseover($element, $js); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Outputs a javascript library mouseup event |
176
|
|
|
* |
177
|
|
|
* @param string $element element to attach the event to |
178
|
|
|
* @param string $js code to execute |
179
|
|
|
* @return string |
180
|
|
|
*/ |
181
|
|
|
public function mouseup($element='this', $js='') { |
182
|
|
|
return $this->js->_mouseup($element, $js); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Outputs a javascript library unload event |
188
|
|
|
* |
189
|
|
|
* @param string $element element to attach the event to |
190
|
|
|
* @param string $js code to execute |
191
|
|
|
* @return string |
192
|
|
|
*/ |
193
|
|
|
public function unload($element='this', $js='') { |
194
|
|
|
return $this->js->_unload($element, $js); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
// -------------------------------------------------------------------- |
198
|
|
|
/** |
199
|
|
|
* Outputs a javascript library resize event |
200
|
|
|
* |
201
|
|
|
* @param string $element element to attach the event to |
202
|
|
|
* @param string $js code to execute |
203
|
|
|
* @return string |
204
|
|
|
*/ |
205
|
|
|
public function resize($element='this', $js='') { |
206
|
|
|
return $this->js->_resize($element, $js); |
207
|
|
|
} |
208
|
|
|
// -------------------------------------------------------------------- |
209
|
|
|
/** |
210
|
|
|
* Outputs a javascript library scroll event |
211
|
|
|
* |
212
|
|
|
* @param string $element element to attach the event to |
213
|
|
|
* @param string $js code to execute |
214
|
|
|
* @return string |
215
|
|
|
*/ |
216
|
|
|
public function scroll($element='this', $js='') { |
217
|
|
|
return $this->js->_scroll($element, $js); |
218
|
|
|
} |
219
|
|
|
} |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: