|
|
@ -11,7 +11,8 @@ var DateUtil = require('../DateUtil'); |
|
|
|
*/ |
|
|
|
function Group (groupId, data, itemSet) { |
|
|
|
this.groupId = groupId; |
|
|
|
|
|
|
|
this.subgroups = {}; |
|
|
|
this.visibleSubgroups = 0; |
|
|
|
this.itemSet = itemSet; |
|
|
|
|
|
|
|
this.dom = {}; |
|
|
@ -64,7 +65,7 @@ Group.prototype._create = function() { |
|
|
|
// to the DOM, or the style of a parent of the Timeline is changed from
|
|
|
|
// display:none is changed to visible.
|
|
|
|
this.dom.marker = document.createElement('div'); |
|
|
|
this.dom.marker.style.visibility = 'hidden'; |
|
|
|
this.dom.marker.style.visibility = 'hidden'; // TODO: ask jos why this is not none?
|
|
|
|
this.dom.marker.innerHTML = '?'; |
|
|
|
this.dom.background.appendChild(this.dom.marker); |
|
|
|
}; |
|
|
@ -163,18 +164,28 @@ Group.prototype.redraw = function(range, margin, restack) { |
|
|
|
stack.stack(this.visibleItems, margin, restack); |
|
|
|
} |
|
|
|
else { // no stacking
|
|
|
|
stack.nostack(this.visibleItems, margin); |
|
|
|
stack.nostack(this.visibleItems, margin, this.subgroups); |
|
|
|
} |
|
|
|
|
|
|
|
// recalculate the height of the group
|
|
|
|
var height; |
|
|
|
var visibleItems = this.visibleItems; |
|
|
|
var visibleSubgroups = []; |
|
|
|
this.visibleSubgroups = 0; |
|
|
|
var me = this; |
|
|
|
if (visibleItems.length) { |
|
|
|
var min = visibleItems[0].top; |
|
|
|
var max = visibleItems[0].top + visibleItems[0].height; |
|
|
|
util.forEach(visibleItems, function (item) { |
|
|
|
min = Math.min(min, item.top); |
|
|
|
max = Math.max(max, (item.top + item.height)); |
|
|
|
if (item.data.subgroup !== undefined) { |
|
|
|
me.subgroups[item.data.subgroup].height = Math.max(me.subgroups[item.data.subgroup].height,item.height); |
|
|
|
if (visibleSubgroups.indexOf(item.data.subgroup) == -1){ |
|
|
|
visibleSubgroups.push(item.data.subgroup); |
|
|
|
me.visibleSubgroups += 1; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
if (min > margin.axis) { |
|
|
|
// there is an empty gap between the lowest item and the axis
|
|
|
@ -210,7 +221,7 @@ Group.prototype.redraw = function(range, margin, restack) { |
|
|
|
// update vertical position of items after they are re-stacked and the height of the group is calculated
|
|
|
|
for (var i = 0, ii = this.visibleItems.length; i < ii; i++) { |
|
|
|
var item = this.visibleItems[i]; |
|
|
|
item.repositionY(); |
|
|
|
item.repositionY(margin); |
|
|
|
} |
|
|
|
|
|
|
|
return resized; |
|
|
@ -270,6 +281,13 @@ Group.prototype.add = function(item) { |
|
|
|
this.items[item.id] = item; |
|
|
|
item.setParent(this); |
|
|
|
|
|
|
|
// add to
|
|
|
|
if (item.data.subgroup !== undefined) { |
|
|
|
if (this.subgroups[item.data.subgroup] === undefined) { |
|
|
|
this.subgroups[item.data.subgroup] = {height:0}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (this.visibleItems.indexOf(item) == -1) { |
|
|
|
var range = this.itemSet.body.range; // TODO: not nice accessing the range like this
|
|
|
|
this._checkIfVisible(item, this.visibleItems, range); |
|
|
@ -396,7 +414,6 @@ Group.prototype._updateVisibleItems = function(orderedItems, visibleItems, range |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
Group.prototype._checkIfInvisible = function(item, visibleItems, range) { |
|
|
|
//if (DateUtil.isHidden(item.data.start,this.itemSet.body.hiddenDates).hidden == false) {
|
|
|
|
if (item.isVisible(range)) { |
|
|
|
if (!item.displayed) item.show(); |
|
|
|
item.repositionX(); |
|
|
@ -409,16 +426,6 @@ Group.prototype._checkIfInvisible = function(item, visibleItems, range) { |
|
|
|
if (item.displayed) item.hide(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
//}
|
|
|
|
//else {
|
|
|
|
// if (item.isVisible(range)) {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// if (item.displayed) item.hide();
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
@ -433,7 +440,6 @@ Group.prototype._checkIfInvisible = function(item, visibleItems, range) { |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
Group.prototype._checkIfVisible = function(item, visibleItems, range) { |
|
|
|
//if (DateUtil.isHidden(item.data.start,this.itemSet.body.hiddenDates).hidden == false) {
|
|
|
|
if (item.isVisible(range)) { |
|
|
|
if (!item.displayed) item.show(); |
|
|
|
// reposition item horizontally
|
|
|
@ -443,12 +449,6 @@ Group.prototype._checkIfVisible = function(item, visibleItems, range) { |
|
|
|
else { |
|
|
|
if (item.displayed) item.hide(); |
|
|
|
} |
|
|
|
//}
|
|
|
|
//else {
|
|
|
|
// if (!item.isVisible(range)) {
|
|
|
|
// if (item.displayed) item.hide();
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
}; |
|
|
|
|
|
|
|
module.exports = Group; |