Commit 72f464e59c9966755e1a72d89cf5d4af00b18699

Authored by totoro
1 parent e45144c2

add url as specialized widget for edit, show and go to.

add the option in all element email, phone and url the option (Bool show_text). If set to false only the icon is shown
Showing 2 changed files with 135 additions and 23 deletions   Show diff stats
web/CXM_form.anubis
... ... @@ -16,6 +16,7 @@ read calexium_lib/web/CXM_web_arg_utils.anubis
16 16 read calexium_lib/web/CXM_making_a_web_site.anubis
17 17 read calexium_lib/web/CXM_html_tooltip.anubis
18 18 read calexium_lib/web/CXM_widgets.anubis
  19 +read calexium_lib/web/widgets/specialized_elements.anubis
19 20  
20 21 public type Mandatory: // used to mark fields as mandatory.
21 22 mandatory,
... ... @@ -95,10 +96,11 @@ public type CXM_Form_Field:
95 96 HTML_Id id,
96 97 WebArgName web_arg_name,
97 98 InitialValue init_value,
  99 + Phone_Type phone_type,
98 100 Width width,
99 101 Mandatory mandatory),
100 102  
101   - //--- phone field ------------------------------------------------------------
  103 + //--- email field ------------------------------------------------------------
102 104 email_input(
103 105 List(CoreAttrs) icon_options,
104 106 List(CoreAttrs) options,
... ... @@ -108,6 +110,17 @@ public type CXM_Form_Field:
108 110 InitialValue init_value,
109 111 Width width,
110 112 Mandatory mandatory),
  113 +
  114 + //--- url field ------------------------------------------------------------
  115 + url_input(
  116 + List(CoreAttrs) icon_options,
  117 + List(CoreAttrs) options,
  118 + HTML_Label label,
  119 + HTML_Id id,
  120 + WebArgName web_arg_name,
  121 + InitialValue init_value,
  122 + Width width,
  123 + Mandatory mandatory),
111 124  
112 125 //--- hidden field ------------------------------------------------------------
113 126 hidden(
... ... @@ -526,9 +539,9 @@ public define HTML_In_Form
526 539 password_input(options, _label, id, name, init, w, mand) then
527 540 password_input([class("in") . options], star(_label, mand), id, name, init, pixels(w)),
528 541  
529   - phone_input(icon_options, options, _label, id, wan, default, w, mand) then
  542 + phone_input(icon_options, options, _label, id, wan, default, phone_type, w, mand) then
530 543 sequence([
531   - image(icon_options, "/icons/16x16/phone.png", ""),
  544 + image(icon_options, "/icons/16x16/"+to_Icon(phone_type), ""),
532 545 text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)),
533 546 ]),
534 547  
... ... @@ -536,7 +549,13 @@ public define HTML_In_Form
536 549 sequence([
537 550 image(icon_options, "/icons/16x16/email_edit.png", ""),
538 551 text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)),
539   - ])
  552 + ]),
  553 +
  554 + url_input(icon_options, options, _label, id, wan, default, w, mand) then
  555 + sequence([
  556 + image(icon_options, "/icons/16x16/url.png", ""),
  557 + text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)),
  558 + ]),
540 559  
541 560 hidden(id, name, init) then
542 561 hidden(id, name, init),
... ...
web/widgets/specialized_elements.anubis
... ... @@ -8,57 +8,150 @@
8 8  
9 9 read calexium_lib/web/CXM_making_a_web_site.anubis
10 10  
  11 +public type Phone_Type:
  12 + generic, //Nothing special, normal phone number like home, mobile, etc..
  13 + landline, //wired phone line number
  14 + cellphone, //mobile or cell phone line number
  15 + fax //fax line number
  16 +.
  17 +
  18 +public define String
  19 + to_Icon
  20 + (
  21 + Phone_Type phone_type
  22 + )=
  23 + if phone_type is
  24 + {
  25 + generic then "desktop_phone.png",
  26 + landline then "desktop_phone.png",
  27 + cellphone then "cellphone.png",
  28 + fax then "fax.png"
  29 + }
  30 +.
  31 +
11 32 public define HTML_Off_Form
12   - phone
  33 + phone_icon
13 34 (
14 35 List(CoreAttrs) attrs,
15 36 String phone_number,
16   - Bool image_only
  37 + Phone_Type phone_type,
  38 + Bool show_text
17 39 )=
18 40 if phone_number = "" then empty
19 41 else
20   - with _attrs = [data("phone-number", phone_number), event(onclick, "hk_phone_call(this)"), class("phone_click") . attrs],
21   - div([
22   - img(_attrs, "/icons/16x16/phone.png"),
23   - if image_only then empty else
  42 + with _attrs = if phone_type = fax then [] else [data("phone-number", phone_number), event(onclick, "hk_phone_call(this)"), class("clickable") . attrs],
  43 + sequence([
  44 + img(_attrs+[class("icon_in_text")], "/icons/16x16/"+to_Icon(phone_type)),
  45 + if show_text then
24 46 text(_attrs, phone_number)
  47 + else
  48 + empty
25 49 ])
26 50 .
27 51  
28 52 public define HTML_Off_Form
29   - phone
  53 + phone_icon
30 54 (
31 55 List(CoreAttrs) attrs,
32 56 String phone_number
33   - )= phone(attrs, phone_number, false).
  57 + )= phone_icon(attrs, phone_number, generic, true).
34 58  
35 59 public define HTML_Off_Form
36   - phone
  60 + phone_icon
37 61 (
38 62 String phone_number
39 63 )=
40   - phone([], phone_number)
  64 + phone_icon([], phone_number, generic, true)
  65 +.
  66 +
  67 +public define HTML_Off_Form
  68 + phone_icon
  69 + (
  70 + String phone_number,
  71 + Phone_Type phone_type,
  72 + Bool show_number
  73 + )=
  74 + phone_icon([], phone_number, phone_type, show_number)
41 75 .
42 76  
43 77 public define HTML_Off_Form
44   - email
  78 + phone_icon
  79 + (
  80 + String phone_number,
  81 + Phone_Type phone_type
  82 + )=
  83 + phone_icon([], phone_number, phone_type, true)
  84 +.
  85 +
  86 +
  87 +public define HTML_Off_Form
  88 + email_icon
45 89 (
46 90 List(CoreAttrs) attrs,
47   - String email_str
  91 + String email_str,
  92 + Bool show_text
48 93 )=
49 94 if email_str = "" then empty
50 95 else
51   - with _attrs = [data("email", email_str), event(onclick, "hk_send_email(this)"), class("email_click") . attrs],
52   - div([
53   - img(_attrs, "/icons/16x16/email.png"),
54   - text(_attrs, email_str)
  96 + with _attrs = [data("email", email_str), event(onclick, "hk_send_email(this)"), class("clickable") . attrs],
  97 + sequence([
  98 + img(_attrs+[class("icon_in_text")], "/icons/16x16/email.png"),
  99 + if show_text then
  100 + text(_attrs, email_str)
  101 + else
  102 + empty
55 103 ])
56 104 .
57 105  
58 106 public define HTML_Off_Form
59   - email
  107 + email_icon
60 108 (
61   - String phone_number
  109 + String email_address,
  110 + Bool show_text
  111 + )=
  112 + email_icon([], email_address, show_text)
  113 +.
  114 +
  115 +public define HTML_Off_Form
  116 + email_icon
  117 + (
  118 + String email_address
  119 + )=
  120 + email_icon([], email_address, true)
  121 +.
  122 +
  123 +public define HTML_Off_Form
  124 + url_icon
  125 + (
  126 + List(CoreAttrs) attrs,
  127 + String url_string,
  128 + Bool show_text
  129 + )=
  130 + if url_string = "" then empty
  131 + else
  132 + with _attrs = [data("url", url_string), event(onclick, "hk_go_url(this)"), class("clickable") . attrs],
  133 + sequence([
  134 + img(_attrs+[class("icon_in_text")], "/icons/16x16/url.png"),
  135 + if show_text then
  136 + text(_attrs, url_string)
  137 + else
  138 + empty
  139 + ])
  140 +.
  141 +
  142 +public define HTML_Off_Form
  143 + url_icon
  144 + (
  145 + String url_string, //url to open
  146 + Bool show_text //if true show the url link near the icon
  147 + )=
  148 + url_icon([], url_string, show_text)
  149 +.
  150 +
  151 +public define HTML_Off_Form
  152 + url_icon
  153 + (
  154 + String url_string
62 155 )=
63   - email([], phone_number)
  156 + url_icon(url_string, true)
64 157 .
... ...