From 4d7a21c84705f1c28ee4a2fc2fb2711e23e99479 Mon Sep 17 00:00:00 2001 From: yotamberk Date: Sat, 3 Dec 2016 11:57:33 +0200 Subject: [PATCH 01/11] fixes #2367 Group editable bug (#2368) * Fix groupEditable * Fix group drag in vertical direction bug * Fix indentation --- lib/timeline/component/ItemSet.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js index ed27f48a..5875a46a 100644 --- a/lib/timeline/component/ItemSet.js +++ b/lib/timeline/component/ItemSet.js @@ -243,7 +243,7 @@ ItemSet.prototype._create = function(){ this.groupHammer.on('panstart', this._onGroupDragStart.bind(this)); this.groupHammer.on('panmove', this._onGroupDrag.bind(this)); this.groupHammer.on('panend', this._onGroupDragEnd.bind(this)); - this.groupHammer.get('pan').set({threshold:5, direction: Hammer.DIRECTION_HORIZONTAL}); + this.groupHammer.get('pan').set({threshold:5, direction: Hammer.DIRECTION_VERTICAL}); this.body.dom.centerContainer.addEventListener('mouseover', this._onMouseOver.bind(this)); this.body.dom.centerContainer.addEventListener('mouseout', this._onMouseOut.bind(this)); @@ -1578,6 +1578,10 @@ ItemSet.prototype._onGroupDrag = function (event) { if (this.options.groupEditable.order && this.groupTouchParams.group) { event.stopPropagation(); + var groupsData = this.groupsData; + if (this.groupsData instanceof DataView) { + groupsData = this.groupsData.getDataSet() + } // drag from one group to another var group = this.groupFromTarget(event); @@ -1602,25 +1606,23 @@ ItemSet.prototype._onGroupDrag = function (event) { } if (group && group != this.groupTouchParams.group) { - var groupsData = this.groupsData; var targetGroup = groupsData.get(group.groupId); var draggedGroup = groupsData.get(this.groupTouchParams.group.groupId); // switch groups if (draggedGroup && targetGroup) { this.options.groupOrderSwap(draggedGroup, targetGroup, this.groupsData); - this.groupsData.update(draggedGroup); - this.groupsData.update(targetGroup); + groupsData.update(draggedGroup); + groupsData.update(targetGroup); } // fetch current order of groups - var newOrder = this.groupsData.getIds({ + var newOrder = groupsData.getIds({ order: this.options.groupOrder - }); + }); // in case of changes since _onGroupDragStart if (!util.equalArray(newOrder, this.groupTouchParams.originalOrder)) { - var groupsData = this.groupsData; var origOrder = this.groupTouchParams.originalOrder; var draggedId = this.groupTouchParams.group.groupId; var numGroups = Math.min(origOrder.length, newOrder.length); From a77e462105ce90634ee6a5537eb34aa013ecdea6 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 3 Dec 2016 15:55:37 -0500 Subject: [PATCH 02/11] =?UTF-8?q?fix:=20#2402=20make=20sure=20a=20given=20?= =?UTF-8?q?element=20isn=E2=80=99t=20undefined=20before=20accessing=20prop?= =?UTF-8?q?erties=20(#2403)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/util.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/util.js b/lib/util.js index 22deac1d..54d68bf7 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1488,17 +1488,19 @@ exports.topMost = function (pile, accessors) { accessors = [accessors]; } for (const member of pile) { - candidate = member[accessors[0]]; - for (let i = 1; i < accessors.length; i++){ + if (member) { + candidate = member[accessors[0]]; + for (let i = 1; i < accessors.length; i++){ + if (candidate) { + candidate = candidate[accessors[i]] + } else { + continue; + } + } if (candidate) { - candidate = candidate[accessors[i]] - } else { - continue; + break; } } - if (candidate) { - break; - } } return candidate; -} +}; From 5900ea0319b2848bd1b8fe39b53a512281955563 Mon Sep 17 00:00:00 2001 From: yotamberk Date: Sun, 4 Dec 2016 17:41:59 +0200 Subject: [PATCH 03/11] fix: _origRedraw sometimes undefined (#2399) --- lib/timeline/Core.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/timeline/Core.js b/lib/timeline/Core.js index 1eeb0faa..aa8344da 100644 --- a/lib/timeline/Core.js +++ b/lib/timeline/Core.js @@ -115,6 +115,10 @@ Core.prototype._create = function (container) { this.on('panmove', this._onDrag.bind(this)); var me = this; + + this._origRedraw = this._redraw.bind(this); + this._redraw = util.throttle(this._origRedraw); + this.on('_change', function (properties) { if (me.itemSet.initialItemSetDrawn && properties && properties.queue == true) { me._redraw() @@ -412,15 +416,7 @@ Core.prototype.setOptions = function (options) { this.configurator.setModuleOptions({global: appliedOptions}); } - // override redraw with a throttled version - if (!this._origRedraw) { - this._origRedraw = this._redraw.bind(this); - this._redraw = util.throttle(this._origRedraw); - } else { - // Not the initial run: redraw everything - this._redraw(); - } - + this._redraw(); }; /** From 9c96927d7db5ce34451e0f90c93aeb5ed055848b Mon Sep 17 00:00:00 2001 From: Alexander Wunschik Date: Sun, 4 Dec 2016 20:09:39 +0100 Subject: [PATCH 04/11] removed merge-stream --- gulpfile.js | 1 - package.json | 1 - 2 files changed, 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 697185d3..05bf2bc3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -8,7 +8,6 @@ var rename = require("gulp-rename"); var webpack = require('webpack'); var uglify = require('uglify-js'); var rimraf = require('rimraf'); -var merge = require('merge-stream'); var argv = require('yargs').argv; var ENTRY = './index.js'; diff --git a/package.json b/package.json index 5d22df48..93c24982 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "gulp-concat": "^2.6.0", "gulp-rename": "^1.2.2", "gulp-util": "^3.0.7", - "merge-stream": "^1.0.0", "mocha": "^3.1.2", "rimraf": "^2.5.2", "uglify-js": "^2.6.2", From d9056c160c85f07da48ec507df8fcf99512676e1 Mon Sep 17 00:00:00 2001 From: Alexander Wunschik Date: Mon, 5 Dec 2016 11:05:55 +0100 Subject: [PATCH 05/11] added code-climate configs --- .codeclimate.yml | 26 ++++++++++++++++++++++++++ .csslintrc | 3 +++ .eslintrc | 6 ++++++ .mdlrc | 6 ++++++ 4 files changed, 41 insertions(+) create mode 100644 .codeclimate.yml create mode 100644 .csslintrc create mode 100644 .eslintrc create mode 100644 .mdlrc diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 00000000..abd4ff1c --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,26 @@ +languages: + JavaScript: true +engines: + eslint: + enabled: true + csslint: + enabled: true + markdownlint: + enabled: true + duplication: + enabled: true + config: + languages: + javascript: + mass_threshold: 300 + fixme : + enabled: true +ratings: + paths: + - "**/*.js" + - "**/*.css" + - "**/*.md" +exclude_paths: + - "dist/**/*" + - "docs/**/*" + - "examples/**/*" diff --git a/.csslintrc b/.csslintrc new file mode 100644 index 00000000..4ed5b8c3 --- /dev/null +++ b/.csslintrc @@ -0,0 +1,3 @@ +{ + "box-sizing": false +} diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..00d60a6e --- /dev/null +++ b/.eslintrc @@ -0,0 +1,6 @@ +{ + "rules": { + "complexity": [2, 50], + "max-statements": [2, 100] + } +} diff --git a/.mdlrc b/.mdlrc new file mode 100644 index 00000000..d1fda796 --- /dev/null +++ b/.mdlrc @@ -0,0 +1,6 @@ +// Markdown Lint Rules +// https://github.com/mivok/markdownlint/blob/master/docs/RULES.md + +rules + "~MD012", // alert on multiple consecutive blank lines + "~MD013", // line length should be no more than 80 characters From 8b184393436502f81cdaed93f65d3abee4521c82 Mon Sep 17 00:00:00 2001 From: Alexander Wunschik Date: Mon, 5 Dec 2016 11:21:15 +0100 Subject: [PATCH 06/11] removed TODO; removed trailing spaces --- HISTORY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 0b7bad0d..e588235e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -14,7 +14,7 @@ http://visjs.org - Fixed #2170: Improved the contribution docs (#1991, #2158, #2178, #2183, #2213, #2218, #2219) - Implemented #1969: generate individual css files for network and timeline (#1970) - Cleanup bower.json (#1968) -- Removed feature-request page from website (TODO) +- Fixed #2114: Removed feature-request page from website - Distinguish better between `devDependencies` and `dependencies` (#1967) - Typos and minor docs improvements (#1958, #2028, #2050, #2093, #2222, #2223, #2224) - Replaced `gulp-minify-css` with `gulp-clean-css` (#1953) @@ -266,7 +266,7 @@ http://visjs.org ### General - Fixed #1353: Custom bundling with browserify requiring manual installation - of `babelify`. + of `babelify`. ### Network @@ -451,7 +451,7 @@ http://visjs.org - Fixed #1033: Moved item data not updated in DataSet when using an asynchronous `onMove` handler. - Fixed #239: Do not zoom/move the window when the mouse is on the left panel - with group labels. + with group labels. ## 2015-07-03, version 4.4.0 From 69da64972fa212e6a4cca83e61f0b03f65004197 Mon Sep 17 00:00:00 2001 From: Alexander Wunschik Date: Mon, 5 Dec 2016 11:26:40 +0100 Subject: [PATCH 07/11] disabled csslint rule box-model --- .csslintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.csslintrc b/.csslintrc index 4ed5b8c3..7e217fd9 100644 --- a/.csslintrc +++ b/.csslintrc @@ -1,3 +1,4 @@ { + "box-model": false, "box-sizing": false } From de7808885abb3d44bb6393a073c0fc572f0668f0 Mon Sep 17 00:00:00 2001 From: Alexander Wunschik Date: Tue, 6 Dec 2016 11:08:30 +0100 Subject: [PATCH 08/11] csslint deactivated 'order-alphabetical' --- .csslintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.csslintrc b/.csslintrc index 7e217fd9..b3f05310 100644 --- a/.csslintrc +++ b/.csslintrc @@ -1,4 +1,5 @@ { "box-model": false, - "box-sizing": false + "box-sizing": false, + "order-alphabetical": false } From 008371a26e6b4678b72ad2d5d82bb32690a82d20 Mon Sep 17 00:00:00 2001 From: Alexander Wunschik Date: Tue, 6 Dec 2016 11:26:54 +0100 Subject: [PATCH 09/11] csslint deactivated 'adjoining-classes' --- .csslintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.csslintrc b/.csslintrc index b3f05310..2b014c6a 100644 --- a/.csslintrc +++ b/.csslintrc @@ -1,4 +1,5 @@ { + "adjoining-classes": false, "box-model": false, "box-sizing": false, "order-alphabetical": false From 0b73a13910db55484181536ccafaa416d67abee3 Mon Sep 17 00:00:00 2001 From: Alexander Wunschik Date: Tue, 6 Dec 2016 12:55:28 +0100 Subject: [PATCH 10/11] mdlint: allow dollar signs used before commands without showing output --- .mdlrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.mdlrc b/.mdlrc index d1fda796..bb5535c3 100644 --- a/.mdlrc +++ b/.mdlrc @@ -4,3 +4,4 @@ rules "~MD012", // alert on multiple consecutive blank lines "~MD013", // line length should be no more than 80 characters + "~MD014", // Dollar signs used before commands without showing output From 607950bf99d1383fc39360d82b0e2b04574d5ba0 Mon Sep 17 00:00:00 2001 From: yotamberk Date: Tue, 6 Dec 2016 15:34:14 +0200 Subject: [PATCH 11/11] fix: #2327 Add support to fixed times drag and drop (#2372) * Add support to fixed times drag and drop * Fix IE support for drag and drop * Add support to IE pointer location and data setting/getting --- examples/timeline/other/drag&drop.html | 16 ++++++++++++---- lib/timeline/Core.js | 8 ++++---- lib/timeline/component/ItemSet.js | 4 ++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/timeline/other/drag&drop.html b/examples/timeline/other/drag&drop.html index 81bcb1f1..5810eb9b 100644 --- a/examples/timeline/other/drag&drop.html +++ b/examples/timeline/other/drag&drop.html @@ -49,6 +49,10 @@
  • item 3 - range
  • +
  • + item 3 - range - fixed times -
    + (start: now, end: now + 10 min) +
  • @@ -110,12 +114,16 @@ var item = { id: new Date(), type: itemType, - content: event.target.innerHTML.split('-')[0].trim(), - start: new Date(), - end: new Date(1000*60*60*24 + (new Date()).valueOf()), + content: event.target.innerHTML.split('-')[0].trim() }; - event.dataTransfer.setData("text/plain", JSON.stringify(item)); + var isFixedTimes = (event.target.innerHTML.split('-')[2] && event.target.innerHTML.split('-')[2].trim() == 'fixed times') + if (isFixedTimes) { + item.start = new Date(); + item.end = new Date(1000*60*10 + (new Date()).valueOf()); + } + + event.dataTransfer.setData("text", JSON.stringify(item)); } var items = document.querySelectorAll('.items .item'); diff --git a/lib/timeline/Core.js b/lib/timeline/Core.js index aa8344da..a5034479 100644 --- a/lib/timeline/Core.js +++ b/lib/timeline/Core.js @@ -231,7 +231,7 @@ Core.prototype._create = function (container) { } // make sure your target is a vis element - if (!event.target.className.includes('vis')) return; + if (!event.target.className.indexOf("vis") > -1) return; // make sure only one item is added every time you're over the timeline if (itemAddedToTimeline) return; @@ -244,7 +244,7 @@ Core.prototype._create = function (container) { function handleDrop(event) { // return when dropping non-vis items try { - var itemData = JSON.parse(event.dataTransfer.getData("text/plain")) + var itemData = JSON.parse(event.dataTransfer.getData("text")) if (!itemData.content) return } catch (err) { return false; @@ -252,8 +252,8 @@ Core.prototype._create = function (container) { itemAddedToTimeline = false; event.center = { - x: event.x, - y: event.y + x: event.clientX, + y: event.clientY } me.itemSet._onAddItem(event); diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js index 5875a46a..b0a71b94 100644 --- a/lib/timeline/component/ItemSet.js +++ b/lib/timeline/component/ItemSet.js @@ -1856,12 +1856,12 @@ ItemSet.prototype._onAddItem = function (event) { newItemData[this.itemsData._fieldId] = itemData.id || util.randomUUID(); if (itemData.type == 'range' || (itemData.end && itemData.start)) { - if (!itemData.end) { var end = this.body.util.toTime(x + this.props.width / 5); newItemData.end = snap ? snap(end, scale, step) : end; } else { - newItemData.end = new Date(newItemData.start._i).getTime() + new Date(itemData.end).getTime() - new Date(itemData.start).getTime(); + newItemData.end = itemData.end; + newItemData.start = itemData.start; } } } else {