From be009662c44d661d41e2addf7bbc8286951daed9 Mon Sep 17 00:00:00 2001 From: yekolia Date: Wed, 12 Sep 2012 09:31:23 +0000 Subject: [PATCH] Modification: support actioner on jquery_button => JQuery_Actioner --- web/CXM_jquery.anubis | 12 ++++++++++++ web/CXM_jquery_button.anubis | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------ 2 files changed, 135 insertions(+), 24 deletions(-) diff --git a/web/CXM_jquery.anubis b/web/CXM_jquery.anubis index 47b5491..49cebd9 100644 --- a/web/CXM_jquery.anubis +++ b/web/CXM_jquery.anubis @@ -11,6 +11,18 @@ read calexium_lib/web/CXM_making_a_web_site.anubis read tools/printable_tree.anubis read tools/basis.anubis +/* jQuery Actioner type */ +public type JQuery_Actioner_type: + jqform, + jqlink +. + +/* jQuery Actioner */ +public type JQuery_Actioner: + jQuery_actioner(Actioner_Target target, JQuery_Actioner_type type, String url_or_form_id) +. + + /* jQuery default js files */ define List(HTML_Head_Tag) jquery_defaults diff --git a/web/CXM_jquery_button.anubis b/web/CXM_jquery_button.anubis index bcc777b..e77adcc 100644 --- a/web/CXM_jquery_button.anubis +++ b/web/CXM_jquery_button.anubis @@ -8,6 +8,7 @@ */ read calexium_lib/web/CXM_making_a_web_site.anubis +read calexium_lib/web/CXM_jquery.anubis read calexium_lib/web/CXM_jquery_icons.anubis read tools/basis.anubis read system/string.anubis @@ -15,10 +16,102 @@ read system/string.anubis public type JQuery_button: jQuery_button( - String button_id, String button_name, String button_label, JQuery_icon primary, JQuery_icon secondary // primary icon is for left icon, secondary icon is for right icon and button_id must set with an unique ID in order to have icons working + String button_id, String button_name, String button_label, JQuery_Actioner actioner, JQuery_icon primary, JQuery_icon secondary // primary icon is for left icon, secondary icon is for right icon and button_id must set with an unique ID in order to have icons working ) . +define String + jquery_button_get_onclick_action_window_options + ( + List(Other_Window_Option) options, + String formated_options + ) + = + if options is + { + [ ] then formated_options, + [ h . t ] then + if h is + { + resizable then + if formated_options="" then // si c'est vide on ne prefixe pas avec une virgule + jquery_button_get_onclick_action_window_options( + t, + formated_options+"resizable='yes'" + ) + else + jquery_button_get_onclick_action_window_options( + t, + formated_options+", resizable='yes'" + ), + scrollbars then + if formated_options="" then // si c'est vide on ne prefixe pas avec une virgule + jquery_button_get_onclick_action_window_options( + t, + formated_options+"scrollbars='yes'" + ) + else + jquery_button_get_onclick_action_window_options( + t, + formated_options+", scrollbars='yes'" + ), + width(w) then + if formated_options="" then // si c'est vide on ne prefixe pas avec une virgule + jquery_button_get_onclick_action_window_options( + t, + formated_options+"width="+w + ) + else + jquery_button_get_onclick_action_window_options( + t, + formated_options+", width="+w + ), + height(h) then + if formated_options="" then // si c'est vide on ne prefixe pas avec une virgule + jquery_button_get_onclick_action_window_options( + t, + formated_options+"height="+h + ) + else + jquery_button_get_onclick_action_window_options( + t, + formated_options+", height="+h + ) + } + } + . + +define HTML_Head_Tag + jquery_button_get_onclick_action + ( + String button_id, + JQuery_Actioner actioner + ) + = + if actioner is jQuery_actioner(target, act_type, str) then + if target is + { + same then + if act_type is + { + jqform then js_inline(script("", "$(document).ready(function(){$('#"+button_id+"').click(function(){$('#"+str+"').submit();});});")), + jqlink then js_inline(script("", "$(document).ready(function(){$('#"+button_id+"').click(function(){document.location='"+str+"';});});")), + }, + same(label) then + if act_type is + { + jqform then js_inline(script("", "$(document).ready(function(){$('#"+button_id+"').click(function(){$('#"+str+"').submit();});});")), + jqlink then js_inline(script("", "$(document).ready(function(){$('#"+button_id+"').click(function(){document.location='"+str+"';});});")), + }, + other(window_name, window_options) then + if act_type is + { + jqform then js_inline(script("", "$(document).ready(function(){$('#"+button_id+"').click(function(){$('#"+str+"').submit();});});")), //il s'agit d'une soumision d'un formulaire => cela se fait uniquement dans la même fenêtre ! + jqlink then js_inline(script("", "$(document).ready(function(){$('#"+button_id+"').click(function(){window.open('"+str+"', '"+window_name+"', '"+jquery_button_get_onclick_action_window_options(window_options, "")+"');});});")), + } + } + . + define HTML_Partial_Content _jquery_buttons ( @@ -35,11 +128,12 @@ define HTML_Partial_Content sequence(reverse(html_buttons)) ), [ h . t ] then - if h is jQuery_button(id, name, label, primary, secondary) then + if h is jQuery_button(id, name, label, actioner, primary, secondary) then + with onclick_action=jquery_button_get_onclick_action(id, actioner), if id = "" then // if the ID is not set => we can't use icons in the buttonset. _jquery_buttons( t, - html_tags, + [ onclick_action . html_tags ], [ literal("") . @@ -52,10 +146,10 @@ define HTML_Partial_Content _jquery_buttons( t, [ - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button();});")) - . - html_tags - ], + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button();});")), + onclick_action + ] + +html_tags, [ literal("") . @@ -66,10 +160,10 @@ define HTML_Partial_Content _jquery_buttons( t, [ - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});});")) - . - html_tags - ], + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});});")), + onclick_action + ] + +html_tags, [ literal("") . @@ -81,10 +175,10 @@ define HTML_Partial_Content _jquery_buttons( t, [ - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"'}});});")) - . - html_tags - ], + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"'}});});")), + onclick_action + ] + +html_tags, [ literal("") . @@ -95,10 +189,10 @@ define HTML_Partial_Content _jquery_buttons( t, [ - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"',secondary:'"+jquery_icon_to_string(secondary)+"'}});});")) - . - html_tags - ], + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"',secondary:'"+jquery_icon_to_string(secondary)+"'}});});")), + onclick_action + ] + +html_tags, [ literal("") . @@ -132,19 +226,22 @@ public define HTML_Partial_Content JQuery_button button ) = - if button is jQuery_button(id, name, label, primary, secondary) then + if button is jQuery_button(id, name, label, actioner, primary, secondary) then + with onclick_action=jquery_button_get_onclick_action(id, actioner), if jquery_icon_to_string(primary) = "" then if jquery_icon_to_string(secondary) = "" then partial_content( [ - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button();});")) + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button();});")), + onclick_action ], literal("") ) else partial_content( [ - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});});")) + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});});")), + onclick_action ], literal("") ) @@ -152,14 +249,16 @@ public define HTML_Partial_Content if jquery_icon_to_string(secondary) = "" then partial_content( [ - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"'}});});")) + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"'}});});")), + onclick_action ], literal("") ) else partial_content( [ - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"',secondary:'"+jquery_icon_to_string(secondary)+"'}});});")) + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"',secondary:'"+jquery_icon_to_string(secondary)+"'}});});")), + onclick_action ], literal("") ) -- libgit2 0.21.4