Browse Source

Merge branch 'develop' of https://github.com/almende/vis into develop

revert-3409-performance
Yotam Berkowitz 8 years ago
parent
commit
582fc64a85
11 changed files with 86 additions and 31 deletions
  1. +26
    -0
      .codeclimate.yml
  2. +6
    -0
      .csslintrc
  3. +6
    -0
      .eslintrc
  4. +7
    -0
      .mdlrc
  5. +3
    -3
      HISTORY.md
  6. +12
    -4
      examples/timeline/other/drag&drop.html
  7. +0
    -1
      gulpfile.js
  8. +4
    -4
      lib/timeline/Core.js
  9. +11
    -9
      lib/timeline/component/ItemSet.js
  10. +11
    -9
      lib/util.js
  11. +0
    -1
      package.json

+ 26
- 0
.codeclimate.yml View File

@ -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/**/*"

+ 6
- 0
.csslintrc View File

@ -0,0 +1,6 @@
{
"adjoining-classes": false,
"box-model": false,
"box-sizing": false,
"order-alphabetical": false
}

+ 6
- 0
.eslintrc View File

@ -0,0 +1,6 @@
{
"rules": {
"complexity": [2, 50],
"max-statements": [2, 100]
}
}

+ 7
- 0
.mdlrc View File

@ -0,0 +1,7 @@
// 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
"~MD014", // Dollar signs used before commands without showing output

+ 3
- 3
HISTORY.md View File

@ -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

+ 12
- 4
examples/timeline/other/drag&drop.html View File

@ -49,6 +49,10 @@
<li draggable="true" class="item">
item 3 - range
</li>
<li draggable="true" class="item">
item 3 - range - fixed times - <br>
(start: now, end: now + 10 min)
</li>
</ul>
</div>
@ -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');

+ 0
- 1
gulpfile.js View File

@ -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';

+ 4
- 4
lib/timeline/Core.js View File

@ -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);

+ 11
- 9
lib/timeline/component/ItemSet.js View File

@ -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);
@ -1854,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 {

+ 11
- 9
lib/util.js View File

@ -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;
}
};

+ 0
- 1
package.json View File

@ -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",

Loading…
Cancel
Save