function Header(props) {
_classCallCheck(this, Header);
var _this = _possibleConstructorReturn(this, (Header.__proto__ || Object.getPrototypeOf(Header)).call(this, props));
_this.periodClick = function (e) {
var _e$target$dataset = e.target.dataset,
time = _e$target$dataset.time,
unit = _e$target$dataset.unit;
if (time && unit) {
_this.props.showPeriod((0, _moment2.default)(time - 0), unit);
}
};
_this.touchStart = function (e) {
if (e.touches.length === 1) {
_this.setState({
touchTarget: e.target || e.touchTarget,
touchActive: true
});
}
};
_this.touchEnd = function (e) {
if (!_this.state.touchActive) {
return _this.resetTouchState();
}
var changedTouches = e.changedTouches[0];
if (changedTouches) {
var elem = document.elementFromPoint(changedTouches.pageX, changedTouches.pageY);
if (elem !== _this.state.touchTarget) {
return _this.resetTouchState();
}
}
_this.resetTouchState();
_this.periodClick(e);
};
_this.state = {
scrollTop: 0,
componentTop: 0,
touchTarget: null,
touchActive: false
};
return _this;
}n/a
function HorizontalLines() {
_classCallCheck(this, HorizontalLines);
return _possibleConstructorReturn(this, (HorizontalLines.__proto__ || Object.getPrototypeOf(HorizontalLines)).apply(this, arguments
));
}n/a
function InfoLabel() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, InfoLabel);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = InfoLabel.__proto__ || Object.getPrototypeOf(InfoLabel
)).call.apply(_ref, [this].concat(args))), _this), _this.shouldComponentUpdate = _function2.default, _temp), _possibleConstructorReturn
(_this, _ret);
}n/a
function Item(props) {
_classCallCheck(this, Item);
var _this = _possibleConstructorReturn(this, (Item.__proto__ || Object.getPrototypeOf(Item)).call(this, props));
_this.onMouseDown = function (e) {
if (!_this.state.interactMounted) {
e.preventDefault();
_this.startedClicking = true;
}
};
_this.onMouseUp = function (e) {
if (!_this.state.interactMounted && _this.startedClicking) {
_this.startedClicking = false;
_this.actualClick(e, 'click');
}
};
_this.onTouchStart = function (e) {
if (!_this.state.interactMounted) {
e.preventDefault();
_this.startedTouching = true;
}
};
_this.onTouchEnd = function (e) {
if (!_this.state.interactMounted && _this.startedTouching) {
_this.startedTouching = false;
_this.actualClick(e, 'touch');
}
};
_this.handleDoubleClick = function (e) {
e.preventDefault();
e.stopPropagation();
if (_this.props.onItemDoubleClick) {
_this.props.onItemDoubleClick(_this.itemId, e);
}
};
_this.handleContextMenu = function (e) {
if (_this.props.onContextMenu) {
e.preventDefault();
e.stopPropagation();
_this.props.onContextMenu(_this.itemId, e);
}
};
_this.cacheDataFromProps(props);
_this.state = {
interactMounted: false,
dragging: null,
dragStart: null,
preDragPosition: null,
dragTime: null,
dragGroupDelta: null,
resizing: null,
resizeEdge: null,
resizeStart: null,
resizeTime: null
};
return _this;
}n/a
function ItemGroup() {
_classCallCheck(this, ItemGroup);
return _possibleConstructorReturn(this, (ItemGroup.__proto__ || Object.getPrototypeOf(ItemGroup)).apply(this, arguments));
}n/a
function Items() {
_classCallCheck(this, Items);
return _possibleConstructorReturn(this, (Items.__proto__ || Object.getPrototypeOf(Items)).apply(this, arguments));
}n/a
function Sidebar(props) {
_classCallCheck(this, Sidebar);
var _this = _possibleConstructorReturn(this, (Sidebar.__proto__ || Object.getPrototypeOf(Sidebar)).call(this, props));
_this.state = {
scrollTop: 0,
componentTop: 0
};
return _this;
}n/a
function TodayLine() {
_classCallCheck(this, TodayLine);
return _possibleConstructorReturn(this, (TodayLine.__proto__ || Object.getPrototypeOf(TodayLine)).apply(this, arguments));
}n/a
function VerticalLines() {
_classCallCheck(this, VerticalLines);
return _possibleConstructorReturn(this, (VerticalLines.__proto__ || Object.getPrototypeOf(VerticalLines)).apply(this, arguments
));
}n/a
function _get(object, key) {
return typeof object.get === 'function' ? object.get(key) : object[key];
}n/a
function _length(object) {
return typeof object.count === 'function' ? object.count() : object.length;
}n/a
function arraysEqual(array1, array2) {
return _length(array1) === _length(array2) && array1.every(function (element, index) {
return element === _get(array2, index);
});
}n/a
function calculateDimensions(_ref) {
var item = _ref.item,
order = _ref.order,
keys = _ref.keys,
canvasTimeStart = _ref.canvasTimeStart,
canvasTimeEnd = _ref.canvasTimeEnd,
canvasWidth = _ref.canvasWidth,
dragSnap = _ref.dragSnap,
lineHeight = _ref.lineHeight,
draggingItem = _ref.draggingItem,
dragTime = _ref.dragTime,
resizingItem = _ref.resizingItem,
resizingEdge = _ref.resizingEdge,
resizeTime = _ref.resizeTime,
newGroupOrder = _ref.newGroupOrder,
itemHeightRatio = _ref.itemHeightRatio,
fullUpdate = _ref.fullUpdate,
visibleTimeStart = _ref.visibleTimeStart,
visibleTimeEnd = _ref.visibleTimeEnd;
var itemId = _get(item, keys.itemIdKey);
var itemTimeStart = _get(item, keys.itemTimeStartKey);
var itemTimeEnd = _get(item, keys.itemTimeEndKey);
var isDragging = itemId === draggingItem;
var isResizing = itemId === resizingItem;
var itemStart = isResizing && resizingEdge === 'left' ? resizeTime : itemTimeStart;
var itemEnd = isResizing && resizingEdge === 'right' ? resizeTime : itemTimeEnd;
var x = isDragging ? dragTime : itemStart;
var w = Math.max(itemEnd - itemStart, dragSnap);
var collisionX = itemStart;
var collisionW = w;
if (isDragging) {
if (itemTimeStart >= dragTime) {
collisionX = dragTime;
collisionW = Math.max(itemTimeEnd - dragTime, dragSnap);
} else {
collisionW = Math.max(dragTime - itemTimeStart + w, dragSnap);
}
}
var clippedLeft = false;
var clippedRight = false;
if (fullUpdate) {
if (!isDragging && (visibleTimeStart > x + w || visibleTimeEnd < x)) {
return null;
}
if (visibleTimeStart > x) {
w -= visibleTimeStart - x;
x = visibleTimeStart;
if (isDragging && w < 0) {
x += w;
w = 0;
}
clippedLeft = true;
}
if (x + w > visibleTimeEnd) {
w -= x + w - visibleTimeEnd;
clippedRight = true;
}
}
var ratio = 1 / coordinateToTimeRatio(canvasTimeStart, canvasTimeEnd, canvasWidth);
var h = lineHeight * itemHeightRatio;
var dimensions = {
left: (x - canvasTimeStart) * ratio,
top: null,
width: Math.max(w * ratio, 3),
height: h,
order: isDragging ? newGroupOrder : order,
stack: true,
collisionLeft: collisionX,
originalLeft: itemTimeStart,
collisionWidth: collisionW,
lineHeight: lineHeight,
isDragging: isDragging,
clippedLeft: clippedLeft,
clippedRight: clippedRight
};
return dimensions;
}n/a
function collision(a, b, lineHeight) {
// var verticalMargin = (lineHeight - a.height)/2;
var verticalMargin = 0;
return a.collisionLeft + EPSILON < b.collisionLeft + b.collisionWidth && a.collisionLeft + a.collisionWidth - EPSILON > b.collisionLeft
&& a.top - verticalMargin + EPSILON < b.top + b.height && a.top + a.height + verticalMargin - EPSILON > b.top;
}n/a
function coordinateToTimeRatio(canvasTimeStart, canvasTimeEnd, canvasWidth) {
return (canvasTimeEnd - canvasTimeStart) / canvasWidth;
}...
}, {
key: 'dragTime',
value: function dragTime(e) {
var startTime = this.itemTimeStart;
if (this.state.dragging) {
var deltaX = e.pageX - this.state.dragStart.x;
var timeDelta = deltaX * this.coordinateToTimeRatio();
return this.dragTimeSnap(startTime + timeDelta, true);
} else {
return startTime;
}
}
}, {
...function createGradientPattern(lineHeight, color1, color2, borderColor) {
if (borderColor) {
if (!color2 || color1 === color2) {
return 'repeating-linear-gradient(to bottom, ' + (color1 + ',') + (color1 + ' ' + (lineHeight - 1) + 'px,') + (borderColor
+ ' ' + (lineHeight - 1) + 'px,') + (borderColor + ' ' + lineHeight + 'px') + ')';
} else {
return 'repeating-linear-gradient(to bottom, ' + (color1 + ',') + (color1 + ' ' + (lineHeight - 1) + 'px,') + (borderColor
+ ' ' + (lineHeight - 1) + 'px,') + (borderColor + ' ' + lineHeight + 'px,') + (color2 + ' ' + lineHeight + 'px,') + (color2 + ' ' + (
lineHeight * 2 - 1) + 'px,') + (borderColor + ' ' + (lineHeight * 2 - 1) + 'px,') + (borderColor + ' ' + lineHeight * 2 + 'px') + ')';
}
} else {
if (!color2 || color1 === color2) {
return color1;
} else {
return 'repeating-linear-gradient(to bottom,' + color1 + ',' + color1 + ' ' + lineHeight + 'px,' + color2 + ' ' + lineHeight
+ 'px,' + color2 + ' ' + lineHeight * 2 + 'px)';
}
}
}n/a
function deepObjectCompare(obj1, obj2) {
for (var p in obj1) {
if (obj1.hasOwnProperty(p) !== obj2.hasOwnProperty(p)) return false;
switch (_typeof(obj1[p])) {
case 'object':
if (!Object.compare(obj1[p], obj2[p])) return false;
break;
case 'function':
if (typeof obj2[p] === 'undefined' || p !== 'compare' && obj1[p].toString() !== obj2[p].toString()) return false;
break;
default:
if (obj1[p] !== obj2[p]) return false;
}
}
for (var r in obj2) {
if (typeof obj1[r] === 'undefined') return false;
}
return true;
}n/a
function getGroupOrders(groups, keys) {
var groupIdKey = keys.groupIdKey;
var groupOrders = {};
for (var i = 0; i < groups.length; i++) {
groupOrders[_get(groups[i], groupIdKey)] = i;
}
return groupOrders;
}...
canvasTimeEnd = _props.canvasTimeEnd,
dimensionItems = _props.dimensionItems;
var _props$keys2 = this.props.keys,
itemIdKey = _props$keys2.itemIdKey,
itemGroupKey = _props$keys2.itemGroupKey;
var groupOrders = this.getGroupOrders();
var visibleItems = this.getVisibleItems(canvasTimeStart, canvasTimeEnd, groupOrders);
var sortedDimensionItems = (0, _utils.keyBy)(dimensionItems, 'id');
return _react2.default.createElement(
'div',
{ className: 'rct-items' },
visibleItems.filter(function (item) {
...function getMinUnit(zoom, width, timeSteps) {
var timeDividers = {
second: 1000,
minute: 60,
hour: 60,
day: 24,
month: 30,
year: 12
};
var minUnit = 'year';
var breakCount = zoom;
var minCellWidth = 17;
Object.keys(timeDividers).some(function (unit) {
breakCount = breakCount / timeDividers[unit];
var cellCount = breakCount / timeSteps[unit];
var countNeeded = width / (timeSteps[unit] && timeSteps[unit] > 1 ? 3 * minCellWidth : minCellWidth);
if (cellCount < countNeeded) {
minUnit = unit;
return true;
}
});
return minUnit;
}n/a
function getNextUnit(unit) {
var nextUnits = {
second: 'minute',
minute: 'hour',
hour: 'day',
day: 'month',
month: 'year'
};
return nextUnits[unit] || '';
}n/a
function getParentPosition(element) {
var xPosition = 0;
var yPosition = 0;
var first = true;
while (element) {
xPosition += element.offsetLeft - (first ? 0 : element.scrollLeft) + element.clientLeft;
yPosition += element.offsetTop - (first ? 0 : element.scrollTop) + element.clientTop;
element = element.offsetParent;
first = false;
}
return { x: xPosition, y: yPosition };
}n/a
function getVisibleItems(items, canvasTimeStart, canvasTimeEnd, keys) {
var itemTimeStartKey = keys.itemTimeStartKey,
itemTimeEndKey = keys.itemTimeEndKey;
return items.filter(function (item) {
return _get(item, itemTimeStartKey) <= canvasTimeEnd && _get(item, itemTimeEndKey) >= canvasTimeStart;
});
}...
dimensionItems = _props.dimensionItems;
var _props$keys2 = this.props.keys,
itemIdKey = _props$keys2.itemIdKey,
itemGroupKey = _props$keys2.itemGroupKey;
var groupOrders = this.getGroupOrders();
var visibleItems = this.getVisibleItems(canvasTimeStart, canvasTimeEnd, groupOrders);
var sortedDimensionItems = (0, _utils.keyBy)(dimensionItems, 'id');
return _react2.default.createElement(
'div',
{ className: 'rct-items' },
visibleItems.filter(function (item) {
return sortedDimensionItems[(0, _utils._get)(item, itemIdKey)];
...function groupBy(collection, groupFunction) {
var obj = {};
collection.forEach(function (element, index, array) {
var key = groupFunction(element);
if (!obj[key]) {
obj[key] = [];
}
obj[key].push(element);
});
return obj;
}n/a
function hasSomeParentTheClass(element, classname) {
if (element.className && element.className.split(' ').indexOf(classname) >= 0) return true;
return element.parentNode && hasSomeParentTheClass(element.parentNode, classname);
}n/a
function iterateTimes(start, end, unit, timeSteps, callback) {
var time = (0, _moment2.default)(start).startOf(unit);
if (timeSteps[unit] && timeSteps[unit] > 1) {
var value = time.get(unit);
time.set(unit, value - value % timeSteps[unit]);
}
while (time.valueOf() < end) {
var nextTime = (0, _moment2.default)(time).add(timeSteps[unit] || 1, unit + 's');
callback(time, nextTime);
time = nextTime;
}
}n/a
function keyBy(value, key) {
var obj = {};
value.forEach(function (element, index, array) {
obj[element[key]] = element;
});
return obj;
}n/a
function nostack(items, groupOrders, lineHeight, headerHeight, force) {
var i, iMax;
var totalHeight = headerHeight;
var groupHeights = {};
var groupTops = {};
var groupedItems = groupBy(items, function (item) {
return item.dimensions.order;
});
if (force) {
// reset top position of all items
for (i = 0, iMax = items.length; i < iMax; i++) {
items[i].dimensions.top = null;
}
}
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = Object.keys(groupOrders)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2
.next()).done); _iteratorNormalCompletion2 = true) {
var url = _step2.value;
var key = groupOrders[url];
// calculate new, non-overlapping positions
var group = groupedItems[key] || [];
groupTops[key] = totalHeight;
var groupHeight = 0;
for (i = 0, iMax = group.length; i < iMax; i++) {
var item = group[i];
var verticalMargin = (item.dimensions.lineHeight - item.dimensions.height) / 2;
if (item.dimensions.top === null) {
item.dimensions.top = totalHeight + verticalMargin;
groupHeight = Math.max(groupHeight, item.dimensions.lineHeight);
}
}
groupHeights[key] = Math.max(groupHeight, lineHeight);
totalHeight += Math.max(groupHeight, lineHeight);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return {
height: totalHeight,
groupHeights: groupHeights,
groupTops: groupTops
};
}n/a
function stack(items, groupOrders, lineHeight, headerHeight, force) {
var i, iMax;
var totalHeight = headerHeight;
var groupHeights = {};
var groupTops = {};
var groupedItems = groupBy(items, function (item) {
return item.dimensions.order;
});
if (force) {
// reset top position of all items
for (i = 0, iMax = items.length; i < iMax; i++) {
items[i].dimensions.top = null;
}
}
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = Object.keys(groupOrders)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next
()).done); _iteratorNormalCompletion = true) {
var url = _step.value;
var key = groupOrders[url];
// calculate new, non-overlapping positions
var group = groupedItems[key] || [];
groupTops[key] = totalHeight;
var groupHeight = 0;
var verticalMargin = 0;
for (i = 0, iMax = group.length; i < iMax; i++) {
var item = group[i];
verticalMargin = item.dimensions.lineHeight - item.dimensions.height;
if (item.dimensions.stack && item.dimensions.top === null) {
item.dimensions.top = totalHeight + verticalMargin;
groupHeight = Math.max(groupHeight, item.dimensions.lineHeight);
do {
var collidingItem = null;
for (var j = 0, jj = group.length; j < jj; j++) {
var other = group[j];
if (other.top !== null && other !== item && other.dimensions.stack && collision(item.dimensions, other.dimensions,
item.dimensions.lineHeight)) {
collidingItem = other;
break;
} else {
// console.log('dont test', other.top !== null, other !== item, other.stack);
}
}
if (collidingItem != null) {
// There is a collision. Reposition the items above the colliding element
item.dimensions.top = collidingItem.dimensions.top + collidingItem.dimensions.lineHeight;
groupHeight = Math.max(groupHeight, item.dimensions.top + item.dimensions.height - totalHeight);
}
} while (collidingItem);
}
}
groupHeights[key] = Math.max(groupHeight + verticalMargin, lineHeight);
totalHeight += Math.max(groupHeight + verticalMargin, lineHeight);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return {
height: totalHeight,
groupHeights: groupHeights,
groupTops: groupTops
};
}n/a