iobroker.ebus 3.2.4 → 3.2.6

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 (47) hide show
  1. package/.eslintrc.json +34 -34
  2. package/.releaseconfig.json +3 -0
  3. package/LICENSE +20 -20
  4. package/README.md +147 -130
  5. package/admin/index_m.html +419 -419
  6. package/admin/style.css +18 -18
  7. package/admin/words.js +27 -27
  8. package/io-package.json +218 -192
  9. package/lib/support_tools.js +370 -370
  10. package/lib/tools.js +99 -99
  11. package/main.js +1232 -1232
  12. package/package.json +13 -11
  13. package/widgets/ebus/lib/js/flot/jquery.canvaswrapper.js +549 -549
  14. package/widgets/ebus/lib/js/flot/jquery.colorhelpers.js +199 -199
  15. package/widgets/ebus/lib/js/flot/jquery.flot.axislabels.js +212 -212
  16. package/widgets/ebus/lib/js/flot/jquery.flot.browser.js +98 -98
  17. package/widgets/ebus/lib/js/flot/jquery.flot.categories.js +202 -202
  18. package/widgets/ebus/lib/js/flot/jquery.flot.composeImages.js +330 -330
  19. package/widgets/ebus/lib/js/flot/jquery.flot.crosshair.js +202 -202
  20. package/widgets/ebus/lib/js/flot/jquery.flot.drawSeries.js +662 -662
  21. package/widgets/ebus/lib/js/flot/jquery.flot.errorbars.js +375 -375
  22. package/widgets/ebus/lib/js/flot/jquery.flot.fillbetween.js +254 -254
  23. package/widgets/ebus/lib/js/flot/jquery.flot.flatdata.js +47 -47
  24. package/widgets/ebus/lib/js/flot/jquery.flot.hover.js +361 -361
  25. package/widgets/ebus/lib/js/flot/jquery.flot.image.js +249 -249
  26. package/widgets/ebus/lib/js/flot/jquery.flot.js +2953 -2953
  27. package/widgets/ebus/lib/js/flot/jquery.flot.legend.js +437 -437
  28. package/widgets/ebus/lib/js/flot/jquery.flot.logaxis.js +298 -298
  29. package/widgets/ebus/lib/js/flot/jquery.flot.navigate.js +834 -834
  30. package/widgets/ebus/lib/js/flot/jquery.flot.pie.js +794 -794
  31. package/widgets/ebus/lib/js/flot/jquery.flot.resize.js +60 -60
  32. package/widgets/ebus/lib/js/flot/jquery.flot.saturated.js +43 -43
  33. package/widgets/ebus/lib/js/flot/jquery.flot.selection.js +527 -527
  34. package/widgets/ebus/lib/js/flot/jquery.flot.stack.js +220 -220
  35. package/widgets/ebus/lib/js/flot/jquery.flot.symbol.js +98 -98
  36. package/widgets/ebus/lib/js/flot/jquery.flot.threshold.js +143 -143
  37. package/widgets/ebus/lib/js/flot/jquery.flot.time.js +586 -586
  38. package/widgets/ebus/lib/js/flot/jquery.flot.touch.js +320 -320
  39. package/widgets/ebus/lib/js/flot/jquery.flot.touchNavigate.js +360 -360
  40. package/widgets/ebus/lib/js/flot/jquery.flot.uiConstants.js +10 -10
  41. package/widgets/ebus/lib/js/flot/jquery.js +9473 -9473
  42. package/widgets/ebus/lib/js/lib/globalize.culture.en-US.js +33 -33
  43. package/widgets/ebus/lib/js/lib/globalize.js +1601 -1601
  44. package/widgets/ebus/lib/js/lib/jquery.event.drag.js +145 -145
  45. package/widgets/ebus/lib/js/lib/jquery.mousewheel.js +86 -86
  46. package/widgets/ebus.html +2395 -2395
  47. package/readme.txt +0 -297
@@ -1,212 +1,212 @@
1
- /*
2
- Axis label plugin for flot
3
-
4
- Derived from:
5
- Axis Labels Plugin for flot.
6
- http://github.com/markrcote/flot-axislabels
7
-
8
- Original code is Copyright (c) 2010 Xuan Luo.
9
- Original code was released under the GPLv3 license by Xuan Luo, September 2010.
10
- Original code was rereleased under the MIT license by Xuan Luo, April 2012.
11
-
12
- Permission is hereby granted, free of charge, to any person obtaining
13
- a copy of this software and associated documentation files (the
14
- "Software"), to deal in the Software without restriction, including
15
- without limitation the rights to use, copy, modify, merge, publish,
16
- distribute, sublicense, and/or sell copies of the Software, and to
17
- permit persons to whom the Software is furnished to do so, subject to
18
- the following conditions:
19
-
20
- The above copyright notice and this permission notice shall be
21
- included in all copies or substantial portions of the Software.
22
-
23
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
- */
31
-
32
- (function($) {
33
- "use strict";
34
-
35
- var options = {
36
- axisLabels: {
37
- show: true
38
- }
39
- };
40
-
41
- function AxisLabel(axisName, position, padding, placeholder, axisLabel, surface) {
42
- this.axisName = axisName;
43
- this.position = position;
44
- this.padding = padding;
45
- this.placeholder = placeholder;
46
- this.axisLabel = axisLabel;
47
- this.surface = surface;
48
- this.width = 0;
49
- this.height = 0;
50
- this.elem = null;
51
- }
52
-
53
- AxisLabel.prototype.calculateSize = function() {
54
- var axisId = this.axisName + 'Label',
55
- layerId = axisId + 'Layer',
56
- className = axisId + ' axisLabels';
57
-
58
- var info = this.surface.getTextInfo(layerId, this.axisLabel, className);
59
- this.labelWidth = info.width;
60
- this.labelHeight = info.height;
61
-
62
- if (this.position === 'left' || this.position === 'right') {
63
- this.width = this.labelHeight + this.padding;
64
- this.height = 0;
65
- } else {
66
- this.width = 0;
67
- this.height = this.labelHeight + this.padding;
68
- }
69
- };
70
-
71
- AxisLabel.prototype.transforms = function(degrees, x, y, svgLayer) {
72
- var transforms = [], translate, rotate;
73
- if (x !== 0 || y !== 0) {
74
- translate = svgLayer.createSVGTransform();
75
- translate.setTranslate(x, y);
76
- transforms.push(translate);
77
- }
78
- if (degrees !== 0) {
79
- rotate = svgLayer.createSVGTransform();
80
- var centerX = Math.round(this.labelWidth / 2),
81
- centerY = 0;
82
- rotate.setRotate(degrees, centerX, centerY);
83
- transforms.push(rotate);
84
- }
85
-
86
- return transforms;
87
- };
88
-
89
- AxisLabel.prototype.calculateOffsets = function(box) {
90
- var offsets = {
91
- x: 0,
92
- y: 0,
93
- degrees: 0
94
- };
95
- if (this.position === 'bottom') {
96
- offsets.x = box.left + box.width / 2 - this.labelWidth / 2;
97
- offsets.y = box.top + box.height - this.labelHeight;
98
- } else if (this.position === 'top') {
99
- offsets.x = box.left + box.width / 2 - this.labelWidth / 2;
100
- offsets.y = box.top;
101
- } else if (this.position === 'left') {
102
- offsets.degrees = -90;
103
- offsets.x = box.left - this.labelWidth / 2;
104
- offsets.y = box.height / 2 + box.top;
105
- } else if (this.position === 'right') {
106
- offsets.degrees = 90;
107
- offsets.x = box.left + box.width - this.labelWidth / 2;
108
- offsets.y = box.height / 2 + box.top;
109
- }
110
- offsets.x = Math.round(offsets.x);
111
- offsets.y = Math.round(offsets.y);
112
-
113
- return offsets;
114
- };
115
-
116
- AxisLabel.prototype.cleanup = function() {
117
- var axisId = this.axisName + 'Label',
118
- layerId = axisId + 'Layer',
119
- className = axisId + ' axisLabels';
120
- this.surface.removeText(layerId, 0, 0, this.axisLabel, className);
121
- };
122
-
123
- AxisLabel.prototype.draw = function(box) {
124
- var axisId = this.axisName + 'Label',
125
- layerId = axisId + 'Layer',
126
- className = axisId + ' axisLabels',
127
- offsets = this.calculateOffsets(box),
128
- style = {
129
- position: 'absolute',
130
- bottom: '',
131
- right: '',
132
- display: 'inline-block',
133
- 'white-space': 'nowrap'
134
- };
135
-
136
- var layer = this.surface.getSVGLayer(layerId);
137
- var transforms = this.transforms(offsets.degrees, offsets.x, offsets.y, layer.parentNode);
138
-
139
- this.surface.addText(layerId, 0, 0, this.axisLabel, className, undefined, undefined, undefined, undefined, transforms);
140
- this.surface.render();
141
- Object.keys(style).forEach(function(key) {
142
- layer.style[key] = style[key];
143
- });
144
- };
145
-
146
- function init(plot) {
147
- plot.hooks.processOptions.push(function(plot, options) {
148
- if (!options.axisLabels.show) {
149
- return;
150
- }
151
-
152
- var axisLabels = {};
153
- var defaultPadding = 2; // padding between axis and tick labels
154
-
155
- plot.hooks.axisReserveSpace.push(function(plot, axis) {
156
- var opts = axis.options;
157
- var axisName = axis.direction + axis.n;
158
-
159
- axis.labelHeight += axis.boxPosition.centerY;
160
- axis.labelWidth += axis.boxPosition.centerX;
161
-
162
- if (!opts || !opts.axisLabel || !axis.show) {
163
- return;
164
- }
165
-
166
- var padding = opts.axisLabelPadding === undefined
167
- ? defaultPadding
168
- : opts.axisLabelPadding;
169
-
170
- var axisLabel = axisLabels[axisName];
171
- if (!axisLabel) {
172
- axisLabel = new AxisLabel(axisName,
173
- opts.position, padding,
174
- plot.getPlaceholder()[0], opts.axisLabel, plot.getSurface());
175
- axisLabels[axisName] = axisLabel;
176
- }
177
-
178
- axisLabel.calculateSize();
179
-
180
- // Incrementing the sizes of the tick labels.
181
- axis.labelHeight += axisLabel.height;
182
- axis.labelWidth += axisLabel.width;
183
- });
184
-
185
- // TODO - use the drawAxis hook
186
- plot.hooks.draw.push(function(plot, ctx) {
187
- $.each(plot.getAxes(), function(flotAxisName, axis) {
188
- var opts = axis.options;
189
- if (!opts || !opts.axisLabel || !axis.show) {
190
- return;
191
- }
192
-
193
- var axisName = axis.direction + axis.n;
194
- axisLabels[axisName].draw(axis.box);
195
- });
196
- });
197
-
198
- plot.hooks.shutdown.push(function(plot, eventHolder) {
199
- for (var axisName in axisLabels) {
200
- axisLabels[axisName].cleanup();
201
- }
202
- });
203
- });
204
- };
205
-
206
- $.plot.plugins.push({
207
- init: init,
208
- options: options,
209
- name: 'axisLabels',
210
- version: '3.0'
211
- });
212
- })(jQuery);
1
+ /*
2
+ Axis label plugin for flot
3
+
4
+ Derived from:
5
+ Axis Labels Plugin for flot.
6
+ http://github.com/markrcote/flot-axislabels
7
+
8
+ Original code is Copyright (c) 2010 Xuan Luo.
9
+ Original code was released under the GPLv3 license by Xuan Luo, September 2010.
10
+ Original code was rereleased under the MIT license by Xuan Luo, April 2012.
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining
13
+ a copy of this software and associated documentation files (the
14
+ "Software"), to deal in the Software without restriction, including
15
+ without limitation the rights to use, copy, modify, merge, publish,
16
+ distribute, sublicense, and/or sell copies of the Software, and to
17
+ permit persons to whom the Software is furnished to do so, subject to
18
+ the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be
21
+ included in all copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
+ */
31
+
32
+ (function($) {
33
+ "use strict";
34
+
35
+ var options = {
36
+ axisLabels: {
37
+ show: true
38
+ }
39
+ };
40
+
41
+ function AxisLabel(axisName, position, padding, placeholder, axisLabel, surface) {
42
+ this.axisName = axisName;
43
+ this.position = position;
44
+ this.padding = padding;
45
+ this.placeholder = placeholder;
46
+ this.axisLabel = axisLabel;
47
+ this.surface = surface;
48
+ this.width = 0;
49
+ this.height = 0;
50
+ this.elem = null;
51
+ }
52
+
53
+ AxisLabel.prototype.calculateSize = function() {
54
+ var axisId = this.axisName + 'Label',
55
+ layerId = axisId + 'Layer',
56
+ className = axisId + ' axisLabels';
57
+
58
+ var info = this.surface.getTextInfo(layerId, this.axisLabel, className);
59
+ this.labelWidth = info.width;
60
+ this.labelHeight = info.height;
61
+
62
+ if (this.position === 'left' || this.position === 'right') {
63
+ this.width = this.labelHeight + this.padding;
64
+ this.height = 0;
65
+ } else {
66
+ this.width = 0;
67
+ this.height = this.labelHeight + this.padding;
68
+ }
69
+ };
70
+
71
+ AxisLabel.prototype.transforms = function(degrees, x, y, svgLayer) {
72
+ var transforms = [], translate, rotate;
73
+ if (x !== 0 || y !== 0) {
74
+ translate = svgLayer.createSVGTransform();
75
+ translate.setTranslate(x, y);
76
+ transforms.push(translate);
77
+ }
78
+ if (degrees !== 0) {
79
+ rotate = svgLayer.createSVGTransform();
80
+ var centerX = Math.round(this.labelWidth / 2),
81
+ centerY = 0;
82
+ rotate.setRotate(degrees, centerX, centerY);
83
+ transforms.push(rotate);
84
+ }
85
+
86
+ return transforms;
87
+ };
88
+
89
+ AxisLabel.prototype.calculateOffsets = function(box) {
90
+ var offsets = {
91
+ x: 0,
92
+ y: 0,
93
+ degrees: 0
94
+ };
95
+ if (this.position === 'bottom') {
96
+ offsets.x = box.left + box.width / 2 - this.labelWidth / 2;
97
+ offsets.y = box.top + box.height - this.labelHeight;
98
+ } else if (this.position === 'top') {
99
+ offsets.x = box.left + box.width / 2 - this.labelWidth / 2;
100
+ offsets.y = box.top;
101
+ } else if (this.position === 'left') {
102
+ offsets.degrees = -90;
103
+ offsets.x = box.left - this.labelWidth / 2;
104
+ offsets.y = box.height / 2 + box.top;
105
+ } else if (this.position === 'right') {
106
+ offsets.degrees = 90;
107
+ offsets.x = box.left + box.width - this.labelWidth / 2;
108
+ offsets.y = box.height / 2 + box.top;
109
+ }
110
+ offsets.x = Math.round(offsets.x);
111
+ offsets.y = Math.round(offsets.y);
112
+
113
+ return offsets;
114
+ };
115
+
116
+ AxisLabel.prototype.cleanup = function() {
117
+ var axisId = this.axisName + 'Label',
118
+ layerId = axisId + 'Layer',
119
+ className = axisId + ' axisLabels';
120
+ this.surface.removeText(layerId, 0, 0, this.axisLabel, className);
121
+ };
122
+
123
+ AxisLabel.prototype.draw = function(box) {
124
+ var axisId = this.axisName + 'Label',
125
+ layerId = axisId + 'Layer',
126
+ className = axisId + ' axisLabels',
127
+ offsets = this.calculateOffsets(box),
128
+ style = {
129
+ position: 'absolute',
130
+ bottom: '',
131
+ right: '',
132
+ display: 'inline-block',
133
+ 'white-space': 'nowrap'
134
+ };
135
+
136
+ var layer = this.surface.getSVGLayer(layerId);
137
+ var transforms = this.transforms(offsets.degrees, offsets.x, offsets.y, layer.parentNode);
138
+
139
+ this.surface.addText(layerId, 0, 0, this.axisLabel, className, undefined, undefined, undefined, undefined, transforms);
140
+ this.surface.render();
141
+ Object.keys(style).forEach(function(key) {
142
+ layer.style[key] = style[key];
143
+ });
144
+ };
145
+
146
+ function init(plot) {
147
+ plot.hooks.processOptions.push(function(plot, options) {
148
+ if (!options.axisLabels.show) {
149
+ return;
150
+ }
151
+
152
+ var axisLabels = {};
153
+ var defaultPadding = 2; // padding between axis and tick labels
154
+
155
+ plot.hooks.axisReserveSpace.push(function(plot, axis) {
156
+ var opts = axis.options;
157
+ var axisName = axis.direction + axis.n;
158
+
159
+ axis.labelHeight += axis.boxPosition.centerY;
160
+ axis.labelWidth += axis.boxPosition.centerX;
161
+
162
+ if (!opts || !opts.axisLabel || !axis.show) {
163
+ return;
164
+ }
165
+
166
+ var padding = opts.axisLabelPadding === undefined
167
+ ? defaultPadding
168
+ : opts.axisLabelPadding;
169
+
170
+ var axisLabel = axisLabels[axisName];
171
+ if (!axisLabel) {
172
+ axisLabel = new AxisLabel(axisName,
173
+ opts.position, padding,
174
+ plot.getPlaceholder()[0], opts.axisLabel, plot.getSurface());
175
+ axisLabels[axisName] = axisLabel;
176
+ }
177
+
178
+ axisLabel.calculateSize();
179
+
180
+ // Incrementing the sizes of the tick labels.
181
+ axis.labelHeight += axisLabel.height;
182
+ axis.labelWidth += axisLabel.width;
183
+ });
184
+
185
+ // TODO - use the drawAxis hook
186
+ plot.hooks.draw.push(function(plot, ctx) {
187
+ $.each(plot.getAxes(), function(flotAxisName, axis) {
188
+ var opts = axis.options;
189
+ if (!opts || !opts.axisLabel || !axis.show) {
190
+ return;
191
+ }
192
+
193
+ var axisName = axis.direction + axis.n;
194
+ axisLabels[axisName].draw(axis.box);
195
+ });
196
+ });
197
+
198
+ plot.hooks.shutdown.push(function(plot, eventHolder) {
199
+ for (var axisName in axisLabels) {
200
+ axisLabels[axisName].cleanup();
201
+ }
202
+ });
203
+ });
204
+ };
205
+
206
+ $.plot.plugins.push({
207
+ init: init,
208
+ options: options,
209
+ name: 'axisLabels',
210
+ version: '3.0'
211
+ });
212
+ })(jQuery);
@@ -1,98 +1,98 @@
1
- /** ## jquery.flot.browser.js
2
-
3
- This plugin is used to make available some browser-related utility functions.
4
-
5
- ### Methods
6
- */
7
-
8
- (function ($) {
9
- 'use strict';
10
-
11
- var browser = {
12
- /**
13
- - getPageXY(e)
14
-
15
- Calculates the pageX and pageY using the screenX, screenY properties of the event
16
- and the scrolling of the page. This is needed because the pageX and pageY
17
- properties of the event are not correct while running tests in Edge. */
18
- getPageXY: function (e) {
19
- // This code is inspired from https://stackoverflow.com/a/3464890
20
- var doc = document.documentElement,
21
- pageX = e.clientX + (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0),
22
- pageY = e.clientY + (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
23
- return { X: pageX, Y: pageY };
24
- },
25
-
26
- /**
27
- - getPixelRatio(context)
28
-
29
- This function returns the current pixel ratio defined by the product of desktop
30
- zoom and page zoom.
31
- Additional info: https://www.html5rocks.com/en/tutorials/canvas/hidpi/
32
- */
33
- getPixelRatio: function(context) {
34
- var devicePixelRatio = window.devicePixelRatio || 1,
35
- backingStoreRatio =
36
- context.webkitBackingStorePixelRatio ||
37
- context.mozBackingStorePixelRatio ||
38
- context.msBackingStorePixelRatio ||
39
- context.oBackingStorePixelRatio ||
40
- context.backingStorePixelRatio || 1;
41
- return devicePixelRatio / backingStoreRatio;
42
- },
43
-
44
- /**
45
- - isSafari, isMobileSafari, isOpera, isFirefox, isIE, isEdge, isChrome, isBlink
46
-
47
- This is a collection of functions, used to check if the code is running in a
48
- particular browser or Javascript engine.
49
- */
50
- isSafari: function() {
51
- // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
52
- // Safari 3.0+ "[object HTMLElementConstructor]"
53
- return /constructor/i.test(window.top.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window.top['safari'] || (typeof window.top.safari !== 'undefined' && window.top.safari.pushNotification));
54
- },
55
-
56
- isMobileSafari: function() {
57
- //isMobileSafari adapted from https://stackoverflow.com/questions/3007480/determine-if-user-navigated-from-mobile-safari
58
- return navigator.userAgent.match(/(iPod|iPhone|iPad)/) && navigator.userAgent.match(/AppleWebKit/);
59
- },
60
-
61
- isOpera: function() {
62
- // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
63
- //Opera 8.0+
64
- return (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
65
- },
66
-
67
- isFirefox: function() {
68
- // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
69
- // Firefox 1.0+
70
- return typeof InstallTrigger !== 'undefined';
71
- },
72
-
73
- isIE: function() {
74
- // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
75
- // Internet Explorer 6-11
76
- return /*@cc_on!@*/false || !!document.documentMode;
77
- },
78
-
79
- isEdge: function() {
80
- // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
81
- // Edge 20+
82
- return !browser.isIE() && !!window.StyleMedia;
83
- },
84
-
85
- isChrome: function() {
86
- // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
87
- // Chrome 1+
88
- return !!window.chrome && !!window.chrome.webstore;
89
- },
90
-
91
- isBlink: function() {
92
- // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
93
- return (browser.isChrome() || browser.isOpera()) && !!window.CSS;
94
- }
95
- };
96
-
97
- $.plot.browser = browser;
98
- })(jQuery);
1
+ /** ## jquery.flot.browser.js
2
+
3
+ This plugin is used to make available some browser-related utility functions.
4
+
5
+ ### Methods
6
+ */
7
+
8
+ (function ($) {
9
+ 'use strict';
10
+
11
+ var browser = {
12
+ /**
13
+ - getPageXY(e)
14
+
15
+ Calculates the pageX and pageY using the screenX, screenY properties of the event
16
+ and the scrolling of the page. This is needed because the pageX and pageY
17
+ properties of the event are not correct while running tests in Edge. */
18
+ getPageXY: function (e) {
19
+ // This code is inspired from https://stackoverflow.com/a/3464890
20
+ var doc = document.documentElement,
21
+ pageX = e.clientX + (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0),
22
+ pageY = e.clientY + (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
23
+ return { X: pageX, Y: pageY };
24
+ },
25
+
26
+ /**
27
+ - getPixelRatio(context)
28
+
29
+ This function returns the current pixel ratio defined by the product of desktop
30
+ zoom and page zoom.
31
+ Additional info: https://www.html5rocks.com/en/tutorials/canvas/hidpi/
32
+ */
33
+ getPixelRatio: function(context) {
34
+ var devicePixelRatio = window.devicePixelRatio || 1,
35
+ backingStoreRatio =
36
+ context.webkitBackingStorePixelRatio ||
37
+ context.mozBackingStorePixelRatio ||
38
+ context.msBackingStorePixelRatio ||
39
+ context.oBackingStorePixelRatio ||
40
+ context.backingStorePixelRatio || 1;
41
+ return devicePixelRatio / backingStoreRatio;
42
+ },
43
+
44
+ /**
45
+ - isSafari, isMobileSafari, isOpera, isFirefox, isIE, isEdge, isChrome, isBlink
46
+
47
+ This is a collection of functions, used to check if the code is running in a
48
+ particular browser or Javascript engine.
49
+ */
50
+ isSafari: function() {
51
+ // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
52
+ // Safari 3.0+ "[object HTMLElementConstructor]"
53
+ return /constructor/i.test(window.top.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window.top['safari'] || (typeof window.top.safari !== 'undefined' && window.top.safari.pushNotification));
54
+ },
55
+
56
+ isMobileSafari: function() {
57
+ //isMobileSafari adapted from https://stackoverflow.com/questions/3007480/determine-if-user-navigated-from-mobile-safari
58
+ return navigator.userAgent.match(/(iPod|iPhone|iPad)/) && navigator.userAgent.match(/AppleWebKit/);
59
+ },
60
+
61
+ isOpera: function() {
62
+ // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
63
+ //Opera 8.0+
64
+ return (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
65
+ },
66
+
67
+ isFirefox: function() {
68
+ // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
69
+ // Firefox 1.0+
70
+ return typeof InstallTrigger !== 'undefined';
71
+ },
72
+
73
+ isIE: function() {
74
+ // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
75
+ // Internet Explorer 6-11
76
+ return /*@cc_on!@*/false || !!document.documentMode;
77
+ },
78
+
79
+ isEdge: function() {
80
+ // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
81
+ // Edge 20+
82
+ return !browser.isIE() && !!window.StyleMedia;
83
+ },
84
+
85
+ isChrome: function() {
86
+ // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
87
+ // Chrome 1+
88
+ return !!window.chrome && !!window.chrome.webstore;
89
+ },
90
+
91
+ isBlink: function() {
92
+ // *** https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
93
+ return (browser.isChrome() || browser.isOpera()) && !!window.CSS;
94
+ }
95
+ };
96
+
97
+ $.plot.browser = browser;
98
+ })(jQuery);