123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- // 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<len;++i){if(typeof arguments[i]!=="number"||isNaN(arguments[i])){return false;}}
- return true;
- }
- function xStr() {
- for(var i=0,len=arguments.length;i<len;++i){if(typeof arguments[i]!=="string"){return false;}}
- return true;
- }
- function xDef() {
- for(var i=0,len=arguments.length;i<len;++i){if(arguments[i]===undefined){return false;}}
- return true;
- }
- function xOffsetLeft(el) {
- el = cpsdojo.byId(el);
- if(!el)return 0;
- return el.offsetLeft;
- }
- function xOffsetTop(el) {
- el = cpsdojo.byId(el);
- if(!el)return 0;
- return el.offsetTop;
- }
- function xClientWidth() {
- if (window.innerWidth) {
- return window.innerWidth;
- } else if(!(document.documentElement.clientWidth == 0)) {
- return document.documentElement.clientWidth; //IE standards
- } else {
- return document.body.clientWidth; //IE quirks
- }
- }
- function xClientHeight() {
- if (window.innerHeight) {
- return window.innerHeight;
- } else if(!(document.documentElement.clientHeight == 0)) {
- return document.documentElement.clientHeight; // IE strict mode
- } else {
- return document.body.clientHeight; //IE quirks
- }
- }
- function xScrollLeft(e, bWin) {
- var offset=0;
- if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
- var w = window;
- if (bWin && e) w = e;
- if(w.document.documentElement && w.document.documentElement.scrollLeft) offset=w.document.documentElement.scrollLeft;
- else if(w.document.body && xDef(w.document.body.scrollLeft)) offset=w.document.body.scrollLeft;
- }
- else {
- e = cpsdojo.byId(e);
- if (e && xNum(e.scrollLeft)) offset = e.scrollLeft;
- }
- return offset;
- }
- function xScrollTop(e, bWin) {
- var offset=0;
- if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
- var w = window;
- if (bWin && e) w = e;
- if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;
- else if(w.document.body && xDef(w.document.body.scrollTop)) offset=w.document.body.scrollTop;
- }
- else {
- e = cpsdojo.byId(e);
- if (e && xNum(e.scrollTop)) offset = e.scrollTop;
- }
- return offset;
- }
|