Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Item events original event #2704

Merged
merged 22 commits into from
Feb 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
dcb2d58
Fix redraw order
yotamberk Dec 2, 2016
582fc64
Merge branch 'develop' of https://github.com/almende/vis into develop
yotamberk Dec 6, 2016
f96e6bf
Merge branch 'develop' of https://github.com/almende/vis into develop
yotamberk Dec 8, 2016
ffa8e0e
Merge branch 'develop' of https://github.com/almende/vis into develop
yotamberk Dec 17, 2016
2f04345
Fix error when option is not defined
yotamberk Dec 20, 2016
3cfa8d0
Allow template labels
yotamberk Dec 22, 2016
aee0fb3
Merge branch 'develop' of https://github.com/almende/vis into develop
yotamberk Dec 22, 2016
4681ace
Merge branch 'develop' of https://github.com/almende/vis into develop
yotamberk Dec 23, 2016
e9d1ebf
Merge branch 'develop' of https://github.com/almende/vis into develop
yotamberk Dec 31, 2016
cd37b2d
Merge branch 'develop' of https://github.com/almende/vis into develop
yotamberk Dec 31, 2016
9a27aa7
Merge branch 'develop' of https://github.com/almende/vis into develop
yotamberk Jan 5, 2017
4982679
Add .travis.yml file
yotamberk Jan 5, 2017
b9144d3
Add experiment travis code
yotamberk Jan 5, 2017
001fd9f
Merge branch 'develop' of https://github.com/almende/vis into develop
yotamberk Jan 15, 2017
e504dc7
Merge branch 'develop' of https://github.com/yotamberk/vis into develop
yotamberk Jan 15, 2017
ada1c90
Fix react example
yotamberk Jan 15, 2017
3124d8e
Merge branch 'develop' of https://github.com/almende/vis into develop
yotamberk Jan 27, 2017
931a2bd
Merge branch 'develop' of https://github.com/almende/vis into item-ev…
yotamberk Feb 11, 2017
ff2d039
Fix events returned from mouse events
yotamberk Feb 11, 2017
bdcc8fd
Fix example
yotamberk Feb 17, 2017
57e87a5
Rename censor to stringifyObject in example
yotamberk Feb 25, 2017
da13445
Merge branch 'develop' of https://github.com/almende/vis into item-ev…
yotamberk Feb 25, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion examples/timeline/interaction/eventListeners.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@
timeline.on('rangechange', function (properties) {
logEvent('rangechange', properties);
});

timeline.on('rangechanged', function (properties) {
logEvent('rangechanged', properties);
});

timeline.on('select', function (properties) {
logEvent('select', properties);
});
Expand All @@ -52,6 +54,7 @@
logEvent('itemover', properties);
setHoveredItem(properties.item);
});

timeline.on('itemout', function (properties) {
logEvent('itemout', properties);
setHoveredItem('none');
Expand Down Expand Up @@ -83,11 +86,23 @@
logEvent(event, properties);
});

function stringifyObject (object) {
if (!object) return;
var replacer = function(key, value) {
if (value && value.tagName) {
return "DOM Element";
} else {
return value;
}
}
return JSON.stringify(object, replacer)
}

function logEvent(event, properties) {
var log = document.getElementById('log');
var msg = document.createElement('div');
msg.innerHTML = 'event=' + JSON.stringify(event) + ', ' +
'properties=' + JSON.stringify(properties);
'properties=' + stringifyObject(properties);
log.firstChild ? log.insertBefore(msg, log.firstChild) : log.appendChild(msg);
}

Expand Down
8 changes: 4 additions & 4 deletions lib/timeline/Range.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ Range.prototype.setRange = function(start, end, animation, byUser, event) {
start: new Date(me.start),
end: new Date(me.end),
byUser:byUser,
event: util.elementsCensor(event)
event: event
}

if (changed) {
Expand Down Expand Up @@ -248,7 +248,7 @@ Range.prototype.setRange = function(start, end, animation, byUser, event) {
start: new Date(this.start),
end: new Date(this.end),
byUser:byUser,
event: util.elementsCensor(event)
event: event
};
this.body.emitter.emit('rangechange', params);
this.body.emitter.emit('rangechanged', params);
Expand Down Expand Up @@ -532,7 +532,7 @@ Range.prototype._onDrag = function (event) {
start: startDate,
end: endDate,
byUser: true,
event: util.elementsCensor(event)
event: event
});

// fire a panmove event
Expand Down Expand Up @@ -565,7 +565,7 @@ Range.prototype._onDragEnd = function (event) {
start: new Date(this.start),
end: new Date(this.end),
byUser: true,
event: util.elementsCensor(event)
event: event
});
};

Expand Down
8 changes: 4 additions & 4 deletions lib/timeline/component/ItemSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,7 @@ ItemSet.prototype._onSelectItem = function (event) {
if (newSelection.length > 0 || oldSelection.length > 0) {
this.body.emitter.emit('select', {
items: newSelection,
event: util.elementsCensor(event)
event: event
});
}
};
Expand Down Expand Up @@ -1921,7 +1921,7 @@ ItemSet.prototype._onMouseOver = function (event) {

this.body.emitter.emit('itemover', {
item: item.id,
event: util.elementsCensor(event)
event: event
});
};
ItemSet.prototype._onMouseOut = function (event) {
Expand All @@ -1941,7 +1941,7 @@ ItemSet.prototype._onMouseOut = function (event) {

this.body.emitter.emit('itemout', {
item: item.id,
event: util.elementsCensor(event)
event: event
});
};
ItemSet.prototype._onMouseMove = function (event) {
Expand Down Expand Up @@ -2145,7 +2145,7 @@ ItemSet.prototype._onMultiSelectItem = function (event) {

this.body.emitter.emit('select', {
items: this.getSelection(),
event: util.elementsCensor(event)
event: event
});
}
};
Expand Down
17 changes: 0 additions & 17 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,6 @@ exports.isNumber = function (object) {
return (object instanceof Number || typeof object == 'number');
};

/**
* Censors object elements containing dom elements
* @param {*} object
* @return {Object} object without elements
*/
exports.elementsCensor = function (object) {
if (!object) return;
var replacer = function(key, value) {
if (value instanceof Element) {
return "DOM Element";
} else {
return value;
}
}
return JSON.parse(JSON.stringify(object, replacer))
}


/**
* Remove everything in the DOM object
Expand Down