Browse Source

Store additional item fields as data- attributes

If additional item fields are defined on the DataSet or array being
passed to the timeline, store them as data- attributes on the content
element.
v3_develop
Dan Turkenkopf 10 years ago
parent
commit
67915d5806
3 changed files with 34 additions and 0 deletions
  1. +12
    -0
      lib/timeline/component/item/ItemBox.js
  2. +10
    -0
      lib/timeline/component/item/ItemPoint.js
  3. +12
    -0
      lib/timeline/component/item/ItemRange.js

+ 12
- 0
lib/timeline/component/item/ItemBox.js View File

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

+ 10
- 0
lib/timeline/component/item/ItemPoint.js View File

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

+ 12
- 0
lib/timeline/component/item/ItemRange.js View File

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

Loading…
Cancel
Save