// Licensed Materials - Property of IBM // // IBM Cognos Products: cpscrn // // (C) Copyright IBM Corp. 2005, 2011 // // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. // // // Copyright (C) 2009 Cognos ULC, an IBM Company. All rights reserved. // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated). var xUA = navigator.userAgent.toLowerCase(); var xIE4Up = xUA.indexOf('msie')!=-1; // we don't support IE4 anymore so don't check for version // Functions from xDrag var xDragElementSource = null; function xDraggableElement(id,draggable,dragStart,drag,dragEnd) { var ele = cpsdojo.byId(id); ele.draggable = draggable; ele.dragStart = dragStart; ele.drag = drag; ele.dragEnd = dragEnd; return ele; } function xDisableDrag(id, last){ if (!xDragElementSource) return; var ele = new xDraggableElement(id,false,null,null,null); xRemoveEventListener(ele, 'mousedown', xDragMouseDown); xRemoveEventListener(document, 'mousemove', xDragMouseMove); } function xEnableDrag(id,dragStart,drag,dragEnd) { var ele = new xDraggableElement(id,true,dragStart,drag,dragEnd); xAddEventListener(ele, 'mousedown', xDragMouseDown); xAddEventListener(document, 'mousemove', xDragMouseMove); } function xDragMouseDown(e) { var evt = cpsdojo.fixEvent(e); var ele = evt.target; while(ele && !ele.draggable) { ele = xParent(ele); } if (ele) { evt.preventDefault(); ele.xDPX = evt.pageX; ele.xDPY = evt.pageY; xDragElementSource = ele; xAddEventListener(document, 'mouseup', xDragMouseUp); if (ele.dragStart) { ele.dragStart(ele, evt.pageX, evt.pageY); } } } function xDragMouseMove(e) { var evt = cpsdojo.fixEvent(e); if (xDragElementSource) { evt.preventDefault(); var dx = evt.pageX - xDragElementSource.xDPX; var dy = evt.pageY - xDragElementSource.xDPY; xDragElementSource.xDPX = evt.pageX; xDragElementSource.xDPY = evt.pageY; if (xDragElementSource.drag) { xDragElementSource.drag(xDragElementSource, dx, dy); } else { xMoveTo(xDragElementSource, xLeft(xDragElementSource) + dx, xTop(xDragElementSource) + dy); } } } function xDragMouseUp(e) { var evt = cpsdojo.fixEvent(e); if (xDragElementSource) { evt.preventDefault(); xRemoveEventListener(document, 'mouseup', xDragMouseUp); if (xDragElementSource.dragEnd) { xDragElementSource.dragEnd(xDragElementSource, evt.pageX, evt.pageY); } xDragElementSource = null; } } //Functions from xEvent // hashmap of the handles for all registered events. var handleMap = new Object(); function xEvent(evt) { return cpsdojo.fixEvent(evt); } function xHandleGenerator(ele, type, listener) { return ('' + ele.id + type + listener.name).toLowerCase(); } function xAddEventListener(ele, type, listener, bCapture) { if (xIE4Up && type=="load") { var loadHandle = cpsdojo.addOnLoad(listener); return loadHandle; } var handle = cpsdojo.connect(cpsdojo.byId(ele), type, listener); var handleKey = xHandleGenerator(ele, type, listener); handleMap[handleKey] = handle; return handle; } function xRemoveEventListener(ele, type, listener, bCapture) { var handleKey = xHandleGenerator(ele, type, listener); cpsdojo.disconnect(handleMap[handleKey]); delete handleMap[handleKey]; } function xPreventDefault(evt) { var dxEvt = cpsdojo.fixEvent(evt); dxEvt.preventDefault(); } function xStopPropagation(evt) { var dxEvt = cpsdojo.fixEvent(evt); dxEvt.stopPropagation(); } //Functions from xDom function xGetElementById(id) { return cpsdojo.byId(id); } function xGetElementsByTagName(tag, base) { return cpsdojo.query(tag, base); } function xGetElementsByClassName(tag, base) { return cpsdojo.query("."+tag, base); } function xCreateElement(el) { if (document.createElement) { return document.createElement(el); } } function xAppendChild(parentEl, childEl) { parentEl.appendChild(childEl); } function xFirstChild(el,tag) { if (tag === undefined) { var nodeList = cpsdojo.query(":first-child", el); return (nodeList.length)?nodeList[0]:null; } else { var nodeList = cpsdojo.query(tag + ":first-of-type", el); return (nodeList.length)?nodeList[0]:null; } } function xGetElementsByAttribute(tag, attribute, match) { var nodeList = null; if (match === undefined) { nodeList = cpsdojo.query(tag + "[" + attribute + "]"); } else { nodeList = cpsdojo.query(tag + "[" + attribute + "=" + match + "]"); } return (nodeList.length && nodeList.length < 1)? null : nodeList; } function xParent(el, returnNode) { el = cpsdojo.byId(el); var parentNode; if (returnNode) { parentNode = (el && el.parentNode)? el.parentNode : null; } else { parentNode = (el && el.offsetParent)? el.offsetParent : null; } return parentNode; } function xParentNode(elem, ancestorNumber) { elem = cpsdojo.byId(elem); while(elem && ancestorNumber--) { elem = elem.parentNode; } return elem; } function xNextSib(elem, tag) { elem = cpsdojo.byId(elem); var sib = elem.nextSibling; while(sib) { if (sib.nodeType == 1 && (!tag || sib.nodeName.toLowerCase() == tag.toLowerCase())) { break; } else { sib = sib.nextSibling; } } return sib; } function xPrevSib(elem, tag) { elem = cpsdojo.byId(elem); var sib = elem.previousSibling; while(sib) { if ((sib.nodeType == 1) && (!tag || sib.nodeName.toLowerCase() == tag.toLowerCase())) { break; } else { sib = sib.previousSibling; } } return sib; } //Functions From xCore function xCamelize(cssProp) { if (cssProp != '') { var split = cssProp.split("-"); var returnVal = null; if (split.length < 1) { return cssProp; } else { returnVal = split[0]; for (var i=1; i < split.length; i++) { returnVal += split[i].substr(0, 1).toUpperCase() + split[i].substr(1, split[i].length); } } return returnVal; } else { return cssProp; } } function xDisplay(elem, val) { var returnVal = null; elem = cpsdojo.byId(elem); returnVal = (val) ? cpsdojo.style(elem, "display", val): cpsdojo.style(elem, "display"); return returnVal; } function xOpacity(e, o) { e = cpsdojo.byId(e); if (o != undefined) { cpsdojo.style(e,"opacity",(o+'')); } else { o = parseFloat(cpsdojo.style(e,"opacity")); } return isNaN(o) ? 1 : o; } function xVisibility(elem, show) { elem = cpsdojo.byId(elem); var returnVal = null; if (show != undefined) { if (show) { cpsdojo.style(elem,"visibility","visible"); } else { cpsdojo.style(elem,"visibility","hidden"); } } return cpsdojo.style(elem,"visibility"); } function xHide(elem) { elem = cpsdojo.byId(elem); cpsdojo.style(elem,"visibility","hidden"); return cpsdojo.style(elem,"visibility"); } function xShow(elem) { elem = cpsdojo.byId(elem); cpsdojo.style(elem,"visibility","visible"); return cpsdojo.style(elem,"visibility"); } function xGetComputedStyle(elem, style, isInt) { elem = cpsdojo.byId(elem); if (!elem) { return null; } var camStyle = xCamelize(style); var returnVal = null; var cssNode = cpsdojo.getComputedStyle(elem); if (cssNode) { returnVal = cssNode[camStyle]; } else { return null; } return (isInt) ? (parseInt(returnVal) || 0) : returnVal; } function xLeft(el, l) { return (l===undefined)?cpsdojo.coords(el).l:cpsdojo.style(el,"left",l); } function xTop(el, t) { return (t===undefined)?cpsdojo.coords(el).t:cpsdojo.style(el,"top",t); } function xMoveTo(el, x, y) { cpsdojo.style(el,"left",x); cpsdojo.style(el,"top",y); } function xHeight(el, h) { if (h===undefined) { return el.offsetHeight; } else { cpsdojo.style(el,"height",h<0?0:(h+"px")); return h; } } function xWidth(el, w) { if (w===undefined) { return el.offsetWidth; } else { cpsdojo.style(el,"width",w<0?0:(w+"px")); return w; } } function xResizeTo(el, w, h) { xHeight(el,h); xWidth(el,w); } function xPageX(el) { return cpsdojo.coords(el).x; } function xPageY(el) { return cpsdojo.coords(el).y; } function xNum() { for(var i=0,len=arguments.length;i