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

📄 dhtmlxtoolbar.js

📁 treegred is very good grid for
💻 JS
📖 第 1 页 / 共 2 页
字号:
/*Copyright DHTMLX LTD. http://www.dhtmlx.com*/ 
 


 
 function dhtmlXToolbarObject(htmlObject,width,height,name,vMode){
 if(_isIE)try{document.execCommand("BackgroundImageCache",false,true);}catch(e){}
 this.width=width;this.height=height;
 if(typeof(htmlObject)!="object")
 this.parentObject=document.getElementById(htmlObject);
 else
 this.parentObject=htmlObject;

 this.xmlDoc=0;
 this.topNod=0;this.dividerCell=0;this.firstCell=0;this.nameCell=0;this.crossCell=0;
 this.items=new Array();this.itemsCount=0;
 this.defaultAction=0;
 this.extraMode=convertStringToBoolean(vMode);
 this.onShow=0;this.onHide=0;
 this.oldMouseMove=0;
 this.tname=name;

 this.tableCSS="toolbarTable";
 this.titleCSS="toolbarName";

 if(!this.extraMode)
 this._create_self();
 else
 this._create_self_vertical();

 if(this._extendedInit)this._extendedInit();
 this.xmlLoader=new dtmlXMLLoaderObject(this._parseXMLTree,this);
 return this;
 
};

 dhtmlXToolbarObject.prototype = new dhtmlXProtobarObject;


 
 

 dhtmlXToolbarObject.prototype.addItem=function(item,pos){
 if((!pos)||(pos>this.itemsCount))
 pos=this.itemsCount;

 if(this.extraMode){
 var tr=document.createElement("tr");
 tr.style.verticalAlign="top";
 tr.appendChild(item.getTopNode());
 this.firstCell.parentNode.parentNode.insertBefore(tr,(pos==this.itemsCount)?this.firstCell.parentNode:this.items[pos].getTopNode().parentNode);
 item.getTopNode().style.width='100%';
}
 else{
 this.firstCell.parentNode.insertBefore(item.getTopNode(),(pos==this.itemsCount)?this.firstCell:this.items[pos].getTopNode());
 item.getTopNode().style.height='100%';
}

 item.parentNod=this;
 if(this.defaultAction)item.setAction(this.defaultAction);

 for(var i=pos;i<this.itemsCount+1;i++){
 var a=this.items[i];
 this.items[i]=item;
 item=a;
}

 this.itemsCount++;
}

 
 dhtmlXToolbarObject.prototype._getItemIndexByPosition=function(position){
 var j=0;
 for(var i=0;i<this.itemsCount;i++)
{
 if(this.items[i].hide!=1)j++;
 if(j==position)return i;
};
 return -1;
};


 
 
 dhtmlXToolbarObject.prototype.getItemByPosition=function(position){
 var z=this._getItemIndexByPosition(position);
 if(z>=0)return this.items[z];
};
 
 dhtmlXToolbarObject.prototype.removeItemById=function(itemId){
 var z=this._getItemIndex(itemId);
 if(z>=0){
 if(this.items[z].removeItem)this.items[z].removeItem();
 this.firstCell.parentNode.removeChild(this.items[z].getTopNode());
 this.items[z]=0;
 this.itemsCount--;
 for(var i=z;i<this.itemsCount;i++){
 this.items[i]=this.items[i+1];
}
}
}
 
 dhtmlXToolbarObject.prototype.removeItemByPosition=function(position){
 var z=this._getItemIndexByPosition(position);
 if(z){
 if(this.items[z].removeItem)this.items[z].removeItem();
 this.firstCell.parentNode.removeChild(this.items[z].getTopNode());
 this.items[z]=0;
 this.itemsCount--;
 for(var i=z;i<this.itemsCount;i++){
 this.items[i]=this.items[i+1];
}
}
 
}

 
 dhtmlXToolbarObject.prototype.hideItemByPosition=function(position){
 var z=this.getItemByPosition(position);
 if(z){z.getTopNode().style.display="none";z.hide=1;}
}

 
 dhtmlXToolbarObject.prototype._attributes=function(n){
 var nAtr=new Object();
 var atr=n.attributes;
 for(var a=0;a<atr.length;a++)
 nAtr[atr[a].name]=atr[a].value;
 if(n.childNodes)
 for(var a=0;a<n.childNodes.length;a++){
 if(n.childNodes[a].nodeType==1){
 var tag=n.childNodes[a];
 if(!nAtr[tag.tagName])nAtr[tag.tagName]=new Array();
 var tog=nAtr[tag.tagName];
 tog[tog.length]=this._attributes(tag);
}
 if(n.childNodes[a].nodeType==3){
 nAtr.content=n.childNodes[a].data;
}
}
 return nAtr;
}

 

 dhtmlXToolbarObject.prototype._parseXMLTree=function(that,node){
 if(!node)node=that.xmlLoader.getXMLTopNode("toolbar");

 var nAtr=that._attributes(node);
 if(!nAtr.globalTextCss)nAtr.globalTextCss=that.globalTextCss;
 if(!nAtr.globalCss)nAtr.globalCss=that.globalCss;

 if(nAtr.toolbarAlign)that.setBarAlign(nAtr.toolbarAlign);
 if(nAtr.absolutePosition=="yes"){
 that.topNod.style.position="absolute";
 that.topNod.style.top=nAtr.left||0;
 that.topNod.style.left=nAtr.top||0;
};
 if((nAtr.absolutePosition!="auto")&&(nAtr.absolutePosition!="yes"))that.dividerCell.style.display="none";
 if(nAtr.name)that.setTitleText(nAtr.name);
 if(nAtr.width)that.setBarSize(nAtr.width,nAtr.height);

 for(var i=0;i<node.childNodes.length;i++)
{
 var localItem=node.childNodes[i];
 if(localItem.nodeType==1)
{
 var lAtr=that._attributes(localItem);
 if((!lAtr.className)&&(nAtr.globalCss))
 lAtr.className=nAtr.globalCss;
 if((!lAtr.textClassName)&&(nAtr.globalTextCss))
 lAtr.textClassName=nAtr.globalTextCss;
 if(localItem.tagName=="divider")
 if(that.extraMode)
 lAtr.button="DividerY";
 else
 lAtr.button="DividerX";
 else
 lAtr.button=localItem.tagName;
 if((lAtr.src)&&(that.sysGfxPath))
 lAtr.src=that.sysGfxPath+lAtr.src;

 var TempNode=dhxButtonFactory(lAtr);

 if(TempNode)that.addItem(TempNode);

 if(localItem.getAttribute("disabled"))
 TempNode.disable();

}
}
 if(that.dhx_xml_end)that.dhx_xml_end(that);
};

 
 dhtmlXToolbarObject.prototype.setOnLoadingEnd=function(func){
 if(typeof(func)=="function")
 this.dhx_xml_end=func;
 else
 this.dhx_xml_end=eval(func);
};

 
 dhtmlXToolbarObject.prototype.setToolbarCSS=function(table,title,button,text){
 this.tableCSS=table;
 this.titleCSS=title;
 this.globalCss=button;
 this.globalTextCss=title;
 this.topNod.className=this.tableCSS;
 this.preNameCell.className=this.titleCSS;
 this.nameCell.className=this.titleCSS;
 
}
 
 
 dhtmlXToolbarObject.prototype._create_self=function()
{
 if(!this.width)this.width=1;
 if(!this.height)this.height=1;

 var div=document.createElement("div");
 div.innerHTML='<table cellpadding="0" cellspacing="1" class="'+this.tableCSS+'" style="display:none" width="'+this.width+'" height="'+this.height+'"><tbody>'+
 '<tr>'+
 '<td width="'+(_isFF?5:3)+'px"><div class="toolbarHandle" '+(_isIE?"style='width:3px'":"")+'>&nbsp;</div></td>'+
 '<td class="'+this.titleCSS+'" style="display:none">'+this.name+'</td>'+
 '<td></td>'+
 '<td align="right" width="100%" class="'+this.titleCSS+'" style="display:none">'+this.name+'</td>'+
 '<td></td>'+
 '</tr></tbody></table>';
 var table=div.childNodes[0];
 table.setAttribute("UNSELECTABLE","on");
 table.onselectstart=this.badDummy;
 this.topNod=table;
 this.dividerCell=table.childNodes[0].childNodes[0].childNodes[0];
 this.dividerCell.toolbar=this;
 this.preNameCell=this.dividerCell.nextSibling;
 this.firstCell=this.preNameCell.nextSibling;
 this.nameCell=this.firstCell.nextSibling;
 this.crossCell=this.nameCell.nextSibling;
 
 this.parentObject.appendChild(table);
};
 
 
 dhtmlXToolbarObject.prototype._create_self_vertical=function()
{
 if(!this.width)this.width=1;
 if(!this.height)this.height=1;
 
 var div=document.createElement("div");
 div.innerHTML='<table cellpadding="0" cellspacing="1" class="'+this.tableCSS+'" style="display:none" width="'+this.width+'" height="'+this.height+'"><tbody>'+
 '<tr><td heigth="'+(_isFF?5:3)+'px"><div class="vtoolbarHandle" style="width:100%;'+(_isIE?"height:3px":"")+' overflow:hidden"></div></td></tr>'+
 '<tr><td height="100%" class="'+this.titleCSS+'" style="display:none">'+this.name+'</td></tr>'+
 '<tr><td></td></tr>'+
 '<tr><td align="right" height="100%" class="'+this.titleCSS+'" style="display:none">'+this.name+'</td></tr>'+
 '<tr><td></td></tr>'+
 '</tbody></table>';

 var table=div.childNodes[0];
 table.onselectstart=this.badDummy;
 table.setAttribute("UNSELECTABLE","on");
 
 this.topNod=table;
 this.dividerCell=table.childNodes[0].childNodes[0].childNodes[0];
 this.dividerCell.toolbar=this;
 this.preNameCell=table.childNodes[0].childNodes[1].childNodes[0];
 this.firstCell=table.childNodes[0].childNodes[2].childNodes[0];
 this.nameCell=table.childNodes[0].childNodes[3].childNodes[0];
 this.crossCell=table.childNodes[0].childNodes[4].childNodes[0];

 this.parentObject.appendChild(table);
};

 
 
function dhxButtonFactory(tag,zone){
 var name="dhtmlX"+tag.button+"Object";
 if(arguments.length==2)tag._td="DIV";

 if(window[name])
 var z=new window[name](tag);

 if(arguments.length==2)
 if(zone)zone.appendChild(z.topNod);
 else{
 document.write("<div id='button_factory_temp'></div>");
 var x=document.getElementById('button_factory_temp');
 x.appendChild(z.topNod);
 x.id='';
}

 return z;
}

 
 function dhtmlXImageButtonObject(src,width,height,action,id,tooltip,className,disableImage){
 if(typeof(src)!="object")
 src=this._arg2obj(arguments,["src","width","height","action","id","tooltip","className","disableImage"]);

 if(src.action)this.setSecondAction(src.action);
 this.id=src.id||0;
 this.className=src.className||"defaultButton";
 this.src=src.src;this.disableImage=src.disableImage;
 this.tooltip=src.tooltip||"";

 td=document.createElement(src._td||"TD");this.topNod=td;
 td.style.height=src.height;
 td.style.width=src.width;td.align="center";td.vAlign="middle";
 td.innerHTML="<img src='"+this.src+"' border='0' title='"+this.tooltip+"' style='padding-left:2px;padding-right:2px;'>";
 td.className=this.className;
 td.objectNode=this;
 if(src.mouseover)
{this._mvImage=src.mouseover;this._mnImage=src.src;}

 this.imageTag=td.childNodes[0];
 this.enable();
};

 
 dhtmlXImageButtonObject.prototype = new dhtmlXButtonPrototypeObject;


 
 
 
 function dhtmlXDividerYObject(id){

⌨️ 快捷键说明

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