CXM_dojo.anubis 9.87 KB
/*
 * 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 calexium_lib/web/CXM_common.anubis
read calexium_lib/web/CXM_making_a_web_site.anubis
read calexium_lib/web/CXM_multihost_http_server.anubis
read calexium_lib/net_services_protocols/logger_service.anubis

read mailfountain_constants.anubis
read mailfountain_types.anubis
read common/language_management.anubis

read tools/mf_loggers.anubis
read system/logger.anubis

public type Dojo_Grid_Data :
  grid_data(String).

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 define HTML_Off_Form
  dojo_dialog
  	(
  	  String name,
  	  String dialog_id,
  	  String execute,
  	)
	=
	sequence[
  	dojo_button(name,"dijit.byId('"+dialog_id+"').show()", "dialog_id"),
  	div([attr("dojoType", "dijit.Dialog"), id(dialog_id), title(name), attr("execute", execute)],
  	  table([], 
  	        empty, 
  	        [
  	          row([], [cell([], literal("<input dojoType=dijit.form.TextBox type=\"text\" name=\"name\" id=\"name_"+dialog_id+"\" />"))]),
  	          row([], [cell([columns(2), h_center], literal("<button dojoType=dijit.form.Button type=\"submit\">OK</button>"))]),
  	        ],
  	        empty)),
  	literal("<br/>"),
//  	literal("
//    <div dojoType=\"dijit.Dialog\" id=\""+id+"\" title=\""+name+"\"
//  		execute=\""+execute+"\">
//  	<table>
//  		<tr>
//  			<td><input dojoType=dijit.form.TextBox type=\"text\" name=\"name\" id=\"name_"+id+"\"></td>
//  		</tr>
//  		
//  		<tr>
//  			<td colspan=\"2\" align=\"center\">
//  				<button dojoType=dijit.form.Button type=\"submit\">OK</button></td>
//  		</tr>
//  	</table>
//  </div><br />")
  ]
.
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
    (
  	  HtmlId                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
    (
  	  HtmlId          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
    (
  	  HtmlId                html_id,
      List(CoreAttrs)       attributes,
   )
  =
  div_empty([id(html_id.id), attr("dojoType", "dojox.Grid") . attributes ]).


public define HTML_Off_Form
  dojo_grid
    (
  	  HtmlId            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_empty([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([
  	literal("<br/>"),
    div([class("message_box")],
      sequence([
			  div([id("node3"), class("box nopad hidden")], name1),
			  div([id("node4"), class("box two nopad")], name2),
			])),
  	literal("<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 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).
//    sequence([
//      literal("<div id=\"" + id + "\" dojoType=\"dijit.layout.ContentPane\" region=\"" + to_String(region) + "\" splitter=\""
//      +(
//      if splitter then "true"
//        else "false"
//      )+
//   //   "\" style=\"overflow: auto;\""+
//    //  "\" minSize=\"20em\""+
//      "\">"),
//      content,
//      literal("</div>")
//      ]).
      
public define HTML_Off_Form
  dojo_TabContainer
  (
      List(CoreAttrs) attributes,
      HTML_Off_Form   content
  )  =
  div([attr("dojoType", "dijit.layout.TabContainer") . attributes ],
      content).
//    sequence([
//      literal("<div id=\"" + id + "\" dojoType=\"dijit.layout.TabContainer\" style=\"width:70em;height:50em\">"),
//      content,
//      literal("</div>")
//      ]).      

public define HTML_Off_Form
  dojo_BorderContainer
  (
      List(CoreAttrs) attributes,
      String          the_title,
      Bool            live_splitter,
      Bool            persist,
      HTML_Off_Form   content
  )  =
  div([attr("dojoType", "dijit.layout.BorderContainer"), title(the_title), 
       attr("design", "sidebar"), attr("liveSplitters", live_splitter), attr("persist", persist) . attributes ],
      content).
    

public define HTML_Off_Form
  dojo_tree
  (
      List(CoreAttrs) attributes,
  )=
  div_empty(attributes).
// literal("<div id=\"" + id + "\"</div>").


public define HTML_Off_Form
  dojo_Toolbar
  (
    List(CoreAttrs) attributes,
    HTML_Off_Form         content
  )=
  div([attr("dojoType", "dijit.Toolbar") . attributes ],
      content).
//  sequence([
//    literal("<div dojoType=\"dijit.Toolbar\" region=\"top\" id =\"" + id + "\">"),
//    content,
//    literal("</div>")
//  ]).
  
  
public define HTML_Off_Form
  dojo_button
  	(
  	  HtmlId html_id,
  	  String name,
  	  String iconclass,
  	  String tip_msg,
  	)
	=
	literal("
  <button dojoType=\"dijit.form.Button\" id=\"" + html_id.id + "\" iconClass=\"" + iconclass + "\">" + name + "</button>
 	<span dojoType=\"dijit.Tooltip\" connectId=\"" + html_id.id + "\">" + tip_msg + "</span>").