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

  1. // global variable decalarations for page objects
  2. var    g_objDispatch = getScriptDispatch();
  3. var g_imgButtonLeft = null;
  4. var g_imgButtonMid = null;
  5. var g_imgButtonRight = null;
  6. var g_imgButtonLeftOver = null;
  7. var g_imgButtonMidOver = null;
  8. var g_imgButtonRightOver = null;
  9.  
  10. // Capture keydown and contextmenu events for the document.
  11. document.onkeydown = keyDownEvent;
  12. document.oncontextmenu = contextMenuEvent;
  13.  
  14. // === keyDownEvent() ==============
  15. // event handler for key down action
  16. function keyDownEvent()
  17. {
  18.     // Capture Ctrl+N and Ctrl+P keystrokes to disable them.
  19.     if (event.ctrlKey && (event.keyCode == 78 || event.keyCode == 80))
  20.         event.returnValue = false;
  21. }
  22.  
  23. // === contextMenuEvent() ==============
  24. // event handler for context menu action
  25. function contextMenuEvent()
  26. {
  27.     // Right-click context menu will only appear if 'Ctrl' key is held down.
  28.     if (!event.ctrlKey)
  29.         event.returnValue = false;
  30. }
  31.  
  32. // === initMainPage() ============================
  33. // initialization function to load main forms page
  34. function initMainPage()
  35. {
  36.     if (g_objDispatch == null)
  37.         return false;
  38.  
  39.     if (!g_objDispatch.GetIsSafeForUI())
  40.     {
  41.         window.setTimeout("initMainPage()", 1000);
  42.         return;
  43.     }
  44.         
  45.     var arrNames = g_objDispatch.GetDatabaseNames();
  46.     if (arrNames.length > 0)
  47.     {
  48.         var viewsEnum = g_objDispatch.GetViewNameURLEnum(arrNames[0]);
  49.         var formsEnum = g_objDispatch.GetFormNameURLEnum(arrNames[0]);
  50.         if (viewsEnum != null && formsEnum != null)
  51.         {
  52.             if (viewsEnum.HasMore() && formsEnum.HasMore())
  53.             {
  54.                 window.location.href = "FormsViewFrame.html";
  55.             }
  56.             else
  57.             {
  58.                 setVisibility("divMain", "visible");
  59.                 disableUICommands();
  60.             }
  61.         }
  62.         else
  63.         {
  64.             window.setTimeout("initMainPage()", 1000);
  65.             return;
  66.         }
  67.     }
  68.     else
  69.     {
  70.         setVisibility("divMain", "visible");
  71.         disableUICommands();
  72.     }
  73.  
  74.     if (g_objDispatch.CanUseDesigner())
  75.     {
  76.         try
  77.         {
  78.             setDisplay("divDesigner", "block");
  79.  
  80.             var intDBCount = g_objDispatch.GetDatabaseCount();
  81.             var bFormsViewsExist = g_objDispatch.AreThereFormsOrViews();
  82.             //if (intDBCount <= 0)
  83.             if (!bFormsViewsExist)
  84.             {
  85.                 setVisibility("spnDesigner", "visible");
  86.                 setDisplay("divButtons", "block");
  87.             }
  88.         }
  89.         catch (error)
  90.         {
  91.             // Hide designer related divs on error.
  92.             setDisplay("divDesigner", "none");
  93.             setVisibility("spnDesigner", "hidden");
  94.             setDisplay("divButtons", "none");
  95.             // Show generic non-designer div on error.
  96.             setDisplay("divNonDesigner", "block");
  97.         }
  98.     }
  99.     else
  100.         setDisplay("divNonDesigner", "block");
  101.  
  102.     // Pre-load the images for the button mouseovers.
  103.     g_imgButtonLeft = new Image(11, 22);
  104.     g_imgButtonLeft.src = "button_left.gif";
  105.     g_imgButtonMid = new Image(11, 22);
  106.     g_imgButtonMid.src = "button_mid.gif";
  107.     g_imgButtonRight = new Image(11, 22);
  108.     g_imgButtonRight.src = "button_right.gif";
  109.     g_imgButtonLeftOver = new Image(11, 22);
  110.     g_imgButtonLeftOver.src = "button_left_over.gif";
  111.     g_imgButtonMidOver = new Image(11, 22);
  112.     g_imgButtonMidOver.src = "button_mid_over.gif";
  113.     g_imgButtonRightOver = new Image(11, 22);
  114.     g_imgButtonRightOver.src = "button_right_over.gif";
  115. }
  116.  
  117. // === goCreate() ========================================
  118. // called when the "Create from Scratch" button is clicked
  119. function goCreate()
  120. {
  121.     g_objDispatch.CreateNewForm();
  122. }
  123.  
  124. // === goBrowse() ========================================
  125. // called when the "Browse Templates..." button is clicked
  126. function goBrowse()
  127. {
  128.     g_objDispatch.ImportDbObjects();
  129. }
  130.  
  131. // === doButtonOver(string) =======================
  132. // highlight button images when user mouses over it
  133. function doButtonOver(i_Name)
  134. {
  135.     changeButtonImages(i_Name, g_imgButtonLeftOver.src, g_imgButtonMidOver.src, g_imgButtonRightOver.src);
  136. }
  137.  
  138. // === doButtonOut(string) ==============================
  139. // reset the button images when the user mouses out of it
  140. function doButtonOut(i_Name)
  141. {
  142.     changeButtonImages(i_Name, g_imgButtonLeft.src, g_imgButtonMid.src, g_imgButtonRight.src);
  143. }
  144.  
  145. // === changeButtonImages(string, string, string, string) ====================
  146. // change the look of a button with the passed in name by replacing the images
  147. function changeButtonImages(i_Name, i_strLeft, i_strMid, i_strRight)
  148. {
  149.     var objButtonLeft = document.getElementById(i_Name + "Left");
  150.     var objButtonMid = document.getElementById(i_Name + "Mid");
  151.     var objButtonRight = document.getElementById(i_Name + "Right");
  152.     if (objButtonLeft && objButtonMid && objButtonRight)
  153.     {
  154.         objButtonLeft.src = i_strLeft;
  155.         objButtonMid.background = i_strMid;
  156.         objButtonRight.src = i_strRight;
  157.     }
  158. }
  159.  
  160. // === setDisplay(string, string) ===================
  161. // sets the dhtml display property for a given object
  162. function setDisplay(i_ID, i_Display)
  163. {
  164.     var objDisplay = document.getElementById(i_ID);
  165.     if (objDisplay != null)
  166.         objDisplay.style.display = i_Display;
  167. }
  168.  
  169. // === setVisibility(string, string) ===================
  170. // sets the dhtml visibility property for a given object
  171. function setVisibility(i_ID, i_Visibility)
  172. {
  173.     var objVisibility = document.getElementById(i_ID);
  174.     if (objVisibility != null)
  175.         objVisibility.style.visibility = i_Visibility;
  176. }
  177.  
  178. // === disableUICommands() =================================
  179. // disable buttons in the command bar that can't be used yet
  180. function disableUICommands()
  181. {
  182.     g_objDispatch.ShowUICommands(true);
  183.     g_objDispatch.SetUICommandEnabled("GUIC_FormsTool_Search", false);
  184.     g_objDispatch.SetUICommandContainerEnabled("GUIC_FormsTool_FormMenu", false);
  185.     g_objDispatch.SetUICommandContainerEnabled("GUIC_FormsTool_ViewMenu", false);
  186. }