Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 452 lines (389 sloc) 15.61 kB
f8ab70b initial jquery binding from dave.benjamin
Jake Donham authored
1 (* jQuery interface for ocamljs *)
2 (* ============================ *)
3
4 class type jQuery =
5 object
6
7 (* jQuery Core *)
8 (* ----------- *)
9
10 (* jQuery Object Accessors *)
11 method size : int
12 method _get_length : int
13 method _get_selector : string
14 method _get_context : Dom.element
15 method get : Dom.element array
16 method get_index_ : int -> Dom.element
17 method index : Dom.element -> int
18 method index_jQuery_ : jQuery -> int
19
20 (* Data *)
21 method data : string -> 'a
22 method data_store_ : string -> 'a -> unit
23 method removeData : string -> unit
24 method queue : string -> (unit -> unit) Ocamljs.jsfun array
25 method queue_enqueue_ : string -> (unit -> unit) Ocamljs.jsfun -> unit
26 method queue_replace_ : string -> (unit -> unit) Ocamljs.jsfun array -> unit
27 method dequeue : string -> unit
28
29 (* Attributes *)
30 (* ---------- *)
31
32 (* Attr *)
33 method attr : string -> 'a
34 method attr_obj_ : 'a -> unit
35 method attr_set_ : string -> 'a -> unit
36 method removeAttr : string -> unit
37
38 (* Class *)
39 method addClass : string -> unit
40 method hasClass : string -> bool
41 method removeClass : string -> unit
42 method toggleClass : string -> unit
43 method toggleClass_switch_ : string -> bool -> unit
44
45 (* HTML *)
46 method html : string
47 method html_set_ : string -> unit
48
49 (* Text *)
50 method text : string
51 method text_set_ : string -> unit
52
53 (* Value *)
54 method val_ : string
55 method val_set_ : string -> unit
56 method val_array_ : string array
57 method val_setarray_ : string array -> unit
58
59 (* Traversing *)
60 (* ---------- *)
61
62 (* Filtering *)
63 method eq : int -> jQuery
64 method filter : string -> jQuery
65 method filter_fn_ : (int -> bool) Ocamljs.jsfun -> jQuery
66 method is : string -> bool
67 method map : (int -> Dom.element -> 'a) Ocamljs.jsfun -> jQuery
68 method not : string -> jQuery
69 method not_element_ : Dom.element -> jQuery
70 method not_elements_ : Dom.element array -> jQuery
71 method slice : int -> int -> jQuery
72 method slice_from_ : int -> jQuery
73
74 (* Finding *)
75 method add : string -> jQuery
76 method add_element_ : Dom.element -> jQuery
77 method add_elements_ : Dom.element array -> jQuery
78 method children : jQuery
79 method children_expr_ : string -> jQuery
80 method closest : jQuery
81 method closest_expr_ : string -> jQuery
82 method contents : jQuery
83 method find : string -> jQuery
84 method next : jQuery
85 method next_expr_ : string -> jQuery
86 method nextAll : jQuery
87 method nextAll_expr_ : string -> jQuery
88 method offsetParent : jQuery
89 method parent : jQuery
90 method parent_expr_ : string -> jQuery
91 method parents : jQuery
92 method parents_expr_ : string -> jQuery
93 method prev : jQuery
94 method prev_expr_ : string -> jQuery
95 method prevAll : jQuery
96 method prevAll_expr_ : string -> jQuery
97 method siblings : jQuery
98 method siblings_expr_ : string -> jQuery
99
100 (* Chaining *)
101 method andSelf : jQuery
102 method end_ : jQuery
103
104 (* Manipulation *)
105 (* ------------ *)
106
107 (* Inserting Inside *)
108 method append : string -> unit
109 method append_element_ : Dom.element -> unit
110 method append_jQuery_ : jQuery -> unit
111 method appendTo : string -> unit
112 method prepend : string -> unit
113 method prepend_element_ : Dom.element -> unit
114 method prepend_jQuery_ : jQuery -> unit
115 method prependTo : string -> unit
116
117 (* Inserting Outside *)
118 method after : string -> unit
119 method after_element_ : Dom.element -> unit
120 method after_jQuery_ : jQuery -> unit
121 method insertAfter : string -> unit
122 method before : string -> unit
123 method before_element_ : Dom.element -> unit
124 method before_jQuery_ : jQuery -> unit
125 method insertBefore : string -> unit
126
127 (* Inserting Around *)
128 method wrap : string -> unit
129 method wrap_element_ : Dom.element -> unit
130 method wrapAll : string -> unit
131 method wrapAll_element_ : Dom.element -> unit
132 method wrapInner : string -> unit
133 method wrapInner_element_ : Dom.element -> unit
134
135 (* Replacing *)
136 method replaceWith : string -> unit
137 method replaceWith_element_ : Dom.element -> unit
138 method replaceWith_jQuery_ : jQuery -> unit
139 method replaceAll : string -> unit
140
141 (* Removing *)
142 method empty : unit
143 method remove : unit
144 method remove_expr_ : string -> unit
145
146 (* Copying *)
147 method clone : bool -> jQuery
148
149 (* CSS *)
150 (* --- *)
151
152 (* CSS *)
153 method css : string -> string
154 method css_obj_ : 'a -> unit
155 method css_set_ : string -> string -> unit
156
157 (* Positioning *)
158 method offset : < _get_top : int; _get_left : int >
159 method position : < _get_top : int; _get_left : int >
160 method scrollTop : int
161 method scrollTop_set_ : int -> unit
162 method scrollLeft : int
163 method scrollLeft_set_ : int -> unit
164
165 (* Height and Width *)
166 method height : int
167 method height_set_ : int -> unit
168 method width : int
169 method width_set_ : int -> unit
170 method innerHeight : int
171 method innerWidth : int
172 method outerHeight : bool -> int
173 method outerWidth : bool -> int
174
175 (* Events *)
176 (* ------ *)
177
178 (* Page Load *)
179 method ready : ((string -> jQuery) -> unit) Ocamljs.jsfun -> unit
180
181 (* Event Handling *)
182 method bind : string -> (Dom.event -> bool) Ocamljs.jsfun -> unit
183 method bind_data_ : string -> 'a -> (Dom.event -> bool) Ocamljs.jsfun -> unit
184 method one : string -> (Dom.event -> bool) Ocamljs.jsfun -> unit
185 method one_data_ : string -> 'a -> (Dom.event -> bool) Ocamljs.jsfun -> unit
186 method trigger : string -> unit
187 method trigger_data_ : string -> 'a array -> unit
188 method trigger_event_ : Dom.event -> unit
189 method trigger_eventdata_ : Dom.event -> 'a array -> unit
190 method trigger_obj_ : 'a -> unit
191 method trigger_objdata_ : 'a -> 'b array -> unit
192 method triggerHandler : string -> unit
193 method triggerHandler_data_ : string -> 'a array -> unit
194 method triggerHandler_event_ : Dom.event -> unit
195 method triggerHandler_eventdata_ : Dom.event -> 'a array -> unit
196 method triggerHandler_obj_ : 'a -> unit
197 method triggerHandler_objdata_ : 'a -> 'b array -> unit
198 method unbind : string -> unit
199 method unbind_fn_ : string -> (Dom.event -> bool) Ocamljs.jsfun -> unit
200 method unbind_event_ : Dom.event -> unit
201 method unbind_eventfn_ :
202 Dom.event -> (Dom.event -> bool) Ocamljs.jsfun -> unit
203 method unbind_obj_ : 'a -> unit
204 method unbind_objfn_ : 'a -> (Dom.event -> bool) Ocamljs.jsfun -> unit
205 method unbind_all_ : unit
206
207 (* Live Events *)
208 method live : string -> (Dom.event -> bool) Ocamljs.jsfun -> unit
209 method die : string -> unit
210 method die_fn_ : string -> (Dom.event -> bool) Ocamljs.jsfun -> unit
211 method die_all_ : unit
212
213 (* Interaction Helpers *)
214 method hover :
215 (Dom.mouseEvent -> unit) Ocamljs.jsfun ->
216 (Dom.mouseEvent -> unit) Ocamljs.jsfun -> unit
217 method toggle_2_ :
218 (Dom.mouseEvent -> unit) Ocamljs.jsfun ->
219 (Dom.mouseEvent -> unit) Ocamljs.jsfun -> unit
220 method toggle_3_ :
221 (Dom.mouseEvent -> unit) Ocamljs.jsfun ->
222 (Dom.mouseEvent -> unit) Ocamljs.jsfun ->
223 (Dom.mouseEvent -> unit) Ocamljs.jsfun -> unit
224 method toggle_4_ :
225 (Dom.mouseEvent -> unit) Ocamljs.jsfun ->
226 (Dom.mouseEvent -> unit) Ocamljs.jsfun ->
227 (Dom.mouseEvent -> unit) Ocamljs.jsfun ->
228 (Dom.mouseEvent -> unit) Ocamljs.jsfun -> unit
229 method toggle_5_ :
230 (Dom.mouseEvent -> unit) Ocamljs.jsfun ->
231 (Dom.mouseEvent -> unit) Ocamljs.jsfun ->
232 (Dom.mouseEvent -> unit) Ocamljs.jsfun ->
233 (Dom.mouseEvent -> unit) Ocamljs.jsfun ->
234 (Dom.mouseEvent -> unit) Ocamljs.jsfun -> unit
235
236 (* Event Helpers *)
237 method blur : (Dom.event -> bool) Ocamljs.jsfun -> unit
238 method blur_trigger_ : unit
239 method change : (Dom.event -> bool) Ocamljs.jsfun -> unit
240 method change_trigger_ : unit
241 method click : (Dom.mouseEvent -> bool) Ocamljs.jsfun -> unit
242 method click_trigger_ : unit
243 method dblclick : (Dom.mouseEvent -> bool) Ocamljs.jsfun -> unit
244 method dblclick_trigger_ : unit
245 method error : (Dom.event -> bool) Ocamljs.jsfun -> unit
246 method error_trigger_ : unit
247 method focus : (Dom.event -> bool) Ocamljs.jsfun -> unit
248 method focus_trigger_ : unit
249 method keydown : (Dom.keyEvent -> bool) Ocamljs.jsfun -> unit
250 method keydown_trigger_ : unit
251 method keypress : (Dom.keyEvent -> bool) Ocamljs.jsfun -> unit
252 method keypress_trigger_ : unit
253 method keyup : (Dom.keyEvent -> bool) Ocamljs.jsfun -> unit
254 method keyup_trigger_ : unit
255 method load_event_ : (Dom.event -> bool) Ocamljs.jsfun -> unit
256 method mousedown : (Dom.mouseEvent -> bool) Ocamljs.jsfun -> unit
257 method mouseenter : (Dom.mouseEvent -> bool) Ocamljs.jsfun -> unit
258 method mouseleave : (Dom.mouseEvent -> bool) Ocamljs.jsfun -> unit
259 method mousemove : (Dom.mouseEvent -> bool) Ocamljs.jsfun -> unit
260 method mouseout : (Dom.mouseEvent -> bool) Ocamljs.jsfun -> unit
261 method mouseover : (Dom.mouseEvent -> bool) Ocamljs.jsfun -> unit
262 method mouseup : (Dom.mouseEvent -> bool) Ocamljs.jsfun -> unit
263 method resize : (Dom.event -> bool) Ocamljs.jsfun -> unit
264 method scroll : (Dom.event -> bool) Ocamljs.jsfun -> unit
265 method select : (Dom.event -> bool) Ocamljs.jsfun -> unit
266 method select_trigger_ : unit
267 method submit : (Dom.event -> bool) Ocamljs.jsfun -> unit
268 method submit_trigger_ : unit
269 method unload : (Dom.event -> bool) Ocamljs.jsfun -> unit
270
271 (* Effects *)
272 (* ------- *)
273
274 (* Basics *)
275 method show : unit
276 method show_ms_ : int -> (unit -> unit) Ocamljs.jsfun -> unit
277 method show_speed_ : string -> (unit -> unit) Ocamljs.jsfun -> unit
278 method hide : unit
279 method hide_ms_ : int -> (unit -> unit) Ocamljs.jsfun -> unit
280 method hide_speed_ : string -> (unit -> unit) Ocamljs.jsfun -> unit
281 method toggle : unit
282 method toggle_switch_ : bool -> unit
283 method toggle_ms_ : int -> (unit -> unit) Ocamljs.jsfun -> unit
284 method toggle_speed_ : string -> (unit -> unit) Ocamljs.jsfun -> unit
285
286 (* Sliding *)
287 method slideDown : unit
288 method slideDown_ms_ : int -> (unit -> unit) Ocamljs.jsfun -> unit
289 method slideDown_speed_ : string -> (unit -> unit) Ocamljs.jsfun -> unit
290 method slideUp : unit
291 method slideUp_ms_ : int -> (unit -> unit) Ocamljs.jsfun -> unit
292 method slideUp_speed_ : string -> (unit -> unit) Ocamljs.jsfun -> unit
293 method slideToggle : unit
294 method slideToggle_ms_ : int -> (unit -> unit) Ocamljs.jsfun -> unit
295 method slideToggle_speed_ : string -> (unit -> unit) Ocamljs.jsfun -> unit
296
297 (* Fading *)
298 method fadeIn : unit
299 method fadeIn_ms_ : int -> (unit -> unit) Ocamljs.jsfun -> unit
300 method fadeIn_speed_ : string -> (unit -> unit) Ocamljs.jsfun -> unit
301 method fadeOut : unit
302 method fadeOut_ms_ : int -> (unit -> unit) Ocamljs.jsfun -> unit
303 method fadeOut_speed_ : string -> (unit -> unit) Ocamljs.jsfun -> unit
304 method fadeTo : int -> float -> unit
305 method fadeTo_ms_ : int -> float -> (unit -> unit) Ocamljs.jsfun -> unit
306 method fadeTo_speed_ : string -> float -> (unit -> unit) Ocamljs.jsfun -> unit
307
308 (* Custom *)
309 method animate : 'a -> unit
310 method animate_ms_ :
311 'a -> int -> string -> (unit -> unit) Ocamljs.jsfun -> unit
312 method animate_speed_ :
313 'a -> string -> string -> (unit -> unit) Ocamljs.jsfun -> unit
314 method animate_custom_ : 'a -> 'b -> unit
315 method stop : bool -> bool -> unit
316
317 (* Ajax *)
318 (* ---- *)
319
320 (* Ajax Requests *)
321 method load : string -> unit
322 method load_fn_ :
323 string -> 'a ->
324 (string -> string -> Dom.xMLHttpRequest -> unit) Ocamljs.jsfun -> unit
325
326 (* Ajax Events *)
327 method ajaxComplete :
328 (Dom.event -> Dom.xMLHttpRequest -> 'a -> unit) Ocamljs.jsfun -> unit
329 method ajaxError :
330 (Dom.event -> Dom.xMLHttpRequest -> 'a -> 'b -> unit) Ocamljs.jsfun -> unit
331 method ajaxSend :
332 (Dom.event -> Dom.xMLHttpRequest -> 'a -> unit) Ocamljs.jsfun -> unit
333 method ajaxStart : (Dom.event -> unit) Ocamljs.jsfun -> unit
334 method ajaxStop : (Dom.event -> unit) Ocamljs.jsfun -> unit
335 method ajaxSuccess :
336 (Dom.event -> Dom.xMLHttpRequest -> 'a -> unit) Ocamljs.jsfun -> unit
337
338 (* Misc *)
339 method serialize : string
340 method serializeArray : 'a array
341 end
342
343 (* The jQuery Function *)
344 val jQuery : string -> jQuery
345 val jQuery_context : string -> Dom.element -> jQuery
346 val jQuery_jQuery : string -> jQuery -> jQuery
347 val jQuery_element : Dom.element -> jQuery
348 val jQuery_elements : Dom.element array -> jQuery
349
350 (* Shorthand for $(document).ready() *)
351 val jQuery_ready : ((string -> jQuery) -> unit) -> unit
352
353 (* Invoking Plugins *)
354 val jQuery_plugin : jQuery -> string -> 'a array -> unit
355
356 (* Plugins *)
357 (* ------- *)
358
359 class type jQuery_fn =
360 object
361 method extend : 'a -> unit
362 end
363
364 val jQuery_fn : jQuery_fn
365
366 (* Effects *)
367 (* ------- *)
368
369 class type jQuery_fx =
370 object
371 method _get_off : bool
372 method _set_off : bool -> unit
373 end
374
375 val jQuery_fx : jQuery_fx
376
377 (* Utilities *)
378 (* --------- *)
379
380 class type jQuery_util =
381 object
382 (* Plugins *)
383 method extend : 'a -> unit
384
385 (* Interoperability *)
386 method noConflict : unit
387 method noConflict_extreme_ : bool -> unit
388
389 (* Ajax Requests *)
390 method ajax : 'a -> Dom.xMLHttpRequest
391 method get :
392 string -> 'a -> ('b -> string -> unit) Ocamljs.jsfun -> Dom.xMLHttpRequest
393 method get_typed_ :
394 string -> 'a -> ('b -> string -> unit) Ocamljs.jsfun -> string ->
395 Dom.xMLHttpRequest
396 method getJSON :
397 string -> 'a -> ('b -> string -> unit) Ocamljs.jsfun -> Dom.xMLHttpRequest
398 method getScript :
399 string -> ('b -> string -> unit) Ocamljs.jsfun -> Dom.xMLHttpRequest
400 method post :
401 string -> 'a -> ('b -> string -> unit) Ocamljs.jsfun -> Dom.xMLHttpRequest
402 method post_typed_ :
403 string -> 'a -> ('b -> string -> unit) Ocamljs.jsfun -> string ->
404 Dom.xMLHttpRequest
405
406 (* Misc Ajax *)
407 method ajaxSetup : 'a -> unit
408
409 (* Browser and Feature Detection *)
410 method _get_support : 'a
411 method _get_browser : 'a
412 method _get_boxModel : bool
413
414 (* Array and Object operations *)
415 method each : 'a -> (int -> 'b -> bool) Ocamljs.jsfun -> unit
416 method extend_obj_ : bool -> 'a -> 'b -> unit
417 method grep : 'a array -> (int -> 'a -> bool) Ocamljs.jsfun -> 'a array
418 method grep_invert_ :
419 'a array -> (int -> 'a -> bool) Ocamljs.jsfun -> bool -> 'a array
420 method makeArray : 'a -> 'b array
421 method map : 'a array -> ('a -> 'b) Ocamljs.jsfun -> 'b array
422 method map_i_ : 'a array -> ('a -> int -> 'b) Ocamljs.jsfun -> 'b array
423 method inArray : 'a -> 'a array -> int
424 method merge : 'a array -> 'a array -> 'a array
425 method unique : 'a array -> 'a array
426
427 (* Test operations *)
428 method isArray : 'a -> bool
429 method isFunction : 'a -> bool
430
431 (* String operations *)
432 method trim : string -> string
433
434 (* URLs *)
435 method param : Dom.element array -> string
436 method param_jQuery_ : jQuery -> string
437 method param_obj_ : 'a -> string
438 end
439
440 val jQuery_util : jQuery_util
441
442 (* Callbacks *)
443 (* --------- *)
444
445 (* These functions work like Ocamljs.jsfun* but take "this" as an additional
446 first argument, since many jQuery methods pass values to callbacks as
447 "this". *)
448 val jqfun : ('this -> 'a -> 'b) -> ('a -> 'b) Ocamljs.jsfun
449 val jqfun2 : ('this -> 'a1 -> 'a2 -> 'b) -> ('a1 -> 'a2 -> 'b) Ocamljs.jsfun
450 val jqfun3 : ('this -> 'a1 -> 'a2 -> 'a3 -> 'b) -> ('a1 -> 'a2 -> 'a3 -> 'b) Ocamljs.jsfun
451 val jqfun4 : ('this -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'b) -> ('a1 -> 'a2 -> 'a3 -> 'a4 -> 'b) Ocamljs.jsfun
Something went wrong with that request. Please try again.