//------------------------------------ // DESCRIPTION // Standard Javascript libraries. // // VERSION INFORMATION // $STARTEAM-HEADER$ // $NoKeywords$ //------------------------------------ //------------------------------------ // HELPER FUNCTIONS //------------------------------------ function xfGet(psId) { return document.getElementById(psId); } function xfGetVal(psId) { var el = document.getElementById(psId); if (el) { return el.value; } return ""; } function xfGetValLen(psId) { var el = document.getElementById(psId); if (el) { return el.value.length; } return 0; } function xfSetVal(psId,pVal) { var el = document.getElementById(psId); if (el) { if (pVal) { el.value = pVal; } else { el.value = ""; } } } function xfSetFocus(psId,pbIgnoreError) { var el = document.getElementById(psId); if (el) { try { el.focus(); return true; } catch (e) { return false; } } } //------------------------------------ // STDLIBS CONFIG //------------------------------------ function XConfigClass() { this.EScopeClient = "client"; this.EScopeServer = "server"; var mScope = this.EScopeServer; this.setScopeClient = function() { mScope = this.EScopeClient; }; this.setScopeServer = function() { mScope = this.EScopeServer; }; this.isClientScope = function() { return mScope == this.EScopeClient; }; this.getBlankPageUrl = function() { if (this.isClientScope()) { return this.resolveWebUrl(this.winUrlBlankClient); } return this.resolveWebUrl(this.winUrlBlankServer); }; this.getBlankImageSrc = function() { if (this.isClientScope()) { return this.resolveWebUrl(this.winUrlBlankImageClient); } return this.resolveWebUrl(this.winUrlBlankImageServer); }; this.isUrlBlankPage = function(psUrl) { if ( (!psUrl) || (psUrl.length < 10) ) { return false; } var url = psUrl.toUpperCase().substr(psUrl.length - 10); if (url.indexOf("BLANK.") >= 0 ) { return true; } return false; }; this.resolveWebUrl = function(psUrl) { if (XString.isEmpty(psUrl)) { return psUrl; } var vdir = this.getVirtualDir(); if (XString.isEmpty(vdir)) { return psUrl; } var url = psUrl + ""; if (!XString.startsWith(url,"/")) { return psUrl; } url = XString.trim(url.toLowerCase()); // if not at the base, then it is relative if ( XString.startsWith(url,"/" + vdir.toLowerCase() + "/") ) { url = psUrl; } else { url = "/" + vdir + psUrl; } return url; }; // General settings var mVirtualDir = ""; this.getVirtualDir = function() { if (XString.startsWith(mVirtualDir,"XXXVIRTUALDIR") ) { mVirtualDir = ""; } return mVirtualDir; }; this.setVirtualDir = function(psDirName) { mVirtualDir = psDirName; }; // Window and url settings this.winUrlBlankServer = "/xsuite/client/web/blank.aspx"; this.winUrlBlankImageServer = "/xsuite/client/web/blank.gif"; this.winUrlLoadingServer = "/xsuite/xapps/std/axStdPageLoadingDialog.aspx"; this.winUrlErrorServer = "/xsuite/client/web/controls/axWindowError.aspx"; this.winUrlDebugServer = "/xsuite/client/web/controls/axWindowDebug.aspx"; this.winUrlPromptServer = "/xsuite/client/web/controls/axWindowPrompt.aspx"; this.winUrlConfirmServer = "/xsuite/client/web/controls/axWindowConfirm.aspx"; this.winUrlAlertServer = "/xsuite/client/web/controls/axWindowAlert.aspx"; this.winUrlYesNoServer = "/xsuite/client/web/controls/axWindowYesNo.aspx"; this.winUrlYesNoCancelServer = "/xsuite/client/web/controls/axWindowYesNoCancel.aspx"; this.winUrlFileChooserServer = "/xsuite/client/web/controls/axWindowFileChooser.aspx"; this.winUrlBlankClient = "web/blank.htm"; this.winUrlBlankImageClient = "web/blank.gif"; this.winUrlLoadingClient = "web/controls/axWindowLoading.htm"; this.winUrlErrorClient = "web/controls/axWindowError.htm"; this.winUrlDebugClient = "web/controls/axWindowDebug.htm"; this.winUrlPromptClient = "web/controls/axWindowPrompt.htm"; this.winUrlConfirmClient = "web/controls/axWindowConfirm.htm"; this.winUrlAlertClient = "web/controls/axWindowAlert.htm"; this.winUrlYesNoClient = "web/controls/axWindowYesNo.htm"; this.winUrlYesNoCancelClient = "web/controls/axWindowYesNoCancel.htm"; this.winUrlFileChooserClient = "web/controls/axWindowFileChooser.htm"; // Resource settings this.webserviceDefaultErrorMsg = "webserviceInternalError"; this.webserviceResultNodeId = "xWsResult"; this.webservicePostCallbackQueryParam = "xWsCallback"; return this; }; var XConfig = new XConfigClass(); //------------------------------------ // Browser Enums //------------------------------------ function XBrowserClass() { this.className = "XBrowserClass"; this.cursorDefault = "default"; this.cursorAuto = "auto"; this.cursorMove = "move"; this.cursorHand = "hand"; this.cursorHelp = "help"; this.cursorWait = "wait"; this.cursorPointer = "pointer"; this.cursorWorking = "progress"; this.cursorText = "text"; this.cursorCrosshair = "crosshair"; this.cursorResize = "resize"; this.cursorResizeNW = "nw-resize"; this.cursorResizeVertical = "n-resize"; this.cursorResizeHorizontal = "w-resize"; this.isIE = function() { try { return navigator.appVersion.indexOf("MSIE")>= 0; } catch (e) { XError.display(this.className,e,"isIE"); throw e; } }; this.hasPlugin = function(psName) { var plugin = null; try { if (navigator.plugins && navigator.plugins.length) { for (var i=0; i 0) ) { var plugin = null; for (i=0; i= XEKeyCode.key0 && evt.keyCode <= XEKeyCode.key9) { return true; } if (evt.keyCode >= XEKeyCode.keyPad0 && evt.keyCode <= XEKeyCode.keyPad9) { return true; } } return false; }; this.isKeyCodeEnter = function(poEvent) { var evt = poEvent? poEvent : window.event; if (evt) { return evt.keyCode == XEKeyCode.keyEnter; } return false; }; this.isKeyCodeTab = function(poEvent) { var evt = poEvent? poEvent : window.event; if (evt) { return evt.keyCode == XEKeyCode.keyTab; } return false; }; this.isAllowableNumericInputFieldKey = function(poEvent) { var evt = poEvent? poEvent : window.event; if (evt) { if (evt.keyCode >= XEKeyCode.key0 && evt.keyCode <= XEKeyCode.key9) { return true; } if (evt.keyCode >= XEKeyCode.keyPad0 && evt.keyCode <= XEKeyCode.keyPad9) { return true; } switch (evt.keyCode) { case XEKeyCode.keyDelete : case XEKeyCode.keyBackspace : case XEKeyCode.keyTab : case XEKeyCode.keyRightArrow : case XEKeyCode.keyLeftArrow : case XEKeyCode.keyHome : case XEKeyCode.keyEnd : return true; default : break; } return false; } return false; }; return this; }; var XEvent = new XEventClass(); //------------------------------------ // XUtil Class //------------------------------------ function XUtilClass() { this.className = "XUtilClass"; this.xnull = function() {}; this.setCookie = function(psName, psValue,pnExpireMillis) { var expMillis = XString.evl(pnExpireMillis,60*60*1000); /* NOTE: default 1 hour */ date = new Date(new Date().getTime() + expMillis); document.cookie = psName + "=" + escape(psValue) + "; path=/; expires=" + date.toGMTString(); }; this.getCookie = function(psName) { // cookies are separated by semicolons var aCookie = document.cookie.split("; "); for (var i=0; i < aCookie.length; i++) { // a name/value pair (a crumb) is separated by an equal sign var aCrumb = aCookie[i].split("="); if (psName == aCrumb[0]) return unescape(aCrumb[1]); } // a cookie with the requested name does not exist return null; }; this.locale = function() { var loc; var idx; if( navigator.language ) { loc = navigator.language; } else if( navigator.browserLanguage ) { loc = navigator.browserLanguage; } if (XString.isNotEmpty(loc)) { idx = loc.indexOf("-"); if (idx > 0) { loc = loc.substring(0,idx+1) + loc.substring(idx+1,loc.length).toUpperCase(); } } return loc; }; this.language = function() { if( navigator.language ) { return navigator.language; } else if( navigator.browserLanguage ) { return navigator.browserLanguage; } return ""; }; return this; }; var XUtil = new XUtilClass(); //------------------------------------ // XHTMLUtil Class //------------------------------------ function XHtmlUtilClass() { this.className = "XHtmlUtilClass"; this.getFrameDocument = function(psFrameName) { try { var frameName = psFrameName; if (XString.isEmpty(frameName)) { return null; } var frameEl = document.getElementById(frameName); if (frameEl) { if (frameEl.contentWindow) { return frameEl.contentWindow.document; } else { frameName = XString.evl(frameEl.getAttribute("name"),frameName); } } var frame = document.frames[frameName]; if (frame) { return frame.document; } } catch (e) { XError.display(this.className,e,"getFrameDocument"); throw e; } }; this.clearFrameDocument = function(psFrameName) { try { var frameDoc = this.getFrameDocument(psFrameName); if (frameDoc) { frameDoc.open(); frameDoc.write(""); frameDoc.close(); } } catch (e) { XError.display(this.className,e,"clearFrameDocument"); throw e; } }; this.disableFormViewState = function(poForm) { try { if (poForm) { var el = poForm.elements["__VIEWSTATE"]; if (el) { var xaction = poForm.getAttribute("xaction"); if (XString.isNotEmpty(xaction)) { poForm.action = xaction; } el.removeNode(true); } } } catch (e) { XError.display(this.className,e,"disableFormViewState"); throw e; } }; this.initValueI = function(poContainerEl) { try { var oEl = poContainerEl; if (!oEl) { oEl = document.body; } if (oEl) { var el; var typ; var vali; var oColl; oColl = oEl.getElementsByTagName("INPUT"); if (oColl && oColl.length > 0) { for ( var i=0; i 0) { for ( var i=0; i 0) { for (var i=0; i 0) { for (var i=0; i 0) { poSelect.selectedIndex = currIndex - 1; return true; } return false; }; this.clearOptions = function(poSelect) { if (!XObject.isNull(poSelect)) { /* var oColl = poSelect.options; if (oColl) { for (var i=0; i 0) { return c < s; } return false; }; this.hasHorizontalScrollbar = function(poEl) { var c = poEl.clientWidth *1; var s = poEl.scrollWidth *1; if (s > 0) { return c < s; } return false; }; this.getObjectHeight = function(poEl) { // does not include border return poEl.offsetHeight; }; this.getObjectWidth = function(poEl) { // does not include width return poEl.offsetWidth; }; this.getAbsoluteOffsetTop = function(poEl) { var val = 0; var oEl = poEl; while ( oEl.offsetParent ) { oEl = oEl.offsetParent; val += oEl.offsetTop; } return val; }; this.getAbsoluteOffsetLeft = function(poEl) { var val = 0; var oEl = poEl; while ( oEl.offsetParent ) { oEl = oEl.offsetParent; val += oEl.offsetLeft; } return val; }; this.calcAbsoluteLeft = function(poObject) { // Find the element's offsetLeft relative to the BODY tag. if (!poObject) { return 0; } var pos = poObject.offsetLeft; var objParent = poObject.offsetParent; while ((objParent) && (objParent.tagName.toUpperCase() != "BODY")) { pos += objParent.offsetLeft; objParent = objParent.offsetParent; } return pos; }; this.calcAbsoluteTop = function(poObject) { // Find the element's offsetTop relative to the BODY tag. if (!poObject) { return 0; } var pos = poObject.offsetTop; var objParent = poObject.offsetParent; while ((objParent) && (objParent.tagName.toUpperCase() != "BODY")) { pos += objParent.offsetTop; objParent = objParent.offsetParent; } return pos; }; this.getChildElementById = function(poParentEl, psElId) { if (!poParentEl) { return document.getElementById(psElId); } return poParentEl.all.item(psElId); }; this.getElementsByTag = function(poEl,psTagName) { if (poEl) { if (poEl.getElementsByTagName) { // IE DOM return poEl.getElementsByTagName(psTagName); } else { if (poEl.all) { // DHTML object model return poEl.all.tags(psTagName); } } } return null; }; // Gets just the direct children, doesn't traverse down this.getChildrenByTag = function(poEl,psTagName) { if (poEl) { if (poEl.getElementsByTagName) { var aChilds = null; var aEls = poEl.getElementsByTagName(psTagName); if (aEls && aEls.length > 0) { aChilds = new Array(aEls.length); var cnt = 0; for (var i=0; i 0) { aChilds = new Array(aEls.length); var cnt = 0; var el = null; for (var i=0; i 0) { row = kids[0]; if (row.tagName == "TR") { oEl = poTable; } else { if (row.tagName == "TBODY") { oEl = row; } else { for (var i=0; i= 0; } else { return psValue.indexOf(psPattern) >= 0; } }; this.nvl = function(psValue,psDefault) { if ( (psValue == null) || (psValue == undefined) || (psValue == "undefined") || (psValue == NaN) ) { return psDefault + ""; } return psValue; }; this.evl = function(psValue,psDefault) { if (this.isEmpty(psValue)) { return psDefault + ""; }else { return psValue; } }; this.replaceAll = function(psValue,psFind,psReplace) { var sStr; var oRegExp; sStr = psValue + ""; if (this.isEmpty(sStr)) { return sStr; } if (psFind == ".") { oRegExp = /\./g; } else { oRegExp = new RegExp(psFind,"g"); } sStr = sStr.replace(oRegExp,psReplace); return sStr; }; this.replace = function(psValue,psFind,psReplace) { var sStr; sStr = new String(psValue + ""); if (this.isEmpty(sStr)) { return sStr; } sStr = sStr.replace(psFind,psReplace); return sStr; }; this.rpad = function(psValue,pnLen,psPadString) { var sStr = psValue + ""; var nCnt; if (this.isEmpty(sStr)) { return sStr; } nCnt = pnLen - sStr.length; for(i=0; i < nCnt; i++) { sStr = sStr + psPadString; } return sStr; }; this.lpad = function(psValue,pnLen,psPadString) { var sStr = psValue + ""; var nCnt; if (this.isEmpty(sStr)) { return sStr; } nCnt = pnLen - sStr.length; for(i=0; i < nCnt; i++) { sStr = psPadString + sStr; } return sStr; }; this.trim = function(psValue) { return this.ltrim(this.rtrim(psValue + "")); }; this.ltrim = function(psValue) { var sStr = psValue + ""; if (sStr) { while (sStr.length > 0 && sStr.charAt(0) == ' ') { sStr = sStr.substring(1); } } return sStr; }; this.rtrim = function(psValue) { var sStr = psValue + ""; if (sStr) { while (sStr.length > 0 && sStr.charAt(sStr.length-1) == ' ') { sStr = sStr.substring(0,sStr.length-1); } } return sStr; }; this.splitNameValue = function(psNameValue,psSplitStr) { var ret = new XOption(); var len = XString.evl(psSplitStr,"").length; if (psNameValue) { var pos = psNameValue.indexOf(psSplitStr); if (pos > 0) { ret.name = psNameValue.substring(0,pos); if ( (psNameValue.length-len) > pos) { ret.value = psNameValue.substring(pos-(-len),psNameValue.length); } else { ret.value = ""; } } else { ret.name = psNameValue; ret.value = ""; } } else { ret.name = ""; ret.value = ""; } return ret; }; this.compare = function(psValue1,psValue2) { var s1 = this.toString(psValue1); var s2 = this.toString(psValue2); if (this.areEqual(s1, s2)) { return 0; } return s1 > s2? 1 : -1; }; return this; }; var XString = new XStringClass(); //------------------------------------ // XBoolean Utilitiy functions. //------------------------------------ function XBooleanClass() { this.className = "XBooleanClass"; this.trueIndicator = "1"; this.falseIndicator = "0"; this.parse = function(psValue,psDefault) { if (XString.isEmpty(psValue)) { return this.isTrue(psDefault); } return this.isTrue(psValue); }; this.parseEl = function(psElId,psDefault) { return this.parse(xfGetVal(psElId),psDefault); }; this.isTrue = function(psValue) { var c; if (XString.isEmpty(psValue)) { return false; } c = psValue.toString().substring(0,1); switch (c) { case '1': case 't': case 'T': case 'Y': case 'y': return true; default : return false; } return false; }; this.toIndicator = function(psValue) { return this.parse(psValue)? "1" : "0"; }; return this; }; var XBoolean = new XBooleanClass(); //------------------------------------ // Number Utility functions. //------------------------------------ function XNumberClass() { this.className = "XNumberClass"; this.parse = function(psValue,pnDefault) { var nval = psValue*1.0; if (nval == Number.NaN || nval == Number.MIN_VALUE) { return pnDefault*1.0; } return nval; }; this.isSet = function(psValue) { var nval = psValue*1.0; if (nval == 0) { return true; } return (!isNaN(nval)) && (nval > Number.MIN_VALUE); }; this.add = function(pnNum1,pnNum2) { return pnNum1 - (-pnNum2); }; this.isType = function(poValue) { var nNumber; if (XObject.isNull(poValue) || XString.isEmpty(poValue)) { return false; } nNumber = new Number(poValue); if (nNumber.toString() == Number.NaN.toString()) { return false; } return true; }; this.absValue = function(pnNumber) { if (!this.isType(pnNumber)) { return Number.NaN; } var nbr = pnNumber*1.0; if (nbr < 0) { return nbr * -1.0; } return nbr; }; this.toInt = function(pnNumber) { return Math.floor(pnNumber); }; this.isInRange = function(pnNumber,pnStart,pnEnd) { if ( (!this.isType(pnNumber)) || (!this.isType(pnStart)) || (!this.isType(pnEnd)) ) { return false; } if ( (pnNumber -0) < (pnStart-0) ) { return false; } if ( (pnNumber -0) > (pnEnd-0) ) { return false; } return true; }; this.hexCharToDecValue = function(psChar) { switch(psChar.toString().toUpperCase().toString()) { case "0": return 0; case "1": return 1; case "2": return 2; case "3": return 3; case "4": return 4; case "5": return 5; case "6": return 6; case "7": return 7; case "8": return 8; case "9": return 9; case "A": return 10; case "B": return 11; case "C": return 12; case "D": return 13; case "E": return 14; case "F": return 15; } }; this.hexToDec = function(psValue) { var nVal = 0; var nMult; for (var i=0; i < psValue.length-1; i++) { nMult = 16; for (j=2; j < psValue.length - i; j++) { nMult = nMult*16; } nVal += nMult*this.hexCharToDecValue(psValue.substr(i,1)); } nVal = nVal - (- this.hexCharToDecValue(psValue.substr(psValue.length-1,1))); return nVal; }; this.compare = function(pnVal1,pnVal2) { var v1 = pnVal1*1; var v2 = pnVal2*1; if ( isNaN(v1) && isNaN(v2) ) { return 0; } if (isNaN(v1)) { return -1; } if (isNaN(v2) ) { return 1; } if (v1 == v2) { return 0; } if (v1 > v2) { return 1; } return -1; }; return this; }; var XNumber = new XNumberClass(); function XIntegerClass() { this.className = "XIntegerClass"; this.parse = function(psValue,pnDefault) { var nval = psValue*1; if (nval == Number.NaN || nval == Number.MIN_VALUE) { return pnDefault*1; } return nval; }; this.isSet = function(psValue) { var nval = psValue*1; if (nval == 0) { return true; } return (!isNaN(nval)) && (nval > Number.MIN_VALUE); }; this.compare = function(pnVal1, pnVal2) { return XNumber.compare(pnVal1,pnVal2); }; return this; }; var XInteger = new XIntegerClass(); //------------------------------------ // Date Utility functions. //------------------------------------ function XDateClass() { this.className = "XDateClass"; this.isType = function(psValue) { var d; try { // try the javascript date d = new Date(psValue); if (!isNaN(d)) { return true; } // try the axacore format return this.isAxDateFormat(psValue); } catch (e) { return false; } }; this.parse = function(psValue) { var d; try { // try the javascript date d = new Date(psValue); if (!isNaN(d)) { return d; } // try the axacore format if (this.isAxDateFormat(psValue)) { return this.parseAxDate(psValue); } return null; } catch (e) { XError.display(this.className, e, "parse"); throw e; } }; this.parseAxDate = function(psValue) { var d = NaN; try { if (psValue.indexOf(".") > 0) { d = new Date( psValue.substr(0,4)*1 ,(psValue.substr(4,2)*1)-1 ,psValue.substr(6,2)*1 ,psValue.substr(9,2)*1 ,psValue.substr(11,2)*1 ,psValue.substr(13,2)*1 ,(psValue.length >=17? psValue.substr(15,3) : 0)*1 ); } else { d = new Date( psValue.substr(0,4)*1 ,(psValue.substr(4,2)*1)-1 ,psValue.substr(6,2)*1); } return d; } catch (e) { XError.display(this.className, e, "parseAxDate"); throw e; } }; this.nowAsMillis = function() { return (new Date()).getTime(); }; // returns value back as yyyyMMddHHmmssfff this.nowAsInteger = function(pbIncludeMillis) { var sval = this.nowAsDouble(pbIncludeMillis); return parseInt(XString.replace(sval,".","")); }; // returns value back as yyyyMMdd.HHmmssfff this.nowAsDouble = function(pbIncludeMillis) { var oDate; var nDateNbr; oDate = new Date(); return parseFloat( "" + oDate.getFullYear() + this.datePartTwoPlaces(oDate.getMonth() + 1) + this.datePartTwoPlaces(oDate.getDate()) + "." + this.datePartTwoPlaces(oDate.getHours()) + this.datePartTwoPlaces(oDate.getMinutes()) + this.datePartTwoPlaces(oDate.getSeconds()) + (XBoolean.parse(pbIncludeMillis)? this.datePartThreePlaces(oDate.getMilliseconds()) : "" ) ); }; this.isAxDateFormat = function(psValue) { return (new String(parseInt(psValue))).length == 8; }; this.convertToAxFormat = function(psDateValue,pbIncludeMillis) { try { if ( XString.isEmpty(XString.trim(psDateValue)) ) { return ""; } var oDate; var nDateNbr; // Try using the normal Javascript Date object nDateNbr = Date.parse(XString.trim(psDateValue)); if (!(isNaN(nDateNbr))) { oDate = new Date(nDateNbr); return parseFloat( "" + oDate.getFullYear() + this.datePartTwoPlaces(oDate.getMonth() + 1) + this.datePartTwoPlaces(oDate.getDate()) + "." + this.datePartTwoPlaces(oDate.getHours()) + this.datePartTwoPlaces(oDate.getMinutes()) + this.datePartTwoPlaces(oDate.getSeconds()) + (XBoolean.parse(pbIncludeMillis)? this.datePartThreePlaces(oDate.getMilliseconds()) : "" ) ); } else { // try the axacore date format try { if (this.isAxDateFormat(psDateValue)) { return XString.trim(psDateValue); } }catch(e) { } return ""; } } catch(e) { return ""; } }; this.datePartTwoPlaces = function(psValue) { return (psValue*1) < 10 ? "0" + psValue : psValue + ""; }; this.datePartThreePlaces = function(psValue) { var nval = psValue * 1; if (nval >= 100) { return psValue; } if (nval >= 10) { return "0" + psValue; } return "00" + psValue; }; this.dailySecToHr = function(pnSeconds) { var nval = XString.isEmpty(pnSeconds)? 0 : pnSeconds - 0; if (nval < 3600) { return 0; } return XNumber.toInt(pnSeconds/3600); }; this.dailySecToMin = function(pnSeconds) { var nval = XString.isEmpty(pnSeconds)? 0 : pnSeconds - 0; var ihr = 0; if (nval < 60) { return 0; } nval = pnSeconds/3600; ihr = XNumber.toInt(nval); return XNumber.toInt((nval - ihr)*60); }; this.toDailySec = function(pnHour,pnMin,pnSec) { var hr = XString.isEmpty(pnHour)? 0 : pnHour - 0; var min = XString.isEmpty(pnMin)? 0 : pnMin - 0; var sec = XString.isEmpty(pnSec)? 0 : pnSec - 0; hr = hr <= 0? 0 : hr; min = min <= 0? 0 : min; sec = sec <= 0? 0 : sec; return (hr*3600) - (-(min*60)) - (-sec); }; this.formatHourAndMin = function(pnHour,pnMin) { var hr = XString.isEmpty(pnHour)? 0 : pnHour-0; var min = XString.isEmpty(pnMin)? 0 : pnMin-0; hr = hr < 0? 0 : hr; min = min<0? 0 : min; return this.datePartTwoPlaces(hr) + ":" + this.datePartTwoPlaces(min); }; return this; }; var XDate = new XDateClass(); //------------------------------------ // HTML Form Validation //------------------------------------ function XFormClass() { this.className = "XFormClass"; this.getValidator = function(pnDataType) { var ndt = pnDataType*1; if ( ndt >= 30 && ndt <= 39) { return XNumberValidator; } if (ndt >= 40 && ndt <= 41) { return XDateValidator; } return XStringValidator; }; this.isValueRequired = function(poEl) { return XBoolean.parse(poEl.getAttribute("axvr")); }; this.isValueNotEmpty = function(poEl) { return !(this.isValueEmpty); }; this.isValueEmpty = function(poEl) { try { if (!poEl) { return true; } if (XString.isNotEmpty(poEl.value)) { return false; } /* if it is a select, and the selectedIndex > 0, assume selected*/ if (poEl.tagName == "SELECT") { if (poEl.selectedIndex > 0) { return false; } } return true; } catch (e) { XError.display(this.className,e,"isValueEmpty"); throw e; } }; this.validate = function(poForm,pbSkipHidden) { var oEls; var oEl; var bHasError = false; var bSkipHidden = XString.isTrue(pbSkipHidden); var axvr; var axvt; var axvp; var axvfr; try { oEls = poForm.elements; if (!oEls) { return true; } for (i=0; i= 30 && ndt <= 39) { valid = XNumberValidator.validate(val, oEl); // TODO: rethink this logic if (ndt == 31 && valid) { oEl.value = XNumber.toInt(val); } return valid; } if (ndt >= 40 && ndt <= 41) { return XDateValidator.validate(val, oEl); } return XStringValidator.validate(val, oEl); // integer type if ( ndt >= 30 && ndt <= 39) { if (!XNumber.isType(val)) { return false; } } // date or date time if (ndt >= 40 && ndt <= 41) { try { if (XString.isEmpty(psMask)) { return XDate.isType(val); } else { // TODO: implement the mask check } } catch (e) { return false; } } return true; }; this.validateType = function(poEl,psMask) { var oEl = poEl; try { if (!this.validateTypeSilent(oEl,psMask)) { XWindow.alert("stdFormValidateMsgDataFormatInvalid"); try { oEl.focus(); oEl.select(); } catch (e) {} return XEvent.cancel(); } } catch (e) { XError.display(this.className,e,"validateType"); return XEvent.cancel(); } return true; }; this.validateKey = function(poForm,psInputName,pbProcessError) { var oEls = poForm.elements[psInputName]; var oEl = null; var oEl2 = null; if ( (oEls) && (oEls.length > 0) ) { for (i=0; i 0 ) { return false; } } } return true; }; this.checkMinLength = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.maxLength); if ( XString.isNotEmpty(rule) ) { if( psValue.length < (rule*1) ) { return false; } } } return true; }; this.checkMaxLength = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.maxLength); if ( XString.isNotEmpty(rule) ) { if( psValue.length > (rule*1) ) { return false; } } } return true; }; this.checkRegex = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.regex); if ( XString.isNotEmpty(rule) ) { return new RegExp(rule,"ig").test(psValue); } } return true; }; return this; }; var XStringValidator = new XStringValidatorClass(); function XNumberValidatorClass () { this.className = "XNumberValidatorClass"; this.lastErrors = ""; this.validate = function (psValue,poRuleEl,pbEvalAll) { var errors = this.getErrors(psValue,poRuleEl,pbEvalAll); this.lastErrors = errors; return XString.isEmpty(errors); }; this.getErrors = function (psValue,poRuleEl,pbEvalAll) { if (!poRuleEl) { return ""; } var value = psValue; var errors = ""; var evalAll = XBoolean.parse(pbEvalAll); if (XString.isEmpty(value)) { errors += XEFormValidationRule.empty + ","; if (!evalAll) { return errors; } } if ( XInteger.isSet(XInteger.parse(value, 0)) == false ) { errors += XEFormValidationRule.parse + ","; if (!evalAll) { return errors; } } if (!this.checkMinLength(value,poRuleEl)) { errors += XEFormValidationRule.minLength + ","; if (!evalAll) { return errors; } } if (!this.checkMaxLength(value,poRuleEl)) { errors += XEFormValidationRule.maxLength + ","; if (!evalAll) { return errors; } } if (!this.checkMinValue(value,poRuleEl)) { errors += XEFormValidationRule.minValue + ","; if (!evalAll) { return errors; } } if (!this.checkMaxValue(value,poRuleEl)) { errors += XEFormValidationRule.maxValue + ","; if (!evalAll) { return errors; } } if (!this.checkRegex(value,poRuleEl)) { errors += XEFormValidationRule.regex + ","; if (!evalAll) { return errors; } } return errors; }; this.checkMinValue = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.minValue); if ( XString.isNotEmpty(rule) ) { if( psValue < (rule*1) ) { return false; } } } return true; }; this.checkMaxValue = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.maxValue); if ( XString.isNotEmpty(rule) ) { if( psValue > (rule*1) ) { return false; } } } return true; }; this.checkMinLength = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.minLength); if ( XString.isNotEmpty(rule) ) { if( psValue.length < (rule*1) ) { return false; } } } return true; }; this.checkMaxLength = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.maxLength); if ( XString.isNotEmpty(rule) ) { if( psValue.length > (rule*1) ) { return false; } } } return true; }; this.checkRegex = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.regex); if ( XString.isNotEmpty(rule) ) { return new RegExp(rule,"ig").test(psValue); } } return true; }; return this; }; var XNumberValidator = new XNumberValidatorClass(); function XDateValidatorClass () { this.className = "XDateValidatorClass"; this.lastErrors = ""; this.validate = function (psValue,poRuleEl,pbEvalAll) { var errors = this.getErrors(psValue,poRuleEl,pbEvalAll); this.lastErrors = errors; return XString.isEmpty(errors); }; this.getErrors = function (psValue,poRuleEl,pbEvalAll) { if (!poRuleEl) { return ""; } var value = psValue; var errors = ""; var evalAll = XBoolean.parse(pbEvalAll); if (XString.isEmpty(value)) { errors += XEFormValidationRule.empty + ","; if (!evalAll) { return errors; } } if (!XDate.parse(value)) { errors += XEFormValidationRule.parse + ","; if (!evalAll) { return errors; } } if (!this.checkMinLength(value,poRuleEl)) { errors += XEFormValidationRule.minLength + ","; if (!evalAll) { return errors; } } if (!this.checkMaxLength(value,poRuleEl)) { errors += XEFormValidationRule.maxLength + ","; if (!evalAll) { return errors; } } if (!this.checkMinValue(value,poRuleEl)) { errors += XEFormValidationRule.minValue + ","; if (!evalAll) { return errors; } } if (!this.checkMaxValue(value,poRuleEl)) { errors += XEFormValidationRule.maxValue + ","; if (!evalAll) { return errors; } } if (!this.checkRegex(value,poRuleEl)) { errors += XEFormValidationRule.regex + ","; if (!evalAll) { return errors; } } return errors; }; this.checkMinValue = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.minValue); if ( XString.isNotEmpty(rule) ) { rule = XDate.parse(rule); var value = XDate.parse(psValue); if (rule && value) { if( value.getTime() < rule.getTime() ) { return false; } } } } return true; }; this.checkMaxValue = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.maxValue); if ( XString.isNotEmpty(rule) ) { rule = XDate.parse(rule); var value = XDate.parse(psValue); if (rule && value) { if( value.getTime() > rule.getTime() ) { return false; } } } } return true; }; this.checkMinLength = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.minLength); if ( XString.isNotEmpty(rule) ) { if( psValue.length < (rule*1) ) { return false; } } } return true; }; this.checkMaxLength = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.maxLength); if ( XString.isNotEmpty(rule) ) { if( psValue.length > (rule*1) ) { return false; } } } return true; }; this.checkRegex = function (psValue, poRuleEl) { if (poRuleEl) { var rule = poRuleEl.getAttribute(XEFormValidationRule.regex); if ( XString.isNotEmpty(rule) ) { return new RegExp(rule,"ig").test(psValue); } } return true; }; return this; }; var XDateValidator = new XDateValidatorClass(); //------------------------------------ // ACTION MOUSE OVER FUNCTIONS //------------------------------------ function XActionUtilClass() { var mClassName = "XActionUtilClass"; this.onMouseOver = function(poEvent,poEl,psClassName) { try { poEl.setAttribute("xClassSave",poEl.className); poEl.className += " " + psClassName + " "; } catch (e) { XError.display(mClassName,e,"onMouseOver"); } }; this.onMouseOut = function(poEvent,poEl) { try { poEl.className = poEl.getAttribute("xClassSave"); } catch (e) { XError.display(mClassName,e,"onMouseOut"); } }; return this; }; var XActionUtil = new XActionUtilClass(); //------------------------------------ // WINDOW FUNCTIONS //------------------------------------ function XWindowClass() { this.className = "XWindowClass"; this.loadingWin = null; this.cleanseWindowName = function(psWindowName) { try { return (psWindowName + "").replace(/[^A-Z,0-9]/ig,"_"); } catch (e) { XError.display(this.className,e,"cleanseWindowName"); throw e; } } this.isInOtherMonitor = function(poWindow) { try { var win = poWindow? poWindow : window; if (win.screenLeft > win.screen.availWidth) { return true; } if (win.screenLeft < 0) { return true; } return false; } catch (e) { XError.display(this.className,e,"isInOtherMonitor"); throw e; } }; this.getOtherMonitorOffset = function(poWindow) { try { var win = poWindow? poWindow : window; if (win.screenLeft > win.screen.availWidth) { return win.screen.availWidth*1; } if (win.screenLeft < 0) { return -win.screen.availWidth; } return 0; } catch (e) { XError.display(this.className,e,"getOtherMonitorOffset"); throw e; } }; this.moveToCurrentMonitor = function(poWindow) { try { if (!poWindow) { return; } var offset = this.getWindowMonitorOffset(poWindow); if (offset != 0) { poWindow.moveTo(win.screenLeft -(-offset),poWindow.screenTop); } } catch (e) { XError.display(this.className,e,"moveToCurrentMonitor"); throw e; } }; this.isInRightMonitor = function(poWindow) { try { var win = poWindow? poWindow : window; win = win.top? win.top : win; return win.screenLeft > win.screen.availWidth; } catch (e) { XError.display(this.className,e,"isInRightMonitor"); throw e; } }; this.moveToRightMonitor = function(poWindow) { try { if (!poWindow) { return; } if (poWindow.screenLeft < poWindow.screen.availWidth) { poWindow.moveTo(poWindow.screenLeft - (- poWindow.screen.availWidth),poWindow.screenTop); } } catch (e) { XError.display(this.className,e,"moveToRightMonitor"); throw e; } }; this.getWindowBox = function(poWindow,pbIgnoreError) { try { var win = poWindow; var winBox = new XBox(); winBox.x = win.screenLeft*1; winBox.y = win.screenTop*1; if (win.document && win.document.body) { winBox.width = win.document.body.offsetWidth*1; winBox.height = win.document.body.offsetHeight*1; } else { winBox.width = win.screen.availWidth*1; winBox.height = win.screen.availHeight*1; } return winBox; } catch (e) { if (XBoolean.parse(pbIgnoreError)) { return null; } XError.display(this.className,e,"getWindowBox"); throw e; } }; this.getBrowserBox = function() { try { var dom = null; var win = window; if (win.top) { try { dom = win.top.document.domain; return this.getWindowBox(win.top,true); } catch (e) { } } if (!win.parent) { return this.getWindowBox(win); } var par = win.parent; while (par) { try { dom = par.document.domain; win = par; par = win.parent; } catch (e) { par = null; } } return this.getWindowBox(win); } catch (e) { XError.display(this.className,e,"getBrowserBox"); throw e; } }; this.getDialogPositionBox = function(pnWidth,pnHeight) { try { var winBox = this.getBrowserBox(); var posBox = new XBox(); posBox.x = (winBox.x + (winBox.width/2)) - (pnWidth/2); posBox.y = (winBox.y + (winBox.height/2)) - (pnHeight/2); posBox.width = pnWidth*1; posBox.height = pnHeight*1; return posBox; } catch (e) { XError.display(this.className,e,"getDialogPositionBox"); throw e; } }; this.getAppPositionBox = function(pnWidth,pnHeight,pnScale) { try { var winBox = this.getBrowserBox(); var offset = this.getOtherMonitorOffset(window); var nWidth = pnWidth*1; var nHeight = pnHeight*1; var nScale = XString.evl(pnScale,"1")*1; if (nWidth <= winBox.width && nHeight <= winBox.height) { return this.getDialogPositionBox(nWidth,nHeight); } var posBox = new XBox(); // if width is less than opening window, then position within opening window if (nWidth <= winBox.width) { posBox = this.getDialogPositionBox(nWidth,nHeight); posBox.y = (window.screen.availHeight - nHeight)/2; posBox.height = Math.min(window.screen.availHeight * nScale,nHeight); return posBox; } // get the default position posBox.x = (window.screen.availWidth - nWidth)/2; posBox.y = (window.screen.availHeight - nHeight)/2; posBox.height = Math.min(window.screen.availHeight * nScale,nHeight); posBox.width = Math.min(window.screen.availWidth * nScale,nWidth); // adjust the x coord for dual monitor posBox.x = posBox.x - (-offset); return posBox; } catch (e) { XError.display(this.className,e,"getAppPositionBox"); throw e; } }; this.showLoadingDialog = function() { try { var baseUrl = XConfig.resolveWebUrl(XConfig.winUrlLoadingServer); if (XConfig.isClientScope()) { baseUrl = XConfig.resolveWebUrl(XConfig.winUrlLoadingClient); } this.loadingWin = this.launchAppModeless(baseUrl,300,125); return this.loadingWin; } catch (e) { XError.display(this.className,e,"showLoadingDialog"); throw e; } }; this.hideLoadingDialog = function() { try { if (this.loadingWin) { this.loadingWin.close(); } } catch (e) { } this.loadingWin = null; }; this.error = function(psResultCode,psResultInfo,psResultExtInfo,psTitle) { try { var sFeatures; var sUrl; var oArgs = null; var sRc = XString.evl(psResultCode,""); var sRi = XString.evl(psResultInfo,""); var sRx = XString.evl(psResultExtInfo,""); var sT = XString.evl(psTitle,""); var baseUrl = XConfig.resolveWebUrl(XConfig.winUrlErrorServer); if (XConfig.isClientScope()) { baseUrl = XConfig.resolveWebUrl(XConfig.winUrlErrorClient); } // always pass the error info in the dialog args oArgs = new Array(4); oArgs[0] = sRc; oArgs[1] = sRi; oArgs[2] = sRx; oArgs[3] = sT; // center the dialog on the window var nWidth = 400; var nHeight = 300; var posBox = this.getDialogPositionBox(nWidth,nHeight); sFeatures = "dialogLeft:" + posBox.x + "px;" + "dialogTop:" + posBox.y + "px;" + "dialogWidth:" + posBox.width + "px;" + "dialogHeight:" + posBox.height + "px;" + "edge:raised;" + "resizable:yes;" //WIN + "help:no;" //WIN + "scroll:no;" //WIN + "status:no;" ; sUrl = baseUrl + "?" + "xResultCode=" + encodeURIComponent(sRc) + "&" + "xResultInfo=" + encodeURIComponent(sRi) + "&" + "xResultExtInfo=" + encodeURIComponent(sRx) + "&" + "xTitle=" + encodeURIComponent(sT) + "&" ; if (sUrl.length > 2000) { sUrl = sUrl.substr(0,2000); } return window.showModalDialog(sUrl,oArgs,sFeatures); } catch (e) { XError.display(this.className,e,"error"); throw e; } }; this.debugWsResult = function(poWsResult,psTitle) { try { if (poWsResult) { this.debug(poWsResult.getCode(),poWsResult.getInfo(),poWsResult.getExtendedInfo(),psTitle); } else { this.debug("","","",psTitle); } } catch (e) { XError.display(this.className,e,"debugWsResult"); throw e; } }; this.debug = function(psResultCode,psResultInfo,psResultExtInfo,psTitle) { try { var sFeatures; var sUrl; var oArgs = null; var sRc = XString.evl(psResultCode,""); var sRi = XString.evl(psResultInfo,""); var sRx = XString.evl(psResultExtInfo,""); var sT = XString.evl(psTitle,""); var baseUrl = XConfig.resolveWebUrl(XConfig.winUrlDebugServer); if (XConfig.isClientScope()) { baseUrl = XConfig.resolveWebUrl(XConfig.winUrlDebugClient); } // always pass the debug info in the dialog args oArgs = new Array(4); oArgs[0] = sRc; oArgs[1] = sRi; oArgs[2] = sRx; oArgs[3] = sT; // center the dialog on the window var nWidth = 550; var nHeight = 350; var posBox = this.getDialogPositionBox(nWidth,nHeight); sFeatures = "dialogLeft:" + posBox.x + "px;" + "dialogTop:" + posBox.y + "px;" + "dialogWidth:" + posBox.width + "px;" + "dialogHeight:" + posBox.height + "px;" + "edge:raised;" + "resizable:yes;" //WIN + "help:no;" //WIN + "scroll:no;" //WIN + "status:no;" ; sUrl = baseUrl + "?" + "xResultCode=" + encodeURIComponent(sRc) + "&" + "xResultInfo=" + encodeURIComponent(sRi) + "&" + "xResultExtInfo=" + encodeURIComponent(sRx) + "&" + "xTitle=" + encodeURIComponent(sT); if (sUrl.length > 2000) { sUrl = sUrl.substr(0,2000); } return window.showModalDialog(sUrl,oArgs,sFeatures); } catch (e) { XError.display(this.className,e,"debug"); throw e; } }; this.prompt = function(psMessage,psValue) { try { var sFeatures; var sUrl; var oArgs = null; var sMsg = XString.evl(psMessage,""); var sValue = XString.evl(psValue,""); var baseUrl = XConfig.resolveWebUrl(XConfig.winUrlPromptServer); if (XConfig.isClientScope()) { baseUrl = XConfig.resolveWebUrl(XConfig.winUrlPromptClient); oArgs = new Array(2); oArgs[0] = sMsg; oArgs[1] = sValue; } // center the dialog on the window var nWidth = 300; var nHeight = 160; var posBox = this.getDialogPositionBox(nWidth,nHeight); sFeatures = "dialogLeft:" + posBox.x + "px;" + "dialogTop:" + posBox.y + "px;" + "dialogWidth:" + posBox.width + "px;" + "dialogHeight:" + posBox.height + "px;" + "edge:raised;" + "resizable:yes;" //WIN + "help:no;" //WIN + "scroll:no;" //WIN + "status:no;" ; sUrl = baseUrl + "?" + "xMessage=" + encodeURIComponent(sMsg) + "&" + "xValue=" + encodeURIComponent(sValue) + "&"; if (sUrl.length > 2000) { sUrl = sUrl.substr(0,2000); } return window.showModalDialog(sUrl,oArgs,sFeatures); } catch (e) { XError.display(this.className,e,"prompt"); throw e; } }; this.fileChooser = function(psMessage,psValue) { try { var sFeatures; var sUrl; var oArgs = null; var sMsg = XString.evl(psMessage,""); var sValue = XString.evl(psValue,""); var baseUrl = XConfig.resolveWebUrl(XConfig.winUrlFileChooserServer); if (XConfig.isClientScope()) { baseUrl = XConfig.resolveWebUrl(XConfig.winUrlFileChooserClient); oArgs = new Array(2); oArgs[0] = sMsg; oArgs[1] = sValue; } // center the dialog on the window var nWidth = 600; var nHeight = 150; var posBox = this.getDialogPositionBox(nWidth,nHeight); sFeatures = "dialogLeft:" + posBox.x + "px;" + "dialogTop:" + posBox.y + "px;" + "dialogWidth:" + posBox.width + "px;" + "dialogHeight:" + posBox.height + "px;" + "edge:raised;" + "resizable:yes;" //WIN + "help:no;" //WIN + "scroll:no;" //WIN + "status:no;" ; sUrl = baseUrl + "?" + "xMessage=" + encodeURIComponent(sMsg) + "&" + "xValue=" + encodeURIComponent(sValue) + "&"; if (sUrl.length > 2000) { sUrl = sUrl.substr(0,2000); } return window.showModalDialog(sUrl,oArgs,sFeatures); } catch (e) { XError.display(this.className,e,"fileChooser"); throw e; } }; this.confirm = function(psMessage) { try { var sFeatures; var sUrl; var sMsg = XString.evl(psMessage,""); var oArgs = sMsg; var baseUrl = XConfig.resolveWebUrl(XConfig.winUrlConfirmServer); if (XConfig.isClientScope()) { baseUrl = XConfig.resolveWebUrl(XConfig.winUrlConfirmClient); } // center the dialog on the window var nWidth = 300; var nHeight = 140; var posBox = this.getDialogPositionBox(nWidth,nHeight); sFeatures = "dialogLeft:" + posBox.x + "px;" + "dialogTop:" + posBox.y + "px;" + "dialogWidth:" + posBox.width + "px;" + "dialogHeight:" + posBox.height + "px;" + "edge:raised;" + "resizable:yes;" //WIN + "help:no;" //WIN + "scroll:no;" //WIN + "status:no;" ; sUrl = baseUrl + "?" + "xMessage=" + encodeURIComponent(sMsg) + "&"; if (sUrl.length > 2000) { sUrl = sUrl.substr(0,2000); } return XBoolean.parse(window.showModalDialog(sUrl,oArgs,sFeatures)); } catch (e) { XError.display(this.className,e,"confirm"); throw e; } }; this.alert = function(psMessage,psAtt1,psAtt2,psAtt3) { try { var sFeatures; var sUrl; var oArgs = null; var sMsg = XString.evl(psMessage,""); var sAtt1 = XString.evl(psAtt1,""); var sAtt2 = XString.evl(psAtt2,""); var sAtt3 = XString.evl(psAtt3,""); var baseUrl = XConfig.resolveWebUrl(XConfig.winUrlAlertServer); if (XConfig.isClientScope()) { baseUrl = XConfig.resolveWebUrl(XConfig.winUrlAlertClient); oArgs = new Array(4); oArgs[0] = sMsg; oArgs[1] = sAtt1; oArgs[2] = sAtt2; oArgs[3] = sAtt3; } // center the dialog on the window var nWidth = 300; var nHeight = 140; var posBox = this.getDialogPositionBox(nWidth,nHeight); sFeatures = "dialogLeft:" + posBox.x + "px;" + "dialogTop:" + posBox.y + "px;" + "dialogWidth:" + posBox.width + "px;" + "dialogHeight:" + posBox.height + "px;" + "edge:raised;" + "resizable:yes;" //WIN + "help:no;" //WIN + "scroll:no;" //WIN + "status:no;" ; sUrl = baseUrl + "?" + "xMessage=" + encodeURIComponent(sMsg) + "&" + "xAtt1=" + encodeURIComponent(sAtt1) + "&" + "xAtt2=" + encodeURIComponent(sAtt2) + "&" + "xAtt3=" + encodeURIComponent(sAtt3) + "&" ; if (sUrl.length > 2000) { sUrl = sUrl.substr(0,2000); } return window.showModalDialog(sUrl,oArgs,sFeatures); } catch (e) { XError.display(this.className,e,"alert"); throw e; } }; this.yesNo= function(psMessage) { try { var sFeatures; var sUrl; var sMsg = XString.evl(psMessage,""); var oArgs = sMsg; var baseUrl = XConfig.resolveWebUrl(XConfig.winUrlYesNoServer); if (XConfig.isClientScope()) { baseUrl = XConfig.resolveWebUrl(XConfig.winUrlYesNoClient); } // center the dialog on the window var nWidth = 300; var nHeight = 140; var posBox = this.getDialogPositionBox(nWidth,nHeight); sFeatures = "dialogLeft:" + posBox.x + "px;" + "dialogTop:" + posBox.y + "px;" + "dialogWidth:" + posBox.width + "px;" + "dialogHeight:" + posBox.height + "px;" + "edge:raised;" + "resizable:yes;" //WIN + "help:no;" //WIN + "scroll:no;" //WIN + "status:no;" ; sUrl = baseUrl + "?" + "xMessage=" + encodeURIComponent(sMsg) + "&"; if (sUrl.length > 2000) { sUrl = sUrl.substr(0,2000); } return XBoolean.parse(window.showModalDialog(sUrl,oArgs,sFeatures)); } catch (e) { XError.display(this.className,e,"yesNo"); throw e; } }; this.yesNoCancel = function(psMessage) { try { var sFeatures; var sUrl; var sMsg = XString.evl(psMessage,""); var oArgs = sMsg; var baseUrl = XConfig.resolveWebUrl(XConfig.winUrlYesNoCancelServer); if (XConfig.isClientScope()) { baseUrl = XConfig.resolveWebUrl(XConfig.winUrlYesNoCancelClient); } // center the dialog on the window var nWidth = 300; var nHeight = 140; var posBox = this.getDialogPositionBox(nWidth,nHeight); sFeatures = "dialogLeft:" + posBox.x + "px;" + "dialogTop:" + posBox.y + "px;" + "dialogWidth:" + posBox.width + "px;" + "dialogHeight:" + posBox.height + "px;" + "edge:raised;" + "resizable:yes;" //WIN + "help:no;" //WIN + "scroll:no;" //WIN + "status:no;" ; sUrl = baseUrl + "?" + "xMessage=" + encodeURIComponent(sMsg) + "&"; if (sUrl.length > 2000) { sUrl = sUrl.substr(0,2000); } var rslt = window.showModalDialog(sUrl,oArgs,sFeatures); switch (rslt) { case "-1" : return null; default : return rslt; } } catch (e) { XError.display(this.className,e,"yesNoCancel"); throw e; } }; this.launchApp = function(psUrl,psWindowName,pnWidth,pnHeight,poArgs) { var sFeatures; var nHeight; var nWidth; var nTop; var nLeft; var sUrl; try { if (XString.isNotEmpty(pnWidth)) { nWidth = pnWidth*1; } else { nWidth = 1000; } if (XString.isNotEmpty(pnHeight)) { nHeight = pnHeight*1; } else { nHeight = 700; } // center the dialog on the window var posBox = this.getAppPositionBox(nWidth,nHeight,.9); sFeatures = //WIN "fullscreen=0," + //WIN "channelmode=0," + //WIN "titlebar=0," + //WIN "toolbar=0," + //WIN "location=0," + //WIN "directories=0," + //WIN "menubar=0," + "status=1," + "scrollbars=1," + "resizable=1," + "left=" + posBox.x + "," + "top=" + posBox.y + "," + "width=" + posBox.width + "," + "height=" + posBox.height; sUrl = XString.evl(psUrl,XConfig.getBlankPageUrl()); sWindowName = XString.evl(psWindowName,new Date().getTime()); win = window.open(sUrl,sWindowName,sFeatures,false); try {win.focus();} catch (e) {} try {win.opener = window.self; } catch (e) {} try {win.openerArgs = poArgs; } catch (e) {} return win; } catch (e) { XError.display(this.className,e,"launchApp"); throw e; } }; this.launchAppModal = function(psUrl,pnWidth,pnHeight,poArgs) { var sFeatures; var nHeight; var nWidth; try { if (XString.isNotEmpty(pnWidth)) { nWidth = pnWidth*1; } else { nWidth = 600; } if (XString.isNotEmpty(pnHeight)) { nHeight = pnHeight*1; } else { nHeight = 400; } // center the dialog on the window var posBox = this.getDialogPositionBox(nWidth,nHeight,.9); sFeatures = "dialogLeft:" + posBox.x + "px;" + "dialogTop:" + posBox.y + "px;" + "dialogWidth:" + posBox.width + "px;" + "dialogHeight:" + posBox.height + "px;" + "edge:raised;" + "resizable:yes;" //WIN + "help:no;" //WIN + "scroll:no;" //WIN + "status:no;" ; return window.showModalDialog(psUrl,poArgs,sFeatures); } catch (e) { XError.display(this.className,e,"launchAppModal"); throw e; } }; this.launchAppModeless = function(psUrl,pnWidth,pnHeight,poArgs) { var sFeatures; var nHeight; var nWidth; var sUrl; try { if (XString.isNotEmpty(pnWidth)) { nWidth = pnWidth*1; } else { nWidth = 600; } if (XString.isNotEmpty(pnHeight)) { nHeight = pnHeight*1; } else { nHeight = 400; } // center the dialog on the window var posBox = this.getDialogPositionBox(nWidth,nHeight,.9); sFeatures = "dialogLeft:" + posBox.x + "px;" + "dialogTop:" + posBox.y + "px;" + "dialogWidth:" + posBox.width + "px;" + "dialogHeight:" + posBox.height + "px;" + "edge:raised;" + "resizable:yes;" //WIN + "help:no;" //WIN + "scroll:no;" //WIN + "status:no;" ; sUrl = XString.evl(psUrl,XConfig.getBlankPageUrl()); var win = window.showModelessDialog(sUrl,poArgs,sFeatures); win.opener = window.self; return win; } catch (e) { XError.display(this.className,e,"launchAppModeless"); throw e; } }; this.launchAppXModal = function(psUrl,pnWidth,pnHeight,poArgs,psWindowName) { var sFeatures; var nHeight; var nWidth; var nTop; var nLeft; var sUrl; var name; try { if (XString.isNotEmpty(pnWidth)) { nWidth = pnWidth*1; } else { nWidth = 1000; } if (XString.isNotEmpty(pnHeight)) { nHeight = pnHeight*1; } else { nHeight = 700; } // center the dialog on the window var posBox = this.getDialogPositionBox(nWidth,nHeight,.9); sFeatures = //WIN "fullscreen=0," + //WIN "channelmode=0," + //WIN "titlebar=0," + //WIN "toolbar=0," + //WIN "location=0," + //WIN "directories=0," + //WIN "menubar=0," + //WIN "scrollbars=0," + //WIN "resizable=0," + "status=1," + "left=" + posBox.x + "," + "top=" + posBox.y + "," + "width=" + posBox.width + "," + "height=" + posBox.height ; sUrl = XString.evl(psUrl,XConfig.getBlankPageUrl()); name = XString.evl(psWindowName,"XWinModal"); win = window.open(sUrl,name,sFeatures,false); try {win.focus();} catch (e) {} try {win.opener = window.self; } catch (e) {} try {win.openerArgs = poArgs; } catch (e) {} return win; } catch (e) { XError.display(this.className,e,"launchAppXModal"); throw e; } }; return this; }; var XWindow = new XWindowClass(); //------------------------------------ // ALERT DIALOG FUNCTIONS //------------------------------------ function XAlertDialogClass() { this.className = "XAlertDialogClass"; this.onLoad = function() { try { XHtmlUtil.initValueI(); window.focus(); var oEl = document.getElementById("xActionDefault"); if (oEl) { oEl.focus(); } } catch (e) { XError.display(this.className,e,"onLoad"); } }; this.onUnload = function(psDefaultReturnValue) { try { if (XObject.isNull(window.returnValue) && (window.returnValue != "") ) { window.returnValue = XString.nvl(psDefaultReturnValue,null); } } catch (e) { XError.display(this.className,e,"onUnload"); } }; this.close = function(psValue) { try { window.returnValue = psValue; window.close(); } catch (e) { XError.display(this.className,e,"close"); } }; return this; }; var XAlertDialog = new XAlertDialogClass(); //------------------------------- // XModalHelper //------------------------------- function XModalHelperClass () { this.className = "XModalHelperClass"; this.dialog = null; this.setDialog = function(poWindow) { this.dialog = poWindow; }; this.clearDialog = function() { if (this.dialog) { try { this.dialog.close(); } catch (e) { } } this.dialog = null; }; this.showDialog = function() { if (this.dialog) { try { this.dialog.focus(); } catch (e) { } } }; this.onWindowFocus = function() { try { if (this.dialog) { try { this.dialog.focus(); } catch (e) { this.dialog = null; } } } catch(e) { XError.display(this.className,e,"onWindowFocus"); } }; return this; }; var XModalHelper = new XModalHelperClass(); //------------------------------------ // XTabFrame Class //------------------------------------ // * poTabEl.name is the name of the tab set // * The following objects exist: // _Container -- parent object holder for all tabs with the following attribs // - axTabClassOffFirst, axTabClassOff, axTabClassOn // _LoadingMsg // - inner HTML is what to display before navigating the frame function XTabFrameClass() { this.className = "XTabFrameClass"; this.navigate = function(poTabEl,poWindow,psRows,psUrl,pbAutoRefresh) { var oTabs; var oTab; var oContainer; var oLoadingMsg; var sClass; var sTabClassOff; var sTabClassOn; var bIsLoaded = false; try { if (!poTabEl) { return; } oLoadingMsg = document.getElementById(poTabEl.name + "_LoadingMsg"); oContainer = document.getElementById(poTabEl.name + "_Container"); oTabs = oContainer.children; sTabClassOff = oContainer.getAttribute("axTabClassOff"); sTabClassOn = oContainer.getAttribute("axTabClassOn"); for (var i=0; i < oTabs.length; i++) { oTab = oTabs[i]; sClass = oTab.className; sClass = sClass.replace(sTabClassOff,""); sClass = sClass.replace(sTabClassOn,""); sClass = XString.trim(sClass); sClass = sTabClassOff + " " + sClass; oTab.className = sClass; } sClass = poTabEl.className; sClass = sClass.replace(sTabClassOff,""); sClass = sClass.replace(sTabClassOn,""); sClass = XString.trim(sClass); sClass = sTabClassOn + " " + sClass; poTabEl.className = sClass; bIsLoaded = XBoolean.parse(poTabEl.getAttribute("axIsLoaded")); if ( (pbAutoRefresh) || (!bIsLoaded) || (XConfig.isUrlBlankPage(poWindow.location.href)) || (XEvent.isCtrlKey()) ) { if (oLoadingMsg) { poWindow.document.body.innerHTML = oLoadingMsg.innerHTML; } poWindow.navigate(psUrl); } parent.frameHolder.rows = psRows; poTabEl.setAttribute("axIsLoaded","1"); } catch (e) { XError.display(this.className,e,"navigate"); poTabEl.setAttribute("axIsLoaded","0"); } }; return this; }; var XTabFrame = new XTabFrameClass(); //------------------------------------ // XTabSet Class //------------------------------------ // * psTabSet is the name of the tab set // * The following objects exist: // _Container -- contains information about the tab set including the following attribs: // - axTabClassOffFirst, axTabClassOff, axTabClassOn // * For each tab in the set, the following must exist: // // // -- tab panel container that will be hidden/displayed function XTabSetClass() { this.className = "XTabSetClass"; this.loadFrameIndAttribute = "axLoadSrc"; this.loadFrameSrcAttribute = "axSrc"; this.initializeTabSet = function(psTabSet,pbPreservePanel) { try { var oSelEl = this.getTabSetSelectedEl(psTabSet); if (oSelEl) { var oElTab = this.getTab(oSelEl.value); if (!oElTab) { oElTab = this.getDefaultTab(psTabSet); } if (!oElTab) { oElTab = this.getFirstTab(psTabSet); } if (oElTab) { this.showTabEl(oElTab,true,pbPreservePanel); } } } catch (e) { XError.display(this.className,e,"initializeTabSet"); throw e; } }; this.getTabElements = function(psTabSet) { try { if (XString.isEmpty(psTabSet)) { return null; } return document.getElementsByName(psTabSet); } catch (e) { XError.display(this.className,e,"getTabElements"); throw e; } }; this.getDefaultTab = function(psTabSet) { try { if (XString.isEmpty(psTabSet)) { return null; } var oColl = this.getTabElements(psTabSet); var el = null; var firstEl = null; var tabId = ""; var tabDefaultInd = ""; if (oColl && oColl.length > 0) { tabId = oColl[0].getAttribute("axTab"); firstEl = document.getElementById(tabId); for (var i=0; i 0) { oElTab = document.getElementById(oColl[0].getAttribute("axTab")); } return oElTab; } catch (e) { XError.display(this.className,e,"getFirstTab"); throw e; } }; this.getSelectedTab = function(psTabSet) { try { var oEl = this.getTabSetSelectedEl(psTabSet); if (oEl) { oEl = document.getElementById(oEl.value); if (oEl) { return oEl.id; } } return ""; } catch (e) { XError.display(this.className,e,"getSelectedTab"); throw e; } }; this.isTabSelected = function(psTabId) { try { var oEl = document.getElementById(psTabId); if (oEl) { var sTabSet = oEl.getAttribute("axTabSet"); oEl = this.getTabSetSelectedEl(sTabSet); if (oEl) { return oEl.value == psTabId; } } return false; } catch (e) { XError.display(this.className,e,"isSelectedTab"); throw e; } }; this.getTabSetControllerEl = function(psTabSetId) { try { return document.getElementById(psTabSetId + "_Controller"); } catch (e) { XError.display(this.className,e,"getTabSetControllerEl"); throw e; } }; this.getTabSetSelectedEl = function(psTabSetId) { try { return document.getElementById(psTabSetId + "_Selected"); } catch (e) { XError.display(this.className,e,"getTabSetSelectedEl"); throw e; } }; this.getTabPanel = function(psTabId) { try { return document.getElementById(psTabId + "_Panel"); } catch (e) { XError.display(this.className,e,"getTabPanel"); throw e; } }; this.getTab = function(psTabId) { try { if (XString.isNotEmpty(psTabId)) { return document.getElementById(psTabId); } return null; } catch (e) { XError.display(this.className,e,"getTab"); throw e; } }; this.hideTabPanel = function(psTabId) { try { var oEl = this.getTabPanel(psTabId); if (oEl) { oEl.style.display = "none"; } } catch (e) { XError.display(this.className,e,"hideTabPanel"); throw e; } }; this.showTabPanel = function(psTabId) { try { var oEl = this.getTabPanel(psTabId); if (oEl) { oEl.style.display = ""; } } catch (e) { XError.display(this.className,e,"showTabPanel"); throw e; } }; this.hideTabs = function(psTabSet) { var oElTabController; var oColl; var oElTab; try { oElTabController = this.getTabSetControllerEl(psTabSet); oColl = this.getTabElements(psTabSet); if (oColl) { for ( var i=0; i // * Traps the move moving and invokes the following methods on the moveListener: // onResized, onResizeStart, onResizeEnd // * axResizeContainerId is the constraining container. if empty, will be the document. // * axResizePadding is the padding in pixels which the element must be within the border of the container. // * axResizeRefreshInterval is the number of pixels that need to be moved before a refresh occurs // * axResizeDir is one of: H=horizontal, V=vertical, both function XResizerClass() { this.className = "XResizerClass"; this.directionHorizontal = "H"; this.directionVertical = "V"; this.directionBoth = ""; this.defaultPadding = 10; this.defaultRefreshInterval = 0; this.defaultCancelThreshhold = 100; // if the x,y diff from the last event is more than this value, action is cancelled this.defaultHideStatus = false; this.defaultCursorStyle = XBrowser.cursorResizeNW; this.defaultMinWidth = 20; this.defaultMaxWidth = 0; this.defaultMinHeight = 4; this.defaultMaxHeight = 0; // control and elements this.controlEl = null; this.listener = null; this.documentState = null; this.containerEl = null; this.containerElState = null; this.containerElWidth = 0; this.containerElHeight = 0; this.containerElPosLeft = 0; this.containerElPosRight = 0; this.containerElPosTop = 0; this.containerElPosBottom = 0; this.targetEl = null; this.targetElId = ""; // the element that has the scrollbars this.scrollEl = null; this.scrollElId = ""; // control variables this.isWorking = false; this.isHideStatus = false; this.isWorkPending = false; this.isEndPending = false; this.isResizeHorizontal = true; this.isResizeVertical = true; this.minPadding = this.defaultPadding; this.cursorStyle = this.defaultCursorStyle; this.refreshInterval = this.defaultRefreshInterval; this.cancelThreshhold = this.defaultCancelThreshhold; this.lastX = 0; this.lastY = 0; this.currX = 0; this.currY = 0; this.minX = 0; this.minY = 0; this.maxX = 0; this.maxY = 0; this.minXX = 0; this.minYY = 0; this.maxXX = 0; this.maxYY = 0; this.startAction = function(poControlEl,poListener,poTargetElId) { var tmp; var oEvent = XEvent.getEvent(); try { this.isWorking = false; this.isWorkPending = false; this.isEndPending = false; this.controlEl = null; this.scrollEl = null; this.documentState = null; var oEl = poControlEl; if (!oEl) { oEl = XEvent.getSrcElement(oEvent); } if (!oEl) { return false; } // control settings this.controlEl = oEl; this.scrollElId = XString.evl(this.controlEl.getAttribute("axResizeScrollId"),""); this.isHideStatus = XBoolean.parse(XString.evl(this.controlEl.getAttribute("axResizeHideStatus"),this.defaultHideStatus)); this.minPadding = XString.evl(this.controlEl.getAttribute("axResizePadding"),this.defaultPadding)*1; this.cursorStyle = XString.evl(this.controlEl.getAttribute("axResizeCursor"),this.defaultCursorStyle); this.refreshInterval = XString.evl(this.controlEl.getAttribute("axResizeRefreshInterval"),this.defaultRefreshInterval); this.cancelThreshhold = XString.evl(this.controlEl.getAttribute("axResizeCancelThreshhold"),this.defaultCancelThreshhold); // resize direction this.isResizeHorizontal = true; this.isResizeVertical = true; this.direction = XString.evl(this.controlEl.getAttribute("axResizeDir"),this.directionBoth); if (this.direction == this.directionHorizontal) { this.isResizeVertical = false; } if (this.direction == this.directionVertical) { this.isResizeHorizontal = false; } // listener this.listener = poListener; // scroll object this.scrollEl = document.getElementById(this.scrollElId); this.setScrollElement(this.scrollEl); // container object tmp = this.controlEl.getAttribute("axResizeContainerId"); if (XString.isNotEmpty(tmp)) { this.containerEl = document.getElementById(tmp); } if (!this.containerEl) { this.containerEl = document.body; } this.setContainer(this.containerEl); // target object this.targetElId = XString.evl(poTargetElId,""); this.targetEl = document.getElementById(this.targetElId); this.setTarget(this.targetEl); // coords var evt = XEvent.getEvent(); // TODO: FIREFOX this.lastX = evt.x;// TODO: FIREFOX this.lastY = evt.y; // TODO: FIREFOX this.currX = evt.x;// TODO: FIREFOX this.currY = evt.y;// TODO: FIREFOX this.minXX = this.containerEl.style.pixelLeft - (-this.minPadding); this.minYY = this.containerEl.style.pixelTop - (-this.minPadding); this.maxXX = this.containerElWidth - this.minPadding; this.maxYY = this.containerElHeight - this.minPadding; this.minX = this.containerElPosLeft - (-this.minPadding); this.minY = this.containerElPosTop - (-this.minPadding); this.maxX = this.containerElPosLeft - (-this.maxXX); this.maxY = this.containerElPosTop - (-this.maxYY); // set the new container events on the container /* this.containerEl.onmousemove = XResizer.performAction; this.containerEl.onmouseup = XResizer.endAction; this.containerEl.onclick = XResizer.endAction; this.containerEl.ondblclick = XResizer.endAction; this.containerEl.style.cursor = this.cursorStyle; */ // set the new container events on the document this.documentState = new XHtmlState(document.body); this.documentState.captureState(true); document.body.onmousemove = XResizer.performAction; document.body.onmouseup = XResizer.endAction; document.body.onclick = XResizer.endAction; document.body.ondblclick = XResizer.endAction; document.body.style.cursor = this.cursorStyle; if (this.listener) { this.listener.onResizeStart(XResizer); } return XEvent.cancel(oEvent); } catch (e) { XError.display(this.className,e,"startAction"); return XEvent.cancel(oEvent); } }; this.setScrollElement = function(poEl) { try { this.scrollElId = ""; this.scrollEl = poEl; if (poEl) { this.scrollElId = poEl.id; } else { this.scrollEl = this.containerEl; } } catch (e) { XError.display(this.className,e,"setScrollElement"); return XEvent.cancel(); } }; this.setTarget = function(poEl) { try { this.targetElId = ""; this.targetEl = poEl; if (poEl) { this.targetElId = poEl.id; } } catch (e) { XError.display(this.className,e,"setTarget"); return XEvent.cancel(); } }; this.setContainer = function(poEl) { try { if (!poEl) { return; } this.containerEl = poEl; this.containerElState = new XHtmlState(this.containerEl); this.containerElState.captureState(true); // clientHeight and clientWidth ignore padding, margin, and scrollbars this.containerElWidth = this.containerEl.clientWidth*1; this.containerElHeight = this.containerEl.clientHeight*1; this.containerElPosLeft = XHtmlUtil.calcAbsoluteLeft(this.containerEl)*1; this.containerElPosRight = this.containerElPosLeft - (-this.containerElWidth); this.containerElPosTop = XHtmlUtil.calcAbsoluteTop(this.containerEl)*1; this.containerElPosBottom = this.containerElPosTop - (-this.containerElHeight); if (!this.scrollEl) { this.scrollEl = this.containerEl; } } catch (e) { XError.display(this.className,e,"setContainer"); return XEvent.cancel(); } }; this.resizeObject = function(poTarget,pnDiffX,pnDiffY,pbAdjustScroll) { var adjusted = false; var oCont = XResizer.containerEl; var oScroll = XResizer.scrollEl; var oEl = poTarget; var diffx = pnDiffX*1; var diffy = pnDiffY*1; var minw = XString.evl(oEl.getAttribute("axResizeMinWidth"),XResizer.defaultMinWidth); var maxw = XString.evl(oEl.getAttribute("axResizeMaxWidth"),XResizer.defaultMaxWidth); var minh = XString.evl(oEl.getAttribute("axResizeMinHeight"),XResizer.defaultMinHeight); var maxh = XString.evl(oEl.getAttribute("axResizeMaxHeight"),XResizer.defaultMaxHeight); var w = XString.evl(oEl.style.pixelWidth,"0")*1; if (w <= 0) { w = oEl.offsetWidth; } var h = XString.evl(oEl.style.pixelHeight,"0")*1; if (h <= 0) { h = oEl.offsetHeight; } var ww = w - (-diffx); var hh = h - (-diffy); if (ww < minw) { ww = minw; adjusted=true; } else { if ( (XResizer.maxXX > 0) && (ww > XResizer.maxXX) ) { ww = XResizer.maxXX - w; adjusted = true; } } if (hh < minh) { hh = minh; adjusted=true; } else { if ( (XResizer.maxYY > 0) && (hh > XResizer.maxYY) ){ hh = XResizer.maxYY - h; adjusted = true; } } oEl.style.pixelWidth = ww; oEl.style.pixelHeight = hh; if (pbAdjustScroll) { // scrollLeft/scrollHeight is the number of pixels the scrollbar is shifted right or down respectively // clientWidth and clientHeight is the "visible" area of the object - minus borders, padding, and scrollbars if (ww > oScroll.clientWidth) { oScroll.scrollLeft += ww - oScroll.clientWidth; } if (hh > oScroll.clientHeight) { oScroll.scrollTop += hh - oScroll.clientHeight; } } return new XPoint(ww,hh,adjusted); }; this.performAction = function() { // check exit conditions if (XResizer.isWorking) { return XEvent.cancel(); } if (!XResizer.controlEl) { XResizer.endAction(); return XEvent.cancel(); } var evt = event; // TODO: FIREFOX if ((!evt) || (evt.button == "0")) { // TODO: move to constant XResizer.endAction(); return XEvent.cancel(); } XResizer.isWorking = true; XResizer.isWorkPending = false; XResizer.isEndPending = false; var checkPosition = true; var x = evt.x*1;// TODO: FIREFOX var y = evt.y*1;// TODO: FIREFOX var diffx = (x - XResizer.lastX)*1; var diffy = (y - XResizer.lastY)*1; XResizer.currX = x; XResizer.currY = y; if (!XResizer.isHideStatus) { window.status = "(" + x + "," + y + ")"; } // check that we moved if ( (diffx == 0) && (diffy == 0) ) { XResizer.isWorking = false; return XEvent.cancel(); } var absDiffx = Math.abs(diffx); var absDiffy = Math.abs(diffy); // check for interval if (XResizer.refreshInterval > 0) { // see if we are under the throttle and j if ( (absDiffx < XResizer.refreshInterval) && (absDiffy < XResizer.refreshInterval) ) { XResizer.isWorking = false; XResizer.isWorkPending = true; return XEvent.cancel(); } } // check the cancel threshhold if (XResizer.cancelThreshhold > 0) { // see if we are over the threshhold if ( (absDiffx > XResizer.cancelThreshhold) || (absDiffy > XResizer.cancelThreshhold) ) { XResizer.endAction(); return XEvent.cancel(); } } // check the resize direction if (!XResizer.isResizeHorizontal) { diffx = 0; } if (!XResizer.isResizeVertical) { diffy = 0; } var point = null; if (XResizer.targetEl) { try { // point is new width,height point = XResizer.resizeObject(XResizer.targetEl,diffx,diffy,true); } catch (e) { } } if (true) { // check if we are outside the container if ( (XNumber.compare(x,XResizer.containerElPosLeft) < 0) || (XNumber.compare(x,XResizer.containerElPosRight) > 0) || (XNumber.compare(y,XResizer.containerElPosTop) < 0) || (XNumber.compare(y,XResizer.containerElPosBottom) > 0) ) { XResizer.isEndPending = true; } } if (XResizer.listener) { try { XResizer.listener.onResizeExec(XResizer); } catch (e) { } } XResizer.lastX = x; XResizer.lastY = y; XResizer.isWorking = false; if (XResizer.isEndPending ) { XResizer.endAction(); return XEvent.cancel(); } return XEvent.cancel(); }; this.endAction = function() { XResizer.isWorking = false; if (XResizer.controlEl) { try { if (XResizer.documentState) { XResizer.documentState.restoreState(); } } catch (e) {} try { // restore the state if (XResizer.containerElState) { XResizer.containerElState.restoreState(); } } catch (e) {} try { if (XResizer.listener) { XResizer.listener.onResizeEnd(XResizer); } } catch (e) {} } XResizer.targetEl = null; XResizer.controlEl = null; XResizer.isWorking = false; XResizer.isWorkPending = false; XResizer.isEndPending = false; return XEvent.cancel(); }; return this; }; var XResizer = new XResizerClass(); // * Eg: // // * Traps the move moving and invokes the following methods on the moveListener: // onMoved, onMoveStart, onMoveEnd // * axMoveContainerId is the constraining container. if empty, will be the document. // * axMovePadding is the padding in pixels which the element must be within the border of the container. // * axMoveRefreshInterval is the number of pixels that need to be moved before a refresh occurs function XMoverClass() { this.className = "XMoverClass"; this.defaultPadding = "10"; this.defaultRefreshInterval = 0; this.defaultCancelThreshhold = 100; // if the x,y diff from the last event is more than this value, action is cancelled this.defaultHideStatus = false; this.defaultCursorStyle = XBrowser.cursorMove; // control and elements this.controlEl = null; this.listener = null; this.documentState = null; this.containerEl = null; this.containerElState = null; this.containerElWidth = 0; this.containerElHeight = 0; this.containerElPosLeft = 0; this.containerElPosRight = 0; this.containerElPosTop = 0; this.containerElPosBottom = 0; this.targetEl = null; this.targetElId = ""; // the element that has the scrollbars this.scrollEl = null; this.scrollElId = ""; // control variables this.isWorking = false; this.isHideStatus = false; this.isWorkPending = false; this.isEndPending = false; this.minPadding = this.defaultPadding; this.cursorStyle = this.defaultCursorStyle; this.refreshInterval = this.defaultRefreshInterval; this.cancelThreshhold = this.defaultCancelThreshhold; this.lastX = 0; this.lastY = 0; this.currX = 0; this.currY = 0; this.minX = 0; this.minY = 0; this.maxX = 0; this.maxY = 0; this.minXX = 0; this.minYY = 0; this.maxXX = 0; this.maxYY = 0; this.startAction = function(poControlEl,poListener,poTargetElId) { try { this.isWorking = false; this.isWorkPending = false; this.isEndPending = false; this.controlEl = null; this.scrollEl = null; this.documentState = null; var oEl = poControlEl; if (!oEl) { oEl = XEvent.getSrcElement(); } if (!oEl) { return false; } // control settings this.controlEl = oEl; this.scrollElId = XString.evl(this.controlEl.getAttribute("axMoveScrollId"),""); this.isHideStatus = XBoolean.parse(XString.evl(this.controlEl.getAttribute("axMoveHideStatus"),this.defaultHideStatus)); this.minPadding = XString.evl(this.controlEl.getAttribute("axMovePadding"),this.defaultPadding)*1; this.cursorStyle = XString.evl(this.controlEl.getAttribute("axMoveCursor"),this.defaultCursorStyle); this.refreshInterval = XString.evl(this.controlEl.getAttribute("axMoveRefreshInterval"),this.defaultRefreshInterval); this.cancelThreshhold = XString.evl(this.controlEl.getAttribute("axMoveCancelThreshhold"),this.defaultCancelThreshhold); // listener this.listener = poListener; // scroll object this.scrollEl = document.getElementById(this.scrollElId); this.setScrollElement(this.scrollEl); // container object var contId = this.controlEl.getAttribute("axMoveContainerId"); if (XString.isNotEmpty(contId)) { this.containerEl = document.getElementById(contId); } if (!this.containerEl) { this.containerEl = document.body; } this.setContainer(this.containerEl); // target object this.targetElId = XString.evl(poTargetElId,""); this.targetEl = document.getElementById(this.targetElId); this.setTarget(this.targetEl); // coords var evt = event; // TODO: FIREFOX this.lastX = evt.x; // TODO: FIREFOX this.lastY = evt.y; // TODO: FIREFOX this.currX = evt.x; // TODO: FIREFOX this.currY = evt.y; // TODO: FIREFOX this.minXX = this.containerEl.style.pixelLeft - (-this.minPadding); this.minYY = this.containerEl.style.pixelTop - (-this.minPadding); this.maxXX = this.containerElWidth - this.minPadding; this.maxYY = this.containerElHeight - this.minPadding; this.minX = this.containerElPosLeft - (-this.minPadding); this.minY = this.containerElPosTop - (-this.minPadding); this.maxX = this.containerElPosLeft - (-this.maxXX); this.maxY = this.containerElPosTop - (-this.maxYY); // set the new container events on the container /* this.containerEl.onmousemove = XMover.performAction; this.containerEl.onmouseup = XMover.endAction; this.containerEl.onclick = XMover.endAction; this.containerEl.ondblclick = XMover.endAction; this.containerEl.style.cursor = this.cursorStyle; */ // set the new container events on the document this.documentState = new XHtmlState(document.body); this.documentState.captureState(true); document.body.onmousemove = XMover.performAction; document.body.onmouseup = XMover.endAction; document.body.onclick = XMover.endAction; document.body.ondblclick = XMover.endAction; document.body.onselectstart = XEvent.cancel; document.body.style.cursor = this.cursorStyle; if (this.listener) { this.listener.onMoveStart(XMover); } return XEvent.cancel(); } catch (e) { XError.display(this.className,e,"startAction"); return XEvent.cancel(); } }; this.setScrollElement = function(poEl) { try { this.scrollElId = ""; this.scrollEl = poEl; if (poEl) { this.scrollElId = poEl.id; } else { this.scrollEl = this.containerEl; } } catch (e) { XError.display(this.className,e,"setScrollElement"); return XEvent.cancel(); } }; this.setTarget = function(poEl) { try { this.targetElId = ""; this.targetEl = poEl; if (poEl) { this.targetElId = poEl.id; } } catch (e) { XError.display(this.className,e,"setTarget"); return XEvent.cancel(); } }; this.setContainer = function(poEl) { try { if (!poEl) { return; } this.containerEl = poEl; this.containerElState = new XHtmlState(this.containerEl); this.containerElState.captureState(true); // clientHeight and clientWidth ignore padding, margin, and scrollbars this.containerElWidth = this.containerEl.clientWidth*1; this.containerElHeight = this.containerEl.clientHeight*1; this.containerElPosLeft = XHtmlUtil.calcAbsoluteLeft(this.containerEl)*1; this.containerElPosRight = this.containerElPosLeft - (-this.containerElWidth); this.containerElPosTop = XHtmlUtil.calcAbsoluteTop(this.containerEl)*1; this.containerElPosBottom = this.containerElPosTop - (-this.containerElHeight); if (!this.scrollEl) { this.scrollEl = this.containerEl; } } catch (e) { XError.display(this.className,e,"setContainer"); return XEvent.cancel(); } }; // returns true if we are outside the container area this.moveObject = function(poTarget,pnDiffX,pnDiffY,pbAdjustScroll) { var adjusted = false; var oCont = XMover.containerEl; var oScroll = XMover.scrollEl; var oEl = poTarget; var diffx = pnDiffX*1; var diffy = pnDiffY*1; var w = XString.evl(oEl.style.pixelWidth,"0")*1; if (w <= 0) { w = oEl.offsetWidth; } var h = XString.evl(oEl.style.pixelHeight,"0")*1; if (h <= 0) { h = oEl.offsetHeight; } var xx = oEl.style.pixelLeft - (-diffx); var yy = oEl.style.pixelTop - (-diffy); var ww = xx - (-w); var hh = yy - (-h); if (xx < XMover.minXX) { xx = XMover.minXX; adjusted=true; } else { if (ww > XMover.maxXX) { xx = XMover.maxXX-w; adjusted=true; } } if (yy < XMover.minYY) { yy = XMover.minYY; adjusted=true; } else { if (hh > XMover.maxYY) { yy = XMover.maxYY-h; adjusted=true; } } oEl.style.pixelLeft = xx; oEl.style.pixelTop = yy; if (pbAdjustScroll) { // scrollLeft/scrollHeight is the number of pixels the scrollbar is shifted right or down respectively // clientWidth and clientHeight is the "visible" area of the object - minus borders, padding, and scrollbars if (xx < oScroll.scrollLeft) { oScroll.scrollLeft += xx - oScroll.scrollLeft; } else if (ww > oScroll.clientWidth) { oScroll.scrollLeft += ww - oScroll.clientWidth; } if (yy < oScroll.scrollTop) { oScroll.scrollTop += yy - oScroll.scrollTop; } else if (hh > oScroll.clientHeight) { oScroll.scrollTop += hh - oScroll.clientHeight; } } return new XPoint(xx,yy,outside); }; this.performAction = function() { // check exit conditions if (XMover.isWorking) { return XEvent.cancel(); } if (!XMover.controlEl) { XMover.endAction(); return XEvent.cancel(); } var evt = event; // TODO: FIREFOX if ((!evt) || (evt.button == "0")) { // TODO: constant XMover.endAction(); return XEvent.cancel(); } XMover.isWorking = true; XMover.isWorkPending = false; XMover.isEndPending = false; var checkPosition = true; var x = evt.x*1; var y = evt.y*1; var diffx = (x - XMover.lastX)*1; var diffy = (y - XMover.lastY)*1; XMover.currX = x; XMover.currY = y; if (!XMover.isHideStatus) { window.status = "(" + x + "," + y + ")"; //window.status += " dx=" + diffx + " dy=" + diffy + " ct=" + XMover.cancelThreshhold; } // check that we moved if ( (diffx == 0) && (diffy == 0) ) { XMover.isWorking = false; return XEvent.cancel(); } var absDiffx = Math.abs(diffx); var absDiffy = Math.abs(diffy); // check for interval if (XMover.refreshInterval > 0) { // see if we are under the throttle and j if ( (absDiffx < XMover.refreshInterval) && (absDiffy < XMover.refreshInterval) ) { XMover.isWorking = false; XMover.isWorkPending = true; return XEvent.cancel(); } } // check the cancel threshhold if (XMover.cancelThreshhold > 0) { // see if we are over the threshhold if ( (absDiffx > XMover.cancelThreshhold) || (absDiffy > XMover.cancelThreshhold) ) { XMover.endAction(); return XEvent.cancel(); } } var point = null; if (XMover.targetEl) { try { point = XMover.moveObject(XMover.targetEl,diffx,diffy,true); } catch (e) { } } if (true) { // check if we are outside the container if ( (XNumber.compare(x,XMover.containerElPosLeft) < 0) || (XNumber.compare(x,XMover.containerElPosRight) > 0) || (XNumber.compare(y,XMover.containerElPosTop) < 0) || (XNumber.compare(y,XMover.containerElPosBottom) > 0) ) { XMover.isEndPending = true; } } if (XMover.listener) { try { XMover.listener.onMoveExec(XMover); } catch (e) { } } XMover.lastX = x; XMover.lastY = y; XMover.isWorking = false; if (XMover.isEndPending ) { XMover.endAction(); return XEvent.cancel(); } return XEvent.cancel(); }; this.endAction = function() { XMover.isWorking = false; if (XMover.controlEl) { try { if (XMover.documentState) { XMover.documentState.restoreState(); } } catch (e) {} try { // restore the state if (XMover.containerElState) { XMover.containerElState.restoreState(); } } catch (e) {} try { if (XMover.listener) { XMover.listener.onMoveEnd(XMover); } } catch (e) {} } XMover.targetEl = null; XMover.controlEl = null; XMover.isWorking = false; XMover.isWorkPending = false; XMover.isEndPending = false; return XEvent.cancel(); }; return this; }; var XMover = new XMoverClass(); // * Eg: // // * The document elements with id = (axResizeEl and axResizeEl2) will get resized within axResizeContainerEl // * axResizeInvert="1" indicates the resize el is on the right or bottom // * axResizeContainerEl - if blank, will use the parent function XFrameResizerClass() { this.className = "XFrameResizerClass"; this.currSliderEl = null; this.currSlideVert = false; this.currResizeInvert = false; this.currParentEl = null; this.currResizeEl = null; this.currResizeEl2 = null; this.currResizeMin = 10; this.currResizeMax = 0; this.currResizeContainerEl = null; this.currContainerWidth = 0; this.currContainerHeight = 0; this.currWidth=0; this.currHeight=0; this.currPosX = 0; this.currPosY = 0; this.currStyleCursor = XBrowser.cursorResize; this.throttle = 20; this.inResizer = false; this.docStateMouseMove = null; this.docStateMouseUp = null; this.docStateSelectStart = null; this.docStateCursor = null; this.startResize = function(poEl) { try { var oEl = poEl; if (!oEl) { oEl = XEvent.getSrcElement(); } if (!oEl) { return false; } // get the slider properties this.inResizer = false; this.currSliderEl = oEl; this.currSlideVert = XBoolean.parse(oEl.getAttribute("axResizeVertical")); this.currResizeInvert = XBoolean.parse(oEl.getAttribute("axResizeInvert")); this.currResizeMin = XString.evl(oEl.getAttribute("axResizeMin"),"1")*1; this.currResizeMax = XString.evl(oEl.getAttribute("axResizeMax"),"0")*1; this.currResizeEl = document.getElementById(oEl.getAttribute("axResizeEl")); this.currResizeEl2 = document.getElementById(oEl.getAttribute("axResizeEl2")); this.currStyleCursor = XString.evl(oEl.getAttribute("axResizeCursor"),XBrowser.cursorResize); var contId = oEl.getAttribute("axResizeContainerEl"); if (XString.isNotEmpty(contId)) { this.currResizeContainerEl = document.getElementById(contId); } if (!this.currResizeContainerEl) { this.currResizeContainerEl = document.body; } this.currContainerWidth = this.currResizeContainerEl.clientWidth; this.currContainerHeight = this.currResizeContainerEl.clientHeight; if (XString.isEmpty(this.currStyleCursor)) { if (this.currSlideVert) { this.currStyleCursor = XBrowser.cursorResizeVertical; } else { this.currStyleCursor = XBrowser.cursorResizeHorizontal; } } var evt = event; // TODO: FIREFOX this.currPosX = evt.x; // TODO: FIREFOX this.currPosY = evt.y; // TODO: FIREFOX this.currWidth = this.currResizeEl.offsetWidth; this.currHeight = this.currResizeEl.offsetHeight; // save the document state this.docStateMouseMove = document.onmousemove; this.docStateMouseUp = document.onmouseup; this.docStateSelectStart = document.onselectstart; this.docStateCursor = document.body.style.cursor; // start the resize document.onmouseup = XFrameResizer.endResize; document.onmousemove = XFrameResizer.resize; document.onselectstart = null; document.onclick = XFrameResizer.endResize; document.body.style.cursor = this.currStyleCursor; } catch (e) { XError.display(this.className,e,"startResize"); } }; this.resize = function() { var evt = event; // TODO: FIREFOX evt.cancelBubble=true; var bend = false; XFrameResizer.inResize = true; if (!window.event) { XFrameResizer.endResize(); return; } var x = evt.x*1; var y = evt.y*1; try { if (evt.button == "0") { // TODO: constant XFrameResizer.endResize(); return; } var diff = 0; var size = 0; var start = 0; var throttle = XFrameResizer.throttle; //var parentEl = document.body; if (!XFrameResizer.currSlideVert) { start = XFrameResizer.currWidth; if (XFrameResizer.currResizeInvert) { diff = (XFrameResizer.currPosX - x)*1; } else { diff = (x - XFrameResizer.currPosX)*1; } if (diff == 0 ) { return; } if ( (diff > 0) && (diff > throttle) ) { return;} if ( (diff < 0) && (diff < (-throttle)) ) { return;} size = XFrameResizer.currWidth - (-diff); if (size < XFrameResizer.currResizeMin) { size = XFrameResizer.currResizeMin; bend = true; } if ( (size > XFrameResizer.currResizeMax) && (XFrameResizer.currResizeMax > 0) ){ size = XFrameResizer.currResizeMax; bend = true; } // make sure the size < the body size if ( size >= XFrameResizer.currContainerWidth) { size = offset; bend = true; } XFrameResizer.currResizeEl.style.width = size; XFrameResizer.currWidth = size; if (XFrameResizer.currResizeEl2) { XFrameResizer.currResizeEl2.style.width = size; } } else { start = XFrameResizer.currHeight; if (XFrameResizer.currResizeInvert) { diff = (XFrameResizer.currPosY - y)*1; } else { diff = (y - XFrameResizer.currPosY)*1; } if (diff == 0 ) { return; } if ( (diff > 0) && (diff > throttle) ) { return;} if ( (diff < 0) && (diff < (-throttle)) ) { return;} size = XFrameResizer.currHeight - (-diff); if (size < XFrameResizer.currResizeMin) { size = XFrameResizer.currResizeMin; bend = true; } if ( (size > XFrameResizer.currResizeMax) && (XFrameResizer.currResizeMax > 0) ){ size = XFrameResizer.currResizeMax; bend = true; } // make sure the size < the body size if ( size >= XFrameResizer.currContainerHeight) { size = offset; bend = true; } XFrameResizer.currResizeEl.style.height = size; XFrameResizer.currHeight = size; if (XFrameResizer.currResizeEl2) { XFrameResizer.currResizeEl2.style.height = size; } } } catch (e) { } XFrameResizer.currPosX = x; XFrameResizer.currPosY = y; if (bend) { XFrameResizer.endResize(); return; } XFrameResizer.inResize = false; }; this.endResize = function() { document.body.style.cursor = XFrameResizer.docStateCursor; document.onmousemove = XFrameResizer.docStateMouseMove; document.onmouseup = XFrameResizer.docStateMouseUp; document.onselectstart = XFrameResizer.docStateSelectStart; XFrameResizer.inResize = false; }; return this; }; var XFrameResizer = new XFrameResizerClass(); //------------------------------------ // ESCAPE //------------------------------------ function XEscapeClass() { this.className = "XEscapeClass"; this.escapeXmlValue = function(psValue) { var val = psValue + ""; val = XString.replaceAll(val,"&","&"); val = XString.replaceAll(val,"<","<"); val = XString.replaceAll(val,">",">"); val = XString.replaceAll(val,'"',"""); val = XString.replaceAll(val,"'","'"); val = XString.replaceAll(val, String.fromCharCode(13)," "); val = XString.replaceAll(val, String.fromCharCode(10)," "); return val; }; this.unescapeXmlValue = function(psValue) { var val = psValue + ""; val = XString.replaceAll(val,"<","<"); val = XString.replaceAll(val,">",">"); val = XString.replaceAll(val,""",'"'); val = XString.replaceAll(val,"'","'"); val = XString.replaceAll(val,"'","'"); val = XString.replaceAll(val," ", String.fromCharCode(13)); val = XString.replaceAll(val,"&xd;", String.fromCharCode(13)); val = XString.replaceAll(val," ", String.fromCharCode(10)); val = XString.replaceAll(val,"&xa;", String.fromCharCode(10)); val = XString.replaceAll(val,"&","&"); return val; }; this.escapeHtmlValue = function(psValue) { var val = psValue + ""; val = XString.replaceAll(val,"&","&"); val = XString.replaceAll(val,'"',"""); val = XString.replaceAll(val,"'","'"); val = XString.replaceAll(val,"<","<"); val = XString.replaceAll(val,">",">"); return val; }; this.unescapeHtmlValue = function(psValue) { var val = psValue + ""; val = XString.replaceAll(val,"<","<"); val = XString.replaceAll(val,">",">"); val = XString.replaceAll(val,""",'"'); val = XString.replaceAll(val,"'","'"); val = XString.replaceAll(val,"'","'"); val = XString.replaceAll(val,"&","&"); return val; }; this.htmlToText = function(psValue) { var val = psValue + ""; val = XString.replaceAll(val,"<","<"); val = XString.replaceAll(val,">",">"); val = XString.replaceAll(val,""",'"'); val = XString.replaceAll(val,"'","'"); val = XString.replaceAll(val,"'","'"); val = XString.replaceAll(val," "," "); // replace the Euro Char //val = XString.replaceAll(val,String.fromCharCode(8364),String.fromCharCode(128)); val = XString.replaceAll(val,"&","&"); return val; }; this.textToHtml = function(psValue,pbPreserveLines) { var val = psValue + ""; val = XString.replaceAll(val,"&","&"); val = XString.replaceAll(val,"<","<"); val = XString.replaceAll(val,">",">"); val = XString.replaceAll(val,'"',"""); val = XString.replaceAll(val," "," "); if (XBoolean.parse(pbPreserveLines)) { val = XString.replaceAll(val,XString.CRLF,"
"); val = XString.replaceAll(val,XString.CR,"
"); val = XString.replaceAll(val,XString.LF,"
"); } // replace the Euro Char //val = XString.replaceAll(val,String.fromCharCode(8364),String.fromCharCode(128)); val = XString.replaceAll(val,"'","'"); return val; }; this.getElementValueAsXml = function(psElementId) { var oEl = document.getElementById(psElementId); if (oEl) { return this.escapeXmlValue(oEl.value); } else { return ""; } }; return this; }; var XEscape = new XEscapeClass(); //------------------------------------ // ESCAPE //------------------------------------ function XmlUtilClass() { this.className = "XmlUtilClass"; this.getXmlValueSafe = function(psElementId) { var oEl = document.getElementById(psElementId); if (oEl) { if (XHtmlUtil.isElementCheckbox(oEl)) { return oEl.checked? oEl.value : ""; } else { return XEscape.escapeXmlValue(oEl.value); } } else { return ""; } }; return this; }; var XmlUtil = new XmlUtilClass(); //------------------------------------ // CUSTOM CONTEXTMENU //------------------------------------ function XContextMenuClass() { this.className = "XContextMenuClass"; this.menus = new Array(); this.clear = function() { var oEl; for ( var i=0; i 0 ) { c = this.div.children[0]; r = c.cloneNode(); c.removeNode(true); return r; } return null; }; this.peek = function() { if ( this.length() > 0 ) { return this.div.children[0]; } return null; }; this.seek = function(pnValue) { if ( this.length() >= pnValue-1 ) { return this.div.children[pnValue]; } return null; }; // work off the bottom of the stack this.append = function() { var oEl = this.createElement(); this.div.insertAdjacentElement("BeforeEnd",oEl); return oEl; }; this.drop = function() { var c, r; if ( this.length() > 0 ) { c = this.div.children[this.length()-1]; r = c.cloneNode(); c.removeNode(true); return r; } return null; }; this.poke = function() { if ( this.length() > 0 ) { return this.div.children[this.length()-1]; } return null; }; // work anywhere in the stack this.insert = function(pnIndex) { var oEl = this.createElement(); if ( this.div.children.length <= pnIndex ) { this.div.children[this.div.children.length-1].insertAdjacentElement("beforeBegin",oEl); } else { this.div.children[pnIndex].insertAdjacentElement("beforeBegin",oEl); } return oEl; }; this.remove = function(pnIndex) { if ( !pnIndex || pnIndex > this.length() ) { return; } this.div.children[pnIndex].removeNode(true); }; this.removeById = function(psId) { var oColl = this.div.children; var c; for ( var i=0; i= tmp.length() ) { break; } } xsTmpEl = tmp.insert(count); xsTmpEl.setAttribute(psSortAttribute,pos); xsTmpEl.setAttribute("axid",xsEl.getAttribute("axid")); } else { // add to end count = tmp.length()-1; if ( pos >= (tmp.seek(count).getAttribute(psSortAttribute)*1) ) { xsTmpEl = tmp.append(); } else { while ( (tmp.seek(count).getAttribute(psSortAttribute)*1) < pos) { count--; if ( count < 0 ) { break; } } xsTmpEl = tmp.insert(count); } xsTmpEl.setAttribute(psSortAttribute,pos); xsTmpEl.setAttribute("axid",xsEl.getAttribute("axid")); } last = pos; } return tmp; } catch(e) { XError.display(this.className,e,"sort"); throw e; } }; return this; }; var XsArrayUtil = new XsArrayUtilClass(); //------------------------------- // CHANGE CONTROL //------------------------------- function XChangeClass () { this.changed = false; var mbIsReload = false; this.logChange = function(pbIsReload) { this.changed = true; if (pbIsReload) { mbIsReload = true; } }; this.setReload = function(pbIsReload) { mbIsReload = XBoolean.parse(pbIsReload); }; this.getReload = function() { return mbIsReload; }; this.hasChanges = function() { return this.changed; }; this.resetChanges = function() { this.changed = false; mbIsReload = false; }; this.checkChanges = function(psConfirmMsg) { var sMsg = XString.evl(psConfirmMsg,"stdMsgCancelChangesConfirm"); if (this.hasChanges()) { if (!XString.isTrue(XWindow.confirm(sMsg))) { return false; } } return true; }; return this; }; var XChange = new XChangeClass(); //------------------------------- // XWebService Utilities //------------------------------- function XEWSClass() { this.resultNodeId = XConfig.webserviceResultNodeId; this.resultAttributeValue = "value"; this.resultAttributeCode = "code"; this.resultAttributeInfo = "info"; this.resultNodeNameExtInfo = "extendedInfo"; this.resultNodeNameData = "data"; this.resultNodeNameMessages = "messages"; this.resultNodeNameDebug = "debug"; this.resultCodeSuccess = "0"; } var XEWS = new XEWSClass(); function XWSResult(poResultNode) { this.className = "XWSResult"; var mResultNode = poResultNode; this.getResultEl = function() { return mResultNode; }; this.getResultElHtml = function() { return mResultNode.outerHTML; }; this.getAttributeValue = function(psName) { return XString.evl(mResultNode.getAttribute(psName),""); }; this.getChildNode = function(psName) { try { var els = mResultNode.children; if (els) { var len = els.length; var el = null; for (var i=0; i 0) { for (var i=0; i this.xarray.lastPos) { return false; } // iterate if the object is null if (!this.xarray.entries[this.xarrayPos]) { return this.next(); } this.currentIndex++; this.currentObject = this.xarray.entries[this.xarrayPos]; return true; }; return this; }; function XDictionaryEnumReverse (pxArray) { this.xarray = pxArray; this.xarrayPos = this.xarray.lastPos-(-1); this.currentIndex = this.xarray.length; this.currentObject = null; this.next = function() { this.xarrayPos--; if (this.xarrayPos < 0) { return false; } // iterate if the object is null if (!this.xarray.entries[this.xarrayPos]) { return this.next(); } this.currentIndex--; this.currentObject = this.xarray.entries[this.xarrayPos]; return true; }; return this; }; //------------------------------- // X ARRAY //------------------------------- function XArray (pnSize) { this.className = "XArray"; this.objects = null; this.length = 0; this.lastPos = -1; this.maxPos = -1; this.initSize = pnSize; if (XString.isNotEmpty(this.initSize)) { this.objects = new Array(this.initSize); } else { this.objects = new Array(25); }; this.push = function(poObject) { try { this.lastPos++; this.objects[this.lastPos] = poObject; this.length++; poObject.setAttribute("xArrayPos",this.lastPos); if (this.lastPos > this.maxPos) { this.maxPos = this.lastPos; } } catch (e) { XError.display(this.className,e,"push"); throw e; } }; this.pop = function() { try { if (this.length <= 0) { return null; } var obj = this.objects[this.lastPos]; this.length--; this.lastPos--; if (!obj) { return this.pop(); } if (obj) { obj.setAttribute("xArrayPos",-1); } return obj; } catch (e) { XError.display(this.className,e,"pop"); throw e; } }; this.indexOf = function(poObject) { try { var pos = -1; var ap = poObject.getAttribute("xArrayPos"); if (ap) { pos = ap*1; } if (pos >= 0) { return pos; } // brute force it var obj = null; for (var i=0; i<=this.lastPos; i++) { obj = this.objects[i]; if (obj == poObject) { return i; } } return -1; } catch (e) { XError.display(this.className,e,"indexOf"); throw e; } }; this.remove = function(poObject) { try { if (!poObject) { return; } var pos = this.indexOf(poObject); if (pos >= 0) { poObject.setAttribute("xArrayPos",-1); this.objects[pos] = null; this.length--; if (pos == this.lastPos) { this.lastPos--; } } } catch (e) { XError.display(this.className,e,"remove"); throw e; } } ; this.clear = function() { this.length = 0; this.lastPos = -1; }; this.getEnumerator = function(pbReverse) { if (XString.isTrue(pbReverse)) { return new XArrayEnumReverse(this); } else { return new XArrayEnum(this); } }; this.sort = function(pFunction) { // sort and fix the array if ( (this.lastPos == this.length-1) && (this.lastPos >= this.maxPos) ) { this.objects.sort(pFunction); } else { var xar = this.copy(); xar.objects.sort(pFunction); this.objects = xar.objects; this.length = xar.length; this.lastPos = xar.lastPos; } }; this.copy = function() { var objs = new XArray(this.length); var obj = null; for (i=0; i<=this.lastPos; i++) { obj = this.objects[i]; if (obj) { objs.push(obj); } } return objs; }; this.printObjects = function() { var rslt = ""; var obj = null; for (var i=0; i moArray.lastPos) { return false; } // iterate if the object is null var obj = moArray.objects[mnPos]; if (!obj) { return this.next(); } this.currentIndex++; this.currentObject = obj; return true; }; return this; }; function XArrayEnumReverse (poArray) { var moArray = poArray; var mnPos = moArray.lastPos-(-1); this.currentIndex = moArray.length; this.currentObject = null; this.next = function() { mnPos--; if (mnPos < 0) { return false; } // iterate if the object is null var obj = moArray.objects[mnPos]; if (!obj) { return this.next(); } this.currentIndex--; this.currentObject = obj; return true; }; return this; }; //------------------------------- // Standard Array Sort Methods //------------------------------- function fnCompareNumeric(pnVal1,pnVal2) { var val1 = pnVal1*1; var val2 = pnVal2*1; if (val1 axDeleteField stores the name of the field of the delete flag Eg: axDeleteTable stores the name of the table of the deleted items Eg: axItemIdField stores the name of the field of the id related to the record - if this is empty then the item is new and when deleted will not be moved to the axDeleteTable Eg: The two axDeleteField and axDeleteTable need to be created in the create row script Eg. var ins = document.createElement(""); cell.appendChild(ins); var ins = document.createElement(""); cell.appendChild(ins); * selectDeselectRows selects or deselects the first col checkboxes in all of the rows * resetRowClass resets the rows to the on/off class view - this is on the TR * saveCheckBoxes saves the checkbox checked states in the row before moving that row - needs a dictionary object initalized and passed to it * outputCheckBoxes resets the checkbox states to their original state before the move - needs the original dictionary object passed * moveRowUp moves the row clicked up one row * moveRowDown moves the row clicked down one row * deleteRow deletes a row and either saves that deleted row in axDeleteTable and changes the axDeleteField to true or deletes the clicked row * getSelectedRows returns the selected rows in the table as an array of obects - needs a table element passed to it * moveSelectedRowsUp moves all the selected rows in the table up one row * moveSelectedRowsDown moves all the selected rows in the table down one row * deleteSelectedRows either deletes all the selected rows in the table or moves them to the axDeleteTable and changes the axDeleteField to true */ this.className = "XTableClass"; this.rowCSSClassAbr = "CRow"; this.findTableEl = function(poEl) { try { var el = poEl; if (!el) { el = XEvent.getSrcElement(); } if (!el) { return null; } return XHtmlUtil.getParentElementByTag(el, "TABLE",true); } catch (e) { XError.display(this.className,e,"findTableEl"); throw e; } }; this.findTableElByEvent = function(poEvent) { try { var el = XEvent.getSrcElement(poEvent); if (!el) { return null; } return XHtmlUtil.getParentElementByTag(el, "TABLE",true); } catch (e) { XError.display(this.className,e,"findTableElByEvent"); throw e; } }; this.findTableRowEl = function(poEl) { try { var el = poEl; if (!el) { el = XEvent.getSrcElement(); } if (!el) { return null; } return XHtmlUtil.getParentElementByTag(el, "TR",true); } catch (e) { XError.display(this.className,e,"findTableRowEl"); throw e; } }; this.findTableCellEl = function(poEl) { try { var el = poEl; if (!el) { el = XEvent.getSrcElement(); } if (!el) { return null; } return XHtmlUtil.getParentElementByTag(el, "TD",true); } catch (e) { XError.display(this.className,e,"findTableCellEl"); throw e; } }; this.findTableRowElByEvent = function(poEvent) { try { var el = XEvent.getSrcElement(poEvent); if (!el) { return null; } return XHtmlUtil.getParentElementByTag(el, "TR",true); } catch (e) { XError.display(this.className,e,"findTableRowElByEvent"); throw e; } }; this.selectDeselectRows = function(poEl) { try { var src = poEl; if (!src) { src = XEvent.getSrcElement(); } var table = this.findTableEl(src); var rows = table.rows; var val = src.checked?true:false; for ( var i=0; i 1) { if (!cbs) { cbs = new XDictionary(row.cells.length); } this.saveCheckBoxes(cbs, row); table.moveRow(row.rowIndex, row.rowIndex-1); this.outputCheckBoxes(cbs); // NOTE: this assumes that the src element is not a ROW CELL! src.parentElement.outerHTML = src.parentElement.outerHTML; } } catch (e) { XError.display(this.className,e,"moveRowUp"); throw e; } this.resetRowClass(src); }; this.moveRowDown = function(poEl) { var src = poEl; try { var nRow = null; var cbs = null; if (!src) { src = XEvent.getSrcElement(); } var row = this.findTableRowEl(src); var table = this.findTableEl(row); if ( row.rowIndex < (table.rows.length-1) ) { if (!cbs) { cbs = new XDictionary(row.cells.length); } this.saveCheckBoxes(cbs, row); table.moveRow(row.rowIndex, row.rowIndex-(-1)); this.outputCheckBoxes(cbs); // NOTE: this assumes that the src element is not a ROW CELL! src.parentElement.outerHTML = src.parentElement.outerHTML; } } catch (e) { XError.display(this.className,e,"fnMoveRowDown"); throw e; } this.resetRowClass(src); }; this.deleteRow = function(poRow) { var table = null; try { var row = this.findTableRowEl(poRow); table = this.findTableEl(row); var idEl = null; var deleteEl = null; var deleteTable = null; var done = false; var itemIdField = ""; var deleteFieldId = ""; var deleteTableId = ""; itemIdField = table.getAttribute("axItemIdField"); deleteFieldId = table.getAttribute("axDeleteField"); deleteTableId = table.getAttribute("axDeleteTable"); if (XString.isNotEmpty(itemIdField)) { // - find the axItemIdField Row idEl = XHtmlUtil.getChildInputByName(row, itemIdField); if (idEl) { if (XString.isEmpty(idEl.value)) { row.removeNode(true); done = true; } } } if (!done) { // handle the delete logic if the delete field or table exists if ( (XString.isNotEmpty(deleteFieldId)) || (XString.isNotEmpty(deleteTableId)) ) { deleteEl = XHtmlUtil.getChildInputByName(row, deleteFieldId); deleteTable = table.axDeleteTableEl; if (!deleteTable) { deleteTable = document.getElementById(deleteTableId); table.axDeleteTableEl = deleteTable; } if (!deleteEl) { XWindow.alert("stdMsgHtmlXTableErrorMissingDeleteEls"); throw XError.createError("table: " + table.id + ".axDeleteField"); } if (!deleteTable) { XWindow.alert("stdMsgHtmlXTableErrorMissingDeleteEls"); throw XError.createError("table: " + table.id + ".axDeleteTable"); } deleteEl.value = XBoolean.trueIndicator; XHtmlUtil.addRowToTable(deleteTable,row); done = true; } } if (!done) { row.removeNode(true); } } catch(e) { XError.display(this.className,e,"deleteRow"); throw e; } this.resetRowClass(table); }; this.getSelectedRows = function(poEl) { try { // pass this function the table object and it will return the selected row objects var table = this.findTableEl(poEl); var rows = table.rows; var row = null; var selRows = new Array(table.rows.length-1); var cnt = 0; for (var i = 1 - (-0); i < rows.length; i++) { row = rows[i]; cb = row.cells[0].firstChild; if (XString.isTrue(cb.checked)) { selRows[cnt] = row; cnt++; } } selRows.length = cnt; return selRows; } catch (e) { XError.display(this.className,e,"getSelectedRows"); throw e; } }; this.moveSelectedRowsUp = function(poEl) { var src = poEl; try { if (!src) { src = XEvent.getSrcElement(); } var table = this.findTableEl(src); var rows = table.rows; var row = null; var cb = null; var cbs = null; for (var i = (1 - (-1)); i < rows.length; i++) { row = rows[i]; if (!cbs) { cbs = new XDictionary(row.cells.length); } cb = row.cells[0].firstChild; if (cb.checked == true) { this.saveCheckBoxes(cbs, row); table.moveRow(i, i-1); this.outputCheckBoxes(cbs); } } } catch (e) { XError.display(this.className,e,"moveSelectedRowsUp"); //throw e; } this.resetRowClass(src); }; this.moveSelectedRowsDown = function(poEl) { var src = poEl; try { if (!src) { src = XEvent.getSrcElement(); } var table = this.findTableEl(src); var rows = table.rows; var row = null; var cb = null; var cbs = null; var dictEntry = null; var inputs = null; var input = null; for (var i = rows.length - 2; i >= 1 ; i--) { row = rows[i]; cb = row.cells[0].firstChild; if (!cbs) { cbs = new XDictionary(row.cells.length); } if (cb.checked == true) { this.saveCheckBoxes(cbs, row); table.moveRow(i, i+1); this.outputCheckBoxes(cbs); } } } catch (e) { XError.display(this.className,e,"moveSelectedRowsDown"); //throw e; } this.resetRowClass(src); }; this.deleteSelectedRows = function(poEl) { var table = null; try { table = this.findTableEl(poEl); var rows = table.rows; var row = null; var oElChecked = null; for ( var i=rows.length-1; i>0; i-- ) { row = rows[i]; oElChecked = row.children[0].children[0].checked; if (XString.isTrue(oElChecked) ) { this.deleteRow(row); } } this.selectDeselectRows(); } catch (e) { XError.display(this.className, e, "deleteSelectedRows"); //throw e; } this.resetRowClass(table); }; return this; }; var XTable = new XTableClass(); function XCheckboxClass() { this.className = "XCheckboxClass"; this.getCheckedByInputId = function(poInputId) { try { var el = xfGet(poInputId + "_CB"); if (el) { return el.checked; } return false; } catch (e) { XError.display(this.className, e, "getCheckedByInputId"); throw e; } }; this.getCheckedByInput = function(poInputEl) { try { if (poInputEl) { return this.getCheckedByInputId(poInputEl.id); } return false; } catch (e) { XError.display(this.className, e, "getCheckedByInput"); throw e; } }; this.getCheckboxFromInputId = function(poInputId) { try { return xfGet(poInputId + "_CB"); } catch (e) { XError.display(this.className, e, "getCheckboxFromInputId"); throw e; } }; this.getCheckboxFromInput = function(poInputEl) { try { if (poInputEl) { return document.getElementById(poInputEl.id + "_CB"); } return null; } catch (e) { XError.display(this.className, e, "getCheckboxFromInput"); throw e; } }; this.getInputFromCheckbox = function(poCheckboxEl) { try { if (poCheckboxEl) { return document.getElementById(poCheckboxEl.getAttribute("axid")); } return null; } catch (e) { XError.display(this.className, e, "getCheckboxFromInput"); throw e; } }; this.setCheckedByInput = function(poInputEl,pbChecked) { try { var input = poInputEl; if (!input) { return; } var checked = XBoolean.parse(pbChecked); var cb = this.getCheckboxFromInput(input); // set the checkbox cb.checked = checked; // set the input if (cb.checked) { input.value = cb.value; } else { input.value = XString.evl(cb.getAttribute("valueoff"),""); } } catch (e) { XError.display(this.className, e, "setCheckedByInput"); throw e; } }; this.setCheckedByCheckbox = function(poCheckboxEl,pbChecked) { try { var cb = poCheckboxEl; if (!cb) { return; } // get the input name of the id cb.checked = XBoolean.parse(pbChecked); var input = this.getInputFromCheckbox(cb); if (cb.checked) { input.value = cb.value; } else { input.value = XString.evl(cb.getAttribute("valueoff"),""); } } catch (e) { XError.display(this.className, e, "setCheckedByCheckbox"); throw e; } }; this.onClick = function(poEl) { var oEl = poEl; try { if (!oEl) { oEl = XEvent.getSrcElement(); } if (!oEl) { return; } this.setCheckedByCheckbox(oEl,oEl.checked); } catch (e) { XError.display(this.className, e, "onClick"); } }; this.toggleChildCheckbox = function(poEl) { try { if (poEl) { // find the first child checkbox var cb = XHtmlUtil.getChildInputByType(poEl,"checkbox"); if (cb) { // toggle the checkbox setting this.setCheckedByCheckbox(cb,!cb.checked); } } return XEvent.cancelBubble(); } catch (e) { XError.display(this.className, e, "toggleChildCheckbox"); } }; this.toggleTableCellXCheckboxes = function(poCell) { try { var src = XTable.findTableCellEl(poCell); if (src) { var idx = src.cellIndex; var table = XTable.findTableEl(src); if (table) { var rows = table.rows; var cell = null; var cb = null; var checked = false; var found = false; // assume a header row for (i=1; i this.listId = psListId; this.listEl = null; this.cssRowActive; this.cssRowSel; this.cssRowUnsel; this.cssRowMouseOver; this.stickySelectInd = pbStickySelect; this.isStickySelect = false; var mAttrSel = "axXListSel"; this.initialize = function() { try { this.listEl = document.getElementById(this.listId); if (XString.isNotEmpty(this.clientListenerName)) { this.clientListener = eval(this.clientListenerName); } this.isStickySelect = XBoolean.parse(pbStickySelect); this.cssRowActive = this.listEl.getAttribute("axCssRowActive"); this.cssRowSel = this.listEl.getAttribute("axCssRowSel"); this.cssRowUnsel = this.listEl.getAttribute("axCssRowUnsel"); this.cssRowMouseOver = this.listEl.getAttribute("axCssMouseOver"); this.setExclusions(); this.activateFirstSelected(); } catch (e) { XError.display(this.className,e,"initialize"); throw e; } }; // activates the first row with axSelected = 1 this.activateFirstSelected = function() { try { var oEl = this.listEl.children; if (oEl) { var row = null for (var i=0; i that represents the rowId this.getRowByInputValue = function(psInputName, psId) { try { if (XString.isEmpty(psInputName)) { return null; } var rows = this.listEl.children; var row = null; var el = null; for (var i=0; i pos1) { oEl = poStartEl.nextSibling; oElEnd = poEndEl; } else { oEl = poEndEl; oElEnd = poStartEl.previousSibling; } while (oEl) { if (this.isRowEnabled(oEl)) { this.selectRow(oEl,pbFireEvent); } if (oEl == oElEnd) { oEl = null; } else { oEl = oEl.nextSibling } } } catch (e) { XError.display(this.className,e,"selectRowRange"); throw e; } }; this.unselectRow = function(poRow,pbFireEvent) { try { if (!poRow) { return; } poRow.className = this.cssRowUnsel; poRow.setAttribute(mAttrSel,XBoolean.falseIndicator); if (this.activeRow == poRow) { this.activeRow = null; } if (pbFireEvent && this.clientListener && this.clientListener.onRowUnselect) { this.clientListener.onRowUnselect(poRow); } } catch (e) { XError.display(this.className,e,"unselectRow"); throw e; } }; this.selectAll = function(pbFireEvent) { try { var rows = this.listEl.children; for (var i=0; i parentChildren.length if (poIndex > childrenLength) { parentoEl.appendChild(childrenLength+1); return; } //pnIndex < parentChildren.length var current = poRow; var old = null; for (var i=0; i < parentChildren.length; i++){ if (i >= poIndex) { old = parentChildren[i]; parentChildren[i] = current; } current = old; } if (pbFireEvent && this.clientListener && this.clientListener.onRowAdd) { this.clientListener.onRowAdd(poRow); } } catch (e) { XError.display(this.className,e,"addRow"); throw e; } }; this.toggleRowSelect = function(poRow,pbFireEvent) { try { if (!poRow) { return; } if (this.isRowSelected(poRow)) { this.unselectRow(poRow,pbFireEvent); } else { this.selectRow(poRow,pbFireEvent); } } catch (e) { XError.display(this.className,e,"toggleRowSelect"); throw e; } }; // Event Listeners this.getParentRow = function(poEl) { try { var oEl = poEl? poEl : XEvent.getSrcElement(); if (!oEl) { return null; } // traverse up until the element is a direct child of the listEl while (oEl.parentElement) { if (oEl.parentElement == this.listEl) { return oEl; } oEl = oEl.parentElement; } return null; } catch (e) { XError.display(this.className,e,"getEventRow"); throw e; } }; this.onMouseOver = function(poRow) { try { var oEl = this.getParentRow(poRow); if ( (!oEl)|| (oEl.className.indexOf(this.cssRowSel) >= 0 ) ) { return XEvent.cancel(); } if (this.activeRow != oEl) { oEl.className = this.cssRowMouseOver; } return XEvent.cancel(); } catch (e) { XError.display(this.className,e,"onMouseOver"); } }; this.onMouseOut = function(poRow) { try { var oEl = this.getParentRow(poRow); if (!oEl) { return XEvent.cancel(); } //oEl.className = oEl.className.replace(" " + this.cssRowMouseOver,""); if (!this.isRowSelected(oEl)) { if (this.activeRow == oEl) { oEl.className = this.cssRowActive; } else { oEl.className = this.cssRowUnsel; } } return XEvent.cancel(); } catch (e) { XError.display(this.className,e,"onMouseOut"); } }; this.onClick = function(poRow,pbBubbleEvent) { try { var oEvent = event; // TODO: FIREFOX var bubble = XBoolean.parse(pbBubbleEvent); var oEl = this.getParentRow(poRow); if (!oEl) { return bubble? true : XEvent.cancel(); } if (XEvent.isCtrlKey(oEvent)) { this.toggleRowSelect(oEl,true); return bubble? true : XEvent.cancel(oEvent); } if (XEvent.isShiftKey(oEvent)) { this.selectRowRange(this.activeRow,oEl,true); return bubble? true : XEvent.cancel(oEvent); } if (this.isStickySelect) { this.toggleRowSelect(oEl,true); } else { this.activateRow(oEl,true); } return bubble? true : XEvent.cancel(oEvent); } catch (e) { XError.display(this.className,e,"onClick"); } }; this.onDblClick = function(poRow) { try { var oEl = this.getParentRow(poRow); if (oEl) { if (this.clientListener && this.clientListener.onDblClick) { this.clientListener.onDblClick(oEl); } } return XEvent.cancel(); } catch (e) { XError.display(this.className,e,"onDblClick"); } }; return this; } //--------------- //-- Grouped List Controller //-- Required Attributes:.axCssRowActive; // axCssRowSel; // axCssRowUnsel; // axCssMouseOver; //-- Events Fired: // onRowEnable // onRowDisable // onRowActivate // onRowSelect // onRowUnselect // onRowRemove // onRowAdd // onDblClick //----------------------- function XListGroupedController(psObjectName,psListId,psClientListenerName,pbStickySelect) { this.className = "XListGroupedController"; this.objectName = psObjectName; this.clientListenerName = psClientListenerName; this.clientListener = null; // ID of the outer html element around the list rows. Usually a
this.listId = psListId; this.listEl = null; this.cssRowActive; this.cssRowSel; this.cssRowUnsel; this.cssRowMouseOver; this.stickySelectInd = pbStickySelect; this.isStickySelect = false; var mAttrSel = "axXListSel"; this.initialize = function() { try { this.listEl = document.getElementById(this.listId); if (XString.isNotEmpty(this.clientListenerName)) { this.clientListener = eval(this.clientListenerName); } this.isStickySelect = XBoolean.parse(pbStickySelect); this.cssRowActive = this.listEl.getAttribute("axCssRowActive"); this.cssRowSel = this.listEl.getAttribute("axCssRowSel"); this.cssRowUnsel = this.listEl.getAttribute("axCssRowUnsel"); this.cssRowMouseOver = this.listEl.getAttribute("axCssMouseOver"); this.setExclusions(); } catch (e) { XError.display(this.className,e,"initialize"); throw e; } }; this.setExclusions = function() { try { var oEl = this.listEl.children; if (oEl) { var row = null for (var i=0; i that represents the rowId this.getRowByInputValue = function(psInputName, psId) { try { if (XString.isEmpty(psInputName)) { return null; } var rows = this.listEl.children; var row = null; var el = null; for (var i=0; i pos1) { oEl = poStartEl.nextSibling; oElEnd = poEndEl; } else { oEl = poEndEl; oElEnd = poStartEl.previousSibling; } while (oEl) { if (this.isRowEnabled(oEl)) { this.selectRow(oEl,pbFireEvent); } if (oEl == oElEnd) { oEl = null; } else { oEl = oEl.nextSibling } } } catch (e) { XError.display(this.className,e,"selectRowRange"); throw e; } }; this.unselectRow = function(poRow,pbFireEvent) { try { if (!poRow) { return; } if ( poRow.getAttribute("axtype") == "group" ) { return; } poRow.className = this.cssRowUnsel; poRow.setAttribute(mAttrSel,XBoolean.falseIndicator); if (this.activeRow == poRow) { this.activeRow = null; } if (pbFireEvent && this.clientListener && this.clientListener.onRowUnselect) { this.clientListener.onRowUnselect(poRow); } } catch (e) { XError.display(this.className,e,"unselectRow"); throw e; } }; this.selectAll = function(pbFireEvent) { try { var rows = this.listEl.children; for (var i=0; i parentChildren.length if (poIndex > childrenLength) { parentoEl.appendChild(childrenLength+1); return; } //pnIndex < parentChildren.length var current = poRow; var old = null; for (var i=0; i < parentChildren.length; i++){ if (i >= poIndex) { old = parentChildren[i]; parentChildren[i] = current; } current = old; } if (pbFireEvent && this.clientListener && this.clientListener.onRowAdd) { this.clientListener.onRowAdd(poRow); } } catch (e) { XError.display(this.className,e,"addRow"); throw e; } }; this.toggleRowSelect = function(poRow,pbFireEvent) { try { if (!poRow) { return; } if (this.isRowSelected(poRow)) { this.unselectRow(poRow,pbFireEvent); } else { this.selectRow(poRow,pbFireEvent); } } catch (e) { XError.display(this.className,e,"toggleRowSelect"); throw e; } }; // Event Listeners this.getParentRow = function(poEl) { try { var oEl = poEl? poEl : XEvent.getSrcElement(); if (!oEl) { return null; } // alert(oEl.parentElement.outerHTML); // traverse up until the element is a direct child of the listEl while (oEl.parentElement) { if (oEl.parentElement == this.listEl) { return oEl; } oEl = oEl.parentElement; } return null; } catch (e) { XError.display(this.className,e,"getEventRow"); throw e; } }; this.onMouseOver = function(poRow) { try { var oEl = this.getParentRow(poRow); if ( (!oEl) || (oEl.className.indexOf(this.cssRowSel) >= 0 ) ) { return XEvent.cancel(); } if ( oEl.getAttribute("axtype") == "group" ) { return XEvent.cancel(); } if (this.activeRow != oEl) { oEl.className = this.cssRowMouseOver; } return XEvent.cancel(); } catch (e) { XError.display(this.className,e,"onMouseOver"); } }; this.onMouseOut = function(poRow) { try { var oEl = this.getParentRow(poRow); if (!oEl) { return XEvent.cancel(); } if ( oEl.getAttribute("axtype") == "group" ) { return XEvent.cancel(); } //oEl.className = oEl.className.replace(" " + this.cssRowMouseOver,""); if (!this.isRowSelected(oEl)) { if (this.activeRow == oEl) { oEl.className = this.cssRowActive; } else { oEl.className = this.cssRowUnsel; } } return XEvent.cancel(); } catch (e) { XError.display(this.className,e,"onMouseOut"); } }; this.onClick = function(poRow,pbBubbleEvent) { try { var oEvent = event; // TODO: FIREFOX var bubble = XBoolean.parse(pbBubbleEvent); var oEl = this.getParentRow(poRow); if (!oEl) { return bubble? true : XEvent.cancel(); } if ( oEl.getAttribute("axtype") == "group" ) { return bubble? true : XEvent.cancel(); } if (XEvent.isCtrlKey(oEvent)) { this.toggleRowSelect(oEl,true); return bubble? true : XEvent.cancel(oEvent); } if (XEvent.isShiftKey(oEvent)) { this.selectRowRange(this.activeRow,oEl,true); return bubble? true : XEvent.cancel(oEvent); } if (this.isStickySelect) { this.toggleRowSelect(oEl,true); } else { this.activateRow(oEl,true); } return bubble? true : XEvent.cancel(oEvent); } catch (e) { XError.display(this.className,e,"onClick"); } }; this.onDblClick = function(poRow) { try { var oEl = this.getParentRow(poRow); if (oEl) { if (this.clientListener && this.clientListener.onDblClick) { this.clientListener.onDblClick(oEl); } } return XEvent.cancel(); } catch (e) { XError.display(this.className,e,"onDblClick"); } }; return this; } //------------------------------------ // SELECTORBOX //------------------------------------ function SelectorBox( poContainer, poBox, poCallbackListener, pbEnabled) { this.className = "SelectorBox"; this.container = poContainer; this.oBox = poBox; this.enabled = XBoolean.parse(pbEnabled); this.isBoxShowing = false; this.pinX = 0; this.pinY = 0; this.x1 = 0; this.y1 = 0; this.x2 = 0; this.y2 = 0; this.isReverse = false; this.getLeft = function() { return this.x1; } this.getTop = function() { return this.y1; } this.getWidth = function() { return this.x2 - this.x1; } this.getHeight = function() { return this.y2 - this.y1; } this.getX1 = function() { return this.x1; } this.getY1 = function() { return this.y1; } this.getX2 = function() { return this.x2; } this.getY2 = function() { return this.y2; } this.callbackListener = poCallbackListener; this.initialize = function() { try { if (this.enabled) { this.enable(); } } catch (e) { XError.display(this.className,e,"initialize"); } }; this.setListener = function(poListener,pbEnabled) { this.callbackListener = poListener; if (this.callbackListener) { var enabled = this.enabled; if (XString.isNotEmpty(pbEnabled)) { enabled = XBoolean.parse(pbEnabled); this.enabled = enabled; } } else { this.disable(); } }; this.disable = function() { try { this.container.style.cursor = "auto"; } catch(e) {} this.enabled = false; }; this.enable = function() { try { this.container.style.cursor = "crosshair"; } catch(e) {} this.enabled = true; }; this.setEnabled = function(pbEnabled) { if (XBoolean.parse(pbEnabled)) { this.enable(); } else { this.disable(); } }; this.isEnabled = function() { return this.enabled; }; this.getRelativeEventX = function(poEvent) { // TODO: FIREFOX return poEvent.x - XHtmlUtil.calcAbsoluteLeft(this.container) -(-this.container.scrollLeft); }; this.getRelativeEventY = function(poEvent) { // TODO: FIREFOX return poEvent.y - XHtmlUtil.calcAbsoluteTop(this.container) -(-this.container.scrollTop); }; this.redrawBox = function() { if (!this.isBoxShowing) { this.oBox.style.display = "none"; return; } this.oBox.style.pixelLeft = this.x1; this.oBox.style.pixelTop = this.y1; this.oBox.style.pixelWidth = this.x2 - this.x1; this.oBox.style.pixelHeight = this.y2 - this.y1; this.oBox.style.display = ""; if (this.callbackListener) { this.callbackListener.onSelectorBoxRedraw(this); } }; this.onMouseDown = function(poEvent) { if (!this.enabled) { return; } this.isReverse = false; var oEvent = poEvent? poEvent : window.event; this.pinX = this.x1 = this.getRelativeEventX(oEvent); this.x2 = this.pinX - (-1); this.pinY = this.y1 = this.getRelativeEventY(oEvent); this.y2 = this.pinY - (-1); // make sure we are not on the scroll bar if ( ( ((this.container.style.pixelHeight -(-this.container.scrollTop) - this.pinY) < 20) ) || ( ((this.container.style.pixelWidth -(-this.container.scrollLeft) - this.pinX) < 20) ) ) { return; } this.isBoxShowing = true; }; this.onMouseUp = function(poEvent) { if (!this.enabled) { return; } try { if (!this.isBoxShowing) { return; } this.isBoxShowing = false; this.redrawBox(); if (this.callbackListener) { var box = new XBox(this.x1,this.y1,(this.x2-this.x1),(this.y2-this.y1),this.isReverse); this.callbackListener.onSelectorBoxComplete(this,box); } } catch (e) { //XError.display(this.className,e,"onMouseMove"); } }; this.onMouseMove = function(poEvent) { if (!this.enabled) { return; } if (!this.isBoxShowing) { return; } var oEvent = poEvent? poEvent : window.event; var nX; var nY; try { nX = this.getRelativeEventX(oEvent); nY = this.getRelativeEventY(oEvent); if ( (nX < this.pinX && nY > this.pinY) || (nY < this.pinY && nX > this.pinX) ) { this.isReverse = true; } else { this.isReverse = false; } // Always adjust so that the x/y coords are the top/left if (nX >= this.pinX) { this.x1 = this.pinX; this.x2 = nX; } else { this.x1 = nX; this.x2 = this.pinX; } if (nY >= this.pinY) { this.y1 = this.pinY; this.y2 = nY; } else { this.y1 = nY; this.y2 = this.pinY; } this.redrawBox(); } catch (e) { //XError.display(this.className,e,"onMouseMove"); } }; return this; }; //------------------------------------ // STDLIBS ENUMS //------------------------------------ function XEKeyCodeClass() { this.key0 = 48; this.key9 = 57; this.keyBackspace = 8; this.keyDelete = 46; this.keyEnd = 35; this.keyEnter = 13; this.keyHome = 36; this.keyTab = 9; this.keyRightArrow = 39; this.keyLeftArrow = 37; this.keyPeriod = 190; this.keyPad0 = 96; this.keyPad9 = 105; this.keyPadDecimal = 110; this.keyCut = 88; // x this.keyCopy = 67; // c this.keyPaste = 86; // v return this; }; var XEKeyCode = new XEKeyCodeClass(); function XEDataTypeClass() { this.unknown = 0; this.str = 20; this.text = 21; this.number = 30; this.integer = 31; this.integerUnsigned = 32; this.dateTime = 40; this.date = 41; this.time = 42; this.boolean = 60; this.isNumberType = function(pnDataTypeId) { var nt = pnDataTypeId*1; return (nt >= 30) && (nt <= 39); }; this.isDateType = function(pnDataTypeId) { var nt = pnDataTypeId*1; return (nt >= 40) && (nt <= 49); }; this.isStringType = function(pnDataTypeId) { var nt = pnDataTypeId*1; return (nt >= 20) && (nt <= 29); }; this.isNonStringType = function(pnDataTypeId) { var nt = pnDataTypeId*1; return (nt < 20) || (nt > 29); }; return this; }; var XEDataType = new XEDataTypeClass(); function XEValidationFailActionClass() { this.fail = 0; this.warn = 1; return this; }; var XEValidationFailAction = new XEValidationFailActionClass(); function XEInputTypeClass() { this.text = "0"; this.textarea = "1"; this.checkbox = "2"; this.list = "3"; this.barcode = "4"; return this; }; var XEInputType = new XEInputTypeClass(); function XEAddressTypeClass() { this.unknown = "0"; this.email = "1"; this.phone = "2"; this.fax = "3"; this.http = "4"; this.ftp = "5"; this.faxraw = "6"; this.file = "7"; this.print = "8"; this.scan = "9"; this.sms = 10; this.wap = 11; this.sftp = 12; this.faxbridge = 13; return this; }; var XEAddressType = new XEAddressTypeClass(); function XEAddressComponentIdClass() { this.addressRaw = 501; this.addressProtocol = 502; this.addressDomain = 503; this.addressPort = 504; this.addressAuthType = 505; this.addressAuthUsername = 506; this.addressAuthPassword = 507; this.addressAuthDomain = 508; this.addressCountryCode = 509; this.addressAreaCode = 510; this.addressLocalAddress = 511; this.addressPath = 512; this.addressNationalAddress = 513; this.addressDocumentFormat = 516; this.addressCanonical = 521; this.addressCleansed = 522; return this; }; var XEAddressComponentId = new XEAddressComponentIdClass(); function XEFileTypeClass() { this.pdf = "PDF"; this.tif = "TIF"; return this; }; var XEFileType = new XEFileTypeClass(); function XEObjectTypeClass() { this.file = "41"; this.document = "46"; return this; }; var XEObjectType = new XEObjectTypeClass(); function XEObjectScopeClass() { this.container = "container"; this.document = "document"; this.file = "file"; return this; }; var XEObjectScope = new XEObjectScopeClass(); function XEDisplayMaskClass() { this.never = 0; this.always = 1; this.editable = 2; return this; }; var XEDisplayMask = new XEDisplayMaskClass(); function XEMessageBoxClass() { this.errorType = 4000; this.warningType = 3999; this.infoType = -1; this.successType = 0; return this; }; var XEMessageBox = new XEMessageBoxClass(); function XEHtmlObjectAttribsClass() { this.valueOld = "axzo"; this.objectId = "axzi"; return this; }; var XEHtmlObjectAttribs = new XEHtmlObjectAttribsClass();