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,80 @@
|
|
1
|
+
/**
|
2
|
+
* @class Groups
|
3
|
+
* This class can store groups and properties specific for groups.
|
4
|
+
*/
|
5
|
+
Groups = function () {
|
6
|
+
this.clear();
|
7
|
+
this.defaultIndex = 0;
|
8
|
+
};
|
9
|
+
|
10
|
+
|
11
|
+
/**
|
12
|
+
* default constants for group colors
|
13
|
+
*/
|
14
|
+
Groups.DEFAULT = [
|
15
|
+
{border: "#2B7CE9", background: "#97C2FC", highlight: {border: "#2B7CE9", background: "#D2E5FF"}}, // blue
|
16
|
+
{border: "#FFA500", background: "#FFFF00", highlight: {border: "#FFA500", background: "#FFFFA3"}}, // yellow
|
17
|
+
{border: "#FA0A10", background: "#FB7E81", highlight: {border: "#FA0A10", background: "#FFAFB1"}}, // red
|
18
|
+
{border: "#41A906", background: "#7BE141", highlight: {border: "#41A906", background: "#A1EC76"}}, // green
|
19
|
+
{border: "#E129F0", background: "#EB7DF4", highlight: {border: "#E129F0", background: "#F0B3F5"}}, // magenta
|
20
|
+
{border: "#7C29F0", background: "#AD85E4", highlight: {border: "#7C29F0", background: "#D3BDF0"}}, // purple
|
21
|
+
{border: "#C37F00", background: "#FFA807", highlight: {border: "#C37F00", background: "#FFCA66"}}, // orange
|
22
|
+
{border: "#4220FB", background: "#6E6EFD", highlight: {border: "#4220FB", background: "#9B9BFD"}}, // darkblue
|
23
|
+
{border: "#FD5A77", background: "#FFC0CB", highlight: {border: "#FD5A77", background: "#FFD1D9"}}, // pink
|
24
|
+
{border: "#4AD63A", background: "#C2FABC", highlight: {border: "#4AD63A", background: "#E6FFE3"}} // mint
|
25
|
+
];
|
26
|
+
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Clear all groups
|
30
|
+
*/
|
31
|
+
Groups.prototype.clear = function () {
|
32
|
+
this.groups = {};
|
33
|
+
this.groups.length = function()
|
34
|
+
{
|
35
|
+
var i = 0;
|
36
|
+
for ( var p in this ) {
|
37
|
+
if (this.hasOwnProperty(p)) {
|
38
|
+
i++;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
return i;
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
|
46
|
+
/**
|
47
|
+
* get group properties of a groupname. If groupname is not found, a new group
|
48
|
+
* is added.
|
49
|
+
* @param {*} groupname Can be a number, string, Date, etc.
|
50
|
+
* @return {Object} group The created group, containing all group properties
|
51
|
+
*/
|
52
|
+
Groups.prototype.get = function (groupname) {
|
53
|
+
var group = this.groups[groupname];
|
54
|
+
|
55
|
+
if (group == undefined) {
|
56
|
+
// create new group
|
57
|
+
var index = this.defaultIndex % Groups.DEFAULT.length;
|
58
|
+
this.defaultIndex++;
|
59
|
+
group = {};
|
60
|
+
group.color = Groups.DEFAULT[index];
|
61
|
+
this.groups[groupname] = group;
|
62
|
+
}
|
63
|
+
|
64
|
+
return group;
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Add a custom group style
|
69
|
+
* @param {String} groupname
|
70
|
+
* @param {Object} style An object containing borderColor,
|
71
|
+
* backgroundColor, etc.
|
72
|
+
* @return {Object} group The created group object
|
73
|
+
*/
|
74
|
+
Groups.prototype.add = function (groupname, style) {
|
75
|
+
this.groups[groupname] = style;
|
76
|
+
if (style.color) {
|
77
|
+
style.color = Node.parseColor(style.color);
|
78
|
+
}
|
79
|
+
return style;
|
80
|
+
};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
/**
|
2
|
+
* @class Images
|
3
|
+
* This class loads images and keeps them stored.
|
4
|
+
*/
|
5
|
+
Images = function () {
|
6
|
+
this.images = {};
|
7
|
+
|
8
|
+
this.callback = undefined;
|
9
|
+
};
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Set an onload callback function. This will be called each time an image
|
13
|
+
* is loaded
|
14
|
+
* @param {function} callback
|
15
|
+
*/
|
16
|
+
Images.prototype.setOnloadCallback = function(callback) {
|
17
|
+
this.callback = callback;
|
18
|
+
};
|
19
|
+
|
20
|
+
/**
|
21
|
+
*
|
22
|
+
* @param {string} url Url of the image
|
23
|
+
* @return {Image} img The image object
|
24
|
+
*/
|
25
|
+
Images.prototype.load = function(url) {
|
26
|
+
var img = this.images[url];
|
27
|
+
if (img == undefined) {
|
28
|
+
// create the image
|
29
|
+
var images = this;
|
30
|
+
img = new Image();
|
31
|
+
this.images[url] = img;
|
32
|
+
img.onload = function() {
|
33
|
+
if (images.callback) {
|
34
|
+
images.callback(this);
|
35
|
+
}
|
36
|
+
};
|
37
|
+
img.src = url;
|
38
|
+
}
|
39
|
+
|
40
|
+
return img;
|
41
|
+
};
|
@@ -0,0 +1,245 @@
|
|
1
|
+
/**
|
2
|
+
* Created by Alex on 1/22/14.
|
3
|
+
*/
|
4
|
+
|
5
|
+
var NavigationMixin = {
|
6
|
+
|
7
|
+
/**
|
8
|
+
* This function moves the navigation controls if the canvas size has been changed. If the arugments
|
9
|
+
* verticaAlignTop and horizontalAlignLeft are false, the correction will be made
|
10
|
+
*
|
11
|
+
* @private
|
12
|
+
*/
|
13
|
+
_relocateNavigation : function() {
|
14
|
+
if (this.sectors !== undefined) {
|
15
|
+
var xOffset = this.navigationClientWidth - this.frame.canvas.clientWidth;
|
16
|
+
var yOffset = this.navigationClientHeight - this.frame.canvas.clientHeight;
|
17
|
+
this.navigationClientWidth = this.frame.canvas.clientWidth;
|
18
|
+
this.navigationClientHeight = this.frame.canvas.clientHeight;
|
19
|
+
var node = null;
|
20
|
+
|
21
|
+
for (var nodeId in this.sectors["navigation"]["nodes"]) {
|
22
|
+
if (this.sectors["navigation"]["nodes"].hasOwnProperty(nodeId)) {
|
23
|
+
node = this.sectors["navigation"]["nodes"][nodeId];
|
24
|
+
if (!node.horizontalAlignLeft) {
|
25
|
+
node.x -= xOffset;
|
26
|
+
}
|
27
|
+
if (!node.verticalAlignTop) {
|
28
|
+
node.y -= yOffset;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
},
|
34
|
+
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Creation of the navigation controls nodes. They are drawn over the rest of the nodes and are not affected by scale and translation
|
38
|
+
* they have a triggerFunction which is called on click. If the position of the navigation controls is dependent
|
39
|
+
* on this.frame.canvas.clientWidth or this.frame.canvas.clientHeight, we flag horizontalAlignLeft and verticalAlignTop false.
|
40
|
+
* This means that the location will be corrected by the _relocateNavigation function on a size change of the canvas.
|
41
|
+
*
|
42
|
+
* @private
|
43
|
+
*/
|
44
|
+
_loadNavigationElements : function() {
|
45
|
+
var DIR = this.constants.navigation.iconPath;
|
46
|
+
this.navigationClientWidth = this.frame.canvas.clientWidth;
|
47
|
+
this.navigationClientHeight = this.frame.canvas.clientHeight;
|
48
|
+
if (this.navigationClientWidth === undefined) {
|
49
|
+
this.navigationClientWidth = 0;
|
50
|
+
this.navigationClientHeight = 0;
|
51
|
+
}
|
52
|
+
var offset = 15;
|
53
|
+
var intermediateOffset = 7;
|
54
|
+
var navigationNodes = [
|
55
|
+
{id: 'navigation_up', shape: 'image', image: DIR + '/uparrow.png', triggerFunction: "_moveUp",
|
56
|
+
verticalAlignTop: false, x: 45 + offset + intermediateOffset, y: this.navigationClientHeight - 45 - offset - intermediateOffset},
|
57
|
+
{id: 'navigation_down', shape: 'image', image: DIR + '/downarrow.png', triggerFunction: "_moveDown",
|
58
|
+
verticalAlignTop: false, x: 45 + offset + intermediateOffset, y: this.navigationClientHeight - 15 - offset},
|
59
|
+
{id: 'navigation_left', shape: 'image', image: DIR + '/leftarrow.png', triggerFunction: "_moveLeft",
|
60
|
+
verticalAlignTop: false, x: 15 + offset, y: this.navigationClientHeight - 15 - offset},
|
61
|
+
{id: 'navigation_right', shape: 'image', image: DIR + '/rightarrow.png',triggerFunction: "_moveRight",
|
62
|
+
verticalAlignTop: false, x: 75 + offset + 2 * intermediateOffset, y: this.navigationClientHeight - 15 - offset},
|
63
|
+
|
64
|
+
{id: 'navigation_plus', shape: 'image', image: DIR + '/plus.png', triggerFunction: "_zoomIn",
|
65
|
+
verticalAlignTop: false, horizontalAlignLeft: false,
|
66
|
+
x: this.navigationClientWidth - 45 - offset - intermediateOffset, y: this.navigationClientHeight - 15 - offset},
|
67
|
+
{id: 'navigation_min', shape: 'image', image: DIR + '/minus.png', triggerFunction: "_zoomOut",
|
68
|
+
verticalAlignTop: false, horizontalAlignLeft: false,
|
69
|
+
x: this.navigationClientWidth - 15 - offset, y: this.navigationClientHeight - 15 - offset},
|
70
|
+
{id: 'navigation_zoomExtends', shape: 'image', image: DIR + '/zoomExtends.png', triggerFunction: "zoomToFit",
|
71
|
+
verticalAlignTop: false, horizontalAlignLeft: false,
|
72
|
+
x: this.navigationClientWidth - 15 - offset, y: this.navigationClientHeight - 45 - offset - intermediateOffset}
|
73
|
+
];
|
74
|
+
|
75
|
+
var nodeObj = null;
|
76
|
+
for (var i = 0; i < navigationNodes.length; i++) {
|
77
|
+
nodeObj = this.sectors["navigation"]['nodes'];
|
78
|
+
nodeObj[navigationNodes[i]['id']] = new Node(navigationNodes[i], this.images, this.groups, this.constants);
|
79
|
+
}
|
80
|
+
},
|
81
|
+
|
82
|
+
|
83
|
+
/**
|
84
|
+
* By setting the clustersize to be larger than 1, we use the clustering drawing method
|
85
|
+
* to illustrate the buttons are presed. We call this highlighting.
|
86
|
+
*
|
87
|
+
* @param {String} elementId
|
88
|
+
* @private
|
89
|
+
*/
|
90
|
+
_highlightNavigationElement : function(elementId) {
|
91
|
+
if (this.sectors["navigation"]["nodes"].hasOwnProperty(elementId)) {
|
92
|
+
this.sectors["navigation"]["nodes"][elementId].clusterSize = 2;
|
93
|
+
}
|
94
|
+
},
|
95
|
+
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Reverting back to a normal button
|
99
|
+
*
|
100
|
+
* @param {String} elementId
|
101
|
+
* @private
|
102
|
+
*/
|
103
|
+
_unHighlightNavigationElement : function(elementId) {
|
104
|
+
if (this.sectors["navigation"]["nodes"].hasOwnProperty(elementId)) {
|
105
|
+
this.sectors["navigation"]["nodes"][elementId].clusterSize = 1;
|
106
|
+
}
|
107
|
+
},
|
108
|
+
|
109
|
+
/**
|
110
|
+
* un-highlight (for lack of a better term) all navigation controls elements
|
111
|
+
* @private
|
112
|
+
*/
|
113
|
+
_unHighlightAll : function() {
|
114
|
+
for (var nodeId in this.sectors['navigation']['nodes']) {
|
115
|
+
if (this.sectors['navigation']['nodes'].hasOwnProperty(nodeId)) {
|
116
|
+
this._unHighlightNavigationElement(nodeId);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
},
|
120
|
+
|
121
|
+
|
122
|
+
_preventDefault : function(event) {
|
123
|
+
if (event !== undefined) {
|
124
|
+
if (event.preventDefault) {
|
125
|
+
event.preventDefault();
|
126
|
+
} else {
|
127
|
+
event.returnValue = false;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
},
|
131
|
+
|
132
|
+
|
133
|
+
/**
|
134
|
+
* move the screen up
|
135
|
+
* By using the increments, instead of adding a fixed number to the translation, we keep fluent and
|
136
|
+
* instant movement. The onKeypress event triggers immediately, then pauses, then triggers frequently
|
137
|
+
* To avoid this behaviour, we do the translation in the start loop.
|
138
|
+
*
|
139
|
+
* @private
|
140
|
+
*/
|
141
|
+
_moveUp : function(event) {
|
142
|
+
this._highlightNavigationElement("navigation_up");
|
143
|
+
this.yIncrement = this.constants.keyboard.speed.y;
|
144
|
+
this.start(); // if there is no node movement, the calculation wont be done
|
145
|
+
this._preventDefault(event);
|
146
|
+
},
|
147
|
+
|
148
|
+
|
149
|
+
/**
|
150
|
+
* move the screen down
|
151
|
+
* @private
|
152
|
+
*/
|
153
|
+
_moveDown : function(event) {
|
154
|
+
this._highlightNavigationElement("navigation_down");
|
155
|
+
this.yIncrement = -this.constants.keyboard.speed.y;
|
156
|
+
this.start(); // if there is no node movement, the calculation wont be done
|
157
|
+
this._preventDefault(event);
|
158
|
+
},
|
159
|
+
|
160
|
+
|
161
|
+
/**
|
162
|
+
* move the screen left
|
163
|
+
* @private
|
164
|
+
*/
|
165
|
+
_moveLeft : function(event) {
|
166
|
+
this._highlightNavigationElement("navigation_left");
|
167
|
+
this.xIncrement = this.constants.keyboard.speed.x;
|
168
|
+
this.start(); // if there is no node movement, the calculation wont be done
|
169
|
+
this._preventDefault(event);
|
170
|
+
},
|
171
|
+
|
172
|
+
|
173
|
+
/**
|
174
|
+
* move the screen right
|
175
|
+
* @private
|
176
|
+
*/
|
177
|
+
_moveRight : function(event) {
|
178
|
+
this._highlightNavigationElement("navigation_right");
|
179
|
+
this.xIncrement = -this.constants.keyboard.speed.y;
|
180
|
+
this.start(); // if there is no node movement, the calculation wont be done
|
181
|
+
this._preventDefault(event);
|
182
|
+
},
|
183
|
+
|
184
|
+
|
185
|
+
/**
|
186
|
+
* Zoom in, using the same method as the movement.
|
187
|
+
* @private
|
188
|
+
*/
|
189
|
+
_zoomIn : function(event) {
|
190
|
+
this._highlightNavigationElement("navigation_plus");
|
191
|
+
this.zoomIncrement = this.constants.keyboard.speed.zoom;
|
192
|
+
this.start(); // if there is no node movement, the calculation wont be done
|
193
|
+
this._preventDefault(event);
|
194
|
+
},
|
195
|
+
|
196
|
+
|
197
|
+
/**
|
198
|
+
* Zoom out
|
199
|
+
* @private
|
200
|
+
*/
|
201
|
+
_zoomOut : function() {
|
202
|
+
this._highlightNavigationElement("navigation_min");
|
203
|
+
this.zoomIncrement = -this.constants.keyboard.speed.zoom;
|
204
|
+
this.start(); // if there is no node movement, the calculation wont be done
|
205
|
+
this._preventDefault(event);
|
206
|
+
},
|
207
|
+
|
208
|
+
|
209
|
+
/**
|
210
|
+
* Stop zooming and unhighlight the zoom controls
|
211
|
+
* @private
|
212
|
+
*/
|
213
|
+
_stopZoom : function() {
|
214
|
+
this._unHighlightNavigationElement("navigation_plus");
|
215
|
+
this._unHighlightNavigationElement("navigation_min");
|
216
|
+
|
217
|
+
this.zoomIncrement = 0;
|
218
|
+
},
|
219
|
+
|
220
|
+
|
221
|
+
/**
|
222
|
+
* Stop moving in the Y direction and unHighlight the up and down
|
223
|
+
* @private
|
224
|
+
*/
|
225
|
+
_yStopMoving : function() {
|
226
|
+
this._unHighlightNavigationElement("navigation_up");
|
227
|
+
this._unHighlightNavigationElement("navigation_down");
|
228
|
+
|
229
|
+
this.yIncrement = 0;
|
230
|
+
},
|
231
|
+
|
232
|
+
|
233
|
+
/**
|
234
|
+
* Stop moving in the X direction and unHighlight left and right.
|
235
|
+
* @private
|
236
|
+
*/
|
237
|
+
_xStopMoving : function() {
|
238
|
+
this._unHighlightNavigationElement("navigation_left");
|
239
|
+
this._unHighlightNavigationElement("navigation_right");
|
240
|
+
|
241
|
+
this.xIncrement = 0;
|
242
|
+
}
|
243
|
+
|
244
|
+
|
245
|
+
};
|