From 0555931cf45f083fa29cd976aadf081a4f3c1d78 Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 12 Dec 2021 01:04:39 +0100 Subject: [PATCH] add the managment of the overlay in load_content and change the code accordingly. in same time add a new alternative into left_menu type with "left_menu_entry_load_content". This is better to understand when constructing a menu --- web/jquery.anubis | 6 +++--- web/load_content.anubis | 40 +++++++++++++++++++++++++++------------- web/widgets/button.anubis | 11 ++++++----- web/widgets/left_menu.anubis | 46 ++++++++++++++++++++++++++++------------------ web/widgets/left_menu_html.anubis | 16 ++++++++-------- 5 files changed, 72 insertions(+), 47 deletions(-) diff --git a/web/jquery.anubis b/web/jquery.anubis index 1dcd483..9faa6e3 100644 --- a/web/jquery.anubis +++ b/web/jquery.anubis @@ -103,7 +103,7 @@ public define String } jqflink(link) then "document.location='"+link+"';", jqscript(script) then script - jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false) + jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false, true) }, same(label) then if act_type is @@ -132,7 +132,7 @@ public define String } jqflink(link) then "document.location='"+link+"';", jqscript(script) then script - jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false) + jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false, true) }, other(window_name, window_options) then if act_type is @@ -164,7 +164,7 @@ public define String } jqflink(link) then "document.location='"+link+"';", jqscript(script) then script - jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false) + jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false, true) } }. diff --git a/web/load_content.anubis b/web/load_content.anubis index 381982d..9f1c59c 100644 --- a/web/load_content.anubis +++ b/web/load_content.anubis @@ -45,10 +45,11 @@ public define String String target, WEB_Action_Name web_action, List((String,String)) extra_args, - Bool replace + Bool replace, + Bool overlay )= - "Xlib.load_content('"+target+"', '"+format_web_action_name(web_action, extra_args)+"', "+to_String(replace)+");" + "Xlib.load_content('"+target+"', '"+format_web_action_name(web_action, extra_args)+"', "+to_String(replace)+", "+to_String(replace)+");" . public define String @@ -57,9 +58,10 @@ public define String String target, WEB_Action_Name web_action, List((String,String)) extra_args, - Bool replace + Bool replace, + Bool overlay )= - to_JS_String("Xlib.load_content('"+target+"', "+format_web_action_name_to_js(web_action, extra_args)+", "+to_String(replace)+")") + to_JS_String("Xlib.load_content('"+target+"', "+format_web_action_name_to_js(web_action, extra_args)+", "+to_String(replace)+", "+to_String(replace)+")") . public define String @@ -69,7 +71,7 @@ public define String WEB_Action_Name web_action, List((String,String)) extra_args )= - load_content(target, web_action, extra_args, true) + load_content(target, web_action, extra_args, true, true) . public define String @@ -79,7 +81,7 @@ public define String WEB_Action_Name web_action, (String, String) extra_arg )= - load_content(target, web_action, [extra_arg], true) + load_content(target, web_action, [extra_arg], true, true) . public define String @@ -88,7 +90,7 @@ public define String String target, WEB_Action_Name web_action )= - load_content(target, web_action, [], true) + load_content(target, web_action, [], true, true) . @@ -99,7 +101,7 @@ public define String WEB_Action_Name web_action, Bool replace )= - load_content(target, web_action, [], replace) + load_content(target, web_action, [], replace, true) . public define HTML_Partial_Content @@ -108,11 +110,12 @@ public define HTML_Partial_Content String target, WEB_Action_Name web_action, List((String,String)) extra_args, - Bool replace + Bool replace, + Bool overlay )= partial_content([ js(js_file("xlib/js/xlib.js")), - js_inline(script("text/javascript","$(document).ready(function(){"+load_content(target, web_action, extra_args, replace)+"});")) + js_inline(script("text/javascript","$(document).ready(function(){"+load_content(target, web_action, extra_args, replace, overlay)+"});")) ], empty) . @@ -122,9 +125,20 @@ public define HTML_Partial_Content ( String target, WEB_Action_Name web_action, + List((String,String)) extra_args, + Bool replace + )= + load_content_init(target, web_action, extra_args, replace, true) +. + +public define HTML_Partial_Content + load_content_init + ( + String target, + WEB_Action_Name web_action, List((String,String)) extra_args )= - load_content_init(target, web_action, extra_args, false) + load_content_init(target, web_action, extra_args, false, true) . public define HTML_Partial_Content @@ -133,7 +147,7 @@ public define HTML_Partial_Content String target, WEB_Action_Name web_action )= - load_content_init(target, web_action, [], false) + load_content_init(target, web_action, [], false, true) . public define HTML_Partial_Content @@ -143,5 +157,5 @@ public define HTML_Partial_Content WEB_Action_Name web_action, Bool replace )= - load_content_init(target, web_action, [], replace) + load_content_init(target, web_action, [], replace, true) . diff --git a/web/widgets/button.anubis b/web/widgets/button.anubis index 9fa8aeb..be1bfae 100644 --- a/web/widgets/button.anubis +++ b/web/widgets/button.anubis @@ -140,10 +140,11 @@ public define HTML_Partial_Content WEB_Action_Name web_action, List((String, String)) extra_args, String target, - Bool replace + Bool replace, + Bool overlay )= partial_content( - img([ event(onclick, load_content(target, web_action, extra_args, replace)), + img([ event(onclick, load_content(target, web_action, extra_args, replace, overlay)), style("cursor: pointer") . core_attrs ], img_path)) . @@ -157,7 +158,7 @@ public define HTML_Partial_Content String target, Bool replace )= - img_button(img_path, [], web_action, extra_args, target, replace) + img_button(img_path, [], web_action, extra_args, target, replace, true) . public define HTML_Partial_Content @@ -168,7 +169,7 @@ public define HTML_Partial_Content List((String, String)) extra_args, String target )= - img_button(img_path, [], web_action, extra_args, target, false) + img_button(img_path, [], web_action, extra_args, target, false, true) . public define HTML_Partial_Content @@ -255,7 +256,7 @@ define List(CoreAttrs) with ok_action = if load_content_target = "" then to_JS_String("Xlib.jq_query("+format_web_action_name_to_js(web_action, extra_ops)+")") else - load_content_JS_String(load_content_target, web_action, extra_ops, true), + load_content_JS_String(load_content_target, web_action, extra_ops, true, true), //to_JS_String("Xlib.load_content('"++"', "+format_web_action_name_to_js(web_action, extra_ops)+", true)"), core_attrs + [id(uid), style("cursor: pointer"), event(onclick, "Xlib.make_confirm_dialog(this, "+ ok_action +");")]. diff --git a/web/widgets/left_menu.anubis b/web/widgets/left_menu.anubis index 29eb90d..002aa7f 100644 --- a/web/widgets/left_menu.anubis +++ b/web/widgets/left_menu.anubis @@ -17,8 +17,7 @@ public type Left_Menu_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 - List((String, String)) extra, //extra web arguments to send when click - Maybe(String) target_id //target_id use during load_content + List((String, String)) extra //extra web arguments to send when click ), left_menu_entry_js( //MENU entry with call to js String entry_id, //it's also use as icon prefix @@ -27,6 +26,17 @@ public type Left_Menu_Entry: String js_call, //javascript to call on click event String text //text to show ), + left_menu_entry_load_content( //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 + List((String, String)) extra, //extra web arguments to send when click + String target_id //target_id use during load_content + Bool replace, + Bool overlay + ), title( //TITLE entry hence no selectable String title_id, //it's also use as icon prefix @@ -150,7 +160,7 @@ public define Left_Menu_Entry WEB_Action_Name action, String text )= - left_menu_entry(entry_id, false, [], action, text, [], failure) + left_menu_entry(entry_id, false, [], action, text, []) . public define Left_Menu_Entry @@ -160,7 +170,7 @@ public define Left_Menu_Entry WEB_Action_Name action, String text )= - left_menu_entry(entry_id, true, [], action, text, [], failure) + left_menu_entry(entry_id, true, [], action, text, []) . public define Left_Menu_Entry @@ -170,7 +180,7 @@ public define Left_Menu_Entry String action, String text )= - left_menu_entry(entry_id, false, [], action_name(action), text, [], failure) + left_menu_entry(entry_id, false, [], action_name(action), text, []) . public define Left_Menu_Entry @@ -180,7 +190,7 @@ public define Left_Menu_Entry String action, String text )= - left_menu_entry(entry_id, true, [], action_name(action), text, [], failure) + left_menu_entry(entry_id, true, [], action_name(action), text, []) . public define Left_Menu_Entry @@ -191,7 +201,7 @@ 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, false, [], action, text, extra, failure) + left_menu_entry(entry_id, false, [], action, text, extra) . public define Left_Menu_Entry @@ -202,11 +212,11 @@ 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, true, [], action, text, extra, failure) + left_menu_entry(entry_id, true, [], action, text, extra) . public define Left_Menu_Entry - left_menu_entry + left_menu_entry_load_content ( String entry_id, //it's also use as icon prefix WEB_Action_Name action, //action (url to apply when click @@ -214,11 +224,11 @@ public define Left_Menu_Entry List((String, String)) extra, //extra web arguments to send when click String target_id )= - left_menu_entry(entry_id, false, [], action, text, extra, success(target_id)) + left_menu_entry_load_content(entry_id, false, [], action, text, extra, target_id, false, true) . public define Left_Menu_Entry - left_menu_sub_entry + left_menu_sub_entry_load_content ( String entry_id, //it's also use as icon prefix WEB_Action_Name action, //action (url to apply when click @@ -226,7 +236,7 @@ public define Left_Menu_Entry 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)) + left_menu_entry_load_content(entry_id, true, [], action, text, extra, target_id, false, true) . public define Left_Menu_Entry @@ -237,7 +247,7 @@ 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, false, [], action_name(action), text, extra, failure) + left_menu_entry(entry_id, false, [], action_name(action), text, extra) . public define Left_Menu_Entry @@ -248,11 +258,11 @@ 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, true, [], action_name(action), text, extra, failure) + left_menu_entry(entry_id, true, [], action_name(action), text, extra) . public define Left_Menu_Entry - left_menu_entry + left_menu_entry_load_content ( String entry_id, //it's also use as icon prefix String action, //action (url to apply when click @@ -260,11 +270,11 @@ public define Left_Menu_Entry List((String, String)) extra, //extra web arguments to send when click String target_id )= - left_menu_entry(entry_id, false, [], action_name(action), text, extra, success(target_id)) + left_menu_entry_load_content(entry_id, false, [], action_name(action), text, extra, target_id, false, true) . public define Left_Menu_Entry - left_menu_sub_entry + left_menu_sub_entry_load_content ( String entry_id, //it's also use as icon prefix String action, //action (url to apply when click @@ -272,7 +282,7 @@ public define Left_Menu_Entry 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)) + left_menu_entry_load_content(entry_id, true, [], action_name(action), text, extra, target_id, false, true) . public define Left_Menu_Entry diff --git a/web/widgets/left_menu_html.anubis b/web/widgets/left_menu_html.anubis index 11d8c4f..bb55a20 100644 --- a/web/widgets/left_menu_html.anubis +++ b/web/widgets/left_menu_html.anubis @@ -26,21 +26,21 @@ define List(HTML_Off_Form) with entry = if h is { - left_menu_entry(_menu_id, subentry, _classes, _action, _text, _extra, _target_id) then + left_menu_entry(_menu_id, subentry, _classes, _action, _text, _extra) then with item_class = if subentry then "subitem " else "item ", - if _target_id is - { - 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_class+"clickable "+_menu_id+"_icon"+(if _menu_id=selected then " selected" else "")+ " "+join(" ", _classes)), - event(onclick, load_content(target_id, _action, _extra))],text(_T(_text))), - } + + p([class(item_class+_menu_id+"_icon"+(if _menu_id=selected then " selected" else "")+ " "+join(" ", _classes))],actioner(same,same, link(_T(_text)),_action,_extra)), left_menu_entry_js(_menu_id, subentry, _classes, _js_to_call, _text) then with item_class = if subentry then "subitem " else "item ", p([class(item_class+"clickable "+_menu_id+"_icon"+(if _menu_id=selected then " selected" else "")+ " "+join(" ", _classes)), event(onclick, _js_to_call)],text(_T(_text))), + left_menu_entry_load_content(_menu_id, subentry, _classes, _action, _text, _extra, _target_id, _replace, _overlay) then + with item_class = if subentry then "subitem " else "item ", + p([class(item_class+"clickable "+_menu_id+"_icon"+(if _menu_id=selected then " selected" else "")+ " "+join(" ", _classes)), + event(onclick, load_content(_target_id, _action, _extra, _replace, _overlay))],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))) -- libgit2 0.21.4