/* ============================================================================ * * ADOBE CONFIDENTIAL * * Copyright 2004 - 2007 Adobe Systems Incorporated * All Rights Reserved. * * Adobe Patent or Adobe Patent Pending Invention Included Within this File * * NOTICE: All information contained herein is, and remains the property of * Adobe Systems Incorporated and its suppliers, if any. The intellectual and * technical concepts contained herein are proprietary to Adobe Systems * Incorporated and its suppliers and may be covered by U.S. and Foreign * Patents, patents in process, and are protected by trade secret or copyright * law. Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained from * Adobe Systems Incorporated. * * $Revision$ * Adobe patent application tracking # B030, entitled Using A distributed Form Object Model To Facilitate Form Event Processing, inventors: McLellan * ============================================================================ */ // // add two objects to the global space // var xss = new xss_runtime(); var xfa = new xss.new_xfa(); xss.initialize_runtime(); // // this function object represents the XFA subset run-time // function xss_runtime() { var rfIndex; var fields; var rootSubform; var elementCount; var imageCount; var tcElement; var fsInitialized_ ; var fsFocusField_; var fsApplicationData_; var fsPageNo_; var hpRatio; var clItemsDelim; var i; var element; var contextOcc; var vareval; var nFieldCount; var idCount; var bIsOpera5; var bIsOpera6; var bIsNetscapelt62; var bIsIE; var bDisableEvents; var bIsClientEvent; var validationMessage = ""; this.initialize_runtime = initialize_runtime; this.displayMessage = displayMessage; this.validationError = validationError; this.exitField = null; this.enterField = null; this.SubmitValidateMode = false; this.enableEvents = enableEvents; this.disableEvents = disableEvents; this.lastParentNode = null; this.lastParentSubform = null; this.firstTabIndex = null; this.lastTabIndex = null; this.lastTabOffset = 0; // // constructors // this.new_xfa = function() { return new xfaFunc(); }; this._dumpModel = dumpModel; this._resetModel = resetModel; this._syncToDocument = syncToDocument; this._addParentElementToModel = _addParentElementToModel; this._addFieldElementToModel = _addFieldElementToModel; this._updateCheckButtonCachedValue = _updateCheckButtonCachedValue; this._removeParentElementFromModel = _removeParentElementFromModel; this._removeFieldElementFromModel = _removeFieldElementFromModel; this._scriptExecuted = false; this._debug = false; this._getFormIndex = function() { return rfIndex; }; function dumpModel() { debugWin = window.open(); debugWin.document.open("text/plain"); xfa._enumerate( 0 ); xfa.host._enumerate( 0 ); rootSubform._enumerate( 0 ); debugWin.document.close(); } function initialize_runtime() { // determine the FORM element for (rfIndex = 0; rfIndex < document.forms.length; rfIndex++) { if (window.document.forms[rfIndex].id == "FORMELM") break; } FSDebug_("initializing"); fields = new Array (window.document.forms[rfIndex].length ); rootSubform = null; elementCount = window.document.forms[rfIndex].length; imageCount = window.document.images.length; fsInitialized_ = window.document.forms[rfIndex].elements["FSINITIALIZED_"]; fsPageNo_ = window.document.forms[rfIndex].elements["FSPAGENO_"]; fsFocusField_ = null; hpRatio=26.4583; clItemsDelim = ";!!;"; contextOcc = 0; vareval = function( strexp ) { try {var bResult = eval(strexp); return(bResult);} catch (oErr) { alert ('javascript error : ' + errorDescription( oErr ) + strexp ); };}; nFieldCount = 0; idCount = 0; bIsOpera5 = ((navigator.userAgent.indexOf("Opera 5") != -1) ||(navigator.userAgent.indexOf("Opera/5") != -1)); bIsOpera6 = ((navigator.userAgent.indexOf("Opera 6") != -1) ||(navigator.userAgent.indexOf("Opera/6") != -1)); bIsOpera = ((navigator.userAgent.indexOf("Opera") != -1)); bIsNetscapelt62 = (((navigator.userAgent.indexOf("Netscape6") != -1) ||(navigator.userAgent.indexOf("Netscape/6") != -1)))&&(parseFloat(navigator.appVersion)<6.2); bIsIE = ((navigator.userAgent.indexOf("MSIE") >= 0) && (bIsOpera == false)); bDisableEvents = false; bIsClientEvent = false; xfaFunc._className = "Xfa"; hostFunc._className = "Host"; subformFunc._className = "Subform"; fieldFunc._className = "Field"; formFunc._className = "Form"; instanceManagerFunc._className = "InstanceManager"; Object.prototype._enumerate = _enumerate; Object.prototype._resetObject = resetObject; String.prototype.trim = function() { return this.replace(/^\s*(\b.*\b|)\s*$/, "$1"); } this.bUseCache = (typeof(oCache) != "undefined"); if (this.bUseCache) { var sTargetURL = oCache["FSTARGETURL_"]; if (typeof(sTargetURL) != "undefined") { document.forms[rfIndex].action = sTargetURL; } var sFieldFocus = oCache["FSFOCUS_"]; if (typeof(sFieldFocus) != "undefined") { var fsFocusHidden_ = document.forms[rfIndex].elements["FSFOCUS_"]; fsFocusHidden_.value = sFieldFocus; } var sApplicationData = oCache["FSAPPLICATIONDATA_"]; if (typeof(sApplicationData) != "undefined") { fsApplicationData_ = document.forms[rfIndex].elements["FSAPPLICATIONDATA_"]; fsApplicationData_.value = sApplicationData; } var sFieldFocus = oCache["FSINITIALIZED_"]; if (typeof(sFieldFocus) != "undefined") { var fsFocusHidden_ = document.forms[rfIndex].elements["FSINITIALIZED_"]; fsInitialized_.value = sFieldFocus; } } var oField = null; this.oLastField = null; for (i = 0; i < elementCount + imageCount; i++) { // // create wrapper for each non-hidden input field // var bIsImage = false; if (i < elementCount) { // get field element element = document.forms[rfIndex].elements[i]; } else { // get image element = document.images[i - elementCount]; bIsImage = true; } this._addFieldElementToModel(element, bIsImage); } if (rootSubform != null) { document.forms[rfIndex].onsubmit = validateAndSubmit; window.onunload = xss._resetModel; if (isInitialized() == false) { // if first time displaying page run initializations xfa.form.execInitialize(); } xfa.form.execCalculate(); syncToDocument(); if (fsFocusField_ != null) { fsFocusField_.focus(); } } FSDebug_("Initializing complete " + nFieldCount ); } function isInitialized() { if (typeof(fsInitialized_.value) != "string") return false; // alert(fsPageNo_.value + " : " + fsInitialized_.value); var bInitialized = false; nPageNo = parseInt( fsPageNo_.value ); var sArr = fsInitialized_.value.split("-"); if (sArr.length >= nPageNo) { sInit = sArr[nPageNo]; if (sInit == "1") return true; } sArr[nPageNo] = "1"; fsInitialized_.value = sArr.join("-"); return false; } // // function constructors // // naming convention: internal utility methods properites start with '._'. // function xfaFunc () { if (typeof(xfaFunc.resolveNode) == "undefined") { xfaFunc.prototype.host = new hostFunc(); xfaFunc.prototype.form = new formFunc(); xfaFunc.prototype.resolveNode = _resolveNode; xfaFunc.prototype.resolveNodes = _resolveNodes; } this._currentContext = null; this._currentSubform = null; } function formFunc () { if (typeof(formFunc.execInitialize) == "undefined") { formFunc.prototype.execInitialize = initAll; formFunc.prototype.execCalculate = calcAll; formFunc.prototype.execValidate = validateAll; formFunc.prototype.resolveNode = _resolveNode; formFunc.prototype.resolveNodes = _resolveNodes; } this._currentContext = null; this._currentSubform = null; } function hostFunc() { if (typeof(this.currentPage) == "undefined") { hostFunc.prototype.currentPage = 0; hostFunc.prototype.numPages = 0; hostFunc.prototype.name = navigator.appName; hostFunc.prototype.validationsEnabled = true; hostFunc.prototype.calculationsEnabled = true; hostFunc.prototype.pageUp = _pageUp; hostFunc.prototype.pageDown = _pageDown; hostFunc.prototype.exportData = _exportData; hostFunc.prototype.importData = _importData; hostFunc.prototype.resetData = _resetData; hostFunc.prototype.gotoURL = GotoURL; hostFunc.prototype.messageBox = msgboxfunc; hostFunc.prototype.setFocus = _setFocus; // // undocumented // hostFunc.prototype._eval = vareval; hostFunc.prototype.print = _printForm; } } function getInstanceManager( oSubform ) { var oInstanceManagerPeer = oSubform._peer.parentNode; var oInstanceManager = oInstanceManagerPeer._peer; if (oInstanceManager == null) { // // Instance Manager not yet created // return new instanceManagerFunc( oSubform ); } // // Return already create InstanceManager return oInstanceManager; } function instanceManagerFunc( oSubform ) { if (typeof(this.addInstance) == "undefined") { instanceManagerFunc.prototype.addInstance = _addInstance; instanceManagerFunc.prototype.removeInstance = _removeInstance; instanceManagerFunc.prototype.moveInstance = _moveInstance; instanceManagerFunc.prototype.setInstances = _setInstances; instanceManagerFunc.prototype.instanceCount = _instanceCount; instanceManagerFunc.prototype._getInstance = _getInstance; instanceManagerFunc.prototype._adjustIndexes = _adjustIndexes; instanceManagerFunc.prototype._tabCount = null; instanceManagerFunc.prototype._getTabCount = _getTabCount; } this._subform = oSubform; this.occur = new Object(); this.occur.max = oSubform._nMaxOccur; this.occur.min = oSubform._nMinOccur; this._peer = oSubform._peer.parentNode; this._peer._peer = this; this.name = "_" + oSubform.name; this.index = 0; this.parent = oSubform.parent; this._idx = this.parent._children.length; this.parent._children[this.parent._children.length++] = this; //alert("creating clone for " + oSubform._peer.id); // create template for cloning if ((oSubform._peer.nodeName.toLowerCase() != "tr") && (bIsIE)) { this._template = oSubform._peer.cloneNode( false ); this._template.innerHTML = oSubform._peer.innerHTML; } else { this._template = oSubform._peer.cloneNode( true ); } FSDebug_("Instance manager created for " + oSubform.name ); } function subformFunc(obj) { if (typeof(this.execInitialize) == "undefined") { subformFunc.prototype.validationMessage = ""; subformFunc.prototype.execInitialize = _execInitialize; subformFunc.prototype.execCalculate = _execCalculate; subformFunc.prototype.execValidate = _execValidate; subformFunc.prototype.resolveNode = _resolveNode; subformFunc.prototype.resolveNodes = _resolveNodes; subformFunc.prototype._setcontext = _setcontext; subformFunc.prototype._execute = _execute; subformFunc.prototype._getAssocHiddenField = _getAssocHiddenField; subformFunc.prototype._removeChild = _removeChild; subformFunc.prototype._moveChild = _moveChild; subformFunc.prototype._getQualifiedName = getQualifiedName; subformFunc.prototype._syncToDocument = _syncSubformToDocument; subformFunc.prototype._nMinOccur = null; subformFunc.prototype._nMaxOccur = null; subformFunc.prototype._bNew = true; subformFunc.prototype._onenter = function () { this._execute( this._enterScript ); } subformFunc.prototype._onexit = function () { this._execute( this._exitScript ); } } setNameAndIndex( this, obj.id ); this._peer = obj; obj._peer = this; this._children = new Array(); this.parent = getParent( obj ); this._eval = eval; var initSubform = obj.firstChild; while ((initSubform != null) && (initSubform.nodeType != 1)) initSubform = initSubform.nextSibling; if (initSubform.nodeName.toLowerCase() == "td") initSubform = initSubform.firstChild; if (initSubform != null) { var sID = initSubform.id; if ((typeof(sID) == "string") && (sID.indexOf("_init__") >= 0)) { var sInitValue = initSubform.value; if (sInitValue.indexOf("_initSubform") >= 0) { this._initSubform = subformInit; eval("this." + sInitValue); } } } if (this._nMinOccur != null) this.instanceManager = getInstanceManager( this ); // Subform properties this._styleElement = obj; this._styleElement._getProperty = _getProperty; this._peer._getProperty = _getProperty; var sBackgroundColor = this._styleElement._getProperty('backgroundColor'); var sBorderTopWidth = this._styleElement._getProperty('borderTopWidth'); var sBorderColor = this._styleElement._getProperty('borderColor'); var sVisibility = this._styleElement._getProperty('visibility'); // presence if (sVisibility.toLowerCase() == 'hidden') this.presence = "invisible"; else this.presence = "visible"; this._oldPresence = this.presence; // fillColor this.fillColor = fromRGB(sBackgroundColor); this._oldFillColor = this.fillColor; // borderWidth this.borderWidth = 0; if (typeof(sBorderTopWidth) != "undefined") this.borderWidth = sBorderTopWidth; this._oldBorderWidth = this.borderWidth; // borderColor this.borderColor = 0; if (sBorderColor != "undefined") this.borderColor = fromRGB(sBorderColor); this._oldBorderColor = this.borderColor; } function fieldFunc(obj) { if (typeof(this._callfunc) == "undefined") { // prototype methods common for all fields fieldFunc.prototype.execCalculate = _execCalculate; fieldFunc.prototype.execInitialize = _execInitialize; fieldFunc.prototype.execValidate = _execValidate; fieldFunc.prototype.execEvent = _execEvent; // private utility functions fieldFunc.prototype.addItem = function(text, value, index) {FSAddItem_( this, text, value, index );}; fieldFunc.prototype.clearItems = function() {FSClear_( this );}; fieldFunc.prototype._callfunc = function ( strexp ) { return eventfunction(this, strexp); }; fieldFunc.prototype._exitfunc = function(exitScript) { FSDebug_("exit function begin" + this.name); var bResult = false; if (!bDisableEvents) { xss.exitField = this; xss.exitField._exitScript = exitScript; this._syncFieldFromDocument(); bResult = exitfunction(this, exitScript); if (bResult == true) { xfa.form.execCalculate(); // recalculate if valid } syncToDocument(); } if (this._isDateField) { _fsCalWin.hideButton(this._popupButton.id); } FSDebug_("exit function end"); return(bResult); }; fieldFunc.prototype._enterfunc = function(enterScript) { FSDebug_("enter function begin"); xss.enterField = this; xss.enterField._enterScript = enterScript; var bResult = false; if (!bDisableEvents) { xss._scriptExecuted = false; bResult = enterfunction(this, enterScript); if (xss._scriptExecuted == true) syncToDocument(); } if (this._isDateField) { _fsCalWin.showButton(this._popupButton.id); } FSDebug_("enter function end"); return(bResult); }; fieldFunc.prototype._clickfunc = function(clickScript) { FSDebug_("click function begin"); xss.enterField = this; var bResult = false; bResult = eventfunction(this, clickScript); FSDebug_("click function end"); return(bResult); }; fieldFunc.prototype._keydownfunc = function(e, textObj) { var keynum; var keychar; var numcheck; if(window.event) // IE { keynum = e.keyCode; } else if(e.which) // Netscape/Firefox/Opera { keynum = e.which; } keychar = String.fromCharCode(keynum); numcheck = /\d/; if(keychar == "("){ var locale = ""; var format = ""; //Get field locale and format for(var i = 0; i < textObj.attributes.length; i++){ //Mozilla, NS donot understand user defined attributes if(textObj.attributes[i].name == "locale"){ locale = textObj.attributes[i].value; } else if(textObj.attributes[i].name == "format"){ format = textObj.attributes[i].value; } } //if locale not found, try page locale if(locale == "") locale = _fsCalProps['LOC']; stopEventFromBubbling(e); // Make sure the event doesn't propagate _fsCalWin.activate(textObj.name, textObj.id + "_anchor", format, locale); document.getElementById('month_left').focus(); } }; fieldFunc.prototype._execute = _execute; fieldFunc.prototype.resolveNode = _resolveNode; fieldFunc.prototype.resolveNodes = _resolveNodes; fieldFunc.prototype._initField = initField; fieldFunc.prototype._initButton = initButton; fieldFunc.prototype._initCheckButton = initCheckButton; fieldFunc.prototype._initNumeric = initNumeric; fieldFunc.prototype._initChoiceList = initChoiceList; fieldFunc.prototype._cacheId = cacheId; fieldFunc.prototype._fullName = getFullName; fieldFunc.prototype._syncToDocument = _syncFieldToDocument; fieldFunc.prototype._syncFieldFromDocument = _syncFieldFromDocument; } this._peer = obj obj._peer = this // //DATE/TIME field // var popupButton = document.getElementById(obj.id + "_anchor"); if (popupButton != null) { this._isDateField = true; this._popupButton = popupButton; } else { this._isDateField = false; this._popupButton = null; } var bRadio = (obj.type == "radio"); var bCheck = (obj.type == "checkbox"); var bSelect = ((obj.type == "select-one") || (obj.type == "select-multiple")); var bImage = (obj.tagName == "IMG"); this._bButton = ((obj.type == "submit") || (obj.type == "button") || (obj.type == "reset")) this._bRadio = bRadio; this._bSelect = bSelect; this._bImage = bImage; // RO Properties var sName; if (bRadio) sName = obj.value; else if (bImage) sName = obj.id; else sName = obj.name; setNameAndIndex( this, sName ); this._styleElement = obj; var oParent = obj.parentNode; while (typeof(oParent) != "undefined") { //ensure we haven't gone too far up if (oParent.tagName.toUpperCase() == "BODY") throw "FSINFO :: Not an XFA field :: " + sName; if (oParent.tagName == "FORM") break; //alert(obj.name + " Type: " + typeof(oParent) + " TagName: " + oParent.tagName + " ID: " + typeof(oParent.id)); if ((typeof(oParent.id) == "string") && (oParent.id.indexOf("_fsw") >= 0)) { this._styleElement = oParent; oParent = oParent.parentNode; break; } if (_isSubformPeer(oParent)) break; if (typeof(oParent.parentNode) == "undefined") break; oParent = oParent.parentNode; }; if (oParent == xss.lastParentNode) { this.parent = xss.lastParentSubform; //add field to children array this._idx = this.parent._children.length; this.parent._children[this.parent._children.length++] = this; } else { this.parent = getParent( obj ); xss.lastParentNode = oParent; xss.lastParentSubform = this.parent; } this._styleElement._getProperty = _getProperty; this._peer._getProperty = _getProperty; var sBackgroundColor = this._styleElement._getProperty('backgroundColor'); var sColor = this._peer._getProperty('color'); var sBorderTopWidth = this._styleElement._getProperty('borderTopWidth'); var sBorderColor = this._styleElement._getProperty('borderColor'); var sVisibility = this._styleElement._getProperty('visibility'); // RW Properties if (bRadio || bCheck || bImage || bSelect) { if (bRadio) { var nRadValue = (this._idx + 1); this._onValue = nRadValue.toString(); // default to number index this._offValue = null; var sTempVal = getHTMLValue( this ); if (sTempVal != null) { this.rawValue = textToValue( this, sTempVal ); syncExGroup( this ); } } else if (bCheck) { this._onValue = 1; this._offValue = 0; } this.formattedValue = getHTMLValue( this ); } else { if (typeof(obj.defaultValue) == "undefined") this.formattedValue = obj.value; else { if ((obj.defaultValue.length == 0) && (obj.value.length > 0) && (bIsOpera5)) this.formattedValue = obj.value; else this.formattedValue = obj.defaultValue; } } this._oldFormattedValue = this.formattedValue; this._numeric = false this.fillColor = fromRGB(sBackgroundColor); this._oldFillColor = this.fillColor; this.fontColor = fromRGB(sColor); this._oldFontColor = this.fontColor; this.borderWidth = 0; if (typeof(sBorderTopWidth) != "undefined") this.borderWidth = sBorderTopWidth; this._oldBorderWidth = this.borderWidth; this.borderColor = 0; if (sBorderColor != "undefined") this.borderColor = fromRGB(sBorderColor); this._oldBorderColor = this.borderColor; this.x = 0; if (typeof(this._styleElement.style.left) != "undefined") this.x = fromDim( this._styleElement.style.left ); this.y = 0; if (typeof(this._styleElement.style.top) != "undefined") this.y = fromDim( this._styleElement.style.top ); this.w = 0; if (typeof(this._styleElement.style.width) != "undefined") this.w = fromDim( this._styleElement.style.width ); this.h = 0; if (typeof(this._styleElement.style.height) != "undefined") this.h = fromDim( this._styleElement.style.height ); this._oldY = this.y; this._oldX = this.x; this._oldW = this.w; this._oldH = this.h; this.mandatory = 'disabled'; this._oldMandatory = this.mandatory; if ((obj.readOnly == true) || (obj.disabled == true)) this.access = "protected"; else this.access = "open"; this._oldAccess = this.access; if (sVisibility.toLowerCase() == 'hidden') this.presence = "invisible"; else this.presence = "visible"; this._oldPresence = this.presence; if ((this.access == "protected") && (obj.onclick != null)) { try { obj.style.cursor = "pointer"; } catch (oErr) { // ignore errors } } this.validationMessage = ""; if (typeof(this._peer.onblur) != "function") this._peer.onblur = function () { this._peer._exitfunc('') }; if (typeof(this._peer.onfocus) != "function") this._peer.onfocus = function () { this._peer._enterfunc('') }; if (typeof(this._peer.onclick) != "function") this._peer.onclick = function () { this._peer._clickfunc('') }; // # 1285381 // If the text field is associated with a calendar popup, associate // keydown event with it. Pressing the down arrow key will activate // the calendar. Event handling is different for Internet Explorer/Opera // and Netscape/Firefox // var browser = navigator.appName; var version = navigator.appVersion; if(browser.indexOf("Netscape") >= 0){ if (popupButton != null) { if (typeof(this._peer.onkeydown) != "function") this._peer.onkeydown = function onkeydown(event) { this._peer._keydownfunc(event, this) }; } } else { if (popupButton != null) { if (typeof(this._peer.onkeydown) != "function") this._peer.onkeydown = function () { this._peer._keydownfunc(event, this) }; } } } // // // function getQualifiedName( bAsRegExp, bAsId, bNameless ) { var sEscape = ""; var sBegin = ""; var sEndBrace = ""; if (bAsRegExp) sEscape = "\\"; if (bAsId) { sBeginBrace = "_"; sEndBrace = ""; } else { sBeginBrace = "["; sEndBrace = "]"; } var sID = this.name + sEscape + sBeginBrace; if (bAsRegExp) sID = sID + "\\d+"; else sID = sID + this.index; sID = sID + sEscape + sEndBrace; var oParent = this.parent; while (oParent != null) { var sParentName = oParent.name; if ((bNameless == true) || (sParentName != "#subform")) { // skip nameless subforms if bNameless is false // don't include top most subform if ((oParent.parent != null) && (oParent.parent.parent != null)) { var sParentID = oParent.name + sEscape + sBeginBrace; if (bAsRegExp) sParentID = sParentID + "\\d+"; else sParentID = sParentID + oParent.index; sParentID = sParentID + sEscape + sEndBrace + sEscape + "."; sID = sParentID + sID; } } oParent = oParent.parent; }; return sID; } function getFullName( ) { return this.name + "[" + this.index + "]"; } function getParentSubformPeer( obj ) { // // search for parent DIV var oDiv = null; var oSubform = null; var oParentNode = obj.parentNode; while (true) { if ((oParentNode.tagName == null)||(oParentNode.tagName.toLowerCase() == "form")) { oDiv = null; break; } if (_isSubformPeer(oParentNode)) { if ((oParentNode.id.indexOf("_fsw") == -1) && (oParentNode.id.indexOf('_fsca') == -1)) { oDiv = (oParentNode.id == "fsFormBody") ? null : oParentNode; break; } } oParentNode = oParentNode.parentNode; } return oDiv; } function getParent( obj ) { var oDiv = null; var oSubform = null; oDiv = getParentSubformPeer( obj ); if (oDiv == null) { if (rootSubform == null) rootSubform = obj._peer; } else { if ((typeof(oDiv._peer) == "undefined") || (oDiv._peer == null)) { oSubform = new subformFunc ( oDiv ); } else { oSubform = oDiv._peer; } } if (oSubform != null) { obj._peer._idx = oSubform._children.length; oSubform._children[oSubform._children.length++] = obj._peer; } return oSubform; } function cacheId( ) { var oParent = this.parent; if (this._bRadio != true) { sID = this.name; if (this.index > 0) sID = sID + "[" + this.index + "]" } else sID = ""; // exclude root and panel subforms while ((oParent != null) && (oParent.parent != null)) { var sParentName = oParent.name; if (sParentName != "#subform") { // skip nameless subforms var sParentID = oParent.name; if (oParent.index > 0) sParentID = sParentID + "[" + oParent.index + "]" if (sID != "") sID = sParentID + "/" + sID; else sID = sParentID; } oParent = oParent.parent; }; return sID; } function getFullName( ) { return this.name + "[" + this.index + "]"; } function _getProperty( sProp ) { if (bIsOpera) return ( this.style[sProp] ); if (bIsNetscapelt62) return ( this.style[sProp] ); var vProp; if (this.currentStyle) { vProp = this.currentStyle[sProp]; this.style[sProp]; } else if (document.defaultView && document.defaultView.getComputedStyle) { if (sProp == 'backgroundColor') sProp = 'background-color'; else if (sProp == 'borderColor') sProp = 'border-top-color'; else if (sProp == 'borderTopWidth') sProp = 'border-top-width'; vProp = document.defaultView.getComputedStyle(this, null).getPropertyValue(sProp); } else { vProp = this.style[sProp]; } if ((typeof(vProp) != 'string') || (vProp.length == 0)) { //alert("can't get " + this.name + " : " + sProp ); vProp = "undefined"; } return vProp; } function setNameAndIndex( obj, sExpression ) { var bIsIdExpr = false; var index = sExpression.lastIndexOf("."); if (index >= 0) sExpression = sExpression.slice( index + 1 ); var regexp = null; var arr = null; regexp = /(\S*)\[(\S*)\]/ arr = sExpression.match( regexp ); if (arr == null) { //XHTML ids var pos = sExpression.lastIndexOf("_"); if (pos > -1) { sExpression = sExpression.substring(0, pos) + ":" + sExpression.substring(pos + 1); } regexp = /(\S*):(\S*)/ arr = sExpression.match( regexp ); bIsIdExpr = true; } if (arr == null) { obj.name = sExpression; obj.index = 0; } else { obj.name = arr[1]; obj.index = parseInt( arr[2]); } //final name fix up for ID expressions only if (bIsIdExpr) { var sName = obj.name; if (sName.indexOf("N") == 0) { //this is a named field - remove the N obj.name = sName.substring(1); } if (sName.indexOf("U") == 0) { //this is an unnamed field - replace U with # obj.name = "#" + sName.substring(1); } } } function SOMExpression( sExpression ) { // FSDebug_("SOMExpression " + sExpression ); var regexp = /(\S*)\[(\S*)\]/ var arr = sExpression.match( regexp ); this.scalerMatch = null; if (arr == null) { this.name = sExpression; if (xfa._currentContext == null) this.index = 0; else this.index = xfa._currentContext._contextOcc; this._bDefaultIndex = true; } else { this._bDefaultIndex = false; this.name = arr[1]; if ( arr[2] == '*' ) this.index = '*'; else this.index = parseInt( arr[2]); } this._matchCount = 0; this.equals = function ( obj ) { return ( this.namesEqual(obj) || this.classesEqual( obj) ) }; this.namesEqual = function ( obj ) { // FSDebug_( "nameEqual?" + this.name + "[" + this.index + "]" + " : " + obj.name + "[" + obj.index + "]"); var bRet; if (this.name == obj.name) { if (((this.index == '*') || (this.index == obj.index))) return true; if ((this._bDefaultIndex) && (obj.index == 0)) this.scalerMatch = obj; } return false; } this.classesEqual = function( obj ) { if ( ((this.name == "#field") && (obj.constructor._className == "Field")) || ((this.name == "#subform") && (obj.constructor._className == "Subform")) ) { var bRet = false; if (this.index == '*') { bRet = true; } else { if (this._matchCount == this.index) bRet = true; else bRet = false; } this._matchCount++; return bRet; } } } function Collection( oArray ) { this.array = oArray; this.length = oArray.length; this.item = function ( index ) { return this.array[index]; }; } function _resolveNodes( sSomExpression ) { var oArray = _resolveNodesCommon( this, sSomExpression, true ); return new Collection ( oArray ); } function _resolveNode( sSomExpression ) { return _resolveNodesCommon( this, sSomExpression, false ); } function _resolveNodesCommon( obj, sSomExpression, bMultiple ) { // FSDebug_(obj.constructor._className + " : " + obj.name + " resolve nodes " + sSomExpression ); if (obj.constructor._className == "Form") { return _resolveNodesCommon( rootSubform, sSomExpression, bMultiple ); } if (obj.constructor._className == "Xfa") { if (xss._this != null) return _resolveNodesCommon( xss._this, sSomExpression, bMultiple ); else return _resolveNodesCommon( rootSubform, sSomExpression, bMultiple ); } var arr1 = sSomExpression.split("."); var oSOM = new SOMExpression( arr1[0] ); var oChildren = null; var oParent = obj; var si = 0; var bRootMatch = false; if (oSOM.equals( obj ) || (oSOM.scalerMatch == obj)) { bRootMatch = true; // // found // if ((arr1.length == 1)) { if (!bMultiple) return obj; oParent = obj.parent; if (oParent == null) return new Array( obj ); si = 0; } else { si = 1; oSOM = new SOMExpression( arr1[1] ); } } if (obj.constructor._className == "Subform") { for (var j = si; j < arr1.length; j++) { var bLast = ((j + 1) == arr1.length); oChildren = _findChildren( oParent, oSOM, bMultiple ); if (oChildren == null) break; bRootMatch = true; if (bLast == false) { oSOM = new SOMExpression( arr1[j+1] ); oParent = oChildren; } } } if (oChildren != null) { return oChildren; } if ((bRootMatch == true) || (obj.parent == null)) { if (bMultiple) return new Array(); return null; } else { // // try parent return _resolveNodesCommon( obj.parent, sSomExpression, bMultiple ); } } function _findChildren( oParents, oSOM, bMultiple ) { var oParent = null; var arr = null; if (oParents.constructor == Array) { if (bMultiple == false) { oParent = oParents[0]; arr = _findChildrenUnderSingleParent(oParent, oSOM, bMultiple); } else { for (var count = 0; count < oParents.length; count++) { var oParent = oParents[count]; if (arr == null) arr = new Array(); arr = arr.concat(_findChildrenUnderSingleParent(oParent, oSOM, bMultiple)); } } } else { arr = _findChildrenUnderSingleParent(oParents, oSOM, bMultiple); } return arr; } function _findChildrenUnderSingleParent( oParent, oSOM, bMultiple) { var arr = null; for (var j = 0; j < oParent._children.length; j++) { var oChild = oParent._children[j]; if (oSOM.equals( oChild )) { if (bMultiple == false) { return oChild; } else { if (arr == null) arr = new Array(); arr[arr.length] = oChild; if (oSOM.index != '*') break; } } } if (oSOM.scalerMatch != null) { if (bMultiple == false) return oSOM.scalerMatch; else arr = new Array( oSOM.scalerMatch ); } return arr; } function _enumerate( index ) { if (typeof(debugWin) == "undefined") return; debugWin.document.writeln(_indent(index) + this.constructor._className + " : name : " + this.name); for (var prop in this) { if (prop.charAt(0) != '_') { var oProp = this[prop]; var sValue = ""; if (typeof(oProp) == "function") sValue = "function"; else if (typeof(oProp) == "object") sValue = (oProp == null) ? "null" : oProp.name; else sValue = oProp; debugWin.document.writeln( _indent(index + 1) + prop + " = " + sValue ); } } if (typeof(this._children) == "undefined") return; var oChildren = this._children; for (var i = 0; i < oChildren.length; i++) oChildren[i]._enumerate( index + 1 ); } function _indent( num ) { var s = ""; for (var j = 0; j < num; j++) { s = s + " "; } return s; } function _importData() { } function _exportData() { } function initScriptObject( sScriptText, obj ) { var sEvalScript = "new " + sScriptText; var oScriptObject = eval(sEvalScript); if (oScriptObject == null) { alert("unable to create " + sScriptText); } oScriptObject.constructor._className = "ScriptObject"; setNameAndIndex( oScriptObject, obj.name ); obj._peer = oScriptObject; oScriptObject._peer = obj; oScriptObject.parent = getParent( obj ); } function subformInit( sMessage, sInit, sCalc, sVal, sEnter, sExit, nMinOccur, nMaxOccur ) { FSDebug_("subform init begin : " + this.name); this.validationMessage = sMessage; this._initScript = sInit; this._calcScript = sCalc; this._valScript = sVal; this._enterScript = sEnter; this._exitScript = sExit; if (typeof(nMinOccur) == 'undefined') { nMinOccur = null; nMaxOccur = null; } this._nMinOccur = nMinOccur; this._nMaxOccur = nMaxOccur; FSDebug_("subform init end : " + this.name); } function initButton( type, somExpression, bValidate, validationMsg, vScript, calcScript, initScript ) { this._initField( bValidate, 'disabled', '', validationMsg, vScript, calcScript, initScript, '', '' ); this.buttonType = type; this.somExpression = somExpression; } function initCheckButton( bValidate, sMandatory, mandatoryMsg, validationMsg, vScript, calcScript, initScript, sOnValue, sOffValue, sBindMatch, sDataRef ) { this._initField( bValidate, sMandatory, mandatoryMsg, validationMsg, vScript, calcScript, initScript, sBindMatch, sDataRef ); if (sOnValue.length > 0) this._onValue = sOnValue; if (sOffValue.length > 0) this._offValue = sOffValue; this.formattedValue = getHTMLValue( this ); /* Fix for watson#1727769 initCheckButton gets called after the field is added in xfa model. For cahced renditions, oCache is looked up in addFieldToModel function. So after init'ing radio button/check boxes, we should update the onValue of field from oCache. */ xss._updateCheckButtonCachedValue(this); } /* * Watson# 1753260. If none of the option is marked selected, make selected index = -1; */ function initChoiceList( bValidate, sMandatory, mandatoryMsg, validationMsg, vScript, calcScript, initScript, sBindMatch, sDataRef ) { this._initField( bValidate, sMandatory, mandatoryMsg, validationMsg, vScript, calcScript, initScript, sBindMatch, sDataRef ); this._bSelect = true; if (xss.bUseCache) { var sCacheId = this._cacheId(); var oCachedValue = oCache[sCacheId]; if (typeof(oCachedValue) != "undefined") { return; } } var selectElem = this._peer; //