Commit bd400dd2bd0972bbb54eae2b37b46e6be83f0735
1 parent
22be332d
The "label" is now optional for all inputs
Showing
1 changed file
with
26 additions
and
80 deletions
Show diff stats
calexium_lib/web/CXM_making_a_web_site.anubis
| ... | ... | @@ -3092,7 +3092,7 @@ define Printable_tree |
| 3092 | 3092 | { |
| 3093 | 3093 | |
| 3094 | 3094 | link(opt, text, mb_name) then |
| 3095 | - with name_tag = if mb_name is success(n) then " name=\" " + n + "\"" else "", | |
| 3095 | + with name_tag = if mb_name is success(n) then " name=\"" + n + "\"" else "", | |
| 3096 | 3096 | [ |
| 3097 | 3097 | "<a href=\"", url, "\"", format_text_options(opt), name_tag, ">", |
| 3098 | 3098 | text, |
| ... | ... | @@ -3519,10 +3519,8 @@ define Printable_tree |
| 3519 | 3519 | "<td valign=bottom>", |
| 3520 | 3520 | "<table>", |
| 3521 | 3521 | "<tbody>", |
| 3522 | - "<tr><td><img alt=\"sroll up\" src=\"scrollup.gif\" onmousedown=\"doscroll_", | |
| 3523 | - idnum,"(0,20);\"></td></tr>", | |
| 3524 | - "<tr><td><img alt=\"scroll down\" src=\"scrolldown.gif\" onmousedown=\"doscroll_", | |
| 3525 | - idnum,"(0,-20);\"></td></tr>", | |
| 3522 | + "<tr><td><img alt=\"sroll up\" src=\"scrollup.gif\" onmousedown=\"doscroll_", idnum,"(0,20);\"></td></tr>", | |
| 3523 | + "<tr><td><img alt=\"scroll down\" src=\"scrolldown.gif\" onmousedown=\"doscroll_", idnum,"(0,-20);\"></td></tr>", | |
| 3526 | 3524 | "</tbody>", |
| 3527 | 3525 | "</table>", |
| 3528 | 3526 | "</td>", |
| ... | ... | @@ -3534,10 +3532,8 @@ define Printable_tree |
| 3534 | 3532 | "<table>", |
| 3535 | 3533 | "<tbody>", |
| 3536 | 3534 | "<tr>", |
| 3537 | - "<td><img alt=\"scroll left\" src=\"scrollleft.gif\" onmousedown=\"doscroll_", | |
| 3538 | - idnum,"(20,0);\"></td>", | |
| 3539 | - "<td><img alt=\"scroll right\" src=\"scrollright.gif\" onmousedown=\"doscroll_", | |
| 3540 | - idnum,"(-20,0);\"></td>", | |
| 3535 | + "<td><img alt=\"scroll left\" src=\"scrollleft.gif\" onmousedown=\"doscroll_", idnum,"(20,0);\"></td>", | |
| 3536 | + "<td><img alt=\"scroll right\" src=\"scrollright.gif\" onmousedown=\"doscroll_", idnum,"(-20,0);\"></td>", | |
| 3541 | 3537 | "</tr>", |
| 3542 | 3538 | "</tbody>", |
| 3543 | 3539 | "</table>", |
| ... | ... | @@ -3548,64 +3544,7 @@ define Printable_tree |
| 3548 | 3544 | "</table>" |
| 3549 | 3545 | ]. |
| 3550 | 3546 | |
| 3551 | - | |
| 3552 | -/* | |
| 3553 | - define Printable_tree | |
| 3554 | - popup_topbar | |
| 3555 | - ( | |
| 3556 | - CommonInfo cinfo, | |
| 3557 | - String title, | |
| 3558 | - RGB color, | |
| 3559 | - Int32 width, | |
| 3560 | - ) = | |
| 3561 | - if cinfo is info(common_name,http_port,https_port,site_directory,secret) then | |
| 3562 | - with xxxx = web_arg_encode(sha1((title,color,width))), | |
| 3563 | - path = site_directory+"/public/buttons/t"+xxxx+".jpg", | |
| 3564 | - result = (Printable_tree)["<img alt=\"button\" src=\"buttons/t"+xxxx+".jpg\">"], | |
| 3565 | - if file_exists(path) then result else | |
| 3566 | - with col = to_rgba(color), | |
| 3567 | - bg = create_button_background(col,width,20), | |
| 3568 | - very_light_color = lighten(col,70), | |
| 3569 | - dark_color = darken(col,40), | |
| 3570 | - title_width = printed_text_width(font,title), | |
| 3571 | - draw_button_text(bg,title,title_width,very_light_color,dark_color,font); | |
| 3572 | - forget(write_image_to_JPEG_file(to_JPEG(bg),path,100)); | |
| 3573 | - result. | |
| 3574 | - | |
| 3575 | - | |
| 3576 | - define Printable_tree | |
| 3577 | - popup_close_button | |
| 3578 | - ( | |
| 3579 | - CommonInfo cinfo, | |
| 3580 | - RGB color, | |
| 3581 | - String div_name, | |
| 3582 | - String state_var_name, | |
| 3583 | - ) = | |
| 3584 | - if cinfo is info(common_name,http_port,https_port,site_directory,secret) then | |
| 3585 | - with xxxx = web_arg_encode(sha1(color)), | |
| 3586 | - path_on = site_directory+"/public/buttons/c"+xxxx+"_on.jpg", | |
| 3587 | - path_off = site_directory+"/public/buttons/c"+xxxx+"_off.jpg", | |
| 3588 | - result = (Printable_tree)["<img alt=\"button\" src=\"buttons/c"+xxxx+"_off.jpg\"", | |
| 3589 | - " onMouseOver=\"this.src='buttons/c"+xxxx+"_on.jpg'\"", | |
| 3590 | - " onMouseOut=\"this.src='buttons/c"+xxxx+"_off.jpg'\"", | |
| 3591 | - " onMouseDown=\"show_local_popup('",div_name,"','",state_var_name,"')\">"], | |
| 3592 | - if file_exists(path_on) then result else | |
| 3593 | - with col = to_rgba(color), | |
| 3594 | - title = "x", | |
| 3595 | - title_width = printed_text_width(font,title), | |
| 3596 | - bg_on = create_button_background(lighten(col,30),20,20), | |
| 3597 | - bg_off = create_button_background(col,20,20), | |
| 3598 | - very_light_color = lighten(col,70), | |
| 3599 | - dark_color = darken(col,40), | |
| 3600 | - draw_button_text(bg_on,title,title_width,very_light_color,dark_color,font); | |
| 3601 | - draw_button_text(bg_off,title,title_width,very_light_color,dark_color,font); | |
| 3602 | - forget(write_image_to_JPEG_file(to_JPEG(bg_on),path_on,100)); | |
| 3603 | - forget(write_image_to_JPEG_file(to_JPEG(bg_off),path_off,100)); | |
| 3604 | - result. | |
| 3605 | - | |
| 3606 | - | |
| 3607 | -*/ | |
| 3608 | - | |
| 3547 | + | |
| 3609 | 3548 | |
| 3610 | 3549 | // The function below formats a datum of type 'HTML_Any($T)'. |
| 3611 | 3550 | |
| ... | ... | @@ -3676,7 +3615,14 @@ define Printable_tree |
| 3676 | 3615 | // *** [5.8] Formating 'in form' elements. |
| 3677 | 3616 | |
| 3678 | 3617 | |
| 3679 | - | |
| 3618 | +define Printable_tree | |
| 3619 | + maybe_label | |
| 3620 | + ( | |
| 3621 | + String label_text, | |
| 3622 | + HtmlId id | |
| 3623 | + ) = | |
| 3624 | + if length(label_text) > 0 then ["<label for=\"",id,"\">",label_text,"</label>"] | |
| 3625 | + else []. | |
| 3680 | 3626 | |
| 3681 | 3627 | |
| 3682 | 3628 | define Printable_tree |
| ... | ... | @@ -3723,44 +3669,44 @@ define Printable_tree |
| 3723 | 3669 | private_download(url,name,extra,action) then |
| 3724 | 3670 | format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https), |
| 3725 | 3671 | text_input(options, label_text, id, name, i, w) then |
| 3726 | - [if length(label_text) > 0 then ["<label for=\"",id,"\">",label_text,"</label>"] else [], | |
| 3672 | + [ maybe_label(label_text, id), | |
| 3727 | 3673 | "<input type=\"text\" name=\"o",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"], |
| 3728 | 3674 | text_input_ro(options, label_text, id, name,i,w) then |
| 3729 | - [if length(label_text) > 0 then ["<label for=\"",id,"\">",label_text,"</label>"] else [], | |
| 3675 | + [ maybe_label(label_text, id), | |
| 3730 | 3676 | "<input readonly=\"readonly\" type=\"text\" name=\"o",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"], |
| 3731 | 3677 | password_input(options, label_text, id, name,i,w) then |
| 3732 | - [if length(label_text) > 0 then ["<label for=\"",id,"\">",label_text,"</label>"] else [], | |
| 3678 | + [ maybe_label(label_text, id), | |
| 3733 | 3679 | "<input type=\"password\" name=\"p",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"], |
| 3734 | 3680 | text_area(opts,n,i,w,h) then |
| 3735 | 3681 | ["<textarea ",format(opts)," name=\"o",n,"\" cols=\"",w,"\" rows=\"",h,"\">",i,"</textarea>"], |
| 3736 | 3682 | file_upload(label, id, n, w) then |
| 3737 | - ["<label for=\"",id,"\">",label,"</label>", | |
| 3683 | + [ maybe_label(label, id), | |
| 3738 | 3684 | "<input type=\"file\" id=\"",id,"\" size=\"",w,"\" name=\"o",n,"\" />"], |
| 3739 | 3685 | selector(opts, label, id, n,s,cs) then |
| 3740 | - ["<label for=\"",id,"\">",label,"</label>", | |
| 3686 | + [ maybe_label(label, id), | |
| 3741 | 3687 | "<select id=\"",id,"\" name=\"o",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs),"</select>"], |
| 3742 | 3688 | selector(opts, label, id, n,s,cs,sd) then |
| 3743 | - ["<label for=\"",id,"\">",label,"</label>", | |
| 3689 | + [ maybe_label(label, id), | |
| 3744 | 3690 | "<select id=\"",id,"\" name=\"o",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs,sd),"</select>"], |
| 3745 | 3691 | selector_c(opts, label, id, n,s,cs) then |
| 3746 | - ["<label for=\"",id,"\">",label,"</label>", | |
| 3692 | + [ maybe_label(label, id), | |
| 3747 | 3693 | "<select id=\"",id,"\" name=\"o",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs),"</select>"], |
| 3748 | 3694 | selector_c(opts, label, id, n,s,cs,sd) then |
| 3749 | - ["<label for=\"",id,"\">",label,"</label>", | |
| 3695 | + [ maybe_label(label, id), | |
| 3750 | 3696 | "<select id=\"",id,"\" name=\"o",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs,sd),"</select>"], |
| 3751 | 3697 | |
| 3752 | 3698 | radio_button(options, label_text, id, n, v, c) then |
| 3753 | - [ "<label for=\"",id,"\">",label_text,"</label>", | |
| 3699 | + [ maybe_label(label_text, id), | |
| 3754 | 3700 | "<input type=\"radio\" name=\"o",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\"" else ""),format_attrs(options)," />"], |
| 3755 | 3701 | radio_button_r(options, label_text, id, n, v, c) then |
| 3756 | 3702 | [ "<input type=\"radio\" name=\"o",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\"" else ""),format_attrs(options)," />", |
| 3757 | - "<label for=\"",id,"\">",label_text,"</label>"], | |
| 3703 | + maybe_label(label_text, id)], | |
| 3758 | 3704 | check_box(options, label_text, id, n, v, c) then |
| 3759 | - [ if length(label_text) > 0 then ["<label for=\"",id,"\">",label_text,"</label>"] else [""], | |
| 3705 | + [ maybe_label(label_text, id), | |
| 3760 | 3706 | "<input type=\"checkbox\" name=\"o",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\" " else ""),format_attrs(options)," />"] |
| 3761 | 3707 | check_box_r(options, label_text, id, n, v, c) then |
| 3762 | 3708 | [ "<input type=\"checkbox\" name=\"o",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\" " else ""),format_attrs(options)," />", |
| 3763 | - if length(label_text) > 0 then ["<label for=\"",id,"\">",label_text,"</label>"] else [""] ] | |
| 3709 | + maybe_label(label_text, id)] | |
| 3764 | 3710 | div(options, e) then |
| 3765 | 3711 | format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https), |
| 3766 | 3712 | div_empty(options) then | ... | ... |