Fix DB creation, fix treegrid header resize, implement payment viewing and editing

rel-1.0
Vitaliy Filippov 2016-04-13 15:51:34 +03:00
parent c744294335
commit 1bc8a8a13d
2 changed files with 37 additions and 35 deletions

View File

@ -1,7 +1,7 @@
/**
* Very simple and fast tree grid/table, compatible with dynamic loading and jQuery fixedHeaderTable
* License: MPL 2.0+, (c) Vitaliy Filippov 2016+
* Version: 2016-04-04
* Version: 2016-04-13
*/
/**
@ -192,6 +192,21 @@ TreeGrid.prototype.initCellSelection = function(restrictToNode)
var self = this;
self.selectCell = function(cell)
{
if (!cell.parentNode._node || cell.className.indexOf(' selected') >= 0)
return;
var i = self.getNodeIndex(cell);
if (!self.onCellSelect || self.onCellSelect(cell.parentNode._node, i, cell))
cell.className += ' selected';
};
self.deselectCell = function(cell)
{
self.onCellDeselect && self.onCellDeselect(cell.parentNode._node, self.getNodeIndex(cell), cell);
cell.className = cell.className.replace(' selected', '');
};
addListener(restrictToNode || document.body, 'mousedown', function(evt)
{
evt = getEventCoord(evt);
@ -199,10 +214,7 @@ TreeGrid.prototype.initCellSelection = function(restrictToNode)
{
var els = self.table.querySelectorAll('td.selected');
for (var i = 0; i < els.length; i++)
{
self.onCellDeselect && self.onCellDeselect(els[i].parentNode._node, self.getNodeIndex(els[i]), els[i]);
els[i].className = els[i].className.replace(' selected', '');
}
self.deselectCell(els[i]);
}
if (evt.which != 1)
return;
@ -272,20 +284,12 @@ TreeGrid.prototype.initCellSelection = function(restrictToNode)
y1 = t;
}
startDrag = null;
function doSelect()
{
if (!this.parentNode._node)
return;
var i = self.getNodeIndex(this);
if (!self.onCellSelect || self.onCellSelect(this.parentNode._node, i, this))
this.className += ' selected';
}
if (x2 > x1+10 && y2 > y1+10)
rectangleSelect(self.table.getElementsByTagName('td'), x1, y1, x2, y2, doSelect);
rectangleSelect(self.table.getElementsByTagName('td'), x1, y1, x2, y2, self.selectCell);
else
{
var t = evt.target || evt.srcElement;
doSelect.apply(t);
self.selectCell(t);
}
if (x2 > x1+10 && y2 > y1+10 || evt.shiftKey)
{
@ -305,7 +309,7 @@ TreeGrid.prototype.initCellSelection = function(restrictToNode)
var w = elements[i].offsetWidth;
var h = elements[i].offsetHeight;
if (offset.left+w >= x1 && offset.top+h >= y1 && offset.left <= x2 && offset.top <= y2)
cb.apply(elements[i]);
cb(elements[i]);
}
}
}

36
util.js
View File

@ -153,21 +153,22 @@ var setCallback = function(r, cb)
}
};
};
window.http_build_query = function(data)
var build_array_query = function(data, prefix)
{
var encoded = '';
var s = '', k;
for (var i in data)
{
k = prefix ? prefix+'['+encodeURIComponent(i)+']' : encodeURIComponent(i);
if (typeof data[i] == 'object')
{
var ii = encodeURIComponent(i);
for (var k in data[i])
encoded = encoded+'&'+ii+'['+encodeURIComponent(k)+']='+(data[i][k] === false || data[i] === null ? '' : encodeURIComponent(data[i][k]));
}
s += build_array_query(data[i], k);
else
encoded = encoded+'&'+encodeURIComponent(i)+'='+(data[i] === false || data[i] === null ? '' : encodeURIComponent(data[i]));
s = s+'&'+k+'='+(data[i] === false || data[i] === null ? '' : encodeURIComponent(data[i]));
}
return encoded.substr(1);
return s;
};
window.http_build_query = function(data)
{
return build_array_query(data).substr(1);
};
window.GET = function(url, data, cb)
@ -197,19 +198,13 @@ window.cloneObject = function(o)
{
if (!o || 'object' !== typeof o)
return o;
var c = 'function' === typeof o.pop ? [] : {};
if (o instanceof Date)
return new Date(+o);
var c = o instanceof Array ? [] : {};
var p, v;
for (p in o)
{
if (o.hasOwnProperty(p))
{
v = o[p];
if(v && 'object' === typeof v)
c[p] = cloneObject(v);
else
c[p] = v;
}
}
c[p] = cloneObject(o[p]);
return c;
}
@ -350,3 +345,6 @@ window.addCSS = function(css)
s.innerHTML = css;
document.getElementsByTagName('head')[0].appendChild(s);
};
window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;