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.JS4 < prev    next >
Text File  |  2007-02-04  |  10KB  |  205 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 FieldCellHTML = "";
  34.  
  35.     if (i_FormObject != null)
  36.     {
  37.         if (i_FormObject.Type == FormObjectType_TabGroup)
  38.         {
  39.             var StyleAttribute = "";
  40.             if (i_FormObject.IsHidden)
  41.                 StyleAttribute = " STYLE=\"display:none;\"";
  42.  
  43.             var FieldBodyHTML = "<TABLE CELLPADDING=\"0\" CELLSPACING=\"0\" BORDER=\"0\" WIDTH=\"100%\"" + StyleAttribute + "><TR>";
  44.  
  45.             if (i_FormObject.Tabs.length > 1)
  46.             {
  47.                 FieldBodyHTML += "<TD>";
  48.                 for (var i = 0; i < i_FormObject.Tabs.length; i++)
  49.                 {
  50.                     var Tab = i_FormObject.Tabs[i];
  51.                     var ClassAttribute = " CLASS=\"";
  52.                     if (i_FormObject.ActiveTabName == Tab.Name || (i == 0 && i_FormObject.ActiveTabName == ""))
  53.                     {
  54.                         i_FormObject.ActiveTabName = Tab.Name;
  55.                         ClassAttribute += "activeTab";
  56.                     }
  57.                     else
  58.                         ClassAttribute += "inactiveTab";
  59.                     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>";
  60.                 }
  61.                 FieldBodyHTML += "</TD></TR><TR>";
  62.             }
  63.             FieldBodyHTML += "<TD CLASS=\"tabContents\">";
  64.  
  65.             for (var i = 0; i < i_FormObject.Tabs.length; i++)
  66.             {
  67.                 var Tab = i_FormObject.Tabs[i];
  68.                 var StyleAttribute = " STYLE=\"display:none; width:100%;\"";
  69.                 if (i_FormObject.ActiveTabName == Tab.Name || (i == 0 && i_FormObject.ActiveTabName == ""))
  70.                     StyleAttribute = " STYLE=\"width:100%;\"";
  71.                 var LayoutScript = "";
  72.                 if (i_FormObject.Tabs.length == 1)
  73.                     LayoutScript = " ONCLICK=\"selectTab(obj" + Tab.Name + ", obj" + i_FormObject.Name + ")\" ONMOUSEOVER=\"hoverTab(obj" + Tab.Name + ", obj" + i_FormObject.Name + ")\"";
  74.                 FieldBodyHTML += "<DIV ID=\"" + Tab.Name + "Contents\"" + StyleAttribute + LayoutScript + ">";
  75.                 FieldBodyHTML += getTableHTML(Tab);
  76.                 FieldBodyHTML += "</DIV>";
  77.             }
  78.             FieldBodyHTML += "</TD></TR></TABLE>";
  79.  
  80.             // The CLASS attribute for the TD tag.
  81.             var ClassAttribute = "";
  82.             if (i_FormObject.ClassName != "")
  83.                 ClassAttribute = " CLASS=\"" + i_FormObject.ClassName + "\"";
  84.             // The ONCLICK attribute for the TD tags.
  85.             var OnClickAttribute = " ONCLICK=\"if (typeof obj" + i_FormObject.Name + " != 'undefined') { selectField(obj" + i_FormObject.Name + "); }\"";
  86.             var OnMouseOverAttribute = " ONMOUSEOVER=\"if (typeof obj" + i_FormObject.Name + " != 'undefined') { hoverField(obj" + i_FormObject.Name + "); }\"";
  87.             // The TITLE attribute for the TD tags.
  88.             var TitleAttribute = " TITLE=\"Click to select this field: " + i_FormObject.Name + "\"";
  89.             // The common attributes for label and field TD tags.
  90.             var LabelAttributes = " VALIGN=\"top\" STYLE=\"cursor:hand;\"" + OnClickAttribute + OnMouseOverAttribute + " ID=\"" + i_FormObject.Name + "_label\"" + ClassAttribute + TitleAttribute;
  91.             var FieldAttributes = " VALIGN=\"top\" STYLE=\"cursor:hand;\"" + OnClickAttribute + OnMouseOverAttribute + " ID=\"" + i_FormObject.Name + "_field\"" + ClassAttribute + TitleAttribute;
  92.             // The COLSPAN attribute for the TD tag.
  93.             var ColumnSpan = getSpanAttribute("COLSPAN", i_FormObject.ColumnSpan * 2);
  94.             var RowSpan = getSpanAttribute("ROWSPAN", i_FormObject.RowSpan);
  95.             // The COLSPAN attribute for the TD tag.
  96.             var FieldColumnSpan = getSpanAttribute("COLSPAN", (i_FormObject.ColumnSpan * 2) - 1);
  97.             // The FONT tag containing the field label.
  98.             var FieldLabel = "<FONT CLASS=\"fieldLabel\">" + getFieldLabel(i_FormObject) + "</FONT>";
  99.  
  100.             switch (i_FormObject.LabelPosition)
  101.             {
  102.                 case "Right":
  103.                     FieldCellHTML += "<TD" + FieldAttributes + RowSpan + ">" + FieldBodyHTML + "</TD>";
  104.                     FieldCellHTML += "<TD" + LabelAttributes + FieldColumnSpan + RowSpan + ">" + FieldLabel + "</TD>";
  105.                     break;
  106.                 case "Top":
  107.                     var LineBreak = "<BR>";
  108.                     if (getFieldLabel(i_FormObject).indexOf("<div") >= 0)
  109.                         LineBreak = "";
  110.                     FieldCellHTML += "<TD" + FieldAttributes + ColumnSpan + RowSpan + ">" + ((getFieldLabel(i_FormObject) != "") ? FieldLabel + LineBreak : "") + FieldBodyHTML + "</TD>";
  111.                     break;
  112.                 default:
  113.                     FieldCellHTML += "<TD" + LabelAttributes + RowSpan + ">" + FieldLabel + "</TD>";
  114.                     FieldCellHTML += "<TD" + FieldAttributes + FieldColumnSpan + RowSpan + ">" + FieldBodyHTML + "</TD>";
  115.                     break;
  116.             }
  117.         }
  118.         else
  119.         {
  120.             // Get the body HTML for the field.
  121.             var FieldBodyHTML = "";
  122.             if (i_FormObject.Type == FormObjectType_FieldGroup)
  123.                 FieldBodyHTML = getFieldGroupBody(i_FormObject, true);
  124.             else
  125.                 FieldBodyHTML = i_FormObject.getBody();
  126.  
  127.             // The STYLE attribute for TD tags.
  128.             var FieldStyleAttribute = "";
  129.             var LabelStyleAttribute = "";
  130.             // Hide fields that should be hidden.
  131.             if (i_FormObject.IsHidden)
  132.             {
  133.                 FieldStyleAttribute += " STYLE=\"display:none;\"";
  134.                 LabelStyleAttribute += " STYLE=\"display:none;\"";
  135.             }
  136.  
  137.             // The CLASS attribute for the TD tags.
  138.             var ClassAttribute = "";
  139.             if (i_FormObject.ClassName != "")
  140.                 ClassAttribute = " CLASS=\"" + i_FormObject.ClassName + "\"";
  141.             // None of these properties apply to form heading fields.
  142.             var OnClickAttribute = "";
  143.             var OnMouseOverAttribute = "";
  144.             var TitleAttribute = "";
  145.             var LabelAttributes = " VALIGN=\"top\"";
  146.             var FieldAttributes = " VALIGN=\"top\"";
  147.             var ColumnSpan = "";
  148.             var RowSpan = getSpanAttribute("ROWSPAN", i_FormObject.RowSpan);
  149.             // If it is not a form heading field, set appropriate attributes.
  150.             if (!i_objContainer.IsHeading)
  151.             {
  152.                 // The ONCLICK attribute for the TD tags.
  153.                 OnClickAttribute = " ONCLICK=\"if (typeof obj" + i_FormObject.Name + " != 'undefined') { selectField(obj" + i_FormObject.Name + "); }\"";
  154.                 OnMouseOverAttribute = " ONMOUSEOVER=\"if (typeof obj" + i_FormObject.Name + " != 'undefined') { hoverField(obj" + i_FormObject.Name + "); }\"";
  155.                 // The TITLE attribute for the TD tags.
  156.                 TitleAttribute = " TITLE=\"Click to select this field: " + i_FormObject.Name + "\"";
  157.                 // The common attributes for label and field TD tags.
  158.                 var LabelAttributes = " VALIGN=\"top\" STYLE=\"cursor:hand;\"" + OnClickAttribute + OnMouseOverAttribute + " ID=\"" + i_FormObject.Name + "_label\"" + ClassAttribute + TitleAttribute;
  159.                 var FieldAttributes = " VALIGN=\"top\" STYLE=\"cursor:hand;\"" + OnClickAttribute + OnMouseOverAttribute + " ID=\"" + i_FormObject.Name + "_field\"" + ClassAttribute + TitleAttribute;
  160.                 // The COLSPAN attribute for the TD tag.
  161.                 var ColumnSpan = getSpanAttribute("COLSPAN", i_FormObject.ColumnSpan * 2);
  162.             }
  163.  
  164.             if (i_FormObject instanceof Static)
  165.             {
  166.                 var AlignAttribute = "";
  167.                 if (i_FormObject.Center)
  168.                     AlignAttribute = " ALIGN=\"center\"";
  169.  
  170.                 FieldCellHTML += "<TD" + FieldAttributes + FieldStyleAttribute + AlignAttribute + ColumnSpan + RowSpan + ">" + FieldBodyHTML + "</TD>";
  171.             }
  172.             else
  173.             {
  174.                 // The COLSPAN attribute for the TD tag.
  175.                 var FieldColumnSpan = getSpanAttribute("COLSPAN", (i_FormObject.ColumnSpan * 2) - 1);
  176.                 // The FONT tag containing the field label.
  177.                 var FieldLabel = "<FONT CLASS=\"fieldLabel\">" + getFieldLabel(i_FormObject) + i_FormObject.getRequired() + "</FONT>";
  178.  
  179.                 switch (i_FormObject.LabelPosition)
  180.                 {
  181.                     case "Right":
  182.                         FieldCellHTML += "<TD" + FieldAttributes + FieldStyleAttribute + RowSpan + ">" + FieldBodyHTML + "</TD>";
  183.                         FieldCellHTML += "<TD" + LabelAttributes + LabelStyleAttribute + FieldColumnSpan + RowSpan + ">" + FieldLabel + "</TD>";
  184.                         break;
  185.                     case "Top":
  186.                         var LineBreak = "<BR>";
  187.                         if (getFieldLabel(i_FormObject).indexOf("<div") >= 0)
  188.                             LineBreak = "";
  189.                         FieldCellHTML += "<TD" + FieldAttributes + FieldStyleAttribute + ColumnSpan + RowSpan + ">" + ((getFieldLabel(i_FormObject) != "" || i_FormObject.getRequired() != "") ? FieldLabel + LineBreak : "") + FieldBodyHTML + "</TD>";
  190.                         break;
  191.                     default:
  192.                         FieldCellHTML += "<TD" + LabelAttributes + LabelStyleAttribute + RowSpan + ">" + FieldLabel + "</TD>";
  193.                         FieldCellHTML += "<TD" + FieldAttributes + FieldStyleAttribute + FieldColumnSpan + RowSpan + ">" + FieldBodyHTML + "</TD>";
  194.                         break;
  195.                 }
  196.             }
  197.         }
  198.     }
  199.     else
  200.     {
  201.         FieldCellHTML += "<TD COLSPAN=\"2\"></TD>";
  202.     }
  203.  
  204.     return FieldCellHTML;
  205. }