/**
 * SWIPE APPLICATION
 */


var swipeData = {
	
};

var swipe = {
	threshold: {
		drag: 20,
		swipe: 10
	}
}


$(document).ready(function(){
	
	console.log('init');
	
	$('.reportSwipe').on('click', function(){
		alert('Download me');
	});
	
	$('.reportSwipe').on('touchstart', function(e){
		var id = $(this).attr('data-index');
		
		var touch = e.originalEvent.touches[0];
		swipeData[id] = {
			swipeStartX: touch.pageX,
			lastSwipeX: touch.pageX,
			
			swipeStartY: touch.pageY,
			lastSwipeY: touch.pageY
		};
		
		
	});
	
	$('.reportSwipe').on('touchmove', function(e){
		
		//Variables and aliases
		var treshhold = swipe.threshold; 
		
		//Variables for ease of access.
		var id = $(this).attr('data-index');
		var touch = e.originalEvent.touches[0];
		
		var pageX = Number(touch.pageX);
		var lastSwipeX = Number(swipeData[id].lastSwipeX);
		
		var pageY = Number(touch.pageY);
		var lastSwipeY = Number(swipeData[id].lastSwipeY);
		
		
		
		//Order of importance:
		// 1. If dragging (Horizontal) - DONT INTERRUPT
		// 2. If swiping (Vertical) - DONT INTERRUPT
		// 3. Happy wife => happy life 
		var isDragging = (((lastSwipeX - pageX) > treshhold.drag) || ((pageX - lastSwipeX) > treshhold.drag));
		
		if ((!isDragging) && (((lastSwipeY - pageY) > treshhold.swipe) || ((pageY - lastSwipeY) > treshhold.swipe))) {
			//Moving vertically..
			console.log("Moving vertically, lastSwipeY - pageY =  " + (String((swipeData[id].lastSwipeY - touch.pageY))))
			$.trigger(e);
			return false;
		}
		
		console.log("Not moving vertically: lastSwipeY: " + swipeData[id].lastSwipeY + " pageY: " + touch.pageY);
		
		e.preventDefault();
		
		
		var swipeDistance = Number(touch.pageX - swipeData[id].swipeStartX);
		var lastMoveDistance = Number(touch.pageX - swipeData[id].lastSwipeX);
		swipeData[id].lastSwipeX = touch.pageX;
		
		
		
		
		//FIND DIRECTION
		var direction = 'left';
		if (swipeData[id].lastSwipeX > touch.pageX) {
			direction = 'right';
		}
		var distance = lastMoveDistance;
		var currentLeft = 0;
		
		
		//ALTER THE DISPLAY
		$(this).css('margin-right', ((Number($(this).css('margin-right').replace('px', ''))) + lastMoveDistance) + 'px');
		
		
	});
	
	$('.reportSwipe').on('touchcancel', function(e){
		var id = $(this).attr('data-index');
		
		//Reset the display
		$(this).css('margin-right', '0px');
		
		console.log("TOUCH CANCELLED");
	});
	
	$('.reportSwipe').on('touchend', function(e){
		var id = $(this).attr('data-index');
		
		//Get total distance. Measure if its enough to complete the swipe.
		
		//Reset the display
		$(this).css('margin-right', '0px');
		
		console.log("TOUCH END");
	});
	
});

@@ -24,25 +24,31 @@
 N%0A */%0A%0A%0Avar 
-s
+globalS
 wipeData = %7B
@@ -118,80 +118,136 @@
 %0A%0A%0A$
-(document).ready(function()%7B%0A%09%0A%09console.log('init');%0A%09%0A%09$('.reportSwipe'
+.fn.swipeAction = function(params)%7B%0A%09globalSwipeData%5Bparams.name%5D = %7B%7D;%0A%09var swipeData = globalSwipeData%5Bparams.name%5D;%0A%09%0A%09$(this
 ).on
@@ -298,38 +298,28 @@
 ;%0A%09%7D);%0A%09%0A%09$(
-'.reportSwipe'
+this
 ).on('touchs
@@ -576,38 +576,28 @@
 %09%0A%09%7D);%0A%09%0A%09$(
-'.reportSwipe'
+this
 ).on('touchm
@@ -979,30 +979,24 @@
 SwipeY);%0A%09%09%0A
-%09%09%0A%09%09%0A
 %09%09//Order of
@@ -1109,42 +1109,8 @@
 UPT%0A
-%09%09// 3. Happy wife =%3E happy life %0A
 %09%09va
@@ -1833,25 +1833,16 @@
 geX;%0A%09%09%0A
-%09%09%0A%09%09%0A%09%09%0A
 %09%09//FIND
@@ -2015,19 +2015,16 @@
 = 0;%0A%09%09%0A
-%09%09%0A
 %09%09//ALTE
@@ -2165,38 +2165,28 @@
 %09%0A%09%7D);%0A%09%0A%09$(
-'.reportSwipe'
+this
 ).on('touchc
@@ -2241,27 +2241,24 @@
 ta-index');%0A
-%09%09%0A
 %09%09//Reset th
@@ -2247,36 +2247,32 @@
 ex');%0A%09%09//Reset 
-the 
 display%0A%09%09$(this
@@ -2306,68 +2306,21 @@
 );%0A%09
-%09%0A%09%09console.log(%22TOUCH CANCELLED%22);%0A%09%7D);%0A%09%0A%09$('.reportSwipe'
+%7D);%0A%09%0A%09$(this
 ).on
@@ -2388,83 +2388,8 @@
 ');%0A
-%09%09%0A%09%09//Get total distance. Measure if its enough to complete the swipe.%0A%09%09%0A
 %09%09//
@@ -2398,12 +2398,8 @@
 set 
-the 
 disp
@@ -2444,46 +2444,15 @@
 ');%0A
-%09%09%0A%09%09console.log(%22TOUCH END%22);%0A
 %09%7D);%0A%09
+%09
 %0A%7D
-)
 ;%0A

Update swipe.js, added as jQuery plugin