XFormsTreeViewItem.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. XFormsTreeViewItem.prototype = new XFormsCaption;
  2. function XFormsTreeViewItem (strParentId, strId)
  3. {
  4. if (!strId)
  5. {
  6. return;
  7. }
  8. XFormsCaption.call(this, strParentId, ""/*strAlert*/, ""/*strHelp*/, ""/*strHint*/, ""/*strText*/, ""/*strAccesskey*/, false/*bAutoresize*/, ""/*strBind*/, ""/*strClass*/, false/*bDisabled*/, false/*bEllipsis*/, ""/*strFormat*/, strId, -1/*nNavindex*/, ""/*strRef*/, ""/*strRoundmode*/, -1/*nRoundposition*/, ""/*strStyle*/, "xforms:treeitem", "visible"/*strVisibility*/);
  9. this.checked;
  10. this.checkboxdisabled;
  11. this.depth;
  12. this.disabled;
  13. this.expanded;
  14. this.expandedImage;
  15. this.image;
  16. this.index;
  17. this.parentIndex;
  18. this.selectedImage;
  19. this.label = "";
  20. this.value = "";
  21. this.itemset;
  22. };
  23. XFormsTreeViewItem.prototype.init = function ()
  24. {
  25. XFormsCaption.prototype.init.call(this);
  26. };
  27. XFormsTreeViewItem.prototype.hasContained = function (heMember, nX)
  28. {
  29. if (null != heMember)
  30. {
  31. var nOffsetWidth = heMember.offsetWidth;
  32. var nOffsetX = heMember.offsetLeft;
  33. if ((nX >= nOffsetX && nX <= nOffsetX + nOffsetWidth))
  34. {
  35. return true;
  36. }
  37. }
  38. return false;
  39. };
  40. XFormsTreeViewItem.prototype.setSelect = function (bSelect)
  41. {
  42. var objCell = this.getRefElement();
  43. if (null == objCell)
  44. {
  45. return;
  46. }
  47. var strId = objCell.id;
  48. var xnParent = this.parent;
  49. var xlRefNode = xnParent.getRefNode();
  50. if (null != xlRefNode)
  51. {
  52. var xnRefNode = xlRefNode.item(0);
  53. if (null != xnRefNode)
  54. {
  55. var strNewValue = objCell.getValue();
  56. if (bSelect)
  57. {
  58. xnParent.value = strNewValue;
  59. XmlLib.setTextValue(xnRefNode, strNewValue);
  60. }
  61. }
  62. }
  63. var heSelectRow;
  64. var strFullRowSelect = xnParent.getAttribute("fullrowselect");
  65. var heSelectRow = objCell.getHtmlElement();
  66. if ("true" == strFullRowSelect)
  67. {
  68. heSelectRow = document.getElementById("HE_" + strId);
  69. }
  70. else
  71. {
  72. heSelectRow = document.getElementById("HE_" + strId + "_content");
  73. }
  74. if (bSelect)
  75. {
  76. HtmlLib.setStyle(heSelectRow, "color", "#FFFFFF");
  77. HtmlLib.setStyle(heSelectRow, "background-color", "#316AC5");
  78. }
  79. else
  80. {
  81. var strFontColor = xnParent.getAttribute("color");
  82. if ("" == strFontColor)
  83. {
  84. strFontColor = "#000000";
  85. }
  86. HtmlLib.setStyle(heSelectRow, "color", strFontColor);
  87. HtmlLib.setStyle(heSelectRow, "background-color", "");
  88. }
  89. };
  90. /**
  91. * getter, setter
  92. */
  93. XFormsTreeViewItem.prototype.getDepth = function ()
  94. {
  95. return this.depth;
  96. };
  97. XFormsTreeViewItem.prototype.setDepth = function (strDepth)
  98. {
  99. this.depth = strDepth;
  100. };
  101. XFormsTreeViewItem.prototype.getExpanded = function ()
  102. {
  103. return this.expaned;
  104. };
  105. XFormsTreeViewItem.prototype.setExpanded = function (strExpanded)
  106. {
  107. this.expanded = strExpaned;
  108. };
  109. XFormsTreeViewItem.prototype.getExpandedImage = function ()
  110. {
  111. return this.expandedImage;
  112. };
  113. XFormsTreeViewItem.prototype.setExpandedImage = function (strExpandedImage)
  114. {
  115. this.expandedImage = strExpandedImage;
  116. };
  117. XFormsTreeViewItem.prototype.getIndex = function ()
  118. {
  119. return this.index;
  120. };
  121. XFormsTreeViewItem.prototype.setIndex = function (strIndex)
  122. {
  123. this.index = strIndex;
  124. };
  125. XFormsTreeViewItem.prototype.getParentIndex = function ()
  126. {
  127. return this.parentIndex;
  128. };
  129. XFormsTreeViewItem.prototype.setParentIndex = function (strParentIndex)
  130. {
  131. this.parentIndex = strParentIndex;
  132. };
  133. XFormsTreeViewItem.prototype.getSelectedImage = function ()
  134. {
  135. return this.selectedImage;
  136. };
  137. XFormsTreeViewItem.prototype.setSelectedImage = function (strSelectedImage)
  138. {
  139. this.selectedImage = strSelectedImage;
  140. };
  141. XFormsTreeViewItem.prototype.setItemSet = function (objItemSet)
  142. {
  143. this.itemset = objItemSet;
  144. };
  145. XFormsTreeViewItem.prototype.getItemSet = function ()
  146. {
  147. return this.itemset;
  148. };
  149. XFormsTreeViewItem.prototype.setLabel = function (objLabel)
  150. {
  151. this.label = objLabel;
  152. };
  153. XFormsTreeViewItem.prototype.getLabel = function ()
  154. {
  155. return this.label;
  156. };
  157. XFormsTreeViewItem.prototype.setValue = function (objValue)
  158. {
  159. this.value = objValue;
  160. };
  161. XFormsTreeViewItem.prototype.getValue = function ()
  162. {
  163. return this.value;
  164. };
  165. XFormsTreeViewItem.prototype.setAttribute = function (strAttribute, strValue)
  166. {
  167. XFormsCaption.prototype.setAttribute.call(this, strAttribute, strValue);
  168. switch (strAttribute)
  169. {
  170. case "nodeset" :
  171. {
  172. if (null != this.parent)
  173. {
  174. this.parent.nodeset = strValue;
  175. }
  176. break;
  177. }
  178. }
  179. };
  180. XFormsTreeViewItem.create = function (strParentId, clAttribute)
  181. {
  182. var strId = clAttribute.item("id") ? clAttribute.item("id") : "";
  183. var objControl = new XFormsTreeViewItem(strParentId, strId);
  184. var arKeys = clAttribute.keys();
  185. for (var i=0; i<arKeys.length; i++)
  186. {
  187. objControl.setAttribute(arKeys[i], clAttribute.item(arKeys[i]));
  188. }
  189. return objControl;
  190. };