vis-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,251 @@
|
|
1
|
+
/**
|
2
|
+
* @constructor ItemRange
|
3
|
+
* @extends Item
|
4
|
+
* @param {ItemSet} parent
|
5
|
+
* @param {Object} data Object containing parameters start, end
|
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 ItemRange (parent, data, options, defaultOptions) {
|
12
|
+
this.props = {
|
13
|
+
content: {
|
14
|
+
left: 0,
|
15
|
+
width: 0
|
16
|
+
}
|
17
|
+
};
|
18
|
+
|
19
|
+
Item.call(this, parent, data, options, defaultOptions);
|
20
|
+
}
|
21
|
+
|
22
|
+
ItemRange.prototype = new Item (null, null);
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Repaint the item
|
26
|
+
* @return {Boolean} changed
|
27
|
+
*/
|
28
|
+
ItemRange.prototype.repaint = function repaint() {
|
29
|
+
// TODO: make an efficient repaint
|
30
|
+
var changed = false;
|
31
|
+
var dom = this.dom;
|
32
|
+
|
33
|
+
if (!dom) {
|
34
|
+
this._create();
|
35
|
+
dom = this.dom;
|
36
|
+
changed = true;
|
37
|
+
}
|
38
|
+
|
39
|
+
if (dom) {
|
40
|
+
if (!this.parent) {
|
41
|
+
throw new Error('Cannot repaint item: no parent attached');
|
42
|
+
}
|
43
|
+
var foreground = this.parent.getForeground();
|
44
|
+
if (!foreground) {
|
45
|
+
throw new Error('Cannot repaint time axis: ' +
|
46
|
+
'parent has no foreground container element');
|
47
|
+
}
|
48
|
+
|
49
|
+
if (!dom.box.parentNode) {
|
50
|
+
foreground.appendChild(dom.box);
|
51
|
+
changed = true;
|
52
|
+
}
|
53
|
+
|
54
|
+
// update content
|
55
|
+
if (this.data.content != this.content) {
|
56
|
+
this.content = this.data.content;
|
57
|
+
if (this.content instanceof Element) {
|
58
|
+
dom.content.innerHTML = '';
|
59
|
+
dom.content.appendChild(this.content);
|
60
|
+
}
|
61
|
+
else if (this.data.content != undefined) {
|
62
|
+
dom.content.innerHTML = this.content;
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
throw new Error('Property "content" missing in item ' + this.data.id);
|
66
|
+
}
|
67
|
+
changed = true;
|
68
|
+
}
|
69
|
+
|
70
|
+
// update class
|
71
|
+
var className = (this.data.className? ' ' + this.data.className : '') +
|
72
|
+
(this.selected ? ' selected' : '');
|
73
|
+
if (this.className != className) {
|
74
|
+
this.className = className;
|
75
|
+
dom.box.className = 'item range' + className;
|
76
|
+
changed = true;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
return changed;
|
81
|
+
};
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Show the item in the DOM (when not already visible). The items DOM will
|
85
|
+
* be created when needed.
|
86
|
+
* @return {Boolean} changed
|
87
|
+
*/
|
88
|
+
ItemRange.prototype.show = function show() {
|
89
|
+
if (!this.dom || !this.dom.box.parentNode) {
|
90
|
+
return this.repaint();
|
91
|
+
}
|
92
|
+
else {
|
93
|
+
return false;
|
94
|
+
}
|
95
|
+
};
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Hide the item from the DOM (when visible)
|
99
|
+
* @return {Boolean} changed
|
100
|
+
*/
|
101
|
+
ItemRange.prototype.hide = function hide() {
|
102
|
+
var changed = false,
|
103
|
+
dom = this.dom;
|
104
|
+
if (dom) {
|
105
|
+
if (dom.box.parentNode) {
|
106
|
+
dom.box.parentNode.removeChild(dom.box);
|
107
|
+
changed = true;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
return changed;
|
111
|
+
};
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Reflow the item: calculate its actual size from the DOM
|
115
|
+
* @return {boolean} resized returns true if the axis is resized
|
116
|
+
* @override
|
117
|
+
*/
|
118
|
+
ItemRange.prototype.reflow = function reflow() {
|
119
|
+
var changed = 0,
|
120
|
+
dom,
|
121
|
+
props,
|
122
|
+
options,
|
123
|
+
margin,
|
124
|
+
padding,
|
125
|
+
parent,
|
126
|
+
start,
|
127
|
+
end,
|
128
|
+
data,
|
129
|
+
range,
|
130
|
+
update,
|
131
|
+
box,
|
132
|
+
parentWidth,
|
133
|
+
contentLeft,
|
134
|
+
orientation,
|
135
|
+
top;
|
136
|
+
|
137
|
+
if (this.data.start == undefined) {
|
138
|
+
throw new Error('Property "start" missing in item ' + this.data.id);
|
139
|
+
}
|
140
|
+
if (this.data.end == undefined) {
|
141
|
+
throw new Error('Property "end" missing in item ' + this.data.id);
|
142
|
+
}
|
143
|
+
|
144
|
+
data = this.data;
|
145
|
+
range = this.parent && this.parent.range;
|
146
|
+
if (data && range) {
|
147
|
+
// TODO: account for the width of the item. Take some margin
|
148
|
+
this.visible = (data.start < range.end) && (data.end > range.start);
|
149
|
+
}
|
150
|
+
else {
|
151
|
+
this.visible = false;
|
152
|
+
}
|
153
|
+
|
154
|
+
if (this.visible) {
|
155
|
+
dom = this.dom;
|
156
|
+
if (dom) {
|
157
|
+
props = this.props;
|
158
|
+
options = this.options;
|
159
|
+
parent = this.parent;
|
160
|
+
start = parent.toScreen(this.data.start);
|
161
|
+
end = parent.toScreen(this.data.end);
|
162
|
+
update = util.updateProperty;
|
163
|
+
box = dom.box;
|
164
|
+
parentWidth = parent.width;
|
165
|
+
orientation = options.orientation || this.defaultOptions.orientation;
|
166
|
+
margin = options.margin && options.margin.axis || this.defaultOptions.margin.axis;
|
167
|
+
padding = options.padding || this.defaultOptions.padding;
|
168
|
+
|
169
|
+
changed += update(props.content, 'width', dom.content.offsetWidth);
|
170
|
+
|
171
|
+
changed += update(this, 'height', box.offsetHeight);
|
172
|
+
|
173
|
+
// limit the width of the this, as browsers cannot draw very wide divs
|
174
|
+
if (start < -parentWidth) {
|
175
|
+
start = -parentWidth;
|
176
|
+
}
|
177
|
+
if (end > 2 * parentWidth) {
|
178
|
+
end = 2 * parentWidth;
|
179
|
+
}
|
180
|
+
|
181
|
+
// when range exceeds left of the window, position the contents at the left of the visible area
|
182
|
+
if (start < 0) {
|
183
|
+
contentLeft = Math.min(-start,
|
184
|
+
(end - start - props.content.width - 2 * padding));
|
185
|
+
// TODO: remove the need for options.padding. it's terrible.
|
186
|
+
}
|
187
|
+
else {
|
188
|
+
contentLeft = 0;
|
189
|
+
}
|
190
|
+
changed += update(props.content, 'left', contentLeft);
|
191
|
+
|
192
|
+
if (orientation == 'top') {
|
193
|
+
top = margin;
|
194
|
+
changed += update(this, 'top', top);
|
195
|
+
}
|
196
|
+
else {
|
197
|
+
// default or 'bottom'
|
198
|
+
top = parent.height - this.height - margin;
|
199
|
+
changed += update(this, 'top', top);
|
200
|
+
}
|
201
|
+
|
202
|
+
changed += update(this, 'left', start);
|
203
|
+
changed += update(this, 'width', Math.max(end - start, 1)); // TODO: reckon with border width;
|
204
|
+
}
|
205
|
+
else {
|
206
|
+
changed += 1;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
return (changed > 0);
|
211
|
+
};
|
212
|
+
|
213
|
+
/**
|
214
|
+
* Create an items DOM
|
215
|
+
* @private
|
216
|
+
*/
|
217
|
+
ItemRange.prototype._create = function _create() {
|
218
|
+
var dom = this.dom;
|
219
|
+
if (!dom) {
|
220
|
+
this.dom = dom = {};
|
221
|
+
// background box
|
222
|
+
dom.box = document.createElement('div');
|
223
|
+
// className is updated in repaint()
|
224
|
+
|
225
|
+
// contents box
|
226
|
+
dom.content = document.createElement('div');
|
227
|
+
dom.content.className = 'content';
|
228
|
+
dom.box.appendChild(dom.content);
|
229
|
+
|
230
|
+
// attach this item as attribute
|
231
|
+
dom.box['timeline-item'] = this;
|
232
|
+
}
|
233
|
+
};
|
234
|
+
|
235
|
+
/**
|
236
|
+
* Reposition the item, recalculate its left, top, and width, using the current
|
237
|
+
* range and size of the items itemset
|
238
|
+
* @override
|
239
|
+
*/
|
240
|
+
ItemRange.prototype.reposition = function reposition() {
|
241
|
+
var dom = this.dom,
|
242
|
+
props = this.props;
|
243
|
+
|
244
|
+
if (dom) {
|
245
|
+
dom.box.style.top = this.top + 'px';
|
246
|
+
dom.box.style.left = this.left + 'px';
|
247
|
+
dom.box.style.width = this.width + 'px';
|
248
|
+
|
249
|
+
dom.content.style.left = props.content.left + 'px';
|
250
|
+
}
|
251
|
+
};
|
@@ -0,0 +1,91 @@
|
|
1
|
+
/**
|
2
|
+
* @constructor ItemRangeOverflow
|
3
|
+
* @extends ItemRange
|
4
|
+
* @param {ItemSet} parent
|
5
|
+
* @param {Object} data Object containing parameters start, end
|
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 ItemRangeOverflow (parent, data, options, defaultOptions) {
|
12
|
+
this.props = {
|
13
|
+
content: {
|
14
|
+
left: 0,
|
15
|
+
width: 0
|
16
|
+
}
|
17
|
+
};
|
18
|
+
|
19
|
+
ItemRange.call(this, parent, data, options, defaultOptions);
|
20
|
+
}
|
21
|
+
|
22
|
+
ItemRangeOverflow.prototype = new ItemRange (null, null);
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Repaint the item
|
26
|
+
* @return {Boolean} changed
|
27
|
+
*/
|
28
|
+
ItemRangeOverflow.prototype.repaint = function repaint() {
|
29
|
+
// TODO: make an efficient repaint
|
30
|
+
var changed = false;
|
31
|
+
var dom = this.dom;
|
32
|
+
|
33
|
+
if (!dom) {
|
34
|
+
this._create();
|
35
|
+
dom = this.dom;
|
36
|
+
changed = true;
|
37
|
+
}
|
38
|
+
|
39
|
+
if (dom) {
|
40
|
+
if (!this.parent) {
|
41
|
+
throw new Error('Cannot repaint item: no parent attached');
|
42
|
+
}
|
43
|
+
var foreground = this.parent.getForeground();
|
44
|
+
if (!foreground) {
|
45
|
+
throw new Error('Cannot repaint time axis: ' +
|
46
|
+
'parent has no foreground container element');
|
47
|
+
}
|
48
|
+
|
49
|
+
if (!dom.box.parentNode) {
|
50
|
+
foreground.appendChild(dom.box);
|
51
|
+
changed = true;
|
52
|
+
}
|
53
|
+
|
54
|
+
// update content
|
55
|
+
if (this.data.content != this.content) {
|
56
|
+
this.content = this.data.content;
|
57
|
+
if (this.content instanceof Element) {
|
58
|
+
dom.content.innerHTML = '';
|
59
|
+
dom.content.appendChild(this.content);
|
60
|
+
}
|
61
|
+
else if (this.data.content != undefined) {
|
62
|
+
dom.content.innerHTML = this.content;
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
throw new Error('Property "content" missing in item ' + this.data.id);
|
66
|
+
}
|
67
|
+
changed = true;
|
68
|
+
}
|
69
|
+
|
70
|
+
// update class
|
71
|
+
var className = this.data.className ? (' ' + this.data.className) : '';
|
72
|
+
if (this.className != className) {
|
73
|
+
this.className = className;
|
74
|
+
dom.box.className = 'item rangeoverflow' + className;
|
75
|
+
changed = true;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
return changed;
|
80
|
+
};
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Return the items width
|
84
|
+
* @return {Number} width
|
85
|
+
*/
|
86
|
+
ItemRangeOverflow.prototype.getWidth = function getWidth() {
|
87
|
+
if (this.props.content !== undefined && this.width < this.props.content.width)
|
88
|
+
return this.props.content.width;
|
89
|
+
else
|
90
|
+
return this.width;
|
91
|
+
};
|