Browse Source

Simplified the background item support for empty/undefined contents

v3_develop
jos 10 years ago
parent
commit
31e0c20f72
3 changed files with 5 additions and 29 deletions
  1. +2
    -9
      lib/timeline/component/css/item.css
  2. +1
    -18
      lib/timeline/component/item/BackgroundItem.js
  3. +2
    -2
      lib/timeline/component/item/Item.js

+ 2
- 9
lib/timeline/component/css/item.css View File

@ -54,8 +54,8 @@
border: none; border: none;
background-color: rgba(213, 221, 246, 0.4); background-color: rgba(213, 221, 246, 0.4);
box-sizing: border-box; box-sizing: border-box;
padding:0px;
margin:0px;
padding: 0;
margin: 0;
top: 0; top: 0;
bottom: 0; bottom: 0;
} }
@ -74,13 +74,6 @@
max-width: 100%; max-width: 100%;
margin: 5px; margin: 5px;
} }
.vis.timeline .item.background .noContent {
position: absolute;
display: inline-block;
overflow: hidden;
max-width: 100%;
margin: 0px;
}
.vis.timeline .item.line { .vis.timeline .item.line {
padding: 0; padding: 0;

+ 1
- 18
lib/timeline/component/item/BackgroundItem.js View File

@ -65,14 +65,7 @@ BackgroundItem.prototype.redraw = function() {
// contents box // contents box
dom.content = document.createElement('div'); dom.content = document.createElement('div');
if (this.data.content === undefined) {
dom.content.className = 'noContent';
this.emptyContent = true;
}
else {
dom.content.className = 'content';
this.emptyContent = false;
}
dom.content.className = 'content';
dom.box.appendChild(dom.content); dom.box.appendChild(dom.content);
// attach this item as attribute // attach this item as attribute
@ -99,16 +92,6 @@ BackgroundItem.prototype.redraw = function() {
// - the item's data is changed // - the item's data is changed
// - the item is selected/deselected // - the item is selected/deselected
if (this.dirty) { if (this.dirty) {
// only change content class when needed
if (this.data.content === undefined && this.emptyContent == false) {
dom.content.className = 'noContent';
this.emptyContent = true;
}
else if (this.data.content !== undefined && this.emptyContent == true) {
dom.content.className = 'content';
this.emptyContent = false;
}
this._updateContents(this.dom.content); this._updateContents(this.dom.content);
this._updateTitle(this.dom.content); this._updateTitle(this.dom.content);
this._updateDataAttributes(this.dom.content); this._updateDataAttributes(this.dom.content);

+ 2
- 2
lib/timeline/component/item/Item.js View File

@ -176,8 +176,8 @@ Item.prototype._updateContents = function (element) {
element.innerHTML = content; element.innerHTML = content;
} }
else { else {
if (!(this.data.type == "background" && this.data.content === undefined)) {
throw new Error('Property "content" missing in item ' + this.data.id);
if (!(this.data.type == 'background' && this.data.content === undefined)) {
throw new Error('Property "content" missing in item ' + this.id);
} }
} }
}; };

Loading…
Cancel
Save