new
This commit is contained in:
@ -763,7 +763,7 @@ class EdtRec
|
||||
td.setAttribute("align","right");
|
||||
button = document.createElement('input');
|
||||
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.onclick=function(thiz){
|
||||
return function(){
|
||||
@ -774,7 +774,7 @@ class EdtRec
|
||||
|
||||
button = document.createElement('input'); //Button cancel
|
||||
button.setAttribute("type","button");
|
||||
button.style.cssText="margin:0px;padding:0px;";
|
||||
button.style.cssText="margin:0px;";
|
||||
button.setAttribute("value",_('Cancel'));
|
||||
//button.onclick=function f_exit(this) { alert(this.win.div); }
|
||||
button.onclick=function(thiz){ return function(){thiz.win.Close();};}(this);
|
||||
|
||||
@ -862,15 +862,25 @@ function replaseTextInCDATA(node,oldStr,newStr)
|
||||
}
|
||||
|
||||
//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);
|
||||
return call.callServer(url,xmlString);
|
||||
};
|
||||
}
|
||||
|
||||
this.processReqChange=function(xmlHttpRequest,url,xmlString)
|
||||
processReqChange(xmlHttpRequest,url,xmlString)
|
||||
{
|
||||
//if (typeof(xmlHttpRequest.readyState)=='undefined' || xmlHttpRequest.readyState == 4)
|
||||
//{
|
||||
@ -910,25 +920,26 @@ function TRequest(listener)
|
||||
}
|
||||
//}
|
||||
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()
|
||||
{
|
||||
@ -939,10 +950,10 @@ function myXMLHttpRequest(obj)
|
||||
thiz.obj.processReqChange(thiz.xmlHttpRequest,thiz.url,thiz.xmlString);//вызываем метод переданного объекта
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
/** Запросить данные постом
|
||||
*/
|
||||
this.callServer=function(url,xmlString)
|
||||
callServer(url,xmlString)
|
||||
{
|
||||
this.url=url;
|
||||
this.xmlString=xmlString;
|
||||
@ -955,10 +966,10 @@ function myXMLHttpRequest(obj)
|
||||
this.xmlHttpRequest.send(xmlString);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
/** Запросить данные гетом
|
||||
*/
|
||||
this.GETFromServer=function(url,xmlString)
|
||||
GETFromServer(url,xmlString)
|
||||
{
|
||||
this.url=url;
|
||||
this.xmlString=xmlString;
|
||||
@ -967,26 +978,49 @@ function myXMLHttpRequest(obj)
|
||||
this.xmlHttpRequest.open("GET", url, true);
|
||||
this.xmlHttpRequest.setRequestHeader("Content-Type", "text/xml");
|
||||
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();
|
||||
};
|
||||
}
|
||||
|
||||
this.onResize=function(x,y)
|
||||
onResize(x,y)
|
||||
{
|
||||
var win=this;
|
||||
return function(e){
|
||||
@ -1029,9 +1063,9 @@ function TWin(dialog)
|
||||
};
|
||||
return false;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
this.Close=function() //Закрыть и удалить окно из родителя и менеджера
|
||||
Close() //Закрыть и удалить окно из родителя и менеджера
|
||||
{
|
||||
this.hide(true);
|
||||
this.setParent(null);
|
||||
@ -1050,7 +1084,7 @@ function TWin(dialog)
|
||||
};
|
||||
|
||||
//Типа конструктор создать окно с заданой позицией
|
||||
this.TWin = function(x,y)
|
||||
TWin(x,y)
|
||||
{
|
||||
this.tWinId=Wins.add(this);
|
||||
/*
|
||||
@ -1170,24 +1204,24 @@ function TWin(dialog)
|
||||
//this.setMove(document.getElementById('TWin_H3_'+this.tWinId));
|
||||
|
||||
this.setLeftTop(x,y);
|
||||
};
|
||||
}
|
||||
|
||||
this.getCaption = function()
|
||||
getCaption()
|
||||
{
|
||||
return document.getElementById('TWin_Ca_'+this.tWinId);
|
||||
};
|
||||
}
|
||||
|
||||
this.setCaption = function(val)
|
||||
setCaption(val)
|
||||
{
|
||||
var obj=document.getElementById('TWin_Ca_'+this.tWinId);
|
||||
if (typeof val === 'string' || val instanceof String)
|
||||
obj.innerHTML=val;
|
||||
else
|
||||
obj.appendChild(val);
|
||||
};
|
||||
}
|
||||
|
||||
//Присвоить содержимое в виде строки
|
||||
this.setContent = function(html)
|
||||
setContent(html)
|
||||
{
|
||||
var obj=document.getElementById('TWin_Co_'+this.tWinId);
|
||||
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.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)
|
||||
{
|
||||
@ -1208,19 +1242,19 @@ function TWin(dialog)
|
||||
this.sel=true;
|
||||
this.ca.style.color="black";
|
||||
this.setWinZ(true);
|
||||
};
|
||||
//Получить значение Z индекса
|
||||
this.getZ = function()
|
||||
}
|
||||
//Получить значение Z индекса TODO сделать через геттер
|
||||
getZ()
|
||||
{
|
||||
return parseInt(this.div.style.zIndex);
|
||||
};
|
||||
//Установить значение Z индекса
|
||||
this.setZ = function(z)
|
||||
}
|
||||
//Установить значение Z индекса TODO сделать через setter
|
||||
setZ(z)
|
||||
{
|
||||
this.div.style.zIndex=z;
|
||||
this.divsh.style.zIndex=z-1;
|
||||
};
|
||||
this.setMove = function(elm)
|
||||
setMove(elm)
|
||||
{
|
||||
elm.onmousedown=function(win){
|
||||
return function(event){
|
||||
@ -1229,7 +1263,7 @@ function TWin(dialog)
|
||||
}(this);
|
||||
};
|
||||
//В центр видимой части экрана
|
||||
this.setCenter=function()
|
||||
setCenter()
|
||||
{
|
||||
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
||||
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.left)<0) this.div.style.left="1px";
|
||||
};
|
||||
this.setLeftTop=function(x,y)
|
||||
setLeftTop(x,y)
|
||||
{
|
||||
this.div.style.left=x+"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"};
|
||||
this.getTop=function(){return parseInt(this.div.style.top)};
|
||||
this.getLeft=function(){return parseInt(this.div.style.left)};
|
||||
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)};
|
||||
|
||||
this.setSize=function(w,h)
|
||||
setSize(w,h)
|
||||
{
|
||||
this.setWidth(w)
|
||||
this.setHeight(h)
|
||||
};
|
||||
//Где w вида '100px' или '100%'
|
||||
this.setWidth=function(w)
|
||||
setWidth(w)
|
||||
{ if(w==null || w=='') return;
|
||||
w=''+w;
|
||||
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"
|
||||
};
|
||||
|
||||
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;
|
||||
h=''+h;
|
||||
@ -1278,14 +1312,15 @@ function TWin(dialog)
|
||||
};
|
||||
|
||||
//Подстроить размер окна по содержимому
|
||||
/*this.adjustHeight=function()
|
||||
/*adjustHeight()
|
||||
{
|
||||
|
||||
}*/
|
||||
|
||||
//Подгрузить содержимое окна из указаного места
|
||||
//json - объект который передастца в виде JSON строки
|
||||
this.load=function(url,json,func)
|
||||
//json - объект который передастца в виде JSON строки по URL
|
||||
//func - функция которая выполниться после загрузки данных в форму
|
||||
load(url,json,func)
|
||||
{
|
||||
this.showProgressBar();
|
||||
var r=createRequestObject();
|
||||
@ -1300,15 +1335,20 @@ function TWin(dialog)
|
||||
//Для подстройки формы под новый размер, а то showProgressBar не по размеру было
|
||||
thiz.div.style.width=thiz.tbl.offsetWidth+"px"
|
||||
thiz.div.style.height=thiz.tbl.offsetHeight+"px";
|
||||
|
||||
thiz.setCenter();
|
||||
}
|
||||
}
|
||||
}(r,this.co,this,func)
|
||||
r.open( "POST", url, true );
|
||||
if(json!=null)
|
||||
r.send(JSON.stringify(json));
|
||||
else
|
||||
r.send();
|
||||
};
|
||||
|
||||
//Переместить окно на передний план (Обычно при щелчке на нём)
|
||||
this.setWinZ=function(s)
|
||||
setWinZ(s)
|
||||
{
|
||||
var i;
|
||||
this.setZ(Wins.getMaxZ()+2); //+2 это для тени
|
||||
@ -1325,8 +1365,8 @@ function TWin(dialog)
|
||||
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) //Забыл зачем это делаю
|
||||
};
|
||||
this.setParent=function(w)
|
||||
}
|
||||
setParent(w)
|
||||
{
|
||||
if(this.parent!=null)
|
||||
{
|
||||
@ -1337,8 +1377,8 @@ function TWin(dialog)
|
||||
this.parent=w;
|
||||
w.childs[w.childs.length]=this;
|
||||
}
|
||||
};
|
||||
this.hide=function(val)
|
||||
}
|
||||
hide(val)
|
||||
{
|
||||
if(val)
|
||||
{ this.div.style.display='none';
|
||||
@ -1348,10 +1388,10 @@ function TWin(dialog)
|
||||
this.div.style.display='inline';
|
||||
if(this.shadow) this.divsh.style.display='block';
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//Показать прогрес бар
|
||||
this.showProgressBar=function()
|
||||
showProgressBar()
|
||||
{
|
||||
this.pBarCnt++;
|
||||
if(this.pBarDiv==null)
|
||||
@ -1366,10 +1406,10 @@ function TWin(dialog)
|
||||
//var eDiv=document.getElementById('eDiv'+this.uid);
|
||||
this.div.appendChild(this.pBarDiv);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//Спрятать прогрес бар
|
||||
this.hideProgressBar=function()
|
||||
hideProgressBar()
|
||||
{
|
||||
this.pBarCnt--;
|
||||
if(this.pBarCnt<=0)
|
||||
@ -1378,71 +1418,50 @@ function TWin(dialog)
|
||||
this.pBarCnt=0;
|
||||
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);
|
||||
return this.mas.length-1;
|
||||
};
|
||||
this.getMaxZ = function() //Получить максимальный Z индекс
|
||||
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;
|
||||
};
|
||||
this.getSel = function() //Получить выделенное окно
|
||||
getSel() //Получить выделенное окно
|
||||
{
|
||||
for(var i=0;i<this.mas.length;i++) if(this.mas[i].sel) return this.mas[i];
|
||||
return null;
|
||||
};
|
||||
this.mas = new Array();
|
||||
}
|
||||
var Wins=new TWins(); //Global object
|
||||
|
||||
//список параметров
|
||||
function TSettings()
|
||||
//список параметров (TODO для чего использую?)
|
||||
class TSettings
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
this.seq=0;
|
||||
this.mas = new Array();
|
||||
this.add=function(id,val)
|
||||
}
|
||||
add(id,val)
|
||||
{ this.mas[id]=val;
|
||||
};
|
||||
this.del=function(id)
|
||||
}
|
||||
del(id)
|
||||
{ return this.mas[id];
|
||||
};
|
||||
this.get=function(id)
|
||||
get(id)
|
||||
{ delete(this.mas[id]);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user