// mobiletouch jquery plug ;(function($){ $.fn.extend({ mobiletouch:function(opt){ var defaults = { methods : [["down",1]], distance : 30, ispagescroll : false } opt = $.extend(defaults,opt); if(!opt.ispagescroll){ $(this)[0].ontouchmove = function(){event.preventdefault();} } var fingerstartx,fingerstarty,fingermovex,fingermovey; function end(event){ var x = fingermovex?fingermovex-fingerstartx:0; var y = fingermovey?fingermovey-fingerstarty:0; for(var p in opt.methods){ switch(opt.methods[p][0].touppercase()){ case "up": if(y<-opt.distance&&opt.upcallback&&opt.methods[p][1]==fingernum) opt.upcallback(); break; case "down": if(y>opt.distance&&opt.downcallback&&opt.methods[p][1]==fingernum) opt.downcallback(); break; case "left": if(x<-opt.distance&&opt.leftcallback&&opt.methods[p][1]==fingernum) opt.leftcallback(); break; case "right": if(x>opt.distance&&opt.rightcallback&&opt.methods[p][1]==fingernum) opt.rightcallback(); break; } } fingermovex = null; fingermovey = null; } var fingernum; function start(event){ fingernum = event.touches.length; fingerstartx = event.targettouches[0].clientx; fingerstarty = event.targettouches[0].clienty; } function move(event){ fingermovex = event.targettouches[0].clientx; fingermovey = event.targettouches[0].clienty; } $(this)[0].addeventlistener("touchend", end, false); $(this)[0].addeventlistener("touchstart", start, false); $(this)[0].addeventlistener("touchmove", move, false); return this; } }); })(jquery); /* $(function(){ if(client.system.iphone||client.system.ipod||client.system.ipad||client.system.android){ $("body").mobiletouch({ ispagescroll:true, methods:[ ["left",1], ["right",1] ], leftcallback:function(){ $("#nav li.current").prev().find(".a").trigger("click"); }, rightcallback:function(){ $("#nav li.current").next().find(".a").trigger("click"); } }); } }) */