/* * Created by PyramIDE. * User: Jeremy * Date: 07/09/2012 * Time: 15:10 * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ read calexium_lib/web/CXM_making_a_web_site.anubis read calexium_lib/web/CXM_jquery.anubis read calexium_lib/web/jQuery/CXM_jquery_icons.anubis read tools/basis.anubis read system/string.anubis public type JQuery_button: jQuery_button( 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 ( List(JQuery_button) buttons, List(HTML_Head_Tag) html_tags, List(HTML_Off_Form) html_buttons ) = if buttons is { [ ] then partial_content( reverse(html_tags), sequence(reverse(html_buttons)) ), [ h . t ] 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, [ onclick_action . html_tags ], [ literal("") . html_buttons ] ) else if jquery_icon_to_string(primary) = "" then if jquery_icon_to_string(secondary) = "" then _jquery_buttons( t, [ js_inline(script("", "$(document).ready(function(){$('#"+id+"').button();});")), onclick_action ] +html_tags, [ literal("") . html_buttons ] ) else _jquery_buttons( t, [ js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});});")), onclick_action ] +html_tags, [ literal("") . html_buttons ] ) else if jquery_icon_to_string(secondary) = "" then _jquery_buttons( t, [ js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"'}});});")), onclick_action ] +html_tags, [ literal("") . html_buttons ] ) else _jquery_buttons( t, [ 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("") . html_buttons ] ) } . public define HTML_Partial_Content jquery_buttons ( String buttons_container_id, List(JQuery_button) buttons ) = if _jquery_buttons(buttons, [], []) is partial_content(tags, html) then partial_content( [ js_inline(script("", "$(document).ready(function(){$('#"+buttons_container_id+"').buttonset();});")) ] + tags, sequence([ literal("
") ]) ) . public define HTML_Partial_Content jquery_button ( JQuery_button button ) = 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();});")), onclick_action ], literal("") ) else partial_content( [ js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});});")), onclick_action ], literal("") ) else if jquery_icon_to_string(secondary) = "" then partial_content( [ 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)+"'}});});")), onclick_action ], literal("") ) .