From 5cd6a2c9a210445354d1d3ea9e6db45d5b80837d Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Wed, 22 Oct 2014 12:29:48 +0200 Subject: [PATCH] fixed all problems with hiddenDates --- HISTORY.md | 3 ++- dist/vis.js | 10 ++++++++-- examples/timeline/29_hiding_times.html | 2 +- lib/timeline/DateUtil.js | 10 ++++++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index d4af068d..f8c236ee 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,7 +6,8 @@ http://visjs.org ### Timeline -- Fixed uneven stepsized with hidden dates +- Fixed uneven stepsized with hidden dates. +- Fixed multiple bugs with regards to hidden dates. ## 2014-10-21, version 3.6.0 diff --git a/dist/vis.js b/dist/vis.js index 4424383e..5239a8b6 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -12622,14 +12622,21 @@ return /******/ (function(modules) { // webpackBootstrap var totalRange = (body.range.end - body.range.start); var pixelTime = totalRange / body.domProps.centerContainer.width; - for (var i = 0; i < hiddenDates.length; i++) { if (hiddenDates[i].repeat !== undefined) { var startDate = moment(hiddenDates[i].start); var endDate = moment(hiddenDates[i].end); + if (startDate._d == "Invalid Date") { + throw new Error("Supplied start date is not valid: " + hiddenDates[i].start); + } + if (endDate._d == "Invalid Date") { + throw new Error("Supplied end date is not valid: " + hiddenDates[i].end); + } + var duration = endDate - startDate; if (duration >= 4 * pixelTime) { + var offset = 0; var runUntil = end.clone(); switch (hiddenDates[i].repeat) { @@ -12728,7 +12735,6 @@ return /******/ (function(modules) { // webpackBootstrap } // remove duplicates, merge where possible exports.removeDuplicates(body); - //exports.printDates(body.hiddenDates) // ensure the new positions are not on hidden dates var startHidden = exports.isHidden(body.range.start, body.hiddenDates); var endHidden = exports.isHidden(body.range.end,body.hiddenDates); diff --git a/examples/timeline/29_hiding_times.html b/examples/timeline/29_hiding_times.html index 6a56e7f5..edf2577e 100644 --- a/examples/timeline/29_hiding_times.html +++ b/examples/timeline/29_hiding_times.html @@ -33,7 +33,7 @@ hiddenDates: [ {start: '2014-03-21 00:00:00', end: '2014-03-28 00:00:00'}, {start: '2013-10-26 00:00:00', end: '2013-10-28 00:00:00', repeat: 'weekly'}, // daily weekly monthly yearly - {start: '2013-03-29 20:00:00', end: '2013-03-30 9:00:00', repeat: 'daily'} // daily weekly monthly yearly + {start: '2013-03-29 20:00:00', end: '2013-03-30 09:00:00', repeat: 'daily'} // daily weekly monthly yearly ], start: '2014-04-17', end: '2014-05-01', diff --git a/lib/timeline/DateUtil.js b/lib/timeline/DateUtil.js index 161a7f73..39751b97 100644 --- a/lib/timeline/DateUtil.js +++ b/lib/timeline/DateUtil.js @@ -44,14 +44,21 @@ exports.updateHiddenDates = function (body, hiddenDates) { var totalRange = (body.range.end - body.range.start); var pixelTime = totalRange / body.domProps.centerContainer.width; - for (var i = 0; i < hiddenDates.length; i++) { if (hiddenDates[i].repeat !== undefined) { var startDate = moment(hiddenDates[i].start); var endDate = moment(hiddenDates[i].end); + if (startDate._d == "Invalid Date") { + throw new Error("Supplied start date is not valid: " + hiddenDates[i].start); + } + if (endDate._d == "Invalid Date") { + throw new Error("Supplied end date is not valid: " + hiddenDates[i].end); + } + var duration = endDate - startDate; if (duration >= 4 * pixelTime) { + var offset = 0; var runUntil = end.clone(); switch (hiddenDates[i].repeat) { @@ -150,7 +157,6 @@ exports.updateHiddenDates = function (body, hiddenDates) { } // remove duplicates, merge where possible exports.removeDuplicates(body); - //exports.printDates(body.hiddenDates) // ensure the new positions are not on hidden dates var startHidden = exports.isHidden(body.range.start, body.hiddenDates); var endHidden = exports.isHidden(body.range.end,body.hiddenDates);