/********************************* * * ReportViewer * ********************************/ function ReportViewer(clientID , toolbarID , waitControlID , reportFrameID , previewFrameID , paramsFrameID , currentPageID , baseReportUrl , baseExportUrl , basePrintUrl , baseParamsUrl , zoomMode , zoomPercent , backgroundColor , popupPlaceholderID , calendarFrameID , calendarFrameSrc , resources) { this.clientID = clientID; this.toolbarID = toolbarID; this.waitControlID = waitControlID; this.reportFrameID = reportFrameID; this.previewFrameID = previewFrameID; this.paramsFrameID = paramsFrameID; this.currentPageID = currentPageID; this.pageCount = 0; this.baseReportUrl = baseReportUrl.replace(/&/g, "&"); this.baseExportUrl = baseExportUrl.replace(/&/g, "&"); this.basePrintUrl = basePrintUrl.replace(/&/g, "&"); this.baseParamsUrl = baseParamsUrl.replace(/&/g, "&"); this.zoomMode = zoomMode; this.zoomPercent = zoomPercent; this.backgroundColor = backgroundColor; this.printFormat = ""; this.pdfPrintEnabled = null; this.popupPlaceholderID = popupPlaceholderID; this.oldEditor = null; this.calendarFrameID = calendarFrameID; this.calendarFrameSrc = calendarFrameSrc; this.resources = resources; this.Init(); if (navigator.userAgent.indexOf("Safari") > -1) { var reportFrame = document.getElementById(this.reportFrameID); if (reportFrame) { reportFrame.src = "javascript:void(0);" } } var paramsFrame = document.getElementById(this.paramsFrameID); if (paramsFrame) { paramsFrame.ReportViewer = this; if (paramsFrame.src.indexOf("javascript") > -1) { paramsFrame.src = this.baseParamsUrl; } } else { var startPageIndex = this.GetCurrentPageIndex(); if (startPageIndex < 0) { startPageIndex = 0; } this.SetCurrentPageIndex(startPageIndex); } } ReportViewer.prototype = ReportViewer; ReportViewer.prototype.InitFinalize = function() { } ReportViewer.prototype.Init = function() { this.AttachOnClickEventHandler(); this.AttachOnLoadEventHandler(); this.InitPreviewFrame(); this.InitToolbar(); this.EndWait(); }; ReportViewer.prototype.AttachOnClickEventHandler = function() { var body = document.body; if (body) { var viewer = this; var onclickEventHandler = function() { viewer.HideEditorPopup(); } if (body.attachEvent) { body.attachEvent("onclick", onclickEventHandler); } else if (body.addEventListener) { body.addEventListener("click", onclickEventHandler, false); } } } ReportViewer.prototype.AttachOnLoadEventHandler = function() { var reportFrame = document.getElementById(this.reportFrameID); var viewer = this; var onLoadHandler = function() { viewer.OnReportLoaded(); }; reportFrame.Viewer = this; if (reportFrame.attachEvent) { reportFrame.attachEvent("onload", onLoadHandler); } else if (reportFrame.addEventListener) { reportFrame.addEventListener("load", onLoadHandler, false); } } ReportViewer.prototype.InitPreviewFrame = function() { var previewFrame = document.getElementById(this.previewFrameID); var viewer = this; var onPrintLoadHandler = function() { viewer.OnPrintReportLoaded(); }; if (previewFrame.attachEvent) { previewFrame.attachEvent("onreadystatechange", onPrintLoadHandler); } else if (previewFrame.addEventListener) { previewFrame.addEventListener("load", onPrintLoadHandler, false); } } ReportViewer.prototype.InitToolbar = function() { var toolbar = document.getElementById(this.toolbarID); var viewer = this; if (toolbar) { toolbar.OnCommand = function(toolbarBtn) { viewer.OnToolbarCmd(toolbarBtn); }; toolbar.OnUpdateCommandState = function(toolbarBtn) { return viewer.OnToolbarUpdateCmdState(toolbarBtn); }; // Making the table cells unselectable. // This is done with javascript code because of the xHtml compliance. var cells = toolbar.getElementsByTagName("td"); for (var i = 0; i < cells.length; i++) { if (cells[i].setAttribute) { cells[i].setAttribute("unselectable", "on"); } } } } ReportViewer.prototype.OnPrintReportLoaded = function() { switch (this.printFormat) { case "HTML": case "PDF": { var previewFrame = document.getElementById(this.previewFrameID); if (previewFrame) { if (document.all) { if (previewFrame.readyState != "complete") return; } this.EnablePrintButton(true); } } } } ReportViewer.prototype.OnReportLoaded = function() { var reportFrame = document.getElementById(this.reportFrameID); var toolbar = document.getElementById(this.toolbarID); var pageNumberButton = null; var pageInfo = reportFrame.contentWindow.PageInfo; if ((typeof(pageInfo) != "undefined") && (pageInfo.length > 0)) { this.pageCount = pageInfo[1]; if (toolbar) { var pageNumberButton = toolbar.GetButtonByName("PageNumber"); if (pageNumberButton) { pageNumberButton.value = 1 + pageInfo[0]; pageNumberButton.SetPageCount(this.pageCount); } } } this.EndWait(); if (pageNumberButton) { pageNumberButton.Enable(this.pageCount > 1); } if (this.backgroundColor) { var reportBody = reportFrame.contentWindow.document.getElementById('ReportBody'); if (reportBody) { reportBody.style.backgroundColor = this.backgroundColor; } } this.SetZoomInternal(toolbar); } ReportViewer.prototype.SetZoomInternal = function(toolbar) { var zoomValue = this.zoomPercent; var zoomMode = this.zoomMode; if ((typeof(toolbar) != "undefined") && (toolbar)) { var zoomControl = toolbar.GetButtonByName("Zoom"); if (zoomControl) { if (isNaN(zoomControl.value)) { zoomValue = 100; zoomMode = zoomControl.value; } else { zoomValue = parseInt(zoomControl.value); zoomMode = ZoomMode.Percent; } } } this.SetZoom(zoomMode, zoomValue); } ReportViewer.prototype.SetZoom = function(zoomMode, zoomPercent) { //zoom is set on the report area using the browser's zoom capability var reportFrame = document.getElementById(this.reportFrameID); if (!reportFrame) return; if (zoomMode == ZoomMode.Percent) { reportFrame.style.zoom = zoomPercent + "%"; } else { var reportTable = reportFrame.contentWindow.document.getElementById('ReportTable'); if (reportTable) { reportFrame.style.zoom = 1; var zoomValue = 1; if (zoomMode == ZoomMode.PageWidth) { zoomValue = reportFrame.offsetWidth / reportTable.offsetWidth; if (reportFrame.offsetHeight < reportTable.offsetHeight * zoomValue) { zoomValue = reportFrame.offsetWidth / (reportTable.offsetWidth + 16); } } else if (zoomMode == ZoomMode.FullPage) { var zoomHor = reportFrame.offsetWidth / reportTable.offsetWidth; var zoomVer = reportFrame.offsetHeight / reportTable.offsetHeight; zoomValue = (zoomHor < zoomVer) ? zoomHor : zoomVer; } // If the viewer is initially hidden and // the zoom mode is FullPage or PageWidth then zoomValue is NaN. if (!isNaN(zoomValue)) { reportFrame.style.zoom = zoomValue; } } } this.UpdateZoomUI(zoomMode, zoomPercent); } ReportViewer.prototype.UpdateZoomUI = function(zoomMode, zoomPercent) { var toolbar = document.getElementById(this.toolbarID); if (!toolbar) return; //toolbar is hidden var zoomControl = toolbar.GetButtonByName("Zoom"); if (!zoomControl) return; //zoomControl is hidden var itemIndex = this.GetOptionIndex(zoomControl, zoomMode, zoomPercent); if (-1 == itemIndex) { var item = document.createElement('option'); item.text = zoomPercent + "%"; item.value = zoomPercent; try { zoomControl.add(item, null); // standards compliant } catch(ex) { zoomControl.add(item); // IE only } itemIndex = zoomControl.length - 1; } if (zoomControl.selectedIndex != itemIndex) { zoomControl.selectedIndex = itemIndex; } } ReportViewer.prototype.GetOptionIndex = function(zoomControl, zoomMode, zoomPercent) { var searchValue = zoomPercent; if (ZoomMode.FullPage == zoomMode || ZoomMode.PageWidth == zoomMode) { searchValue = zoomMode; } for (i = 0; i < zoomControl.length; i++) { if (searchValue == zoomControl.options[i].value) { return i; } } return -1; } // Return false to disable the command; otherwise the command is enabled ReportViewer.prototype.OnToolbarUpdateCmdState = function(toolbarBtn) { switch (toolbarBtn.CommandName) { case "Print": return this.OnUpdatePrintState(); case "FirstPage": return this.CanNavigateToPage(0); case "PrevPage": return this.CanNavigateToPage(this.GetCurrentPageIndex() - 1); case "NextPage": return this.CanNavigateToPage(this.GetCurrentPageIndex() + 1); case "LastPage": return this.CanNavigateToPage(this.pageCount - 1); case "PageNumber": return (this.pageCount > 0); case "Export": var formatList = toolbarBtn.Toolbar.GetButtonByName("FormatList"); var val = (null != formatList && formatList.selectedIndex != 0); return val; } }; ReportViewer.prototype.OnToolbarCmd = function(toolbarBtn) { switch (toolbarBtn.CommandName) { case "Refresh": this.OnRefresh(); break; case "Print": this.OnPrint(); break; case "FirstPage": this.SetCurrentPageIndex(0); break; case "PrevPage": this.SetCurrentPageIndex(this.GetCurrentPageIndex() - 1); break; case "NextPage": this.SetCurrentPageIndex(this.GetCurrentPageIndex() + 1); break; case "LastPage": this.SetCurrentPageIndex(this.pageCount - 1); break; case "PageNumber": var pageIndex = parseInt(toolbarBtn.value) - 1; if (isNaN(pageIndex) || (pageIndex < 0 || pageIndex >= this.pageCount)) { alert("Please, select page between 1-" + this.pageCount); //TODO: localize toolbarBtn.focus(); toolbarBtn.select(); } else { this.SetCurrentPageIndex(pageIndex); } break; case "Export": var formatList = toolbarBtn.Toolbar.GetButtonByName("FormatList"); var exportFormat = formatList.value; this.ExportInternal(exportFormat, this.GetCurrentPageIndex()); break; case "Zoom": this.SetZoomInternal(toolbarBtn.Toolbar); break; case "ParametersArea": this.set_ShowParametersArea(!this.get_ShowParametersArea(), toolbarBtn); break; } }; ReportViewer.prototype.SetCurrentPageIndex = function(pageIndex) { if (this.baseReportUrl) { this.StoreCurrentPageIndex(pageIndex); var url = this.baseReportUrl + "&PageIndex=" + pageIndex; this.BeginWait(); var reportFrame = document.getElementById(this.reportFrameID); reportFrame.src = url; } } ReportViewer.prototype.StoreCurrentPageIndex = function(pageIndex) { var input = document.getElementById(this.currentPageID); if (input) { input.value = pageIndex; } } ReportViewer.prototype.GetCurrentPageIndex = function() { var index = -1; var input = document.getElementById(this.currentPageID); if (input) { index = parseInt(input.value); if (isNaN(index)) { index = -1; } } return index; // page index is 0-base; -1 - invalid page index }; ReportViewer.prototype.get_CurrentPage = function() { return this.GetCurrentPageIndex() + 1; } ReportViewer.prototype.set_CurrentPage = function(pageNumber) { this.SetCurrentPageIndex(pageNumber - 1); } ReportViewer.prototype.get_TotalPages = function() { return this.pageCount; } ReportViewer.prototype.CanMoveToPage = function(pageNumber) { return this.CanNavigateToPage(pageNumber - 1); } ReportViewer.prototype.CanNavigateToPage = function(pageIndex) { var currentPageIndex = this.GetCurrentPageIndex(pageIndex); return (0 <= pageIndex && pageIndex < this.pageCount && pageIndex != currentPageIndex); }; ReportViewer.prototype.ExportReport = function(format) { this.ExportInternal(format, this.GetCurrentPageIndex()); }; ReportViewer.prototype.ExportInternal = function(format, pageIndex) { if (this.baseExportUrl) { var currentPageIndex = this.GetCurrentPageIndex(pageIndex); var url = this.baseExportUrl + "&ExportFormat=" + format; // url = url + "&PageIndex=" + currentPageIndex; window.open(url, "_blank"); } }; ReportViewer.prototype.RefreshReport = function() { this.OnRefresh(); } ReportViewer.prototype.OnRefresh = function() { if (this.baseReportUrl) { this.BeginWait(); var reportFrame = document.getElementById(this.reportFrameID); this.StoreCurrentPageIndex(0); reportFrame.src = this.baseReportUrl + "&PageIndex=0&Refresh=true"; } }; ReportViewer.prototype.OnUpdatePrintState = function() { return true; var reportFrame = document.getElementById(this.reportFrameID); if (!reportFrame) return false; var wnd = reportFrame.contentWindow; try { return wnd.document.queryCommandSupported("print"); } catch (ex) { if (!document.all && wnd.print) { return true; } } return false; }; ReportViewer.prototype.CanEnablePrintButton = function() { // Under Opera and Safari the print button cannot be enabled. var agent = navigator.userAgent; if (agent.indexOf("Opera") != -1) return false; if (agent.indexOf("Safari") != -1) return false; return true; }; ReportViewer.prototype.PrintAs = function(pf) { try { this.printFormat = pf; switch (this.printFormat) { case "PDF": case "HTML": { var previewFrameID = this.previewFrameID; var previewFrame = document.getElementById(previewFrameID); if (previewFrame) { var printUrl = this.CreatePrintReportUrl(this.printFormat); if (this.CanEnablePrintButton()) { this.EnablePrintButton(false); } previewFrame.src = printUrl; } break; } case "Default": { if (this.CanEnablePrintButton()) { var reportFrame = document.getElementById(this.reportFrameID); var wnd = reportFrame.contentWindow; if (document.all) { wnd.document.execCommand("print", true, null); } else if (wnd.print) { wnd.print(); } } else { alert("Unable to perform the Print operation."); } } } } catch (ex) { alert("Error printing the report:\n\n" + ex); } } ReportViewer.prototype.EnablePrintButton = function(enable) { var toolbar = document.getElementById(this.toolbarID); if (toolbar) { var btn = toolbar.GetButtonByName("Print"); if (btn) { btn.Enable(enable); } } } ReportViewer.prototype.DefaultPrint = function() { this.PrintAs("Default"); } ReportViewer.prototype.CreatePrintReportUrl = function(printFormat) { var date = new Date().getTime(); var printUrl = this.basePrintUrl + "&format=" + printFormat + "&rand=" + date; return printUrl; } ReportViewer.prototype.GetIEPlugin = function(classid) { var result = null; try { result = new ActiveXObject(classid); } catch (ex) { } return result; } ReportViewer.prototype.DetectIEPDFPlugin = function() { return this.GetIEPlugin("PDF.PdfCtrl.5") || this.GetIEPlugin("PDF.PdfCtrl.6") || this.GetIEPlugin("AcroPDF.PDF.1"); } ReportViewer.prototype.DetectFFPDFPlugin = function() { var pdfPlugins = navigator.mimeTypes["application/pdf"]; var pdfPlugin = pdfPlugins != null ? pdfPlugins.enabledPlugin : null; return ( (pdfPlugin) && (pdfPlugin.description.indexOf("Adobe") != -1) && ((pdfPlugin.description.indexOf("Version") == -1 || parseFloat(pdfPlugin.description.split("Version")[1]) >= 6)) ); } ReportViewer.prototype.IsPdfPrintEnabled = function() { if (this.pdfPrintEnabled == null) { this.pdfPrintEnabled = this.DetectIEPDFPlugin() || this.DetectFFPDFPlugin(); } return this.pdfPrintEnabled; }; ReportViewer.prototype.PrintReport = function() { this.PrintAs(this.IsPdfPrintEnabled() ? "PDF" : "Default"); }; ReportViewer.prototype.OnPrint = function() { this.PrintReport(); }; ReportViewer.prototype.BeginWait = function() { this.Wait(true); }; ReportViewer.prototype.EndWait = function() { this.Wait(false); }; ReportViewer.prototype.Wait = function(wait) { var toolbar = document.getElementById(this.toolbarID); var waitControl = document.getElementById(this.waitControlID); var reportFrame = document.getElementById(this.reportFrameID); wait = (false != wait); if (waitControl) waitControl.style.display = wait ? "" : "none"; if (reportFrame) { // reportFrame.style.display = wait ? "none" : ""; reportFrame.style.width = wait ? "0px" : "100%"; reportFrame.style.height = wait ? "0px" : "100%"; } if (toolbar) toolbar.Enable(!wait); }; ReportViewer.prototype.Wait = function(wait) { var toolbar = document.getElementById(this.toolbarID); var waitControl = document.getElementById(this.waitControlID); var reportFrame = document.getElementById(this.reportFrameID); wait = (false != wait); if (waitControl) waitControl.style.display = wait ? "" : "none"; if (reportFrame) { // reportFrame.style.display = wait ? "none" : ""; reportFrame.style.width = wait ? "0px" : "100%"; reportFrame.style.height = wait ? "0px" : "100%"; } if (toolbar) toolbar.Enable(!wait); }; ReportViewer.prototype.UpdateParamReport = function() { var paramFrame = document.getElementById(this.paramsFrameID); if ((paramFrame) && (paramFrame.src.indexOf("javascript") == -1)) { var startPageIndex = this.GetCurrentPageIndex(); if (startPageIndex < 0) { startPageIndex = 0; this.SetCurrentPageIndex(startPageIndex); } else { this.OnRefresh(); } } } //toolbarButton is an optional parameter ReportViewer.prototype.set_ShowParametersArea = function(visible, toolbarButton) { var paramFrame = document.getElementById(this.paramsFrameID); if (!paramFrame) return; //if toolbarButton is not passed, resolve it if (!toolbarButton) { var toolbarButton; var toolbar = document.getElementById(this.toolbarID); if (toolbar) { toolbarButton = toolbar.GetButtonByName("ParametersArea"); } } var newDisplayStyle = ""; if (false == visible) { newDisplayStyle = "none"; } if(paramFrame.style.display != newDisplayStyle) { paramFrame.style.display = newDisplayStyle; //update button's state if(toolbarButton) { toolbarButton.Pressed = visible; toolbarButton.onmouseout(); //refresh the Pressed state; var inputs = toolbarButton.getElementsByTagName("input"); if ((inputs) && (inputs.length > 1)) { var tooltip = inputs[0].value; var imageButton = inputs[1]; var tooltips = tooltip.split("|"); imageButton.title = visible ? tooltips[0] : tooltips[1]; } } } } ReportViewer.prototype.get_ShowParametersArea = function() { var paramFrame = document.getElementById(this.paramsFrameID); if (!paramFrame) { return false; } return "" == paramFrame.style.display; } //ReportViewer.prototype.ToggleParametersAreaVisibilityInternal = function(toolbarButton) //{ // var paramFrame = document.getElementById(this.paramsFrameID); // if ("" == paramFrame.style.display) // { // paramFrame.style.display = "none"; // toolbarButton.Pressed = false; // } // else // { // paramFrame.style.display = ""; // toolbarButton.Pressed = true; // } // // if (toolbarButton) // { // var inputs = toolbarButton.getElementsByTagName("input"); // if ((inputs) && (inputs.length > 1)) // { // var tooltip = inputs[0].value; // var imageButton = inputs[1]; // var tooltips = tooltip.split("|"); // if (paramFrame) // { // imageButton.title = ("" == paramFrame.style.display) ? tooltips[0] : tooltips[1]; // } // } // } //} ReportViewer.prototype.ShowCalendar = function(dateTimeEditor, location) { var frameSrc = this.calendarFrameSrc + "&SelectedDate=" + dateTimeEditor.GetSelectedDate(); var calendarFrame = document.getElementById(this.calendarFrameID); if (calendarFrame) { if (calendarFrame.style.display == "none") { var paramFrame = document.getElementById(this.paramsFrameID); var frameLocation = GetAbsolutePosition(paramFrame); calendarFrame.style.left = FormatDimension(location.Left + frameLocation.Left); calendarFrame.style.top = FormatDimension(location.Top + frameLocation.Top); calendarFrame.style.display = ""; calendarFrame.ReportViewer = this; this.dateTimeEditor = dateTimeEditor; calendarFrame.src = frameSrc; } else { calendarFrame.style.display = "none"; } } } ReportViewer.prototype.UpdateDate = function(selectedDate) { if (this.dateTimeEditor) { this.dateTimeEditor.UpdateDate(selectedDate); } var calendarFrame = document.getElementById(this.calendarFrameID); if (calendarFrame) { calendarFrame.style.display = "none"; } } ReportViewer.prototype.GetString = function(keyName) { return eval('this.resources.' + keyName); } /********************************** * * ReportToolbar * **********************************/ function ReportToolbar(id, arrButtons) { var toolBar = document.getElementById(id); if (toolBar) { toolBar.Buttons = arrButtons; // Methods toolBar.Init = ReportToolbar_Init; toolBar.Enable = ReportToolbar_Enable; toolBar.GetButton = ReportToolbar_GetButton; toolBar.GetButtonByName = ReportToolbar_GetButtonByName; toolBar.OnCommand = ReportToolbar_OnCommand; toolBar.OnUpdateCommandState = ReportToolbar_OnUpdateCommandState; toolBar.ExportFormatChanged = ReportToolbar_ExportFormatChanged; toolBar.ZoomChanged = ReportToolbar_ZoomChanged; toolBar.Init(); } } function ReportToolbar_Init() { var btn = null; for (var i = 0; i < this.Buttons.length; i++) { btn = this.GetButton(this.Buttons[i]); if (btn) { btn.Toolbar = this; } } } function ReportToolbar_Enable(enabled) { enabled = (false != enabled); var btn = null; for (var i = 0; i < this.Buttons.length; i++) { btn = this.GetButton(this.Buttons[i]); if (btn && btn.Enable) { btn.Enable(enabled && (false != this.OnUpdateCommandState(btn))); } } } function ReportToolbar_GetButton(id) { var btn = document.getElementById(id); if (!btn) { alert("Button " + id + " not found"); } return btn; } function ReportToolbar_GetButtonByName(commandName) { var btn = null; for (var i = 0; i < this.Buttons.length; i++) { btn = this.GetButton(this.Buttons[i]); if (btn && btn.CommandName == commandName) { return btn; } } return null; } function ReportToolbar_UpdateButtons() { var btn = null; for (var i = 0; i < this.Buttons.length; i++) { btn = this.GetButton(this.Buttons[i]); if (btn) { this.OnUpdateState(btn); } } } function ReportToolbar_OnUpdateCommandState(toolbarButton) { alert("OnUpdateCommandState: " + toolbarButton.CommandName); return true; } function ReportToolbar_OnCommand(toolbarButton) { alert("OnCommand: " + toolbarButton.CommandName); } function ReportToolbar_ExportFormatChanged(formatList) { var enable = (formatList.selectedIndex != 0); var btn = this.GetButtonByName("Export"); if (btn) { btn.Enable(enable); } return enable; } function ReportToolbar_ZoomChanged(zoomSelect) { return true; } /********************************** * * ToolbarButton * **********************************/ function ToolbarButton(id, commandName, enabled, enableStyle, disableStyle) { var btn = document.getElementById(id); if (btn) { btn.CommandName = commandName; if (enableStyle.length > 0) { btn.EnableStyle = enableStyle; } if (disableStyle.length > 0) { btn.DisableStyle = disableStyle; } btn.Enable = ToolbarButton_Enable; btn.Exec = ToolbarButton_Exec; btn.Enable(true); return btn; } return null; } function ToolbarButton_Enable(enabled) { this.Enabled = (false != enabled); if (typeof(this.EnableStyle) != "undefined") { this.className = enabled ? this.EnableStyle : this.DisableStyle; } this.disabled = enabled ? "" : "disabled"; } function ToolbarButton_Exec() { if (this.Toolbar) { this.Toolbar.OnCommand(this); } } /********************************** * * ToolbarImageButton * **********************************/ function ToolbarImageButton(id , commandName , enabled , enabledStyle , disabledStyle , buttonStyle , pressed) { var btn = ToolbarButton(id, commandName, enabled, enabledStyle, disabledStyle); if (btn) { // Properties btn.ButtonStyle = buttonStyle; // true: toggle button; false: push button btn.Pressed = ("ToggleButton" == buttonStyle) ? pressed : false; // events btn.onclick = ToolbarImageButton_Click; btn.onmouseover = ToolbarImageButton_MouseOver; btn.onmouseout = ToolbarImageButton_MouseOut; } } function ToolbarImageButton_Click(e) { if (!e) { e = window.event; } CancelEvent(e); if (!this.Enabled) return; if ("ToggleButton" == this.ButtonStyle) { this.Pressed = !this.Pressed; this.onmouseover(); } this.Exec(); } function ToolbarImageButton_MouseOver() { if (this.Enabled) { this.className = this.Pressed ? "HoverPressedButton" : "HoverButton"; } } function ToolbarImageButton_MouseOut() { if (this.Enabled) { this.className = this.Pressed ? "PressedButton" : "NormalButton"; } } /********************************** * * ReportPageNumberTextBox * **********************************/ function ReportPageNumberTextBox(id, commandName, enabled, enabledStyle, disabledStyle, pageCountLabelID) { var btn = ToolbarButton(id, commandName, enabled, enabledStyle, disabledStyle); if (btn) { btn.PageCountLabelID = pageCountLabelID; btn.SetPageCount = ReportPageNumberTextBox_SetPageCount; // Events btn.onkeypress = ReportPageNumberTextBox_KeyPress; } } function ReportPageNumberTextBox_SetPageCount(pageCount) { var o = document.getElementById(this.PageCountLabelID); if (o) { o.innerHTML = (pageCount > 0) ? pageCount : " -- "; } } function ReportPageNumberTextBox_KeyPress(e) { if (!e) { e = window.event; } if (e.keyCode == 10 || e.keyCode == 13) { try { this.Exec(); } catch (ex) { } CancelEvent(e); } } /********************************** * * ReportTextButton * **********************************/ function ReportTextButton(id, commandName, enabled, enabledStyle, disabledStyle) { var btn = ToolbarButton(id, commandName, enabled, enabledStyle, disabledStyle); if (btn) { // events btn.onclick = ReportTextButton_Click; } } function ReportTextButton_Click(e) { if (!e) { e = window.event; } CancelEvent(e); if (this.Enabled) { this.Exec(); } } /********************************** * * ExportFormatButton * **********************************/ function ExportFormatButton(id, commandName, enabled, enabledStyle, disabledStyle) { var btn = ToolbarButton(id, commandName, enabled, enabledStyle, disabledStyle); if (btn) { // events btn.onchange = function() { this.Toolbar.ExportFormatChanged(this); }; } } /********************************** * * ZoomButton * **********************************/ function ZoomButton(id, commandName, enabled, enabledStyle, disabledStyle) { var btn = ToolbarButton(id, commandName, enabled, enabledStyle, disabledStyle); if (btn) { // events btn.onchange = ReportTextButton_Click; } } /********************************** * * ZoomMode * **********************************/ function ZoomMode(name) { this.name = name; } ZoomMode.prototype.toString = function () { return this.name; }; ZoomMode.FullPage = new ZoomMode("FullPage"); ZoomMode.PageWidth = new ZoomMode("PageWidth"); ZoomMode.Percent = new ZoomMode("Percent"); /********************************** * * Global functions * **********************************/ function CancelEvent(e) { if (e) { e.returnValue = false; e.cancelBubble = true; if (e.preventDefault) { e.preventDefault(); } } } ReportViewer.prototype.HideEditorPopup = function() { if (this.oldEditor) { var popupPlaceholder = document.getElementById(this.popupPlaceholderID); if (this.oldEditor.GetValue) { this.oldEditor.GetValue(popupPlaceholder); } popupPlaceholder.innerHTML = ""; popupPlaceholder.style.display = "none"; this.oldEditor = null; /* var paramFrame = document.getElementById(this.paramsFrameID); if ((paramFrame) && (paramFrame.contentWindow.document.CloseActiveEditor)) { paramFrame.contentWindow.document.CloseActiveEditor(); } */ } var calendarFrame = document.getElementById(this.calendarFrameID); if (calendarFrame) { calendarFrame.style.display = "none"; } } ReportViewer.prototype.ShowEditorPopup = function (valueEditor, rectangle) { var popupPlaceholder = document.getElementById(this.popupPlaceholderID); if ((valueEditor) && (popupPlaceholder)) { var editor = valueEditor.GetPopupEditor(); popupPlaceholder.innerHTML = editor.innerHTML; if (valueEditor.UpdateState) { valueEditor.UpdateState(popupPlaceholder); } var paramFrame = document.getElementById(this.paramsFrameID); var frameLocation = GetAbsolutePosition(paramFrame); var absoluteTop = frameLocation.Top + rectangle.Top; var absoluteLeft = frameLocation.Left + rectangle.Left; popupPlaceholder.style.top = FormatDimension(absoluteTop); popupPlaceholder.style.left = FormatDimension(absoluteLeft); popupPlaceholder.style.width = FormatDimension(rectangle.Width); popupPlaceholder.style.height = FormatDimension(rectangle.Height); popupPlaceholder.style.backgroundColor = editor.style.backgroundColor; popupPlaceholder.style.borderColor = editor.style.borderColor; popupPlaceholder.style.borderWidth = editor.style.borderWidth; popupPlaceholder.style.borderStyle = editor.style.borderStyle; popupPlaceholder.style.position = "absolute"; popupPlaceholder.style.display = ""; this.oldEditor = valueEditor; } } function FormatDimension(dimension) { var dim = dimension.toString(); if ((dim.length > 0) && (dim.indexOf("px") == -1)) { return dim + "px"; } return dim; } function GetAbsolutePosition(element) { var top = 0; var left = 0; while ((null != element) && (element != document.body)) { if (element.style.position == "absolute") { element = null; break; }; top += element.offsetTop; left += element.offsetLeft; element = element.offsetParent; } if (null != element) { left += element.offsetLeft; top += element.offsetTop; } return { Left:left, Top:top }; } function StyelExists(header, href) { var styles = header.getElementsByTagName("link"); for (var i = 0; i < styles.length; i++) { var style = styles[i]; if (href == style.href) { return true; } } return false; } function LoadStyle(href) { var header = document.getElementsByTagName("head")[0]; if (!StyelExists(header, href)) { var cssNode = document.createElement('link'); cssNode.type = 'text/css'; cssNode.rel = 'stylesheet'; cssNode.href = href; cssNode.media = 'screen'; header.appendChild(cssNode); } } if ((typeof(Sys) != "undefined") && (typeof(Sys.Application) != "undefined")) { Sys.Application.notifyScriptLoaded(); }