home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / ProPlus.WW / ProPsWW.cab / FORM_EDIT.JS5 < prev    next >
Text File  |  2007-02-04  |  10KB  |  210 lines

  1. /*********************************************************************
  2.                                  Notice
  3.  
  4. You may not modify, use, copy or distribute this file or its contents. 
  5. Internal interfaces referenced in this file are nonpublic, unsupported 
  6. and subject to change without notice. These interfaces may not be 
  7. utilized in other software applications or components.
  8.  
  9.  
  10. *********************************************************************/
  11.  
  12. // ============================================================ \\
  13. // form_edit.js                                                 \\
  14. // ------------                                                 \\
  15. // This file contains functions that override what is comtained \\
  16. // in form.js, that allow form preview and layout changes.      \\
  17. // ============================================================ \\
  18.  
  19. FieldContainer.prototype.displayFields = function()
  20. {
  21.     var strDivName = "divFieldsContainer";
  22.     if (this.IsHeading)
  23.         strDivName = "divHeadingFieldsContainer";
  24.  
  25.     var FieldsHTML = getFields(this);
  26.     var objDivFieldContainer = document.getElementById(strDivName);
  27.     if (objDivFieldContainer != null)
  28.         objDivFieldContainer.innerHTML = FieldsHTML;
  29. }
  30.  
  31. function getFieldCellHTML(i_FormObject, i_objContainer)
  32. {
  33.     var Priv = getScriptHostQI("IGrooveFormsToolUIDelegatePrivate");
  34.     var FieldCellHTML = "";
  35.  
  36.     if (i_FormObject != null)
  37.     {
  38.         if (i_FormObject.Type == FormObjectType_TabGroup)
  39.         {
  40.             var StyleAttribute = "";
  41.             if (i_FormObject.IsHidden)
  42.                 StyleAttribute = " STYLE=\"display:none;\"";
  43.  
  44.             var FieldBodyHTML = "<TABLE CELLPADDING=\"0\" CELLSPACING=\"0\" BORDER=\"0\" WIDTH=\"100%\"" + StyleAttribute + "><TR>";
  45.  
  46.             if (i_FormObject.Tabs.length > 1)
  47.             {
  48.                 FieldBodyHTML += "<TD>";
  49.                 for (var i = 0; i < i_FormObject.Tabs.length; i++)
  50.                 {
  51.                     var Tab = i_FormObject.Tabs[i];
  52.                     var ClassAttribute = " CLASS=\"";
  53.                     if (i_FormObject.ActiveTabName == Tab.Name || (i == 0 && i_FormObject.ActiveTabName == ""))
  54.                     {
  55.                         i_FormObject.ActiveTabName = Tab.Name;
  56.                         ClassAttribute += "activeTab";
  57.                     }
  58.                     else
  59.                         ClassAttribute += "inactiveTab";
  60.                     FieldBodyHTML += "<SPAN STYLE=\"padding:2px 8px 2px 8px;\"" + ClassAttribute + "\" ID=\"" + Tab.Name + "\" ONCLICK=\"selectTab(obj" + Tab.Name + ", obj" + i_FormObject.Name + ")\" ONMOUSEOVER=\"hoverTab(obj" + Tab.Name + ", obj" + i_FormObject.Name + ")\">" + Tab.Text + "</SPAN>";
  61.                 }
  62.                 FieldBodyHTML += "</TD></TR><TR>";
  63.             }
  64.             FieldBodyHTML += "<TD CLASS=\"tabContents\">";
  65.  
  66.             for (var i = 0; i < i_FormObject.Tabs.length; i++)
  67.             {
  68.                 var Tab = i_FormObject.Tabs[i];
  69.                 var StyleAttribute = " STYLE=\"display:none; width:100%;\"";
  70.                 if (i_FormObject.ActiveTabName == Tab.Name || (i == 0 && i_FormObject.ActiveTabName == ""))
  71.                     StyleAttribute = " STYLE=\"width:100%;\"";
  72.                 var LayoutScript = "";
  73.                 if (i_FormObject.Tabs.length == 1)
  74.                     LayoutScript = " ONCLICK=\"selectTab(obj" + Tab.Name + ", obj" + i_FormObject.Name + ")\" ONMOUSEOVER=\"hoverTab(obj" + Tab.Name + ", obj" + i_FormObject.Name + ")\"";
  75.                 FieldBodyHTML += "<DIV ID=\"" + Tab.Name + "Contents\"" + StyleAttribute + LayoutScript + ">";
  76.                 FieldBodyHTML += getTableHTML(Tab);
  77.                 FieldBodyHTML += "</DIV>";
  78.             }
  79.             FieldBodyHTML += "</TD></TR></TABLE>";
  80.  
  81.             // The CLASS attribute for the TD tag.
  82.             var ClassAttribute = "";
  83.             if (i_FormObject.ClassName != "")
  84.                 ClassAttribute = " CLASS=\"" + i_FormObject.ClassName + "\"";
  85.             // The ONCLICK attribute for the TD tags.
  86.             var OnClickAttribute = " ONCLICK=\"if (typeof obj" + i_FormObject.Name + " != 'undefined') { selectField(obj" + i_FormObject.Name + "); }\"";
  87.             var OnMouseOverAttribute = " ONMOUSEOVER=\"if (typeof obj" + i_FormObject.Name + " != 'undefined') { hoverField(obj" + i_FormObject.Name + "); }\"";
  88.             // The TITLE attribute for the TD tags.
  89.             var MsgFormatEnum = CreateBSTREnumFromArray([i_FormObject.Name]);
  90.             // IDS_FORMS_TOOL_JS_FIELD_TITLE
  91.             TitleAttribute = " TITLE=\"" + Priv.MessageFormat(IDS_FORMS_TOOL_JS_FIELD_TITLE, MsgFormatEnum) + "\"";
  92.             // The common attributes for label and field TD tags.
  93.             var LabelAttributes = " VALIGN=\"top\" STYLE=\"cursor:hand;\"" + OnClickAttribute + OnMouseOverAttribute + " ID=\"" + i_FormObject.Name + "_label\"" + ClassAttribute + TitleAttribute;
  94.             var FieldAttributes = " VALIGN=\"top\" STYLE=\"cursor:hand;\"" + OnClickAttribute + OnMouseOverAttribute + " ID=\"" + i_FormObject.Name + "_field\"" + ClassAttribute + TitleAttribute;
  95.             // The COLSPAN attribute for the TD tag.
  96.             var ColumnSpan = getSpanAttribute("COLSPAN", i_FormObject.ColumnSpan * 2);
  97.             var RowSpan = getSpanAttribute("ROWSPAN", i_FormObject.RowSpan);
  98.             // The COLSPAN attribute for the TD tag.
  99.             var FieldColumnSpan = getSpanAttribute("COLSPAN", (i_FormObject.ColumnSpan * 2) - 1);
  100.             // The FONT tag containing the field label.
  101.             var FieldLabel = "<FONT CLASS=\"fieldLabel\">" + getFieldLabel(i_FormObject) + "</FONT>";
  102.  
  103.             switch (i_FormObject.LabelPosition)
  104.             {
  105.                 case "Right":
  106.                     FieldCellHTML += "<TD" + FieldAttributes + RowSpan + ">" + FieldBodyHTML + "</TD>";
  107.                     FieldCellHTML += "<TD" + LabelAttributes + FieldColumnSpan + RowSpan + ">" + FieldLabel + "</TD>";
  108.                     break;
  109.                 case "Top":
  110.                     var LineBreak = "<BR>";
  111.                     if (getFieldLabel(i_FormObject).indexOf("<div") >= 0)
  112.                         LineBreak = "";
  113.                     FieldCellHTML += "<TD" + FieldAttributes + ColumnSpan + RowSpan + ">" + ((getFieldLabel(i_FormObject) != "") ? FieldLabel + LineBreak : "") + FieldBodyHTML + "</TD>";
  114.                     break;
  115.                 default:
  116.                     FieldCellHTML += "<TD" + LabelAttributes + RowSpan + ">" + FieldLabel + "</TD>";
  117.                     FieldCellHTML += "<TD" + FieldAttributes + FieldColumnSpan + RowSpan + ">" + FieldBodyHTML + "</TD>";
  118.                     break;
  119.             }
  120.         }
  121.         else
  122.         {
  123.             // Get the body HTML for the field.
  124.             var FieldBodyHTML = "";
  125.             if (i_FormObject.Type == FormObjectType_FieldGroup)
  126.                 FieldBodyHTML = getFieldGroupBody(i_FormObject, true);
  127.             else
  128.                 FieldBodyHTML = i_FormObject.getBody();
  129.  
  130.             // The STYLE attribute for TD tags.
  131.             var FieldStyleAttribute = "";
  132.             var LabelStyleAttribute = "";
  133.             // Hide fields that should be hidden.
  134.             if (i_FormObject.IsHidden)
  135.             {
  136.                 FieldStyleAttribute += " STYLE=\"display:none;\"";
  137.                 LabelStyleAttribute += " STYLE=\"display:none;\"";
  138.             }
  139.  
  140.             // The CLASS attribute for the TD tags.
  141.             var ClassAttribute = "";
  142.             if (i_FormObject.ClassName != "")
  143.                 ClassAttribute = " CLASS=\"" + i_FormObject.ClassName + "\"";
  144.             // None of these properties apply to form heading fields.
  145.             var OnClickAttribute = "";
  146.             var OnMouseOverAttribute = "";
  147.             var TitleAttribute = "";
  148.             var LabelAttributes = " VALIGN=\"top\"";
  149.             var FieldAttributes = " VALIGN=\"top\"";
  150.             var ColumnSpan = "";
  151.             var RowSpan = getSpanAttribute("ROWSPAN", i_FormObject.RowSpan);
  152.             // If it is not a form heading field, set appropriate attributes.
  153.             if (!i_objContainer.IsHeading)
  154.             {
  155.                 // The ONCLICK attribute for the TD tags.
  156.                 OnClickAttribute = " ONCLICK=\"if (typeof obj" + i_FormObject.Name + " != 'undefined') { selectField(obj" + i_FormObject.Name + "); }\"";
  157.                 OnMouseOverAttribute = " ONMOUSEOVER=\"if (typeof obj" + i_FormObject.Name + " != 'undefined') { hoverField(obj" + i_FormObject.Name + "); }\"";
  158.                 // The TITLE attribute for the TD tags.
  159.                 var MsgFormatEnum = CreateBSTREnumFromArray([i_FormObject.Name]);
  160.                 // IDS_FORMS_TOOL_JS_FIELD_TITLE
  161.                 TitleAttribute = " TITLE=\"" + Priv.MessageFormat(IDS_FORMS_TOOL_JS_FIELD_TITLE, MsgFormatEnum) + "\"";
  162.                 // The common attributes for label and field TD tags.
  163.                 var LabelAttributes = " VALIGN=\"top\" STYLE=\"cursor:hand;\"" + OnClickAttribute + OnMouseOverAttribute + " ID=\"" + i_FormObject.Name + "_label\"" + ClassAttribute + TitleAttribute;
  164.                 var FieldAttributes = " VALIGN=\"top\" STYLE=\"cursor:hand;\"" + OnClickAttribute + OnMouseOverAttribute + " ID=\"" + i_FormObject.Name + "_field\"" + ClassAttribute + TitleAttribute;
  165.                 // The COLSPAN attribute for the TD tag.
  166.                 var ColumnSpan = getSpanAttribute("COLSPAN", i_FormObject.ColumnSpan * 2);
  167.             }
  168.  
  169.             if (i_FormObject instanceof Static)
  170.             {
  171.                 var AlignAttribute = "";
  172.                 if (i_FormObject.Center)
  173.                     AlignAttribute = " ALIGN=\"center\"";
  174.  
  175.                 FieldCellHTML += "<TD" + FieldAttributes + FieldStyleAttribute + AlignAttribute + ColumnSpan + RowSpan + ">" + FieldBodyHTML + "</TD>";
  176.             }
  177.             else
  178.             {
  179.                 // The COLSPAN attribute for the TD tag.
  180.                 var FieldColumnSpan = getSpanAttribute("COLSPAN", (i_FormObject.ColumnSpan * 2) - 1);
  181.                 // The FONT tag containing the field label.
  182.                 var FieldLabel = "<FONT CLASS=\"fieldLabel\">" + getFieldLabel(i_FormObject) + i_FormObject.getRequired() + "</FONT>";
  183.  
  184.                 switch (i_FormObject.LabelPosition)
  185.                 {
  186.                     case "Right":
  187.                         FieldCellHTML += "<TD" + FieldAttributes + FieldStyleAttribute + RowSpan + ">" + FieldBodyHTML + "</TD>";
  188.                         FieldCellHTML += "<TD" + LabelAttributes + LabelStyleAttribute + FieldColumnSpan + RowSpan + ">" + FieldLabel + "</TD>";
  189.                         break;
  190.                     case "Top":
  191.                         var LineBreak = "<BR>";
  192.                         if (getFieldLabel(i_FormObject).indexOf("<div") >= 0)
  193.                             LineBreak = "";
  194.                         FieldCellHTML += "<TD" + FieldAttributes + FieldStyleAttribute + ColumnSpan + RowSpan + ">" + ((getFieldLabel(i_FormObject) != "" || i_FormObject.getRequired() != "") ? FieldLabel + LineBreak : "") + FieldBodyHTML + "</TD>";
  195.                         break;
  196.                     default:
  197.                         FieldCellHTML += "<TD" + LabelAttributes + LabelStyleAttribute + RowSpan + ">" + FieldLabel + "</TD>";
  198.                         FieldCellHTML += "<TD" + FieldAttributes + FieldStyleAttribute + FieldColumnSpan + RowSpan + ">" + FieldBodyHTML + "</TD>";
  199.                         break;
  200.                 }
  201.             }
  202.         }
  203.     }
  204.     else
  205.     {
  206.         FieldCellHTML += "<TD COLSPAN=\"2\"></TD>";
  207.     }
  208.  
  209.     return FieldCellHTML;
  210. }