Commit 0a3b5fb134307526981ed6818f36f2cf69f402c1

Authored by David RENÉ
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
web/widgets/left_menu.anubis
@@ -20,6 +20,14 @@ public type Left_Menu_Entry: @@ -20,6 +20,14 @@ public type Left_Menu_Entry:
20 List((String, String)) extra, //extra web arguments to send when click 20 List((String, String)) extra, //extra web arguments to send when click
21 Maybe(String) target_id //target_id use during load_content 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 title( //TITLE entry hence no selectable 31 title( //TITLE entry hence no selectable
24 String title_id, //it's also use as icon prefix 32 String title_id, //it's also use as icon prefix
25 Bool subtitle, 33 Bool subtitle,
@@ -298,3 +306,47 @@ public define Left_Menu_Entry @@ -298,3 +306,47 @@ public define Left_Menu_Entry
298 )= 306 )=
299 title(title_id, true, [], text) 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,6 +36,11 @@ define List(HTML_Off_Form)
36 event(onclick, load_content(target_id, _action, _extra))],text(_T(_text))), 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 title(_title_id, subtitle, _classes, _text) then 44 title(_title_id, subtitle, _classes, _text) then
40 p([class(if subtitle then "menu_subtitle" else "menu_title"), class((if _title_id=selected then " selected" else "")+ " "+join(" ", _classes))], text([],_T(_text))) 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 // p([class("menu_title"), class("item "+_title_id+"_icon"+if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text))) 46 // p([class("menu_title"), class("item "+_title_id+"_icon"+if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text)))