Skip to content

Commit

Permalink
* Start with all other events. :)
Browse files Browse the repository at this point in the history
  • Loading branch information
spockz committed Jan 5, 2012
1 parent bfc45d9 commit bd560c0
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions resources/static/hjs/jcu.hs
Expand Up @@ -48,11 +48,12 @@ ajaxQ url onSuccess onFail = do
onSuccess
onFail

register_events :: [(String, JEventType, JEventHandler)] -> IO ()
register_events = mapM_ (\ (e, event, eh) -> do elem <- jQuery e
bind elem
event
eh)
registerEvents :: [(String, JEventType, EventHandler)] -> IO ()
registerEvents = mapM_ (\ (e, event, eh) -> do elem <- jQuery e
jeh <- mkJEventHandler eh
bind elem
event
jeh)

main :: IO ()
main = do init <- ioWrap initialize
Expand All @@ -67,8 +68,19 @@ initialize = do -- Rendering

-- Rules list
ajaxQ "/rules/stored" addRules noop


registerEvents $ [("#btnCheck" , "click" , noevent)
,("#btnAddRule", "click" , noevent)
,("#btnReset" , "click" , noevent)
,("#txtAddRule", "keypress", noevent)
,("#txtAddRule", "blur" , noevent)
,("#btnSubst" , "click" , noevent)
]
where noop :: AjaxCallback (JSPtr a)
noop = (\x y z -> return ())
noevent :: EventHandler
noevent x = return False


addRules :: AjaxCallback (JSArray JSRule)
Expand Down Expand Up @@ -102,6 +114,4 @@ foreign import jscript "wrapper"
ioWrap :: IO () -> IO (JSFunPtr (IO ()))

alertType :: a -> IO ()
alertType = _alert . typeof

defaultDragOptions = Draggable
alertType = _alert . typeof

0 comments on commit bd560c0

Please sign in to comment.