This commit is contained in:
2020-03-04 17:26:04 +06:00
parent 93e452fbdf
commit 44f3b72b71
2 changed files with 133 additions and 114 deletions

View File

@ -763,7 +763,7 @@ class EdtRec
td.setAttribute("align","right"); td.setAttribute("align","right");
button = document.createElement('input'); button = document.createElement('input');
button.setAttribute("type","button"); button.setAttribute("type","button");
button.style.cssText="margin:0px;margin-right:1px;padding:0px;"; button.style.cssText="margin:0px;margin-right:1px;";
button.setAttribute("value",_('Apply')); button.setAttribute("value",_('Apply'));
button.onclick=function(thiz){ button.onclick=function(thiz){
return function(){ return function(){
@ -774,7 +774,7 @@ class EdtRec
button = document.createElement('input'); //Button cancel button = document.createElement('input'); //Button cancel
button.setAttribute("type","button"); button.setAttribute("type","button");
button.style.cssText="margin:0px;padding:0px;"; button.style.cssText="margin:0px;";
button.setAttribute("value",_('Cancel')); button.setAttribute("value",_('Cancel'));
//button.onclick=function f_exit(this) { alert(this.win.div); } //button.onclick=function f_exit(this) { alert(this.win.div); }
button.onclick=function(thiz){ return function(){thiz.win.Close();};}(this); button.onclick=function(thiz){ return function(){thiz.win.Close();};}(this);

View File

@ -862,15 +862,25 @@ function replaseTextInCDATA(node,oldStr,newStr)
} }
//Wrapper for XMLHttpRequest //Wrapper for XMLHttpRequest
function TRequest(listener) class TRequest
{ {
this.callServer=function(url,xmlString) constructor(listener)
{
if(listener.applyReq==null) alert('An object can not be found the function: "applyReq()"!');
//if(listener.name==null) alert('An object can not be found the propenty: "name"!'); незачем
this.winObj=listener;
//private
this.m_seq=0;
this.seq=-1;
}
callServer(url,xmlString)
{ {
var call=new myXMLHttpRequest(this); var call=new myXMLHttpRequest(this);
return call.callServer(url,xmlString); return call.callServer(url,xmlString);
}; }
this.processReqChange=function(xmlHttpRequest,url,xmlString) processReqChange(xmlHttpRequest,url,xmlString)
{ {
//if (typeof(xmlHttpRequest.readyState)=='undefined' || xmlHttpRequest.readyState == 4) //if (typeof(xmlHttpRequest.readyState)=='undefined' || xmlHttpRequest.readyState == 4)
//{ //{
@ -910,25 +920,26 @@ function TRequest(listener)
} }
//} //}
return null; return null;
}; }
if(listener.applyReq==null) alert('An object can not be found the function: "applyReq()"!');
//if(listener.name==null) alert('An object can not be found the propenty: "name"!'); незачем
this.winObj=listener;
//private
this.m_seq=0;
this.seq=-1;
}; };
//Session=new TSession(); //Global object (закоментил потому что в глобальности нет необходимости каждый раз должен быть новый)
/** Класс асинхронных запросов к серверу /** Класс асинхронных запросов к серверу
*/ */
function myXMLHttpRequest(obj) class myXMLHttpRequest
{ {
constructor(obj)
{
this.url=null;
this.xmlString=null;
this.name="myXMLHttpRequest";
this.obj=obj;
if(obj.processReqChange==null) alert('Нет функции "processReqChange"');
this.xmlHttpRequest=createRequestObject();
}
/** /**
* Функция возвращяет ссылку на анонимную функцию * Функция возвращяет ссылку на анонимную функцию
*/ */
this.LocCallback=function(thiz) LocCallback(thiz)
{ {
return function() return function()
{ {
@ -939,10 +950,10 @@ function myXMLHttpRequest(obj)
thiz.obj.processReqChange(thiz.xmlHttpRequest,thiz.url,thiz.xmlString);//вызываем метод переданного объекта thiz.obj.processReqChange(thiz.xmlHttpRequest,thiz.url,thiz.xmlString);//вызываем метод переданного объекта
} }
}; };
}; }
/** Запросить данные постом /** Запросить данные постом
*/ */
this.callServer=function(url,xmlString) callServer(url,xmlString)
{ {
this.url=url; this.url=url;
this.xmlString=xmlString; this.xmlString=xmlString;
@ -955,10 +966,10 @@ function myXMLHttpRequest(obj)
this.xmlHttpRequest.send(xmlString); this.xmlHttpRequest.send(xmlString);
return true; return true;
}; }
/** Запросить данные гетом /** Запросить данные гетом
*/ */
this.GETFromServer=function(url,xmlString) GETFromServer(url,xmlString)
{ {
this.url=url; this.url=url;
this.xmlString=xmlString; this.xmlString=xmlString;
@ -967,26 +978,49 @@ function myXMLHttpRequest(obj)
this.xmlHttpRequest.open("GET", url, true); this.xmlHttpRequest.open("GET", url, true);
this.xmlHttpRequest.setRequestHeader("Content-Type", "text/xml"); this.xmlHttpRequest.setRequestHeader("Content-Type", "text/xml");
this.xmlHttpRequest.send(xmlString); this.xmlHttpRequest.send(xmlString);
}; }
this.url=null;
this.xmlString=null;
this.name="myXMLHttpRequest";
this.obj=obj;
if(obj.processReqChange==null) alert('Нет функции "processReqChange"');
this.xmlHttpRequest=createRequestObject();
} }
//Класс окна //Класс окна
function TWin(dialog) class TWin
{ {
this.addResizeListener=function(func) constructor(dialog)
{
this.dialog=dialog; //Показывать окно как диалог (без возможности изменения размеров)
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; //Прогресс бар
var fnResizeListener=null;
}
addResizeListener(func)
{ {
this.fnResizeListener=func; this.fnResizeListener=func;
this.fnResizeListener(); this.fnResizeListener();
}; }
this.onResize=function(x,y) onResize(x,y)
{ {
var win=this; var win=this;
return function(e){ return function(e){
@ -1029,9 +1063,9 @@ function TWin(dialog)
}; };
return false; return false;
}; };
}; }
this.Close=function() //Закрыть и удалить окно из родителя и менеджера Close() //Закрыть и удалить окно из родителя и менеджера
{ {
this.hide(true); this.hide(true);
this.setParent(null); this.setParent(null);
@ -1050,7 +1084,7 @@ function TWin(dialog)
}; };
//Типа конструктор создать окно с заданой позицией //Типа конструктор создать окно с заданой позицией
this.TWin = function(x,y) TWin(x,y)
{ {
this.tWinId=Wins.add(this); this.tWinId=Wins.add(this);
/* /*
@ -1170,24 +1204,24 @@ function TWin(dialog)
//this.setMove(document.getElementById('TWin_H3_'+this.tWinId)); //this.setMove(document.getElementById('TWin_H3_'+this.tWinId));
this.setLeftTop(x,y); this.setLeftTop(x,y);
}; }
this.getCaption = function() getCaption()
{ {
return document.getElementById('TWin_Ca_'+this.tWinId); return document.getElementById('TWin_Ca_'+this.tWinId);
}; }
this.setCaption = function(val) setCaption(val)
{ {
var obj=document.getElementById('TWin_Ca_'+this.tWinId); var obj=document.getElementById('TWin_Ca_'+this.tWinId);
if (typeof val === 'string' || val instanceof String) if (typeof val === 'string' || val instanceof String)
obj.innerHTML=val; obj.innerHTML=val;
else else
obj.appendChild(val); obj.appendChild(val);
}; }
//Присвоить содержимое в виде строки //Присвоить содержимое в виде строки
this.setContent = function(html) setContent(html)
{ {
var obj=document.getElementById('TWin_Co_'+this.tWinId); var obj=document.getElementById('TWin_Co_'+this.tWinId);
if(obj!=null) if(obj!=null)
@ -1196,9 +1230,9 @@ function TWin(dialog)
if(this.tbl.offsetHeight>this.div.offsetHeight) this.div.style.height=this.tbl.offsetHeight+"px"; 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"; if(this.tbl.offsetWidth>this.div.offsetWidth) this.div.style.width=this.tbl.offsetWidth+"px";
} }
}; }
//Выбрать (активизировать) окно //Выбрать (активизировать) окно
this.setSel = function() setSel()
{ {
for(var i=0;i<Wins.mas.length;i++) if(Wins.mas[i]!=null) for(var i=0;i<Wins.mas.length;i++) if(Wins.mas[i]!=null)
{ {
@ -1208,19 +1242,19 @@ function TWin(dialog)
this.sel=true; this.sel=true;
this.ca.style.color="black"; this.ca.style.color="black";
this.setWinZ(true); this.setWinZ(true);
}; }
//Получить значение Z индекса //Получить значение Z индекса TODO сделать через геттер
this.getZ = function() getZ()
{ {
return parseInt(this.div.style.zIndex); return parseInt(this.div.style.zIndex);
}; }
//Установить значение Z индекса //Установить значение Z индекса TODO сделать через setter
this.setZ = function(z) setZ(z)
{ {
this.div.style.zIndex=z; this.div.style.zIndex=z;
this.divsh.style.zIndex=z-1; this.divsh.style.zIndex=z-1;
}; };
this.setMove = function(elm) setMove(elm)
{ {
elm.onmousedown=function(win){ elm.onmousedown=function(win){
return function(event){ return function(event){
@ -1229,7 +1263,7 @@ function TWin(dialog)
}(this); }(this);
}; };
//В центр видимой части экрана //В центр видимой части экрана
this.setCenter=function() setCenter()
{ {
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft; var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
var scrollTop = window.pageYOffset || document.documentElement.scrollTop; var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
@ -1239,22 +1273,22 @@ function TWin(dialog)
if(parseInt(this.div.style.top)<0) this.div.style.top="1px"; if(parseInt(this.div.style.top)<0) this.div.style.top="1px";
if(parseInt(this.div.style.left)<0) this.div.style.left="1px"; if(parseInt(this.div.style.left)<0) this.div.style.left="1px";
}; };
this.setLeftTop=function(x,y) setLeftTop(x,y)
{ {
this.div.style.left=x+"px" this.div.style.left=x+"px"
if(y<0) y=0;this.div.style.top=y+"px" if(y<0) y=0;this.div.style.top=y+"px"
}; };
this.setTop=function(y){if(y<0) y=0;this.div.style.top=y+"px"}; setTop(y){if(y<0) y=0;this.div.style.top=y+"px"};
this.getTop=function(){return parseInt(this.div.style.top)}; getTop(){return parseInt(this.div.style.top)};
this.getLeft=function(){return parseInt(this.div.style.left)}; getLeft(){return parseInt(this.div.style.left)};
this.setSize=function(w,h) setSize(w,h)
{ {
this.setWidth(w) this.setWidth(w)
this.setHeight(h) this.setHeight(h)
}; };
//Где w вида '100px' или '100%' //Где w вида '100px' или '100%'
this.setWidth=function(w) setWidth(w)
{ if(w==null || w=='') return; { if(w==null || w=='') return;
w=''+w; w=''+w;
if(w.indexOf('px')<0 && w.indexOf('%')<0) w+='px'; //По умолчанию пиксели if(w.indexOf('px')<0 && w.indexOf('%')<0) w+='px'; //По умолчанию пиксели
@ -1262,9 +1296,9 @@ function TWin(dialog)
if(this.tbl.offsetWidth>this.div.offsetWidth) this.div.style.width=this.tbl.offsetWidth+"px" if(this.tbl.offsetWidth>this.div.offsetWidth) this.div.style.width=this.tbl.offsetWidth+"px"
}; };
this.getWidth=function(){return parseInt(this.tbl.offsetWidth);}; getWidth(){return parseInt(this.tbl.offsetWidth);};
this.setHeight=function(h) setHeight(h)
{ {
if(h==null || h=='') return; if(h==null || h=='') return;
h=''+h; h=''+h;
@ -1278,14 +1312,15 @@ function TWin(dialog)
}; };
//Подстроить размер окна по содержимому //Подстроить размер окна по содержимому
/*this.adjustHeight=function() /*adjustHeight()
{ {
}*/ }*/
//Подгрузить содержимое окна из указаного места //Подгрузить содержимое окна из указаного места
//json - объект который передастца в виде JSON строки //json - объект который передастца в виде JSON строки по URL
this.load=function(url,json,func) //func - функция которая выполниться после загрузки данных в форму
load(url,json,func)
{ {
this.showProgressBar(); this.showProgressBar();
var r=createRequestObject(); var r=createRequestObject();
@ -1300,15 +1335,20 @@ function TWin(dialog)
//Для подстройки формы под новый размер, а то showProgressBar не по размеру было //Для подстройки формы под новый размер, а то showProgressBar не по размеру было
thiz.div.style.width=thiz.tbl.offsetWidth+"px" thiz.div.style.width=thiz.tbl.offsetWidth+"px"
thiz.div.style.height=thiz.tbl.offsetHeight+"px"; thiz.div.style.height=thiz.tbl.offsetHeight+"px";
thiz.setCenter();
} }
} }
}(r,this.co,this,func) }(r,this.co,this,func)
r.open( "POST", url, true ); r.open( "POST", url, true );
r.send(JSON.stringify(json)); if(json!=null)
r.send(JSON.stringify(json));
else
r.send();
}; };
//Переместить окно на передний план (Обычно при щелчке на нём) //Переместить окно на передний план (Обычно при щелчке на нём)
this.setWinZ=function(s) setWinZ(s)
{ {
var i; var i;
this.setZ(Wins.getMaxZ()+2); //+2 это для тени this.setZ(Wins.getMaxZ()+2); //+2 это для тени
@ -1325,8 +1365,8 @@ function TWin(dialog)
this.parent.childs[0]=tmp; 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) //Забыл зачем это делаю for(i=this.childs.length;i>0;i--) if(this.childs[i-1]!=null) this.childs[i-1].setWinZ(false) //Забыл зачем это делаю
}; }
this.setParent=function(w) setParent(w)
{ {
if(this.parent!=null) if(this.parent!=null)
{ {
@ -1337,8 +1377,8 @@ function TWin(dialog)
this.parent=w; this.parent=w;
w.childs[w.childs.length]=this; w.childs[w.childs.length]=this;
} }
}; }
this.hide=function(val) hide(val)
{ {
if(val) if(val)
{ this.div.style.display='none'; { this.div.style.display='none';
@ -1348,10 +1388,10 @@ function TWin(dialog)
this.div.style.display='inline'; this.div.style.display='inline';
if(this.shadow) this.divsh.style.display='block'; if(this.shadow) this.divsh.style.display='block';
} }
}; }
//Показать прогрес бар //Показать прогрес бар
this.showProgressBar=function() showProgressBar()
{ {
this.pBarCnt++; this.pBarCnt++;
if(this.pBarDiv==null) if(this.pBarDiv==null)
@ -1366,10 +1406,10 @@ function TWin(dialog)
//var eDiv=document.getElementById('eDiv'+this.uid); //var eDiv=document.getElementById('eDiv'+this.uid);
this.div.appendChild(this.pBarDiv); this.div.appendChild(this.pBarDiv);
} }
}; }
//Спрятать прогрес бар //Спрятать прогрес бар
this.hideProgressBar=function() hideProgressBar()
{ {
this.pBarCnt--; this.pBarCnt--;
if(this.pBarCnt<=0) if(this.pBarCnt<=0)
@ -1378,71 +1418,50 @@ function TWin(dialog)
this.pBarCnt=0; this.pBarCnt=0;
this.pBarDiv=null; this.pBarDiv=null;
} }
}; }
this.dialog=dialog; //Показывать окно как диалог (без возможности изменения размеров)
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; //Прогресс бар
var fnResizeListener=null;
} }
function TWins() class TWins
{ {
this.add = function(win) //Добавить окно в список constructor()
{
this.mas = new Array();
}
add(win) //Добавить окно в список
{ {
this.mas.push(win); this.mas.push(win);
return this.mas.length-1; return this.mas.length-1;
}; };
this.getMaxZ = function() //Получить максимальный Z индекс getMaxZ() //Получить максимальный Z индекс
{ {
var z=100; //По умолчанию 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(); 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; return z;
}; };
this.getSel = function() //Получить выделенное окно getSel() //Получить выделенное окно
{ {
for(var i=0;i<this.mas.length;i++) if(this.mas[i].sel) return this.mas[i]; for(var i=0;i<this.mas.length;i++) if(this.mas[i].sel) return this.mas[i];
return null; return null;
}; };
this.mas = new Array();
} }
var Wins=new TWins(); //Global object var Wins=new TWins(); //Global object
//список параметров //список параметров (TODO для чего использую?)
function TSettings() class TSettings
{ {
this.seq=0; constructor()
this.mas = new Array(); {
this.add=function(id,val) this.seq=0;
this.mas = new Array();
}
add(id,val)
{ this.mas[id]=val; { this.mas[id]=val;
}; }
this.del=function(id) del(id)
{ return this.mas[id]; { return this.mas[id];
}; };
this.get=function(id) get(id)
{ delete(this.mas[id]); { delete(this.mas[id]);
}; };
} }