vis-rails 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/README.md +2 -0
- data/lib/vis/rails/version.rb +1 -1
- data/vendor/assets/javascripts/module/exports-only-timeline.js +55 -0
- data/vendor/assets/javascripts/vis-only-timeline.js +23 -0
- data/vendor/assets/javascripts/vis.js +3 -3
- data/vendor/assets/stylesheets/vis-only-timeline.css +3 -0
- data/vendor/assets/vis/DataSet.js +106 -130
- data/vendor/assets/vis/DataView.js +35 -37
- data/vendor/assets/vis/graph/Edge.js +225 -45
- data/vendor/assets/vis/graph/Graph.js +120 -24
- data/vendor/assets/vis/graph/Node.js +16 -16
- data/vendor/assets/vis/graph/graphMixins/HierarchicalLayoutMixin.js +1 -1
- data/vendor/assets/vis/graph/graphMixins/ManipulationMixin.js +143 -0
- data/vendor/assets/vis/graph/graphMixins/SelectionMixin.js +81 -3
- data/vendor/assets/vis/graph3d/Graph3d.js +3306 -0
- data/vendor/assets/vis/module/exports.js +2 -3
- data/vendor/assets/vis/timeline/Range.js +93 -80
- data/vendor/assets/vis/timeline/Timeline.js +525 -428
- data/vendor/assets/vis/timeline/component/Component.js +19 -53
- data/vendor/assets/vis/timeline/component/CurrentTime.js +57 -25
- data/vendor/assets/vis/timeline/component/CustomTime.js +55 -19
- data/vendor/assets/vis/timeline/component/Group.js +47 -50
- data/vendor/assets/vis/timeline/component/ItemSet.js +402 -206
- data/vendor/assets/vis/timeline/component/TimeAxis.js +112 -169
- data/vendor/assets/vis/timeline/component/css/animation.css +33 -0
- data/vendor/assets/vis/timeline/component/css/currenttime.css +1 -1
- data/vendor/assets/vis/timeline/component/css/customtime.css +1 -1
- data/vendor/assets/vis/timeline/component/css/item.css +1 -11
- data/vendor/assets/vis/timeline/component/css/itemset.css +13 -18
- data/vendor/assets/vis/timeline/component/css/labelset.css +8 -6
- data/vendor/assets/vis/timeline/component/css/panel.css +56 -13
- data/vendor/assets/vis/timeline/component/css/timeaxis.css +15 -8
- data/vendor/assets/vis/timeline/component/item/Item.js +16 -15
- data/vendor/assets/vis/timeline/component/item/ItemBox.js +30 -30
- data/vendor/assets/vis/timeline/component/item/ItemPoint.js +20 -21
- data/vendor/assets/vis/timeline/component/item/ItemRange.js +23 -24
- data/vendor/assets/vis/timeline/component/item/ItemRangeOverflow.js +10 -10
- data/vendor/assets/vis/timeline/stack.js +5 -5
- data/vendor/assets/vis/util.js +81 -35
- metadata +7 -4
- data/vendor/assets/vis/timeline/component/Panel.js +0 -170
- data/vendor/assets/vis/timeline/component/RootPanel.js +0 -176
@@ -1,73 +1,38 @@
|
|
1
1
|
/**
|
2
2
|
* Prototype for visual components
|
3
|
+
* @param {{dom: Object, domProps: Object, emitter: Emitter, range: Range}} [body]
|
4
|
+
* @param {Object} [options]
|
3
5
|
*/
|
4
|
-
function Component () {
|
5
|
-
this.id = null;
|
6
|
-
this.parent = null;
|
7
|
-
this.childs = null;
|
6
|
+
function Component (body, options) {
|
8
7
|
this.options = null;
|
9
|
-
|
10
|
-
this.top = 0;
|
11
|
-
this.left = 0;
|
12
|
-
this.width = 0;
|
13
|
-
this.height = 0;
|
8
|
+
this.props = null;
|
14
9
|
}
|
15
10
|
|
16
|
-
// Turn the Component into an event emitter
|
17
|
-
Emitter(Component.prototype);
|
18
|
-
|
19
11
|
/**
|
20
|
-
* Set
|
21
|
-
*
|
22
|
-
* @param {Object} options
|
23
|
-
* {String | function} [className]
|
24
|
-
* {String | Number | function} [left]
|
25
|
-
* {String | Number | function} [top]
|
26
|
-
* {String | Number | function} [width]
|
27
|
-
* {String | Number | function} [height]
|
12
|
+
* Set options for the component. The new options will be merged into the
|
13
|
+
* current options.
|
14
|
+
* @param {Object} options
|
28
15
|
*/
|
29
|
-
Component.prototype.setOptions = function
|
16
|
+
Component.prototype.setOptions = function(options) {
|
30
17
|
if (options) {
|
31
18
|
util.extend(this.options, options);
|
32
|
-
|
33
|
-
this.repaint();
|
34
19
|
}
|
35
20
|
};
|
36
21
|
|
37
22
|
/**
|
38
|
-
*
|
39
|
-
*
|
40
|
-
* this.defaultOptions.
|
41
|
-
* @param {String} name
|
42
|
-
* @return {*} value
|
43
|
-
*/
|
44
|
-
Component.prototype.getOption = function getOption(name) {
|
45
|
-
var value;
|
46
|
-
if (this.options) {
|
47
|
-
value = this.options[name];
|
48
|
-
}
|
49
|
-
if (value === undefined && this.defaultOptions) {
|
50
|
-
value = this.defaultOptions[name];
|
51
|
-
}
|
52
|
-
return value;
|
53
|
-
};
|
54
|
-
|
55
|
-
/**
|
56
|
-
* Get the frame element of the component, the outer HTML DOM element.
|
57
|
-
* @returns {HTMLElement | null} frame
|
23
|
+
* Repaint the component
|
24
|
+
* @return {boolean} Returns true if the component is resized
|
58
25
|
*/
|
59
|
-
Component.prototype.
|
26
|
+
Component.prototype.redraw = function() {
|
60
27
|
// should be implemented by the component
|
61
|
-
return
|
28
|
+
return false;
|
62
29
|
};
|
63
30
|
|
64
31
|
/**
|
65
|
-
*
|
66
|
-
* @return {boolean} Returns true if the component is resized
|
32
|
+
* Destroy the component. Cleanup DOM and event listeners
|
67
33
|
*/
|
68
|
-
Component.prototype.
|
34
|
+
Component.prototype.destroy = function() {
|
69
35
|
// should be implemented by the component
|
70
|
-
return false;
|
71
36
|
};
|
72
37
|
|
73
38
|
/**
|
@@ -76,11 +41,12 @@ Component.prototype.repaint = function repaint() {
|
|
76
41
|
* @return {Boolean} Returns true if the component is resized
|
77
42
|
* @protected
|
78
43
|
*/
|
79
|
-
Component.prototype._isResized = function
|
80
|
-
var resized = (this._previousWidth !== this.width ||
|
44
|
+
Component.prototype._isResized = function() {
|
45
|
+
var resized = (this.props._previousWidth !== this.props.width ||
|
46
|
+
this.props._previousHeight !== this.props.height);
|
81
47
|
|
82
|
-
this._previousWidth = this.width;
|
83
|
-
this._previousHeight = this.height;
|
48
|
+
this.props._previousWidth = this.props.width;
|
49
|
+
this.props._previousHeight = this.props.height;
|
84
50
|
|
85
51
|
return resized;
|
86
52
|
};
|
@@ -1,33 +1,33 @@
|
|
1
1
|
/**
|
2
2
|
* A current time bar
|
3
|
-
* @param {Range}
|
3
|
+
* @param {{range: Range, dom: Object, domProps: Object}} body
|
4
4
|
* @param {Object} [options] Available parameters:
|
5
5
|
* {Boolean} [showCurrentTime]
|
6
6
|
* @constructor CurrentTime
|
7
7
|
* @extends Component
|
8
8
|
*/
|
9
9
|
|
10
|
-
function CurrentTime (
|
11
|
-
this.
|
10
|
+
function CurrentTime (body, options) {
|
11
|
+
this.body = body;
|
12
12
|
|
13
|
-
|
14
|
-
this.options = options || {};
|
13
|
+
// default options
|
15
14
|
this.defaultOptions = {
|
16
|
-
showCurrentTime:
|
15
|
+
showCurrentTime: true
|
17
16
|
};
|
17
|
+
this.options = util.extend({}, this.defaultOptions);
|
18
18
|
|
19
19
|
this._create();
|
20
|
+
|
21
|
+
this.setOptions(options);
|
20
22
|
}
|
21
23
|
|
22
24
|
CurrentTime.prototype = new Component();
|
23
25
|
|
24
|
-
CurrentTime.prototype.setOptions = Component.prototype.setOptions;
|
25
|
-
|
26
26
|
/**
|
27
27
|
* Create the HTML DOM for the current time bar
|
28
28
|
* @private
|
29
29
|
*/
|
30
|
-
CurrentTime.prototype._create = function
|
30
|
+
CurrentTime.prototype._create = function() {
|
31
31
|
var bar = document.createElement('div');
|
32
32
|
bar.className = 'currenttime';
|
33
33
|
bar.style.position = 'absolute';
|
@@ -38,25 +38,57 @@ CurrentTime.prototype._create = function _create () {
|
|
38
38
|
};
|
39
39
|
|
40
40
|
/**
|
41
|
-
*
|
42
|
-
|
41
|
+
* Destroy the CurrentTime bar
|
42
|
+
*/
|
43
|
+
CurrentTime.prototype.destroy = function () {
|
44
|
+
this.options.showCurrentTime = false;
|
45
|
+
this.redraw(); // will remove the bar from the DOM and stop refreshing
|
46
|
+
|
47
|
+
this.body = null;
|
48
|
+
};
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Set options for the component. Options will be merged in current options.
|
52
|
+
* @param {Object} options Available parameters:
|
53
|
+
* {boolean} [showCurrentTime]
|
43
54
|
*/
|
44
|
-
CurrentTime.prototype.
|
45
|
-
|
55
|
+
CurrentTime.prototype.setOptions = function(options) {
|
56
|
+
if (options) {
|
57
|
+
// copy all options that we know
|
58
|
+
util.selectiveExtend(['showCurrentTime'], this.options, options);
|
59
|
+
}
|
46
60
|
};
|
47
61
|
|
48
62
|
/**
|
49
63
|
* Repaint the component
|
50
64
|
* @return {boolean} Returns true if the component is resized
|
51
65
|
*/
|
52
|
-
CurrentTime.prototype.
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
66
|
+
CurrentTime.prototype.redraw = function() {
|
67
|
+
if (this.options.showCurrentTime) {
|
68
|
+
var parent = this.body.dom.backgroundVertical;
|
69
|
+
if (this.bar.parentNode != parent) {
|
70
|
+
// attach to the dom
|
71
|
+
if (this.bar.parentNode) {
|
72
|
+
this.bar.parentNode.removeChild(this.bar);
|
73
|
+
}
|
74
|
+
parent.appendChild(this.bar);
|
75
|
+
|
76
|
+
this.start();
|
77
|
+
}
|
78
|
+
|
79
|
+
var now = new Date();
|
80
|
+
var x = this.body.util.toScreen(now);
|
81
|
+
|
82
|
+
this.bar.style.left = x + 'px';
|
83
|
+
this.bar.title = 'Current time: ' + now;
|
84
|
+
}
|
85
|
+
else {
|
86
|
+
// remove the line from the DOM
|
87
|
+
if (this.bar.parentNode) {
|
88
|
+
this.bar.parentNode.removeChild(this.bar);
|
89
|
+
}
|
90
|
+
this.stop();
|
91
|
+
}
|
60
92
|
|
61
93
|
return false;
|
62
94
|
};
|
@@ -64,19 +96,19 @@ CurrentTime.prototype.repaint = function repaint() {
|
|
64
96
|
/**
|
65
97
|
* Start auto refreshing the current time bar
|
66
98
|
*/
|
67
|
-
CurrentTime.prototype.start = function
|
99
|
+
CurrentTime.prototype.start = function() {
|
68
100
|
var me = this;
|
69
101
|
|
70
102
|
function update () {
|
71
103
|
me.stop();
|
72
104
|
|
73
105
|
// determine interval to refresh
|
74
|
-
var scale = me.range.conversion(me.
|
106
|
+
var scale = me.body.range.conversion(me.body.domProps.center.width).scale;
|
75
107
|
var interval = 1 / scale / 10;
|
76
108
|
if (interval < 30) interval = 30;
|
77
109
|
if (interval > 1000) interval = 1000;
|
78
110
|
|
79
|
-
me.
|
111
|
+
me.redraw();
|
80
112
|
|
81
113
|
// start a timer to adjust for the new time
|
82
114
|
me.currentTimeTimer = setTimeout(update, interval);
|
@@ -88,7 +120,7 @@ CurrentTime.prototype.start = function start() {
|
|
88
120
|
/**
|
89
121
|
* Stop auto refreshing the current time bar
|
90
122
|
*/
|
91
|
-
CurrentTime.prototype.stop = function
|
123
|
+
CurrentTime.prototype.stop = function() {
|
92
124
|
if (this.currentTimeTimer !== undefined) {
|
93
125
|
clearTimeout(this.currentTimeTimer);
|
94
126
|
delete this.currentTimeTimer;
|
@@ -1,35 +1,49 @@
|
|
1
1
|
/**
|
2
2
|
* A custom time bar
|
3
|
+
* @param {{range: Range, dom: Object}} body
|
3
4
|
* @param {Object} [options] Available parameters:
|
4
5
|
* {Boolean} [showCustomTime]
|
5
6
|
* @constructor CustomTime
|
6
7
|
* @extends Component
|
7
8
|
*/
|
8
9
|
|
9
|
-
function CustomTime (options) {
|
10
|
-
this.
|
10
|
+
function CustomTime (body, options) {
|
11
|
+
this.body = body;
|
11
12
|
|
12
|
-
|
13
|
+
// default options
|
13
14
|
this.defaultOptions = {
|
14
15
|
showCustomTime: false
|
15
16
|
};
|
17
|
+
this.options = util.extend({}, this.defaultOptions);
|
16
18
|
|
17
19
|
this.customTime = new Date();
|
18
20
|
this.eventParams = {}; // stores state parameters while dragging the bar
|
19
21
|
|
20
22
|
// create the DOM
|
21
23
|
this._create();
|
24
|
+
|
25
|
+
this.setOptions(options);
|
22
26
|
}
|
23
27
|
|
24
28
|
CustomTime.prototype = new Component();
|
25
29
|
|
26
|
-
|
30
|
+
/**
|
31
|
+
* Set options for the component. Options will be merged in current options.
|
32
|
+
* @param {Object} options Available parameters:
|
33
|
+
* {boolean} [showCustomTime]
|
34
|
+
*/
|
35
|
+
CustomTime.prototype.setOptions = function(options) {
|
36
|
+
if (options) {
|
37
|
+
// copy all options that we know
|
38
|
+
util.selectiveExtend(['showCustomTime'], this.options, options);
|
39
|
+
}
|
40
|
+
};
|
27
41
|
|
28
42
|
/**
|
29
43
|
* Create the DOM for the custom time
|
30
44
|
* @private
|
31
45
|
*/
|
32
|
-
CustomTime.prototype._create = function
|
46
|
+
CustomTime.prototype._create = function() {
|
33
47
|
var bar = document.createElement('div');
|
34
48
|
bar.className = 'customtime';
|
35
49
|
bar.style.position = 'absolute';
|
@@ -55,22 +69,44 @@ CustomTime.prototype._create = function _create () {
|
|
55
69
|
};
|
56
70
|
|
57
71
|
/**
|
58
|
-
*
|
59
|
-
* @returns {HTMLElement} frame
|
72
|
+
* Destroy the CustomTime bar
|
60
73
|
*/
|
61
|
-
CustomTime.prototype.
|
62
|
-
|
74
|
+
CustomTime.prototype.destroy = function () {
|
75
|
+
this.options.showCustomTime = false;
|
76
|
+
this.redraw(); // will remove the bar from the DOM
|
77
|
+
|
78
|
+
this.hammer.enable(false);
|
79
|
+
this.hammer = null;
|
80
|
+
|
81
|
+
this.body = null;
|
63
82
|
};
|
64
83
|
|
65
84
|
/**
|
66
85
|
* Repaint the component
|
67
86
|
* @return {boolean} Returns true if the component is resized
|
68
87
|
*/
|
69
|
-
CustomTime.prototype.
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
88
|
+
CustomTime.prototype.redraw = function () {
|
89
|
+
if (this.options.showCustomTime) {
|
90
|
+
var parent = this.body.dom.backgroundVertical;
|
91
|
+
if (this.bar.parentNode != parent) {
|
92
|
+
// attach to the dom
|
93
|
+
if (this.bar.parentNode) {
|
94
|
+
this.bar.parentNode.removeChild(this.bar);
|
95
|
+
}
|
96
|
+
parent.appendChild(this.bar);
|
97
|
+
}
|
98
|
+
|
99
|
+
var x = this.body.util.toScreen(this.customTime);
|
100
|
+
|
101
|
+
this.bar.style.left = x + 'px';
|
102
|
+
this.bar.title = 'Time: ' + this.customTime;
|
103
|
+
}
|
104
|
+
else {
|
105
|
+
// remove the line from the DOM
|
106
|
+
if (this.bar.parentNode) {
|
107
|
+
this.bar.parentNode.removeChild(this.bar);
|
108
|
+
}
|
109
|
+
}
|
74
110
|
|
75
111
|
return false;
|
76
112
|
};
|
@@ -81,7 +117,7 @@ CustomTime.prototype.repaint = function () {
|
|
81
117
|
*/
|
82
118
|
CustomTime.prototype.setCustomTime = function(time) {
|
83
119
|
this.customTime = new Date(time.valueOf());
|
84
|
-
this.
|
120
|
+
this.redraw();
|
85
121
|
};
|
86
122
|
|
87
123
|
/**
|
@@ -114,13 +150,13 @@ CustomTime.prototype._onDrag = function (event) {
|
|
114
150
|
if (!this.eventParams.dragging) return;
|
115
151
|
|
116
152
|
var deltaX = event.gesture.deltaX,
|
117
|
-
x = this.
|
118
|
-
time = this.
|
153
|
+
x = this.body.util.toScreen(this.eventParams.customTime) + deltaX,
|
154
|
+
time = this.body.util.toTime(x);
|
119
155
|
|
120
156
|
this.setCustomTime(time);
|
121
157
|
|
122
158
|
// fire a timechange event
|
123
|
-
this.emit('timechange', {
|
159
|
+
this.body.emitter.emit('timechange', {
|
124
160
|
time: new Date(this.customTime.valueOf())
|
125
161
|
});
|
126
162
|
|
@@ -137,7 +173,7 @@ CustomTime.prototype._onDragEnd = function (event) {
|
|
137
173
|
if (!this.eventParams.dragging) return;
|
138
174
|
|
139
175
|
// fire a timechanged event
|
140
|
-
this.emit('timechanged', {
|
176
|
+
this.body.emitter.emit('timechanged', {
|
141
177
|
time: new Date(this.customTime.valueOf())
|
142
178
|
});
|
143
179
|
|
@@ -16,6 +16,7 @@ function Group (groupId, data, itemSet) {
|
|
16
16
|
height: 0
|
17
17
|
}
|
18
18
|
};
|
19
|
+
this.className = null;
|
19
20
|
|
20
21
|
this.items = {}; // items filtered by groupId of this group
|
21
22
|
this.visibleItems = []; // items currently visible in window
|
@@ -49,8 +50,10 @@ Group.prototype._create = function() {
|
|
49
50
|
this.dom.foreground = foreground;
|
50
51
|
|
51
52
|
this.dom.background = document.createElement('div');
|
53
|
+
this.dom.background.className = 'group';
|
52
54
|
|
53
55
|
this.dom.axis = document.createElement('div');
|
56
|
+
this.dom.axis.className = 'group';
|
54
57
|
|
55
58
|
// create a hidden marker to detect when the Timelines container is attached
|
56
59
|
// to the DOM, or the style of a parent of the Timeline is changed from
|
@@ -65,7 +68,7 @@ Group.prototype._create = function() {
|
|
65
68
|
* Set the group data for this group
|
66
69
|
* @param {Object} data Group data, can contain properties content and className
|
67
70
|
*/
|
68
|
-
Group.prototype.setData = function
|
71
|
+
Group.prototype.setData = function(data) {
|
69
72
|
// update contents
|
70
73
|
var content = data && data.content;
|
71
74
|
if (content instanceof Element) {
|
@@ -78,42 +81,34 @@ Group.prototype.setData = function setData(data) {
|
|
78
81
|
this.dom.inner.innerHTML = this.groupId;
|
79
82
|
}
|
80
83
|
|
84
|
+
if (!this.dom.inner.firstChild) {
|
85
|
+
util.addClassName(this.dom.inner, 'hidden');
|
86
|
+
}
|
87
|
+
else {
|
88
|
+
util.removeClassName(this.dom.inner, 'hidden');
|
89
|
+
}
|
90
|
+
|
81
91
|
// update className
|
82
|
-
var className = data && data.className;
|
83
|
-
if (className) {
|
92
|
+
var className = data && data.className || null;
|
93
|
+
if (className != this.className) {
|
94
|
+
if (this.className) {
|
95
|
+
util.removeClassName(this.dom.label, className);
|
96
|
+
util.removeClassName(this.dom.foreground, className);
|
97
|
+
util.removeClassName(this.dom.background, className);
|
98
|
+
util.removeClassName(this.dom.axis, className);
|
99
|
+
}
|
84
100
|
util.addClassName(this.dom.label, className);
|
101
|
+
util.addClassName(this.dom.foreground, className);
|
102
|
+
util.addClassName(this.dom.background, className);
|
103
|
+
util.addClassName(this.dom.axis, className);
|
85
104
|
}
|
86
105
|
};
|
87
106
|
|
88
|
-
/**
|
89
|
-
* Get the foreground container element
|
90
|
-
* @return {HTMLElement} foreground
|
91
|
-
*/
|
92
|
-
Group.prototype.getForeground = function getForeground() {
|
93
|
-
return this.dom.foreground;
|
94
|
-
};
|
95
|
-
|
96
|
-
/**
|
97
|
-
* Get the background container element
|
98
|
-
* @return {HTMLElement} background
|
99
|
-
*/
|
100
|
-
Group.prototype.getBackground = function getBackground() {
|
101
|
-
return this.dom.background;
|
102
|
-
};
|
103
|
-
|
104
|
-
/**
|
105
|
-
* Get the axis container element
|
106
|
-
* @return {HTMLElement} axis
|
107
|
-
*/
|
108
|
-
Group.prototype.getAxis = function getAxis() {
|
109
|
-
return this.dom.axis;
|
110
|
-
};
|
111
|
-
|
112
107
|
/**
|
113
108
|
* Get the width of the group label
|
114
109
|
* @return {number} width
|
115
110
|
*/
|
116
|
-
Group.prototype.getLabelWidth = function
|
111
|
+
Group.prototype.getLabelWidth = function() {
|
117
112
|
return this.props.label.width;
|
118
113
|
};
|
119
114
|
|
@@ -125,7 +120,7 @@ Group.prototype.getLabelWidth = function getLabelWidth() {
|
|
125
120
|
* @param {boolean} [restack=false] Force restacking of all items
|
126
121
|
* @return {boolean} Returns true if the group is resized
|
127
122
|
*/
|
128
|
-
Group.prototype.
|
123
|
+
Group.prototype.redraw = function(range, margin, restack) {
|
129
124
|
var resized = false;
|
130
125
|
|
131
126
|
this.visibleItems = this._updateVisibleItems(this.orderedItems, this.visibleItems, range);
|
@@ -138,7 +133,7 @@ Group.prototype.repaint = function repaint(range, margin, restack) {
|
|
138
133
|
|
139
134
|
util.forEach(this.items, function (item) {
|
140
135
|
item.dirty = true;
|
141
|
-
if (item.displayed) item.
|
136
|
+
if (item.displayed) item.redraw();
|
142
137
|
});
|
143
138
|
|
144
139
|
restack = true;
|
@@ -151,10 +146,6 @@ Group.prototype.repaint = function repaint(range, margin, restack) {
|
|
151
146
|
else { // no stacking
|
152
147
|
stack.nostack(this.visibleItems, margin);
|
153
148
|
}
|
154
|
-
for (var i = 0, ii = this.visibleItems.length; i < ii; i++) {
|
155
|
-
var item = this.visibleItems[i];
|
156
|
-
item.repositionY();
|
157
|
-
}
|
158
149
|
|
159
150
|
// recalculate the height of the group
|
160
151
|
var height;
|
@@ -188,34 +179,40 @@ Group.prototype.repaint = function repaint(range, margin, restack) {
|
|
188
179
|
foreground.style.height = height + 'px';
|
189
180
|
this.dom.label.style.height = height + 'px';
|
190
181
|
|
182
|
+
// update vertical position of items after they are re-stacked and the height of the group is calculated
|
183
|
+
for (var i = 0, ii = this.visibleItems.length; i < ii; i++) {
|
184
|
+
var item = this.visibleItems[i];
|
185
|
+
item.repositionY();
|
186
|
+
}
|
187
|
+
|
191
188
|
return resized;
|
192
189
|
};
|
193
190
|
|
194
191
|
/**
|
195
192
|
* Show this group: attach to the DOM
|
196
193
|
*/
|
197
|
-
Group.prototype.show = function
|
194
|
+
Group.prototype.show = function() {
|
198
195
|
if (!this.dom.label.parentNode) {
|
199
|
-
this.itemSet.
|
196
|
+
this.itemSet.dom.labelSet.appendChild(this.dom.label);
|
200
197
|
}
|
201
198
|
|
202
199
|
if (!this.dom.foreground.parentNode) {
|
203
|
-
this.itemSet.
|
200
|
+
this.itemSet.dom.foreground.appendChild(this.dom.foreground);
|
204
201
|
}
|
205
202
|
|
206
203
|
if (!this.dom.background.parentNode) {
|
207
|
-
this.itemSet.
|
204
|
+
this.itemSet.dom.background.appendChild(this.dom.background);
|
208
205
|
}
|
209
206
|
|
210
207
|
if (!this.dom.axis.parentNode) {
|
211
|
-
this.itemSet.
|
208
|
+
this.itemSet.dom.axis.appendChild(this.dom.axis);
|
212
209
|
}
|
213
210
|
};
|
214
211
|
|
215
212
|
/**
|
216
213
|
* Hide this group: remove from the DOM
|
217
214
|
*/
|
218
|
-
Group.prototype.hide = function
|
215
|
+
Group.prototype.hide = function() {
|
219
216
|
var label = this.dom.label;
|
220
217
|
if (label.parentNode) {
|
221
218
|
label.parentNode.removeChild(label);
|
@@ -241,12 +238,12 @@ Group.prototype.hide = function hide() {
|
|
241
238
|
* Add an item to the group
|
242
239
|
* @param {Item} item
|
243
240
|
*/
|
244
|
-
Group.prototype.add = function
|
241
|
+
Group.prototype.add = function(item) {
|
245
242
|
this.items[item.id] = item;
|
246
243
|
item.setParent(this);
|
247
244
|
|
248
245
|
if (item instanceof ItemRange && this.visibleItems.indexOf(item) == -1) {
|
249
|
-
var range = this.itemSet.range; // TODO: not nice accessing the range like this
|
246
|
+
var range = this.itemSet.body.range; // TODO: not nice accessing the range like this
|
250
247
|
this._checkIfVisible(item, this.visibleItems, range);
|
251
248
|
}
|
252
249
|
};
|
@@ -255,7 +252,7 @@ Group.prototype.add = function add(item) {
|
|
255
252
|
* Remove an item from the group
|
256
253
|
* @param {Item} item
|
257
254
|
*/
|
258
|
-
Group.prototype.remove = function
|
255
|
+
Group.prototype.remove = function(item) {
|
259
256
|
delete this.items[item.id];
|
260
257
|
item.setParent(this.itemSet);
|
261
258
|
|
@@ -270,14 +267,14 @@ Group.prototype.remove = function remove(item) {
|
|
270
267
|
* Remove an item from the corresponding DataSet
|
271
268
|
* @param {Item} item
|
272
269
|
*/
|
273
|
-
Group.prototype.removeFromDataSet = function
|
270
|
+
Group.prototype.removeFromDataSet = function(item) {
|
274
271
|
this.itemSet.removeItem(item.id);
|
275
272
|
};
|
276
273
|
|
277
274
|
/**
|
278
275
|
* Reorder the items
|
279
276
|
*/
|
280
|
-
Group.prototype.order = function
|
277
|
+
Group.prototype.order = function() {
|
281
278
|
var array = util.toArray(this.items);
|
282
279
|
this.orderedItems.byStart = array;
|
283
280
|
this.orderedItems.byEnd = this._constructByEndArray(array);
|
@@ -292,7 +289,7 @@ Group.prototype.order = function order() {
|
|
292
289
|
* @returns {ItemRange[]}
|
293
290
|
* @private
|
294
291
|
*/
|
295
|
-
Group.prototype._constructByEndArray = function
|
292
|
+
Group.prototype._constructByEndArray = function(array) {
|
296
293
|
var endArray = [];
|
297
294
|
|
298
295
|
for (var i = 0; i < array.length; i++) {
|
@@ -311,7 +308,7 @@ Group.prototype._constructByEndArray = function _constructByEndArray(array) {
|
|
311
308
|
* @return {Item[]} visibleItems The new visible items.
|
312
309
|
* @private
|
313
310
|
*/
|
314
|
-
Group.prototype._updateVisibleItems = function
|
311
|
+
Group.prototype._updateVisibleItems = function(orderedItems, visibleItems, range) {
|
315
312
|
var initialPosByStart,
|
316
313
|
newVisibleItems = [],
|
317
314
|
i;
|
@@ -374,7 +371,7 @@ Group.prototype._updateVisibleItems = function _updateVisibleItems(orderedItems,
|
|
374
371
|
* @returns {number}
|
375
372
|
* @private
|
376
373
|
*/
|
377
|
-
Group.prototype._binarySearch = function
|
374
|
+
Group.prototype._binarySearch = function(orderedItems, range, byEnd) {
|
378
375
|
var array = [];
|
379
376
|
var byTime = byEnd ? 'end' : 'start';
|
380
377
|
if (byEnd == true) {array = orderedItems.byEnd; }
|
@@ -435,7 +432,7 @@ Group.prototype._binarySearch = function _binarySearch(orderedItems, range, byEn
|
|
435
432
|
* @returns {boolean}
|
436
433
|
* @private
|
437
434
|
*/
|
438
|
-
Group.prototype._checkIfInvisible = function
|
435
|
+
Group.prototype._checkIfInvisible = function(item, visibleItems, range) {
|
439
436
|
if (item.isVisible(range)) {
|
440
437
|
if (!item.displayed) item.show();
|
441
438
|
item.repositionX();
|
@@ -460,7 +457,7 @@ Group.prototype._checkIfInvisible = function _checkIfInvisible(item, visibleItem
|
|
460
457
|
* @param {{start:number, end:number}} range
|
461
458
|
* @private
|
462
459
|
*/
|
463
|
-
Group.prototype._checkIfVisible = function
|
460
|
+
Group.prototype._checkIfVisible = function(item, visibleItems, range) {
|
464
461
|
if (item.isVisible(range)) {
|
465
462
|
if (!item.displayed) item.show();
|
466
463
|
// reposition item horizontally
|