123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 |
- 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<clAttribute.count(); i++)
- {
- var strAttributeName = clAttribute.keys()[i];
- switch (strAttributeName)
- {
- case "alert" :
- {
- strAlert = clAttribute.item(strAttributeName);
- break;
- }
- case "help" :
- {
- strHelp = clAttribute.item(strAttributeName);
- break;
- }
- case "hint" :
- {
- strHint = clAttribute.item(strAttributeName);
- break;
- }
- case "text" :
- {
- strText = clAttribute.item(strAttributeName);
- break;
- }
- case "accesskey" :
- {
- strAccesskey = clAttribute.item(strAttributeName);
- break;
- }
- case "autoreisze" :
- {
- if ("true" == clAttribute.item(strAttributeName))
- {
- bAutoResize = true;
- }
- break;
- }
- case "bind" :
- {
- strBind = clAttribute.item(strAttributeName);
- break;
- }
- case "class" :
- {
- strClass = clAttribute.item(strAttributeName);
- break;
- }
- case "disabled" :
- {
- if ("true" == clAttribute.item(strAttributeName))
- {
- bDisabled = true;
- }
- break;
- }
- case "ellipsis" :
- {
- if ("true" == clAttribute.item(strAttributeName))
- {
- bEllipsis = true;
- }
- break;
- }
- case "format" :
- {
- strFormat = clAttribute.item(strAttributeName);
- break;
- }
- case "id" :
- {
- strId = clAttribute.item(strAttributeName);
- break;
- }
- case "navindex" :
- {
- nNavindex = parseInt(clAttribute.item(strAttributeName));
- break;
- }
- case "ref" :
- {
- strRef = clAttribute.item(strAttributeName);
- break;
- }
- case "roundmode" :
- {
- strRoundMode = clAttribute.item(strAttributeName);
- break;
- }
- case "roundposition" :
- {
- nRoundPosition = parseInt(clAttribute.item(strAttributeName));
- break;
- }
- case "visibility" :
- {
- strVisibility = clAttribute.item(strAttributeName);
- break;
- }
-
- default :
- {
- if (!STYLE_LIST[strAttributeName])
- {
- strUserDefineAttrib += strAttributeName + ":" + clAttribute.item(strAttributeName) + "; ";
- }
- break;
- }
- }
- }
- var objCaption = new XFormsCaption (strParentId, strAlert, strHelp, strHint, strText, strAccesskey, bAutoResize, strBind, strClass, bDisabled, bEllipsis, strFormat, strId, nNavindex, strRef, strRoundMode, nRoundPosition, strStyle, "xforms:caption", strVisibility, strUserDefineAttrib);
- return objCaption;
- };
- XFormsCaption.createAttribute = function (xnHtmlNode, clAttribute)
- {
- xnHtmlNode = XFormsBindableControl.createAttribute(xnHtmlNode, clAttribute);
- xnHtmlNode.cellSpacing = 0;
- xnHtmlNode.cellPadding = 0;
- xnHtmlNode.style.tableLayout = "fixed";
- return xnHtmlNode;
- };
|