Permalink
Browse files

* Boolean support

* Added a WIP Draggable binding
  • Loading branch information...
1 parent 8445915 commit e8ce7ea57c56547ab1a68a5124c3acfb5dd153ed @spockz spockz committed Jan 3, 2012
@@ -0,0 +1,19 @@
+module Language.UHC.JScript.ECMA.Bool where
+
+import Language.UHC.JScript.Types
+
+data JSBoolPtr
+type JSBool = JSBoolPtr
+
+instance ToJS Bool JSBool where
+ toJS = toJSBool
+
+toJSBool :: Bool -> JSBool
+toJSBool True = _true
+toJSBool False = _false
+
+foreign import jscript "true"
+ _true :: JSBool
+
+foreign import jscript "false"
+ _false :: JSBool
@@ -0,0 +1,26 @@
+module Language.UHC.JScript.JQuery.Draggable where
+
+import Language.UHC.JScript.ECMA.Bool
+
+import Language.UHC.JScript.Primitives
+import Language.UHC.JScript.Types
+import Language.UHC.JScript.JQuery.JQuery
+
+data Draggable = Draggable { scroll :: JSBool, containment :: JSString,
+ revert :: JSBool, revertDuration :: Int,
+ scrollSensitivity :: Int,
+ start :: JUIEventHandler}
+
+data JSDraggablePtr
+type JSDraggable = JSPtr JSDraggablePtr
+
+draggable :: JQuery -> Draggable -> IO ()
+draggable jq drag =
+ do jsdrag <- mkJSDraggable drag
+ _draggable jq jsdrag
+
+foreign import jscript "{}"
+ mkJSDraggable :: Draggable -> IO JSDraggable
+
+foreign import jscript "%1.draggable(%2)"
+ _draggable :: JQuery -> JSDraggable -> IO ()
@@ -137,15 +137,24 @@ jqshow j (Just n) Nothing (Just c) = jqshow2' j n c
jqshow j (Just n) (Just e) (Just c) = jqshow3 j n (toJS e) c
+foreign import jscript "%1.blur()"
+ doBlur :: JQuery -> IO ()
+
-------------------------------------------------------------------------------
-- Events
data JUIPtr
type JUI = JSPtr JUIPtr
+type EventHandler = JQuery -> JEventResult
+type UIEventHandler = JQuery -> JUI -> JEventResult -- TODO: Split this off to JQueryUI or something :)
+
+
type JEventResult = IO Bool
-type JEventHandler = JSFunPtr ( JQuery -> JEventResult )
-type JUIEventHandler = JSFunPtr ( JQuery -> JUI -> JEventResult )
+
+type JEventHandler = JSFunPtr EventHandler
+type JUIEventHandler = JSFunPtr UIEventHandler
+
type JEventType = String
bind :: JQuery -> JEventType -> JEventHandler -> IO ()
@@ -176,12 +185,22 @@ onDocumentReady f = _ready f
foreign import jscript "$('document').ready(%1)"
_ready :: JSFunPtr (IO ()) -> IO ()
+foreign import jscript "wrapper"
+ mkJEventHandler :: EventHandler -> IO JEventHandler
+
+foreign import jscript "wrapper"
+ mkJUIEventHandler :: UIEventHandler -> IO JUIEventHandler
+
-------------------------------------------------------------------------------
-- DOM Manipulation
append :: JQuery -> JQuery -> IO ()
append = _append
+appendString :: JQuery -> String -> IO ()
+appendString jq str = do jq' <- jQuery str
+ _append jq jq'
+
foreign import jscript "%1.append(%*)"
_append :: JQuery -> JQuery -> IO ()

0 comments on commit e8ce7ea

Please sign in to comment.