/* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Viewer *| (C) Copyright IBM Corp. 2011, 2015 *| *| US Government Users Restricted Rights - Use, duplication or *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *| *+------------------------------------------------------------------------+ */ /** * Class responsibility: Add or remove Highlight image map areas */ function CImageMapHighlight(map, webContentRoot) { this.m_webContentRoot = webContentRoot; this.createHighlight = CImageMapHighlight.prototype.createHighlightElement; this.initialize(map); } CImageMapHighlight.prototype.initialize = function(map) { this.m_map = map; this.m_areas = {}; this.m_areaNodes = {}; this.m_visibleAreas = []; this.initImageBlank(); this.m_divCanvas = null; this.m_creationNode = null; this._setMapAreasId(); this.m_sDefaultFillColour = "#F7E1BC"; this.m_sDefaultStrokeColour = "#F0A630"; this.m_sFillColour = this.m_sDefaultFillColour; this.m_sStrokeColour = this.m_sDefaultStrokeColour; }; CImageMapHighlight.prototype.setFillColour = function( sFillColour ){ this.m_sFillColour = ( !sFillColour ) ? this.m_sDefaultFillColour : sFillColour; }; CImageMapHighlight.prototype.getFillColour = function(){ return this.m_sFillColour; }; CImageMapHighlight.prototype.setStrokeColour = function( sStrokeColour ){ this.m_sStrokeColour = (!sStrokeColour ) ? this.m_sDefaultStrokeColour : sStrokeColour ; }; CImageMapHighlight.prototype.getStrokeColour = function(){ return this.m_sStrokeColour; }; CImageMapHighlight.prototype.resetColours = function(){ this.m_sStrokeColour = this.m_sDefaultStrokeColour; this.m_sFillColour = this.m_sDefaultFillColour; }; CImageMapHighlight.prototype.initImageBlank = function() { var img = this._getChartImageFromMap(); // this test is to avoid a javascript error, but it won't work if (img === null) { return; } this.m_img = img; this.m_sImageHeight = img.offsetHeight + "px"; this.m_sImageWidth = img.offsetWidth + "px"; this.m_sUseMap = img.getAttribute( "usemap" ); this.m_imgLid = img.getAttribute( "lid" ); this.m_imgBlank = img.ownerDocument.createElement( "IMG" ); this.m_imgBlank.src = this.m_webContentRoot + "/rv/images/blank.gif"; this.m_imgBlank.style.height = this.m_sImageHeight; this.m_imgBlank.style.width = this.m_sImageWidth; this.m_imgBlank.style.position = "absolute"; this.m_imgBlank.border = "0"; this.m_imgBlank.useMap = this.m_sUseMap; this.m_imgBlank.setAttribute("lid", this.m_imgLid); this.m_imgBlank.setAttribute("rsvpchart", img.getAttribute( "rsvpchart")); this.m_imgBlank.alt = img.alt; if ( this.m_bShowPointer ) { this.m_imgBlank.style.cursor = "auto"; } this.m_imgBlank.v_bIsBlankImageMapImg = true; img.parentNode.insertBefore( this.m_imgBlank, img ); this.f_copyStyle( img, this.m_imgBlank ); this.m_imgBlank.style.borderColor = "transparent"; }; /** * Look in the DOM for the chart container image * [
]
[ ] */ CImageMapHighlight.prototype._getChartImageFromMap = function() { var map = this.m_map; var result = null; // 1. find the span which is the chart container (it should be in the next var chartContainerSpan = null; var mapNextSibling = map.nextSibling; while (mapNextSibling) { if(mapNextSibling.tagName == "DIV") { var nDivChild = mapNextSibling.firstChild; while (nDivChild) { if ((nDivChild.tagName == "SPAN" || nDivChild.tagName == "DIV") && nDivChild.getAttribute("chartcontainer") == "true") { chartContainerSpan = nDivChild; break; } nDivChild = nDivChild.nextSibling; } } if(chartContainerSpan) { break; } mapNextSibling = mapNextSibling.nextSibling; } // 2. Find the image within the chart container Span if (chartContainerSpan) { var chartContainerChildren = chartContainerSpan.children; var chartContainerChildrenCount = chartContainerChildren.length; for (var i=0; i