XFormsCaption.prototype = new XFormsBindableControl; function XFormsCaption (strParentId, strAlert, strHelp, strHint, strText, strAccesskey, bAutoresize, strBind, strClass, bDisabled, bEllipsis, strFormat, strId, nNavindex, strRef, strRoundMode, nRoundPosition, strStyle, strTag, strVisibility, strUserDefineAttrib) { if (!strId) { return; } XFormsBindableControl.call(this, strParentId, strAlert, strHelp, strHint, strAccesskey, strBind, strClass, bDisabled, strId, nNavindex, strRef, strStyle, strTag, strVisibility, strUserDefineAttrib); /** * Attribute */ strText = strText.split("__TF_STR_N").join("\\n"); strText = strText.split("__TF_STR_T").join("\\t"); strText = strText.split("__TF_STR_R").join("\\r"); strText = strText.split("\_\_TF\_N").join("\n"); strText = strText.split("\_\_TF\_T").join("\t"); strText = strText.split("\_\_TF\_R").join("\r"); this.attribute["text"] = strText; this.attribute["autoresize"] = String(bAutoresize); this.attribute["ellipsis"] = String(bEllipsis); this.attribute["format"] = strFormat; this.attribute["roundmode"] = strRoundMode; this.attribute["roundposition"] = String(nRoundPosition); /** * Property */ this.ellipsis = bEllipsis; this.label = strText; this.m_heControlText = document.getElementById("HE_" + this.id + "_TEXT"); }; /** * Attribute 값을 변경시키고 Attribute 값 변화에 맞는 동작을 수행한다. * @param strAttribute * @param strValue * @return */ XFormsCaption.prototype.init = function () { XFormsBindableControl.prototype.init.call(this); if ("xforms:caption" == this.attribute["tag"] ||"xforms:output" == this.attribute["tag"]) { if("true" != this.attribute["autoresize"]) { this.m_heControlText.style.overflow = "hidden"; // 말줄임 표시(Ellipsis) Attribute 설정 if("" != this.attribute["ellipsis"]) { this.m_heControlText.style.noWrap = "true"; this.setEllipsis(this.attribute["ellipsis"]); } } else { this.m_heControlText.style.overflow = "visible"; } } this.resizeControl(); }; XFormsCaption.prototype.getAbility = function () { return EA_CONTROL | EA_HAS_FORMAT | EA_HAS_TEXT; }; /** * 인스턴스 데이터를 실제 컨트롤에 반영 * @return */ XFormsCaption.prototype.refresh = function () { if (null != this.m_heControl) { var strValue = ""; if (this.m_bBinded) { strValue = this.getValue(); } else { strValue = this.getAttribute("text"); } var nFormatStatus = formatStatus(this.attribute["format"]); if (0 != nFormatStatus) // format이 존재한다면 { if (null == strValue) { strValue = ""; } strValue = strValue.formatting(this.attribute["format"]); if (4 == nFormatStatus && "" != this.attribute["roundmode"] && "" != this.attribute["roundposition"]) {//roundmode설정이 정상적으로 있다면 형식대로 처리 strValue = getRoundMode(strValue, this.attribute["roundmode"], this.attribute["roundposition"]); } } if (null != this.m_heControlText) { if (null == strValue) { strValue = ""; } strValue = strValue.newlineCharConvert(); this.m_heControlText.innerHTML = strValue; } //this.__verticalAlign(); } }; XFormsCaption.prototype.applyDefaultStyle = function () { XFormsBindableControl.prototype.applyDefaultStyle.call(this); if (!this.attribute["cursor"]) { HtmlLib.setStyle(this.m_heControl, "cursor", "default"); } }; XFormsCaption.prototype.getBindingType = function () { return BT_SINGLE; }; XFormsCaption.prototype.setText = function (strText) { if (null != this.m_heControlText) { XFormsBindableControl.prototype.setText.call(this, strText); if (null == strText) { strText = ""; } this.m_heControlText.innerHTML = strText.newlineCharConvert(); } }; XFormsCaption.prototype.setAttribute = function (strAttribute, strValue) { XFormsBindableControl.prototype.setAttribute.call(this, strAttribute, strValue); switch (strAttribute) { case "text" : { if ("xforms:caption" == this.attribute["tag"] ||"xforms:output" == this.attribute["tag"]) { this.text = strValue; this.attribute["text"] = strValue; this.setText(strValue); break; } } case "autoresize" : { if ("true" == strValue) { this.attribute["autoresize"] = true; this.m_heControl.style.overflow = "visible"; } else if ("false" == strValue) { this.attribute["autoresize"] = false; this.m_heControl.style.overflow = "hidden"; } break; } case "ellipsis" : { if ("true" == strValue) { this.attribute["ellipsis"] = "true"; this.m_heControl.style.textOverflow = "ellipsis"; this.m_heControl.style.whiteSpace = "nowrap"; } else if ("false" == strValue) { this.attribute["ellipsis"] = "false"; this.m_heControl.style.textOverflow = "clip"; this.m_heControl.style.whiteSpace = "normal"; } break; } case "format" : { this.attribute["format"] = strValue; break; } case "roundmode" : { this.attribute["roundmode"] = strValue; break; } case "roundposition" : { this.attribute["roundposition"] = strValue; break; } } }; XFormsCaption.prototype.setEllipsis = function (bEllipsis) { // Property 변경 this.ellipsis = bEllipsis; // Attribute 변경 this.attribute["ellipsis"] = bEllipsis; var strTagName = this.attribute["tag"]; if ("xforms:button" != strTagName) { // HTML 적용 if ("true" == bEllipsis) { this.m_heControlText.style.textOverflow = "ellipsis"; } else { this.m_heControlText.style.textOverflow = "clip"; } } else { if ("false" == bEllipsis) { this.m_heControl.style.textOverflow = "ellipsis"; } else { this.m_heControl.style.textOverflow = "clip"; } } }; XFormsCaption.create = function (strParentId, clAttribute, strStyle) { // 메인노드 생성 var xnCaption = XFormsCaption.createMainNode(clAttribute); var xnParent = document.getElementById("HE_"+strParentId); xnParent.appendChild(xnCaption); // 하위노드 생성 xnCaption = XFormsCaption.createSubNodes(xnCaption, clAttribute); // object 생성 return XFormsCaption.createObject(strParentId, xnCaption, clAttribute, strStyle); }; XFormsCaption.createMainNode = function (clAttribute) { var xnCaption = document.createElement("table"); xnCaption = XFormsCaption.createAttribute(xnCaption, clAttribute); xnCaption.onclick = function () {}; xnCaption.ondbclick = function () {}; xnCaption.onmousedown = function () {}; xnCaption.onmousemove = function () {}; xnCaption.onmouseup = function () {}; return xnCaption; }; XFormsCaption.createSubNodes = function (xnCaption, clAttribute) { // 상위의 아이디를 가져온다. var strId = clAttribute.item("id"); var xnCaptionTbody = document.createElement("tbody"); var xnCaptionTR = document.createElement("tr"); var xnCaptionTD = document.createElement("td"); xnCaptionTD.setAttribute("id", "HE_" + strId + "_TEXT"); xnCaptionTD.style.overflow = "hidden"; if (xnCaption.getAttribute("text")) xnCaptionTD.innerHTML = xnCaption.getAttribute("text").newlineCharConvert(); xnCaptionTR.appendChild(xnCaptionTD); xnCaptionTbody.appendChild(xnCaptionTR); xnCaption.appendChild(xnCaptionTbody); return xnCaption; }; XFormsCaption.createObject = function (strParentId, xnCaption, clAttribute, strStyle) { var strAlert = ""; var strHelp = ""; var strHint = ""; var strText = ""; var strAccesskey = ""; var bAutoResize = false; var strBind = ""; var strClass = ""; var bDisabled = false; var bEllipsis = false; var strFormat = ""; var strId = ""; var nNavindex = 9007199254740992; var strRef = ""; var strRoundMode = ""; var nRoundPosition = 0; var strVisibility = "visible"; var strUserDefineAttrib = ""; for (var i=0; i