// Licensed Materials - Property of IBM // // IBM Cognos Products: ps // // (C) Copyright IBM Corp. 2005, 2013 // // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. // Copyright (C) 2008 Cognos Incorporated. All rights reserved. // Cognos and the Cognos logo are trademarks of Cognos Incorporated. function addEvent(obj, evType, fn) { if (obj.addEventListener) { obj.addEventListener(evType, fn, false); return true; } else if (obj.attachEvent) { var r = obj.attachEvent("on" + evType, fn); return r; } else { return false; } } function removeEvent(obj, type, fn) { if (obj.removeEventListener) { return obj.removeEventListener(type, fn, false); } else if (obj.detachEvent) { return obj.detachEvent('on' + type, fn); } else { return false; } } var aboutBox = null; function updateAboutBoxTitleAttribute(){ try{ if (aboutBox.currentMessageRequest.readyState == 4) { if (aboutBox.currentMessageRequest.status == 404){ //in this case we failed to load the real message file....lets load the default aboutBox.messageLoadErrorCount++; if (aboutBox.messageLoadErrorCount < 2) { aboutBox.loadMessageFile(aboutBox.JSMessageFileDefault); } } if (aboutBox.currentMessageRequest.status >= 200 && aboutBox.currentMessageRequest.status < 300) { var messageFile = eval("(" + aboutBox.currentMessageRequest.responseText + ")"); //Set the ALT text for the aboutbox image var text = messageFile.ABT.IDS_ABT_PRODUCT + "\n" + messageFile.ABT.IDS_ABT_VERSION + "\n" + messageFile.ABT.IDS_ABT_LEGAL; aboutBox.imageEl.alt = text; aboutBox.imageEl.title = text; text = messageFile.ABT.IDS_ABT_OK; if (typeof messageFile.ABT.IDS_ABT_OK === "undefined"){ //if it can't find the ok string in the passed in message file then lets go with a hard coded ok.... text = "OK"; } aboutBox.okButtonText = text; } aboutBox.completeShow(); } } catch (e){aboutBox.completeShow();} } function about_dialog(aboutImage, defaultImage, JSMessageFile, JSMessageFileDefault) { this.xmlHttpVersions = [ "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP" ]; this.xmlHttpDefault=this.findXMLHttpActiveXVersion(); this.mainDiv = null; this.aboutImage = aboutImage; this.imageHeight = 452; this.imageWidth = 652; this.lockingFrame = null; this.defaultImage = defaultImage; this.JSMessageFile = JSMessageFile; this.JSMessageFileDefault = JSMessageFileDefault; aboutBox = this; this.currentMessageRequest = null; this.messageLoadErrorCount = 0; this.idToFocusOnClose = null; this.okButtonText = null; } about_dialog.prototype = { create: function() { this.errorCount = 0; this.mainDiv = document.createElement("div"); this.mainDiv.tabIndex = "-1"; this.mainDiv.style.width = this.imageWidth; this.mainDiv.style.position = "absolute"; this.lockingFrame = document.createElement("div"); this.lockingFrame.style.filter = "alpha(opacity=50)"; this.lockingFrame.style.opacity = "0.5"; this.lockingFrame.style.MozOpacity = "0.5"; this.lockingFrame.style.height = "100%"; this.lockingFrame.style.width = "100%"; this.lockingFrame.style.position = "absolute"; this.lockingFrame.style.left = "0px"; this.lockingFrame.style.top = "0px"; this.lockingFrame.style.backgroundColor = "rgb(221, 221, 221)"; this.lockingFrame.style.zIndex = "100"; this.mainDiv.style.zIndex = "200"; this.hide(); document.body.appendChild(this.mainDiv); document.body.appendChild(this.lockingFrame); this.imageEl = document.createElement("img"); this.imageEl.tabIndex = "0"; if (typeof this.defaultImage !== 'undefined'){ this.imageEl.style.visibility = "hidden"; addEvent(this.imageEl, "error", this.loadDefaultImage); addEvent(this.imageEl, "load", this.loadImageLoadComplete); } this.imageEl.src = this.aboutImage; this.mainDiv.appendChild(this.imageEl); addEvent(this.mainDiv, "click", this.aboutClicked); }, loadMessageFile: function(messageFile){ aboutBox.currentMessageRequest = aboutBox.getXMLHttpRequest(); aboutBox.currentMessageRequest.open("GET",messageFile,true); aboutBox.currentMessageRequest.onreadystatechange = updateAboutBoxTitleAttribute; aboutBox.currentMessageRequest.send(null); }, loadImageLoadComplete: function(){ aboutBox.loadMessageFile(aboutBox.JSMessageFile); aboutBox.imageEl.style.visibility = "visible"; }, loadDefaultImage: function(){ aboutBox.errorCount++; if (aboutBox.errorCount < 2){ aboutBox.imageEl.src = aboutBox.defaultImage; } }, createOKButton: function() { var aboutDivEl = document.createElement("div"); aboutDivEl.style.border = "1px solid #999999"; aboutDivEl.style.fontSize = "90%"; aboutDivEl.style.fontWeight = "normal"; aboutDivEl.style.padding = "2px 10px 3px"; aboutDivEl.style.position = "absolute"; this.mainDiv.appendChild(aboutDivEl); aboutDivEl.width = "55"; var anc = document.createElement("a"); anc.href = "javascript:if (aboutBox != null){aboutBox.aboutClicked();}"; anc.onclick = function() {return false;}; aboutDivEl.appendChild(anc); var ancText = this.okButtonText; if (ancText == null){ ancText = "OK"; } var textEl = document.createTextNode(ancText); anc.appendChild(textEl); anc.style.color = "#000000"; anc.style.textDecoration = "none"; anc.setAttribute("role", "button"); this.okButton = anc; addEvent(anc, "keydown", this.aboutKeyDown); aboutDivEl.style.left = 20 + "px"; aboutDivEl.style.bottom = "20px"; }, show: function() { if (this.mainDiv == null) { this.create(); createOK = true; } else { this.completeShow(); } }, completeShow: function(){ this.center(); this.mainDiv.style.display = 'block'; this.mainDiv.style.visibility = 'visible'; this.lockingFrame.style.display = 'block'; this.lockingFrame.style.visibility = 'visible'; addEvent(document.body, "keydown", this.aboutKeyDown); this.createOKButton(); this.mainDiv.focus(); } , center: function() { this.mainDiv.style.left = ((document.body.clientWidth - this.imageWidth) / 2) + document.body.scrollLeft + "px"; this.mainDiv.style.top = ((this.getWindowHeight() - this.imageHeight) / 2) + document.body.scrollTop + "px"; }, getWindowHeight: function() { if( document.documentElement && document.documentElement.clientHeight ) { return document.documentElement.clientHeight; } else if( document.body && document.body.clientHeight ) { return document.body.clientHeight; } else if( typeof( window.innerHeight ) == 'number' ) { return window.innerHeight; } }, aboutClicked: function(event) { if (event.stopPropagation) { event.stopPropagation(); } else { event.cancelBubble = 'true'; } if (aboutBox != null) { aboutBox.hide(); aboutBox.destroyDialog(); } }, aboutKeyDown: function(event) { if (aboutBox == null) { return; } if (event.keyCode == 27 || event.keyCode == 32) { aboutBox.hide(); aboutBox.destroyDialog(); } }, hide: function() { removeEvent(document.body, 'keydown', this.aboutKeyDown); aboutBox.mainDiv.style.display = 'none'; this.mainDiv.style.visibility = 'hidden'; this.lockingFrame.style.display = 'none'; this.lockingFrame.style.visibility = 'hidden'; if (this.idToFocusOnClose != null){ var focEl = document.getElementById(this.idToFocusOnClose); if (focEl != null) { focEl.focus(); } } }, destroyDialog: function() { document.body.removeChild(this.mainDiv); document.body.removeChild(this.lockingFrame); this.mainDiv = null; this.lockingFrame = null; aboutBox = null; }, findXMLHttpActiveXVersion: function(){ if (window.ActiveXObject) { var i, l = this.xmlHttpVersions.length; for (i = 0; i < l; i++) { try { // Try and create the ActiveXObject for Internet Explorer, if it doesn't work, try again. var xmlhttp = new ActiveXObject(this.xmlHttpVersions[i]); if (xmlhttp) return this.xmlHttpVersions[i]; } catch (e) { // this ActiveX is not there, continue with next one in list } } } return null; }, getXMLHttpRequest:function(){ if (this.xmlHttpDefault != null) { return new ActiveXObject(this.xmlHttpDefault); } // Well if there is no ActiveXObject available it must be firefox, opera, or something else if (typeof XMLHttpRequest != 'undefined') { try { return new XMLHttpRequest(); } catch (e) { alert(e); } } throw "No XMLHttpRequest object is available"; } };