Permalink
Browse files

Copy Zepto into build dir, fix copying jqtouch-jquery bridge

  • Loading branch information...
1 parent 702ecd8 commit 249367f20c4a51ac43859808730268f618412948 @davidkaneda davidkaneda committed Feb 17, 2013
Showing with 5 additions and 1,943 deletions.
  1. +5 −4 Gruntfile.coffee
  2. +0 −113 lib/zepto/touch.js
  3. +0 −1,713 lib/zepto/zepto.js
  4. +0 −113 src/jqtouch-jquery.js
View
@@ -106,10 +106,11 @@ module.exports = (grunt) ->
expand: yes
cwd: 'submodules/zepto/dist/'
src: 'zepto.js'
- dest: 'lib/zepto'
+ dest: '<%= dirs.build %>/lib/zepto'
,
- "<%= dirs.build %>/src/jqtouch-jquery.js": ["submodules/zepto/src/touch.js"]
- ]
+ src: 'submodules/zepto/src/touch.js'
+ dest: '<%= dirs.build %>/src/jqtouch-jquery.js'
+ ]
"jquery-bridge":
options:
@@ -215,6 +216,6 @@ module.exports = (grunt) ->
grunt.registerTask "test", ["copy:prepare", "copy:test", "qunit"]
# Full-build tasks
- grunt.registerTask "light", ["nuke", "copy:prepare", "compass"]
+ grunt.registerTask "light", ["nuke", "copy:prepare", "compass", "copy:zepto"]
grunt.registerTask "dist", ["nuke", "zepto", "jquery-bridge", "light", "test", "copy:dist", "uglify"]
grunt.registerTask "full", ['update_submodules', "nuke", "light", "dist"]
View
@@ -1,113 +0,0 @@
-// Zepto.js
-// (c) 2010-2012 Thomas Fuchs
-// Zepto.js may be freely distributed under the MIT license.
-
-;(function($){
- var touch = {},
- touchTimeout, tapTimeout, swipeTimeout,
- longTapDelay = 750, longTapTimeout
-
- function parentIfText(node) {
- return 'tagName' in node ? node : node.parentNode
- }
-
- function swipeDirection(x1, x2, y1, y2) {
- var xDelta = Math.abs(x1 - x2), yDelta = Math.abs(y1 - y2)
- return xDelta >= yDelta ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down')
- }
-
- function longTap() {
- longTapTimeout = null
- if (touch.last) {
- touch.el.trigger('longTap')
- touch = {}
- }
- }
-
- function cancelLongTap() {
- if (longTapTimeout) clearTimeout(longTapTimeout)
- longTapTimeout = null
- }
-
- function cancelAll() {
- if (touchTimeout) clearTimeout(touchTimeout)
- if (tapTimeout) clearTimeout(tapTimeout)
- if (swipeTimeout) clearTimeout(swipeTimeout)
- if (longTapTimeout) clearTimeout(longTapTimeout)
- touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null
- touch = {}
- }
-
- $(document).ready(function(){
- var now, delta
-
- $(document.body)
- .bind('touchstart', function(e){
- now = Date.now()
- delta = now - (touch.last || now)
- touch.el = $(parentIfText(e.touches[0].target))
- touchTimeout && clearTimeout(touchTimeout)
- touch.x1 = e.touches[0].pageX
- touch.y1 = e.touches[0].pageY
- if (delta > 0 && delta <= 250) touch.isDoubleTap = true
- touch.last = now
- longTapTimeout = setTimeout(longTap, longTapDelay)
- })
- .bind('touchmove', function(e){
- cancelLongTap()
- touch.x2 = e.touches[0].pageX
- touch.y2 = e.touches[0].pageY
- })
- .bind('touchend', function(e){
- cancelLongTap()
-
- // swipe
- if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) ||
- (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30))
-
- swipeTimeout = setTimeout(function() {
- touch.el.trigger('swipe')
- touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)))
- touch = {}
- }, 0)
-
- // normal tap
- else if ('last' in touch)
-
- // delay by one tick so we can cancel the 'tap' event if 'scroll' fires
- // ('tap' fires before 'scroll')
- tapTimeout = setTimeout(function() {
-
- // trigger universal 'tap' with the option to cancelTouch()
- // (cancelTouch cancels processing of single vs double taps for faster 'tap' response)
- var event = $.Event('tap')
- event.cancelTouch = cancelAll
- touch.el.trigger(event)
-
- // trigger double tap immediately
- if (touch.isDoubleTap) {
- touch.el.trigger('doubleTap')
- touch = {}
- }
-
- // trigger single tap after 250ms of inactivity
- else {
- touchTimeout = setTimeout(function(){
- touchTimeout = null
- touch.el.trigger('singleTap')
- touch = {}
- }, 250)
- }
-
- }, 0)
-
- })
- .bind('touchcancel', cancelAll)
-
- $(window).bind('scroll', cancelAll)
- })
-
- ;['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(m){
- $.fn[m] = function(callback){ return this.bind(m, callback) }
- })
-})(Zepto)
Oops, something went wrong.

0 comments on commit 249367f

Please sign in to comment.