function GetControl(controlID) { var control = document.getElementById(controlID); if (control == null) alert("Unable to locate control: " + controlID); return control; } function IsIEBrowser() { if (navigator.appName.indexOf("Microsoft") != -1) return true; else return false; } function SaveActionsForPostback(hiddenType, hiddenParam, actionType, actionParam) { var typeObj = GetControl(hiddenType); typeObj.value = actionType; var paramObj = GetControl(hiddenParam); paramObj.value = actionParam; } function OnDocMapExpand(stateID) { var stateObject = GetControl(stateID); var docMapID = GetDocMapID(); stateObject.value = stateObject.value + docMapID + ","; } function OnDocMapCollapse(stateID) { var stateObject = GetControl(stateID); var docMapID = GetDocMapID(); stateObject.value = stateObject.value.replace("," + docMapID + ",", ","); } function GetDocMapID() { var treeView = event.srcElement; var treeNode = treeView.getTreeNode(event.treeNodeIndex); return treeNode.getAttribute("DocMapID"); } function ToggleInputImageSrc(inputCtrlID, enabledImage, disabledImage, enabled) { var inputCtrl = document.getElementById(inputCtrlID); if (enabled) inputCtrl.src = enabledImage; else inputCtrl.src = disabledImage; } function SetCalendarUrl(dropDownObject, iframeObject, url) { // If the selected dates are the different then get a new page var currentDate = GetSelectedDateFromUrl(iframeObject.document.location.search); var newDate = GetSelectedDateFromUrl(url); if (currentDate != newDate) { iframeObject.document.location.replace(url); } else { // Hide the calendar that is showing and make sure the one with the // users selection is showing. iframeObject.HideUnhide(iframeObject.gCurrentShowing, 'DatePickerDiv', iframeObject.g_currentID, null); iframeObject.PositionFrame('DatePickerDiv'); } } function GetSelectedDateFromUrl(url) { var pos = url.lastIndexOf('selectDate'); var date = null; if (pos != -1) { date = url.substring(pos); pos = date.indexOf('='); if (pos == -1) date = null; else { date = date.substring(pos + 1); pos = date.indexOf('&'); if (pos != -1) date = date.substring(0, pos); } } return date; } // Params area object constructor function RSParameters(disabledColor, disabledStyle, parametersGridID, credentialLinkID) { this.m_disabledColor = disabledColor; this.m_disabledStyle = disabledStyle; this.m_parametersGridID = parametersGridID; this.m_credentialLinkID = credentialLinkID; } // Update the state of a nullable parameter. function UpdateParam1(nullChkID, param1ID) { this.UpdateParam2(nullChkID, param1ID, null); } RSParameters.prototype.UpdateParam1 = UpdateParam1; function UpdateParam2(nullChkID, param1ID, param2ID) { if (!IsIEBrowser) return; // Get the interesting controls var nullChkBox = GetControl(nullChkID); if (nullChkBox == null) return; var param1Control = GetControl(param1ID); if (param1Control == null) return; var param2Control = null; if (param2ID != null) { param2Control = GetControl(param2ID); if (param2Control == null) return; } // If the null checkbox itself is not enabled, don't change the state // of the parameter controls. The null check box is disabled when // a data driven parameter has an outstanding dependencies if (nullChkBox.disabled) return; // Enable/Disable the other controls this.DisableInput(param1Control, nullChkBox.checked); if (param2Control != null) this.DisableInput(param2Control, nullChkBox.checked); } RSParameters.prototype.UpdateParam2 = UpdateParam2; function DisableInput(control, shouldDisable) { if (control.type == "text") // Enable/disable a text box { this.DisableTextInput(control, shouldDisable); } else if (control.type == "radio") // Enable/disable a radio button { // ASP sets the disabled tag on a span that contains the radio button control.parentNode.disabled = shouldDisable; } else control.disabled = shouldDisable; } RSParameters.prototype.DisableInput = DisableInput; function DisableReportViewerTextInput(control, shouldDisable) { if (shouldDisable) { if (this.m_disabledStyle != "") control.className = this.m_disabledStyle; else control.style.backgroundColor = this.m_disabledColor; } else { if (this.m_disabledStyle != "") control.className = ""; else control.style.backgroundColor = ""; } control.disabled = shouldDisable; } RSParameters.prototype.DisableTextInput = DisableReportViewerTextInput; function ControlClicked() { if (this.ActiveDropDown != null) this.ActiveDropDown.Hide(); } RSParameters.prototype.ControlClicked = ControlClicked; function OnChangeCredentialsClicked() { // Hide the link event.srcElement.style.display = "none"; // Make sure each row in the table is visible var paramsTable = GetControl(this.m_parametersGridID); for (var i = 0; i < paramsTable.rows.length; i++) { var row = paramsTable.rows[i]; if (row.IsParameterRow != "true") row.style.display = "inline"; else row.style.display = "none"; } } RSParameters.prototype.OnChangeCredentialsClicked = OnChangeCredentialsClicked; function ShouldValidateCredentials() { // Get the credential link var credentialLink = document.getElementById(this.m_credentialLinkID); // The credential link is not rendered in 2 cases. // 1 - There are no credentials. This method is only called when validating // credentials. So this method won't get called in this case. // 2 - The credential prompts are being shown initially because they aren't // satisfied. In this case, we always want to validate the input boxes. if (credentialLink == null) return true; // Switched back from intial view of parameters to credentials return credentialLink.style.display == "none"; } RSParameters.prototype.ShouldValidateCredentials = ShouldValidateCredentials; function ShouldValidateParameters() { // Get the credential link var credentialLink = document.getElementById(this.m_credentialLinkID); // The credential link is not rendered in 2 cases. // 1 - There are no credentials. This method is only called when validating // parameters. If there are no credentials, the parameters must be visible // and should be validated // 2 - The credential prompts are being shown initially because they aren't // satisfied. In this case, there are no rendered parameter prompts, so // this method won't get called. if (credentialLink == null) return true; // Initial view was of parameters and it still is return credentialLink.style.display != "none"; } RSParameters.prototype.ShouldValidateParameters = ShouldValidateParameters; function ValidateCredential(userID, errMsg) { // If the credentials are not visible, we don't need to validate them. if (!this.ShouldValidateCredentials()) return true; var userControl = GetControl(userID); if (userControl.value == "") { alert(errMsg); return false; } return true; } RSParameters.prototype.ValidateCredential = ValidateCredential; // Validate that the parameter has a non-empty value function ValidateHasValue(paramID, nullChkID, errmsg) { // If the parameters are not visible, we don't need to validate them. if (!this.ShouldValidateParameters()) return true; if (nullChkID != "" && (document.getElementById(nullChkID).checked == true)) return true; var paramValue = document.getElementById(paramID).value; if ((paramValue == null) || (paramValue == "")) { alert(errmsg); return false; } return true; } RSParameters.prototype.ValidateHasValue = ValidateHasValue; function DoesInputHaveValue(elementID) { var element = document.getElementById(elementID); if (element.value != null && element.value != "") return true; return false; } RSParameters.prototype.DoesInputHaveValue = DoesInputHaveValue; function DoesBooleanHaveValue(trueID, falseID) { var trueElement = document.getElementById(trueID); var falseElement = document.getElementById(falseID); if (trueElement.checked || falseElement.checked) return true; return false; } RSParameters.prototype.DoesBooleanHaveValue = DoesBooleanHaveValue; // Validate a drop down list function ValidateDropDown(paramID, errMsg, hasInitialBlank) { // If the parameters are not visible, we don't need to validate them. if (!this.ShouldValidateParameters()) return true; // The first item is a blank place holder if (hasInitialBlank) { var dropDown = document.getElementById(paramID); if (dropDown.selectedIndex == 0) { alert(errMsg); return false; } } return true; } RSParameters.prototype.ValidateDropDown = ValidateDropDown; function ValidateBoolean(trueID, falseID, nullChkID, errmsg) { // If the parameters are not visible, we don't need to validate them. if (!this.ShouldValidateParameters()) return true; if (nullChkID != "" && (document.getElementById(nullChkID).checked == true)) return true; var trueChecked = document.getElementById(trueID).checked; var falseChecked = document.getElementById(falseID).checked; if (!trueChecked && !falseChecked) { alert(errmsg); return false; } return true; } RSParameters.prototype.ValidateBoolean = ValidateBoolean; function ValidateMultiValidValue(editorID, errMsg) { // If the parameters are not visible, we don't need to validate them. if (!this.ShouldValidateParameters()) return true; var summaryString = GetValueStringFromValidValueList(editorID); var isValid = summaryString.length > 0; if (!isValid) alert(errMsg) return isValid; } RSParameters.prototype.ValidateMultiValidValue = ValidateMultiValidValue; function ValidateMultiEditValue(editorID, errMsg) { // If the parameters are not visible, we don't need to validate them. if (!this.ShouldValidateParameters()) return true; // Need to check for a value specified. This code only runs if not allow blank. // GetValueStringFromTextEditor filters out blank strings. So if it was all blank, // the final string will be length 0 var summaryString = GetValueStringFromTextEditor(editorID, true, false) var isValid = false; if (summaryString.length > 0) isValid = true; if (!isValid) alert(errMsg); return isValid; } RSParameters.prototype.ValidateMultiEditValue = ValidateMultiEditValue; /**************************************************************************/ // DropDownParamClass function DropDownParamClass(thisID, visibleTextBoxID, floatingIFrameID, paramObject, autoPostBackMethod) { this.m_thisID = thisID; this.m_visibleTextBoxID = visibleTextBoxID; this.m_floatingIframeID = floatingIFrameID; this.m_paramObject = paramObject; this.m_autoPostBackMethod = autoPostBackMethod; this.m_shouldAutoPostBack = false; } function ToggleVisibility() { var floatingIframe = GetControl(this.m_floatingIframeID); if (floatingIframe.style.display != "inline") this.Show(); else this.Hide(); } DropDownParamClass.prototype.ToggleVisibility = ToggleVisibility; function IsVisible() { var floatingIframe = GetControl(this.m_floatingIframeID); if (floatingIframe.style.display == "inline") return true; else return false; } DropDownParamClass.prototype.IsVisible = IsVisible; function DDShow() { var floatingIframe = GetControl(this.m_floatingIframeID); if (floatingIframe.style.display == "inline") return; var visibleTextBox = GetControl(this.m_visibleTextBoxID); // Position the drop down var newDropDownPosition = this.GetDropDownPosition(); var floatingIFrame = GetControl(this.m_floatingIframeID); floatingIFrame.style.left = newDropDownPosition.Left; floatingIFrame.style.top = newDropDownPosition.Top; floatingIFrame.style.width = visibleTextBox.offsetWidth; floatingIFrame.style.display = "inline"; // If another multi value is open, close it first var dropDownObject = this; if (this.PollingHideObject != null) dropDownObject = this.PollingHideObject; if (this.m_paramObject.ActiveDropDown != dropDownObject && this.m_paramObject.ActiveDropDown != null) this.m_paramObject.ControlClicked(); this.m_paramObject.ActiveDropDown = dropDownObject; this.StartPolling(); } DropDownParamClass.prototype.Show = DDShow; function DDHide() { var floatingIFrame = GetControl(this.m_floatingIframeID); // Hide the dropDown floatingIFrame.style.display = "none"; // Check that the reference is still us in case event ordering // caused another dropdown to click open var dropDownObject = this; if (this.PollingHideObject != null) dropDownObject = this.PollingHideObject; if (this.m_paramObject.ActiveDropDown == dropDownObject) this.m_paramObject.ActiveDropDown = null; // When the dropdown collapses, the parameter is done changing value, // so perform the autopost back for dependent parameters. if (this.m_shouldAutoPostBack) this.m_autoPostBackMethod(); } DropDownParamClass.prototype.Hide = DDHide; function SetAutoPostBackOnHide() { // Not all uses of this class call this method when the parameter value changes. this.m_shouldAutoPostBack = true; } DropDownParamClass.prototype.SetAutoPostBackOnHide = SetAutoPostBackOnHide; function GetDropDownPosition() { // Make the editor visible var visibleTextBox = GetControl(this.m_visibleTextBoxID); var textBoxPosition = GetObjectPosition(visibleTextBox); return {Left:textBoxPosition.Left, Top:textBoxPosition.Top + visibleTextBox.offsetHeight}; } DropDownParamClass.prototype.GetDropDownPosition = GetDropDownPosition; function StartDropDownPolling() { setTimeout(this.m_thisID + ".PollingCallback();", 100); } DropDownParamClass.prototype.StartPolling = StartDropDownPolling; function DropDownPollingCallback() { // If the iframe isn't visible, no more events. var floatingIframe = GetControl(this.m_floatingIframeID); if (floatingIframe.style.display != "inline") return; // If the text box moved, something on the page resized, so close the editor var expectedIframePos = this.GetDropDownPosition(); if (floatingIframe.style.left != expectedIframePos.Left + "px" || floatingIframe.style.top != expectedIframePos.Top + "px") { if (this.PollingHideObject != null) this.PollingHideObject.Hide(); else this.Hide(); } else { this.StartPolling(); } } DropDownParamClass.prototype.PollingCallback = DropDownPollingCallback; /**************************************************************************/ // MultiValueParamClass function MultiValueParamClass(thisID, floatingEditorID, dropDownObject, hasValidValues, allowBlank) { this.m_thisID = thisID; this.m_floatingEditorID = floatingEditorID; this.m_dropDownObject = dropDownObject; this.m_hasValidValues = hasValidValues; this.m_allowBlank = allowBlank; this.m_dropDownObject.PollingHideObject = this; this.m_floatingIframeID = this.m_dropDownObject.m_floatingIframeID; this.UpdateSummaryString(); } // Set up the toggle for this class. It can use the DropDown ToggleVisibility which // will end up calling this classes Show and hide MultiValueParamClass.prototype.ToggleVisibility = ToggleVisibility; function Show() { var floatingEditor = GetControl(this.m_floatingEditorID); if (floatingEditor.style.display == "inline") return; // Set drop down and summary string to the same width to make it look like a drop down var visibleTextBox = GetControl(this.m_dropDownObject.m_visibleTextBoxID); floatingEditor.style.width = visibleTextBox.offsetWidth; // Position the drop down var newEditorPosition = this.m_dropDownObject.GetDropDownPosition(); floatingEditor.style.left = newEditorPosition.Left; floatingEditor.style.top = newEditorPosition.Top; floatingEditor.style.display = "inline"; // Call the drop down object to show the iframe this.m_dropDownObject.Show(); // Set the iframe height to our controls height var floatingIFrame = GetControl(this.m_dropDownObject.m_floatingIframeID); floatingIFrame.style.height = floatingEditor.offsetHeight; if (floatingEditor.childNodes[0].focus) floatingEditor.childNodes[0].focus(); } MultiValueParamClass.prototype.Show = Show; function Hide() { var floatingEditor = GetControl(this.m_floatingEditorID); // Hide the editor floatingEditor.style.display = "none"; // Update the text box this.UpdateSummaryString(); // Call the dropdown object to hide the iframe this.m_dropDownObject.Hide(); } MultiValueParamClass.prototype.Hide = Hide; function SetAutoPostBackOnHideMultiValue() { this.m_dropDownObject.SetAutoPostBackOnHide(); } MultiValueParamClass.prototype.SetAutoPostBackOnHide = SetAutoPostBackOnHideMultiValue; function UpdateSummaryString() { var summaryString; if (this.m_hasValidValues) summaryString = GetValueStringFromValidValueList(this.m_floatingEditorID); else summaryString = GetValueStringFromTextEditor(this.m_floatingEditorID, false, this.m_allowBlank); var visibleTextBox = GetControl(this.m_dropDownObject.m_visibleTextBoxID); visibleTextBox.value = summaryString; } MultiValueParamClass.prototype.UpdateSummaryString = UpdateSummaryString; /*****************************************************************************/ function GetObjectPosition(obj) { var totalTop = 0; var totalLeft = 0; while (obj != document.body) { // Add up the position totalTop += obj.offsetTop; totalLeft += obj.offsetLeft; // Prepare for next iteration obj = obj.offsetParent; } totalTop += obj.offsetTop; totalLeft += obj.offsetLeft; return {Left:totalLeft, Top:totalTop}; } function GetValueStringFromTextEditor(floatingEditorID, asRaw, allowBlank) { var span = GetControl(floatingEditorID); var editor = span.childNodes[0]; var valueString = editor.value; // Remove the blanks if (!allowBlank) { // Break down the text box string to the individual lines var valueArray = valueString.split("\r\n"); var delimiter; if (asRaw) delimiter = "\r\n"; else delimiter = ", "; var finalValue = ""; for (var i = 0; i < valueArray.length; i++) { // If the string is non-blank, add it if (valueArray[i].length > 0) { if (finalValue.length > 0) finalValue += delimiter; finalValue += valueArray[i]; } } return finalValue; } else { if (asRaw) return valueString; else return valueString.replace(/\r\n/g, ", "); } } function GetValueStringFromValidValueList(editorID) { var valueString = ""; // Get the table var div = GetControl(editorID); var table = div.childNodes[0]; if (table.nodeName != "TABLE") // Skip whitespace if needed table = div.childNodes[1]; // If there is only one element, it is a real value, not the select all option var startIndex = 0; if (table.rows.length > 1) startIndex = 1; for (var i = startIndex; i < table.rows.length; i++) { var rowInfo = GetValueForMultiValidValueRow(table, i); if (rowInfo.CheckBox.checked) { if (valueString.length > 0) valueString += ", "; valueString += rowInfo.Label; } } return valueString; } function MultiValidValuesSelectAll(src, editorID) { // Get the table var div = GetControl(editorID); var table = div.childNodes[0]; if (table.nodeName != "TABLE") table = div.childNodes[1]; for (var i = 1; i < table.rows.length; i++) { var rowInfo = GetValueForMultiValidValueRow(table, i); rowInfo.CheckBox.checked = src.checked; } } function GetValueForMultiValidValueRow(table, rowIndex) { // Get the first cell of the row var firstCell = table.rows[rowIndex].cells[0]; var span = firstCell.childNodes[0]; var checkBox = span.childNodes[0]; // Span is not always generated. var label; if (span.nodeName == "INPUT") { checkBox = span; label = firstCell.childNodes[1]; } else label = span.childNodes[1]; // The label can be blank. If it exists, make it non-zero length so that // view report button validation realizes there is a value selected. Makes // text summary a little easier to read too. var labelStr = " "; if (label != null && label.firstChild != null) labelStr = label.firstChild.nodeValue; if (labelStr == "") labelStr = " "; return {CheckBox:checkBox, Label:labelStr}; } function OnClickMultiValidValue(src, selectAllCheckBox) { if (!src.checked) selectAllCheckBox.checked = false; } // Report class constructor function RSReport(clientController, reportPrefix, reportDivID, reportCellID, initialZoomValue, navigationId, pageNumber, totalPages, hasDocMap, enableFindNext, autoRefreshAction, autoRefreshInterval) { this.m_clientController = clientController; this.m_reportPrefix = reportPrefix; this.m_reportDivID = reportDivID; this.m_reportCellID = reportCellID; this.m_initialZoomValue = initialZoomValue; this.m_navigationId = navigationId; this.m_pageNumber = pageNumber; this.m_totalPages = totalPages; this.m_hasDocMap = hasDocMap; this.m_nextHit = 1; this.m_enableFindNext = enableFindNext; this.m_autoRefreshAction = autoRefreshAction; this.m_autoRefreshInterval = autoRefreshInterval; } function OnLoadReport(reloadDocMap) { this.m_clientController.OnReportLoaded(this, reloadDocMap); if (null != this.m_navigationId && this.m_navigationId != "") window.location.replace("#" + this.m_navigationId); if (this.m_autoRefreshAction != null) setTimeout(this.m_autoRefreshAction, this.m_autoRefreshInterval); } RSReport.prototype.OnLoadReport = OnLoadReport; function UpdateZoom(paramZoomValue) { if (paramZoomValue != null) zoomValue = paramZoomValue; else if (this.m_lastZoomValue != null) zoomValue = this.m_lastZoomValue; else // Zoom should be set initially during OnLoad. Until then, ignore calls from toolbar/resize event return; // Get the report cell var reportCell = GetControl(this.m_reportCellID); if (reportCell == null) return; if ((zoomValue != "PageWidth") && (zoomValue != "FullPage")) reportCell.style.zoom = zoomValue + "%"; else { // Get the report div var reportDiv = GetControl(this.m_reportDivID); if (reportDiv == null) return; if (zoomValue != "PageWidth") { if ((reportCell.offsetWidth * reportDiv.offsetHeight) < (reportCell.offsetHeight * reportDiv.offsetWidth)) SetZoom(reportCell, reportDiv.offsetHeight, reportCell.offsetHeight); else SetZoom(reportCell, reportDiv.offsetWidth, reportCell.offsetWidth); } else { var vbar = reportDiv.offsetHeight != reportDiv.clientHeight; var proceed = (reportCell.offsetWidth > 0); for (var iter = 0; (iter <= 1) & proceed; ++iter) { zoomValue = SetZoom(reportCell, reportDiv.clientWidth, reportCell.offsetWidth); proceed = vbar != ((reportCell.offsetHeight * zoomValue) > reportDiv.offsetHeight); } } } if (paramZoomValue != null) this.m_lastZoomValue = paramZoomValue; } RSReport.prototype.UpdateZoom = UpdateZoom; function ActionHandler(actionType, actionParam) { var completeActionParam; if (actionType == "Sort") { if (window.event && window.event.shiftKey) completeActionParam = actionParam + "_T"; else completeActionParam = actionParam + "_F"; } else completeActionParam = actionParam; return this.m_clientController.ActionHandler(actionType, completeActionParam); } RSReport.prototype.ActionHandler = ActionHandler; // Zoom to the ratio specified by div / rep. function SetZoom(reportCell, div, rep) { if (rep <= 0) return 1.0; var z = (div - 1) / rep; reportCell.style.zoom = z; return z; } function ReportFindNext () { // Unhighlight previous hit, if any. if (this.m_nextHit > 0) { var hitElem = document.getElementById(this.m_reportPrefix + "oHit" + (this.m_nextHit - 1)); if (hitElem != null) { hitElem.style.backgroundColor = ""; hitElem.style.color = ""; } } // Highlight current hit and navigate to it. var hitElem = document.getElementById(this.m_reportPrefix + "oHit" + this.m_nextHit); if (hitElem == null) return false; hitElem.style.backgroundColor = "highlight"; hitElem.style.color = "highlighttext"; window.location.replace("#" + this.m_reportPrefix + "oHit" + this.m_nextHit); this.m_nextHit ++; return true; } RSReport.prototype.FindNext = ReportFindNext function OnFrameVisible() { // In async mode, fit proportional must happen after the report frame // becomes visible, otherwise images dimensions are 0. In sync mode // it is handled inline in the renderer. if (typeof(ResizeImages) == "function") // Make sure it is defined ResizeImages(); this.UpdateZoom(this.m_initialZoomValue); } RSReport.prototype.OnFrameVisible = OnFrameVisible // The client side viewer controller function RSClientController(actionPostbackFunction, waitControlID, docMapReportFrameID, docMapUrl, docMapSize, docMapVisible, baseReportPageUrl, canHandlePageNavOnClient, canHandleToggleOnClient, canHandleSortOnClient, canHandleBookmarkOnClient, canHandleDocMapOnClient, canHandleSearchOnClient, errMessageInvalidPage, clientCurrentPageID, enableFindNextID, canHandleRefreshOnClient) { this.m_actionPostbackFunction = actionPostbackFunction; this.m_waitControlID = waitControlID; this.m_docMapReportFrameID = docMapReportFrameID; this.m_docMapUrl = docMapUrl; this.m_docMapSize = docMapSize; this.m_docMapVisible = docMapVisible; this.m_baseReportPageUrl = baseReportPageUrl; this.m_canHandlePageNavOnClient = canHandlePageNavOnClient; this.m_canHandleToggleOnClient = canHandleToggleOnClient; this.m_canHandleSortOnClient = canHandleSortOnClient; this.m_canHandleBookmarkOnClient = canHandleBookmarkOnClient; this.m_canHandleDocMapOnClient = canHandleDocMapOnClient; this.m_canHandleRefreshOnClient = canHandleRefreshOnClient; this.m_errMessageInvalidPage = errMessageInvalidPage; this.m_clientCurrentPageID = clientCurrentPageID; this.m_canHandleSearchOnClient = canHandleSearchOnClient; this.m_enableFindNextID = enableFindNextID; this.m_reportLoaded = false; // Calculated property if (this.m_docMapReportFrameID == "") this.IsAsync = false; else this.IsAsync = true; } function ControllerActionHandler(actionType, actionParam) { if (this.CanHandleClientSideAction(actionType)) { // Construct the url var actionUrl = this.m_baseReportPageUrl + "&" + this.CommonReportPageQueryParams(); actionUrl += "&ActionType=" + actionType; actionUrl += "&ActionParam=" + encodeURIComponent(actionParam); actionUrl += "&PageNumber=" + this.CurrentPage; // Sort can change the document map if (actionType == "Sort") actionUrl += "&ReloadDocMap=" + "true"; // Set report frame this.PerformClientSidePageChange(actionUrl); } else return this.m_actionPostbackFunction(actionType, actionParam); } RSClientController.prototype.ActionHandler = ControllerActionHandler; function CanHandleClientSideAction(actionType) { if (actionType == "Toggle") return this.m_canHandleToggleOnClient; else if (actionType == "Bookmark") return this.m_canHandleBookmarkOnClient; else if (actionType == "DocumentMap") return this.m_canHandleDocMapOnClient; else if (actionType == "Sort") return this.m_canHandleSortOnClient; else if (actionType == "Search") return this.m_canHandleSearchOnClient; else if (actionType == "SearchNext") return this.m_canHandleSearchOnClient; else if (actionType == "Refresh") return this.m_canHandleRefreshOnClient; else return false; // Drillthrough } RSClientController.prototype.CanHandleClientSideAction = CanHandleClientSideAction; function OnReportLoaded(reportObject, reloadDocMap) { this.m_reportObject = reportObject; this.CurrentPage = reportObject.m_pageNumber; this.TotalPages = reportObject.m_totalPages; // If the toolbar is visible, update the display if (this.m_toolBar != null) this.m_toolBar.EnableToolbar(this.CurrentPage, this.TotalPages, reportObject.m_enableFindNext); // Update the client side page number so that it is available to the server object // if it was changed asynchronously. var clientCurrentPage = GetControl(this.m_clientCurrentPageID); if (clientCurrentPage != null) clientCurrentPage.value = this.CurrentPage; // Update find next button if it was changed asynchronously. var enableFindNext = GetControl(this.m_enableFindNextID); if (enableFindNext != null) enableFindNext.value = reportObject.m_enableFindNext == "true" ? "1" : "0"; // If there is a document map, display it if (this.m_reportObject.m_hasDocMap && this.IsAsync) { // This method is called each time the report loads. This happens // for page navigations and report actions. For many of these cases, // the doc map didn't change, so don't reload it. if (reloadDocMap) { var docMapReportFrame = frames[this.m_docMapReportFrameID]; docMapReportFrame.frames["docmap"].location.replace(this.m_docMapUrl); } if (this.m_docMapVisible) this.SetDocMapVisibility(true); if (this.m_toolBar != null) this.m_toolBar.SetHasDocMap(); } } RSClientController.prototype.OnReportLoaded = OnReportLoaded; function OnReportFrameLoaded() { this.m_reportLoaded = true; this.ShowWaitFrame(false); if (this.IsAsync && this.m_reportObject != null) this.m_reportObject.OnFrameVisible(); } RSClientController.prototype.OnReportFrameLoaded = OnReportFrameLoaded; function SetToolBar(toolBar) { this.m_toolBar = toolBar; } RSClientController.prototype.SetToolBar = SetToolBar; function DelegateZoomChange(zoomValue) { this.m_reportObject.UpdateZoom(zoomValue); } RSClientController.prototype.SetZoom = DelegateZoomChange; function ShowInitialWaitFrame() { if (!this.m_reportLoaded) this.ShowWaitFrame(true); } RSClientController.prototype.ShowInitialWaitFrame = ShowInitialWaitFrame; function ShowWaitFrame(startShowingWaitFrame) { // Check for synchronous processing if (!this.IsAsync) return; var waitControl = document.getElementById(this.m_waitControlID); if (!waitControl) return; var reportFrame = GetControl(this.m_docMapReportFrameID); if (startShowingWaitFrame) { waitControl.style.display = "inline"; reportFrame.style.display = "none"; } else { waitControl.style.display = "none"; reportFrame.style.display = "inline"; } } RSClientController.prototype.ShowWaitFrame = ShowWaitFrame; function SetDocMapVisibility(makeVisible) { var docMapReportFrame = frames[this.m_docMapReportFrameID]; var frameset = docMapReportFrame.GetFrameSet(); var reportFrame = docMapReportFrame.GetReportFrame(); if (makeVisible) { frameset.cols = this.m_docMapSize + ",*"; frameset.frameSpacing = "3"; reportFrame.noResize = null; } else { frameset.cols = "0,*"; frameset.frameSpacing = "0"; reportFrame.noResize = "true"; } this.m_docMapVisible = makeVisible; // If the toolbar is visible, update the display if (this.m_toolBar != null) this.m_toolBar.OnDocMapVisibilityChange(); } RSClientController.prototype.SetDocMapVisibility = SetDocMapVisibility; function IsDocMapVisible() { var docMapReportFrame = frames[this.m_docMapReportFrameID]; var reportFrame = docMapReportFrame.GetReportFrame(); return !reportFrame.noResize; } RSClientController.prototype.IsDocMapVisible = IsDocMapVisible; function HandleUserTextPageChange(targetPage) { var pageNumber = parseInt(targetPage); if (isNaN(pageNumber) || pageNumber < 1 || pageNumber > this.TotalPages) { alert(this.m_errMessageInvalidPage); return true; // Handled } else return this.HandleClientSidePageNav(pageNumber); } RSClientController.prototype.HandleUserTextPageChange = HandleUserTextPageChange; function HandleClientSidePageNav(targetPage) { if (!this.m_canHandlePageNavOnClient) return false; var enableFindNext = GetControl(this.m_enableFindNextID); if (enableFindNext != null) enableFindNext.value = "0"; // Construct the url var pageNavUrl = this.m_baseReportPageUrl + "&" + this.CommonReportPageQueryParams(); pageNavUrl += "&PageNumber=" + targetPage; // Set report frame this.PerformClientSidePageChange(pageNavUrl); return true; } RSClientController.prototype.HandleClientSidePageNav = HandleClientSidePageNav; function HandleClientSideFind() { var findTextBox = GetControl(this.m_toolBar.m_findTextID); if (findTextBox == null || findTextBox.value == null || findTextBox.value == "") return true; this.m_toolBar.m_findNextController.SetViewerLinkActive(true); this.ActionHandler ("Search", findTextBox.value); return true; } RSClientController.prototype.HandleClientSideFind = HandleClientSideFind; function HandleClientSideFindNext() { var findTextBox = GetControl(this.m_toolBar.m_findTextID); if (findTextBox == null || findTextBox.value == null || findTextBox.value == "") return true; if (!this.m_toolBar.m_findNextController.IsViewerLinkActive()) return true; if (this.m_reportObject.FindNext()) return true; this.ActionHandler ("SearchNext", findTextBox.value); return true; } RSClientController.prototype.HandleClientSideFindNext = HandleClientSideFindNext; function PerformClientSidePageChange(url) { // Disable the toolbar if (this.m_toolBar != null) this.m_toolBar.DisableToolbar(); // Get the report frame and set the url var docMapReportFrame = frames[this.m_docMapReportFrameID]; var reportFrame = docMapReportFrame.frames["report"]; this.m_reportObject = null; // We are changing the frame content. The report object will be freed automatically. reportFrame.location.replace(url); } RSClientController.prototype.PerformClientSidePageChange = PerformClientSidePageChange; function CommonReportPageQueryParams() { // Get the current zoom value. If there is a toolbar, it will have the current value. // If no toolbar was rendered, the initial value from the current report is still current. var zoomValue = null; if (this.m_toolBar != null) zoomValue = this.m_toolBar.CurrentZoomValue(); // Might be null if zoom control not rendered if (zoomValue == null) zoomValue = this.m_reportObject.m_initialZoomValue; var zoomMode = "Percent"; var zoomPercent = "100"; if (zoomValue == "PageWidth" || zoomValue == "FullPage") zoomMode = zoomValue; else zoomPercent = zoomValue; return "ZoomMode=" + zoomMode + "&ZoomPct=" + zoomPercent; } RSClientController.prototype.CommonReportPageQueryParams = CommonReportPageQueryParams; // Link class constructor function ReportViewerLink(linkID, initialActive, activeLinkStyle, disabledLinkStyle, activeLinkColor, disabledLinkColor, activeHoverLinkColor) { this.m_linkID = linkID; this.m_isActive = initialActive; this.m_activeLinkStyle = activeLinkStyle; this.m_disabledLinkStyle = disabledLinkStyle; this.m_activeLinkColor = activeLinkColor; this.m_disabledLinkColor = disabledLinkColor; this.m_activeHoverLinkColor = activeHoverLinkColor; if (this.m_activeLinkStyle != "") this.m_isUsingStyles = true; else this.m_isUsingStyles = false; } function ReportViewerLinkIsViewerLinkActive() { return this.m_isActive; } ReportViewerLink.prototype.IsViewerLinkActive = ReportViewerLinkIsViewerLinkActive; function ReportViewerLinkSetViewerLinkActive(isActive) { var button = GetControl(this.m_linkID); if (button == null) return; this.m_isActive = isActive; // If using styles, update style name if (this.m_isUsingStyles) { if (this.m_isActive) button.className = this.m_activeLinkStyle; else button.className = this.m_disabledLinkStyle; } this.OnLinkNormal(); } ReportViewerLink.prototype.SetViewerLinkActive = ReportViewerLinkSetViewerLinkActive; function ReportViewerLinkOnLinkHover() { if (this.m_isUsingStyles) return; var link = GetControl(this.m_linkID); if (link == null) return; if (this.m_isActive) { link.style.textDecoration = "underline"; link.style.color = this.m_activeHoverLinkColor; link.style.cursor = "pointer"; } else link.style.cursor = "default"; } ReportViewerLink.prototype.OnLinkHover = ReportViewerLinkOnLinkHover; function ReportViewerLinkOnLinkNormal() { if (this.m_isUsingStyles) return; var link = GetControl(this.m_linkID); if (link == null) return; if (this.m_isActive) link.style.color = this.m_activeLinkColor; else link.style.color = this.m_disabledLinkColor; link.style.textDecoration = "none"; } ReportViewerLink.prototype.OnLinkNormal = ReportViewerLinkOnLinkNormal; function ReportViewerHoverButton(buttonID, isPressed, normalStyle, hoverStyle, hoverPressedStyle, normalColor, hoverColor, hoverPressedColor, normalBorder, hoverBorder, hoverPressedBorder) { this.m_buttonID = buttonID; this.m_isPressed = isPressed; this.m_normalStyle = normalStyle; this.m_hoverStyle = hoverStyle; this.m_hoverPressedStyle = hoverPressedStyle; this.m_normalColor = normalColor; this.m_hoverColor = hoverColor; this.m_hoverPressedColor = hoverPressedColor; this.m_normalBorder = normalBorder; this.m_hoverBorder = hoverBorder; this.m_hoverPressedBorder = hoverPressedBorder; if (this.m_normalStyle != "") this.m_isUsingStyles = true; else this.m_isUsingStyles = false; } function ReportViewerHoverButtonOnHover() { var button = GetControl(this.m_buttonID); if (button == null) return; if (this.m_isUsingStyles) button.className = this.m_isPressed ? this.m_hoverPressedStyle : this.m_hoverStyle; else { button.style.border = this.m_isPressed ? this.m_hoverPressedBorder : this.m_hoverBorder; button.style.backgroundColor = this.m_isPressed ? this.m_hoverPressedColor : this.m_hoverColor; button.style.cursor = "pointer"; } } ReportViewerHoverButton.prototype.OnHover = ReportViewerHoverButtonOnHover; function ReportViewerHoverButtonOnNormal() { var button = GetControl(this.m_buttonID); if (button == null) return; if (this.m_isUsingStyles) button.className = this.m_isPressed ? this.m_hoverStyle : this.m_normalStyle; else { button.style.border = this.m_isPressed ? this.m_hoverBorder : this.m_normalBorder; button.style.backgroundColor = this.m_isPressed ? this.m_hoverColor : this.m_normalColor; button.style.cursor = "default"; } } ReportViewerHoverButton.prototype.OnNormal = ReportViewerHoverButtonOnNormal; function ReportViewerHoverButtonSetPressed(isPressed) { this.m_isPressed = isPressed; this.OnNormal(); } ReportViewerHoverButton.prototype.SetPressed = ReportViewerHoverButtonSetPressed; // Toolbar class constructor function RSToolbar(clientController, currentPageID, totalPagesID, firstEnableMethod, previousEnableMethod, nextEnableMethod, lastEnableMethod, zoomID, findTextID, findController, findNextController, formatsID, exportController, parametersRowID, docMapController, docMapGroupID, docMapVisibilityStateID, printHtmlLink, printFrame, exportUrlBase, enablePrintMethod) { this.m_clientController = clientController; this.m_currentPageID = currentPageID; this.m_totalPagesID = totalPagesID; this.m_zoomID = zoomID; this.m_findTextID = findTextID; this.m_findController = findController; this.m_findNextController = findNextController; this.m_formatsID = formatsID; this.m_exportController = exportController; this.m_parametersRowID = parametersRowID; this.m_docMapController = docMapController; this.m_docMapGroupID = docMapGroupID; this.m_docMapVisibilityStateID = docMapVisibilityStateID; this.m_printHtmlLink = printHtmlLink; this.m_printFrame = printFrame; this.m_exportUrlBase = exportUrlBase; this.m_enablePrintMethod = enablePrintMethod; // Hook up methods this.EnableFirstNav = firstEnableMethod; this.EnablePreviousNav = previousEnableMethod; this.EnableNextNav = nextEnableMethod; this.EnableLastNav = lastEnableMethod; this.m_nextHit = 0; this.m_clientController.SetToolBar(this); } function EnableToolbar(pageNumber, totalPages, enableFindNext) { // Page navigation controls may have been turned off. Can't assume it is rendered var currentPageControl = document.getElementById(this.m_currentPageID); if (currentPageControl != null) { var totalPageControl = GetControl(this.m_totalPagesID); currentPageControl.value = pageNumber; totalPageControl.innerHTML = totalPages; this.EnableFirstNav(pageNumber > 1); this.EnablePreviousNav(pageNumber > 1); this.EnableNextNav(pageNumber < totalPages); this.EnableLastNav(pageNumber < totalPages); if (totalPages > 1) currentPageControl.disabled = null; else currentPageControl.disabled = "disabled"; } // Zoom controls may have been turned off. Can't assume it is rendered var zoomControl = document.getElementById(this.m_zoomID); if (zoomControl != null) zoomControl.disabled = null; // Find controls may have been turned off. Can't assume it is rendered var findTextBox = document.getElementById(this.m_findTextID); if (findTextBox != null) { var hasText = findTextBox.value != null && findTextBox.value != ""; this.m_findController.SetViewerLinkActive(hasText); this.m_findNextController.SetViewerLinkActive(enableFindNext); } // Export controls may have been turned off. Can't assume it is rendered var formatControl = document.getElementById(this.m_formatsID); if (formatControl != null) formatControl.disabled = null; // Print may have been turned off. Can't assume it is rendered var printFrameControl = document.getElementById(this.m_printFrame); if (printFrameControl != null) { this.m_enablePrintMethod(true); } } RSToolbar.prototype.EnableToolbar = EnableToolbar; function DisableToolbar() { // Page navigation controls may have been turned off. Can't assume it is rendered var currentPageControl = document.getElementById(this.m_currentPageID); if (currentPageControl != null) { currentPageControl.disabled = "disabled"; this.EnableFirstNav(false); this.EnablePreviousNav(false); this.EnableNextNav(false); this.EnableLastNav(false); } // Zoom controls may have been turned off. Can't assume it is rendered var zoomControl = document.getElementById(this.m_zoomID); if (zoomControl != null) zoomControl.disabled = "disabled"; // Find controls may have been turned off. Can't assume it is rendered var findTextBox = document.getElementById(this.m_findTextID); if (findTextBox != null) { this.m_findController.SetViewerLinkActive(false); this.m_findNextController.SetViewerLinkActive(false); } // Export controls may have been turned off. Can't assume it is rendered var formatControl = document.getElementById(this.m_formatsID); if (formatControl != null) formatControl.disabled = "disabled"; // Print may have been turned off. Can't assume it is rendered var printFrameControl = document.getElementById(this.m_printFrame); if (printFrameControl != null) { this.m_enablePrintMethod(false); } } RSToolbar.prototype.DisableToolbar = DisableToolbar; function OnExportFormatChanged() { // Get the export UI elements var formatList = GetControl(this.m_formatsID); if (formatList == null) return; // Enable the export button if the renderer selection is not the // "Please select a renderer" option. this.m_exportController.SetViewerLinkActive(formatList.selectedIndex != 0); } RSToolbar.prototype.OnExportFormatChanged = OnExportFormatChanged; function OnToggleParamsAreaVisibility(hideParamsArea) { var parametersRow = GetControl(this.m_parametersRowID); if (parametersRow == null) return; if (hideParamsArea) parametersRow.style.display = "none"; else parametersRow.style.display = ""; } RSToolbar.prototype.OnToggleParamsAreaVisibility = OnToggleParamsAreaVisibility; function OnDocMapClick() { var isVisible = this.m_clientController.IsDocMapVisible(); this.m_clientController.SetDocMapVisibility(!isVisible); } RSToolbar.prototype.OnDocMapClick = OnDocMapClick; function SetHasDocMap() { var docMapGroup = document.getElementById(this.m_docMapGroupID); if (docMapGroup != null) { // Make the button visible docMapGroup.style.display = "inline"; // Make sure there is a spacer (there won't be in the docmap is the only button), and make it visible var docMapSpacer = docMapGroup.nextSibling; if (docMapSpacer != null && docMapSpacer.ToolbarSpacer == "true") docMapSpacer.style.display = "inline"; this.OnDocMapVisibilityChange(); // Update display styles for button } } RSToolbar.prototype.SetHasDocMap = SetHasDocMap; function OnDocMapVisibilityChange() { var docMapVisibilityState = document.getElementById(this.m_docMapVisibilityStateID); if (docMapVisibilityState != null) { // Update the state var isDocMapVisible = this.m_clientController.IsDocMapVisible(); if (isDocMapVisible) docMapVisibilityState.value = "false"; else docMapVisibilityState.value = "true"; // Update color this.m_docMapController.SetPressed(isDocMapVisible); } } RSToolbar.prototype.OnDocMapVisibilityChange = OnDocMapVisibilityChange; function OnZoomChanged(zoomValue) { this.m_clientController.SetZoom(zoomValue); } RSToolbar.prototype.OnZoomChanged = OnZoomChanged; function CurrentZoomValue() { var zoomControl = document.getElementById(this.m_zoomID); if (zoomControl == null) return null; else return zoomControl.value; } RSToolbar.prototype.CurrentZoomValue = CurrentZoomValue; function LoadPrintControl() { var printFrame = GetControl(this.m_printFrame); if (printFrame != null) { if (printFrame.src != this.m_printHtmlLink) { window.frames[this.m_printFrame].window.location.replace(this.m_printHtmlLink); } else eval(this.m_printFrame + ".Print();"); } return false; } RSToolbar.prototype.LoadPrintControl = LoadPrintControl; function HandleClientSideExport() { // Get the export format var formatDropDown = GetControl(this.m_formatsID); var selectedFormat = formatDropDown.value; // Perform the export var fullExportUrl = this.m_exportUrlBase + escape(selectedFormat); window.open(fullExportUrl, "_blank"); // Reset the selection formatDropDown.selectedIndex = 0; this.m_exportController.SetViewerLinkActive(false); return true; } RSToolbar.prototype.HandleClientSideExport = HandleClientSideExport; function OnFindTextChange() { if (event.propertyName != "value") return; // Get the find text box var findTextBox = GetControl(this.m_findTextID); if (findTextBox == null) return; // Enable or disable the buttons var hasText = findTextBox.value != null && findTextBox.value != ""; this.m_findController.SetViewerLinkActive(hasText); this.m_findNextController.SetViewerLinkActive(false); } RSToolbar.prototype.OnFindTextChange = OnFindTextChange;