Commit d80e09a7a66e812ea8e3e5c8f1ddc40d08670b2e

Authored by Cédric RICARD
1 parent 8c34737c

Several minor improvements on web objects. No compatibility loose except for file upload input.

Showing 1 changed file with 54 additions and 30 deletions   Show diff stats
calexium_lib/web/CXM_making_a_web_site.anubis
... ... @@ -647,7 +647,7 @@ public type Text_Option:
647 647 nowrap,
648 648 class(String), //CSS class
649 649 id(String),
650   -// name(String),
  650 + style(String),
651 651 tooltip(String).
652 652  
653 653 A list of 'Text_Option' must be given with each text you want to put in your page.
... ... @@ -922,8 +922,8 @@ public type Actioner_Aspect:
922 922 button (String url_off, String url_on), // rollover button
923 923 button (String url_off, String url_on, Int32 w, Int32 h), // idem with size
924 924 submit (List(CoreAttrs),String text),
925   - immediate_selector (WebArgName name, Int32 size, List((WebArgValue,String)) choices),
926   - immediate_selector (WebArgName name, Int32 size, List((WebArgValue,String)) choices, InitialValue selected).
  925 + immediate_selector (List(CoreAttrs),WebArgName name, Int32 size, List((WebArgValue,String)) choices),
  926 + immediate_selector (List(CoreAttrs),WebArgName name, Int32 size, List((WebArgValue,String)) choices, InitialValue selected).
927 927  
928 928  
929 929  
... ... @@ -1005,7 +1005,7 @@ public type HTML_In_Form:
1005 1005 text_input_ro (List(InputAttrs), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width),
1006 1006 password_input (List(InputAttrs), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width),
1007 1007 text_area (List(TextAreaOption), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width, Int32 height),
1008   - file_upload (String label, HtmlId id, WebArgName name, Int32 width),
  1008 + file_upload (List(InputAttrs), String label, HtmlId id, WebArgName name, Int32 width),
1009 1009 selector (List(InputAttrs), String label_text, HtmlId id, WebArgName name, Int32 size, List(String) choices),
1010 1010 selector (List(InputAttrs), String label_text, HtmlId id, WebArgName name, Int32 size, List(String) choices, InitialValue selected),
1011 1011 // List((String,String)) = List((code,name)) where :
... ... @@ -1155,7 +1155,7 @@ public define HTML_In_Form
1155 1155  
1156 1156 public define HTML_In_Form
1157 1157 file_upload (WebArgName name, Int32 width)
1158   - = file_upload("", htmlId(""), name, width).
  1158 + = file_upload([], "", htmlId(""), name, width).
1159 1159  
1160 1160  
1161 1161 public type HTML_Off_Form:
... ... @@ -1187,8 +1187,8 @@ public type HTML_Off_Form:
1187 1187 private_download (String abs_path, String name, String extra_ext,
1188 1188 Maybe((String,List((String,String)))) action),
1189 1189 label (String name),
1190   - form (String form_name, List(CoreAttrs), HTML_In_Form content),
1191   - form (String form_name, List(CoreAttrs),
  1190 + form (HtmlId form_id, List(CoreAttrs), HTML_In_Form content),
  1191 + form (HtmlId form_id, List(CoreAttrs),
1192 1192 String action_name, List((String,String)) extra_ops,
1193 1193 HTML_In_Form content),
1194 1194 div (List(CoreAttrs), HTML_Off_Form content),
... ... @@ -1196,6 +1196,27 @@ public type HTML_Off_Form:
1196 1196  
1197 1197 'HTML_Off_Form' defines all the elements you may put outside any form.
1198 1198  
  1199 +
  1200 +public define HTML_Off_Form
  1201 + form
  1202 + (
  1203 + String form_name,
  1204 + List(CoreAttrs) options,
  1205 + HTML_In_Form content
  1206 + ) =
  1207 + form(htmlId(form_name), options, content).
  1208 +
  1209 +public define HTML_Off_Form
  1210 + form
  1211 + (
  1212 + String form_name,
  1213 + List(CoreAttrs) options,
  1214 + String action_name,
  1215 + List((String,String)) extra_ops,
  1216 + HTML_In_Form content
  1217 + ) =
  1218 + form(htmlId(form_name), options, action_name, extra_ops, content).
  1219 +
1199 1220  
1200 1221 public define HTML_Off_Form literal(Printable_tree t) = literal_pt(t).
1201 1222 public define HTML_Off_Form fixed_size(HTML_Size width, HTML_Size height, String name_of_HTML_file)
... ... @@ -2894,8 +2915,8 @@ define List(Text_Option)
2894 2915 get_text_options(t)
2895 2916 else if h is id(_) then
2896 2917 get_text_options(t)
2897   -// else if h is name(_) then
2898   -// get_text_options(t)
  2918 + else if h is style(_) then
  2919 + get_text_options(t)
2899 2920 else if h is tooltip(_) then
2900 2921 get_text_options(t)
2901 2922 else
... ... @@ -2922,8 +2943,8 @@ define List(CoreAttrs)
2922 2943 [ class(name) . get_css_class(t) ]
2923 2944 else if h is id(name) then
2924 2945 [ id(name) . get_css_class(t) ]
2925   -// else if h is name(the_name) then
2926   -// [ name(the_name) . get_css_class(t) ]
  2946 + else if h is style(the_style) then
  2947 + [ style(the_style) . get_css_class(t) ]
2927 2948 else if h is tooltip(name) then
2928 2949 [ tooltip(name) . get_css_class(t) ]
2929 2950 else
... ... @@ -2963,7 +2984,7 @@ public define String
2963 2984 " class=\"" + class_name + "\"",
2964 2985 style(style_string) then
2965 2986 " style=\"" + style_string + "\"",
2966   -
  2987 +
2967 2988 tooltip(title_string) then
2968 2989 " title=\"" + title_string + "\"",
2969 2990  
... ... @@ -3123,8 +3144,8 @@ define Maybe(String)
3123 3144 button(_,_) then failure,
3124 3145 button(_,_,_,_) then failure,
3125 3146 submit(opts,_) then extract_id(opts),
3126   - immediate_selector(_,_,_) then failure,
3127   - immediate_selector(_,_,_,_) then failure,
  3147 + immediate_selector(_,_,_,_) then failure,
  3148 + immediate_selector(_,_,_,_,_) then failure,
3128 3149 }.
3129 3150  
3130 3151 to do Complete format_foreign_link
... ... @@ -3169,9 +3190,9 @@ define Printable_tree
3169 3190 submit(options, text) then
3170 3191 [ ],
3171 3192  
3172   - immediate_selector(name,size,choices) then
  3193 + immediate_selector(opt,name,size,choices) then
3173 3194 [ ],
3174   - immediate_selector(name,size,choices,selected) then
  3195 + immediate_selector(opt,name,size,choices,selected) then
3175 3196 [ ],
3176 3197 }.
3177 3198  
... ... @@ -3264,22 +3285,22 @@ define Printable_tree
3264 3285 }
3265 3286 ],
3266 3287  
3267   - immediate_selector(name,size,choices) then
  3288 + immediate_selector(options,name,size,choices) then
3268 3289 [ if action is
3269 3290 {
3270 3291 url(u) then ["<select href=\"",u]
3271 3292 javascript(s,h) then [s,"<select onchange=\"",h]
3272 3293 },
3273   - "\" name=\"o",name,"\" size=\"",size,"\">",
  3294 + "\" name=\"o",name,"\" size=\"",size,"\"", format_attrs(options), ">",
3274 3295 format_choices(choices),"</select>"
3275 3296 ],
3276   - immediate_selector(name,size,choices,selected) then
  3297 + immediate_selector(options,name,size,choices,selected) then
3277 3298 [ if action is
3278 3299 {
3279 3300 url(u) then ["<select href=\"",u]
3280 3301 javascript(s,h) then [s,"<select onchange=\"",h]
3281 3302 },
3282   - "\" name=\"o",name,"\" size=\"",size,"\">",
  3303 + "\" name=\"o",name,"\" size=\"",size,"\"", format_attrs(options), ">",
3283 3304 format_choices(choices, selected),"</select>"
3284 3305 ],
3285 3306 }.
... ... @@ -3317,8 +3338,8 @@ define Printable_tree
3317 3338 " onMouseOut=\"this.src='",url_off,"'\">",
3318 3339 ],
3319 3340 submit(opt, text) then [text],
3320   - immediate_selector(name,size,choices) then alert,
3321   - immediate_selector(name,size,choices,selected) then alert,
  3341 + immediate_selector(options,name,size,choices) then alert,
  3342 + immediate_selector(options,name,size,choices,selected) then alert,
3322 3343  
3323 3344 },
3324 3345 "</a>"].
... ... @@ -3608,7 +3629,8 @@ define String
3608 3629 line_through then "text-decoration:line-through",
3609 3630 nowrap then "white-space:nowrap",
3610 3631 class(class_name)then " class=\"" + class_name +"\"",
3611   - id(id_name) then " id=\"" + id_name +"\""
  3632 + id(id_name) then " id=\"" + id_name +"\"",
  3633 + style(style_string) then " style=\"" + style_string + "\"",
3612 3634 tooltip(title) then " title=\"" + title +"\""
3613 3635 } + if t is [ ] then "" else ("; "+format(t))
3614 3636 }.
... ... @@ -3858,9 +3880,9 @@ define Printable_tree
3858 3880 "<input type=\"password\" name=\"p",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"],
3859 3881 text_area(opts,label_text, id, n,i,w,h) then
3860 3882 [ maybe_label(label_text, id), "<textarea ",format(opts)," id=\"",id,"\" name=\"o",n,"\" cols=\"",w,"\" rows=\"",h,"\">",i,"</textarea>"],
3861   - file_upload(label, id, n, w) then
  3883 + file_upload(options, label, id, n, w) then
3862 3884 [ maybe_label(label, id),
3863   - "<input type=\"file\" id=\"",id,"\" size=\"",w,"\" name=\"o",n,"\" />"],
  3885 + "<input type=\"file\" id=\"",id,"\" size=\"",w,"\" name=\"o",n,"\"",format_attrs(options)," />"],
3864 3886 selector(opts, label, id, n,s,cs) then
3865 3887 [ maybe_label(label, id),
3866 3888 "<select id=\"",id,"\" name=\"o",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs),"</select>"],
... ... @@ -3961,7 +3983,7 @@ define Bool
3961 3983 text_input_ro(o,lt,l,n,i,w) then false,
3962 3984 password_input(o,lt,l,n,i,w) then false,
3963 3985 text_area(o,lt,id,n,i,w,h) then false,
3964   - file_upload(l,i,n,w) then true,
  3986 + file_upload(o,l,i,n,w) then true,
3965 3987 selector(o,l,i,n,s,c) then false,
3966 3988 selector(o,l,i,n,s,c,p) then false,
3967 3989 selector_c(o,l,i,n,s,c) then false,
... ... @@ -4039,7 +4061,7 @@ define Printable_tree
4039 4061 label(n) then ["<a name=\"",n,"\">"],
4040 4062 form(fn,attributs, c) then
4041 4063 [
4042   - "<form name=\"f",fn,"\"",
  4064 + "<form id=\"f",fn,"\"",
4043 4065 format(cinfo,sn,ic_v,any_coreattrs(attributs),format_element,is_https),
4044 4066 " method=\"post\"",
4045 4067 enctype(c),
... ... @@ -4048,14 +4070,15 @@ define Printable_tree
4048 4070 "://",common_name,":",http_port,"/\">",
4049 4071 // action is set dynamically by
4050 4072 // the actioner using JavaScript
4051   - format(cinfo,fn,sn,ic_v,c,is_https),
  4073 + if fn is htmlId(id) then
  4074 + format(cinfo,id,sn,ic_v,c,is_https),
4052 4075 "</form>"
4053 4076 ]
4054 4077 form(fn,attributs, action_name, extra_ops, c) then
4055 4078 with url = make_actioner_url(cinfo, same, same,
4056 4079 sn, action_name, extra_ops, is_https),
4057 4080 [
4058   - "<form name=\"f",fn,"\"",
  4081 + "<form id=\"f",fn,"\"",
4059 4082 format(cinfo,sn,ic_v,any_coreattrs(attributs),format_element,is_https),
4060 4083 " method=\"post\"",
4061 4084 enctype(c),
... ... @@ -4065,7 +4088,8 @@ define Printable_tree
4065 4088 // "://",common_name,":",http_port,"/\">",
4066 4089 // action is set dynamically by
4067 4090 // the actioner using JavaScript
4068   - format(cinfo,fn,sn,ic_v,c,is_https),
  4091 + if fn is htmlId(id) then
  4092 + format(cinfo,id,sn,ic_v,c,is_https),
4069 4093 "</form>"
4070 4094 ]
4071 4095 div(options, e) then
... ...