/*
Product Name: dhtmlxSuite
Version: 5.2.0
Edition: Professional
License: content of this file is covered by DHTMLX Commercial or Enterprise license. Usage without proper license is prohibited. To obtain it contact sales@dhtmlx.com
Copyright UAB Dinamenta http://www.dhtmlx.com
*/
function dhtmlXLayoutObject(base, pattern, skin) {
// console.log("resize over iframe");
var autoload = null;
if (base != null && typeof(base) == "object" && typeof(base.tagName) == "undefined" && base._isCell != true) {
// api-init
autoload = {};
if (base.autosize != null) autoload.autosize = base.autosize;
if (base.cells != null) autoload.cells = base.cells;
if (base.pattern != null) pattern = base.pattern;
if (base.skin != null) skin = base.skin;
if (base.offsets != null) autoload.offsets = base.offsets;
base = base.parent;
}
this.cdata = {};
this.conf = {
skin: (skin||window.dhx4.skin||(typeof(dhtmlx)!="undefined"?dhtmlx.skin:null)||window.dhx4.skinDetect("dhxlayout")||"material"),
css: "dhxlayout", // css prefix for topcell mtb
hh: 20, // header height collapsed, add auto-detect?
autosize: "b", // cell which will sized when parent size changed
nextCell: {a:"b",b:"a"},
inited: false,
b_size: {w:-1,h:-1} // base size for onResize
};
if (this.conf.skin == "material") {
this.conf.hh = window.dhx4.readFromCss("dhxlayout_base_material dhxlayout_collapsed_height");
}
// attach layout
if (typeof(base) == "object" && base._isCell == true) {
var conf = (typeof(autoload) != "undefined" && autoload != null ? autoload : {});
if (conf.pattern == null && pattern != null) conf.pattern = pattern;
if (conf.skin == null && skin != null) conf.skin = skin;
var layout = base.attachLayout(conf);
return layout;
}
// init top container
window.dhtmlXCellTop.apply(this, [base, (autoload==null?null:autoload.offsets)]);
// separator width/height
this.conf.sw = this._detectSW();
var that = this;
this._getLayout = function() {
return this;
}
this.mainInst = (base._layoutMainInst != null ? base._layoutMainInst : null);
this._getMainInst = function() {
if (this.mainInst != null) return this.mainInst._getMainInst();
return this;
}
this._init = function(pattern) {
var t = (typeof(pattern) == "string" ? this.tplData[pattern] : pattern );
this.conf.mode = t.mode;
if (this.conf.mode == "c") {
this.cdata.a = new dhtmlXLayoutCell("a", this);
} else {
this.cdata.a = new dhtmlXLayoutCell("a", this);
this.cdata.b = new dhtmlXLayoutCell("b", this);
}
for (var a in this.cdata) {
this.cont.appendChild(this.cdata[a].cell);
this.cdata[a].conf.init = { w: 0.5, h: 0.5 };
}
if (this.conf.mode != "c") {
var mainInst = this._getMainInst();
if (mainInst.conf.sep_idx == null) mainInst.conf.sep_idx = 1; else mainInst.conf.sep_idx++;
this.sep = new dhtmlXLayoutSepObject(this.conf.mode, mainInst.conf.sep_idx);
this.cont.appendChild(this.sep.sep);
this.sep._getLayout = function() {
return that._getLayout();
}
mainInst = null;
}
if (t.cells != null) {
for (var a in t.cells) {
if (t.cells[a].width != null) this.cdata[a].conf.init.w = t.cells[a].width;
if (t.cells[a].height != null) this.cdata[a].conf.init.h = t.cells[a].height;
if (t.cells[a].name != null) {
this.cdata[a].conf.name = t.cells[a].name;
this.cdata[a].setText(t.cells[a].name);
}
// fixed size conf
if (t.cells[a].fsize != null) this.cdata[a].conf.fsize = t.cells[a].fsize;
}
}
this.setSizes();
for (var a in this.cdata) this.cdata[a].conf.init = {};
if (t.cells != null) {
for (var a in t.cells) {
if (t.cells[a].layout != null) {
this.cdata[a].dataNested = true;
this.cdata[a]._layoutMainInst = this;
this.cdata[a].cell.className += " dhx_cell_nested_layout";
this.cdata[a].attachLayout({pattern:t.cells[a].layout});
this.cdata[a]._layoutMainInst = null;
}
}
}
}
this.setSizes = function(parentIdd, autosize, noCalcCont, actionType) {
// noCalcCont = skip inner content adjusting, for autoexpand
var rEv = (this.conf.inited==true && this._getMainInst()==this && this.checkEvent("onResizeFinish")==true ? {}:false); // resize event
// celltop
this._adjustCont();
var w = this.cont.offsetWidth; // baseW
var h = this.cont.offsetHeight; // baseH
if (this.conf.mode == "c") {
var ax = 0;
var ay = 0;
var aw = w;
var ah = h;
this.cdata.a._setSize(ax, ay, aw, ah, parentIdd, noCalcCont, actionType);
this.callEvent("_onSetSizes", []);
if (rEv && (!(this.conf.b_size.w == w && this.conf.b_size.h == h))) {
this._callMainEvent("onResizeFinish", []);
}
this.conf.b_size = {w: w, h: h};
return;
}
if (typeof(autosize) == "undefined") {
var k = (this.conf.mode=="v"?"w":"h");
autosize = this.conf.autosize;
if (this.cdata.a.conf.collapsed) {
autosize = "b";
} else if (this.cdata.b.conf.collapsed) {
autosize = "a";
} else if (parentIdd == "a" || parentIdd == "b") {
autosize = this.conf.nextCell[parentIdd];
}
} else {
//debugger
}
if (this.conf.mode == "v") {
if (autosize == "a") { // fix "b", fit "a"
if (this.cdata.b.conf.init.w != null) {
var bw = Math.round(w*this.cdata.b.conf.init.w-this.conf.sw/2);
} else {
var bw = this.cdata.b.conf.size.w;
}
var bx = w-bw;
var by = 0;
var bh = h;
var ax = 0;
var ay = by;
var aw = bx-ax-this.conf.sw;
var ah = bh;
} else { // fix "a", fit "b"
var ax = 0;
var ay = 0;
// check if init stage
if (this.cdata.a.conf.init.w != null) {
var aw = Math.round(w*this.cdata.a.conf.init.w-this.conf.sw/2)-ax;
} else {
var aw = this.cdata.a.conf.size.w;
}
var ah = h-ay;
var bx = ax+aw+this.conf.sw;
var by = ay;
var bw = w-bx;
var bh = ah;
}
this.cdata.a._setSize(ax, ay, aw, ah, parentIdd, noCalcCont, actionType);
this.cdata.b._setSize(bx, by, bw, bh, parentIdd, noCalcCont, actionType);
this.sep._setSize(ax+aw, ay, this.conf.sw, ah);
} else {
if (autosize == "a") { // fix "b", fit "a"
if (this.cdata.b.conf.init.h != null) {
var bh = Math.round(h*this.cdata.b.conf.init.h-this.conf.sw/2);
} else {
var bh = this.cdata.b.conf.size.h;
}
var bx = 0;
var by = h-bh;
var bw = w-bx;
var ax = bx;
var ay = 0;
var aw = bw;
var ah = by-ay-this.conf.sw;
} else { // fix "a", fit "b"
var ax = 0;
var ay = 0;
var aw = w-ax;
// check if init stage
if (this.cdata.a.conf.init.h != null) {
var ah = Math.round(h*this.cdata.a.conf.init.h-this.conf.sw/2);
} else {
var ah = this.cdata.a.conf.size.h;
}
var bx = ax;
var by = ay+ah+this.conf.sw;
var bw = aw;
var bh = h-by;
}
this.cdata.a._setSize(ax, ay, aw, ah, parentIdd, noCalcCont, actionType);
this.cdata.b._setSize(bx, by, bw, bh, parentIdd, noCalcCont, actionType);
this.sep._setSize(ax, ay+ah, aw, this.conf.sw);
}
this.callEvent("_onSetSizes", []);
// public event for main instance
if (rEv && (!(this.conf.b_size.w == w && this.conf.b_size.h == h))) {
this._callMainEvent("onResizeFinish", []);
}
this.conf.b_size = {w: w, h: h};
}
this._getAvailWidth = function() {
// logic:
// 1) take width of all not-collapsed cells marked as "autosize"
// 2) if cell collapsed - try next cell
// 3) get min alaiv width
// 4) base.ofsW - minW -> allowed min
var w = [];
for (var q=0; q0?Math.min.apply(window, w):0);
return this.cont.offsetWidth-r;
}
this._getAvailHeight = function() {
var h = [];
for (var q=0; q= 0 && navigator.userAgent.indexOf("Trident") >= 0) {
this.conf.btn_left = 1;
}
this.sep = document.createElement("DIV");
this.sep.className = "dhxlayout_sep";
/*
// dev, show sep index
this.sep.innerHTML = ""+idx+"";
this.sep.style.overflow = "visible";
*/
if (window.dhx4.isIE == true) {
this.sep.onselectstart = function(){return false;};
}
this.sep.className = "dhxlayout_sep dhxlayout_sep_resize_"+this.conf.mode;
this._setSize = function(x, y, w, h) {
this.sep.style.left = x+"px";
this.sep.style.top = y+"px";
this.sep.style.width = Math.max(w,0)+"px";
this.sep.style.height = Math.max(h,0)+"px";
}
this._lockSep = function(mode) { // by fix cell size
this.conf.locked = (mode==true);
this._blockSep();
}
this._setWH = function(size) { // change default separator size
var layout = this._getLayout();
layout.conf.sw = (size == null ? layout._detectSW() : Math.max(parseInt(size)||-1, -1));
layout._getMainInst().setSizes();
layout = null;
}
this._blockSep = function() { // by expand/collapse
var k = this._getLayout();
var state = k.cdata.a.conf.collapsed||k.cdata.b.conf.collapsed||this.conf.locked;
k = null;
if (this.conf.blocked == state) return;
this.sep.className = "dhxlayout_sep"+(state?"":" dhxlayout_sep_resize_"+this.conf.mode);
this.conf.blocked = state;
}
this._beforeResize = function(e) {
if (this.conf.blocked) return;
if (this.conf.resize != null && this.conf.resize.active == true) return;
if (e.type == window.dhx4.dnd.evs.start) {
this.sep.className += " dhxlayout_sep_resize_actv";
var sx = (e.pageX||e.touches[0].pageX);
var sy = (e.pageY||e.touches[0].pageY);
} else {
if (e.button !== this.conf.btn_left) return;
var sx = e.clientX;
var sy = e.clientY;
}
if (window.dhx4.dnd.p_en == true) window.dhx4.dnd._touchOff();
var k = this._getLayout();
// resize init point
this.conf.resize = {
sx: sx,
sy: sy,
tx: e.layerX,
ty: e.layerY,
sep_x: parseInt(this.sep.style.left),
sep_y: parseInt(this.sep.style.top),
min_wa: k.cdata.a._getAvailWidth("a"),
min_wb: k.cdata.b._getAvailWidth("b"),
min_ha: k.cdata.a._getAvailHeight("a"),
min_hb: k.cdata.b._getAvailHeight("b")
}
this.conf.resize.nx = this.conf.resize.sep_x;
this.conf.resize.ny = this.conf.resize.sep_y;
if (typeof(window.addEventListener) == "function") {
window.addEventListener("mousemove", this._doOnMouseMove, false);
window.addEventListener("mouseup", this._doOnMouseUp, false);
window.addEventListener(window.dhx4.dnd.evs.move, this._doOnMouseMove, false);
window.addEventListener(window.dhx4.dnd.evs.end, this._doOnMouseUp, false);
} else {
document.body.attachEvent("onmousemove", this._doOnMouseMove);
document.body.attachEvent("onmouseup", this._doOnMouseUp);
}
k = null;
}
this._onResize = function(e) {
if (!this.conf.resize.active) {
this._initResizeArea();
this.conf.resize.active = true;
}
if (this.conf.mode == "v") {
var x = (e.type == "mousemove" ? e.clientX : (e.pageX||e.touches[0].pageX));
var ofs = this.conf.resize.sx-x;
this.conf.resize.nx = this.conf.resize.sep_x-ofs;
if (this.conf.resize.nx > this.conf.resize.sep_x+this.conf.resize.min_wb) {
this.conf.resize.nx = this.conf.resize.sep_x+this.conf.resize.min_wb;
} else if (this.conf.resize.nx < this.conf.resize.sep_x-this.conf.resize.min_wa) {
this.conf.resize.nx = this.conf.resize.sep_x-this.conf.resize.min_wa;
}
this.r_sep.style.left = this.conf.resize.nx+"px";
} else {
var y = (e.type == "mousemove" ? e.clientY : (e.pageY||e.touches[0].pageY));
var ofs = this.conf.resize.sy-y;
this.conf.resize.ny = this.conf.resize.sep_y-ofs;
if (this.conf.resize.ny > this.conf.resize.sep_y+this.conf.resize.min_hb) {
this.conf.resize.ny = this.conf.resize.sep_y+this.conf.resize.min_hb;
} else if (this.conf.resize.ny < this.conf.resize.sep_y-this.conf.resize.min_ha) {
this.conf.resize.ny = this.conf.resize.sep_y-this.conf.resize.min_ha;
}
this.r_sep.style.top = this.conf.resize.ny+"px";
}
}
this._afterResize = function(e) {
if (typeof(window.addEventListener) == "function") {
window.removeEventListener("mousemove", this._doOnMouseMove, false);
window.removeEventListener("mouseup", this._doOnMouseUp, false);
window.removeEventListener(window.dhx4.dnd.evs.move, this._doOnMouseMove, false);
window.removeEventListener(window.dhx4.dnd.evs.end, this._doOnMouseUp, false);
} else {
document.body.detachEvent("onmousemove", this._doOnMouseMove);
document.body.detachEvent("onmouseup", this._doOnMouseUp);
}
if (!this.conf.resize.active) {
this.conf.resize = null;
return;
}
if (e.type == window.dhx4.dnd.evs.end) {
this.sep.className = this.sep.className.replace(/\s{0,}dhxlayout_sep_resize_actv/gi,"");
} else {
if (e.button !== this.conf.btn_left) return;
}
var k = this._getLayout();
var mainInst = k._getMainInst();
var rCells = (mainInst.checkEvent("onPanelResizeFinish")==true?{}:false);
if (rCells !== false) {
mainInst.forEachItem(function(cell){
rCells[cell.conf.name] = {w: cell.conf.size.w, h: cell.conf.size.h};
cell = null;
});
}
var ofs_x = this.conf.resize.nx-this.conf.resize.sep_x;
var ofs_y = this.conf.resize.ny-this.conf.resize.sep_y;
k.cdata.a._setSize(k.cdata.a.conf.size.x, k.cdata.a.conf.size.y, k.cdata.a.conf.size.w+ofs_x, k.cdata.a.conf.size.h+ofs_y, "a");
k.cdata.b._setSize(k.cdata.b.conf.size.x+ofs_x, k.cdata.b.conf.size.y+ofs_y, k.cdata.b.conf.size.w-ofs_x, k.cdata.b.conf.size.h-ofs_y, "b");
this._setSize(parseInt(this.r_sep.style.left), parseInt(this.r_sep.style.top), parseInt(this.r_sep.style.width), parseInt(this.r_sep.style.height));
if (window.dhx4.isIE) {
// w/o timeout cursor not changed to normal state in IE
var p0 = this;
window.setTimeout(function(){p0._removeResizeArea();p0=null;},1);
} else {
this._removeResizeArea();
}
if (rCells !== false) {
var p = [];
mainInst.forEachItem(function(cell){
var t = rCells[cell.conf.name];
if (!(t.w == cell.conf.size.w && t.h == cell.conf.size.h)) p.push(cell.conf.name);
cell = null;
});
mainInst._callMainEvent("onPanelResizeFinish", [p]);
}
mainInst = k = null;
this.conf.resize.active = false;
this.conf.resize = null;
if (window.dhx4.dnd.p_en == true) window.dhx4.dnd._touchOn();
}
this._initResizeArea = function() {
if (this.r_sep == null) {
this.r_sep = document.createElement("DIV");
this.r_sep.className = "dhxlayout_resize_sep";
this.r_sep.style.left = this.sep.style.left;
this.r_sep.style.top = this.sep.style.top;
this.r_sep.style.width = this.sep.style.width;
this.r_sep.style.height = this.sep.style.height;
this.sep.parentNode.appendChild(this.r_sep);
if (window.dhx4.isIE) this.r_sep.onselectstart = function(){return false;};
}
if (this.r_area == null) {
this.r_area = document.createElement("DIV");
this.r_area.className = "dhxlayout_resize_area";
this.sep.parentNode.appendChild(this.r_area);
if (window.dhx4.isIE) this.r_area.onselectstart = function(){return false;};
if (this.conf.mode == "v") {
var x = parseInt(this.r_sep.style.left)-this.conf.resize.min_wa;
var y = parseInt(this.r_sep.style.top);
var w = this.conf.resize.min_wa+this.conf.resize.min_wb+parseInt(this.r_sep.style.width);
var h = parseInt(this.r_sep.style.height);
} else {
var x = parseInt(this.r_sep.style.left);
var y = parseInt(this.r_sep.style.top)-this.conf.resize.min_ha;
var w = parseInt(this.r_sep.style.width);
var h = this.conf.resize.min_ha+this.conf.resize.min_hb+parseInt(this.r_sep.style.height);
}
this.r_area.style.left = x+"px";
this.r_area.style.top = y+"px";
if (!dhtmlXLayoutObject.prototype._confGlob.reszieCover) {
dhtmlXLayoutObject.prototype._confGlob.reszieCover = {};
this.r_area.style.width = w+"px";
this.r_area.style.height = h+"px";
dhtmlXLayoutObject.prototype._confGlob.reszieCover.w = parseInt(this.r_area.style.width)-this.r_area.offsetWidth;
dhtmlXLayoutObject.prototype._confGlob.reszieCover.h = parseInt(this.r_area.style.height)-this.r_area.offsetHeight;
}
this.r_area.style.width = w+dhtmlXLayoutObject.prototype._confGlob.reszieCover.w+"px";
this.r_area.style.height = h+dhtmlXLayoutObject.prototype._confGlob.reszieCover.h+"px";
}
document.body.className += " dhxlayout_resize_"+this.conf.mode;
}
this._removeResizeArea = function() {
this.r_sep.onselectstart = null;
this.r_sep.parentNode.removeChild(this.r_sep);
this.r_sep = null;
this.r_area.onselectstart = null;
this.r_area.parentNode.removeChild(this.r_area);
this.r_area = null;
document.body.className = String(document.body.className).replace(/\s{0,}dhxlayout_resize_[vh]/gi,"");
}
this._doOnMouseDown = function(e) {
e = e||event;
if (e.preventDefault) e.preventDefault(); else e.cancelBubble = true;
that._beforeResize(e);
}
this._doOnBodyMouseDown = function(e) {
e = e||event;
if (that.conf.resize == null) return;
if (that.conf.resize.active == true && e.button !== that.conf.btn_left) {
if (e.preventDefault) e.preventDefault();
e.returnValue = false;
e.cancelBubble = true;
return false;
}
}
this._doOnMouseMove = function(e) {
e = e||event;
if (e.preventDefault) e.preventDefault(); else e.cancelBubble = true;
that._onResize(e);
}
this._doOnMouseUp = function(e) {
e = e||event;
if (e.type == "mouseup" && e.button !== that.conf.btn_left) return;
that._afterResize(e);
}
if (typeof(window.addEventListener) == "function") {
this.sep.addEventListener("mousedown", this._doOnMouseDown, false);
this.sep.addEventListener(window.dhx4.dnd.evs.start, this._doOnMouseDown, false);
document.body.addEventListener("mousedown", this._doOnBodyMouseDown, false);
document.body.addEventListener("contextmenu", this._doOnBodyMouseDown, false);
} else {
this.sep.attachEvent("onmousedown", this._doOnMouseDown);
document.body.attachEvent("onmousedown", this._doOnBodyMouseDown);
document.body.attachEvent("oncontextmenu", this._doOnBodyMouseDown);
}
this._unload = function() {
if (typeof(window.addEventListener) == "function") {
this.sep.removeEventListener("mousedown", this._doOnMouseDown, false);
this.sep.removeEventListener(window.dhx4.dnd.evs.start, this._doOnMouseDown, false);
document.body.removeEventListener("mousedown", this._doOnBodyMouseDown, false);
document.body.removeEventListener("contextmenu", this._doOnBodyMouseDown, false);
} else {
this.sep.detachEvent("onmousedown", this._doOnMouseDown);
document.body.detachEvent("onmousedown", this._doOnBodyMouseDown);
document.body.detachEvent("oncontextmenu", this._doOnBodyMouseDown);
}
if (window.dhx4.isIE == true) {
this.sep.onselectstart = null;
}
this.sep.parentNode.removeChild(this.sep);
this.sep = null;
for (var a in this) this[a] = null;
that = null;
}
return this;
};
dhtmlXLayoutObject.prototype.setSeparatorSize = function(index, size) {
if (typeof(index) == "number") {
var s = this.setSeparatorSize({index: index, current: -1}, size);
if (s.sep != null) s.sep._setWH(size);
return;
}
// seq: a->sep->b
for (var a in this.cdata) {
if (this.cdata[a].dataType == "layout" && this.cdata[a].dataNested == true && this.cdata[a].dataObj != null) {
index = this.cdata[a].dataObj.setSeparatorSize(index, size);
if (index.sep != null) return index;
}
if (a == "a" && this.sep != null) {
index.current++;
if (index.index == index.current) return {sep: this.sep};
}
}
return index;
};
window.dhtmlXLayoutCell = function(id, layout) {
dhtmlXCellObject.apply(this, [id, "_layout"]);
var that = this;
this.layout = layout;
this.conf.skin = this.layout.conf.skin;
this.conf.mode = this.layout.conf.mode;
this.conf.collapsed = false;
this.conf.fixed = {w: false, h: false}; // fix size
this.conf.docked = true;
if (this.conf.skin == "material") {
this.conf.min_width = 42;
this.conf.min_height = 26;
} else {
this.conf.min_width = 26;
this.conf.min_height = 26;
}
this.attachEvent("_onCellUnload", function(){
this.cell.childNodes[this.conf.idx.hdr].ondblclick = null; // header dblclick
if (this.conf.mode != "c") this.cell.childNodes[this.conf.idx.hdr].lastChild.onclick = null; // arrow onclick
this._unloadDocking();
this.layout = null;
that = null;
});
// init header
this._hdrInit();
this.cell.childNodes[this.conf.idx.hdr].ondblclick = function(){
var mainInst = that.layout._getMainInst();
mainInst._callMainEvent("onDblClick", [that.conf.name]);
mainInst = null;
};
// onContentLoaded
this.attachEvent("_onContentLoaded", function() {
var mainInst = this.layout._getMainInst();
mainInst._callMainEvent("onContentLoaded", [this.conf.name]);
mainInst = null;
});
// init expand/collapse
if (this.conf.mode != "c") {
var t = document.createElement("DIV");
t.title = this.i18n.expand;
t.className = "dhxlayout_arrow dhxlayout_arrow_"+this.conf.mode+this._idd;
this.cell.childNodes[this.conf.idx.hdr].appendChild(t);
t.onclick = function(e) {
if (that.conf.collapsed) that.expand(); else that.collapse();
}
t = null;
}
this.attachEvent("_onBeforeContentAttach", function(dataType) {
if (dataType == "tabbar" || dataType == "layout" || dataType == "acc") {
this._hideBorders();
}
if (dataType == "sidebar" && this.conf.skin != "dhx_skyblue" && this.conf.skin != "dhx_terrace") {
this._hideBorders();
this.showHeader();
}
});
this._initDocking();
return this;
};
dhtmlXLayoutCell.prototype = new dhtmlXCellObject();
dhtmlXLayoutCell.prototype.i18n = { expand : "Expand / Collapse" };
dhtmlXLayoutCell.prototype.getId = function() {
return this.conf.name;
};
dhtmlXLayoutCell.prototype._initDocking = function() {
var that = this;
this.dock = function() {
var mainInst = this.layout._getMainInst();
if (mainInst.dhxWins == null || this.conf.docked) {
mainInst = null;
return;
}
var w1 = mainInst.dhxWins.window(this.conf.name);
w1.close();
// move content
this._attachFromCell(w1);
this.conf.docked = true;
if (!this.conf.dock_collapsed) this.expand();
mainInst._callMainEvent("onDock",[this.conf.name]);
mainInst = w1 = null;
};
this.undock = function(x, y, w, h) {
var mainInst = this.layout._getMainInst();
if (mainInst.dhxWins == null || this.conf.docked == false) {
mainInst = null;
return;
}
this.conf.dock_collapsed = this.conf.collapsed;
if (!this.conf.collapsed) this.collapse();
if (mainInst.dhxWins.window(this.conf.name) != null) {
var w1 = mainInst.dhxWins.window(this.conf.name);
w1.show();
} else {
if (x == null) x = 20;
if (y == null) y = 20;
if (w == null) w = 320;
if (h == null) h = 200;
var w1 = mainInst.dhxWins.createWindow(this.conf.name, x, y, w, h);
w1.button("close").hide();
// dock button
w1.addUserButton("dock", 99, "Dock");
w1.button("dock").show();
w1.button("dock").attachEvent("onClick", this._doOnDockClick);
// text update only first time
w1.setText(this.getText());
// closeing
w1.attachEvent("onClose", this._doOnDockWinClose);
}
this.conf.docked = false;
// move content
w1._attachFromCell(this);
mainInst._callMainEvent("onUnDock",[this.conf.name]);
mainInst = w1 = null;
}
this._doOnDockClick = function() {
that.dock();
}
this._doOnDockWinClose = function(win) {
win.hide();
return false;
}
this._unloadDocking = function() {
that = null;
}
};
dhtmlXLayoutCell.prototype._hdrInit = function() {
var cssExt = "";
if (window.dhx4.isIE) {
if (navigator.userAgent.indexOf("MSIE 9.0") != -1) {
cssExt = " dhx_cell_hdr_text_ie9";
} else if (window.dhx4.isIE8) {
cssExt = " dhx_cell_hdr_text_ie8";
} else if (window.dhx4.isIE7) {
cssExt = " dhx_cell_hdr_text_ie7";
} else if (window.dhx4.isIE6) {
cssExt = " dhx_cell_hdr_text_ie6";
}
} else if (window.dhx4.isChrome || window.dhx4.isKHTML) {
cssExt = " dhx_cell_hdr_text_chrome";
}
var t = document.createElement("DIV");
t.className = "dhx_cell_hdr";
t.innerHTML = "";
this.cell.insertBefore(t, this.cell.childNodes[this.conf.idx.cont]);
t = null;
// include into content top offset calculation
this.conf.ofs_nodes.t._getHdrHeight = "func";
// show/hide
this.conf.hdr = {visible: true};
// include into index
this.conf.idx_data.hdr = "dhx_cell_hdr";
this._updateIdx();
// fit header when cell changed
this.attachEvent("_onSetSize", this._hdrOnSetSize);
this.attachEvent("_onBorderChange", this._hdrOnBorderChange);
// keep visibility state of header if view changed
this.attachEvent("_onViewSave", this._hdrOnViewSave);
this.attachEvent("_onViewRestore", this._hdrOnViewRestore);
};
dhtmlXLayoutCell.prototype.showHeader = function(noCalcCont) {
if (this.conf.hdr.visible || this.conf.collapsed) return;
if (this.conf.hdr.w_saved > this._getAvailWidth() || this.conf.hdr.h_saved > this._getAvailHeight()) {
// console.log("no space to show header");
return;
}
this.conf.hdr.w_saved = this.conf.hdr.h_saved = null;
this.conf.hdr.visible = true;
this.cell.childNodes[this.conf.idx.hdr].className = "dhx_cell_hdr";
if (noCalcCont !== true) this._adjustCont(this._idd);
};
dhtmlXLayoutCell.prototype.hideHeader = function(noCalcCont) {
if (!this.conf.hdr.visible || this.conf.collapsed) return;
this.conf.hdr.w_saved = this._getMinWidth(this._idd);
this.conf.hdr.h_saved = this._getMinHeight(this._idd);
this.conf.hdr.visible = false;
this.cell.childNodes[this.conf.idx.hdr].className = "dhx_cell_hdr dhx_cell_hdr_hidden";
this._hdrUpdBorder();
this._mtbUpdBorder();
if (noCalcCont !== true) this._adjustCont(this._idd);
};
dhtmlXLayoutCell.prototype.isHeaderVisible = function() {
return (this.conf.hdr.visible==true);
};
// arrow
dhtmlXLayoutCell.prototype.showArrow = function() {
this.cell.childNodes[this.conf.idx.hdr].childNodes[1].style.display = "";
};
dhtmlXLayoutCell.prototype.hideArrow = function() {
this.cell.childNodes[this.conf.idx.hdr].childNodes[1].style.display = "none";
};
dhtmlXLayoutCell.prototype.isArrowVisible = function() {
return (this.cell.childNodes[this.conf.idx.hdr].childNodes[1].style.display == "");
};
// text
dhtmlXLayoutCell.prototype.setText = function(text) {
this.conf.hdr.text = text;
this._hdrUpdText();
};
dhtmlXLayoutCell.prototype.getText = function() {
return this.conf.hdr.text;
};
dhtmlXLayoutCell.prototype.setCollapsedText = function(text) {
this.conf.hdr.text_collapsed = text;
this._hdrUpdText();
};
dhtmlXLayoutCell.prototype.getCollapsedText = function() {
return (this.conf.hdr.text_collapsed != null ? this.conf.hdr.text_collapsed : this.conf.hdr.text );
};
dhtmlXLayoutCell.prototype._hdrUpdText = function() {
var text = (this.conf.collapsed == true && this.conf.hdr.text_collapsed != null ? this.conf.hdr.text_collapsed : this.conf.hdr.text);
this.cell.childNodes[this.conf.idx.hdr].firstChild.innerHTML = ""+text+"";
};
dhtmlXLayoutCell.prototype._hdrUpdBorder = function() {
if (this.conf.borders == true) {
this.cell.childNodes[this.conf.idx.hdr].className = "dhx_cell_hdr"+(this.conf.hdr.visible?"":" dhx_cell_hdr_hidden");
} else {
if (!this.conf.hdr.visible) {
this.cell.childNodes[this.conf.idx.hdr].className = "dhx_cell_hdr dhx_cell_hdr_hidden_no_borders";
}
}
};
dhtmlXLayoutCell.prototype._hdrOnSetSize = function() {
if (this.conf.collapsed && this.conf.mode == "v") this._fitHdr();
};
dhtmlXLayoutCell.prototype._hdrOnBorderChange = function() {
this.hideHeader(true);
this._hdrUpdBorder();
};
dhtmlXLayoutCell.prototype._hdrOnViewSave = function(name) {
this.views[name].hdr_vis = this.conf.hdr.visible;
};
dhtmlXLayoutCell.prototype._hdrOnViewRestore = function(name){
if (this.conf.hdr.visible != this.views[name].hdr_vis) {
this[this.views[name].hdr_vis?"showHeader":"hideHeader"](true);
}
this.views[name].hdr_vis = null;
delete this.views[name].hdr_vis;
};
dhtmlXLayoutCell.prototype._getHdrHeight = function(incColl) {
if (this.conf.collapsed && this.conf.mode == "v" && incColl !== true) {
// collapsed vertical cell, move to conf?
// offsetHeight returns full cell height, needed only for adjusting bottom border
return 27;
}
return this.cell.childNodes[this.conf.idx.hdr].offsetHeight;
};
dhtmlXLayoutCell.prototype._fitHdr = function() {
var h = this.cell.childNodes[this.conf.idx.hdr];
if (this.conf.collapsed == true) {
if (typeof(dhtmlXLayoutObject.prototype._confGlob.hdrColH) == "undefined") {
h.style.height = this.cell.offsetHeight+"px";
dhtmlXLayoutObject.prototype._confGlob.hdrColH = parseInt(h.style.height)-this._getHdrHeight(true);
}
var size = this.cell.offsetHeight+dhtmlXLayoutObject.prototype._confGlob.hdrColH;
h.style.height = size+"px";
h.firstChild.style.width = size-39+"px";
} else {
h.firstChild.style.width = h.style.height = null;
}
h = null;
};
/* expand */
dhtmlXLayoutCell.prototype.expand = function(autoExpand) {
if (!this.conf.collapsed) return true;
var k = this.layout;
if (this.conf.mode == "v") {
var w_nextCell = (autoExpand ? k.conf.hh : k.cdata[k.conf.nextCell[this._idd]]._getMinWidth(this._idd));
var w_avl = k.cont.offsetWidth-k.conf.sw;
if (w_nextCell + this.conf.size.w_avl > w_avl) {
k = null;
return false;
}
} else {
// if autoExpand - next cell coing to be collapsed, move value to conf?
// min heigth of next cell = min_height+hdr_height
var h_nextCell = (autoExpand ? k.conf.hh : k.cdata[k.conf.nextCell[this._idd]]._getMinHeight(this._idd)+k.cdata[k.conf.nextCell[this._idd]]._getHdrHeight());
var h_avl = k.cont.offsetHeight-k.conf.sw; // avail height for both cells = base_h-sep_h
if (h_nextCell + this.conf.size.h_avl > h_avl) {
// new logic, menu/tb attached
k = null;
return false;
}
}
if (this.conf.docked == false) {
this.dock();
return;
}
// hide header if it was temporary restored while cell collapsed
if (this.conf.hdr.visible == false) {
this.cell.childNodes[this.conf.idx.hdr].className = "dhx_cell_hdr dhx_cell_hdr_hidden";
this._hdrUpdBorder();
}
this.cell.className = String(this.cell.className).replace(/\s{0,}dhxlayout_collapsed_[hv]/gi, "");
this.conf.collapsed = false;
if (this.conf.mode == "v") {
this.conf.size.w = Math.min(w_avl-w_nextCell, this.conf.size.w_saved);
this.conf.size.w_saved = this.conf.size.w_avl = null;
} else {
this.conf.size.h = Math.min(h_avl-h_nextCell, this.conf.size.h_saved);
this.conf.size.h_saved = this.conf.size.h_avl = null;
}
if (this.conf.mode == "v") this._fitHdr();
k.setSizes(k.conf.nextCell[this._idd], k.conf.nextCell[this._idd], autoExpand==true, "expand");
k.sep._blockSep();
k = null;
this._hdrUpdText();
var mainInst = this.layout._getMainInst();
mainInst._callMainEvent("onExpand", [this.conf.name]);
mainInst = null;
return true;
};
/* collapse */
dhtmlXLayoutCell.prototype.collapse = function() {
if (this.conf.collapsed) return false;
var k = this.layout;
if (k.cdata[k.conf.nextCell[this._idd]].expand(true) == false) return false; // no space to expand next cell if it collapsed
if (this.conf.mode == "v") {
this.conf.size.w_saved = this.conf.size.w;
this.conf.size.w_avl = this._getMinWidth(this._idd); // save min width
} else {
this.conf.size.h_saved = this.conf.size.h;
this.conf.size.h_avl = this._getMinHeight(this._idd)+this._getHdrHeight(); // save min height
}
// restore header temporary while cell collapsed
if (this.conf.hdr.visible == false) {
this.cell.childNodes[this.conf.idx.hdr].className = "dhx_cell_hdr";
}
this.cell.className += " dhxlayout_collapsed_"+this.conf.mode;
this.conf.collapsed = true;
if (this.conf.mode == "v") {
this.conf.size.w = k.conf.hh; // move to conf?
} else {
this.conf.size.h = this._getHdrHeight();
}
k.setSizes(k.conf.nextCell[this._idd], k.conf.nextCell[this._idd], false, "collapse");
k.sep._blockSep();
k = null;
this._hdrUpdText();
var mainInst = this.layout._getMainInst();
mainInst._callMainEvent("onCollapse", [this.conf.name]);
mainInst = null;
return true;
};
dhtmlXLayoutCell.prototype.isCollapsed = function() {
return (this.conf.collapsed==true);
};
// cell sizing
dhtmlXLayoutCell.prototype.setMinWidth = function(w) { // added in 4.1.3
this.conf.min_width = parseInt(w)||0;
};
dhtmlXLayoutCell.prototype.setMinHeight = function(h) { // added in 4.1.3
this.conf.min_height = parseInt(h)||0;
};
dhtmlXLayoutCell.prototype._getMinWidth = function(parentIdd) {
// min space should allow to collapse ?
if (this.dataType == "layout" && this.dataObj != null) {
if (this.layout._getMainInst() != this.dataObj._getMainInst()) {
return this.dataObj._getAvailWidth();
}
if (this.dataObj.conf.pattern == "1C") {
return Math.max(this.conf.min_width, this.dataObj.cdata.a._getMinWidth(parentIdd));
} else if (this.dataObj.conf.mode == "v") {
var c1 = parentIdd||this._idd; // "views" fix for layout-in-layout
if (this.dataObj.cdata[c1].conf.collapsed) c1 = this.dataObj.conf.nextCell[c1];
return Math.max(this.conf.min_width, this.dataObj.cdata[c1]._getMinWidth(parentIdd)+this.dataObj.cdata[this.dataObj.conf.nextCell[c1]]._getWidth()+this.dataObj.conf.sw); // c1 min width + c2 full width + sw
} else {
return Math.max(this.conf.min_width, this.dataObj.cdata.a._getMinWidth(parentIdd), this.dataObj.cdata.b._getMinWidth(parentIdd));
}
}
return Math.max(this.conf.min_width, 1);
};
dhtmlXLayoutCell.prototype._getMinHeight = function(parentIdd) {
var h = 0;
if (this.conf.idx.menu != null) h += this.cell.childNodes[this.conf.idx.menu].offsetHeight;
if (this.dataType == "layout" && this.dataObj != null) {
if (this.layout._getMainInst() != this.dataObj._getMainInst()) {
return this.dataObj._getAvailHeight();
}
if (this.dataObj.conf.pattern == "1C") {
return Math.max(this.conf.min_height, this.dataObj.cdata.a._getMinHeight(parentIdd));
} else if (this.dataObj.conf.mode == "h") {
var c1 = parentIdd;
if (this.dataObj.cdata[c1].conf.collapsed) c1 = this.dataObj.conf.nextCell[c1];
return Math.max(this.conf.min_height, this.dataObj.cdata[c1]._getMinHeight(parentIdd)+this.dataObj.cdata[c1]._getHdrHeight()+this.dataObj.cdata[this.dataObj.conf.nextCell[c1]]._getHeight()+this.dataObj.conf.sw); // c1 min height + c1 hdr height + c2 full height + sw
} else {
return Math.max(this.conf.min_height, this.dataObj.cdata.a._getMinHeight(parentIdd)+this.dataObj.cdata.a._getHdrHeight(), this.dataObj.cdata.b._getMinHeight(parentIdd)+this.dataObj.cdata.b._getHdrHeight());
}
}
return Math.max(this.conf.min_height, h);
};
dhtmlXLayoutCell.prototype._getAvailWidth = function(parentIdd) {
if (this.dataType == "layout" && this.dataObj != null) {
if (this.dataObj.conf.pattern == "1C") {
return this.dataObj.cdata.a._getAvailWidth(parentIdd);
} else if (this.dataObj.conf.mode == "v") {
var ac = (this.dataObj.cdata.a.conf.collapsed == true);
var bc = (this.dataObj.cdata.b.conf.collapsed == true);
if (parentIdd == "a") {
return this.dataObj.cdata[bc?"a":"b"]._getAvailWidth(parentIdd);
} else {
return this.dataObj.cdata[ac?"b":"a"]._getAvailWidth(parentIdd);
}
} else {
return Math.min(this.dataObj.cdata.a._getAvailWidth(parentIdd), this.dataObj.cdata.b._getAvailWidth(parentIdd));
}
}
return this.cell.offsetWidth-this._getMinWidth();
};
dhtmlXLayoutCell.prototype._getAvailHeight = function(parentIdd) {
if (this.dataType == "layout" && this.dataObj != null) {
if (this.dataObj.conf.pattern == "1C") {
return this.dataObj.cdata.a._getAvailHeight(parentIdd);
} else if (this.dataObj.conf.mode == "h") {
var ac = (this.dataObj.cdata.a.conf.collapsed == true);
var bc = (this.dataObj.cdata.b.conf.collapsed == true);
if (parentIdd == "a") {
return this.dataObj.cdata[bc?"a":"b"]._getAvailHeight(parentIdd);
} else {
return this.dataObj.cdata[ac?"b":"a"]._getAvailHeight(parentIdd);
}
} else {
return Math.min(this.dataObj.cdata.a._getAvailHeight(parentIdd), this.dataObj.cdata.b._getAvailHeight(parentIdd));
}
}
var hh = this._getHdrHeight();
if (this.conf.mode == "v" && this.conf.collapsed) hh = this.conf.hh; // not include header if v-cell is collapsed
return this.cell.offsetHeight-hh-this._getMinHeight();
};
dhtmlXLayoutCell.prototype.setWidth = function(w) {
if (this.conf.mode == "v") {
if (this.conf.collapsed) return;
var k = this.layout;
var nextCell = k.cdata[k.conf.nextCell[this._idd]];
if (nextCell.conf.collapsed) {
// try to change parent cell
w = w + k.conf.sw + nextCell._getWidth(); // increase width including nextCell and sw
/*
var p = this.layout._getMainInst();
if (p != this.layout) {
for (var a in p.cdata) if (p.cdata[a].dataObj == k) p.cdata[a].setWidth(w);
}
*/
p = k = nextCell = null;
return;
}
var minW = this._getMinWidth(this._idd);
var maxW = k.cont.offsetWidth-nextCell._getMinWidth(this._idd)-k.conf.sw;
w = Math.max(minW, Math.min(w, maxW));
this.conf.size.w = w;
k.setSizes(nextCell._idd, nextCell._idd);
k = nextCell = null;
} else {
// check parent's width
if (this.layout == null || this.layout.parentLayout == null) return;
var p = this.layout.parentLayout;
var k = this.layout;
var nextCell = k.cdata[k.conf.nextCell[this._idd]];
for (var a in p.cdata) if (p.cdata[a].dataObj == k) p.cdata[a].setWidth(w);
p = k = null;
}
};
dhtmlXLayoutCell.prototype.setHeight = function(h) {
if (this.conf.mode == "h") {
if (this.conf.collapsed) return;
var k = this.layout;
var nextCell = k.cdata[k.conf.nextCell[this._idd]];
if (nextCell.conf.collapsed) {
// try to change parent cell
h = h + k.conf.sw + nextCell._getHeight(); // increase with including nextCell and sw, header=cell_height due it collapsed
var p = (this.layout != null && this.layout.parentLayout != null ? this.layout.parentLayout : null);
if (p != null) {
for (var a in p.cdata) if (p.cdata[a].dataObj == k) p.cdata[a].setHeight(h);
}
p = k = nextCell = null;
return;
}
var minH = this._getMinHeight(this._idd)+this._getHdrHeight();
var maxH = k.cont.offsetHeight-nextCell._getMinHeight(this._idd)-nextCell._getHdrHeight()-k.conf.sw;
h = Math.max(minH, Math.min(h, maxH));
this.conf.size.h = h;
k.setSizes(nextCell._idd, nextCell._idd);
k = nextCell = null;
} else {
// check parent's height
if (this.layout == null || this.layout.parentLayout == null) return;
var p = this.layout.parentLayout;
var k = this.layout;
var nextCell = k.cdata[k.conf.nextCell[this._idd]];
for (var a in p.cdata) if (p.cdata[a].dataObj == k) p.cdata[a].setHeight(h);
p = k = null;
}
};
dhtmlXLayoutCell.prototype.getWidth = function() {
return this.conf.size.w;
};
dhtmlXLayoutCell.prototype.getHeight = function() {
return this.conf.size.h;
};
dhtmlXLayoutCell.prototype.fixSize = function(w, h) {
this.conf.fixed.w = window.dhx4.s2b(w);
this.conf.fixed.h = window.dhx4.s2b(h);
var mainInst = this.layout._getMainInst();
var s = {};
mainInst.forEachItem(function(cell){
if (cell.conf.fsize != null) {
var id = cell.getId();
var p = {
h: (cell.conf.fixed.w==true),
v: (cell.conf.fixed.h==true)
};
for (var a in p) {
if (p[a] == true && cell.conf.fsize[a] != null) {
if (!(cell.conf.fsize[a] instanceof Array)) cell.conf.fsize[a] = [cell.conf.fsize[a]];
for (var q=0; q