Browse Source

Merge branch 'master' into develop

v3_develop
jos 10 years ago
parent
commit
5c71fdcccb
3 changed files with 22 additions and 10 deletions
  1. +11
    -3
      HISTORY.md
  2. +4
    -2
      docs/dataset.html
  3. +7
    -5
      lib/DataSet.js

+ 11
- 3
HISTORY.md View File

@ -11,7 +11,15 @@ http://visjs.org
- Added getPositions() method to get the position of all nodes.
- Added getCenterCoordinates() method to get the x and y position in canvas space of the center of the view.
## 2014-10-16, version 3.5.0
## not yet released, version 3.5.1
### DataSet
- Event listeners of `update` now receive an extra property `data`,
containing the changed fields of the changed items.
## 2014-09-16, version 3.5.0
### Network
@ -24,7 +32,7 @@ http://visjs.org
- Fixed dataAxis not showing large numbers correctly.
## 2014-10-12, version 3.4.2
## 2014-09-12, version 3.4.2
### Network
@ -35,7 +43,7 @@ http://visjs.org
- Added startStabilization event.
## 2014-10-11, version 3.4.1
## 2014-09-11, version 3.4.1
### Network

+ 4
- 2
docs/dataset.html View File

@ -448,8 +448,10 @@ function (event, properties, senderId) {
In case of the events <code>add</code>,
<code>update</code>, and <code>remove</code>,
<code>properties</code> is always an object containing a property
items, which contains an array with the ids of the affected
items.
<code>items</code>, which contains an array with the ids of the affected
items. The <code>update</code> event has an extra field <code>data</code>
containing the original data of the updated items, i.e. the gives the
changed fields of the changed items.
</td>
</tr>
<tr>

+ 7
- 5
lib/DataSet.js View File

@ -204,10 +204,11 @@ DataSet.prototype.add = function (data, senderId) {
* @return {Array} updatedIds The ids of the added or updated items
*/
DataSet.prototype.update = function (data, senderId) {
var addedIds = [],
updatedIds = [],
me = this,
fieldId = me._fieldId;
var addedIds = [];
var updatedIds = [];
var updatedData = [];
var me = this;
var fieldId = me._fieldId;
var addOrUpdate = function (item) {
var id = item[fieldId];
@ -215,6 +216,7 @@ DataSet.prototype.update = function (data, senderId) {
// update item
id = me._updateItem(item);
updatedIds.push(id);
updatedData.push(item);
}
else {
// add new item
@ -254,7 +256,7 @@ DataSet.prototype.update = function (data, senderId) {
this._trigger('add', {items: addedIds}, senderId);
}
if (updatedIds.length) {
this._trigger('update', {items: updatedIds}, senderId);
this._trigger('update', {items: updatedIds, data: updatedData}, senderId);
}
return addedIds.concat(updatedIds);

Loading…
Cancel
Save