diff --git a/lib/timeline/component/item/ItemBox.js b/lib/timeline/component/item/ItemBox.js index e1c23df7..282293e1 100644 --- a/lib/timeline/component/item/ItemBox.js +++ b/lib/timeline/component/item/ItemBox.js @@ -132,6 +132,18 @@ ItemBox.prototype.redraw = function() { this.dirty = true; } + // set all other fields as data- attributes + var auxiliaryData = Object.keys(this.data); + + for (var i in auxiliaryData) { + var c = auxiliaryData[i]; + if (['start', 'end', 'content', 'title', 'id', 'className', 'group', 'type'].indexOf(c) < 0) { + dom.content.setAttribute('data-' + c, this.data[c]); + } + } + + + // recalculate size if (this.dirty) { this.props.dot.height = dom.dot.offsetHeight; diff --git a/lib/timeline/component/item/ItemPoint.js b/lib/timeline/component/item/ItemPoint.js index 7f87665e..77f6a2a8 100644 --- a/lib/timeline/component/item/ItemPoint.js +++ b/lib/timeline/component/item/ItemPoint.js @@ -121,6 +121,16 @@ ItemPoint.prototype.redraw = function() { this.dirty = true; } + // set all other fields as data- attributes + var auxiliaryData = Object.keys(this.data); + + for (var i in auxiliaryData) { + var c = auxiliaryData[i]; + if (['start', 'end', 'content', 'title', 'id', 'className', 'group', 'type'].indexOf(c) < 0) { + dom.content.setAttribute('data-' + c, this.data[c]); + } + } + // recalculate size if (this.dirty) { this.width = dom.point.offsetWidth; diff --git a/lib/timeline/component/item/ItemRange.js b/lib/timeline/component/item/ItemRange.js index ebff69fb..d7068ade 100644 --- a/lib/timeline/component/item/ItemRange.js +++ b/lib/timeline/component/item/ItemRange.js @@ -115,6 +115,18 @@ ItemRange.prototype.redraw = function() { this.dirty = true; } + + // set all other fields as data- attributes + var auxiliaryData = Object.keys(this.data); + + for (var i in auxiliaryData) { + var c = auxiliaryData[i]; + if (['start', 'end', 'content', 'title', 'id', 'className', 'group', 'type'].indexOf(c) < 0) { + dom.content.setAttribute('data-' + c, this.data[c]); + } + } + + // recalculate size if (this.dirty) { // determine from css whether this box has overflow