vis-rails 1.0.2 → 2.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.
- 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
@@ -3,11 +3,12 @@
|
|
3
3
|
* @extends Item
|
4
4
|
* @param {Object} data Object containing parameters start
|
5
5
|
* content, className.
|
6
|
-
* @param {
|
7
|
-
*
|
6
|
+
* @param {{toScreen: function, toTime: function}} conversion
|
7
|
+
* Conversion functions from time to screen and vice versa
|
8
|
+
* @param {Object} [options] Configuration options
|
8
9
|
* // TODO: describe available options
|
9
10
|
*/
|
10
|
-
function ItemPoint (data,
|
11
|
+
function ItemPoint (data, conversion, options) {
|
11
12
|
this.props = {
|
12
13
|
dot: {
|
13
14
|
top: 0,
|
@@ -27,17 +28,17 @@ function ItemPoint (data, options, defaultOptions) {
|
|
27
28
|
}
|
28
29
|
}
|
29
30
|
|
30
|
-
Item.call(this, data,
|
31
|
+
Item.call(this, data, conversion, options);
|
31
32
|
}
|
32
33
|
|
33
|
-
ItemPoint.prototype = new Item (null);
|
34
|
+
ItemPoint.prototype = new Item (null, null, null);
|
34
35
|
|
35
36
|
/**
|
36
37
|
* Check whether this item is visible inside given range
|
37
38
|
* @returns {{start: Number, end: Number}} range with a timestamp for start and end
|
38
39
|
* @returns {boolean} True if visible
|
39
40
|
*/
|
40
|
-
ItemPoint.prototype.isVisible = function
|
41
|
+
ItemPoint.prototype.isVisible = function(range) {
|
41
42
|
// determine visibility
|
42
43
|
// TODO: account for the real width of the item. Right now we just add 1/4 to the window
|
43
44
|
var interval = (range.end - range.start) / 4;
|
@@ -47,7 +48,7 @@ ItemPoint.prototype.isVisible = function isVisible (range) {
|
|
47
48
|
/**
|
48
49
|
* Repaint the item
|
49
50
|
*/
|
50
|
-
ItemPoint.prototype.
|
51
|
+
ItemPoint.prototype.redraw = function() {
|
51
52
|
var dom = this.dom;
|
52
53
|
if (!dom) {
|
53
54
|
// create DOM
|
@@ -56,7 +57,7 @@ ItemPoint.prototype.repaint = function repaint() {
|
|
56
57
|
|
57
58
|
// background box
|
58
59
|
dom.point = document.createElement('div');
|
59
|
-
// className is updated in
|
60
|
+
// className is updated in redraw()
|
60
61
|
|
61
62
|
// contents box, right from the dot
|
62
63
|
dom.content = document.createElement('div');
|
@@ -73,12 +74,12 @@ ItemPoint.prototype.repaint = function repaint() {
|
|
73
74
|
|
74
75
|
// append DOM to parent DOM
|
75
76
|
if (!this.parent) {
|
76
|
-
throw new Error('Cannot
|
77
|
+
throw new Error('Cannot redraw item: no parent attached');
|
77
78
|
}
|
78
79
|
if (!dom.point.parentNode) {
|
79
|
-
var foreground = this.parent.
|
80
|
+
var foreground = this.parent.dom.foreground;
|
80
81
|
if (!foreground) {
|
81
|
-
throw new Error('Cannot
|
82
|
+
throw new Error('Cannot redraw time axis: parent has no foreground container element');
|
82
83
|
}
|
83
84
|
foreground.appendChild(dom.point);
|
84
85
|
}
|
@@ -137,16 +138,16 @@ ItemPoint.prototype.repaint = function repaint() {
|
|
137
138
|
* Show the item in the DOM (when not already visible). The items DOM will
|
138
139
|
* be created when needed.
|
139
140
|
*/
|
140
|
-
ItemPoint.prototype.show = function
|
141
|
+
ItemPoint.prototype.show = function() {
|
141
142
|
if (!this.displayed) {
|
142
|
-
this.
|
143
|
+
this.redraw();
|
143
144
|
}
|
144
145
|
};
|
145
146
|
|
146
147
|
/**
|
147
148
|
* Hide the item from the DOM (when visible)
|
148
149
|
*/
|
149
|
-
ItemPoint.prototype.hide = function
|
150
|
+
ItemPoint.prototype.hide = function() {
|
150
151
|
if (this.displayed) {
|
151
152
|
if (this.dom.point.parentNode) {
|
152
153
|
this.dom.point.parentNode.removeChild(this.dom.point);
|
@@ -163,8 +164,8 @@ ItemPoint.prototype.hide = function hide() {
|
|
163
164
|
* Reposition the item horizontally
|
164
165
|
* @Override
|
165
166
|
*/
|
166
|
-
ItemPoint.prototype.repositionX = function
|
167
|
-
var start = this.
|
167
|
+
ItemPoint.prototype.repositionX = function() {
|
168
|
+
var start = this.conversion.toScreen(this.data.start);
|
168
169
|
|
169
170
|
this.left = start - this.props.dot.width;
|
170
171
|
|
@@ -176,16 +177,14 @@ ItemPoint.prototype.repositionX = function repositionX() {
|
|
176
177
|
* Reposition the item vertically
|
177
178
|
* @Override
|
178
179
|
*/
|
179
|
-
ItemPoint.prototype.repositionY = function
|
180
|
-
var orientation = this.options.orientation
|
180
|
+
ItemPoint.prototype.repositionY = function() {
|
181
|
+
var orientation = this.options.orientation,
|
181
182
|
point = this.dom.point;
|
182
183
|
|
183
184
|
if (orientation == 'top') {
|
184
185
|
point.style.top = this.top + 'px';
|
185
|
-
point.style.bottom = '';
|
186
186
|
}
|
187
187
|
else {
|
188
|
-
point.style.top = '';
|
189
|
-
point.style.bottom = this.top + 'px';
|
188
|
+
point.style.top = (this.parent.height - this.top - this.height) + 'px';
|
190
189
|
}
|
191
190
|
};
|
@@ -3,11 +3,12 @@
|
|
3
3
|
* @extends Item
|
4
4
|
* @param {Object} data Object containing parameters start, end
|
5
5
|
* content, className.
|
6
|
-
* @param {
|
7
|
-
*
|
8
|
-
*
|
6
|
+
* @param {{toScreen: function, toTime: function}} conversion
|
7
|
+
* Conversion functions from time to screen and vice versa
|
8
|
+
* @param {Object} [options] Configuration options
|
9
|
+
* // TODO: describe options
|
9
10
|
*/
|
10
|
-
function ItemRange (data,
|
11
|
+
function ItemRange (data, conversion, options) {
|
11
12
|
this.props = {
|
12
13
|
content: {
|
13
14
|
width: 0
|
@@ -24,10 +25,10 @@ function ItemRange (data, options, defaultOptions) {
|
|
24
25
|
}
|
25
26
|
}
|
26
27
|
|
27
|
-
Item.call(this, data,
|
28
|
+
Item.call(this, data, conversion, options);
|
28
29
|
}
|
29
30
|
|
30
|
-
ItemRange.prototype = new Item (null);
|
31
|
+
ItemRange.prototype = new Item (null, null, null);
|
31
32
|
|
32
33
|
ItemRange.prototype.baseClassName = 'item range';
|
33
34
|
|
@@ -36,7 +37,7 @@ ItemRange.prototype.baseClassName = 'item range';
|
|
36
37
|
* @returns {{start: Number, end: Number}} range with a timestamp for start and end
|
37
38
|
* @returns {boolean} True if visible
|
38
39
|
*/
|
39
|
-
ItemRange.prototype.isVisible = function
|
40
|
+
ItemRange.prototype.isVisible = function(range) {
|
40
41
|
// determine visibility
|
41
42
|
return (this.data.start < range.end) && (this.data.end > range.start);
|
42
43
|
};
|
@@ -44,7 +45,7 @@ ItemRange.prototype.isVisible = function isVisible (range) {
|
|
44
45
|
/**
|
45
46
|
* Repaint the item
|
46
47
|
*/
|
47
|
-
ItemRange.prototype.
|
48
|
+
ItemRange.prototype.redraw = function() {
|
48
49
|
var dom = this.dom;
|
49
50
|
if (!dom) {
|
50
51
|
// create DOM
|
@@ -53,7 +54,7 @@ ItemRange.prototype.repaint = function repaint() {
|
|
53
54
|
|
54
55
|
// background box
|
55
56
|
dom.box = document.createElement('div');
|
56
|
-
// className is updated in
|
57
|
+
// className is updated in redraw()
|
57
58
|
|
58
59
|
// contents box
|
59
60
|
dom.content = document.createElement('div');
|
@@ -66,12 +67,12 @@ ItemRange.prototype.repaint = function repaint() {
|
|
66
67
|
|
67
68
|
// append DOM to parent DOM
|
68
69
|
if (!this.parent) {
|
69
|
-
throw new Error('Cannot
|
70
|
+
throw new Error('Cannot redraw item: no parent attached');
|
70
71
|
}
|
71
72
|
if (!dom.box.parentNode) {
|
72
|
-
var foreground = this.parent.
|
73
|
+
var foreground = this.parent.dom.foreground;
|
73
74
|
if (!foreground) {
|
74
|
-
throw new Error('Cannot
|
75
|
+
throw new Error('Cannot redraw time axis: parent has no foreground container element');
|
75
76
|
}
|
76
77
|
foreground.appendChild(dom.box);
|
77
78
|
}
|
@@ -121,9 +122,9 @@ ItemRange.prototype.repaint = function repaint() {
|
|
121
122
|
* Show the item in the DOM (when not already visible). The items DOM will
|
122
123
|
* be created when needed.
|
123
124
|
*/
|
124
|
-
ItemRange.prototype.show = function
|
125
|
+
ItemRange.prototype.show = function() {
|
125
126
|
if (!this.displayed) {
|
126
|
-
this.
|
127
|
+
this.redraw();
|
127
128
|
}
|
128
129
|
};
|
129
130
|
|
@@ -131,7 +132,7 @@ ItemRange.prototype.show = function show() {
|
|
131
132
|
* Hide the item from the DOM (when visible)
|
132
133
|
* @return {Boolean} changed
|
133
134
|
*/
|
134
|
-
ItemRange.prototype.hide = function
|
135
|
+
ItemRange.prototype.hide = function() {
|
135
136
|
if (this.displayed) {
|
136
137
|
var box = this.dom.box;
|
137
138
|
|
@@ -150,12 +151,12 @@ ItemRange.prototype.hide = function hide() {
|
|
150
151
|
* Reposition the item horizontally
|
151
152
|
* @Override
|
152
153
|
*/
|
153
|
-
ItemRange.prototype.repositionX = function
|
154
|
+
ItemRange.prototype.repositionX = function() {
|
154
155
|
var props = this.props,
|
155
156
|
parentWidth = this.parent.width,
|
156
|
-
start = this.
|
157
|
-
end = this.
|
158
|
-
padding =
|
157
|
+
start = this.conversion.toScreen(this.data.start),
|
158
|
+
end = this.conversion.toScreen(this.data.end),
|
159
|
+
padding = this.options.padding,
|
159
160
|
contentLeft;
|
160
161
|
|
161
162
|
// limit the width of the this, as browsers cannot draw very wide divs
|
@@ -188,17 +189,15 @@ ItemRange.prototype.repositionX = function repositionX() {
|
|
188
189
|
* Reposition the item vertically
|
189
190
|
* @Override
|
190
191
|
*/
|
191
|
-
ItemRange.prototype.repositionY = function
|
192
|
-
var orientation = this.options.orientation
|
192
|
+
ItemRange.prototype.repositionY = function() {
|
193
|
+
var orientation = this.options.orientation,
|
193
194
|
box = this.dom.box;
|
194
195
|
|
195
196
|
if (orientation == 'top') {
|
196
197
|
box.style.top = this.top + 'px';
|
197
|
-
box.style.bottom = '';
|
198
198
|
}
|
199
199
|
else {
|
200
|
-
box.style.top = '';
|
201
|
-
box.style.bottom = this.top + 'px';
|
200
|
+
box.style.top = (this.parent.height - this.top - this.height) + 'px';
|
202
201
|
}
|
203
202
|
};
|
204
203
|
|
@@ -3,11 +3,12 @@
|
|
3
3
|
* @extends ItemRange
|
4
4
|
* @param {Object} data Object containing parameters start, end
|
5
5
|
* content, className.
|
6
|
-
* @param {
|
7
|
-
*
|
8
|
-
*
|
6
|
+
* @param {{toScreen: function, toTime: function}} conversion
|
7
|
+
* Conversion functions from time to screen and vice versa
|
8
|
+
* @param {Object} [options] Configuration options
|
9
|
+
* // TODO: describe options
|
9
10
|
*/
|
10
|
-
function ItemRangeOverflow (data,
|
11
|
+
function ItemRangeOverflow (data, conversion, options) {
|
11
12
|
this.props = {
|
12
13
|
content: {
|
13
14
|
left: 0,
|
@@ -15,10 +16,10 @@ function ItemRangeOverflow (data, options, defaultOptions) {
|
|
15
16
|
}
|
16
17
|
};
|
17
18
|
|
18
|
-
ItemRange.call(this, data,
|
19
|
+
ItemRange.call(this, data, conversion, options);
|
19
20
|
}
|
20
21
|
|
21
|
-
ItemRangeOverflow.prototype = new ItemRange (null);
|
22
|
+
ItemRangeOverflow.prototype = new ItemRange (null, null, null);
|
22
23
|
|
23
24
|
ItemRangeOverflow.prototype.baseClassName = 'item rangeoverflow';
|
24
25
|
|
@@ -26,11 +27,10 @@ ItemRangeOverflow.prototype.baseClassName = 'item rangeoverflow';
|
|
26
27
|
* Reposition the item horizontally
|
27
28
|
* @Override
|
28
29
|
*/
|
29
|
-
ItemRangeOverflow.prototype.repositionX = function
|
30
|
+
ItemRangeOverflow.prototype.repositionX = function() {
|
30
31
|
var parentWidth = this.parent.width,
|
31
|
-
start = this.
|
32
|
-
end = this.
|
33
|
-
padding = 'padding' in this.options ? this.options.padding : this.defaultOptions.padding,
|
32
|
+
start = this.conversion.toScreen(this.data.start),
|
33
|
+
end = this.conversion.toScreen(this.data.end),
|
34
34
|
contentLeft;
|
35
35
|
|
36
36
|
// limit the width of the this, as browsers cannot draw very wide divs
|
@@ -7,7 +7,7 @@ var stack = {};
|
|
7
7
|
* Order items by their start data
|
8
8
|
* @param {Item[]} items
|
9
9
|
*/
|
10
|
-
stack.orderByStart = function
|
10
|
+
stack.orderByStart = function(items) {
|
11
11
|
items.sort(function (a, b) {
|
12
12
|
return a.data.start - b.data.start;
|
13
13
|
});
|
@@ -18,7 +18,7 @@ stack.orderByStart = function orderByStart(items) {
|
|
18
18
|
* is used.
|
19
19
|
* @param {Item[]} items
|
20
20
|
*/
|
21
|
-
stack.orderByEnd = function
|
21
|
+
stack.orderByEnd = function(items) {
|
22
22
|
items.sort(function (a, b) {
|
23
23
|
var aTime = ('end' in a.data) ? a.data.end : a.data.start,
|
24
24
|
bTime = ('end' in b.data) ? b.data.end : b.data.start;
|
@@ -38,7 +38,7 @@ stack.orderByEnd = function orderByEnd(items) {
|
|
38
38
|
* If true, all items will be repositioned. If false (default), only
|
39
39
|
* items having a top===null will be re-stacked
|
40
40
|
*/
|
41
|
-
stack.stack = function
|
41
|
+
stack.stack = function(items, margin, force) {
|
42
42
|
var i, iMax;
|
43
43
|
|
44
44
|
if (force) {
|
@@ -83,7 +83,7 @@ stack.stack = function _stack (items, margin, force) {
|
|
83
83
|
* @param {{item: number, axis: number}} margin
|
84
84
|
* Margins between items and between items and the axis.
|
85
85
|
*/
|
86
|
-
stack.nostack = function
|
86
|
+
stack.nostack = function(items, margin) {
|
87
87
|
var i, iMax;
|
88
88
|
|
89
89
|
// reset top position of all items
|
@@ -104,7 +104,7 @@ stack.nostack = function nostack (items, margin) {
|
|
104
104
|
* the requested margin.
|
105
105
|
* @return {boolean} true if a and b collide, else false
|
106
106
|
*/
|
107
|
-
stack.collision = function
|
107
|
+
stack.collision = function(a, b, margin) {
|
108
108
|
return ((a.left - margin) < (b.left + b.width) &&
|
109
109
|
(a.left + a.width + margin) > b.left &&
|
110
110
|
(a.top - margin) < (b.top + b.height) &&
|
data/vendor/assets/vis/util.js
CHANGED
@@ -8,7 +8,7 @@ var util = {};
|
|
8
8
|
* @param {*} object
|
9
9
|
* @return {Boolean} isNumber
|
10
10
|
*/
|
11
|
-
util.isNumber = function
|
11
|
+
util.isNumber = function(object) {
|
12
12
|
return (object instanceof Number || typeof object == 'number');
|
13
13
|
};
|
14
14
|
|
@@ -17,7 +17,7 @@ util.isNumber = function isNumber(object) {
|
|
17
17
|
* @param {*} object
|
18
18
|
* @return {Boolean} isString
|
19
19
|
*/
|
20
|
-
util.isString = function
|
20
|
+
util.isString = function(object) {
|
21
21
|
return (object instanceof String || typeof object == 'string');
|
22
22
|
};
|
23
23
|
|
@@ -26,7 +26,7 @@ util.isString = function isString(object) {
|
|
26
26
|
* @param {Date | String} object
|
27
27
|
* @return {Boolean} isDate
|
28
28
|
*/
|
29
|
-
util.isDate = function
|
29
|
+
util.isDate = function(object) {
|
30
30
|
if (object instanceof Date) {
|
31
31
|
return true;
|
32
32
|
}
|
@@ -49,7 +49,7 @@ util.isDate = function isDate(object) {
|
|
49
49
|
* @param {*} object
|
50
50
|
* @return {Boolean} isDataTable
|
51
51
|
*/
|
52
|
-
util.isDataTable = function
|
52
|
+
util.isDataTable = function(object) {
|
53
53
|
return (typeof (google) !== 'undefined') &&
|
54
54
|
(google.visualization) &&
|
55
55
|
(google.visualization.DataTable) &&
|
@@ -61,7 +61,7 @@ util.isDataTable = function isDataTable(object) {
|
|
61
61
|
* source: http://stackoverflow.com/a/105074/1262753
|
62
62
|
* @return {String} uuid
|
63
63
|
*/
|
64
|
-
util.randomUUID = function
|
64
|
+
util.randomUUID = function() {
|
65
65
|
var S4 = function () {
|
66
66
|
return Math.floor(
|
67
67
|
Math.random() * 0x10000 /* 65536 */
|
@@ -88,7 +88,34 @@ util.extend = function (a, b) {
|
|
88
88
|
for (var i = 1, len = arguments.length; i < len; i++) {
|
89
89
|
var other = arguments[i];
|
90
90
|
for (var prop in other) {
|
91
|
-
if (other.hasOwnProperty(prop)
|
91
|
+
if (other.hasOwnProperty(prop)) {
|
92
|
+
a[prop] = other[prop];
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
return a;
|
98
|
+
};
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Extend object a with selected properties of object b or a series of objects
|
102
|
+
* Only properties with defined values are copied
|
103
|
+
* @param {Array.<String>} props
|
104
|
+
* @param {Object} a
|
105
|
+
* @param {... Object} b
|
106
|
+
* @return {Object} a
|
107
|
+
*/
|
108
|
+
util.selectiveExtend = function (props, a, b) {
|
109
|
+
if (!Array.isArray(props)) {
|
110
|
+
throw new Error('Array with property names expected as first argument');
|
111
|
+
}
|
112
|
+
|
113
|
+
for (var i = 1, len = arguments.length; i < len; i++) {
|
114
|
+
var other = arguments[i];
|
115
|
+
|
116
|
+
for (var p = 0, pp = props.length; p < pp; p++) {
|
117
|
+
var prop = props[p];
|
118
|
+
if (other.hasOwnProperty(prop)) {
|
92
119
|
a[prop] = other[prop];
|
93
120
|
}
|
94
121
|
}
|
@@ -103,7 +130,7 @@ util.extend = function (a, b) {
|
|
103
130
|
* @param {Object} b
|
104
131
|
* @returns {Object}
|
105
132
|
*/
|
106
|
-
util.deepExtend = function
|
133
|
+
util.deepExtend = function(a, b) {
|
107
134
|
// TODO: add support for Arrays to deepExtend
|
108
135
|
if (Array.isArray(b)) {
|
109
136
|
throw new TypeError('Arrays are not supported by deepExtend');
|
@@ -116,7 +143,7 @@ util.deepExtend = function deepExtend (a, b) {
|
|
116
143
|
a[prop] = {};
|
117
144
|
}
|
118
145
|
if (a[prop].constructor === Object) {
|
119
|
-
deepExtend(a[prop], b[prop]);
|
146
|
+
util.deepExtend(a[prop], b[prop]);
|
120
147
|
}
|
121
148
|
else {
|
122
149
|
a[prop] = b[prop];
|
@@ -157,7 +184,7 @@ util.equalArray = function (a, b) {
|
|
157
184
|
* @return {*} object
|
158
185
|
* @throws Error
|
159
186
|
*/
|
160
|
-
util.convert = function
|
187
|
+
util.convert = function(object, type) {
|
161
188
|
var match;
|
162
189
|
|
163
190
|
if (object === undefined) {
|
@@ -292,8 +319,7 @@ util.convert = function convert(object, type) {
|
|
292
319
|
}
|
293
320
|
|
294
321
|
default:
|
295
|
-
throw new Error('
|
296
|
-
' to type "' + type + '"');
|
322
|
+
throw new Error('Unknown type "' + type + '"');
|
297
323
|
}
|
298
324
|
};
|
299
325
|
|
@@ -307,7 +333,7 @@ var ASPDateRegex = /^\/?Date\((\-?\d+)/i;
|
|
307
333
|
* @param {*} object
|
308
334
|
* @return {String} type
|
309
335
|
*/
|
310
|
-
util.getType = function
|
336
|
+
util.getType = function(object) {
|
311
337
|
var type = typeof object;
|
312
338
|
|
313
339
|
if (type == 'object') {
|
@@ -350,7 +376,7 @@ util.getType = function getType(object) {
|
|
350
376
|
* @return {number} left The absolute left position of this element
|
351
377
|
* in the browser page.
|
352
378
|
*/
|
353
|
-
util.getAbsoluteLeft = function
|
379
|
+
util.getAbsoluteLeft = function(elem) {
|
354
380
|
var doc = document.documentElement;
|
355
381
|
var body = document.body;
|
356
382
|
|
@@ -370,7 +396,7 @@ util.getAbsoluteLeft = function getAbsoluteLeft (elem) {
|
|
370
396
|
* @return {number} top The absolute top position of this element
|
371
397
|
* in the browser page.
|
372
398
|
*/
|
373
|
-
util.getAbsoluteTop = function
|
399
|
+
util.getAbsoluteTop = function(elem) {
|
374
400
|
var doc = document.documentElement;
|
375
401
|
var body = document.body;
|
376
402
|
|
@@ -389,7 +415,7 @@ util.getAbsoluteTop = function getAbsoluteTop (elem) {
|
|
389
415
|
* @param {Event} event
|
390
416
|
* @return {Number} pageY
|
391
417
|
*/
|
392
|
-
util.getPageY = function
|
418
|
+
util.getPageY = function(event) {
|
393
419
|
if ('pageY' in event) {
|
394
420
|
return event.pageY;
|
395
421
|
}
|
@@ -415,7 +441,7 @@ util.getPageY = function getPageY (event) {
|
|
415
441
|
* @param {Event} event
|
416
442
|
* @return {Number} pageX
|
417
443
|
*/
|
418
|
-
util.getPageX = function
|
444
|
+
util.getPageX = function(event) {
|
419
445
|
if ('pageY' in event) {
|
420
446
|
return event.pageX;
|
421
447
|
}
|
@@ -441,7 +467,7 @@ util.getPageX = function getPageX (event) {
|
|
441
467
|
* @param {Element} elem
|
442
468
|
* @param {String} className
|
443
469
|
*/
|
444
|
-
util.addClassName = function
|
470
|
+
util.addClassName = function(elem, className) {
|
445
471
|
var classes = elem.className.split(' ');
|
446
472
|
if (classes.indexOf(className) == -1) {
|
447
473
|
classes.push(className); // add the class to the array
|
@@ -454,7 +480,7 @@ util.addClassName = function addClassName(elem, className) {
|
|
454
480
|
* @param {Element} elem
|
455
481
|
* @param {String} className
|
456
482
|
*/
|
457
|
-
util.removeClassName = function
|
483
|
+
util.removeClassName = function(elem, className) {
|
458
484
|
var classes = elem.className.split(' ');
|
459
485
|
var index = classes.indexOf(className);
|
460
486
|
if (index != -1) {
|
@@ -472,7 +498,7 @@ util.removeClassName = function removeClassname(elem, className) {
|
|
472
498
|
* the object or array with three parameters:
|
473
499
|
* callback(value, index, object)
|
474
500
|
*/
|
475
|
-
util.forEach = function
|
501
|
+
util.forEach = function(object, callback) {
|
476
502
|
var i,
|
477
503
|
len;
|
478
504
|
if (object instanceof Array) {
|
@@ -497,7 +523,7 @@ util.forEach = function forEach (object, callback) {
|
|
497
523
|
* @param {Object} object
|
498
524
|
* @param {Array} array
|
499
525
|
*/
|
500
|
-
util.toArray = function
|
526
|
+
util.toArray = function(object) {
|
501
527
|
var array = [];
|
502
528
|
|
503
529
|
for (var prop in object) {
|
@@ -514,7 +540,7 @@ util.toArray = function toArray(object) {
|
|
514
540
|
* @param {*} value
|
515
541
|
* @return {Boolean} changed
|
516
542
|
*/
|
517
|
-
util.updateProperty = function
|
543
|
+
util.updateProperty = function(object, key, value) {
|
518
544
|
if (object[key] !== value) {
|
519
545
|
object[key] = value;
|
520
546
|
return true;
|
@@ -532,7 +558,7 @@ util.updateProperty = function updateProperty (object, key, value) {
|
|
532
558
|
* @param {function} listener The callback function to be executed
|
533
559
|
* @param {boolean} [useCapture]
|
534
560
|
*/
|
535
|
-
util.addEventListener = function
|
561
|
+
util.addEventListener = function(element, action, listener, useCapture) {
|
536
562
|
if (element.addEventListener) {
|
537
563
|
if (useCapture === undefined)
|
538
564
|
useCapture = false;
|
@@ -554,7 +580,7 @@ util.addEventListener = function addEventListener(element, action, listener, use
|
|
554
580
|
* @param {function} listener The listener function
|
555
581
|
* @param {boolean} [useCapture]
|
556
582
|
*/
|
557
|
-
util.removeEventListener = function
|
583
|
+
util.removeEventListener = function(element, action, listener, useCapture) {
|
558
584
|
if (element.removeEventListener) {
|
559
585
|
// non-IE browsers
|
560
586
|
if (useCapture === undefined)
|
@@ -577,7 +603,7 @@ util.removeEventListener = function removeEventListener(element, action, listene
|
|
577
603
|
* @param {Event} event
|
578
604
|
* @return {Element} target element
|
579
605
|
*/
|
580
|
-
util.getTarget = function
|
606
|
+
util.getTarget = function(event) {
|
581
607
|
// code from http://www.quirksmode.org/js/events_properties.html
|
582
608
|
if (!event) {
|
583
609
|
event = window.event;
|
@@ -605,7 +631,7 @@ util.getTarget = function getTarget(event) {
|
|
605
631
|
* @param {Element} element
|
606
632
|
* @param {Event} event
|
607
633
|
*/
|
608
|
-
util.fakeGesture = function
|
634
|
+
util.fakeGesture = function(element, event) {
|
609
635
|
var eventType = null;
|
610
636
|
|
611
637
|
// for hammer.js 1.0.5
|
@@ -721,7 +747,7 @@ util.option.asElement = function (value, defaultValue) {
|
|
721
747
|
|
722
748
|
|
723
749
|
|
724
|
-
util.GiveDec = function
|
750
|
+
util.GiveDec = function(Hex) {
|
725
751
|
var Value;
|
726
752
|
|
727
753
|
if (Hex == "A")
|
@@ -742,7 +768,7 @@ util.GiveDec = function GiveDec(Hex) {
|
|
742
768
|
return Value;
|
743
769
|
};
|
744
770
|
|
745
|
-
util.GiveHex = function
|
771
|
+
util.GiveHex = function(Dec) {
|
746
772
|
var Value;
|
747
773
|
|
748
774
|
if(Dec == 10)
|
@@ -785,6 +811,10 @@ util.parseColor = function(color) {
|
|
785
811
|
highlight: {
|
786
812
|
background:lighterColorHex,
|
787
813
|
border:darkerColorHex
|
814
|
+
},
|
815
|
+
hover: {
|
816
|
+
background:lighterColorHex,
|
817
|
+
border:darkerColorHex
|
788
818
|
}
|
789
819
|
};
|
790
820
|
}
|
@@ -795,6 +825,10 @@ util.parseColor = function(color) {
|
|
795
825
|
highlight: {
|
796
826
|
background:color,
|
797
827
|
border:color
|
828
|
+
},
|
829
|
+
hover: {
|
830
|
+
background:color,
|
831
|
+
border:color
|
798
832
|
}
|
799
833
|
};
|
800
834
|
}
|
@@ -815,6 +849,18 @@ util.parseColor = function(color) {
|
|
815
849
|
c.highlight.background = color.highlight && color.highlight.background || c.background;
|
816
850
|
c.highlight.border = color.highlight && color.highlight.border || c.border;
|
817
851
|
}
|
852
|
+
|
853
|
+
if (util.isString(color.hover)) {
|
854
|
+
c.hover = {
|
855
|
+
border: color.hover,
|
856
|
+
background: color.hover
|
857
|
+
}
|
858
|
+
}
|
859
|
+
else {
|
860
|
+
c.hover = {};
|
861
|
+
c.hover.background = color.hover && color.hover.background || c.background;
|
862
|
+
c.hover.border = color.hover && color.hover.border || c.border;
|
863
|
+
}
|
818
864
|
}
|
819
865
|
|
820
866
|
return c;
|
@@ -826,7 +872,7 @@ util.parseColor = function(color) {
|
|
826
872
|
* @param {String} hex
|
827
873
|
* @returns {{r: *, g: *, b: *}}
|
828
874
|
*/
|
829
|
-
util.hexToRGB = function
|
875
|
+
util.hexToRGB = function(hex) {
|
830
876
|
hex = hex.replace("#","").toUpperCase();
|
831
877
|
|
832
878
|
var a = util.GiveDec(hex.substring(0, 1));
|
@@ -843,7 +889,7 @@ util.hexToRGB = function hexToRGB(hex) {
|
|
843
889
|
return {r:r,g:g,b:b};
|
844
890
|
};
|
845
891
|
|
846
|
-
util.RGBToHex = function
|
892
|
+
util.RGBToHex = function(red,green,blue) {
|
847
893
|
var a = util.GiveHex(Math.floor(red / 16));
|
848
894
|
var b = util.GiveHex(red % 16);
|
849
895
|
var c = util.GiveHex(Math.floor(green / 16));
|
@@ -865,7 +911,7 @@ util.RGBToHex = function RGBToHex(red,green,blue) {
|
|
865
911
|
* @returns {*}
|
866
912
|
* @constructor
|
867
913
|
*/
|
868
|
-
util.RGBToHSV = function
|
914
|
+
util.RGBToHSV = function(red,green,blue) {
|
869
915
|
red=red/255; green=green/255; blue=blue/255;
|
870
916
|
var minRGB = Math.min(red,Math.min(green,blue));
|
871
917
|
var maxRGB = Math.max(red,Math.max(green,blue));
|
@@ -893,7 +939,7 @@ util.RGBToHSV = function RGBToHSV (red,green,blue) {
|
|
893
939
|
* @returns {{r: number, g: number, b: number}}
|
894
940
|
* @constructor
|
895
941
|
*/
|
896
|
-
util.HSVToRGB = function
|
942
|
+
util.HSVToRGB = function(h, s, v) {
|
897
943
|
var r, g, b;
|
898
944
|
|
899
945
|
var i = Math.floor(h * 6);
|
@@ -914,22 +960,22 @@ util.HSVToRGB = function HSVToRGB(h, s, v) {
|
|
914
960
|
return {r:Math.floor(r * 255), g:Math.floor(g * 255), b:Math.floor(b * 255) };
|
915
961
|
};
|
916
962
|
|
917
|
-
util.HSVToHex = function
|
963
|
+
util.HSVToHex = function(h, s, v) {
|
918
964
|
var rgb = util.HSVToRGB(h, s, v);
|
919
965
|
return util.RGBToHex(rgb.r, rgb.g, rgb.b);
|
920
966
|
};
|
921
967
|
|
922
|
-
util.hexToHSV = function
|
968
|
+
util.hexToHSV = function(hex) {
|
923
969
|
var rgb = util.hexToRGB(hex);
|
924
970
|
return util.RGBToHSV(rgb.r, rgb.g, rgb.b);
|
925
971
|
};
|
926
972
|
|
927
|
-
util.isValidHex = function
|
973
|
+
util.isValidHex = function(hex) {
|
928
974
|
var isOk = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex);
|
929
975
|
return isOk;
|
930
976
|
};
|
931
977
|
|
932
|
-
util.copyObject = function
|
978
|
+
util.copyObject = function(objectFrom, objectTo) {
|
933
979
|
for (var i in objectFrom) {
|
934
980
|
if (objectFrom.hasOwnProperty(i)) {
|
935
981
|
if (typeof objectFrom[i] == "object") {
|