From 6ee7fd04d8974910855b31cf3d210a73896c6a32 Mon Sep 17 00:00:00 2001 From: totoro Date: Tue, 17 Mar 2020 14:08:34 +0900 Subject: [PATCH] add sub_entry and subtitle in left menu entry --- web/widgets/left_menu.anubis | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------ web/widgets/left_menu_html.anubis | 11 ++++++----- 2 files changed, 102 insertions(+), 17 deletions(-) diff --git a/web/widgets/left_menu.anubis b/web/widgets/left_menu.anubis index ba6f2bd..b4ad13d 100644 --- a/web/widgets/left_menu.anubis +++ b/web/widgets/left_menu.anubis @@ -14,6 +14,7 @@ read system/string.anubis public type Left_Menu_Entry: left_menu_entry( //MENU entry hence no selectable String entry_id, //it's also use as icon prefix + Bool sub_entry, List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) WEB_Action_Name action, //action (url to apply when click String text, //text to show @@ -22,6 +23,7 @@ public type Left_Menu_Entry: ), title( //TITLE entry hence no selectable String title_id, //it's also use as icon prefix + Bool subtitle, List(String) classes, //additional classes if need (change background color, font size, etc.) String text //text to show ) @@ -141,9 +143,19 @@ public define Left_Menu_Entry WEB_Action_Name action, String text )= - left_menu_entry(entry_id, [], action, text, [], failure) + left_menu_entry(entry_id, false, [], action, text, [], failure) . - + +public define Left_Menu_Entry + left_menu_sub_entry + ( + String entry_id, + WEB_Action_Name action, + String text + )= + left_menu_entry(entry_id, true, [], action, text, [], failure) +. + public define Left_Menu_Entry left_menu_entry ( @@ -151,9 +163,19 @@ public define Left_Menu_Entry String action, String text )= - left_menu_entry(entry_id, [], action_name(action), text, [], failure) + left_menu_entry(entry_id, false, [], action_name(action), text, [], failure) . - + +public define Left_Menu_Entry + left_menu_sub_entry + ( + String entry_id, + String action, + String text + )= + left_menu_entry(entry_id, true, [], action_name(action), text, [], failure) +. + public define Left_Menu_Entry left_menu_entry ( @@ -162,7 +184,18 @@ public define Left_Menu_Entry String text, //text to show List((String, String)) extra //extra web arguments to send when click )= - left_menu_entry(entry_id, [], action, text, extra, failure) + left_menu_entry(entry_id, false, [], action, text, extra, failure) +. + +public define Left_Menu_Entry + left_menu_sub_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, true, [], action, text, extra, failure) . public define Left_Menu_Entry @@ -174,9 +207,21 @@ public define Left_Menu_Entry List((String, String)) extra, //extra web arguments to send when click String target_id )= - left_menu_entry(entry_id, [], action, text, extra, success(target_id)) + left_menu_entry(entry_id, false, [], action, text, extra, success(target_id)) . - + +public define Left_Menu_Entry + left_menu_sub_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 + String target_id + )= + left_menu_entry(entry_id, true, [], action, text, extra, success(target_id)) +. + public define Left_Menu_Entry left_menu_entry ( @@ -185,7 +230,18 @@ public define Left_Menu_Entry String text, //text to show List((String, String)) extra //extra web arguments to send when click )= - left_menu_entry(entry_id, [], action_name(action), text, extra, failure) + left_menu_entry(entry_id, false, [], action_name(action), text, extra, failure) +. + +public define Left_Menu_Entry + left_menu_sub_entry + ( + String entry_id, //it's also use as icon prefix + String 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, true, [], action_name(action), text, extra, failure) . public define Left_Menu_Entry @@ -197,15 +253,34 @@ public define Left_Menu_Entry List((String, String)) extra, //extra web arguments to send when click String target_id )= - left_menu_entry(entry_id, [], action_name(action), text, extra, success(target_id)) + left_menu_entry(entry_id, false, [], action_name(action), text, extra, success(target_id)) . - + +public define Left_Menu_Entry + left_menu_sub_entry + ( + String entry_id, //it's also use as icon prefix + String action, //action (url to apply when click + String text, //text to show + List((String, String)) extra, //extra web arguments to send when click + String target_id + )= + left_menu_entry(entry_id, true, [], action_name(action), text, extra, success(target_id)) +. + public define Left_Menu_Entry title ( String text )= - title("", [], text). + title("", false, [], text). + +public define Left_Menu_Entry + subtitle + ( + String text + )= + title("", true, [], text). public define Left_Menu_Entry title @@ -213,5 +288,14 @@ public define Left_Menu_Entry String title_id, String text )= - title(title_id, [], text). + title(title_id, false, [], text) +. +public define Left_Menu_Entry + subtitle + ( + String title_id, + String text + )= + title(title_id, true, [], text) +. diff --git a/web/widgets/left_menu_html.anubis b/web/widgets/left_menu_html.anubis index 71bf919..6398261 100644 --- a/web/widgets/left_menu_html.anubis +++ b/web/widgets/left_menu_html.anubis @@ -26,18 +26,19 @@ define List(HTML_Off_Form) with entry = if h is { - left_menu_entry(_menu_id, _classes, _action, _text, _extra, _target_id) then + left_menu_entry(_menu_id, subentry, _classes, _action, _text, _extra, _target_id) then + with item_class = if subentry then "subitem " else "item ", if _target_id is { - failure then p([class("item "+_menu_id+"_icon"+if _menu_id=selected then " selected" else ""+ " "+join(" ", _classes))],actioner(same,same, link(_T(_text)),_action,_extra)), + failure then p([class(item_class+_menu_id+"_icon"+if _menu_id=selected then " selected" else ""+ " "+join(" ", _classes))],actioner(same,same, link(_T(_text)),_action,_extra)), success(target_id) then - p([class("item "+_menu_id+"_icon"+if _menu_id=selected then " selected" else ""+ " "+join(" ", _classes)), + p([class(item_class+"clickable "+_menu_id+"_icon"+if _menu_id=selected then " selected" else ""+ " "+join(" ", _classes)), // event(onclick, "CalexiumToolBox.ajax_load_content('"+target_id+"', "+format_web_action_name_to_js(_action, _extra)+")")],text(_T(_text))), event(onclick, load_content(target_id, _action, _extra))],text(_T(_text))), } - title(_title_id, _classes, _text) then - p([class("menu_title"), class(if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text))) + title(_title_id, subtitle, _classes, _text) then + p([class(if subtitle then "menu_subtitle" else "menu_title"), class(if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text))) // p([class("menu_title"), class("item "+_title_id+"_icon"+if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text))) }, make_left_menu(_T, t, selected, [ entry . so_far]) -- libgit2 0.21.4