0byt3m1n1
Path:
C:
/
Program Files (x86)
/
Microsoft Office
/
Office12
/
Groove
/
ToolData
/
groove.net
/
GrooveForms
/
[
Home
]
File: VIEW.JS
// Global variable decalarations for page objects. var g_objDispatch = getScriptDispatch(); var g_BasePath = g_objDispatch.GetBasePath(); var g_objDataList = null; var g_AllowCreate = null; var g_AllowEdit = null; var g_AllowDelete = null; // Global variable used in enabledatalist call. var g_CalledInitialized = false; var g_DataListInitialized = false; // Global variables to keep the current and previous record info. var g_CurrentRecordID = null; var g_CurrentFormURL = null; var g_PreviousRecordID = null; var g_PreviousFormURL = null; // Global variables to be used for button image hovering. var g_imgButtonLeft = null; var g_imgButtonMid = null; var g_imgButtonRight = null; var g_imgButtonLeftOver = null; var g_imgButtonMidOver = null; var g_imgButtonRightOver = null; var g_TimeoutIncrement = 1; // Include the stylesheet code as it was broken with the IE security patch. document.write("<STYLE TYPE=\"text/css\">"); document.write("BODY, TD, DIV, A, SELECT { font-family:arial,verdana,sans-serif; font-size:11px; color:rgb(0,0,0); }"); document.write("BODY { margin:4px 8px 8px 8px; background-color:rgb(134,152,175); }"); document.write("INPUT { width:75px; }"); document.write(".button, .button TD { font-family:tahoma,sans-serif; color:rgb(255,255,255); cursor:default; }"); document.write(".heading { font-family:tahoma,sans-serif; font-size:18px; font-weight:bold; color:rgb(10,53,108); }"); document.write("#divViewNavBase { height:28px; }"); document.write("#divSearchCount, #divViewCount { font-family:tahoma,sans-serif; font-style:italic; color:rgb(255,255,255); }"); document.write("</STYLE>"); // Capture keydown and contextmenu events for the document. document.onkeydown = keyDownEvent; document.oncontextmenu = contextMenuEvent; // === keyDownEvent() ============== // event handler for key down action function keyDownEvent() { // Capture Backspace, Ctrl+N, and Ctrl+P keystrokes to disable them. if (event.ctrlKey && (event.keyCode == 78 || event.keyCode == 80)) event.returnValue = false; } // === contextMenuEvent() ============== // event handler for context menu action function contextMenuEvent() { // Right-click context menu will only appear if 'Ctrl' key is held down. if (!event.ctrlKey) event.returnValue = false; } // === initDataList(bool) ====================== // data view initialization, sets up event sinks function initDataList(i_blnHideButtons) { if (g_objDispatch == null) return false; // Set forms glue global variable for command bar. g_objDispatch.SetOnFormPage(false); // Pass out document to be used by glue code. g_objDispatch.SetCurrentDocument(document); // Find the data view object in the page. var arrObject = document.getElementsByTagName("OBJECT"); if (arrObject.length > 0) g_objDataList = arrObject[0]; if (g_objDataList) { // Set up the event sinks for the data view object. document.getElementById("ViewDblClickScript").htmlFor = g_objDataList.name; document.getElementById("ViewSelectionChangedScript").htmlFor = g_objDataList.name; } if (g_objDataList) { g_CalledInitialized = false; try { if (!g_objDataList.IGrooveDataListDisplay.Initialized) { window.setTimeout("enableDataList()", 10); } else { enableDataList(); } } catch (error) { g_objDispatch.ActiveXMessageBox(); } } if (i_blnHideButtons) { // Hide the view buttons if they should not be displayed. var objDivViewNavBase = document.getElementById("divViewNavBase"); objDivViewNavBase.style.display = "none"; } else { // Set-up the buttons to be displayed on the view. setupViewButtons(); // Make the buttons disabled by default, they will be re-enabled when a record is selected. canEditOrDelete(-1); } } // === enableDataList() =========================================== // make sure a record is selected when the data list is initialized function enableDataList() { try { if (g_objDataList.IGrooveDataListDisplay.Initialized) { g_DataListInitialized = true; var intFocusRowID = g_objDataList.IGrooveDataListDisplay.FocusRow; var intCurrentRowID = g_objDispatch.GetSelectedRecordID(); if (intCurrentRowID == null || intCurrentRowID == -1 || intFocusRowID == intCurrentRowID) { goPreview(intFocusRowID); goSetSelectedRecordID(intFocusRowID); } else { g_objDataList.IGrooveDataListDisplay.SetFocusRow(intCurrentRowID); } g_objDispatch.ShowUICommands(true); g_objDispatch.ShowMenuCommands(); } else { if (!g_CalledInitialized) { g_objDispatch.InitializeRunTimeSettings(true); g_CalledInitialized = true; } window.setTimeout("enableDataList()", 10); } } catch (error) { window.setTimeout("enableDataList()", 10) } } // === goEdit() ====================================================== // open the selected record in the form it was created in for updating function goEdit() { if (g_CurrentRecordID >= 0 && g_AllowEdit) { var FormUrl = g_CurrentFormURL + "?RecordID=" + g_CurrentRecordID; if (FormUrl != "") { g_objDispatch.WebBrowserViewNavigate(FormUrl); g_objDispatch.HideUICommands(); } } } // === goOpen(integer) ============================= // open the record for the passed in id for updating function goOpen(i_RowID) { if (typeof i_RowID == "undefined" || i_RowID == null) { if (g_CurrentRecordID > 0) i_RowID = g_CurrentRecordID; else return; } var FormUrl = g_objDispatch.GetFormUrlByRecordID(i_RowID); if (g_objDispatch.CanEdit(i_RowID)) g_objDispatch.WebBrowserViewNavigate(FormUrl + "?RecordID=" + i_RowID); else g_objDispatch.WebBrowserViewNavigate(FormUrl + "?RecordID=" + i_RowID + "&noedit=true"); g_objDispatch.HideUICommands(); } // === goDelete() ======================================= // delete the selected record and clear the preview frame function goDelete() { try { if (g_CurrentRecordID >= 0 && g_AllowDelete) { if (g_objDispatch.YesNoMessageBox("This operation cannot be undone. Are you sure you want to delete the selected record?", "Delete Record")) { g_objDispatch.DeleteRecord(g_CurrentRecordID); resetPreviewPane(); if (g_objDispatch.GetRecordCount() <= 0) { doButtonDisable("EditButton"); doButtonDisable("DeleteButton"); } } } if(g_objDataList) g_objDataList.focus(); } catch(error) { } } // === goSearch() ============================ // perform a search of the data using any form function goSearch() { g_objDispatch.LoadFormSearchControl(); } // === goClear() ============== // clear the search result data function goClear() { g_objDispatch.ClearSearchResults(); } // === goPreview(integer) ========================= // preview the selected record in the preview frame function goPreview(i_RowID) { var RecordID = i_RowID; if (RecordID != null && RecordID != -1) { g_PreviousRecordID = RecordID; g_PreviousFormURL = g_CurrentFormURL; g_CurrentFormURL = g_objDispatch.GetFormUrlByRecordID(RecordID); if (g_PreviousFormURL == g_CurrentFormURL && g_PreviousFormURL != null) { var PreviewValid = g_objDispatch.DisplayPreviewForRecordID(RecordID) // If we get a 'Permission Denied' error, timeout then try again. if (PreviewValid == -2146828218) { if ((50 * (2 * g_TimeoutIncrement)) >= 2000) { g_objDispatch.OKMessageBox("Groove was unable to properly update the preview pane due to an error, but will refresh the Forms tool when you close this message. This should resolve the problem.", "Alert"); g_objDispatch.LoadHomePage(); return; } else { g_objDispatch.GrooveDebugFunctions.OutputString("\n Received Permission denied error - current backoff is: " + 50 * (2 * g_TimeoutIncrement) + "\n\n"); window.setTimeout("goPreview(" + i_RowID + ")", 50 * (2 * g_TimeoutIncrement++)); return; } } else if (PreviewValid == -1) { g_TimeoutIncrement = 1; g_objDispatch.WebBrowserViewNavigatePreview(g_CurrentFormURL + "?RecordID=" + RecordID + "&preview=true"); } } else if (g_CurrentFormURL != null && g_CurrentFormURL != "") { g_TimeoutIncrement = 1; g_objDispatch.WebBrowserViewNavigatePreview(g_CurrentFormURL + "?RecordID=" + RecordID + "&preview=true") } else resetPreviewPane(); } else resetPreviewPane(); } // === goSetSelectedRecordID(integer) ========= // sets the selected record id in the glue code function goSetSelectedRecordID(i_RowID) { var RecordID = i_RowID; if (RecordID != null) { g_CurrentRecordID = RecordID; g_objDispatch.SetSelectedRecordID(RecordID); if (RecordID != -1) g_objDataList.IGrooveDataListDisplay.ScrollToRow(RecordID); // Enable or disable buttons depending on permissions. canEditOrDelete(RecordID); } } // === goSearchComplete() ================== // called when a record search has completed function goSearchComplete() { var intDataListCount = g_objDispatch.GetDataListCollectionCount(); if (intDataListCount != null) { if (intDataListCount == 0) { resetPreviewPane(); window.setTimeout("g_objDispatch.OKMessageBox('Search is complete. There are no results to display.', 'Search Complete')", 500); } displaySearchCount(); } } // === displaySearchCount() ==================================== // display the number of records in the data list after a search function displaySearchCount() { var intDataListCount = g_objDispatch.GetDataListCollectionCount(); var intToolCount = g_objDispatch.GetToolCollectionCount(); if (intDataListCount != null && intToolCount != null) { var strCount = intDataListCount + " of " + intToolCount + " records in view"; if (intToolCount == 1) strCount = intDataListCount + " of " + intToolCount + " record in view"; var objDivSearchCount = document.getElementById("divSearchCount"); if (objDivSearchCount != null) objDivSearchCount.innerHTML = strCount; } } // === displayViewCount() ======================= // display the number of records in the data list function displayViewCount() { var intToolCount = g_objDispatch.GetToolCollectionCount(); if (intToolCount != null) { var strCount = intToolCount + " records in view"; if (intToolCount == 1) strCount = intToolCount + " record in view"; var objDivViewCount = document.getElementById("divViewCount"); if (objDivViewCount != null) objDivViewCount.innerHTML = strCount; } } // === canEditOrDelete(integer) ===================== // enable or disable buttons depending on permissions function canEditOrDelete(i_RecordID) { if (typeof i_RecordID == "undefined" || i_RecordID == null) { i_RecordID = g_objDataList.IGrooveDataListDisplay.FocusRow; if (typeof i_RecordID == "undefined" || i_RecordID == null) i_RecordID = -1; } g_AllowCreate = g_objDispatch.CanCreate(); g_AllowEdit = g_objDispatch.CanEdit(i_RecordID); g_AllowDelete = g_objDispatch.CanDelete(i_RecordID); if (g_AllowEdit) doButtonOut("EditButton"); else doButtonDisable("EditButton"); if (g_AllowDelete) doButtonOut("DeleteButton"); else doButtonDisable("DeleteButton"); } // === resetPreviewPane() ==================== // clear the preview pane and global variables function resetPreviewPane() { g_objDispatch.WebBrowserViewNavigatePreview(g_BasePath + "FormsBlankPage.html"); g_CurrentRecordID = -1; g_PreviousRecordID = -1; g_CurrentFormURL = null; g_PreviousFormURL = null; g_TimeoutIncrement = 1; } // === addDocument() ================================= // add the current document to the HTMLComponentBridge function addDocument() { g_objDispatch.AddHTMLDocument(document); /*if (!g_objDataList.IGrooveDataListDisplay.Initialized) { g_objDispatch.SetupBridge(); window.setTimeout("initDataList()", 10); } */ } // === removeDocument() =================================== // remove the current document from the HTMLComponentBridge function removeDocument() { g_objDispatch.RemoveHTMLDocument(document); } // === enableUICommands() ============== // enable the buttons in the command bar function enableUICommands() { g_objDispatch.SetUICommandEnabled("GUIC_FormsTool_Search", true); g_objDispatch.SetUICommandContainerEnabled("GUIC_FormsTool_FormMenu", true); g_objDispatch.SetUICommandContainerEnabled("GUIC_FormsTool_ViewMenu", true); } // === getButton(string, string, string, string) ===== // creates an html button from the passed in variables function getButton(i_Name, i_Label, i_Tooltip, i_OnMouseUp) { var strButton = "<div id=\"" + i_Name + "\" title=\"" + i_Tooltip + "\" class=\"button\" onmouseup=\"" + i_OnMouseUp + "\" onmouseover=\"doButtonOver('" + i_Name + "')\" onmouseout=\"doButtonOut('" + i_Name + "')\">"; strButton += " <table cellpadding=0 cellspacing=0 border=0 width=\"100%\">"; strButton += " <tr>"; strButton += " <td width=11 height=22><img src=\"" + g_BasePath + "button_left.gif\" width=11 height=22 id=\"" + i_Name + "Left\"></td>"; strButton += " <td height=22 background=\"" + g_BasePath + "button_mid.gif\" align=\"center\" nowrap id=\"" + i_Name + "Mid\" unselectable=\"on\">" + i_Label + "</td>"; strButton += " <td width=11 height=22><img src=\"" + g_BasePath + "button_right.gif\" width=11 height=22 id=\"" + i_Name + "Right\"></td>"; strButton += " </tr>"; strButton += "</table>"; strButton += "</div>"; return strButton; } // === doButtonOver(string) ======================= // highlight button images when user mouses over it function doButtonOver(i_Name) { if ((i_Name == "DeleteButton" && !g_AllowDelete) || (i_Name == "EditButton" && !g_AllowEdit) || ((i_Name == "DeleteButton" || i_Name == "EditButton") && g_objDispatch.GetRecordCount() <= 0)) return; changeButtonImages(i_Name, g_imgButtonLeftOver.src, g_imgButtonMidOver.src, g_imgButtonRightOver.src); } // === doButtonOut(string) ============================== // reset the button images when the user mouses out of it function doButtonOut(i_Name) { if (i_Name == "EditButton" && g_objDispatch.GetRecordCount() <= 0) doButtonDisable("EditButton"); else if (i_Name == "DeleteButton" && g_objDispatch.GetRecordCount() <= 0) doButtonDisable("DeleteButton"); else if (i_Name == "EditButton" && g_AllowEdit) changeButtonImages(i_Name, g_imgButtonLeft.src, g_imgButtonMid.src, g_imgButtonRight.src); else if (i_Name == "EditButton" && g_AllowEdit!= null && g_AllowEdit== false) doButtonDisable("EditButton"); else if (i_Name == "DeleteButton" && g_AllowDelete) changeButtonImages(i_Name, g_imgButtonLeft.src, g_imgButtonMid.src, g_imgButtonRight.src); else if (i_Name == "DeleteButton" && g_AllowDelete != null && g_AllowDelete == false) doButtonDisable("DeleteButton"); else changeButtonImages(i_Name, g_imgButtonLeft.src, g_imgButtonMid.src, g_imgButtonRight.src); } // === doButtonDisable(string) ===================================== // disable the button images when it shouldn't be able to be clicked function doButtonDisable(i_Name) { changeButtonImages(i_Name, g_imgButtonLeftDisable.src, g_imgButtonMidDisable.src, g_imgButtonRightDisable.src); } // === setupViewButtons() ====================== // pre-load the images for the button mouseovers function setupViewButtons() { // Pre-load the images for the button mouseovers. g_imgButtonLeft = new Image(11, 22); g_imgButtonLeft.src = g_BasePath + "button_left.gif"; g_imgButtonMid = new Image(11, 22); g_imgButtonMid.src = g_BasePath + "button_mid.gif"; g_imgButtonRight = new Image(11, 22); g_imgButtonRight.src = g_BasePath + "button_right.gif"; g_imgButtonLeftOver = new Image(11, 22); g_imgButtonLeftOver.src = g_BasePath + "button_left_over.gif"; g_imgButtonMidOver = new Image(11, 22); g_imgButtonMidOver.src = g_BasePath + "button_mid_over.gif"; g_imgButtonRightOver = new Image(11, 22); g_imgButtonRightOver.src = g_BasePath + "button_right_over.gif"; g_imgButtonLeftDisable = new Image(11, 22); g_imgButtonLeftDisable.src = g_BasePath + "button_left_disable.gif"; g_imgButtonMidDisable = new Image(11, 22); g_imgButtonMidDisable.src = g_BasePath + "button_mid_disable.gif"; g_imgButtonRightDisable = new Image(11, 22); g_imgButtonRightDisable.src = g_BasePath + "button_right_disable.gif"; // Get the current view name to preset in the default button set. var ViewName = g_objDispatch.GetCurrentWebView(); // Edit and delete buttons that are common to both search and default headings. var EditDeleteButtons = "<td width=72>" + getButton("EditButton", "Edit...", "Edit currently selected record.", "goEdit()") + "</td><td width=72>" + getButton("DeleteButton", "Delete", "Delete currently selected record", "goDelete()") + "</td>"; // Create the default and search result button sets. var DefaultButtons = "<table width=\"100%\"><tr>" + EditDeleteButtons + "<td width=10> </td><td width=106>" + getButton("ImportExportButton", "Import/Export <img src=\"" + g_BasePath + "menu_arrow.gif\" width=7 height=7 align=absmiddle>", "Import or export data currently displayed in the view", "createImportExportMenu(ImportExportButton)") + "</td><td width=10> </td><td><div id=\"divViewCount\"></div></td><td align=right class=\"heading\"><img src=\"" + g_BasePath + "viewby.gif\" width=24 height=24 align=absmiddle> " + ViewName + "</td></tr></table>"; var SearchButtons = "<table width=\"100%\"><tr>" + EditDeleteButtons + "<td width=10> </td><td><div id=\"divSearchCount\"></div></td><td align=right class=\"heading\"><img src=\"" + g_BasePath + "search.gif\" width=24 height=24 align=absmiddle> Search Results</td><td width=10> </td><td width=144>" + getButton("ClearButton", "Clear Search Results", "Clear the search results from the view", "goClear()") + "</td></tr></table>"; // Pass button HTML string to glue code, which will determine what to display. g_objDispatch.SetButtonsHTML(DefaultButtons, SearchButtons); g_objDispatch.DisplayViewNavButtons(); } // === changeButtonImages(string, string, string, string) ==================== // change the look of a button with the passed in name by replacing the images function changeButtonImages(i_Name, i_strLeft, i_strMid, i_strRight) { var objButtonLeft = document.getElementById(i_Name + "Left"); var objButtonMid = document.getElementById(i_Name + "Mid"); var objButtonRight = document.getElementById(i_Name + "Right"); if (objButtonLeft && objButtonMid && objButtonRight) { objButtonLeft.src = i_strLeft; objButtonMid.background = i_strMid; objButtonRight.src = i_strRight; } } // === createImportExportMenu(object) =================== // create and set up the menu for import/export functions function createImportExportMenu(i_objRef) { var blnExportEnabled = false; if (g_objDispatch.GetToolCollectionCount() > 0) blnExportEnabled = true; var objImportExportMenu = new Menu(); objImportExportMenu.AddMenuItem("Export as Binary XML...", "parent.g_objPopup.hide(); parent.getScriptDispatch().ExportData(0);", blnExportEnabled); objImportExportMenu.AddMenuItem("Export as Tabular Text...", "parent.g_objPopup.hide(); parent.getScriptDispatch().ExportData(1);", blnExportEnabled); objImportExportMenu.AddMenuItem("Export as Structured Text...", "parent.g_objPopup.hide(); parent.getScriptDispatch().ExportData(2);", blnExportEnabled); objImportExportMenu.AddMenuItem("Export as XML (without attachments)...", "parent.g_objPopup.hide(); parent.getScriptDispatch().ExportData(3);", blnExportEnabled); objImportExportMenu.AddSeparator(); objImportExportMenu.AddMenuItem("Import...", "parent.g_objPopup.hide(); parent.getScriptDispatch().ImportData();", g_AllowCreate); objImportExportMenu.Create(); MenuPopup(i_objRef, objImportExportMenu); } // === getScriptDispatch() =============================== // safely get the script dispatch from the forms glue code function getScriptDispatch() { try { var objDispatch = window.external.Delegate.GetScriptDispatch(); return objDispatch; } catch (error) { alert("This web page should only be opened from within Groove. Please close the window."); return null; } }