menu.anubis
7.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 18/02/2017
* Time: 01:52
* © Calexium
*/
transmit tools/basis.anubis
read system/string.anubis
read calexium_lib/web/CXM_making_a_web_site.anubis
transmit calexium_lib/web/widgets/icon.anubis
public type Menu_Item:
menu_item( //MENU entry
String text, //text to show
Icon icon,
List(String) ids, //it's also use as icon prefix
List(String) classes, //additional classes if need (for disabling entry, change background color, etc.)
WEB_Action_Name action, //action (url to apply when click
List((String, String)) extra, //extra web arguments to send when click
Actioner_Target target, //target if need
List(Menu_Item) sub_menu
//Bool selected
),
// menu_title( //TITLE entry hence no selectable
// String text, //text to show
// List(String) ids, //it's also use as icon prefix
// List(String) classes //additional classes if need (change background color, font size, etc.)
// ),
menu_item_content(
HTML_Partial_Content content
),
menu_separator
.
public type Menu:
no_menu,
menu(
List(Menu_Item) items
//String selected
)
.
public define Menu_Item
menu_item
(
String text,
WEB_Action_Name action,
List((String, String)) extra_op
)=
menu_item(text, no_icon, [], [], action, extra_op, same, [])
.
public define Menu_Item
menu_item
(
String text,
Icon icon,
WEB_Action_Name action,
List((String, String)) extra_op
)=
menu_item(text, icon, [], [], action, extra_op, same, [])
.
public define Menu_Item
menu_item
(
String text,
WEB_Action_Name action
)=
menu_item(text, no_icon, [], [], action, [], same, [])
.
public define Menu_Item
menu_item
(
String text,
Icon icon,
WEB_Action_Name action
)=
menu_item(text, icon, [], [], action, [], same, [])
.
public define Menu_Item
menu_item
(
String text,
WEB_Action_Name action,
List(Menu_Item) sub_menu
)=
menu_item(text, no_icon, [], [], action, [], same, sub_menu)
.
public define Menu_Item
menu_item
(
String text,
Icon icon,
WEB_Action_Name action,
List(Menu_Item) sub_menu
)=
menu_item(text, icon, [], [], action, [], same, sub_menu)
.
//public define Nav_Menu_Entry
// nav_menu_entry
// (
// String entry_id, //it's also use as icon prefix
// WEB_Action_Name action, //action (url to apply when click
// String text, //text to show
// List((String, String)) extra //extra web arguments to send when click
// )=
// left_menu_entry(entry_id, [], action, text, extra)
// .
//public define Menu_Item
// menu_title
// (
// String text
// )=
// menu_title(text, [], []).
//
//public define Menu_Item
// menu_title
// (
// String text,
// List(String) title_ids,
// )=
// menu_title(text, title_ids, []).
define List(HTML_Off_Form)
generate_menu
(
(String) -> String _T, //translator function
List(Menu_Item) items,
List(HTML_Off_Form) so_far,
Int level
)=
if items is
{
[] then reverse(so_far), //reverse to be in the right direction
[_item . t] then
if _item is
{
//menu_item then generate_hk_menu(_T, t, so_far, level),
//li
menu_item(_text, _icon, _ids, _classes, _action, _extra, _target, _sub_menu) then
with classes = join(" ",[(if level = 0 then "maintab" else ""),
(if is_empty(_sub_menu) then "" else "has_submenu") .
_classes]),
with current_li = (HTML_Off_Form)li( [class(classes)],
//if _icon = "" then [] else [class(_icon+"_icon")],
sequence([actioner(same, _target,
html(if level = 0 then [class("title")] else [],
sequence([
//format the icon if need
to_HTML(_icon),
//format the text if need
if _text = "" then empty else span(_T(_text)), /*link(help_string(_text, _T))*/
//span(1),
])),
_action,_extra
),
if is_empty(_sub_menu) then
empty
else
(HTML_Off_Form)ul([class("submenu")], sequence(generate_menu(_T, _sub_menu, [], level+1)))
])),
generate_menu(_T, t, [current_li . so_far], level),
// menu_title(text, _ids, _classes) then
menu_item_content(_content) then
// with current_li = (HTML_Off_Form)li([class("item "+_class+"_icon")],actioner(same,same, link(_T(_text)),_action,_extra)),
with current_li = (HTML_Off_Form)li([],partial(_content)),
generate_menu(_T, t, [current_li . so_far], level),
menu_separator then
with current_li = (HTML_Off_Form)li([],text("--- SEPARATOR ---")),
generate_menu(_T, t, [current_li . so_far], level)
}
}
.
// //ul
//
// hk_menu_list(_class, _action, _text, _extra, _entries) then
// with current_li =
// (HTML_Off_Form)li([class(_class+"_icon")],
// sequence([
//// actioner(same,same, link(_T(_text)),_action,_extra),
// actioner(same,same, link(help_string(_text, _T)),_action,_extra),
// text([class(if level = 0 then "dropBottom" else "dropRight")], ""),
// (HTML_Off_Form)ul([], sequence(generate_hk_menu(_T, _entries, [], level+1)))])),
// generate_hk_menu(_T, t, [current_li . so_far], level)
//
// }
// }.
define List(HTML_Off_Form)
make_menu
(
(String) -> String _T, //translator function
List(Menu_Item) menu_items,
String direction
)=
[literal("<nav id=\"nav-"+direction+"\" role=\"navigation\">")] +
[ul([class("menu")], sequence(generate_menu(_T, menu_items, [], 0)))] +
[literal(" <span class=\"menu-collapse\"><i class=\"fa fa-step-backward\" aria-hidden=\"true\"></i></span>"),
literal("</nav>")].
public define HTML_Partial_Content
make_menu
(
(String) -> String _T, //translator function
Menu _menu,
String _direction
)=
if _menu is
{
no_menu then partial_content(empty),
menu(items) then
partial_content([css(css_file("/css/cxm/cxm_menu.css"))],
//partial_content([css(css_file("/css/admin_theme.css"))],
sequence(make_menu(_T, items, _direction)))
}.