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