+ Config BTN
This commit is contained in:
@ -1,14 +1,87 @@
|
||||
/** HTML закладки
|
||||
*/
|
||||
class tcTabs
|
||||
{
|
||||
//element_id - Контейнер где будут созданны закладки
|
||||
constructor(element_id){
|
||||
this.tbs=new Array();
|
||||
if(typeof element_id == 'string') this.bd=document.getElementById(element_id); else this.bd=element_id;
|
||||
|
||||
this.wra=document.createElement('div');
|
||||
this.wra.style.cssText="display: table; width :100%; height: 100%; padding: 0px; margin: 0px; border-collapse: collapse; border: 0px solid #000000;";
|
||||
|
||||
var tr=null;
|
||||
tr=document.createElement('div');
|
||||
tr.style.cssText='display: table-row; height: 1%; padding: 0px; margin: 0px; border: 0px solid #0000ff;'
|
||||
|
||||
this.btt=document.createElement('div');
|
||||
this.btt.style.cssText='display: table-cell; width :100%; height: 1%; padding: 0px; margin: 0px; border: 0px solid #0000ff;background-color: '+g_backColor2+';color:'+g_textColor1+';';
|
||||
tr.appendChild(this.btt);
|
||||
this.wra.appendChild(tr);
|
||||
|
||||
tr=document.createElement('div');
|
||||
tr.style.cssText='display: table-row; width :100%; height: 100%; padding: 0px; margin: 0px; border: 0px solid #0000ff;'
|
||||
|
||||
//Content
|
||||
this.ctt=document.createElement('div');
|
||||
this.ctt.style.cssText='display:table-cell; width :100%; height: 100%; padding: 0px; margin: 0px; border; border: 1px solid #b3b3b3; overflow:hidden;'
|
||||
|
||||
tr.appendChild(this.ctt);
|
||||
this.wra.appendChild(tr);
|
||||
|
||||
this.bd.appendChild(this.wra);
|
||||
}
|
||||
//Добавление новой закладки
|
||||
addTab(config)
|
||||
{
|
||||
let tab=new tcTab(config)
|
||||
tab.par=this
|
||||
this.btt.appendChild(tab.div);
|
||||
|
||||
this.tbs[this.tbs.length]=tab;
|
||||
return tab;
|
||||
}
|
||||
//Удаление закладки
|
||||
delTab(tab)
|
||||
{
|
||||
if (typeof tab === 'string' || tab instanceof String)
|
||||
{
|
||||
}else
|
||||
{
|
||||
for(let i=0;i<this.tbs.length;i++)
|
||||
{
|
||||
if(this.tbs[i]==tab)
|
||||
{
|
||||
this.btt.removeChild(tab.div);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Поиск закладки по имени
|
||||
getTabByName(name)
|
||||
{
|
||||
for(let i=0;i<this.tbs.length;i++)
|
||||
{
|
||||
if(this.tbs[i].name==name)
|
||||
{
|
||||
return this.tbs[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class tcTab
|
||||
{
|
||||
constructor(config){
|
||||
|
||||
|
||||
this.bColor="";
|
||||
|
||||
|
||||
if(typeof config == 'undefined' || config == null) config = {};
|
||||
if(typeof config.float == 'undefined'){ config.float='left'; }
|
||||
|
||||
if(typeof config.name == 'undefined'){ config.name=''; }
|
||||
|
||||
this.id=0;
|
||||
this.name=config.name;
|
||||
this.par=null;
|
||||
this.sel=false;
|
||||
this.con=null; //Элемент с содержимым
|
||||
@ -61,65 +134,4 @@ class tcTab
|
||||
this.con.style.display='block';
|
||||
this.sel=true
|
||||
}
|
||||
}
|
||||
|
||||
/** Создать закладки
|
||||
* id - контейнер либо идентификатор контейнера в который вставляем табы
|
||||
*/
|
||||
class tcTabs
|
||||
{
|
||||
constructor(id){
|
||||
this.tbs=new Array();
|
||||
if(typeof id == 'string') this.bd=document.getElementById(id); else this.bd=id;
|
||||
|
||||
this.wra=document.createElement('div');
|
||||
this.wra.style.cssText="display: table; width :100%; height: 100%; padding: 0px; margin: 0px; border-collapse: collapse; border: 0px solid #000000;";
|
||||
|
||||
var tr=null;
|
||||
tr=document.createElement('div');
|
||||
tr.style.cssText='display: table-row; height: 1%; padding: 0px; margin: 0px; border: 0px solid #0000ff;'
|
||||
|
||||
this.btt=document.createElement('div');
|
||||
this.btt.style.cssText='display: table-cell; width :100%; height: 1%; padding: 0px; margin: 0px; border: 0px solid #0000ff;background-color: '+g_backColor2+';color:'+g_textColor1+';';
|
||||
tr.appendChild(this.btt);
|
||||
this.wra.appendChild(tr);
|
||||
|
||||
tr=document.createElement('div');
|
||||
tr.style.cssText='display: table-row; width :100%; height: 100%; padding: 0px; margin: 0px; border: 0px solid #0000ff;'
|
||||
|
||||
//Content
|
||||
this.ctt=document.createElement('div');
|
||||
this.ctt.style.cssText='display:table-cell; width :100%; height: 100%; padding: 0px; margin: 0px; border; border: 1px solid #b3b3b3; overflow:hidden;'
|
||||
|
||||
tr.appendChild(this.ctt);
|
||||
this.wra.appendChild(tr);
|
||||
|
||||
this.bd.appendChild(this.wra);
|
||||
}
|
||||
|
||||
addTab(config)
|
||||
{
|
||||
let tab=new tcTab(config)
|
||||
tab.par=this
|
||||
this.btt.appendChild(tab.div);
|
||||
|
||||
this.tbs[this.tbs.length]=tab;
|
||||
return tab;
|
||||
}
|
||||
|
||||
delTab(tab)
|
||||
{
|
||||
if (typeof tab === 'string' || tab instanceof String)
|
||||
{
|
||||
}else
|
||||
{
|
||||
for(let i=0;i<this.tbs.length;i++)
|
||||
{
|
||||
if(this.tbs[i]==tab)
|
||||
{
|
||||
this.btt.removeChild(tab.div);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user