XFormsCase.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. XFormsCase.prototype = new XFormsGroup;
  2. function XFormsCase (strParentId, strAlert, strHelp, strHint, strAccesskey, strClass, bDisabled, strId, nNavindex, strOverflow,
  3. strScroll, bSelected, strStyle, strTag, strVisibility, strUserDefineAttrib)
  4. {
  5. if (!strId)
  6. {
  7. return;
  8. }
  9. XFormsGroup.call(this, strParentId, strAlert, strHelp, strHint, strAccesskey, ""/*strBind*/, strClass, bDisabled, strId, nNavindex,
  10. strOverflow, ""/*bPopup*/, ""/*strRef*/, strScroll, ""/*strShowEffect*/, strStyle, strTag, strVisibility, strUserDefineAttrib);
  11. /**
  12. * html Element 별도로 정의한다. init 구조 수정 후 보완
  13. */
  14. this.m_heControl = document.getElementById("HE_" + strId);
  15. /**
  16. * Attribute
  17. */
  18. this.attribute["selected"] = String(bSelected); // selected
  19. this.m_nIndex = -1;
  20. this.m_bIsChild = true;
  21. };
  22. XFormsCase.prototype.init = function ()
  23. {
  24. XFormsGroup.prototype.init.call(this);
  25. };
  26. XFormsCase.prototype.applyDefaultStyle = function ()
  27. {
  28. HtmlLib.setStyle(this.m_heControl, "left", "0px");
  29. HtmlLib.setStyle(this.m_heControl, "top", "0px");
  30. HtmlLib.setStyle(this.m_heControl, "width", "100%");
  31. HtmlLib.setStyle(this.m_heControl, "height", "100%");
  32. };
  33. XFormsCase.prototype.setAttribute = function (strAttribute, strValue)
  34. {
  35. XFormsGroup.prototype.setAttribute.call(this, strAttribute, strValue);
  36. switch (strAttribute)
  37. {
  38. case "selected" :
  39. {
  40. this.select(strValue);
  41. break;
  42. }
  43. }
  44. };
  45. XFormsCase.prototype.getIndex = function ()
  46. {
  47. return this.m_nIndex;
  48. };
  49. XFormsCase.prototype.setIndex = function (nIndex)
  50. {
  51. this.m_nIndex = nIndex;
  52. };
  53. XFormsCase.prototype.select = function (bSelected)
  54. {
  55. // String으로 처리한다.
  56. bSelected = String(bSelected);
  57. if ("true" == bSelected)
  58. {
  59. var objSwitch = this.parent;
  60. if (null != objSwitch)
  61. {
  62. if (objSwitch instanceof XFormsSwitch)
  63. {
  64. var arKeySet = objSwitch.children.keys();
  65. for (var i=0; i<arKeySet.length; i++)
  66. {
  67. var strId = arKeySet[i];
  68. if (this.id != strId)
  69. {
  70. var objOtherCase = objSwitch.children.item(strId);
  71. objOtherCase.select("false");
  72. }
  73. }
  74. }
  75. objSwitch.selectedIndex = this.m_nIndex;
  76. }
  77. this.attribute["selected"] = "true";
  78. this.m_heControl.style.visibility = "visible";
  79. if(is_smartphone)this.m_heControl.style.display = "";
  80. this.m_heControl.style.width = "100%";
  81. this.m_heControl.style.height = "100%";
  82. //this.m_heControl.style.display = "";
  83. }
  84. else
  85. {
  86. this.attribute["selected"] = "false";
  87. this.m_heControl.style.visibility = "hidden";
  88. if(is_smartphone)this.m_heControl.style.display = "none";
  89. this.m_heControl.style.width = "0%";
  90. this.m_heControl.style.height = "0%";
  91. //this.m_heControl.style.display = "none";
  92. }
  93. };
  94. XFormsCase.prototype.descendants = function (strId, bIncludeThis)
  95. {
  96. };
  97. XFormsCase.create = function (strParentId, clAttribute, strStyle)
  98. {
  99. // 메인노드 생성
  100. var xnCase = XFormsCase.createMainNode(clAttribute);
  101. var xnParent = document.getElementById("HE_"+strParentId);
  102. xnParent.appendChild(xnCase);
  103. // 하위노드 생성
  104. xnCase = XFormsCase.createSubNodes(xnCase, clAttribute);
  105. // object 생성
  106. var objCase = XFormsCase.createObject(strParentId, xnCase, clAttribute, strStyle);
  107. var objParent = document.controls.item(strParentId);
  108. var nIndex = -1;
  109. var arKeyset = objParent.children.keys();
  110. for (var i=0; i<arKeyset.length; i++)
  111. {
  112. var strId = arKeyset[i];
  113. var objTempCase = objParent.children.item(strId);
  114. if (objTempCase instanceof XFormsCase)
  115. {
  116. if (objTempCase != objCase && objTempCase.m_nIndex > nIndex)
  117. {
  118. nIndex = objTempCase.m_nIndex;
  119. }
  120. }
  121. }
  122. nIndex++;
  123. objCase.setIndex(nIndex);
  124. return objCase;
  125. };
  126. XFormsCase.createMainNode = function (clAttribute)
  127. {
  128. var xnCase = document.createElement("div");
  129. xnCase = XFormsCase.createAttribute(xnCase, clAttribute);
  130. return xnCase;
  131. };
  132. XFormsCase.createSubNodes = function (xnCase, clAttribute)
  133. {
  134. return xnCase;
  135. };
  136. XFormsCase.createObject = function (strParentId, xnCase, clAttribute, strStyle)
  137. {
  138. var strAlert = "";
  139. var strHelp = "";
  140. var strHint = "";
  141. var strAccesskey = "";
  142. var strClass = "";
  143. var bDisabled = false;
  144. var strId = "";
  145. var nNavindex = 9007199254740992;
  146. var strOverflow = "";
  147. var strScroll = "";
  148. var bSelected = "false";
  149. var strVisibility = "visible";
  150. var strUserDefineAttrib = "";
  151. for (var i=0; i<clAttribute.count(); i++)
  152. {
  153. var strAttributeName = clAttribute.keys()[i];
  154. switch (strAttributeName)
  155. {
  156. case "alert" :
  157. {
  158. strAlert = clAttribute.item(strAttributeName);
  159. break;
  160. }
  161. case "help" :
  162. {
  163. strHelp = clAttribute.item(strAttributeName);
  164. break;
  165. }
  166. case "hint" :
  167. {
  168. strHint = clAttribute.item(strAttributeName);
  169. break;
  170. }
  171. case "accesskey" :
  172. {
  173. strAccesskey = clAttribute.item(strAttributeName);
  174. break;
  175. }
  176. case "class" :
  177. {
  178. strClass = clAttribute.item(strAttributeName);
  179. break;
  180. }
  181. case "disabled" :
  182. {
  183. if ("true" == clAttribute.item(strAttributeName))
  184. {
  185. bDisabled = true;
  186. }
  187. break;
  188. }
  189. case "id" :
  190. {
  191. strId = clAttribute.item(strAttributeName);
  192. break;
  193. }
  194. case "navindex" :
  195. {
  196. nNavindex = parseInt(clAttribute.item(strAttributeName));
  197. break;
  198. }
  199. case "overflow" :
  200. {
  201. strOverflow = clAttribute.item(strAttributeName);
  202. break;
  203. }
  204. case "scroll" :
  205. {
  206. strScroll = clAttribute.item(strAttributeName);
  207. break;
  208. }
  209. case "selected" :
  210. {
  211. if ("true" == clAttribute.item(strAttributeName))
  212. {
  213. bSelected = "true";
  214. }
  215. break;
  216. }
  217. case "visibility" :
  218. {
  219. strVisibility = clAttribute.item(strAttributeName);
  220. break;
  221. }
  222. default :
  223. {
  224. if (!STYLE_LIST[strAttributeName])
  225. {
  226. strUserDefineAttrib += strAttributeName + ":" + clAttribute.item(strAttributeName) + "; ";
  227. }
  228. break;
  229. }
  230. }
  231. }
  232. var objCase = new XFormsCase (strParentId, strAlert, strHelp, strHint, strAccesskey, strClass, bDisabled, strId, nNavindex, strOverflow, strScroll, bSelected, strStyle, "xforms:case", strVisibility, strUserDefineAttrib);
  233. return objCase;
  234. };
  235. XFormsCase.createAttribute = function (xnHtmlNode, clAttribute)
  236. {
  237. xnHtmlNode = XFormsGroup.createAttribute(xnHtmlNode, clAttribute);
  238. return xnHtmlNode;
  239. };