489 lines
21 KiB
JavaScript
489 lines
21 KiB
JavaScript
//Класс окна
|
||
|
||
class TWin
|
||
{
|
||
constructor(dialog,path)
|
||
{
|
||
this.dialog=dialog; //Показывать окно как диалог (без возможности изменения размеров)
|
||
if(typeof path !== 'undefined')
|
||
this.path=path;
|
||
else
|
||
this.path='../resources';
|
||
|
||
this.disableClosing=false;
|
||
|
||
this.closed=false; //Закрыли (те. удалили из родителя и детей и из DOM)
|
||
this.onClose=null; //слушатель закрытия окна
|
||
this.childs=new Array(); //Подчинёные окна
|
||
this.parent=null; //родительское окно
|
||
this.name="TWin";
|
||
this.tWinId=0;
|
||
this.dx=0;
|
||
this.dy=0;
|
||
this.sel=false;
|
||
this.obj=null; //user data
|
||
|
||
this.div=document.createElement('div'); //Окно
|
||
this.divsh=document.createElement('div'); //Тень для модального окна
|
||
this.tbl=null;
|
||
this.h0=null;
|
||
this.ca=null;
|
||
this.co=null;
|
||
this.shadow = false; //Показывать ли тень вокруг окошка
|
||
this.uid=getUID(); //Уникальныйидентификатор
|
||
|
||
this.pBarCnt=0; //Прогресс бар
|
||
this.pBarDiv=null; //Прогресс бар
|
||
|
||
this.fnResizeListener=null;
|
||
}
|
||
|
||
addResizeListener(func)
|
||
{
|
||
this.fnResizeListener=func;
|
||
this.fnResizeListener();
|
||
}
|
||
|
||
onResize(x,y)
|
||
{
|
||
let win=this;
|
||
return function(e){
|
||
if(!e) e = window.event;
|
||
win.dx=e.pageX || e.x
|
||
win.dy=e.pageY || e.y
|
||
|
||
document.onmousedown = function() {
|
||
|
||
if(win.fnResizeListener!=null) win.fnResizeListener();
|
||
|
||
return false;
|
||
};
|
||
document.onmousemove = function(e) {
|
||
if(!e) e = window.event;
|
||
let x2 = e.pageX || e.x;
|
||
let y2 = e.pageY || e.y;
|
||
let w=parseInt(win.div.style.width)-(win.dx-x2)*x;
|
||
let h=parseInt(win.div.style.height)-(win.dy-y2)*y;
|
||
if(w<0)w=0;
|
||
if(h<0)h=0;
|
||
win.setWidth(w+"px");
|
||
win.setHeight(h+"px");
|
||
if(x<0)win.div.style.left=parseInt(win.div.style.left)-(win.dx-x2)+"px";
|
||
if(y<0)win.div.style.top=parseInt(win.div.style.top)-(win.dy-y2)+"px";
|
||
win.dx=x2;
|
||
win.dy=y2;
|
||
|
||
if(win.fnResizeListener!=null) win.fnResizeListener();
|
||
|
||
return false;
|
||
};
|
||
document.onmouseup = function() {
|
||
document.onmousedown = null;
|
||
document.onmousemove = MMove//null;
|
||
|
||
if(win.fnResizeListener!=null) win.fnResizeListener();
|
||
|
||
return false;
|
||
};
|
||
return false;
|
||
};
|
||
}
|
||
|
||
Close() //Закрыть и удалить окно из родителя и менеджера
|
||
{
|
||
if(this.disableClosing)
|
||
return;
|
||
|
||
//Переместил перед удалением компонент так как бывает нужно поработать с ними перед удалением
|
||
if(this.onClose!=null)
|
||
{
|
||
this.onClose();
|
||
}
|
||
|
||
this.hide(true);
|
||
this.setParent(null);
|
||
for(let i=0;i<this.childs.length;i++) if(this.childs[i]!=null) this.childs[i].parent=null
|
||
|
||
//??? зачем коментил (пояснение не понятное)? раскоментил потому что после пересоздания формы HTML id сохранялись (Вот непонятный комент: Закоментил потому что в магазине могут закрыть окно а оно больше не появится...)
|
||
if(this.div.parentNode!=null) this.div.parentNode.removeChild(this.div);
|
||
if(this.divsh.parentNode!=null) this.divsh.parentNode.removeChild(this.divsh);
|
||
|
||
this.closed=true;
|
||
};
|
||
|
||
//Типа конструктор создать окно с заданой позицией
|
||
BuildGUI(x,y)
|
||
{
|
||
this.tWinId=g_wins.add(this);
|
||
/*
|
||
let hd='';
|
||
hd+='<table style="width: 100%;">';
|
||
hd+=' <tr>';
|
||
hd+=' <td style="vertical-align:bottom;cursor:move;" id="TWin_H1_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/t1.gif" style="width: 20px; height: 20px; display: block;" alt="" border="0px" draggable="false"/></td>';
|
||
hd+=' <td align="center" width="100%" bgcolor="#3366CC" style="font-weight: bold; cursor:move; background: #92b5df url('+this.path+'/metadata/dbms/form/1.gif) repeat-x top;" id="TWin_H2_'+this.tWinId+'"><nobr id="TWin_Ca_'+this.tWinId+'"></nobr></td>';
|
||
hd+=' <td style="vertical-align:bottom;cursor:move;" id="TWin_H3_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/t2.gif" alt="" style="width: 20px; height: 20px; display: block;" border="0px" draggable="false"/></td>';
|
||
//hd+=' <td width="100%"> </td>';
|
||
hd+=' <td style="vertical-align:bottom;cursor:pointer;"><img src="'+this.path+'/metadata/dbms/form/none.gif" alt="" style="width: 21px; height: 21px; display: block;" border="0px" draggable="false"/></td>';
|
||
hd+=' <td style="vertical-align:bottom;cursor:pointer;"><img src="'+this.path+'/metadata/dbms/form/none.gif" alt="" style="width: 21px; height: 21px; display: block;" border="0px" draggable="false"/></td>';
|
||
hd+=' <td style="vertical-align:bottom;cursor:pointer;"><img src="'+this.path+'/metadata/dbms/form/close.gif" alt="X" style="width: 21px; height: 21px; display: block;" border="0px" draggable="false" id="TWin_CL_'+this.tWinId+'"/></td>';
|
||
hd+=' <td style="vertical-align:bottom;"><img src="'+this.path+'/metadata/dbms/form/none.gif" alt="" style="width: 21px; height: 21px; display: block;" border="0px" draggable="false"/></td>';
|
||
hd+=' </tr>';
|
||
hd+='</table>';
|
||
|
||
let str='';
|
||
str+='<table id="TWin_TBL_'+this.tWinId+'" border="0px" style="width: 100%; height: 100%;">';
|
||
str+=' <tr id="TWin_H0_'+this.tWinId+'"><td colspan=3>'+hd+'</td></tr>';
|
||
str+=' <tr>';
|
||
str+=' <td style="width: 10px; height: 10px; cursor:nw-resize;"><img src="'+this.path+'/metadata/dbms/form/_t-l.gif" alt="" style="width: 10px; height: 10px; display: block;" border="0px" draggable="false" id="TWin_TL_'+this.tWinId+'"></td>';
|
||
str+=' <td style="vertical-align:top; height: 10px; cursor:n-resize;" background="'+this.path+'/metadata/dbms/form/t.gif" id="TWin_T_'+this.tWinId+'"></td>';
|
||
str+=' <td style="width: 10px; height: 10px; cursor:ne-resize;" id="TWin_TR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/t-r.gif" alt="" style="width: 10px; height: 10px; display: block;" border="0px" draggable="false"></td>';
|
||
str+=' </tr>';
|
||
str+=' <tr style="height: 100%">';
|
||
str+=' <td style="vertical-align:top;height: 10px; cursor:w-resize;" background="'+this.path+'/metadata/dbms/form/l.gif" id="TWin_L_'+this.tWinId+'"></td>';
|
||
str+=' <td style="vertical-align:top;cursor:default;"><table style="width: 100%; height: 100%;"><tr><td id="TWin_Co_'+this.tWinId+'" style="vertical-align:top;"> </td></tr></table></td>';
|
||
str+=' <td style="vertical-align: top; height: 10px; cursor:e-resize;" background="'+this.path+'/metadata/dbms/form/r.gif" id="TWin_R_'+this.tWinId+'"></td>';
|
||
str+=' </tr>';
|
||
str+=' <tr>';
|
||
str+=' <td style="width: 10px; height: 10px; cursor:sw-resize;" id="TWin_BL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/b-l.gif" alt="" style="width: 10px; height: 10px; display: block;" border="0px" draggable="false"></td>';
|
||
str+=' <td style="vertical-align: top; height: 10px; cursor:s-resize;" background="'+this.path+'/metadata/dbms/form/b.gif" id="TWin_B_'+this.tWinId+'"></td>';
|
||
str+=' <td style="width: 10px; height: 10px; cursor:se-resize;" id="TWin_BR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/b-r.gif" alt="" style="width: 10px; height: 10px; display: block;" border="0px" draggable="false"></td>';
|
||
str+=' </tr>';
|
||
str+='</table>';
|
||
*/
|
||
/*
|
||
let str='';
|
||
str+='<table id="TWin_TBL_'+this.tWinId+'" class="TWin">';
|
||
str+=' <tr id="TWin_H0_'+this.tWinId+'" style="border-bottom: 1px solid #b3b3b3;"><td></td><td><table style="width: 100%; height: 29px;"><tr><td id="TWin_Ca_'+this.tWinId+'" style="vertical-align: middle; cursor: move; font-weight: bold; white-space: nowrap;"></td><td style="width: 10px; vertical-align: middle;"><img src="'+this.path+'/metadata/dbms/form/x.gif" id="TWin_CL_'+this.tWinId+'" style="cursor:pointer;"></td></tr></table></td><td></td></tr>';
|
||
str+=' <tr>';
|
||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:nw-resize;' : '')+'" id="TWin_TL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||
str+=' <td style="vertical-align: top; height: 5px;'+(!this.dialog ? ' cursor: n-resize;' : '')+'" id="TWin_T_'+this.tWinId+'"></td>';
|
||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:ne-resize;' : '')+'" id="TWin_TR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||
str+=' </tr>';
|
||
str+=' <tr style="height: 100%">';
|
||
str+=' <td style="height: 5px;'+(!this.dialog ? ' cursor:w-resize;' : '')+'" id="TWin_L_'+this.tWinId+'"></td>';
|
||
str+=' <td style="vertical-align:top; cursor: default;"><table style="width: 100%; height: 100%;"><tr><td id="TWin_Co_'+this.tWinId+'" style="vertical-align:top;"></td></tr></table></td>';
|
||
str+=' <td style="height: 5px;'+(!this.dialog ? ' cursor:e-resize;' : '')+'" id="TWin_R_'+this.tWinId+'"></td>';
|
||
str+=' </tr>';
|
||
str+=' <tr>';
|
||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:sw-resize;' : '')+'" id="TWin_BL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||
str+=' <td style="vertical-align:top;height: 5px;'+(!this.dialog ? ' cursor: s-resize;' : '')+'" id="TWin_B_'+this.tWinId+'"></td>';
|
||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:se-resize;' : '')+'" id="TWin_BR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||
str+=' </tr>';
|
||
str+='</table>';
|
||
*/
|
||
|
||
let str='';
|
||
str+='<table id="TWin_TBL_'+this.tWinId+'" class="DBMSShadow" style="width: 100%; height: 100%; border: 1px solid #000000;">';
|
||
str+=' <tr id="TWin_H0_'+this.tWinId+'" style="background: var(--path-grad) repeat-x;"><td></td><td><table style="width: 100%; height: 29px;"><tr><td id="TWin_Ca_'+this.tWinId+'" style="vertical-align: middle; cursor: move; font-weight: bold; white-space: nowrap;"></td><td style="width: 10px; vertical-align: middle;">'+(this.disableClosing ? '' : '<div id="TWin_CL_'+this.tWinId+'" style="display: inline-block; width: 10px; height: 10px; background-image: var(--path-X); background-repeat: no-repeat; cursor:pointer;padding-right: 5px;"></div>')+'</td></tr></table></td><td></td></tr>';
|
||
str+=' <tr>';
|
||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:nw-resize;' : '')+'" id="TWin_TL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||
str+=' <td style="vertical-align:top;height: 5px;'+(!this.dialog ? ' cursor:n-resize;' : '')+'" id="TWin_T_'+this.tWinId+'"></td>';
|
||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:ne-resize;' : '')+'" id="TWin_TR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||
str+=' </tr>';
|
||
str+=' <tr style="height: 100%">';
|
||
str+=' <td style="height: 5px;'+(!this.dialog ? ' cursor:w-resize;' : '')+'" id="TWin_L_'+this.tWinId+'"></td>';
|
||
str+=' <td style="vertical-align:top;cursor:default;"><table style="width: 100%; height: 100%;"><tr><td id="TWin_Co_'+this.tWinId+'" style="vertical-align:top;"></td></tr></table></td>';
|
||
str+=' <td style="height: 5px;'+(!this.dialog ? ' cursor:e-resize;' : '')+'" id="TWin_R_'+this.tWinId+'"></td>';
|
||
str+=' </tr>';
|
||
str+=' <tr>';
|
||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:sw-resize;' : '')+'" id="TWin_BL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||
str+=' <td style="vertical-align:top; height: 5px;'+(!this.dialog ? ' cursor:s-resize;' : '')+'" id="TWin_B_'+this.tWinId+'"></td>';
|
||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:se-resize;' : '')+'" id="TWin_BR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||
str+=' </tr>';
|
||
str+='</table>';
|
||
|
||
//создаём невидемую тень
|
||
this.divsh.style.cssText="display: none; position: fixed; top:0; left:0; height: 100%; width: 100%; background: rgba(0,0,0,0.3);";
|
||
this.divsh.onclick=function(win){return function(){ win.Close(); };}(this);
|
||
|
||
document.body.appendChild( this.divsh );
|
||
|
||
//Создаём родительский элемент для окна
|
||
this.div = document.createElement('div');
|
||
this.div.setAttribute("id","TWin_"+this.tWinId);
|
||
this.div.style.cssText="position:absolute; height:50px; width:640px;";
|
||
this.div.innerHTML=str;
|
||
document.body.appendChild( this.div );
|
||
this.tbl=document.getElementById('TWin_TBL_'+this.tWinId);
|
||
this.h0=document.getElementById('TWin_H0_'+this.tWinId);
|
||
this.co=document.getElementById('TWin_Co_'+this.tWinId);
|
||
this.ca=document.getElementById('TWin_Ca_'+this.tWinId);
|
||
this.setSel();
|
||
|
||
this.div.onmousedown=(e)=>this.setSel();
|
||
//Кнопка закрыть окно
|
||
let obj=document.getElementById('TWin_CL_'+this.tWinId);
|
||
if(obj!=null){
|
||
//obj.onclick=function(win){return function(){ win.Close(); };}(this);
|
||
obj.onclick=(function(){ this.Close(); }).bind(this);
|
||
}
|
||
|
||
if(!this.dialog)
|
||
{
|
||
document.getElementById('TWin_B_'+this.tWinId).onmousedown=this.onResize(0,1);
|
||
document.getElementById('TWin_T_'+this.tWinId).onmousedown=this.onResize(0,-1);
|
||
document.getElementById('TWin_BR_'+this.tWinId).onmousedown=this.onResize(1,1);
|
||
document.getElementById('TWin_TL_'+this.tWinId).onmousedown=this.onResize(-1,-1);
|
||
document.getElementById('TWin_BL_'+this.tWinId).onmousedown=this.onResize(-1,1);
|
||
document.getElementById('TWin_R_'+this.tWinId).onmousedown=this.onResize(1,0);
|
||
document.getElementById('TWin_L_'+this.tWinId).onmousedown=this.onResize(-1,0);
|
||
document.getElementById('TWin_TR_'+this.tWinId).onmousedown=this.onResize(1,-1);
|
||
}
|
||
|
||
this.setMove(document.getElementById('TWin_H0_'+this.tWinId));
|
||
//this.setMove(document.getElementById('TWin_H1_'+this.tWinId));
|
||
//this.setMove(document.getElementById('TWin_H2_'+this.tWinId));
|
||
//this.setMove(document.getElementById('TWin_H3_'+this.tWinId));
|
||
|
||
this.setLeftTop(x,y);
|
||
}
|
||
|
||
getCaption()
|
||
{
|
||
return document.getElementById('TWin_Ca_'+this.tWinId);
|
||
}
|
||
|
||
setCaption(val)
|
||
{
|
||
if(val==null) val='';
|
||
let obj=document.getElementById('TWin_Ca_'+this.tWinId);
|
||
if (typeof val === 'string' || val instanceof String)
|
||
obj.innerHTML=val;
|
||
else
|
||
obj.appendChild(val);
|
||
}
|
||
|
||
//Присвоить содержимое в виде строки
|
||
setContent(html)
|
||
{
|
||
let obj=document.getElementById('TWin_Co_'+this.tWinId);
|
||
if(obj!=null)
|
||
{
|
||
obj.innerHTML=html;
|
||
if(this.tbl.offsetHeight>this.div.offsetHeight) this.div.style.height=this.tbl.offsetHeight+"px";
|
||
if(this.tbl.offsetWidth>this.div.offsetWidth) this.div.style.width=this.tbl.offsetWidth+"px";
|
||
}
|
||
}
|
||
//Выбрать (активизировать) окно
|
||
setSel()
|
||
{
|
||
for(let i=0;i<g_wins.mas.length;i++) if(g_wins.mas[i]!=null)
|
||
{
|
||
g_wins.mas[i].sel=false;
|
||
g_wins.mas[i].ca.style.color="var(--inactive-font-color)";
|
||
}
|
||
this.sel=true;
|
||
this.ca.style.color="var(--main-font-color)";
|
||
this.setWinZ(true);
|
||
}
|
||
//Получить значение Z индекса TODO сделать через геттер
|
||
getZ()
|
||
{
|
||
return parseInt(this.div.style.zIndex);
|
||
}
|
||
//Установить значение Z индекса TODO сделать через setter
|
||
setZ(z)
|
||
{
|
||
this.div.style.zIndex=z;
|
||
this.divsh.style.zIndex=z-1;
|
||
};
|
||
setMove(elm)
|
||
{
|
||
elm.onmousedown=function(win){
|
||
return function(event){
|
||
move_me(event,win);
|
||
};
|
||
}(this);
|
||
};
|
||
//В центр видимой части экрана
|
||
setCenter()
|
||
{
|
||
let scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
||
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
||
|
||
this.div.style.left=(scrollLeft+((document.documentElement.clientWidth || document.body.clientWidth)-parseInt(this.div.style.width))/2)+"px"
|
||
this.div.style.top=(scrollTop+((document.documentElement.clientHeight || document.body.clientHeight)-parseInt(this.div.style.height))/2)+"px"
|
||
if(parseInt(this.div.style.top)<0) this.div.style.top="1px";
|
||
if(parseInt(this.div.style.left)<0) this.div.style.left="1px";
|
||
};
|
||
setLeftTop(x,y)
|
||
{
|
||
this.div.style.left=x+"px"
|
||
if(y<0) y=0;this.div.style.top=y+"px"
|
||
};
|
||
setTop(y){if(y<0) y=0;this.div.style.top=y+"px"};
|
||
getTop(){return parseInt(this.div.style.top)};
|
||
getLeft(){return parseInt(this.div.style.left)};
|
||
|
||
setSize(w,h)
|
||
{
|
||
this.setWidth(w)
|
||
this.setHeight(h)
|
||
};
|
||
//Где w вида '100px' или '100%'
|
||
setWidth(w)
|
||
{ if(w==null || w=='') return;
|
||
w=''+w;
|
||
if(w.indexOf('px')<0 && w.indexOf('%')<0) w+='px'; //По умолчанию пиксели
|
||
this.div.style.width=w
|
||
if(this.tbl.offsetWidth>this.div.offsetWidth) this.div.style.width=this.tbl.offsetWidth+"px"
|
||
};
|
||
|
||
getWidth(){
|
||
if(this.tbl!=null)
|
||
return parseInt(this.tbl.offsetWidth);
|
||
else
|
||
return 0;
|
||
};
|
||
|
||
setHeight(h)
|
||
{
|
||
if(h==null || h=='') return;
|
||
h=''+h;
|
||
if(h.indexOf('%')>-1) h=(this.div.parentNode.offsetHeight/100*parseInt(h));
|
||
|
||
this.co.style.height=(parseInt(h)-20-this.h0.offsetHeight)+"px";
|
||
this.div.style.height=parseInt(h)+'px';
|
||
|
||
if(this.tbl.offsetHeight>this.div.offsetHeight)
|
||
this.div.style.height=this.tbl.offsetHeight+"px";
|
||
};
|
||
|
||
//Подстроить размер окна по содержимому
|
||
/*adjustHeight()
|
||
{
|
||
|
||
}*/
|
||
|
||
//Подгрузить содержимое окна из указаного места
|
||
//json - объект который передастца в виде JSON строки по URL
|
||
//func - функция которая выполниться после загрузки данных в форму
|
||
load(url,json,func,tr)
|
||
{
|
||
this.showProgressBar();
|
||
var r=createRequestObject();
|
||
r.onreadystatechange = function(r,w,thiz,func)
|
||
{
|
||
return function(){
|
||
if(r.readyState == 4){
|
||
if(tr) w.innerHTML=trts(r.responseText);
|
||
else w.innerHTML=r.responseText;
|
||
thiz.hideProgressBar();
|
||
if(func !== undefined && func!=null) func();
|
||
|
||
//Для подстройки формы под новый размер, а то showProgressBar не по размеру было
|
||
thiz.div.style.width=thiz.tbl.offsetWidth+"px"
|
||
thiz.div.style.height=thiz.tbl.offsetHeight+"px";
|
||
|
||
thiz.setCenter();
|
||
}
|
||
}
|
||
}(r,this.co,this,func,tr)
|
||
r.open( "POST", url, true );
|
||
if(json!=null)
|
||
r.send(JSON.stringify(json));
|
||
else
|
||
r.send();
|
||
};
|
||
|
||
//Переместить окно на передний план (Обычно при щелчке на нём)
|
||
setWinZ(s)
|
||
{
|
||
let i;
|
||
this.setZ(g_wins.getMaxZ()+2); //+2 это для тени
|
||
if(s && this.parent!=null) //Переносим текущий элемент в 0й элемент массива детей родительского
|
||
{
|
||
var tmp=this.parent.childs[0];
|
||
for(i=1;i<this.parent.childs.length;i++)
|
||
{
|
||
if(tmp==this) break;
|
||
let t=this.parent.childs[i];
|
||
this.parent.childs[i]=tmp;
|
||
tmp=t;
|
||
}
|
||
this.parent.childs[0]=tmp;
|
||
}
|
||
for(i=this.childs.length;i>0;i--) if(this.childs[i-1]!=null) this.childs[i-1].setWinZ(false) //Забыл зачем это делаю
|
||
}
|
||
setParent(w)
|
||
{
|
||
if(this.parent!=null)
|
||
{
|
||
for(let i=0;i<this.parent.childs.length;i++) if(this.parent.childs[i]==this) this.parent.childs[i]=null;
|
||
}
|
||
if(typeof w !== 'undefined' && w!=null)
|
||
{
|
||
this.parent=w;
|
||
w.childs[w.childs.length]=this;
|
||
}
|
||
}
|
||
hide(val)
|
||
{
|
||
if(val)
|
||
{ this.div.style.display='none';
|
||
this.divsh.style.display='none';
|
||
}else
|
||
{
|
||
this.div.style.display='inline';
|
||
if(this.shadow) this.divsh.style.display='block';
|
||
}
|
||
}
|
||
|
||
//Показать прогрес бар
|
||
showProgressBar()
|
||
{
|
||
this.pBarCnt++;
|
||
if(this.pBarDiv==null)
|
||
{
|
||
var img='loading.gif';
|
||
if(this.getWidth()<230) img='loading3.gif';
|
||
|
||
this.pBarDiv=document.createElement('div');
|
||
this.pBarDiv.style.cssText='position: absolute; left: 0px; top: 0px; z-index: 1; width:100%; height: 100%; margin-top:30px; padding-bottom:30px;';
|
||
this.pBarDiv.innerHTML='<table style="background-color: rgba(0,0,0,0.5);" width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td align="center" style="vertical-align: middle;"><img src="'+this.path+'/metadata/dbms/images/'+img+'" alt=""></td></tr></table>';
|
||
|
||
//var eDiv=document.getElementById('eDiv'+this.uid);
|
||
this.div.appendChild(this.pBarDiv);
|
||
}
|
||
}
|
||
|
||
//Спрятать прогрес бар
|
||
hideProgressBar()
|
||
{
|
||
this.pBarCnt--;
|
||
if(this.pBarCnt<=0)
|
||
{
|
||
if(this.pBarDiv!==null) deleteHTML(this.pBarDiv);
|
||
this.pBarCnt=0;
|
||
this.pBarDiv=null;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
class TWins
|
||
{
|
||
constructor()
|
||
{
|
||
this.mas = new Array();
|
||
}
|
||
add(win) //Добавить окно в список
|
||
{
|
||
this.mas.push(win);
|
||
return this.mas.length-1;
|
||
};
|
||
getMaxZ() //Получить максимальный Z индекс
|
||
{
|
||
var z=100; //По умолчанию
|
||
for(var i=0;i<this.mas.length;i++) if(this.mas[i]!==null && this.mas[i].getZ()>z) z=this.mas[i].getZ();
|
||
return z;
|
||
};
|
||
getSel() //Получить выделенное окно
|
||
{
|
||
for(var i=0;i<this.mas.length;i++) if(this.mas[i].sel) return this.mas[i];
|
||
return null;
|
||
};
|
||
}
|
||
var g_wins=new TWins(); //Global object
|
||
|