comparison togglePanel.ur @ 27:5905b56e0cd9

Adapt to new HTML contexts
author Adam Chlipala <adam@chlipala.net>
date Tue, 20 Dec 2011 21:04:21 -0500
parents 30f9a763f5fb
children 7d0014542199
comparison
equal deleted inserted replaced
26:86857ae0f386 27:5905b56e0cd9
1 datatype panelState = Open | Closed 1 datatype panelState = Open | Closed
2 2
3 con formatCtl = fn ctx :: {Unit} => [body ~ ctx] => 3 con formatCtl = fn ctx :: {Unit} => [[Dyn] ~ ctx] =>
4 {FormatPanel : xml (body ++ ctx) [] [] 4 {FormatPanel : xml ([Dyn] ++ ctx) [] []
5 -> xml (body ++ ctx) [] [] 5 -> xml ([Dyn] ++ ctx) [] []
6 -> xml (body ++ ctx) [] [], 6 -> xml ([Dyn] ++ ctx) [] [],
7 OpenCtl : transaction unit -> xml (body ++ ctx) [] [], 7 OpenCtl : transaction unit -> xml ([Dyn] ++ ctx) [] [],
8 CloseCtl : transaction unit -> xml (body ++ ctx) [] []} 8 CloseCtl : transaction unit -> xml ([Dyn] ++ ctx) [] []}
9 9
10 val defaultFormat [body ~ []] = 10 val defaultFormat [[Dyn] ~ body'] =
11 {FormatPanel = fn ctl panel => <xml>{ctl}{panel}</xml>, 11 {FormatPanel = fn ctl panel => <xml>{ctl}{panel}</xml>,
12 OpenCtl = fn behaviour => <xml><button value="Open" onclick={behaviour}/></xml>, 12 OpenCtl = fn behaviour => <xml><button value="Open" onclick={behaviour}/></xml>,
13 CloseCtl = fn behaviour => <xml><button value="Close" onclick={behaviour}/></xml>} 13 CloseCtl = fn behaviour => <xml><button value="Close" onclick={behaviour}/></xml>}
14 14
15 con togglePanel t ctx = {PanelState : source panelState, 15 con togglePanel t ctx = {PanelState : source panelState,
23 23
24 return {PanelState = state, 24 return {PanelState = state,
25 FormatCtl = @f, 25 FormatCtl = @f,
26 Content = content} 26 Content = content}
27 27
28 fun render [t ::: Type] [ctx ::: {Unit}] (_ : gui t ctx) [body ~ ctx] (panel : togglePanel t ctx) = 28 fun render [t ::: Type] [ctx ::: {Unit}] (_ : gui t ctx) [[Dyn] ~ ctx] (panel : togglePanel t ctx) =
29 let 29 let
30 val format = panel.FormatCtl ! 30 val format = panel.FormatCtl !
31 val openCtl = format.CloseCtl (set panel.PanelState Closed) 31 val openCtl = format.CloseCtl (set panel.PanelState Closed)
32 val closeCtl = format.OpenCtl (set panel.PanelState Open) 32 val closeCtl = format.OpenCtl (set panel.PanelState Open)
33 33