Skip to content

Commit

Permalink
Bounded Effects module
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-cardoso committed Aug 25, 2011
1 parent c1b7b95 commit 72405d3
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 29 deletions.
9 changes: 6 additions & 3 deletions .depend
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
effects.cmo: effects.cmi
effects.cmx: effects.cmi
examples/test.cmo: tools.cmi jQuery.cmi
examples/test.cmx: tools.cmx jQuery.cmx
jQuery.cmo: tools.cmi jQuery.cmi
jQuery.cmx: tools.cmx jQuery.cmi
jQuery.cmo: tools.cmi effects.cmi jQuery.cmi
jQuery.cmx: tools.cmx effects.cmx jQuery.cmi
tools.cmo: tools.cmi
tools.cmx: tools.cmi
jQuery.cmi: tools.cmi
effects.cmi:
jQuery.cmi: tools.cmi effects.cmi
tools.cmi:
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MLS=$(shell find * -name "*.ml")
MLIS=$(shell find * -name "*.mli")
OCAMLFIND=ocamlfind
OCAMLDOC=ocamldoc
CMOS=tools.cmo jQuery.cmo
CMOS=tools.cmo effects.cmo jQuery.cmo

all: $(OQUERY)

Expand Down
87 changes: 87 additions & 0 deletions effects.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
(*
JQuery binding for Js_of_ocaml - 2011
jQuery module
@author : Gabriel Cardoso
*)

open Js

type duration = Value of int | Slow | Fast
type duration_pre = Name of js_string t | ValueP of int

let of_duration = function
| Value i -> ValueP i
| Slow -> Name (Js.string "slow")
| Fast -> Name (Js.string "fast")

type easing =
| Def
| Jswing
| Easeinquad
| Easeoutquad
| Easeinoutquad
| Easeincubic
| Easeoutcubic
| Easeinoutcubic
| Easeinquart
| Easeoutquart
| Easeinoutquart
| Easeinsine
| Easeoutsine
| Easeinoutsine
| Easeinexpo
| Easeoutexpo
| Easeinoutexpo
| Easeinquint
| Easeoutquint
| Easeinoutquint
| Easeincirc
| Easeoutcirc
| Easeinoutcirc
| Easeinelastic
| Easeoutelastic
| Easeinoutelastic
| Easeinback
| Easeoutback
| Easeinoutback
| Easeinbounce
| Easeoutbounce
| Easeinoutbounce

type easing_pre = js_string t

let of_easing = function
| Def -> Js.string "def"
| Jswing -> Js.string "jswing"
| Easeinquad -> Js.string "easeinquad"
| Easeoutquad -> Js.string "easeoutquad"
| Easeinoutquad -> Js.string "easeinoutquad"
| Easeincubic -> Js.string "easeincubic"
| Easeoutcubic -> Js.string "easeoutcubic"
| Easeinoutcubic -> Js.string "easeinoutcubic"
| Easeinquart -> Js.string "easeinquart"
| Easeoutquart -> Js.string "easeoutquart"
| Easeinoutquart -> Js.string "easeinoutquart"
| Easeinsine -> Js.string "easeinsine"
| Easeoutsine -> Js.string "easeoutsine"
| Easeinoutsine -> Js.string "easeinoutsine"
| Easeinexpo -> Js.string "easeinexpo"
| Easeoutexpo -> Js.string "easeoutexpo"
| Easeinoutexpo -> Js.string "easeinoutexpo"
| Easeinquint -> Js.string "easeinquint"
| Easeoutquint -> Js.string "easeoutquint"
| Easeinoutquint -> Js.string "easeinoutquint"
| Easeincirc -> Js.string "easeincirc"
| Easeoutcirc -> Js.string "easeoutcirc"
| Easeinoutcirc -> Js.string "easeinoutcirc"
| Easeinelastic -> Js.string "easeinelastic"
| Easeoutelastic -> Js.string "easeoutelastic"
| Easeinoutelastic -> Js.string "easeinoutelastic"
| Easeinback -> Js.string "easeinback"
| Easeoutback -> Js.string "easeoutback"
| Easeinoutback -> Js.string "easeinoutback"
| Easeinbounce -> Js.string "easeinbounce"
| Easeoutbounce -> Js.string "easeoutbounce"
| Easeinoutbounce -> Js.string "easeinoutbounce"
50 changes: 50 additions & 0 deletions effects.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
(**
JQuery binding for Js_of_ocaml - 2011
Effects module
@author : Gabriel Cardoso
*)

open Js

type duration = Value of int | Slow | Fast
type duration_pre
val of_duration : duration -> duration_pre

type easing =
| Def
| Jswing
| Easeinquad
| Easeoutquad
| Easeinoutquad
| Easeincubic
| Easeoutcubic
| Easeinoutcubic
| Easeinquart
| Easeoutquart
| Easeinoutquart
| Easeinsine
| Easeoutsine
| Easeinoutsine
| Easeinexpo
| Easeoutexpo
| Easeinoutexpo
| Easeinquint
| Easeoutquint
| Easeinoutquint
| Easeincirc
| Easeoutcirc
| Easeinoutcirc
| Easeinelastic
| Easeoutelastic
| Easeinoutelastic
| Easeinback
| Easeoutback
| Easeinoutback
| Easeinbounce
| Easeoutbounce
| Easeinoutbounce

type easing_pre
val of_easing : easing -> easing_pre
62 changes: 38 additions & 24 deletions jQuery.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*)

open Js
open Effects

class type jQuery = object
method add : js_string t -> jQuery t meth
Expand All @@ -22,16 +23,44 @@ class type jQuery = object
method ajaxComplete :
(#Dom_html.event t -> #XmlHttpRequest.xmlHttpRequest t -> 'a)
-> jQuery t meth
method animate : Dom_html.cssStyleDeclaration t -> duration_pre
-> easing_pre opt -> 'a callback t -> jQuery t
method clearQueue : js_string t opt -> jQuery t meth
method css_get : js_string t -> js_string t meth
method css : js_string t -> js_string t -> jQuery meth
method css : js_string t -> js_string t -> jQuery t meth
method delay : int -> js_string t opt -> jQuery t meth
method dequeue : js_string t opt -> jQuery t meth
method fadeIn : duration_pre -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method fadeOut : duration_pre -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method fadeTo : duration_pre -> float -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method fadeToggle : duration_pre opt -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method hide : duration_pre opt -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method queue : js_string t opt -> js_string t js_array t meth
method show : duration_pre -> float -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method slideDown : duration_pre -> float -> easing_pre opt
-> 'a callback t opt -> jQuery t meth
method slideToggle : duration_pre -> float -> easing_pre opt
-> 'a callback t opt -> jQuery t meth
method slideUp : duration_pre -> float -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method stop : bool t opt -> bool t opt -> jQuery t meth
method toggle : bool t -> jQuery t meth
method toggle_ : duration_pre -> float -> easing_pre opt -> 'a callback t opt
-> jQuery t meth

(* TODO : implement the right types for these methods c.f. jQuery API
method ajaxError
method ajaxSend
method ajaxStart
method ajaxStop
method ajaxSuccess
method andSelf
method animate
method append
method appendTo
method attr
Expand All @@ -40,27 +69,20 @@ class type jQuery = object
method blur
method change
method children
method clearQueue
method click
method clone
method closest
method contents
method conte
method context
method data
method dblclick
method delay
method delegate
method dequeue
method die
method each
method empty
method end_
method eq
method error
method fadeIn
method fadeOut
method fadeTo
method fadeToggle
method filter
method find
method first
Expand All @@ -71,7 +93,6 @@ class type jQuery = object
method has
method hasClass
method height
method hide
method hover
method html
method index
Expand Down Expand Up @@ -118,7 +139,6 @@ class type jQuery = object
method promise
method prop
method pushStack
method queue
method ready
method remove
method removeAttr
Expand All @@ -134,19 +154,12 @@ class type jQuery = object
method select
method serialize
method serializeArray
method show
method siblings
method size
method slice
method slideDown
method slideToggle
method slideUp
method stop
method submit
method text
method toArray
method toggle
method toggle
method toggleClass
method trigger
method triggerHandler
Expand All @@ -165,10 +178,11 @@ let jQuery selector context_opt =
Unsafe.variable "jQuery"

let ajax : js_string t -> unit meth = Unsafe.variable "jQuery.ajax"
(* TODO implement these values as in the jQuery API

(* TODO implement these values as in the jQuery API *)
let ajaxPrefilter = Unsafe.variable "jQuery.ajaxPrefilter"
let ajaxSetup = Unsafe.variable "jQuery.ajaxSetup"
let boxModel = Unsafae.varible "jQuery.boxModel"
let boxModel = Unsafe.variable "jQuery.boxModel"
let browser = Unsafe.variable "jQuery.browser"
module Deferred = struct
let always = Unsafe.variable "jQuery.deferred.always"
Expand Down Expand Up @@ -248,7 +262,7 @@ let removeData = Unsafe.variable "jQuery.removeData"
let sub = Unsafe.variable "jQuery.sub"
let suppo = Unsafe.variable "jQuery.suppo"
let trim = Unsafe.variable "jQuery.trim"
let type = Unsafe.variable "jQuery.type"
let type_ = Unsafe.variable "jQuery.type"
let unique = Unsafe.variable "jQuery.unique"
let when = Unsafe.variable "jQuery.when"
*)
let when_ = Unsafe.variable "jQuery.when"

31 changes: 30 additions & 1 deletion jQuery.mli
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*)

open Js
open Effects

class type jQuery = object
method add : js_string t -> jQuery t meth
Expand All @@ -22,8 +23,36 @@ class type jQuery = object
method ajaxComplete :
(#Dom_html.event t -> #XmlHttpRequest.xmlHttpRequest t -> 'a)
-> jQuery t meth
method animate : Dom_html.cssStyleDeclaration t -> duration_pre
-> easing_pre opt -> 'a callback t -> jQuery t
method clearQueue : js_string t opt -> jQuery t meth
method css_get : js_string t -> js_string t meth
method css : js_string t -> js_string t -> jQuery meth
method css : js_string t -> js_string t -> jQuery t meth
method delay : int -> js_string t opt -> jQuery t meth
method dequeue : js_string t opt -> jQuery t meth
method fadeIn : duration_pre -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method fadeOut : duration_pre -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method fadeTo : duration_pre -> float -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method fadeToggle : duration_pre opt -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method hide : duration_pre opt -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method queue : js_string t opt -> js_string t js_array t meth
method show : duration_pre -> float -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method slideDown : duration_pre -> float -> easing_pre opt
-> 'a callback t opt -> jQuery t meth
method slideToggle : duration_pre -> float -> easing_pre opt
-> 'a callback t opt -> jQuery t meth
method slideUp : duration_pre -> float -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
method stop : bool t opt -> bool t opt -> jQuery t meth
method toggle : bool t -> jQuery t meth
method toggle_ : duration_pre -> float -> easing_pre opt -> 'a callback t opt
-> jQuery t meth
end

(** Construct the jQuery object i.e. "$" in jQuery **)
Expand Down

0 comments on commit 72405d3

Please sign in to comment.