BS_DESELECTED = 0; BS_SELECTED = 1; BS_NONESELECTED = 2; BM_2STATE = 0; BM_3STATE = 1; XFormsBool.prototype = new XFormsBindableControl; function XFormsBool (strParentId, strAlert, strHelp, strHint, strAccesskey, strBind, strCheckValue, strClass, bDisabled, strId, nNavindex, strRef, 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 */ this.attribute["checkvalue"] = strCheckValue; this.attribute["mode"] = "2state"; /** * property */ this.selected = false; this.m_nState = 0; this.m_strTrue = "true"; this.m_strFalse = "false"; this.m_strNone; if (null != strCheckValue && "" != strCheckValue) { var arValue = strCheckValue.split(","); if (null != arValue && 2 == arValue.length) // 2 State { this.m_strTrue = arValue[0]; this.m_strFalse = arValue[1]; } else if (null != arValue && 3 == arValue.length) // 3 State { this.m_strTrue = arValue[0]; this.m_strFalse = arValue[1]; this.m_strNone = arValue[2]; this.attribute["mode"] = "3state"; } } }; XFormsBool.prototype.init = function () { XFormsBindableControl.prototype.init.call(this); if (!this.getAttribute("background-image")) { this.setAttribute("background-image", __getAppName() + "/kr/comsquare/image/checkbox/uncheck.gif"); } if (!this.getSelectAttribute("background-image")) { this.setSelectAttribute("background-image", __getAppName() + "/kr/comsquare/image/checkbox/check.gif"); } if (!this.getDisableAttribute("background-image")) { this.setDisableAttribute("background-image", __getAppName() + "/kr/comsquare/image/checkbox/disuncheck.gif"); } if (!this.getDisableAttribute("select.background-image")) { this.setDisableAttribute("select.background-image", __getAppName() + "/kr/comsquare/image/checkbox/discheck.gif"); } this.resizeControl(); }; XFormsBool.prototype.applyDefaultStyle = function () { XFormsBindableControl.prototype.applyDefaultStyle.call(this); this.m_heControl.style.padding = ""; this.m_heControl.style.paddingLeft = ""; this.m_heControl.style.paddingTop = ""; this.m_heControl.style.paddingRight = ""; this.m_heControl.style.paddingBottom = ""; if (!this.attribute["border-color"]) { this.m_heControl.style.borderColor = "#000000"; } }; XFormsBool.prototype.getAbility = function () { return EA_CONTROL; }; XFormsBool.prototype.getBindingType = function () { return BT_SINGLE; }; XFormsBool.prototype.getMode = function () { return ("3state" == this.getAttribute("mode")) ? BM_3STATE : BM_2STATE; }; /** * 인스턴스 데이터를 실제 컨트롤에 반영 * * @return */ XFormsBool.prototype.refresh = function () { var strValue = this.getValue(); if (BM_2STATE == this.getMode()) { if (this.m_strTrue == strValue) { this.setState(FCS_SELECT, true); this.m_nState = BS_SELECTED; this.selected = true; } else { this.setState(FCS_SELECT, false); this.m_nState = BS_DESELECTED; this.selected = false; } } else if (BM_3STATE == this.getMode()) { if (this.m_strTrue == strValue) { this.setState(FCS_SELECT, true); this.m_nState = BS_SELECTED; this.selected = true; } else if (this.m_strNone == strValue) { this.setState(FCS_SELECT, true); this.m_nState = BS_NONESELECTED; this.selected = true; } else { this.setState(FCS_SELECT, false); this.m_nState = BS_DESELECTED; this.selected = false; } } }; XFormsBool.prototype.setAttribute = function (strAttribute, strValue) { XFormsBindableControl.prototype.setAttribute.call(this, strAttribute, strValue); switch (strAttribute) { case "checkvalue" : { this.attribute["checkvalue"] = strValue; if (null != strValue && "" != strValue) { var arValue = strValue.split(","); if (null != arValue && 2 == arValue.length) // 2 State { this.m_strTrue = arValue[0]; this.m_strFalse = arValue[1]; } else if (null != arValue && 3 == arValue.length) // 3 State { this.m_strTrue = arValue[0]; this.m_strFalse = arValue[1]; this.m_strNone = arValue[2]; this.attribute["mode"] = "3state"; } } break; } } }; XFormsBool.prototype.onClick = function (event) { XFormsBindableControl.prototype.onClick.call(this, event); if (this.disabled) { return; } var bSelect = this.getState(FCS_SELECT); if ((bSelect && this.m_nState == BS_DESELECTED) || (!bSelect && this.m_nState != BS_DESELECTED)) { this.m_nState = bSelect ? BS_SELECTED : BS_DESELECTED; } if (BS_SELECTED == this.m_nState) { if (BM_2STATE == this.getMode()) { this.setState(FCS_SELECT, false); this.m_nState = BS_DESELECTED; this.selected = false; this.dispatch("xforms-deselect"); } else { this.setState(FCS_SELECT, true); this.m_nState = BS_NONESELECTED; this.selected = true; this.dispatch("xforms-noneselect"); } this.dispatch("xforms-value-changed"); } else if (BS_DESELECTED == this.m_nState) { this.setState(FCS_SELECT, true); this.m_nState = BS_SELECTED; this.selected = true; this.dispatch("xforms-select"); this.dispatch("xforms-value-changed"); } else if (BS_NONESELECTED == this.m_nState) { this.setState(FCS_SELECT, false); this.m_nState = BS_DESELECTED; this.selected = false; this.dispatch("xforms-select"); this.dispatch("xforms-value-changed"); } }; XFormsBool.prototype.onKeyDown = function (event) { if (this.disabled) { return; } switch (event.keyCode) { case TFEvent.TAB : case TFEvent.F1 : { XFormsBindableControl.prototype.onKeyDown.call(this, event); break; } case TFEvent.SPACE : case TFEvent.ENTER : { if(BS_SELECTED == this.m_nState) { if(BM_2STATE == this.getMode()) { this.setState(FCS_SELECT, false); this.m_nState = BS_DESELECTED; this.selected = false; this.dispatch("xforms-deselect"); } else { this.setState(FCS_SELECT, true); this.m_nState = BS_NONESELECTED; this.selected = true; this.dispatch("xforms-noneselect"); } } else if(BS_NONESELECTED == this.m_nState) { this.setState(FCS_SELECT, false); this.m_nState = BS_DESELECTED; this.selected = false; this.dispatch("xforms-deselect"); } else if(BS_DESELECTED == this.m_nState) { if(BM_2STATE == this.getMode()) { this.setState(FCS_SELECT, true); this.m_nState = BS_SELECTED; this.selected = true; this.dispatch("xforms-select"); } else { this.setState(FCS_SELECT, true); this.m_nState = BS_SELECTED; this.selected = true; this.dispatch("xforms-select"); } } this.dispatch("xforms-value-changed"); break; } } }; XFormsBool.prototype.onSelect = function (event) { this.setValue(this.m_strTrue); this.refreshCurrentModel(this.attribute["ref"]); }; XFormsBool.prototype.onDeSelect = function (event) { this.setValue(this.m_strFalse); this.refreshCurrentModel(this.attribute["ref"]); }; XFormsBool.prototype.onNoneSelect = function (event) { this.setValue(this.m_strNone); this.refreshCurrentModel(this.attribute["ref"]); }; XFormsBool.prototype.defaultAction = function (strEventName, event) { XFormsBindableControl.prototype.defaultAction.call(this, strEventName, event); switch(strEventName) { case "xforms-select" : { this.onSelect(event); break; } case "xforms-deselect" : { this.onDeSelect(event); break; } case "xforms-noneselect" : { this.onNoneSelect(event); break; } } }; XFormsBool.create = function (strParentId, clAttribute, strStyle) { // 메인노드 생성 var xnBool = XFormsBool.createMainNode(clAttribute); var xnParent = document.getElementById("HE_"+strParentId); xnParent.appendChild(xnBool); // object 생성 return XFormsBool.createObject(strParentId, xnBool, clAttribute, strStyle); }; XFormsBool.createMainNode = function (clAttribute) { var xnBool = document.createElement("div"); xnBool = XFormsBool.createAttribute(xnBool, clAttribute); xnBool.onclick = function () {}; xnBool.ondbclick = function () {}; xnBool.onmousedown = function () {}; xnBool.onmousemove = function () {}; xnBool.onmouseup = function () {}; return xnBool; }; XFormsBool.createObject = function (strParentId, xnBool, clAttribute, strStyle) { var strAlert = ""; var strHelp = ""; var strHint = ""; var strAccesskey = ""; var strCheckValue = ""; var strClass = ""; var bDisabled = false; var strId = ""; var nNavindex = 9007199254740992; var strRef = ""; var strVisibility = "visible"; var strUserDefineAttrib = ""; for (var i=0; i