dojo.anubis 23.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828
/*
 * Created by PyramIDE.
 * User: Steve Marechal
 * Date: 11/06/2008
 * Time: 09:54
 * 
 */

read tools/basis.anubis
read tools/base64.anubis
read locale/L3LanguageInfo.anubis
read system/string.anubis
read system/logger.anubis

read xlib/web/common.anubis
read xlib/web/making_a_web_site.anubis
read xlib/web/multihost_http_server.anubis
 read xlib/net_services_protocols/logger_service.anubis

public type Dojo_Grid_Data :
  grid_data(String).

public type Position_Direction:
 	brup,
 	brleft, 
 	blup, 
 	blright, 
 	trdown, 
 	trleft, 
 	tldown, 
 	tlright.

define String
  pos_dir_to_str
  (
    Position_Direction pos
  )=
  if pos is
  {
    brup    then "br-up",
 	  brleft  then "br-left", 
 	  blup    then "bl-up", 
 	  blright then "bl-right", 
 	  trdown  then "tr-down", 
 	  trleft  then "tr-left", 
 	  tldown  then "tl-down", 
 	  tlright then "tl-right"
  }.



public define HTML_Off_Form
  dojo_button
  	(
  	  String name,
  	  String execute,
  	  String id,
  	)
	=
	literal("
  <button dojoType=\"dijit.form.Button\" id=\""+id+"\" onclick=\""+execute+"\">"+name+"</button>")
.

public type Dojo_Input_Type:
  file,
  text,
  password.

public type InputDial:
  input_dial(HTML_Id id, Dojo_Input_Type input_type, String label, Maybe(String) class),
  input_date(HTML_Id id, String label),
  input_combo(HTML_Id id, String label, List((List(CoreAttrs), WebArgValue, String)) list_data),
  input_check(HTML_Id id, String label, Bool checked),
  input_hidden(HTML_Id id, WebArgValue value).


define List(HTML_Off_Form)
  format_list_data 
  (
    List((List(CoreAttrs), WebArgValue, String))  list_data,
    List(HTML_Off_Form)         result_list
  )=
  if list_data is
  {
    [] then result_list,
    [h . t] then
      if h is (_, wa, label) then
      format_list_data(t, [literal("<option value=\"" + wa.value + "\">" + label + "</option>") . result_list])
  }.

public define HTML_Off_Form
  dojo_combobox
  (
    WebArgName                  the_name,
    HTML_Id                      the_id,
    String                      label,
    List((List(CoreAttrs), WebArgValue, String))  list_data,
  )=
  sequence([
    literal("<label for=\"" + the_id.id + "\">" + label + "</label>
		<select id=\""+the_id.id+"\"
				name=\"" + the_name.name + "\"
				dojoType=\"dijit.form.ComboBox\"
				autoComplete=\"false\">"),
		sequence((format_list_data(list_data, []))),
    literal("</select>")
    ]).

define HTML_Off_Form
  _maybe_label
  (
    String    label_text,
    HTML_Id    html_id
  ) =
  if length(label_text) > 0 then literal("<label for=\"" + html_id.id + "\">" + label_text + "</label>") 
                            else literal("").
   
public define HTML_Off_Form
  dojo_checkbox
  (
    WebArgName    the_name,
    HTML_Id        the_id,
    String        label,
    WebArgValue   val,
    Bool          checked,
  )=
  sequence([
    _maybe_label(label, the_id),
    literal("<input type=\"checkbox\" name=\"" + the_name.name + "\" id=\"" + the_id.id + "\" value=\"" + val.value + "\"" 
            + (if checked then " checked=\"checked\" " else "") + " dojoType=\"dijit.form.CheckBox\" />"),
  ]).


define HTML_Off_Form
  input_in_dialog
  (
    InputDial input_data
  )=
  if input_data is 
  {
    input_dial(html_id, input, label, class) then
      sequence([ 
        literal("<div id=\"" + html_id.id +"_block\"" +
        if class is
        {
          failure then " class=\"dojo_diag\"",
          success(class_name) then " class=\"dojo_diag block_"+ class_name +"\""
        }+"><label for=\"" + html_id.id + "\" id=\"label_" + html_id.id + "\"" +
        if class is
        {
          failure then "",
          success(class_name) then " class=\"label_" + class_name + "\""
        }+">" + label + "</label>"),
        literal("<input dojoType=dijit.form.TextBox " +
        if input is
        {
          file then "type=\"file\"",
          text then "type=\"text\"",
          password then "type=\"password\""
        } +
        " name=\""+html_id.id+"\" id=\""+html_id.id+"\" /></div>")
      ]),
      
    input_date(html_id, label) then 
      sequence([
        literal("<div id=\"" + html_id.id +"_block\" class=\"dojo_diag\" ><label for=\"" + html_id.id + "\"> " + label + "</label>"), 
        literal("<div id=\""+html_id.id+"\" type=\"text\" name=\"date1\"
    					   dojoType=\"dijit.form.DateTextBox\">
    				</div></div>"
    				)
    	]),
    	
  	input_combo(the_id, label, list_data) then
  	  sequence([
    	  literal("<div id=\"" + the_id.id +"_block\" class=\"dojo_diag\">"), 
    	  dojo_combobox(wan(the_id.id), the_id, label, list_data),
    	  literal("</div>")
  	  ]),
  	
  	input_check(the_id, label, checked) then
      sequence([
    	  literal("<div id=\"" + the_id.id +"_block\" class=\"dojo_diag\">"), 
    	  dojo_checkbox(wan(the_id.id), the_id, label, wav("1"), checked),
    	  literal("</div>"),
      ]),
    
    input_hidden(the_id, val) then
    	literal("<input type=\"hidden\" id=\"" + the_id.id +"\" name=\"" + the_id.id +"\" value=\"" + val.value + "\" class=\"dojo_diag\" />"), 
  }
.

define List(HTML_Off_Form)
  inputs_in_dialog
  (
    List(InputDial) inputs_data
  )=
  if inputs_data is
  {
    []      then [],
    [h . t] then [input_in_dialog(h) . inputs_in_dialog(t)]
  }.

public define HTML_Off_Form
  dijit_dialog
  	(
  	  String          name,
  	  String          dialog_id,
  	  String          execute,
  	  String          ok_label,
  	  Maybe(String)   cancel,
  	  List(InputDial) inputs_data,
  	  Maybe(String)   do_cancel
  	)
	=
	sequence([
  	div([attr("dojoType", "dijit.Dialog"), id(dialog_id), title(name), attr("execute", execute)],
  	  sequence([
  	    sequence(inputs_in_dialog(inputs_data)),
  	    literal("<button dojoType=dijit.form.Button type=\"submit\" class=\"dialog_ok\">" + ok_label + "</button>" +
  	       if cancel is
  	       {
  	         failure               then "",
  	         success(cancel_label) then "<button dojoType=dijit.form.Button type=\"cancel\" class=\"dialog_cancel\" onclick=\"" +
  	           if do_cancel is
  	           {
  	             failure then "dijit.byId('"+ dialog_id +"').hide()",
  	             success(to_do_cancel) then to_do_cancel 
  	           }+ "\">" + cancel_label + "</button>"
  	       }),
        br,
  	  ])
  	)
 ])
.

public define HTML_Off_Form
  dojo_dialog
  	(
  	  String        name,
  	  String        dialog_id,
  	  String        execute,
  	  String        ok_label,
  	  Maybe(String) cancel,
  	  List(InputDial) inputs_data,
  	  Maybe(String)   do_cancel
  	)
	=
	sequence[
  	dojo_button(name,"dijit.byId('"+dialog_id+"').show()", dialog_id + "_button"),
  	dijit_dialog(name, dialog_id, execute, ok_label, cancel, inputs_data, do_cancel)
  ]
.




public type DojoGridEditor:
  inputEditor,
  boolEditor,
  selectEditor(List(String) options),
  alwaysOnEditor.
 
public type DojoGridDefaultColumn:
  dojo_grid_default_column( 
                    String                styles,
                    Maybe(String)         width,
                    Maybe(DojoGridEditor) editor).

public type DojoGridColumn:
  dojo_grid_column( String        label,
                    String        field_name,
                    Maybe(String) width,
                    Maybe(DojoGridEditor) editor).

public type  DojoGridView:
  dojo_grid_view(
      Maybe(DojoGridDefaultColumn)  default_column,
      List(DojoGridColumn)          columns).

public type  DojoGridLayout:
  dojo_grid_layout(
      Maybe(String)       selectable_row_header_width,
      List(DojoGridView)  views).

define String to_String(DojoGridEditor editor) =
  "editor: " + 
    if editor is
    {
      inputEditor           then "dojox.grid.editors.Input",
      boolEditor            then "dojox.grid.editors.Bool",
      selectEditor(options) then "dojox.grid.editors.Select, options: [" + join(",", map((String o) |-> "\"" + o + "\"", options)) + "]",
      alwaysOnEditor        then "dojox.grid.editors.AlwaysOn"
    }.

define String to_String(DojoGridView view) =
  "{ " + (if view.default_column is success(col) then 
            (if col is dojo_grid_default_column(styles, mb_width, mb_editor) then
            "defaultCell: {"
                   + "styles: \"" + styles + "\""
                   + (if mb_width is success(w) then ", width=\"" + w + "\"" else "")
                   + (if mb_editor is success(e) then ", " + to_String(e) else "")
                   + "}, ")
          else "")
       + "cells: [[" + join(",", map((DojoGridColumn col) |->
                                     if col is dojo_grid_column(label, field, mb_width, mb_editor) then
                                     "{"
                                           + "name: \"" + label + "\""
                                           + "field: \"" + field + "\""
                                           + (if mb_width is success(w) then ", width=\"" + w + "\"" else "")
                                           + (if mb_editor is success(e) then ", " + to_String(e) else "")
                                   + "}",
                                 view.columns)) + "]]"
  +"}".
  

public define String
  dojo_make_grid_script
    (
  	  HTML_Id                html_id,
  	  DojoGridLayout        layout,
  	  String                layout_name,
  	  String                store_name,
      Bool                  can_edit
   )
  =
"<script type=\"text/javascript\">
  " + layout_name + " = [" 
      + (if layout.selectable_row_header_width is success(w) then "{ type: 'dojox.GridRowView', width: '" + w + "'}, " else "")
      + join(", ", map(to_String, layout.views))
    + "];
</script>".

public define HTML_Off_Form
  dojo_make_grid_script
    (
  	  HTML_Id          html_id,
  	  List(String)    columns,
      Bool            can_edit
   )
  =
  literal(
"<script type=\"text/javascript\">
  var cols = ["+join(",", map((String col) |-> "\"" + col + "\"", columns)) + "];
 	dojo.addOnLoad(function(){
	  init_dojo_grid(\""+html_id.id+"\", cols, "+ (if can_edit then "1" else "0")+");
 	});
</script>").

public define HTML_Off_Form
  dojo_grid
    (
  	  HTML_Id                html_id,
      Int                   rowsPerPage,
      List(Table_Option)    attributes,
    )=
    table([attr("dojoType", "dojox.grid.DataGrid"), attr("id", html_id.id), attr("jsId", html_id.id), 
           class("soria"), attr("singleClickEdit", "true"), attr("rowsPerPage", to_decimal(rowsPerPage)) . attributes],
         empty, [], empty).


public define HTML_Off_Form
  dojo_grid
  (
    HTML_Id            html_id,
    List(CoreAttrs)   attributes,
//  	  List(GridColumn)  columns,
      String colum1,
      String colum2,
      String colum3,
      String colum4,
      Bool              can_edit
   )
  =
  sequence([
    literal(

"<script type=\"text/javascript\">
  dojo.addOnLoad(function(){
   init_dojo_grid(\""+html_id.id+"\", \""+colum1+"\",\""+colum2+"\", \""+colum3+"\", \""+colum4+"\", "+ (if can_edit then "1" else "0")+");
});
</script>"),
    div([id(html_id.id) . attributes /*attr("dojoType", "dojox.Grid"), */]),
  ]).
//<div id=\"gridContainer\"></div>").


public define HTML_Off_Form
  dojo_message_box
  (
    HTML_Off_Form name1,
    HTML_Off_Form name2,
  )=
  sequence([
    br,
    div([class("message_box")], [
        div([id("node3"), class("box nopad hidden")], name1),
        div([id("node4"), class("box two nopad")], name2),
      ]),
    br,
  ]).



public define HTML_Off_Form
  dojo_tooltip
  (
    String title,
    String keyword,
  ) =
  actioner(same,same, link([id("dojo_tip_" + keyword),class("dojoToolTip")],title, success(title)), "show_address_mailing", [("address_mailing", keyword)], []).
  //actioner(same, same, push_button([id("dojo_tip_" + keyword), class("in"), event(onclick,"new_search(this)")], keyword), "", [], []).
  

public type BorderContainerRegion:
  center, 
  top,
  bottom,
  leading,
  trailing,
  left,
  right.

define String 
  to_String
  (
    BorderContainerRegion region
  )=
  if region is
  {
    center    then "center", 
    top       then "top",
    bottom    then "bottom",
    leading   then "leading",
    trailing  then "trailing",
    left      then "left",
    right     then "right"
  }.
  
public type BorderContainerDesign:
  headline,
  sidebar.

define String 
  to_String
  (
    BorderContainerDesign design
  )=
  if design is
  {
    headline   then "headline",
    sidebar    then "sidebar" 
  }.
  
  
public define HTML_Off_Form
  dojo_ContentPane
  (
      List(CoreAttrs)       attributes,
      BorderContainerRegion region,
      Bool                  splitter,
      HTML_Off_Form         content
  )  =
  div([ attr("dojoType", "dijit.layout.ContentPane"), 
        attr("region", to_String(region)), 
        attr("splitter", if splitter then "true" else "false") . attributes ],
      content).

public define HTML_In_Form
  dojo_ContentPane
  (
      List(CoreAttrs)       attributes,
      BorderContainerRegion region,
      Bool                  splitter,
      HTML_In_Form         content
  )  =
  div([ attr("dojoType", "dijit.layout.ContentPane"), 
        attr("region", to_String(region)), 
        attr("splitter", if splitter then "true" else "false") . attributes ],
      content).
      
public define HTML_Off_Form
  dojo_TabContainer
  (
      List(CoreAttrs) attributes,
      HTML_Off_Form   content
  )  =
  div([attr("dojoType", "dijit.layout.TabContainer") . attributes ],
      content).


public define HTML_Off_Form
  dojo_BorderContainer
  (
      List(CoreAttrs)       attributes,
      Maybe(String)         the_title,
      BorderContainerDesign design,
      Bool                  live_splitter,
      Bool                  persist,
      Bool                  closable,
      String                container,
      HTML_Off_Form         content
  )  =
  with the_attributes = (List(CoreAttrs)) [attr("dojoType", "dijit.layout.BorderContainer"), attr("dojoAttachPoint", container),
                         attr("design", to_String(design)), attr("liveSplitters", live_splitter), attr("persist", persist), 
                         attr("closable",closable) . attributes ],
       total_attributes = if the_title is
                          {
                            failure then the_attributes,
                            success(t) then [title(t) . the_attributes]
                          },
  div(total_attributes, content).

public define HTML_In_Form
  dojo_BorderContainer
  (
      List(CoreAttrs)       attributes,
      Maybe(String)         the_title,
      BorderContainerDesign design,
      Bool                  live_splitter,
      Bool                  persist,
      Bool                  closable,
      String                container,
      HTML_In_Form         content
  )  =
  with the_attributes = (List(CoreAttrs)) [attr("dojoType", "dijit.layout.BorderContainer"), attr("dojoAttachPoint", container),
                         attr("design", to_String(design)), attr("liveSplitters", live_splitter), attr("persist", persist), 
                         attr("closable",closable) . attributes ],
       total_attributes = if the_title is
                          {
                            failure then the_attributes,
                            success(t) then [title(t) . the_attributes]
                          },
  div(total_attributes, content).    

public define HTML_Off_Form
  dojo_tree
  (
      List(CoreAttrs) attributes,
  )=
  div(attributes).



public define HTML_Off_Form
  dojo_Toolbar
  (
    List(CoreAttrs) attributes,
    HTML_Off_Form         content
  )=
  div([attr("dojoType", "dijit.Toolbar") . attributes ],
      content).


public define HTML_Off_Form
  dojo_tooltip
  (
    List(CoreAttrs)   attributes,
//    List(Text_Option) txt_attr,  
    HTML_Id            html_id,
    String            label,
    HTML_Off_Form     tooltip_content,
  )=
  sequence([
    text([id(html_id.id)], label),
    div([id(html_id.id + "_tt"), attr("connectId", html_id.id), attr("dojoType", "dijit.Tooltip") . attributes], tooltip_content)
  ]).
  
  
public define HTML_Off_Form
  dojo_button
  	(
  	  HTML_Id        html_id,
//  	  Maybe(String) class,
  	  String        name,
  	  String iconclass,
  	  Maybe(String) tip_msg,
  	  String        execute,
  	)=
	literal("
    <button dojoType=\"dijit.form.Button\" id=\"" + html_id.id + "\" iconClass=\"" + iconclass + "\" >" 
  + name
  + "<script type=\"dojo/method\" event=\"onClick\">"
  + execute
  + "</script>"
  + "</button>" +
  if tip_msg is 
  {
    failure then "",
    success(tip) then 
      "<span dojoType=\"dijit.Tooltip\" connectId=\"" + html_id.id + "\">" + tip + "</span>"
  }).

public define HTML_In_Form
   dojo_button
  	(
  	  HTML_Id        html_id,
//  	  Maybe(String) class,
  	  String        name,
  	  String iconclass,
  	  Maybe(String) tip_msg,
  	  String        execute,
  	)=
	literal("
    <button dojoType=\"dijit.form.Button\" id=\"" + html_id.id + "\" iconClass=\"" + iconclass + "\" >" 
  + name
  + "<script type=\"dojo/method\" event=\"onClick\">"
  + execute
  + "</script>"
  + "</button>" +
  if tip_msg is 
  {
    failure then "",
    success(tip) then 
      "<span dojoType=\"dijit.Tooltip\" connectId=\"" + html_id.id + "\">" + tip + "</span>"
  }).


public define HTML_Off_Form
  dojo_declaration
  	(
      String          name,
      List(CoreAttrs) attributes,
      HTML_Off_Form   content
    )=
  div([attr("dojoType", "dijit.Declaration"), attr("widgetClass", name) . attributes ],
      content).
 

public define HTML_In_Form
  dojo_declaration
  	(
      String          name,
      List(CoreAttrs) attributes,
      HTML_In_Form    content
    )=
  div([attr("dojoType", "dijit.Declaration"), attr("widgetClass", name) . attributes ],
      content).

public define HTML_Off_Form
  dojo_editor
  	(
      List(CoreAttrs)  attributes,
      HTML_Id           html_id,
      WebArgName       input_name,
      HTML_Off_Form     text,
    )=
    div([id(html_id.id), attr("name", input_name.name), attr("dojoType", "dijit.Editor")
	  ,attr("extraPlugins", "['|', 'foreColor','hiliteColor',{name:'dojox.editor.plugins.FontChoice', command:'fontName', generic:true},'fontSize','formatBlock','|','createLink','insertImage']")
  	. attributes], text).
 
  public define HTML_In_Form
  dojo_button
  	(
  	  HTML_Id        html_id,
  	  String        name,
  	  String        iconclass,
  	  Maybe(String) tip_msg,
  	  String        execute,
  	)=
	literal("<input id=\"realSubmitButton"+ html_id.id + "\" type=\"submit\" style=\"display:none\">
    <button dojoType=\"dijit.form.Button\" id=\"" + html_id.id + "\" iconClass=\"" + iconclass + "\" onclick=\"dojo.byId('realSubmitButton" + html_id.id + "').click();" + execute + "\">" + name + "</button>" +
    if tip_msg is 
    {
      failure then "",
      success(tip) then 
        "<span dojoType=\"dijit.Tooltip\" connectId=\"" + html_id.id + "\">" + tip + "</span>"
    }).

public define HTML_In_Form
  dojo_checkbox
  (
    List(CoreAttrs) attributes,
    WebArgName      name,
    HTML_Id         id,
    String          label_str,
    Bool            checked,
  )=
    check_box_r([attr("dojoType", "dijit.form.CheckBox") . attributes] , label(label_str, no_help), id, name, checked).

public define HTML_In_Form
  dojo_combobox
  (
    List(CoreAttrs)            attributes,
    WebArgName                  name,
    HTML_Id                      id,
    String                      label_str,
    List((List(CoreAttrs),WebArgValue,String))  list_data,
    InitialValue                selected,
  )=
   // selector_c([attr("dojoType", "dijit.form.ComboBox") . attributes], label, id, name, 1, list_data, selected, non_mandatory).
  selector_c([attr("dojoType", "dijit.form.ComboBox") . attributes], label(label_str, no_help), id, name, 1, list_data, selected).

public define HTML_Off_Form
  dojo_toaster
  (
    List(CoreAttrs)            attributes,
    HTML_Id                     html_id,
    String                     message_topic,
    Position_Direction         position_direction,
    Bool                       separator,
    Maybe(Int)                 duration
  )=
  div(append(append(if separator then [attr("separator","&lt;hr&gt;")]
             else [],
             if duration is
             {
              failure then [],
              success(dur) then [attr("duration", abs_to_decimal(dur))]
             }),
             [attr("dojoType", "dojox.widget.Toaster"), attr("messageTopic", message_topic),
      attr("positionDirection", pos_dir_to_str(position_direction)), id(html_id.id) 
      . attributes ]),
      literal("")).
  
public define HTML_Off_Form
  dojo_progressBar
  (
    List(CoreAttrs)            attributes,
//    List(Text_Option)          attributes_text,
    HTML_Id                    html_id,
    String                     label
  )=
   sequence([
     text([id("text_" + html_id.id), class("progress_bar")], label),
     div([id(html_id.id), class("progress_bar"), attr("indeterminate", "true"), attr("dojoType", "dijit.ProgressBar") . attributes], literal(""))
   ]).

public define HTML_Off_Form
  dojo_progressBar
  (
    List(CoreAttrs)            attributes,
//    List(Text_Option)          attributes_text,
    HTML_Id                    html_id,
    String                     label,
    Int                        progress,
    Int                        maximum
  )=
   sequence([
     text([id("text_" + html_id.id), class("progress_bar")], label),
     div([id(html_id.id), 
          class("progress_bar"), 
          attr("maximum",   abs_to_decimal(maximum)), 
          attr("progress",  abs_to_decimal(progress)), 
          attr("dojoType", "dijit.ProgressBar") . attributes])
   ]).

define Maybe(Int)
  string_to_month
  (
    String month_s
  )=
  with month = to_lower(month_s),
  if      month = "jan" then success(1)
  else if month = "feb" then success(2)
  else if month = "mar" then success(3)
  else if month = "apr" then success(4)
  else if month = "may" then success(5)
  else if month = "jun" then success(6)
  else if month = "jul" then success(7)
  else if month = "aug" then success(8)
  else if month = "sep" then success(9)
  else if month = "oct" then success(10)
  else if month = "nov" then success(11)
  else if month = "dec" then success(12)
  else failure
  .


//  'Thu Jan 14 2010 00:00:00 GMT+0100' must be replaced by '2010-01-14 00:00:00'



public define Maybe(String)
  dojo_date_to_db_datetime
  (
    String data
  )=
  with list_data = split_by_token(data, ' '),
  if nth(2, list_data) is
  {
    failure then failure,
    success(day) then
      if nth(1, list_data) is
      {
        failure then failure,
        success(month) then
          if nth(3, list_data) is
          {
            failure then failure,
            success(year) then
              if nth(4, list_data) is
              {
                failure then failure,
                success(hour) then
                  if string_to_month(month) is
                  {
                    failure then failure,
                    success(month_int) then
                      success(year+"-"+month_int+"-"+day+" "+hour)
                  }
              }
          }
      }
  }.
 
public define List(HTML_Head_Tag)
   dojo_defaults
   =
   [
      // js(js_file("js/dojo/dojo.js", [attr("djConfig", "parseOnLoad: true, isDebug: " + (if debug_mode then "true" else "false") + ", usePlainJson: true")])),
      js(js_file("js/dojo/dojo/dojo.js", [attr("djConfig", "parseOnLoad: true, isDebug: false, usePlainJson: true")])),
      js(js_file("js/dojo/dijit/dijit.js")),
      //css(css_file("js/dojo/dojo/resources/dojo.css"))
   ].
  
   
public define List(HTML_Head_Tag)
  dojo_init
  (
    String web_dir,
    String theme_name
  )
  =
  with _theme_name = if file_exists(web_dir+"/public/js/dojo/dijit/themes/"+theme_name+"/"+theme_name+".css")then theme_name else "claro",
  [ css(css_file("js/dojo/dijit/themes/"+_theme_name+"/"+_theme_name+".css")) .
    [ css(css_file("js/dojo/dijit/themes/"+_theme_name+"/"+_theme_name+"_rtl.css")) . dojo_defaults ]
  ]
  .