function XMessageFieldClass(psObjectName) { this.className = "XMessageFieldClass"; this.objectName = psObjectName; this.objectPanel = null; this.tablePanel = null; this.fadeDelay = "1000"; this.fadeSpeed = "80"; this.fadeAlphaStart = "100"; this.fadeAlphaDecrement = "6"; var mbInitialized = false; var moImageEl = null; var moTextEl = null; var moNoteEl = null; this.initialize = function() { try { this.objectPanel = document.getElementById(this.objectName); this.tablePanel = document.getElementById(this.objectName + "_table"); moTextEl = document.getElementById(this.objectName + "_text"); moImageEl = document.getElementById(this.objectName + "_image"); moNoteEl = document.getElementById(this.objectName + "_notes"); this.fadeDelay = XString.evl(this.objectPanel.getAttribute("axFadeDelay"),"1000")*1; this.fadeSpeed = XString.evl(this.objectPanel.getAttribute("axFadeSpeed"),"80")*1; this.fadeAlphaStart = XString.evl(this.objectPanel.getAttribute("axFadeAlphaStart"),"100")*1; this.fadeAlphaDecrement = XString.evl(this.objectPanel.getAttribute("axFadeAlphaDecrement"),"6")*1; this.cssError = this.objectPanel.getAttribute("axCssError"); this.cssWarning = this.objectPanel.getAttribute("axCssWarning"); this.cssSuccess = this.objectPanel.getAttribute("axCssSuccess"); this.cssInfo = this.objectPanel.getAttribute("axCssInfo"); this.imgError = this.objectPanel.getAttribute("axImgError"); this.imgWarning = this.objectPanel.getAttribute("axImgWarning"); this.imgSuccess = this.objectPanel.getAttribute("axImgSuccess"); this.imgInfo = this.objectPanel.getAttribute("axImgInfo"); this.msgError = this.objectPanel.getAttribute("axMsgError"); this.msgWarning = this.objectPanel.getAttribute("axMsgWarning"); this.msgSuccess = this.objectPanel.getAttribute("axMsgSuccess"); this.msgInfo = this.objectPanel.getAttribute("axMsgInfo"); mbInitialized = true; if (XBoolean.parse(this.objectPanel.getAttribute("axFadeOnInit"))) { this.startFade(); } } catch (e) { XError.display(this.className, e, "initialize"); throw e; } }; this.checkInit = function() { try { if (!mbInitialized) { this.initialize(); } } catch (e) { XError.display(this.className, e, "checkInit"); throw e; } }; this.setMessageText = function(psMessage) { try { this.checkInit(); moTextEl.innerHTML = psMessage + ""; } catch (e) { XError.display(this.className, e, "setMessageText"); throw e; } }; this.setMessageType = function(psType) { try { this.checkInit(); switch (psType) { case XEMessageBox.warningType : this.tablePanel.className = this.cssWarning; moImageEl.src = this.imgWarning; break; case XEMessageBox.errorType : this.tablePanel.className = this.cssError; moImageEl.src = this.imgError; break; case XEMessageBox.successType : this.tablePanel.className = this.cssSuccess; moImageEl.src = this.imgSuccess; break; default : this.tablePanel.className = this.cssInfo; moImageEl.src = this.imgInfo; break; } } catch (e) { XError.display(this.className, e, "setMessageType"); throw e; } }; this.displayMessage = function(psType, psMessage, psNote, psSplitter) { try { this.checkInit(); var bMessageExists = true; var sMessage = psMessage; if (XString.isEmpty(psType)) { return; } if (XString.isEmpty(sMessage)) { bMessageExists = false; } if (XString.isEmpty(psNote)) { psNote = null; } if (XString.isEmpty(psSplitter)) { psSplitter = ","; // NOTE: default spliting for the notes (if passed in as text) is a comma - unless you pass an array } if (this.tablePanel) { var oImage = moImageEl; var oMessage = moTextEl; var oNote = moNoteEl; switch (psType) { case XEMessageBox.warningType : this.tablePanel.className = this.cssWarning; oImage.src = this.imgWarning; sMessage = (!bMessageExists)? this.msgWarning : sMessage; break; case XEMessageBox.errorType : this.tablePanel.className = this.cssError; oImage.src = this.imgError; sMessage = (!bMessageExists)? this.msgError : sMessage; break; case XEMessageBox.successType : this.tablePanel.className = this.cssSuccess; oImage.src = this.imgSuccess; sMessage = (!bMessageExists)? this.msgSuccess : sMessage; break; default : this.tablePanel.className = this.cssInfo; oImage.src = this.imgInfo; sMessage = (!bMessageExists)? this.msgInfo : sMessage; break; } oMessage.innerHTML = sMessage; var resolveNotes = null; if ( (oNote) && (psNote) ) { if (psNote[0]) { resolveNotes = psNote; } else { resolveNotes = psNote.split(psSplitter); } var notes = ""; for (var i=0; i < resolveNotes.length; i++){ notes += "- " + resolveNotes[i] + "
"; } oNote.innerHTML = notes; } this.setAlpha(this.fadeAlphaStart); this.objectPanel.style.display = "block"; } } catch (e) { XError.display(this.className, e, "displayMessage"); } }; this.startFade = function(pnDelay) { this.checkInit(); var delay = XString.evl(pnDelay,this.fadeDelay)*1; if (this.tablePanel) { window.setTimeout(this.objectName + ".fadeIt()", delay); } }; this.setAlpha = function (pnAlpha) { this.checkInit(); if (this.tablePanel) { if (this.tablePanel.style.filter != null) { // BROWSER: IE this.tablePanel.style.filter = "alpha(opacity=" + pnAlpha + ")"; } else { // BROWSER: firefox this.tablePanel.style.opacity = pnAlpha / 100; } } }; this.fadeIt = function(pnAlpha) { try { this.checkInit(); var alpha = XString.evl(pnAlpha,this.fadeAlphaStart)*1; alpha = alpha - this.fadeAlphaDecrement; this.setAlpha(alpha); if (alpha > 1) { window.setTimeout(this.objectName + ".fadeIt(" + alpha + ")", this.fadeSpeed); return; } else { this.objectPanel.style.display = "none"; } return; } catch (e) { alert(this.className + ", " + e.description + ", fnFadeIt"); } }; this.clear = function() { this.fadeIt(-1); }; return this; };