KDLabel.htc 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <!--/******************************************************************
  2. ** 文件名: KDLabel.htc
  3. ** Copyright (c) 2005 金蝶国际软件集团有限公司 研发中心
  4. ** http://www.kingdee.com
  5. **
  6. ** 创建人: 叶汉良
  7. ** 日 期: 2005.08.08
  8. **
  9. ** 描述:标签控件
  10. ** 版 本:Web V1.0
  11. ******************************************************************/-->
  12. <public:component tagName="KDLabel" lightWeight=true>
  13. <public:attach event="oncontentready" onevent="kdLabelReady()"/>
  14. <public:attach event="onpropertychange" onevent="kdLabelPropertyChange()"/>
  15. <public:property name="height" value="20"/>
  16. <public:property name="width" value="323"/>
  17. <public:property name="name" value=""/>
  18. <public:property name="id" value=""/>
  19. <public:property name="fontFamily1" value="arial"/>
  20. <public:property name="fontSize1" value="9pt"/>
  21. <public:property name="initializeTextFontColor" value="#000000"/>
  22. <public:property name="initializeBorderColor" value="#B4B4B4"/>
  23. <public:property name="disableTextFontColor" value="#666666"/>
  24. <public:property name="disableBorderColor" value="#B4B4B4"/>
  25. <public:property name="focusTextFontColor" value="#000000"/>
  26. <public:property name="focusBorderColor" value="#5C85B3"/>
  27. <public:property name="readonlyTextFontColor" value="#000000"/>
  28. <public:property name="readonlyBorderColor" value="#B4B4B4"/>
  29. <public:property name="caption" value=""/>
  30. <public:property name="iconUrl" value=""/>
  31. <public:property name="iconWidth" value="0"/>
  32. <public:property name="tips" value=""/>
  33. <public:property name="isShowLine" value="true"/>
  34. <public:property name="lineWidth" value="155"/>
  35. <public:property name="disable" value="false"/>
  36. <public:property name="readonly" value="false"/>
  37. <public:property name="plusChar" value=":"/>
  38. <public:method name="getWidth"/>
  39. </public:component>
  40. <script language="javascript">
  41. var d1;
  42. /**
  43. *控件初始化
  44. *
  45. */
  46. function kdLabelReady()
  47. {
  48. initCss();
  49. var oTableE = element.children(0);
  50. initTable(oTableE);
  51. doEvents(oTableE);
  52. }
  53. /**
  54. *控件属性值发生变化的时候处理事件
  55. *
  56. */
  57. function kdLabelPropertyChange()
  58. {
  59. }
  60. /**
  61. *初始设置表格相关的内容
  62. *
  63. */
  64. function initTable(oTable)
  65. {
  66. oTable.name = name;
  67. oTable.id = id;
  68. oTable.style.tableLayout = "fixed";
  69. oTable.style.display = "inline";
  70. oTable.style.height = height;
  71. oTable.style.width = width;
  72. oTable.style.borderCollapse = "collapse";
  73. oTable.style.borderSpacing = 0;
  74. oTable.style.padding = 0;
  75. oTable.title = tips;
  76. oTrE = oTable.rows(0);
  77. //图片单元格
  78. var oTdImgE = oTrE.cells(0);
  79. //标题单元格
  80. var oTdCaptionE = oTrE.cells(1);
  81. //容器单元格
  82. var oTdContainE = oTrE.cells(2);
  83. oTdImgE.style.verticalAlign = "bottom";
  84. oTdImgE.isCaption = true;
  85. oTdCaptionE.isCaption = true;
  86. oTdCaptionE.style.fontFamily = fontFamily1;
  87. oTdCaptionE.style.fontSize = fontSize1;
  88. oTdCaptionE.style.wordBreak = "keep-all";
  89. oTdCaptionE.style.verticalAlign = "bottom";
  90. oTdContainE.style.padding = 0;
  91. //显示线条
  92. if (eval(isShowLine) == true)
  93. {
  94. //禁止状态
  95. if (eval(disable) == true)
  96. {
  97. oTdImgE.style.borderBottom = "solid 1 " + disableBorderColor;
  98. oTdCaptionE.style.borderBottom = "solid 1 " + disableBorderColor;
  99. oTdCaptionE.style.color = disableTextFontColor;
  100. }
  101. else
  102. {
  103. if (eval(readonly) == false)
  104. {
  105. oTdImgE.style.borderBottom = "solid 1 " + initializeBorderColor;
  106. oTdCaptionE.style.borderBottom = "solid 1 " + initializeBorderColor;
  107. oTdCaptionE.style.color = initializeTextFontColor;
  108. }
  109. else
  110. {
  111. oTdImgE.style.borderBottom = "solid 1 " + readonlyBorderColor;
  112. oTdCaptionE.style.borderBottom = "solid 1 " + readonlyBorderColor;
  113. oTdCaptionE.style.color = readonlyTextFontColor;
  114. }
  115. }
  116. }
  117. else
  118. {
  119. //禁止状态
  120. if (eval(disable) == true)
  121. {
  122. oTdCaptionE.style.color = disableTextFontColor;
  123. }
  124. else
  125. {
  126. if (eval(readonly) == false)
  127. {
  128. oTdCaptionE.style.color = initializeTextFontColor;
  129. }
  130. else
  131. {
  132. oTdCaptionE.style.color = readonlyTextFontColor;
  133. }
  134. }
  135. }
  136. if (iconUrl != "")
  137. {
  138. oTdImgE.style.width = iconWidth;
  139. var oImgE = window.document.createElement("<img>");
  140. oImgE.src = iconUrl;
  141. oImgE.style.width = iconWidth;
  142. oTdImgE.appendChild(oImgE);
  143. //图标和标题间隔时5个像素
  144. oTdCaptionE.style.paddingLeft = 5;
  145. if (eval(disable) == true)
  146. {
  147. oImgE.style.filter = "gray";
  148. }
  149. }
  150. else
  151. {
  152. oTdImgE.style.width = 0;
  153. }
  154. oTdCaptionE.style.width = parseInt(lineWidth) - parseInt(iconWidth);
  155. oTdCaptionE.innerText = caption + plusChar;
  156. oTdContainE.style.width = parseInt(width) - parseInt(lineWidth);
  157. oTdContainE.style.height = height;
  158. oTdContainE.style.verticalAlign = "bottom";
  159. if (oTdContainE.children.length != 0)
  160. {
  161. var oChildNode = oTdContainE.children(0);
  162. if (oChildNode == null)
  163. {
  164. return;
  165. }
  166. oChildNode.width = oTdContainE.style.pixelWidth;
  167. oChildNode.height = oTdContainE.style.pixelHeight - 1;
  168. if (oChildNode.tagName == "KDComboBox" || oChildNode.tagName == "KDSpinner" || oChildNode.tagName == "KDPromptBox")
  169. {
  170. oTdContainE.style.paddingTop = 1;
  171. }
  172. }
  173. }
  174. /**
  175. *处理相关的事件
  176. *
  177. */
  178. function doEvents(oTable)
  179. {
  180. oTable.onmousedown = doMouseDown;
  181. oTable.onmouseup = doMouseUp;
  182. oTable.onactivate = doActivate;
  183. oTable.ondeactivate = doDeactivate;
  184. }
  185. /**
  186. *鼠标onmousedown事件
  187. *
  188. */
  189. function doMouseDown()
  190. {
  191. var oChildNode;
  192. if (element.children(0).rows(0).cells(2).children.length > 0)
  193. {
  194. oChildNode = element.children(0).rows(0).cells(2).children(0);
  195. }
  196. if (oChildNode == null)
  197. {
  198. return;
  199. }
  200. oChildNode.isMouseDown = true;
  201. }
  202. /**
  203. *鼠标onmouseup事件
  204. *
  205. */
  206. function doMouseUp()
  207. {
  208. var oChildNode;
  209. if (element.children(0).rows(0).cells(2).children.length > 0)
  210. {
  211. oChildNode = element.children(0).rows(0).cells(2).children(0);
  212. }
  213. if (oChildNode == null)
  214. {
  215. return;
  216. }
  217. oChildNode.isMouseDown = false;
  218. }
  219. /**
  220. *处理激活的相关事件
  221. *
  222. */
  223. function doActivate()
  224. {
  225. if (eval(disable) == true)
  226. {
  227. return;
  228. }
  229. var oSrc = event.srcElement;
  230. var oTr = element.children(0).rows(0);
  231. if (eval(isShowLine) == true && eval(readonly) == false)
  232. {
  233. oTr.cells(0).style.borderBottomColor = focusBorderColor;
  234. oTr.cells(1).style.borderBottomColor = focusBorderColor;
  235. oTr.cells(1).style.color = focusTextFontColor;
  236. if (oTr.cells(2).children(0) && oSrc.isCaption == true)
  237. {
  238. oTr.cells(2).children(0).focus();
  239. }
  240. }
  241. else if (eval(isShowLine) == false && eval(readonly) == false)
  242. {
  243. if (oTr.cells(2).children(0) && oSrc.isCaption == true)
  244. {
  245. oTr.cells(2).children(0).focus();
  246. }
  247. }
  248. }
  249. /**
  250. *处理去激活的相关事件
  251. *
  252. */
  253. function doDeactivate()
  254. {
  255. if (eval(disable) == true)
  256. {
  257. return;
  258. }
  259. if (eval(isShowLine) == true && eval(readonly) == false)
  260. {
  261. var oTr = element.children(0).rows(0);
  262. oTr.cells(0).style.borderBottomColor = initializeBorderColor;
  263. oTr.cells(1).style.borderBottomColor = initializeBorderColor;
  264. oTr.cells(1).style.color = initializeTextFontColor;
  265. }
  266. }
  267. /**
  268. *由于button的长度是计算出来的,所以不能直接应用width
  269. *
  270. */
  271. function getWidth()
  272. {
  273. return element.children(0).style.pixelWidth;
  274. }
  275. /**
  276. *初始样式
  277. *
  278. */
  279. function initCss()
  280. {
  281. var os = element.currentStyle;
  282. initializeBorderColor = getCssStyle(initializeBorderColor,"#B4B4B4",os.initializeBorderColor);
  283. //initializeBGColor = getCssStyle(initializeBGColor,"#FFFFFF",os.initializeBGColor);
  284. initializeTextFontColor = getCssStyle(initializeTextFontColor,"#000000",os.initializeTextFontColor);
  285. focusBorderColor = getCssStyle(focusBorderColor,"#5C85B3",os.focusBorderColor);
  286. //focusBGColor = getCssStyle(focusBGColor,"#F9F9F9",os.focusBGColor);
  287. focusTextFontColor = getCssStyle(focusTextFontColor,"#000000",os.focusTextFontColor);
  288. readonlyBorderColor = getCssStyle(readonlyBorderColor,"#B4B4B4",os.readonlyBorderColor);
  289. //readonlyBGColor = getCssStyle(readonlyBGColor,"#FFFFFF",os.readonlyBGColor);
  290. readonlyTextFontColor = getCssStyle(readonlyTextFontColor,"#777777",os.readonlyTextFontColor);
  291. disableBorderColor = getCssStyle(disableBorderColor,"#B4B4B4",os.disableBorderColor);
  292. //disableBGColor = getCssStyle(disableBGColor,"#D9D9D0",os.disableBGColor);
  293. disableTextFontColor = getCssStyle(disableTextFontColor,"#777777",os.disableTextFontColor);
  294. //mustBorderColor = getCssStyle("mustBorderColor","#B4B4B4");
  295. //mustBGColor = getCssStyle("mustBGColor","#FCFBCE");
  296. //mustTextFontColor = getCssStyle("mustTextFontColor","#000000");
  297. fontSize1 = getCssStyle(fontSize1,"9pt");
  298. fontFamily1 = getCssStyle(fontFamily1,"arial");
  299. }
  300. </script>