iobroker.ebus 3.3.7 → 3.4.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 (52) hide show
  1. package/README.md +8 -0
  2. package/admin/i18n/de/translations.json +29 -9
  3. package/admin/i18n/en/translations.json +25 -5
  4. package/admin/i18n/es/translations.json +20 -0
  5. package/admin/i18n/fr/translations.json +20 -0
  6. package/admin/i18n/it/translations.json +20 -0
  7. package/admin/i18n/nl/translations.json +20 -0
  8. package/admin/i18n/pl/translations.json +20 -0
  9. package/admin/i18n/pt/translations.json +20 -0
  10. package/admin/i18n/ru/translations.json +20 -0
  11. package/admin/i18n/uk/translations.json +20 -0
  12. package/admin/i18n/zh-cn/translations.json +20 -0
  13. package/admin/jsonConfig.json +393 -0
  14. package/admin/words.js +29 -9
  15. package/io-package.json +192 -31
  16. package/main.js +108 -44
  17. package/package.json +4 -3
  18. package/widgets/ebus/img/Prev_tplebus.png +0 -0
  19. package/widgets/ebus/lib/js/flot/jquery.canvaswrapper.js +549 -0
  20. package/widgets/ebus/lib/js/flot/jquery.colorhelpers.js +199 -0
  21. package/widgets/ebus/lib/js/flot/jquery.flot.axislabels.js +212 -0
  22. package/widgets/ebus/lib/js/flot/jquery.flot.browser.js +98 -0
  23. package/widgets/ebus/lib/js/flot/jquery.flot.categories.js +202 -0
  24. package/widgets/ebus/lib/js/flot/jquery.flot.composeImages.js +330 -0
  25. package/widgets/ebus/lib/js/flot/jquery.flot.crosshair.js +202 -0
  26. package/widgets/ebus/lib/js/flot/jquery.flot.drawSeries.js +662 -0
  27. package/widgets/ebus/lib/js/flot/jquery.flot.errorbars.js +375 -0
  28. package/widgets/ebus/lib/js/flot/jquery.flot.fillbetween.js +254 -0
  29. package/widgets/ebus/lib/js/flot/jquery.flot.flatdata.js +47 -0
  30. package/widgets/ebus/lib/js/flot/jquery.flot.hover.js +361 -0
  31. package/widgets/ebus/lib/js/flot/jquery.flot.image.js +249 -0
  32. package/widgets/ebus/lib/js/flot/jquery.flot.js +2953 -0
  33. package/widgets/ebus/lib/js/flot/jquery.flot.legend.js +437 -0
  34. package/widgets/ebus/lib/js/flot/jquery.flot.logaxis.js +298 -0
  35. package/widgets/ebus/lib/js/flot/jquery.flot.navigate.js +834 -0
  36. package/widgets/ebus/lib/js/flot/jquery.flot.pie.js +794 -0
  37. package/widgets/ebus/lib/js/flot/jquery.flot.resize.js +60 -0
  38. package/widgets/ebus/lib/js/flot/jquery.flot.saturated.js +43 -0
  39. package/widgets/ebus/lib/js/flot/jquery.flot.selection.js +527 -0
  40. package/widgets/ebus/lib/js/flot/jquery.flot.stack.js +220 -0
  41. package/widgets/ebus/lib/js/flot/jquery.flot.symbol.js +98 -0
  42. package/widgets/ebus/lib/js/flot/jquery.flot.threshold.js +143 -0
  43. package/widgets/ebus/lib/js/flot/jquery.flot.time.js +586 -0
  44. package/widgets/ebus/lib/js/flot/jquery.flot.touch.js +320 -0
  45. package/widgets/ebus/lib/js/flot/jquery.flot.touchNavigate.js +360 -0
  46. package/widgets/ebus/lib/js/flot/jquery.flot.uiConstants.js +10 -0
  47. package/widgets/ebus/lib/js/flot/jquery.js +9473 -0
  48. package/widgets/ebus/lib/js/lib/globalize.culture.en-US.js +33 -0
  49. package/widgets/ebus/lib/js/lib/globalize.js +1601 -0
  50. package/widgets/ebus/lib/js/lib/jquery.event.drag.js +145 -0
  51. package/widgets/ebus/lib/js/lib/jquery.mousewheel.js +86 -0
  52. package/widgets/ebus.html +2395 -0
@@ -0,0 +1,320 @@
1
+
2
+ /* global jQuery */
3
+
4
+ (function($) {
5
+ 'use strict';
6
+
7
+ var options = {
8
+ propagateSupportedGesture: false
9
+ };
10
+
11
+ function init(plot) {
12
+ plot.hooks.processOptions.push(initTouchNavigation);
13
+ }
14
+
15
+ function initTouchNavigation(plot, options) {
16
+ var gestureState = {
17
+ twoTouches: false,
18
+ currentTapStart: { x: 0, y: 0 },
19
+ currentTapEnd: { x: 0, y: 0 },
20
+ prevTap: { x: 0, y: 0 },
21
+ currentTap: { x: 0, y: 0 },
22
+ interceptedLongTap: false,
23
+ isUnsupportedGesture: false,
24
+ prevTapTime: null,
25
+ tapStartTime: null,
26
+ longTapTriggerId: null
27
+ },
28
+ maxDistanceBetweenTaps = 20,
29
+ maxIntervalBetweenTaps = 500,
30
+ maxLongTapDistance = 20,
31
+ minLongTapDuration = 1500,
32
+ pressedTapDuration = 125,
33
+ mainEventHolder;
34
+
35
+ function interpretGestures(e) {
36
+ var o = plot.getOptions();
37
+
38
+ if (!o.pan.active && !o.zoom.active) {
39
+ return;
40
+ }
41
+
42
+ updateOnMultipleTouches(e);
43
+ mainEventHolder.dispatchEvent(new CustomEvent('touchevent', { detail: e }));
44
+
45
+ if (isPinchEvent(e)) {
46
+ executeAction(e, 'pinch');
47
+ } else {
48
+ executeAction(e, 'pan');
49
+ if (!wasPinchEvent(e)) {
50
+ if (isDoubleTap(e)) {
51
+ executeAction(e, 'doubleTap');
52
+ }
53
+ executeAction(e, 'tap');
54
+ executeAction(e, 'longTap');
55
+ }
56
+ }
57
+ }
58
+
59
+ function executeAction(e, gesture) {
60
+ switch (gesture) {
61
+ case 'pan':
62
+ pan[e.type](e);
63
+ break;
64
+ case 'pinch':
65
+ pinch[e.type](e);
66
+ break;
67
+ case 'doubleTap':
68
+ doubleTap.onDoubleTap(e);
69
+ break;
70
+ case 'longTap':
71
+ longTap[e.type](e);
72
+ break;
73
+ case 'tap':
74
+ tap[e.type](e);
75
+ break;
76
+ }
77
+ }
78
+
79
+ function bindEvents(plot, eventHolder) {
80
+ mainEventHolder = eventHolder[0];
81
+ eventHolder[0].addEventListener('touchstart', interpretGestures, false);
82
+ eventHolder[0].addEventListener('touchmove', interpretGestures, false);
83
+ eventHolder[0].addEventListener('touchend', interpretGestures, false);
84
+ }
85
+
86
+ function shutdown(plot, eventHolder) {
87
+ eventHolder[0].removeEventListener('touchstart', interpretGestures);
88
+ eventHolder[0].removeEventListener('touchmove', interpretGestures);
89
+ eventHolder[0].removeEventListener('touchend', interpretGestures);
90
+ if (gestureState.longTapTriggerId) {
91
+ clearTimeout(gestureState.longTapTriggerId);
92
+ gestureState.longTapTriggerId = null;
93
+ }
94
+ }
95
+
96
+ var pan = {
97
+ touchstart: function(e) {
98
+ updatePrevForDoubleTap();
99
+ updateCurrentForDoubleTap(e);
100
+ updateStateForLongTapStart(e);
101
+
102
+ mainEventHolder.dispatchEvent(new CustomEvent('panstart', { detail: e }));
103
+ },
104
+
105
+ touchmove: function(e) {
106
+ preventEventBehaviors(e);
107
+
108
+ updateCurrentForDoubleTap(e);
109
+ updateStateForLongTapEnd(e);
110
+
111
+ if (!gestureState.isUnsupportedGesture) {
112
+ mainEventHolder.dispatchEvent(new CustomEvent('pandrag', { detail: e }));
113
+ }
114
+ },
115
+
116
+ touchend: function(e) {
117
+ preventEventBehaviors(e);
118
+
119
+ if (wasPinchEvent(e)) {
120
+ mainEventHolder.dispatchEvent(new CustomEvent('pinchend', { detail: e }));
121
+ mainEventHolder.dispatchEvent(new CustomEvent('panstart', { detail: e }));
122
+ } else if (noTouchActive(e)) {
123
+ mainEventHolder.dispatchEvent(new CustomEvent('panend', { detail: e }));
124
+ }
125
+ }
126
+ };
127
+
128
+ var pinch = {
129
+ touchstart: function(e) {
130
+ mainEventHolder.dispatchEvent(new CustomEvent('pinchstart', { detail: e }));
131
+ },
132
+
133
+ touchmove: function(e) {
134
+ preventEventBehaviors(e);
135
+ gestureState.twoTouches = isPinchEvent(e);
136
+ if (!gestureState.isUnsupportedGesture) {
137
+ mainEventHolder.dispatchEvent(new CustomEvent('pinchdrag', { detail: e }));
138
+ }
139
+ },
140
+
141
+ touchend: function(e) {
142
+ preventEventBehaviors(e);
143
+ }
144
+ };
145
+
146
+ var doubleTap = {
147
+ onDoubleTap: function(e) {
148
+ preventEventBehaviors(e);
149
+ mainEventHolder.dispatchEvent(new CustomEvent('doubletap', { detail: e }));
150
+ }
151
+ };
152
+
153
+ var longTap = {
154
+ touchstart: function(e) {
155
+ longTap.waitForLongTap(e);
156
+ },
157
+
158
+ touchmove: function(e) {
159
+ },
160
+
161
+ touchend: function(e) {
162
+ if (gestureState.longTapTriggerId) {
163
+ clearTimeout(gestureState.longTapTriggerId);
164
+ gestureState.longTapTriggerId = null;
165
+ }
166
+ },
167
+
168
+ isLongTap: function(e) {
169
+ var currentTime = new Date().getTime(),
170
+ tapDuration = currentTime - gestureState.tapStartTime;
171
+ if (tapDuration >= minLongTapDuration && !gestureState.interceptedLongTap) {
172
+ if (distance(gestureState.currentTapStart.x, gestureState.currentTapStart.y, gestureState.currentTapEnd.x, gestureState.currentTapEnd.y) < maxLongTapDistance) {
173
+ gestureState.interceptedLongTap = true;
174
+ return true;
175
+ }
176
+ }
177
+ return false;
178
+ },
179
+
180
+ waitForLongTap: function(e) {
181
+ var longTapTrigger = function() {
182
+ if (longTap.isLongTap(e)) {
183
+ mainEventHolder.dispatchEvent(new CustomEvent('longtap', { detail: e }));
184
+ }
185
+ gestureState.longTapTriggerId = null;
186
+ };
187
+ if (!gestureState.longTapTriggerId) {
188
+ gestureState.longTapTriggerId = setTimeout(longTapTrigger, minLongTapDuration);
189
+ }
190
+ }
191
+ };
192
+
193
+ var tap = {
194
+ touchstart: function(e) {
195
+ gestureState.tapStartTime = new Date().getTime();
196
+ },
197
+
198
+ touchmove: function(e) {
199
+ },
200
+
201
+ touchend: function(e) {
202
+ if (tap.isTap(e)) {
203
+ mainEventHolder.dispatchEvent(new CustomEvent('tap', { detail: e }));
204
+ preventEventBehaviors(e);
205
+ }
206
+ },
207
+
208
+ isTap: function(e) {
209
+ var currentTime = new Date().getTime(),
210
+ tapDuration = currentTime - gestureState.tapStartTime;
211
+ if (tapDuration <= pressedTapDuration) {
212
+ if (distance(gestureState.currentTapStart.x, gestureState.currentTapStart.y, gestureState.currentTapEnd.x, gestureState.currentTapEnd.y) < maxLongTapDistance) {
213
+ return true;
214
+ }
215
+ }
216
+ return false;
217
+ }
218
+ };
219
+
220
+ if (options.pan.enableTouch === true || options.zoom.enableTouch) {
221
+ plot.hooks.bindEvents.push(bindEvents);
222
+ plot.hooks.shutdown.push(shutdown);
223
+ };
224
+
225
+ function updatePrevForDoubleTap() {
226
+ gestureState.prevTap = {
227
+ x: gestureState.currentTap.x,
228
+ y: gestureState.currentTap.y
229
+ };
230
+ };
231
+
232
+ function updateCurrentForDoubleTap(e) {
233
+ gestureState.currentTap = {
234
+ x: e.touches[0].pageX,
235
+ y: e.touches[0].pageY
236
+ };
237
+ }
238
+
239
+ function updateStateForLongTapStart(e) {
240
+ gestureState.tapStartTime = new Date().getTime();
241
+ gestureState.interceptedLongTap = false;
242
+ gestureState.currentTapStart = {
243
+ x: e.touches[0].pageX,
244
+ y: e.touches[0].pageY
245
+ };
246
+ gestureState.currentTapEnd = {
247
+ x: e.touches[0].pageX,
248
+ y: e.touches[0].pageY
249
+ };
250
+ };
251
+
252
+ function updateStateForLongTapEnd(e) {
253
+ gestureState.currentTapEnd = {
254
+ x: e.touches[0].pageX,
255
+ y: e.touches[0].pageY
256
+ };
257
+ };
258
+
259
+ function isDoubleTap(e) {
260
+ var currentTime = new Date().getTime(),
261
+ intervalBetweenTaps = currentTime - gestureState.prevTapTime;
262
+
263
+ if (intervalBetweenTaps >= 0 && intervalBetweenTaps < maxIntervalBetweenTaps) {
264
+ if (distance(gestureState.prevTap.x, gestureState.prevTap.y, gestureState.currentTap.x, gestureState.currentTap.y) < maxDistanceBetweenTaps) {
265
+ e.firstTouch = gestureState.prevTap;
266
+ e.secondTouch = gestureState.currentTap;
267
+ return true;
268
+ }
269
+ }
270
+ gestureState.prevTapTime = currentTime;
271
+ return false;
272
+ }
273
+
274
+ function preventEventBehaviors(e) {
275
+ if (!gestureState.isUnsupportedGesture) {
276
+ e.preventDefault();
277
+ if (!plot.getOptions().propagateSupportedGesture) {
278
+ e.stopPropagation();
279
+ }
280
+ }
281
+ }
282
+
283
+ function distance(x1, y1, x2, y2) {
284
+ return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
285
+ }
286
+
287
+ function noTouchActive(e) {
288
+ return (e.touches && e.touches.length === 0);
289
+ }
290
+
291
+ function wasPinchEvent(e) {
292
+ return (gestureState.twoTouches && e.touches.length === 1);
293
+ }
294
+
295
+ function updateOnMultipleTouches(e) {
296
+ if (e.touches.length >= 3) {
297
+ gestureState.isUnsupportedGesture = true;
298
+ } else {
299
+ gestureState.isUnsupportedGesture = false;
300
+ }
301
+ }
302
+
303
+ function isPinchEvent(e) {
304
+ if (e.touches && e.touches.length >= 2) {
305
+ if (e.touches[0].target === plot.getEventHolder() &&
306
+ e.touches[1].target === plot.getEventHolder()) {
307
+ return true;
308
+ }
309
+ }
310
+ return false;
311
+ }
312
+ }
313
+
314
+ $.plot.plugins.push({
315
+ init: init,
316
+ options: options,
317
+ name: 'navigateTouch',
318
+ version: '0.3'
319
+ });
320
+ })(jQuery);
@@ -0,0 +1,360 @@
1
+ /* global jQuery */
2
+
3
+ (function($) {
4
+ 'use strict';
5
+
6
+ var options = {
7
+ zoom: {
8
+ enableTouch: false
9
+ },
10
+ pan: {
11
+ enableTouch: false,
12
+ touchMode: 'manual'
13
+ },
14
+ recenter: {
15
+ enableTouch: true
16
+ }
17
+ };
18
+
19
+ var ZOOM_DISTANCE_MARGIN = $.plot.uiConstants.ZOOM_DISTANCE_MARGIN;
20
+
21
+ function init(plot) {
22
+ plot.hooks.processOptions.push(initTouchNavigation);
23
+ }
24
+
25
+ function initTouchNavigation(plot, options) {
26
+ var gestureState = {
27
+ zoomEnable: false,
28
+ prevDistance: null,
29
+ prevTapTime: 0,
30
+ prevPanPosition: { x: 0, y: 0 },
31
+ prevTapPosition: { x: 0, y: 0 }
32
+ },
33
+ navigationState = {
34
+ prevTouchedAxis: 'none',
35
+ currentTouchedAxis: 'none',
36
+ touchedAxis: null,
37
+ navigationConstraint: 'unconstrained',
38
+ initialState: null
39
+ },
40
+ useManualPan = options.pan.interactive && options.pan.touchMode === 'manual',
41
+ smartPanLock = options.pan.touchMode === 'smartLock',
42
+ useSmartPan = options.pan.interactive && (smartPanLock || options.pan.touchMode === 'smart'),
43
+ pan, pinch, doubleTap;
44
+
45
+ function bindEvents(plot, eventHolder) {
46
+ var o = plot.getOptions();
47
+
48
+ if (o.zoom.interactive && o.zoom.enableTouch) {
49
+ eventHolder[0].addEventListener('pinchstart', pinch.start, false);
50
+ eventHolder[0].addEventListener('pinchdrag', pinch.drag, false);
51
+ eventHolder[0].addEventListener('pinchend', pinch.end, false);
52
+ }
53
+
54
+ if (o.pan.interactive && o.pan.enableTouch) {
55
+ eventHolder[0].addEventListener('panstart', pan.start, false);
56
+ eventHolder[0].addEventListener('pandrag', pan.drag, false);
57
+ eventHolder[0].addEventListener('panend', pan.end, false);
58
+ }
59
+
60
+ if ((o.recenter.interactive && o.recenter.enableTouch)) {
61
+ eventHolder[0].addEventListener('doubletap', doubleTap.recenterPlot, false);
62
+ }
63
+ }
64
+
65
+ function shutdown(plot, eventHolder) {
66
+ eventHolder[0].removeEventListener('panstart', pan.start);
67
+ eventHolder[0].removeEventListener('pandrag', pan.drag);
68
+ eventHolder[0].removeEventListener('panend', pan.end);
69
+ eventHolder[0].removeEventListener('pinchstart', pinch.start);
70
+ eventHolder[0].removeEventListener('pinchdrag', pinch.drag);
71
+ eventHolder[0].removeEventListener('pinchend', pinch.end);
72
+ eventHolder[0].removeEventListener('doubletap', doubleTap.recenterPlot);
73
+ }
74
+
75
+ pan = {
76
+ start: function(e) {
77
+ presetNavigationState(e, 'pan', gestureState);
78
+ updateData(e, 'pan', gestureState, navigationState);
79
+
80
+ if (useSmartPan) {
81
+ var point = getPoint(e, 'pan');
82
+ navigationState.initialState = plot.navigationState(point.x, point.y);
83
+ }
84
+ },
85
+
86
+ drag: function(e) {
87
+ presetNavigationState(e, 'pan', gestureState);
88
+
89
+ if (useSmartPan) {
90
+ var point = getPoint(e, 'pan');
91
+ plot.smartPan({
92
+ x: navigationState.initialState.startPageX - point.x,
93
+ y: navigationState.initialState.startPageY - point.y
94
+ }, navigationState.initialState, navigationState.touchedAxis, false, smartPanLock);
95
+ } else if (useManualPan) {
96
+ plot.pan({
97
+ left: -delta(e, 'pan', gestureState).x,
98
+ top: -delta(e, 'pan', gestureState).y,
99
+ axes: navigationState.touchedAxis
100
+ });
101
+ updatePrevPanPosition(e, 'pan', gestureState, navigationState);
102
+ }
103
+ },
104
+
105
+ end: function(e) {
106
+ presetNavigationState(e, 'pan', gestureState);
107
+
108
+ if (useSmartPan) {
109
+ plot.smartPan.end();
110
+ }
111
+
112
+ if (wasPinchEvent(e, gestureState)) {
113
+ updateprevPanPosition(e, 'pan', gestureState, navigationState);
114
+ }
115
+ }
116
+ };
117
+
118
+ var pinchDragTimeout;
119
+ pinch = {
120
+ start: function(e) {
121
+ if (pinchDragTimeout) {
122
+ clearTimeout(pinchDragTimeout);
123
+ pinchDragTimeout = null;
124
+ }
125
+ presetNavigationState(e, 'pinch', gestureState);
126
+ setPrevDistance(e, gestureState);
127
+ updateData(e, 'pinch', gestureState, navigationState);
128
+ },
129
+
130
+ drag: function(e) {
131
+ if (pinchDragTimeout) {
132
+ return;
133
+ }
134
+ pinchDragTimeout = setTimeout(function() {
135
+ presetNavigationState(e, 'pinch', gestureState);
136
+ plot.pan({
137
+ left: -delta(e, 'pinch', gestureState).x,
138
+ top: -delta(e, 'pinch', gestureState).y,
139
+ axes: navigationState.touchedAxis
140
+ });
141
+ updatePrevPanPosition(e, 'pinch', gestureState, navigationState);
142
+
143
+ var dist = pinchDistance(e);
144
+
145
+ if (gestureState.zoomEnable || Math.abs(dist - gestureState.prevDistance) > ZOOM_DISTANCE_MARGIN) {
146
+ zoomPlot(plot, e, gestureState, navigationState);
147
+
148
+ //activate zoom mode
149
+ gestureState.zoomEnable = true;
150
+ }
151
+ pinchDragTimeout = null;
152
+ }, 1000 / 60);
153
+ },
154
+
155
+ end: function(e) {
156
+ if (pinchDragTimeout) {
157
+ clearTimeout(pinchDragTimeout);
158
+ pinchDragTimeout = null;
159
+ }
160
+ presetNavigationState(e, 'pinch', gestureState);
161
+ gestureState.prevDistance = null;
162
+ }
163
+ };
164
+
165
+ doubleTap = {
166
+ recenterPlot: function(e) {
167
+ if (e && e.detail && e.detail.type === 'touchstart') {
168
+ // only do not recenter for touch start;
169
+ recenterPlotOnDoubleTap(plot, e, gestureState, navigationState);
170
+ }
171
+ }
172
+ };
173
+
174
+ if (options.pan.enableTouch === true || options.zoom.enableTouch === true) {
175
+ plot.hooks.bindEvents.push(bindEvents);
176
+ plot.hooks.shutdown.push(shutdown);
177
+ }
178
+
179
+ function presetNavigationState(e, gesture, gestureState) {
180
+ navigationState.touchedAxis = getAxis(plot, e, gesture, navigationState);
181
+ if (noAxisTouched(navigationState)) {
182
+ navigationState.navigationConstraint = 'unconstrained';
183
+ } else {
184
+ navigationState.navigationConstraint = 'axisConstrained';
185
+ }
186
+ }
187
+ }
188
+
189
+ $.plot.plugins.push({
190
+ init: init,
191
+ options: options,
192
+ name: 'navigateTouch',
193
+ version: '0.3'
194
+ });
195
+
196
+ function recenterPlotOnDoubleTap(plot, e, gestureState, navigationState) {
197
+ checkAxesForDoubleTap(plot, e, navigationState);
198
+ if ((navigationState.currentTouchedAxis === 'x' && navigationState.prevTouchedAxis === 'x') ||
199
+ (navigationState.currentTouchedAxis === 'y' && navigationState.prevTouchedAxis === 'y') ||
200
+ (navigationState.currentTouchedAxis === 'none' && navigationState.prevTouchedAxis === 'none')) {
201
+ var event;
202
+
203
+ plot.recenter({ axes: navigationState.touchedAxis });
204
+
205
+ if (navigationState.touchedAxis) {
206
+ event = new $.Event('re-center', { detail: { axisTouched: navigationState.touchedAxis } });
207
+ } else {
208
+ event = new $.Event('re-center', { detail: e });
209
+ }
210
+ plot.getPlaceholder().trigger(event);
211
+ }
212
+ }
213
+
214
+ function checkAxesForDoubleTap(plot, e, navigationState) {
215
+ var axis = plot.getTouchedAxis(e.detail.firstTouch.x, e.detail.firstTouch.y);
216
+ if (axis[0] !== undefined) {
217
+ navigationState.prevTouchedAxis = axis[0].direction;
218
+ }
219
+
220
+ axis = plot.getTouchedAxis(e.detail.secondTouch.x, e.detail.secondTouch.y);
221
+ if (axis[0] !== undefined) {
222
+ navigationState.touchedAxis = axis;
223
+ navigationState.currentTouchedAxis = axis[0].direction;
224
+ }
225
+
226
+ if (noAxisTouched(navigationState)) {
227
+ navigationState.touchedAxis = null;
228
+ navigationState.prevTouchedAxis = 'none';
229
+ navigationState.currentTouchedAxis = 'none';
230
+ }
231
+ }
232
+
233
+ function zoomPlot(plot, e, gestureState, navigationState) {
234
+ var offset = plot.offset(),
235
+ center = {
236
+ left: 0,
237
+ top: 0
238
+ },
239
+ zoomAmount = pinchDistance(e) / gestureState.prevDistance,
240
+ dist = pinchDistance(e);
241
+
242
+ center.left = getPoint(e, 'pinch').x - offset.left;
243
+ center.top = getPoint(e, 'pinch').y - offset.top;
244
+
245
+ // send the computed touched axis to the zoom function so that it only zooms on that one
246
+ plot.zoom({
247
+ center: center,
248
+ amount: zoomAmount,
249
+ axes: navigationState.touchedAxis
250
+ });
251
+ gestureState.prevDistance = dist;
252
+ }
253
+
254
+ function wasPinchEvent(e, gestureState) {
255
+ return (gestureState.zoomEnable && e.detail.touches.length === 1);
256
+ }
257
+
258
+ function getAxis(plot, e, gesture, navigationState) {
259
+ if (e.type === 'pinchstart') {
260
+ var axisTouch1 = plot.getTouchedAxis(e.detail.touches[0].pageX, e.detail.touches[0].pageY);
261
+ var axisTouch2 = plot.getTouchedAxis(e.detail.touches[1].pageX, e.detail.touches[1].pageY);
262
+
263
+ if (axisTouch1.length === axisTouch2.length && axisTouch1.toString() === axisTouch2.toString()) {
264
+ return axisTouch1;
265
+ }
266
+ } else if (e.type === 'panstart') {
267
+ return plot.getTouchedAxis(e.detail.touches[0].pageX, e.detail.touches[0].pageY);
268
+ } else if (e.type === 'pinchend') {
269
+ //update axis since instead on pinch, a pan event is made
270
+ return plot.getTouchedAxis(e.detail.touches[0].pageX, e.detail.touches[0].pageY);
271
+ } else {
272
+ return navigationState.touchedAxis;
273
+ }
274
+ }
275
+
276
+ function noAxisTouched(navigationState) {
277
+ return (!navigationState.touchedAxis || navigationState.touchedAxis.length === 0);
278
+ }
279
+
280
+ function setPrevDistance(e, gestureState) {
281
+ gestureState.prevDistance = pinchDistance(e);
282
+ }
283
+
284
+ function updateData(e, gesture, gestureState, navigationState) {
285
+ var axisDir,
286
+ point = getPoint(e, gesture);
287
+
288
+ switch (navigationState.navigationConstraint) {
289
+ case 'unconstrained':
290
+ navigationState.touchedAxis = null;
291
+ gestureState.prevTapPosition = {
292
+ x: gestureState.prevPanPosition.x,
293
+ y: gestureState.prevPanPosition.y
294
+ };
295
+ gestureState.prevPanPosition = {
296
+ x: point.x,
297
+ y: point.y
298
+ };
299
+ break;
300
+ case 'axisConstrained':
301
+ axisDir = navigationState.touchedAxis[0].direction;
302
+ navigationState.currentTouchedAxis = axisDir;
303
+ gestureState.prevTapPosition[axisDir] = gestureState.prevPanPosition[axisDir];
304
+ gestureState.prevPanPosition[axisDir] = point[axisDir];
305
+ break;
306
+ default:
307
+ break;
308
+ }
309
+ }
310
+
311
+ function distance(x1, y1, x2, y2) {
312
+ return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
313
+ }
314
+
315
+ function pinchDistance(e) {
316
+ var t1 = e.detail.touches[0],
317
+ t2 = e.detail.touches[1];
318
+ return distance(t1.pageX, t1.pageY, t2.pageX, t2.pageY);
319
+ }
320
+
321
+ function updatePrevPanPosition(e, gesture, gestureState, navigationState) {
322
+ var point = getPoint(e, gesture);
323
+
324
+ switch (navigationState.navigationConstraint) {
325
+ case 'unconstrained':
326
+ gestureState.prevPanPosition.x = point.x;
327
+ gestureState.prevPanPosition.y = point.y;
328
+ break;
329
+ case 'axisConstrained':
330
+ gestureState.prevPanPosition[navigationState.currentTouchedAxis] =
331
+ point[navigationState.currentTouchedAxis];
332
+ break;
333
+ default:
334
+ break;
335
+ }
336
+ }
337
+
338
+ function delta(e, gesture, gestureState) {
339
+ var point = getPoint(e, gesture);
340
+
341
+ return {
342
+ x: point.x - gestureState.prevPanPosition.x,
343
+ y: point.y - gestureState.prevPanPosition.y
344
+ }
345
+ }
346
+
347
+ function getPoint(e, gesture) {
348
+ if (gesture === 'pinch') {
349
+ return {
350
+ x: (e.detail.touches[0].pageX + e.detail.touches[1].pageX) / 2,
351
+ y: (e.detail.touches[0].pageY + e.detail.touches[1].pageY) / 2
352
+ }
353
+ } else {
354
+ return {
355
+ x: e.detail.touches[0].pageX,
356
+ y: e.detail.touches[0].pageY
357
+ }
358
+ }
359
+ }
360
+ })(jQuery);
@@ -0,0 +1,10 @@
1
+ (function ($) {
2
+ 'use strict';
3
+ $.plot.uiConstants = {
4
+ SNAPPING_CONSTANT: 20,
5
+ PANHINT_LENGTH_CONSTANT: 10,
6
+ MINOR_TICKS_COUNT_CONSTANT: 4,
7
+ TICK_LENGTH_CONSTANT: 10,
8
+ ZOOM_DISTANCE_MARGIN: 25
9
+ };
10
+ })(jQuery);