📄 select.htc
字号:
vClickNum = true;
}
}
function clickBtn(){ //click the button
//debugger;
if(window.event.button != 1) return;
//if(objList) hideList3(); //在有list的情况下关闭list按钮变成over状态
//else{ //在没有list的情况下
downBtn(); //按钮样式变为down状态
showList();
//}
}
function showList(){ //show drop down option list
var i;
var objTemp;
var objTR,objTD;
var collNodes;
var vEleCurrTop,vEleCurrHeight;
var vListHeight,vListTop;
var vDocClientHeight;
var vScrollTopTemp; //当前选项的顶端与list 的底部之间的距离
var oCaption;//标题对象
//debugger;
if(!objXMLDoc) return;
if(autoSize.toString() == "true"){ //设置autoSize,true时等于选项的最宽宽度
objList.style.overflowX = "visible";
objList.childNodes[0].style.pixelWidth = objTemp.offsetWidth;
}
else{ //false时等于组件的宽度。
objList.style.overflowX = "hidden";
objList.childNodes[0].style.pixelWidth = objList.offsetWidth;
}
//locate list box
vEleCurrTop = vElementTop - element.document.body.scrollTop; //element顶端到所在页面当前可视区域的顶端的距离
//vEleCurrTop = vElementTop - element.offsetParent.scrollTop; //element顶端到所在页面当前可视区域的顶端的距离
vEleCurrHeight =element.offsetHeight; //element当前高度
vDocClientHeight = element.document.body.clientHeight; //页面可视范围高度
vListHeight = Math.min(objList.scrollHeight + 2,vListMaxHigh); //确定list的高度,不允许超过限定高度vListMaxHigh
//确定 list's top以及可能重新确定 height
if(vDocClientHeight - vEleCurrTop - vEleCurrHeight < vListHeight){ //element to body's bottom如果小于list需要的高度就在element上方显示
vListTop = - Math.min((vListHeight + 1),vEleCurrTop); //如果element上方的空间也不够那 list 也只能顶到当前可视范围的顶部
if(vListHeight > vDocClientHeight) vListHeight -= vListHeight - vDocClientHeight;
}
else{
//vListTop = vEleCurrTop + objInput.offsetHeight + 3;
vListTop = objInput.offsetTop + objInput.offsetHeight + 2;
}
element.style.zIndex = 10; //解决 select 之间无法互相覆盖的问题
if(autoSize.toString() == "true" && objList.scrollHeight + 2 <= vListMaxHigh) objList.style.overflowY = "visible"; //对于autoSize情况下如果不会出现滚动条则 list 的overflow-y必须为visible,否则其右侧会出现难看的滚动条宽度的空白,放在这里是因为程序执行到这里才最终确定了vListHeight
with(objList){
style.top = parseInt(vListTop) -1;
style.pixelHeight = vListHeight;
style.visibility = "visible";
}
}
function hideList(){ //hide option list
if(objList){
objList.style.visibility = "hidden";
element.style.zIndex = 1; //解决select之间无法互相覆盖的问题
}
}
function hideList2(){ //hide option list and objBtn恢复到初始状态
hideList();
outBtn();
}
function hideList3(){ //hide option list and objBtn恢复到 mouseover 状态
hideList();
overBtn();
}
function overOption(){
var objSrc = window.event.srcElement;
if(objSelectedOption != objSrc && objSrc.tagName.toLowerCase() == "td"){
objSrc.runtimeStyle.color = "#ffffff";
objSrc.runtimeStyle.backgroundColor = "#666666";
if(objSelectedOption){
objSelectedOption.runtimeStyle.color = "";
objSelectedOption.runtimeStyle.backgroundColor = "";
}
objSelectedOption = objSrc;
}
}
function selectOption(){
//debugger;
if(window.event.button != 1) return;
var objSrc = window.event.srcElement;
if(objSrc.tagName.toLowerCase() == "td"){
value = objSrc.value;
////////hzh 2004-04-20//////////
objInput.focus();
/////////////////////////////
hideList2(); //objBtn初始状态
}
window.event.cancelBubble = true;
}
function clear(){ //no option,clear
vValue = "";
vText = "";
bInputChange = false; //not fire objInput's onpropertychange event,看changeInput()
objInput.value = "";
objXMLDoc = null;
}
function turn(){ //trun over the list,input_keydown
var objNode;
switch(window.event.keyCode){
case 38: //up direction key
objNode = objXMLDoc.selectSingleNode("/*/*[@" + vValueCol + "='" + vValue + "' and @" + vTextCol + "='" + vText + "']");
if(objNode) objNode = objNode.previousSibling;
else objNode = objXMLDoc.documentElement.firstChild;
if(objNode) value = objNode.getAttribute(vValueCol);
window.event.returnValue = false;
break;
case 40: //down direction key
objNode = objXMLDoc.selectSingleNode("/*/*[@" + vValueCol + "='" + vValue + "' and @" + vTextCol + "='" + vText + "']");
if(objNode) objNode = objNode.nextSibling;
else objNode = objXMLDoc.documentElement.firstChild;
if(objNode) value = objNode.getAttribute(vValueCol);
window.event.returnValue = false;
break;
}
}
function overBtn(){ //鼠标移动到objBtn上的样式
var objBtnBg = objBtn.children(0); //表现按钮背景的<v:roundrect>
objBtnBg.fillcolor = "#BDE3FF";
objBtnBg.fill.color2 = "#E7F3FF";
}
function outBtn(){ //鼠标移出Btn 或者input时的样式
var objBtnBg;
if(objList && objList.style.display != "none") overBtn(); //打开了 list 情况下 out btn 或者 input 的情况下按钮变 over 的情况
else{ //没打开的情况下则恢复原有样式
objBtnBg = objBtn.children(0); //表现按钮背景的<v:roundrect>
objBtnBg.fillcolor = "#B5CFFF";
objBtnBg.fill.color2 = "#DEE3FF";
}
}
function downBtn(){ // Btn 按下后的样式
var objBtnBg = objBtn.children(0); //表现按钮背景的<v:roundrect>
objBtnBg.fillcolor = "#9CB2F7";
objBtnBg.fill.color2 = "#6B8EF7";
}
function noResponse(){
window.event.cancelBubble = true;
window.event.returnValue = false;
}
function inputXML(argSource){ //get XMLDocument
var objGloballCommonInst;
if(typeof(__objGlobalCommonInst) == "undefined"){
objGloballCommonInst = window.dialogArguments.__objGlobalCommonInst;
}else{
objGloballCommonInst = __objGlobalCommonInst;
}
return objGloballCommonInst.inputXML(argSource);
}
function refresh2(){
var objTemp;
var intHeight;
with(element){
style.top = parseInt(vTop);
style.left = parseInt(vLeft);
style.pixelHeight = vHeight;
style.pixelWidth = vWidth;
}
with(oDiv){
style.left = oCaption.style.width;
style.pixelHeight = vHeight - 2;
style.pixelWidth = vWidth - parseInt(oCaption.style.width) + 1;
}
with(objInput){
style.pixelWidth = (parseInt(oDiv.style.pixelWidth)) - 18;
intHeight = oDiv.style.pixelHeight - 5;
style.top = 0;
style.height = (intHeight < 17)?(intHeight + 3):(intHeight);
}
with(objBtn){
style.left = parseInt(objInput.style.width) - 1;
style.height = parseInt(oDiv.style.pixelHeight) -1;
}
with(oCaption){
style.top = 4;
}
with(objList){
//debugger;
onmousedown = selectOption;
onmouseover = overOption;
style.visibility = "hidden";
style.left = parseInt(oDiv.style.left);
style.width = parseInt(oDiv.style.width) + 500;
style.top = 1; //初始值,后面将改变
style.pixelHeight = 1; //初始值,后面将改变
style.pixelWidth = parseInt(objInput.style.width) + 18;
///////////////////////
style.scrollbarArrowColor = "#666666";
style.scrollbarFaceColor = "#B3E0FF";
style.scrollbarHighlightColor = "#A6C4E1";
style.scrollbarShadowColor = "#BFD5EA";
style.scrollbarTrackColor = "#B3E0FF";
}
}
function refresh(){ //刷新
refresh2();
vValue = "";
vText = ""; //重置
}
function clearContent(){//
if(event.keyCode == "27"){
objInput.value = "";
vText = "";
vValue = "";
}
}
function initialize(){
//全局变量赋值
initGlobalCommon();
objSelectedOption = null;
vValue = "";
vText = "";
vListMaxHigh = 92;
vOptionLineHigh = 15;
bInputChange = true;
vClickNum = false;
comStyle = comStyle.toLowerCase(); //comStyle
oDiv = element.document.createElement("<div class='phms_selectoDiv'/>");
oDiv = element.appendChild(oDiv);
oCaption = element.document.createElement("<span class='phms_secCaption'/>");
oCaption = element.appendChild(oCaption);
objInput = element.document.createElement("<input class='phms_sec_input'/>");
objInput = oDiv.appendChild(objInput);
objInput.onkeyup = clearContent;
//下拉框
objList = element.document.createElement("<div class='phms_sec_list'></div>");
objList = element.appendChild(objList);
ouvSPAN = element.document.createElement("span");
ouvSPAN = element.appendChild(ouvSPAN);
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'/>");
objBtn = element.children(0);
objBtn = oDiv.appendChild(objBtn);
with(objBtn){
onmousedown = clickBtn;
onmouseup = overBtn;
onmouseover = overBtn;
onmouseout = outBtn;
}
with(ouvSPAN){
//
style.visibility = "hidden";
if(typeof(vCaption)!="undefined") innerText = vCaption;
}
with(oCaption){//secCaption定位、样式
style.top = 6;
style.width = ouvSPAN.offsetWidth;
style.height = ouvSPAN.offsetHeight;
vIvsB = (105 - parseInt(style.width))/14;
if(typeof(vCaption) != "undefined")
innerText = vCaption;
ouvSPAN = element.removeChild(ouvSPAN);
}
if(vText) objInput.value = vText; //如果有初始值则赋初值
readOnly = false; //设置objBtn和objInput的事件绑定
refresh2();
element.runtimeStyle.visibility = "visible";
}
function initGlobalCommon(){//初始化__objGlobalCommonInst
if(!element.document.parentWindow.__objGlobalCommonInst){//如果还没有初始化
var oWindow;
oWindow = element.document.parentWindow;
oWindow.__objGlobalCommonInst = oWindow.parent.__objGlobalCommonInst;
__objGlobalCommonInst = oWindow.__objGlobalCommonInst;
if(typeof(__objGlobalCommonInst) == "undefined")
__objGlobalCommonInst = window.dialogArguments.__objGlobalCommonInst;
}
}
</script>
</public:component>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -