?? coolbutton.js
字號:
var popupWin_btn=null;
function coolButton()
{
this.oParent=null;
this.direction="H";
if (arguments[0]!=null)
{
if (typeof arguments[0]=="string")
{
this.oParent=document.getElementById(arguments[0]);
if (this.oParent==null)
this.oParent=document.getElementsByName(arguments[0])[0];
}
}
if (arguments[1]!=null)
this.direction=arguments[1].toUpperCase();
if (this.oParent==null)
this.oParent=document.body;
this.cssFile="coolButton.css";
this.oTable=document.createElement("TABLE");
if (this.oParent!=document.body)
this.oTable.className="parentNoBody";
else
this.oTable.className="parentBody";
this.oTable.id="coolButtonBar";
this.imagesPath="";
if (this.direction=="H")
{
this.oTr=this.oTable.insertRow();
this.oTd=this.oTr.insertCell();
this.oTd.width="100%";
this.oTd.className="LeftArrow";
this.oTd.id="LeftArrow";
this.oTd.style.cursor="hand";
}
this.popupcoolBar=null;
this.hasPupupBar=false;
this.oParent.appendChild(this.oTable);
}
coolButton.prototype.createButton=function()
{
var tempTd,tempTr;
var iLeft=0;
if (arguments.length<5)
return;
if (typeof arguments[1]!="function")
return;
if (this.oParent!=document.body)
iLeft=this.oParent.offsetLeft;
if (this.direction=="H" && this.oTd.offsetLeft>document.body.clientWidth-105-iLeft)
{
return this.createPupupBar(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]);
}
if (this.direction=="H")
tempTd=this.oTr.insertCell(this.oTr.cells.length-1);
else if (this.direction=="V")
{
tempTr=this.oTable.insertRow();
tempTd=tempTr.insertCell();
}
else
return;
var tempBtn=document.createElement("BUTTON");
tempBtn.hideFocus=true;
tempBtn.className="imgBtn";
tempBtn.name=arguments[0];
tempBtn.id=arguments[0];
tempBtn.onclick=arguments[1];
tempBtn.title=arguments[2];
var tempImg=document.createElement("IMG");
tempImg.src=this.imagesPath+"/"+arguments[4];
tempBtn.disabled=(typeof arguments[5]=="boolean")?arguments[5]:false;
tempImg.align="absmiddle";
tempBtn.appendChild(tempImg);
tempTd.appendChild(tempBtn);
return document.getElementById(arguments[0]);
};
coolButton.prototype.sperateButton=function()
{
var tempTd,tempTr,count;
if (arguments.length<1)
count=1;
else
count=arguments[0];
if (this.hasPupupBar)
{
var tempTr=this.popupcoolBar.insertRow();
var tempTd=tempTr.insertCell();
tempTd.height="10px";
tempTd.innerHTML ="";
for(var i=0; i<count; i++)
tempTd.innerHTML +=" ";
}
else
{
if (this.direction=="H")
tempTd=this.oTr.insertCell(this.oTr.cells.length-1);
else if (this.direction=="V")
{
tempTr=this.oTable.insertRow();
tempTd=tempTr.insertCell();
}
else
return;
tempTd.innerHTML ="";
for(var i=0; i<count; i++)
tempTd.innerHTML +=" ";
}
};
coolButton.prototype.createPupupBar=function()
{
var d;
if (popupWin_btn==null)
{
popupWin_btn=window.createPopup();
this.hasPupupBar=true;
d=popupWin_btn.document;
d.write("<html><head></head><link rel=\"STYLESHEET\" type=\"text/css\" href=\""+this.cssFile+"\"><body class=\"CoolBar\"></body></html>");
alert("<html><head></head><link rel=\"STYLESHEET\" type=\"text/css\" href=\""+this.cssFile+"\"><body class=\"CoolBar\"></body></html>");
this.popupcoolBar=d.createElement("TABLE");
this.popupcoolBar.id="coolPanel";
this.popupcoolBar.className="parentNoBody";
d.body.appendChild(this.popupcoolBar);
this.oTd.innerText="6";
this.oTd.style.cursor="hand";
this.oTd.onclick=this.showBar;
}
d=popupWin_btn.document;
var tempTr=this.popupcoolBar.insertRow();
var tempTd=tempTr.insertCell();
var tempBtn=d.createElement("BUTTON");
tempBtn.hideFocus=true;
tempBtn.className="imgBtn";
tempBtn.name=arguments[0];
tempBtn.id=arguments[0];
tempBtn.onclick=arguments[1];
tempBtn.title=arguments[2];
tempBtn.disabled=(typeof arguments[5]=="boolean")?arguments[5]:false;
var tempImg=d.createElement("IMG");
tempImg.src=this.imagesPath+"/"+arguments[4];
tempImg.align="absmiddle";
tempBtn.appendChild(tempImg);
tempBtn.innerHTML+=" "+arguments[3];
tempTd.appendChild(tempBtn);
return d.getElementById(arguments[0]);
};
coolButton.prototype.showBar=function()
{
var oTable=popupWin_btn.document.getElementById("coolPanel");
var iBtnNums=popupWin_btn.document.getElementsByTagName("BUTTON");
var iPopupHeight=parseInt(oTable.rows.length*54+(oTable.rows.length<5?4:2));
popupWin_btn.show(-110,37,110,iPopupHeight,document.getElementById("LeftArrow"));
};
coolButton.prototype.setEnabled=function()
{
var oObj,benabled=false;
if (arguments.length<1)
return;
if (typeof arguments[0]=="string")
{
oObj=document.getElementById(arguments[0]);
if (oObj==null)
oObj=document.getElementsByName(arguments[0])[0];
}
else if (typeof arguments[0]=="object")
oObj=arguments[0];
if (oObj==null)
return;
if (typeof arguments[1]=="boolean")
benabled=!arguments[1];
oObj.disabled=benabled;
if (oObj.childNodes.length>0 && oObj.childNodes[0].tagName=="IMG")
oObj.childNodes[0].className=benabled?"disabled":"enabled";
}
function setEnabled()
{
var oObj,benabled=false;
if (arguments.length<2)
return;
oObj = arguments[0];
if (oObj==null)
return;
if (typeof arguments[1]=="boolean")
benabled=!arguments[1];
oObj.disabled=benabled;
if (oObj.childNodes.length>0 && oObj.childNodes[0].tagName=="IMG")
oObj.childNodes[0].className=benabled?"disabled":"enabled";
}
//查詢按鈕
coolButton.prototype.queryButton=function()
{
if (arguments.length<2)//沒有參數
return;
if (typeof arguments[0]!="function")
return;
return this.createButton("btnQuery",arguments[0],arguments[1],"查詢","query.gif",arguments[2]);
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -