123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- <!--/******************************************************************
- ** 文件名: KDLabel.htc
- ** Copyright (c) 2005 金蝶国际软件集团有限公司 研发中心
- ** http://www.kingdee.com
- **
- ** 创建人: 叶汉良
- ** 日 期: 2005.08.08
- **
- ** 描述:标签控件
- ** 版 本:Web V1.0
- ******************************************************************/-->
- <public:component tagName="KDLabel" lightWeight=true>
- <public:attach event="oncontentready" onevent="kdLabelReady()"/>
- <public:attach event="onpropertychange" onevent="kdLabelPropertyChange()"/>
- <public:property name="height" value="20"/>
- <public:property name="width" value="323"/>
- <public:property name="name" value=""/>
- <public:property name="id" value=""/>
- <public:property name="fontFamily1" value="arial"/>
- <public:property name="fontSize1" value="9pt"/>
- <public:property name="initializeTextFontColor" value="#000000"/>
- <public:property name="initializeBorderColor" value="#B4B4B4"/>
- <public:property name="disableTextFontColor" value="#666666"/>
- <public:property name="disableBorderColor" value="#B4B4B4"/>
- <public:property name="focusTextFontColor" value="#000000"/>
- <public:property name="focusBorderColor" value="#5C85B3"/>
- <public:property name="readonlyTextFontColor" value="#000000"/>
- <public:property name="readonlyBorderColor" value="#B4B4B4"/>
- <public:property name="caption" value=""/>
- <public:property name="iconUrl" value=""/>
- <public:property name="iconWidth" value="0"/>
- <public:property name="tips" value=""/>
- <public:property name="isShowLine" value="true"/>
- <public:property name="lineWidth" value="155"/>
- <public:property name="disable" value="false"/>
- <public:property name="readonly" value="false"/>
- <public:property name="plusChar" value=":"/>
- <public:method name="getWidth"/>
- </public:component>
- <script language="javascript">
- var d1;
- /**
- *控件初始化
- *
- */
- function kdLabelReady()
- {
- initCss();
-
- var oTableE = element.children(0);
- initTable(oTableE);
-
- doEvents(oTableE);
- }
- /**
- *控件属性值发生变化的时候处理事件
- *
- */
- function kdLabelPropertyChange()
- {
-
- }
- /**
- *初始设置表格相关的内容
- *
- */
- function initTable(oTable)
- {
- oTable.name = name;
- oTable.id = id;
- oTable.style.tableLayout = "fixed";
- oTable.style.display = "inline";
- oTable.style.height = height;
- oTable.style.width = width;
- oTable.style.borderCollapse = "collapse";
- oTable.style.borderSpacing = 0;
- oTable.style.padding = 0;
-
- oTable.title = tips;
- oTrE = oTable.rows(0);
-
- //图片单元格
- var oTdImgE = oTrE.cells(0);
- //标题单元格
- var oTdCaptionE = oTrE.cells(1);
- //容器单元格
- var oTdContainE = oTrE.cells(2);
-
- oTdImgE.style.verticalAlign = "bottom";
-
- oTdImgE.isCaption = true;
- oTdCaptionE.isCaption = true;
-
- oTdCaptionE.style.fontFamily = fontFamily1;
- oTdCaptionE.style.fontSize = fontSize1;
- oTdCaptionE.style.wordBreak = "keep-all";
- oTdCaptionE.style.verticalAlign = "bottom";
- oTdContainE.style.padding = 0;
-
- //显示线条
- if (eval(isShowLine) == true)
- {
- //禁止状态
- if (eval(disable) == true)
- {
- oTdImgE.style.borderBottom = "solid 1 " + disableBorderColor;
- oTdCaptionE.style.borderBottom = "solid 1 " + disableBorderColor;
- oTdCaptionE.style.color = disableTextFontColor;
- }
- else
- {
- if (eval(readonly) == false)
- {
- oTdImgE.style.borderBottom = "solid 1 " + initializeBorderColor;
- oTdCaptionE.style.borderBottom = "solid 1 " + initializeBorderColor;
- oTdCaptionE.style.color = initializeTextFontColor;
- }
- else
- {
- oTdImgE.style.borderBottom = "solid 1 " + readonlyBorderColor;
- oTdCaptionE.style.borderBottom = "solid 1 " + readonlyBorderColor;
- oTdCaptionE.style.color = readonlyTextFontColor;
- }
- }
- }
- else
- {
- //禁止状态
- if (eval(disable) == true)
- {
- oTdCaptionE.style.color = disableTextFontColor;
- }
- else
- {
- if (eval(readonly) == false)
- {
- oTdCaptionE.style.color = initializeTextFontColor;
- }
- else
- {
- oTdCaptionE.style.color = readonlyTextFontColor;
- }
- }
- }
-
- if (iconUrl != "")
- {
- oTdImgE.style.width = iconWidth;
- var oImgE = window.document.createElement("<img>");
- oImgE.src = iconUrl;
- oImgE.style.width = iconWidth;
- oTdImgE.appendChild(oImgE);
- //图标和标题间隔时5个像素
- oTdCaptionE.style.paddingLeft = 5;
- if (eval(disable) == true)
- {
- oImgE.style.filter = "gray";
- }
- }
- else
- {
- oTdImgE.style.width = 0;
- }
-
- oTdCaptionE.style.width = parseInt(lineWidth) - parseInt(iconWidth);
- oTdCaptionE.innerText = caption + plusChar;
- oTdContainE.style.width = parseInt(width) - parseInt(lineWidth);
- oTdContainE.style.height = height;
-
- oTdContainE.style.verticalAlign = "bottom";
-
- if (oTdContainE.children.length != 0)
- {
- var oChildNode = oTdContainE.children(0);
- if (oChildNode == null)
- {
- return;
- }
- oChildNode.width = oTdContainE.style.pixelWidth;
- oChildNode.height = oTdContainE.style.pixelHeight - 1;
- if (oChildNode.tagName == "KDComboBox" || oChildNode.tagName == "KDSpinner" || oChildNode.tagName == "KDPromptBox")
- {
- oTdContainE.style.paddingTop = 1;
- }
- }
- }
- /**
- *处理相关的事件
- *
- */
- function doEvents(oTable)
- {
- oTable.onmousedown = doMouseDown;
- oTable.onmouseup = doMouseUp;
- oTable.onactivate = doActivate;
- oTable.ondeactivate = doDeactivate;
- }
- /**
- *鼠标onmousedown事件
- *
- */
- function doMouseDown()
- {
- var oChildNode;
- if (element.children(0).rows(0).cells(2).children.length > 0)
- {
- oChildNode = element.children(0).rows(0).cells(2).children(0);
- }
- if (oChildNode == null)
- {
- return;
- }
- oChildNode.isMouseDown = true;
- }
- /**
- *鼠标onmouseup事件
- *
- */
- function doMouseUp()
- {
- var oChildNode;
- if (element.children(0).rows(0).cells(2).children.length > 0)
- {
- oChildNode = element.children(0).rows(0).cells(2).children(0);
- }
- if (oChildNode == null)
- {
- return;
- }
- oChildNode.isMouseDown = false;
- }
- /**
- *处理激活的相关事件
- *
- */
- function doActivate()
- {
- if (eval(disable) == true)
- {
- return;
- }
-
- var oSrc = event.srcElement;
-
- var oTr = element.children(0).rows(0);
-
- if (eval(isShowLine) == true && eval(readonly) == false)
- {
- oTr.cells(0).style.borderBottomColor = focusBorderColor;
- oTr.cells(1).style.borderBottomColor = focusBorderColor;
- oTr.cells(1).style.color = focusTextFontColor;
- if (oTr.cells(2).children(0) && oSrc.isCaption == true)
- {
- oTr.cells(2).children(0).focus();
- }
- }
- else if (eval(isShowLine) == false && eval(readonly) == false)
- {
- if (oTr.cells(2).children(0) && oSrc.isCaption == true)
- {
- oTr.cells(2).children(0).focus();
- }
- }
- }
-
- /**
- *处理去激活的相关事件
- *
- */
- function doDeactivate()
- {
- if (eval(disable) == true)
- {
- return;
- }
-
- if (eval(isShowLine) == true && eval(readonly) == false)
- {
- var oTr = element.children(0).rows(0);
-
- oTr.cells(0).style.borderBottomColor = initializeBorderColor;
- oTr.cells(1).style.borderBottomColor = initializeBorderColor;
- oTr.cells(1).style.color = initializeTextFontColor;
- }
- }
-
- /**
- *由于button的长度是计算出来的,所以不能直接应用width
- *
- */
- function getWidth()
- {
- return element.children(0).style.pixelWidth;
- }
- /**
- *初始样式
- *
- */
- function initCss()
- {
- var os = element.currentStyle;
- initializeBorderColor = getCssStyle(initializeBorderColor,"#B4B4B4",os.initializeBorderColor);
- //initializeBGColor = getCssStyle(initializeBGColor,"#FFFFFF",os.initializeBGColor);
- initializeTextFontColor = getCssStyle(initializeTextFontColor,"#000000",os.initializeTextFontColor);
- focusBorderColor = getCssStyle(focusBorderColor,"#5C85B3",os.focusBorderColor);
- //focusBGColor = getCssStyle(focusBGColor,"#F9F9F9",os.focusBGColor);
- focusTextFontColor = getCssStyle(focusTextFontColor,"#000000",os.focusTextFontColor);
- readonlyBorderColor = getCssStyle(readonlyBorderColor,"#B4B4B4",os.readonlyBorderColor);
- //readonlyBGColor = getCssStyle(readonlyBGColor,"#FFFFFF",os.readonlyBGColor);
- readonlyTextFontColor = getCssStyle(readonlyTextFontColor,"#777777",os.readonlyTextFontColor);
- disableBorderColor = getCssStyle(disableBorderColor,"#B4B4B4",os.disableBorderColor);
- //disableBGColor = getCssStyle(disableBGColor,"#D9D9D0",os.disableBGColor);
- disableTextFontColor = getCssStyle(disableTextFontColor,"#777777",os.disableTextFontColor);
- //mustBorderColor = getCssStyle("mustBorderColor","#B4B4B4");
- //mustBGColor = getCssStyle("mustBGColor","#FCFBCE");
- //mustTextFontColor = getCssStyle("mustTextFontColor","#000000");
- fontSize1 = getCssStyle(fontSize1,"9pt");
- fontFamily1 = getCssStyle(fontFamily1,"arial");
- }
-
- </script>
|