From c52d284587dad39927b87e57cc1547a8bf6927e3 Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 15 Nov 2015 12:23:34 +0100 Subject: [PATCH] + Add on_change function on immediate selector. + Merge all immediate_selector together and create some immediate_selector function with less argument. These functions call the master function with default value for the arguments which are removed from the call + Add HTML_partial_content to HTTP_answer. This allow to send small part of html without body and header. Need for Ajax call + Change the HTML DOCTYPE from old xhtml to html 5 + Add autoOpen argument on jq_dialog_create --- web/CXM_making_a_web_site.anubis | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------- web/jQuery/CXM_jquery_dialog.anubis | 28 ++++++++++++++++++++++++---- 2 files changed, 133 insertions(+), 49 deletions(-) diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis index 5f330f0..7597b3c 100644 --- a/web/CXM_making_a_web_site.anubis +++ b/web/CXM_making_a_web_site.anubis @@ -11,7 +11,7 @@ *Authors* Alain Prouté David René Jérémy Larrieu - Julien Vernueil + Julien Verneuil *Revised* May 2015 @@ -956,10 +956,35 @@ public type Actioner_Aspect: button (String url_off, String url_on), // rollover button button (String url_off, String url_on, Int w, Int h), // idem with size submit (List(CoreAttrs),String text), - immediate_selector (List(CoreAttrs),WebArgName name, Int size, List((List(CoreAttrs),WebArgValue,String)) choices), - immediate_selector (List(CoreAttrs),WebArgName name, Int size, List((List(CoreAttrs),WebArgValue,String)) choices, InitialValue selected), +// immediate_selector (List(CoreAttrs),WebArgName name, Int size, List((List(CoreAttrs),WebArgValue,String)) choices), +// immediate_selector (List(CoreAttrs),WebArgName name, Int size, List((List(CoreAttrs),WebArgValue,String)) choices, InitialValue selected), + immediate_selector (List(CoreAttrs),WebArgName name, Int size, List((List(CoreAttrs),WebArgValue,String)) choices, Maybe(InitialValue) selected, String onchange_fn), + html (HTML_Off_Form). +public define Actioner_Aspect + immediate_selector + ( + List(CoreAttrs) core_attrs, + WebArgName name, + Int size, + List((List(CoreAttrs),WebArgValue,String)) choices + )= + immediate_selector(core_attrs, name, size, choices, failure, "") + . + +public define Actioner_Aspect + immediate_selector + ( + List(CoreAttrs) core_attrs, + WebArgName name, + Int size, + List((List(CoreAttrs),WebArgValue,String)) choices, + Maybe(InitialValue) selected + )= + immediate_selector(core_attrs, name, size, choices, selected, "") + . + public type Actioner_Local_Action: close_window. @@ -1652,7 +1677,9 @@ public type HTTP_Answer: Printable_tree /*content*/), http_raw (Printable_tree), html_content (HTTP_Status /*http_status*/, - HTML_Off_Form). + HTML_Off_Form), + html_partial_content (HTTP_Status /*http_status*/, + HTML_Partial_Content). public define HTTP_Answer @@ -1882,13 +1909,13 @@ define Printable_tree public define String doctype_w3c_header = - "\n". + "\n". //html 5 -public define String - html_header - = - "\n". +// No longer used in HTML 5 +//public define String +// html_header +// = +// "\n". *** [1] States. @@ -3064,10 +3091,10 @@ public define Printable_tree public define Printable_tree format_choices - ( - List(String) l, - InitialValue selected - ) = + ( + List(String) l, + InitialValue selected + ) = if l is { [ ] then [ ], @@ -3483,8 +3510,8 @@ define Maybe(String) button(_,_) then failure, button(_,_,_,_) then failure, submit(opts,_) then extract_id(opts), - immediate_selector(_,_,_,_) then failure, - immediate_selector(_,_,_,_,_) then failure, + //immediate_selector(_,_,_,_) then failure, + immediate_selector(_,_,_,_,_,_) then failure, html(_) then failure, }. @@ -3541,9 +3568,9 @@ define Printable_tree submit(options, text) then [ ], - immediate_selector(opt,name,size,choices) then - [ ], - immediate_selector(opt,name,size,choices,selected) then + //immediate_selector(opt,name,size,choices) then + // [ ], + immediate_selector(opt,name,size,choices,selected,function) then [ ], html(html_off_form) then [ @@ -3647,23 +3674,29 @@ define Printable_tree } ], - immediate_selector(options,name,size,choices) then - [ if action is - { - url(u) then ["" - ], - immediate_selector(options,name,size,choices,selected) then - [ if action is +// immediate_selector(options,name,size,choices) then +// [ if action is +// { +// url(u) then ["" +// ], + immediate_selector(options, name, size, choices, mb_selected, custom_function_name) then + [ + //if custom function name is provided, that name is used instead of autogenerated js function + if custom_function_name = "" then + if action is { url(u) then ["" + if mb_selected is success(selected) then format_choices(choices, selected) else format_choices(choices),"" ], html(html_off_form) then [ @@ -4663,8 +4696,8 @@ define Printable_tree = if lwf is { - [] then reverse(so_far), - [ h . t] then + [] then reverse(so_far), + [ h . t] then if h is { meta(meta) then @@ -4693,15 +4726,16 @@ public define Printable_tree String charset ) = - with lwf = (List(HTML_Head_Tag))[ meta(http_equiv("content-type", "text/html; charset="+charset)) . lwf], - if lwf is - { - [] then - [], - [ h . t] then - _format_html_head(lwf, []) - } - . + _format_html_head((List(HTML_Head_Tag))[ meta(http_equiv("content-type", "text/html; charset="+charset)) . lwf], []). + +public define Printable_tree + format_html_head + ( + List(HTML_Head_Tag) lwf + ) + = + _format_html_head(lwf, []). + public type HTML_ajax_content: html_ajax_content( String html_body, String script, List(String) js_file, List(String) css_file). @@ -4748,6 +4782,12 @@ public define HTML_ajax_content CommonInfo cinfo )= to_html_ajax_content(content_HTML, cinfo, ""). +public define HTML_ajax_content + to_html_ajax_content + ( + HTML_Partial_Content content_HTML, + CommonInfo cinfo + )= to_html_ajax_content(partial(content_HTML), cinfo, ""). public define Printable_tree format @@ -4776,7 +4816,7 @@ public define Printable_tree ""], answer_body_header = [doctype_w3c_header, - html_header, + // html_header, "\n", format_html_head(head_tags + *p_content_head_tags, charset),"\n", ], @@ -4795,7 +4835,7 @@ public define Printable_tree if format(status) is (status_string, status_headers) then with answer_body = [ doctype_w3c_header, - html_header, + //html_header, "\n", add_css_styles(css_styles), add_css_files(css_files), @@ -4889,5 +4929,29 @@ public define Printable_tree crlf . content ], + //HMTL content with some header + html_partial_content(HTTP_Status status, HTML_Partial_Content p_content) then + + since p_content is partial_content(head_tags, html_content), + since format(status) is (status_string, status_headers), + with + answer_body = (Printable_tree) + [ + format(cinfo, state_name, ic_v, html_content, is_https, var(0), p_content_head_tags), + ], + answer_header = (Printable_tree) + [ + // html_header, + format_html_head(head_tags + *p_content_head_tags), + ], + [ "HTTP/1.1 " + status_string, crlf, + format_headers(standard_headers), + format_headers(standard_headers_for("text/html", length(answer_header) + length(answer_body), success(charset))), + format_headers(status_headers), + format_headers(additional_headers), + crlf, + answer_header . + answer_body + ], }. diff --git a/web/jQuery/CXM_jquery_dialog.anubis b/web/jQuery/CXM_jquery_dialog.anubis index 01bb241..aca36e2 100644 --- a/web/jQuery/CXM_jquery_dialog.anubis +++ b/web/jQuery/CXM_jquery_dialog.anubis @@ -6,6 +6,7 @@ * © Calexium */ +read system/convert.anubis read calexium_lib/web/CXM_making_a_web_site.anubis read calexium_lib/web/CXM_jquery.anubis @@ -23,16 +24,17 @@ public define HTML_Partial_Content ( JQuery_dialog_id dial_id, JQuery_dialog content, - String extra_parm + Bool autoOpen, + String extra_param )= with dlg_id = id(dial_id), js = js_inline(jquery_ready(" $( \"#"+dlg_id+"\" ).dialog({ - autoOpen: false, + autoOpen: "+to_String(autoOpen)+", modal: true, height: 'auto', width: 'auto', - "+extra_parm+" + "+extra_param+" Cancel: function() { $( this ).dialog( 'close' ); } @@ -49,6 +51,15 @@ public define HTML_Partial_Content ajax(url) then partial_content( [js], div_empty([id(dlg_id), attr("ajax_url",url)])) }. + +public define HTML_Partial_Content + jq_dialog_create + ( + JQuery_dialog_id dial_id, + JQuery_dialog content, + String extra_param + )= + jq_dialog_create(dial_id, content, false, extra_param). public define HTML_Partial_Content jq_dialog_create @@ -56,8 +67,17 @@ public define HTML_Partial_Content JQuery_dialog_id dial_id, JQuery_dialog content )= - jq_dialog_create(dial_id, content, ""). + jq_dialog_create(dial_id, content, false, ""). +public define HTML_Partial_Content + jq_dialog_create + ( + JQuery_dialog_id dial_id, + JQuery_dialog content, + Bool autoOpen + )= + jq_dialog_create(dial_id, content, autoOpen, ""). + define String _jq_dialog_open ( -- libgit2 0.21.4