📄 multiselect.htc
字号:
<!-- MultiSelect HTML Compense组件 -->
<public:component name="MultiSelect" urn="MultiSelect" lightweight=true>
<!--Select的数据源XML,Select的选项均来自于该属性传递的xml。该属性只写,无默认值-->
<public:property name="xmlSource" put="putXMLSource"/>
<!--作为Select选项值的xml属性名。该属性无处理(读写),无默认值。 -->
<public:property name="valueCol"/>
<!--作为Select选项值的xml属性名。该属性无处理(读写),无默认值。 -->
<public:property name="textCol"/>
<!--组件与其所在页面上边框之间的距离,无处理(读写),默认值0。 -->
<public:property name="top" value="0" put="putTop"/>
<!--组件与其所在页面左边框之间的距离,无处理(读写),默认值0。-->
<public:property name="left" value="0" put="putLeft"/>
<!--组件宽度,无处理(读写),默认值120。 -->
<public:property name="width" value="120"/>
<!--列表框一次显示的条目数,无处理(读写),默认值20。 -->
<public:property name="selectsize" value = "5"/>
<!--组件属性, 文本框中分隔用的符号,无处理(读写), 默认值'|' -->
<public:property name="departsymbol" value='|'/>
<!--行为属性,执行初始化过程,只写,无默认值。 -->
<public:property name="init" put="initialize"/>
<!--组件前面的字 caption 可读写 无默认值-->
<public:property name="caption" put="putCaption"/>
<!--readOnly属性-->
<public:property name="readOnly" value="false" get="getReadOnly" put="putReadOnly"/>
<!--读取所选项的值-->
<public:property name="value" get="getValue" put="putValue" />
<!--读取所选项的值-->
<public:property name="text" get="getText"/>
<!--刷新组件-->
<public:method name="refresh"/>
<!--得到装配的R-->
<public:method name="saveText"/>
<script language="JavaScript">
<!--
var objDIVSelect,objSelect; //包括了列表框, 确定按钮 , 取消取消按钮的Element
var objDIVInput; //包括了你文本框,选择按钮的Element
var objCaption;
var arrValue = new Array (); //保存数据的的数据
var arrText = new Array (); //保存数据所对应的文本
var objXMLDoc; //XML文档对像
var comtop; //组件的上边距
var comleft; //组件的左边距
var textCaption; //caption属性,显示的组件的标题
var IsReadOnly;//组件的不可编辑属性
var CanCreateSec = false;//是否可以创建Select
var textTimeer;
function getText(){//取条目文本
return arrText;
}
function getValue(){//取条目值
return arrValue;
}
function putValue(anyvalue){//设置arrValue的值
var tmpText="";
var isFirest = true;
if(anyvalue==null)
return;
if(typeof(anyvalue) == "string"){//string
arrValue = anyvalue.split(departsymbol);
}else{//array
arrValue = anyvalue;//赋新值
}//End of typeof(anyValue)
arrText = new Array();
if(typeof(objXMLDoc)=='object'){
for(var i=0;i<arrValue.length;i++){
if(arrValue[i] != ""){
if(isFirest==false){
tmpText +=";";
}
arrText[i] = objXMLDoc.selectSingleNode("//*[@"+valueCol+"='"+arrValue[i]+"']").getAttribute(textCol);
tmpText += arrText[i];
isFirest = false;
}else{
arrValue.pop();
}//end if...elese
}//end for
}
objDIVInput.children(0).value = tmpText; //从列表到数组的转化
}//end of function putValue
function getReadOnly(){//得到只读属性
return IsReadOnly;
}
function putReadOnly(inIsReadOnly){//设置组件的只读属性
var objBtnRect = objDIVInput.children(1).children(0);
this.IsReadOnly = inIsReadOnly;
if(IsReadOnly){//如果是true
objBtnRect.fillcolor = "#CCCCCC";
objBtnRect.strokecolor = "#BBBBBB";
objBtnRect.fill.color2= "#F5F5F5";
objDIVInput.style.borderColor = "#CCCCCC";
}else//否则
{
objBtnRect.fillcolor = "#B5CFFF";
objBtnRect.strokecolor = "#ADC3F7";
objBtnRect.fill.color2= "#DEE3FF";
if(objDIVInput)
objDIVInput.style.borderColor = "#7B9EBD";
}//end if
}//end function of putReadOnly
function putCaption( inCaption){//设置组件的caption属性
textCaption = inCaption;
createCaption(inCaption);
}
function putTop(inTop){//设置上边距
comtop = parseInt(inTop);
}
function putLeft(inLeft){//设置左边距
comleft = parseInt(inLeft);
}
function lostFocus(){//焦点消失/
window.document.attachEvent("onmousedown",clickDocument);
}
function clickDocument(){//点击Input以外的Document对象时隐藏QInput
if(false) return;
var objSrc = window.event.srcElement;
if(element.contains(objSrc)) return;
//QInput消失
window.document.detachEvent("onmousedown",clickDocument);
onClickCancel();//隐藏列表框
}
function saveText(){//返回当前编辑的数据的XML(R)的格式
var length = arrValue.length;
var TextReturn = "";//返回的字符串
for(var nindex=0; nindex<length; nindex++){//转化库字符串
if(nindex!=0)
TextReturn += departsymbol;//以相应的分隔符分开
TextReturn += arrValue[nindex]; //将数组连接起来
}
return TextReturn;//返回连接好的字符串
}
function createSelectDIV(){ //创建DIV以来容纳列表框以及两个选择按钮
var btnOK; //确定按钮
var btnCacel; //取消按钮
//创建容纳列表的DIV
///////////////////////hzh///////
//objDIVSelect = element.document.createElement("<DIV style=\"position:absolute;z-index:90;display:block;border:1px solid #7B9EBD;padding:1px;background:#cccccc\";>");
objDIVSelect = element.document.createElement("<DIV style='position:absolute;z-index:200;border:1px solid #7B9EBD;padding:1px;background-color:#ffffff;'>");
////////////////////////////
objDIVSelect = element.appendChild(objDIVSelect) ;
//
objDIVSelect.style.width = width;
objDIVSelect.style.border = "1px solid #666666"; //设置objDIVselect的边框样式
objDIVSelect.style.visibility = "hidden"; //设置库不可见
// if(textCaption!=null){//如果caption不为空
// objDIVSelect.style.left = 12*(textCaption.length + 1);//指定父元素的左边距
// objDIVSelect.style.left = element.children("theCaptionObj").offsetWidth;
// }else
// objDIVSelect.style.left = 0; //指定父元素的左边距
//创建确定按钮
btnOK = element.insertAdjacentHTML("afterBegin","<v:group style='bottom:1px;right:20px;position:absolute;width:14px; height:16px;z-index:1; ' coordsize='14,16'><v:roundrect arcsize='0.1' style='width:14;height:16;' fillcolor='#B5CFFF' strokecolor='#ADC3F7'><v:fill type='gradientradial' color2='#DEE3FF' angle='45'/></v:roundrect><v:polyline style='position:absolute;top:6; left:3' points='0,2 4,4 8,0' strokecolor='7B9EBD' strokeweight='2px' filled='false'/></v:group><xml:namespace ns='schemas-microsoft-com:VML' prefix='v'/>");
//btnOK = element.insertAdjacentHTML("afterBegin","<v:group style='top:1px;right:1px;position:absolute;width:14px; height:16px;z-index:3;' coordsize='14,16'><v:roundrect arcsize='0.1' style='width:14;height:12;' fillcolor='#B5CFFF' strokecolor='#ADC3F7'><v:fill type='gradientradial' color2='#DEE3FF' angle='75'/></v:roundrect><v:polyline style='position:absolute;top:4; left:3' points='0,0 4,4 8,0' strokecolor='#4A6184' strokeweight='2px' filled='false'/></v:group><xml:namespace ns='schemas-microsoft-com:VML' prefix='v'/>");
btnOK = element.children(0);
btnOK = objDIVSelect.appendChild(btnOK); //设作objDIVSelect的子元素
with(btnOK){
onmousedown = onClickOK ;//确定的点击事件
}
//创建取消按钮
btnCancel = element.insertAdjacentHTML("afterBegin","<v:group style='bottom:1px;right:2px;position:absolute;width:14px; height:16px;z-index:1;' coordsize='14,16'><v:roundrect arcsize='0.1' style='width:14;height:16;' fillcolor='#B5CFFF' strokecolor='#ADC3F7'><v:fill type='gradientradial' color2='#DEE3FF' angle='45'/></v:roundrect><v:polyline style='position:absolute;top:6; left:3' points='0,0 4,4 8,0 0,8 4,4 8,8' strokecolor='#4A6184' strokeweight='2px' filled='false'/></v:group><xml:namespace ns='schemas-microsoft-com:VML' prefix='v'/>");
btnCancel = element.children(0);
btnCancel = objDIVSelect.appendChild(btnCancel); //设作objDIVSelect的子元素
with(btnCancel){
onmousedown = onClickCancel;//取消的点击事件
}//end with
CanCreateSec = false;
createObjSelect();//创建列表框
}
function createObjSelect(){//创建列表框
var topofDIV; //DIV的上边距
var vXSLT; //用来格式化objXMLDoc文件的的XSL文档(str串)
var objXSLT;//用来格式化objXMLDoc文件的的XSL文档对象
var strSelect;//select的创建串
var objIfr;//用于包含objSelect的iframe
// var objSelect;//Select的对像
var size; //Select中的可选size数
if(!objXMLDoc) return ;
if(!CanCreateSec) return; //是否可以创建了
if (objSelect) return; //如果列表框已经创建
//创建格式化objXMLDoc的XSL:vXSLT
vXSLT ="<xsl:stylesheet version = '1.0' xmlns:xsl = 'http://www.w3.org/1999/XSL/Transform'><xsl:output method = 'html'/><xsl:template match=\"/\"><xsl:for-each select=\"/*/*\"><option><xsl:attribute name='value'>";
vXSLT +="<xsl:value-of select='@"+valueCol+"'/></xsl:attribute><xsl:attribute name='id'><xsl:value-of select='@"+valueCol+"'/></xsl:attribute><xsl:value-of select='@"+textCol+"'/></option></xsl:for-each></xsl:template></xsl:stylesheet>";
try{
strSelect = "<select multiple='true' style='position;absolute;top:200px;left:0px;border:1px solid red;'>";//构造select的HTML代码
strSelect += window.parent.__objGlobalCommonInst.transformDicXML(objXMLDoc,vXSLT);//添加OPTION
}catch(e){
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -