Commit 27567d6ece0fba082e5be5d25863c1d1e50c021d

Authored by totoro
1 parent f0b6401d

add core attributes in html alternative for Actioner

add i and span alternatives in HTML_In_Form and HTML_Off_Form
add Awesome Font support
add Menu with direction positioning (top and side)
add Icon support (png and Awesome font)
web/CXM_making_a_web_site.anubis
... ... @@ -1084,8 +1084,7 @@ public type Actioner_Aspect:
1084 1084 button (String url_off, String url_on, Int w, Int h), // idem with size
1085 1085 submit (List(CoreAttrs),String text),
1086 1086 immediate_selector (List(CoreAttrs),WebArgName name, Int size, List((List(CoreAttrs),WebArgValue,String)) choices, Maybe(InitialValue) selected, String onchange_fn),
1087   -
1088   - html (HTML_Off_Form).
  1087 + html (List(CoreAttrs), HTML_Off_Form).
1089 1088  
1090 1089 public define Actioner_Aspect
1091 1090 immediate_selector
... ... @@ -1378,7 +1377,10 @@ public type HTML_In_Form:
1378 1377 ol (List(CoreAttrs), HTML_In_Form content),
1379 1378 ul (List(CoreAttrs), HTML_In_Form content),
1380 1379 li (List(CoreAttrs), HTML_In_Form content),
1381   - button (List(CoreAttrs), HTML_In_Form content).
  1380 + button (List(CoreAttrs), HTML_In_Form content),
  1381 + i (List(CoreAttrs), String text),
  1382 + span (List(CoreAttrs), String text)
  1383 +.
1382 1384  
1383 1385  
1384 1386 'HTML_In_Form' defines all the elements you may put within a form. We define a
... ... @@ -1530,12 +1532,7 @@ public define HTML_In_Form
1530 1532 ) =
1531 1533 private_download(abs_path,name,extra_ext,success((action_name,args))).
1532 1534  
1533   -public define HTML_In_Form
1534   - text
1535   - (
1536   - String s
1537   - ) =
1538   - text([],s).
  1535 +
1539 1536  
1540 1537 public define HTML_In_Form
1541 1538 text
... ... @@ -1543,14 +1540,39 @@ public define HTML_In_Form
1543 1540 List(Text_Option) lto,
1544 1541 Int i
1545 1542 ) =
1546   - text(lto, to_decimal(i)).
  1543 + text(lto, to_decimal(i)).
1547 1544  
1548 1545 public define HTML_In_Form
1549 1546 text
1550 1547 (
  1548 + String s
  1549 + )=
  1550 + text([],s)
  1551 +.
  1552 +
  1553 +public define HTML_In_Form
  1554 + text
  1555 + (
1551 1556 Int i
1552 1557 ) =
1553   - text([],i).
  1558 + text([], i)
  1559 +.
  1560 +
  1561 +public define HTML_In_Form
  1562 + span
  1563 + (
  1564 + String s
  1565 + )=
  1566 + span([],s)
  1567 +.
  1568 +
  1569 +public define HTML_In_Form
  1570 + span
  1571 + (
  1572 + Int i
  1573 + ) =
  1574 + span([], to_decimal(i))
  1575 +.
1554 1576  
1555 1577 public define HTML_In_Form
1556 1578 radio_button (List(CoreAttrs) options, HTML_Label label, WebArgName n, WebArgValue value, Bool checked)
... ... @@ -1628,7 +1650,10 @@ public type HTML_Off_Form:
1628 1650 ol (List(CoreAttrs), HTML_Off_Form content),
1629 1651 ul (List(CoreAttrs), HTML_Off_Form content),
1630 1652 li (List(CoreAttrs), HTML_Off_Form content),
1631   - button (List(CoreAttrs), HTML_Off_Form content).
  1653 + button (List(CoreAttrs), HTML_Off_Form content),
  1654 + i (List(CoreAttrs), String text),
  1655 + span (List(CoreAttrs), String text)
  1656 +.
1632 1657  
1633 1658 'HTML_Off_Form' defines all the elements you may put outside any form.
1634 1659  
... ... @@ -1828,19 +1853,39 @@ public define HTML_Off_Form
1828 1853  
1829 1854  
1830 1855 public define HTML_Off_Form
1831   - text
1832   - (
1833   - Int i
1834   - ) =
1835   - text([],i).
  1856 + text
  1857 + (
  1858 + Int i
  1859 + )=
  1860 + text([], i)
  1861 +.
1836 1862  
1837 1863 public define HTML_Off_Form
1838 1864 text
1839 1865 (
1840 1866 String s
1841 1867 ) =
1842   - text([],s).
  1868 + text([],s)
  1869 +.
  1870 +
  1871 +
1843 1872  
  1873 +public define HTML_Off_Form
  1874 + span
  1875 + (
  1876 + String s
  1877 + )=
  1878 + span([], s)
  1879 +.
  1880 +
  1881 +public define HTML_Off_Form
  1882 + span
  1883 + (
  1884 + Int i
  1885 + )=
  1886 + span([], to_decimal(i))
  1887 +.
  1888 +
1844 1889 - Cell a gap between two other cells :
1845 1890  
1846 1891 public define HTML_Cell(HTML_Off_Form)
... ... @@ -3456,7 +3501,10 @@ type HTML_Any($T):
3456 3501 any_ol (List(CoreAttrs), $T content),
3457 3502 any_ul (List(CoreAttrs), $T content),
3458 3503 any_li (List(CoreAttrs), $T content),
3459   - any_button (List(CoreAttrs), $T element).
  3504 + any_button (List(CoreAttrs), $T element),
  3505 + any_i (List(CoreAttrs), String text),
  3506 + any_span (List(CoreAttrs), String text)
  3507 +.
3460 3508  
3461 3509  
3462 3510  
... ... @@ -4079,7 +4127,7 @@ define Maybe(String)
4079 4127 submit(opts,_) then extract_id(opts),
4080 4128 //immediate_selector(_,_,_,_) then failure,
4081 4129 immediate_selector(_,_,_,_,_,_) then failure,
4082   - html(_) then failure,
  4130 + html(_, _) then failure,
4083 4131 }.
4084 4132  
4085 4133 to do Complete format_foreign_link
... ... @@ -4139,9 +4187,9 @@ define Printable_tree
4139 4187 // [ ],
4140 4188 immediate_selector(opt,name,size,choices,selected,function) then
4141 4189 [ ],
4142   - html(html_off_form) then
  4190 + html(options, html_off_form) then
4143 4191 [
4144   - "<a href=\"", full_url, "\">",
  4192 + "<a href=\"", full_url,"\"", format_attrs(options), ">",
4145 4193 format(cinfo, ic_v, html_off_form, is_https, action_count, head_tags),
4146 4194 "</a>"
4147 4195 ]
... ... @@ -4288,9 +4336,9 @@ define Printable_tree
4288 4336 "\" name=\"",name,"\" size=\"",size,"\"", format_attrs(options), ">",
4289 4337 if mb_selected is success(selected) then format_choices(choices, selected) else format_choices(choices),"</select>"
4290 4338 ],
4291   - html(html_off_form) then
  4339 + html(options, html_off_form) then
4292 4340 [
4293   - "<a href=\"", url, "\">",
  4341 + "<a href=\"", url,"\"", format_attrs(options), ">",
4294 4342 format(cinfo, ic_v, html_off_form, is_https, action_count, head_tags),
4295 4343 "</a>"
4296 4344 ]
... ... @@ -4857,6 +4905,13 @@ define Printable_tree
4857 4905 ["<li", format_attrs(opts), ">",format_element(e),"</li>\n"],
4858 4906 any_button(options, e) then
4859 4907 [["<button" + format_attrs(options) + ">"], format_element(e),"</button>\n"],
  4908 + any_i(opts,t) then
  4909 + if t = "" then
  4910 + ["<i", format_attrs(opts), "></i>\n"]
  4911 + else
  4912 + ["<i", format_attrs(opts), ">",t,"</i>\n"],
  4913 + any_span(opts , t) then
  4914 + ["<span", format_attrs(opts), ">",t,"</span>"]
4860 4915 }.
4861 4916  
4862 4917  
... ... @@ -5084,7 +5139,11 @@ define Printable_tree
5084 5139 li(opts, t) then
5085 5140 format(cinfo,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags),
5086 5141 button(options, e) then
5087   - format(cinfo,ic_v,any_button(options, e),format_element,is_https, action_count, head_tags),
  5142 + format(cinfo,ic_v,any_button(options, e),format_element,is_https, action_count, head_tags),
  5143 + i(opts, t) then
  5144 + format(cinfo,ic_v,any_i(opts,t),format_element,is_https, action_count, head_tags),
  5145 + span(opts,t) then
  5146 + format(cinfo,ic_v,any_span(opts,t),format_element,is_https, action_count, head_tags)
5088 5147 }.
5089 5148  
5090 5149  
... ... @@ -5172,8 +5231,11 @@ define Bool
5172 5231 ol(_,_) then false,
5173 5232 ul(_,_) then false,
5174 5233 li(_,_) then false,
5175   - button(_,_) then false
5176   - }.
  5234 + button(_,_) then false,
  5235 + i(_,_) then false,
  5236 + span(_,_) then false
  5237 + }
  5238 +.
5177 5239  
5178 5240 define String
5179 5241 enctype
... ... @@ -5312,6 +5374,10 @@ define Printable_tree
5312 5374 format(cinfo,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags),
5313 5375 button(options, e) then
5314 5376 format(cinfo, ic_v, any_button(options, e), format_element, is_https, action_count, head_tags),
  5377 + i(opts, t) then
  5378 + format(cinfo,ic_v,any_i(opts,t),format_element,is_https, action_count, head_tags),
  5379 + span(opts,t) then
  5380 + format(cinfo,ic_v,any_span(opts,t),format_element,is_https, action_count, head_tags),
5315 5381 }.
5316 5382  
5317 5383  
... ...
web/CXM_web_session.anubis
... ... @@ -113,7 +113,7 @@ define List(WEB_Session_Field_No_Var)
113 113  
114 114 public define WEB_Session
115 115 to_WEB_Session
116   - (
  116 + (
117 117 WEB_Session_No_Var _session
118 118 )=
119 119 since _session is web_session(language, fields, web_request, previous_web_request),
... ... @@ -190,9 +190,9 @@ define One
190 190 {
191 191 [] then fields_org <- [session_field(_field_name, _field_type, var(_field_value)) . *fields_org],
192 192 [h . t] then
193   - println("h.field_name = "+h.field_name+" _field_name = "+_field_name);
  193 + //println("h.field_name = "+h.field_name+" _field_name = "+_field_name);
194 194 if h.field_name = _field_name & h.field_type = _field_type then
195   - println("replace field_name found");
  195 + //println("replace field_name found");
196 196 h.field_datum <- _field_value
197 197 else
198 198 replace_any(t, _field_type, _field_name, _field_value, fields_org)
... ...
web/fonts/awesome.anubis 0 โ†’ 100644
  1 +๏ปฟ/*
  2 + * Created by PyramIDE.
  3 + * User: ใƒ•ใƒฉใƒณใ‚นใฎใƒˆใƒˆใƒญ aka (David RENร‰)
  4 + * Date: 23/02/2017
  5 + * Time: 21:43
  6 + * ยฉ Calexium
  7 + */
  8 +
  9 +read calexium_lib/web/CXM_making_a_web_site.anubis
  10 +
  11 +public type Font_Awesome:
  12 + awesome(
  13 + String code
  14 + )
  15 +.
  16 +
  17 +public define HTML_Off_Form
  18 + to_HTML
  19 + (
  20 + Font_Awesome fa
  21 + )=
  22 + since fa is awesome(code),
  23 + i([class("fa fa-"+code), attr("aria-hidden", "true")],"")
  24 +.
... ...
web/widgets/icon.anubis 0 โ†’ 100644
  1 +๏ปฟ/*
  2 + * Created by PyramIDE.
  3 + * User: ใƒ•ใƒฉใƒณใ‚นใฎใƒˆใƒˆใƒญ aka (David RENร‰)
  4 + * Date: 23/02/2017
  5 + * Time: 21:49
  6 + * ยฉ Calexium
  7 + */
  8 +
  9 +transmit calexium_lib/web/fonts/awesome.anubis
  10 +read calexium_lib/web/CXM_making_a_web_site.anubis
  11 +
  12 +public type Icon:
  13 + no_icon,
  14 + font_awesome(
  15 + Font_Awesome fa
  16 + ),
  17 + icon16(
  18 + String name
  19 + ),
  20 + icon32(
  21 + String name
  22 + ),
  23 + icon(
  24 + String name
  25 + )
  26 +.
  27 +
  28 +public define HTML_Off_Form
  29 + to_HTML
  30 + (
  31 + Icon icon
  32 + )=
  33 + if icon is
  34 + {
  35 + no_icon then empty,
  36 + font_awesome(code) then to_HTML(code),
  37 + icon16(name) then todo "handle case 'icon16'",
  38 + icon32(name) then todo "handle case 'icon32'",
  39 + icon(name) then todo "handle case 'icon'"
  40 + }
  41 +.
... ...
web/widgets/menu.anubis 0 โ†’ 100644
  1 +๏ปฟ/*
  2 + * Created by PyramIDE.
  3 + * User: ใƒ•ใƒฉใƒณใ‚นใฎใƒˆใƒˆใƒญ aka (David RENร‰)
  4 + * Date: 18/02/2017
  5 + * Time: 01:52
  6 + * ยฉ Calexium
  7 + */
  8 +
  9 +
  10 +transmit tools/basis.anubis
  11 +read system/string.anubis
  12 +
  13 +read calexium_lib/web/CXM_making_a_web_site.anubis
  14 +transmit calexium_lib/web/widgets/icon.anubis
  15 +
  16 +public type Menu_Item:
  17 + menu_item( //MENU entry
  18 + String text, //text to show
  19 + Icon icon,
  20 + List(String) ids, //it's also use as icon prefix
  21 + List(String) classes, //additional classes if need (for disabling entry, change background color, etc.)
  22 + WEB_Action_Name action, //action (url to apply when click
  23 + List((String, String)) extra, //extra web arguments to send when click
  24 + Actioner_Target target, //target if need
  25 + List(Menu_Item) sub_menu
  26 + //Bool selected
  27 + ),
  28 +// menu_title( //TITLE entry hence no selectable
  29 +// String text, //text to show
  30 +// List(String) ids, //it's also use as icon prefix
  31 +// List(String) classes //additional classes if need (change background color, font size, etc.)
  32 +// ),
  33 + menu_item_content(
  34 + HTML_Partial_Content content
  35 + ),
  36 + menu_separator
  37 +.
  38 +
  39 +public type Menu:
  40 + no_menu,
  41 + menu(
  42 + List(Menu_Item) items
  43 + //String selected
  44 + )
  45 +.
  46 +
  47 +public define Menu_Item
  48 + menu_item
  49 + (
  50 + String text,
  51 + WEB_Action_Name action,
  52 + List((String, String)) extra_op
  53 + )=
  54 + menu_item(text, no_icon, [], [], action, extra_op, same, [])
  55 +.
  56 +
  57 +public define Menu_Item
  58 + menu_item
  59 + (
  60 + String text,
  61 + Icon icon,
  62 + WEB_Action_Name action,
  63 + List((String, String)) extra_op
  64 + )=
  65 + menu_item(text, icon, [], [], action, extra_op, same, [])
  66 +.
  67 +
  68 +public define Menu_Item
  69 + menu_item
  70 + (
  71 + String text,
  72 + WEB_Action_Name action
  73 + )=
  74 + menu_item(text, no_icon, [], [], action, [], same, [])
  75 +.
  76 +
  77 +public define Menu_Item
  78 + menu_item
  79 + (
  80 + String text,
  81 + Icon icon,
  82 + WEB_Action_Name action
  83 + )=
  84 + menu_item(text, icon, [], [], action, [], same, [])
  85 +.
  86 +
  87 +public define Menu_Item
  88 + menu_item
  89 + (
  90 + String text,
  91 + WEB_Action_Name action,
  92 + List(Menu_Item) sub_menu
  93 + )=
  94 + menu_item(text, no_icon, [], [], action, [], same, sub_menu)
  95 +.
  96 +
  97 +public define Menu_Item
  98 + menu_item
  99 + (
  100 + String text,
  101 + Icon icon,
  102 + WEB_Action_Name action,
  103 + List(Menu_Item) sub_menu
  104 + )=
  105 + menu_item(text, icon, [], [], action, [], same, sub_menu)
  106 +.
  107 +
  108 +//public define Nav_Menu_Entry
  109 +// nav_menu_entry
  110 +// (
  111 +// String entry_id, //it's also use as icon prefix
  112 +// WEB_Action_Name action, //action (url to apply when click
  113 +// String text, //text to show
  114 +// List((String, String)) extra //extra web arguments to send when click
  115 +// )=
  116 +// left_menu_entry(entry_id, [], action, text, extra)
  117 +// .
  118 +
  119 +//public define Menu_Item
  120 +// menu_title
  121 +// (
  122 +// String text
  123 +// )=
  124 +// menu_title(text, [], []).
  125 +//
  126 +//public define Menu_Item
  127 +// menu_title
  128 +// (
  129 +// String text,
  130 +// List(String) title_ids,
  131 +// )=
  132 +// menu_title(text, title_ids, []).
  133 +
  134 +define List(HTML_Off_Form)
  135 + generate_menu
  136 + (
  137 + (String) -> String _T, //translator function
  138 + List(Menu_Item) items,
  139 + List(HTML_Off_Form) so_far,
  140 + Int level
  141 + )=
  142 + if items is
  143 + {
  144 + [] then reverse(so_far), //reverse to be in the right direction
  145 + [_item . t] then
  146 + if _item is
  147 + {
  148 + //menu_item then generate_hk_menu(_T, t, so_far, level),
  149 + //li
  150 + menu_item(_text, _icon, _ids, _classes, _action, _extra, _target, _sub_menu) then
  151 + with classes = join(" ",[(if level = 0 then "maintab" else ""),
  152 + (if is_empty(_sub_menu) then "" else "has_submenu") .
  153 + _classes]),
  154 + with current_li = (HTML_Off_Form)li( [class(classes)],
  155 + //if _icon = "" then [] else [class(_icon+"_icon")],
  156 + sequence([actioner(same, _target,
  157 + html(if level = 0 then [class("title")] else [],
  158 + sequence([
  159 + //format the icon if need
  160 + to_HTML(_icon),
  161 + //format the text if need
  162 + if _text = "" then empty else span(_T(_text)), /*link(help_string(_text, _T))*/
  163 + //span(1),
  164 + ])),
  165 +
  166 + _action,_extra
  167 + ),
  168 +
  169 + if is_empty(_sub_menu) then
  170 + empty
  171 + else
  172 + (HTML_Off_Form)ul([class("submenu")], sequence(generate_menu(_T, _sub_menu, [], level+1)))
  173 + ])),
  174 + generate_menu(_T, t, [current_li . so_far], level),
  175 +
  176 +// menu_title(text, _ids, _classes) then
  177 + menu_item_content(_content) then
  178 +// with current_li = (HTML_Off_Form)li([class("item "+_class+"_icon")],actioner(same,same, link(_T(_text)),_action,_extra)),
  179 + with current_li = (HTML_Off_Form)li([],partial(_content)),
  180 + generate_menu(_T, t, [current_li . so_far], level),
  181 + menu_separator then
  182 + with current_li = (HTML_Off_Form)li([],text("--- SEPARATOR ---")),
  183 + generate_menu(_T, t, [current_li . so_far], level)
  184 +
  185 + }
  186 + }
  187 +.
  188 +// //ul
  189 +//
  190 +// hk_menu_list(_class, _action, _text, _extra, _entries) then
  191 +// with current_li =
  192 +// (HTML_Off_Form)li([class(_class+"_icon")],
  193 +// sequence([
  194 +//// actioner(same,same, link(_T(_text)),_action,_extra),
  195 +// actioner(same,same, link(help_string(_text, _T)),_action,_extra),
  196 +// text([class(if level = 0 then "dropBottom" else "dropRight")], ""),
  197 +// (HTML_Off_Form)ul([], sequence(generate_hk_menu(_T, _entries, [], level+1)))])),
  198 +// generate_hk_menu(_T, t, [current_li . so_far], level)
  199 +//
  200 +// }
  201 +// }.
  202 +
  203 +
  204 +define List(HTML_Off_Form)
  205 + make_menu
  206 + (
  207 + (String) -> String _T, //translator function
  208 + List(Menu_Item) menu_items,
  209 + String direction
  210 + )=
  211 + [literal("<nav id=\"nav-"+direction+"\" role=\"navigation\">")] +
  212 + [ul([class("menu")], sequence(generate_menu(_T, menu_items, [], 0)))] +
  213 + [literal(" <span class=\"menu-collapse\"><i class=\"fa fa-step-backward\" aria-hidden=\"true\"></i></span>"),
  214 + literal("</nav>")].
  215 +
  216 +public define HTML_Partial_Content
  217 + make_menu
  218 + (
  219 + (String) -> String _T, //translator function
  220 + Menu _menu,
  221 + String _direction
  222 + )=
  223 + if _menu is
  224 + {
  225 + no_menu then partial_content(empty),
  226 + menu(items) then
  227 + partial_content([css(css_file("/css/cxm/cxm_menu.css"))],
  228 + //partial_content([css(css_file("/css/admin_theme.css"))],
  229 + sequence(make_menu(_T, items, _direction)))
  230 + }.
  231 +
... ...