iobroker.vis2-materialdesign 0.1.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 (164) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +198 -0
  3. package/admin/admin.d.ts +93 -0
  4. package/admin/i18n/de.json +985 -0
  5. package/admin/i18n/en.json +985 -0
  6. package/admin/i18n/es.json +985 -0
  7. package/admin/i18n/fr.json +985 -0
  8. package/admin/i18n/it.json +985 -0
  9. package/admin/i18n/nl.json +985 -0
  10. package/admin/i18n/pl.json +985 -0
  11. package/admin/i18n/pt.json +985 -0
  12. package/admin/i18n/ru.json +985 -0
  13. package/admin/i18n/uk.json +985 -0
  14. package/admin/i18n/zh-cn.json +985 -0
  15. package/admin/img/info-big.png +0 -0
  16. package/admin/index_m.html +456 -0
  17. package/admin/index_m.js +1018 -0
  18. package/admin/lib/clipboard-polyfill.promise.js +16 -0
  19. package/admin/lib/colors.json +1304 -0
  20. package/admin/lib/colorsDark.json +1304 -0
  21. package/admin/lib/defaultcolors.json +22 -0
  22. package/admin/lib/defaultcolorsDark.json +22 -0
  23. package/admin/lib/defaultfontSizes.json +14 -0
  24. package/admin/lib/defaultfonts.json +14 -0
  25. package/admin/lib/fontSizes.json +380 -0
  26. package/admin/lib/fonts.json +386 -0
  27. package/admin/lib/monolith.min.css +1 -0
  28. package/admin/lib/pickr.min.js +5 -0
  29. package/admin/materialdesign-widgets-click-sound.mp3 +0 -0
  30. package/admin/style.css +31 -0
  31. package/admin/tsconfig.json +9 -0
  32. package/admin/vis-materialdesign.png +0 -0
  33. package/admin/vis-materialdesign_16_9.png +0 -0
  34. package/admin/words.js +11949 -0
  35. package/io-package.json +184 -0
  36. package/package.json +71 -0
  37. package/widgets/materialdesign/css/widgets.css +7174 -0
  38. package/widgets/materialdesign/css/widgets.min.css +1 -0
  39. package/widgets/materialdesign/img/IoBroker_Logo.png +0 -0
  40. package/widgets/materialdesign/img/bar_chart.png +0 -0
  41. package/widgets/materialdesign/img/calendar.png +0 -0
  42. package/widgets/materialdesign/img/pie_chart.png +0 -0
  43. package/widgets/materialdesign/img/prev_alerts.png +0 -0
  44. package/widgets/materialdesign/img/prev_autocomplete.png +0 -0
  45. package/widgets/materialdesign/img/prev_color_schemes.png +0 -0
  46. package/widgets/materialdesign/img/prev_dialog_view.png +0 -0
  47. package/widgets/materialdesign/img/prev_grid_views.png +0 -0
  48. package/widgets/materialdesign/img/prev_icon.png +0 -0
  49. package/widgets/materialdesign/img/prev_iconlist.png +0 -0
  50. package/widgets/materialdesign/img/prev_input.png +0 -0
  51. package/widgets/materialdesign/img/prev_json_chart.png +0 -0
  52. package/widgets/materialdesign/img/prev_line_history_chart.png +0 -0
  53. package/widgets/materialdesign/img/prev_list.png +0 -0
  54. package/widgets/materialdesign/img/prev_masonry_views.png +0 -0
  55. package/widgets/materialdesign/img/prev_select_bool.png +0 -0
  56. package/widgets/materialdesign/img/prev_select_value.png +0 -0
  57. package/widgets/materialdesign/img/prev_table.png +0 -0
  58. package/widgets/materialdesign/img/prev_top_app_bar_nav_drawer.png +0 -0
  59. package/widgets/materialdesign/img/prev_version.png +0 -0
  60. package/widgets/materialdesign/img/preview.jpg +0 -0
  61. package/widgets/materialdesign/js/materialdesign.js +56 -0
  62. package/widgets/materialdesign/js/widgets/materialdesign.00.helper.js +1229 -0
  63. package/widgets/materialdesign/js/widgets/materialdesign.00.vue.helper.js +710 -0
  64. package/widgets/materialdesign/js/widgets/materialdesign.alerts.js +177 -0
  65. package/widgets/materialdesign/js/widgets/materialdesign.autocomplete.js +263 -0
  66. package/widgets/materialdesign/js/widgets/materialdesign.button.js +1617 -0
  67. package/widgets/materialdesign/js/widgets/materialdesign.calendar.js +472 -0
  68. package/widgets/materialdesign/js/widgets/materialdesign.card.js +276 -0
  69. package/widgets/materialdesign/js/widgets/materialdesign.chart.bar.js +389 -0
  70. package/widgets/materialdesign/js/widgets/materialdesign.chart.helper.js +494 -0
  71. package/widgets/materialdesign/js/widgets/materialdesign.chart.json.js +621 -0
  72. package/widgets/materialdesign/js/widgets/materialdesign.chart.line.js +552 -0
  73. package/widgets/materialdesign/js/widgets/materialdesign.chart.pie.js +380 -0
  74. package/widgets/materialdesign/js/widgets/materialdesign.checkbox.js +281 -0
  75. package/widgets/materialdesign/js/widgets/materialdesign.colorschemes.js +129 -0
  76. package/widgets/materialdesign/js/widgets/materialdesign.dialog.js +384 -0
  77. package/widgets/materialdesign/js/widgets/materialdesign.iconList.js +873 -0
  78. package/widgets/materialdesign/js/widgets/materialdesign.list.js +503 -0
  79. package/widgets/materialdesign/js/widgets/materialdesign.materialdesignicons.js +7055 -0
  80. package/widgets/materialdesign/js/widgets/materialdesign.progress.js +413 -0
  81. package/widgets/materialdesign/js/widgets/materialdesign.roundslider.js +267 -0
  82. package/widgets/materialdesign/js/widgets/materialdesign.select.js +243 -0
  83. package/widgets/materialdesign/js/widgets/materialdesign.slider.js +363 -0
  84. package/widgets/materialdesign/js/widgets/materialdesign.switch.js +284 -0
  85. package/widgets/materialdesign/js/widgets/materialdesign.table.js +688 -0
  86. package/widgets/materialdesign/js/widgets/materialdesign.textfield.js +260 -0
  87. package/widgets/materialdesign/js/widgets/materialdesign.topappbarnav.js +747 -0
  88. package/widgets/materialdesign/js/widgets/materialdesign.value.js +369 -0
  89. package/widgets/materialdesign/js/widgets/materialdesign.views.js +827 -0
  90. package/widgets/materialdesign/js/widgets/materialdesign.viseditor.js +1088 -0
  91. package/widgets/materialdesign/js/widgets.min.js +1 -0
  92. package/widgets/materialdesign/lib/Chart.css +47 -0
  93. package/widgets/materialdesign/lib/Chart.js +16151 -0
  94. package/widgets/materialdesign/lib/VueTheMask.umd.js +556 -0
  95. package/widgets/materialdesign/lib/chartjs-plugin-datalabels.js +1385 -0
  96. package/widgets/materialdesign/lib/chroma.js +3225 -0
  97. package/widgets/materialdesign/lib/fonts/material-design-icons/materialdesignicons-webfont.ttf +0 -0
  98. package/widgets/materialdesign/lib/fonts/material-design-icons/materialdesignicons.css +27457 -0
  99. package/widgets/materialdesign/lib/fonts/material-design-icons/materialdesignicons.min.css +1 -0
  100. package/widgets/materialdesign/lib/fonts/material-icons/MaterialIcons-Regular.ttf +0 -0
  101. package/widgets/materialdesign/lib/fonts/material-icons/material-icons.css +31 -0
  102. package/widgets/materialdesign/lib/he.js +345 -0
  103. package/widgets/materialdesign/lib/jquery.initialize.js +156 -0
  104. package/widgets/materialdesign/lib/jquery.knob.js +820 -0
  105. package/widgets/materialdesign/lib/jquery.mobile-events.js +940 -0
  106. package/widgets/materialdesign/lib/material-components-web.css +10011 -0
  107. package/widgets/materialdesign/lib/material-components-web.js +22651 -0
  108. package/widgets/materialdesign/lib/math.js +41 -0
  109. package/widgets/materialdesign/lib/moment-duration-format.js +1737 -0
  110. package/widgets/materialdesign/lib/myUnderscore.js +1695 -0
  111. package/widgets/materialdesign/lib/raw/moment-with-locales.min.js +28 -0
  112. package/widgets/materialdesign/lib/raw/round-slider.js +271 -0
  113. package/widgets/materialdesign/lib/raw/sentry/bundle.min.js +3 -0
  114. package/widgets/materialdesign/lib/raw/sentry/captureconsole.min.js +2 -0
  115. package/widgets/materialdesign/lib/raw/sentry/dedupe.min.js +2 -0
  116. package/widgets/materialdesign/lib/svg-inject.js +697 -0
  117. package/widgets/materialdesign/lib/vue.js +11965 -0
  118. package/widgets/materialdesign/lib/vuetify.js +43729 -0
  119. package/widgets/materialdesign/lib.min.css +1 -0
  120. package/widgets/materialdesign/lib.min.js +6285 -0
  121. package/widgets/materialdesign.html +1063 -0
  122. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonAdition-BOasvewn.js +1 -0
  123. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonAditionVertical-CfxLrjtz.js +1 -0
  124. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonLink-DFOHalVe.js +1 -0
  125. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonLinkVertical-bLBc2Zj6.js +1 -0
  126. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonNavigation-loocTeHA.js +1 -0
  127. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonNavigationVertical-wKivh3mz.js +1 -0
  128. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonState-DyuzNIZY.js +1 -0
  129. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonStateMulti-D9YVumU3.js +1 -0
  130. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonStateMultiVertical-J7SUuXNA.js +1 -0
  131. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonStateVertical-EhVri-Bj.js +1 -0
  132. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonToggle-CLxaT9SA.js +1 -0
  133. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonToggleVertical-4zI4T-cI.js +1 -0
  134. package/widgets/vis2-materialdesign/assets/MaterialDesignButtons-BHDA55zY.js +1 -0
  135. package/widgets/vis2-materialdesign/assets/MaterialDesignCheckbox-Dwl43BB6.js +1 -0
  136. package/widgets/vis2-materialdesign/assets/MaterialDesignIcon-07Jl1QSv.js +1 -0
  137. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonAdition-DkyLUAuu.js +1 -0
  138. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonLink-CFh_41FT.js +1 -0
  139. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonNavigation-CLvhcORZ.js +1 -0
  140. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonSlider-TfUJKNib.js +1 -0
  141. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonState-Con_l2iN.js +1 -0
  142. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonStateMulti-DuakGd7h.js +1 -0
  143. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonToggle-B3Yxo-Ii.js +1 -0
  144. package/widgets/vis2-materialdesign/assets/MaterialDesignSwitch-BPSYRrDe.js +1 -0
  145. package/widgets/vis2-materialdesign/assets/MaterialDesignValue-D5sJ-iyi.js +1 -0
  146. package/widgets/vis2-materialdesign/assets/_virtual_mf-localSharedImportMap___mfe_internal__vis2MaterialDesignWidgets-BFI0756z.js +1 -0
  147. package/widgets/vis2-materialdesign/assets/_virtual_mf___mfe_internal__vis2MaterialDesignWidgets__loadShare__react__loadShare__.js-4V-ZaKyJ.js +1 -0
  148. package/widgets/vis2-materialdesign/assets/_virtual_mf___mfe_internal__vis2MaterialDesignWidgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-Eu2aWCKd.js +1 -0
  149. package/widgets/vis2-materialdesign/assets/_virtual_mf___mfe_internal__vis2MaterialDesignWidgets__loadShare__react_mf_2_dom__loadShare__.js-D3wyrTEe.js +8 -0
  150. package/widgets/vis2-materialdesign/assets/hostInit-CP4jqDxy.js +1 -0
  151. package/widgets/vis2-materialdesign/assets/index-jMDUG1V1.js +1 -0
  152. package/widgets/vis2-materialdesign/assets/mf-entry-bootstrap-0-5bdbe7bd.js +35 -0
  153. package/widgets/vis2-materialdesign/assets/rolldown-runtime-CNC7AqOf.js +1 -0
  154. package/widgets/vis2-materialdesign/assets/translations-CYT3A7CQ.js +1 -0
  155. package/widgets/vis2-materialdesign/assets/virtualExposes-BFTZrXtp.js +1 -0
  156. package/widgets/vis2-materialdesign/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__vis2MaterialDesignWidgets__customWidgets_js-BOvf1QCd.js +4 -0
  157. package/widgets/vis2-materialdesign/assets/virtual_mf-exposes-ssr___mfe_internal__vis2MaterialDesignWidgets__customWidgets_js-vY7qHvFF.js +2 -0
  158. package/widgets/vis2-materialdesign/assets/virtual_mf-exposes___mfe_internal__vis2MaterialDesignWidgets__customWidgets_js-C28iDRsy.js +2 -0
  159. package/widgets/vis2-materialdesign/assets/vite-preload-helper-DuG8C5Si.js +1 -0
  160. package/widgets/vis2-materialdesign/assets/widgetUtils-D_-xivaB.js +1 -0
  161. package/widgets/vis2-materialdesign/customWidgets.js +1 -0
  162. package/widgets/vis2-materialdesign/customWidgets.ssr.js +1 -0
  163. package/widgets/vis2-materialdesign/materialdesign-widgets-click-sound.mp3 +0 -0
  164. package/widgets/vis2-materialdesign/mf-stats.json +1 -0
@@ -0,0 +1,940 @@
1
+ /*!
2
+ * jQuery Mobile Events
3
+ * by Ben Major
4
+ *
5
+ * Copyright 2011-2019, Ben Major
6
+ * Licensed under the MIT License:
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in
16
+ * all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ * THE SOFTWARE.
25
+ *
26
+ */
27
+
28
+ "use strict";
29
+
30
+ (function ($) {
31
+ $.attrFn = $.attrFn || {};
32
+
33
+ var touchCapable = ('ontouchstart' in window),
34
+
35
+ settings = {
36
+ tap_pixel_range: 5,
37
+ swipe_h_threshold: 50,
38
+ swipe_v_threshold: 50,
39
+ taphold_threshold: 750,
40
+ doubletap_int: 500,
41
+ shake_threshold: 15,
42
+
43
+ touch_capable: touchCapable,
44
+ orientation_support: ('orientation' in window && 'onorientationchange' in window),
45
+
46
+ startevent: (touchCapable) ? 'touchstart' : 'mousedown',
47
+ endevent: (touchCapable) ? 'touchend' : 'mouseup',
48
+ moveevent: (touchCapable) ? 'touchmove' : 'mousemove',
49
+ tapevent: (touchCapable) ? 'tap' : 'click',
50
+ scrollevent: (touchCapable) ? 'touchmove' : 'scroll',
51
+
52
+ hold_timer: null,
53
+ tap_timer: null
54
+ };
55
+
56
+ // Declare touch namespace:
57
+ $.touch = { };
58
+
59
+ // Convenience functions:
60
+ $.isTouchCapable = function() { return settings.touch_capable; };
61
+ $.getStartEvent = function() { return settings.startevent; };
62
+ $.getEndEvent = function() { return settings.endevent; };
63
+ $.getMoveEvent = function() { return settings.moveevent; };
64
+ $.getTapEvent = function() { return settings.tapevent; };
65
+ $.getScrollEvent = function() { return settings.scrollevent; };
66
+
67
+ // SETTERS:
68
+ // Set the X threshold of swipe events:
69
+ $.touch.setSwipeThresholdX = function( threshold ) {
70
+ if( typeof threshold !== 'number' ) { throw new Error('Threshold parameter must be a type of number'); }
71
+ settings.swipe_h_threshold = threshold;
72
+ };
73
+
74
+ // Set the Y threshold of swipe events:
75
+ $.touch.setSwipeThresholdY = function( threshold ) {
76
+ if( typeof threshold !== 'number' ) { throw new Error('Threshold parameter must be a type of number'); }
77
+ settings.swipe_v_threshold = threshold;
78
+ };
79
+
80
+ // Set the double tap interval:
81
+ $.touch.setDoubleTapInt = function( interval ) {
82
+ if( typeof interval !== 'number' ) { throw new Error('Interval parameter must be a type of number'); }
83
+ settings.doubletap_int = interval;
84
+ };
85
+
86
+ // Set the taphold threshold:
87
+ $.touch.setTapHoldThreshold = function( threshold ) {
88
+ if( typeof threshold !== 'number' ) { throw new Error('Threshold parameter must be a type of number'); }
89
+ settings.taphold_threshold = threshold;
90
+ };
91
+
92
+ // Set the pixel range for tapas:
93
+ $.touch.setTapRange = function( threshold ) {
94
+ if( typeof threshold !== 'number' ) { throw new Error('Ranger parameter must be a type of number'); }
95
+ settings.tap_pixel_range = threshold;
96
+ };
97
+
98
+ // Add Event shortcuts:
99
+ $.each(['tapstart', 'tapend', 'tapmove', 'tap', 'singletap', 'doubletap', 'taphold', 'swipe', 'swipeup', 'swiperight', 'swipedown', 'swipeleft', 'swipeend', 'scrollstart', 'scrollend', 'orientationchange', 'tap2', 'taphold2'], function (i, name) {
100
+ $.fn[name] = function (fn) {
101
+ return fn ? this.on(name, fn) : this.trigger(name);
102
+ };
103
+
104
+ $.attrFn[name] = true;
105
+ });
106
+
107
+ // tapstart Event:
108
+ $.event.special.tapstart = {
109
+ setup: function () {
110
+
111
+ var thisObject = this,
112
+ $this = $(thisObject);
113
+
114
+ $this.on(settings.startevent, function tapStartFunc(e) {
115
+
116
+ $this.data('callee', tapStartFunc);
117
+ if (e.which && e.which !== 1) {
118
+ return false;
119
+ }
120
+
121
+ var offset = ($this.get(0) !== window && $this.get(0) !== document) ? $this.offset() : { left: 0, top: 0 };
122
+ var origEvent = e.originalEvent,
123
+ touchData = {
124
+ 'position': {
125
+ 'x': ((settings.touch_capable) ? origEvent.touches[0].pageX : e.pageX),
126
+ 'y': (settings.touch_capable) ? origEvent.touches[0].pageY : e.pageY
127
+ },
128
+ 'offset': {
129
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - offset.left) : Math.round(e.pageX - offset.left),
130
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - offset.top) : Math.round(e.pageY - offset.top)
131
+ },
132
+ 'time': Date.now(),
133
+ 'target': e.target
134
+ };
135
+
136
+ triggerCustomEvent(thisObject, 'tapstart', e, touchData);
137
+ return true;
138
+ });
139
+ },
140
+
141
+ remove: function () {
142
+ $(this).off(settings.startevent, $(this).data.callee);
143
+ }
144
+ };
145
+
146
+ // tapmove Event:
147
+ $.event.special.tapmove = {
148
+ setup: function() {
149
+ var thisObject = this,
150
+ $this = $(thisObject);
151
+
152
+ $this.on(settings.moveevent, function tapMoveFunc(e) {
153
+ $this.data('callee', tapMoveFunc);
154
+
155
+ var offset = ($this.get(0) !== window && $this.get(0) !== document) ? $this.offset() : { left: 0, top: 0 };
156
+ var origEvent = e.originalEvent,
157
+ touchData = {
158
+ 'position': {
159
+ 'x': ((settings.touch_capable) ? origEvent.touches[0].pageX : e.pageX),
160
+ 'y': (settings.touch_capable) ? origEvent.touches[0].pageY : e.pageY
161
+ },
162
+ 'offset': {
163
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - offset.left) : Math.round(e.pageX - offset.left),
164
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - offset.top) : Math.round(e.pageY - offset.top)
165
+ },
166
+ 'time': Date.now(),
167
+ 'target': e.target
168
+ };
169
+
170
+ triggerCustomEvent(thisObject, 'tapmove', e, touchData);
171
+ return true;
172
+ });
173
+ },
174
+ remove: function() {
175
+ $(this).off(settings.moveevent, $(this).data.callee);
176
+ }
177
+ };
178
+
179
+ // tapend Event:
180
+ $.event.special.tapend = {
181
+ setup: function () {
182
+ var thisObject = this,
183
+ $this = $(thisObject);
184
+
185
+ $this.on(settings.endevent, function tapEndFunc(e) {
186
+ // Touch event data:
187
+ $this.data('callee', tapEndFunc);
188
+
189
+ var offset = ($this.get(0) !== window && $this.get(0) !== document) ? $this.offset() : { left: 0, top: 0 };
190
+ var origEvent = e.originalEvent;
191
+ var touchData = {
192
+ 'position': {
193
+ 'x': (settings.touch_capable) ? origEvent.changedTouches[0].pageX : e.pageX,
194
+ 'y': (settings.touch_capable) ? origEvent.changedTouches[0].pageY : e.pageY
195
+ },
196
+ 'offset': {
197
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - offset.left) : Math.round(e.pageX - offset.left),
198
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - offset.top) : Math.round(e.pageY - offset.top)
199
+ },
200
+ 'time': Date.now(),
201
+ 'target': e.target
202
+ };
203
+ triggerCustomEvent(thisObject, 'tapend', e, touchData);
204
+ return true;
205
+ });
206
+ },
207
+ remove: function () {
208
+ $(this).off(settings.endevent, $(this).data.callee);
209
+ }
210
+ };
211
+
212
+ // taphold Event:
213
+ $.event.special.taphold = {
214
+ setup: function () {
215
+ var thisObject = this,
216
+ $this = $(thisObject),
217
+ origTarget,
218
+ start_pos = {
219
+ x: 0,
220
+ y: 0
221
+ },
222
+ end_x = 0,
223
+ end_y = 0;
224
+
225
+ $this.on(settings.startevent, function tapHoldFunc1(e) {
226
+ if (e.which && e.which !== 1) {
227
+ return false;
228
+ } else {
229
+ $this.data('tapheld', false);
230
+ origTarget = e.target;
231
+
232
+ var origEvent = e.originalEvent;
233
+ var start_time = Date.now(),
234
+ startPosition = {
235
+ 'x': (settings.touch_capable) ? origEvent.touches[0].pageX : e.pageX,
236
+ 'y': (settings.touch_capable) ? origEvent.touches[0].pageY : e.pageY
237
+ },
238
+ startOffset = {
239
+ 'x': (settings.touch_capable) ? origEvent.touches[0].pageX - origEvent.touches[0].target.offsetLeft : e.offsetX,
240
+ 'y': (settings.touch_capable) ? origEvent.touches[0].pageY - origEvent.touches[0].target.offsetTop : e.offsetY
241
+ };
242
+
243
+ start_pos.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
244
+ start_pos.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
245
+
246
+ end_x = start_pos.x;
247
+ end_y = start_pos.y;
248
+
249
+ // Get the element's threshold:
250
+ var ele_threshold = ($this.parent().data('threshold')) ? $this.parent().data('threshold') : $this.data('threshold'),
251
+ threshold = (typeof ele_threshold !== 'undefined' && ele_threshold !== false && parseInt(ele_threshold)) ? parseInt(ele_threshold) : settings.taphold_threshold;
252
+
253
+ $this.data('hold_timer', window.setTimeout(function () {
254
+
255
+ var diff_x = (start_pos.x - end_x),
256
+ diff_y = (start_pos.y - end_y);
257
+
258
+ if (e.target == origTarget && ((start_pos.x == end_x && start_pos.y == end_y) || (diff_x >= -(settings.tap_pixel_range) && diff_x <= settings.tap_pixel_range && diff_y >= -(settings.tap_pixel_range) && diff_y <= settings.tap_pixel_range))) {
259
+ $this.data('tapheld', true);
260
+
261
+ var end_time = Date.now();
262
+
263
+ var duration = end_time - start_time,
264
+ touches = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches : [ e ],
265
+ touchData = [ ];
266
+
267
+ var offset = ($this.get(0) !== window && $this.get(0) !== document) ? $this.offset() : { left: 0, top: 0 };
268
+ for( var i = 0; i < touches.length; i++)
269
+ {
270
+ var touch = {
271
+ 'position': {
272
+ 'x': (settings.touch_capable) ? origEvent.changedTouches[i].pageX : e.pageX,
273
+ 'y': (settings.touch_capable) ? origEvent.changedTouches[i].pageY : e.pageY
274
+ },
275
+ 'offset': {
276
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[i].pageX - offset.left) : Math.round(e.pageX - offset.left),
277
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[i].pageY - offset.top) : Math.round(e.pageY - offset.top)
278
+ },
279
+ 'time': Date.now(),
280
+ 'target': e.target,
281
+ 'duration': duration
282
+ };
283
+
284
+ touchData.push( touch );
285
+ }
286
+
287
+ var evt_name = ( touches.length == 2 ) ? 'taphold2' : 'taphold';
288
+
289
+ $this.data('callee1', tapHoldFunc1);
290
+
291
+ triggerCustomEvent(thisObject, evt_name, e, touchData);
292
+ }
293
+ }, threshold) );
294
+
295
+ return true;
296
+ }
297
+ }).on(settings.endevent, function tapHoldFunc2() {
298
+ $this.data('callee2', tapHoldFunc2);
299
+ $this.data('tapheld', false);
300
+ window.clearTimeout( $this.data('hold_timer') );
301
+ })
302
+ .on(settings.moveevent, function tapHoldFunc3(e) {
303
+ $this.data('callee3', tapHoldFunc3);
304
+
305
+ end_x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
306
+ end_y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
307
+ });
308
+ },
309
+
310
+ remove: function () {
311
+ $(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2).off(settings.moveevent, $(this).data.callee3);
312
+ }
313
+ };
314
+
315
+ // doubletap Event:
316
+ $.event.special.doubletap = {
317
+ setup: function () {
318
+ var thisObject = this,
319
+ $this = $(thisObject),
320
+ origTarget,
321
+ action,
322
+ firstTap = null,
323
+ origEvent,
324
+ cooloff,
325
+ cooling = false;
326
+
327
+ $this.on(settings.startevent, function doubleTapFunc1(e) {
328
+ if (e.which && e.which !== 1) {
329
+ return false;
330
+ }
331
+
332
+ $this.data('doubletapped', false);
333
+ origTarget = e.target;
334
+ $this.data('callee1', doubleTapFunc1);
335
+
336
+ origEvent = e.originalEvent;
337
+ if (!firstTap) {
338
+ var offset = ($this.get(0) !== window && $this.get(0) !== document) ? $this.offset() : { left: 0, top: 0 };
339
+ firstTap = {
340
+ 'position': {
341
+ 'x': (settings.touch_capable) ? origEvent.touches[0].pageX : e.pageX,
342
+ 'y': (settings.touch_capable) ? origEvent.touches[0].pageY : e.pageY
343
+ },
344
+ 'offset': {
345
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - offset.left) : Math.round(e.pageX - offset.left),
346
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - offset.top) : Math.round(e.pageY - offset.top)
347
+ },
348
+ 'time': Date.now(),
349
+ 'target': e.target,
350
+ 'element': e.originalEvent.srcElement,
351
+ 'index': $(e.target).index()
352
+ };
353
+ }
354
+
355
+ return true;
356
+ }).on(settings.endevent, function doubleTapFunc2(e) {
357
+
358
+ var now = Date.now();
359
+ var lastTouch = $this.data('lastTouch') || now + 1;
360
+ var delta = now - lastTouch;
361
+ window.clearTimeout(action);
362
+ $this.data('callee2', doubleTapFunc2);
363
+
364
+ if (delta < settings.doubletap_int && ($(e.target).index() == firstTap.index) && delta > 100) {
365
+ $this.data('doubletapped', true);
366
+ window.clearTimeout(settings.tap_timer);
367
+
368
+ // Now get the current event:
369
+ var offset = ($this.get(0) !== window && $this.get(0) !== document) ? $this.offset() : { left: 0, top: 0 };
370
+ var lastTap = {
371
+ 'position': {
372
+ 'x': (settings.touch_capable) ? e.originalEvent.changedTouches[0].pageX : e.pageX,
373
+ 'y': (settings.touch_capable) ? e.originalEvent.changedTouches[0].pageY : e.pageY
374
+ },
375
+ 'offset': {
376
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - offset.left) : Math.round(e.pageX - offset.left),
377
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - offset.top) : Math.round(e.pageY - offset.top)
378
+ },
379
+ 'time': Date.now(),
380
+ 'target': e.target,
381
+ 'element': e.originalEvent.srcElement,
382
+ 'index': $(e.target).index()
383
+ };
384
+
385
+ var touchData = {
386
+ 'firstTap': firstTap,
387
+ 'secondTap': lastTap,
388
+ 'interval': lastTap.time - firstTap.time
389
+ };
390
+
391
+ if (!cooling) {
392
+ triggerCustomEvent(thisObject, 'doubletap', e, touchData);
393
+ firstTap = null;
394
+ }
395
+
396
+ cooling = true;
397
+
398
+ cooloff = window.setTimeout(function () {
399
+ cooling = false;
400
+ }, settings.doubletap_int);
401
+
402
+ } else {
403
+ $this.data('lastTouch', now);
404
+ action = window.setTimeout(function () {
405
+ firstTap = null;
406
+ window.clearTimeout(action);
407
+ }, settings.doubletap_int, [e]);
408
+ }
409
+ $this.data('lastTouch', now);
410
+ });
411
+ },
412
+ remove: function () {
413
+ $(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2);
414
+ }
415
+ };
416
+
417
+ // singletap Event:
418
+ // This is used in conjuction with doubletap when both events are needed on the same element
419
+ $.event.special.singletap = {
420
+ setup: function () {
421
+ var thisObject = this,
422
+ $this = $(thisObject),
423
+ origTarget = null,
424
+ startTime = null,
425
+ start_pos = {
426
+ x: 0,
427
+ y: 0
428
+ };
429
+
430
+ $this.on(settings.startevent, function singleTapFunc1(e) {
431
+ if (e.which && e.which !== 1) {
432
+ return false;
433
+ } else {
434
+ startTime = Date.now();
435
+ origTarget = e.target;
436
+ $this.data('callee1', singleTapFunc1);
437
+
438
+ // Get the start x and y position:
439
+ start_pos.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
440
+ start_pos.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
441
+
442
+ return true;
443
+ }
444
+ }).on(settings.endevent, function singleTapFunc2(e) {
445
+ $this.data('callee2', singleTapFunc2);
446
+ if (e.target == origTarget) {
447
+
448
+ // Get the end point:
449
+ var end_pos_x = (e.originalEvent.changedTouches) ? e.originalEvent.changedTouches[0].pageX : e.pageX,
450
+ end_pos_y = (e.originalEvent.changedTouches) ? e.originalEvent.changedTouches[0].pageY : e.pageY;
451
+
452
+ // We need to check if it was a taphold:
453
+
454
+ settings.tap_timer = window.setTimeout(function () {
455
+
456
+ var diff_x = (start_pos.x - end_pos_x), diff_y = (start_pos.y - end_pos_y);
457
+
458
+ if(!$this.data('doubletapped') && !$this.data('tapheld') && (((start_pos.x == end_pos_x) && (start_pos.y == end_pos_y)) || (diff_x >= -(settings.tap_pixel_range) && diff_x <= settings.tap_pixel_range && diff_y >= -(settings.tap_pixel_range) && diff_y <= settings.tap_pixel_range))) {
459
+
460
+ var offset = ($this.get(0) !== window && $this.get(0) !== document) ? $this.offset() : { left: 0, top: 0 };
461
+ var origEvent = e.originalEvent;
462
+ var touchData = {
463
+ 'position': {
464
+ 'x': (settings.touch_capable) ? origEvent.changedTouches[0].pageX : e.pageX,
465
+ 'y': (settings.touch_capable) ? origEvent.changedTouches[0].pageY : e.pageY
466
+ },
467
+ 'offset': {
468
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - offset.left) : Math.round(e.pageX - offset.left),
469
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - offset.top) : Math.round(e.pageY - offset.top)
470
+ },
471
+ 'time': Date.now(),
472
+ 'target': e.target
473
+ };
474
+
475
+ // Was it a taphold?
476
+ if((touchData.time - startTime) < settings.taphold_threshold)
477
+ {
478
+ triggerCustomEvent(thisObject, 'singletap', e, touchData);
479
+ }
480
+ }
481
+ }, settings.doubletap_int);
482
+ }
483
+ });
484
+ },
485
+
486
+ remove: function () {
487
+ $(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2);
488
+ }
489
+ };
490
+
491
+ // tap Event:
492
+ $.event.special.tap = {
493
+ setup: function () {
494
+ var thisObject = this,
495
+ $this = $(thisObject),
496
+ started = false,
497
+ origTarget = null,
498
+ start_time,
499
+ start_pos = {
500
+ x: 0,
501
+ y: 0
502
+ },
503
+ touches;
504
+
505
+ $this.on(settings.startevent, function tapFunc1(e) {
506
+ $this.data('callee1', tapFunc1);
507
+
508
+ if( e.which && e.which !== 1 )
509
+ {
510
+ return false;
511
+ }
512
+ else
513
+ {
514
+ started = true;
515
+ start_pos.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
516
+ start_pos.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
517
+ start_time = Date.now();
518
+ origTarget = e.target;
519
+
520
+ touches = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches : [ e ];
521
+ return true;
522
+ }
523
+ }).on(settings.endevent, function tapFunc2(e) {
524
+ $this.data('callee2', tapFunc2);
525
+
526
+ // Only trigger if they've started, and the target matches:
527
+ var end_x = (e.originalEvent.targetTouches) ? e.originalEvent.changedTouches[0].pageX : e.pageX,
528
+ end_y = (e.originalEvent.targetTouches) ? e.originalEvent.changedTouches[0].pageY : e.pageY,
529
+ diff_x = (start_pos.x - end_x),
530
+ diff_y = (start_pos.y - end_y),
531
+ eventName;
532
+
533
+ if (origTarget == e.target && started && ((Date.now() - start_time) < settings.taphold_threshold) && ((start_pos.x == end_x && start_pos.y == end_y) || (diff_x >= -(settings.tap_pixel_range) && diff_x <= settings.tap_pixel_range && diff_y >= -(settings.tap_pixel_range) && diff_y <= settings.tap_pixel_range))) {
534
+ var offset = ($this.get(0) !== window && $this.get(0) !== document) ? $this.offset() : { left: 0, top: 0 };
535
+ var origEvent = e.originalEvent;
536
+ var touchData = [ ];
537
+
538
+ for( var i = 0; i < touches.length; i++)
539
+ {
540
+ var touch = {
541
+ 'position': {
542
+ 'x': (settings.touch_capable) ? origEvent.changedTouches[i].pageX : e.pageX,
543
+ 'y': (settings.touch_capable) ? origEvent.changedTouches[i].pageY : e.pageY
544
+ },
545
+ 'offset': {
546
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[i].pageX - offset.left) : Math.round(e.pageX - offset.left),
547
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[i].pageY - offset.top) : Math.round(e.pageY - offset.top)
548
+ },
549
+ 'time': Date.now(),
550
+ 'target': e.target
551
+ };
552
+
553
+ touchData.push( touch );
554
+ }
555
+
556
+ var evt_name = ( touches.length == 2 ) ? 'tap2' : 'tap';
557
+
558
+ triggerCustomEvent(thisObject, evt_name, e, touchData);
559
+ }
560
+ });
561
+ },
562
+
563
+ remove: function () {
564
+ $(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2);
565
+ }
566
+ };
567
+
568
+ // swipe Event (also handles swipeup, swiperight, swipedown and swipeleft):
569
+ $.event.special.swipe = {
570
+ setup: function () {
571
+ var thisObject = this,
572
+ $this = $(thisObject),
573
+ started = false,
574
+ hasSwiped = false,
575
+ originalCoord = {
576
+ x: 0,
577
+ y: 0
578
+ },
579
+ finalCoord = {
580
+ x: 0,
581
+ y: 0
582
+ },
583
+ startEvnt;
584
+
585
+ // Screen touched, store the original coordinate
586
+
587
+ function touchStart(e) {
588
+ $this = $(e.currentTarget);
589
+ $this.data('callee1', touchStart);
590
+ originalCoord.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
591
+ originalCoord.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
592
+ finalCoord.x = originalCoord.x;
593
+ finalCoord.y = originalCoord.y;
594
+ started = true;
595
+ var offset = ($this.get(0) !== window && $this.get(0) !== document) ? $this.offset() : { left: 0, top: 0 };
596
+ var origEvent = e.originalEvent;
597
+ // Read event data into our startEvt:
598
+ startEvnt = {
599
+ 'position': {
600
+ 'x': (settings.touch_capable) ? origEvent.touches[0].pageX : e.pageX,
601
+ 'y': (settings.touch_capable) ? origEvent.touches[0].pageY : e.pageY
602
+ },
603
+ 'offset': {
604
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - offset.left) : Math.round(e.pageX - offset.left),
605
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - offset.top) : Math.round(e.pageY - offset.top)
606
+ },
607
+ 'time': Date.now(),
608
+ 'target': e.target
609
+ };
610
+ }
611
+
612
+ // Store coordinates as finger is swiping
613
+
614
+ function touchMove(e) {
615
+ $this = $(e.currentTarget);
616
+ $this.data('callee2', touchMove);
617
+ finalCoord.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
618
+ finalCoord.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
619
+
620
+ var swipedir;
621
+
622
+ // We need to check if the element to which the event was bound contains a data-xthreshold | data-vthreshold:
623
+ var ele_x_threshold = ($this.parent().data('xthreshold')) ? $this.parent().data('xthreshold') : $this.data('xthreshold'),
624
+ ele_y_threshold = ($this.parent().data('ythreshold')) ? $this.parent().data('ythreshold') : $this.data('ythreshold'),
625
+ h_threshold = (typeof ele_x_threshold !== 'undefined' && ele_x_threshold !== false && parseInt(ele_x_threshold)) ? parseInt(ele_x_threshold) : settings.swipe_h_threshold,
626
+ v_threshold = (typeof ele_y_threshold !== 'undefined' && ele_y_threshold !== false && parseInt(ele_y_threshold)) ? parseInt(ele_y_threshold) : settings.swipe_v_threshold;
627
+
628
+ if (Math.abs(finalCoord.x - originalCoord.x) > Math.abs(finalCoord.y - originalCoord.y)) {
629
+ if (originalCoord.x < finalCoord.x && (finalCoord.x - originalCoord.x > h_threshold)) {
630
+ swipedir = 'swiperight';
631
+ }
632
+ if (originalCoord.x > finalCoord.x && (originalCoord.x - finalCoord.x > h_threshold)) {
633
+ swipedir = 'swipeleft';
634
+ }
635
+ }
636
+ else {
637
+ if (originalCoord.y > finalCoord.y && (originalCoord.y - finalCoord.y > v_threshold)) {
638
+ swipedir = 'swipeup';
639
+ }
640
+ if (originalCoord.y < finalCoord.y && (finalCoord.y - originalCoord.y > v_threshold)) {
641
+ swipedir = 'swipedown';
642
+ }
643
+ }
644
+
645
+ if (swipedir != undefined && started) {
646
+ originalCoord.x = 0;
647
+ originalCoord.y = 0;
648
+ finalCoord.x = 0;
649
+ finalCoord.y = 0;
650
+ started = false;
651
+
652
+ // Read event data into our endEvnt:
653
+ var offset = ($this.get(0) !== window && $this.get(0) !== document) ? $this.offset() : { left: 0, top: 0 };
654
+ var origEvent = e.originalEvent;
655
+ var endEvnt = {
656
+ 'position': {
657
+ 'x': (settings.touch_capable) ? origEvent.touches[0].pageX : e.pageX,
658
+ 'y': (settings.touch_capable) ? origEvent.touches[0].pageY : e.pageY
659
+ },
660
+ 'offset': {
661
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - offset.left) : Math.round(e.pageX - offset.left),
662
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - offset.top) : Math.round(e.pageY - offset.top)
663
+ },
664
+ 'time': Date.now(),
665
+ 'target': e.target
666
+ };
667
+
668
+ // Calculate the swipe amount (normalized):
669
+ var xAmount = Math.abs(startEvnt.position.x - endEvnt.position.x),
670
+ yAmount = Math.abs(startEvnt.position.y - endEvnt.position.y);
671
+
672
+ var touchData = {
673
+ 'startEvnt': startEvnt,
674
+ 'endEvnt': endEvnt,
675
+ 'direction': swipedir.replace('swipe', ''),
676
+ 'xAmount': xAmount,
677
+ 'yAmount': yAmount,
678
+ 'duration': endEvnt.time - startEvnt.time
679
+ };
680
+ hasSwiped = true;
681
+ $this.trigger('swipe', touchData).trigger(swipedir, touchData);
682
+ }
683
+ }
684
+
685
+ function touchEnd(e) {
686
+ $this = $(e.currentTarget);
687
+ var swipedir = "";
688
+ $this.data('callee3', touchEnd);
689
+ if (hasSwiped) {
690
+ // We need to check if the element to which the event was bound contains a data-xthreshold | data-vthreshold:
691
+ var ele_x_threshold = $this.data('xthreshold'),
692
+ ele_y_threshold = $this.data('ythreshold'),
693
+ h_threshold = (typeof ele_x_threshold !== 'undefined' && ele_x_threshold !== false && parseInt(ele_x_threshold)) ? parseInt(ele_x_threshold) : settings.swipe_h_threshold,
694
+ v_threshold = (typeof ele_y_threshold !== 'undefined' && ele_y_threshold !== false && parseInt(ele_y_threshold)) ? parseInt(ele_y_threshold) : settings.swipe_v_threshold;
695
+
696
+ var offset = ($this.get(0) !== window && $this.get(0) !== document) ? $this.offset() : { left: 0, top: 0 };
697
+ var origEvent = e.originalEvent;
698
+ var endEvnt = {
699
+ 'position': {
700
+ 'x': (settings.touch_capable) ? origEvent.changedTouches[0].pageX : e.pageX,
701
+ 'y': (settings.touch_capable) ? origEvent.changedTouches[0].pageY : e.pageY
702
+ },
703
+ 'offset': {
704
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - offset.left) : Math.round(e.pageX - offset.left),
705
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - offset.top) : Math.round(e.pageY - offset.top)
706
+ },
707
+ 'time': Date.now(),
708
+ 'target': e.target
709
+ };
710
+
711
+ // Calculate the swipe amount (normalized):
712
+ var xAmount = Math.abs(startEvnt.position.x - endEvnt.position.x),
713
+ yAmount = Math.abs(startEvnt.position.y - endEvnt.position.y);
714
+
715
+ // Read event data into our endEvnt:
716
+ if (xAmount > yAmount) {
717
+ if (startEvnt.position.x < endEvnt.position.x && (endEvnt.position.x - startEvnt.position.x > h_threshold)) {
718
+ swipedir = 'swiperight';
719
+ }
720
+ if (startEvnt.position.x > endEvnt.position.x && (startEvnt.position.x - endEvnt.position.x > h_threshold)) {
721
+ swipedir = 'swipeleft';
722
+ }
723
+ }
724
+ else {
725
+ if (startEvnt.position.y > endEvnt.position.y && (startEvnt.position.y - endEvnt.position.y > v_threshold)) {
726
+ swipedir = 'swipeup';
727
+ }
728
+ if (startEvnt.position.y < endEvnt.position.y && (endEvnt.position.y - startEvnt.position.y > v_threshold)) {
729
+ swipedir = 'swipedown';
730
+ }
731
+ }
732
+
733
+ var touchData = {
734
+ 'startEvnt': startEvnt,
735
+ 'endEvnt': endEvnt,
736
+ 'direction': swipedir.replace('swipe', ''),
737
+ 'xAmount': xAmount,
738
+ 'yAmount': yAmount,
739
+ 'duration': endEvnt.time - startEvnt.time
740
+ };
741
+ $this.trigger('swipeend', touchData);
742
+ }
743
+
744
+ started = false;
745
+ hasSwiped = false;
746
+ }
747
+
748
+ $this.on(settings.startevent, touchStart);
749
+ $this.on(settings.moveevent, touchMove);
750
+ $this.on(settings.endevent, touchEnd);
751
+ },
752
+
753
+ remove: function () {
754
+ $(this).off(settings.startevent, $(this).data.callee1).off(settings.moveevent, $(this).data.callee2).off(settings.endevent, $(this).data.callee3);
755
+ }
756
+ };
757
+
758
+ // scrollstart Event (also handles scrollend):
759
+ $.event.special.scrollstart = {
760
+ setup: function () {
761
+ var thisObject = this,
762
+ $this = $(thisObject),
763
+ scrolling,
764
+ timer;
765
+
766
+ function trigger(event, state) {
767
+ scrolling = state;
768
+ triggerCustomEvent(thisObject, scrolling ? 'scrollstart' : 'scrollend', event);
769
+ }
770
+
771
+ // iPhone triggers scroll after a small delay; use touchmove instead
772
+ $this.on(settings.scrollevent, function scrollFunc(event) {
773
+ $this.data('callee', scrollFunc);
774
+
775
+ if (!scrolling) {
776
+ trigger(event, true);
777
+ }
778
+
779
+ clearTimeout(timer);
780
+ timer = setTimeout(function () {
781
+ trigger(event, false);
782
+ }, 50);
783
+ });
784
+ },
785
+
786
+ remove: function () {
787
+ $(this).off(settings.scrollevent, $(this).data.callee);
788
+ }
789
+ };
790
+
791
+ // This is the orientation change (largely borrowed from jQuery Mobile):
792
+ var win = $(window),
793
+ special_event,
794
+ get_orientation,
795
+ last_orientation,
796
+ initial_orientation_is_landscape,
797
+ initial_orientation_is_default,
798
+ portrait_map = {
799
+ '0': true,
800
+ '180': true
801
+ };
802
+
803
+ if (settings.orientation_support) {
804
+ var ww = window.innerWidth || win.width(),
805
+ wh = window.innerHeight || win.height(),
806
+ landscape_threshold = 50;
807
+
808
+ initial_orientation_is_landscape = ww > wh && (ww - wh) > landscape_threshold;
809
+ initial_orientation_is_default = portrait_map[window.orientation];
810
+
811
+ if ((initial_orientation_is_landscape && initial_orientation_is_default) || (!initial_orientation_is_landscape && !initial_orientation_is_default)) {
812
+ portrait_map = {
813
+ '-90': true,
814
+ '90': true
815
+ };
816
+ }
817
+ }
818
+
819
+ $.event.special.orientationchange = special_event = {
820
+ setup: function () {
821
+ // If the event is supported natively, return false so that jQuery
822
+ // will on to the event using DOM methods.
823
+ if (settings.orientation_support) {
824
+ return false;
825
+ }
826
+
827
+ // Get the current orientation to avoid initial double-triggering.
828
+ last_orientation = get_orientation();
829
+
830
+ win.on('throttledresize', handler);
831
+ return true;
832
+ },
833
+ teardown: function () {
834
+ if (settings.orientation_support) {
835
+ return false;
836
+ }
837
+
838
+ win.off('throttledresize', handler);
839
+ return true;
840
+ },
841
+ add: function (handleObj) {
842
+ // Save a reference to the bound event handler.
843
+ var old_handler = handleObj.handler;
844
+
845
+ handleObj.handler = function (event) {
846
+ event.orientation = get_orientation();
847
+ return old_handler.apply(this, arguments);
848
+ };
849
+ }
850
+ };
851
+
852
+ // If the event is not supported natively, this handler will be bound to
853
+ // the window resize event to simulate the orientationchange event.
854
+
855
+ function handler() {
856
+ // Get the current orientation.
857
+ var orientation = get_orientation();
858
+
859
+ if (orientation !== last_orientation) {
860
+ // The orientation has changed, so trigger the orientationchange event.
861
+ last_orientation = orientation;
862
+ win.trigger("orientationchange");
863
+ }
864
+ }
865
+
866
+ $.event.special.orientationchange.orientation = get_orientation = function () {
867
+ var isPortrait = true,
868
+ elem = document.documentElement;
869
+
870
+ if (settings.orientation_support) {
871
+ isPortrait = portrait_map[window.orientation];
872
+ } else {
873
+ isPortrait = elem && elem.clientWidth / elem.clientHeight < 1.1;
874
+ }
875
+
876
+ return isPortrait ? 'portrait' : 'landscape';
877
+ };
878
+
879
+ // throttle Handler:
880
+ $.event.special.throttledresize = {
881
+ setup: function () {
882
+ $(this).on('resize', throttle_handler);
883
+ },
884
+ teardown: function () {
885
+ $(this).off('resize', throttle_handler);
886
+ }
887
+ };
888
+
889
+ var throttle = 250,
890
+ throttle_handler = function () {
891
+ curr = Date.now();
892
+ diff = curr - lastCall;
893
+
894
+ if (diff >= throttle) {
895
+ lastCall = curr;
896
+ $(this).trigger('throttledresize');
897
+
898
+ } else {
899
+ if (heldCall) {
900
+ window.clearTimeout(heldCall);
901
+ }
902
+
903
+ // Promise a held call will still execute
904
+ heldCall = window.setTimeout(handler, throttle - diff);
905
+ }
906
+ },
907
+ lastCall = 0,
908
+ heldCall,
909
+ curr,
910
+ diff;
911
+
912
+ // Trigger a custom event:
913
+
914
+ function triggerCustomEvent(obj, eventType, event, touchData) {
915
+ var originalType = event.type;
916
+ event.type = eventType;
917
+
918
+ $.event.dispatch.call(obj, event, touchData);
919
+ event.type = originalType;
920
+ }
921
+
922
+ // Correctly on anything we've overloaded:
923
+ $.each({
924
+ scrollend: 'scrollstart',
925
+ swipeup: 'swipe',
926
+ swiperight: 'swipe',
927
+ swipedown: 'swipe',
928
+ swipeleft: 'swipe',
929
+ swipeend: 'swipe',
930
+ tap2: 'tap',
931
+ taphold2: 'taphold'
932
+ }, function (e, srcE) {
933
+ $.event.special[e] = {
934
+ setup: function () {
935
+ $(this).on(srcE, $.noop);
936
+ }
937
+ };
938
+ });
939
+
940
+ }(jQuery));