view popupNav.urs @ 7:48a4180171b0

Shifted some more generic theme navigation code to the library. Also generalized formatting options a bit for popupNav.
author Karn Kallio <kkallio@eka>
date Fri, 06 May 2011 23:00:22 -0430
parents f17b869fbb71
children
line wrap: on
line source
(* POPUPNAV provides a simple navigation menu which opens and
 * closes when the user clicks on an associated control. *)

con popupNav :: Type -> Type
(* The type of popping open navigation menus. *)

type formatCtl = {FormatMenu : xbody -> xbody -> xbody,
                  (* Allows for formatting the menu.  The first two parameters
                   * represent "holes" for the control and menu items and
                   * the result should be the desired menu xml.  The controls
                   * can be formatted with the options below, and the menu items
                   * will be placed as a chain of <li><a> ....</a></li> wrapped
                   * as given below.  The menu part appears and disappears according
                   * to the use of the controls. *)

                   WrapMenu : xbody -> xbody,
                   (* This allows for the wrapping of menu <li> ... </li> with some
                    * chrome that will appear and disappear. *)

                  OpenCtl : transaction unit -> xbody,
                  (* This should accept the transaction representing the opening of
                   * the menu and produce an xml control having this as action. *)

                  CloseCtl : transaction unit -> xbody}
                  (* This should accept the transaction representing the closing of
                   * the menu and produce an xml control having this as action. *)

val defaultFormat : formatCtl
(* Some reasonable default formats for the menu layout and controls. *)

val create : t ::: Type -> formatCtl -> Navbar.mode t -> Navbar.navBar t -> transaction (popupNav t)
(* Given instructions for formatting the display and a navbar, get a popup navigation. *)

val render : t ::: Type -> Navbar.mode t -> popupNav t -> xbody
(* Pretty prints a popup navigation as a piece of xml. *)