|
|
@ -5,6 +5,7 @@ |
|
|
|
* @param {function} moment |
|
|
|
* @param {Object} body |
|
|
|
* @param {Array | Object} hiddenDates |
|
|
|
* @returns {Number} |
|
|
|
*/ |
|
|
|
exports.convertHiddenOptions = function(moment, body, hiddenDates) { |
|
|
|
if (hiddenDates && !Array.isArray(hiddenDates)) { |
|
|
@ -32,9 +33,11 @@ exports.convertHiddenOptions = function(moment, body, hiddenDates) { |
|
|
|
|
|
|
|
/** |
|
|
|
* create new entrees for the repeating hidden dates |
|
|
|
* |
|
|
|
* @param {function} moment |
|
|
|
* @param {Object} body |
|
|
|
* @param {Array | Object} hiddenDates |
|
|
|
* @returns {null} |
|
|
|
*/ |
|
|
|
exports.updateHiddenDates = function (moment, body, hiddenDates) { |
|
|
|
if (hiddenDates && !Array.isArray(hiddenDates)) { |
|
|
@ -181,7 +184,8 @@ exports.updateHiddenDates = function (moment, body, hiddenDates) { |
|
|
|
/** |
|
|
|
* remove duplicates from the hidden dates list. Duplicates are evil. They mess everything up. |
|
|
|
* Scales with N^2 |
|
|
|
* @param body |
|
|
|
* |
|
|
|
* @param {Object} body |
|
|
|
*/ |
|
|
|
exports.removeDuplicates = function(body) { |
|
|
|
var hiddenDates = body.hiddenDates; |
|
|
@ -229,7 +233,7 @@ exports.printDates = function(dates) { |
|
|
|
* Used in TimeStep to avoid the hidden times. |
|
|
|
* @param {function} moment |
|
|
|
* @param {TimeStep} timeStep |
|
|
|
* @param previousTime |
|
|
|
* @param {Date} previousTime |
|
|
|
*/ |
|
|
|
exports.stepOverHiddenDates = function(moment, timeStep, previousTime) { |
|
|
|
var stepInHidden = false; |
|
|
@ -281,10 +285,11 @@ exports.stepOverHiddenDates = function(moment, timeStep, previousTime) { |
|
|
|
|
|
|
|
/** |
|
|
|
* replaces the Core toScreen methods |
|
|
|
* @param Core |
|
|
|
* @param time |
|
|
|
* @param width |
|
|
|
* @returns {number} |
|
|
|
* |
|
|
|
* @param {vis.Core} Core |
|
|
|
* @param {Date} time |
|
|
|
* @param {Number} width |
|
|
|
* @returns {Number} |
|
|
|
*/ |
|
|
|
exports.toScreen = function (Core, time, width) { |
|
|
|
var conversion; |
|
|
@ -322,9 +327,10 @@ exports.toScreen = function (Core, time, width) { |
|
|
|
|
|
|
|
/** |
|
|
|
* Replaces the core toTime methods |
|
|
|
* @param Core |
|
|
|
* @param x |
|
|
|
* @param width |
|
|
|
* |
|
|
|
* @param {vis.Core} Core |
|
|
|
* @param {number} x |
|
|
|
* @param {number} width |
|
|
|
* @returns {Date} |
|
|
|
*/ |
|
|
|
exports.toTime = function(Core, x, width) { |
|
|
@ -338,8 +344,7 @@ exports.toTime = function(Core, x, width) { |
|
|
|
var partialDuration = totalDuration * x / width; |
|
|
|
var accumulatedHiddenDuration = exports.getAccumulatedHiddenDuration(Core.body.hiddenDates, Core.range, partialDuration); |
|
|
|
|
|
|
|
var newTime = new Date(accumulatedHiddenDuration + partialDuration + Core.range.start); |
|
|
|
return newTime; |
|
|
|
return new Date(accumulatedHiddenDuration + partialDuration + Core.range.start); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
@ -347,8 +352,9 @@ exports.toTime = function(Core, x, width) { |
|
|
|
/** |
|
|
|
* Support function |
|
|
|
* |
|
|
|
* @param hiddenDates |
|
|
|
* @param range |
|
|
|
* @param {Array<{start: Window.start, end: *}>} hiddenDates |
|
|
|
* @param {number} start |
|
|
|
* @param {number} end |
|
|
|
* @returns {number} |
|
|
|
*/ |
|
|
|
exports.getHiddenDurationBetween = function(hiddenDates, start, end) { |
|
|
@ -365,13 +371,13 @@ exports.getHiddenDurationBetween = function(hiddenDates, start, end) { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Support function |
|
|
|
* |
|
|
|
* @param hiddenDates |
|
|
|
* @param start |
|
|
|
* @param end |
|
|
|
* @returns {number} |
|
|
|
*/ |
|
|
|
* Support function |
|
|
|
* |
|
|
|
* @param {Array<{start: Window.start, end: *}>} hiddenDates |
|
|
|
* @param {number} start |
|
|
|
* @param {number} end |
|
|
|
* @returns {number} |
|
|
|
*/ |
|
|
|
exports.getHiddenDurationBeforeStart = function (hiddenDates, start, end) { |
|
|
|
var duration = 0; |
|
|
|
for (var i = 0; i < hiddenDates.length; i++) { |
|
|
@ -388,11 +394,11 @@ exports.getHiddenDurationBeforeStart = function (hiddenDates, start, end) { |
|
|
|
|
|
|
|
/** |
|
|
|
* Support function |
|
|
|
* @param moment |
|
|
|
* @param hiddenDates |
|
|
|
* @param range |
|
|
|
* @param time |
|
|
|
* @returns {{duration: number, time: *, offset: number}} |
|
|
|
* @param {function} moment |
|
|
|
* @param {Array<{start: Window.start, end: *}>} hiddenDates |
|
|
|
* @param {{start: number, end: number}} range |
|
|
|
* @param {Date} time |
|
|
|
* @returns {number} |
|
|
|
*/ |
|
|
|
exports.correctTimeForHidden = function(moment, hiddenDates, range, time) { |
|
|
|
time = moment(time).toDate().valueOf(); |
|
|
@ -420,10 +426,10 @@ exports.getHiddenDurationBefore = function(moment, hiddenDates, range, time) { |
|
|
|
/** |
|
|
|
* sum the duration from start to finish, including the hidden duration, |
|
|
|
* until the required amount has been reached, return the accumulated hidden duration |
|
|
|
* @param hiddenDates |
|
|
|
* @param range |
|
|
|
* @param time |
|
|
|
* @returns {{duration: number, time: *, offset: number}} |
|
|
|
* @param {Array<{start: Window.start, end: *}>} hiddenDates |
|
|
|
* @param {{start: number, end: number}} range |
|
|
|
* @param {number} [requiredDuration=0] |
|
|
|
* @returns {number} |
|
|
|
*/ |
|
|
|
exports.getAccumulatedHiddenDuration = function(hiddenDates, range, requiredDuration) { |
|
|
|
var hiddenDuration = 0; |
|
|
@ -453,11 +459,11 @@ exports.getAccumulatedHiddenDuration = function(hiddenDates, range, requiredDura |
|
|
|
|
|
|
|
/** |
|
|
|
* used to step over to either side of a hidden block. Correction is disabled on tablets, might be set to true |
|
|
|
* @param hiddenDates |
|
|
|
* @param time |
|
|
|
* @param direction |
|
|
|
* @param correctionEnabled |
|
|
|
* @returns {*} |
|
|
|
* @param {Array<{start: Window.start, end: *}>} hiddenDates |
|
|
|
* @param {Date} time |
|
|
|
* @param {Number} direction |
|
|
|
* @param {Boolean} correctionEnabled |
|
|
|
* @returns {Date|Number} |
|
|
|
*/ |
|
|
|
exports.snapAwayFromHidden = function(hiddenDates, time, direction, correctionEnabled) { |
|
|
|
var isHidden = exports.isHidden(time, hiddenDates); |
|
|
@ -489,8 +495,8 @@ exports.snapAwayFromHidden = function(hiddenDates, time, direction, correctionEn |
|
|
|
/** |
|
|
|
* Check if a time is hidden |
|
|
|
* |
|
|
|
* @param time |
|
|
|
* @param hiddenDates |
|
|
|
* @param {Date} time |
|
|
|
* @param {Array<{start: Window.start, end: *}>} hiddenDates |
|
|
|
* @returns {{hidden: boolean, startDate: Window.start, endDate: *}} |
|
|
|
*/ |
|
|
|
exports.isHidden = function(time, hiddenDates) { |
|
|
|