📄 dhtmlxtabbar.js
字号:
this.dhx_tab_close=eval(func);};dhtmlXTabBar.prototype.forceLoad=function(tabId,href){var tab=this.tabsId[tabId];if (href)this._hrefs[tabId]=href;this._content[tab.idd]._loaded=false;this._setContent(tab,this._lastActive.idd!=tabId);};dhtmlXTabBar.prototype.setHrefMode=function(mode){this._hrfmode=mode;};dhtmlXTabBar.prototype.setContentHref=function(id,href){if (!this._hrefs)this._hrefs=new Array();this._hrefs[id]=href;switch(this._hrfmode){case "iframe":
if (!this._glframe){var z=document.createElement("DIV");z.className="dhx_tabcontent_sub_zone";z.innerHTML="<iframe frameborder='0' width='100%' height='100%' src='"+this._imgPath+"blank.html'></iframe>";this._glframe=z.childNodes[0];this._conZone.appendChild(this._glframe);};return;break;case "iframes":
case "iframes-on-demand":
var z=document.createElement("DIV");z.className="dhx_tabcontent_sub_zone";z.style.display='none';z.innerHTML="<iframe frameborder='0' width='100%' height='100%' src='"+((this._hrfmode=="iframes")?href:(this._imgPath+"blank.html"))+"'></iframe>";this.setContent(id,z);break;case "ajax":
case "ajax-html":
var z=document.createElement("DIV");z.className="dhx_tabcontent_sub_zone";this.setContent(id,z);break;};this._content[id]._loaded=false;};dhtmlXTabBar.prototype.tabWindow=function(tab_id){if (this._hrfmode.indexOf("iframe")==0)
return (this._content[tab_id]?this._content[tab_id].childNodes[0].contentWindow:null);};dhtmlXTabBar.prototype._ajaxOnLoad=function(obj,a,b,c,loader){if (obj[0]._hrfmode=="ajax"){var z=loader.getXMLTopNode("content");var val=obj[0]._getXMLContent(z);}else var val=loader.xmlDoc.responseText;obj[0]._resolveContent(obj[1],val);obj[0].adjustSize();if (obj[0].dhx_tab_loaded)obj[0].dhx_tab_loaded(obj[1]);};dhtmlXTabBar.prototype._resolveContent=function(id,val){var z=val.match(/<script[^>]*>([^<]+)<\/script>/g);if (this._content[id]){this._content[id].innerHTML=val;if (z)for (var i=0;i<z.length;i++)eval(z[i].replace(/<([\/]{0,1})s[^>]*>/g,""));};};dhtmlXTabBar.prototype.setOnSelectHandler=function(func){if (typeof(func)=="function")
this._onsel=func;else
this._onsel=eval(func);};dhtmlXTabBar.prototype.setContent=function(id,nodeId){if (typeof(nodeId)=="string")
nodeId=document.getElementById(nodeId);if (this._content[id])this._content[id].parentNode.removeChild(this._content[id]);this._content[id]=nodeId;this._content[id]._loaded=true;if (nodeId.parentNode)nodeId.parentNode.removeChild(nodeId);nodeId.style.position="absolute";if (this._dspN){nodeId.style.display="none";nodeId.style.visibility="visible";}else{nodeId.style.visibility="hidden";nodeId.style.display="block";};nodeId.style.top="0px";nodeId.style.top="0px";this._conZone.appendChild(nodeId);if ((this._lastActive)&&(this._lastActive.idd==id)) this._setContent(this._lastActive);};dhtmlXTabBar.prototype._setContent=function(tab,stelth){if (this._hrfmode)switch(this._hrfmode){case "iframe":
this._glframe.src=this._hrefs[tab.idd];return;break;case "iframes":
case "iframes-on-demand":
if ((this._hrfmode=="iframes-on-demand")&&(!this._content[tab.idd]._loaded))
{this._content[tab.idd].childNodes[0].src=this._hrefs[tab.idd];this._content[tab.idd]._loaded="true";};break;case "ajax":
case "ajax-html":
var z=this._content[tab.idd];if (!z._loaded){z.innerHTML="<div class='dhx_ajax_loader'><img src='"+this._imgPath+"loading.gif' /> Loading...</div>";(new dtmlXMLLoaderObject(this._ajaxOnLoad,[this,tab.idd],true,this.no_cashe)).loadXML(this._hrefs[tab.idd]);z._loaded=true;};break;};if (!stelth){if ((this._lastActive)&&(this._content[this._lastActive.idd]))
if (this._dspN)this._content[this._lastActive.idd].style.display='none';else
this._content[this._lastActive.idd].style.visibility='hidden';if (this._content[tab.idd])if (this._dspN)this._content[tab.idd].style.display='block';else
this._content[tab.idd].style.visibility='';};this.adjustSize();};dhtmlXTabBar.prototype.setContentHTML=function(id,html){var z=document.createElement("DIV");z.className="dhx_tabcontent_sub_zone";z.innerHTML=html;this.setContent(id,z);};dhtmlXTabBar.prototype.setStyle=function(name){if (this._styles[name]){this._cstyle=name;if(this._styles[this._cstyle][12])this._conZone.style.backgroundColor=this._styles[this._cstyle][12];};};dhtmlXTabBar.prototype.enableContentZone=function(mode){this._eczF=convertStringToBoolean(mode);this._conZone.style.display=this._eczF?"":'none';};dhtmlXTabBar.prototype.enableForceHiding=function(mode){this._dspN=convertStringToBoolean(mode);};dhtmlXTabBar.prototype.setSkinColors=function(a_tab,p_tab,c_zone){this._styles[this._cstyle][10]=p_tab;this._styles[this._cstyle][11]=a_tab;this._conZone.style.backgroundColor=c_zone||a_tab;};dhtmlXTabBar.prototype.getActiveTab=function(){if (this._lastActive)return this._lastActive.idd;return null;};dhtmlXTabBar.prototype.goToNextTab=function(tab){var z=tab||this._lastActive;if (z){if (z.nextSibling.idd){if (!this._setTabActive(z.nextSibling))
return this.goToNextTab(z.nextSibling);return z.nextSibling.idd;}else
if (z.parentNode.nextSibling){var arow=z.parentNode.nextSibling.childNodes[0];if (!this._setTabActive(arow))
return this.goToNextTab(arow);return arow.idd;};};return null;};dhtmlXTabBar.prototype.goToPrevTab=function(tab){var z=tab||this._lastActive;if (z){if (z.previousSibling){if (!this._setTabActive(z.previousSibling))
return this.goToPrevTab(z.previousSibling);return this._lastActive.idd;}else
if (z.parentNode.previousSibling){var arow=z.parentNode.previousSibling.childNodes;if ((!arow)||(!arow.tabCount)) return null;arow=arow[arow.tabCount-1];if (!this._setTabActive(arow))
return this.goToPrevTab(arow);return arow.idd;};};return null;};dhtmlXTabBar.prototype.enableAutoSize=function(autoWidth,autoHeight){this._ahdj=convertStringToBoolean(autoHeight);this._awdj=convertStringToBoolean(autoWidth);if (this._awdj && this._ahdj)this._conZone.style.overflow='hidden';else this._conZone.style.overflow='auto';};dhtmlXTabBar.prototype.enableAutoReSize=function(mode){this._EARS=convertStringToBoolean(mode)
if (this._EARS){this.entBox.style.overflow="hidden";if (arguments.length==1){if ((this.entBox.style.width||"").indexOf("%")==-1) this.entBox.style.width="100%";if ((this.entBox.style.height||"").indexOf("%")==-1) this.entBox.style.height="100%";};var self=this;if(this.entBox.addEventListener){if ((_isFF)&&(_FFrv<1.8))
window.addEventListener("resize",function (){window.setTimeout(function(){self.adjustOuterSize();},10);},false);else
window.addEventListener("resize",function (){if (self.adjustOuterSize)self.adjustOuterSize();},false);}else if (window.attachEvent)window.attachEvent("onresize",function(){if (self._resize_timer)window.clearTimeout(self._resize_timer);if (self.adjustOuterSize)self._resize_timer=window.setTimeout(function(){self.adjustOuterSize();},500);});if (this._lineA)this.adjustOuterSize();};};dhtmlXTabBar.prototype.setSize=function(width,height,contentZone){height=parseInt(height);width=parseInt(width);if (contentZone){if(!this._vMode)height+=20*this.rows.length;else
width+=20*this.rows.length;};this.height=height+"px";this.width=width+"px";this._lineA.style[this._vMode?"left":"top"]=(this._bMode?0:(this._height+2))+"px";this._lineA.style[this._vMode?"height":"width"]=this[this._vMode?"height":"width"];if(this._vMode){for (var i=0;i<this.rows.length;i++)this.rows[i].style.height=parseInt(this.height)+"px";this._conZone.style.height=height-(_isFF?2:0)+"px";}else
{this._conZone.style.width=parseInt(this.width)-(_isFF?2:0)+"px";for (var i=0;i<this.rows.length;i++)this.rows[i].style.width=parseInt(this.width)+"px";};for (var i=0;i<this.rows.length;i++)this._redrawRow(this.rows[i]);this._setSizes();};dhtmlXTabBar.prototype.adjustOuterSize=function(){if (!this._EARS)return;this.setSize(this.entBox.offsetWidth,this.entBox.offsetHeight,false);};dhtmlXTabBar.prototype.adjustSize=function(){if ((!this._ahdj)&&(!this._awdj)) return;var flag=false;var x=0;var y=0;for (var id in this._content){var box=this._content[id];if (!box)continue;if ((this._ahdj)&&(box.scrollHeight>y)){y=box.scrollHeight+2;flag=true;};if ((this._awdj)&&(box.scrollWidth>x)){x=box.scrollWidth+2;flag=true;};};if (flag)this.setSize(x||this._conZone.offsetWidth,y||this._conZone.offsetHeight,true);};dhtmlXTabBar.prototype.preventIECashing=function(mode){this.no_cashe = convertStringToBoolean(mode);if (this.XMLLoader)this.XMLLoader.rSeed=this.no_cashe;};dhtmlXTabBar.prototype.hideTab = function(tab,mode){var tab=this.tabsId[tab];if (!tab)return;this._goToAny(tab,mode);tab.style.display='none';var row=tab.parentNode;this._redrawRow(row);};dhtmlXTabBar.prototype.showTab = function(tab){var tab=this.tabsId[tab];if (!tab)return;tab.style.display='block';var row=tab.parentNode;this._redrawRow(row)
};dhtmlXTabBar.prototype.enableTab = function(tab){var tab=this.tabsId[tab];if (!tab)return;tab._disabled=false;tab.className=(tab.className||"").replace(/dhx_tab_element_disabled/g,"");};dhtmlXTabBar.prototype.disableTab = function(tab,mode){var tab=this.tabsId[tab];if (!tab)return;this._goToAny(tab,mode);tab._disabled=true;tab.className+=" dhx_tab_element_disabled";};dhtmlXTabBar.prototype.setLabel = function(tab,value){var tab=this.tabsId[tab];if (!tab)return;switch(this._tbst){case 'text':
tab.innerHTML=value;break;case 'win_text':
tab.childNodes[2].childNodes[0].innerHTML=value;break;};};dhtmlXTabBar.prototype.getLabel = function(tab){var tab=this.tabsId[tab];if (!tab)return;switch(this._tbst){case 'text':
return tab.innerHTML;break;case 'win_text':
return tab.childNodes[2].childNodes[0].innerHTML;break;};};dhtmlXTabBar.prototype.detachTab=function(id) {var WindowName = this.getLabel(id);var tab=this.tabsId[id];if (!tab)return;var node = this._content[tab.idd];tab = this._getTabById(id);var tab_w = parseInt(tab.style.width);this.removeTab(id, true);node.style.position = '';var width = parseInt(this._conZone.style.width)+5;var height = parseInt(this._conZone.style.height)+25;var min_width = 100;var min_height = 50;width = width<min_width?min_width:width;height = height<min_height?min_height:height;var top = Math.ceil(window.offsetHeight/20-height/20);var left = Math.ceil(window.offsetWidth/20-width/20);var win = new dhtmlxWindow(420,300,width,height,WindowName,false);win._tab_w = tab_w;win.attachContent(node);return win;};dhtmlXTabBar.prototype.enableTabCloseButton=function(bool) {this._TabCloseButton = convertStringToBoolean(bool);};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -