vis-rails 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.gitmodules +3 -0
- data/.project +11 -0
- data/Gemfile +4 -0
- data/LICENSE +202 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/vis/rails/engine.rb +6 -0
- data/lib/vis/rails/version.rb +5 -0
- data/lib/vis/rails.rb +7 -0
- data/vendor/assets/javascripts/vis.js +1 -0
- data/vendor/assets/stylesheets/vis.css +3 -0
- data/vendor/assets/vis/DataSet.js +936 -0
- data/vendor/assets/vis/DataView.js +281 -0
- data/vendor/assets/vis/EventBus.js +89 -0
- data/vendor/assets/vis/events.js +116 -0
- data/vendor/assets/vis/graph/ClusterMixin.js +1019 -0
- data/vendor/assets/vis/graph/Edge.js +620 -0
- data/vendor/assets/vis/graph/Graph.js +2111 -0
- data/vendor/assets/vis/graph/Groups.js +80 -0
- data/vendor/assets/vis/graph/Images.js +41 -0
- data/vendor/assets/vis/graph/NavigationMixin.js +245 -0
- data/vendor/assets/vis/graph/Node.js +978 -0
- data/vendor/assets/vis/graph/Popup.js +105 -0
- data/vendor/assets/vis/graph/SectorsMixin.js +547 -0
- data/vendor/assets/vis/graph/SelectionMixin.js +515 -0
- data/vendor/assets/vis/graph/dotparser.js +829 -0
- data/vendor/assets/vis/graph/img/downarrow.png +0 -0
- data/vendor/assets/vis/graph/img/leftarrow.png +0 -0
- data/vendor/assets/vis/graph/img/minus.png +0 -0
- data/vendor/assets/vis/graph/img/plus.png +0 -0
- data/vendor/assets/vis/graph/img/rightarrow.png +0 -0
- data/vendor/assets/vis/graph/img/uparrow.png +0 -0
- data/vendor/assets/vis/graph/img/zoomExtends.png +0 -0
- data/vendor/assets/vis/graph/shapes.js +225 -0
- data/vendor/assets/vis/module/exports.js +68 -0
- data/vendor/assets/vis/module/header.js +24 -0
- data/vendor/assets/vis/module/imports.js +32 -0
- data/vendor/assets/vis/shim.js +252 -0
- data/vendor/assets/vis/timeline/Controller.js +172 -0
- data/vendor/assets/vis/timeline/Range.js +553 -0
- data/vendor/assets/vis/timeline/Stack.js +192 -0
- data/vendor/assets/vis/timeline/TimeStep.js +449 -0
- data/vendor/assets/vis/timeline/Timeline.js +476 -0
- data/vendor/assets/vis/timeline/component/Component.js +148 -0
- data/vendor/assets/vis/timeline/component/ContentPanel.js +113 -0
- data/vendor/assets/vis/timeline/component/CurrentTime.js +101 -0
- data/vendor/assets/vis/timeline/component/CustomTime.js +255 -0
- data/vendor/assets/vis/timeline/component/Group.js +129 -0
- data/vendor/assets/vis/timeline/component/GroupSet.js +546 -0
- data/vendor/assets/vis/timeline/component/ItemSet.js +612 -0
- data/vendor/assets/vis/timeline/component/Panel.js +112 -0
- data/vendor/assets/vis/timeline/component/RootPanel.js +215 -0
- data/vendor/assets/vis/timeline/component/TimeAxis.js +522 -0
- data/vendor/assets/vis/timeline/component/css/currenttime.css +5 -0
- data/vendor/assets/vis/timeline/component/css/customtime.css +6 -0
- data/vendor/assets/vis/timeline/component/css/groupset.css +59 -0
- data/vendor/assets/vis/timeline/component/css/item.css +93 -0
- data/vendor/assets/vis/timeline/component/css/itemset.css +17 -0
- data/vendor/assets/vis/timeline/component/css/panel.css +14 -0
- data/vendor/assets/vis/timeline/component/css/timeaxis.css +41 -0
- data/vendor/assets/vis/timeline/component/css/timeline.css +2 -0
- data/vendor/assets/vis/timeline/component/item/Item.js +81 -0
- data/vendor/assets/vis/timeline/component/item/ItemBox.js +302 -0
- data/vendor/assets/vis/timeline/component/item/ItemPoint.js +237 -0
- data/vendor/assets/vis/timeline/component/item/ItemRange.js +251 -0
- data/vendor/assets/vis/timeline/component/item/ItemRangeOverflow.js +91 -0
- data/vendor/assets/vis/util.js +673 -0
- data/vis-rails.gemspec +47 -0
- metadata +142 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
.vis.timeline .axis {
|
2
|
+
position: relative;
|
3
|
+
}
|
4
|
+
|
5
|
+
.vis.timeline .axis .text {
|
6
|
+
position: absolute;
|
7
|
+
color: #4d4d4d;
|
8
|
+
padding: 3px;
|
9
|
+
white-space: nowrap;
|
10
|
+
}
|
11
|
+
|
12
|
+
.vis.timeline .axis .text.measure {
|
13
|
+
position: absolute;
|
14
|
+
padding-left: 0;
|
15
|
+
padding-right: 0;
|
16
|
+
margin-left: 0;
|
17
|
+
margin-right: 0;
|
18
|
+
visibility: hidden;
|
19
|
+
}
|
20
|
+
|
21
|
+
.vis.timeline .axis .grid.vertical {
|
22
|
+
position: absolute;
|
23
|
+
width: 0;
|
24
|
+
border-right: 1px solid;
|
25
|
+
}
|
26
|
+
|
27
|
+
.vis.timeline .axis .grid.horizontal {
|
28
|
+
position: absolute;
|
29
|
+
left: 0;
|
30
|
+
width: 100%;
|
31
|
+
height: 0;
|
32
|
+
border-bottom: 1px solid;
|
33
|
+
}
|
34
|
+
|
35
|
+
.vis.timeline .axis .grid.minor {
|
36
|
+
border-color: #e5e5e5;
|
37
|
+
}
|
38
|
+
|
39
|
+
.vis.timeline .axis .grid.major {
|
40
|
+
border-color: #bfbfbf;
|
41
|
+
}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/**
|
2
|
+
* @constructor Item
|
3
|
+
* @param {ItemSet} parent
|
4
|
+
* @param {Object} data Object containing (optional) parameters type,
|
5
|
+
* start, end, content, group, className.
|
6
|
+
* @param {Object} [options] Options to set initial property values
|
7
|
+
* @param {Object} [defaultOptions] default options
|
8
|
+
* // TODO: describe available options
|
9
|
+
*/
|
10
|
+
function Item (parent, data, options, defaultOptions) {
|
11
|
+
this.parent = parent;
|
12
|
+
this.data = data;
|
13
|
+
this.dom = null;
|
14
|
+
this.options = options || {};
|
15
|
+
this.defaultOptions = defaultOptions || {};
|
16
|
+
|
17
|
+
this.selected = false;
|
18
|
+
this.visible = false;
|
19
|
+
this.top = 0;
|
20
|
+
this.left = 0;
|
21
|
+
this.width = 0;
|
22
|
+
this.height = 0;
|
23
|
+
}
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Select current item
|
27
|
+
*/
|
28
|
+
Item.prototype.select = function select() {
|
29
|
+
this.selected = true;
|
30
|
+
if (this.visible) this.repaint();
|
31
|
+
};
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Unselect current item
|
35
|
+
*/
|
36
|
+
Item.prototype.unselect = function unselect() {
|
37
|
+
this.selected = false;
|
38
|
+
if (this.visible) this.repaint();
|
39
|
+
};
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Show the Item in the DOM (when not already visible)
|
43
|
+
* @return {Boolean} changed
|
44
|
+
*/
|
45
|
+
Item.prototype.show = function show() {
|
46
|
+
return false;
|
47
|
+
};
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Hide the Item from the DOM (when visible)
|
51
|
+
* @return {Boolean} changed
|
52
|
+
*/
|
53
|
+
Item.prototype.hide = function hide() {
|
54
|
+
return false;
|
55
|
+
};
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Repaint the item
|
59
|
+
* @return {Boolean} changed
|
60
|
+
*/
|
61
|
+
Item.prototype.repaint = function repaint() {
|
62
|
+
// should be implemented by the item
|
63
|
+
return false;
|
64
|
+
};
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Reflow the item
|
68
|
+
* @return {Boolean} resized
|
69
|
+
*/
|
70
|
+
Item.prototype.reflow = function reflow() {
|
71
|
+
// should be implemented by the item
|
72
|
+
return false;
|
73
|
+
};
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Return the items width
|
77
|
+
* @return {Integer} width
|
78
|
+
*/
|
79
|
+
Item.prototype.getWidth = function getWidth() {
|
80
|
+
return this.width;
|
81
|
+
}
|
@@ -0,0 +1,302 @@
|
|
1
|
+
/**
|
2
|
+
* @constructor ItemBox
|
3
|
+
* @extends Item
|
4
|
+
* @param {ItemSet} parent
|
5
|
+
* @param {Object} data Object containing parameters start
|
6
|
+
* content, className.
|
7
|
+
* @param {Object} [options] Options to set initial property values
|
8
|
+
* @param {Object} [defaultOptions] default options
|
9
|
+
* // TODO: describe available options
|
10
|
+
*/
|
11
|
+
function ItemBox (parent, data, options, defaultOptions) {
|
12
|
+
this.props = {
|
13
|
+
dot: {
|
14
|
+
left: 0,
|
15
|
+
top: 0,
|
16
|
+
width: 0,
|
17
|
+
height: 0
|
18
|
+
},
|
19
|
+
line: {
|
20
|
+
top: 0,
|
21
|
+
left: 0,
|
22
|
+
width: 0,
|
23
|
+
height: 0
|
24
|
+
}
|
25
|
+
};
|
26
|
+
|
27
|
+
Item.call(this, parent, data, options, defaultOptions);
|
28
|
+
}
|
29
|
+
|
30
|
+
ItemBox.prototype = new Item (null, null);
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Repaint the item
|
34
|
+
* @return {Boolean} changed
|
35
|
+
*/
|
36
|
+
ItemBox.prototype.repaint = function repaint() {
|
37
|
+
// TODO: make an efficient repaint
|
38
|
+
var changed = false;
|
39
|
+
var dom = this.dom;
|
40
|
+
|
41
|
+
if (!dom) {
|
42
|
+
this._create();
|
43
|
+
dom = this.dom;
|
44
|
+
changed = true;
|
45
|
+
}
|
46
|
+
|
47
|
+
if (dom) {
|
48
|
+
if (!this.parent) {
|
49
|
+
throw new Error('Cannot repaint item: no parent attached');
|
50
|
+
}
|
51
|
+
|
52
|
+
if (!dom.box.parentNode) {
|
53
|
+
var foreground = this.parent.getForeground();
|
54
|
+
if (!foreground) {
|
55
|
+
throw new Error('Cannot repaint time axis: ' +
|
56
|
+
'parent has no foreground container element');
|
57
|
+
}
|
58
|
+
foreground.appendChild(dom.box);
|
59
|
+
changed = true;
|
60
|
+
}
|
61
|
+
|
62
|
+
if (!dom.line.parentNode) {
|
63
|
+
var background = this.parent.getBackground();
|
64
|
+
if (!background) {
|
65
|
+
throw new Error('Cannot repaint time axis: ' +
|
66
|
+
'parent has no background container element');
|
67
|
+
}
|
68
|
+
background.appendChild(dom.line);
|
69
|
+
changed = true;
|
70
|
+
}
|
71
|
+
|
72
|
+
if (!dom.dot.parentNode) {
|
73
|
+
var axis = this.parent.getAxis();
|
74
|
+
if (!background) {
|
75
|
+
throw new Error('Cannot repaint time axis: ' +
|
76
|
+
'parent has no axis container element');
|
77
|
+
}
|
78
|
+
axis.appendChild(dom.dot);
|
79
|
+
changed = true;
|
80
|
+
}
|
81
|
+
|
82
|
+
// update contents
|
83
|
+
if (this.data.content != this.content) {
|
84
|
+
this.content = this.data.content;
|
85
|
+
if (this.content instanceof Element) {
|
86
|
+
dom.content.innerHTML = '';
|
87
|
+
dom.content.appendChild(this.content);
|
88
|
+
}
|
89
|
+
else if (this.data.content != undefined) {
|
90
|
+
dom.content.innerHTML = this.content;
|
91
|
+
}
|
92
|
+
else {
|
93
|
+
throw new Error('Property "content" missing in item ' + this.data.id);
|
94
|
+
}
|
95
|
+
changed = true;
|
96
|
+
}
|
97
|
+
|
98
|
+
// update class
|
99
|
+
var className = (this.data.className? ' ' + this.data.className : '') +
|
100
|
+
(this.selected ? ' selected' : '');
|
101
|
+
if (this.className != className) {
|
102
|
+
this.className = className;
|
103
|
+
dom.box.className = 'item box' + className;
|
104
|
+
dom.line.className = 'item line' + className;
|
105
|
+
dom.dot.className = 'item dot' + className;
|
106
|
+
changed = true;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
return changed;
|
111
|
+
};
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Show the item in the DOM (when not already visible). The items DOM will
|
115
|
+
* be created when needed.
|
116
|
+
* @return {Boolean} changed
|
117
|
+
*/
|
118
|
+
ItemBox.prototype.show = function show() {
|
119
|
+
if (!this.dom || !this.dom.box.parentNode) {
|
120
|
+
return this.repaint();
|
121
|
+
}
|
122
|
+
else {
|
123
|
+
return false;
|
124
|
+
}
|
125
|
+
};
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Hide the item from the DOM (when visible)
|
129
|
+
* @return {Boolean} changed
|
130
|
+
*/
|
131
|
+
ItemBox.prototype.hide = function hide() {
|
132
|
+
var changed = false,
|
133
|
+
dom = this.dom;
|
134
|
+
if (dom) {
|
135
|
+
if (dom.box.parentNode) {
|
136
|
+
dom.box.parentNode.removeChild(dom.box);
|
137
|
+
changed = true;
|
138
|
+
}
|
139
|
+
if (dom.line.parentNode) {
|
140
|
+
dom.line.parentNode.removeChild(dom.line);
|
141
|
+
}
|
142
|
+
if (dom.dot.parentNode) {
|
143
|
+
dom.dot.parentNode.removeChild(dom.dot);
|
144
|
+
}
|
145
|
+
}
|
146
|
+
return changed;
|
147
|
+
};
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Reflow the item: calculate its actual size and position from the DOM
|
151
|
+
* @return {boolean} resized returns true if the axis is resized
|
152
|
+
* @override
|
153
|
+
*/
|
154
|
+
ItemBox.prototype.reflow = function reflow() {
|
155
|
+
var changed = 0,
|
156
|
+
update,
|
157
|
+
dom,
|
158
|
+
props,
|
159
|
+
options,
|
160
|
+
margin,
|
161
|
+
start,
|
162
|
+
align,
|
163
|
+
orientation,
|
164
|
+
top,
|
165
|
+
left,
|
166
|
+
data,
|
167
|
+
range;
|
168
|
+
|
169
|
+
if (this.data.start == undefined) {
|
170
|
+
throw new Error('Property "start" missing in item ' + this.data.id);
|
171
|
+
}
|
172
|
+
|
173
|
+
data = this.data;
|
174
|
+
range = this.parent && this.parent.range;
|
175
|
+
if (data && range) {
|
176
|
+
// TODO: account for the width of the item
|
177
|
+
var interval = (range.end - range.start);
|
178
|
+
this.visible = (data.start > range.start - interval) && (data.start < range.end + interval);
|
179
|
+
}
|
180
|
+
else {
|
181
|
+
this.visible = false;
|
182
|
+
}
|
183
|
+
|
184
|
+
if (this.visible) {
|
185
|
+
dom = this.dom;
|
186
|
+
if (dom) {
|
187
|
+
update = util.updateProperty;
|
188
|
+
props = this.props;
|
189
|
+
options = this.options;
|
190
|
+
start = this.parent.toScreen(this.data.start);
|
191
|
+
align = options.align || this.defaultOptions.align;
|
192
|
+
margin = options.margin && options.margin.axis || this.defaultOptions.margin.axis;
|
193
|
+
orientation = options.orientation || this.defaultOptions.orientation;
|
194
|
+
|
195
|
+
changed += update(props.dot, 'height', dom.dot.offsetHeight);
|
196
|
+
changed += update(props.dot, 'width', dom.dot.offsetWidth);
|
197
|
+
changed += update(props.line, 'width', dom.line.offsetWidth);
|
198
|
+
changed += update(props.line, 'height', dom.line.offsetHeight);
|
199
|
+
changed += update(props.line, 'top', dom.line.offsetTop);
|
200
|
+
changed += update(this, 'width', dom.box.offsetWidth);
|
201
|
+
changed += update(this, 'height', dom.box.offsetHeight);
|
202
|
+
if (align == 'right') {
|
203
|
+
left = start - this.width;
|
204
|
+
}
|
205
|
+
else if (align == 'left') {
|
206
|
+
left = start;
|
207
|
+
}
|
208
|
+
else {
|
209
|
+
// default or 'center'
|
210
|
+
left = start - this.width / 2;
|
211
|
+
}
|
212
|
+
changed += update(this, 'left', left);
|
213
|
+
|
214
|
+
changed += update(props.line, 'left', start - props.line.width / 2);
|
215
|
+
changed += update(props.dot, 'left', start - props.dot.width / 2);
|
216
|
+
changed += update(props.dot, 'top', -props.dot.height / 2);
|
217
|
+
if (orientation == 'top') {
|
218
|
+
top = margin;
|
219
|
+
|
220
|
+
changed += update(this, 'top', top);
|
221
|
+
}
|
222
|
+
else {
|
223
|
+
// default or 'bottom'
|
224
|
+
var parentHeight = this.parent.height;
|
225
|
+
top = parentHeight - this.height - margin;
|
226
|
+
|
227
|
+
changed += update(this, 'top', top);
|
228
|
+
}
|
229
|
+
}
|
230
|
+
else {
|
231
|
+
changed += 1;
|
232
|
+
}
|
233
|
+
}
|
234
|
+
|
235
|
+
return (changed > 0);
|
236
|
+
};
|
237
|
+
|
238
|
+
/**
|
239
|
+
* Create an items DOM
|
240
|
+
* @private
|
241
|
+
*/
|
242
|
+
ItemBox.prototype._create = function _create() {
|
243
|
+
var dom = this.dom;
|
244
|
+
if (!dom) {
|
245
|
+
this.dom = dom = {};
|
246
|
+
|
247
|
+
// create the box
|
248
|
+
dom.box = document.createElement('DIV');
|
249
|
+
// className is updated in repaint()
|
250
|
+
|
251
|
+
// contents box (inside the background box). used for making margins
|
252
|
+
dom.content = document.createElement('DIV');
|
253
|
+
dom.content.className = 'content';
|
254
|
+
dom.box.appendChild(dom.content);
|
255
|
+
|
256
|
+
// line to axis
|
257
|
+
dom.line = document.createElement('DIV');
|
258
|
+
dom.line.className = 'line';
|
259
|
+
|
260
|
+
// dot on axis
|
261
|
+
dom.dot = document.createElement('DIV');
|
262
|
+
dom.dot.className = 'dot';
|
263
|
+
|
264
|
+
// attach this item as attribute
|
265
|
+
dom.box['timeline-item'] = this;
|
266
|
+
}
|
267
|
+
};
|
268
|
+
|
269
|
+
/**
|
270
|
+
* Reposition the item, recalculate its left, top, and width, using the current
|
271
|
+
* range and size of the items itemset
|
272
|
+
* @override
|
273
|
+
*/
|
274
|
+
ItemBox.prototype.reposition = function reposition() {
|
275
|
+
var dom = this.dom,
|
276
|
+
props = this.props,
|
277
|
+
orientation = this.options.orientation || this.defaultOptions.orientation;
|
278
|
+
|
279
|
+
if (dom) {
|
280
|
+
var box = dom.box,
|
281
|
+
line = dom.line,
|
282
|
+
dot = dom.dot;
|
283
|
+
|
284
|
+
box.style.left = this.left + 'px';
|
285
|
+
box.style.top = this.top + 'px';
|
286
|
+
|
287
|
+
line.style.left = props.line.left + 'px';
|
288
|
+
if (orientation == 'top') {
|
289
|
+
line.style.top = 0 + 'px';
|
290
|
+
line.style.height = this.top + 'px';
|
291
|
+
}
|
292
|
+
else {
|
293
|
+
// orientation 'bottom'
|
294
|
+
line.style.top = (this.top + this.height) + 'px';
|
295
|
+
line.style.height = Math.max(this.parent.height - this.top - this.height +
|
296
|
+
this.props.dot.height / 2, 0) + 'px';
|
297
|
+
}
|
298
|
+
|
299
|
+
dot.style.left = props.dot.left + 'px';
|
300
|
+
dot.style.top = props.dot.top + 'px';
|
301
|
+
}
|
302
|
+
};
|
@@ -0,0 +1,237 @@
|
|
1
|
+
/**
|
2
|
+
* @constructor ItemPoint
|
3
|
+
* @extends Item
|
4
|
+
* @param {ItemSet} parent
|
5
|
+
* @param {Object} data Object containing parameters start
|
6
|
+
* content, className.
|
7
|
+
* @param {Object} [options] Options to set initial property values
|
8
|
+
* @param {Object} [defaultOptions] default options
|
9
|
+
* // TODO: describe available options
|
10
|
+
*/
|
11
|
+
function ItemPoint (parent, data, options, defaultOptions) {
|
12
|
+
this.props = {
|
13
|
+
dot: {
|
14
|
+
top: 0,
|
15
|
+
width: 0,
|
16
|
+
height: 0
|
17
|
+
},
|
18
|
+
content: {
|
19
|
+
height: 0,
|
20
|
+
marginLeft: 0
|
21
|
+
}
|
22
|
+
};
|
23
|
+
|
24
|
+
Item.call(this, parent, data, options, defaultOptions);
|
25
|
+
}
|
26
|
+
|
27
|
+
ItemPoint.prototype = new Item (null, null);
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Repaint the item
|
31
|
+
* @return {Boolean} changed
|
32
|
+
*/
|
33
|
+
ItemPoint.prototype.repaint = function repaint() {
|
34
|
+
// TODO: make an efficient repaint
|
35
|
+
var changed = false;
|
36
|
+
var dom = this.dom;
|
37
|
+
|
38
|
+
if (!dom) {
|
39
|
+
this._create();
|
40
|
+
dom = this.dom;
|
41
|
+
changed = true;
|
42
|
+
}
|
43
|
+
|
44
|
+
if (dom) {
|
45
|
+
if (!this.parent) {
|
46
|
+
throw new Error('Cannot repaint item: no parent attached');
|
47
|
+
}
|
48
|
+
var foreground = this.parent.getForeground();
|
49
|
+
if (!foreground) {
|
50
|
+
throw new Error('Cannot repaint time axis: ' +
|
51
|
+
'parent has no foreground container element');
|
52
|
+
}
|
53
|
+
|
54
|
+
if (!dom.point.parentNode) {
|
55
|
+
foreground.appendChild(dom.point);
|
56
|
+
foreground.appendChild(dom.point);
|
57
|
+
changed = true;
|
58
|
+
}
|
59
|
+
|
60
|
+
// update contents
|
61
|
+
if (this.data.content != this.content) {
|
62
|
+
this.content = this.data.content;
|
63
|
+
if (this.content instanceof Element) {
|
64
|
+
dom.content.innerHTML = '';
|
65
|
+
dom.content.appendChild(this.content);
|
66
|
+
}
|
67
|
+
else if (this.data.content != undefined) {
|
68
|
+
dom.content.innerHTML = this.content;
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
throw new Error('Property "content" missing in item ' + this.data.id);
|
72
|
+
}
|
73
|
+
changed = true;
|
74
|
+
}
|
75
|
+
|
76
|
+
// update class
|
77
|
+
var className = (this.data.className? ' ' + this.data.className : '') +
|
78
|
+
(this.selected ? ' selected' : '');
|
79
|
+
if (this.className != className) {
|
80
|
+
this.className = className;
|
81
|
+
dom.point.className = 'item point' + className;
|
82
|
+
changed = true;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
return changed;
|
87
|
+
};
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Show the item in the DOM (when not already visible). The items DOM will
|
91
|
+
* be created when needed.
|
92
|
+
* @return {Boolean} changed
|
93
|
+
*/
|
94
|
+
ItemPoint.prototype.show = function show() {
|
95
|
+
if (!this.dom || !this.dom.point.parentNode) {
|
96
|
+
return this.repaint();
|
97
|
+
}
|
98
|
+
else {
|
99
|
+
return false;
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Hide the item from the DOM (when visible)
|
105
|
+
* @return {Boolean} changed
|
106
|
+
*/
|
107
|
+
ItemPoint.prototype.hide = function hide() {
|
108
|
+
var changed = false,
|
109
|
+
dom = this.dom;
|
110
|
+
if (dom) {
|
111
|
+
if (dom.point.parentNode) {
|
112
|
+
dom.point.parentNode.removeChild(dom.point);
|
113
|
+
changed = true;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
return changed;
|
117
|
+
};
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Reflow the item: calculate its actual size from the DOM
|
121
|
+
* @return {boolean} resized returns true if the axis is resized
|
122
|
+
* @override
|
123
|
+
*/
|
124
|
+
ItemPoint.prototype.reflow = function reflow() {
|
125
|
+
var changed = 0,
|
126
|
+
update,
|
127
|
+
dom,
|
128
|
+
props,
|
129
|
+
options,
|
130
|
+
margin,
|
131
|
+
orientation,
|
132
|
+
start,
|
133
|
+
top,
|
134
|
+
data,
|
135
|
+
range;
|
136
|
+
|
137
|
+
if (this.data.start == undefined) {
|
138
|
+
throw new Error('Property "start" missing in item ' + this.data.id);
|
139
|
+
}
|
140
|
+
|
141
|
+
data = this.data;
|
142
|
+
range = this.parent && this.parent.range;
|
143
|
+
if (data && range) {
|
144
|
+
// TODO: account for the width of the item
|
145
|
+
var interval = (range.end - range.start);
|
146
|
+
this.visible = (data.start > range.start - interval) && (data.start < range.end);
|
147
|
+
}
|
148
|
+
else {
|
149
|
+
this.visible = false;
|
150
|
+
}
|
151
|
+
|
152
|
+
if (this.visible) {
|
153
|
+
dom = this.dom;
|
154
|
+
if (dom) {
|
155
|
+
update = util.updateProperty;
|
156
|
+
props = this.props;
|
157
|
+
options = this.options;
|
158
|
+
orientation = options.orientation || this.defaultOptions.orientation;
|
159
|
+
margin = options.margin && options.margin.axis || this.defaultOptions.margin.axis;
|
160
|
+
start = this.parent.toScreen(this.data.start);
|
161
|
+
|
162
|
+
changed += update(this, 'width', dom.point.offsetWidth);
|
163
|
+
changed += update(this, 'height', dom.point.offsetHeight);
|
164
|
+
changed += update(props.dot, 'width', dom.dot.offsetWidth);
|
165
|
+
changed += update(props.dot, 'height', dom.dot.offsetHeight);
|
166
|
+
changed += update(props.content, 'height', dom.content.offsetHeight);
|
167
|
+
|
168
|
+
if (orientation == 'top') {
|
169
|
+
top = margin;
|
170
|
+
}
|
171
|
+
else {
|
172
|
+
// default or 'bottom'
|
173
|
+
var parentHeight = this.parent.height;
|
174
|
+
top = Math.max(parentHeight - this.height - margin, 0);
|
175
|
+
}
|
176
|
+
changed += update(this, 'top', top);
|
177
|
+
changed += update(this, 'left', start - props.dot.width / 2);
|
178
|
+
changed += update(props.content, 'marginLeft', 1.5 * props.dot.width);
|
179
|
+
//changed += update(props.content, 'marginRight', 0.5 * props.dot.width); // TODO
|
180
|
+
|
181
|
+
changed += update(props.dot, 'top', (this.height - props.dot.height) / 2);
|
182
|
+
}
|
183
|
+
else {
|
184
|
+
changed += 1;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
return (changed > 0);
|
189
|
+
};
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Create an items DOM
|
193
|
+
* @private
|
194
|
+
*/
|
195
|
+
ItemPoint.prototype._create = function _create() {
|
196
|
+
var dom = this.dom;
|
197
|
+
if (!dom) {
|
198
|
+
this.dom = dom = {};
|
199
|
+
|
200
|
+
// background box
|
201
|
+
dom.point = document.createElement('div');
|
202
|
+
// className is updated in repaint()
|
203
|
+
|
204
|
+
// contents box, right from the dot
|
205
|
+
dom.content = document.createElement('div');
|
206
|
+
dom.content.className = 'content';
|
207
|
+
dom.point.appendChild(dom.content);
|
208
|
+
|
209
|
+
// dot at start
|
210
|
+
dom.dot = document.createElement('div');
|
211
|
+
dom.dot.className = 'dot';
|
212
|
+
dom.point.appendChild(dom.dot);
|
213
|
+
|
214
|
+
// attach this item as attribute
|
215
|
+
dom.point['timeline-item'] = this;
|
216
|
+
}
|
217
|
+
};
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Reposition the item, recalculate its left, top, and width, using the current
|
221
|
+
* range and size of the items itemset
|
222
|
+
* @override
|
223
|
+
*/
|
224
|
+
ItemPoint.prototype.reposition = function reposition() {
|
225
|
+
var dom = this.dom,
|
226
|
+
props = this.props;
|
227
|
+
|
228
|
+
if (dom) {
|
229
|
+
dom.point.style.top = this.top + 'px';
|
230
|
+
dom.point.style.left = this.left + 'px';
|
231
|
+
|
232
|
+
dom.content.style.marginLeft = props.content.marginLeft + 'px';
|
233
|
+
//dom.content.style.marginRight = props.content.marginRight + 'px'; // TODO
|
234
|
+
|
235
|
+
dom.dot.style.top = props.dot.top + 'px';
|
236
|
+
}
|
237
|
+
};
|