annotate examples/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 554e342665fe
children 93140c5cc972
rev   line source
kkallio@8 1 open Gui
kkallio@8 2 open TogglePanel
kkallio@8 3
kkallio@8 4 val defaultContent : xbody = <xml><p>Here I am inside the panel.<br/><b>Default format</b></p></xml>
kkallio@8 5 val otherContent : xbody = <xml><p>Here I am inside the panel.<br/><b>Other format</b></p></xml>
kkallio@8 6
adam@20 7 val otherFormat = fn [body ~ []] =>
adam@20 8 {FormatPanel = fn ctl panel => <xml><span>A Custom {ctl} Format</span>{panel}</xml>,
adam@20 9 OpenCtl = fn behaviour => <xml><a href={bless "http://#"} onclick={behaviour}>View</a></xml>,
adam@20 10 CloseCtl = fn behaviour => <xml><a href={bless "http://#"} onclick={behaviour}>Hide</a></xml>}
kkallio@8 11
kkallio@8 12 fun main () =
kkallio@8 13
adam@20 14 defaultFormatPanel <- create @defaultFormat defaultContent True;
adam@20 15 otherFormatPanel <- create @otherFormat otherContent False;
kkallio@8 16
kkallio@8 17 return <xml>
kkallio@8 18 <head>
kkallio@8 19 <title>A panel that can be shown or hidden.</title>
kkallio@8 20 </head>
kkallio@8 21 <body>
kkallio@8 22 <h1>Example using the togglePanel widget.</h1>
kkallio@8 23 <p>
kkallio@8 24 This is a widget which has a content display panel
kkallio@8 25 which can be shown or hidden.
kkallio@8 26 </p>
kkallio@8 27 <h2>Example of the default format, starting open.</h2>
kkallio@8 28 <p>
kkallio@8 29 {toXml defaultFormatPanel}
kkallio@8 30 </p>
kkallio@8 31 <h2>Example of another format, starting closed.</h2>
kkallio@8 32 <p>
kkallio@8 33 {toXml otherFormatPanel}
kkallio@8 34 </p>
kkallio@8 35 </body>
kkallio@8 36 </xml>