/** * a browser agnostic onload */ var controllerRepViewer$coreViewer = new CoreController(); if(window.addEventListener) { window.addEventListener('load', initializeRepViewer$coreViewer, false); window.addEventListener('resize', resizeControlRepViewer$coreViewer, false); } else { window.attachEvent('onload', function(){ initializeRepViewer$coreViewer(); }); window.attachEvent('onresize', function() { resizeControlRepViewer$coreViewer(); }); } /* * Initializes the controller and loads the specified report. * This is the starting point for the script to make the initial ajax call to get * the report. */ function initializeRepViewer$coreViewer(){ initializeSplitterLocation(); initializeSize(); makeDragableSplitter(); currentTime = new Date(); DiagContext.traceVerbose('Initializing for RepViewer$coreViewer ' + currentTime.getMinutes() + ':' + currentTime.getMilliseconds()); controllerRepViewer$coreViewer.loadPageValues(); } /* * Set the size and position for the loading image based off of the size of the viewer IFrame area. */ function setLoadingImagePosition(){ var image = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportLoadingImage")); if(!image.complete) image.onload = loadingImageLoaded; else loadingImageLoaded(); } /* * Set the size and position for the loading image based off of the size of the viewer IFrame area and the * loading image. */ function loadingImageLoaded() { var coreIFrame = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("CorePanel")); if(coreIFrame == null){ return; } var loadingImageDiv = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("loadingImageDiv")); loadingImageDiv.style.top = coreIFrame.offsetTop + "px"; loadingImageDiv.style.left = coreIFrame.offsetLeft + "px"; loadingImageDiv.style.width = coreIFrame.clientWidth + "px"; loadingImageDiv.style.height = coreIFrame.clientHeight + "px"; var image = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportLoadingImage")); /* IE does not always have the height and width properties set on an image that is loaded. Check * if naturalHeight/naturalWidth are set and use them instead. */ var imageHeight = image.height; if(imageHeight <= 0 && image.naturalHeight) imageHeight = image.naturalHeight; var imageWidth = image.width; if(imageWidth <= 0 && image.naturalWidth) imageWidth = image.naturalWidth; if(imageHeight <= 0 && imageWidth <= 0){ /* At this point either the image does not exist or we are in a browser (IE8 or earlier) * that does not support naturalWidth/naturalHeight. Create the loading image in memory * and gather it's dimensions if it exists. */ var memoryImage = new Image(); memoryImage.src = image.src; imageHeight = memoryImage.height; imageWidth = memoryImage.width; memoryImage = null; } var imageDivHalfHeight = coreIFrame.clientHeight/2; var imageHalfHeight = imageHeight/2; var calculatedTop = imageDivHalfHeight - (imageHalfHeight + coreIFrame.offsetTop); var top = (calculatedTop > 0) ? calculatedTop : 0; image.style.top = top + "px"; var imageHalfWidth = imageWidth/2; var imageDivHalfWidth = coreIFrame.clientWidth/2; var calculatedLeft = imageDivHalfWidth - (imageHalfWidth + coreIFrame.offsetLeft); var left = (calculatedLeft > 0) ? calculatedLeft : 0; image.style.left = left + "px"; } function getViewportSize(){ var size = [0, 0]; if (typeof window.innerWidth != 'undefined') { size = [ window.innerWidth, window.innerHeight ]; } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) { size = [ document.documentElement.clientWidth, document.documentElement.clientHeight ]; } else { size = [ document.getElementsByTagName('body')[0].clientWidth, document.getElementsByTagName('body')[0].clientHeight ]; } return size; } /* * resize event handler to deal with resizing the controls if they are set to dock. */ var g_prevSize=[-1,-1]; var g_prevSize2=[-1,-1]; var g_isIE8 = (document.documentMode && document.documentMode >= 8); function resizeControlRepViewer$coreViewer(){ var currentSize = getViewportSize(); if(currentSize[0] == g_prevSize[0] && currentSize[1] == g_prevSize[1]) return; if(g_isIE8) // fix for IE8 docked viewer infinite resize loop { if(currentSize[0] == g_prevSize2[0] && currentSize[1] == g_prevSize2[1]) { g_prevSize2=[-1,-1]; return; } g_prevSize2 = g_prevSize; } g_prevSize = currentSize; var mainControl = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportViewerControlPanel")); if(mainControl == null){ setLoadingImagePosition(); return; //not using the wrapped viewer } var isDocked = (mainControl.parentNode.className == "docked"); if(isDocked){ initializeSize(); } } /* * Sets the intial location of the splitter control based off of the size of the sidebar. */ function initializeSplitterLocation(){ var sideBar = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportViewerSideBar")); var splitter = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("splitter")); if(sideBar==null || splitter==null){ return; } splitter.style.left = sideBar.style.width; var leftColumn = document.getElementById("coverLeftColumn"); leftColumn.style.width = sideBar.style.width; } var parentControlRepViewer$coreViewer = null; //outter most part of the web viewer control var outterNodeRepViewer$coreViewer = null; //container hosting the web control var mainControlWidth; /* * Initializes the size of the core viewer controls. Used to allow for full dock inside a parent. */ function initializeSize(){ var mainControl = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportViewerControlPanel")); if(mainControl == null){ setLoadingImagePosition() return; //not using the wrapped viewer } var isDocked = (mainControl.parentNode.className == "docked"); var controlWidth = mainControl.clientWidth; var controlHeight = mainControl.clientHeight; if(isDocked){ if (parentControlRepViewer$coreViewer == null || outterNodeRepViewer$coreViewer == null) { findParentAndHost(mainControl); } var parentControl = parentControlRepViewer$coreViewer; var outterNode = outterNodeRepViewer$coreViewer; if(outterNode == document || outterNode.tagName.toLowerCase() == "body") { controlHeight = Math.max(document.documentElement.clientHeight, document.body.clientHeight); controlWidth = Math.max(document.documentElement.clientWidth, document.body.clientWidth); } else{ controlHeight = outterNode.clientHeight; controlWidth = outterNode.clientWidth; } parentControl.style.position = "relative"; parentControl.style.top = 0; parentControl.style.left = 0; } var isPdf = controllerRepViewer$coreViewer.reportInstance.format.toLowerCase() == "pdf"; var padding = isPdf ? 18 : 2; var toolbarBottomMargin = 2; mainControlWidth = controlWidth - padding; var mainControlHeight = controlHeight - padding var toolBar = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportViewerToolbar")); toolBar.style.position = "relative"; toolBar.style.left = "0px"; toolBar.style.top = "0px"; toolBar.style.width = mainControlWidth + "px"; var toolBarHeight = toolBar.clientHeight + toolbarBottomMargin; var bottomPanel = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportViewerLowerPanel")); bottomPanel.style.position = "relative"; bottomPanel.style.top = "0px"; bottomPanel.style.left = "0px"; bottomPanel.style.width = mainControlWidth + "px"; var calculatedHeight = (mainControlHeight - toolBarHeight); var height = (calculatedHeight > 0) ? calculatedHeight : 0; bottomPanel.style.height = height + "px"; var bottomPanelHeight = bottomPanel.clientHeight; var sideBar = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportViewerSideBar")); var sideBarWidth = 0; if(sideBar.style.display.length == 0){ var splitter = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("splitter")); splitter.style.display = ''; sideBarWidth = (splitter.offsetLeft >= 0) ? splitter.offsetLeft : splitter.style.width; if(sideBarWidth >= mainControlWidth){ var adjustedWidth = mainControl.clientWidth/3; sideBarWidth = ((adjustedWidth > 0) ? adjustedWidth : 0 ) splitter.style.left = sideBarWidth + "px"; } sideBar.style.position = "absolute"; sideBar.style.top = "0px"; sideBar.style.left = "0px"; sideBar.style.height = bottomPanelHeight + "px"; sideBar.style.width = sideBarWidth + "px"; var leftColumn = document.getElementById("coverLeftColumn"); leftColumn.style.width = sideBarWidth + "px"; var sideBarToolbar = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportViewerSidebarToolbar")); var sideBarToolbarHeight = sideBarToolbar.clientHeight + 2; sideBarToolbar.style.width = sideBarWidth + "px"; var findPanel = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("findPanel")); var calculatedHeight = (bottomPanelHeight - sideBarToolbarHeight); var height = (calculatedHeight > 0) ? calculatedHeight : 10; findPanel.style.height = height + "px"; findPanel.style.width = sideBarWidth + "px"; var parameterPanel = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("parameterPanel")); parameterPanel.style.height = height + "px"; parameterPanel.style.width = sideBarWidth + "px"; var documentMapPanel = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("documentMapPanel")); documentMapPanel.style.height = height + "px"; documentMapPanel.style.width = sideBarWidth + "px"; var documentArea = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportViewerCoreViewerPanel")); documentArea.style.top = "0px"; documentArea.style.position = "absolute"; documentArea.className = "reportPreviewPanel"; documentArea.style.left = sideBarWidth + "px"; var reportContentContainer = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("coreViewerReportOutputContainer")); var calculatedHeight = (bottomPanelHeight - (reportContentContainer.offsetTop * 2) * 2); var height = (calculatedHeight > 0 ) ? calculatedHeight : 0; documentArea.style.height = height + "px"; offset = documentArea.offsetLeft - sideBarWidth; var calculatedWidth = mainControlWidth - (sideBarWidth + offset); var width = ( calculatedWidth > 0) ? calculatedWidth : 0; documentArea.style.width = width + "px"; var coreIFrame = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("CorePanel")); if(height > 0){ calculatedHeight = bottomPanelHeight - ((bottomPanelHeight - height) - ((coreIFrame.offsetTop) * 2)); } else{ calculatedHeight = ((bottomPanelHeight - height) - ((coreIFrame.offsetTop) * 2)); } var height = (calculatedHeight > 0 ) ? calculatedHeight : 0; coreIFrame.style.height = height + "px"; } else { var splitter = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("splitter")); splitter.style.display = 'none'; var documentArea = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportViewerCoreViewerPanel")); documentArea.style.position = ""; documentArea.style.width = "100%"; documentArea.style.position = "absolute"; documentArea.style.top = "0px"; documentArea.style.left = "0px"; var reportContentContainer = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("coreViewerReportOutputContainer")); var offset = (reportContentContainer.offsetTop * 2) * 2; var calculatedHeight = (bottomPanelHeight - offset); var height = (calculatedHeight > 0) ? calculatedHeight : 0; documentArea.style.height = height + "px"; documentArea.className = ""; /* clear class name to remove the left margin */ var coreIFrame = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("CorePanel")); if(height > 0){ calculatedHeight = bottomPanelHeight - ((bottomPanelHeight - height) - ((coreIFrame.offsetTop) * 2)); } else{ calculatedHeight = ((bottomPanelHeight - height) - ((coreIFrame.offsetTop) * 2)); } var height = (calculatedHeight > 0 ) ? calculatedHeight : 0; coreIFrame.style.height = height + "px"; } controllerRepViewer$coreViewer._updateForResize(isPdf); setLoadingImagePosition(); } /* * Helper function for the docking code */ function findParentAndHost(mainControl) { var parentControl = mainControl.parentNode var outterNode = parentControl.parentNode //if the hosting control is a form find the next non-form hosting container while(outterNode.tagName.toLowerCase() == "form"){ outterNode = outterNode.parentNode; } var controlWidth = outterNode.clientWidth; var controlHeight = outterNode.clientHeight; if(controlWidth == 0 || controlHeight == 0){ do{ outterNode = outterNode.parentNode; controlWidth = outterNode.clientWidth; controlHeight = outterNode.clientHeight; }while(controlWidth == 0 || controlHeight == 0 || outterNode.parentNode ) } parentControlRepViewer$coreViewer = parentControl; outterNodeRepViewer$coreViewer = outterNode; } /** *Splitter code */ var doSlideRepViewer$coreViewer=false; var xRepViewer$coreViewer; var offsetRepViewer$coreViewer; var maxOffsetRepViewer$coreViewer; var btnRepViewer$coreViewer = -1; /* * Initializes the events for the the splitter functionality */ function makeDragableSplitter() { var splitter = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("splitter")); if(splitter == null){ return; } splitter.onmousedown=drags; splitter.onmousemove=move; splitter.onmouseup=release; var cover = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("splitterCover")); cover.onmouseup=release; cover.onmousemove=move; var lowerPanel = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportViewerLowerPanel")); lowerPanel.onmouseleave=release; } /* * Handles the event when the mouse button is release to apply the new size based off of the location of the splitter. */ function release() { if(doSlideRepViewer$coreViewer) { var splitter = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("splitter")); splitter.className = "splitter"; initializeSize(); hideCover(); } doSlideRepViewer$coreViewer=false; btnRepViewer$coreViewer = 99; } /* * Handles moving the splitter control when the mouse is moved. */ function move(evt) { if (evt == null) evt = window.event; var parent = evt.target; if (parent == null) parent = evt.srcElement; if(doSlideRepViewer$coreViewer) { if (btnRepViewer$coreViewer==1) { var change = offsetRepViewer$coreViewer+evt.clientX-xRepViewer$coreViewer; var splitter = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("splitter")); change = Math.min(change,maxOffsetRepViewer$coreViewer); splitter.style.left = change + 'px'; var leftColumn = document.getElementById("coverLeftColumn"); leftColumn.style.width = change + 'px'; } } } /* * Puts the splitter in a drag mode to prepare for sizing. */ function drags(evt) { if (evt == null) evt = window.event; var parent = evt.target; if (parent == null) parent = evt.srcElement; if (parent.className=="splitter") { if(evt.button == 0 || evt.button ==1) btnRepViewer$coreViewer = 1; showCover(); doSlideRepViewer$coreViewer=true; offsetRepViewer$coreViewer=parent.offsetLeft; xRepViewer$coreViewer=evt.clientX; parent.className = "splitterFocus"; var mainControl = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("reportViewerControlPanel")); maxOffsetRepViewer$coreViewer=mainControlWidth - 1; } // stop default event (selection) from firing return false; } /* * Enables the splitter cover which covers the lower panel. This prevents problems with the iframe taking the mouse events away from the splitter. */ function showCover(){ var mainPanel = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("previewMainPanel")); mainPanel.style.display = "none"; var cover = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("splitterCover")); cover.style.display = ""; } /* * Hides the splitter cover which covers the lower panel. */ function hideCover(){ var mainPanel = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("previewMainPanel")); mainPanel.style.display = ""; var cover = document.getElementById(controllerRepViewer$coreViewer.buildUniqueString("splitterCover")); cover.style.display = "none"; }