|
|
@ -286,24 +286,37 @@ exports.stepOverHiddenDates = function(moment, timeStep, previousTime) { |
|
|
|
* @param width |
|
|
|
* @returns {number} |
|
|
|
*/ |
|
|
|
exports.toScreen = function(Core, time, width) { |
|
|
|
if (Core.body.hiddenDates.length == 0) { |
|
|
|
var conversion = Core.range.conversion(width); |
|
|
|
return (time.valueOf() - conversion.offset) * conversion.scale; |
|
|
|
} |
|
|
|
else { |
|
|
|
var hidden = exports.isHidden(time, Core.body.hiddenDates); |
|
|
|
if (hidden.hidden == true) { |
|
|
|
time = hidden.startDate; |
|
|
|
} |
|
|
|
|
|
|
|
var duration = exports.getHiddenDurationBetween(Core.body.hiddenDates, Core.range.start, Core.range.end); |
|
|
|
time = exports.correctTimeForHidden(Core.options.moment, Core.body.hiddenDates, Core.range, time); |
|
|
|
exports.toScreen = function (Core, time, width) { |
|
|
|
if (Core.body.hiddenDates.length == 0) { |
|
|
|
var conversion = Core.range.conversion(width); |
|
|
|
return (time.valueOf() - conversion.offset) * conversion.scale; |
|
|
|
} else { |
|
|
|
var hidden = exports.isHidden(time, Core.body.hiddenDates); |
|
|
|
if (hidden.hidden == true) { |
|
|
|
time = hidden.startDate; |
|
|
|
} |
|
|
|
|
|
|
|
var conversion = Core.range.conversion(width, duration); |
|
|
|
return (time.valueOf() - conversion.offset) * conversion.scale; |
|
|
|
} |
|
|
|
}; |
|
|
|
var duration = exports.getHiddenDurationBetween(Core.body.hiddenDates, Core.range.start, Core.range.end); |
|
|
|
if (time < Core.range.start) { |
|
|
|
var conversion = Core.range.conversion(width, duration); |
|
|
|
var hiddenBeforeStart = exports.getHiddenDurationBeforeStart(Core.body.hiddenDates, time, conversion.offset); |
|
|
|
time = Core.options.moment(time).toDate().valueOf(); |
|
|
|
time = time + hiddenBeforeStart; |
|
|
|
return -(conversion.offset - time.valueOf()) * conversion.scale; |
|
|
|
|
|
|
|
} else if (time > Core.range.end) { |
|
|
|
var rangeAfterEnd = {start: Core.range.start, end: time}; |
|
|
|
time = exports.correctTimeForHidden(Core.options.moment, Core.body.hiddenDates, rangeAfterEnd, time); |
|
|
|
var conversion = Core.range.conversion(width, duration); |
|
|
|
return (time.valueOf() - conversion.offset) * conversion.scale; |
|
|
|
|
|
|
|
} else { |
|
|
|
time = exports.correctTimeForHidden(Core.options.moment, Core.body.hiddenDates, Core.range, time); |
|
|
|
var conversion = Core.range.conversion(width, duration); |
|
|
|
return (time.valueOf() - conversion.offset) * conversion.scale; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -351,6 +364,27 @@ exports.getHiddenDurationBetween = function(hiddenDates, start, end) { |
|
|
|
return duration; |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Support function |
|
|
|
* |
|
|
|
* @param hiddenDates |
|
|
|
* @param start |
|
|
|
* @param end |
|
|
|
* @returns {number} |
|
|
|
*/ |
|
|
|
exports.getHiddenDurationBeforeStart = function (hiddenDates, start, end) { |
|
|
|
var duration = 0; |
|
|
|
for (var i = 0; i < hiddenDates.length; i++) { |
|
|
|
var startDate = hiddenDates[i].start; |
|
|
|
var endDate = hiddenDates[i].end; |
|
|
|
|
|
|
|
if (startDate >= start && endDate <= end) { |
|
|
|
duration += endDate - startDate; |
|
|
|
} |
|
|
|
} |
|
|
|
return duration; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Support function |
|
|
@ -470,4 +504,4 @@ exports.isHidden = function(time, hiddenDates) { |
|
|
|
} |
|
|
|
} |
|
|
|
return {hidden: false, startDate: startDate, endDate: endDate}; |
|
|
|
} |
|
|
|
} |