comparison navigation.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
children
comparison
equal deleted inserted replaced
6:f17b869fbb71 7:48a4180171b0
1 (* A navigation is a collection of navigation bars (menus) made of links of
2 * which up to one may be marked as active, optional isolated links not part of
3 * menu bars and also optional message or status zones containing xml. The
4 * programmer can provide a way to format these elements into a collection of
5 * pieces of xml which can then be inserted into themes. *)
6
7 functor Make(M : sig
8 con linkPos :: {Unit}
9 (* The collection of isolated links. Should be inferred. *)
10
11 val linkFolder : folder linkPos
12 (* Implementation detail; should be inferred. *)
13
14 con navbarPos :: {Unit}
15 (* The collection of navbars. *)
16
17 con msgPos :: {Unit}
18 (* The collection of optional status or message xml pieces. *)
19
20 val msgFolder : folder msgPos
21 (* Implementation detail; should be inferred. *)
22
23 con linkStyles :: {Type} = mapU (option css_class) linkPos
24 (* The collection of isolated links, with an optional CSS class
25 * which will be applied to that link. *)
26
27 con themePos :: {Unit}
28 (* The positions in the theme to generate xml for. *)
29
30 val linkStyles : $linkStyles
31 (* The input optional link positions and styles. *)
32
33 val formatNav : $(mapU xbody navbarPos) -> $(mapU xbody linkPos) -> $(mapU xbody msgPos)
34 -> $(mapU xbody themePos)
35 (* The way to format the collections of navbars, links and message
36 * zones into pieces of xml for the theme positions. *)
37
38 end) : sig
39
40 con modeLs :: {Type} -> Type = fn r :: {Type} => $(map Navbar.mode r)
41 con barLs :: {Type} -> Type = fn r :: {Type} => $(map Navbar.navBar r)
42
43 con linkLs :: {Unit} -> Type = fn r :: {Unit} => $(mapU (option Navbar.navItem) r)
44 con msgLs :: {Unit} -> Type = fn r :: {Unit} => $(mapU (option xbody) r)
45
46 class shape
47
48 val shape_npos : shape $(mapU xbody M.navbarPos)
49
50 con crush :: {Type} -> Type = fn r :: {Type} => $(map (fn _ => xbody) r)
51
52 con navigation :: {Type} -> Type = fn m :: {Type} => {Nav : barLs m,
53 Link : linkLs M.linkPos,
54 Msg : msgLs M.msgPos}
55 (* Represents a complete navigation ensemble. *)
56
57 val mkNav : m ::: {Type} -> shape (crush m) -> modeLs m -> barLs m
58 -> linkLs M.linkPos -> msgLs M.msgPos
59 -> navigation m
60 (* Builds a navigation from input elements of navbars, isolated links and messages. *)
61
62 val toXml : m ::: {Type} -> folder m -> shape (crush m) -> modeLs m
63 -> navigation m -> $(mapU xbody M.themePos)
64 (* Renders a navigation to xml pieces suitable for inclusion in a theme. *)
65
66 end