ext_yarn 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +41 -47
- data/README.md +10 -0
- data/bin/yarn_after +12 -0
- data/lib/ext_yarn/version.rb +1 -1
- data/package.json +14 -13
- data/vendor/.yarn-integrity +35 -39
- data/vendor/bootswatch-sass/package.json +1 -1
- data/vendor/chart.js/dist/Chart.bundle.js +5754 -5711
- data/vendor/chart.js/dist/Chart.js +2118 -2046
- data/vendor/chart.js/package.json +1 -1
- data/vendor/chartkick/LICENSE.txt +1 -1
- data/vendor/chartkick/dist/chartkick.js +2239 -0
- data/vendor/chartkick/package.json +18 -8
- data/vendor/file-saver/dist/FileSaver.js +180 -0
- data/vendor/file-saver/package.json +16 -4
- data/vendor/jquery/dist/jquery.js +453 -342
- data/vendor/jquery/dist/jquery.slim.js +428 -319
- data/vendor/jquery/package.json +32 -21
- data/vendor/{tempusdominus-bootstrap-4 → jquery-touch-events}/LICENSE +21 -21
- data/vendor/jquery-touch-events/package.json +32 -0
- data/vendor/jquery-touch-events/src/jquery.mobile-events.js +920 -0
- data/vendor/jquery-ui-touch-punch-zoom-fork/jquery.ui.touch-punch.js +186 -0
- data/vendor/jquery-ujs/package.json +1 -1
- data/vendor/jquery-ujs/src/rails.js +14 -4
- data/vendor/{bootswatch → jquery.iframe-transport}/LICENSE +2 -2
- data/vendor/jquery.iframe-transport/jquery.iframe-transport.js +247 -0
- data/vendor/jquery.iframe-transport/package.json +28 -0
- data/vendor/jstz/dist/jstz.js +9 -1
- data/vendor/jstz/package.json +6 -4
- data/vendor/lazysizes/LICENSE +22 -0
- data/vendor/lazysizes/lazysizes-umd.js +706 -0
- data/vendor/lazysizes/lazysizes.js +703 -0
- data/vendor/lazysizes/package.json +65 -0
- data/vendor/lazysizes/plugins/artdirect/ls.artdirect.js +160 -0
- data/vendor/lazysizes/plugins/aspectratio/ls.aspectratio.js +209 -0
- data/vendor/lazysizes/plugins/attrchange/ls.attrchange.js +129 -0
- data/vendor/lazysizes/plugins/bgset/ls.bgset.js +198 -0
- data/vendor/lazysizes/plugins/blur-up/ls.blur-up.js +191 -0
- data/vendor/lazysizes/plugins/custommedia/ls.custommedia.js +75 -0
- data/vendor/lazysizes/plugins/fix-ios-sizes/fix-ios-sizes.js +80 -0
- data/vendor/lazysizes/plugins/include/ls.include.js +589 -0
- data/vendor/lazysizes/plugins/noscript/ls.noscript.js +87 -0
- data/vendor/lazysizes/plugins/object-fit/ls.object-fit.js +149 -0
- data/vendor/lazysizes/plugins/optimumx/ls.optimumx.js +273 -0
- data/vendor/lazysizes/plugins/parent-fit/ls.parent-fit.js +157 -0
- data/vendor/lazysizes/plugins/print/ls.print.js +51 -0
- data/vendor/lazysizes/plugins/progressive/ls.progressive.js +49 -0
- data/vendor/lazysizes/plugins/respimg/ls.respimg.js +314 -0
- data/vendor/lazysizes/plugins/rias/ls.rias.js +391 -0
- data/vendor/lazysizes/plugins/static-gecko-picture/ls.static-gecko-picture.js +82 -0
- data/vendor/lazysizes/plugins/twitter/ls.twitter.js +63 -0
- data/vendor/lazysizes/plugins/unload/ls.unload.js +155 -0
- data/vendor/lazysizes/plugins/unveilhooks/ls.unveilhooks.js +145 -0
- data/vendor/lazysizes/plugins/video-embed/ls.video-embed.js +114 -0
- data/vendor/lodash/core.js +75 -57
- data/vendor/lodash/lodash.js +105 -82
- data/vendor/lodash/package.json +2 -2
- data/vendor/moment/locale/af.js +58 -60
- data/vendor/moment/locale/ar-dz.js +45 -47
- data/vendor/moment/locale/ar-kw.js +45 -47
- data/vendor/moment/locale/ar-ly.js +106 -112
- data/vendor/moment/locale/ar-ma.js +45 -48
- data/vendor/moment/locale/ar-sa.js +88 -91
- data/vendor/moment/locale/ar-tn.js +45 -47
- data/vendor/moment/locale/ar.js +119 -128
- data/vendor/moment/locale/az.js +89 -91
- data/vendor/moment/locale/be.js +111 -115
- data/vendor/moment/locale/bg.js +73 -75
- data/vendor/moment/locale/bm.js +44 -47
- data/vendor/moment/locale/bn.js +103 -105
- data/vendor/moment/locale/bo.js +103 -105
- data/vendor/moment/locale/br.js +88 -90
- data/vendor/moment/locale/bs.js +133 -136
- data/vendor/moment/locale/ca.js +68 -70
- data/vendor/moment/locale/cs.js +160 -162
- data/vendor/moment/locale/cv.js +48 -50
- data/vendor/moment/locale/cy.js +64 -67
- data/vendor/moment/locale/da.js +46 -48
- data/vendor/moment/locale/de-at.js +61 -66
- data/vendor/moment/locale/de-ch.js +61 -65
- data/vendor/moment/locale/de.js +61 -65
- data/vendor/moment/locale/dv.js +82 -85
- data/vendor/moment/locale/el.js +82 -84
- data/vendor/moment/locale/en-au.js +53 -55
- data/vendor/moment/locale/en-ca.js +49 -51
- data/vendor/moment/locale/en-gb.js +53 -55
- data/vendor/moment/locale/en-ie.js +53 -55
- data/vendor/moment/locale/en-il.js +61 -0
- data/vendor/moment/locale/en-nz.js +53 -55
- data/vendor/moment/locale/eo.js +56 -60
- data/vendor/moment/locale/es-do.js +72 -73
- data/vendor/moment/locale/es-us.js +64 -66
- data/vendor/moment/locale/es.js +72 -74
- data/vendor/moment/locale/et.js +64 -67
- data/vendor/moment/locale/eu.js +52 -54
- data/vendor/moment/locale/fa.js +90 -93
- data/vendor/moment/locale/fi.js +93 -95
- data/vendor/moment/locale/fo.js +46 -48
- data/vendor/moment/locale/fr-ca.js +58 -60
- data/vendor/moment/locale/fr-ch.js +62 -64
- data/vendor/moment/locale/fr.js +66 -68
- data/vendor/moment/locale/fy.js +59 -61
- data/vendor/moment/locale/gd.js +57 -59
- data/vendor/moment/locale/gl.js +60 -62
- data/vendor/moment/locale/gom-latn.js +107 -109
- data/vendor/moment/locale/gu.js +108 -110
- data/vendor/moment/locale/he.js +77 -81
- data/vendor/moment/locale/hi.js +108 -110
- data/vendor/moment/locale/hr.js +136 -138
- data/vendor/moment/locale/hu.js +92 -94
- data/vendor/moment/locale/hy-am.js +78 -80
- data/vendor/moment/locale/id.js +67 -70
- data/vendor/moment/locale/is.js +110 -112
- data/vendor/moment/locale/it.js +53 -56
- data/vendor/moment/locale/ja.js +77 -67
- data/vendor/moment/locale/jv.js +67 -70
- data/vendor/moment/locale/ka.js +70 -72
- data/vendor/moment/locale/kk.js +72 -74
- data/vendor/moment/locale/km.js +96 -46
- data/vendor/moment/locale/kn.js +110 -112
- data/vendor/moment/locale/ko.js +66 -69
- data/vendor/moment/locale/ky.js +72 -75
- data/vendor/moment/locale/lb.js +113 -116
- data/vendor/moment/locale/lo.js +55 -57
- data/vendor/moment/locale/lt.js +100 -102
- data/vendor/moment/locale/lv.js +81 -84
- data/vendor/moment/locale/me.js +93 -95
- data/vendor/moment/locale/mi.js +50 -52
- data/vendor/moment/locale/mk.js +73 -75
- data/vendor/moment/locale/ml.js +66 -68
- data/vendor/moment/locale/mn.js +103 -0
- data/vendor/moment/locale/mr.js +140 -143
- data/vendor/moment/locale/ms-my.js +67 -70
- data/vendor/moment/locale/ms.js +67 -69
- data/vendor/moment/locale/mt.js +46 -48
- data/vendor/moment/locale/my.js +77 -82
- data/vendor/moment/locale/nb.js +48 -51
- data/vendor/moment/locale/ne.js +107 -109
- data/vendor/moment/locale/nl-be.js +68 -71
- data/vendor/moment/locale/nl.js +68 -71
- data/vendor/moment/locale/nn.js +46 -48
- data/vendor/moment/locale/pa-in.js +108 -110
- data/vendor/moment/locale/pl.js +104 -106
- data/vendor/moment/locale/pt-br.js +46 -48
- data/vendor/moment/locale/pt.js +50 -52
- data/vendor/moment/locale/ro.js +59 -62
- data/vendor/moment/locale/ru.js +153 -157
- data/vendor/moment/locale/sd.js +82 -84
- data/vendor/moment/locale/se.js +46 -49
- data/vendor/moment/locale/si.js +56 -58
- data/vendor/moment/locale/sk.js +138 -141
- data/vendor/moment/locale/sl.js +154 -156
- data/vendor/moment/locale/sq.js +54 -58
- data/vendor/moment/locale/sr-cyrl.js +93 -95
- data/vendor/moment/locale/sr.js +93 -95
- data/vendor/moment/locale/ss.js +72 -75
- data/vendor/moment/locale/sv.js +55 -57
- data/vendor/moment/locale/sw.js +45 -47
- data/vendor/moment/locale/ta.js +113 -116
- data/vendor/moment/locale/te.js +74 -76
- data/vendor/moment/locale/tet.js +53 -56
- data/vendor/moment/locale/tg.js +115 -0
- data/vendor/moment/locale/th.js +52 -54
- data/vendor/moment/locale/tl-ph.js +48 -50
- data/vendor/moment/locale/tlh.js +101 -103
- data/vendor/moment/locale/tr.js +80 -78
- data/vendor/moment/locale/tzl.js +75 -78
- data/vendor/moment/locale/tzm-latn.js +44 -46
- data/vendor/moment/locale/tzm.js +44 -46
- data/vendor/moment/locale/ug-cn.js +118 -0
- data/vendor/moment/locale/uk.js +129 -132
- data/vendor/moment/locale/ur.js +82 -85
- data/vendor/moment/locale/uz-latn.js +44 -46
- data/vendor/moment/locale/uz.js +44 -46
- data/vendor/moment/locale/vi.js +64 -66
- data/vendor/moment/locale/x-pseudo.js +54 -56
- data/vendor/moment/locale/yo.js +46 -48
- data/vendor/moment/locale/zh-cn.js +95 -98
- data/vendor/moment/locale/zh-hk.js +88 -92
- data/vendor/moment/locale/zh-tw.js +88 -91
- data/vendor/moment/min/locales.js +9701 -9581
- data/vendor/moment/min/moment-with-locales.js +13426 -13335
- data/vendor/moment/moment.js +3780 -3809
- data/vendor/moment/package.json +10 -10
- data/vendor/moment-timezone/builds/moment-timezone-with-data-2012-2022.js +43 -35
- data/vendor/moment-timezone/builds/moment-timezone-with-data.js +290 -282
- data/vendor/moment-timezone/moment-timezone-utils.js +12 -10
- data/vendor/moment-timezone/moment-timezone.js +15 -7
- data/vendor/moment-timezone/package.json +5 -3
- data/vendor/{bootstrap → pako}/LICENSE +2 -3
- data/vendor/pako/dist/pako.js +6811 -0
- data/vendor/pako/dist/pako_deflate.js +3995 -0
- data/vendor/pako/dist/pako_inflate.js +3295 -0
- data/vendor/pako/package.json +48 -0
- data/yarn.lock +51 -78
- metadata +45 -155
- data/vendor/bootstrap/dist/js/bootstrap.bundle.js +0 -6461
- data/vendor/bootstrap/dist/js/bootstrap.js +0 -3944
- data/vendor/bootstrap/js/dist/alert.js +0 -204
- data/vendor/bootstrap/js/dist/button.js +0 -192
- data/vendor/bootstrap/js/dist/carousel.js +0 -567
- data/vendor/bootstrap/js/dist/collapse.js +0 -431
- data/vendor/bootstrap/js/dist/dropdown.js +0 -552
- data/vendor/bootstrap/js/dist/index.js +0 -23
- data/vendor/bootstrap/js/dist/modal.js +0 -634
- data/vendor/bootstrap/js/dist/popover.js +0 -266
- data/vendor/bootstrap/js/dist/scrollspy.js +0 -379
- data/vendor/bootstrap/js/dist/tab.js +0 -278
- data/vendor/bootstrap/js/dist/tooltip.js +0 -734
- data/vendor/bootstrap/js/dist/util.js +0 -144
- data/vendor/bootstrap/package.json +0 -217
- data/vendor/bootstrap/scss/_alert.scss +0 -51
- data/vendor/bootstrap/scss/_badge.scss +0 -47
- data/vendor/bootstrap/scss/_breadcrumb.scss +0 -41
- data/vendor/bootstrap/scss/_button-group.scss +0 -172
- data/vendor/bootstrap/scss/_buttons.scss +0 -143
- data/vendor/bootstrap/scss/_card.scss +0 -301
- data/vendor/bootstrap/scss/_carousel.scss +0 -236
- data/vendor/bootstrap/scss/_close.scss +0 -35
- data/vendor/bootstrap/scss/_code.scss +0 -48
- data/vendor/bootstrap/scss/_custom-forms.scss +0 -433
- data/vendor/bootstrap/scss/_dropdown.scss +0 -166
- data/vendor/bootstrap/scss/_forms.scss +0 -333
- data/vendor/bootstrap/scss/_functions.scss +0 -86
- data/vendor/bootstrap/scss/_grid.scss +0 -52
- data/vendor/bootstrap/scss/_images.scss +0 -42
- data/vendor/bootstrap/scss/_input-group.scss +0 -173
- data/vendor/bootstrap/scss/_jumbotron.scss +0 -16
- data/vendor/bootstrap/scss/_list-group.scss +0 -115
- data/vendor/bootstrap/scss/_media.scss +0 -8
- data/vendor/bootstrap/scss/_mixins.scss +0 -41
- data/vendor/bootstrap/scss/_modal.scss +0 -180
- data/vendor/bootstrap/scss/_nav.scss +0 -118
- data/vendor/bootstrap/scss/_navbar.scss +0 -299
- data/vendor/bootstrap/scss/_pagination.scss +0 -78
- data/vendor/bootstrap/scss/_popover.scss +0 -183
- data/vendor/bootstrap/scss/_print.scss +0 -141
- data/vendor/bootstrap/scss/_progress.scss +0 -34
- data/vendor/bootstrap/scss/_reboot.scss +0 -483
- data/vendor/bootstrap/scss/_root.scss +0 -19
- data/vendor/bootstrap/scss/_tables.scss +0 -187
- data/vendor/bootstrap/scss/_tooltip.scss +0 -115
- data/vendor/bootstrap/scss/_transitions.scss +0 -22
- data/vendor/bootstrap/scss/_type.scss +0 -125
- data/vendor/bootstrap/scss/_utilities.scss +0 -15
- data/vendor/bootstrap/scss/_variables.scss +0 -952
- data/vendor/bootstrap/scss/bootstrap-grid.scss +0 -32
- data/vendor/bootstrap/scss/bootstrap-reboot.scss +0 -12
- data/vendor/bootstrap/scss/bootstrap.scss +0 -42
- data/vendor/bootstrap/scss/mixins/_alert.scss +0 -13
- data/vendor/bootstrap/scss/mixins/_background-variant.scss +0 -21
- data/vendor/bootstrap/scss/mixins/_badge.scss +0 -12
- data/vendor/bootstrap/scss/mixins/_border-radius.scss +0 -35
- data/vendor/bootstrap/scss/mixins/_box-shadow.scss +0 -5
- data/vendor/bootstrap/scss/mixins/_breakpoints.scss +0 -123
- data/vendor/bootstrap/scss/mixins/_buttons.scss +0 -109
- data/vendor/bootstrap/scss/mixins/_caret.scss +0 -66
- data/vendor/bootstrap/scss/mixins/_clearfix.scss +0 -7
- data/vendor/bootstrap/scss/mixins/_float.scss +0 -11
- data/vendor/bootstrap/scss/mixins/_forms.scss +0 -147
- data/vendor/bootstrap/scss/mixins/_gradients.scss +0 -45
- data/vendor/bootstrap/scss/mixins/_grid-framework.scss +0 -67
- data/vendor/bootstrap/scss/mixins/_grid.scss +0 -52
- data/vendor/bootstrap/scss/mixins/_hover.scss +0 -37
- data/vendor/bootstrap/scss/mixins/_image.scss +0 -36
- data/vendor/bootstrap/scss/mixins/_list-group.scss +0 -21
- data/vendor/bootstrap/scss/mixins/_lists.scss +0 -7
- data/vendor/bootstrap/scss/mixins/_nav-divider.scss +0 -10
- data/vendor/bootstrap/scss/mixins/_pagination.scss +0 -22
- data/vendor/bootstrap/scss/mixins/_reset-text.scss +0 -17
- data/vendor/bootstrap/scss/mixins/_resize.scss +0 -6
- data/vendor/bootstrap/scss/mixins/_screen-reader.scss +0 -33
- data/vendor/bootstrap/scss/mixins/_size.scss +0 -6
- data/vendor/bootstrap/scss/mixins/_table-row.scss +0 -30
- data/vendor/bootstrap/scss/mixins/_text-emphasis.scss +0 -14
- data/vendor/bootstrap/scss/mixins/_text-hide.scss +0 -13
- data/vendor/bootstrap/scss/mixins/_text-truncate.scss +0 -8
- data/vendor/bootstrap/scss/mixins/_transition.scss +0 -13
- data/vendor/bootstrap/scss/mixins/_visibility.scss +0 -7
- data/vendor/bootstrap/scss/utilities/_align.scss +0 -8
- data/vendor/bootstrap/scss/utilities/_background.scss +0 -19
- data/vendor/bootstrap/scss/utilities/_borders.scss +0 -59
- data/vendor/bootstrap/scss/utilities/_clearfix.scss +0 -3
- data/vendor/bootstrap/scss/utilities/_display.scss +0 -38
- data/vendor/bootstrap/scss/utilities/_embed.scss +0 -52
- data/vendor/bootstrap/scss/utilities/_flex.scss +0 -51
- data/vendor/bootstrap/scss/utilities/_float.scss +0 -9
- data/vendor/bootstrap/scss/utilities/_position.scss +0 -37
- data/vendor/bootstrap/scss/utilities/_screenreaders.scss +0 -11
- data/vendor/bootstrap/scss/utilities/_shadows.scss +0 -6
- data/vendor/bootstrap/scss/utilities/_sizing.scss +0 -12
- data/vendor/bootstrap/scss/utilities/_spacing.scss +0 -51
- data/vendor/bootstrap/scss/utilities/_text.scss +0 -58
- data/vendor/bootstrap/scss/utilities/_visibility.scss +0 -11
- data/vendor/bootswatch/dist/cerulean/_bootswatch.scss +0 -99
- data/vendor/bootswatch/dist/cerulean/_variables.scss +0 -57
- data/vendor/bootswatch/dist/cosmo/_bootswatch.scss +0 -38
- data/vendor/bootswatch/dist/cosmo/_variables.scss +0 -68
- data/vendor/bootswatch/dist/cyborg/_bootswatch.scss +0 -230
- data/vendor/bootswatch/dist/cyborg/_variables.scss +0 -173
- data/vendor/bootswatch/dist/darkly/_bootswatch.scss +0 -186
- data/vendor/bootswatch/dist/darkly/_variables.scss +0 -178
- data/vendor/bootswatch/dist/flatly/_bootswatch.scss +0 -185
- data/vendor/bootswatch/dist/flatly/_variables.scss +0 -113
- data/vendor/bootswatch/dist/journal/_bootswatch.scss +0 -73
- data/vendor/bootswatch/dist/journal/_variables.scss +0 -60
- data/vendor/bootswatch/dist/litera/_bootswatch.scss +0 -212
- data/vendor/bootswatch/dist/litera/_variables.scss +0 -77
- data/vendor/bootswatch/dist/lumen/_bootswatch.scss +0 -429
- data/vendor/bootswatch/dist/lumen/_variables.scss +0 -82
- data/vendor/bootswatch/dist/lux/_bootswatch.scss +0 -157
- data/vendor/bootswatch/dist/lux/_variables.scss +0 -120
- data/vendor/bootswatch/dist/materia/_bootswatch.scss +0 -677
- data/vendor/bootswatch/dist/materia/_variables.scss +0 -131
- data/vendor/bootswatch/dist/minty/_bootswatch.scss +0 -258
- data/vendor/bootswatch/dist/minty/_variables.scss +0 -97
- data/vendor/bootswatch/dist/pulse/_bootswatch.scss +0 -154
- data/vendor/bootswatch/dist/pulse/_variables.scss +0 -100
- data/vendor/bootswatch/dist/sandstone/_bootswatch.scss +0 -235
- data/vendor/bootswatch/dist/sandstone/_variables.scss +0 -143
- data/vendor/bootswatch/dist/simplex/_bootswatch.scss +0 -130
- data/vendor/bootswatch/dist/simplex/_variables.scss +0 -108
- data/vendor/bootswatch/dist/sketchy/_bootswatch.scss +0 -411
- data/vendor/bootswatch/dist/sketchy/_variables.scss +0 -164
- data/vendor/bootswatch/dist/slate/_bootswatch.scss +0 -425
- data/vendor/bootswatch/dist/slate/_variables.scss +0 -160
- data/vendor/bootswatch/dist/solar/_bootswatch.scss +0 -119
- data/vendor/bootswatch/dist/solar/_variables.scss +0 -175
- data/vendor/bootswatch/dist/spacelab/_bootswatch.scss +0 -167
- data/vendor/bootswatch/dist/spacelab/_variables.scss +0 -63
- data/vendor/bootswatch/dist/superhero/_bootswatch.scss +0 -200
- data/vendor/bootswatch/dist/superhero/_variables.scss +0 -148
- data/vendor/bootswatch/dist/united/_bootswatch.scss +0 -26
- data/vendor/bootswatch/dist/united/_variables.scss +0 -53
- data/vendor/bootswatch/dist/yeti/_bootswatch.scss +0 -468
- data/vendor/bootswatch/dist/yeti/_variables.scss +0 -110
- data/vendor/bootswatch/package.json +0 -38
- data/vendor/chartkick/chartkick.js +0 -1872
- data/vendor/file-saver/FileSaver.js +0 -188
- data/vendor/popper.js/dist/umd/popper-utils.js +0 -1133
- data/vendor/popper.js/dist/umd/popper.js +0 -2540
- data/vendor/popper.js/package.json +0 -54
- data/vendor/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.js +0 -2779
- data/vendor/tempusdominus-bootstrap-4/package.json +0 -79
- data/vendor/tempusdominus-bootstrap-4/src/sass/_tempusdominus-bootstrap-4.scss +0 -342
- data/vendor/tempusdominus-bootstrap-4/src/sass/tempusdominus-bootstrap-4-build.scss +0 -12
@@ -0,0 +1,920 @@
|
|
1
|
+
/*!
|
2
|
+
* jQuery Mobile Events
|
3
|
+
* by Ben Major
|
4
|
+
*
|
5
|
+
* Copyright 2011-2017, 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( range ) {
|
94
|
+
if( typeof range !== '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 origEvent = e.originalEvent,
|
122
|
+
touchData = {
|
123
|
+
'position': {
|
124
|
+
'x': ((settings.touch_capable) ? origEvent.touches[0].pageX : e.pageX),
|
125
|
+
'y': (settings.touch_capable) ? origEvent.touches[0].pageY : e.pageY
|
126
|
+
},
|
127
|
+
'offset': {
|
128
|
+
'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
|
129
|
+
'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
|
130
|
+
},
|
131
|
+
'time': Date.now(),
|
132
|
+
'target': e.target
|
133
|
+
};
|
134
|
+
|
135
|
+
triggerCustomEvent(thisObject, 'tapstart', e, touchData);
|
136
|
+
return true;
|
137
|
+
});
|
138
|
+
},
|
139
|
+
|
140
|
+
remove: function () {
|
141
|
+
$(this).off(settings.startevent, $(this).data.callee);
|
142
|
+
}
|
143
|
+
};
|
144
|
+
|
145
|
+
// tapmove Event:
|
146
|
+
$.event.special.tapmove = {
|
147
|
+
setup: function() {
|
148
|
+
var thisObject = this,
|
149
|
+
$this = $(thisObject);
|
150
|
+
|
151
|
+
$this.on(settings.moveevent, function tapMoveFunc(e) {
|
152
|
+
$this.data('callee', tapMoveFunc);
|
153
|
+
|
154
|
+
var origEvent = e.originalEvent,
|
155
|
+
touchData = {
|
156
|
+
'position': {
|
157
|
+
'x': ((settings.touch_capable) ? origEvent.touches[0].pageX : e.pageX),
|
158
|
+
'y': (settings.touch_capable) ? origEvent.touches[0].pageY : e.pageY
|
159
|
+
},
|
160
|
+
'offset': {
|
161
|
+
'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
|
162
|
+
'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
|
163
|
+
},
|
164
|
+
'time': Date.now(),
|
165
|
+
'target': e.target
|
166
|
+
};
|
167
|
+
|
168
|
+
triggerCustomEvent(thisObject, 'tapmove', e, touchData);
|
169
|
+
return true;
|
170
|
+
});
|
171
|
+
},
|
172
|
+
remove: function() {
|
173
|
+
$(this).off(settings.moveevent, $(this).data.callee);
|
174
|
+
}
|
175
|
+
};
|
176
|
+
|
177
|
+
// tapend Event:
|
178
|
+
$.event.special.tapend = {
|
179
|
+
setup: function () {
|
180
|
+
var thisObject = this,
|
181
|
+
$this = $(thisObject);
|
182
|
+
|
183
|
+
$this.on(settings.endevent, function tapEndFunc(e) {
|
184
|
+
// Touch event data:
|
185
|
+
$this.data('callee', tapEndFunc);
|
186
|
+
|
187
|
+
var origEvent = e.originalEvent;
|
188
|
+
var touchData = {
|
189
|
+
'position': {
|
190
|
+
'x': (settings.touch_capable) ? origEvent.changedTouches[0].pageX : e.pageX,
|
191
|
+
'y': (settings.touch_capable) ? origEvent.changedTouches[0].pageY : e.pageY
|
192
|
+
},
|
193
|
+
'offset': {
|
194
|
+
'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
|
195
|
+
'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
|
196
|
+
},
|
197
|
+
'time': Date.now(),
|
198
|
+
'target': e.target
|
199
|
+
};
|
200
|
+
triggerCustomEvent(thisObject, 'tapend', e, touchData);
|
201
|
+
return true;
|
202
|
+
});
|
203
|
+
},
|
204
|
+
remove: function () {
|
205
|
+
$(this).off(settings.endevent, $(this).data.callee);
|
206
|
+
}
|
207
|
+
};
|
208
|
+
|
209
|
+
// taphold Event:
|
210
|
+
$.event.special.taphold = {
|
211
|
+
setup: function () {
|
212
|
+
var thisObject = this,
|
213
|
+
$this = $(thisObject),
|
214
|
+
origTarget,
|
215
|
+
start_pos = {
|
216
|
+
x: 0,
|
217
|
+
y: 0
|
218
|
+
},
|
219
|
+
end_x = 0,
|
220
|
+
end_y = 0;
|
221
|
+
|
222
|
+
$this.on(settings.startevent, function tapHoldFunc1(e) {
|
223
|
+
if (e.which && e.which !== 1) {
|
224
|
+
return false;
|
225
|
+
} else {
|
226
|
+
$this.data('tapheld', false);
|
227
|
+
origTarget = e.target;
|
228
|
+
|
229
|
+
var origEvent = e.originalEvent;
|
230
|
+
var start_time = Date.now(),
|
231
|
+
startPosition = {
|
232
|
+
'x': (settings.touch_capable) ? origEvent.touches[0].pageX : e.pageX,
|
233
|
+
'y': (settings.touch_capable) ? origEvent.touches[0].pageY : e.pageY
|
234
|
+
},
|
235
|
+
startOffset = {
|
236
|
+
'x': (settings.touch_capable) ? origEvent.touches[0].pageX - origEvent.touches[0].target.offsetLeft : e.offsetX,
|
237
|
+
'y': (settings.touch_capable) ? origEvent.touches[0].pageY - origEvent.touches[0].target.offsetTop : e.offsetY
|
238
|
+
};
|
239
|
+
|
240
|
+
start_pos.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
|
241
|
+
start_pos.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
|
242
|
+
|
243
|
+
end_x = start_pos.x;
|
244
|
+
end_y = start_pos.y;
|
245
|
+
|
246
|
+
// Get the element's threshold:
|
247
|
+
var ele_threshold = ($this.parent().data('threshold')) ? $this.parent().data('threshold') : $this.data('threshold'),
|
248
|
+
threshold = (typeof ele_threshold !== 'undefined' && ele_threshold !== false && parseInt(ele_threshold)) ? parseInt(ele_threshold) : settings.taphold_threshold;
|
249
|
+
|
250
|
+
settings.hold_timer = window.setTimeout(function () {
|
251
|
+
|
252
|
+
var diff_x = (start_pos.x - end_x),
|
253
|
+
diff_y = (start_pos.y - end_y);
|
254
|
+
|
255
|
+
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))) {
|
256
|
+
$this.data('tapheld', true);
|
257
|
+
|
258
|
+
var end_time = Date.now();
|
259
|
+
|
260
|
+
var duration = end_time - start_time,
|
261
|
+
touches = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches : [ e ],
|
262
|
+
touchData = [ ];
|
263
|
+
|
264
|
+
for( var i = 0; i < touches.length; i++)
|
265
|
+
{
|
266
|
+
var touch = {
|
267
|
+
'position': {
|
268
|
+
'x': (settings.touch_capable) ? origEvent.changedTouches[i].pageX : e.pageX,
|
269
|
+
'y': (settings.touch_capable) ? origEvent.changedTouches[i].pageY : e.pageY
|
270
|
+
},
|
271
|
+
'offset': {
|
272
|
+
'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[i].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
|
273
|
+
'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[i].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
|
274
|
+
},
|
275
|
+
'time': Date.now(),
|
276
|
+
'target': e.target,
|
277
|
+
'duration': duration
|
278
|
+
};
|
279
|
+
|
280
|
+
touchData.push( touch );
|
281
|
+
}
|
282
|
+
|
283
|
+
var evt_name = ( touches.length == 2 ) ? 'taphold2' : 'taphold';
|
284
|
+
|
285
|
+
$this.data('callee1', tapHoldFunc1);
|
286
|
+
|
287
|
+
triggerCustomEvent(thisObject, evt_name, e, touchData);
|
288
|
+
}
|
289
|
+
}, threshold);
|
290
|
+
|
291
|
+
return true;
|
292
|
+
}
|
293
|
+
}).on(settings.endevent, function tapHoldFunc2() {
|
294
|
+
$this.data('callee2', tapHoldFunc2);
|
295
|
+
$this.data('tapheld', false);
|
296
|
+
window.clearTimeout(settings.hold_timer);
|
297
|
+
})
|
298
|
+
.on(settings.moveevent, function tapHoldFunc3(e) {
|
299
|
+
$this.data('callee3', tapHoldFunc3);
|
300
|
+
|
301
|
+
end_x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
|
302
|
+
end_y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
|
303
|
+
});
|
304
|
+
},
|
305
|
+
|
306
|
+
remove: function () {
|
307
|
+
$(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2).off(settings.moveevent, $(this).data.callee3);
|
308
|
+
}
|
309
|
+
};
|
310
|
+
|
311
|
+
// doubletap Event:
|
312
|
+
$.event.special.doubletap = {
|
313
|
+
setup: function () {
|
314
|
+
var thisObject = this,
|
315
|
+
$this = $(thisObject),
|
316
|
+
origTarget,
|
317
|
+
action,
|
318
|
+
firstTap = null,
|
319
|
+
origEvent,
|
320
|
+
cooloff,
|
321
|
+
cooling = false;
|
322
|
+
|
323
|
+
$this.on(settings.startevent, function doubleTapFunc1(e) {
|
324
|
+
if (e.which && e.which !== 1) {
|
325
|
+
return false;
|
326
|
+
}
|
327
|
+
|
328
|
+
$this.data('doubletapped', false);
|
329
|
+
origTarget = e.target;
|
330
|
+
$this.data('callee1', doubleTapFunc1);
|
331
|
+
|
332
|
+
origEvent = e.originalEvent;
|
333
|
+
if (!firstTap) {
|
334
|
+
firstTap = {
|
335
|
+
'position': {
|
336
|
+
'x': (settings.touch_capable) ? origEvent.touches[0].pageX : e.pageX,
|
337
|
+
'y': (settings.touch_capable) ? origEvent.touches[0].pageY : e.pageY
|
338
|
+
},
|
339
|
+
'offset': {
|
340
|
+
'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
|
341
|
+
'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
|
342
|
+
},
|
343
|
+
'time': Date.now(),
|
344
|
+
'target': e.target,
|
345
|
+
'element': e.originalEvent.srcElement,
|
346
|
+
'index': $(e.target).index()
|
347
|
+
};
|
348
|
+
}
|
349
|
+
|
350
|
+
return true;
|
351
|
+
}).on(settings.endevent, function doubleTapFunc2(e) {
|
352
|
+
|
353
|
+
var now = Date.now();
|
354
|
+
var lastTouch = $this.data('lastTouch') || now + 1;
|
355
|
+
var delta = now - lastTouch;
|
356
|
+
window.clearTimeout(action);
|
357
|
+
$this.data('callee2', doubleTapFunc2);
|
358
|
+
|
359
|
+
if (delta < settings.doubletap_int && ($(e.target).index() == firstTap.index) && delta > 100) {
|
360
|
+
$this.data('doubletapped', true);
|
361
|
+
window.clearTimeout(settings.tap_timer);
|
362
|
+
|
363
|
+
// Now get the current event:
|
364
|
+
var lastTap = {
|
365
|
+
'position': {
|
366
|
+
'x': (settings.touch_capable) ? e.originalEvent.changedTouches[0].pageX : e.pageX,
|
367
|
+
'y': (settings.touch_capable) ? e.originalEvent.changedTouches[0].pageY : e.pageY
|
368
|
+
},
|
369
|
+
'offset': {
|
370
|
+
'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
|
371
|
+
'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
|
372
|
+
},
|
373
|
+
'time': Date.now(),
|
374
|
+
'target': e.target,
|
375
|
+
'element': e.originalEvent.srcElement,
|
376
|
+
'index': $(e.target).index()
|
377
|
+
};
|
378
|
+
|
379
|
+
var touchData = {
|
380
|
+
'firstTap': firstTap,
|
381
|
+
'secondTap': lastTap,
|
382
|
+
'interval': lastTap.time - firstTap.time
|
383
|
+
};
|
384
|
+
|
385
|
+
if (!cooling) {
|
386
|
+
triggerCustomEvent(thisObject, 'doubletap', e, touchData);
|
387
|
+
firstTap = null;
|
388
|
+
}
|
389
|
+
|
390
|
+
cooling = true;
|
391
|
+
|
392
|
+
cooloff = window.setTimeout(function () {
|
393
|
+
cooling = false;
|
394
|
+
}, settings.doubletap_int);
|
395
|
+
|
396
|
+
} else {
|
397
|
+
$this.data('lastTouch', now);
|
398
|
+
action = window.setTimeout(function () {
|
399
|
+
firstTap = null;
|
400
|
+
window.clearTimeout(action);
|
401
|
+
}, settings.doubletap_int, [e]);
|
402
|
+
}
|
403
|
+
$this.data('lastTouch', now);
|
404
|
+
});
|
405
|
+
},
|
406
|
+
remove: function () {
|
407
|
+
$(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2);
|
408
|
+
}
|
409
|
+
};
|
410
|
+
|
411
|
+
// singletap Event:
|
412
|
+
// This is used in conjuction with doubletap when both events are needed on the same element
|
413
|
+
$.event.special.singletap = {
|
414
|
+
setup: function () {
|
415
|
+
var thisObject = this,
|
416
|
+
$this = $(thisObject),
|
417
|
+
origTarget = null,
|
418
|
+
startTime = null,
|
419
|
+
start_pos = {
|
420
|
+
x: 0,
|
421
|
+
y: 0
|
422
|
+
};
|
423
|
+
|
424
|
+
$this.on(settings.startevent, function singleTapFunc1(e) {
|
425
|
+
if (e.which && e.which !== 1) {
|
426
|
+
return false;
|
427
|
+
} else {
|
428
|
+
startTime = Date.now();
|
429
|
+
origTarget = e.target;
|
430
|
+
$this.data('callee1', singleTapFunc1);
|
431
|
+
|
432
|
+
// Get the start x and y position:
|
433
|
+
start_pos.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
|
434
|
+
start_pos.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
|
435
|
+
|
436
|
+
return true;
|
437
|
+
}
|
438
|
+
}).on(settings.endevent, function singleTapFunc2(e) {
|
439
|
+
$this.data('callee2', singleTapFunc2);
|
440
|
+
if (e.target == origTarget) {
|
441
|
+
|
442
|
+
// Get the end point:
|
443
|
+
var end_pos_x = (e.originalEvent.changedTouches) ? e.originalEvent.changedTouches[0].pageX : e.pageX,
|
444
|
+
end_pos_y = (e.originalEvent.changedTouches) ? e.originalEvent.changedTouches[0].pageY : e.pageY;
|
445
|
+
|
446
|
+
// We need to check if it was a taphold:
|
447
|
+
|
448
|
+
settings.tap_timer = window.setTimeout(function () {
|
449
|
+
|
450
|
+
var diff_x = (start_pos.x - end_pos_x), diff_y = (start_pos.y - end_pos_y);
|
451
|
+
|
452
|
+
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))) {
|
453
|
+
|
454
|
+
var origEvent = e.originalEvent;
|
455
|
+
var touchData = {
|
456
|
+
'position': {
|
457
|
+
'x': (settings.touch_capable) ? origEvent.changedTouches[0].pageX : e.pageX,
|
458
|
+
'y': (settings.touch_capable) ? origEvent.changedTouches[0].pageY : e.pageY
|
459
|
+
},
|
460
|
+
'offset': {
|
461
|
+
'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
|
462
|
+
'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
|
463
|
+
},
|
464
|
+
'time': Date.now(),
|
465
|
+
'target': e.target
|
466
|
+
};
|
467
|
+
|
468
|
+
// Was it a taphold?
|
469
|
+
if((touchData.time - startTime) < settings.taphold_threshold)
|
470
|
+
{
|
471
|
+
triggerCustomEvent(thisObject, 'singletap', e, touchData);
|
472
|
+
}
|
473
|
+
}
|
474
|
+
}, settings.doubletap_int);
|
475
|
+
}
|
476
|
+
});
|
477
|
+
},
|
478
|
+
|
479
|
+
remove: function () {
|
480
|
+
$(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2);
|
481
|
+
}
|
482
|
+
};
|
483
|
+
|
484
|
+
// tap Event:
|
485
|
+
$.event.special.tap = {
|
486
|
+
setup: function () {
|
487
|
+
var thisObject = this,
|
488
|
+
$this = $(thisObject),
|
489
|
+
started = false,
|
490
|
+
origTarget = null,
|
491
|
+
start_time,
|
492
|
+
start_pos = {
|
493
|
+
x: 0,
|
494
|
+
y: 0
|
495
|
+
},
|
496
|
+
touches;
|
497
|
+
|
498
|
+
$this.on(settings.startevent, function tapFunc1(e) {
|
499
|
+
$this.data('callee1', tapFunc1);
|
500
|
+
|
501
|
+
if( e.which && e.which !== 1 )
|
502
|
+
{
|
503
|
+
return false;
|
504
|
+
}
|
505
|
+
else
|
506
|
+
{
|
507
|
+
started = true;
|
508
|
+
start_pos.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
|
509
|
+
start_pos.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
|
510
|
+
start_time = Date.now();
|
511
|
+
origTarget = e.target;
|
512
|
+
|
513
|
+
touches = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches : [ e ];
|
514
|
+
return true;
|
515
|
+
}
|
516
|
+
}).on(settings.endevent, function tapFunc2(e) {
|
517
|
+
$this.data('callee2', tapFunc2);
|
518
|
+
|
519
|
+
// Only trigger if they've started, and the target matches:
|
520
|
+
var end_x = (e.originalEvent.targetTouches) ? e.originalEvent.changedTouches[0].pageX : e.pageX,
|
521
|
+
end_y = (e.originalEvent.targetTouches) ? e.originalEvent.changedTouches[0].pageY : e.pageY,
|
522
|
+
diff_x = (start_pos.x - end_x),
|
523
|
+
diff_y = (start_pos.y - end_y),
|
524
|
+
eventName;
|
525
|
+
|
526
|
+
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))) {
|
527
|
+
var origEvent = e.originalEvent;
|
528
|
+
var touchData = [ ];
|
529
|
+
|
530
|
+
for( var i = 0; i < touches.length; i++)
|
531
|
+
{
|
532
|
+
var touch = {
|
533
|
+
'position': {
|
534
|
+
'x': (settings.touch_capable) ? origEvent.changedTouches[i].pageX : e.pageX,
|
535
|
+
'y': (settings.touch_capable) ? origEvent.changedTouches[i].pageY : e.pageY
|
536
|
+
},
|
537
|
+
'offset': {
|
538
|
+
'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[i].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
|
539
|
+
'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[i].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
|
540
|
+
},
|
541
|
+
'time': Date.now(),
|
542
|
+
'target': e.target
|
543
|
+
};
|
544
|
+
|
545
|
+
touchData.push( touch );
|
546
|
+
}
|
547
|
+
|
548
|
+
var evt_name = ( touches.length == 2 ) ? 'tap2' : 'tap';
|
549
|
+
|
550
|
+
triggerCustomEvent(thisObject, evt_name, e, touchData);
|
551
|
+
}
|
552
|
+
});
|
553
|
+
},
|
554
|
+
|
555
|
+
remove: function () {
|
556
|
+
$(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2);
|
557
|
+
}
|
558
|
+
};
|
559
|
+
|
560
|
+
// swipe Event (also handles swipeup, swiperight, swipedown and swipeleft):
|
561
|
+
$.event.special.swipe = {
|
562
|
+
setup: function () {
|
563
|
+
var thisObject = this,
|
564
|
+
$this = $(thisObject),
|
565
|
+
started = false,
|
566
|
+
hasSwiped = false,
|
567
|
+
originalCoord = {
|
568
|
+
x: 0,
|
569
|
+
y: 0
|
570
|
+
},
|
571
|
+
finalCoord = {
|
572
|
+
x: 0,
|
573
|
+
y: 0
|
574
|
+
},
|
575
|
+
startEvnt;
|
576
|
+
|
577
|
+
// Screen touched, store the original coordinate
|
578
|
+
|
579
|
+
function touchStart(e) {
|
580
|
+
$this = $(e.currentTarget);
|
581
|
+
$this.data('callee1', touchStart);
|
582
|
+
originalCoord.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
|
583
|
+
originalCoord.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
|
584
|
+
finalCoord.x = originalCoord.x;
|
585
|
+
finalCoord.y = originalCoord.y;
|
586
|
+
started = true;
|
587
|
+
var origEvent = e.originalEvent;
|
588
|
+
// Read event data into our startEvt:
|
589
|
+
startEvnt = {
|
590
|
+
'position': {
|
591
|
+
'x': (settings.touch_capable) ? origEvent.touches[0].pageX : e.pageX,
|
592
|
+
'y': (settings.touch_capable) ? origEvent.touches[0].pageY : e.pageY
|
593
|
+
},
|
594
|
+
'offset': {
|
595
|
+
'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
|
596
|
+
'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
|
597
|
+
},
|
598
|
+
'time': Date.now(),
|
599
|
+
'target': e.target
|
600
|
+
};
|
601
|
+
}
|
602
|
+
|
603
|
+
// Store coordinates as finger is swiping
|
604
|
+
|
605
|
+
function touchMove(e) {
|
606
|
+
$this = $(e.currentTarget);
|
607
|
+
$this.data('callee2', touchMove);
|
608
|
+
finalCoord.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
|
609
|
+
finalCoord.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
|
610
|
+
|
611
|
+
var swipedir;
|
612
|
+
|
613
|
+
// We need to check if the element to which the event was bound contains a data-xthreshold | data-vthreshold:
|
614
|
+
var ele_x_threshold = ($this.parent().data('xthreshold')) ? $this.parent().data('xthreshold') : $this.data('xthreshold'),
|
615
|
+
ele_y_threshold = ($this.parent().data('ythreshold')) ? $this.parent().data('ythreshold') : $this.data('ythreshold'),
|
616
|
+
h_threshold = (typeof ele_x_threshold !== 'undefined' && ele_x_threshold !== false && parseInt(ele_x_threshold)) ? parseInt(ele_x_threshold) : settings.swipe_h_threshold,
|
617
|
+
v_threshold = (typeof ele_y_threshold !== 'undefined' && ele_y_threshold !== false && parseInt(ele_y_threshold)) ? parseInt(ele_y_threshold) : settings.swipe_v_threshold;
|
618
|
+
|
619
|
+
if (originalCoord.y > finalCoord.y && (originalCoord.y - finalCoord.y > v_threshold)) {
|
620
|
+
swipedir = 'swipeup';
|
621
|
+
}
|
622
|
+
if (originalCoord.x < finalCoord.x && (finalCoord.x - originalCoord.x > h_threshold)) {
|
623
|
+
swipedir = 'swiperight';
|
624
|
+
}
|
625
|
+
if (originalCoord.y < finalCoord.y && (finalCoord.y - originalCoord.y > v_threshold)) {
|
626
|
+
swipedir = 'swipedown';
|
627
|
+
}
|
628
|
+
if (originalCoord.x > finalCoord.x && (originalCoord.x - finalCoord.x > h_threshold)) {
|
629
|
+
swipedir = 'swipeleft';
|
630
|
+
}
|
631
|
+
if (swipedir != undefined && started) {
|
632
|
+
originalCoord.x = 0;
|
633
|
+
originalCoord.y = 0;
|
634
|
+
finalCoord.x = 0;
|
635
|
+
finalCoord.y = 0;
|
636
|
+
started = false;
|
637
|
+
|
638
|
+
// Read event data into our endEvnt:
|
639
|
+
var origEvent = e.originalEvent;
|
640
|
+
var endEvnt = {
|
641
|
+
'position': {
|
642
|
+
'x': (settings.touch_capable) ? origEvent.touches[0].pageX : e.pageX,
|
643
|
+
'y': (settings.touch_capable) ? origEvent.touches[0].pageY : e.pageY
|
644
|
+
},
|
645
|
+
'offset': {
|
646
|
+
'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
|
647
|
+
'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
|
648
|
+
},
|
649
|
+
'time': Date.now(),
|
650
|
+
'target': e.target
|
651
|
+
};
|
652
|
+
|
653
|
+
// Calculate the swipe amount (normalized):
|
654
|
+
var xAmount = Math.abs(startEvnt.position.x - endEvnt.position.x),
|
655
|
+
yAmount = Math.abs(startEvnt.position.y - endEvnt.position.y);
|
656
|
+
|
657
|
+
var touchData = {
|
658
|
+
'startEvnt': startEvnt,
|
659
|
+
'endEvnt': endEvnt,
|
660
|
+
'direction': swipedir.replace('swipe', ''),
|
661
|
+
'xAmount': xAmount,
|
662
|
+
'yAmount': yAmount,
|
663
|
+
'duration': endEvnt.time - startEvnt.time
|
664
|
+
};
|
665
|
+
hasSwiped = true;
|
666
|
+
$this.trigger('swipe', touchData).trigger(swipedir, touchData);
|
667
|
+
}
|
668
|
+
}
|
669
|
+
|
670
|
+
function touchEnd(e) {
|
671
|
+
$this = $(e.currentTarget);
|
672
|
+
var swipedir = "";
|
673
|
+
$this.data('callee3', touchEnd);
|
674
|
+
if (hasSwiped) {
|
675
|
+
// We need to check if the element to which the event was bound contains a data-xthreshold | data-vthreshold:
|
676
|
+
var ele_x_threshold = $this.data('xthreshold'),
|
677
|
+
ele_y_threshold = $this.data('ythreshold'),
|
678
|
+
h_threshold = (typeof ele_x_threshold !== 'undefined' && ele_x_threshold !== false && parseInt(ele_x_threshold)) ? parseInt(ele_x_threshold) : settings.swipe_h_threshold,
|
679
|
+
v_threshold = (typeof ele_y_threshold !== 'undefined' && ele_y_threshold !== false && parseInt(ele_y_threshold)) ? parseInt(ele_y_threshold) : settings.swipe_v_threshold;
|
680
|
+
|
681
|
+
var origEvent = e.originalEvent;
|
682
|
+
var endEvnt = {
|
683
|
+
'position': {
|
684
|
+
'x': (settings.touch_capable) ? origEvent.changedTouches[0].pageX : e.pageX,
|
685
|
+
'y': (settings.touch_capable) ? origEvent.changedTouches[0].pageY : e.pageY
|
686
|
+
},
|
687
|
+
'offset': {
|
688
|
+
'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
|
689
|
+
'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
|
690
|
+
},
|
691
|
+
'time': Date.now(),
|
692
|
+
'target': e.target
|
693
|
+
};
|
694
|
+
|
695
|
+
// Read event data into our endEvnt:
|
696
|
+
if (startEvnt.position.y > endEvnt.position.y && (startEvnt.position.y - endEvnt.position.y > v_threshold)) {
|
697
|
+
swipedir = 'swipeup';
|
698
|
+
}
|
699
|
+
if (startEvnt.position.x < endEvnt.position.x && (endEvnt.position.x - startEvnt.position.x > h_threshold)) {
|
700
|
+
swipedir = 'swiperight';
|
701
|
+
}
|
702
|
+
if (startEvnt.position.y < endEvnt.position.y && (endEvnt.position.y - startEvnt.position.y > v_threshold)) {
|
703
|
+
swipedir = 'swipedown';
|
704
|
+
}
|
705
|
+
if (startEvnt.position.x > endEvnt.position.x && (startEvnt.position.x - endEvnt.position.x > h_threshold)) {
|
706
|
+
swipedir = 'swipeleft';
|
707
|
+
}
|
708
|
+
|
709
|
+
// Calculate the swipe amount (normalized):
|
710
|
+
var xAmount = Math.abs(startEvnt.position.x - endEvnt.position.x),
|
711
|
+
yAmount = Math.abs(startEvnt.position.y - endEvnt.position.y);
|
712
|
+
|
713
|
+
var touchData = {
|
714
|
+
'startEvnt': startEvnt,
|
715
|
+
'endEvnt': endEvnt,
|
716
|
+
'direction': swipedir.replace('swipe', ''),
|
717
|
+
'xAmount': xAmount,
|
718
|
+
'yAmount': yAmount,
|
719
|
+
'duration': endEvnt.time - startEvnt.time
|
720
|
+
};
|
721
|
+
$this.trigger('swipeend', touchData);
|
722
|
+
}
|
723
|
+
|
724
|
+
started = false;
|
725
|
+
hasSwiped = false;
|
726
|
+
}
|
727
|
+
|
728
|
+
$this.on(settings.startevent, touchStart);
|
729
|
+
$this.on(settings.moveevent, touchMove);
|
730
|
+
$this.on(settings.endevent, touchEnd);
|
731
|
+
},
|
732
|
+
|
733
|
+
remove: function () {
|
734
|
+
$(this).off(settings.startevent, $(this).data.callee1).off(settings.moveevent, $(this).data.callee2).off(settings.endevent, $(this).data.callee3);
|
735
|
+
}
|
736
|
+
};
|
737
|
+
|
738
|
+
// scrollstart Event (also handles scrollend):
|
739
|
+
$.event.special.scrollstart = {
|
740
|
+
setup: function () {
|
741
|
+
var thisObject = this,
|
742
|
+
$this = $(thisObject),
|
743
|
+
scrolling,
|
744
|
+
timer;
|
745
|
+
|
746
|
+
function trigger(event, state) {
|
747
|
+
scrolling = state;
|
748
|
+
triggerCustomEvent(thisObject, scrolling ? 'scrollstart' : 'scrollend', event);
|
749
|
+
}
|
750
|
+
|
751
|
+
// iPhone triggers scroll after a small delay; use touchmove instead
|
752
|
+
$this.on(settings.scrollevent, function scrollFunc(event) {
|
753
|
+
$this.data('callee', scrollFunc);
|
754
|
+
|
755
|
+
if (!scrolling) {
|
756
|
+
trigger(event, true);
|
757
|
+
}
|
758
|
+
|
759
|
+
clearTimeout(timer);
|
760
|
+
timer = setTimeout(function () {
|
761
|
+
trigger(event, false);
|
762
|
+
}, 50);
|
763
|
+
});
|
764
|
+
},
|
765
|
+
|
766
|
+
remove: function () {
|
767
|
+
$(this).off(settings.scrollevent, $(this).data.callee);
|
768
|
+
}
|
769
|
+
};
|
770
|
+
|
771
|
+
// This is the orientation change (largely borrowed from jQuery Mobile):
|
772
|
+
var win = $(window),
|
773
|
+
special_event,
|
774
|
+
get_orientation,
|
775
|
+
last_orientation,
|
776
|
+
initial_orientation_is_landscape,
|
777
|
+
initial_orientation_is_default,
|
778
|
+
portrait_map = {
|
779
|
+
'0': true,
|
780
|
+
'180': true
|
781
|
+
};
|
782
|
+
|
783
|
+
if (settings.orientation_support) {
|
784
|
+
var ww = window.innerWidth || win.width(),
|
785
|
+
wh = window.innerHeight || win.height(),
|
786
|
+
landscape_threshold = 50;
|
787
|
+
|
788
|
+
initial_orientation_is_landscape = ww > wh && (ww - wh) > landscape_threshold;
|
789
|
+
initial_orientation_is_default = portrait_map[window.orientation];
|
790
|
+
|
791
|
+
if ((initial_orientation_is_landscape && initial_orientation_is_default) || (!initial_orientation_is_landscape && !initial_orientation_is_default)) {
|
792
|
+
portrait_map = {
|
793
|
+
'-90': true,
|
794
|
+
'90': true
|
795
|
+
};
|
796
|
+
}
|
797
|
+
}
|
798
|
+
|
799
|
+
$.event.special.orientationchange = special_event = {
|
800
|
+
setup: function () {
|
801
|
+
// If the event is supported natively, return false so that jQuery
|
802
|
+
// will on to the event using DOM methods.
|
803
|
+
if (settings.orientation_support) {
|
804
|
+
return false;
|
805
|
+
}
|
806
|
+
|
807
|
+
// Get the current orientation to avoid initial double-triggering.
|
808
|
+
last_orientation = get_orientation();
|
809
|
+
|
810
|
+
win.on('throttledresize', handler);
|
811
|
+
return true;
|
812
|
+
},
|
813
|
+
teardown: function () {
|
814
|
+
if (settings.orientation_support) {
|
815
|
+
return false;
|
816
|
+
}
|
817
|
+
|
818
|
+
win.off('throttledresize', handler);
|
819
|
+
return true;
|
820
|
+
},
|
821
|
+
add: function (handleObj) {
|
822
|
+
// Save a reference to the bound event handler.
|
823
|
+
var old_handler = handleObj.handler;
|
824
|
+
|
825
|
+
handleObj.handler = function (event) {
|
826
|
+
event.orientation = get_orientation();
|
827
|
+
return old_handler.apply(this, arguments);
|
828
|
+
};
|
829
|
+
}
|
830
|
+
};
|
831
|
+
|
832
|
+
// If the event is not supported natively, this handler will be bound to
|
833
|
+
// the window resize event to simulate the orientationchange event.
|
834
|
+
|
835
|
+
function handler() {
|
836
|
+
// Get the current orientation.
|
837
|
+
var orientation = get_orientation();
|
838
|
+
|
839
|
+
if (orientation !== last_orientation) {
|
840
|
+
// The orientation has changed, so trigger the orientationchange event.
|
841
|
+
last_orientation = orientation;
|
842
|
+
win.trigger("orientationchange");
|
843
|
+
}
|
844
|
+
}
|
845
|
+
|
846
|
+
$.event.special.orientationchange.orientation = get_orientation = function () {
|
847
|
+
var isPortrait = true,
|
848
|
+
elem = document.documentElement;
|
849
|
+
|
850
|
+
if (settings.orientation_support) {
|
851
|
+
isPortrait = portrait_map[window.orientation];
|
852
|
+
} else {
|
853
|
+
isPortrait = elem && elem.clientWidth / elem.clientHeight < 1.1;
|
854
|
+
}
|
855
|
+
|
856
|
+
return isPortrait ? 'portrait' : 'landscape';
|
857
|
+
};
|
858
|
+
|
859
|
+
// throttle Handler:
|
860
|
+
$.event.special.throttledresize = {
|
861
|
+
setup: function () {
|
862
|
+
$(this).on('resize', throttle_handler);
|
863
|
+
},
|
864
|
+
teardown: function () {
|
865
|
+
$(this).off('resize', throttle_handler);
|
866
|
+
}
|
867
|
+
};
|
868
|
+
|
869
|
+
var throttle = 250,
|
870
|
+
throttle_handler = function () {
|
871
|
+
curr = Date.now();
|
872
|
+
diff = curr - lastCall;
|
873
|
+
|
874
|
+
if (diff >= throttle) {
|
875
|
+
lastCall = curr;
|
876
|
+
$(this).trigger('throttledresize');
|
877
|
+
|
878
|
+
} else {
|
879
|
+
if (heldCall) {
|
880
|
+
window.clearTimeout(heldCall);
|
881
|
+
}
|
882
|
+
|
883
|
+
// Promise a held call will still execute
|
884
|
+
heldCall = window.setTimeout(handler, throttle - diff);
|
885
|
+
}
|
886
|
+
},
|
887
|
+
lastCall = 0,
|
888
|
+
heldCall,
|
889
|
+
curr,
|
890
|
+
diff;
|
891
|
+
|
892
|
+
// Trigger a custom event:
|
893
|
+
|
894
|
+
function triggerCustomEvent(obj, eventType, event, touchData) {
|
895
|
+
var originalType = event.type;
|
896
|
+
event.type = eventType;
|
897
|
+
|
898
|
+
$.event.dispatch.call(obj, event, touchData);
|
899
|
+
event.type = originalType;
|
900
|
+
}
|
901
|
+
|
902
|
+
// Correctly on anything we've overloaded:
|
903
|
+
$.each({
|
904
|
+
scrollend: 'scrollstart',
|
905
|
+
swipeup: 'swipe',
|
906
|
+
swiperight: 'swipe',
|
907
|
+
swipedown: 'swipe',
|
908
|
+
swipeleft: 'swipe',
|
909
|
+
swipeend: 'swipe',
|
910
|
+
tap2: 'tap',
|
911
|
+
taphold2: 'taphold'
|
912
|
+
}, function (e, srcE) {
|
913
|
+
$.event.special[e] = {
|
914
|
+
setup: function () {
|
915
|
+
$(this).on(srcE, $.noop);
|
916
|
+
}
|
917
|
+
};
|
918
|
+
});
|
919
|
+
|
920
|
+
}(jQuery));
|