zepto_rails 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.
- data/.gitignore +8 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +91 -0
- data/MIT-LICENSE +20 -0
- data/README.md +46 -0
- data/Rakefile +27 -0
- data/lib/zepto/rails.rb +2 -0
- data/lib/zepto/rails/engine.rb +6 -0
- data/lib/zepto/rails/version.rb +5 -0
- data/lib/zepto_rails.rb +1 -0
- data/vendor/assets/javascripts/zepto.js +7 -0
- data/vendor/assets/javascripts/zepto/ajax.js +314 -0
- data/vendor/assets/javascripts/zepto/all.js +14 -0
- data/vendor/assets/javascripts/zepto/assets.js +21 -0
- data/vendor/assets/javascripts/zepto/data.js +67 -0
- data/vendor/assets/javascripts/zepto/detect.js +55 -0
- data/vendor/assets/javascripts/zepto/event.js +248 -0
- data/vendor/assets/javascripts/zepto/form.js +40 -0
- data/vendor/assets/javascripts/zepto/fx.js +102 -0
- data/vendor/assets/javascripts/zepto/fx_methods.js +71 -0
- data/vendor/assets/javascripts/zepto/gesture.js +35 -0
- data/vendor/assets/javascripts/zepto/polyfill.js +36 -0
- data/vendor/assets/javascripts/zepto/selector.js +81 -0
- data/vendor/assets/javascripts/zepto/stack.js +22 -0
- data/vendor/assets/javascripts/zepto/touch.js +115 -0
- data/vendor/assets/javascripts/zepto/zepto.js +790 -0
- data/zepto_rails.gemspec +21 -0
- metadata +110 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
// Zepto.js
|
2
|
+
// (c) 2010-2012 Thomas Fuchs
|
3
|
+
// Zepto.js may be freely distributed under the MIT license.
|
4
|
+
|
5
|
+
;(function($, undefined){
|
6
|
+
var prefix = '', eventPrefix, endEventName, endAnimationName,
|
7
|
+
vendors = { Webkit: 'webkit', Moz: '', O: 'o', ms: 'MS' },
|
8
|
+
document = window.document, testEl = document.createElement('div'),
|
9
|
+
supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,
|
10
|
+
transform,
|
11
|
+
transitionProperty, transitionDuration, transitionTiming,
|
12
|
+
animationName, animationDuration, animationTiming,
|
13
|
+
cssReset = {}
|
14
|
+
|
15
|
+
function dasherize(str) { return downcase(str.replace(/([a-z])([A-Z])/, '$1-$2')) }
|
16
|
+
function downcase(str) { return str.toLowerCase() }
|
17
|
+
function normalizeEvent(name) { return eventPrefix ? eventPrefix + name : downcase(name) }
|
18
|
+
|
19
|
+
$.each(vendors, function(vendor, event){
|
20
|
+
if (testEl.style[vendor + 'TransitionProperty'] !== undefined) {
|
21
|
+
prefix = '-' + downcase(vendor) + '-'
|
22
|
+
eventPrefix = event
|
23
|
+
return false
|
24
|
+
}
|
25
|
+
})
|
26
|
+
|
27
|
+
transform = prefix + 'transform'
|
28
|
+
cssReset[transitionProperty = prefix + 'transition-property'] =
|
29
|
+
cssReset[transitionDuration = prefix + 'transition-duration'] =
|
30
|
+
cssReset[transitionTiming = prefix + 'transition-timing-function'] =
|
31
|
+
cssReset[animationName = prefix + 'animation-name'] =
|
32
|
+
cssReset[animationDuration = prefix + 'animation-duration'] =
|
33
|
+
cssReset[animationTiming = prefix + 'animation-timing-function'] = ''
|
34
|
+
|
35
|
+
$.fx = {
|
36
|
+
off: (eventPrefix === undefined && testEl.style.transitionProperty === undefined),
|
37
|
+
speeds: { _default: 400, fast: 200, slow: 600 },
|
38
|
+
cssPrefix: prefix,
|
39
|
+
transitionEnd: normalizeEvent('TransitionEnd'),
|
40
|
+
animationEnd: normalizeEvent('AnimationEnd')
|
41
|
+
}
|
42
|
+
|
43
|
+
$.fn.animate = function(properties, duration, ease, callback){
|
44
|
+
if ($.isPlainObject(duration))
|
45
|
+
ease = duration.easing, callback = duration.complete, duration = duration.duration
|
46
|
+
if (duration) duration = (typeof duration == 'number' ? duration :
|
47
|
+
($.fx.speeds[duration] || $.fx.speeds._default)) / 1000
|
48
|
+
return this.anim(properties, duration, ease, callback)
|
49
|
+
}
|
50
|
+
|
51
|
+
$.fn.anim = function(properties, duration, ease, callback){
|
52
|
+
var key, cssValues = {}, cssProperties, transforms = '',
|
53
|
+
that = this, wrappedCallback, endEvent = $.fx.transitionEnd
|
54
|
+
|
55
|
+
if (duration === undefined) duration = 0.4
|
56
|
+
if ($.fx.off) duration = 0
|
57
|
+
|
58
|
+
if (typeof properties == 'string') {
|
59
|
+
// keyframe animation
|
60
|
+
cssValues[animationName] = properties
|
61
|
+
cssValues[animationDuration] = duration + 's'
|
62
|
+
cssValues[animationTiming] = (ease || 'linear')
|
63
|
+
endEvent = $.fx.animationEnd
|
64
|
+
} else {
|
65
|
+
cssProperties = []
|
66
|
+
// CSS transitions
|
67
|
+
for (key in properties)
|
68
|
+
if (supportedTransforms.test(key)) transforms += key + '(' + properties[key] + ') '
|
69
|
+
else cssValues[key] = properties[key], cssProperties.push(dasherize(key))
|
70
|
+
|
71
|
+
if (transforms) cssValues[transform] = transforms, cssProperties.push(transform)
|
72
|
+
if (duration > 0 && typeof properties === 'object') {
|
73
|
+
cssValues[transitionProperty] = cssProperties.join(', ')
|
74
|
+
cssValues[transitionDuration] = duration + 's'
|
75
|
+
cssValues[transitionTiming] = (ease || 'linear')
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
wrappedCallback = function(event){
|
80
|
+
if (typeof event !== 'undefined') {
|
81
|
+
if (event.target !== event.currentTarget) return // makes sure the event didn't bubble from "below"
|
82
|
+
$(event.target).unbind(endEvent, wrappedCallback)
|
83
|
+
}
|
84
|
+
$(this).css(cssReset)
|
85
|
+
callback && callback.call(this)
|
86
|
+
}
|
87
|
+
if (duration > 0) this.bind(endEvent, wrappedCallback)
|
88
|
+
|
89
|
+
// trigger page reflow so new elements can animate
|
90
|
+
this.size() && this.get(0).clientLeft
|
91
|
+
|
92
|
+
this.css(cssValues)
|
93
|
+
|
94
|
+
if (duration <= 0) setTimeout(function() {
|
95
|
+
that.each(function(){ wrappedCallback.call(this) })
|
96
|
+
}, 0)
|
97
|
+
|
98
|
+
return this
|
99
|
+
}
|
100
|
+
|
101
|
+
testEl = null
|
102
|
+
})(Zepto)
|
@@ -0,0 +1,71 @@
|
|
1
|
+
// Zepto.js
|
2
|
+
// (c) 2010-2012 Thomas Fuchs
|
3
|
+
// Zepto.js may be freely distributed under the MIT license.
|
4
|
+
|
5
|
+
;(function($, undefined){
|
6
|
+
var document = window.document, docElem = document.documentElement,
|
7
|
+
origShow = $.fn.show, origHide = $.fn.hide, origToggle = $.fn.toggle
|
8
|
+
|
9
|
+
function anim(el, speed, opacity, scale, callback) {
|
10
|
+
if (typeof speed == 'function' && !callback) callback = speed, speed = undefined
|
11
|
+
var props = { opacity: opacity }
|
12
|
+
if (scale) {
|
13
|
+
props.scale = scale
|
14
|
+
el.css($.fx.cssPrefix + 'transform-origin', '0 0')
|
15
|
+
}
|
16
|
+
return el.animate(props, speed, null, callback)
|
17
|
+
}
|
18
|
+
|
19
|
+
function hide(el, speed, scale, callback) {
|
20
|
+
return anim(el, speed, 0, scale, function(){
|
21
|
+
origHide.call($(this))
|
22
|
+
callback && callback.call(this)
|
23
|
+
})
|
24
|
+
}
|
25
|
+
|
26
|
+
$.fn.show = function(speed, callback) {
|
27
|
+
origShow.call(this)
|
28
|
+
if (speed === undefined) speed = 0
|
29
|
+
else this.css('opacity', 0)
|
30
|
+
return anim(this, speed, 1, '1,1', callback)
|
31
|
+
}
|
32
|
+
|
33
|
+
$.fn.hide = function(speed, callback) {
|
34
|
+
if (speed === undefined) return origHide.call(this)
|
35
|
+
else return hide(this, speed, '0,0', callback)
|
36
|
+
}
|
37
|
+
|
38
|
+
$.fn.toggle = function(speed, callback) {
|
39
|
+
if (speed === undefined || typeof speed == 'boolean')
|
40
|
+
return origToggle.call(this, speed)
|
41
|
+
else return this.each(function(){
|
42
|
+
var el = $(this)
|
43
|
+
el[el.css('display') == 'none' ? 'show' : 'hide'](speed, callback)
|
44
|
+
})
|
45
|
+
}
|
46
|
+
|
47
|
+
$.fn.fadeTo = function(speed, opacity, callback) {
|
48
|
+
return anim(this, speed, opacity, null, callback)
|
49
|
+
}
|
50
|
+
|
51
|
+
$.fn.fadeIn = function(speed, callback) {
|
52
|
+
var target = this.css('opacity')
|
53
|
+
if (target > 0) this.css('opacity', 0)
|
54
|
+
else target = 1
|
55
|
+
return origShow.call(this).fadeTo(speed, target, callback)
|
56
|
+
}
|
57
|
+
|
58
|
+
$.fn.fadeOut = function(speed, callback) {
|
59
|
+
return hide(this, speed, null, callback)
|
60
|
+
}
|
61
|
+
|
62
|
+
$.fn.fadeToggle = function(speed, callback) {
|
63
|
+
return this.each(function(){
|
64
|
+
var el = $(this)
|
65
|
+
el[
|
66
|
+
(el.css('opacity') == 0 || el.css('display') == 'none') ? 'fadeIn' : 'fadeOut'
|
67
|
+
](speed, callback)
|
68
|
+
})
|
69
|
+
}
|
70
|
+
|
71
|
+
})(Zepto)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
// Zepto.js
|
2
|
+
// (c) 2010-2012 Thomas Fuchs
|
3
|
+
// Zepto.js may be freely distributed under the MIT license.
|
4
|
+
|
5
|
+
;(function($){
|
6
|
+
if ($.os.ios) {
|
7
|
+
var gesture = {}, gestureTimeout
|
8
|
+
|
9
|
+
function parentIfText(node){
|
10
|
+
return 'tagName' in node ? node : node.parentNode
|
11
|
+
}
|
12
|
+
|
13
|
+
$(document).bind('gesturestart', function(e){
|
14
|
+
var now = Date.now(), delta = now - (gesture.last || now)
|
15
|
+
gesture.target = parentIfText(e.target)
|
16
|
+
gestureTimeout && clearTimeout(gestureTimeout)
|
17
|
+
gesture.e1 = e.scale
|
18
|
+
gesture.last = now
|
19
|
+
}).bind('gesturechange', function(e){
|
20
|
+
gesture.e2 = e.scale
|
21
|
+
}).bind('gestureend', function(e){
|
22
|
+
if (gesture.e2 > 0) {
|
23
|
+
Math.abs(gesture.e1 - gesture.e2) != 0 && $(gesture.target).trigger('pinch') &&
|
24
|
+
$(gesture.target).trigger('pinch' + (gesture.e1 - gesture.e2 > 0 ? 'In' : 'Out'))
|
25
|
+
gesture.e1 = gesture.e2 = gesture.last = 0
|
26
|
+
} else if ('last' in gesture) {
|
27
|
+
gesture = {}
|
28
|
+
}
|
29
|
+
})
|
30
|
+
|
31
|
+
;['pinch', 'pinchIn', 'pinchOut'].forEach(function(m){
|
32
|
+
$.fn[m] = function(callback){ return this.bind(m, callback) }
|
33
|
+
})
|
34
|
+
}
|
35
|
+
})(Zepto)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
// Zepto.js
|
2
|
+
// (c) 2010-2012 Thomas Fuchs
|
3
|
+
// Zepto.js may be freely distributed under the MIT license.
|
4
|
+
|
5
|
+
;(function(undefined){
|
6
|
+
if (String.prototype.trim === undefined) // fix for iOS 3.2
|
7
|
+
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g, '') }
|
8
|
+
|
9
|
+
// For iOS 3.x
|
10
|
+
// from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduce
|
11
|
+
if (Array.prototype.reduce === undefined)
|
12
|
+
Array.prototype.reduce = function(fun){
|
13
|
+
if(this === void 0 || this === null) throw new TypeError()
|
14
|
+
var t = Object(this), len = t.length >>> 0, k = 0, accumulator
|
15
|
+
if(typeof fun != 'function') throw new TypeError()
|
16
|
+
if(len == 0 && arguments.length == 1) throw new TypeError()
|
17
|
+
|
18
|
+
if(arguments.length >= 2)
|
19
|
+
accumulator = arguments[1]
|
20
|
+
else
|
21
|
+
do{
|
22
|
+
if(k in t){
|
23
|
+
accumulator = t[k++]
|
24
|
+
break
|
25
|
+
}
|
26
|
+
if(++k >= len) throw new TypeError()
|
27
|
+
} while (true)
|
28
|
+
|
29
|
+
while (k < len){
|
30
|
+
if(k in t) accumulator = fun.call(undefined, accumulator, t[k], k, t)
|
31
|
+
k++
|
32
|
+
}
|
33
|
+
return accumulator
|
34
|
+
}
|
35
|
+
|
36
|
+
})()
|
@@ -0,0 +1,81 @@
|
|
1
|
+
;(function($){
|
2
|
+
var zepto = $.zepto, oldQsa = zepto.qsa, oldMatches = zepto.matches
|
3
|
+
|
4
|
+
function visible(elem){
|
5
|
+
elem = $(elem)
|
6
|
+
return !!(elem.width() || elem.height()) && elem.css("display") !== "none"
|
7
|
+
}
|
8
|
+
|
9
|
+
// Implements a subset from:
|
10
|
+
// http://api.jquery.com/category/selectors/jquery-selector-extensions/
|
11
|
+
//
|
12
|
+
// Each filter function receives the current index, all nodes in the
|
13
|
+
// considered set, and a value if there were parentheses. The value
|
14
|
+
// of `this` is the node currently being considered. The function returns the
|
15
|
+
// resulting node(s), null, or undefined.
|
16
|
+
//
|
17
|
+
// Complex selectors are not supported:
|
18
|
+
// li:has(label:contains("foo")) + li:has(label:contains("bar"))
|
19
|
+
// ul.inner:first > li
|
20
|
+
var filters = $.expr[':'] = {
|
21
|
+
visible: function(){ if (visible(this)) return this },
|
22
|
+
hidden: function(){ if (!visible(this)) return this },
|
23
|
+
selected: function(){ if (this.selected) return this },
|
24
|
+
checked: function(){ if (this.checked) return this },
|
25
|
+
parent: function(){ return this.parentNode },
|
26
|
+
first: function(idx){ if (idx === 0) return this },
|
27
|
+
last: function(idx, nodes){ if (idx === nodes.length - 1) return this },
|
28
|
+
eq: function(idx, _, value){ if (idx === value) return this },
|
29
|
+
contains: function(idx, _, text){ if ($(this).text().indexOf(text) > -1) return this },
|
30
|
+
has: function(idx, _, sel){ if (zepto.qsa(this, sel).length) return this }
|
31
|
+
}
|
32
|
+
|
33
|
+
var filterRe = new RegExp('(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*'),
|
34
|
+
childRe = /^\s*>/,
|
35
|
+
classTag = 'Zepto' + (+new Date())
|
36
|
+
|
37
|
+
function process(sel, fn) {
|
38
|
+
// quote the hash in `a[href^=#]` expression
|
39
|
+
sel = sel.replace(/=#\]/g, '="#"]')
|
40
|
+
var filter, arg, match = filterRe.exec(sel)
|
41
|
+
if (match && match[2] in filters) {
|
42
|
+
filter = filters[match[2]], arg = match[3]
|
43
|
+
sel = match[1]
|
44
|
+
if (arg) {
|
45
|
+
var num = Number(arg)
|
46
|
+
if (isNaN(num)) arg = arg.replace(/^["']|["']$/g, '')
|
47
|
+
else arg = num
|
48
|
+
}
|
49
|
+
}
|
50
|
+
return fn(sel, filter, arg)
|
51
|
+
}
|
52
|
+
|
53
|
+
zepto.qsa = function(node, selector) {
|
54
|
+
return process(selector, function(sel, filter, arg){
|
55
|
+
try {
|
56
|
+
var taggedParent
|
57
|
+
if (!sel && filter) sel = '*'
|
58
|
+
else if (childRe.test(sel))
|
59
|
+
// support "> *" child queries by tagging the parent node with a
|
60
|
+
// unique class and prepending that classname onto the selector
|
61
|
+
taggedParent = $(node).addClass(classTag), sel = '.'+classTag+' '+sel
|
62
|
+
|
63
|
+
var nodes = oldQsa(node, sel)
|
64
|
+
} catch(e) {
|
65
|
+
console.error('error performing selector: %o', selector)
|
66
|
+
throw e
|
67
|
+
} finally {
|
68
|
+
if (taggedParent) taggedParent.removeClass(classTag)
|
69
|
+
}
|
70
|
+
return !filter ? nodes :
|
71
|
+
zepto.uniq($.map(nodes, function(n, i){ return filter.call(n, i, nodes, arg) }))
|
72
|
+
})
|
73
|
+
}
|
74
|
+
|
75
|
+
zepto.matches = function(node, selector){
|
76
|
+
return process(selector, function(sel, filter, arg){
|
77
|
+
return (!sel || oldMatches(node, sel)) &&
|
78
|
+
(!filter || filter.call(node, null, arg) === node)
|
79
|
+
})
|
80
|
+
}
|
81
|
+
})(Zepto)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// Zepto.js
|
2
|
+
// (c) 2010-2012 Thomas Fuchs
|
3
|
+
// Zepto.js may be freely distributed under the MIT license.
|
4
|
+
|
5
|
+
;(function($){
|
6
|
+
$.fn.end = function(){
|
7
|
+
return this.prevObject || $()
|
8
|
+
}
|
9
|
+
|
10
|
+
$.fn.andSelf = function(){
|
11
|
+
return this.add(this.prevObject || $())
|
12
|
+
}
|
13
|
+
|
14
|
+
'filter,add,not,eq,first,last,find,closest,parents,parent,children,siblings'.split(',').forEach(function(property){
|
15
|
+
var fn = $.fn[property]
|
16
|
+
$.fn[property] = function(){
|
17
|
+
var ret = fn.apply(this, arguments)
|
18
|
+
ret.prevObject = this
|
19
|
+
return ret
|
20
|
+
}
|
21
|
+
})
|
22
|
+
})(Zepto)
|
@@ -0,0 +1,115 @@
|
|
1
|
+
// Zepto.js
|
2
|
+
// (c) 2010-2012 Thomas Fuchs
|
3
|
+
// Zepto.js may be freely distributed under the MIT license.
|
4
|
+
|
5
|
+
;(function($){
|
6
|
+
var touch = {},
|
7
|
+
touchTimeout, tapTimeout, swipeTimeout,
|
8
|
+
longTapDelay = 750, longTapTimeout
|
9
|
+
|
10
|
+
function parentIfText(node) {
|
11
|
+
return 'tagName' in node ? node : node.parentNode
|
12
|
+
}
|
13
|
+
|
14
|
+
function swipeDirection(x1, x2, y1, y2) {
|
15
|
+
var xDelta = Math.abs(x1 - x2), yDelta = Math.abs(y1 - y2)
|
16
|
+
return xDelta >= yDelta ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down')
|
17
|
+
}
|
18
|
+
|
19
|
+
function longTap() {
|
20
|
+
longTapTimeout = null
|
21
|
+
if (touch.last) {
|
22
|
+
touch.el.trigger('longTap')
|
23
|
+
touch = {}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
function cancelLongTap() {
|
28
|
+
if (longTapTimeout) clearTimeout(longTapTimeout)
|
29
|
+
longTapTimeout = null
|
30
|
+
}
|
31
|
+
|
32
|
+
function cancelAll() {
|
33
|
+
if (touchTimeout) clearTimeout(touchTimeout)
|
34
|
+
if (tapTimeout) clearTimeout(tapTimeout)
|
35
|
+
if (swipeTimeout) clearTimeout(swipeTimeout)
|
36
|
+
if (longTapTimeout) clearTimeout(longTapTimeout)
|
37
|
+
touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null
|
38
|
+
touch = {}
|
39
|
+
}
|
40
|
+
|
41
|
+
$(document).ready(function(){
|
42
|
+
var now, delta
|
43
|
+
|
44
|
+
$(document.body)
|
45
|
+
.bind('touchstart', function(e){
|
46
|
+
now = Date.now()
|
47
|
+
delta = now - (touch.last || now)
|
48
|
+
touch.el = $(parentIfText(e.touches[0].target))
|
49
|
+
touchTimeout && clearTimeout(touchTimeout)
|
50
|
+
touch.x1 = e.touches[0].pageX
|
51
|
+
touch.y1 = e.touches[0].pageY
|
52
|
+
if (delta > 0 && delta <= 250) touch.isDoubleTap = true
|
53
|
+
touch.last = now
|
54
|
+
longTapTimeout = setTimeout(longTap, longTapDelay)
|
55
|
+
})
|
56
|
+
.bind('touchmove', function(e){
|
57
|
+
cancelLongTap()
|
58
|
+
touch.x2 = e.touches[0].pageX
|
59
|
+
touch.y2 = e.touches[0].pageY
|
60
|
+
if (Math.abs(touch.x1 - touch.x2) > 10)
|
61
|
+
e.preventDefault()
|
62
|
+
})
|
63
|
+
.bind('touchend', function(e){
|
64
|
+
cancelLongTap()
|
65
|
+
|
66
|
+
// swipe
|
67
|
+
if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) ||
|
68
|
+
(touch.y2 && Math.abs(touch.y1 - touch.y2) > 30))
|
69
|
+
|
70
|
+
swipeTimeout = setTimeout(function() {
|
71
|
+
touch.el.trigger('swipe')
|
72
|
+
touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)))
|
73
|
+
touch = {}
|
74
|
+
}, 0)
|
75
|
+
|
76
|
+
// normal tap
|
77
|
+
else if ('last' in touch)
|
78
|
+
|
79
|
+
// delay by one tick so we can cancel the 'tap' event if 'scroll' fires
|
80
|
+
// ('tap' fires before 'scroll')
|
81
|
+
tapTimeout = setTimeout(function() {
|
82
|
+
|
83
|
+
// trigger universal 'tap' with the option to cancelTouch()
|
84
|
+
// (cancelTouch cancels processing of single vs double taps for faster 'tap' response)
|
85
|
+
var event = $.Event('tap')
|
86
|
+
event.cancelTouch = cancelAll
|
87
|
+
touch.el.trigger(event)
|
88
|
+
|
89
|
+
// trigger double tap immediately
|
90
|
+
if (touch.isDoubleTap) {
|
91
|
+
touch.el.trigger('doubleTap')
|
92
|
+
touch = {}
|
93
|
+
}
|
94
|
+
|
95
|
+
// trigger single tap after 250ms of inactivity
|
96
|
+
else {
|
97
|
+
touchTimeout = setTimeout(function(){
|
98
|
+
touchTimeout = null
|
99
|
+
touch.el.trigger('singleTap')
|
100
|
+
touch = {}
|
101
|
+
}, 250)
|
102
|
+
}
|
103
|
+
|
104
|
+
}, 0)
|
105
|
+
|
106
|
+
})
|
107
|
+
.bind('touchcancel', cancelAll)
|
108
|
+
|
109
|
+
$(window).bind('scroll', cancelAll)
|
110
|
+
})
|
111
|
+
|
112
|
+
;['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(m){
|
113
|
+
$.fn[m] = function(callback){ return this.bind(m, callback) }
|
114
|
+
})
|
115
|
+
})(Zepto)
|