/* * Created by PyramIDE. * User: Jeremy * Date: 21/08/2012 * Time: 16:52 * */ 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, jqflink, jqscript. /* jQuery Actioner */ public type JQuery_Actioner: jQuery_actioner(Actioner_Target target, JQuery_Actioner_type type, String url_or_form_id_or_script). /* jQuery Selector - http://api.jquery.com/category/selectors/ */ public type JQuerySelector: element(HTML_Id id), element_class(String name), childs(HTML_Id id). define String jquery_button_get_onclick_action_window_options ( List(Other_Window_Option) options, String formated_options ) = //if there is already formated_options add a comma + space between the options with comma = if formated_options="" then "" else ", ", if options is { [ ] then formated_options, [ c . t ] then if c is { resizable then jquery_button_get_onclick_action_window_options( t, formated_options+ comma + "resizable=yes"), scrollbars then jquery_button_get_onclick_action_window_options( t, formated_options+ comma + "scrollbars=yes"), width(w) then jquery_button_get_onclick_action_window_options( t, formated_options+ comma + "width="+w), height(h) then jquery_button_get_onclick_action_window_options( t, formated_options+ comma + "height="+h) } } . public define String jquery_button_get_onclick_action ( JQuery_Actioner actioner ) = if actioner is jQuery_actioner(target, act_type, str) then if target is { same then if act_type is { jqform then "$('#"+str+"').submit();", jqlink then "document.location='/?a="+str+"';", jqflink then "document.location='"+str+"';", jqscript then str }, same(label) then if act_type is { jqform then "$('#"+str+"').submit();", jqlink then "document.location='/?a="+str+"';", jqflink then "document.location='"+str+"';", jqscript then str }, other(window_name, window_options) then if act_type is { jqform then "$('#"+str+"').submit();", //il s'agit d'une soumision d'un formulaire => cela se fait uniquement dans la même fenêtre ! jqlink then "window.open('"+str+"', '"+window_name+"', '"+jquery_button_get_onclick_action_window_options(window_options, "")+"');", jqflink then "document.location='"+str+"';", jqscript then str } }. public define String format_jquery_selector ( JQuerySelector selector ) = if selector is { element(html_id) then if html_id is html_Id(id) then "'#" + id + "'", element_class(name) then "'." + name + "'", childs(html_id) then if html_id is html_Id(id) then "'#" + id + " > *'" }. /* */ public define Script jquery_ready ( String code //javascript code to execute when the document is ready )= script("text/javascript","$(document).ready(function(){"+code+"});"). public define String jquery_ready ( String code //javascript code to execute when the document is ready )= "$(document).ready(function(){"+code+"});". /* jQuery default js files */ define List(HTML_Head_Tag) jquery_defaults = [ js(js_file("/js/jquery/jquery-1.11.3.min.js")), js(js_file("/js/jquery/jquery-ui-1.11.4/jquery-ui.min.js")), ]. /* Initialize jQuery in compatiblity mode with jQueryUI */ public define List(HTML_Head_Tag) jquery_init ( String web_dir, String theme_name ) = if file_exists(web_dir+"/public/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.min.css") then [ css(css_file("/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.min.css")), css(css_file("/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.structure.min.css")), css(css_file("/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.theme.min.css")) . jquery_defaults ] else println("Jquery Theme not found "+web_dir+"/public/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.min.css"); //TODO change to real default jquery ui css [ css(css_file("/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.min.css")) . jquery_defaults ] .