git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Create jquery_io.purs
commite2d5428e0c077ed391028d61d3b4ed359c39b7f3 authorPhil Freeman <paf31@cantab.net> dateFri 10 Jan 2014, 15:39 (13 years ago) parentda0530b
1 file changed+30
libraries/jquery/jquery_io.purs+30
libraries/jquery/jquery_io.pursnew file+30
@@ -0,0 +1,30 @@
1+module JQuery where
2+
3+ import Prelude
4+
5+ -- An effect type which indicates DOM manipulation
6+ foreign import data DOM :: !
7+
8+ -- The jQuery wrapper type
9+ foreign import data JQuery :: *
10+
11+ -- Wrapper function for jQuery selection $('..')
12+ foreign import select "function select(selector) { return function () { return jQuery(selector); }; }" :: forall eff. String -> Eff (dom :: DOM | eff) JQuery
13+
14+ -- Wrapper function for jQuery creation e.g. $('<div>')
15+ foreign import create "function create(html) { return function () { return jQuery(html); }; }" :: forall eff. String -> Eff (dom :: DOM | eff) JQuery
16+
17+ -- .attr({ ... })
18+ foreign import attr "function attr(attrs) { return function(ob) { return function () { return ob.attr(attrs); }; }; }" :: forall eff attr. { | attr } -> JQuery -> Eff (dom :: DOM | eff) JQuery
19+
20+ -- .css({ ... })
21+ foreign import css "function css(props) { return function(ob) { return function () { return ob.css(props); }; }; }" :: forall eff css. { | css } -> JQuery -> Eff (dom :: DOM | eff) JQuery
22+
23+ -- .append(...)
24+ foreign import append "function append(ob) { return function(ob1) { return function () { return ob.append(ob1); }; }; }" :: forall eff. JQuery -> JQuery -> Eff (dom :: DOM | eff) JQuery
25+
26+ -- .append(...)
27+ foreign import appendText "function appendText(ob) { return function(s) { return function () { return ob.append(s); }; }; }" :: forall eff. JQuery -> String -> Eff (dom :: DOM | eff) JQuery
28+
29+ -- Get the document body
30+ foreign import body "function body() { return jQuery(document.body); }" :: forall eff. Eff (dom :: DOM | eff) JQuery