⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dhtmlxmenubar.js

📁 dhtmlXTreeprofessional 这是专业1.3版
💻 JS
📖 第 1 页 / 共 3 页
字号:
/*
Copyright Scand LLC http://www.scbr.com
To use this component please contact info@scbr.com to obtain license

*/ 
 

 


 function dhtmlXMenuBarObject(htmlObject,width,height,name,vMode,gfxPath,httpsdummy){
 if(typeof(htmlObject)!="object")
 this.parentObject=document.getElementById(htmlObject);
 else
 this.parentObject=htmlObject;
 if(!this.parentObject)this.parentObject=document.body;


 if((_isIE)&&(document.readyState!="complete")&&(this.parentObject==document.body))
 this._delayInit=true;

 var self=this;
 if(this._delayInit)window.attachEvent("onload",function(){
 self.parentObject.appendChild(self.hiddenForm);
 self.parentObject.appendChild(self._del_iframe);
 self.parentObject.appendChild(self._del_table);

});

 if(!vMode)this.flsmd=true;
 this.tname=name;
 this.topMenu=this;
 this.width=width;
 this.height=height;
 this.topNod=0;
 this._httpsdummy=httpsdummy;
 this.ieFix=(document.all?true:false);

 var detect = navigator.userAgent.toLowerCase();
 place = detect.indexOf('opera')+1;
 if(place)this.ieFix=false;

 this.ieWinMode=true;
 this.ieWinModeState=0;
 this.zIndex=999;
 this.maxItems=99;
 this.echsw=true;
 this.sysGfxPath=gfxPath;
 this.dividerCell=0;
 this.firstCell=0;
 this.nameCell=0;
 this.crossCell=0;
 this.echsw2=true;
 
 this.tableCSS="menuTable";
 this.titleCSS="menuName";
 this.secTableCSS="secondMenuTable";
 
 this.extraMode=convertStringToBoolean(vMode);
 
 this.defaultAction=0;
 this.onShow=0;
 this.onHide=0;
 
 var lastOpenedPanel=0;
 var lastSelectedItem=0;
 
 this.items=new Array();
 this.itemsCount=0;
 this.gitems=new Array();
 this.gitemsCount=0;
 
 this.subMenus=new Array();
 this.subMenusCount=0;
 

 if(!this.extraMode)
 this._createPanel();
 else
 this._createVPanel();

 
 this.hiddenForm=document.createElement("FORM");
 this.hiddenForm.style.display="none";
 if(!this._delayInit)
 this.parentObject.appendChild(this.hiddenForm);

 if(this._extendedInit)this._extendedInit();
 this.xmlUnit=new dtmlXMLLoaderObject(this._parseXMLTree,this);
 this.setMenuMode("classic");


 this.showBar();
 return this;
}
 
 dhtmlXMenuBarObject.prototype = new dhtmlXProtobarObject;



 
 function dhtmlXMenuBarPanelObject(parentPanel,parentItem,mode,minWidth,withoutImages){
 this.extraMode=!convertStringToBoolean(mode);
 this.parentPanel=parentPanel;
 this.parentItem=parentItem;
 this.parentObject=parentPanel.parentObject;
 this.topMenu=parentPanel.topMenu;
 this.topNod=0;
 this.dividerCell=0;
 this.firstCell=0;
 this.nameCell=0;
 this.crossCell=0;
 this.maxItems=99;
 this.items=new Array();
 this.itemsCount=0;
 this.withoutImages=(withoutImages==1);
 this.mixedImages=(withoutImages==2);
 if(minWidth)this.width=minWidth;

 if((!this.topMenu.flsmd)||(this.topMenu!=this.parentPanel))
 this.parentItem.setHasChild(true);
 
 if(mode)
 this._createVPanel=this.topMenu._createPanel;
 else
 this._createVPanel=this.topMenu._createVPanel;

 

 this._createVPanel();
 
 this.topNod.panel=this;
 this.topNod.onmouseover=this.topMenu._onmouseoverZ;
 this.topNod.onmouseout=this.topMenu._onmouseoutZ;
 
 parentItem.subMenu=this;
 this.topNod.style.position="absolute";
 this.topMenu.subMenus[this.topMenu.subMenusCount]=this;
 this.topMenu.subMenusCount++;
 return this;
}
 
 
 
 dhtmlXMenuBarObject.prototype.enableIESelectBoxFix=function(mode){
 this.ieFix=convertStringToBoolean(mode);
};
 
 dhtmlXMenuBarObject.prototype.enableTooltip=function(mode){
 this._endtt=(!convertStringToBoolean(mode));
};


 
 dhtmlXMenuBarObject.prototype.disableSmartPositioning=function(mode){
 this._skipAPP=convertStringToBoolean(mode);
};


 
 dhtmlXMenuBarObject.prototype.enableMenuHandle=function(mode){
 if(convertStringToBoolean(mode))this.dividerCell.style.display="";
 else this.dividerCell.style.display="none";
};
 
 dhtmlXMenuBarObject.prototype.enableChildIcon=function(mode){
 this.echsw=convertStringToBoolean(mode);
};
 
 dhtmlXMenuBarObject.prototype.enableChildIconSwitching=function(mode){
 this.echsw2=convertStringToBoolean(mode);
};
 
 dhtmlXMenuBarObject.prototype.enableWindowOpenMode=function(mode){
 this.ieWinMode=convertStringToBoolean(mode);
};
 
 
 dhtmlXProtobarObject.prototype._getItemIndex=function(id){
 for(var i=0;i<this.gitemsCount;i++)
{
 if(this.gitems[i].id==id)return i;
};
 return -1;
};
 
 dhtmlXProtobarObject.prototype.getItem=function(itemId){
 var z=this._getItemIndex(itemId);
 if(z>=0)return this.gitems[z];
};
 

 
 
 dhtmlXMenuBarObject.prototype._showScroll=function(node,order,rest,mode){
 if(!node.items[order])return;
 
 if(mode=="")
 if(rest==1)node.cAr[2]++;
 else node.cAr[0]--;
 else 
 if(rest==1)node.cAr[0]++;
 else node.cAr[2]--;

 if((!node.items[order].CSSTag)||(node.items[order].hide))
{
 node.items[order].topNod.parentNode.style.display=mode;
 this._showScroll(node,order*1+rest*1,rest,mode);
}
 else
{
 node.items[order].topNod.parentNode.style.display=mode;
}

}
 
 
 dhtmlXMenuBarObject.prototype._fixScrollState=function(node,rest){
 
 if(parseInt(node.topNod.offsetWidth)>parseInt(node.topNod.width))
 node.topNod.width=node.topNod.offsetWidth;
 
 var flag=0;

 if(rest>0){
 this._showScroll(node,node.cAr[0],1,"none");
 this._showScroll(node,node.cAr[2],1,"");
}
 else{
 this._showScroll(node,node.cAr[0]-1,-1,"");
 this._showScroll(node,node.cAr[2]-1,-1,"none");
}
 z.scrollState+=rest*1;
 
 
 if((node.scrollState*1+node.maxItems*1)==(node.realItemsCount))
 node.scrollDown.className="menuscrollerdisabled";
 else
{
 node.scrollDown.className="menuscrollerenabled";
 flag++;
}
 
 if(node.scrollState==0)
 node.scrollUp.className="menuscrollerdisabled";
 else
{
 node.scrollUp.className="menuscrollerenabled";
 flag++;
}
 
 
 return flag;
}



 
 dhtmlXMenuBarObject.prototype._scrollstart=function(){
 if(this.timeoutops)clearTimeout(this.timeoutops);
 z=this.parentNode.parentNode.parentNode.menu;
 if(z.scrollDown==this)
 var rest=1;
 else
 var rest=-1;
 
 if(z.topMenu._fixScrollState(z,rest)==2)
 this.timeoutops=setTimeout(new z.topMenu._delayedTimerCall(this,"onmouseover",0,0),333);
}
 
 dhtmlXMenuBarObject.prototype._scrollend=function(node){
 if(this.timeoutops)window.clearTimeout(this.timeoutops);
}
 
 dhtmlXMenuBarObject.prototype._scrollCheck=function(node){
 var z_count=0;
 for(var i=0;i<node.itemsCount;i++)
 if((node.items[i].CSSTag)&&(!node.items[i].hide))z_count++;

 node.realItemsCount=z_count;
 node.cAr=new Array(0,0,0);
 if((node.realItemsCount>node.maxItems)&&(node.scrollDown)){
 node.scrollDown.style.display="";
 node.scrollUp.style.display="";
 node.scrollDown.className='menuscrollerenabled';
 node.scrollState=0;
 node.scrollUp.onmouseover=this._scrollstart;
 node.scrollUp.onmouseout=this._scrollend;
 node.scrollDown.onmouseover=this._scrollstart;
 node.scrollDown.onmouseout=this._scrollend;
 node.cAr[2]=0;

 var z_count=0;
 var b_flag=true;
 for(var i=0;i<node.itemsCount;i++)
{
 if((node.items[i].CSSTag)&&(!node.items[i].hide))z_count++;
 if(z_count>node.maxItems){
 node.items[i].topNod.parentNode.style.display="none";
 if(node.cAr[2]==0)node.cAr[2]=i;}
 else{
 node.items[i].topNod.parentNode.style.display="";
}

}
}
}

 dhtmlXMenuBarObject.prototype._scrollClear=function(node){
 for(var i=0;i<node.itemsCount;i++){
 if((node.items[i].CSSTag)&&(!node.items[i].hide))
 node.items[i].topNod.parentNode.style.display="";
 if(node.scrollDown)
 node.scrollDown.style.display="none";
 if(node.scrollUp)
 node.scrollUp.style.display="none";
}
}

 
 dhtmlXMenuBarObject.prototype.getPanel=function(panelId){
 var z=this._getGItemIndex(panelId);
 if(z<0)return this;
 else return this.gitems[z].subMenu;
}
 
 
 dhtmlXMenuBarObject.prototype.addItem=function(panel,item){
 if(this==panel)this.addFirstLevel(panel,item);
 else this.addSecondLevel(panel,item);
}
 
 
 dhtmlXMenuBarObject.prototype._addItem=function(panel,item){
 panel.items[panel.itemsCount]=item;
 panel.firstCell.parentNode.insertBefore(item.getTopNode(),panel.firstCell);
 item.getTopNode().style.marginBottom="20px";
 item.parentNod=this;
 item.parentPanel=panel;
 if(this.defaultAction)item.setAction(this.defaultAction);
 panel.itemsCount++;

 this.gitems[this.gitemsCount]=item;
 this.gitemsCount++;
}

 
 dhtmlXMenuBarObject.prototype.addItem_vertical=function(panel,item){
 panel.items[panel.itemsCount]=item;
 var tr=document.createElement("tr");
 tr.style.verticalAlign="top";
 tr.appendChild(item.getTopNode());
 panel.firstCell.parentNode.insertBefore(tr,panel.firstCell);
 item.parentNod=this;
 item.parentPanel=panel;
 if(this.defaultAction)item.setAction(this.defaultAction);
 panel.itemsCount++;

 this.gitems[this.gitemsCount]=item;
 this.gitemsCount++;
}

 
 dhtmlXProtobarObject.prototype._getGItemIndex=function(id){
 
 return(this._getItemIndex(id));
};
 
 
 dhtmlXMenuBarObject.prototype.removeItem=function(id){
 var z=this._getGItemIndex(id);
 if(z>=0){
 var panel=this.gitems[z].parentPanel;
 if(this.gitems[z].removeItem)this.gitems[z].removeItem();

 if(panel.firstCell.tagName=="TR")
 var zw=this.gitems[z].getTopNode().parentNode
 else
 var zw=this.gitems[z].getTopNode().parentNode
 zw.parentNode.removeChild(zw);


 panel.itemsCount--;
 for(var i=0;i<panel.itemsCount;i++)
 if(panel.items[i]==this.gitems[z]){
 panel.items[i]=panel.items[i+1];
 panel.items[i+1]=this.gitems[z];
}
 this.items[panel.itemsCount]=0;

 this.gitemsCount--;
 for(var i=z;i<this.gitemsCount;i++){
 this.gitems[i]=this.gitems[i+1];
}
 this.gitems[this.gitemsCount]=0;



}
}
 
 
 dhtmlXMenuBarObject.prototype._parseXMLTree=function(that,node,level,parentNode,aTempNode,mode){
 if(!node){
 node=that.xmlUnit.getXMLTopNode("menu");

 if(that._awaitXML){
 aTempNode=that._awaitXML;
 parentNode=aTempNode.parentPanel;

 level=1;
 that._awaitXML=null;
 mode=this.modeValue;
}
 else{
 level=0;
 parentNode=that;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -