123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474 |
- 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<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 "accesskey" :
- {
- strAccesskey = clAttribute.item(strAttributeName);
- break;
- }
- case "checkvalue" :
- {
- strCheckValue = clAttribute.item(strAttributeName);
- break;
- }
- case "class" :
- {
- strClass = clAttribute.item(strAttributeName);
- break;
- }
- case "disabled" :
- {
- if ("true" == clAttribute.item(strAttributeName))
- {
- bDisabled = true;
- }
- break;
- }
- case "id" :
- {
- strId = clAttribute.item(strAttributeName);
- break;
- }
- case "navindex" :
- {
- nNavindex = parseInt(clAttribute.item(strAttributeName));
- break;
- }
- case "ref" :
- {
- strRef = clAttribute.item(strAttributeName);
- break;
- }
- case "visibility" :
- {
- strVisibility = clAttribute.item(strAttributeName);
- break;
- }
- default :
- {
- if (!STYLE_LIST[strAttributeName])
- {
- strUserDefineAttrib += strAttributeName + ":" + clAttribute.item(strAttributeName) + "; ";
- }
- break;
- }
- }
- }
- var objBool = new XFormsBool (strParentId, strAlert, strHelp, strHint, strAccesskey, "", strCheckValue, strClass, bDisabled, strId, nNavindex, strRef, strStyle, "xforms:bool", strVisibility, strUserDefineAttrib);
- return objBool;
- };
- XFormsBool.createAttribute = function (xnHtmlNode, clAttribute)
- {
- xnHtmlNode.style.backgroundRepeat = "no-repeat";
- xnHtmlNode.style.backgroundPosition = "center";
- xnHtmlNode.style.backgroundImage = "url(" + __getAppName() + "/kr/comsquare/image/checkbox/uncheck.gif" + ")";
-
- xnHtmlNode = XFormsBindableControl.createAttribute(xnHtmlNode, clAttribute);
- return xnHtmlNode;
- };
|