📄 toolbar.js
字号:
var oButton = document.all (this.id + "_" + order);
if (oButton == null) return;
var i = order;
this.buttons[i].disable = disable;
if (disable)
{
this.normalButton(order);
if ((this.buttons[i].type == 1) || (this.buttons[i].type == 2))
{
oButton.style.filter = "alpha(opacity=25)";
oButton.onclick = null;
}
else if (this.buttons[i].type == 3)
{
oButton.value = this.buttons[i].currentValue;
oButton.disabled = true;
oButton.onblur = null;
oButton.onkeydown = null;
}
else if (this.buttons[i].type == 4)
{
oButton.value = this.buttons[i].currentValue;
oButton.disabled = true;
oButton.onchange = null;
}
}
else
{
if ((this.buttons[i].type == 1) || (this.buttons[i].type == 2))
{
oButton.style.filter = "";
oButton.attachEvent("onclick",this.buttons[i].handle);
oButton.attachEvent("onclick",this.getValue);
}
else if (this.buttons[i].type == 3)
{
oButton.disabled = false;
oButton.attachEvent("onblur",this.buttons[i].handle);
oButton.attachEvent("onblur",this.getValue);
oButton.attachEvent("onkeydown",this.doKeyDown)
}
else if (this.buttons[i].type == 4)
{
oButton.disabled = false;
oButton.attachEvent("onchange",this.buttons[i].handle);
oButton.attachEvent("onchange",this.getValue);
}
}
}
toolbar.prototype.normalButton = function (order)
{
if (this.buttons[order].disable) return;
var oButton = document.all (this.id + "_" + order);
if (oButton == null) return;
if ((this.buttons[order].type == 1) || (this.buttons[order].type == 2))
{
with (oButton.style)
{
border = "medium none";
padding = "2px";
cursor = "default";
textAlign = "left";
}
}
else if ((this.buttons[order].type == 3) || (this.buttons[order].type == 4))
{
oButton.value = this.buttons[order].currentValue;
}
this.buttons[order].status = 1;
this.makeGray(oButton,true);
}
toolbar.prototype.pressedButton = function (order)
{
if (this.buttons[order].disable) return;
if ((this.buttons[order].type == 1) || (this.buttons[order].type == 2))
{
var oButton = document.all (this.id + "_" + order);
if (oButton == null) return;
with (oButton.style)
{
borderLeft = "1px solid buttonshadow";
borderRight = "1px solid buttonhighlight";
borderTop = "1px solid buttonshadow";
borderBottom = "1px solid buttonhighlight";
paddingTop = "2px";
paddingLeft = "2px";
paddingBottom = "0px";
paddingRight = "0px";
}
this.buttons[order].status = 2;
this.makeGray(oButton,false);
}
else this.buttons[order].status = 1;
}
toolbar.prototype.raisedButton = function (order)
{
if (this.buttons[order].disable) return;
if ((this.buttons[order].type == 1) || (this.buttons[order].type == 2))
{
var oButton = document.all (this.id + "_" + order);
if (oButton == null) return;
with (oButton.style)
{
borderLeft = "1px solid buttonhighlight";
borderRight = "1px solid buttonshadow";
borderTop = "1px solid buttonhighlight";
borderBottom = "1px solid buttonshadow";
padding = "1px";
}
this.buttons[order].status = 3;
this.makeGray(oButton,false);
}
else this.buttons[order].status = 1;
}
toolbar.prototype.findChildren = function (eE, type, value)
{
var children = eE.children;
var tmp = new Array();
var j=0;
for (var i=0; i<children.length; i++)
{
if (eval("children[i]." + type + "==\"" + value + "\""))
{
tmp[tmp.length] = children[i];
}
tmp = tmp.concat(this.findChildren(children[i], type, value));
}
return tmp;
}
toolbar.prototype.makeGray = function (eE,b)
{
var filtval;
if (b)
filtval = "gray()";
else
filtval = "";
var imgs = this.findChildren(eE, "tagName", "IMG");
for (var i=0; i<imgs.length; i++)
imgs[i].style.filter = filtval;
}
toolbar.prototype.initToolbar = function ()
{
var oToolbar = document.all (this.id);
if (oToolbar == null) return;
oToolbar.onmousedown = this.doMouseDown;
oToolbar.onmouseup = this.doMouseUp;
oToolbar.onmouseover = this.doMouseOver;
oToolbar.onmouseout = this.doMouseOut;
if (this.ismove)
document.attachEvent ("onmousemove",this.doMouseMove);
}
toolbar.prototype.doKeyDown = function()
{
if (window.event.keyCode == 13)
{
var oE = tgetReal(window.event.srcElement,"isB","yes");
if (oE == null) return;
var i = parseInt(oE.torder);
getToolRef(window.event.srcElement);
if (crrT == null) return;
if ((i<0)||(i>=crrT.buttons.length)||isNaN(i)) return;
crrT.order = i;
if (crrT.buttons[i].type != 3) return;
crrT.buttons[i].currentValue = oE.value;
crrT.buttons[i].handle();
}
}
toolbar.prototype.doMouseDown = function ()
{
getToolRef(window.event.srcElement);
if (crrT == null) return;
window.event.returnValue = false;
window.event.cancelBubble = true;
var eE = tgetReal(window.event.srcElement,"isB","yes");
if (eE == null) return;
if (eE.torder == "drag")
if (crrT.ismove)
{
crrT.drag = true;
var odragbar = document.all (crrT.id);
crrT.bartx = window.event.clientX - parseInt(odragbar.style.left);
crrT.barty = window.event.clientY - parseInt(odragbar.style.top);
}
else crrT.drag = false;
else
{
var i = parseInt(eE.torder);
if (isNaN(i)) return;
if ((i<0) || (i>=crrT.buttons.length)) return;
if (crrT.buttons[i].disable) return;
if (crrT.buttons[i].type == 1)
crrT.pressedButton(i);
else if (crrT.buttons[i].type == 2)
if (crrT.buttons[i].status == 2) //the button is pressed
crrT.raisedButton(i);
else crrT.pressedButton(i);
}
crrT = null;
}
toolbar.prototype.doMouseUp = function ()
{
getToolRef(window.event.srcElement);
if (crrT == null) return;
window.event.returnValue = false;
window.event.cancelBubble = true;
var eE = tgetReal(window.event.srcElement,"isB","yes");
if (eE == null) return;
crrT.drag = false;
if (eE.torder != "drag")
{
var i = parseInt(eE.torder);
if (isNaN(i)) return;
if ((i<0) || (i>=crrT.buttons.length)) return;
if (crrT.buttons[i].type == 1)
crrT.raisedButton(i);
}
crrT = null;
}
toolbar.prototype.doMouseOver = function ()
{
getToolRef(window.event.toElement);
if (crrT == null) return;
window.event.returnValue = false;
window.event.cancelBubble = true;
var eE = tgetReal(window.event.toElement,"isB","yes");
if (eE == null) return;
crrT.drag = false;
if (eE.torder != "drag")
{
var i = parseInt(eE.torder);
if (isNaN(i)) return;
if ((i<0) || (i>= crrT.buttons.length)) return;
if (crrT.buttons[i].type == 1)
crrT.raisedButton(i);
else if ((crrT.buttons[i].type == 2)&&(crrT.buttons[i].status == 1))
crrT.raisedButton(i);
}
crrT = null;
}
toolbar.prototype.doMouseMove = function ()
{
getToolRef(window.event.srcElement);
if (crrT == null) return;
window.event.returnValue = false;
window.event.cancelBubble = true;
if (!crrT.drag) return;
if (!crrT.ismove) return;
var eE = tgetReal(window.event.srcElement,"torder","drag");
if (eE == null) return;
var odragbar = document.all (crrT.id);
if (odragbar)
{
odragbar.style.left = window.event.clientX - crrT.bartx;
odragbar.style.top = window.event.clientY - crrT.barty;
}
}
toolbar.prototype.doMouseOut = function ()
{
getToolRef(window.event.fromElement);
if (crrT == null) return;
window.event.returnValue = false;
window.event.cancelBubble = true;
var eE = tgetReal(window.event.fromElement,"isB","yes");
if (eE == null) return;
crrT.drag = false;
if (eE.torder != "drag")
{
var i = parseInt(eE.torder);
if (isNaN(i)) return;
if ((i<0) || (i>=crrT.buttons.length)) return;
if (crrT.buttons[i].type == 1)
crrT.normalButton(i);
else if ((crrT.buttons[i].type == 2)&&(crrT.buttons[i].status == 3))
crrT.normalButton(i);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -