📄 dhtmlxmenubar.js
字号:
mode=node.getAttribute("mode");
if(mode)that.setMenuMode(mode);
var menuAlign=node.getAttribute("menuAlign");
if(menuAlign)that.setBarAlign(menuAlign);
that.maxItems=node.getAttribute("maxItems")||99;
var absolutePosition=node.getAttribute("absolutePosition");
var aleft=node.getAttribute("left");
var atop=node.getAttribute("top");
if(absolutePosition)that.topNod.style.top=atop || 0;
if(absolutePosition)that.topNod.style.left=aleft || 0;
if(absolutePosition=="yes")that.topNod.style.position="absolute";
var name=node.getAttribute("name");
if(name)that.setTitleText(name);
var width=node.getAttribute("width");
var height=node.getAttribute("height");
that.setBarSize(width,height);
var imageTextButtonCssClass=node.getAttribute("imageTextButtonCssClass");
var globalTextCss=node.getAttribute("globalTextCss");
that.globalSecondCss=node.getAttribute("globalSecondCss");
that.globalCss=node.getAttribute("globalCss");
that.globalTextCss=node.getAttribute("globalTextCss");
if(node.getAttribute("withoutImages"))that.withoutImages=true;
if(node.getAttribute("mixedImages"))that.mixedImages=true;
that.type=node.getAttribute("type")||"a1";
}
}
if(level){
var parentNode=new dhtmlXMenuBarPanelObject(parentNode,aTempNode,((mode!="classic")&&(mode!="popup")),node.getAttribute("panelWidth"),(node.getAttribute("withoutImages")?1:(node.getAttribute("mixedImages")?2:0)));
parentNode.maxItems=node.getAttribute("maxItems")||that.maxItems;
}
for(var i=0;i<node.childNodes.length;i++)
{
if(node.childNodes[i].nodeType==1)
{
var localItem=node.childNodes[i]
if(!level)
{
if((!localItem.getAttribute("className"))&&(that.globalCss))
localItem.setAttribute("className",that.globalCss);
}
else
if(!localItem.getAttribute("className"))
{
if(that.globalSecondCss)
localItem.setAttribute("className",that.globalSecondCss);
else
localItem.setAttribute("className","menuButtonSecond");
}
if((!localItem.getAttribute("textClassName"))&&(that.globalTextCss))
localItem.setAttribute("textClassName",that.globalTextCss);
var tempsrc=localItem.getAttribute("src");
if(parentNode.withoutImages){
localItem.setAttribute("src","");
localItem.setAttribute("src2",that.sysGfxPath+"blank.gif");
}
else
{
if((parentNode.mixedImages)&&(tempsrc==null))
tempsrc=that.sysGfxPath+"blank.gif";
else
tempsrc=that.sysGfxPath+(tempsrc||"blank.gif");
localItem.setAttribute("src",tempsrc);
}
tempsrc=localItem.getAttribute("wide");
if(tempsrc==null){
localItem.setAttribute("width","100%");
}
if(that._endtt)localItem.setAttribute("tooltip","");
var z=eval("window.dhtmlX"+localItem.tagName+"Object");
if(z)
var TempNode= new z(localItem,node.getAttribute("type")||that.type);
else
var TempNode=null;
if(localItem.tagName=="divider")
if((level)||(that.modeValue=="popup"))
that.addItem(parentNode,new dhtmlXMenuDividerYObject(localItem.getAttribute("id")));
else
that.addItem(parentNode,new dhtmlXMenuDividerXObject(localItem.getAttribute("id")));
else
if(TempNode)
if(level)
that.addItem(parentNode,TempNode);
else
that.addItem(parentNode,TempNode);
if(that.checkXMLChild(localItem))that._parseXMLTree(that,localItem,level+1,parentNode,TempNode,mode);
}
}
that._scrollCheck(parentNode);
if((level==0)&&(that.topMenu.waitCall))that.topMenu.waitCall();
}
dhtmlXMenuBarObject.prototype.checkXMLChild=function(node){
for(var i=0;i<node.childNodes.length;i++)
if(node.childNodes[i].nodeType==1)return true;
return false;
}
dhtmlXMenuBarObject.prototype._createPanel=function()
{
if(!this.width)this.width=1;
if(!this.height)this.height=1;
var div=document.createElement("div");
div.innerHTML='<table cellpadding="0" cellspacing="0" class="'+this.topMenu.tableCSS+'" width="'+this.width+'" height="'+this.height+'"><tbody>'+
'<tr>'+
'<td width="3px" style="display:none"><div class="menuHandle"> </div></td>'+
'<td class="'+this.topMenu.titleCSS+'" style="display:none">'+this.topMenu.tname+'</td>'+
'<td></td>'+
'<td align="right" width="100%" class="'+this.topMenu.titleCSS+'"> '+this.topMenu.tname+'</td>'+
'<td > </td>'+
'</tr></tbody></table>';
var table=div.childNodes[0];
table.style.display="none";
table.setAttribute("UNSELECTABLE","on");
table.onselectstart=this.topMenu.badDummy;
this.topNod=table;
this.dividerCell=table.childNodes[0].childNodes[0].childNodes[0];
this.dividerCell.menu=this;
this.preNameCell=this.dividerCell.nextSibling;
this.firstCell=this.preNameCell.nextSibling;
this.nameCell=this.firstCell.nextSibling;
this.crossCell=this.nameCell.nextSibling;
if(this.topMenu!=this){
this.dividerCell.style.display="none";
this.preNameCell.style.display="none";
this.nameCell.style.display="none";
this.crossCell.style.display="none";
table.className=this.topMenu.secTableCSS;
}
this.topNod.style.zIndex=this.topMenu.zIndex;
if(this.topMenu.ieFix)
{
var iframe=document.createElement("IFRAME");
if(this.topMenu.sysGfxPath)
iframe.src=(this._httpsdummy||(this.topMenu.sysGfxPath+"blank.gif"));
iframe.style.zIndex=this.topMenu.zIndex-1;iframe.style.position="absolute";
iframe.style.display="none";iframe.scrolling="no";iframe.frameBorder=0;
if(!this._delayInit)
this.parentObject.appendChild(iframe);
else this._del_iframe=iframe;
}
if(!this._delayInit)
this.parentObject.appendChild(table);
else this._del_table=table;
};
dhtmlXMenuBarObject.prototype.setMenuCSS=function(table,title,secTable){
this.tableCSS=table;
this.titleCSS=title;
this.secTableCSS=secTable;
this.topNod.className=this.tableCSS;
this.preNameCell.className=this.titleCSS;
this.nameCell.className=this.titleCSS;
}
dhtmlXMenuBarObject.prototype._createVPanel=function()
{
if(!this.width)this.width=120;
if(!this.height)this.height=20;
var div=document.createElement("div");
div.innerHTML='<table cellpadding="0" cellspacing="0" class="'+this.topMenu.tableCSS+'" width="'+this.width+'" ><tbody>'+
'<tr ><td class="menuscrollerdisabled" style="display:none"><img src="'+this.topMenu.sysGfxPath+'btn_up1.gif"></td></tr>'+
'<tr><td class="'+this.topMenu.titleCSS+'" style="display:none">'+this.tname+'</td></tr>'+
'<tr><td></td></tr>'+
'<tr><td class="menuscrollerdisabled" style="display:none"><img src="'+this.topMenu.sysGfxPath+'btn_up2.gif"></td></tr>'+
'<tr><td align="right" class="'+this.topMenu.titleCSS+'" style="display:none">'+this.tname+'</td></tr>'+
'<tr><td></td></tr>'+
'</tbody></table>';
var table=div.childNodes[0];
table.style.display='none';
this.topNod=table;
table.onselectstart=this.topMenu.badDummy;
table.setAttribute("UNSELECTABLE","on");
this.dividerCell=table.childNodes[0].childNodes[0].childNodes[0];
table.menu=this;
this.scrollUp=this.dividerCell;
this.scrollonmouseover="";
this.preNameCell=table.childNodes[0].childNodes[1].childNodes[0];
this.firstCell=table.childNodes[0].childNodes[2];
this.scrollDown=table.childNodes[0].childNodes[3].childNodes[0];
this.nameCell=table.childNodes[0].childNodes[4].childNodes[0];
this.crossCell=table.childNodes[0].childNodes[5].childNodes[0];
if(this.topMenu!=this){
this.preNameCell.parentNode.style.display="none";
this.nameCell.parentNode.style.display="none";
this.crossCell.parentNode.style.display="none";
table.className=this.topMenu.secTableCSS;
}
this.topNod.style.zIndex=this.topMenu.zIndex;
if(this.topMenu.ieFix)
{
var iframe=document.createElement("IFRAME");
iframe.style.zIndex=this.topMenu.zIndex-1;iframe.style.position="absolute";
iframe.src=(this._httpsdummy||(this.topMenu.sysGfxPath+"blank.gif"));
iframe.style.display="none";iframe.scrolling="no";iframe.frameBorder=0;
if(!this._delayInit)
this.parentObject.appendChild(iframe);
else this._del_iframe=iframe;
this.topNod.ieFix=iframe;
}
if(!this._delayInit)
this.parentObject.appendChild(table);
else this._del_table=table;
};
function dhtmlXMenuItemObject(id,text,width,src,className,disableImage,href,target,type){
type=type||"a1";
var src2="";
var tooltip="";
if(id.tagName=="MenuItem")
{
type=text||"a1";
src=id.getAttribute("src");
src2=id.getAttribute("src2");
text=id.getAttribute("name");
className=id.getAttribute("className");
disableImage=id.getAttribute("disableImage");
width=id.getAttribute("width");
href=id.getAttribute("href");
target=id.getAttribute("target");
tooltip=id.getAttribute("tooltip");
if((tooltip!=="")&&(!tooltip))tooltip=text;
id=id.getAttribute("id");
}
if(id)this.id=id;
else this.id=(new Date()).valueOf();
src2=src2||src;
this.topNod=0;
this.action=0;
this.persAction=0;
this.src=src;
this.text=text;
this.href=href;
this.target=target;
this.className=className||"menuButton";
this.textClassName="defaultMenuText";
this.disableImage=disableImage;
td=document.createElement("td");
this.topNod=td;td.align="center";
td.noWrap=true;
td.innerHTML="<table align='left' cellpadding='0' cellspacing='0' border='0' "+(width?("width='"+width+"'"):"")+" height='100%'><tr><td width='20px' style=' "+(src?"":"display:none;")+"'><img src='"+src2+"' border='0' width='18px' height='18px'></td><td width='100%' align='left' style=' "+(src?" padding-left:2px;":"")+" overflow:hidden;' ><table width='100%' height='100%' cellpadding='0' cellspacing='0'><tr><td title='"+tooltip+"' class='"+this.textClassName+"' nowrap >"+this.text+"</td><td width='12px'><img style='display:none'></td></tr></table></td></tr></table>";
this.imageTag=td.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0];
this.childMenuTag=td.childNodes[0].childNodes[0].childNodes[0].childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[1].childNodes[0];
this.textTag=this.childMenuTag.parentNode.parentNode.childNodes[0];
switch(type){
case "a1":
this.CSSTag=td;
this.CSSImageTag=null;
break;
case "a2":
this.CSSTag=td.childNodes[0];
this.CSSImageTag=null;
break;
case "a3":
this.CSSTag=td.childNodes[0].childNodes[0].childNodes[0].childNodes[1];
this.CSSImageTag=null;
break;
case "b1":
this.CSSTag=td;
this.CSSImageTag=this.imageTag.parentNode;
break;
case "b2":
this.CSSTag=td.childNodes[0];
this.CSSImageTag=this.imageTag.parentNode;
break;
case "b3":
this.CSSTag=td.childNodes[0].childNodes[0].childNodes[0].childNodes[1];
this.CSSImageTag=this.imageTag.parentNode;
break;
}
td.id="menuItem_"+this.id;
this.CSSTag.className=this.className;
td.objectNode=this;
this.enable();
return this;
};
dhtmlXMenuItemObject.prototype=new dhtmlXButtonPrototypeObject;
dhtmlXMenuItemObject.prototype.enable=function(){
if(this.disableImage)this.imageTag.src=this.src;
else
if(!this.className)
this.topNod.className=this.objectNode.className;
else
this.topNod.className=this.className;
if(this.textTag)
this.textTag.className=this.textClassName;
this.topNod.onmouseover=this._onmouseoverX;
this.topNod.onmouseout=this._onmouseoutX;
this.topNod.onmousedown=this._onmousedownX;
this.topNod.onmouseup=this._onclickX;
};
dhtmlXMenuItemObject.prototype._onmousedownX=function(e){if((!this.objectNode.parentPanel.parentPanel)&&(this.objectNode.subMenu))this.objectNode._onclickX(e,this.objectNode);};
dhtmlXMenuItemObject.prototype.setHasChild = function(mode){
if((convertStringToBoolean(mode))&&(this.parentPanel.topMenu.echsw)){
this.childMenuTag.src=this.parentPanel.topMenu.sysGfxPath+'btn_rt1.gif';
this.childMenuTag.style.display='';
}
else this.childMenuTag.style.display='none';
};
dhtmlXMenuItemObject.prototype.setText = function(newText){
this.topNod.childNodes[0].childNodes[0].childNodes[0].childNodes[1].innerHTML=newText;
};
dhtmlXMenuItemObject.prototype._onclickX=function(e,that){
if(!e)e=event;
e.cancelBubble=true;
if(!that)that=this.objectNode;
var thatM=that.parentPanel.topMenu;
if(that.topNod.dstatus)return;
if((thatM.ieWinMode)&&(!thatM.ieWinModeState)&&(that.subMenu))
{
that.parentPanel.topMenu._onItemOver(that,that.subMenu);
if(document.body.currentActiveMenu!=thatM)
if(document.body.onmouseup){document.body.onmouseup();}
if(thatM.realWinModeStart)
{
that.parentPanel.topMenu.ieWinModeState=1;
if(document.body.onmouseup!=thatM._onclickclose)
{
thatM.olddoc=document.body.onmouseup;
document.body.onmouseup=thatM._onclickclose;
}
document.body.currentActiveMenu=that.parentPanel.topMenu;
thatM.realWinModeStart=0;
}
else thatM.realWinModeStart=1;
return;
}
if((thatM.ieWinMode)&&(thatM.ieWinModeState)&&(that.subMenu)){
if(!thatM.realWinModeStart)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -