vis-rails 0.0.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vis/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/vis.js +2 -9
  4. data/vendor/assets/vis/DataSet.js +17 -9
  5. data/vendor/assets/vis/graph/Edge.js +49 -24
  6. data/vendor/assets/vis/graph/Graph.js +268 -64
  7. data/vendor/assets/vis/graph/Groups.js +1 -1
  8. data/vendor/assets/vis/graph/Node.js +18 -67
  9. data/vendor/assets/vis/graph/Popup.js +40 -13
  10. data/vendor/assets/vis/graph/css/graph-navigation.css +18 -14
  11. data/vendor/assets/vis/graph/graphMixins/ClusterMixin.js +7 -5
  12. data/vendor/assets/vis/graph/graphMixins/HierarchicalLayoutMixin.js +20 -5
  13. data/vendor/assets/vis/graph/graphMixins/ManipulationMixin.js +33 -33
  14. data/vendor/assets/vis/graph/graphMixins/MixinLoader.js +30 -32
  15. data/vendor/assets/vis/graph/graphMixins/NavigationMixin.js +33 -1
  16. data/vendor/assets/vis/graph/graphMixins/SectorsMixin.js +2 -2
  17. data/vendor/assets/vis/graph/graphMixins/SelectionMixin.js +72 -60
  18. data/vendor/assets/vis/graph/graphMixins/physics/BarnesHut.js +43 -18
  19. data/vendor/assets/vis/graph/graphMixins/physics/HierarchialRepulsion.js +8 -8
  20. data/vendor/assets/vis/graph/graphMixins/physics/PhysicsMixin.js +309 -129
  21. data/vendor/assets/vis/graph/graphMixins/physics/Repulsion.js +10 -10
  22. data/vendor/assets/vis/module/exports.js +1 -2
  23. data/vendor/assets/vis/module/header.js +2 -2
  24. data/vendor/assets/vis/timeline/Range.js +53 -93
  25. data/vendor/assets/vis/timeline/Timeline.js +328 -224
  26. data/vendor/assets/vis/timeline/component/Component.js +17 -95
  27. data/vendor/assets/vis/timeline/component/CurrentTime.js +54 -59
  28. data/vendor/assets/vis/timeline/component/CustomTime.js +55 -83
  29. data/vendor/assets/vis/timeline/component/Group.js +398 -75
  30. data/vendor/assets/vis/timeline/component/ItemSet.js +662 -403
  31. data/vendor/assets/vis/timeline/component/Panel.js +118 -60
  32. data/vendor/assets/vis/timeline/component/RootPanel.js +80 -132
  33. data/vendor/assets/vis/timeline/component/TimeAxis.js +191 -277
  34. data/vendor/assets/vis/timeline/component/css/item.css +16 -23
  35. data/vendor/assets/vis/timeline/component/css/itemset.css +25 -4
  36. data/vendor/assets/vis/timeline/component/css/labelset.css +34 -0
  37. data/vendor/assets/vis/timeline/component/css/panel.css +15 -1
  38. data/vendor/assets/vis/timeline/component/css/timeaxis.css +8 -8
  39. data/vendor/assets/vis/timeline/component/item/Item.js +48 -26
  40. data/vendor/assets/vis/timeline/component/item/ItemBox.js +156 -230
  41. data/vendor/assets/vis/timeline/component/item/ItemPoint.js +118 -166
  42. data/vendor/assets/vis/timeline/component/item/ItemRange.js +135 -187
  43. data/vendor/assets/vis/timeline/component/item/ItemRangeOverflow.js +29 -92
  44. data/vendor/assets/vis/timeline/stack.js +112 -0
  45. data/vendor/assets/vis/util.js +136 -38
  46. metadata +4 -18
  47. data/vendor/assets/vis/.gitignore +0 -1
  48. data/vendor/assets/vis/EventBus.js +0 -89
  49. data/vendor/assets/vis/events.js +0 -116
  50. data/vendor/assets/vis/graph/ClusterMixin.js +0 -1019
  51. data/vendor/assets/vis/graph/NavigationMixin.js +0 -245
  52. data/vendor/assets/vis/graph/SectorsMixin.js +0 -547
  53. data/vendor/assets/vis/graph/SelectionMixin.js +0 -515
  54. data/vendor/assets/vis/graph/img/downarrow.png +0 -0
  55. data/vendor/assets/vis/graph/img/leftarrow.png +0 -0
  56. data/vendor/assets/vis/graph/img/rightarrow.png +0 -0
  57. data/vendor/assets/vis/graph/img/uparrow.png +0 -0
  58. data/vendor/assets/vis/timeline/Controller.js +0 -183
  59. data/vendor/assets/vis/timeline/Stack.js +0 -190
  60. data/vendor/assets/vis/timeline/component/ContentPanel.js +0 -113
  61. data/vendor/assets/vis/timeline/component/GroupSet.js +0 -580
  62. data/vendor/assets/vis/timeline/component/css/groupset.css +0 -59
@@ -1,183 +0,0 @@
1
- /**
2
- * @constructor Controller
3
- *
4
- * A Controller controls the reflows and repaints of all components,
5
- * and is used as an event bus for all components.
6
- */
7
- function Controller () {
8
- var me = this;
9
-
10
- this.id = util.randomUUID();
11
- this.components = {};
12
-
13
- /**
14
- * Listen for a 'request-reflow' event. The controller will schedule a reflow
15
- * @param {Boolean} [force] If true, an immediate reflow is forced. Default
16
- * is false.
17
- */
18
- var reflowTimer = null;
19
- this.on('request-reflow', function requestReflow(force) {
20
- if (force) {
21
- me.reflow();
22
- }
23
- else {
24
- if (!reflowTimer) {
25
- reflowTimer = setTimeout(function () {
26
- reflowTimer = null;
27
- me.reflow();
28
- }, 0);
29
- }
30
- }
31
- });
32
-
33
- /**
34
- * Request a repaint. The controller will schedule a repaint
35
- * @param {Boolean} [force] If true, an immediate repaint is forced. Default
36
- * is false.
37
- */
38
- var repaintTimer = null;
39
- this.on('request-repaint', function requestRepaint(force) {
40
- if (force) {
41
- me.repaint();
42
- }
43
- else {
44
- if (!repaintTimer) {
45
- repaintTimer = setTimeout(function () {
46
- repaintTimer = null;
47
- me.repaint();
48
- }, 0);
49
- }
50
- }
51
- });
52
- }
53
-
54
- // Extend controller with Emitter mixin
55
- Emitter(Controller.prototype);
56
-
57
- /**
58
- * Add a component to the controller
59
- * @param {Component} component
60
- */
61
- Controller.prototype.add = function add(component) {
62
- // validate the component
63
- if (component.id == undefined) {
64
- throw new Error('Component has no field id');
65
- }
66
- if (!(component instanceof Component) && !(component instanceof Controller)) {
67
- throw new TypeError('Component must be an instance of ' +
68
- 'prototype Component or Controller');
69
- }
70
-
71
- // add the component
72
- component.setController(this);
73
- this.components[component.id] = component;
74
- };
75
-
76
- /**
77
- * Remove a component from the controller
78
- * @param {Component | String} component
79
- */
80
- Controller.prototype.remove = function remove(component) {
81
- var id;
82
- for (id in this.components) {
83
- if (this.components.hasOwnProperty(id)) {
84
- if (id == component || this.components[id] === component) {
85
- break;
86
- }
87
- }
88
- }
89
-
90
- if (id) {
91
- // unregister the controller (gives the component the ability to unregister
92
- // event listeners and clean up other stuff)
93
- this.components[id].setController(null);
94
-
95
- delete this.components[id];
96
- }
97
- };
98
-
99
- /**
100
- * Repaint all components
101
- */
102
- Controller.prototype.repaint = function repaint() {
103
- var changed = false;
104
-
105
- // cancel any running repaint request
106
- if (this.repaintTimer) {
107
- clearTimeout(this.repaintTimer);
108
- this.repaintTimer = undefined;
109
- }
110
-
111
- var done = {};
112
-
113
- function repaint(component, id) {
114
- if (!(id in done)) {
115
- // first repaint the components on which this component is dependent
116
- if (component.depends) {
117
- component.depends.forEach(function (dep) {
118
- repaint(dep, dep.id);
119
- });
120
- }
121
- if (component.parent) {
122
- repaint(component.parent, component.parent.id);
123
- }
124
-
125
- // repaint the component itself and mark as done
126
- changed = component.repaint() || changed;
127
- done[id] = true;
128
- }
129
- }
130
-
131
- util.forEach(this.components, repaint);
132
-
133
- this.emit('repaint');
134
-
135
- // immediately reflow when needed
136
- if (changed) {
137
- this.reflow();
138
- }
139
- // TODO: limit the number of nested reflows/repaints, prevent loop
140
- };
141
-
142
- /**
143
- * Reflow all components
144
- */
145
- Controller.prototype.reflow = function reflow() {
146
- var resized = false;
147
-
148
- // cancel any running repaint request
149
- if (this.reflowTimer) {
150
- clearTimeout(this.reflowTimer);
151
- this.reflowTimer = undefined;
152
- }
153
-
154
- var done = {};
155
-
156
- function reflow(component, id) {
157
- if (!(id in done)) {
158
- // first reflow the components on which this component is dependent
159
- if (component.depends) {
160
- component.depends.forEach(function (dep) {
161
- reflow(dep, dep.id);
162
- });
163
- }
164
- if (component.parent) {
165
- reflow(component.parent, component.parent.id);
166
- }
167
-
168
- // reflow the component itself and mark as done
169
- resized = component.reflow() || resized;
170
- done[id] = true;
171
- }
172
- }
173
-
174
- util.forEach(this.components, reflow);
175
-
176
- this.emit('reflow');
177
-
178
- // immediately repaint when needed
179
- if (resized) {
180
- this.repaint();
181
- }
182
- // TODO: limit the number of nested reflows/repaints, prevent loop
183
- };
@@ -1,190 +0,0 @@
1
- /**
2
- * @constructor Stack
3
- * Stacks items on top of each other.
4
- * @param {ItemSet} itemset
5
- * @param {Object} [options]
6
- */
7
- function Stack (itemset, options) {
8
- this.itemset = itemset;
9
-
10
- this.options = options || {};
11
- this.defaultOptions = {
12
- order: function (a, b) {
13
- //return (b.width - a.width) || (a.left - b.left); // TODO: cleanup
14
- // Order: ranges over non-ranges, ranged ordered by width, and
15
- // lastly ordered by start.
16
- if (a instanceof ItemRange) {
17
- if (b instanceof ItemRange) {
18
- var aInt = (a.data.end - a.data.start);
19
- var bInt = (b.data.end - b.data.start);
20
- return (aInt - bInt) || (a.data.start - b.data.start);
21
- }
22
- else {
23
- return -1;
24
- }
25
- }
26
- else {
27
- if (b instanceof ItemRange) {
28
- return 1;
29
- }
30
- else {
31
- return (a.data.start - b.data.start);
32
- }
33
- }
34
- },
35
- margin: {
36
- item: 10
37
- }
38
- };
39
-
40
- this.ordered = []; // ordered items
41
- }
42
-
43
- /**
44
- * Set options for the stack
45
- * @param {Object} options Available options:
46
- * {ItemSet} itemset
47
- * {Number} margin
48
- * {function} order Stacking order
49
- */
50
- Stack.prototype.setOptions = function setOptions (options) {
51
- util.extend(this.options, options);
52
-
53
- // TODO: register on data changes at the connected itemset, and update the changed part only and immediately
54
- };
55
-
56
- /**
57
- * Stack the items such that they don't overlap. The items will have a minimal
58
- * distance equal to options.margin.item.
59
- */
60
- Stack.prototype.update = function update() {
61
- this._order();
62
- this._stack();
63
- };
64
-
65
- /**
66
- * Order the items. If a custom order function has been provided via the options,
67
- * then this will be used.
68
- * @private
69
- */
70
- Stack.prototype._order = function _order () {
71
- var items = this.itemset.items;
72
- if (!items) {
73
- throw new Error('Cannot stack items: ItemSet does not contain items');
74
- }
75
-
76
- // TODO: store the sorted items, to have less work later on
77
- var ordered = [];
78
- var index = 0;
79
- // items is a map (no array)
80
- util.forEach(items, function (item) {
81
- if (item.visible) {
82
- ordered[index] = item;
83
- index++;
84
- }
85
- });
86
-
87
- //if a customer stack order function exists, use it.
88
- var order = this.options.order || this.defaultOptions.order;
89
- if (!(typeof order === 'function')) {
90
- throw new Error('Option order must be a function');
91
- }
92
-
93
- ordered.sort(order);
94
-
95
- this.ordered = ordered;
96
- };
97
-
98
- /**
99
- * Adjust vertical positions of the events such that they don't overlap each
100
- * other.
101
- * @private
102
- */
103
- Stack.prototype._stack = function _stack () {
104
- var i,
105
- iMax,
106
- ordered = this.ordered,
107
- options = this.options,
108
- orientation = options.orientation || this.defaultOptions.orientation,
109
- axisOnTop = (orientation == 'top'),
110
- margin;
111
-
112
- if (options.margin && options.margin.item !== undefined) {
113
- margin = options.margin.item;
114
- }
115
- else {
116
- margin = this.defaultOptions.margin.item
117
- }
118
-
119
- // calculate new, non-overlapping positions
120
- for (i = 0, iMax = ordered.length; i < iMax; i++) {
121
- var item = ordered[i];
122
- var collidingItem = null;
123
- do {
124
- // TODO: optimize checking for overlap. when there is a gap without items,
125
- // you only need to check for items from the next item on, not from zero
126
- collidingItem = this.checkOverlap(ordered, i, 0, i - 1, margin);
127
- if (collidingItem != null) {
128
- // There is a collision. Reposition the event above the colliding element
129
- if (axisOnTop) {
130
- item.top = collidingItem.top + collidingItem.height + margin;
131
- }
132
- else {
133
- item.top = collidingItem.top - item.height - margin;
134
- }
135
- }
136
- } while (collidingItem);
137
- }
138
- };
139
-
140
- /**
141
- * Check if the destiny position of given item overlaps with any
142
- * of the other items from index itemStart to itemEnd.
143
- * @param {Array} items Array with items
144
- * @param {int} itemIndex Number of the item to be checked for overlap
145
- * @param {int} itemStart First item to be checked.
146
- * @param {int} itemEnd Last item to be checked.
147
- * @return {Object | null} colliding item, or undefined when no collisions
148
- * @param {Number} margin A minimum required margin.
149
- * If margin is provided, the two items will be
150
- * marked colliding when they overlap or
151
- * when the margin between the two is smaller than
152
- * the requested margin.
153
- */
154
- Stack.prototype.checkOverlap = function checkOverlap (items, itemIndex,
155
- itemStart, itemEnd, margin) {
156
- var collision = this.collision;
157
-
158
- // we loop from end to start, as we suppose that the chance of a
159
- // collision is larger for items at the end, so check these first.
160
- var a = items[itemIndex];
161
- for (var i = itemEnd; i >= itemStart; i--) {
162
- var b = items[i];
163
- if (collision(a, b, margin)) {
164
- if (i != itemIndex) {
165
- return b;
166
- }
167
- }
168
- }
169
-
170
- return null;
171
- };
172
-
173
- /**
174
- * Test if the two provided items collide
175
- * The items must have parameters left, width, top, and height.
176
- * @param {Component} a The first item
177
- * @param {Component} b The second item
178
- * @param {Number} margin A minimum required margin.
179
- * If margin is provided, the two items will be
180
- * marked colliding when they overlap or
181
- * when the margin between the two is smaller than
182
- * the requested margin.
183
- * @return {boolean} true if a and b collide, else false
184
- */
185
- Stack.prototype.collision = function collision (a, b, margin) {
186
- return ((a.left - margin) < (b.left + b.width) &&
187
- (a.left + a.width + margin) > b.left &&
188
- (a.top - margin) < (b.top + b.height) &&
189
- (a.top + a.height + margin) > b.top);
190
- };
@@ -1,113 +0,0 @@
1
- /**
2
- * A content panel can contain a groupset or an itemset, and can handle
3
- * vertical scrolling
4
- * @param {Component} [parent]
5
- * @param {Component[]} [depends] Components on which this components depends
6
- * (except for the parent)
7
- * @param {Object} [options] Available parameters:
8
- * {String | Number | function} [left]
9
- * {String | Number | function} [top]
10
- * {String | Number | function} [width]
11
- * {String | Number | function} [height]
12
- * {String | function} [className]
13
- * @constructor ContentPanel
14
- * @extends Panel
15
- */
16
- function ContentPanel(parent, depends, options) {
17
- this.id = util.randomUUID();
18
- this.parent = parent;
19
- this.depends = depends;
20
-
21
- this.options = options || {};
22
- }
23
-
24
- ContentPanel.prototype = new Component();
25
-
26
- /**
27
- * Set options. Will extend the current options.
28
- * @param {Object} [options] Available parameters:
29
- * {String | function} [className]
30
- * {String | Number | function} [left]
31
- * {String | Number | function} [top]
32
- * {String | Number | function} [width]
33
- * {String | Number | function} [height]
34
- */
35
- ContentPanel.prototype.setOptions = Component.prototype.setOptions;
36
-
37
- /**
38
- * Get the container element of the panel, which can be used by a child to
39
- * add its own widgets.
40
- * @returns {HTMLElement} container
41
- */
42
- ContentPanel.prototype.getContainer = function () {
43
- return this.frame;
44
- };
45
-
46
- /**
47
- * Repaint the component
48
- * @return {Boolean} changed
49
- */
50
- ContentPanel.prototype.repaint = function () {
51
- var changed = 0,
52
- update = util.updateProperty,
53
- asSize = util.option.asSize,
54
- options = this.options,
55
- frame = this.frame;
56
- if (!frame) {
57
- frame = document.createElement('div');
58
- frame.className = 'content-panel';
59
-
60
- var className = options.className;
61
- if (className) {
62
- if (typeof className == 'function') {
63
- util.addClassName(frame, String(className()));
64
- }
65
- else {
66
- util.addClassName(frame, String(className));
67
- }
68
- }
69
-
70
- this.frame = frame;
71
- changed += 1;
72
- }
73
- if (!frame.parentNode) {
74
- if (!this.parent) {
75
- throw new Error('Cannot repaint panel: no parent attached');
76
- }
77
- var parentContainer = this.parent.getContainer();
78
- if (!parentContainer) {
79
- throw new Error('Cannot repaint panel: parent has no container element');
80
- }
81
- parentContainer.appendChild(frame);
82
- changed += 1;
83
- }
84
-
85
- changed += update(frame.style, 'top', asSize(options.top, '0px'));
86
- changed += update(frame.style, 'left', asSize(options.left, '0px'));
87
- changed += update(frame.style, 'width', asSize(options.width, '100%'));
88
- changed += update(frame.style, 'height', asSize(options.height, '100%'));
89
-
90
- return (changed > 0);
91
- };
92
-
93
- /**
94
- * Reflow the component
95
- * @return {Boolean} resized
96
- */
97
- ContentPanel.prototype.reflow = function () {
98
- var changed = 0,
99
- update = util.updateProperty,
100
- frame = this.frame;
101
-
102
- if (frame) {
103
- changed += update(this, 'top', frame.offsetTop);
104
- changed += update(this, 'left', frame.offsetLeft);
105
- changed += update(this, 'width', frame.offsetWidth);
106
- changed += update(this, 'height', frame.offsetHeight);
107
- }
108
- else {
109
- changed += 1;
110
- }
111
-
112
- return (changed > 0);
113
- };