From e973169f822a3f58f460289b896e68341e1b80c3 Mon Sep 17 00:00:00 2001 From: Verneuil Julien Date: Sun, 21 Jun 2015 16:44:53 +0200 Subject: [PATCH] add img_button_confirm function which return the raw html of the button with associated inline script as a string --- web/widgets/button.anubis | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 84 insertions(+), 10 deletions(-) diff --git a/web/widgets/button.anubis b/web/widgets/button.anubis index f78c30e..da894a2 100644 --- a/web/widgets/button.anubis +++ b/web/widgets/button.anubis @@ -60,7 +60,33 @@ public define HTML_Partial_Content List((String, String)) extra_ops )= img_button(img_path, same, url, extra_ops). - + +define inline String + img_button_confirm_js + ( + String uid, + String dlg_title, + String dlg_text, + String dlg_ok, + String dlg_cancel + ) = + "CalexiumToolBox.data.confirm_dialog[" + to_js_string(uid) + "] = " + + "{ title: " + to_js_string(dlg_title) + + ", text: " + to_js_string(dlg_text) + + ", ok : " + to_js_string(dlg_ok) + + ", cancel: " + to_js_string(dlg_cancel) + + "};". + +define List(CoreAttrs) + img_button_confirm_image_attrs + ( + List(CoreAttrs) core_attrs, + String uid, + String url, + List((String, String)) extra_ops + ) = + core_attrs + [id(uid), style("cursor: pointer"), event(onclick, "CalexiumToolBox.make_confirm_dialog(this, " + to_js_string("/?a=" + url + format_extra_operands(extra_ops))+");")]. + public define HTML_Partial_Content img_button_confirm ( @@ -75,15 +101,8 @@ public define HTML_Partial_Content )= with uid = generate_random_string(20), - js_confirm_dialog_data_obj = "CalexiumToolBox.data.confirm_dialog[" + to_js_string(uid) + "]", - js_data = js_confirm_dialog_data_obj + " = { - title: " + to_js_string(dlg_title) + ", - text: " + to_js_string(dlg_text) + ", - ok : " + to_js_string(dlg_ok) + ", - cancel: " + to_js_string(dlg_cancel) + "};", - - partial_content([js(js_file("js/cxm/cxm.js")), js_inline(jquery_ready(js_data))], - image(core_attrs + [id(uid), style("cursor: pointer"), event(onclick, "CalexiumToolBox.make_confirm_dialog(this, " + to_js_string("/?a=" + url + format_extra_operands(extra_ops))+");")], img_path, "")). + partial_content([js(js_file("js/cxm/cxm.js")), js_inline(jquery_ready(img_button_confirm_js(uid, dlg_title, dlg_text, dlg_ok, dlg_cancel)))], + image(img_button_confirm_image_attrs(core_attrs, uid, url, extra_ops), img_path, "")). public define HTML_Partial_Content img_button_confirm @@ -122,4 +141,59 @@ public define HTML_Partial_Content List((String, String)) extra_ops )= img_button_confirm(img_path, [], dlg_title, dlg_text, dlg_ok, dlg_cancel, url, extra_ops). + +public define String + img_button_confirm + ( + String img_path, + List(CoreAttrs) core_attrs, + String dlg_title, + String dlg_text, + String dlg_ok, + String dlg_cancel, + String url, + List((String, String)) extra_ops + ) = + with uid = generate_random_string(20), + + "" + + "". + +public define String + img_button_confirm + ( + String img_path, + String dlg_title, + String dlg_text, + String dlg_ok, + String dlg_cancel, + String url + )= + img_button_confirm(img_path, [], dlg_title, dlg_text, dlg_ok, dlg_cancel, url, []). +public define String + img_button_confirm + ( + String img_path, + List(CoreAttrs) core_attrs, + String dlg_title, + String dlg_text, + String dlg_ok, + String dlg_cancel, + String url + )= + img_button_confirm(img_path, core_attrs, dlg_title, dlg_text, dlg_ok, dlg_cancel, url, []). + +public define String + img_button_confirm + ( + String img_path, + String dlg_title, + String dlg_text, + String dlg_ok, + String dlg_cancel, + String url, + List((String, String)) extra_ops + )= + img_button_confirm(img_path, [], dlg_title, dlg_text, dlg_ok, dlg_cancel, url, extra_ops). + -- libgit2 0.21.4