├── .gitignore
├── compile.sh
├── test
├── test.html
└── main.js
├── lib
├── ocaml
│ ├── test.ml
│ └── jquery.ml
└── js
│ ├── test.js
│ └── jquery.js
├── README.md
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 |
4 |
--------------------------------------------------------------------------------
/compile.sh:
--------------------------------------------------------------------------------
1 | ./node_modules/bs-platform/bin/bsc.exe -I lib/ocaml -c -bs-main lib/ocaml/jquery.ml -bs-package-name bucklescript-jquery -bs-package-output lib/js
2 |
--------------------------------------------------------------------------------
/test/test.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/lib/ocaml/test.ml:
--------------------------------------------------------------------------------
1 | open Jquery;;
2 |
3 | external js_assert : Js.boolean -> unit = "assert" [@@bs.val]
4 |
5 | let attributes_raw () =
6 | let el = jquery "#container" in
7 | ignore (el |> addClass (`str "test"));
8 | ignore (el |> addClass' (fun [@bs.this] jq i s -> s^"-list"));
9 | ();;
10 |
11 | let attributes_overloaded () =
12 | let el = jquery "#container" in
13 | ignore (el |> attr (`kv ("class","foo")));
14 | ();;
15 |
16 |
17 | let css_test () =
18 | let el = jquery "body" in
19 | let h = el |> css_get' [|"height"; "background"|] in
20 | Js.log h;
21 | h##background #= "lightblue";
22 | Js.log h;
23 | el |> css' h;
24 | ();;
25 |
26 | let () =
27 | attributes_raw ();
28 | attributes_overloaded ();
29 | append_test ();
30 | css_test ();;
31 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BuckleScript jQuery binding
2 |
3 | BuckleScript binding for jQuery 3.1.
4 |
5 | Still only covers a small part of jQuery, but hopefully this repo and npm package help others understand how to do FFI and make a npm package for BuckleScript.
6 |
7 | ## How to use
8 |
9 | ### Compile
10 |
11 | To compile, for example, a client-side script with `src/main.ml` as an entry point.
12 |
13 | ```shell
14 | bsc -I src -c -bs-main src/main.ml -bs-package-include bucklescript-jquery -bs-package-name $npm_package_name -bs-package-output dist
15 | ```
16 |
17 | ### Bundle
18 |
19 | To bundle with webpack:
20 |
21 | ```shell
22 | webpack -p dist/main.js dist/bundle.js
23 | ```
24 |
25 | then load `dist/bundle.js` in your HTML.
26 |
27 | ## Testing
28 |
29 | Run `npm run compile_test` then open `test/test.html`. It should show "Test success" in a browser if test is successful.
30 |
31 | Only a small fragment of testing has been added.
32 |
33 | ## Copyright
34 |
35 | Copyright 2016 by Nebuta. MIT license.
--------------------------------------------------------------------------------
/lib/js/test.js:
--------------------------------------------------------------------------------
1 | // Generated by BUCKLESCRIPT VERSION 1.0.3 , PLEASE EDIT WITH CARE
2 | 'use strict';
3 |
4 | var Jquery = require("./jquery");
5 |
6 | function attributes_raw() {
7 | var el = Jquery.jquery("#container");
8 | Jquery.addClass(/* `str */[
9 | 5744817,
10 | "test"
11 | ], el);
12 | el.addClass(function (_, s) {
13 | return s + "-list";
14 | });
15 | return /* () */0;
16 | }
17 |
18 | function attributes_overloaded() {
19 | var el = Jquery.jquery("#container");
20 | Jquery.attr(/* `kv */[
21 | 23979,
22 | /* tuple */[
23 | "class",
24 | "foo"
25 | ]
26 | ], el);
27 | return /* () */0;
28 | }
29 |
30 | function css_test() {
31 | var el = Jquery.jquery("body");
32 | var h = Jquery.css_get$prime(/* array */[
33 | "height",
34 | "background"
35 | ], el);
36 | console.log(h);
37 | h.background = "lightblue";
38 | console.log(h);
39 | Jquery.css$prime(h, el);
40 | return /* () */0;
41 | }
42 |
43 | attributes_raw(/* () */0);
44 |
45 | attributes_overloaded(/* () */0);
46 |
47 | css_test(/* () */0);
48 |
49 | exports.attributes_raw = attributes_raw;
50 | exports.attributes_overloaded = attributes_overloaded;
51 | exports.css_test = css_test;
52 | /* Not a pure module */
53 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bucklescript-jquery",
3 | "version": "0.0.1",
4 | "description": "Jquery binding for BuckleScript.",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "compile": "mkdir -p lib/js && ./node_modules/bs-platform/bin/bsc.exe -I lib/ocaml -c -bs-main lib/ocaml/jquery.ml -bs-package-name $npm_package_name -bs-package-output lib/js || true",
9 | "compile_test": "mkdir -p lib/js && ./node_modules/bs-platform/bin/bsc.exe -I lib/ocaml -c -bs-main lib/ocaml/test.ml -bs-package-name $npm_package_name -bs-package-output lib/js && webpack test/main.js test/bundle.js"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "https://github.com/nebuta/bucklescript-jquery"
14 | },
15 | "keywords": [
16 | "BuckleScript",
17 | "OCaml",
18 | "JQuery"
19 | ],
20 | "author": "Nebuta",
21 | "license": "MIT",
22 | "bugs": {
23 | "url": "https://github.com/nebuta/bucklescript-jquery/issues"
24 | },
25 | "homepage": "https://github.com/nebuta/bucklescript-jquery",
26 | "devDependencies": {
27 | "bs-platform": "^1.0.3",
28 | "esprima": "^3.0.0",
29 | "lodash": "^4.16.2"
30 | },
31 | "dependencies": {
32 | "jquery": "^3.1.0"
33 | },
34 | "bundleDependencies": [
35 | "jquery"
36 | ]
37 | }
38 |
--------------------------------------------------------------------------------
/test/main.js:
--------------------------------------------------------------------------------
1 | // How to test:
2 | // First run `npm run compile_test` to make `lib/js/test.js` and webpack this main js file.
3 | // Then open test_index.html to load it.
4 |
5 |
6 | const _ = require('lodash');
7 | const $ = require('jquery');
8 | var esprima = require('esprima');
9 | const ml_compiled = require('../lib/js/test.js');
10 |
11 | function programEqual(fn1,fn2) {
12 | if(typeof fn1 != 'function' || typeof fn2 != 'function') {
13 | console.log('Either of them is non-function.');
14 | return false;
15 | }
16 | const p1 = esprima.parse(fn1.toString());
17 | const p2 = esprima.parse(fn2.toString());
18 | if(_.isEqual(p1.body[0].body,p2.body[0].body)){
19 | console.log('Equivalent function body: '+p1.body[0].id.name+", " + p2.body[0].id.name);
20 | return true;
21 | }else{
22 | console.log('Not equivalent:');
23 | console.log(p1,p2);
24 | return false;
25 | }
26 | }
27 |
28 | // Unit tests
29 |
30 | function attributes_raw() {
31 | var el = Jquery.jquery("#container");
32 | el.addClass("test");
33 | el.addClass(function (_, s) {
34 | return s+"-list";
35 | });
36 | return 0;
37 | }
38 |
39 | function main() {
40 | var flag = true;
41 | // Equality cannot be checked by this way for polymorphic variants.
42 | // flag &= programEqual(ml_compiled.attributes_raw,attributes_raw);
43 | if(flag){
44 | console.log("Test success!");
45 | $('body').append('Test success
')
46 | }else{
47 | console.log("Test failed.");
48 | $('body').append('Test failure
')
49 | }
50 | }
51 |
52 | main();
--------------------------------------------------------------------------------
/lib/js/jquery.js:
--------------------------------------------------------------------------------
1 | // Generated by BUCKLESCRIPT VERSION 1.0.3 , PLEASE EDIT WITH CARE
2 | 'use strict';
3 |
4 | var Jquery = require("jquery");
5 | var $$String = require("bs-platform/lib/js/string");
6 | var Js_types = require("bs-platform/lib/js/js_types");
7 |
8 | function addClass(at, jq) {
9 | if (at[0] >= 5744817) {
10 | return jq.addClass(at[1]);
11 | }
12 | else {
13 | return jq.addClass(at[1]);
14 | }
15 | }
16 |
17 | function attr_get(prim, prim$1) {
18 | return prim$1.attr(prim);
19 | }
20 |
21 | function attr(at, jq) {
22 | var variant = at[0];
23 | if (variant !== 23979) {
24 | if (variant >= 5442204) {
25 | return jq.attr(at[1]);
26 | }
27 | else {
28 | return jq.attr(at[1]);
29 | }
30 | }
31 | else {
32 | var match = at[1];
33 | return jq.attr(match[0], match[1]);
34 | }
35 | }
36 |
37 | function hasClass(prim, prim$1) {
38 | return prim$1.hasClass(prim);
39 | }
40 |
41 | function html_get(prim) {
42 | return prim.html();
43 | }
44 |
45 | function html(at, jq) {
46 | if (at[0] >= 5744817) {
47 | return jq.html(at[1]);
48 | }
49 | else {
50 | return jq.html(at[1]);
51 | }
52 | }
53 |
54 | function prop_get(k) {
55 | var p = function (param) {
56 | return param.prop(k);
57 | };
58 | var match = Js_types.reify_type(p);
59 | var v = match[1];
60 | var switcher = match[0] - 2 | 0;
61 | if (switcher > 2 || switcher < 0) {
62 | return /* error */-215364664;
63 | }
64 | else {
65 | switch (switcher) {
66 | case 0 :
67 | return /* `bool */[
68 | -1055161302,
69 | v
70 | ];
71 | case 1 :
72 | return /* error */-215364664;
73 | case 2 :
74 | return /* `str */[
75 | 5744817,
76 | v
77 | ];
78 |
79 | }
80 | }
81 | }
82 |
83 | function prop(at, jq) {
84 | var variant = at[0];
85 | if (variant !== 23979) {
86 | if (variant >= 5442204) {
87 | return jq.prop(at[1]);
88 | }
89 | else {
90 | return jq.prop(at[1]);
91 | }
92 | }
93 | else {
94 | var match = at[1];
95 | return jq.prop(match[0], match[1]);
96 | }
97 | }
98 |
99 | function removeAttr(prim, prim$1) {
100 | return prim$1.removeAttr(prim);
101 | }
102 |
103 | function removeClass(at, jq) {
104 | if (typeof at === "number") {
105 | return jq.removeClass();
106 | }
107 | else if (at[0] >= 5744817) {
108 | return jq.removeClass(at[1]);
109 | }
110 | else {
111 | return jq.removeClass(at[1]);
112 | }
113 | }
114 |
115 | function removeProp(prim, prim$1) {
116 | return prim$1.removeProp(prim);
117 | }
118 |
119 | function to_js_bool(b) {
120 | if (b) {
121 | return true;
122 | }
123 | else {
124 | return false;
125 | }
126 | }
127 |
128 | function toggleClass(at, jq) {
129 | var variant = at[0];
130 | if (variant >= -866389342) {
131 | if (variant >= 5744817) {
132 | if (variant >= 288862789) {
133 | var match = at[1];
134 | return jq.toggleClass($$String.concat(" ", match[0]), match[1] ? true : false);
135 | }
136 | else {
137 | return jq.toggleClass(at[1]);
138 | }
139 | }
140 | else if (variant >= -280389785) {
141 | var match$1 = at[1];
142 | return jq.toggleClass(match$1[0], match$1[1]);
143 | }
144 | else {
145 | return jq.toggleClass($$String.concat(" ", at[1]));
146 | }
147 | }
148 | else if (variant >= -866389359) {
149 | var match$2 = at[1];
150 | return jq.toggleClass(match$2[0], match$2[1] ? true : false);
151 | }
152 | else {
153 | return jq.toggleClass(at[1]);
154 | }
155 | }
156 |
157 | function val_get(prim) {
158 | return prim.val();
159 | }
160 |
161 | function val_(at, jq) {
162 | if (at[0] >= 5744817) {
163 | return jq.val(at[1]);
164 | }
165 | else {
166 | return jq.val(at[1]);
167 | }
168 | }
169 |
170 | function css_get(prim, prim$1) {
171 | return prim$1.css(prim);
172 | }
173 |
174 | function css_get$prime(prim, prim$1) {
175 | return prim$1.css(prim);
176 | }
177 |
178 | function css(at, jq) {
179 | var variant = at[0];
180 | if (variant !== 23979) {
181 | if (variant >= 5442204) {
182 | return jq.css(at[1]);
183 | }
184 | else {
185 | var match = at[1];
186 | return jq.css(match[0], match[1]);
187 | }
188 | }
189 | else {
190 | var match$1 = at[1];
191 | return jq.css(match$1[0], match$1[1]);
192 | }
193 | }
194 |
195 | function height_get(prim) {
196 | return prim.height();
197 | }
198 |
199 | function height(at, jq) {
200 | var variant = at[0];
201 | if (variant !== 5246191) {
202 | if (variant >= 5744817) {
203 | return jq.height(at[1]);
204 | }
205 | else {
206 | return jq.height(at[1]);
207 | }
208 | }
209 | else {
210 | return jq.height(at[1]);
211 | }
212 | }
213 |
214 | function innerHeight(prim) {
215 | return prim.innerHeight();
216 | }
217 |
218 | function innerWidth(prim) {
219 | return prim.innerWidth();
220 | }
221 |
222 | var cssHooks = Jquery.cssHooks;
223 |
224 | var cssNumber = Jquery.cssNumber;
225 |
226 | function escapeSelector(prim) {
227 | return Jquery.escapeSelector(prim);
228 | }
229 |
230 | function offset_get(prim) {
231 | return prim.offset();
232 | }
233 |
234 | function offset(at, jq) {
235 | if (at[0] >= 5541879) {
236 | return jq.offset(at[1]);
237 | }
238 | else {
239 | return jq.offset(at[1]);
240 | }
241 | }
242 |
243 | function outerHeight(prim) {
244 | return prim.outerHeight();
245 | }
246 |
247 | function outerHeight$prime(prim, prim$1) {
248 | return prim$1.outerHeight(prim);
249 | }
250 |
251 | function outerWidth(prim) {
252 | return prim.outerWidth();
253 | }
254 |
255 | function outerWidth$prime(prim, prim$1) {
256 | return prim$1.outerWidth(prim);
257 | }
258 |
259 | function position(prim) {
260 | return prim.position();
261 | }
262 |
263 | function scrollLeft_get(prim) {
264 | return prim.scrollLeft();
265 | }
266 |
267 | function scrollLeft(prim, prim$1) {
268 | return prim$1.scrollLeft(prim);
269 | }
270 |
271 | function scrollTop_get(prim) {
272 | return prim.scrollTop();
273 | }
274 |
275 | function scrollTop(prim, prim$1) {
276 | return prim$1.scrollTop(prim);
277 | }
278 |
279 | function width_get(prim) {
280 | return prim.width();
281 | }
282 |
283 | function width(at, jq) {
284 | var variant = at[0];
285 | if (variant !== 5246191) {
286 | if (variant >= 5744817) {
287 | return jq.width(at[1]);
288 | }
289 | else {
290 | return jq.width(at[1]);
291 | }
292 | }
293 | else {
294 | return jq.width(at[1]);
295 | }
296 | }
297 |
298 | function clone(jq) {
299 | return jq.clone(false, false);
300 | }
301 |
302 | function jquery(prim) {
303 | return Jquery(prim);
304 | }
305 |
306 | var clone$prime = clone;
307 |
308 | exports.addClass = addClass;
309 | exports.attr_get = attr_get;
310 | exports.attr = attr;
311 | exports.hasClass = hasClass;
312 | exports.html_get = html_get;
313 | exports.html = html;
314 | exports.prop_get = prop_get;
315 | exports.prop = prop;
316 | exports.removeAttr = removeAttr;
317 | exports.removeClass = removeClass;
318 | exports.removeProp = removeProp;
319 | exports.to_js_bool = to_js_bool;
320 | exports.toggleClass = toggleClass;
321 | exports.val_get = val_get;
322 | exports.val_ = val_;
323 | exports.css_get = css_get;
324 | exports.css_get$prime = css_get$prime;
325 | exports.height_get = height_get;
326 | exports.height = height;
327 | exports.innerHeight = innerHeight;
328 | exports.innerWidth = innerWidth;
329 | exports.cssHooks = cssHooks;
330 | exports.cssNumber = cssNumber;
331 | exports.escapeSelector = escapeSelector;
332 | exports.offset_get = offset_get;
333 | exports.offset = offset;
334 | exports.outerHeight$prime = outerHeight$prime;
335 | exports.outerWidth = outerWidth;
336 | exports.outerWidth$prime = outerWidth$prime;
337 | exports.position = position;
338 | exports.scrollLeft_get = scrollLeft_get;
339 | exports.scrollLeft = scrollLeft;
340 | exports.scrollTop_get = scrollTop_get;
341 | exports.scrollTop = scrollTop;
342 | exports.width_get = width_get;
343 | exports.width = width;
344 | exports.clone = clone;
345 | exports.clone$prime = clone$prime;
346 | exports.jquery = jquery;
347 | exports.css = css;
348 | exports.outerHeight = outerHeight;
349 | /* cssHooks Not a pure module */
350 |
--------------------------------------------------------------------------------
/lib/ocaml/jquery.ml:
--------------------------------------------------------------------------------
1 | type jquery;;
2 | type event;;
3 | type stub;;
4 |
5 | type ('a,'b) attr_func = jquery -> int -> 'a -> 'b [@bs.this];;
6 | type attr_func_str = (string,string) attr_func;;
7 | type js_coord = < top : int ; left : int > Js.t
8 |
9 | type t;;
10 | external jquery : string -> jquery = "" [@@bs.module]
11 | external jquery_ : jquery = "jquery" [@@bs.module]
12 | external jquery' : jquery -> jquery = "jquery" [@@bs.module]
13 |
14 | (* Attributes *)
15 | external addClass : string -> jquery = "addClass" [@@bs.send.pipe: jquery]
16 | external addClass' : (string,string) attr_func -> jquery = "addClass" [@@bs.send.pipe: jquery]
17 | let addClass at jq =
18 | match at with
19 | `str s -> addClass s jq
20 | | `func f -> addClass' f jq;;
21 |
22 | external attr_get : string -> string = "attr" [@@bs.send.pipe: jquery]
23 | let attr_get = attr_get;;
24 |
25 | external attr : string -> string -> jquery = "attr" [@@bs.send.pipe: jquery]
26 | external attr_ : 'a Js.t -> jquery = "attr" [@@bs.send.pipe: jquery]
27 | external attr' : (string,string) attr_func -> jquery = "attr" [@@bs.send.pipe: jquery]
28 |
29 | let attr at (jq : jquery) : jquery =
30 | match at with
31 | `kv (k,v) -> attr k v jq;
32 | | `map obj -> attr_ obj jq
33 | | `func f -> attr' f jq;;
34 |
35 |
36 | external hasClass : string -> Js.boolean = "hasClass" [@@bs.send.pipe: jquery]
37 | let hasClass = hasClass;;
38 |
39 | external html_get : string = "html" [@@bs.send.pipe: jquery]
40 | external html : string -> jquery = "html" [@@bs.send.pipe: jquery]
41 | external html' : (string,string) attr_func -> jquery = "html" [@@bs.send.pipe: jquery]
42 |
43 | let html_get = html_get;;
44 | let html at (jq : jquery) : jquery =
45 | match at with
46 | `str s -> html s jq;
47 | | `func f -> html' f jq;;
48 |
49 |
50 | external prop_get : string -> 'a Js.t = "prop" [@@bs.send.pipe: jquery]
51 |
52 | (* external prop_get_bool : string -> Js.boolean = "prop" [@@bs.send.pipe: jquery] *)
53 | external prop : string -> string -> jquery = "prop" [@@bs.send.pipe: jquery]
54 | external prop_ : 'a Js.t -> jquery = "prop" [@@bs.send.pipe: jquery]
55 | external prop' : (string,string) attr_func -> jquery = "prop" [@@bs.send.pipe: jquery]
56 |
57 | let prop_get (type t) (k : string) : [`str of t | `bool of t | `error] =
58 | let p = prop_get k in
59 | let ty, v = Js.Types.reify_type p in
60 | match (ty : t Js.Types.t) with
61 | | Js.Types.String -> `str v
62 | | Js.Types.Boolean -> `bool v
63 | | _ -> `error;;
64 |
65 | let prop at (jq : jquery) : jquery =
66 | match at with
67 | | `kv (k,v) -> prop k v jq
68 | | `map obj -> prop_ obj jq
69 | | `func f -> prop' f jq;;
70 |
71 | external removeAttr : string -> jquery = "removeAttr" [@@bs.send.pipe: jquery]
72 | let removeAttr = removeAttr;;
73 |
74 | external removeClass : string -> jquery = "removeClass" [@@bs.send.pipe: jquery]
75 | external removeClass_ : jquery = "removeClass" [@@bs.send.pipe: jquery]
76 | external removeClass' : (string,string) attr_func -> jquery = "removeClass" [@@bs.send.pipe: jquery]
77 |
78 | let removeClass at jq =
79 | match at with
80 | | `void -> removeClass_ jq
81 | | `str s -> removeClass s jq
82 | | `func f -> removeClass' f jq;;
83 |
84 | external removeProp : string -> jquery = "removeProp" [@@bs.send.pipe: jquery]
85 |
86 | let removeProp = removeProp;;
87 |
88 | external toggleClass : string -> jquery = "toggleClass" [@@bs.send.pipe: jquery]
89 | external toggleClass_ : string -> Js.boolean -> jquery = "toggleClass" [@@bs.send.pipe: jquery]
90 | external toggleClass' : (string,string) attr_func -> jquery = "toggleClass" [@@bs.send.pipe: jquery]
91 | external toggleClass'' : (string,string) attr_func -> Js.boolean -> jquery = "toggleClass" [@@bs.send.pipe: jquery]
92 |
93 | let to_js_bool b = if b then Js.true_ else Js.false_
94 |
95 | let toggleClass at jq =
96 | match at with
97 | `str s -> toggleClass s jq
98 | | `strs ss -> toggleClass (String.concat " " ss) jq
99 | | `strb (s,b) -> toggleClass_ s (to_js_bool b) jq
100 | | `strs_b (ss,b) -> toggleClass_ (String.concat " " ss) (to_js_bool b) jq
101 | | `func f -> toggleClass' f jq
102 | | `func_b (f,b) -> toggleClass'' f b jq
103 |
104 | external val_get : string = "val" [@@bs.send.pipe: jquery]
105 | let val_get = val_get
106 |
107 | external val_ : string -> jquery = "val" [@@bs.send.pipe: jquery]
108 | external val_' : (string,string) attr_func -> jquery = "val" [@@bs.send.pipe: jquery]
109 | let val_ at jq =
110 | match at with
111 | `str s -> val_ s jq
112 | | `func f -> val_' f jq
113 |
114 | (* CSS: https://api.jquery.com/category/css/ *)
115 | external css_get : string -> string = "css" [@@bs.send.pipe: jquery]
116 | external css_get' : string array -> 'a Js.t = "css" [@@bs.send.pipe: jquery]
117 | let css_get = css_get
118 | let css_get' = css_get'
119 |
120 | external css : string -> string -> jquery = "css" [@@bs.send.pipe: jquery]
121 | external css_ : 'a Js.t -> jquery = "css" [@@bs.send.pipe: jquery]
122 | external css' : string -> attr_func_str -> jquery = "css" [@@bs.send.pipe: jquery]
123 | let css at jq =
124 | match at with
125 | | `kv (k,v) -> css k v jq
126 | | `map obj -> css_ obj jq
127 | | `func (n,f) -> css' n f jq;;
128 |
129 | external height_get : int = "height" [@@bs.send.pipe: jquery]
130 | let height_get = height_get
131 |
132 | external height : string -> jquery = "height" [@@bs.send.pipe: jquery]
133 | external height_ : int -> jquery = "height" [@@bs.send.pipe: jquery]
134 | external height' : (int, 'a Js.t) attr_func -> jquery = "height" [@@bs.send.pipe: jquery]
135 | let height at jq =
136 | match at with
137 | `str v -> height v jq
138 | | `int v -> height_ v jq
139 | | `func f -> height' f jq;;
140 |
141 | external innerHeight : int = "innerHeight" [@@bs.send.pipe: jquery]
142 | let innerHeight = innerHeight
143 |
144 | external innerWidth : int = "innerWidth" [@@bs.send.pipe: jquery]
145 | let innerWidth = innerWidth
146 |
147 | external cssHooks : 'a Js.t = "" [@@bs.module "jquery"]
148 | let cssHooks = cssHooks;;
149 |
150 | external cssNumber : 'a Js.t = "" [@@bs.module "jquery"]
151 | let cssNumber = cssNumber;;
152 |
153 | external escapeSelector : string -> string = "" [@@bs.module "jquery"]
154 | let escapeSelector = escapeSelector;;
155 |
156 | external offset_get : js_coord = "offset" [@@bs.send.pipe: jquery]
157 | let offset_get = offset_get
158 |
159 | external offset : js_coord -> jquery = "offset" [@@bs.send.pipe: jquery]
160 | external offset' : (js_coord, js_coord) attr_func -> jquery = "offset" [@@bs.send.pipe: jquery]
161 | let offset at jq =
162 | match at with
163 | `obj v -> offset v jq
164 | | `func f -> offset' f jq;;
165 |
166 | external outerHeight : int = "outerHeight" [@@bs.send.pipe: jquery]
167 | external outerHeight' : Js.boolean -> int = "outerHeight" [@@bs.send.pipe: jquery]
168 | let outerHeight = outerHeight
169 | let outerHeight' = outerHeight'
170 |
171 | external outerWidth : int = "outerWidth" [@@bs.send.pipe: jquery]
172 | external outerWidth' : Js.boolean -> int = "outerWidth" [@@bs.send.pipe: jquery]
173 | let outerWidth = outerWidth
174 | let outerWidth' = outerWidth'
175 |
176 | external position : js_coord = "position" [@@bs.send.pipe: jquery]
177 | let position = position
178 |
179 | external scrollLeft_get : int = "scrollLeft" [@@bs.send.pipe: jquery]
180 | let scrollLeft_get = scrollLeft_get
181 |
182 | external scrollLeft : int -> jquery = "scrollLeft" [@@bs.send.pipe: jquery]
183 | let scrollLeft = scrollLeft
184 |
185 | external scrollTop_get : int = "scrollTop" [@@bs.send.pipe: jquery]
186 | let scrollTop_get = scrollTop_get
187 |
188 | external scrollTop : int -> jquery = "scrollTop" [@@bs.send.pipe: jquery]
189 | let scrollTop = scrollTop
190 |
191 | external width_get : int = "width" [@@bs.send.pipe: jquery]
192 | let width_get = width_get
193 |
194 | external width : string -> jquery = "width" [@@bs.send.pipe: jquery]
195 | external width_ : int -> jquery = "width" [@@bs.send.pipe: jquery]
196 | external width' : (int, 'a Js.t) attr_func -> jquery = "width" [@@bs.send.pipe: jquery]
197 | let width at jq =
198 | match at with
199 | `str v -> width v jq
200 | | `int v -> width_ v jq
201 | | `func f -> width' f jq;;
202 |
203 | (* Manipulation - Copying *)
204 | external clone : Js.boolean -> Js.boolean -> jquery = "clone" [@@bs.send.pipe: jquery]
205 | let clone jq = clone Js.false_ Js.false_ jq
206 | let clone' = clone
207 |
208 | (* Manipulation - DOM Insertion, Around *)
209 | external unwrap : jquery = "unwrap" [@@bs.send.pipe: jquery]
210 | external unwrap_ : string -> jquery = "unwrap" [@@bs.send.pipe: jquery]
211 | external wrap : 'a Js.t -> jquery = "wrap" [@@bs.send.pipe: jquery]
212 | external wrap' : (jquery -> int -> 'a Js.t [@bs.this]) -> jquery = "wrap" [@@bs.send.pipe: jquery]
213 | external wrapAll : 'a Js.t -> jquery = "wrapAll" [@@bs.send.pipe: jquery]
214 | external wrapAll' : (jquery -> int -> 'a Js.t [@bs.this]) -> jquery = "wrapAll" [@@bs.send.pipe: jquery]
215 | external wrapInner : 'a Js.t -> jquery = "wrapInner" [@@bs.send.pipe: jquery]
216 | external wrapInner' : (jquery -> int -> 'a Js.t [@bs.this]) -> jquery = "wrapInner" [@@bs.send.pipe: jquery]
217 |
218 | (* Manipulation - DOM Insertion, Inside *)
219 | external append : 'a Js.t -> jquery = "append" [@@bs.send.pipe: jquery]
220 | external append' : (string,'a Js.t) attr_func -> jquery = "append" [@@bs.send.pipe: jquery]
221 | external appendTo : jquery -> jquery = "appendTo" [@@bs.send.pipe: jquery]
222 | external appendTo' : (string,'a Js.t) attr_func -> jquery = "appendTo" [@@bs.send.pipe: jquery]
223 | external text_get : string = "text" [@@bs.send.pipe: jquery]
224 | external text : 'a Js.t -> jquery = "text" [@@bs.send.pipe: jquery]
225 | external text' : (string,string) attr_func -> jquery = "text" [@@bs.send.pipe: jquery]
226 |
227 | (* Manipulation - DOM Insertion, Outside *)
228 | external after : 'a Js.t -> jquery = "after" [@@bs.send.pipe: jquery]
229 | external after' : (jquery -> int -> 'a Js.t [@bs.this]) -> jquery = "after" [@@bs.send.pipe: jquery]
230 | external after'' : (string,'a Js.t) attr_func -> jquery = "after" [@@bs.send.pipe: jquery]
231 | external before : 'a Js.t -> jquery = "before" [@@bs.send.pipe: jquery]
232 | external before'' : (jquery -> int -> 'a Js.t [@bs.this]) -> jquery = "before" [@@bs.send.pipe: jquery]
233 | external before'' : (string,'a Js.t) attr_func -> jquery = "before" [@@bs.send.pipe: jquery]
234 | external insertAfter : 'a Js.t -> jquery = "" [@@bs.send.pipe: jquery]
235 | external insertBefore : 'a Js.t -> jquery = "" [@@bs.send.pipe: jquery]
236 |
237 |
238 | (* Manipulation - DOM Removal *)
239 | external detach : string -> jquery = "detach" [@@bs.send.pipe: jquery]
240 | external empty : jquery = "empty" [@@bs.send.pipe: jquery]
241 | external remove : jquery = "remove" [@@bs.send.pipe: jquery]
242 | external remove' : string -> jquery = "remove" [@@bs.send.pipe: jquery]
243 |
244 | (* Manipulation - DOM Replacement *)
245 | external replaceAll : 'a Js.t -> jquery = "replaceAll" [@@bs.send.pipe: jquery]
246 | external replaceWith : 'a Js.t -> jquery = "replaceWith" [@@bs.send.pipe: jquery]
247 | external replaceWith' : (jquery -> 'a Js.t [@bs.this]) -> jquery = "replaceWith" [@@bs.send.pipe: jquery]
248 |
249 | (* Effects - Basics *)
250 | external toggle : Js.boolean -> jquery = "" [@@bs.send.pipe: jquery]
251 | external hide : jquery = "" [@@bs.send.pipe: jquery]
252 | external show : jquery = "" [@@bs.send.pipe: jquery]
253 |
254 | (* Done above*)
255 |
256 | (*
257 | (* Effects - Basics *)
258 | external toggle : jquery = "" [@@bs.send.pipe: jquery]
259 |
260 | (* Effects - Custom *)
261 | external animate : string -> jquery = "" [@@bs.send.pipe: jquery]
262 | external clearQueue : string -> jquery = "" [@@bs.send.pipe: jquery]
263 | external delay : string -> jquery = "" [@@bs.send.pipe: jquery]
264 | external dequeue : string -> jquery = "" [@@bs.send.pipe: jquery]
265 |
266 | (* Effects - Fading *)
267 | external fadeIn : string -> jquery = "" [@@bs.send.pipe: jquery]
268 | external fadeOut : string -> jquery = "" [@@bs.send.pipe: jquery]
269 | external fadeTo : string -> jquery = "" [@@bs.send.pipe: jquery]
270 | external fadeToggle : string -> jquery = "" [@@bs.send.pipe: jquery]
271 |
272 | (* Effects - Sliding *)
273 | external slideDown : string -> jquery = "" [@@bs.send.pipe: jquery]
274 | external slideToggle : string -> jquery = "" [@@bs.send.pipe: jquery]
275 | external slideUp : string -> jquery = "" [@@bs.send.pipe: jquery]
276 |
277 | *)
278 |
279 | (* Events - Browser Events *)
280 | external error : string -> jquery = "" [@@bs.send.pipe: jquery]
281 | external resize : string -> jquery = "" [@@bs.send.pipe: jquery]
282 | external scroll : string -> jquery = "" [@@bs.send.pipe: jquery]
283 |
284 | (* Events - Document Loading *)
285 | external load : string -> jquery = "" [@@bs.send.pipe: jquery]
286 | external ready : string -> jquery = "" [@@bs.send.pipe: jquery]
287 | external unload : string -> jquery = "" [@@bs.send.pipe: jquery]
288 |
289 | (* Events - Event Handler Attachement *)
290 | external off : string -> jquery = "" [@@bs.send.pipe: jquery]
291 | external on : string -> (jquery -> 'a Js.t -> Js.boolean [@bs.this]) -> jquery = "" [@@bs.send.pipe: jquery]
292 | external on' : string -> string -> (jquery -> 'a Js.t -> Js.boolean [@bs.this]) -> jquery = "on" [@@bs.send.pipe: jquery]
293 | external one : string -> jquery = "" [@@bs.send.pipe: jquery]
294 | external trigger : string -> jquery = "" [@@bs.send.pipe: jquery]
295 | external triggerHandler : string -> jquery = "" [@@bs.send.pipe: jquery]
296 |
297 | (* Tree Traversal *)
298 |
299 | external closest : string -> jquery = "" [@@bs.send.pipe: jquery]
300 |
301 | external find : string -> jquery = "" [@@bs.send.pipe: jquery]
302 |
303 | (* Data *)
304 | external data_get : string -> string = "data" [@@bs.send.pipe: jquery]
305 | external data : string -> string -> jquery = "data" [@@bs.send.pipe: jquery]
306 |
307 | (* Other *)
308 | external focus : jquery = "" [@@bs.send.pipe: jquery]
309 | external blur : jquery = "" [@@bs.send.pipe: jquery]
310 | external hashchange : (jquery -> 'a Js.t -> Js.boolean [@bs.this]) -> jquery = "" [@@bs.send.pipe: jquery]
311 |
312 |
313 | let jquery = jquery;;
314 | (* let addClass = addClass;;
315 | *)let css = css;;
316 | let outerHeight = outerHeight;;
317 | (* let cssNumber = cssNumber jquery_;; *)
318 |
319 |
320 |
--------------------------------------------------------------------------------