/** * XFormsElementBase * * @param strParentId * @param strId * @param strTag * @return */ function XFormsElementBase (strParentId, strId, strTag) { if (!strId) { return; } // Property this.children = new Collection(); // child collection this.elementName = strTag; this.parent; this.id = strId; this.tag = strTag; this.text; this.m_strLocalTag = strTag; var nIndex = this.m_strLocalTag.indexOf(":"); if (-1 != nIndex) { this.m_strLocalTag = this.m_strLocalTag.substr(nIndex + 1); } this.m_objElement = null; this.setParent(strParentId); XFormsDocument.appendAll(strId, this); }; XFormsElementBase.prototype.getElement = function () { if (this.m_objElement) { this.m_objElement.setRefElement(this); } return this.m_objElement; }; XFormsElementBase.prototype.setElement = function (objElement) { this.m_objElement = objElement; }; XFormsElementBase.prototype.getAttribute = function (strName) { return null; }; XFormsElementBase.prototype.setAttribute = function (strName, strValue) { return; }; XFormsElementBase.prototype.getId = function () { return this.getAttribute("id"); }; XFormsElementBase.prototype.getTag = function () { return this.tag; }; XFormsElementBase.prototype.getLocalTag = function () { return this.m_strLocalTag; }; XFormsElementBase.prototype.getParent = function () { return this.parent; }; XFormsElementBase.prototype.setParent = function (strParentId) { if (this instanceof XFormsElementBase) { // 부모 setting var objParent = document.allElement.item(strParentId); this.parent = objParent; // 부모에 자식 세팅 if (objParent instanceof XFormsElementBase) { if (this instanceof XFormsModel) { if (objParent.children.exists(this.id)) { return; } } objParent.setChild(this.id, this); } } }; XFormsElementBase.prototype.setChild = function (strChildId, objChild) { this.children.add(strChildId, objChild); }; XFormsElementBase.prototype.getElementName = function () { return this.elementName; }; XFormsElementBase.prototype.getText = function () { return this.text; }; XFormsElementBase.prototype.setText = function (strText) { // TODO isParsed 처리 this.text = strText; this.attribute["text"] = strText; }; XFormsElementBase.prototype.isChild = function (strId) { var objElement = document.allElement.item(strId); if (!objElement) { return false; } return (this == objElement.parent); }; XFormsElementBase.prototype.isDescendants = function (strId, bIncludeThis) { var objElement = document.allElement.item(strId); if (!objElement) { return false; } var objParent; if (bIncludeThis) { objParent = objElement; } else { objParent = objElement.parent; } while (objParent) { if (this == objParent) { return true; } objParent = objParent.parent; } return false; }; /** * XFormsAttribute * @return */ XFormsAttribute.prototype = new XFormsElementBase; function XFormsAttribute (strParentId, strId, strTag) { if (!strId) { return; } XFormsElementBase.call(this, strParentId, strId, strTag); this.attribute = new Hashtable(); // Attribute this.attribute["id"] = strId; this.attribute["tag"] = strTag; /** * 일반 스티일 외의 스타일 */ this.m_htHoverStyle = null; // hover style this.m_htDownStyle = null; // down style this.m_htFocusStyle = null; // focus style this.m_htDisableStyle = null; // disable style this.m_htSelectStyle = null; // select style }; XFormsAttribute.prototype.initStyle = function (strAttribute) { }; XFormsAttribute.prototype.getAttribute = function (strName) { return this.attribute[strName]; }; XFormsAttribute.prototype.setAttribute = function (strName, objValue) { if (STYLE_LIST[strName]) { HtmlLib.setStyle(this.m_heControl, strName, objValue); } this.attribute[strName] = objValue; }; XFormsAttribute.prototype.applyDefaultStyle = function () { if (null != this.m_heControl) { if (this.attribute["right"]) { HtmlLib.setStyle(this.m_heControl, "right", this.attribute["right"]); } if (this.attribute["bottom"]) { HtmlLib.setStyle(this.m_heControl, "bottom", this.attribute["bottom"]); } if (!this.attribute["color"] && !this.m_heControl.style.color) { HtmlLib.setStyle(this.m_heControl, "color", "#000000"); } if (!this.attribute["font-family"] && !this.m_heControl.style.fontFamily) { HtmlLib.setStyle(this.m_heControl, "font-family", Lan_DefaultFontFamily); } if (!this.attribute["font-size"] && !this.m_heControl.style.fontSize) { HtmlLib.setStyle(this.m_heControl, "font-size", "10pt"); } if (this.attribute["word-wrap"]) { var strWordWrap = "break-word"; if ("none" == this.attribute["word-wrap"] || "hard" == this.attribute["word-wrap"]) { strWordWrap = "normal"; } HtmlLib.setStyle(this.m_heControl, "word-wrap", strWordWrap); } if (this.attribute["line-spacing"]) { var strLineSpacing = this.attribute["line-spacing"]; if (strLineSpacing) { var strLineHeight = (parseInt(strLineSpacing.replaceAll("px","")) + 18) + "px"; HtmlLib.setStyle(this.m_heControl, "line-height", strLineHeight); } } if (this.attribute["background-image"]) { if (!this.attribute["background-color"]) { HtmlLib.setStyle(this.m_heControl, "background-color", "transparent"); } var strBackgroundImage = this.attribute["background-image"]; if (0 > strBackgroundImage.indexOf("url(")) { HtmlLib.setStyle(this.m_heControl, "background-image", strBackgroundImage); } } if (!this.attribute["background-color"] && !this.m_heControl.style.backgroundColor) { //HtmlLib.setStyle(this.m_heControl, "background-color", "transparent"); } if (!this.attribute["background-repeat"] && !this.m_heControl.style.backgroundRepeat) { HtmlLib.setStyle(this.m_heControl, "background-repeat", "no-repeat"); } // background-position if (this.attribute["background-position"]) { var strBackgroundPosition = this.attribute["background-position"]; // background-position-x 설정 var strBackgroundPositionX = ""; if (-1 != strBackgroundPosition.indexOf("left")) { strBackgroundPositionX = "left"; } else if (-1 != strBackgroundPosition.indexOf("right")) { strBackgroundPositionX = "right"; } // background-position-y 설정 var strBackgroundPositionY = ""; if (-1 != strBackgroundPosition.indexOf("top")) { strBackgroundPositionY = "top"; } else if (-1 != strBackgroundPosition.indexOf("bottom")) { strBackgroundPositionY = "bottom"; } // 설정 값이 center일 때 if ("centercenter" == strBackgroundPosition) { strBackgroundPositionX = "center"; strBackgroundPositionY = "center"; } if (-1 != strBackgroundPosition.indexOf("center")) { if ("" == strBackgroundPositionX) strBackgroundPositionX = "center"; if ("" == strBackgroundPositionY) strBackgroundPositionY = "center"; } HtmlLib.setStyle(this.m_heControl, "background-position-x", strBackgroundPositionX); HtmlLib.setStyle(this.m_heControl, "background-position-y", strBackgroundPositionY); } else { HtmlLib.setStyle(this.m_heControl, "background-position-x", "left"); HtmlLib.setStyle(this.m_heControl, "background-position-y", "top"); } // opacity if (this.attribute["opacity"]) { var strOpacity = this.attribute["opacity"]; HtmlLib.setStyle(this.m_heControl, "opacity", strOpacity); } // cursor if (this.attribute["cursor"]) { var strCursor = this.attribute["cursor"]; HtmlLib.setStyle(this.m_heControl, "cursor", strCursor); } // border-width if (this.attribute["border-width"]) { // var nWidthIndex = arKey.find("border-width"); // var nLeftWidthIndex = arKey.find("border-left-width"); // var nTopWidthIndex = arKey.find("border-top-width"); // var nRightWidthIndex = arKey.find("border-right-width"); // var nBottomWidthIndex = arKey.find("border-bottom-width"); // // if (nWidthIndex < nLeftWidthIndex || // nWidthIndex < nTopWidthIndex || // nWidthIndex < nRightWidthIndex || // nWidthIndex < nBottomWidthIndex) { HtmlLib.setStyleFront(this.m_heControl, "border-width", this.attribute["border-width"]); } } else { HtmlLib.setStyleFront(this.m_heControl, "border-width", "1px"); } // border-style if (this.attribute["border-style"]) { var bSunken = false; if ("hidden" == this.attribute["border-style"]) { HtmlLib.setStyle(this.m_heControl, "border-style", "none"); } else if ("sunken" == this.attribute["border-style"]) { bSunken = true; } if ("hidden" == this.attribute["border-left-style"]) { HtmlLib.setStyle(this.m_heControl, "border-left-style", "none"); } else if ("sunken" == this.attribute["border-left-style"]) { bSunken = true; } if ("hidden" == this.attribute["border-top-style"]) { HtmlLib.setStyle(this.m_heControl, "border-top-style", "none"); } else if ("sunken" == this.attribute["border-top-style"]) { bSunken = true; } if ("hidden" == this.attribute["border-right-style"]) { HtmlLib.setStyle(this.m_heControl, "border-right-style", "none"); } else if ("sunken" == this.attribute["border-right-style"]) { bSunken = true; } if("hidden" == this.attribute["border-bottom-style"]) { HtmlLib.setStyle(this.m_heControl, "border-bottom-style", "none"); } else if ("sunken" == this.attribute["border-bottom-style"]) { bSunken = true; } if (bSunken) { HtmlLib.setStyle(this.m_heControl, "border-left-style", ""); HtmlLib.setStyle(this.m_heControl, "border-top-style", ""); HtmlLib.setStyle(this.m_heControl, "border-right-style", ""); HtmlLib.setStyle(this.m_heControl, "border-bottom-style", ""); HtmlLib.setStyle(this.m_heControl, "border-style", "inset"); HtmlLib.setStyle(this.m_heControl, "border-width", "2px"); } else { HtmlLib.setStyleFront(this.m_heControl, "border-style", this.attribute["border-style"]); } } } }; XFormsAttribute.prototype.setChildStyle = function () { if (!this.parent || !this.parent.m_heControl) { return; } if (!this.attribute["font-family"] && !this.m_heControl.style.fontFamily && -1 != this.parent.m_strStyle.indexOf("font-family")) { HtmlLib.setStyle(this.m_heControl, "font-family", this.parent.m_heControl.style.fontFamily); } if (!this.attribute["font-size"] && !this.m_heControl.style.fontSize && -1 != this.parent.m_strStyle.indexOf("font-size")) { HtmlLib.setStyle(this.m_heControl, "font-size", this.parent.m_heControl.style.fontSize); } if (!this.attribute["font-weight"] && !this.m_heControl.style.fontWeight && -1 != this.parent.m_strStyle.indexOf("font-weight")) { HtmlLib.setStyle(this.m_heControl, "font-weight", this.parent.m_heControl.style.fontWeight); } if (!this.attribute["font-style"] && !this.m_heControl.style.fontStyle && -1 != this.parent.m_strStyle.indexOf("font-style")) { HtmlLib.setStyle(this.m_heControl, "font-style", this.parent.m_heControl.style.fontStyle); } if (!this.attribute["text-decoration"] && !this.m_heControl.style.textDecoration && -1 != this.parent.m_strStyle.indexOf("text-decoration")) { HtmlLib.setStyle(this.m_heControl, "text-decoration", this.parent.m_heControl.style.textDecoration); } if (!this.attribute["color"] && !this.m_heControl.style.color && -1 != this.parent.m_strStyle.indexOf("color")) { HtmlLib.setStyle(this.m_heControl, "color", this.parent.m_heControl.style.color); } if (!this.attribute["text-align"] && !this.m_heControl.style.textAlign && -1 != this.parent.m_strStyle.indexOf("text-align")) { HtmlLib.setStyle(this.m_heControl, "text-align", this.parent.m_heControl.style.textAlign); } if (!this.attribute["vertical-align"] && !this.m_heControl.style.verticalAlign && -1 != this.parent.m_strStyle.indexOf("vertical-align")) { HtmlLib.setStyle(this.m_heControl, "vertical-align", this.parent.m_heControl.style.verticalAlign); } if (!this.attribute["line-height"] && !this.m_heControl.style.lineHeight && -1 != this.parent.m_strStyle.indexOf("line-height")) { HtmlLib.setStyle(this.m_heControl, "line-height", this.parent.m_heControl.style.lineHeight); } if (!this.attribute["letter-spacing"] && !this.m_heControl.style.letterSpacing && -1 != this.parent.m_strStyle.indexOf("letter-spacing")) { HtmlLib.setStyle(this.m_heControl, "letter-spacing", this.parent.m_heControl.style.letterSpacing); } if (!this.attribute["background-repeat"] && !this.m_heControl.style.backgroundRepeat && -1 != this.parent.m_strStyle.indexOf("background-repeat")) { HtmlLib.setStyle(this.m_heControl, "background-repeat", "no-repeat"); } if (!this.attribute["cursor"] && !this.m_heControl.style.cursor && -1 != this.parent.m_strStyle.indexOf("cursor")) { HtmlLib.setStyle(this.m_heControl, "cursor", this.parent.m_heControl.style.cursor); } }; XFormsAttribute.prototype.setNotObjToChildStyle = function () { //물리적인 컨트롤이 존재하지 않는 객체(item..)들의 부모 기본 스타일을 받는다 if (!this.parent || !this.parent.m_heControl) { return; } if (!this.attribute["font-family"]) { this.setAttribute("font-family", this.parent.m_heControl.style.fontFamily); } if (!this.attribute["font-size"]) { this.setAttribute("font-size", this.parent.m_heControl.style.fontSize); } if (!this.attribute["font-weight"]) { this.setAttribute("font-weight", this.parent.m_heControl.style.fontWeight); } if (!this.attribute["font-style"]) { this.setAttribute("font-style", this.parent.m_heControl.style.fontStyle); } if (!this.attribute["text-decoration"]) { this.setAttribute("text-decoration", this.parent.m_heControl.style.textDecoration); } if (!this.attribute["color"]) { this.setAttribute("color", this.parent.m_heControl.style.color); } if (!this.attribute["line-height"]) { this.setAttribute("line-height", this.parent.m_heControl.style.lineHeight); } if (!this.attribute["letter-spacing"]) { this.setAttribute("line-height", this.parent.m_heControl.style.letterSpacing); } if (!this.attribute["background-repeat"]) { this.setAttribute("line-height", this.parent.m_heControl.style.backgroundRepeat); } if (!this.attribute["cursor"]) { this.setAttribute("line-height", this.parent.m_heControl.style.cursor); } }; XFormsAttribute.createAttribute = function (xnHtmlNode, clAttribute) { return xnHtmlNode; }; XFormsAttribute.prototype.setHoverStyle = function (htStyle) { this.m_htHoverStyle = htStyle; }; XFormsAttribute.prototype.getHoverAttribute = function (strKey) { var strValue = null; if (null != this.m_htHoverStyle) { return this.m_htHoverStyle[strKey]; } return strValue; }; XFormsAttribute.prototype.setHoverAttribute = function (strKey, strName) { if (null == this.m_htHoverStyle) { this.m_htHoverStyle = new Hashtable(); } this.m_htHoverStyle[strKey] = strName; }; XFormsAttribute.prototype.setDownStyle = function (htStyle) { this.m_htDownStyle = htStyle; }; XFormsAttribute.prototype.getDownAttribute = function (strKey) { var strValue = null; if (null != this.m_htDownStyle) { return this.m_htDownStyle[strKey]; } return strValue; }; XFormsAttribute.prototype.setDownAttribute = function (strKey, strName) { if (null == this.m_htDownStyle) { this.m_htDownStyle = new Hashtable(); } this.m_htDownStyle[strKey] = strName; }; XFormsAttribute.prototype.setFocusStyle = function (htStyle) { this.m_htFocusStyle = htStyle; }; XFormsAttribute.prototype.getFocusAttribute = function (strKey) { var strValue = null; if (null != this.m_htFocusStyle) { return this.m_htFocusStyle[strKey]; } return strValue; }; XFormsAttribute.prototype.setFocusAttribute = function (strKey, strName) { if (null == this.m_htFocusStyle) { this.m_htFocusStyle = new Hashtable(); } this.m_htFocusStyle[strKey] = strName; }; XFormsAttribute.prototype.setDisableStyle = function (htStyle) { this.m_htDisableStyle = htStyle; }; XFormsAttribute.prototype.getDisableAttribute = function (strKey) { var strValue = null; if (null != this.m_htDisableStyle) { return this.m_htDisableStyle[strKey]; } return strValue; }; XFormsAttribute.prototype.setDisableAttribute = function (strKey, strName) { if (null == this.m_htDisableStyle) { this.m_htDisableStyle = new Hashtable(); } this.m_htDisableStyle[strKey] = strName; }; XFormsAttribute.prototype.setSelectStyle = function (htStyle) { this.m_htDisableStyle = htStyle; }; XFormsAttribute.prototype.getSelectAttribute = function (strKey) { var strValue = null; if (null != this.m_htSelectStyle) { return this.m_htSelectStyle[strKey]; } return strValue; }; XFormsAttribute.prototype.setSelectAttribute = function (strKey, strName) { if (null == this.m_htSelectStyle) { this.m_htSelectStyle = new Hashtable(); } this.m_htSelectStyle[strKey] = strName; }; XFormsAttribute.prototype.getSelectAttribute = function (strKey) { if (null == this.m_htSelectStyle) { return ""; } return this.m_htSelectStyle[strKey]; }; /** * XFormsElement */ XFormsElement.prototype = new XFormsAttribute; function XFormsElement (strParentId, strId, strTag) { if (!strId) { return; } XFormsAttribute.call(this, strParentId, strId, strTag); this.m_hmEvent = new Hashtable(); this.m_objRefElement = null; }; XFormsElement.prototype.init = function () { }; XFormsElement.prototype.getElement = function () { return this; }; XFormsElement.prototype.getRefElement = function () { return this.m_objRefElement; }; XFormsElement.prototype.setRefElement = function (objElementBase) { this.m_objRefElement = objElementBase; }; XFormsElement.prototype.isCSSValid = function (strKey) { var bValid = false; if ((null == this.attribute[strKey] || "" == this.attribute[strKey]) && (null == HtmlLib.getStyle(this.m_heControl, strKey) || "" == HtmlLib.getStyle(this.m_heControl, strKey))) { bValid = true; } return bValid; }; /** * 자식 엘리먼트를 만드는 함수 XFormsElement를 상속받는 클래스에서 재정의 해서 쓰자. * @param strElement * @param strAttribute * @return */ XFormsElement.prototype.createChild = function (strElementName, strAttribute) { strAttribute = strAttribute.trim(); if (";" == strAttribute.charAt(strAttribute.length - 1)) { strAttribute = strAttribute.substring(0, strAttribute.length - 1); } var arAttribute = strAttribute.split(";"); var strStyle = ""; var clAttribute = new Collection(); var strAttributeName; var strAttributeValue; for (var i=0; i 32) { // TODO Error Message event.m_nRef--; return; } // run capture if ("" != event.capture) { var objCapture = document.allElement.item(event.capture); if (null != objCapture && EA_HAS_EVENT & objCapture.getAbility()) { // objCapture.runAction("oncapture"); if ("cancel" != event.defaultAction) { objCapture.onCapture(event); } } } this.internalDispatch(strEventName); event.name = strOriginEventName; event.target = strOriginTarget; event.currentTarget = strOriginCurrentTarget; event.description = strOriginDescription; event.propagate = strOriginPropagate; event.defaultAction = strOriginDefaultAction; event.m_nRef--; try { if (!((this instanceof XFormsTextArea) || (this instanceof XFormsGroup))) { if (event.name != "onkeypress" && event.name != "onkeydown" && event.name != "onkeyup" && event.name != "onmousewheel") { // if (!(this instanceof XFormsCol && this.m_bInputKey)) // { event.m_browserEvent.returnValue = false; if (event.m_browserEvent.stopPropagation) { event.m_browserEvent.stopPropagation(); event.m_browserEvent.preventDefault(); } // } } } } catch (e) { // TODO exception } }; XFormsElement.prototype.addEventListener = function (strEventName, strHandler, strPropagate, strDefaultAction, strActionArg1, strActionArg2, strActionArg3) { var objEvent = new TFEvent(); objEvent.name = strEventName; objEvent.handler = strHandler; objEvent.propagate = strPropagate; objEvent.defaultAction = strDefaultAction; if ("inPacking_destroy" == strHandler) { objEvent.ref = strActionArg1; } else if ("inPacking_dispatch" == strHandler) { objEvent.dispatchtarget = strActionArg1; objEvent.dispatchtargetname = strActionArg2; } else if ("inPacking_load" == strHandler) { objEvent.resource = strActionArg1; objEvent.show = strActionArg2; } else if ("inPacking_message" == strHandler) { objEvent.src = strActionArg1; objEvent.level = strActionArg2; objEvent.text = strActionArg3; } else if ("inPacking_reset" == strHandler) { objEvent.model = strActionArg1; } else if ("inPacking_send" == strHandler) { objEvent.submission = strActionArg1; } else if ("inPacking_setfocus" == strHandler) { objEvent.control = strActionArg1; } else if ("inPacking_setvalue" == strHandler) { objEvent.ref = strActionArg1; objEvent.value = strActionArg2; } else if ("inPacking_toggle" == strHandler) { objEvent.togglecase = strActionArg1; } var alEvent = this.m_hmEvent[strEventName]; if (alEvent) { alEvent.push(objEvent); } else { alEvent = new Array(); alEvent.push(objEvent); this.m_hmEvent[strEventName] = alEvent; } }; XFormsElement.prototype.eventAddAttribute = function (event, objEvent) { event.handler = objEvent.handler; event.propagate = objEvent.propagate; event.defaultAction = objEvent.defaultAction; if ("inPacking_destroy" == event.handler) { event.ref = objEvent.ref; } else if ("inPacking_dispatch" == event.handler) { event.dispatchtarget = objEvent.dispatchtarget; event.dispatchtargetname = objEvent.dispatchtargetname; } else if ("inPacking_load" == event.handler) { event.resource = objEvent.resource; event.show = objEvent.show; } else if ("inPacking_message" == event.handler) { event.src = objEvent.src; event.level = objEvent.level; event.text = objEvent.text; } else if ("inPacking_reset" == event.handler) { event.text = objEvent.model; } else if ("inPacking_send" == event.handler) { event.submission = objEvent.submission; } else if ("inPacking_setfocus" == event.handler) { event.control = objEvent.control; } else if ("inPacking_setvalue" == event.handler) { event.ref = objEvent.ref; event.value = objEvent.value; } else if ("inPacking_toggle" == event.handler) { event.togglecase = objEvent.togglecase; } return event; }; XFormsElement.prototype.internalDispatch = function (strEventName) { var event = XFormsWindow.getCurrentEvent(); event.name = strEventName; event.currentTarget = this.getId(); event.propagate = ""; event.defaultAction = ""; this.preTranslateEvent(event); var strGlobalFunc = ""; if (event.name) { strGlobalFunc = event.name; strGlobalFunc = strGlobalFunc.replaceAll("-", "_"); } if (!("stop" == event.propagate)) { this.fireEvent(strGlobalFunc); } var alEvent = this.m_hmEvent[strEventName]; if(alEvent && !("stop" == event.propagate)) { for (var i=0; i