view popupNav.urs @ 6:f17b869fbb71

Shifting some generic theme navigation menu code to the library.
author Karn Kallio <kkallio@eka>
date Tue, 26 Apr 2011 20:27:04 -0430
parents
children 48a4180171b0
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>. *)

                  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. *)