1(function() { 2 $.fn.extend({ 3 aemTouchUtil: function(options) { 4 var settings; 5 settings = { 6 touchClassName: 'is-touch' 7 }; 8 settings = $.extend(settings, options); 9 return this.each(function() { 10 var $elem; 11 $elem = $(this); 12 return $elem.on('touchstart', function() { 13 return $elem.addClass(settings.touchClassName); 14 }).on('touchmove', function() { 15 return $elem.removeClass(settings.touchClassName); 16 }).on('touchend', function() { 17 return $elem.removeClass(settings.touchClassName); 18 }); 19 }); 20 }, 21 aemTouch: function(options) { 22 var hasCallback, settings; 23 settings = { 24 touchClassName: 'is-touch' 25 }; 26 settings = $.extend(settings, options); 27 hasCallback = typeof settings.callback === 'function'; 28 return $(this).each(function() { 29 var $elem, isMove, touchStartX, touchStartY; 30 $elem = $(this); 31 isMove = false; 32 touchStartX = null; 33 touchStartY = null; 34 return $elem.on('touchend touchstart touchmove click', function(e) { 35 var eventType, touches; 36 eventType = e.type; 37 if (eventType === 'click') { 38 if (($elem.data('eventHandled')) === true) { 39 $elem.data('eventHandled', false); 40 return false; 41 } 42 if (hasCallback === true) { 43 settings.callback($elem, e); 44 return false; 45 } 46 } 47 if (eventType === 'touchstart') { 48 isMove = false; 49 touches = e.originalEvent.touches; 50 touchStartX = touches[0].pageX; 51 touchStartY = touches[0].pageY; 52 $elem.addClass(settings.touchClassName); 53 return true; 54 } else if (eventType === 'touchmove') { 55 if (Math.abs(e.originalEvent.touches[0].pageX - touchStartX) > 12 || Math.abs(e.originalEvent.touches[0].pageY - touchStartY) > 12) { 56 isMove = true; 57 $elem.removeClass(settings.touchClassName); 58 } 59 return true; 60 } else if (e.type === 'touchend') { 61 if (isMove === true) { 62 isMove = false; 63 return false; 64 } 65 $elem.removeClass(settings.touchClassName); 66 if (hasCallback === true) { 67 $elem.data('eventHandled', true); 68 settings.callback($elem, e); 69 return false; 70 } 71 } 72 }); 73 }); 74 } 75 }); 76 77}).call(this);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.