(function( window, $, undefined ) { // http://www.netcu.de/jquery-touchwipe-iphone-ipad-library $.fn.touchwipe = function(settings) { var config = { min_move_x: 20, min_move_y: 20, wipeLeft: function() { }, wipeRight: function() { }, wipeUp: function() { }, wipeDown: function() { }, preventDefaultEvents: true }; if (settings) $.extend(config, settings); this.each(function() { var startX; var startY; var isMoving = false; function cancelTouch() { this.removeEventListener('touchmove', onTouchMove); startX = null; isMoving = false; } function onTouchMove(e) { if(config.preventDefaultEvents) { e.preventDefault(); } if(isMoving) { var x = e.touches[0].pageX; var y = e.touches[0].pageY; var dx = startX - x; var dy = startY - y; if(Math.abs(dx) >= config.min_move_x) { cancelTouch(); if(dx > 0) { config.wipeLeft(); } else { config.wipeRight(); } } else if(Math.abs(dy) >= config.min_move_y) { cancelTouch(); if(dy > 0) { config.wipeDown(); } else { config.wipeUp(); } } } } function onTouchStart(e) { if (e.touches.length == 1) { startX = e.touches[0].pageX; startY = e.touches[0].pageY; isMoving = true; this.addEventListener('touchmove', onTouchMove, false); } } if ('ontouchstart' in document.documentElement) { this.addEventListener('touchstart', onTouchStart, false); } }); return this; }; $.elastislide = function( options, element ) { this.$el = $( element ); this._init( options ); }; $.elastislide.defaults = { speed : 450, // animation speed easing : '', // animation easing effect imageW : 190, // the images width margin : 3, // image margin right border : 1, // image border minItems : 1, // the minimum number of items to show. // when we resize the window, this will make sure minItems are always shown // (unless of course minItems is higher than the total number of elements) current : 0, // index of the current item // when we resize the window, the carousel will make sure this item is visible onClick : function() { return false; } // click item callback }; $.elastislide.prototype = { _init : function( options ) { this.options = $.extend( true, {}, $.elastislide.defaults, options ); //