123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- XFormsSwitch.prototype = new XFormsControl;
- function XFormsSwitch (strParentId, strClass, bDisabled, strId, strStyle, strTag, strVisibility, strUserDefineAttrib)
- {
- if (!strId)
- {
- return;
- }
-
- XFormsControl.call(this, strParentId, /*strAlert*/"", /*strHelp*/"", /*strHint*/"", /*strAccesskey*/"", strClass, bDisabled, strId, /*nNavindex*/"", strStyle, strTag, strVisibility, strUserDefineAttrib);
-
- /**
- * Property
- */
- this.selected;
- this.selectedIndex;
-
- /**
- * Method
- */
- this.m_isChild;
- };
- XFormsSwitch.prototype.init = function ()
- {
- XFormsControl.prototype.init.call(this);
-
- var bSelectCase = false;
- var strFirstChildId = "";
- var nIndex = 0;
-
- var arKeyset = this.children.keys();
- for (var i=0; i<arKeyset.length; i++)
- {
- var strId = arKeyset[i];
- var objCase = this.children.item(strId);
- if (objCase instanceof XFormsCase)
- {
- objCase.setIndex(nIndex);
- if ("true" == objCase.attribute["selected"])
- {
- objCase.select("true");
- bSelectCase = true;
- }
-
- if (0 == nIndex)
- {
- strFirstChildId = strId;
- }
-
- nIndex++;
- }
- }
-
- if (!bSelectCase && strFirstChildId != "")
- {
- var objFirstCase = this.children.item(strFirstChildId);
- objFirstCase.select("true");
- }
- this.resizeControl();
- };
- XFormsSwitch.prototype.applyDefaultStyle = function ()
- {
- XFormsControl.prototype.applyDefaultStyle.call(this);
-
- if (null == HtmlLib.getStyle(this.m_heControl,"background-color") || "" == HtmlLib.getStyle(this.m_heControl,"background-color"))
- {
- HtmlLib.setStyle(this.m_heControl, "background-color", "#FFFFFF");
- }
- };
- /**
- * 지정한 스타일을 최초 로딩시점과 동일하게 초기화
- * @return
- */
- XFormsSwitch.prototype.initStyle = function ()
- {
-
- };
- /**
- * 인스턴스 데이터를 실제 컨트롤에 반영
- * @return
- */
- XFormsSwitch.prototype.refresh = function ()
- {
- var arKeyset = this.children.keys();
- for (var i=0; i<arKeyset.length; i++)
- {
- var strId = arKeyset[i];
- var objChild = this.children.item(strId);
-
- if (null != objChild && objChild instanceof XFormsElement && objChild.refresh)
- {
- objChild.refresh();
- }
- }
- };
- XFormsSwitch.prototype.setSelectedIndex = function (nIndex)
- {
- var arKeyset = this.children.keys();
- for (var i=0; i<arKeyset.length; i++)
- {
- var strId = arKeyset[i];
- var objCase = this.children.item(strId);
- if (objCase instanceof XFormsCase)
- {
- if (nIndex == objCase.getIndex())
- {
- objCase.select("true");
- }
- }
- }
- };
- /**
- * ID가 strId인 컨트롤이 Switch의 자식인지 판단한다.
- * @param strId 컨트롤의 ID
- * @return
- */
- XFormsSwitch.prototype.isChild = function (strId)
- {
- var objChild = this.children.item(strId);
- if (null != objChild)
- {
- return true;
- }
- else
- {
- return false;
- }
- };
- /**
- * ID가 strId인 컨트롤이 Switch의 자손인지 판단한다.
- * @param strId 컨트롤의 ID
- * @param bIncludeThis Switch 자신을 포함할지 여부
- * @return
- */
- XFormsSwitch.prototype.isDescendants = function(strId, bIncludeThis)
- {
- if(null == bIncludeThis)
- {
- bIncludeThis = false;
- }
-
- var objChild = document.allElement.item(strId);
-
- if (null != objChild)
- {
- if (bIncludeThis)
- {
- if (objChild == this)
- {
- return true;
- }
- }
-
- var objParent = objChild.parent;
- while(null != objParent)
- {
- if (objParent == this)
- {
- return true;
- }
- objParent = objParent.parent;
- }
-
- return false;
- }
-
- return false;
- };
- XFormsSwitch.create = function (strParentId, clAttribute, strStyle)
- {
- // 메인노드 생성
- var xnSwitch = XFormsSwitch.createMainNode(clAttribute);
- var xnParent = document.getElementById("HE_"+strParentId);
- xnParent.appendChild(xnSwitch);
- // 하위노드 생성
- xnSwitch = XFormsSwitch.createSubNodes(xnSwitch, clAttribute);
- // object 생성
- return XFormsSwitch.createObject(strParentId, xnSwitch, clAttribute, strStyle);
- };
- XFormsSwitch.createMainNode = function (clAttribute)
- {
- var xnSwitch = document.createElement("div");
- xnSwitch = XFormsSwitch.createAttribute(xnSwitch, clAttribute);
- return xnSwitch;
- };
- XFormsSwitch.createSubNodes = function (xnSwitch, clAttribute)
- {
- return xnSwitch;
- };
- XFormsSwitch.createObject = function (strParentId, xnSwitch, clAttribute, strStyle)
- {
- var strClass = "";
- var bDisabled = false;
- var strId = "";
- var strVisibility = "visible";
- var strUserDefineAttrib = "";
-
- for (var i=0; i<clAttribute.count(); i++)
- {
- var strAttributeName = clAttribute.keys()[i];
- switch (strAttributeName)
- {
- 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 "visibility" :
- {
- strVisibility = clAttribute.item(strAttributeName);
- break;
- }
-
- default :
- {
- if (!STYLE_LIST[strAttributeName])
- {
- strUserDefineAttrib += strAttributeName + ":" + clAttribute.item(strAttributeName) + "; ";
- }
- break;
- }
- }
- }
- var objSwitch = new XFormsSwitch(strParentId, strClass, bDisabled, strId, strStyle, "xforms:switch", strVisibility, strUserDefineAttrib);
- return objSwitch;
- };
- XFormsSwitch.createAttribute = function (xnHtmlNode, clAttribute)
- {
- xnHtmlNode = XFormsControl.createAttribute(xnHtmlNode, clAttribute);
- return xnHtmlNode;
- };
|