/*! touchjs.min v0.2.14 2014-08-05 */ "use strict";!function(a,b){"function"==typeof define&&(define.amd||define.cmd)?define(b):a.touch=b()}(this,function(){function a(){var a="mouseup mousedown mousemove mouseout",c="touchstart touchmove touchend touchcancel",d=b.hastouch?c:a;d.split(" ").foreach(function(a){document.addeventlistener(a,a,!1)})}var b={};b.pcevts={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",touchcancel:"mouseout"},b.hastouch="ontouchstart"in window,b.gettype=function(a){return object.prototype.tostring.call(a).match(/\s([a-z|a-z]+)/)[1].tolowercase()},b.getselector=function(a){if(a.id)return"#"+a.id;if(a.classname){var b=a.classname.split(/\s+/);return"."+b.join(".")}return a===document?"body":a.tagname.tolowercase()},b.matchselector=function(a,b){return a.webkitmatchesselector(b)},b.geteventlisteners=function(a){return a.listeners},b.getpcevts=function(a){return this.pcevts[a]||a},b.forcereflow=function(){var a="reflowdivblock",b=document.getelementbyid(a);b||(b=document.createelement("div"),b.id=a,document.body.appendchild(b));var c=b.parentnode,d=b.nextsibling;c.removechild(b),c.insertbefore(b,d)},b.simpleclone=function(a){return object.create(a)},b.getposofevent=function(a){if(this.hastouch){for(var b=[],c=null,d=0,e=a.touches.length;e>d;d++)c=a.touches[d],b.push({x:c.pagex,y:c.pagey});return b}return[{x:a.pagex,y:a.pagey}]},b.getdistance=function(a,b){var c=b.x-a.x,d=b.y-a.y;return math.sqrt(c*c+d*d)},b.getfingers=function(a){return a.touches?a.touches.length:1},b.calscale=function(a,b){if(a.length>=2&&b.length>=2){var c=this.getdistance(a[1],a[0]),d=this.getdistance(b[1],b[0]);return d/c}return 1},b.getangle=function(a,b){return 180*math.atan2(b.y-a.y,b.x-a.x)/math.pi},b.getangle180=function(a,b){var c=math.atan(-1*(b.y-a.y)/(b.x-a.x))*(180/math.pi);return 0>c?c+180:c},b.getdirectionfromangle=function(a){var b={up:-45>a&&a>-135,down:a>=45&&135>a,left:a>=135||-135>=a,right:a>=-45&&45>=a};for(var c in b)if(b[c])return c;return null},b.getxybyelement=function(a){for(var b=0,c=0;a.offsetparent;)b+=a.offsetleft,c+=a.offsettop,a=a.offsetparent;return{left:b,top:c}},b.reset=function(){h=i=j=null,q=o=k=l=!1,m=!1,f={},t=!1},b.istouchmove=function(a){return"touchmove"===a.type||"mousemove"===a.type},b.istouchend=function(a){return"touchend"===a.type||"mouseup"===a.type||"touchcancel"===a.type},b.env=function(){var a={},b=navigator.useragent,c=b.match(/(android)[\s\/]+([\d\.]+)/),d=b.match(/(ipad|iphone|ipod)\s+os\s([\d_\.]+)/),e=b.match(/(windows\s+phone)\s([\d\.]+)/),f=/webkit\/[\d.]+/i.test(b),g=d?navigator.standalone?f:/safari/i.test(b)&&!/crios/i.test(b)&&!/mqqbrowser/i.test(b):!1;return c&&(a.android=!0,a.version=c[2]),d&&(a.ios=!0,a.version=d[2].replace(/_/g,"."),a.ios7=/^7/.test(a.version),"ipad"===d[1]?a.ipad=!0:"iphone"===d[1]?(a.iphone=!0,a.iphone5=568==screen.height):"ipod"===d[1]&&(a.ipod=!0)),e&&(a.wp=!0,a.version=e[2],a.wp8=/^8/.test(a.version)),f&&(a.webkit=!0),g&&(a.safari=!0),a}();var c={proxyid:0,proxies:[],trigger:function(a,b,c){c=c||{};var d,e={bubbles:!0,cancelable:!0,detail:c};try{"undefined"!=typeof customevent?(d=new customevent(b,e),a&&a.dispatchevent(d)):(d=document.createevent("customevent"),d.initcustomevent(b,!0,!0,c),a&&a.dispatchevent(d))}catch(f){console.warn("touch.js is not supported by environment.")}},bind:function(a,c,d){a.listeners=a.listeners||{},a.listeners[c]?a.listeners[c].push(d):a.listeners[c]=[d];var e=function(a){b.env.ios7&&b.forcereflow(),a.originevent=a;for(var c in a.detail)"type"!==c&&(a[c]=a.detail[c]);a.startrotate=function(){t=!0};var e=d.call(a.target,a);"undefined"==typeof e||e||(a.stoppropagation(),a.preventdefault())};d.proxy=d.proxy||{},d.proxy[c]?d.proxy[c].push(this.proxyid++):d.proxy[c]=[this.proxyid++],this.proxies.push(e),a.addeventlistener&&a.addeventlistener(c,e,!1)},unbind:function(a,b,c){if(c){var d=c.proxy[b];d&&d.length&&d.foreach(function(){a.removeeventlistener&&a.removeeventlistener(b,this.proxies[this.proxyid],!1)})}else{var e=a.listeners[b];e&&e.length&&e.foreach(function(c){a.removeeventlistener(b,c,!1)})}},delegate:function(a,c,d,e){var f=function(c){var f,g;c.originevent=c;for(var h in c.detail)"type"!==h&&(c[h]=c.detail[h]);c.startrotate=function(){t=!0};var i=b.getselector(a)+" "+d,j=b.matchselector(c.target,i),k=b.matchselector(c.target,i+" "+c.target.nodename);if(!j&&k){for(b.env.ios7&&b.forcereflow(),f=c.target;!b.matchselector(f,i);)f=f.parentnode;g=e.call(c.target,c),"undefined"==typeof g||g||(c.stoppropagation(),c.preventdefault())}else b.env.ios7&&b.forcereflow(),(j||k)&&(g=e.call(c.target,c),"undefined"==typeof g||g||(c.stoppropagation(),c.preventdefault()))};e.proxy=e.proxy||{},e.proxy[c]?e.proxy[c].push(this.proxyid++):e.proxy[c]=[this.proxyid++],this.proxies.push(f),a.listeners=a.listeners||{},a.listeners[c]?a.listeners[c].push(f):a.listeners[c]=[f],a.addeventlistener&&a.addeventlistener(c,f,!1)},undelegate:function(a,b,c,d){if(d){var e=d.proxy[b];e.length&&e.foreach(function(){a.removeeventlistener&&a.removeeventlistener(b,this.proxies[this.proxyid],!1)})}else{var f=a.listeners[b];f.foreach(function(c){a.removeeventlistener(b,c,!1)})}}},d={tap:!0,doubletap:!0,tapmaxdistance:10,hold:!0,taptime:200,holdtime:650,maxdoubletapinterval:300,swipe:!0,swipetime:300,swipemindistance:18,swipefactor:5,drag:!0,pinch:!0,minscalerate:0,minrotationangle:0},e={touch_start:"touchstart",touch_move:"touchmove",touch_end:"touchend",touch_cancel:"touchcancel",mouse_down:"mousedown",mouse_move:"mousemove",mouse_up:"mouseup",click:"click",pinch_start:"pinchstart",pinch_end:"pinchend",pinch:"pinch",pinch_in:"pinchin",pinch_out:"pinchout",rotation_left:"rotateleft",rotation_right:"rotateright",rotation:"rotate",swipe_start:"swipestart",swiping:"swiping",swipe_end:"swipeend",swipe_left:"swipeleft",swipe_right:"swiperight",swipe_up:"swipeup",swipe_down:"swipedown",swipe:"swipe",drag:"drag",dragstart:"dragstart",dragend:"dragend",hold:"hold",tap:"tap",double_tap:"doubletap"},f={start:null,move:null,end:null},g=0,h=null,i=null,j=null,k=!1,l=!1,m=!1,n={},o=!1,p=null,q=!1,r=null,s=1,t=!1,u=[],v=0,w=0,x=0,y=null,z={getanglediff:function(a){for(var c=parseint(v-b.getangle180(a[0],a[1]),10),d=0;math.abs(c-w)>90&&d++<50;)0>w?c-=180:c+=180;return w=parseint(c,10)},pinch:function(a){var g=a.target;if(d.pinch){if(!o)return;if(b.getfingers(a)<2&&!b.istouchend(a))return;var h=b.calscale(f.start,f.move),i=this.getanglediff(f.move),j={type:"",originevent:a,scale:h,rotation:i,direction:i>0?"right":"left",fingerscount:b.getfingers(a)};if(l?b.istouchmove(a)?(j.fingerstatus="move",c.trigger(g,e.pinch,j)):b.istouchend(a)&&(j.fingerstatus="end",c.trigger(g,e.pinch_end,j),b.reset()):(l=!0,j.fingerstatus="start",c.trigger(g,e.pinch_start,j)),math.abs(1-h)>d.minscalerate){var k=b.simpleclone(j),m=1e-11;h>s?(s=h-m,c.trigger(g,e.pinch_out,k,!1)):s>h&&(s=h+m,c.trigger(g,e.pinch_in,k,!1)),b.istouchend(a)&&(s=1)}if(math.abs(i)>d.minrotationangle){var n,p=b.simpleclone(j);n=i>0?e.rotation_right:e.rotation_left,c.trigger(g,n,p,!1),c.trigger(g,e.rotation,j)}}},rotatesinglefinger:function(a){var d=a.target;if(t&&b.getfingers(a)<2){if(!f.move)return;if(u.length<2){var g=b.getxybyelement(d);u=[{x:g.left+d.offsetwidth/2,y:g.top+d.offsetheight/2},f.move[0]],v=parseint(b.getangle180(u[0],u[1]),10)}var h=[u[0],f.move[0]],i=this.getanglediff(h),j={type:"",originevent:a,rotation:i,direction:i>0?"right":"left",fingerscount:b.getfingers(a)};b.istouchmove(a)?j.fingerstatus="move":(b.istouchend(a)||"mouseout"===a.type)&&(j.fingerstatus="end",c.trigger(d,e.pinch_end,j),b.reset());var k=i>0?e.rotation_right:e.rotation_left;c.trigger(d,k,j),c.trigger(d,e.rotation,j)}},swipe:function(a){var h=a.target;if(o&&f.move&&!(b.getfingers(a)>1)){var i=date.now(),j=i-g,l=b.getdistance(f.start[0],f.move[0]),p={x:f.move[0].x-n.left,y:f.move[0].y-n.top},q=b.getangle(f.start[0],f.move[0]),r=b.getdirectionfromangle(q),s=j/1e3,t=10*(10-d.swipefactor)*s*s,u={type:e.swipe,originevent:a,position:p,direction:r,distance:l,distancex:f.move[0].x-f.start[0].x,distancey:f.move[0].y-f.start[0].y,x:f.move[0].x-f.start[0].x,y:f.move[0].y-f.start[0].y,angle:q,duration:j,fingerscount:b.getfingers(a),factor:t};if(d.swipe){var v=function(){var a=e;switch(r){case"up":c.trigger(h,a.swipe_up,u);break;case"down":c.trigger(h,a.swipe_down,u);break;case"left":c.trigger(h,a.swipe_left,u);break;case"right":c.trigger(h,a.swipe_right,u)}};k?b.istouchmove(a)?(u.fingerstatus=u.swipe="move",c.trigger(h,e.swiping,u),j>d.swipetime&&jd.swipemindistance&&(v(),c.trigger(h,e.swipe,u,!1))):(b.istouchend(a)||"mouseout"===a.type)&&(u.fingerstatus=u.swipe="end",c.trigger(h,e.swipe_end,u),d.swipetime>j&&l>d.swipemindistance&&(v(),c.trigger(h,e.swipe,u,!1))):(u.fingerstatus=u.swipe="start",k=!0,c.trigger(h,e.swipe_start,u))}d.drag&&(m?b.istouchmove(a)?(u.fingerstatus=u.swipe="move",c.trigger(h,e.drag,u)):b.istouchend(a)&&(u.fingerstatus=u.swipe="end",c.trigger(h,e.dragend,u)):(u.fingerstatus=u.swipe="start",m=!0,c.trigger(h,e.dragstart,u)))}},tap:function(a){var h=a.target;if(d.tap){var i=date.now(),j=i-g,k=b.getdistance(f.start[0],f.move?f.move[0]:f.start[0]);cleartimeout(p);var l=function(){if(y&&d.doubletap&&g-xa)return!0}return!1}();if(l)return cleartimeout(r),void c.trigger(h,e.double_tap,{type:e.double_tap,originevent:a,position:f.start[0]});if(d.tapmaxdistancej&&b.getfingers(a)<=1&&(q=!0,x=i,y=f.start[0],r=settimeout(function(){c.trigger(h,e.tap,{type:e.tap,originevent:a,fingerscount:b.getfingers(a),position:y})},d.taptime))}},hold:function(a){var e=a.target;d.hold&&(cleartimeout(p),p=settimeout(function(){if(f.start){var g=b.getdistance(f.start[0],f.move?f.move[0]:f.start[0]);d.tapmaxdistance=2&&(v=parseint(b.getangle180(f.start[0],f.start[1]),10)),g=date.now(),h=a,n={};var d=c.getboundingclientrect(),e=document.documentelement;n={top:d.top+(window.pageyoffset||e.scrolltop)-(e.clienttop||0),left:d.left+(window.pagexoffset||e.scrollleft)-(e.clientleft||0)},z.hold(a);break;case"touchmove":case"mousemove":if(!o||!f.start)return;f.move=b.getposofevent(a),b.getfingers(a)>=2?z.pinch(a):t?z.rotatesinglefinger(a):z.swipe(a);break;case"touchend":case"touchcancel":case"mouseup":case"mouseout":if(!o)return;j=a,l?z.pinch(a):t?z.rotatesinglefinger(a):k?z.swipe(a):z.tap(a),b.reset(),v=0,w=0,a.touches&&1===a.touches.length&&(o=!0,t=!0)}},b=function(){function a(a){b.hastouch||(a=b.getpcevts(a)),j.foreach(function(b){c.delegate(b,a,h,g[a])})}function d(a){b.hastouch||(a=b.getpcevts(a)),j.foreach(function(b){c.bind(b,a,g[a])})}var e,f,g,h,i=arguments;if(i.length<2||i>4)return console.error("unexpected arguments!");var j="string"===b.gettype(i[0])?document.queryselectorall(i[0]):i[0];if(j=j.length?array.prototype.slice.call(j):[j],3===i.length&&"string"===b.gettype(i[1]))return e=i[1].split(" "),f=i[2],void e.foreach(function(a){b.hastouch||(a=b.getpcevts(a)),j.foreach(function(b){c.bind(b,a,f)})});if(3!==i.length||"object"!==b.gettype(i[1]))if(2!==i.length||"object"!==b.gettype(i[1])){if(4===i.length&&"object"===b.gettype(i[2]))return e=i[1].split(" "),f=i[3],void e.foreach(function(a){b.hastouch||(a=b.getpcevts(a)),j.foreach(function(b){c.bind(b,a,f)})});if(4===i.length){var k=j[0];return e=i[1].split(" "),h=i[2],f=i[3],void e.foreach(function(a){b.hastouch||(a=b.getpcevts(a)),c.delegate(k,a,h,f)})}}else{g=i[1];for(var l in g)d(l)}else{g=i[1],h=i[2];for(var m in g)a(m)}},c=function(){var a,d,e=arguments;if(e.length<1||e.length>4)return console.error("unexpected arguments!");var f="string"===b.gettype(e[0])?document.queryselectorall(e[0]):e[0];if(f=f.length?array.prototype.slice.call(f):[f],1===e.length||2===e.length)return void f.foreach(function(d){a=e[1]?e[1].split(" "):object.keys(d.listeners),a.length&&a.foreach(function(a){b.hastouch||(a=b.getpcevts(a)),c.unbind(d,a),c.undelegate(d,a)})});if(3===e.length&&"function"===b.gettype(e[2]))return d=e[2],void f.foreach(function(f){a=e[1].split(" "),a.foreach(function(a){b.hastouch||(a=b.getpcevts(a)),c.unbind(f,a,d)})});if(3===e.length&&"string"===b.gettype(e[2])){var g=e[2];return void f.foreach(function(d){a=e[1].split(" "),a.foreach(function(a){b.hastouch||(a=b.getpcevts(a)),c.undelegate(d,a,g)})})}return 4===e.length?(d=e[3],void f.foreach(function(f){a=e[1].split(" "),a.foreach(function(a){b.hastouch||(a=b.getpcevts(a)),c.undelegate(f,a,g,d)})})):void 0},d=function(a,d,e){var f=arguments;b.hastouch||(d=b.getpcevts(d));var g="string"===b.gettype(f[0])?document.queryselectorall(f[0]):f[0];g=g.length?array.prototype.call(g):[g],g.foreach(function(a){c.trigger(a,d,e)})};a();var e={};return e.on=e.bind=e.live=b,e.off=e.unbind=e.die=c,e.config=d,e.trigger=d,e});