annotate navbar.urs @ 34:2d195bee1efa

CKeditor wrapper
author Adam Chlipala <adam@chlipala.net>
date Thu, 21 Nov 2013 18:19:02 -0500
parents d314d2ec3300
children
rev   line source
kkallio@6 1 (* NAVBAR provides services to construct and pretty print to xml typical
kkallio@6 2 * menu items (of a visible text and a url link) and menu bars assembled
kkallio@6 3 * from them. It is intended to be used as a low-level component in
kkallio@6 4 * constructing navigation related widgets and theme parts. *)
kkallio@6 5
kkallio@6 6 type navItem
kkallio@6 7 (* Items in the navigation menu. *)
kkallio@6 8
kkallio@6 9 con navBar :: Type -> Type
kkallio@6 10 (* A menu bar of navigation links. Up to one link may be active. *)
kkallio@6 11
kkallio@6 12 type build
kkallio@6 13 type print
kkallio@6 14 (* These track the current navbar mode. *)
kkallio@6 15
kkallio@6 16 class mode
kkallio@6 17 (* To make sure we always print the navbar correctly. *)
kkallio@6 18
kkallio@6 19 val navToXml_build : mode build
kkallio@6 20 val navToXml_print : mode print
kkallio@6 21 (* How to print both modes. *)
kkallio@6 22
kkallio@6 23 val printingNavBar : navBar build -> navBar print
kkallio@6 24 (* This switches the navbar from building mode to printing mode. Normally not
kkallio@6 25 * necessary to call this, but is in the signature in case the programmer will
kkallio@6 26 * pass the same navbar to several components wanting to print it. Then by
kkallio@6 27 * using this first multiple (redundant) calls to List.rev can be avoided.
kkallio@6 28 * Mode tracking makes this optimization safe. *)
kkallio@6 29
kkallio@6 30 val emptyNavBar : navBar build
kkallio@6 31 (* An empty menu bar. *)
kkallio@6 32
kkallio@6 33 val mkNavItem : string -> url -> navItem
kkallio@6 34 (* Make a menu item with visible text given by the string and linking to url. *)
kkallio@6 35
kkallio@6 36 val navAdd : navItem -> navBar build -> navBar build
kkallio@6 37 (* Add an unactive item to the right end of the navbar. *)
kkallio@6 38
kkallio@6 39 val navAddActive : navItem -> navBar build -> navBar build
kkallio@6 40 (* Add an active item to the right end of the navbar. If there already
kkallio@6 41 * was an active item it will be deactivated. *)
kkallio@6 42
kkallio@6 43 val navItemToXml : option css_class -> navItem -> xbody
kkallio@6 44 (* Pretty print a navItem with an optional style to a piece of <a>...</a> xml. *)
kkallio@6 45
kkallio@6 46 val navBarToXml : t ::: Type -> mode t -> navBar t -> xbody
kkallio@6 47 (* Pretty print the navigation menu as a piece of xml made of
kkallio@6 48 * a chain <li><a>...</a></li> repeated. *)
kkallio@6 49
rmbruijn@24 50 val name : navItem -> string
rmbruijn@24 51 (* navItems have a name, which this function returns *)
rmbruijn@24 52
kkallio@6 53 style active
kkallio@6 54 style last
kkallio@6 55 (* CSS classes to mark the active and last menu item. *)