Commit 0a3b5fb134307526981ed6818f36f2cf69f402c1
1 parent
2549d33e
[+] add left_menu_entry_js to call javascript when a click event occur on menu e…
…ntry. Add also variant function as helper without all the arguments
Showing
2 changed files
with
57 additions
and
0 deletions
Show diff stats
web/widgets/left_menu.anubis
| ... | ... | @@ -20,6 +20,14 @@ public type Left_Menu_Entry: |
| 20 | 20 | List((String, String)) extra, //extra web arguments to send when click |
| 21 | 21 | Maybe(String) target_id //target_id use during load_content |
| 22 | 22 | ), |
| 23 | + left_menu_entry_js( //MENU entry with call to js | |
| 24 | + String entry_id, //it's also use as icon prefix | |
| 25 | + Bool sub_entry, | |
| 26 | + List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) | |
| 27 | + String js_call, //javascript to call on click event | |
| 28 | + String text //text to show | |
| 29 | + ), | |
| 30 | + | |
| 23 | 31 | title( //TITLE entry hence no selectable |
| 24 | 32 | String title_id, //it's also use as icon prefix |
| 25 | 33 | Bool subtitle, |
| ... | ... | @@ -298,3 +306,47 @@ public define Left_Menu_Entry |
| 298 | 306 | )= |
| 299 | 307 | title(title_id, true, [], text) |
| 300 | 308 | . |
| 309 | + | |
| 310 | +public define Left_Menu_Entry | |
| 311 | + left_menu_entry_js | |
| 312 | + ( | |
| 313 | + String entry_id, //it's also use as icon prefix | |
| 314 | + //Bool sub_entry, | |
| 315 | + //List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) | |
| 316 | + String js_call, //javascript to call on click event | |
| 317 | + String text //text to show | |
| 318 | + )= | |
| 319 | + left_menu_entry_js(entry_id, false, [], js_call, text). | |
| 320 | + | |
| 321 | +public define Left_Menu_Entry | |
| 322 | + left_menu_sub_entry_js | |
| 323 | + ( | |
| 324 | + String entry_id, //it's also use as icon prefix | |
| 325 | + //Bool sub_entry, | |
| 326 | + //List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) | |
| 327 | + String js_call, //javascript to call on click event | |
| 328 | + String text //text to show | |
| 329 | + )= | |
| 330 | + left_menu_entry_js(entry_id, true, [], js_call, text). | |
| 331 | + | |
| 332 | +public define Left_Menu_Entry | |
| 333 | + left_menu_entry_js | |
| 334 | + ( | |
| 335 | + String entry_id, //it's also use as icon prefix | |
| 336 | + //Bool sub_entry, | |
| 337 | + List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) | |
| 338 | + String js_call, //javascript to call on click event | |
| 339 | + String text //text to show | |
| 340 | + )= | |
| 341 | + left_menu_entry_js(entry_id, false, classes, js_call, text). | |
| 342 | + | |
| 343 | +public define Left_Menu_Entry | |
| 344 | + left_menu_sub_entry_js | |
| 345 | + ( | |
| 346 | + String entry_id, //it's also use as icon prefix | |
| 347 | + //Bool sub_entry, | |
| 348 | + List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) | |
| 349 | + String js_call, //javascript to call on click event | |
| 350 | + String text //text to show | |
| 351 | + )= | |
| 352 | + left_menu_entry_js(entry_id, true, classes, js_call, text). | ... | ... |
web/widgets/left_menu_html.anubis
| ... | ... | @@ -36,6 +36,11 @@ define List(HTML_Off_Form) |
| 36 | 36 | event(onclick, load_content(target_id, _action, _extra))],text(_T(_text))), |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | + left_menu_entry_js(_menu_id, subentry, _classes, _js_to_call, _text) then | |
| 40 | + with item_class = if subentry then "subitem " else "item ", | |
| 41 | + p([class(item_class+"clickable "+_menu_id+"_icon"+(if _menu_id=selected then " selected" else "")+ " "+join(" ", _classes)), | |
| 42 | + event(onclick, _js_to_call)],text(_T(_text))), | |
| 43 | + | |
| 39 | 44 | title(_title_id, subtitle, _classes, _text) then |
| 40 | 45 | p([class(if subtitle then "menu_subtitle" else "menu_title"), class((if _title_id=selected then " selected" else "")+ " "+join(" ", _classes))], text([],_T(_text))) |
| 41 | 46 | // p([class("menu_title"), class("item "+_title_id+"_icon"+if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text))) | ... | ... |