vis-rails 0.0.6 → 1.0.0

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.
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
@@ -4,17 +4,18 @@
4
4
  function Component () {
5
5
  this.id = null;
6
6
  this.parent = null;
7
- this.depends = null;
8
- this.controller = null;
7
+ this.childs = null;
9
8
  this.options = null;
10
9
 
11
- this.frame = null; // main DOM element
12
10
  this.top = 0;
13
11
  this.left = 0;
14
12
  this.width = 0;
15
13
  this.height = 0;
16
14
  }
17
15
 
16
+ // Turn the Component into an event emitter
17
+ Emitter(Component.prototype);
18
+
18
19
  /**
19
20
  * Set parameters for the frame. Parameters will be merged in current parameter
20
21
  * set.
@@ -29,10 +30,7 @@ Component.prototype.setOptions = function setOptions(options) {
29
30
  if (options) {
30
31
  util.extend(this.options, options);
31
32
 
32
- if (this.controller) {
33
- this.requestRepaint();
34
- this.requestReflow();
35
- }
33
+ this.repaint();
36
34
  }
37
35
  };
38
36
 
@@ -54,46 +52,18 @@ Component.prototype.getOption = function getOption(name) {
54
52
  return value;
55
53
  };
56
54
 
57
- /**
58
- * Set controller for this component, or remove current controller by passing
59
- * null as parameter value.
60
- * @param {Controller | null} controller
61
- */
62
- Component.prototype.setController = function setController (controller) {
63
- this.controller = controller || null;
64
- };
65
-
66
- /**
67
- * Get controller of this component
68
- * @return {Controller} controller
69
- */
70
- Component.prototype.getController = function getController () {
71
- return this.controller;
72
- };
73
-
74
- /**
75
- * Get the container element of the component, which can be used by a child to
76
- * add its own widgets. Not all components do have a container for childs, in
77
- * that case null is returned.
78
- * @returns {HTMLElement | null} container
79
- */
80
- // TODO: get rid of the getContainer and getFrame methods, provide these via the options
81
- Component.prototype.getContainer = function getContainer() {
82
- // should be implemented by the component
83
- return null;
84
- };
85
-
86
55
  /**
87
56
  * Get the frame element of the component, the outer HTML DOM element.
88
57
  * @returns {HTMLElement | null} frame
89
58
  */
90
59
  Component.prototype.getFrame = function getFrame() {
91
- return this.frame;
60
+ // should be implemented by the component
61
+ return null;
92
62
  };
93
63
 
94
64
  /**
95
65
  * Repaint the component
96
- * @return {Boolean} changed
66
+ * @return {boolean} Returns true if the component is resized
97
67
  */
98
68
  Component.prototype.repaint = function repaint() {
99
69
  // should be implemented by the component
@@ -101,64 +71,16 @@ Component.prototype.repaint = function repaint() {
101
71
  };
102
72
 
103
73
  /**
104
- * Reflow the component
105
- * @return {Boolean} resized
74
+ * Test whether the component is resized since the last time _isResized() was
75
+ * called.
76
+ * @return {Boolean} Returns true if the component is resized
77
+ * @protected
106
78
  */
107
- Component.prototype.reflow = function reflow() {
108
- // should be implemented by the component
109
- return false;
110
- };
79
+ Component.prototype._isResized = function _isResized() {
80
+ var resized = (this._previousWidth !== this.width || this._previousHeight !== this.height);
111
81
 
112
- /**
113
- * Hide the component from the DOM
114
- * @return {Boolean} changed
115
- */
116
- Component.prototype.hide = function hide() {
117
- if (this.frame && this.frame.parentNode) {
118
- this.frame.parentNode.removeChild(this.frame);
119
- return true;
120
- }
121
- else {
122
- return false;
123
- }
124
- };
125
-
126
- /**
127
- * Show the component in the DOM (when not already visible).
128
- * A repaint will be executed when the component is not visible
129
- * @return {Boolean} changed
130
- */
131
- Component.prototype.show = function show() {
132
- if (!this.frame || !this.frame.parentNode) {
133
- return this.repaint();
134
- }
135
- else {
136
- return false;
137
- }
138
- };
82
+ this._previousWidth = this.width;
83
+ this._previousHeight = this.height;
139
84
 
140
- /**
141
- * Request a repaint. The controller will schedule a repaint
142
- */
143
- Component.prototype.requestRepaint = function requestRepaint() {
144
- if (this.controller) {
145
- this.controller.emit('request-repaint');
146
- }
147
- else {
148
- throw new Error('Cannot request a repaint: no controller configured');
149
- // TODO: just do a repaint when no parent is configured?
150
- }
151
- };
152
-
153
- /**
154
- * Request a reflow. The controller will schedule a reflow
155
- */
156
- Component.prototype.requestReflow = function requestReflow() {
157
- if (this.controller) {
158
- this.controller.emit('request-reflow');
159
- }
160
- else {
161
- throw new Error('Cannot request a reflow: no controller configured');
162
- // TODO: just do a reflow when no parent is configured?
163
- }
85
+ return resized;
164
86
  };
@@ -1,23 +1,22 @@
1
1
  /**
2
2
  * A current time bar
3
- * @param {Component} parent
4
- * @param {Component[]} [depends] Components on which this components depends
5
- * (except for the parent)
3
+ * @param {Range} range
6
4
  * @param {Object} [options] Available parameters:
7
5
  * {Boolean} [showCurrentTime]
8
6
  * @constructor CurrentTime
9
7
  * @extends Component
10
8
  */
11
9
 
12
- function CurrentTime (parent, depends, options) {
10
+ function CurrentTime (range, options) {
13
11
  this.id = util.randomUUID();
14
- this.parent = parent;
15
- this.depends = depends;
16
12
 
13
+ this.range = range;
17
14
  this.options = options || {};
18
15
  this.defaultOptions = {
19
16
  showCurrentTime: false
20
17
  };
18
+
19
+ this._create();
21
20
  }
22
21
 
23
22
  CurrentTime.prototype = new Component();
@@ -25,77 +24,73 @@ CurrentTime.prototype = new Component();
25
24
  CurrentTime.prototype.setOptions = Component.prototype.setOptions;
26
25
 
27
26
  /**
28
- * Get the container element of the bar, which can be used by a child to
29
- * add its own widgets.
30
- * @returns {HTMLElement} container
27
+ * Create the HTML DOM for the current time bar
28
+ * @private
31
29
  */
32
- CurrentTime.prototype.getContainer = function () {
33
- return this.frame;
30
+ CurrentTime.prototype._create = function _create () {
31
+ var bar = document.createElement('div');
32
+ bar.className = 'currenttime';
33
+ bar.style.position = 'absolute';
34
+ bar.style.top = '0px';
35
+ bar.style.height = '100%';
36
+
37
+ this.bar = bar;
38
+ };
39
+
40
+ /**
41
+ * Get the frame element of the current time bar
42
+ * @returns {HTMLElement} frame
43
+ */
44
+ CurrentTime.prototype.getFrame = function getFrame() {
45
+ return this.bar;
34
46
  };
35
47
 
36
48
  /**
37
49
  * Repaint the component
38
- * @return {Boolean} changed
50
+ * @return {boolean} Returns true if the component is resized
39
51
  */
40
- CurrentTime.prototype.repaint = function () {
41
- var bar = this.frame,
42
- parent = this.parent,
43
- parentContainer = parent.parent.getContainer();
52
+ CurrentTime.prototype.repaint = function repaint() {
53
+ var parent = this.parent;
44
54
 
45
- if (!parent) {
46
- throw new Error('Cannot repaint bar: no parent attached');
47
- }
55
+ var now = new Date();
56
+ var x = this.options.toScreen(now);
48
57
 
49
- if (!parentContainer) {
50
- throw new Error('Cannot repaint bar: parent has no container element');
51
- }
58
+ this.bar.style.left = x + 'px';
59
+ this.bar.title = 'Current time: ' + now;
52
60
 
53
- if (!this.getOption('showCurrentTime')) {
54
- if (bar) {
55
- parentContainer.removeChild(bar);
56
- delete this.frame;
57
- }
61
+ return false;
62
+ };
58
63
 
59
- return false;
60
- }
64
+ /**
65
+ * Start auto refreshing the current time bar
66
+ */
67
+ CurrentTime.prototype.start = function start() {
68
+ var me = this;
61
69
 
62
- if (!bar) {
63
- bar = document.createElement('div');
64
- bar.className = 'currenttime';
65
- bar.style.position = 'absolute';
66
- bar.style.top = '0px';
67
- bar.style.height = '100%';
70
+ function update () {
71
+ me.stop();
68
72
 
69
- parentContainer.appendChild(bar);
70
- this.frame = bar;
71
- }
73
+ // determine interval to refresh
74
+ var scale = me.range.conversion(me.parent.width).scale;
75
+ var interval = 1 / scale / 10;
76
+ if (interval < 30) interval = 30;
77
+ if (interval > 1000) interval = 1000;
72
78
 
73
- if (!parent.conversion) {
74
- parent._updateConversion();
75
- }
79
+ me.repaint();
76
80
 
77
- var now = new Date();
78
- var x = parent.toScreen(now);
81
+ // start a timer to adjust for the new time
82
+ me.currentTimeTimer = setTimeout(update, interval);
83
+ }
79
84
 
80
- bar.style.left = x + 'px';
81
- bar.title = 'Current time: ' + now;
85
+ update();
86
+ };
82
87
 
83
- // start a timer to adjust for the new time
88
+ /**
89
+ * Stop auto refreshing the current time bar
90
+ */
91
+ CurrentTime.prototype.stop = function stop() {
84
92
  if (this.currentTimeTimer !== undefined) {
85
93
  clearTimeout(this.currentTimeTimer);
86
94
  delete this.currentTimeTimer;
87
95
  }
88
-
89
- var timeline = this;
90
- var interval = 1 / parent.conversion.scale / 2;
91
-
92
- if (interval < 30) {
93
- interval = 30;
94
- }
95
-
96
- this.currentTimeTimer = setTimeout(function() {
97
- timeline.repaint();
98
- }, interval);
99
-
100
- return false;
101
96
  };
@@ -1,18 +1,13 @@
1
1
  /**
2
2
  * A custom time bar
3
- * @param {Component} parent
4
- * @param {Component[]} [depends] Components on which this components depends
5
- * (except for the parent)
6
3
  * @param {Object} [options] Available parameters:
7
4
  * {Boolean} [showCustomTime]
8
5
  * @constructor CustomTime
9
6
  * @extends Component
10
7
  */
11
8
 
12
- function CustomTime (parent, depends, options) {
9
+ function CustomTime (options) {
13
10
  this.id = util.randomUUID();
14
- this.parent = parent;
15
- this.depends = depends;
16
11
 
17
12
  this.options = options || {};
18
13
  this.defaultOptions = {
@@ -21,85 +16,61 @@ function CustomTime (parent, depends, options) {
21
16
 
22
17
  this.customTime = new Date();
23
18
  this.eventParams = {}; // stores state parameters while dragging the bar
19
+
20
+ // create the DOM
21
+ this._create();
24
22
  }
25
23
 
26
24
  CustomTime.prototype = new Component();
27
25
 
28
- Emitter(CustomTime.prototype);
29
-
30
26
  CustomTime.prototype.setOptions = Component.prototype.setOptions;
31
27
 
32
28
  /**
33
- * Get the container element of the bar, which can be used by a child to
34
- * add its own widgets.
35
- * @returns {HTMLElement} container
29
+ * Create the DOM for the custom time
30
+ * @private
31
+ */
32
+ CustomTime.prototype._create = function _create () {
33
+ var bar = document.createElement('div');
34
+ bar.className = 'customtime';
35
+ bar.style.position = 'absolute';
36
+ bar.style.top = '0px';
37
+ bar.style.height = '100%';
38
+ this.bar = bar;
39
+
40
+ var drag = document.createElement('div');
41
+ drag.style.position = 'relative';
42
+ drag.style.top = '0px';
43
+ drag.style.left = '-10px';
44
+ drag.style.height = '100%';
45
+ drag.style.width = '20px';
46
+ bar.appendChild(drag);
47
+
48
+ // attach event listeners
49
+ this.hammer = Hammer(bar, {
50
+ prevent_default: true
51
+ });
52
+ this.hammer.on('dragstart', this._onDragStart.bind(this));
53
+ this.hammer.on('drag', this._onDrag.bind(this));
54
+ this.hammer.on('dragend', this._onDragEnd.bind(this));
55
+ };
56
+
57
+ /**
58
+ * Get the frame element of the custom time bar
59
+ * @returns {HTMLElement} frame
36
60
  */
37
- CustomTime.prototype.getContainer = function () {
38
- return this.frame;
61
+ CustomTime.prototype.getFrame = function getFrame() {
62
+ return this.bar;
39
63
  };
40
64
 
41
65
  /**
42
66
  * Repaint the component
43
- * @return {Boolean} changed
67
+ * @return {boolean} Returns true if the component is resized
44
68
  */
45
69
  CustomTime.prototype.repaint = function () {
46
- var bar = this.frame,
47
- parent = this.parent;
48
-
49
- if (!parent) {
50
- throw new Error('Cannot repaint bar: no parent attached');
51
- }
52
-
53
- var parentContainer = parent.parent.getContainer();
54
- if (!parentContainer) {
55
- throw new Error('Cannot repaint bar: parent has no container element');
56
- }
57
-
58
- if (!this.getOption('showCustomTime')) {
59
- if (bar) {
60
- parentContainer.removeChild(bar);
61
- delete this.frame;
62
- }
63
-
64
- return false;
65
- }
66
-
67
- if (!bar) {
68
- bar = document.createElement('div');
69
- bar.className = 'customtime';
70
- bar.style.position = 'absolute';
71
- bar.style.top = '0px';
72
- bar.style.height = '100%';
73
-
74
- parentContainer.appendChild(bar);
75
-
76
- var drag = document.createElement('div');
77
- drag.style.position = 'relative';
78
- drag.style.top = '0px';
79
- drag.style.left = '-10px';
80
- drag.style.height = '100%';
81
- drag.style.width = '20px';
82
- bar.appendChild(drag);
83
-
84
- this.frame = bar;
85
-
86
- // attach event listeners
87
- this.hammer = Hammer(bar, {
88
- prevent_default: true
89
- });
90
- this.hammer.on('dragstart', this._onDragStart.bind(this));
91
- this.hammer.on('drag', this._onDrag.bind(this));
92
- this.hammer.on('dragend', this._onDragEnd.bind(this));
93
- }
94
-
95
- if (!parent.conversion) {
96
- parent._updateConversion();
97
- }
98
-
99
- var x = parent.toScreen(this.customTime);
100
-
101
- bar.style.left = x + 'px';
102
- bar.title = 'Time: ' + this.customTime;
70
+ var x = this.options.toScreen(this.customTime);
71
+
72
+ this.bar.style.left = x + 'px';
73
+ this.bar.title = 'Time: ' + this.customTime;
103
74
 
104
75
  return false;
105
76
  };
@@ -127,6 +98,7 @@ CustomTime.prototype.getCustomTime = function() {
127
98
  * @private
128
99
  */
129
100
  CustomTime.prototype._onDragStart = function(event) {
101
+ this.eventParams.dragging = true;
130
102
  this.eventParams.customTime = this.customTime;
131
103
 
132
104
  event.stopPropagation();
@@ -139,18 +111,18 @@ CustomTime.prototype._onDragStart = function(event) {
139
111
  * @private
140
112
  */
141
113
  CustomTime.prototype._onDrag = function (event) {
114
+ if (!this.eventParams.dragging) return;
115
+
142
116
  var deltaX = event.gesture.deltaX,
143
- x = this.parent.toScreen(this.eventParams.customTime) + deltaX,
144
- time = this.parent.toTime(x);
117
+ x = this.options.toScreen(this.eventParams.customTime) + deltaX,
118
+ time = this.options.toTime(x);
145
119
 
146
120
  this.setCustomTime(time);
147
121
 
148
122
  // fire a timechange event
149
- if (this.controller) {
150
- this.controller.emit('timechange', {
151
- time: this.customTime
152
- })
153
- }
123
+ this.emit('timechange', {
124
+ time: new Date(this.customTime.valueOf())
125
+ });
154
126
 
155
127
  event.stopPropagation();
156
128
  event.preventDefault();
@@ -162,12 +134,12 @@ CustomTime.prototype._onDrag = function (event) {
162
134
  * @private
163
135
  */
164
136
  CustomTime.prototype._onDragEnd = function (event) {
137
+ if (!this.eventParams.dragging) return;
138
+
165
139
  // fire a timechanged event
166
- if (this.controller) {
167
- this.controller.emit('timechanged', {
168
- time: this.customTime
169
- })
170
- }
140
+ this.emit('timechanged', {
141
+ time: new Date(this.customTime.valueOf())
142
+ });
171
143
 
172
144
  event.stopPropagation();
173
145
  event.preventDefault();